plotlink-ows 1.2.95 → 1.2.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/lib/cartoon-production-status.ts +77 -0
- package/app/lib/cuts.ts +135 -18
- package/app/lib/lettering-status.ts +64 -6
- package/app/web/components/CartoonNextAction.tsx +154 -36
- package/app/web/components/CartoonProductionStatus.tsx +142 -0
- package/app/web/components/CartoonPublishPage.tsx +34 -25
- package/app/web/components/CutListPanel.tsx +1239 -513
- package/app/web/components/CutOverlayPreview.tsx +306 -0
- package/app/web/components/EpisodesPage.tsx +24 -0
- package/app/web/components/FinishEpisodePanel.tsx +28 -104
- package/app/web/components/LetteringEditor.tsx +968 -437
- package/app/web/components/PreviewPanel.tsx +1457 -848
- package/app/web/components/StoriesPage.tsx +1022 -526
- package/app/web/components/StoryInfoPage.tsx +31 -14
- package/app/web/components/StoryProgressPanel.tsx +19 -23
- package/app/web/dist/assets/{export-cut-che5mMWc.js → export-cut-Cj-cOtan.js} +1 -1
- package/app/web/dist/assets/index-CCeEYE7p.css +32 -0
- package/app/web/dist/assets/index-CF7pE09m.js +141 -0
- package/app/web/dist/index.html +2 -2
- package/package.json +1 -1
- package/app/web/dist/assets/index-CcfChGEK.css +0 -32
- package/app/web/dist/assets/index-Dc2TQ3Ij.js +0 -143
|
@@ -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 Pu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vd={exports:{}},co={};/**
|
|
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 nb;function _C(){if(nb)return co;nb=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 co.Fragment=t,co.jsx=i,co.jsxs=i,co}var rb;function bC(){return rb||(rb=1,Vd.exports=_C()),Vd.exports}var d=bC(),Kd={exports:{}},nt={};/**
|
|
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 sb;function vC(){if(sb)return nt;sb=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"),f=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.iterator;function v(A){return A===null||typeof A!="object"?null:(A=b&&A[b]||A["@@iterator"],typeof A=="function"?A:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,B={};function E(A,Z,k){this.props=A,this.context=Z,this.refs=B,this.updater=k||S}E.prototype.isReactComponent={},E.prototype.setState=function(A,Z){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,Z,"setState")},E.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function z(){}z.prototype=E.prototype;function I(A,Z,k){this.props=A,this.context=Z,this.refs=B,this.updater=k||S}var R=I.prototype=new z;R.constructor=I,N(R,E.prototype),R.isPureReactComponent=!0;var H=Array.isArray;function D(){}var ie={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function ve(A,Z,k){var oe=k.ref;return{$$typeof:e,type:A,key:Z,ref:oe!==void 0?oe:null,props:k}}function L(A,Z){return ve(A.type,Z,A.props)}function re(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function F(A){var Z={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(k){return Z[k]})}var Y=/\/+/g;function K(A,Z){return typeof A=="object"&&A!==null&&A.key!=null?F(""+A.key):Z.toString(36)}function $(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(D,D):(A.status="pending",A.then(function(Z){A.status==="pending"&&(A.status="fulfilled",A.value=Z)},function(Z){A.status==="pending"&&(A.status="rejected",A.reason=Z)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function T(A,Z,k,oe,ae){var V=typeof A;(V==="undefined"||V==="boolean")&&(A=null);var X=!1;if(A===null)X=!0;else switch(V){case"bigint":case"string":case"number":X=!0;break;case"object":switch(A.$$typeof){case e:case t:X=!0;break;case _:return X=A._init,T(X(A._payload),Z,k,oe,ae)}}if(X)return ae=ae(A),X=oe===""?"."+K(A,0):oe,H(ae)?(k="",X!=null&&(k=X.replace(Y,"$&/")+"/"),T(ae,Z,k,"",function(Ae){return Ae})):ae!=null&&(re(ae)&&(ae=L(ae,k+(ae.key==null||A&&A.key===ae.key?"":(""+ae.key).replace(Y,"$&/")+"/")+X)),Z.push(ae)),1;X=0;var he=oe===""?".":oe+":";if(H(A))for(var _e=0;_e<A.length;_e++)oe=A[_e],V=he+K(oe,_e),X+=T(oe,Z,k,V,ae);else if(_e=v(A),typeof _e=="function")for(A=_e.call(A),_e=0;!(oe=A.next()).done;)oe=oe.value,V=he+K(oe,_e++),X+=T(oe,Z,k,V,ae);else if(V==="object"){if(typeof A.then=="function")return T($(A),Z,k,oe,ae);throw Z=String(A),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return X}function q(A,Z,k){if(A==null)return A;var oe=[],ae=0;return T(A,oe,"","",function(V){return Z.call(k,V,ae++)}),oe}function W(A){if(A._status===-1){var Z=A._result;Z=Z(),Z.then(function(k){(A._status===0||A._status===-1)&&(A._status=1,A._result=k)},function(k){(A._status===0||A._status===-1)&&(A._status=2,A._result=k)}),A._status===-1&&(A._status=0,A._result=Z)}if(A._status===1)return A._result.default;throw A._result}var ge=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},j={map:q,forEach:function(A,Z,k){q(A,function(){Z.apply(this,arguments)},k)},count:function(A){var Z=0;return q(A,function(){Z++}),Z},toArray:function(A){return q(A,function(Z){return Z})||[]},only:function(A){if(!re(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};return nt.Activity=g,nt.Children=j,nt.Component=E,nt.Fragment=i,nt.Profiler=a,nt.PureComponent=I,nt.StrictMode=s,nt.Suspense=p,nt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ie,nt.__COMPILER_RUNTIME={__proto__:null,c:function(A){return ie.H.useMemoCache(A)}},nt.cache=function(A){return function(){return A.apply(null,arguments)}},nt.cacheSignal=function(){return null},nt.cloneElement=function(A,Z,k){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var oe=N({},A.props),ae=A.key;if(Z!=null)for(V in Z.key!==void 0&&(ae=""+Z.key),Z)!ue.call(Z,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&Z.ref===void 0||(oe[V]=Z[V]);var V=arguments.length-2;if(V===1)oe.children=k;else if(1<V){for(var X=Array(V),he=0;he<V;he++)X[he]=arguments[he+2];oe.children=X}return ve(A.type,ae,oe)},nt.createContext=function(A){return A={$$typeof:c,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:o,_context:A},A},nt.createElement=function(A,Z,k){var oe,ae={},V=null;if(Z!=null)for(oe in Z.key!==void 0&&(V=""+Z.key),Z)ue.call(Z,oe)&&oe!=="key"&&oe!=="__self"&&oe!=="__source"&&(ae[oe]=Z[oe]);var X=arguments.length-2;if(X===1)ae.children=k;else if(1<X){for(var he=Array(X),_e=0;_e<X;_e++)he[_e]=arguments[_e+2];ae.children=he}if(A&&A.defaultProps)for(oe in X=A.defaultProps,X)ae[oe]===void 0&&(ae[oe]=X[oe]);return ve(A,V,ae)},nt.createRef=function(){return{current:null}},nt.forwardRef=function(A){return{$$typeof:h,render:A}},nt.isValidElement=re,nt.lazy=function(A){return{$$typeof:_,_payload:{_status:-1,_result:A},_init:W}},nt.memo=function(A,Z){return{$$typeof:f,type:A,compare:Z===void 0?null:Z}},nt.startTransition=function(A){var Z=ie.T,k={};ie.T=k;try{var oe=A(),ae=ie.S;ae!==null&&ae(k,oe),typeof oe=="object"&&oe!==null&&typeof oe.then=="function"&&oe.then(D,ge)}catch(V){ge(V)}finally{Z!==null&&k.types!==null&&(Z.types=k.types),ie.T=Z}},nt.unstable_useCacheRefresh=function(){return ie.H.useCacheRefresh()},nt.use=function(A){return ie.H.use(A)},nt.useActionState=function(A,Z,k){return ie.H.useActionState(A,Z,k)},nt.useCallback=function(A,Z){return ie.H.useCallback(A,Z)},nt.useContext=function(A){return ie.H.useContext(A)},nt.useDebugValue=function(){},nt.useDeferredValue=function(A,Z){return ie.H.useDeferredValue(A,Z)},nt.useEffect=function(A,Z){return ie.H.useEffect(A,Z)},nt.useEffectEvent=function(A){return ie.H.useEffectEvent(A)},nt.useId=function(){return ie.H.useId()},nt.useImperativeHandle=function(A,Z,k){return ie.H.useImperativeHandle(A,Z,k)},nt.useInsertionEffect=function(A,Z){return ie.H.useInsertionEffect(A,Z)},nt.useLayoutEffect=function(A,Z){return ie.H.useLayoutEffect(A,Z)},nt.useMemo=function(A,Z){return ie.H.useMemo(A,Z)},nt.useOptimistic=function(A,Z){return ie.H.useOptimistic(A,Z)},nt.useReducer=function(A,Z,k){return ie.H.useReducer(A,Z,k)},nt.useRef=function(A){return ie.H.useRef(A)},nt.useState=function(A){return ie.H.useState(A)},nt.useSyncExternalStore=function(A,Z,k){return ie.H.useSyncExternalStore(A,Z,k)},nt.useTransition=function(){return ie.H.useTransition()},nt.version="19.2.3",nt}var ab;function $p(){return ab||(ab=1,Kd.exports=vC()),Kd.exports}var w=$p();const yC=Pu(w);var Xd={exports:{}},uo={},Zd={exports:{}},Qd={};/**
|
|
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 lb;function SC(){return lb||(lb=1,(function(e){function t(T,q){var W=T.length;T.push(q);e:for(;0<W;){var ge=W-1>>>1,j=T[ge];if(0<a(j,q))T[ge]=q,T[W]=j,W=ge;else break e}}function i(T){return T.length===0?null:T[0]}function s(T){if(T.length===0)return null;var q=T[0],W=T.pop();if(W!==q){T[0]=W;e:for(var ge=0,j=T.length,A=j>>>1;ge<A;){var Z=2*(ge+1)-1,k=T[Z],oe=Z+1,ae=T[oe];if(0>a(k,W))oe<j&&0>a(ae,k)?(T[ge]=ae,T[oe]=W,ge=oe):(T[ge]=k,T[Z]=W,ge=Z);else if(oe<j&&0>a(ae,W))T[ge]=ae,T[oe]=W,ge=oe;else break e}}return q}function a(T,q){var W=T.sortIndex-q.sortIndex;return W!==0?W:T.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=[],f=[],_=1,g=null,b=3,v=!1,S=!1,N=!1,B=!1,E=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function R(T){for(var q=i(f);q!==null;){if(q.callback===null)s(f);else if(q.startTime<=T)s(f),q.sortIndex=q.expirationTime,t(p,q);else break;q=i(f)}}function H(T){if(N=!1,R(T),!S)if(i(p)!==null)S=!0,D||(D=!0,F());else{var q=i(f);q!==null&&$(H,q.startTime-T)}}var D=!1,ie=-1,ue=5,ve=-1;function L(){return B?!0:!(e.unstable_now()-ve<ue)}function re(){if(B=!1,D){var T=e.unstable_now();ve=T;var q=!0;try{e:{S=!1,N&&(N=!1,z(ie),ie=-1),v=!0;var W=b;try{t:{for(R(T),g=i(p);g!==null&&!(g.expirationTime>T&&L());){var ge=g.callback;if(typeof ge=="function"){g.callback=null,b=g.priorityLevel;var j=ge(g.expirationTime<=T);if(T=e.unstable_now(),typeof j=="function"){g.callback=j,R(T),q=!0;break t}g===i(p)&&s(p),R(T)}else s(p);g=i(p)}if(g!==null)q=!0;else{var A=i(f);A!==null&&$(H,A.startTime-T),q=!1}}break e}finally{g=null,b=W,v=!1}q=void 0}}finally{q?F():D=!1}}}var F;if(typeof I=="function")F=function(){I(re)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,K=Y.port2;Y.port1.onmessage=re,F=function(){K.postMessage(null)}}else F=function(){E(re,0)};function $(T,q){ie=E(function(){T(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(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ue=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(T){switch(b){case 1:case 2:case 3:var q=3;break;default:q=b}var W=b;b=q;try{return T()}finally{b=W}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(T,q){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var W=b;b=T;try{return q()}finally{b=W}},e.unstable_scheduleCallback=function(T,q,W){var ge=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?ge+W:ge):W=ge,T){case 1:var j=-1;break;case 2:j=250;break;case 5:j=1073741823;break;case 4:j=1e4;break;default:j=5e3}return j=W+j,T={id:_++,callback:q,priorityLevel:T,startTime:W,expirationTime:j,sortIndex:-1},W>ge?(T.sortIndex=W,t(f,T),i(p)===null&&T===i(f)&&(N?(z(ie),ie=-1):N=!0,$(H,W-ge))):(T.sortIndex=j,t(p,T),S||v||(S=!0,D||(D=!0,F()))),T},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(T){var q=b;return function(){var W=b;b=q;try{return T.apply(this,arguments)}finally{b=W}}}})(Qd)),Qd}var ob;function wC(){return ob||(ob=1,Zd.exports=SC()),Zd.exports}var Jd={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 cb;function CC(){if(cb)return un;cb=1;var e=$p();function t(p){var f="https://react.dev/errors/"+p;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)f+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+p+"; visit "+f+" 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,f,_){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:g==null?null:""+g,children:p,containerInfo:f,implementation:_}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,f){if(p==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return un.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,un.createPortal=function(p,f){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return o(p,f,null,_)},un.flushSync=function(p){var f=c.T,_=s.p;try{if(c.T=null,s.p=2,p)return p()}finally{c.T=f,s.p=_,s.d.f()}},un.preconnect=function(p,f){typeof p=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(p,f))},un.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},un.preinit=function(p,f){if(typeof p=="string"&&f&&typeof f.as=="string"){var _=f.as,g=h(_,f.crossOrigin),b=typeof f.integrity=="string"?f.integrity:void 0,v=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;_==="style"?s.d.S(p,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:g,integrity:b,fetchPriority:v}):_==="script"&&s.d.X(p,{crossOrigin:g,integrity:b,fetchPriority:v,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},un.preinitModule=function(p,f){if(typeof p=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var _=h(f.as,f.crossOrigin);s.d.M(p,{crossOrigin:_,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(p)},un.preload=function(p,f){if(typeof p=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var _=f.as,g=h(_,f.crossOrigin);s.d.L(p,_,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},un.preloadModule=function(p,f){if(typeof p=="string")if(f){var _=h(f.as,f.crossOrigin);s.d.m(p,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:_,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(p)},un.requestFormReset=function(p){s.d.r(p)},un.unstable_batchedUpdates=function(p,f){return p(f)},un.useFormState=function(p,f,_){return c.H.useFormState(p,f,_)},un.useFormStatus=function(){return c.H.useHostTransitionStatus()},un.version="19.2.3",un}var ub;function kC(){if(ub)return Jd.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(),Jd.exports=CC(),Jd.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 hb;function EC(){if(hb)return uo;hb=1;var e=wC(),t=$p(),i=kC();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 f(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 x=m.alternate;if(x===null){if(u=m.return,u!==null){l=u;continue}break}if(m.child===x.child){for(x=m.child;x;){if(x===l)return p(m),n;if(x===u)return p(m),r;x=x.sibling}throw Error(s(188))}if(l.return!==u.return)l=m,u=x;else{for(var y=!1,C=m.child;C;){if(C===l){y=!0,l=m,u=x;break}if(C===u){y=!0,u=m,l=x;break}C=C.sibling}if(!y){for(C=x.child;C;){if(C===l){y=!0,l=x,u=m;break}if(C===u){y=!0,u=x,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 _(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n;for(n=n.child;n!==null;){if(r=_(n),r!==null)return r;n=n.sibling}return null}var g=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),I=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function F(n){return n===null||typeof n!="object"?null:(n=re&&n[re]||n["@@iterator"],typeof n=="function"?n:null)}var Y=Symbol.for("react.client.reference");function K(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===Y?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case E:return"Profiler";case B:return"StrictMode";case H:return"Suspense";case D:return"SuspenseList";case ve:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case S:return"Portal";case I:return n.displayName||"Context";case z: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 ie:return r=n.displayName||null,r!==null?r:K(n.type)||"Memo";case ue:r=n._payload,n=n._init;try{return K(n(r))}catch{}}return null}var $=Array.isArray,T=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,W={pending:!1,data:null,method:null,action:null},ge=[],j=-1;function A(n){return{current:n}}function Z(n){0>j||(n.current=ge[j],ge[j]=null,j--)}function k(n,r){j++,ge[j]=n.current,n.current=r}var oe=A(null),ae=A(null),V=A(null),X=A(null);function he(n,r){switch(k(V,r),k(ae,n),k(oe,null),r.nodeType){case 9:case 11:n=(n=r.documentElement)&&(n=n.namespaceURI)?E_(n):0;break;default:if(n=r.tagName,r=r.namespaceURI)r=E_(r),n=N_(r,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Z(oe),k(oe,n)}function _e(){Z(oe),Z(ae),Z(V)}function Ae(n){n.memoizedState!==null&&k(X,n);var r=oe.current,l=N_(r,n.type);r!==l&&(k(ae,n),k(oe,l))}function Oe(n){ae.current===n&&(Z(oe),Z(ae)),X.current===n&&(Z(X),so._currentValue=W)}var He,Re;function et(n){if(He===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);He=r&&r[1]||"",Re=-1<l.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+He+n+Re}var Ge=!1;function ot(n,r){if(!n||Ge)return"";Ge=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(le){var te=le}Reflect.construct(n,[],fe)}else{try{fe.call()}catch(le){te=le}n.call(fe.prototype)}}else{try{throw Error()}catch(le){te=le}(fe=n())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(le){if(le&&te&&typeof le.stack=="string")return[le.stack,te.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 x=u.DetermineComponentFrameRoot(),y=x[0],C=x[1];if(y&&C){var O=y.split(`
|
|
44
|
+
`),J=C.split(`
|
|
45
|
+
`);for(m=u=0;u<O.length&&!O[u].includes("DetermineComponentFrameRoot");)u++;for(;m<J.length&&!J[m].includes("DetermineComponentFrameRoot");)m++;if(u===O.length||m===J.length)for(u=O.length-1,m=J.length-1;1<=u&&0<=m&&O[u]!==J[m];)m--;for(;1<=u&&0<=m;u--,m--)if(O[u]!==J[m]){if(u!==1||m!==1)do if(u--,m--,0>m||O[u]!==J[m]){var ce=`
|
|
46
|
+
`+O[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{Ge=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?et(l):""}function Pe(n,r){switch(n.tag){case 26:case 27:case 5:return et(n.type);case 16:return et("Lazy");case 13:return n.child!==r&&r!==null?et("Suspense Fallback"):et("Suspense");case 19:return et("SuspenseList");case 0:case 15:return ot(n.type,!1);case 11:return ot(n.type.render,!1);case 1:return ot(n.type,!0);case 31:return et("Activity");default:return""}}function Be(n){try{var r="",l=null;do r+=Pe(n,l),l=n,n=n.return;while(n);return r}catch(u){return`
|
|
47
|
+
Error generating stack: `+u.message+`
|
|
48
|
+
`+u.stack}}var Ve=Object.prototype.hasOwnProperty,Nt=e.unstable_scheduleCallback,kt=e.unstable_cancelCallback,pi=e.unstable_shouldYield,Me=e.unstable_requestPaint,St=e.unstable_now,ct=e.unstable_getCurrentPriorityLevel,ee=e.unstable_ImmediatePriority,xe=e.unstable_UserBlockingPriority,Te=e.unstable_NormalPriority,Ue=e.unstable_LowPriority,Ye=e.unstable_IdlePriority,Kt=e.log,mi=e.unstable_setDisableYieldValue,Lt=null,Et=null;function Gt(n){if(typeof Kt=="function"&&mi(n),Et&&typeof Et.setStrictMode=="function")try{Et.setStrictMode(Lt,n)}catch{}}var ut=Math.clz32?Math.clz32:Cn,$t=Math.log,wt=Math.LN2;function Cn(n){return n>>>=0,n===0?32:31-($t(n)/wt|0)|0}var Yt=256,ni=262144,U=4194304;function be(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 Ie(n,r,l){var u=n.pendingLanes;if(u===0)return 0;var m=0,x=n.suspendedLanes,y=n.pingedLanes;n=n.warmLanes;var C=u&134217727;return C!==0?(u=C&~x,u!==0?m=be(u):(y&=C,y!==0?m=be(y):l||(l=C&~n,l!==0&&(m=be(l))))):(C=u&~x,C!==0?m=be(C):y!==0?m=be(y):l||(l=u&~n,l!==0&&(m=be(l)))),m===0?0:r!==0&&r!==m&&(r&x)===0&&(x=m&-m,l=r&-r,x>=l||x===32&&(l&4194048)!==0)?r:m}function Ee(n,r){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&r)===0}function Qe(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 rt(){var n=U;return U<<=1,(U&62914560)===0&&(U=4194304),n}function tt(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function Dt(n,r){n.pendingLanes|=r,r!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function ft(n,r,l,u,m,x){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,O=n.expirationTimes,J=n.hiddenUpdates;for(l=y&~l;0<l;){var ce=31-ut(l),fe=1<<ce;C[ce]=0,O[ce]=-1;var te=J[ce];if(te!==null)for(J[ce]=null,ce=0;ce<te.length;ce++){var le=te[ce];le!==null&&(le.lane&=-536870913)}l&=~fe}u!==0&&pt(n,u,0),x!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=x&~(y&~r))}function pt(n,r,l){n.pendingLanes|=r,n.suspendedLanes&=~r;var u=31-ut(r);n.entangledLanes|=r,n.entanglements[u]=n.entanglements[u]|1073741824|l&261930}function Di(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-ut(l),m=1<<u;m&r|n[u]&r&&(n[u]|=r),l&=~m}}function gi(n,r){var l=r&-r;return l=(l&42)!==0?1:on(l),(l&(n.suspendedLanes|r))!==0?0:l}function on(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 Ui(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Mi(){var n=q.p;return n!==0?n:(n=window.event,n===void 0?32:X_(n.type))}function Xn(n,r){var l=q.p;try{return q.p=n,r()}finally{q.p=l}}var xi=Math.random().toString(36).slice(2),Xt="__reactFiber$"+xi,At="__reactProps$"+xi,ri="__reactContainer$"+xi,M="__reactEvents$"+xi,ne="__reactListeners$"+xi,me="__reactHandles$"+xi,De="__reactResources$"+xi,Se="__reactMarker$"+xi;function Ne(n){delete n[Xt],delete n[At],delete n[M],delete n[ne],delete n[me]}function We(n){var r=n[Xt];if(r)return r;for(var l=n.parentNode;l;){if(r=l[ri]||l[Xt]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=B_(n);n!==null;){if(l=n[Xt])return l;n=B_(n)}return r}n=l,l=n.parentNode}return null}function Ke(n){if(n=n[Xt]||n[ri]){var r=n.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return n}return null}function vt(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n.stateNode;throw Error(s(33))}function it(n){var r=n[De];return r||(r=n[De]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Ze(n){n[Se]=!0}var Ot=new Set,yi={};function mn(n,r){Bi(n,r),Bi(n+"Capture",r)}function Bi(n,r){for(yi[n]=r,n=0;n<r.length;n++)Ot.add(r[n])}var si=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]*$"),cn={},On={};function Lr(n){return Ve.call(On,n)?!0:Ve.call(cn,n)?!1:si.test(n)?On[n]=!0:(cn[n]=!0,!1)}function vr(n,r,l){if(Lr(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 Ft(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 Si(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Or(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function zr(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,x=u.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(y){l=""+y,x.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=Or(n)?"checked":"value";n._valueTracker=zr(n,r,""+n[r])}}function Zn(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return n&&(u=Or(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function Pr(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 Ws=/[\n"\\]/g;function Ji(n){return n.replace(Ws,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ir(n,r,l,u,m,x,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=""+Si(r)):n.value!==""+Si(r)&&(n.value=""+Si(r)):y!=="submit"&&y!=="reset"||n.removeAttribute("value"),r!=null?dr(n,y,Si(r)):l!=null?dr(n,y,Si(l)):u!=null&&n.removeAttribute("value"),m==null&&x!=null&&(n.defaultChecked=!!x),m!=null&&(n.checked=m&&typeof m!="function"&&typeof m!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?n.name=""+Si(C):n.removeAttribute("name")}function wi(n,r,l,u,m,x,y,C){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(n.type=x),r!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||r!=null)){Zt(n);return}l=l!=null?""+Si(l):"",r=r!=null?""+Si(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 dr(n,r,l){r==="number"&&Pr(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function Ci(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=""+Si(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 zn(n,r,l){if(r!=null&&(r=""+Si(r),r!==n.value&&(n.value=r),l==null)){n.defaultValue!==r&&(n.defaultValue=r);return}n.defaultValue=l!=null?""+Si(l):""}function us(n,r,l,u){if(r==null){if(u!=null){if(l!=null)throw Error(s(92));if($(u)){if(1<u.length)throw Error(s(93));u=u[0]}l=u}l==null&&(l=""),r=l}l=Si(r),n.defaultValue=l,u=n.textContent,u===l&&u!==""&&u!==null&&(n.value=u),Zt(n)}function Pn(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var Zo=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 vl(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||Zo.has(r)?r==="float"?n.cssFloat=l:n[r]=(""+l).trim():n[r]=l+"px"}function Sa(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&&vl(n,m,u)}else for(var x in r)r.hasOwnProperty(x)&&vl(n,x,r[x])}function wa(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 Gs=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"]]),yl=/^[\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 Ys(n){return yl.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function gn(){}var Ca=null;function Sl(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var hs=null,Hr=null;function ka(n){var r=Ke(n);if(r&&(n=r.stateNode)){var l=n[At]||null;e:switch(n=r.stateNode,r.type){case"input":if(Ir(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="'+Ji(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==n&&u.form===n.form){var m=u[At]||null;if(!m)throw Error(s(90));Ir(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&&Zn(u)}break e;case"textarea":zn(n,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&Ci(n,!!l.multiple,r,!1)}}}var wl=!1;function Qo(n,r,l){if(wl)return n(r,l);wl=!0;try{var u=n(r);return u}finally{if(wl=!1,(hs!==null||Hr!==null)&&(Lc(),hs&&(r=hs,n=Hr,Hr=hs=null,ka(r),n)))for(r=0;r<n.length;r++)ka(n[r])}}function fr(n,r){var l=n.stateNode;if(l===null)return null;var u=l[At]||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 kn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cl=!1;if(kn)try{var yr={};Object.defineProperty(yr,"passive",{get:function(){Cl=!0}}),window.addEventListener("test",yr,yr),window.removeEventListener("test",yr,yr)}catch{Cl=!1}var pr=null,se=null,Ce=null;function ke(){if(Ce)return Ce;var n,r=se,l=r.length,u,m="value"in pr?pr.value:pr.textContent,x=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[x-u];u++);return Ce=m.slice(n,1<u?1-u:void 0)}function Je(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 zt(){return!0}function Li(){return!1}function oi(n){function r(l,u,m,x,y){this._reactName=l,this._targetInst=m,this.type=u,this.nativeEvent=x,this.target=y,this.currentTarget=null;for(var C in n)n.hasOwnProperty(C)&&(l=n[C],this[C]=l?l(x):x[C]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?zt:Li,this.isPropagationStopped=Li,this}return g(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=zt)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=zt)},persist:function(){},isPersistent:zt}),r}var En={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qn=oi(En),ds=g({},En,{view:0,detail:0}),g1=oi(ds),Xu,Zu,kl,Jo=g({},ds,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ju,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!==kl&&(kl&&n.type==="mousemove"?(Xu=n.screenX-kl.screenX,Zu=n.screenY-kl.screenY):Zu=Xu=0,kl=n),Xu)},movementY:function(n){return"movementY"in n?n.movementY:Zu}}),Tm=oi(Jo),x1=g({},Jo,{dataTransfer:0}),_1=oi(x1),b1=g({},ds,{relatedTarget:0}),Qu=oi(b1),v1=g({},En,{animationName:0,elapsedTime:0,pseudoElement:0}),y1=oi(v1),S1=g({},En,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),w1=oi(S1),C1=g({},En,{data:0}),Am=oi(C1),k1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},E1={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"},N1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function j1(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=N1[n])?!!r[n]:!1}function Ju(){return j1}var T1=g({},ds,{key:function(n){if(n.key){var r=k1[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Je(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?E1[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ju,charCode:function(n){return n.type==="keypress"?Je(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Je(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),A1=oi(T1),R1=g({},Jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Rm=oi(R1),D1=g({},ds,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ju}),M1=oi(D1),B1=g({},En,{propertyName:0,elapsedTime:0,pseudoElement:0}),L1=oi(B1),O1=g({},Jo,{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}),z1=oi(O1),P1=g({},En,{newState:0,oldState:0}),I1=oi(P1),H1=[9,13,27,32],eh=kn&&"CompositionEvent"in window,El=null;kn&&"documentMode"in document&&(El=document.documentMode);var U1=kn&&"TextEvent"in window&&!El,Dm=kn&&(!eh||El&&8<El&&11>=El),Mm=" ",Bm=!1;function Lm(n,r){switch(n){case"keyup":return H1.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Om(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Ea=!1;function $1(n,r){switch(n){case"compositionend":return Om(r);case"keypress":return r.which!==32?null:(Bm=!0,Mm);case"textInput":return n=r.data,n===Mm&&Bm?null:n;default:return null}}function F1(n,r){if(Ea)return n==="compositionend"||!eh&&Lm(n,r)?(n=ke(),Ce=se=pr=null,Ea=!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 Dm&&r.locale!=="ko"?null:r.data;default:return null}}var q1={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 zm(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!q1[n.type]:r==="textarea"}function Pm(n,r,l,u){hs?Hr?Hr.push(u):Hr=[u]:hs=u,r=$c(r,"onChange"),0<r.length&&(l=new Qn("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var Nl=null,jl=null;function W1(n){v_(n,0)}function ec(n){var r=vt(n);if(Zn(r))return n}function Im(n,r){if(n==="change")return r}var Hm=!1;if(kn){var th;if(kn){var ih="oninput"in document;if(!ih){var Um=document.createElement("div");Um.setAttribute("oninput","return;"),ih=typeof Um.oninput=="function"}th=ih}else th=!1;Hm=th&&(!document.documentMode||9<document.documentMode)}function $m(){Nl&&(Nl.detachEvent("onpropertychange",Fm),jl=Nl=null)}function Fm(n){if(n.propertyName==="value"&&ec(jl)){var r=[];Pm(r,jl,n,Sl(n)),Qo(W1,r)}}function G1(n,r,l){n==="focusin"?($m(),Nl=r,jl=l,Nl.attachEvent("onpropertychange",Fm)):n==="focusout"&&$m()}function Y1(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return ec(jl)}function V1(n,r){if(n==="click")return ec(r)}function K1(n,r){if(n==="input"||n==="change")return ec(r)}function X1(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var In=typeof Object.is=="function"?Object.is:X1;function Tl(n,r){if(In(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(!Ve.call(r,m)||!In(n[m],r[m]))return!1}return!0}function qm(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Wm(n,r){var l=qm(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=qm(l)}}function Gm(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Gm(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Ym(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var r=Pr(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=Pr(n.document)}return r}function nh(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 Z1=kn&&"documentMode"in document&&11>=document.documentMode,Na=null,rh=null,Al=null,sh=!1;function Vm(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;sh||Na==null||Na!==Pr(u)||(u=Na,"selectionStart"in u&&nh(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}),Al&&Tl(Al,u)||(Al=u,u=$c(rh,"onSelect"),0<u.length&&(r=new Qn("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=Na)))}function Vs(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var ja={animationend:Vs("Animation","AnimationEnd"),animationiteration:Vs("Animation","AnimationIteration"),animationstart:Vs("Animation","AnimationStart"),transitionrun:Vs("Transition","TransitionRun"),transitionstart:Vs("Transition","TransitionStart"),transitioncancel:Vs("Transition","TransitionCancel"),transitionend:Vs("Transition","TransitionEnd")},ah={},Km={};kn&&(Km=document.createElement("div").style,"AnimationEvent"in window||(delete ja.animationend.animation,delete ja.animationiteration.animation,delete ja.animationstart.animation),"TransitionEvent"in window||delete ja.transitionend.transition);function Ks(n){if(ah[n])return ah[n];if(!ja[n])return n;var r=ja[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in Km)return ah[n]=r[l];return n}var Xm=Ks("animationend"),Zm=Ks("animationiteration"),Qm=Ks("animationstart"),Q1=Ks("transitionrun"),J1=Ks("transitionstart"),ew=Ks("transitioncancel"),Jm=Ks("transitionend"),eg=new Map,lh="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(" ");lh.push("scrollEnd");function mr(n,r){eg.set(n,r),mn(r,[n])}var tc=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,oh=0;function ic(){for(var n=Ta,r=oh=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 x=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}x!==0&&tg(l,m,x)}}function nc(n,r,l,u){Jn[Ta++]=n,Jn[Ta++]=r,Jn[Ta++]=l,Jn[Ta++]=u,oh|=u,n.lanes|=u,n=n.alternate,n!==null&&(n.lanes|=u)}function ch(n,r,l,u){return nc(n,r,l,u),rc(n)}function Xs(n,r){return nc(n,null,null,r),rc(n)}function tg(n,r,l){n.lanes|=l;var u=n.alternate;u!==null&&(u.lanes|=l);for(var m=!1,x=n.return;x!==null;)x.childLanes|=l,u=x.alternate,u!==null&&(u.childLanes|=l),x.tag===22&&(n=x.stateNode,n===null||n._visibility&1||(m=!0)),n=x,x=x.return;return n.tag===3?(x=n.stateNode,m&&r!==null&&(m=31-ut(l),n=x.hiddenUpdates,u=n[m],u===null?n[m]=[r]:u.push(r),r.lane=l|536870912),x):null}function rc(n){if(50<Ql)throw Ql=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 Aa={};function tw(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 Hn(n,r,l,u){return new tw(n,r,l,u)}function uh(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Ur(n,r){var l=n.alternate;return l===null?(l=Hn(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 ig(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 sc(n,r,l,u,m,x){var y=0;if(u=n,typeof n=="function")uh(n)&&(y=1);else if(typeof n=="string")y=aC(n,l,oe.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case ve:return n=Hn(31,l,r,m),n.elementType=ve,n.lanes=x,n;case N:return Zs(l.children,m,x,r);case B:y=8,m|=24;break;case E:return n=Hn(12,l,r,m|2),n.elementType=E,n.lanes=x,n;case H:return n=Hn(13,l,r,m),n.elementType=H,n.lanes=x,n;case D:return n=Hn(19,l,r,m),n.elementType=D,n.lanes=x,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case I:y=10;break e;case z:y=9;break e;case R:y=11;break e;case ie:y=14;break e;case ue:y=16,u=null;break e}y=29,l=Error(s(130,n===null?"null":typeof n,"")),u=null}return r=Hn(y,l,r,m),r.elementType=n,r.type=u,r.lanes=x,r}function Zs(n,r,l,u){return n=Hn(7,n,u,r),n.lanes=l,n}function hh(n,r,l){return n=Hn(6,n,null,r),n.lanes=l,n}function ng(n){var r=Hn(18,null,null,0);return r.stateNode=n,r}function dh(n,r,l){return r=Hn(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}var rg=new WeakMap;function er(n,r){if(typeof n=="object"&&n!==null){var l=rg.get(n);return l!==void 0?l:(r={value:n,source:r,stack:Be(r)},rg.set(n,r),r)}return{value:n,source:r,stack:Be(r)}}var Ra=[],Da=0,ac=null,Rl=0,tr=[],ir=0,fs=null,Sr=1,wr="";function $r(n,r){Ra[Da++]=Rl,Ra[Da++]=ac,ac=n,Rl=r}function sg(n,r,l){tr[ir++]=Sr,tr[ir++]=wr,tr[ir++]=fs,fs=n;var u=Sr;n=wr;var m=32-ut(u)-1;u&=~(1<<m),l+=1;var x=32-ut(r)+m;if(30<x){var y=m-m%5;x=(u&(1<<y)-1).toString(32),u>>=y,m-=y,Sr=1<<32-ut(r)+m|l<<m|u,wr=x+n}else Sr=1<<x|l<<m|u,wr=n}function fh(n){n.return!==null&&($r(n,1),sg(n,1,0))}function ph(n){for(;n===ac;)ac=Ra[--Da],Ra[Da]=null,Rl=Ra[--Da],Ra[Da]=null;for(;n===fs;)fs=tr[--ir],tr[ir]=null,wr=tr[--ir],tr[ir]=null,Sr=tr[--ir],tr[ir]=null}function ag(n,r){tr[ir++]=Sr,tr[ir++]=wr,tr[ir++]=fs,Sr=r.id,wr=r.overflow,fs=n}var en=null,Qt=null,yt=!1,ps=null,nr=!1,mh=Error(s(519));function ms(n){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Dl(er(r,n)),mh}function lg(n){var r=n.stateNode,l=n.type,u=n.memoizedProps;switch(r[Xt]=n,r[At]=u,l){case"dialog":gt("cancel",r),gt("close",r);break;case"iframe":case"object":case"embed":gt("load",r);break;case"video":case"audio":for(l=0;l<eo.length;l++)gt(eo[l],r);break;case"source":gt("error",r);break;case"img":case"image":case"link":gt("error",r),gt("load",r);break;case"details":gt("toggle",r);break;case"input":gt("invalid",r),wi(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":gt("invalid",r);break;case"textarea":gt("invalid",r),us(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||C_(r.textContent,l)?(u.popover!=null&&(gt("beforetoggle",r),gt("toggle",r)),u.onScroll!=null&>("scroll",r),u.onScrollEnd!=null&>("scrollend",r),u.onClick!=null&&(r.onclick=gn),r=!0):r=!1,r||ms(n,!0)}function og(n){for(en=n.return;en;)switch(en.tag){case 5:case 31:case 13:nr=!1;return;case 27:case 3:nr=!0;return;default:en=en.return}}function Ma(n){if(n!==en)return!1;if(!yt)return og(n),yt=!0,!1;var r=n.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||Md(n.type,n.memoizedProps)),l=!l),l&&Qt&&ms(n),og(n),r===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Qt=M_(n)}else if(r===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Qt=M_(n)}else r===27?(r=Qt,Ts(n.type)?(n=Pd,Pd=null,Qt=n):Qt=r):Qt=en?sr(n.stateNode.nextSibling):null;return!0}function Qs(){Qt=en=null,yt=!1}function gh(){var n=ps;return n!==null&&(An===null?An=n:An.push.apply(An,n),ps=null),n}function Dl(n){ps===null?ps=[n]:ps.push(n)}var xh=A(null),Js=null,Fr=null;function gs(n,r,l){k(xh,r._currentValue),r._currentValue=l}function qr(n){n._currentValue=xh.current,Z(xh)}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 bh(n,r,l,u){var m=n.child;for(m!==null&&(m.return=n);m!==null;){var x=m.dependencies;if(x!==null){var y=m.child;x=x.firstContext;e:for(;x!==null;){var C=x;x=m;for(var O=0;O<r.length;O++)if(C.context===r[O]){x.lanes|=l,C=x.alternate,C!==null&&(C.lanes|=l),_h(x.return,l,n),u||(y=null);break e}x=C.next}}else if(m.tag===18){if(y=m.return,y===null)throw Error(s(341));y.lanes|=l,x=y.alternate,x!==null&&(x.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 Ba(n,r,l,u){n=null;for(var m=r,x=!1;m!==null;){if(!x){if((m.flags&524288)!==0)x=!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;In(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(so):n=[so])}m=m.return}n!==null&&bh(r,n,l,u),r.flags|=262144}function lc(n){for(n=n.firstContext;n!==null;){if(!In(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function ea(n){Js=n,Fr=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function tn(n){return cg(Js,n)}function oc(n,r){return Js===null&&ea(n),cg(n,r)}function cg(n,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},Fr===null){if(n===null)throw Error(s(308));Fr=r,n.dependencies={lanes:0,firstContext:r},n.flags|=524288}else Fr=Fr.next=r;return l}var iw=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()})}},nw=e.unstable_scheduleCallback,rw=e.unstable_NormalPriority,ki={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vh(){return{controller:new iw,data:new Map,refCount:0}}function Ml(n){n.refCount--,n.refCount===0&&nw(rw,function(){n.controller.abort()})}var Bl=null,yh=0,La=0,Oa=null;function sw(n,r){if(Bl===null){var l=Bl=[];yh=0,La=Cd(),Oa={status:"pending",value:void 0,then:function(u){l.push(u)}}}return yh++,r.then(ug,ug),r}function ug(){if(--yh===0&&Bl!==null){Oa!==null&&(Oa.status="fulfilled");var n=Bl;Bl=null,La=0,Oa=null;for(var r=0;r<n.length;r++)(0,n[r])()}}function aw(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 hg=T.S;T.S=function(n,r){Vx=St(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&sw(n,r),hg!==null&&hg(n,r)};var ta=A(null);function Sh(){var n=ta.current;return n!==null?n:qt.pooledCache}function cc(n,r){r===null?k(ta,ta.current):k(ta,r.pool)}function dg(){var n=Sh();return n===null?null:{parent:ki._currentValue,pool:n}}var za=Error(s(460)),wh=Error(s(474)),uc=Error(s(542)),hc={then:function(){}};function fg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function pg(n,r,l){switch(l=n[l],l===void 0?n.push(r):l!==r&&(r.then(gn,gn),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,gg(n),n;default:if(typeof r.status=="string")r.then(gn,gn);else{if(n=qt,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,gg(n),n}throw na=r,za}}function ia(n){try{var r=n._init;return r(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(na=l,za):l}}var na=null;function mg(){if(na===null)throw Error(s(459));var n=na;return na=null,n}function gg(n){if(n===za||n===uc)throw Error(s(483))}var Pa=null,Ll=0;function dc(n){var r=Ll;return Ll+=1,Pa===null&&(Pa=[]),pg(Pa,n,r)}function Ol(n,r){r=r.props.ref,n.ref=r!==void 0?r:null}function fc(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 xg(n){function r(G,P){if(n){var Q=G.deletions;Q===null?(G.deletions=[P],G.flags|=16):Q.push(P)}}function l(G,P){if(!n)return null;for(;P!==null;)r(G,P),P=P.sibling;return null}function u(G){for(var P=new Map;G!==null;)G.key!==null?P.set(G.key,G):P.set(G.index,G),G=G.sibling;return P}function m(G,P){return G=Ur(G,P),G.index=0,G.sibling=null,G}function x(G,P,Q){return G.index=Q,n?(Q=G.alternate,Q!==null?(Q=Q.index,Q<P?(G.flags|=67108866,P):Q):(G.flags|=67108866,P)):(G.flags|=1048576,P)}function y(G){return n&&G.alternate===null&&(G.flags|=67108866),G}function C(G,P,Q,de){return P===null||P.tag!==6?(P=hh(Q,G.mode,de),P.return=G,P):(P=m(P,Q),P.return=G,P)}function O(G,P,Q,de){var $e=Q.type;return $e===N?ce(G,P,Q.props.children,de,Q.key):P!==null&&(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ue&&ia($e)===P.type)?(P=m(P,Q.props),Ol(P,Q),P.return=G,P):(P=sc(Q.type,Q.key,Q.props,null,G.mode,de),Ol(P,Q),P.return=G,P)}function J(G,P,Q,de){return P===null||P.tag!==4||P.stateNode.containerInfo!==Q.containerInfo||P.stateNode.implementation!==Q.implementation?(P=dh(Q,G.mode,de),P.return=G,P):(P=m(P,Q.children||[]),P.return=G,P)}function ce(G,P,Q,de,$e){return P===null||P.tag!==7?(P=Zs(Q,G.mode,de,$e),P.return=G,P):(P=m(P,Q),P.return=G,P)}function fe(G,P,Q){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=hh(""+P,G.mode,Q),P.return=G,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return Q=sc(P.type,P.key,P.props,null,G.mode,Q),Ol(Q,P),Q.return=G,Q;case S:return P=dh(P,G.mode,Q),P.return=G,P;case ue:return P=ia(P),fe(G,P,Q)}if($(P)||F(P))return P=Zs(P,G.mode,Q,null),P.return=G,P;if(typeof P.then=="function")return fe(G,dc(P),Q);if(P.$$typeof===I)return fe(G,oc(G,P),Q);fc(G,P)}return null}function te(G,P,Q,de){var $e=P!==null?P.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return $e!==null?null:C(G,P,""+Q,de);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case v:return Q.key===$e?O(G,P,Q,de):null;case S:return Q.key===$e?J(G,P,Q,de):null;case ue:return Q=ia(Q),te(G,P,Q,de)}if($(Q)||F(Q))return $e!==null?null:ce(G,P,Q,de,null);if(typeof Q.then=="function")return te(G,P,dc(Q),de);if(Q.$$typeof===I)return te(G,P,oc(G,Q),de);fc(G,Q)}return null}function le(G,P,Q,de,$e){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return G=G.get(Q)||null,C(P,G,""+de,$e);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case v:return G=G.get(de.key===null?Q:de.key)||null,O(P,G,de,$e);case S:return G=G.get(de.key===null?Q:de.key)||null,J(P,G,de,$e);case ue:return de=ia(de),le(G,P,Q,de,$e)}if($(de)||F(de))return G=G.get(Q)||null,ce(P,G,de,$e,null);if(typeof de.then=="function")return le(G,P,Q,dc(de),$e);if(de.$$typeof===I)return le(G,P,Q,oc(P,de),$e);fc(P,de)}return null}function Le(G,P,Q,de){for(var $e=null,jt=null,ze=P,at=P=0,bt=null;ze!==null&&at<Q.length;at++){ze.index>at?(bt=ze,ze=null):bt=ze.sibling;var Tt=te(G,ze,Q[at],de);if(Tt===null){ze===null&&(ze=bt);break}n&&ze&&Tt.alternate===null&&r(G,ze),P=x(Tt,P,at),jt===null?$e=Tt:jt.sibling=Tt,jt=Tt,ze=bt}if(at===Q.length)return l(G,ze),yt&&$r(G,at),$e;if(ze===null){for(;at<Q.length;at++)ze=fe(G,Q[at],de),ze!==null&&(P=x(ze,P,at),jt===null?$e=ze:jt.sibling=ze,jt=ze);return yt&&$r(G,at),$e}for(ze=u(ze);at<Q.length;at++)bt=le(ze,G,at,Q[at],de),bt!==null&&(n&&bt.alternate!==null&&ze.delete(bt.key===null?at:bt.key),P=x(bt,P,at),jt===null?$e=bt:jt.sibling=bt,jt=bt);return n&&ze.forEach(function(Bs){return r(G,Bs)}),yt&&$r(G,at),$e}function qe(G,P,Q,de){if(Q==null)throw Error(s(151));for(var $e=null,jt=null,ze=P,at=P=0,bt=null,Tt=Q.next();ze!==null&&!Tt.done;at++,Tt=Q.next()){ze.index>at?(bt=ze,ze=null):bt=ze.sibling;var Bs=te(G,ze,Tt.value,de);if(Bs===null){ze===null&&(ze=bt);break}n&&ze&&Bs.alternate===null&&r(G,ze),P=x(Bs,P,at),jt===null?$e=Bs:jt.sibling=Bs,jt=Bs,ze=bt}if(Tt.done)return l(G,ze),yt&&$r(G,at),$e;if(ze===null){for(;!Tt.done;at++,Tt=Q.next())Tt=fe(G,Tt.value,de),Tt!==null&&(P=x(Tt,P,at),jt===null?$e=Tt:jt.sibling=Tt,jt=Tt);return yt&&$r(G,at),$e}for(ze=u(ze);!Tt.done;at++,Tt=Q.next())Tt=le(ze,G,at,Tt.value,de),Tt!==null&&(n&&Tt.alternate!==null&&ze.delete(Tt.key===null?at:Tt.key),P=x(Tt,P,at),jt===null?$e=Tt:jt.sibling=Tt,jt=Tt);return n&&ze.forEach(function(xC){return r(G,xC)}),yt&&$r(G,at),$e}function Ht(G,P,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===N&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case v:e:{for(var $e=Q.key;P!==null;){if(P.key===$e){if($e=Q.type,$e===N){if(P.tag===7){l(G,P.sibling),de=m(P,Q.props.children),de.return=G,G=de;break e}}else if(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ue&&ia($e)===P.type){l(G,P.sibling),de=m(P,Q.props),Ol(de,Q),de.return=G,G=de;break e}l(G,P);break}else r(G,P);P=P.sibling}Q.type===N?(de=Zs(Q.props.children,G.mode,de,Q.key),de.return=G,G=de):(de=sc(Q.type,Q.key,Q.props,null,G.mode,de),Ol(de,Q),de.return=G,G=de)}return y(G);case S:e:{for($e=Q.key;P!==null;){if(P.key===$e)if(P.tag===4&&P.stateNode.containerInfo===Q.containerInfo&&P.stateNode.implementation===Q.implementation){l(G,P.sibling),de=m(P,Q.children||[]),de.return=G,G=de;break e}else{l(G,P);break}else r(G,P);P=P.sibling}de=dh(Q,G.mode,de),de.return=G,G=de}return y(G);case ue:return Q=ia(Q),Ht(G,P,Q,de)}if($(Q))return Le(G,P,Q,de);if(F(Q)){if($e=F(Q),typeof $e!="function")throw Error(s(150));return Q=$e.call(Q),qe(G,P,Q,de)}if(typeof Q.then=="function")return Ht(G,P,dc(Q),de);if(Q.$$typeof===I)return Ht(G,P,oc(G,Q),de);fc(G,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,P!==null&&P.tag===6?(l(G,P.sibling),de=m(P,Q),de.return=G,G=de):(l(G,P),de=hh(Q,G.mode,de),de.return=G,G=de),y(G)):l(G,P)}return function(G,P,Q,de){try{Ll=0;var $e=Ht(G,P,Q,de);return Pa=null,$e}catch(ze){if(ze===za||ze===uc)throw ze;var jt=Hn(29,ze,null,G.mode);return jt.lanes=de,jt.return=G,jt}finally{}}}var ra=xg(!0),_g=xg(!1),xs=!1;function Ch(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function kh(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 _s(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function bs(n,r,l){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Rt&2)!==0){var m=u.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),u.pending=r,r=rc(n),tg(n,null,l),r}return nc(n,u,r,l),rc(n)}function zl(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,Di(n,l)}}function Eh(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var m=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var y={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?m=x=y:x=x.next=y,l=l.next}while(l!==null);x===null?m=x=r:x=x.next=r}else m=x=r;l={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:x,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 Nh=!1;function Pl(){if(Nh){var n=Oa;if(n!==null)throw n}}function Il(n,r,l,u){Nh=!1;var m=n.updateQueue;xs=!1;var x=m.firstBaseUpdate,y=m.lastBaseUpdate,C=m.shared.pending;if(C!==null){m.shared.pending=null;var O=C,J=O.next;O.next=null,y===null?x=J:y.next=J,y=O;var ce=n.alternate;ce!==null&&(ce=ce.updateQueue,C=ce.lastBaseUpdate,C!==y&&(C===null?ce.firstBaseUpdate=J:C.next=J,ce.lastBaseUpdate=O))}if(x!==null){var fe=m.baseState;y=0,ce=J=O=null,C=x;do{var te=C.lane&-536870913,le=te!==C.lane;if(le?(_t&te)===te:(u&te)===te){te!==0&&te===La&&(Nh=!0),ce!==null&&(ce=ce.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Le=n,qe=C;te=r;var Ht=l;switch(qe.tag){case 1:if(Le=qe.payload,typeof Le=="function"){fe=Le.call(Ht,fe,te);break e}fe=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=qe.payload,te=typeof Le=="function"?Le.call(Ht,fe,te):Le,te==null)break e;fe=g({},fe,te);break e;case 2:xs=!0}}te=C.callback,te!==null&&(n.flags|=64,le&&(n.flags|=8192),le=m.callbacks,le===null?m.callbacks=[te]:le.push(te))}else le={lane:te,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ce===null?(J=ce=le,O=fe):ce=ce.next=le,y|=te;if(C=C.next,C===null){if(C=m.shared.pending,C===null)break;le=C,C=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);ce===null&&(O=fe),m.baseState=O,m.firstBaseUpdate=J,m.lastBaseUpdate=ce,x===null&&(m.shared.lanes=0),Cs|=y,n.lanes=y,n.memoizedState=fe}}function bg(n,r){if(typeof n!="function")throw Error(s(191,n));n.call(r)}function vg(n,r){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)bg(l[n],r)}var Ia=A(null),pc=A(0);function yg(n,r){n=Jr,k(pc,n),k(Ia,r),Jr=n|r.baseLanes}function jh(){k(pc,Jr),k(Ia,Ia.current)}function Th(){Jr=pc.current,Z(Ia),Z(pc)}var Un=A(null),rr=null;function vs(n){var r=n.alternate;k(_i,_i.current&1),k(Un,n),rr===null&&(r===null||Ia.current!==null||r.memoizedState!==null)&&(rr=n)}function Ah(n){k(_i,_i.current),k(Un,n),rr===null&&(rr=n)}function Sg(n){n.tag===22?(k(_i,_i.current),k(Un,n),rr===null&&(rr=n)):ys()}function ys(){k(_i,_i.current),k(Un,Un.current)}function $n(n){Z(Un),rr===n&&(rr=null),Z(_i)}var _i=A(0);function mc(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Od(l)||zd(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 Wr=0,st=null,Pt=null,Ei=null,gc=!1,Ha=!1,sa=!1,xc=0,Hl=0,Ua=null,lw=0;function ci(){throw Error(s(321))}function Rh(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!In(n[l],r[l]))return!1;return!0}function Dh(n,r,l,u,m,x){return Wr=x,st=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,T.H=n===null||n.memoizedState===null?sx:Yh,sa=!1,x=l(u,m),sa=!1,Ha&&(x=Cg(r,l,u,m)),wg(n),x}function wg(n){T.H=Fl;var r=Pt!==null&&Pt.next!==null;if(Wr=0,Ei=Pt=st=null,gc=!1,Hl=0,Ua=null,r)throw Error(s(300));n===null||Ni||(n=n.dependencies,n!==null&&lc(n)&&(Ni=!0))}function Cg(n,r,l,u){st=n;var m=0;do{if(Ha&&(Ua=null),Hl=0,Ha=!1,25<=m)throw Error(s(301));if(m+=1,Ei=Pt=null,n.updateQueue!=null){var x=n.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}T.H=ax,x=r(l,u)}while(Ha);return x}function ow(){var n=T.H,r=n.useState()[0];return r=typeof r.then=="function"?Ul(r):r,n=n.useState()[0],(Pt!==null?Pt.memoizedState:null)!==n&&(st.flags|=1024),r}function Mh(){var n=xc!==0;return xc=0,n}function Bh(n,r,l){r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~l}function Lh(n){if(gc){for(n=n.memoizedState;n!==null;){var r=n.queue;r!==null&&(r.pending=null),n=n.next}gc=!1}Wr=0,Ei=Pt=st=null,Ha=!1,Hl=xc=0,Ua=null}function xn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ei===null?st.memoizedState=Ei=n:Ei=Ei.next=n,Ei}function bi(){if(Pt===null){var n=st.alternate;n=n!==null?n.memoizedState:null}else n=Pt.next;var r=Ei===null?st.memoizedState:Ei.next;if(r!==null)Ei=r,Pt=n;else{if(n===null)throw st.alternate===null?Error(s(467)):Error(s(310));Pt=n,n={memoizedState:Pt.memoizedState,baseState:Pt.baseState,baseQueue:Pt.baseQueue,queue:Pt.queue,next:null},Ei===null?st.memoizedState=Ei=n:Ei=Ei.next=n}return Ei}function _c(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ul(n){var r=Hl;return Hl+=1,Ua===null&&(Ua=[]),n=pg(Ua,n,r),r=st,(Ei===null?r.memoizedState:Ei.next)===null&&(r=r.alternate,T.H=r===null||r.memoizedState===null?sx:Yh),n}function bc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Ul(n);if(n.$$typeof===I)return tn(n)}throw Error(s(438,String(n)))}function Oh(n){var r=null,l=st.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var u=st.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=_c(),st.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]=L;return r.index++,l}function Gr(n,r){return typeof r=="function"?r(n):r}function vc(n){var r=bi();return zh(r,Pt,n)}function zh(n,r,l){var u=n.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=l;var m=n.baseQueue,x=u.pending;if(x!==null){if(m!==null){var y=m.next;m.next=x.next,x.next=y}r.baseQueue=m=x,u.pending=null}if(x=n.baseState,m===null)n.memoizedState=x;else{r=m.next;var C=y=null,O=null,J=r,ce=!1;do{var fe=J.lane&-536870913;if(fe!==J.lane?(_t&fe)===fe:(Wr&fe)===fe){var te=J.revertLane;if(te===0)O!==null&&(O=O.next={lane:0,revertLane:0,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),fe===La&&(ce=!0);else if((Wr&te)===te){J=J.next,te===La&&(ce=!0);continue}else fe={lane:0,revertLane:J.revertLane,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},O===null?(C=O=fe,y=x):O=O.next=fe,st.lanes|=te,Cs|=te;fe=J.action,sa&&l(x,fe),x=J.hasEagerState?J.eagerState:l(x,fe)}else te={lane:fe,revertLane:J.revertLane,gesture:J.gesture,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},O===null?(C=O=te,y=x):O=O.next=te,st.lanes|=fe,Cs|=fe;J=J.next}while(J!==null&&J!==r);if(O===null?y=x:O.next=C,!In(x,n.memoizedState)&&(Ni=!0,ce&&(l=Oa,l!==null)))throw l;n.memoizedState=x,n.baseState=y,n.baseQueue=O,u.lastRenderedState=x}return m===null&&(u.lanes=0),[n.memoizedState,u.dispatch]}function Ph(n){var r=bi(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=l.dispatch,m=l.pending,x=r.memoizedState;if(m!==null){l.pending=null;var y=m=m.next;do x=n(x,y.action),y=y.next;while(y!==m);In(x,r.memoizedState)||(Ni=!0),r.memoizedState=x,r.baseQueue===null&&(r.baseState=x),l.lastRenderedState=x}return[x,u]}function kg(n,r,l){var u=st,m=bi(),x=yt;if(x){if(l===void 0)throw Error(s(407));l=l()}else l=r();var y=!In((Pt||m).memoizedState,l);if(y&&(m.memoizedState=l,Ni=!0),m=m.queue,Uh(jg.bind(null,u,m,n),[n]),m.getSnapshot!==r||y||Ei!==null&&Ei.memoizedState.tag&1){if(u.flags|=2048,$a(9,{destroy:void 0},Ng.bind(null,u,m,l,r),null),qt===null)throw Error(s(349));x||(Wr&127)!==0||Eg(u,r,l)}return l}function Eg(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=st.updateQueue,r===null?(r=_c(),st.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function Ng(n,r,l,u){r.value=l,r.getSnapshot=u,Tg(r)&&Ag(n)}function jg(n,r,l){return l(function(){Tg(r)&&Ag(n)})}function Tg(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!In(n,l)}catch{return!0}}function Ag(n){var r=Xs(n,2);r!==null&&Rn(r,n,2)}function Ih(n){var r=xn();if(typeof n=="function"){var l=n;if(n=l(),sa){Gt(!0);try{l()}finally{Gt(!1)}}}return r.memoizedState=r.baseState=n,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:n},r}function Rg(n,r,l,u){return n.baseState=l,zh(n,Pt,typeof u=="function"?u:Gr)}function cw(n,r,l,u,m){if(wc(n))throw Error(s(485));if(n=r.action,n!==null){var x={payload:m,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){x.listeners.push(y)}};T.T!==null?l(!0):x.isTransition=!1,u(x),l=r.pending,l===null?(x.next=r.pending=x,Dg(r,x)):(x.next=l.next,r.pending=l.next=x)}}function Dg(n,r){var l=r.action,u=r.payload,m=n.state;if(r.isTransition){var x=T.T,y={};T.T=y;try{var C=l(m,u),O=T.S;O!==null&&O(y,C),Mg(n,r,C)}catch(J){Hh(n,r,J)}finally{x!==null&&y.types!==null&&(x.types=y.types),T.T=x}}else try{x=l(m,u),Mg(n,r,x)}catch(J){Hh(n,r,J)}}function Mg(n,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){Bg(n,r,u)},function(u){return Hh(n,r,u)}):Bg(n,r,l)}function Bg(n,r,l){r.status="fulfilled",r.value=l,Lg(r),n.state=l,r=n.pending,r!==null&&(l=r.next,l===r?n.pending=null:(l=l.next,r.next=l,Dg(n,l)))}function Hh(n,r,l){var u=n.pending;if(n.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=l,Lg(r),r=r.next;while(r!==u)}n.action=null}function Lg(n){n=n.listeners;for(var r=0;r<n.length;r++)(0,n[r])()}function Og(n,r){return r}function zg(n,r){if(yt){var l=qt.formState;if(l!==null){e:{var u=st;if(yt){if(Qt){t:{for(var m=Qt,x=nr;m.nodeType!==8;){if(!x){m=null;break t}if(m=sr(m.nextSibling),m===null){m=null;break t}}x=m.data,m=x==="F!"||x==="F"?m:null}if(m){Qt=sr(m.nextSibling),u=m.data==="F!";break e}}ms(u)}u=!1}u&&(r=l[0])}}return l=xn(),l.memoizedState=l.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Og,lastRenderedState:r},l.queue=u,l=ix.bind(null,st,u),u.dispatch=l,u=Ih(!1),x=Gh.bind(null,st,!1,u.queue),u=xn(),m={state:r,dispatch:null,action:n,pending:null},u.queue=m,l=cw.bind(null,st,m,x,l),m.dispatch=l,u.memoizedState=n,[r,l,!1]}function Pg(n){var r=bi();return Ig(r,Pt,n)}function Ig(n,r,l){if(r=zh(n,r,Og)[0],n=vc(Gr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=Ul(r)}catch(y){throw y===za?uc:y}else u=r;r=bi();var m=r.queue,x=m.dispatch;return l!==r.memoizedState&&(st.flags|=2048,$a(9,{destroy:void 0},uw.bind(null,m,l),null)),[u,x,n]}function uw(n,r){n.action=r}function Hg(n){var r=bi(),l=Pt;if(l!==null)return Ig(r,l,n);bi(),r=r.memoizedState,l=bi();var u=l.queue.dispatch;return l.memoizedState=n,[r,u,!1]}function $a(n,r,l,u){return n={tag:n,create:l,deps:u,inst:r,next:null},r=st.updateQueue,r===null&&(r=_c(),st.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 Ug(){return bi().memoizedState}function yc(n,r,l,u){var m=xn();st.flags|=n,m.memoizedState=$a(1|r,{destroy:void 0},l,u===void 0?null:u)}function Sc(n,r,l,u){var m=bi();u=u===void 0?null:u;var x=m.memoizedState.inst;Pt!==null&&u!==null&&Rh(u,Pt.memoizedState.deps)?m.memoizedState=$a(r,x,l,u):(st.flags|=n,m.memoizedState=$a(1|r,x,l,u))}function $g(n,r){yc(8390656,8,n,r)}function Uh(n,r){Sc(2048,8,n,r)}function hw(n){st.flags|=4;var r=st.updateQueue;if(r===null)r=_c(),st.updateQueue=r,r.events=[n];else{var l=r.events;l===null?r.events=[n]:l.push(n)}}function Fg(n){var r=bi().memoizedState;return hw({ref:r,nextImpl:n}),function(){if((Rt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function qg(n,r){return Sc(4,2,n,r)}function Wg(n,r){return Sc(4,4,n,r)}function Gg(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 Yg(n,r,l){l=l!=null?l.concat([n]):null,Sc(4,4,Gg.bind(null,r,n),l)}function $h(){}function Vg(n,r){var l=bi();r=r===void 0?null:r;var u=l.memoizedState;return r!==null&&Rh(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function Kg(n,r){var l=bi();r=r===void 0?null:r;var u=l.memoizedState;if(r!==null&&Rh(r,u[1]))return u[0];if(u=n(),sa){Gt(!0);try{n()}finally{Gt(!1)}}return l.memoizedState=[u,r],u}function Fh(n,r,l){return l===void 0||(Wr&1073741824)!==0&&(_t&261930)===0?n.memoizedState=r:(n.memoizedState=l,n=Xx(),st.lanes|=n,Cs|=n,l)}function Xg(n,r,l,u){return In(l,r)?l:Ia.current!==null?(n=Fh(n,l,u),In(n,r)||(Ni=!0),n):(Wr&42)===0||(Wr&1073741824)!==0&&(_t&261930)===0?(Ni=!0,n.memoizedState=l):(n=Xx(),st.lanes|=n,Cs|=n,r)}function Zg(n,r,l,u,m){var x=q.p;q.p=x!==0&&8>x?x:8;var y=T.T,C={};T.T=C,Gh(n,!1,r,l);try{var O=m(),J=T.S;if(J!==null&&J(C,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var ce=aw(O,u);$l(n,r,ce,Wn(n))}else $l(n,r,u,Wn(n))}catch(fe){$l(n,r,{then:function(){},status:"rejected",reason:fe},Wn())}finally{q.p=x,y!==null&&C.types!==null&&(y.types=C.types),T.T=y}}function dw(){}function qh(n,r,l,u){if(n.tag!==5)throw Error(s(476));var m=Qg(n).queue;Zg(n,m,r,W,l===null?dw:function(){return Jg(n),l(u)})}function Qg(n){var r=n.memoizedState;if(r!==null)return r;r={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:W},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:l},next:null},n.memoizedState=r,n=n.alternate,n!==null&&(n.memoizedState=r),r}function Jg(n){var r=Qg(n);r.next===null&&(r=n.alternate.memoizedState),$l(n,r.next.queue,{},Wn())}function Wh(){return tn(so)}function ex(){return bi().memoizedState}function tx(){return bi().memoizedState}function fw(n){for(var r=n.return;r!==null;){switch(r.tag){case 24:case 3:var l=Wn();n=_s(l);var u=bs(r,n,l);u!==null&&(Rn(u,r,l),zl(u,r,l)),r={cache:vh()},n.payload=r;return}r=r.return}}function pw(n,r,l){var u=Wn();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wc(n)?nx(r,l):(l=ch(n,r,l,u),l!==null&&(Rn(l,n,u),rx(l,r,u)))}function ix(n,r,l){var u=Wn();$l(n,r,l,u)}function $l(n,r,l,u){var m={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(wc(n))nx(r,m);else{var x=n.alternate;if(n.lanes===0&&(x===null||x.lanes===0)&&(x=r.lastRenderedReducer,x!==null))try{var y=r.lastRenderedState,C=x(y,l);if(m.hasEagerState=!0,m.eagerState=C,In(C,y))return nc(n,r,m,0),qt===null&&ic(),!1}catch{}finally{}if(l=ch(n,r,m,u),l!==null)return Rn(l,n,u),rx(l,r,u),!0}return!1}function Gh(n,r,l,u){if(u={lane:2,revertLane:Cd(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},wc(n)){if(r)throw Error(s(479))}else r=ch(n,l,u,2),r!==null&&Rn(r,n,2)}function wc(n){var r=n.alternate;return n===st||r!==null&&r===st}function nx(n,r){Ha=gc=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function rx(n,r,l){if((l&4194048)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,Di(n,l)}}var Fl={readContext:tn,use:bc,useCallback:ci,useContext:ci,useEffect:ci,useImperativeHandle:ci,useLayoutEffect:ci,useInsertionEffect:ci,useMemo:ci,useReducer:ci,useRef:ci,useState:ci,useDebugValue:ci,useDeferredValue:ci,useTransition:ci,useSyncExternalStore:ci,useId:ci,useHostTransitionStatus:ci,useFormState:ci,useActionState:ci,useOptimistic:ci,useMemoCache:ci,useCacheRefresh:ci};Fl.useEffectEvent=ci;var sx={readContext:tn,use:bc,useCallback:function(n,r){return xn().memoizedState=[n,r===void 0?null:r],n},useContext:tn,useEffect:$g,useImperativeHandle:function(n,r,l){l=l!=null?l.concat([n]):null,yc(4194308,4,Gg.bind(null,r,n),l)},useLayoutEffect:function(n,r){return yc(4194308,4,n,r)},useInsertionEffect:function(n,r){yc(4,2,n,r)},useMemo:function(n,r){var l=xn();r=r===void 0?null:r;var u=n();if(sa){Gt(!0);try{n()}finally{Gt(!1)}}return l.memoizedState=[u,r],u},useReducer:function(n,r,l){var u=xn();if(l!==void 0){var m=l(r);if(sa){Gt(!0);try{l(r)}finally{Gt(!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=pw.bind(null,st,n),[u.memoizedState,n]},useRef:function(n){var r=xn();return n={current:n},r.memoizedState=n},useState:function(n){n=Ih(n);var r=n.queue,l=ix.bind(null,st,r);return r.dispatch=l,[n.memoizedState,l]},useDebugValue:$h,useDeferredValue:function(n,r){var l=xn();return Fh(l,n,r)},useTransition:function(){var n=Ih(!1);return n=Zg.bind(null,st,n.queue,!0,!1),xn().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,r,l){var u=st,m=xn();if(yt){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),qt===null)throw Error(s(349));(_t&127)!==0||Eg(u,r,l)}m.memoizedState=l;var x={value:l,getSnapshot:r};return m.queue=x,$g(jg.bind(null,u,x,n),[n]),u.flags|=2048,$a(9,{destroy:void 0},Ng.bind(null,u,x,l,r),null),l},useId:function(){var n=xn(),r=qt.identifierPrefix;if(yt){var l=wr,u=Sr;l=(u&~(1<<32-ut(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=xc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=lw++,r="_"+r+"r_"+l.toString(32)+"_";return n.memoizedState=r},useHostTransitionStatus:Wh,useFormState:zg,useActionState:zg,useOptimistic:function(n){var r=xn();r.memoizedState=r.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Gh.bind(null,st,!0,l),l.dispatch=r,[n,r]},useMemoCache:Oh,useCacheRefresh:function(){return xn().memoizedState=fw.bind(null,st)},useEffectEvent:function(n){var r=xn(),l={impl:n};return r.memoizedState=l,function(){if((Rt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},Yh={readContext:tn,use:bc,useCallback:Vg,useContext:tn,useEffect:Uh,useImperativeHandle:Yg,useInsertionEffect:qg,useLayoutEffect:Wg,useMemo:Kg,useReducer:vc,useRef:Ug,useState:function(){return vc(Gr)},useDebugValue:$h,useDeferredValue:function(n,r){var l=bi();return Xg(l,Pt.memoizedState,n,r)},useTransition:function(){var n=vc(Gr)[0],r=bi().memoizedState;return[typeof n=="boolean"?n:Ul(n),r]},useSyncExternalStore:kg,useId:ex,useHostTransitionStatus:Wh,useFormState:Pg,useActionState:Pg,useOptimistic:function(n,r){var l=bi();return Rg(l,Pt,n,r)},useMemoCache:Oh,useCacheRefresh:tx};Yh.useEffectEvent=Fg;var ax={readContext:tn,use:bc,useCallback:Vg,useContext:tn,useEffect:Uh,useImperativeHandle:Yg,useInsertionEffect:qg,useLayoutEffect:Wg,useMemo:Kg,useReducer:Ph,useRef:Ug,useState:function(){return Ph(Gr)},useDebugValue:$h,useDeferredValue:function(n,r){var l=bi();return Pt===null?Fh(l,n,r):Xg(l,Pt.memoizedState,n,r)},useTransition:function(){var n=Ph(Gr)[0],r=bi().memoizedState;return[typeof n=="boolean"?n:Ul(n),r]},useSyncExternalStore:kg,useId:ex,useHostTransitionStatus:Wh,useFormState:Hg,useActionState:Hg,useOptimistic:function(n,r){var l=bi();return Pt!==null?Rg(l,Pt,n,r):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:Oh,useCacheRefresh:tx};ax.useEffectEvent=Fg;function Vh(n,r,l,u){r=n.memoizedState,l=l(u,r),l=l==null?r:g({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Kh={enqueueSetState:function(n,r,l){n=n._reactInternals;var u=Wn(),m=_s(u);m.payload=r,l!=null&&(m.callback=l),r=bs(n,m,u),r!==null&&(Rn(r,n,u),zl(r,n,u))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=Wn(),m=_s(u);m.tag=1,m.payload=r,l!=null&&(m.callback=l),r=bs(n,m,u),r!==null&&(Rn(r,n,u),zl(r,n,u))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Wn(),u=_s(l);u.tag=2,r!=null&&(u.callback=r),r=bs(n,u,l),r!==null&&(Rn(r,n,l),zl(r,n,l))}};function lx(n,r,l,u,m,x,y){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,x,y):r.prototype&&r.prototype.isPureReactComponent?!Tl(l,u)||!Tl(m,x):!0}function ox(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 aa(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=g({},l));for(var m in n)l[m]===void 0&&(l[m]=n[m])}return l}function cx(n){tc(n)}function ux(n){console.error(n)}function hx(n){tc(n)}function Cc(n,r){try{var l=n.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function dx(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 Xh(n,r,l){return l=_s(l),l.tag=3,l.payload={element:null},l.callback=function(){Cc(n,r)},l}function fx(n){return n=_s(n),n.tag=3,n}function px(n,r,l,u){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var x=u.value;n.payload=function(){return m(x)},n.callback=function(){dx(r,l,u)}}var y=l.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(n.callback=function(){dx(r,l,u),typeof m!="function"&&(ks===null?ks=new Set([this]):ks.add(this));var C=u.stack;this.componentDidCatch(u.value,{componentStack:C!==null?C:""})})}function mw(n,r,l,u,m){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=l.alternate,r!==null&&Ba(r,l,m,!0),l=Un.current,l!==null){switch(l.tag){case 31:case 13:return rr===null?Oc():l.alternate===null&&ui===0&&(ui=3),l.flags&=-257,l.flags|=65536,l.lanes=m,u===hc?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([u]):r.add(u),yd(n,u,m)),!1;case 22:return l.flags|=65536,u===hc?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)),yd(n,u,m)),!1}throw Error(s(435,l.tag))}return yd(n,u,m),Oc(),!1}if(yt)return r=Un.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=m,u!==mh&&(n=Error(s(422),{cause:u}),Dl(er(n,l)))):(u!==mh&&(r=Error(s(423),{cause:u}),Dl(er(r,l))),n=n.current.alternate,n.flags|=65536,m&=-m,n.lanes|=m,u=er(u,l),m=Xh(n.stateNode,u,m),Eh(n,m),ui!==4&&(ui=2)),!1;var x=Error(s(520),{cause:u});if(x=er(x,l),Zl===null?Zl=[x]:Zl.push(x),ui!==4&&(ui=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=Xh(l.stateNode,u,n),Eh(l,n),!1;case 1:if(r=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(ks===null||!ks.has(x))))return l.flags|=65536,m&=-m,l.lanes|=m,m=fx(m),px(m,n,l,u),Eh(l,m),!1}l=l.return}while(l!==null);return!1}var Zh=Error(s(461)),Ni=!1;function nn(n,r,l,u){r.child=n===null?_g(r,null,l,u):ra(r,n.child,l,u)}function mx(n,r,l,u,m){l=l.render;var x=r.ref;if("ref"in u){var y={};for(var C in u)C!=="ref"&&(y[C]=u[C])}else y=u;return ea(r),u=Dh(n,r,l,y,x,m),C=Mh(),n!==null&&!Ni?(Bh(n,r,m),Yr(n,r,m)):(yt&&C&&fh(r),r.flags|=1,nn(n,r,u,m),r.child)}function gx(n,r,l,u,m){if(n===null){var x=l.type;return typeof x=="function"&&!uh(x)&&x.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=x,xx(n,r,x,u,m)):(n=sc(l.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(x=n.child,!sd(n,m)){var y=x.memoizedProps;if(l=l.compare,l=l!==null?l:Tl,l(y,u)&&n.ref===r.ref)return Yr(n,r,m)}return r.flags|=1,n=Ur(x,u),n.ref=r.ref,n.return=r,r.child=n}function xx(n,r,l,u,m){if(n!==null){var x=n.memoizedProps;if(Tl(x,u)&&n.ref===r.ref)if(Ni=!1,r.pendingProps=u=x,sd(n,m))(n.flags&131072)!==0&&(Ni=!0);else return r.lanes=n.lanes,Yr(n,r,m)}return Qh(n,r,l,u,m)}function _x(n,r,l,u){var m=u.children,x=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(x=x!==null?x.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&~x}else u=0,r.child=null;return bx(n,r,x,l,u)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},n!==null&&cc(r,x!==null?x.cachePool:null),x!==null?yg(r,x):jh(),Sg(r);else return u=r.lanes=536870912,bx(n,r,x!==null?x.baseLanes|l:l,l,u)}else x!==null?(cc(r,x.cachePool),yg(r,x),ys(),r.memoizedState=null):(n!==null&&cc(r,null),jh(),ys());return nn(n,r,m,l),r.child}function ql(n,r){return n!==null&&n.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function bx(n,r,l,u,m){var x=Sh();return x=x===null?null:{parent:ki._currentValue,pool:x},r.memoizedState={baseLanes:l,cachePool:x},n!==null&&cc(r,null),jh(),Sg(r),n!==null&&Ba(n,r,u,!0),r.childLanes=m,null}function kc(n,r){return r=Nc({mode:r.mode,children:r.children},n.mode),r.ref=n.ref,n.child=r,r.return=n,r}function vx(n,r,l){return ra(r,n.child,null,l),n=kc(r,r.pendingProps),n.flags|=2,$n(r),r.memoizedState=null,n}function gw(n,r,l){var u=r.pendingProps,m=(r.flags&128)!==0;if(r.flags&=-129,n===null){if(yt){if(u.mode==="hidden")return n=kc(r,u),r.lanes=536870912,ql(null,n);if(Ah(r),(n=Qt)?(n=D_(n,nr),n=n!==null&&n.data==="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:fs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},l=ng(n),l.return=r,r.child=l,en=r,Qt=null)):n=null,n===null)throw ms(r);return r.lanes=536870912,null}return kc(r,u)}var x=n.memoizedState;if(x!==null){var y=x.dehydrated;if(Ah(r),m)if(r.flags&256)r.flags&=-257,r=vx(n,r,l);else if(r.memoizedState!==null)r.child=n.child,r.flags|=128,r=null;else throw Error(s(558));else if(Ni||Ba(n,r,l,!1),m=(l&n.childLanes)!==0,Ni||m){if(u=qt,u!==null&&(y=gi(u,l),y!==0&&y!==x.retryLane))throw x.retryLane=y,Xs(n,y),Rn(u,n,y),Zh;Oc(),r=vx(n,r,l)}else n=x.treeContext,Qt=sr(y.nextSibling),en=r,yt=!0,ps=null,nr=!1,n!==null&&ag(r,n),r=kc(r,u),r.flags|=4096;return r}return n=Ur(n.child,{mode:u.mode,children:u.children}),n.ref=r.ref,r.child=n,n.return=r,n}function Ec(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 Qh(n,r,l,u,m){return ea(r),l=Dh(n,r,l,u,void 0,m),u=Mh(),n!==null&&!Ni?(Bh(n,r,m),Yr(n,r,m)):(yt&&u&&fh(r),r.flags|=1,nn(n,r,l,m),r.child)}function yx(n,r,l,u,m,x){return ea(r),r.updateQueue=null,l=Cg(r,u,l,m),wg(n),u=Mh(),n!==null&&!Ni?(Bh(n,r,x),Yr(n,r,x)):(yt&&u&&fh(r),r.flags|=1,nn(n,r,l,x),r.child)}function Sx(n,r,l,u,m){if(ea(r),r.stateNode===null){var x=Aa,y=l.contextType;typeof y=="object"&&y!==null&&(x=tn(y)),x=new l(u,x),r.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=Kh,r.stateNode=x,x._reactInternals=r,x=r.stateNode,x.props=u,x.state=r.memoizedState,x.refs={},Ch(r),y=l.contextType,x.context=typeof y=="object"&&y!==null?tn(y):Aa,x.state=r.memoizedState,y=l.getDerivedStateFromProps,typeof y=="function"&&(Vh(r,l,y,u),x.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(y=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),y!==x.state&&Kh.enqueueReplaceState(x,x.state,null),Il(r,u,x,m),Pl(),x.state=r.memoizedState),typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(n===null){x=r.stateNode;var C=r.memoizedProps,O=aa(l,C);x.props=O;var J=x.context,ce=l.contextType;y=Aa,typeof ce=="object"&&ce!==null&&(y=tn(ce));var fe=l.getDerivedStateFromProps;ce=typeof fe=="function"||typeof x.getSnapshotBeforeUpdate=="function",C=r.pendingProps!==C,ce||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(C||J!==y)&&ox(r,x,u,y),xs=!1;var te=r.memoizedState;x.state=te,Il(r,u,x,m),Pl(),J=r.memoizedState,C||te!==J||xs?(typeof fe=="function"&&(Vh(r,l,fe,u),J=r.memoizedState),(O=xs||lx(r,l,O,u,te,J,y))?(ce||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=J),x.props=u,x.state=J,x.context=y,u=O):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{x=r.stateNode,kh(n,r),y=r.memoizedProps,ce=aa(l,y),x.props=ce,fe=r.pendingProps,te=x.context,J=l.contextType,O=Aa,typeof J=="object"&&J!==null&&(O=tn(J)),C=l.getDerivedStateFromProps,(J=typeof C=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(y!==fe||te!==O)&&ox(r,x,u,O),xs=!1,te=r.memoizedState,x.state=te,Il(r,u,x,m),Pl();var le=r.memoizedState;y!==fe||te!==le||xs||n!==null&&n.dependencies!==null&&lc(n.dependencies)?(typeof C=="function"&&(Vh(r,l,C,u),le=r.memoizedState),(ce=xs||lx(r,l,ce,u,te,le,O)||n!==null&&n.dependencies!==null&&lc(n.dependencies))?(J||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(u,le,O),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(u,le,O)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||y===n.memoizedProps&&te===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&te===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=le),x.props=u,x.state=le,x.context=O,u=ce):(typeof x.componentDidUpdate!="function"||y===n.memoizedProps&&te===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&te===n.memoizedState||(r.flags|=1024),u=!1)}return x=u,Ec(n,r),u=(r.flags&128)!==0,x||u?(x=r.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:x.render(),r.flags|=1,n!==null&&u?(r.child=ra(r,n.child,null,m),r.child=ra(r,null,l,m)):nn(n,r,l,m),r.memoizedState=x.state,n=r.child):n=Yr(n,r,m),n}function wx(n,r,l,u){return Qs(),r.flags|=256,nn(n,r,l,u),r.child}var Jh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ed(n){return{baseLanes:n,cachePool:dg()}}function td(n,r,l){return n=n!==null?n.childLanes&~l:0,r&&(n|=qn),n}function Cx(n,r,l){var u=r.pendingProps,m=!1,x=(r.flags&128)!==0,y;if((y=x)||(y=n!==null&&n.memoizedState===null?!1:(_i.current&2)!==0),y&&(m=!0,r.flags&=-129),y=(r.flags&32)!==0,r.flags&=-33,n===null){if(yt){if(m?vs(r):ys(),(n=Qt)?(n=D_(n,nr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:fs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},l=ng(n),l.return=r,r.child=l,en=r,Qt=null)):n=null,n===null)throw ms(r);return zd(n)?r.lanes=32:r.lanes=536870912,null}var C=u.children;return u=u.fallback,m?(ys(),m=r.mode,C=Nc({mode:"hidden",children:C},m),u=Zs(u,m,l,null),C.return=r,u.return=r,C.sibling=u,r.child=C,u=r.child,u.memoizedState=ed(l),u.childLanes=td(n,y,l),r.memoizedState=Jh,ql(null,u)):(vs(r),id(r,C))}var O=n.memoizedState;if(O!==null&&(C=O.dehydrated,C!==null)){if(x)r.flags&256?(vs(r),r.flags&=-257,r=nd(n,r,l)):r.memoizedState!==null?(ys(),r.child=n.child,r.flags|=128,r=null):(ys(),C=u.fallback,m=r.mode,u=Nc({mode:"visible",children:u.children},m),C=Zs(C,m,l,null),C.flags|=2,u.return=r,C.return=r,u.sibling=C,r.child=u,ra(r,n.child,null,l),u=r.child,u.memoizedState=ed(l),u.childLanes=td(n,y,l),r.memoizedState=Jh,r=ql(null,u));else if(vs(r),zd(C)){if(y=C.nextSibling&&C.nextSibling.dataset,y)var J=y.dgst;y=J,u=Error(s(419)),u.stack="",u.digest=y,Dl({value:u,source:null,stack:null}),r=nd(n,r,l)}else if(Ni||Ba(n,r,l,!1),y=(l&n.childLanes)!==0,Ni||y){if(y=qt,y!==null&&(u=gi(y,l),u!==0&&u!==O.retryLane))throw O.retryLane=u,Xs(n,u),Rn(y,n,u),Zh;Od(C)||Oc(),r=nd(n,r,l)}else Od(C)?(r.flags|=192,r.child=n.child,r=null):(n=O.treeContext,Qt=sr(C.nextSibling),en=r,yt=!0,ps=null,nr=!1,n!==null&&ag(r,n),r=id(r,u.children),r.flags|=4096);return r}return m?(ys(),C=u.fallback,m=r.mode,O=n.child,J=O.sibling,u=Ur(O,{mode:"hidden",children:u.children}),u.subtreeFlags=O.subtreeFlags&65011712,J!==null?C=Ur(J,C):(C=Zs(C,m,l,null),C.flags|=2),C.return=r,u.return=r,u.sibling=C,r.child=u,ql(null,u),u=r.child,C=n.child.memoizedState,C===null?C=ed(l):(m=C.cachePool,m!==null?(O=ki._currentValue,m=m.parent!==O?{parent:O,pool:O}:m):m=dg(),C={baseLanes:C.baseLanes|l,cachePool:m}),u.memoizedState=C,u.childLanes=td(n,y,l),r.memoizedState=Jh,ql(n.child,u)):(vs(r),l=n.child,n=l.sibling,l=Ur(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 id(n,r){return r=Nc({mode:"visible",children:r},n.mode),r.return=n,n.child=r}function Nc(n,r){return n=Hn(22,n,null,r),n.lanes=0,n}function nd(n,r,l){return ra(r,n.child,null,l),n=id(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function kx(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),_h(n.return,r,l)}function rd(n,r,l,u,m,x){var y=n.memoizedState;y===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:m,treeForkCount:x}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=u,y.tail=l,y.tailMode=m,y.treeForkCount=x)}function Ex(n,r,l){var u=r.pendingProps,m=u.revealOrder,x=u.tail;u=u.children;var y=_i.current,C=(y&2)!==0;if(C?(y=y&1|2,r.flags|=128):y&=1,k(_i,y),nn(n,r,u,l),u=yt?Rl:0,!C&&n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&kx(n,l,r);else if(n.tag===19)kx(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&&mc(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),rd(r,!1,m,l,x,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&&mc(n)===null){r.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}rd(r,!0,l,null,x,u);break;case"together":rd(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function Yr(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),Cs|=r.lanes,(l&r.childLanes)===0)if(n!==null){if(Ba(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=Ur(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Ur(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function sd(n,r){return(n.lanes&r)!==0?!0:(n=n.dependencies,!!(n!==null&&lc(n)))}function xw(n,r,l){switch(r.tag){case 3:he(r,r.stateNode.containerInfo),gs(r,ki,n.memoizedState.cache),Qs();break;case 27:case 5:Ae(r);break;case 4:he(r,r.stateNode.containerInfo);break;case 10:gs(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Ah(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(vs(r),r.flags|=128,null):(l&r.child.childLanes)!==0?Cx(n,r,l):(vs(r),n=Yr(n,r,l),n!==null?n.sibling:null);vs(r);break;case 19:var m=(n.flags&128)!==0;if(u=(l&r.childLanes)!==0,u||(Ba(n,r,l,!1),u=(l&r.childLanes)!==0),m){if(u)return Ex(n,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),k(_i,_i.current),u)break;return null;case 22:return r.lanes=0,_x(n,r,l,r.pendingProps);case 24:gs(r,ki,n.memoizedState.cache)}return Yr(n,r,l)}function Nx(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps)Ni=!0;else{if(!sd(n,l)&&(r.flags&128)===0)return Ni=!1,xw(n,r,l);Ni=(n.flags&131072)!==0}else Ni=!1,yt&&(r.flags&1048576)!==0&&sg(r,Rl,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(n=ia(r.elementType),r.type=n,typeof n=="function")uh(n)?(u=aa(n,u),r.tag=1,r=Sx(null,r,n,u,l)):(r.tag=0,r=Qh(null,r,n,u,l));else{if(n!=null){var m=n.$$typeof;if(m===R){r.tag=11,r=mx(null,r,n,u,l);break e}else if(m===ie){r.tag=14,r=gx(null,r,n,u,l);break e}}throw r=K(n)||n,Error(s(306,r,""))}}return r;case 0:return Qh(n,r,r.type,r.pendingProps,l);case 1:return u=r.type,m=aa(u,r.pendingProps),Sx(n,r,u,m,l);case 3:e:{if(he(r,r.stateNode.containerInfo),n===null)throw Error(s(387));u=r.pendingProps;var x=r.memoizedState;m=x.element,kh(n,r),Il(r,u,null,l);var y=r.memoizedState;if(u=y.cache,gs(r,ki,u),u!==x.cache&&bh(r,[ki],l,!0),Pl(),u=y.element,x.isDehydrated)if(x={element:u,isDehydrated:!1,cache:y.cache},r.updateQueue.baseState=x,r.memoizedState=x,r.flags&256){r=wx(n,r,u,l);break e}else if(u!==m){m=er(Error(s(424)),r),Dl(m),r=wx(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(Qt=sr(n.firstChild),en=r,yt=!0,ps=null,nr=!0,l=_g(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Qs(),u===m){r=Yr(n,r,l);break e}nn(n,r,u,l)}r=r.child}return r;case 26:return Ec(n,r),n===null?(l=P_(r.type,null,r.pendingProps,null))?r.memoizedState=l:yt||(l=r.type,n=r.pendingProps,u=Fc(V.current).createElement(l),u[Xt]=r,u[At]=n,rn(u,l,n),Ze(u),r.stateNode=u):r.memoizedState=P_(r.type,n.memoizedProps,r.pendingProps,n.memoizedState),null;case 27:return Ae(r),n===null&&yt&&(u=r.stateNode=L_(r.type,r.pendingProps,V.current),en=r,nr=!0,m=Qt,Ts(r.type)?(Pd=m,Qt=sr(u.firstChild)):Qt=m),nn(n,r,r.pendingProps.children,l),Ec(n,r),n===null&&(r.flags|=4194304),r.child;case 5:return n===null&&yt&&((m=u=Qt)&&(u=Yw(u,r.type,r.pendingProps,nr),u!==null?(r.stateNode=u,en=r,Qt=sr(u.firstChild),nr=!1,m=!0):m=!1),m||ms(r)),Ae(r),m=r.type,x=r.pendingProps,y=n!==null?n.memoizedProps:null,u=x.children,Md(m,x)?u=null:y!==null&&Md(m,y)&&(r.flags|=32),r.memoizedState!==null&&(m=Dh(n,r,ow,null,null,l),so._currentValue=m),Ec(n,r),nn(n,r,u,l),r.child;case 6:return n===null&&yt&&((n=l=Qt)&&(l=Vw(l,r.pendingProps,nr),l!==null?(r.stateNode=l,en=r,Qt=null,n=!0):n=!1),n||ms(r)),null;case 13:return Cx(n,r,l);case 4:return he(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=ra(r,null,u,l):nn(n,r,u,l),r.child;case 11:return mx(n,r,r.type,r.pendingProps,l);case 7:return nn(n,r,r.pendingProps,l),r.child;case 8:return nn(n,r,r.pendingProps.children,l),r.child;case 12:return nn(n,r,r.pendingProps.children,l),r.child;case 10:return u=r.pendingProps,gs(r,r.type,u.value),nn(n,r,u.children,l),r.child;case 9:return m=r.type._context,u=r.pendingProps.children,ea(r),m=tn(m),u=u(m),r.flags|=1,nn(n,r,u,l),r.child;case 14:return gx(n,r,r.type,r.pendingProps,l);case 15:return xx(n,r,r.type,r.pendingProps,l);case 19:return Ex(n,r,l);case 31:return gw(n,r,l);case 22:return _x(n,r,l,r.pendingProps);case 24:return ea(r),u=tn(ki),n===null?(m=Sh(),m===null&&(m=qt,x=vh(),m.pooledCache=x,x.refCount++,x!==null&&(m.pooledCacheLanes|=l),m=x),r.memoizedState={parent:u,cache:m},Ch(r),gs(r,ki,m)):((n.lanes&l)!==0&&(kh(n,r),Il(r,null,null,l),Pl()),m=n.memoizedState,x=r.memoizedState,m.parent!==u?(m={parent:u,cache:u},r.memoizedState=m,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=m),gs(r,ki,u)):(u=x.cache,gs(r,ki,u),u!==m.cache&&bh(r,[ki],l,!0))),nn(n,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Vr(n){n.flags|=4}function ad(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(e_())n.flags|=8192;else throw na=hc,wh}else n.flags&=-16777217}function jx(n,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!F_(r))if(e_())n.flags|=8192;else throw na=hc,wh}function jc(n,r){r!==null&&(n.flags|=4),n.flags&16384&&(r=n.tag!==22?rt():536870912,n.lanes|=r,Ga|=r)}function Wl(n,r){if(!yt)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 Jt(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 _w(n,r,l){var u=r.pendingProps;switch(ph(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jt(r),null;case 1:return Jt(r),null;case 3:return l=r.stateNode,u=null,n!==null&&(u=n.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),qr(ki),_e(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(Ma(r)?Vr(r):n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,gh())),Jt(r),null;case 26:var m=r.type,x=r.memoizedState;return n===null?(Vr(r),x!==null?(Jt(r),jx(r,x)):(Jt(r),ad(r,m,null,u,l))):x?x!==n.memoizedState?(Vr(r),Jt(r),jx(r,x)):(Jt(r),r.flags&=-16777217):(n=n.memoizedProps,n!==u&&Vr(r),Jt(r),ad(r,m,n,u,l)),null;case 27:if(Oe(r),l=V.current,m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Vr(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Jt(r),null}n=oe.current,Ma(r)?lg(r):(n=L_(m,u,l),r.stateNode=n,Vr(r))}return Jt(r),null;case 5:if(Oe(r),m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Vr(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Jt(r),null}if(x=oe.current,Ma(r))lg(r);else{var y=Fc(V.current);switch(x){case 1:x=y.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:x=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":x=y.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":x=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":x=y.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof u.is=="string"?y.createElement("select",{is:u.is}):y.createElement("select"),u.multiple?x.multiple=!0:u.size&&(x.size=u.size);break;default:x=typeof u.is=="string"?y.createElement(m,{is:u.is}):y.createElement(m)}}x[Xt]=r,x[At]=u;e:for(y=r.child;y!==null;){if(y.tag===5||y.tag===6)x.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=x;e:switch(rn(x,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&&Vr(r)}}return Jt(r),ad(r,r.type,n===null?null:n.memoizedProps,r.pendingProps,l),null;case 6:if(n&&r.stateNode!=null)n.memoizedProps!==u&&Vr(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(n=V.current,Ma(r)){if(n=r.stateNode,l=r.memoizedProps,u=null,m=en,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}n[Xt]=r,n=!!(n.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||C_(n.nodeValue,l)),n||ms(r,!0)}else n=Fc(n).createTextNode(u),n[Xt]=r,r.stateNode=n}return Jt(r),null;case 31:if(l=r.memoizedState,n===null||n.memoizedState!==null){if(u=Ma(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[Xt]=r}else Qs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Jt(r),n=!1}else l=gh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return r.flags&256?($n(r),r):($n(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Jt(r),null;case 13:if(u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(m=Ma(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[Xt]=r}else Qs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Jt(r),m=!1}else m=gh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=m),m=!0;if(!m)return r.flags&256?($n(r),r):($n(r),null)}return $n(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),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==m&&(u.flags|=2048)),l!==n&&l&&(r.child.flags|=8192),jc(r,r.updateQueue),Jt(r),null);case 4:return _e(),n===null&&jd(r.stateNode.containerInfo),Jt(r),null;case 10:return qr(r.type),Jt(r),null;case 19:if(Z(_i),u=r.memoizedState,u===null)return Jt(r),null;if(m=(r.flags&128)!==0,x=u.rendering,x===null)if(m)Wl(u,!1);else{if(ui!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(x=mc(n),x!==null){for(r.flags|=128,Wl(u,!1),n=x.updateQueue,r.updateQueue=n,jc(r,n),r.subtreeFlags=0,n=l,l=r.child;l!==null;)ig(l,n),l=l.sibling;return k(_i,_i.current&1|2),yt&&$r(r,u.treeForkCount),r.child}n=n.sibling}u.tail!==null&&St()>Mc&&(r.flags|=128,m=!0,Wl(u,!1),r.lanes=4194304)}else{if(!m)if(n=mc(x),n!==null){if(r.flags|=128,m=!0,n=n.updateQueue,r.updateQueue=n,jc(r,n),Wl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!x.alternate&&!yt)return Jt(r),null}else 2*St()-u.renderingStartTime>Mc&&l!==536870912&&(r.flags|=128,m=!0,Wl(u,!1),r.lanes=4194304);u.isBackwards?(x.sibling=r.child,r.child=x):(n=u.last,n!==null?n.sibling=x:r.child=x,u.last=x)}return u.tail!==null?(n=u.tail,u.rendering=n,u.tail=n.sibling,u.renderingStartTime=St(),n.sibling=null,l=_i.current,k(_i,m?l&1|2:l&1),yt&&$r(r,u.treeForkCount),n):(Jt(r),null);case 22:case 23:return $n(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&&(Jt(r),r.subtreeFlags&6&&(r.flags|=8192)):Jt(r),l=r.updateQueue,l!==null&&jc(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&&Z(ta),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),qr(ki),Jt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function bw(n,r){switch(ph(r),r.tag){case 1:return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return qr(ki),_e(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 26:case 27:case 5:return Oe(r),null;case 31:if(r.memoizedState!==null){if($n(r),r.alternate===null)throw Error(s(340));Qs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 13:if($n(r),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Qs()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Z(_i),null;case 4:return _e(),null;case 10:return qr(r.type),null;case 22:case 23:return $n(r),Th(),n!==null&&Z(ta),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 24:return qr(ki),null;case 25:return null;default:return null}}function Tx(n,r){switch(ph(r),r.tag){case 3:qr(ki),_e();break;case 26:case 27:case 5:Oe(r);break;case 4:_e();break;case 31:r.memoizedState!==null&&$n(r);break;case 13:$n(r);break;case 19:Z(_i);break;case 10:qr(r.type);break;case 22:case 23:$n(r),Th(),n!==null&&Z(ta);break;case 24:qr(ki)}}function Gl(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 x=l.create,y=l.inst;u=x(),y.destroy=u}l=l.next}while(l!==m)}}catch(C){Bt(r,r.return,C)}}function Ss(n,r,l){try{var u=r.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var x=m.next;u=x;do{if((u.tag&n)===n){var y=u.inst,C=y.destroy;if(C!==void 0){y.destroy=void 0,m=r;var O=l,J=C;try{J()}catch(ce){Bt(m,O,ce)}}}u=u.next}while(u!==x)}}catch(ce){Bt(r,r.return,ce)}}function Ax(n){var r=n.updateQueue;if(r!==null){var l=n.stateNode;try{vg(r,l)}catch(u){Bt(n,n.return,u)}}}function Rx(n,r,l){l.props=aa(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(u){Bt(n,r,u)}}function Yl(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){Bt(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){Bt(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){Bt(n,r,m)}else l.current=null}function Dx(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){Bt(n,n.return,m)}}function ld(n,r,l){try{var u=n.stateNode;Uw(u,n.type,l,r),u[At]=r}catch(m){Bt(n,n.return,m)}}function Mx(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Ts(n.type)||n.tag===4}function od(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Mx(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&&Ts(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 cd(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=gn));else if(u!==4&&(u===27&&Ts(n.type)&&(l=n.stateNode,r=null),n=n.child,n!==null))for(cd(n,r,l),n=n.sibling;n!==null;)cd(n,r,l),n=n.sibling}function Tc(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&&Ts(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(Tc(n,r,l),n=n.sibling;n!==null;)Tc(n,r,l),n=n.sibling}function Bx(n){var r=n.stateNode,l=n.memoizedProps;try{for(var u=n.type,m=r.attributes;m.length;)r.removeAttributeNode(m[0]);rn(r,u,l),r[Xt]=n,r[At]=l}catch(x){Bt(n,n.return,x)}}var Kr=!1,ji=!1,ud=!1,Lx=typeof WeakSet=="function"?WeakSet:Set,Fi=null;function vw(n,r){if(n=n.containerInfo,Rd=Xc,n=Ym(n),nh(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,x=u.focusNode;u=u.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var y=0,C=-1,O=-1,J=0,ce=0,fe=n,te=null;t:for(;;){for(var le;fe!==l||m!==0&&fe.nodeType!==3||(C=y+m),fe!==x||u!==0&&fe.nodeType!==3||(O=y+u),fe.nodeType===3&&(y+=fe.nodeValue.length),(le=fe.firstChild)!==null;)te=fe,fe=le;for(;;){if(fe===n)break t;if(te===l&&++J===m&&(C=y),te===x&&++ce===u&&(O=y),(le=fe.nextSibling)!==null)break;fe=te,te=fe.parentNode}fe=le}l=C===-1||O===-1?null:{start:C,end:O}}else l=null}l=l||{start:0,end:0}}else l=null;for(Dd={focusedElem:n,selectionRange:l},Xc=!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,x=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&&x!==null){n=void 0,l=r,m=x.memoizedProps,x=x.memoizedState,u=l.stateNode;try{var Le=aa(l.type,m);n=u.getSnapshotBeforeUpdate(Le,x),u.__reactInternalSnapshotBeforeUpdate=n}catch(qe){Bt(l,l.return,qe)}}break;case 3:if((n&1024)!==0){if(n=r.stateNode.containerInfo,l=n.nodeType,l===9)Ld(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Ld(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 Ox(n,r,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:Zr(n,l),u&4&&Gl(5,l);break;case 1:if(Zr(n,l),u&4)if(n=l.stateNode,r===null)try{n.componentDidMount()}catch(y){Bt(l,l.return,y)}else{var m=aa(l.type,r.memoizedProps);r=r.memoizedState;try{n.componentDidUpdate(m,r,n.__reactInternalSnapshotBeforeUpdate)}catch(y){Bt(l,l.return,y)}}u&64&&Ax(l),u&512&&Yl(l,l.return);break;case 3:if(Zr(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{vg(n,r)}catch(y){Bt(l,l.return,y)}}break;case 27:r===null&&u&4&&Bx(l);case 26:case 5:Zr(n,l),r===null&&u&4&&Dx(l),u&512&&Yl(l,l.return);break;case 12:Zr(n,l);break;case 31:Zr(n,l),u&4&&Ix(n,l);break;case 13:Zr(n,l),u&4&&Hx(n,l),u&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=Tw.bind(null,l),Kw(n,l))));break;case 22:if(u=l.memoizedState!==null||Kr,!u){r=r!==null&&r.memoizedState!==null||ji,m=Kr;var x=ji;Kr=u,(ji=r)&&!x?Qr(n,l,(l.subtreeFlags&8772)!==0):Zr(n,l),Kr=m,ji=x}break;case 30:break;default:Zr(n,l)}}function zx(n){var r=n.alternate;r!==null&&(n.alternate=null,zx(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&Ne(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 ti=null,Nn=!1;function Xr(n,r,l){for(l=l.child;l!==null;)Px(n,r,l),l=l.sibling}function Px(n,r,l){if(Et&&typeof Et.onCommitFiberUnmount=="function")try{Et.onCommitFiberUnmount(Lt,l)}catch{}switch(l.tag){case 26:ji||Cr(l,r),Xr(n,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:ji||Cr(l,r);var u=ti,m=Nn;Ts(l.type)&&(ti=l.stateNode,Nn=!1),Xr(n,r,l),io(l.stateNode),ti=u,Nn=m;break;case 5:ji||Cr(l,r);case 6:if(u=ti,m=Nn,ti=null,Xr(n,r,l),ti=u,Nn=m,ti!==null)if(Nn)try{(ti.nodeType===9?ti.body:ti.nodeName==="HTML"?ti.ownerDocument.body:ti).removeChild(l.stateNode)}catch(x){Bt(l,r,x)}else try{ti.removeChild(l.stateNode)}catch(x){Bt(l,r,x)}break;case 18:ti!==null&&(Nn?(n=ti,A_(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),el(n)):A_(ti,l.stateNode));break;case 4:u=ti,m=Nn,ti=l.stateNode.containerInfo,Nn=!0,Xr(n,r,l),ti=u,Nn=m;break;case 0:case 11:case 14:case 15:Ss(2,l,r),ji||Ss(4,l,r),Xr(n,r,l);break;case 1:ji||(Cr(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"&&Rx(l,r,u)),Xr(n,r,l);break;case 21:Xr(n,r,l);break;case 22:ji=(u=ji)||l.memoizedState!==null,Xr(n,r,l),ji=u;break;default:Xr(n,r,l)}}function Ix(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{el(n)}catch(l){Bt(r,r.return,l)}}}function Hx(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{el(n)}catch(l){Bt(r,r.return,l)}}function yw(n){switch(n.tag){case 31:case 13:case 19:var r=n.stateNode;return r===null&&(r=n.stateNode=new Lx),r;case 22:return n=n.stateNode,r=n._retryCache,r===null&&(r=n._retryCache=new Lx),r;default:throw Error(s(435,n.tag))}}function Ac(n,r){var l=yw(n);r.forEach(function(u){if(!l.has(u)){l.add(u);var m=Aw.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],x=n,y=r,C=y;e:for(;C!==null;){switch(C.tag){case 27:if(Ts(C.type)){ti=C.stateNode,Nn=!1;break e}break;case 5:ti=C.stateNode,Nn=!1;break e;case 3:case 4:ti=C.stateNode.containerInfo,Nn=!0;break e}C=C.return}if(ti===null)throw Error(s(160));Px(x,y,m),ti=null,Nn=!1,x=m.alternate,x!==null&&(x.return=null),m.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)Ux(r,n),r=r.sibling}var gr=null;function Ux(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:jn(r,n),Tn(n),u&4&&(Ss(3,n,n.return),Gl(3,n),Ss(5,n,n.return));break;case 1:jn(r,n),Tn(n),u&512&&(ji||l===null||Cr(l,l.return)),u&64&&Kr&&(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=gr;if(jn(r,n),Tn(n),u&512&&(ji||l===null||Cr(l,l.return)),u&4){var x=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":x=m.getElementsByTagName("title")[0],(!x||x[Se]||x[Xt]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=m.createElement(u),m.head.insertBefore(x,m.querySelector("head > title"))),rn(x,u,l),x[Xt]=n,Ze(x),u=x;break e;case"link":var y=U_("link","href",m).get(u+(l.href||""));if(y){for(var C=0;C<y.length;C++)if(x=y[C],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){y.splice(C,1);break t}}x=m.createElement(u),rn(x,u,l),m.head.appendChild(x);break;case"meta":if(y=U_("meta","content",m).get(u+(l.content||""))){for(C=0;C<y.length;C++)if(x=y[C],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){y.splice(C,1);break t}}x=m.createElement(u),rn(x,u,l),m.head.appendChild(x);break;default:throw Error(s(468,u))}x[Xt]=n,Ze(x),u=x}n.stateNode=u}else $_(m,n.type,n.stateNode);else n.stateNode=H_(m,u,n.memoizedProps);else x!==u?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,u===null?$_(m,n.type,n.stateNode):H_(m,u,n.memoizedProps)):u===null&&n.stateNode!==null&&ld(n,n.memoizedProps,l.memoizedProps)}break;case 27:jn(r,n),Tn(n),u&512&&(ji||l===null||Cr(l,l.return)),l!==null&&u&4&&ld(n,n.memoizedProps,l.memoizedProps);break;case 5:if(jn(r,n),Tn(n),u&512&&(ji||l===null||Cr(l,l.return)),n.flags&32){m=n.stateNode;try{Pn(m,"")}catch(Le){Bt(n,n.return,Le)}}u&4&&n.stateNode!=null&&(m=n.memoizedProps,ld(n,m,l!==null?l.memoizedProps:m)),u&1024&&(ud=!0);break;case 6:if(jn(r,n),Tn(n),u&4){if(n.stateNode===null)throw Error(s(162));u=n.memoizedProps,l=n.stateNode;try{l.nodeValue=u}catch(Le){Bt(n,n.return,Le)}}break;case 3:if(Gc=null,m=gr,gr=qc(r.containerInfo),jn(r,n),gr=m,Tn(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{el(r.containerInfo)}catch(Le){Bt(n,n.return,Le)}ud&&(ud=!1,$x(n));break;case 4:u=gr,gr=qc(n.stateNode.containerInfo),jn(r,n),Tn(n),gr=u;break;case 12:jn(r,n),Tn(n);break;case 31:jn(r,n),Tn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Ac(n,u)));break;case 13:jn(r,n),Tn(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Dc=St()),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Ac(n,u)));break;case 22:m=n.memoizedState!==null;var O=l!==null&&l.memoizedState!==null,J=Kr,ce=ji;if(Kr=J||m,ji=ce||O,jn(r,n),ji=ce,Kr=J,Tn(n),u&8192)e:for(r=n.stateNode,r._visibility=m?r._visibility&-2:r._visibility|1,m&&(l===null||O||Kr||ji||la(n)),l=null,r=n;;){if(r.tag===5||r.tag===26){if(l===null){O=l=r;try{if(x=O.stateNode,m)y=x.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{C=O.stateNode;var fe=O.memoizedProps.style,te=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;C.style.display=te==null||typeof te=="boolean"?"":(""+te).trim()}}catch(Le){Bt(O,O.return,Le)}}}else if(r.tag===6){if(l===null){O=r;try{O.stateNode.nodeValue=m?"":O.memoizedProps}catch(Le){Bt(O,O.return,Le)}}}else if(r.tag===18){if(l===null){O=r;try{var le=O.stateNode;m?R_(le,!0):R_(O.stateNode,!1)}catch(Le){Bt(O,O.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,Ac(n,l))));break;case 19:jn(r,n),Tn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Ac(n,u)));break;case 30:break;case 21:break;default:jn(r,n),Tn(n)}}function Tn(n){var r=n.flags;if(r&2){try{for(var l,u=n.return;u!==null;){if(Mx(u)){l=u;break}u=u.return}if(l==null)throw Error(s(160));switch(l.tag){case 27:var m=l.stateNode,x=od(n);Tc(n,x,m);break;case 5:var y=l.stateNode;l.flags&32&&(Pn(y,""),l.flags&=-33);var C=od(n);Tc(n,C,y);break;case 3:case 4:var O=l.stateNode.containerInfo,J=od(n);cd(n,J,O);break;default:throw Error(s(161))}}catch(ce){Bt(n,n.return,ce)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function $x(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var r=n;$x(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),n=n.sibling}}function Zr(n,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Ox(n,r.alternate,r),r=r.sibling}function la(n){for(n=n.child;n!==null;){var r=n;switch(r.tag){case 0:case 11:case 14:case 15:Ss(4,r,r.return),la(r);break;case 1:Cr(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&Rx(r,r.return,l),la(r);break;case 27:io(r.stateNode);case 26:case 5:Cr(r,r.return),la(r);break;case 22:r.memoizedState===null&&la(r);break;case 30:la(r);break;default:la(r)}n=n.sibling}}function Qr(n,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,m=n,x=r,y=x.flags;switch(x.tag){case 0:case 11:case 15:Qr(m,x,l),Gl(4,x);break;case 1:if(Qr(m,x,l),u=x,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(J){Bt(u,u.return,J)}if(u=x,m=u.updateQueue,m!==null){var C=u.stateNode;try{var O=m.shared.hiddenCallbacks;if(O!==null)for(m.shared.hiddenCallbacks=null,m=0;m<O.length;m++)bg(O[m],C)}catch(J){Bt(u,u.return,J)}}l&&y&64&&Ax(x),Yl(x,x.return);break;case 27:Bx(x);case 26:case 5:Qr(m,x,l),l&&u===null&&y&4&&Dx(x),Yl(x,x.return);break;case 12:Qr(m,x,l);break;case 31:Qr(m,x,l),l&&y&4&&Ix(m,x);break;case 13:Qr(m,x,l),l&&y&4&&Hx(m,x);break;case 22:x.memoizedState===null&&Qr(m,x,l),Yl(x,x.return);break;case 30:break;default:Qr(m,x,l)}r=r.sibling}}function hd(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&&Ml(l))}function dd(n,r){n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&Ml(n))}function xr(n,r,l,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Fx(n,r,l,u),r=r.sibling}function Fx(n,r,l,u){var m=r.flags;switch(r.tag){case 0:case 11:case 15:xr(n,r,l,u),m&2048&&Gl(9,r);break;case 1:xr(n,r,l,u);break;case 3:xr(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&&Ml(n)));break;case 12:if(m&2048){xr(n,r,l,u),n=r.stateNode;try{var x=r.memoizedProps,y=x.id,C=x.onPostCommit;typeof C=="function"&&C(y,r.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(O){Bt(r,r.return,O)}}else xr(n,r,l,u);break;case 31:xr(n,r,l,u);break;case 13:xr(n,r,l,u);break;case 23:break;case 22:x=r.stateNode,y=r.alternate,r.memoizedState!==null?x._visibility&2?xr(n,r,l,u):Vl(n,r):x._visibility&2?xr(n,r,l,u):(x._visibility|=2,Fa(n,r,l,u,(r.subtreeFlags&10256)!==0||!1)),m&2048&&hd(y,r);break;case 24:xr(n,r,l,u),m&2048&&dd(r.alternate,r);break;default:xr(n,r,l,u)}}function Fa(n,r,l,u,m){for(m=m&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var x=n,y=r,C=l,O=u,J=y.flags;switch(y.tag){case 0:case 11:case 15:Fa(x,y,C,O,m),Gl(8,y);break;case 23:break;case 22:var ce=y.stateNode;y.memoizedState!==null?ce._visibility&2?Fa(x,y,C,O,m):Vl(x,y):(ce._visibility|=2,Fa(x,y,C,O,m)),m&&J&2048&&hd(y.alternate,y);break;case 24:Fa(x,y,C,O,m),m&&J&2048&&dd(y.alternate,y);break;default:Fa(x,y,C,O,m)}r=r.sibling}}function Vl(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:Vl(l,u),m&2048&&hd(u.alternate,u);break;case 24:Vl(l,u),m&2048&&dd(u.alternate,u);break;default:Vl(l,u)}r=r.sibling}}var Kl=8192;function qa(n,r,l){if(n.subtreeFlags&Kl)for(n=n.child;n!==null;)qx(n,r,l),n=n.sibling}function qx(n,r,l){switch(n.tag){case 26:qa(n,r,l),n.flags&Kl&&n.memoizedState!==null&&lC(l,gr,n.memoizedState,n.memoizedProps);break;case 5:qa(n,r,l);break;case 3:case 4:var u=gr;gr=qc(n.stateNode.containerInfo),qa(n,r,l),gr=u;break;case 22:n.memoizedState===null&&(u=n.alternate,u!==null&&u.memoizedState!==null?(u=Kl,Kl=16777216,qa(n,r,l),Kl=u):qa(n,r,l));break;default:qa(n,r,l)}}function Wx(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 Xl(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,Yx(u,n)}Wx(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Gx(n),n=n.sibling}function Gx(n){switch(n.tag){case 0:case 11:case 15:Xl(n),n.flags&2048&&Ss(9,n,n.return);break;case 3:Xl(n);break;case 12:Xl(n);break;case 22:var r=n.stateNode;n.memoizedState!==null&&r._visibility&2&&(n.return===null||n.return.tag!==13)?(r._visibility&=-3,Rc(n)):Xl(n);break;default:Xl(n)}}function Rc(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,Yx(u,n)}Wx(n)}for(n=n.child;n!==null;){switch(r=n,r.tag){case 0:case 11:case 15:Ss(8,r,r.return),Rc(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,Rc(r));break;default:Rc(r)}n=n.sibling}}function Yx(n,r){for(;Fi!==null;){var l=Fi;switch(l.tag){case 0:case 11:case 15:Ss(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:Ml(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,x=u.return;if(zx(u),u===l){Fi=null;break e}if(m!==null){m.return=x,Fi=m;break e}Fi=x}}}var Sw={getCacheForType:function(n){var r=tn(ki),l=r.data.get(n);return l===void 0&&(l=n(),r.data.set(n,l)),l},cacheSignal:function(){return tn(ki).controller.signal}},ww=typeof WeakMap=="function"?WeakMap:Map,Rt=0,qt=null,mt=null,_t=0,Mt=0,Fn=null,ws=!1,Wa=!1,fd=!1,Jr=0,ui=0,Cs=0,oa=0,pd=0,qn=0,Ga=0,Zl=null,An=null,md=!1,Dc=0,Vx=0,Mc=1/0,Bc=null,ks=null,Oi=0,Es=null,Ya=null,es=0,gd=0,xd=null,Kx=null,Ql=0,_d=null;function Wn(){return(Rt&2)!==0&&_t!==0?_t&-_t:T.T!==null?Cd():Mi()}function Xx(){if(qn===0)if((_t&536870912)===0||yt){var n=ni;ni<<=1,(ni&3932160)===0&&(ni=262144),qn=n}else qn=536870912;return n=Un.current,n!==null&&(n.flags|=32),qn}function Rn(n,r,l){(n===qt&&(Mt===2||Mt===9)||n.cancelPendingCommit!==null)&&(Va(n,0),Ns(n,_t,qn,!1)),Dt(n,l),((Rt&2)===0||n!==qt)&&(n===qt&&((Rt&2)===0&&(oa|=l),ui===4&&Ns(n,_t,qn,!1)),kr(n))}function Zx(n,r,l){if((Rt&6)!==0)throw Error(s(327));var u=!l&&(r&127)===0&&(r&n.expiredLanes)===0||Ee(n,r),m=u?Ew(n,r):vd(n,r,!0),x=u;do{if(m===0){Wa&&!u&&Ns(n,r,0,!1);break}else{if(l=n.current.alternate,x&&!Cw(l)){m=vd(n,r,!1),x=!1;continue}if(m===2){if(x=r,n.errorRecoveryDisabledLanes&x)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=Zl;var O=C.current.memoizedState.isDehydrated;if(O&&(Va(C,y).flags|=256),y=vd(C,y,!1),y!==2){if(fd&&!O){C.errorRecoveryDisabledLanes|=x,oa|=x,m=4;break e}x=An,An=m,x!==null&&(An===null?An=x:An.push.apply(An,x))}m=y}if(x=!1,m!==2)continue}}if(m===1){Va(n,0),Ns(n,r,0,!0);break}e:{switch(u=n,x=m,x){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:Ns(u,r,qn,!ws);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(m=Dc+300-St(),10<m)){if(Ns(u,r,qn,!ws),Ie(u,0,!0)!==0)break e;es=r,u.timeoutHandle=j_(Qx.bind(null,u,l,An,Bc,md,r,qn,oa,Ga,ws,x,"Throttled",-0,0),m);break e}Qx(u,l,An,Bc,md,r,qn,oa,Ga,ws,x,null,-0,0)}}break}while(!0);kr(n)}function Qx(n,r,l,u,m,x,y,C,O,J,ce,fe,te,le){if(n.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gn},qx(r,x,fe);var Le=(x&62914560)===x?Dc-St():(x&4194048)===x?Vx-St():0;if(Le=oC(fe,Le),Le!==null){es=x,n.cancelPendingCommit=Le(a_.bind(null,n,r,x,l,u,m,y,C,O,ce,fe,null,te,le)),Ns(n,x,y,!J);return}}a_(n,r,x,l,u,m,y,C,O)}function Cw(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],x=m.getSnapshot;m=m.value;try{if(!In(x(),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 Ns(n,r,l,u){r&=~pd,r&=~oa,n.suspendedLanes|=r,n.pingedLanes&=~r,u&&(n.warmLanes|=r),u=n.expirationTimes;for(var m=r;0<m;){var x=31-ut(m),y=1<<x;u[x]=-1,m&=~y}l!==0&&pt(n,l,r)}function Lc(){return(Rt&6)===0?(Jl(0),!1):!0}function bd(){if(mt!==null){if(Mt===0)var n=mt.return;else n=mt,Fr=Js=null,Lh(n),Pa=null,Ll=0,n=mt;for(;n!==null;)Tx(n.alternate,n),n=n.return;mt=null}}function Va(n,r){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,qw(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),es=0,bd(),qt=n,mt=l=Ur(n.current,null),_t=r,Mt=0,Fn=null,ws=!1,Wa=Ee(n,r),fd=!1,Ga=qn=pd=oa=Cs=ui=0,An=Zl=null,md=!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-ut(u),x=1<<m;r|=n[m],u&=~x}return Jr=r,ic(),l}function Jx(n,r){st=null,T.H=Fl,r===za||r===uc?(r=mg(),Mt=3):r===wh?(r=mg(),Mt=4):Mt=r===Zh?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Fn=r,mt===null&&(ui=1,Cc(n,er(r,n.current)))}function e_(){var n=Un.current;return n===null?!0:(_t&4194048)===_t?rr===null:(_t&62914560)===_t||(_t&536870912)!==0?n===rr:!1}function t_(){var n=T.H;return T.H=Fl,n===null?Fl:n}function i_(){var n=T.A;return T.A=Sw,n}function Oc(){ui=4,ws||(_t&4194048)!==_t&&Un.current!==null||(Wa=!0),(Cs&134217727)===0&&(oa&134217727)===0||qt===null||Ns(qt,_t,qn,!1)}function vd(n,r,l){var u=Rt;Rt|=2;var m=t_(),x=i_();(qt!==n||_t!==r)&&(Bc=null,Va(n,r)),r=!1;var y=ui;e:do try{if(Mt!==0&&mt!==null){var C=mt,O=Fn;switch(Mt){case 8:bd(),y=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(r=!0);var J=Mt;if(Mt=0,Fn=null,Ka(n,C,O,J),l&&Wa){y=0;break e}break;default:J=Mt,Mt=0,Fn=null,Ka(n,C,O,J)}}kw(),y=ui;break}catch(ce){Jx(n,ce)}while(!0);return r&&n.shellSuspendCounter++,Fr=Js=null,Rt=u,T.H=m,T.A=x,mt===null&&(qt=null,_t=0,ic()),y}function kw(){for(;mt!==null;)n_(mt)}function Ew(n,r){var l=Rt;Rt|=2;var u=t_(),m=i_();qt!==n||_t!==r?(Bc=null,Mc=St()+500,Va(n,r)):Wa=Ee(n,r);e:do try{if(Mt!==0&&mt!==null){r=mt;var x=Fn;t:switch(Mt){case 1:Mt=0,Fn=null,Ka(n,r,x,1);break;case 2:case 9:if(fg(x)){Mt=0,Fn=null,r_(r);break}r=function(){Mt!==2&&Mt!==9||qt!==n||(Mt=7),kr(n)},x.then(r,r);break e;case 3:Mt=7;break e;case 4:Mt=5;break e;case 7:fg(x)?(Mt=0,Fn=null,r_(r)):(Mt=0,Fn=null,Ka(n,r,x,7));break;case 5:var y=null;switch(mt.tag){case 26:y=mt.memoizedState;case 5:case 27:var C=mt;if(y?F_(y):C.stateNode.complete){Mt=0,Fn=null;var O=C.sibling;if(O!==null)mt=O;else{var J=C.return;J!==null?(mt=J,zc(J)):mt=null}break t}}Mt=0,Fn=null,Ka(n,r,x,5);break;case 6:Mt=0,Fn=null,Ka(n,r,x,6);break;case 8:bd(),ui=6;break e;default:throw Error(s(462))}}Nw();break}catch(ce){Jx(n,ce)}while(!0);return Fr=Js=null,T.H=u,T.A=m,Rt=l,mt!==null?0:(qt=null,_t=0,ic(),ui)}function Nw(){for(;mt!==null&&!pi();)n_(mt)}function n_(n){var r=Nx(n.alternate,n,Jr);n.memoizedProps=n.pendingProps,r===null?zc(n):mt=r}function r_(n){var r=n,l=r.alternate;switch(r.tag){case 15:case 0:r=yx(l,r,r.pendingProps,r.type,void 0,_t);break;case 11:r=yx(l,r,r.pendingProps,r.type.render,r.ref,_t);break;case 5:Lh(r);default:Tx(l,r),r=mt=ig(r,Jr),r=Nx(l,r,Jr)}n.memoizedProps=n.pendingProps,r===null?zc(n):mt=r}function Ka(n,r,l,u){Fr=Js=null,Lh(r),Pa=null,Ll=0;var m=r.return;try{if(mw(n,m,r,l,_t)){ui=1,Cc(n,er(l,n.current)),mt=null;return}}catch(x){if(m!==null)throw mt=m,x;ui=1,Cc(n,er(l,n.current)),mt=null;return}r.flags&32768?(yt||u===1?n=!0:Wa||(_t&536870912)!==0?n=!1:(ws=n=!0,(u===2||u===9||u===3||u===6)&&(u=Un.current,u!==null&&u.tag===13&&(u.flags|=16384))),s_(r,n)):zc(r)}function zc(n){var r=n;do{if((r.flags&32768)!==0){s_(r,ws);return}n=r.return;var l=_w(r.alternate,r,Jr);if(l!==null){mt=l;return}if(r=r.sibling,r!==null){mt=r;return}mt=r=n}while(r!==null);ui===0&&(ui=5)}function s_(n,r){do{var l=bw(n.alternate,n);if(l!==null){l.flags&=32767,mt=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(n=n.sibling,n!==null)){mt=n;return}mt=n=l}while(n!==null);ui=6,mt=null}function a_(n,r,l,u,m,x,y,C,O){n.cancelPendingCommit=null;do Pc();while(Oi!==0);if((Rt&6)!==0)throw Error(s(327));if(r!==null){if(r===n.current)throw Error(s(177));if(x=r.lanes|r.childLanes,x|=oh,ft(n,l,x,y,C,O),n===qt&&(mt=qt=null,_t=0),Ya=r,Es=n,es=l,gd=x,xd=m,Kx=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,Rw(Te,function(){return h_(),null})):(n.callbackNode=null,n.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=T.T,T.T=null,m=q.p,q.p=2,y=Rt,Rt|=4;try{vw(n,r,l)}finally{Rt=y,q.p=m,T.T=u}}Oi=1,l_(),o_(),c_()}}function l_(){if(Oi===1){Oi=0;var n=Es,r=Ya,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=T.T,T.T=null;var u=q.p;q.p=2;var m=Rt;Rt|=4;try{Ux(r,n);var x=Dd,y=Ym(n.containerInfo),C=x.focusedElem,O=x.selectionRange;if(y!==C&&C&&C.ownerDocument&&Gm(C.ownerDocument.documentElement,C)){if(O!==null&&nh(C)){var J=O.start,ce=O.end;if(ce===void 0&&(ce=J),"selectionStart"in C)C.selectionStart=J,C.selectionEnd=Math.min(ce,C.value.length);else{var fe=C.ownerDocument||document,te=fe&&fe.defaultView||window;if(te.getSelection){var le=te.getSelection(),Le=C.textContent.length,qe=Math.min(O.start,Le),Ht=O.end===void 0?qe:Math.min(O.end,Le);!le.extend&&qe>Ht&&(y=Ht,Ht=qe,qe=y);var G=Wm(C,qe),P=Wm(C,Ht);if(G&&P&&(le.rangeCount!==1||le.anchorNode!==G.node||le.anchorOffset!==G.offset||le.focusNode!==P.node||le.focusOffset!==P.offset)){var Q=fe.createRange();Q.setStart(G.node,G.offset),le.removeAllRanges(),qe>Ht?(le.addRange(Q),le.extend(P.node,P.offset)):(Q.setEnd(P.node,P.offset),le.addRange(Q))}}}}for(fe=[],le=C;le=le.parentNode;)le.nodeType===1&&fe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<fe.length;C++){var de=fe[C];de.element.scrollLeft=de.left,de.element.scrollTop=de.top}}Xc=!!Rd,Dd=Rd=null}finally{Rt=m,q.p=u,T.T=l}}n.current=r,Oi=2}}function o_(){if(Oi===2){Oi=0;var n=Es,r=Ya,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=T.T,T.T=null;var u=q.p;q.p=2;var m=Rt;Rt|=4;try{Ox(n,r.alternate,r)}finally{Rt=m,q.p=u,T.T=l}}Oi=3}}function c_(){if(Oi===4||Oi===3){Oi=0,Me();var n=Es,r=Ya,l=es,u=Kx;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Oi=5:(Oi=0,Ya=Es=null,u_(n,n.pendingLanes));var m=n.pendingLanes;if(m===0&&(ks=null),Ui(l),r=r.stateNode,Et&&typeof Et.onCommitFiberRoot=="function")try{Et.onCommitFiberRoot(Lt,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=T.T,m=q.p,q.p=2,T.T=null;try{for(var x=n.onRecoverableError,y=0;y<u.length;y++){var C=u[y];x(C.value,{componentStack:C.stack})}}finally{T.T=r,q.p=m}}(es&3)!==0&&Pc(),kr(n),m=n.pendingLanes,(l&261930)!==0&&(m&42)!==0?n===_d?Ql++:(Ql=0,_d=n):Ql=0,Jl(0)}}function u_(n,r){(n.pooledCacheLanes&=r)===0&&(r=n.pooledCache,r!=null&&(n.pooledCache=null,Ml(r)))}function Pc(){return l_(),o_(),c_(),h_()}function h_(){if(Oi!==5)return!1;var n=Es,r=gd;gd=0;var l=Ui(es),u=T.T,m=q.p;try{q.p=32>l?32:l,T.T=null,l=xd,xd=null;var x=Es,y=es;if(Oi=0,Ya=Es=null,es=0,(Rt&6)!==0)throw Error(s(331));var C=Rt;if(Rt|=4,Gx(x.current),Fx(x,x.current,y,l),Rt=C,Jl(0,!1),Et&&typeof Et.onPostCommitFiberRoot=="function")try{Et.onPostCommitFiberRoot(Lt,x)}catch{}return!0}finally{q.p=m,T.T=u,u_(n,r)}}function d_(n,r,l){r=er(l,r),r=Xh(n.stateNode,r,2),n=bs(n,r,2),n!==null&&(Dt(n,2),kr(n))}function Bt(n,r,l){if(n.tag===3)d_(n,n,l);else for(;r!==null;){if(r.tag===3){d_(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ks===null||!ks.has(u))){n=er(l,n),l=fx(2),u=bs(r,l,2),u!==null&&(px(l,u,r,n),Dt(u,2),kr(u));break}}r=r.return}}function yd(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new ww;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)||(fd=!0,m.add(l),n=jw.bind(null,n,r,l),r.then(n,n))}function jw(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,qt===n&&(_t&l)===l&&(ui===4||ui===3&&(_t&62914560)===_t&&300>St()-Dc?(Rt&2)===0&&Va(n,0):pd|=l,Ga===_t&&(Ga=0)),kr(n)}function f_(n,r){r===0&&(r=rt()),n=Xs(n,r),n!==null&&(Dt(n,r),kr(n))}function Tw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),f_(n,l)}function Aw(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),f_(n,l)}function Rw(n,r){return Nt(n,r)}var Ic=null,Xa=null,Sd=!1,Hc=!1,wd=!1,js=0;function kr(n){n!==Xa&&n.next===null&&(Xa===null?Ic=Xa=n:Xa=Xa.next=n),Hc=!0,Sd||(Sd=!0,Mw())}function Jl(n,r){if(!wd&&Hc){wd=!0;do for(var l=!1,u=Ic;u!==null;){if(n!==0){var m=u.pendingLanes;if(m===0)var x=0;else{var y=u.suspendedLanes,C=u.pingedLanes;x=(1<<31-ut(42|n)+1)-1,x&=m&~(y&~C),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,x_(u,x))}else x=_t,x=Ie(u,u===qt?x:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(x&3)===0||Ee(u,x)||(l=!0,x_(u,x));u=u.next}while(l);wd=!1}}function Dw(){p_()}function p_(){Hc=Sd=!1;var n=0;js!==0&&Fw()&&(n=js);for(var r=St(),l=null,u=Ic;u!==null;){var m=u.next,x=m_(u,r);x===0?(u.next=null,l===null?Ic=m:l.next=m,m===null&&(Xa=l)):(l=u,(n!==0||(x&3)!==0)&&(Hc=!0)),u=m}Oi!==0&&Oi!==5||Jl(n),js!==0&&(js=0)}function m_(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,m=n.expirationTimes,x=n.pendingLanes&-62914561;0<x;){var y=31-ut(x),C=1<<y,O=m[y];O===-1?((C&l)===0||(C&u)!==0)&&(m[y]=Qe(C,r)):O<=r&&(n.expiredLanes|=C),x&=~C}if(r=qt,l=_t,l=Ie(n,n===r?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u=n.callbackNode,l===0||n===r&&(Mt===2||Mt===9)||n.cancelPendingCommit!==null)return u!==null&&u!==null&&kt(u),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||Ee(n,l)){if(r=l&-l,r===n.callbackPriority)return r;switch(u!==null&&kt(u),Ui(l)){case 2:case 8:l=xe;break;case 32:l=Te;break;case 268435456:l=Ye;break;default:l=Te}return u=g_.bind(null,n),l=Nt(l,u),n.callbackPriority=r,n.callbackNode=l,r}return u!==null&&u!==null&&kt(u),n.callbackPriority=2,n.callbackNode=null,2}function g_(n,r){if(Oi!==0&&Oi!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(Pc()&&n.callbackNode!==l)return null;var u=_t;return u=Ie(n,n===qt?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u===0?null:(Zx(n,u,r),m_(n,St()),n.callbackNode!=null&&n.callbackNode===l?g_.bind(null,n):null)}function x_(n,r){if(Pc())return null;Zx(n,r,!0)}function Mw(){Ww(function(){(Rt&6)!==0?Nt(ee,Dw):p_()})}function Cd(){if(js===0){var n=La;n===0&&(n=Yt,Yt<<=1,(Yt&261888)===0&&(Yt=256)),js=n}return js}function __(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Ys(""+n)}function b_(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 Bw(n,r,l,u,m){if(r==="submit"&&l&&l.stateNode===m){var x=__((m[At]||null).action),y=u.submitter;y&&(r=(r=y[At]||null)?__(r.formAction):y.getAttribute("formAction"),r!==null&&(x=r,y=null));var C=new Qn("action","action",null,u,m);n.push({event:C,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(js!==0){var O=y?b_(m,y):new FormData(m);qh(l,{pending:!0,data:O,method:m.method,action:x},null,O)}}else typeof x=="function"&&(C.preventDefault(),O=y?b_(m,y):new FormData(m),qh(l,{pending:!0,data:O,method:m.method,action:x},x,O))},currentTarget:m}]})}}for(var kd=0;kd<lh.length;kd++){var Ed=lh[kd],Lw=Ed.toLowerCase(),Ow=Ed[0].toUpperCase()+Ed.slice(1);mr(Lw,"on"+Ow)}mr(Xm,"onAnimationEnd"),mr(Zm,"onAnimationIteration"),mr(Qm,"onAnimationStart"),mr("dblclick","onDoubleClick"),mr("focusin","onFocus"),mr("focusout","onBlur"),mr(Q1,"onTransitionRun"),mr(J1,"onTransitionStart"),mr(ew,"onTransitionCancel"),mr(Jm,"onTransitionEnd"),Bi("onMouseEnter",["mouseout","mouseover"]),Bi("onMouseLeave",["mouseout","mouseover"]),Bi("onPointerEnter",["pointerout","pointerover"]),Bi("onPointerLeave",["pointerout","pointerover"]),mn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),mn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),mn("onBeforeInput",["compositionend","keypress","textInput","paste"]),mn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),mn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),mn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var eo="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(" "),zw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(eo));function v_(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 x=void 0;if(r)for(var y=u.length-1;0<=y;y--){var C=u[y],O=C.instance,J=C.currentTarget;if(C=C.listener,O!==x&&m.isPropagationStopped())break e;x=C,m.currentTarget=J;try{x(m)}catch(ce){tc(ce)}m.currentTarget=null,x=O}else for(y=0;y<u.length;y++){if(C=u[y],O=C.instance,J=C.currentTarget,C=C.listener,O!==x&&m.isPropagationStopped())break e;x=C,m.currentTarget=J;try{x(m)}catch(ce){tc(ce)}m.currentTarget=null,x=O}}}}function gt(n,r){var l=r[M];l===void 0&&(l=r[M]=new Set);var u=n+"__bubble";l.has(u)||(y_(r,n,2,!1),l.add(u))}function Nd(n,r,l){var u=0;r&&(u|=4),y_(l,n,u,r)}var Uc="_reactListening"+Math.random().toString(36).slice(2);function jd(n){if(!n[Uc]){n[Uc]=!0,Ot.forEach(function(l){l!=="selectionchange"&&(zw.has(l)||Nd(l,!1,n),Nd(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Uc]||(r[Uc]=!0,Nd("selectionchange",!1,r))}}function y_(n,r,l,u){switch(X_(r)){case 2:var m=hC;break;case 8:m=dC;break;default:m=Fd}l=m.bind(null,r,l,n),m=void 0,!Cl||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 x=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 O=y.tag;if((O===3||O===4)&&y.stateNode.containerInfo===m)return;y=y.return}for(;C!==null;){if(y=We(C),y===null)return;if(O=y.tag,O===5||O===6||O===26||O===27){u=x=y;continue e}C=C.parentNode}}u=u.return}Qo(function(){var J=x,ce=Sl(l),fe=[];e:{var te=eg.get(n);if(te!==void 0){var le=Qn,Le=n;switch(n){case"keypress":if(Je(l)===0)break e;case"keydown":case"keyup":le=A1;break;case"focusin":Le="focus",le=Qu;break;case"focusout":Le="blur",le=Qu;break;case"beforeblur":case"afterblur":le=Qu;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":le=Tm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":le=_1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":le=M1;break;case Xm:case Zm:case Qm:le=y1;break;case Jm:le=L1;break;case"scroll":case"scrollend":le=g1;break;case"wheel":le=z1;break;case"copy":case"cut":case"paste":le=w1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":le=Rm;break;case"toggle":case"beforetoggle":le=I1}var qe=(r&4)!==0,Ht=!qe&&(n==="scroll"||n==="scrollend"),G=qe?te!==null?te+"Capture":null:te;qe=[];for(var P=J,Q;P!==null;){var de=P;if(Q=de.stateNode,de=de.tag,de!==5&&de!==26&&de!==27||Q===null||G===null||(de=fr(P,G),de!=null&&qe.push(to(P,de,Q))),Ht)break;P=P.return}0<qe.length&&(te=new le(te,Le,null,l,ce),fe.push({event:te,listeners:qe}))}}if((r&7)===0){e:{if(te=n==="mouseover"||n==="pointerover",le=n==="mouseout"||n==="pointerout",te&&l!==Ca&&(Le=l.relatedTarget||l.fromElement)&&(We(Le)||Le[ri]))break e;if((le||te)&&(te=ce.window===ce?ce:(te=ce.ownerDocument)?te.defaultView||te.parentWindow:window,le?(Le=l.relatedTarget||l.toElement,le=J,Le=Le?We(Le):null,Le!==null&&(Ht=o(Le),qe=Le.tag,Le!==Ht||qe!==5&&qe!==27&&qe!==6)&&(Le=null)):(le=null,Le=J),le!==Le)){if(qe=Tm,de="onMouseLeave",G="onMouseEnter",P="mouse",(n==="pointerout"||n==="pointerover")&&(qe=Rm,de="onPointerLeave",G="onPointerEnter",P="pointer"),Ht=le==null?te:vt(le),Q=Le==null?te:vt(Le),te=new qe(de,P+"leave",le,l,ce),te.target=Ht,te.relatedTarget=Q,de=null,We(ce)===J&&(qe=new qe(G,P+"enter",Le,l,ce),qe.target=Q,qe.relatedTarget=Ht,de=qe),Ht=de,le&&Le)t:{for(qe=Pw,G=le,P=Le,Q=0,de=G;de;de=qe(de))Q++;de=0;for(var $e=P;$e;$e=qe($e))de++;for(;0<Q-de;)G=qe(G),Q--;for(;0<de-Q;)P=qe(P),de--;for(;Q--;){if(G===P||P!==null&&G===P.alternate){qe=G;break t}G=qe(G),P=qe(P)}qe=null}else qe=null;le!==null&&S_(fe,te,le,qe,!1),Le!==null&&Ht!==null&&S_(fe,Ht,Le,qe,!0)}}e:{if(te=J?vt(J):window,le=te.nodeName&&te.nodeName.toLowerCase(),le==="select"||le==="input"&&te.type==="file")var jt=Im;else if(zm(te))if(Hm)jt=K1;else{jt=Y1;var ze=G1}else le=te.nodeName,!le||le.toLowerCase()!=="input"||te.type!=="checkbox"&&te.type!=="radio"?J&&wa(J.elementType)&&(jt=Im):jt=V1;if(jt&&(jt=jt(n,J))){Pm(fe,jt,l,ce);break e}ze&&ze(n,te,J),n==="focusout"&&J&&te.type==="number"&&J.memoizedProps.value!=null&&dr(te,"number",te.value)}switch(ze=J?vt(J):window,n){case"focusin":(zm(ze)||ze.contentEditable==="true")&&(Na=ze,rh=J,Al=null);break;case"focusout":Al=rh=Na=null;break;case"mousedown":sh=!0;break;case"contextmenu":case"mouseup":case"dragend":sh=!1,Vm(fe,l,ce);break;case"selectionchange":if(Z1)break;case"keydown":case"keyup":Vm(fe,l,ce)}var at;if(eh)e:{switch(n){case"compositionstart":var bt="onCompositionStart";break e;case"compositionend":bt="onCompositionEnd";break e;case"compositionupdate":bt="onCompositionUpdate";break e}bt=void 0}else Ea?Lm(n,l)&&(bt="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(bt="onCompositionStart");bt&&(Dm&&l.locale!=="ko"&&(Ea||bt!=="onCompositionStart"?bt==="onCompositionEnd"&&Ea&&(at=ke()):(pr=ce,se="value"in pr?pr.value:pr.textContent,Ea=!0)),ze=$c(J,bt),0<ze.length&&(bt=new Am(bt,n,null,l,ce),fe.push({event:bt,listeners:ze}),at?bt.data=at:(at=Om(l),at!==null&&(bt.data=at)))),(at=U1?$1(n,l):F1(n,l))&&(bt=$c(J,"onBeforeInput"),0<bt.length&&(ze=new Am("onBeforeInput","beforeinput",null,l,ce),fe.push({event:ze,listeners:bt}),ze.data=at)),Bw(fe,n,J,l,ce)}v_(fe,r)})}function to(n,r,l){return{instance:n,listener:r,currentTarget:l}}function $c(n,r){for(var l=r+"Capture",u=[];n!==null;){var m=n,x=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||x===null||(m=fr(n,l),m!=null&&u.unshift(to(n,m,x)),m=fr(n,r),m!=null&&u.push(to(n,m,x))),n.tag===3)return u;n=n.return}return[]}function Pw(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function S_(n,r,l,u,m){for(var x=r._reactName,y=[];l!==null&&l!==u;){var C=l,O=C.alternate,J=C.stateNode;if(C=C.tag,O!==null&&O===u)break;C!==5&&C!==26&&C!==27||J===null||(O=J,m?(J=fr(l,x),J!=null&&y.unshift(to(l,J,O))):m||(J=fr(l,x),J!=null&&y.push(to(l,J,O)))),l=l.return}y.length!==0&&n.push({event:r,listeners:y})}var Iw=/\r\n?/g,Hw=/\u0000|\uFFFD/g;function w_(n){return(typeof n=="string"?n:""+n).replace(Iw,`
|
|
49
|
+
`).replace(Hw,"")}function C_(n,r){return r=w_(r),w_(n)===r}function It(n,r,l,u,m,x){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Pn(n,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Pn(n,""+u);break;case"className":Ft(n,"class",u);break;case"tabIndex":Ft(n,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Ft(n,l,u);break;case"style":Sa(n,u,x);break;case"data":if(r!=="object"){Ft(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=Ys(""+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 x=="function"&&(l==="formAction"?(r!=="input"&&It(n,r,"name",m.name,m,null),It(n,r,"formEncType",m.formEncType,m,null),It(n,r,"formMethod",m.formMethod,m,null),It(n,r,"formTarget",m.formTarget,m,null)):(It(n,r,"encType",m.encType,m,null),It(n,r,"method",m.method,m,null),It(n,r,"target",m.target,m,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(l);break}u=Ys(""+u),n.setAttribute(l,u);break;case"onClick":u!=null&&(n.onclick=gn);break;case"onScroll":u!=null&>("scroll",n);break;case"onScrollEnd":u!=null&>("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=Ys(""+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":gt("beforetoggle",n),gt("toggle",n),vr(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":vr(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=Gs.get(l)||l,vr(n,l,u))}}function Ad(n,r,l,u,m,x){switch(l){case"style":Sa(n,u,x);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"?Pn(n,u):(typeof u=="number"||typeof u=="bigint")&&Pn(n,""+u);break;case"onScroll":u!=null&>("scroll",n);break;case"onScrollEnd":u!=null&>("scrollend",n);break;case"onClick":u!=null&&(n.onclick=gn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!yi.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),r=l.slice(2,m?l.length-7:void 0),x=n[At]||null,x=x!=null?x[l]:null,typeof x=="function"&&n.removeEventListener(r,x,m),typeof u=="function")){typeof x!="function"&&x!==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,""):vr(n,l,u)}}}function rn(n,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":gt("error",n),gt("load",n);var u=!1,m=!1,x;for(x in l)if(l.hasOwnProperty(x)){var y=l[x];if(y!=null)switch(x){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:It(n,r,x,y,l,null)}}m&&It(n,r,"srcSet",l.srcSet,l,null),u&&It(n,r,"src",l.src,l,null);return;case"input":gt("invalid",n);var C=x=y=m=null,O=null,J=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":O=ce;break;case"defaultChecked":J=ce;break;case"value":x=ce;break;case"defaultValue":C=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,r));break;default:It(n,r,u,ce,l,null)}}wi(n,x,C,O,J,y,m,!1);return;case"select":gt("invalid",n),u=y=x=null;for(m in l)if(l.hasOwnProperty(m)&&(C=l[m],C!=null))switch(m){case"value":x=C;break;case"defaultValue":y=C;break;case"multiple":u=C;default:It(n,r,m,C,l,null)}r=x,l=y,n.multiple=!!u,r!=null?Ci(n,!!u,r,!1):l!=null&&Ci(n,!!u,l,!0);return;case"textarea":gt("invalid",n),x=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":x=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:It(n,r,y,C,l,null)}us(n,u,m,x);return;case"option":for(O in l)if(l.hasOwnProperty(O)&&(u=l[O],u!=null))switch(O){case"selected":n.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:It(n,r,O,u,l,null)}return;case"dialog":gt("beforetoggle",n),gt("toggle",n),gt("cancel",n),gt("close",n);break;case"iframe":case"object":gt("load",n);break;case"video":case"audio":for(u=0;u<eo.length;u++)gt(eo[u],n);break;case"image":gt("error",n),gt("load",n);break;case"details":gt("toggle",n);break;case"embed":case"source":case"link":gt("error",n),gt("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(J in l)if(l.hasOwnProperty(J)&&(u=l[J],u!=null))switch(J){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:It(n,r,J,u,l,null)}return;default:if(wa(r)){for(ce in l)l.hasOwnProperty(ce)&&(u=l[ce],u!==void 0&&Ad(n,r,ce,u,l,void 0));return}}for(C in l)l.hasOwnProperty(C)&&(u=l[C],u!=null&&It(n,r,C,u,l,null))}function Uw(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,x=null,y=null,C=null,O=null,J=null,ce=null;for(le in l){var fe=l[le];if(l.hasOwnProperty(le)&&fe!=null)switch(le){case"checked":break;case"value":break;case"defaultValue":O=fe;default:u.hasOwnProperty(le)||It(n,r,le,null,u,fe)}}for(var te in u){var le=u[te];if(fe=l[te],u.hasOwnProperty(te)&&(le!=null||fe!=null))switch(te){case"type":x=le;break;case"name":m=le;break;case"checked":J=le;break;case"defaultChecked":ce=le;break;case"value":y=le;break;case"defaultValue":C=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,r));break;default:le!==fe&&It(n,r,te,le,u,fe)}}Ir(n,y,C,O,J,ce,x,m);return;case"select":le=y=C=te=null;for(x in l)if(O=l[x],l.hasOwnProperty(x)&&O!=null)switch(x){case"value":break;case"multiple":le=O;default:u.hasOwnProperty(x)||It(n,r,x,null,u,O)}for(m in u)if(x=u[m],O=l[m],u.hasOwnProperty(m)&&(x!=null||O!=null))switch(m){case"value":te=x;break;case"defaultValue":C=x;break;case"multiple":y=x;default:x!==O&&It(n,r,m,x,u,O)}r=C,l=y,u=le,te!=null?Ci(n,!!l,te,!1):!!u!=!!l&&(r!=null?Ci(n,!!l,r,!0):Ci(n,!!l,l?[]:"",!1));return;case"textarea":le=te=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:It(n,r,C,null,u,m)}for(y in u)if(m=u[y],x=l[y],u.hasOwnProperty(y)&&(m!=null||x!=null))switch(y){case"value":te=m;break;case"defaultValue":le=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(s(91));break;default:m!==x&&It(n,r,y,m,u,x)}zn(n,te,le);return;case"option":for(var Le in l)if(te=l[Le],l.hasOwnProperty(Le)&&te!=null&&!u.hasOwnProperty(Le))switch(Le){case"selected":n.selected=!1;break;default:It(n,r,Le,null,u,te)}for(O in u)if(te=u[O],le=l[O],u.hasOwnProperty(O)&&te!==le&&(te!=null||le!=null))switch(O){case"selected":n.selected=te&&typeof te!="function"&&typeof te!="symbol";break;default:It(n,r,O,te,u,le)}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 qe in l)te=l[qe],l.hasOwnProperty(qe)&&te!=null&&!u.hasOwnProperty(qe)&&It(n,r,qe,null,u,te);for(J in u)if(te=u[J],le=l[J],u.hasOwnProperty(J)&&te!==le&&(te!=null||le!=null))switch(J){case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(s(137,r));break;default:It(n,r,J,te,u,le)}return;default:if(wa(r)){for(var Ht in l)te=l[Ht],l.hasOwnProperty(Ht)&&te!==void 0&&!u.hasOwnProperty(Ht)&&Ad(n,r,Ht,void 0,u,te);for(ce in u)te=u[ce],le=l[ce],!u.hasOwnProperty(ce)||te===le||te===void 0&&le===void 0||Ad(n,r,ce,te,u,le);return}}for(var G in l)te=l[G],l.hasOwnProperty(G)&&te!=null&&!u.hasOwnProperty(G)&&It(n,r,G,null,u,te);for(fe in u)te=u[fe],le=l[fe],!u.hasOwnProperty(fe)||te===le||te==null&&le==null||It(n,r,fe,te,u,le)}function k_(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function $w(){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],x=m.transferSize,y=m.initiatorType,C=m.duration;if(x&&C&&k_(y)){for(y=0,C=m.responseEnd,u+=1;u<l.length;u++){var O=l[u],J=O.startTime;if(J>C)break;var ce=O.transferSize,fe=O.initiatorType;ce&&k_(fe)&&(O=O.responseEnd,y+=ce*(O<C?1:(C-J)/(O-J)))}if(--u,r+=8*(x+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 Rd=null,Dd=null;function Fc(n){return n.nodeType===9?n:n.ownerDocument}function E_(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 N_(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 Md(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 Bd=null;function Fw(){var n=window.event;return n&&n.type==="popstate"?n===Bd?!1:(Bd=n,!0):(Bd=null,!1)}var j_=typeof setTimeout=="function"?setTimeout:void 0,qw=typeof clearTimeout=="function"?clearTimeout:void 0,T_=typeof Promise=="function"?Promise:void 0,Ww=typeof queueMicrotask=="function"?queueMicrotask:typeof T_<"u"?function(n){return T_.resolve(null).then(n).catch(Gw)}:j_;function Gw(n){setTimeout(function(){throw n})}function Ts(n){return n==="head"}function A_(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),el(r);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")io(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,io(l);for(var x=l.firstChild;x;){var y=x.nextSibling,C=x.nodeName;x[Se]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=y}}else l==="body"&&io(n.ownerDocument.body);l=m}while(l);el(r)}function R_(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 Ld(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":Ld(l),Ne(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function Yw(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[Se])switch(r){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(x=n.getAttribute("rel"),x==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(x!==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(x=n.getAttribute("src"),(x!==(m.src==null?null:m.src)||n.getAttribute("type")!==(m.type==null?null:m.type)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&x&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(r==="input"&&n.type==="hidden"){var x=m.name==null?null:""+m.name;if(m.type==="hidden"&&n.getAttribute("name")===x)return n}else return n;if(n=sr(n.nextSibling),n===null)break}return null}function Vw(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 D_(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 Od(n){return n.data==="$?"||n.data==="$~"}function zd(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function Kw(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 Pd=null;function M_(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 B_(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 L_(n,r,l){switch(r=Fc(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 io(n){for(var r=n.attributes;r.length;)n.removeAttributeNode(r[0]);Ne(n)}var ar=new Map,O_=new Set;function qc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var ts=q.d;q.d={f:Xw,r:Zw,D:Qw,C:Jw,L:eC,m:tC,X:nC,S:iC,M:rC};function Xw(){var n=ts.f(),r=Lc();return n||r}function Zw(n){var r=Ke(n);r!==null&&r.tag===5&&r.type==="form"?Jg(r):ts.r(n)}var Za=typeof document>"u"?null:document;function z_(n,r,l){var u=Za;if(u&&typeof r=="string"&&r){var m=Ji(r);m='link[rel="'+n+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),O_.has(m)||(O_.add(m),n={rel:n,crossOrigin:l,href:r},u.querySelector(m)===null&&(r=u.createElement("link"),rn(r,"link",n),Ze(r),u.head.appendChild(r)))}}function Qw(n){ts.D(n),z_("dns-prefetch",n,null)}function Jw(n,r){ts.C(n,r),z_("preconnect",n,r)}function eC(n,r,l){ts.L(n,r,l);var u=Za;if(u&&n&&r){var m='link[rel="preload"][as="'+Ji(r)+'"]';r==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+Ji(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+Ji(l.imageSizes)+'"]')):m+='[href="'+Ji(n)+'"]';var x=m;switch(r){case"style":x=Qa(n);break;case"script":x=Ja(n)}ar.has(x)||(n=g({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:n,as:r},l),ar.set(x,n),u.querySelector(m)!==null||r==="style"&&u.querySelector(no(x))||r==="script"&&u.querySelector(ro(x))||(r=u.createElement("link"),rn(r,"link",n),Ze(r),u.head.appendChild(r)))}}function tC(n,r){ts.m(n,r);var l=Za;if(l&&n){var u=r&&typeof r.as=="string"?r.as:"script",m='link[rel="modulepreload"][as="'+Ji(u)+'"][href="'+Ji(n)+'"]',x=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Ja(n)}if(!ar.has(x)&&(n=g({rel:"modulepreload",href:n},r),ar.set(x,n),l.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ro(x)))return}u=l.createElement("link"),rn(u,"link",n),Ze(u),l.head.appendChild(u)}}}function iC(n,r,l){ts.S(n,r,l);var u=Za;if(u&&n){var m=it(u).hoistableStyles,x=Qa(n);r=r||"default";var y=m.get(x);if(!y){var C={loading:0,preload:null};if(y=u.querySelector(no(x)))C.loading=5;else{n=g({rel:"stylesheet",href:n,"data-precedence":r},l),(l=ar.get(x))&&Id(n,l);var O=y=u.createElement("link");Ze(O),rn(O,"link",n),O._p=new Promise(function(J,ce){O.onload=J,O.onerror=ce}),O.addEventListener("load",function(){C.loading|=1}),O.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Wc(y,r,u)}y={type:"stylesheet",instance:y,count:1,state:C},m.set(x,y)}}}function nC(n,r){ts.X(n,r);var l=Za;if(l&&n){var u=it(l).hoistableScripts,m=Ja(n),x=u.get(m);x||(x=l.querySelector(ro(m)),x||(n=g({src:n,async:!0},r),(r=ar.get(m))&&Hd(n,r),x=l.createElement("script"),Ze(x),rn(x,"link",n),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(m,x))}}function rC(n,r){ts.M(n,r);var l=Za;if(l&&n){var u=it(l).hoistableScripts,m=Ja(n),x=u.get(m);x||(x=l.querySelector(ro(m)),x||(n=g({src:n,async:!0,type:"module"},r),(r=ar.get(m))&&Hd(n,r),x=l.createElement("script"),Ze(x),rn(x,"link",n),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(m,x))}}function P_(n,r,l,u){var m=(m=V.current)?qc(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=Qa(l.href),l=it(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=Qa(l.href);var x=it(m).hoistableStyles,y=x.get(n);if(y||(m=m.ownerDocument||m,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(n,y),(x=m.querySelector(no(n)))&&!x._p&&(y.instance=x,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),x||sC(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=Ja(l),l=it(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 Qa(n){return'href="'+Ji(n)+'"'}function no(n){return'link[rel="stylesheet"]['+n+"]"}function I_(n){return g({},n,{"data-precedence":n.precedence,precedence:null})}function sC(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}),rn(r,"link",l),Ze(r),n.head.appendChild(r))}function Ja(n){return'[src="'+Ji(n)+'"]'}function ro(n){return"script[async]"+n}function H_(n,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=n.querySelector('style[data-href~="'+Ji(l.href)+'"]');if(u)return r.instance=u,Ze(u),u;var m=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(n.ownerDocument||n).createElement("style"),Ze(u),rn(u,"style",m),Wc(u,l.precedence,n),r.instance=u;case"stylesheet":m=Qa(l.href);var x=n.querySelector(no(m));if(x)return r.state.loading|=4,r.instance=x,Ze(x),x;u=I_(l),(m=ar.get(m))&&Id(u,m),x=(n.ownerDocument||n).createElement("link"),Ze(x);var y=x;return y._p=new Promise(function(C,O){y.onload=C,y.onerror=O}),rn(x,"link",u),r.state.loading|=4,Wc(x,l.precedence,n),r.instance=x;case"script":return x=Ja(l.src),(m=n.querySelector(ro(x)))?(r.instance=m,Ze(m),m):(u=l,(m=ar.get(x))&&(u=g({},l),Hd(u,m)),n=n.ownerDocument||n,m=n.createElement("script"),Ze(m),rn(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,Wc(u,l.precedence,n));return r.instance}function Wc(n,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,x=m,y=0;y<u.length;y++){var C=u[y];if(C.dataset.precedence===r)x=C;else if(x!==m)break}x?x.parentNode.insertBefore(n,x.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(n,r.firstChild))}function Id(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.title==null&&(n.title=r.title)}function Hd(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.integrity==null&&(n.integrity=r.integrity)}var Gc=null;function U_(n,r,l){if(Gc===null){var u=new Map,m=Gc=new Map;m.set(l,u)}else m=Gc,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 x=l[m];if(!(x[Se]||x[Xt]||n==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var y=x.getAttribute(r)||"";y=n+y;var C=u.get(y);C?C.push(x):u.set(y,[x])}}return u}function $_(n,r,l){n=n.ownerDocument||n,n.head.insertBefore(l,r==="title"?n.querySelector("head > title"):null)}function aC(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 F_(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function lC(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=Qa(u.href),x=r.querySelector(no(m));if(x){r=x._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(n.count++,n=Yc.bind(n),r.then(n,n)),l.state.loading|=4,l.instance=x,Ze(x);return}x=r.ownerDocument||r,u=I_(u),(m=ar.get(m))&&Id(u,m),x=x.createElement("link"),Ze(x);var y=x;y._p=new Promise(function(C,O){y.onload=C,y.onerror=O}),rn(x,"link",u),l.instance=x}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=Yc.bind(n),r.addEventListener("load",l),r.addEventListener("error",l))}}var Ud=0;function oC(n,r){return n.stylesheets&&n.count===0&&Kc(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var u=setTimeout(function(){if(n.stylesheets&&Kc(n,n.stylesheets),n.unsuspend){var x=n.unsuspend;n.unsuspend=null,x()}},6e4+r);0<n.imgBytes&&Ud===0&&(Ud=62500*$w());var m=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Kc(n,n.stylesheets),n.unsuspend)){var x=n.unsuspend;n.unsuspend=null,x()}},(n.imgBytes>Ud?50:800)+r);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Yc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Vc=null;function Kc(n,r){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Vc=new Map,r.forEach(cC,n),Vc=null,Yc.call(n))}function cC(n,r){if(!(r.state.loading&4)){var l=Vc.get(n);if(l)var u=l.get(null);else{l=new Map,Vc.set(n,l);for(var m=n.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<m.length;x++){var y=m[x];(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"),x=l.get(y)||u,x===u&&l.set(null,m),l.set(y,m),this.count++,u=Yc.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),x?x.parentNode.insertBefore(m,x.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(m,n.firstChild)),r.state.loading|=4}}var so={$$typeof:I,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function uC(n,r,l,u,m,x,y,C,O){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=tt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tt(0),this.hiddenUpdates=tt(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=x,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function q_(n,r,l,u,m,x,y,C,O,J,ce,fe){return n=new uC(n,r,l,y,O,J,ce,fe,C),r=1,x===!0&&(r|=24),x=Hn(3,null,null,r),n.current=x,x.stateNode=n,r=vh(),r.refCount++,n.pooledCache=r,r.refCount++,x.memoizedState={element:u,isDehydrated:l,cache:r},Ch(x),n}function W_(n){return n?(n=Aa,n):Aa}function G_(n,r,l,u,m,x){m=W_(m),u.context===null?u.context=m:u.pendingContext=m,u=_s(r),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=bs(n,u,r),l!==null&&(Rn(l,n,r),zl(l,n,r))}function Y_(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function $d(n,r){Y_(n,r),(n=n.alternate)&&Y_(n,r)}function V_(n){if(n.tag===13||n.tag===31){var r=Xs(n,67108864);r!==null&&Rn(r,n,67108864),$d(n,67108864)}}function K_(n){if(n.tag===13||n.tag===31){var r=Wn();r=on(r);var l=Xs(n,r);l!==null&&Rn(l,n,r),$d(n,r)}}var Xc=!0;function hC(n,r,l,u){var m=T.T;T.T=null;var x=q.p;try{q.p=2,Fd(n,r,l,u)}finally{q.p=x,T.T=m}}function dC(n,r,l,u){var m=T.T;T.T=null;var x=q.p;try{q.p=8,Fd(n,r,l,u)}finally{q.p=x,T.T=m}}function Fd(n,r,l,u){if(Xc){var m=qd(u);if(m===null)Td(n,r,u,Zc,l),Z_(n,u);else if(pC(m,n,r,l,u))u.stopPropagation();else if(Z_(n,u),r&4&&-1<fC.indexOf(n)){for(;m!==null;){var x=Ke(m);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var y=be(x.pendingLanes);if(y!==0){var C=x;for(C.pendingLanes|=2,C.entangledLanes|=2;y;){var O=1<<31-ut(y);C.entanglements[1]|=O,y&=~O}kr(x),(Rt&6)===0&&(Mc=St()+500,Jl(0))}}break;case 31:case 13:C=Xs(x,2),C!==null&&Rn(C,x,2),Lc(),$d(x,2)}if(x=qd(u),x===null&&Td(n,r,u,Zc,l),x===m)break;m=x}m!==null&&u.stopPropagation()}else Td(n,r,u,null,l)}}function qd(n){return n=Sl(n),Wd(n)}var Zc=null;function Wd(n){if(Zc=null,n=We(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 Zc=n,null}function X_(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(ct()){case ee:return 2;case xe:return 8;case Te:case Ue:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var Gd=!1,As=null,Rs=null,Ds=null,ao=new Map,lo=new Map,Ms=[],fC="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 Z_(n,r){switch(n){case"focusin":case"focusout":As=null;break;case"dragenter":case"dragleave":Rs=null;break;case"mouseover":case"mouseout":Ds=null;break;case"pointerover":case"pointerout":ao.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":lo.delete(r.pointerId)}}function oo(n,r,l,u,m,x){return n===null||n.nativeEvent!==x?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:x,targetContainers:[m]},r!==null&&(r=Ke(r),r!==null&&V_(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function pC(n,r,l,u,m){switch(r){case"focusin":return As=oo(As,n,r,l,u,m),!0;case"dragenter":return Rs=oo(Rs,n,r,l,u,m),!0;case"mouseover":return Ds=oo(Ds,n,r,l,u,m),!0;case"pointerover":var x=m.pointerId;return ao.set(x,oo(ao.get(x)||null,n,r,l,u,m)),!0;case"gotpointercapture":return x=m.pointerId,lo.set(x,oo(lo.get(x)||null,n,r,l,u,m)),!0}return!1}function Q_(n){var r=We(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,Xn(n.priority,function(){K_(l)});return}}else if(r===31){if(r=h(l),r!==null){n.blockedOn=r,Xn(n.priority,function(){K_(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 Qc(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=qd(n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);Ca=u,l.target.dispatchEvent(u),Ca=null}else return r=Ke(l),r!==null&&V_(r),n.blockedOn=l,!1;r.shift()}return!0}function J_(n,r,l){Qc(n)&&l.delete(r)}function mC(){Gd=!1,As!==null&&Qc(As)&&(As=null),Rs!==null&&Qc(Rs)&&(Rs=null),Ds!==null&&Qc(Ds)&&(Ds=null),ao.forEach(J_),lo.forEach(J_)}function Jc(n,r){n.blockedOn===r&&(n.blockedOn=null,Gd||(Gd=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,mC)))}var eu=null;function eb(n){eu!==n&&(eu=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){eu===n&&(eu=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(Wd(u||l)===null)continue;break}var x=Ke(l);x!==null&&(n.splice(r,3),r-=3,qh(x,{pending:!0,data:m,method:l.method,action:u},u,m))}}))}function el(n){function r(O){return Jc(O,n)}As!==null&&Jc(As,n),Rs!==null&&Jc(Rs,n),Ds!==null&&Jc(Ds,n),ao.forEach(r),lo.forEach(r);for(var l=0;l<Ms.length;l++){var u=Ms[l];u.blockedOn===n&&(u.blockedOn=null)}for(;0<Ms.length&&(l=Ms[0],l.blockedOn===null);)Q_(l),l.blockedOn===null&&Ms.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var m=l[u],x=l[u+1],y=m[At]||null;if(typeof x=="function")y||eb(l);else if(y){var C=null;if(x&&x.hasAttribute("formAction")){if(m=x,y=x[At]||null)C=y.formAction;else if(Wd(m)!==null)continue}else C=y.action;typeof C=="function"?l[u+1]=C:(l.splice(u,3),u-=3),eb(l)}}}function tb(){function n(x){x.canIntercept&&x.info==="react-transition"&&x.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 x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.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 Yd(n){this._internalRoot=n}tu.prototype.render=Yd.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));var l=r.current,u=Wn();G_(l,u,n,r,null,null)},tu.prototype.unmount=Yd.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;G_(n.current,2,null,n,null,null),Lc(),r[ri]=null}};function tu(n){this._internalRoot=n}tu.prototype.unstable_scheduleHydration=function(n){if(n){var r=Mi();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Ms.length&&r!==0&&r<Ms[l].priority;l++);Ms.splice(l,0,n),l===0&&Q_(n)}};var ib=t.version;if(ib!=="19.2.3")throw Error(s(527,ib,"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=f(r),n=n!==null?_(n):null,n=n===null?null:n.stateNode,n};var gC={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var iu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iu.isDisabled&&iu.supportsFiber)try{Lt=iu.inject(gC),Et=iu}catch{}}return uo.createRoot=function(n,r){if(!a(n))throw Error(s(299));var l=!1,u="",m=cx,x=ux,y=hx;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&&(x=r.onCaughtError),r.onRecoverableError!==void 0&&(y=r.onRecoverableError)),r=q_(n,1,!1,null,null,l,u,null,m,x,y,tb),n[ri]=r.current,jd(n),new Yd(r)},uo.hydrateRoot=function(n,r,l){if(!a(n))throw Error(s(299));var u=!1,m="",x=cx,y=ux,C=hx,O=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(y=l.onCaughtError),l.onRecoverableError!==void 0&&(C=l.onRecoverableError),l.formState!==void 0&&(O=l.formState)),r=q_(n,1,!0,r,l??null,u,m,O,x,y,C,tb),r.context=W_(null),l=r.current,u=Wn(),u=on(u),m=_s(u),m.callback=null,bs(l,m,u),l=u,r.current.lanes=l,Dt(r,l),kr(r),n[ri]=r.current,jd(n),new tu(r)},uo.version="19.2.3",uo}var db;function NC(){if(db)return Xd.exports;db=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(),Xd.exports=EC(),Xd.exports}var jC=NC();const TC=Pu(jC);function AC({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 f=await e(t);f&&a(f),c(!1)};return d.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:d.jsxs("div",{className:"w-full max-w-sm",children:[d.jsxs("div",{className:"border-border rounded border p-6",children:[d.jsxs("div",{className:"mb-6 text-center",children:[d.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),d.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),d.jsxs("form",{onSubmit:h,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),d.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&&d.jsx("p",{className:"text-error text-xs",children:s}),d.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"})]})]}),d.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function RC({onSetup:e}){const[t,i]=w.useState(""),[s,a]=w.useState(""),[o,c]=w.useState(null),[h,p]=w.useState(!1),f=async _=>{if(_.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 g=await e(t);g&&c(g),p(!1)};return d.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:d.jsx("div",{className:"w-full max-w-sm",children:d.jsxs("div",{className:"border-border rounded border p-6",children:[d.jsxs("div",{className:"mb-6 text-center",children:[d.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),d.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),d.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."}),d.jsxs("form",{onSubmit:f,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),d.jsx("input",{type:"password",value:t,onChange:_=>i(_.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"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),d.jsx("input",{type:"password",value:s,onChange:_=>a(_.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&&d.jsx("p",{className:"text-error text-xs",children:o}),d.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 ef="http://localhost:7777";function My({token:e}){const[t,i]=w.useState(null),[s,a]=w.useState(!1),[o,c]=w.useState(null),[h,p]=w.useState(!1),[f,_]=w.useState(null),g=w.useCallback((E,z)=>fetch(E,{...z,headers:{...z==null?void 0:z.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]),b=w.useCallback(()=>{g(`${ef}/api/wallet`).then(E=>E.json()).then(E=>i(E)).catch(()=>i({exists:!1,error:"Failed to load wallet"}))},[g]);w.useEffect(()=>{b()},[b]);const v=async()=>{a(!0),_(null);try{const E=await g(`${ef}/api/wallet/create`,{method:"POST"}),z=await E.json();if(!E.ok)throw new Error(z.error||"Creation failed");b()}catch(E){_(E instanceof Error?E.message:"Failed to create wallet")}a(!1)},S=async E=>{c(E.walletId||E.name),_(null);try{const z=await g(`${ef}/api/wallet/active`,{method:"POST",body:JSON.stringify({walletId:E.walletId,name:E.name,address:E.normalizedAddress||E.address})}),I=await z.json();if(!z.ok)throw new Error(I.error||"Wallet switch failed");b()}catch(z){_(z instanceof Error?z.message:"Failed to switch wallet")}c(null)},N=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),p(!0),setTimeout(()=>p(!1),2e3))},B=E=>`${E.slice(0,6)}...${E.slice(-4)}`;return d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&d.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-muted text-xs",children:t.error||"No wallet created yet. Create one to enable autonomous transactions."}),f&&d.jsx("p",{className:"text-error text-xs",children:f}),d.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&&d.jsxs("div",{className:"mb-4 space-y-3 rounded border border-amber-600/30 bg-amber-950/10 p-3",children:[d.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=>d.jsxs("div",{className:"border-border flex items-center justify-between gap-3 rounded border p-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-foreground truncate text-xs font-medium",children:E.name}),d.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),d.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)),f&&d.jsx("p",{className:"text-error text-xs",children:f})]}),t&&t.exists&&t.address&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Active Wallet (Base)"}),d.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&&d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Name"}),d.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.name})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:B(t.address)}),d.jsx("button",{onClick:N,className:"text-muted hover:text-accent text-xs transition-colors",children:h?"copied":"copy"})]}),d.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"ETH"}),d.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"USDC"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"PLOT"}),d.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Network"}),d.jsx("span",{className:"text-foreground",children:"Base"})]})]}),t.wallets&&t.wallets.length>1&&d.jsxs("div",{className:"border-border space-y-2 border-t pt-3",children:[d.jsx("p",{className:"text-muted text-[10px] font-medium uppercase tracking-wider",children:"Switch Wallet"}),t.wallets.map(E=>d.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("p",{className:E.active?"text-accent truncate font-medium":"text-foreground truncate",children:[E.name,E.active?" (active)":""]}),d.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),!E.active&&d.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)),f&&d.jsx("p",{className:"text-error text-xs",children:f})]}),d.jsxs("div",{className:"border-border border-t pt-3",children:[d.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),d.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),d.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)&&d.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 Eu(e){return!!e&&e.codex.installed&&e.codex.auth==="unknown"}const Fp="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 DC({token:e,onLogout:t}){const[i,s]=w.useState(""),[a,o]=w.useState(""),[c,h]=w.useState(null),[p,f]=w.useState(!1),[_,g]=w.useState(!1),[b,v]=w.useState(null),[S,N]=w.useState("AI Writer"),[B,E]=w.useState(""),[z,I]=w.useState(""),[R,H]=w.useState(!1),[D,ie]=w.useState(null),[ue,ve]=w.useState(""),[L,re]=w.useState(null),[F,Y]=w.useState(!1),[K,$]=w.useState(null),[T,q]=w.useState(null),[W,ge]=w.useState(null),j=w.useCallback((ae,V)=>fetch(ae,{...V,headers:{...V==null?void 0:V.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);w.useEffect(()=>{j("/api/settings/link-status").then(ae=>ae.json()).then(ae=>v(ae)).catch(()=>v({linked:!1}))},[]),w.useEffect(()=>{j("/api/agent/readiness").then(ae=>ae.ok?ae.json():null).then(ae=>{ae&&ge(ae)}).catch(()=>{})},[]);const A=async()=>{if(!S.trim()){ie("Agent name is required");return}if(!B.trim()){ie("Description is required");return}H(!0),ie(null);try{const ae=await j("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:S,description:B,...z.trim()&&{genre:z}})}),V=await ae.json();if(!ae.ok)throw new Error(V.error||"Registration failed");v({linked:!0,agentId:V.agentId,owsWallet:V.owsWallet,txHash:V.txHash})}catch(ae){ie(ae instanceof Error?ae.message:"Registration failed")}H(!1)},Z=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){$("Enter a valid wallet address (0x...)");return}Y(!0),$(null),re(null);try{const ae=await j("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),V=await ae.json();if(!ae.ok)throw new Error(V.error||"Failed to generate binding code");re(V)}catch(ae){$(ae instanceof Error?ae.message:"Failed to generate binding code")}Y(!1)},k=async(ae,V)=>{await navigator.clipboard.writeText(ae),q(V),setTimeout(()=>q(null),2e3)},oe=async()=>{if(h(null),f(!1),!i||i.length<4){h("Passphrase must be at least 4 characters");return}if(i!==a){h("Passphrases do not match");return}g(!0);try{const ae=await j("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:i})});if(!ae.ok){const V=await ae.json();throw new Error(V.error||"Reset failed")}f(!0),s(""),o(""),setTimeout(()=>f(!1),3e3)}catch(ae){h(ae instanceof Error?ae.message:"Reset failed")}g(!1)};return d.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[d.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),d.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&d.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&d.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&d.jsx("p",{className:"text-muted text-xs",children:d.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),d.jsx("p",{className:"text-muted text-xs",children:d.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"})})]}):d.jsxs("div",{className:"space-y-3",children:[d.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."}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),d.jsx("input",{value:S,onChange:ae=>N(ae.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"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),d.jsx("input",{value:B,onChange:ae=>E(ae.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"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),d.jsx("input",{value:z,onChange:ae=>I(ae.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"})]}),D&&d.jsx("p",{className:"text-error text-xs",children:D}),d.jsx("button",{onClick:A,disabled:R||!S.trim()||!B.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"})]})]}),d.jsxs("div",{className:"border-border rounded border p-4","data-testid":"provider-readiness",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Providers"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Claude"}),d.jsx("span",{className:"text-muted text-xs",children:W!=null&&W.claude.installed?"Installed":"Not detected"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex"}),d.jsx("span",{className:"text-muted text-xs",children:W!=null&&W.codex.installed?"Installed":"Not detected"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex version"}),d.jsx("span",{className:"text-muted text-xs font-mono",children:(W==null?void 0:W.codex.version)??"—"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Image generation"}),d.jsx("span",{className:"text-muted text-xs",children:(W==null?void 0:W.codex.imageGeneration)??"unknown"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex auth"}),d.jsx("span",{className:"text-muted text-xs","data-testid":"codex-auth-status",children:W!=null&&W.codex.installed?W.codex.auth==="ok"?"ok":"unclear":"—"})]}),Eu(W)&&d.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"codex-auth-unknown-settings",children:Fp}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Last checked"}),d.jsx("span",{className:"text-muted text-xs",children:W!=null&&W.checkedAt?new Date(W.checkedAt).toLocaleString():"—"})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?d.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",d.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):d.jsxs("div",{className:"space-y-3",children:[d.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."}),d.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[d.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),d.jsx("p",{children:'2. Click "Generate Binding Code"'}),d.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),d.jsx("input",{value:ue,onChange:ae=>ve(ae.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"}),K&&d.jsx("p",{className:"text-error text-xs",children:K}),d.jsx("button",{onClick:Z,disabled:F||!ue.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"}),L&&d.jsxs("div",{className:"space-y-3 mt-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:L.signature}),d.jsx("button",{onClick:()=>k(L.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:T==="signature"?"Copied!":"Copy"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:L.owsWallet}),d.jsx("button",{onClick:()=>k(L.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:T==="wallet"?"Copied!":"Copy"})]})]}),L.agentId&&d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:L.agentId}),d.jsx("button",{onClick:()=>k(String(L.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:T==="agentId"?"Copied!":"Copy"})]})]}),d.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),d.jsx(My,{token:e}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("input",{type:"password",value:i,onChange:ae=>s(ae.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"}),d.jsx("input",{type:"password",value:a,onChange:ae=>o(ae.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&&d.jsx("p",{className:"text-error text-xs",children:c}),p&&d.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),d.jsx("button",{onClick:oe,disabled:_||!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:_?"updating...":"update passphrase"})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),d.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 MC="http://localhost:7777";function BC({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(`${MC}/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?d.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[d.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),d.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),d.jsxs("div",{className:"space-y-1.5",children:[t.wallet.name&&d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Active wallet"}),d.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.wallet.name})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Address"}),d.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"ETH Balance"}),d.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"USDC Balance"}),d.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),d.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Royalties earned"}),d.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),d.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),d.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),d.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Stories published"}),d.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?d.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):d.jsx("div",{className:"space-y-3",children:t.stories.published.map(h=>d.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsxs("div",{children:[h.genre&&d.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:h.genre}),d.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:h.title}),d.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:h.storyName})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[h.hasNotIndexed&&d.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),d.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[h.publishedFiles," published"]})]})]}),d.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium",children:h.plotCount}),d.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:h.storylineId?`#${h.storylineId}`:"—"}),d.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium",children:h.totalGasCostEth??"—"}),d.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),d.jsx("div",{className:"mt-2 space-y-1",children:h.files.map(p=>d.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),d.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&d.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))}),d.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[d.jsx("span",{className:"text-muted",children:c(h.latestPublishedAt)}),h.storylineId&&d.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&&d.jsx("div",{className:"border-border rounded border p-4",children:d.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const LC={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},OC={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function zC({authFetch:e,selectedStory:t,selectedFile:i,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,h]=w.useState([]),[p,f]=w.useState([]),[_,g]=w.useState(new Set),[b,v]=w.useState(!1),S=w.useCallback(async()=>{try{const H=await e("/api/stories");if(H.ok){const D=await H.json();h(D.stories)}}catch{}},[e]),N=w.useCallback(async()=>{try{const H=await e("/api/stories/archived");if(H.ok){const D=await H.json();f(D.stories)}}catch{}},[e]),B=w.useCallback(async H=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H})})).ok&&(N(),S())}catch{}},[e,N,S]);w.useEffect(()=>{S();const H=setInterval(S,5e3);return()=>clearInterval(H)},[S]),w.useEffect(()=>{b&&N()},[b,N]),w.useEffect(()=>{t&&g(H=>new Set(H).add(t))},[t]);const E=H=>{g(D=>{const ie=new Set(D);return ie.has(H)?ie.delete(H):ie.add(H),ie})},z=H=>{var ie;const D=H.map(ue=>{var ve;return{file:ue.file,num:(ve=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:ve[1]}}).filter(ue=>ue.num!=null).sort((ue,ve)=>parseInt(ve.num)-parseInt(ue.num));return D.length>0?D[0].file:H.some(ue=>ue.file==="genesis.md")?"genesis.md":H.some(ue=>ue.file==="structure.md")?"structure.md":((ie=H[0])==null?void 0:ie.file)??null},I=H=>{if(E(H.name),H.contentType==="cartoon")s(H.name,"");else{const D=z(H.files);D&&s(H.name,D)}},R=H=>{const D=ie=>{if(ie==="structure.md")return 0;if(ie==="genesis.md")return 1;const ue=ie.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...H].sort((ie,ue)=>D(ie.file)-D(ue.file))};return b?d.jsxs("div",{className:"h-full flex flex-col",children:[d.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),d.jsx("span",{className:"text-xs text-muted",children:p.length})]}),d.jsx("div",{className:"px-3 py-2 border-b border-border",children:d.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:[d.jsx("span",{children:"←"}),d.jsx("span",{children:"Back"})]})}),d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?d.jsx("div",{className:"p-3 text-sm text-muted",children:d.jsx("p",{children:"No archived stories."})}):p.map(H=>d.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[d.jsx("span",{className:"text-sm font-medium truncate",title:H.name,children:H.title||H.name}),d.jsx("button",{onClick:()=>B(H.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},H.name))})]}):d.jsxs("div",{className:"h-full flex flex-col",children:[d.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),d.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&d.jsx("div",{className:"px-3 py-2 border-b border-border",children:d.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:[d.jsx("span",{children:"+"}),d.jsx("span",{children:"New Story"})]})}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(H=>d.jsx("div",{children:d.jsxs("button",{onClick:()=>s(H,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===H?"bg-surface":""}`,children:[d.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),d.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},H)),c.length===0&&o.length===0?d.jsxs("div",{className:"p-3 text-sm text-muted",children:[d.jsx("p",{children:"No stories yet."}),d.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(H=>H.name!=="_example").map(H=>d.jsxs("div",{children:[d.jsxs("button",{onClick:()=>I(H),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[d.jsx("span",{className:"text-xs text-muted",children:_.has(H.name)?"▼":"▶"}),d.jsx("span",{className:"font-medium truncate",title:H.name,children:H.title||H.name}),H.contentType==="cartoon"&&d.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),d.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[H.publishedCount,"/",H.files.length]})]}),_.has(H.name)&&d.jsx("div",{className:"pl-4",children:R(H.files).map(D=>{const ie=t===H.name&&i===D.file;return d.jsxs("button",{onClick:()=>s(H.name,D.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ie?"bg-surface font-medium":""}`,children:[d.jsx("span",{className:OC[D.status],children:LC[D.status]}),d.jsx("span",{className:"truncate font-mono",children:D.file})]},D.file)})})]},H.name))]}),d.jsx("div",{className:"px-3 py-2 border-t border-border",children:d.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:d.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 By=Object.defineProperty,PC=Object.getOwnPropertyDescriptor,IC=(e,t)=>{for(var i in t)By(e,i,{get:t[i],enumerable:!0})},fi=(e,t,i,s)=>{for(var a=s>1?void 0:s?PC(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&&By(t,i,a),a},je=(e,t)=>(i,s)=>t(i,s,e),fb="Terminal input",Uf={get:()=>fb,set:e=>fb=e},pb="Too much output to announce, navigate to rows manually to read",$f={get:()=>pb,set:e=>pb=e};function HC(e){return e.replace(/\r?\n/g,"\r")}function UC(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function $C(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function FC(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");Ly(a,t,i,s)}}function Ly(e,t,i,s){e=HC(e),e=UC(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Oy(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 mb(e,t,i,s,a){Oy(e,t,i),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Is(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Iu(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 qC=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}},WC=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,f=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 B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=B-S;for(;f<E;){if(f>=i)return 0;if(N=e[f++],(N&192)!==128){f--,b=!0;break}else this.interim[S++]=N,v<<=6,v|=N&63}b||(B===2?v<128?f--:t[s++]=v:B===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let _=i-4,g=f;for(;g<i;){for(;g<_&&!((a=e[g])&128)&&!((o=e[g+1])&128)&&!((c=e[g+2])&128)&&!((h=e[g+3])&128);)t[s++]=a,t[s++]=o,t[s++]=c,t[s++]=h,g+=4;if(a=e[g++],a<128)t[s++]=a;else if((a&224)===192){if(g>=i)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(p=(a&31)<<6|o&63,p<128){g--;continue}t[s++]=p}else if((a&240)===224){if(g>=i)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[g++],(c&192)!==128){g--;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(g>=i)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[g++],(c&192)!==128){g--;continue}if(g>=i)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(h=e[g++],(h&192)!==128){g--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},zy="",Us=" ",Fo=class Py{constructor(){this.fg=0,this.bg=0,this.extended=new Nu}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 Py;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}},Nu=class Iy{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 Iy(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},hr=class Hy extends Fo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nu,this.combinedData=""}static fromCharData(t){let i=new Hy;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?Is(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()]}},gb="di$target",Ff="di$dependencies",tf=new Map;function GC(e){return e[Ff]||[]}function Qi(e){if(tf.has(e))return tf.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");YC(t,i,a)};return t._id=e,tf.set(e,t),t}function YC(e,t,i){t[gb]===t?t[Ff].push({id:e,index:i}):(t[Ff]=[{id:e,index:i}],t[gb]=t)}var Sn=Qi("BufferService"),Uy=Qi("CoreMouseService"),va=Qi("CoreService"),VC=Qi("CharsetService"),qp=Qi("InstantiationService"),$y=Qi("LogService"),wn=Qi("OptionsService"),Fy=Qi("OscLinkService"),KC=Qi("UnicodeService"),qo=Qi("DecorationService"),qf=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;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,f=!1;for(let g=0;g<c;g++)if(!(p===-1&&!i.hasContent(g))){if(i.loadCell(g,o),o.hasExtendedAttrs()&&o.extended.urlId)if(p===-1){p=g,h=o.extended.urlId;continue}else f=o.extended.urlId!==h;else p!==-1&&(f=!0);if(f||p!==-1&&g===c-1){let b=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(b){let v={start:{x:p+1,y:e},end:{x:g+(!f&&g===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,B)=>a?a.activate(N,B,v):XC(N,B),hover:(N,B)=>{var E;return(E=a==null?void 0:a.hover)==null?void 0:E.call(a,N,B,v)},leave:(N,B)=>{var E;return(E=a==null?void 0:a.leave)==null?void 0:E.call(a,N,B,v)}})}f=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=g,h=o.extended.urlId):(p=-1,h=-1)}}t(s)}};qf=fi([je(0,Sn),je(1,wn),je(2,Fy)],qf);function XC(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 Hu=Qi("CharSizeService"),ls=Qi("CoreBrowserService"),Wp=Qi("MouseService"),os=Qi("RenderService"),ZC=Qi("SelectionService"),qy=Qi("CharacterJoinerService"),gl=Qi("ThemeService"),Wy=Qi("LinkProviderService"),QC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xb.isErrorNoTelemetry(e)?new xb(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)}},JC=new QC;function xu(e){ek(e)||JC.onUnexpectedError(e)}var Wf="Canceled";function ek(e){return e instanceof tk?!0:e instanceof Error&&e.name===Wf&&e.message===Wf}var tk=class extends Error{constructor(){super(Wf),this.name=this.message}};function ik(e){return new Error(`Illegal argument: ${e}`)}var xb=class Gf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gf)return t;let i=new Gf;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Yf=class Gy extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Gy.prototype)}};function Gn(e,t=0){return e[e.length-(1+t)]}var nk;(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})(nk||(nk={}));function rk(e,t){let i=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(i,arguments))),a}}var Yy;(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 H=R.length-1;H>=0;H--)yield R[H]}e.reverse=h;function p(R){return!R||R[Symbol.iterator]().next().done===!0}e.isEmpty=p;function f(R){return R[Symbol.iterator]().next().value}e.first=f;function _(R,H){let D=0;for(let ie of R)if(H(ie,D++))return!0;return!1}e.some=_;function g(R,H){for(let D of R)if(H(D))return D}e.find=g;function*b(R,H){for(let D of R)H(D)&&(yield D)}e.filter=b;function*v(R,H){let D=0;for(let ie of R)yield H(ie,D++)}e.map=v;function*S(R,H){let D=0;for(let ie of R)yield*H(ie,D++)}e.flatMap=S;function*N(...R){for(let H of R)yield*H}e.concat=N;function B(R,H,D){let ie=D;for(let ue of R)ie=H(ie,ue);return ie}e.reduce=B;function*E(R,H,D=R.length){for(H<0&&(H+=R.length),D<0?D+=R.length:D>R.length&&(D=R.length);H<D;H++)yield R[H]}e.slice=E;function z(R,H=Number.POSITIVE_INFINITY){let D=[];if(H===0)return[D,R];let ie=R[Symbol.iterator]();for(let ue=0;ue<H;ue++){let ve=ie.next();if(ve.done)return[D,e.empty()];D.push(ve.value)}return[D,{[Symbol.iterator](){return ie}}]}e.consume=z;async function I(R){let H=[];for await(let D of R)H.push(D);return Promise.resolve(H)}e.asyncToArray=I})(Yy||(Yy={}));function xa(e){if(Yy.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 sk(...e){return ii(()=>xa(e))}function ii(e){return{dispose:rk(()=>{e()})}}var Vy=class Ky{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{xa(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?Ky.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)}};Vy.DISABLE_DISPOSED_WARNING=!1;var $s=Vy,dt=class{constructor(){this._store=new $s,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)}};dt.None=Object.freeze({dispose(){}});var fl=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}},as=typeof window=="object"?window:globalThis,Vf=class Kf{constructor(t){this.element=t,this.next=Kf.Undefined,this.prev=Kf.Undefined}};Vf.Undefined=new Vf(void 0);var ai=Vf,_b=class{constructor(){this._first=ai.Undefined,this._last=ai.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ai.Undefined}clear(){let e=this._first;for(;e!==ai.Undefined;){let t=e.next;e.prev=ai.Undefined,e.next=ai.Undefined,e=t}this._first=ai.Undefined,this._last=ai.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new ai(e);if(this._first===ai.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!==ai.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ai.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ai.Undefined&&e.next!==ai.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ai.Undefined&&e.next===ai.Undefined?(this._first=ai.Undefined,this._last=ai.Undefined):e.next===ai.Undefined?(this._last=this._last.prev,this._last.next=ai.Undefined):e.prev===ai.Undefined&&(this._first=this._first.next,this._first.prev=ai.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ai.Undefined;)yield e.element,e=e.next}},ak=globalThis.performance&&typeof globalThis.performance.now=="function",lk=class Xy{static create(t){return new Xy(t)}constructor(t){this._now=ak&&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}},ln;(e=>{e.None=()=>dt.None;function t(F,Y){return g(F,()=>{},0,void 0,!0,void 0,Y)}e.defer=t;function i(F){return(Y,K=null,$)=>{let T=!1,q;return q=F(W=>{if(!T)return q?q.dispose():T=!0,Y.call(K,W)},null,$),T&&q.dispose(),q}}e.once=i;function s(F,Y,K){return f(($,T=null,q)=>F(W=>$.call(T,Y(W)),null,q),K)}e.map=s;function a(F,Y,K){return f(($,T=null,q)=>F(W=>{Y(W),$.call(T,W)},null,q),K)}e.forEach=a;function o(F,Y,K){return f(($,T=null,q)=>F(W=>Y(W)&&$.call(T,W),null,q),K)}e.filter=o;function c(F){return F}e.signal=c;function h(...F){return(Y,K=null,$)=>{let T=sk(...F.map(q=>q(W=>Y.call(K,W))));return _(T,$)}}e.any=h;function p(F,Y,K,$){let T=K;return s(F,q=>(T=Y(T,q),T),$)}e.reduce=p;function f(F,Y){let K,$={onWillAddFirstListener(){K=F(T.fire,T)},onDidRemoveLastListener(){K==null||K.dispose()}},T=new we($);return Y==null||Y.add(T),T.event}function _(F,Y){return Y instanceof Array?Y.push(F):Y&&Y.add(F),F}function g(F,Y,K=100,$=!1,T=!1,q,W){let ge,j,A,Z=0,k,oe={leakWarningThreshold:q,onWillAddFirstListener(){ge=F(V=>{Z++,j=Y(j,V),$&&!A&&(ae.fire(j),j=void 0),k=()=>{let X=j;j=void 0,A=void 0,(!$||Z>1)&&ae.fire(X),Z=0},typeof K=="number"?(clearTimeout(A),A=setTimeout(k,K)):A===void 0&&(A=0,queueMicrotask(k))})},onWillRemoveListener(){T&&Z>0&&(k==null||k())},onDidRemoveLastListener(){k=void 0,ge.dispose()}},ae=new we(oe);return W==null||W.add(ae),ae.event}e.debounce=g;function b(F,Y=0,K){return e.debounce(F,($,T)=>$?($.push(T),$):[T],Y,void 0,!0,void 0,K)}e.accumulate=b;function v(F,Y=($,T)=>$===T,K){let $=!0,T;return o(F,q=>{let W=$||!Y(q,T);return $=!1,T=q,W},K)}e.latch=v;function S(F,Y,K){return[e.filter(F,Y,K),e.filter(F,$=>!Y($),K)]}e.split=S;function N(F,Y=!1,K=[],$){let T=K.slice(),q=F(j=>{T?T.push(j):ge.fire(j)});$&&$.add(q);let W=()=>{T==null||T.forEach(j=>ge.fire(j)),T=null},ge=new we({onWillAddFirstListener(){q||(q=F(j=>ge.fire(j)),$&&$.add(q))},onDidAddFirstListener(){T&&(Y?setTimeout(W):W())},onDidRemoveLastListener(){q&&q.dispose(),q=null}});return $&&$.add(ge),ge.event}e.buffer=N;function B(F,Y){return(K,$,T)=>{let q=Y(new z);return F(function(W){let ge=q.evaluate(W);ge!==E&&K.call($,ge)},void 0,T)}}e.chain=B;let E=Symbol("HaltChainable");class z{constructor(){this.steps=[]}map(Y){return this.steps.push(Y),this}forEach(Y){return this.steps.push(K=>(Y(K),K)),this}filter(Y){return this.steps.push(K=>Y(K)?K:E),this}reduce(Y,K){let $=K;return this.steps.push(T=>($=Y($,T),$)),this}latch(Y=(K,$)=>K===$){let K=!0,$;return this.steps.push(T=>{let q=K||!Y(T,$);return K=!1,$=T,q?T:E}),this}evaluate(Y){for(let K of this.steps)if(Y=K(Y),Y===E)break;return Y}}function I(F,Y,K=$=>$){let $=(...ge)=>W.fire(K(...ge)),T=()=>F.on(Y,$),q=()=>F.removeListener(Y,$),W=new we({onWillAddFirstListener:T,onDidRemoveLastListener:q});return W.event}e.fromNodeEventEmitter=I;function R(F,Y,K=$=>$){let $=(...ge)=>W.fire(K(...ge)),T=()=>F.addEventListener(Y,$),q=()=>F.removeEventListener(Y,$),W=new we({onWillAddFirstListener:T,onDidRemoveLastListener:q});return W.event}e.fromDOMEventEmitter=R;function H(F){return new Promise(Y=>i(F)(Y))}e.toPromise=H;function D(F){let Y=new we;return F.then(K=>{Y.fire(K)},()=>{Y.fire(void 0)}).finally(()=>{Y.dispose()}),Y.event}e.fromPromise=D;function ie(F,Y){return F(K=>Y.fire(K))}e.forward=ie;function ue(F,Y,K){return Y(K),F($=>Y($))}e.runAndSubscribe=ue;class ve{constructor(Y,K){this._observable=Y,this._counter=0,this._hasChanged=!1;let $={onWillAddFirstListener:()=>{Y.addObserver(this)},onDidRemoveLastListener:()=>{Y.removeObserver(this)}};this.emitter=new we($),K&&K.add(this.emitter)}beginUpdate(Y){this._counter++}handlePossibleChange(Y){}handleChange(Y,K){this._hasChanged=!0}endUpdate(Y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function L(F,Y){return new ve(F,Y).emitter.event}e.fromObservable=L;function re(F){return(Y,K,$)=>{let T=0,q=!1,W={beginUpdate(){T++},endUpdate(){T--,T===0&&(F.reportChanges(),q&&(q=!1,Y.call(K)))},handlePossibleChange(){},handleChange(){q=!0}};F.addObserver(W),F.reportChanges();let ge={dispose(){F.removeObserver(W)}};return $ instanceof $s?$.add(ge):Array.isArray($)&&$.push(ge),ge}}e.fromObservableLight=re})(ln||(ln={}));var Xf=class Zf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Zf._idPool++}`,Zf.all.add(this)}start(t){this._stopWatch=new lk,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}}};Xf.all=new Set,Xf._idPool=0;var ok=Xf,ck=-1,Zy=class Qy{constructor(t,i,s=(Qy._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 dk(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}};Zy._idPool=1;var uk=Zy,hk=class Jy{constructor(t){this.value=t}static create(){let t=new Error;return new Jy(t.stack??"")}print(){console.warn(this.value.split(`
|
|
67
|
+
`).slice(2).join(`
|
|
68
|
+
`))}},dk=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},fk=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},pk=0,nf=class{constructor(e){this.value=e,this.id=pk++}},mk=2,gk,we=class{constructor(t){var i,s,a,o;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new uk((t==null?void 0:t.onListenerError)??xu,((s=this._options)==null?void 0:s.leakWarningThreshold)??ck):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new ok(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,f,_,g;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 fk(`${b}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((h=this._options)==null?void 0:h.onListenerError)||xu)(S),dt.None}if(this._disposed)return dt.None;i&&(t=t.bind(i));let a=new nf(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hk.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof nf?(this._deliveryQueue??(this._deliveryQueue=new xk),this._listeners=[this._listeners,a]):this._listeners.push(a):((f=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||f.call(p,this),this._listeners=a,(g=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||g.call(_,this)),this._size++;let c=ii(()=>{o==null||o(),this._removeListener(a)});return s instanceof $s?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*mk<=i.length){let f=0;for(let _=0;_<i.length;_++)i[_]?i[f++]=i[_]:a&&(this._deliveryQueue.end--,f<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=f}}_deliver(t,i){var a;if(!t)return;let s=((a=this._options)==null?void 0:a.onListenerError)||xu;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 nf)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}},xk=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}},Qf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,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}};Qf.INSTANCE=new Qf;var Gp=Qf;function _k(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Gp.INSTANCE.onDidChangeZoomLevel;function bk(e){return Gp.INSTANCE.getZoomFactor(e)}Gp.INSTANCE.onDidChangeFullscreen;var xl=typeof navigator=="object"?navigator.userAgent:"",Jf=xl.indexOf("Firefox")>=0,vk=xl.indexOf("AppleWebKit")>=0,Yp=xl.indexOf("Chrome")>=0,yk=!Yp&&xl.indexOf("Safari")>=0;xl.indexOf("Electron/")>=0;xl.indexOf("Android")>=0;var rf=!1;if(typeof as.matchMedia=="function"){let e=as.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=as.matchMedia("(display-mode: fullscreen)");rf=e.matches,_k(as,e,({matches:i})=>{rf&&t.matches||(rf=i)})}var ol="en",ep=!1,tp=!1,_u=!1,e0=!1,nu,bu=ol,bb=ol,Sk,_r,ga=globalThis,an,Ay;typeof ga.vscode<"u"&&typeof ga.vscode.process<"u"?an=ga.vscode.process:typeof process<"u"&&typeof((Ay=process==null?void 0:process.versions)==null?void 0:Ay.node)=="string"&&(an=process);var Ry,wk=typeof((Ry=an==null?void 0:an.versions)==null?void 0:Ry.electron)=="string",Ck=wk&&(an==null?void 0:an.type)==="renderer",Dy;if(typeof an=="object"){ep=an.platform==="win32",tp=an.platform==="darwin",_u=an.platform==="linux",_u&&an.env.SNAP&&an.env.SNAP_REVISION,an.env.CI||an.env.BUILD_ARTIFACTSTAGINGDIRECTORY,nu=ol,bu=ol;let e=an.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);nu=t.userLocale,bb=t.osLocale,bu=t.resolvedLanguage||ol,Sk=(Dy=t.languagePack)==null?void 0:Dy.translationsConfigFile}catch{}e0=!0}else typeof navigator=="object"&&!Ck?(_r=navigator.userAgent,ep=_r.indexOf("Windows")>=0,tp=_r.indexOf("Macintosh")>=0,(_r.indexOf("Macintosh")>=0||_r.indexOf("iPad")>=0||_r.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,_u=_r.indexOf("Linux")>=0,(_r==null?void 0:_r.indexOf("Mobi"))>=0,bu=globalThis._VSCODE_NLS_LANGUAGE||ol,nu=navigator.language.toLowerCase(),bb=nu):console.error("Unable to resolve platform.");var t0=ep,Dr=tp,kk=_u,vb=e0,Mr=_r,Ls=bu,Ek;(e=>{function t(){return Ls}e.value=t;function i(){return Ls.length===2?Ls==="en":Ls.length>=3?Ls[0]==="e"&&Ls[1]==="n"&&Ls[2]==="-":!1}e.isDefaultVariant=i;function s(){return Ls==="en"}e.isDefault=s})(Ek||(Ek={}));var Nk=typeof ga.postMessage=="function"&&!ga.importScripts;(()=>{if(Nk){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 jk=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!jk&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var tl=typeof navigator=="object"?navigator:{};vb||document.queryCommandSupported&&document.queryCommandSupported("copy")||tl&&tl.clipboard&&tl.clipboard.writeText,vb||tl&&tl.clipboard&&tl.clipboard.readText;var Vp=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}},sf=new Vp,yb=new Vp,Sb=new Vp,Tk=new Array(230),i0;(e=>{function t(h){return sf.keyCodeToStr(h)}e.toString=t;function i(h){return sf.strToKeyCode(h)}e.fromString=i;function s(h){return yb.keyCodeToStr(h)}e.toUserSettingsUS=s;function a(h){return Sb.keyCodeToStr(h)}e.toUserSettingsGeneral=a;function o(h){return yb.strToKeyCode(h)||Sb.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 sf.keyCodeToStr(h)}e.toElectronAccelerator=c})(i0||(i0={}));var Ak=class n0{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 n0&&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 Rk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Rk=class{constructor(e){if(e.length===0)throw ik("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 Dk(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return i0.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Jf)switch(t){case 59:return 85;case 60:if(kk)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(vk&&(Dr&&t===93||!Dr&&t===92))return 57;return Tk[t]||0}var Mk=Dr?256:2048,Bk=512,Lk=1024,Ok=Dr?2048:256,wb=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=Dk(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|=Mk),this.altKey&&(t|=Bk),this.shiftKey&&(t|=Lk),this.metaKey&&(t|=Ok),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ak(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Cb=new WeakMap;function zk(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 Pk=class{static getSameOriginWindowChain(e){let t=Cb.get(e);if(!t){t=[],Cb.set(e,t);let i=e,s;do s=zk(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}}},ru=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=Pk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},kb=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(Yp){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?Jf&&!Dr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")yk&&t0?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?Jf&&!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()}},r0=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Ik;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Hk?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ln.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:r0})})(Ik||(Ik={}));var Hk=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?r0:(this._emitter||(this._emitter=new we),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 Yf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Yf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Uk=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 Yf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ii(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},$k;(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})($k||($k={}));var Eb=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 we,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 ln.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())}};Eb.EMPTY=Eb.fromArray([]);var{getWindow:Ar,getWindowId:Fk,onDidRegisterWindow:qk}=(function(){let e=new Map,t={window:as,disposables:new $s};e.set(as.vscodeWindowId,t);let i=new we,s=new we,a=new we;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 dt.None;let h=new $s,p={window:c,disposables:h.add(new $s)};return e.set(c.vscodeWindowId,p),h.add(ii(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(Xe(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 f;let h=c;if((f=h==null?void 0:h.ownerDocument)!=null&&f.defaultView)return h.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:as},getDocument(c){return Ar(c).document}}})(),Wk=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 Xe(e,t,i,s){return new Wk(e,t,i,s)}var Nb=function(e,t,i,s){return Xe(e,t,i,s)},Xp,Gk=class extends Uk{constructor(e){super(),this.defaultTarget=e&&Ar(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},jb=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){xu(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(jb.sort),c.shift().execute();s.set(o,!1)};Xp=(o,c,h=0)=>{let p=Fk(o),f=new jb(c,h),_=e.get(p);return _||(_=[],e.set(p,_)),_.push(f),i.get(p)||(i.set(p,!0),o.requestAnimationFrame(()=>a(p))),f}})();function Yk(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"},Vk=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=Dn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Dn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Dn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Dn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Dn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Dn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Dn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Dn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Dn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Dn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Dn(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=Dn(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=Dn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Dn(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 Dn(e){return typeof e=="number"?`${e}px`:e}function Ro(e){return new Vk(e)}var s0=class{constructor(){this._hooks=new $s,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(ii(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Ar(e)}this._hooks.add(Xe(o,qi.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Xe(o,qi.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Kk(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 jr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(jr||(jr={}));var wo=class hn extends dt{constructor(){super(),this.dispatched=!1,this.targets=new _b,this.ignoreTargets=new _b,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ln.runAndSubscribe(qk,({window:t,disposables:i})=>{i.add(Xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:as,disposables:this._store}))}static addTarget(t){if(!hn.isTouchDevice())return dt.None;hn.INSTANCE||(hn.INSTANCE=new hn);let i=hn.INSTANCE.targets.push(t);return ii(i)}static ignoreTarget(t){if(!hn.isTouchDevice())return dt.None;hn.INSTANCE||(hn.INSTANCE=new hn);let i=hn.INSTANCE.ignoreTargets.push(t);return ii(i)}static isTouchDevice(){return"ontouchstart"in as||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(jr.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],f=Date.now()-p.initialTimeStamp;if(f<hn.HOLD_DELAY&&Math.abs(p.initialPageX-Gn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Gn(p.rollingPageY))<30){let _=this.newGestureEvent(jr.Tap,p.initialTarget);_.pageX=Gn(p.rollingPageX),_.pageY=Gn(p.rollingPageY),this.dispatchEvent(_)}else if(f>=hn.HOLD_DELAY&&Math.abs(p.initialPageX-Gn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Gn(p.rollingPageY))<30){let _=this.newGestureEvent(jr.Contextmenu,p.initialTarget);_.pageX=Gn(p.rollingPageX),_.pageY=Gn(p.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=Gn(p.rollingPageX),g=Gn(p.rollingPageY),b=Gn(p.rollingTimestamps)-p.rollingTimestamps[0],v=_-p.rollingPageX[0],S=g-p.rollingPageY[0],N=[...this.targets].filter(B=>p.initialTarget instanceof Node&&B.contains(p.initialTarget));this.inertia(t,N,s,Math.abs(v)/b,v>0?1:-1,_,Math.abs(S)/b,S>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(jr.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===jr.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===jr.Change||t.type===jr.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,f){this.handle=Xp(t,()=>{let _=Date.now(),g=_-s,b=0,v=0,S=!0;a+=hn.SCROLL_FRICTION*g,h+=hn.SCROLL_FRICTION*g,a>0&&(S=!1,b=o*a*g),h>0&&(S=!1,v=p*h*g);let N=this.newGestureEvent(jr.Change);N.translationX=b,N.translationY=v,i.forEach(B=>B.dispatchEvent(N)),S||this.inertia(t,i,_,a,o,c+b,h,p,f+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(jr.Change,c.initialTarget);h.translationX=o.pageX-Gn(c.rollingPageX),h.translationY=o.pageY-Gn(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)}};wo.SCROLL_FRICTION=-.005,wo.HOLD_DELAY=700,wo.CLEAR_TAP_COUNT_TIME=400,fi([Kk],wo,"isTouchDevice",1);var Xk=wo,Zp=class extends dt{onclick(e,t){this._register(Xe(e,qi.CLICK,i=>t(new ru(Ar(e),i))))}onmousedown(e,t){this._register(Xe(e,qi.MOUSE_DOWN,i=>t(new ru(Ar(e),i))))}onmouseover(e,t){this._register(Xe(e,qi.MOUSE_OVER,i=>t(new ru(Ar(e),i))))}onmouseleave(e,t){this._register(Xe(e,qi.MOUSE_LEAVE,i=>t(new ru(Ar(e),i))))}onkeydown(e,t){this._register(Xe(e,qi.KEY_DOWN,i=>t(new wb(i))))}onkeyup(e,t){this._register(Xe(e,qi.KEY_UP,i=>t(new wb(i))))}oninput(e,t){this._register(Xe(e,qi.INPUT,t))}onblur(e,t){this._register(Xe(e,qi.BLUR,t))}onfocus(e,t){this._register(Xe(e,qi.FOCUS,t))}onchange(e,t){this._register(Xe(e,qi.CHANGE,t))}ignoreGesture(e){return Xk.ignoreTarget(e)}},Tb=11,Zk=class extends Zp{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=Tb+"px",this.domNode.style.height=Tb+"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 s0),this._register(Nb(this.bgDomNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nb(this.domNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Gk),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()}},Qk=class ip{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 ip(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 ip(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}}},Jk=class extends dt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qk(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 Rb(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=Rb.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)))}},Ab=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function af(e,t){let i=t-e;return function(s){return e+i*i2(s)}}function e2(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Rb=class np{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),e2(af(t,a),af(o,i),.33)}return af(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 Ab(s,a,!1)}return new Ab(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return np.start(t,i,s)}static start(t,i,s){s=s+10;let a=Date.now()-10;return new np(t,i,a,s)}};function t2(e){return Math.pow(e,3)}function i2(e){return 1-t2(1-e)}var n2=class extends dt{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":"")))}},r2=140,a0=class extends Zp{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 n2(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new s0),this._shouldRender=!0,this.domNode=Ro(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(Xe(this.domNode.domNode,qi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zk(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Ro(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(Xe(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=Yk(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(t0&&c>r2){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()}},l0=class rp{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 rp(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 f=Math.round(Math.max(20,Math.floor(s*h/a))),_=(h-f)/(a-s),g=o*_;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:_,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=rp._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)}},s2=class extends a0{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new l0(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}},a2=class extends a0{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new l0(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}},l2=500,Db=50,o2=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},sp=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(Yp){let i=Ar(t.browserEvent),s=bk(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 o2(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),f=Math.max(Math.min(o,h),1),_=Math.max(a,c),g=Math.max(o,h);_%p===0&&g%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};sp.INSTANCE=new sp;var c2=sp,u2=class extends Zp{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=d2(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 a2(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new s2(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=Ro(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ro(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ro(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=xa(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 kb(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xa(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new kb(i))};this._mouseWheelToDispose.push(Xe(this._listenOnDomNode,qi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=c2.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(),f={};if(o){let _=Db*o,g=p.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(f,g)}if(c){let _=Db*c,g=p.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(f,g)}f=this._scrollable.validateScrollPosition(f),(p.scrollLeft!==f.scrollLeft||p.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),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(),l2)}},h2=class extends u2{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 d2(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 ap=class extends dt{constructor(e,t,i,s,a,o,c,h){super(),this._bufferService=i,this._optionsService=c,this._renderService=h,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jk({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Xp(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new h2(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(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ln.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ii(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ii(()=>this._styleElement.remove())),this._register(ln.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(f=>this._handleScroll(f)))}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}};ap=fi([je(2,Sn),je(3,ls),je(4,Uy),je(5,gl),je(6,wn),je(7,os)],ap);var lp=class extends dt{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(ii(()=>{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()}};lp=fi([je(1,Sn),je(2,ls),je(3,qo),je(4,os)],lp);var f2=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},Os={full:0,left:0,center:0,right:0},ho={full:0,left:0,center:0,right:0},ju=class extends dt{constructor(e,t,i,s,a,o,c,h){var f;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 f2,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(),(f=this._viewportElement.parentElement)==null||f.insertBefore(this._canvas,this._viewportElement),this._register(ii(()=>{var _;return(_=this._canvas)==null?void 0:_.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);Os.full=this._canvas.width,Os.left=e,Os.center=t,Os.right=e,this._refreshDrawHeightConstants(),ho.full=1,ho.left=1,ho.center=1+Os.left,ho.right=1+Os.left+Os.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(ho[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Er[e.position||"full"]/2),Os[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}))}};ju=fi([je(2,Sn),je(3,qo),je(4,os),je(5,wn),je(6,gl),je(7,ls)],ju);var pe;(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=""))(pe||(pe={}));var vu;(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=""))(vu||(vu={}));var o0;(e=>e.ST=`${pe.ESC}\\`)(o0||(o0={}));var op=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(`${pe.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)}}};op=fi([je(2,Sn),je(3,wn),je(4,va),je(5,os)],op);var Wi=0,Gi=0,Yi=0,hi=0,Mb={css:"#00000000",rgba:0},Ri;(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})(Ri||(Ri={}));var ei;(e=>{function t(p,f){if(hi=(f.rgba&255)/255,hi===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,g=f.rgba>>16&255,b=f.rgba>>8&255,v=p.rgba>>24&255,S=p.rgba>>16&255,N=p.rgba>>8&255;Wi=v+Math.round((_-v)*hi),Gi=S+Math.round((g-S)*hi),Yi=N+Math.round((b-N)*hi);let B=Ri.toCss(Wi,Gi,Yi),E=Ri.toRgba(Wi,Gi,Yi);return{css:B,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,f,_){let g=yu.ensureContrastRatio(p.rgba,f.rgba,_);if(g)return Ri.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(p){let f=(p.rgba|255)>>>0;return[Wi,Gi,Yi]=yu.toChannels(f),{css:Ri.toCss(Wi,Gi,Yi),rgba:f}}e.opaque=a;function o(p,f){return hi=Math.round(f*255),[Wi,Gi,Yi]=yu.toChannels(p.rgba),{css:Ri.toCss(Wi,Gi,Yi,hi),rgba:Ri.toRgba(Wi,Gi,Yi,hi)}}e.opacity=o;function c(p,f){return hi=p.rgba&255,o(p,hi*f/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(ei||(ei={}));var li;(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),Ri.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),hi=parseInt(a.slice(4,5).repeat(2),16),Ri.toColor(Wi,Gi,Yi,hi);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]),hi=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ri.toColor(Wi,Gi,Yi,hi);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,hi]=t.getImageData(0,0,1,1).data,hi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ri.toRgba(Wi,Gi,Yi,hi),css:a}}e.toColor=s})(li||(li={}));var _n;(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,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),g=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+g*.0722}e.relativeLuminance2=i})(_n||(_n={}));var yu;(e=>{function t(c,h){if(hi=(h&255)/255,hi===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,g=c>>24&255,b=c>>16&255,v=c>>8&255;return Wi=g+Math.round((p-g)*hi),Gi=b+Math.round((f-b)*hi),Yi=v+Math.round((_-v)*hi),Ri.toRgba(Wi,Gi,Yi)}e.blend=t;function i(c,h,p){let f=_n.relativeLuminance(c>>8),_=_n.relativeLuminance(h>>8);if(is(f,_)<p){if(_<f){let v=s(c,h,p),S=is(f,_n.relativeLuminance(v>>8));if(S<p){let N=a(c,h,p),B=is(f,_n.relativeLuminance(N>>8));return S>B?v:N}return v}let g=a(c,h,p),b=is(f,_n.relativeLuminance(g>>8));if(b<p){let v=s(c,h,p),S=is(f,_n.relativeLuminance(v>>8));return b>S?g:v}return g}}e.ensureContrastRatio=i;function s(c,h,p){let f=c>>24&255,_=c>>16&255,g=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=is(_n.relativeLuminance2(b,v,S),_n.relativeLuminance2(f,_,g));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=is(_n.relativeLuminance2(b,v,S),_n.relativeLuminance2(f,_,g));return(b<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let f=c>>24&255,_=c>>16&255,g=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=is(_n.relativeLuminance2(b,v,S),_n.relativeLuminance2(f,_,g));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=is(_n.relativeLuminance2(b,v,S),_n.relativeLuminance2(f,_,g));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})(yu||(yu={}));function ca(e){let t=e.toString(16);return t.length<2?"0"+t:t}function is(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var p2=class extends Fo{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()]}},Tu=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 f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(f-a>1){let _=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g<_.length;g++)i.push(_[g])}a=f,c=o,h=this._workCell.fg,p=this._workCell.bg}o+=this._workCell.getChars().length||Us.length}if(this._bufferService.cols-a>1){let f=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_<f.length;_++)i.push(f[_])}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 f=0;f<p.length;f++)Tu._mergeRanges(c,p[f])}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),f=t.getString(h).length||Us.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+=f}}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}};Tu=fi([je(0,Sn)],Tu);function m2(e){return 57508<=e&&e<=57558}function g2(e){return 9472<=e&&e<=9631}function x2(e){return m2(e)||g2(e)}function _2(){return{css:{canvas:su(),cell:su()},device:{canvas:su(),cell:su(),char:{width:0,height:0,left:0,top:0}}}}function su(){return{width:0,height:0}}var cp=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,f,_){let g=[],b=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,S=e.getNoBgTrimmedLength();i&&S<o+1&&(S=o+1);let N,B=0,E="",z=0,I=0,R=0,H=0,D=!1,ie=0,ue=!1,ve=0,L=0,re=[],F=f!==-1&&_!==-1;for(let Y=0;Y<S;Y++){e.loadCell(Y,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let $=!1,T=Y>=L,q=Y,W=this._workCell;if(b.length>0&&Y===b[0][0]&&T){let Re=b.shift(),et=this._isCellInSelection(Re[0],t);for(z=Re[0]+1;z<Re[1];z++)T&&(T=et===this._isCellInSelection(z,t));T&&(T=!i||o<Re[0]||o>=Re[1]),T?($=!0,W=new p2(this._workCell,e.translateToString(!0,Re[0],Re[1]),Re[1]-Re[0]),q=Re[1]-1,K=W.getWidth()):L=Re[1]}let ge=this._isCellInSelection(Y,t),j=i&&Y===o,A=F&&Y>=f&&Y<=_,Z=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,Re=>{Z=!0});let k=W.getChars()||Us;if(k===" "&&(W.isUnderline()||W.isOverline())&&(k=" "),ve=K*h-p.get(k,W.isBold(),W.isItalic()),!N)N=this._document.createElement("span");else if(B&&(ge&&ue||!ge&&!ue&&W.bg===I)&&(ge&&ue&&v.selectionForeground||W.fg===R)&&W.extended.ext===H&&A===D&&ve===ie&&!j&&!$&&!Z&&T){W.isInvisible()?E+=Us:E+=k,B++;continue}else B&&(N.textContent=E),N=this._document.createElement("span"),B=0,E="";if(I=W.bg,R=W.fg,H=W.extended.ext,D=A,ie=ve,ue=ge,$&&o>=Y&&o<=q&&(o=Y),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&re.push("xterm-cursor-blink"),re.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline");break}}if(W.isBold()&&re.push("xterm-bold"),W.isItalic()&&re.push("xterm-italic"),W.isDim()&&re.push("xterm-dim"),W.isInvisible()?E=Us:E=W.getChars()||Us,W.isUnderline()&&(re.push(`xterm-underline-${W.extended.underlineStyle}`),E===" "&&(E=" "),!W.isUnderlineColorDefault()))if(W.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${Fo.toColorRGB(W.getUnderlineColor()).join(",")})`;else{let Re=W.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&W.isBold()&&Re<8&&(Re+=8),N.style.textDecorationColor=v.ansi[Re].css}W.isOverline()&&(re.push("xterm-overline"),E===" "&&(E=" ")),W.isStrikethrough()&&re.push("xterm-strikethrough"),A&&(N.style.textDecoration="underline");let oe=W.getFgColor(),ae=W.getFgColorMode(),V=W.getBgColor(),X=W.getBgColorMode(),he=!!W.isInverse();if(he){let Re=oe;oe=V,V=Re;let et=ae;ae=X,X=et}let _e,Ae,Oe=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,Re=>{Re.options.layer!=="top"&&Oe||(Re.backgroundColorRGB&&(X=50331648,V=Re.backgroundColorRGB.rgba>>8&16777215,_e=Re.backgroundColorRGB),Re.foregroundColorRGB&&(ae=50331648,oe=Re.foregroundColorRGB.rgba>>8&16777215,Ae=Re.foregroundColorRGB),Oe=Re.options.layer==="top")}),!Oe&&ge&&(_e=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,V=_e.rgba>>8&16777215,X=50331648,Oe=!0,v.selectionForeground&&(ae=50331648,oe=v.selectionForeground.rgba>>8&16777215,Ae=v.selectionForeground)),Oe&&re.push("xterm-decoration-top");let He;switch(X){case 16777216:case 33554432:He=v.ansi[V],re.push(`xterm-bg-${V}`);break;case 50331648:He=Ri.toColor(V>>16,V>>8&255,V&255),this._addStyle(N,`background-color:#${Bb((V>>>0).toString(16),"0",6)}`);break;case 0:default:he?(He=v.foreground,re.push("xterm-bg-257")):He=v.background}switch(_e||W.isDim()&&(_e=ei.multiplyOpacity(He,.5)),ae){case 16777216:case 33554432:W.isBold()&&oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(oe+=8),this._applyMinimumContrast(N,He,v.ansi[oe],W,_e,void 0)||re.push(`xterm-fg-${oe}`);break;case 50331648:let Re=Ri.toColor(oe>>16&255,oe>>8&255,oe&255);this._applyMinimumContrast(N,He,Re,W,_e,Ae)||this._addStyle(N,`color:#${Bb(oe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(N,He,v.foreground,W,_e,Ae)||he&&re.push("xterm-fg-257")}re.length&&(N.className=re.join(" "),re.length=0),!j&&!$&&!Z&&T?B++:N.textContent=E,ve!==this.defaultSpacing&&(N.style.letterSpacing=`${ve}px`),g.push(N),Y=q}return N&&B&&(N.textContent=E),g}_applyMinimumContrast(e,t,i,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||x2(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=ei.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]}};cp=fi([je(1,qy),je(2,wn),je(3,ls),je(4,va),je(5,qo),je(6,gl)],cp);function Bb(e,t,i){for(;e.length<i;)e=t+e;return e}var b2=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}},v2=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 y2(){return new v2}var lf="xterm-dom-renderer-owner-",lr="xterm-rows",au="xterm-fg-",Lb="xterm-bg-",fo="xterm-focus",lu="xterm-selection",S2=1,up=class extends dt{constructor(e,t,i,s,a,o,c,h,p,f,_,g,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=f,this._bufferService=_,this._coreService=g,this._coreBrowserService=b,this._themeService=v,this._terminalClass=S2++,this._rowElements=[],this._selectionRenderModel=y2(),this.onRequestRedraw=this._register(new we).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(lu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=_2(),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(cp,document),this._element.classList.add(lf+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(ii(()=>{this._element.classList.remove(lf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new b2(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: ${ei.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}.${fo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${lr}.${fo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${lr}.${fo} .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} .${lu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${lu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${lu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${au}${o} { color: ${c.css}; }${this._terminalSelector} .${au}${o}.xterm-dim { color: ${ei.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Lb}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${au}257 { color: ${ei.opaque(e.background).css}; }${this._terminalSelector} .${au}257.xterm-dim { color: ${ei.multiplyOpacity(ei.opaque(e.background),.5).css}; }${this._terminalSelector} .${Lb}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(fo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(fo),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,f=o===a?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(o,p,f));let _=c-o-1;if(h.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==c){let g=a===c?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,0,g))}}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 f=p+i.ydisp,_=this._rowElements[p],g=i.lines.get(f);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,f,f===s,c,h,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${lf}${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,f=Math.min(h.x,a-1),_=this._optionsService.rawOptions.cursorBlink,g=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],B=h.lines.get(S);if(!N||!B)break;N.replaceChildren(...this._rowFactory.createRow(B,S,S===p,g,b,f,_,this.dimensions.css.cell.width,this._widthCache,o?v===i?e:0:-1,o?(v===s?t:a)-1:-1))}}};up=fi([je(7,qp),je(8,Hu),je(9,wn),je(10,Sn),je(11,va),je(12,ls),je(13,gl)],up);var hp=class extends dt{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new C2(this._optionsService))}catch{this._measureStrategy=this._register(new w2(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())}};hp=fi([je(2,wn)],hp);var c0=class extends dt{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)}},w2=class extends c0{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}},C2=class extends c0{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}},k2=class extends dt{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 E2(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(ln.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(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}},E2=class extends dt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new fl),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ii(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(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)}},N2=class extends dt{constructor(){super(),this.linkProviders=[],this._register(ii(()=>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 Qp(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 j2(e,t,i,s,a,o,c,h,p){if(!o)return;let f=Qp(e,t,i);if(f)return f[0]=Math.ceil((f[0]+(p?c/2:0))/c),f[1]=Math.ceil(f[1]/h),f[0]=Math.min(Math.max(f[0],1),s+(p?1:0)),f[1]=Math.min(Math.max(f[1],1),a),f}var dp=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,a){return j2(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=Qp(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])}}};dp=fi([je(0,os),je(1,Hu)],dp);var T2=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=[]}},u0={};IC(u0,{getSafariVersion:()=>R2,isChromeOS:()=>p0,isFirefox:()=>h0,isIpad:()=>D2,isIphone:()=>M2,isLegacyEdge:()=>A2,isLinux:()=>Jp,isMac:()=>Au,isNode:()=>Uu,isSafari:()=>d0,isWindows:()=>f0});var Uu=typeof process<"u"&&"title"in process,Wo=Uu?"node":navigator.userAgent,Go=Uu?"node":navigator.platform,h0=Wo.includes("Firefox"),A2=Wo.includes("Edge"),d0=/^((?!chrome|android).)*safari/i.test(Wo);function R2(){if(!d0)return 0;let e=Wo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Au=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Go),D2=Go==="iPad",M2=Go==="iPhone",f0=["Windows","Win16","Win32","WinCE"].includes(Go),Jp=Go.indexOf("Linux")>=0,p0=/\bCrOS\b/.test(Wo),m0=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()}},B2=class extends m0{_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())}}},L2=class extends m0{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ru=!Uu&&"requestIdleCallback"in window?L2:B2,O2=class{constructor(){this._queue=new Ru}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},fp=class extends dt{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 fl),this._pausedResizeTask=new O2,this._observerDisposable=this._register(new fl),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 we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new T2((f,_)=>this._renderRows(f,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new z2(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ii(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var f;return(f=this._renderer.value)==null?void 0:f.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(f=>this._registerIntersectionObserver(f,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=ii(()=>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()}};fp=fi([je(2,wn),je(3,Hu),je(4,va),je(5,qo),je(6,Sn),je(7,ls),je(8,gl)],fp);var z2=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 P2(e,t,i,s){let a=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return U2(a,o,e,t,i,s)+$u(o,t,i,s)+$2(a,o,e,t,i,s);let c;if(o===t)return c=a>e?"D":"C",zo(Math.abs(a-e),Oo(c,s));c=o>t?"D":"C";let h=Math.abs(o-t),p=H2(o>t?e:a,i)+(h-1)*i.cols+1+I2(o>t?a:e);return zo(p,Oo(c,s))}function I2(e,t){return e-1}function H2(e,t){return t.cols-e}function U2(e,t,i,s,a,o){return $u(t,s,a,o).length===0?"":zo(x0(e,t,e,t-_a(t,a),!1,a).length,Oo("D",o))}function $u(e,t,i,s){let a=e-_a(e,i),o=t-_a(t,i),c=Math.abs(a-o)-F2(e,t,i);return zo(c,Oo(g0(e,t),s))}function $2(e,t,i,s,a,o){let c;$u(t,s,a,o).length>0?c=s-_a(s,a):c=t;let h=s,p=q2(e,t,i,s,a,o);return zo(x0(e,c,i,h,p==="C",a).length,Oo(p,o))}function F2(e,t,i){var c;let s=0,a=e-_a(e,i),o=t-_a(t,i);for(let h=0;h<Math.abs(a-o);h++){let p=g0(e,t)==="A"?-1:1;(c=i.buffer.lines.get(a+p*h))!=null&&c.isWrapped&&s++}return s}function _a(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 q2(e,t,i,s,a,o){let c;return $u(i,s,a,o).length>0?c=s-_a(s,a):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function g0(e,t){return e>t?"A":"B"}function x0(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 Oo(e,t){let i=t?"O":"[";return pe.ESC+i+e}function zo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var W2=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 Ob(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 of=50,G2=15,Y2=50,V2=500,K2=" ",X2=new RegExp(K2,"g"),pp=class extends dt{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 we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new W2(this._bufferService),this._activeSelectionMode=0,this._register(ii(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.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(X2," ")).join(f0?`\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())),Jp&&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=Ob(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=Qp(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,-of),of),t/=of,t/Math.abs(t)+Math.round(t*(G2-1)))}shouldForceSelection(e){return Au?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(),Y2)}_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&&!(Au&&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<V2&&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=P2(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,f=e[0]-h,_=0,g=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 B=e[0],E=e[0];o.getWidth(B)===0&&(_++,B--),o.getWidth(E)===2&&(g++,E++);let z=o.getString(E).length;for(z>1&&(v+=z-1,p+=z-1);B>0&&h>0&&!this._isCharWordSeparator(o.loadCell(B-1,this._workCell));){o.loadCell(B-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,B--):I>1&&(b+=I-1,h-=I-1),h--,B--}for(;E<o.length&&p+1<c.length&&!this._isCharWordSeparator(o.loadCell(E+1,this._workCell));){o.loadCell(E+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,E++):I>1&&(v+=I-1,p+=I-1),p++,E++}}p++;let S=h+f-_+b,N=Math.min(this._bufferService.cols,p-h+_+g-b-v);if(!(!t&&c.slice(h,p).trim()==="")){if(i&&S===0&&o.getCodePoint(0)!==32){let B=a.lines.get(e[1]-1);if(B&&o.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let z=this._bufferService.cols-E.start;S-=z,N+=z}}}if(s&&S+N===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let B=a.lines.get(e[1]+1);if(B!=null&&B.isWrapped&&B.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=Ob(i,this._bufferService.cols)}};pp=fi([je(3,Sn),je(4,va),je(5,Wp),je(6,wn),je(7,os),je(8,ls)],pp);var zb=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={}}},Pb=class{constructor(){this._color=new zb,this._css=new zb}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=[li.toColor("#2e3436"),li.toColor("#cc0000"),li.toColor("#4e9a06"),li.toColor("#c4a000"),li.toColor("#3465a4"),li.toColor("#75507b"),li.toColor("#06989a"),li.toColor("#d3d7cf"),li.toColor("#555753"),li.toColor("#ef2929"),li.toColor("#8ae234"),li.toColor("#fce94f"),li.toColor("#729fcf"),li.toColor("#ad7fa8"),li.toColor("#34e2e2"),li.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:Ri.toCss(s,a,o),rgba:Ri.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Ri.toCss(s,s,s),rgba:Ri.toRgba(s,s,s)})}return e})()),fa=li.toColor("#ffffff"),Co=li.toColor("#000000"),Ib=li.toColor("#ffffff"),Hb=Co,po={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Z2=fa,mp=class extends dt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Pb,this._halfContrastCache=new Pb,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:fa,background:Co,cursor:Ib,cursorAccent:Hb,selectionForeground:void 0,selectionBackgroundTransparent:po,selectionBackgroundOpaque:ei.blend(Co,po),selectionInactiveBackgroundTransparent:po,selectionInactiveBackgroundOpaque:ei.blend(Co,po),scrollbarSliderBackground:ei.opacity(fa,.2),scrollbarSliderHoverBackground:ei.opacity(fa,.4),scrollbarSliderActiveBackground:ei.opacity(fa,.5),overviewRulerBorder:fa,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=Ut(e.foreground,fa),t.background=Ut(e.background,Co),t.cursor=ei.blend(t.background,Ut(e.cursor,Ib)),t.cursorAccent=ei.blend(t.background,Ut(e.cursorAccent,Hb)),t.selectionBackgroundTransparent=Ut(e.selectionBackground,po),t.selectionBackgroundOpaque=ei.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ut(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ei.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ut(e.selectionForeground,Mb):void 0,t.selectionForeground===Mb&&(t.selectionForeground=void 0),ei.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ei.opacity(t.selectionBackgroundTransparent,.3)),ei.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ei.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ut(e.scrollbarSliderBackground,ei.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ut(e.scrollbarSliderHoverBackground,ei.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ut(e.scrollbarSliderActiveBackground,ei.opacity(t.foreground,.5)),t.overviewRulerBorder=Ut(e.overviewRulerBorder,Z2),t.ansi=zi.slice(),t.ansi[0]=Ut(e.black,zi[0]),t.ansi[1]=Ut(e.red,zi[1]),t.ansi[2]=Ut(e.green,zi[2]),t.ansi[3]=Ut(e.yellow,zi[3]),t.ansi[4]=Ut(e.blue,zi[4]),t.ansi[5]=Ut(e.magenta,zi[5]),t.ansi[6]=Ut(e.cyan,zi[6]),t.ansi[7]=Ut(e.white,zi[7]),t.ansi[8]=Ut(e.brightBlack,zi[8]),t.ansi[9]=Ut(e.brightRed,zi[9]),t.ansi[10]=Ut(e.brightGreen,zi[10]),t.ansi[11]=Ut(e.brightYellow,zi[11]),t.ansi[12]=Ut(e.brightBlue,zi[12]),t.ansi[13]=Ut(e.brightMagenta,zi[13]),t.ansi[14]=Ut(e.brightCyan,zi[14]),t.ansi[15]=Ut(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]=Ut(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()}}};mp=fi([je(0,wn)],mp);function Ut(e,t){if(e!==void 0)try{return li.toColor(e)}catch{}return t}var Q2=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)}},J2=class{constructor(){this._services=new Q2,this._services.set(qp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=GC(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)}},eE={trace:0,debug:1,info:2,warn:3,error:4,off:5},tE="xterm.js: ",gp=class extends dt{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=eE[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?"":tE)+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)}};gp=fi([je(0,wn)],gp);var Ub=class extends dt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),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}},ht=3,Ai=Object.freeze(new Fo),ou=0,cf=2,ko=class _0{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ht);let a=i||hr.fromCharData([0,zy,1,0]);for(let o=0;o<t;++o)this.setCell(o,a);this.length=t}get(t){let i=this._data[t*ht+0],s=i&2097151;return[this._data[t*ht+1],i&2097152?this._combined[t]:s?Is(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*ht+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*ht+0]=t|2097152|i[2]<<22):this._data[t*ht+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*ht+0]>>22}hasWidth(t){return this._data[t*ht+0]&12582912}getFg(t){return this._data[t*ht+1]}getBg(t){return this._data[t*ht+2]}hasContent(t){return this._data[t*ht+0]&4194303}getCodePoint(t){let i=this._data[t*ht+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*ht+0]&2097152}getString(t){let i=this._data[t*ht+0];return i&2097152?this._combined[t]:i&2097151?Is(i&2097151):""}isProtected(t){return this._data[t*ht+2]&536870912}loadCell(t,i){return ou=t*ht,i.content=this._data[ou+0],i.fg=this._data[ou+1],i.bg=this._data[ou+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*ht+0]=i.content,this._data[t*ht+1]=i.fg,this._data[t*ht+2]=i.bg}setCellFromCodepoint(t,i,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*ht+0]=i|s<<22,this._data[t*ht+1]=a.fg,this._data[t*ht+2]=a.bg}addCodepointToCell(t,i,s){let a=this._data[t*ht+0];a&2097152?this._combined[t]+=Is(i):a&2097151?(this._combined[t]=Is(a&2097151)+Is(i),a&=-2097152,a|=2097152):a=i|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*ht+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*cf<this._data.buffer.byteLength;let s=t*ht;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*cf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*cf<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 _0(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*ht+0]&4194303)return t+(this._data[t*ht+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ht+0]&4194303||this._data[t*ht+2]&50331648)return t+(this._data[t*ht+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 f=0;f<ht;f++)this._data[(s+p)*ht+f]=c[(i+p)*ht+f];c[(i+p)*ht+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}else for(let p=0;p<a;p++){for(let f=0;f<ht;f++)this._data[(s+p)*ht+f]=c[(i+p)*ht+f];c[(i+p)*ht+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 f=parseInt(h[p],10);f>=i&&(this._combined[f-i+s]=t._combined[f])}}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*ht+0],h=c&2097151,p=c&2097152?this._combined[i]:h?Is(h):Us;if(o+=p,a)for(let f=0;f<p.length;++f)a.push(i);i+=c>>22||1}return a&&a.push(i),o}};function iE(e,t,i,s,a,o){let c=[];for(let h=0;h<e.length-1;h++){let p=h,f=e.get(++p);if(!f.isWrapped)continue;let _=[e.get(h)];for(;p<e.length&&f.isWrapped;)_.push(f),f=e.get(++p);if(!o&&s>=h&&s<p){h+=_.length-1;continue}let g=0,b=Po(_,g,t),v=1,S=0;for(;v<_.length;){let B=Po(_,v,t),E=B-S,z=i-b,I=Math.min(E,z);_[g].copyCellsFrom(_[v],S,b,I,!1),b+=I,b===i&&(g++,b=0),S+=I,S===B&&(v++,S=0),b===0&&g!==0&&_[g-1].getWidth(i-1)===2&&(_[g].copyCellsFrom(_[g-1],i-1,b++,1,!1),_[g-1].setCell(i-1,a))}_[g].replaceCells(b,i,a);let N=0;for(let B=_.length-1;B>0&&(B>g||_[B].getTrimmedLength()===0);B--)N++;N>0&&(c.push(h+_.length-N),c.push(N)),h+=_.length-1}return c}function nE(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 rE(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 sE(e,t,i){let s=[],a=e.map((p,f)=>Po(e,f,t)).reduce((p,f)=>p+f),o=0,c=0,h=0;for(;h<a;){if(a-h<i){s.push(a-h);break}o+=i;let p=Po(e,c,t);o>p&&(o-=p,c++);let f=e[c].getWidth(o-1)===2;f&&o--;let _=f?i-1:i;s.push(_),h+=_}return s}function Po(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 b0=class v0{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=v0._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};b0._nextId=1;var aE=b0,Hi={},pa=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 $b=4294967295,Fb=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=Ai.clone(),this.savedCharset=pa,this.markers=[],this._nullCell=hr.fromCharData([0,zy,1,0]),this._whitespaceCell=hr.fromCharData([0,Us,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ru,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ub(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 Nu),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 Nu),this._whitespaceCell}getBlankLine(e,t){return new ko(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>$b?$b:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ai);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 Ub(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Ai),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 ko(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 ko(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=iE(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ai),i);if(s.length>0){let a=nE(this.lines,s);rE(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Ai),a=i;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ko(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(Ai),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 I=this.ybase+this.y;if(I>=c&&I<c+p.length)continue}let f=p[p.length-1].getTrimmedLength(),_=sE(p,this._cols,e),g=_.length-p.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+g):b=Math.max(0,this.lines.length-this.lines.maxLength+g);let v=[];for(let I=0;I<g;I++){let R=this.getBlankLine(Ai,!0);v.push(R)}v.length>0&&(a.push({start:c+p.length+o,newLines:v}),o+=v.length),p.push(...v);let S=_.length-1,N=_[S];N===0&&(S--,N=_[S]);let B=p.length-g-1,E=f;for(;B>=0;){let I=Math.min(E,N);if(p[S]===void 0)break;if(p[S].copyCellsFrom(p[B],E-I,N-I,I,!0),N-=I,N===0&&(S--,N=_[S]),E-=I,E===0){B--;let R=Math.max(B,0);E=Po(p,R,this._cols)}}for(let I=0;I<p.length;I++)_[I]<e&&p[I].setCell(_[I],s);let z=g-b;for(;z-- >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+g,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,f=p-1,_=0,g=a[_];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(g&&g.start>f+b){for(let B=g.newLines.length-1;B>=0;B--)this.lines.set(N--,g.newLines[B]);N++,c.push({index:f+1,amount:g.newLines.length}),b+=g.newLines.length,g=a[++_]}else this.lines.set(N,h[f--]);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 aE(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)}},lE=class extends dt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),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 Fb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Fb(!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)}},y0=2,S0=1,xp=class extends dt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,y0),this.rows=Math.max(e.rawOptions.rows||0,S0),this.buffers=this._register(new lE(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))}};xp=fi([je(0,wn)],xp);var il={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:Au,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},oE=["normal","bold","100","200","300","400","500","600","700","800","900"],cE=class extends dt{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...il};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(ii(()=>{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 il))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in il))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=il[e]),!uE(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=il[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=oE.includes(t)?t:il[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 uE(e){return e==="block"||e==="underline"||e==="bar"}function Eo(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]&&Eo(e[s],t-1);return i}var qb=Object.freeze({insertMode:!1}),Wb=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 dt{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 we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Eo(qb),this.decPrivateModes=Eo(Wb)}reset(){this.modes=Eo(qb),this.decPrivateModes=Eo(Wb)}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=fi([je(0,Sn),je(1,$y),je(2,wn)],_p);var Gb={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 uf(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 hf=String.fromCharCode,Yb={DEFAULT:e=>{let t=[uf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${hf(t[0])}${hf(t[1])}${hf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${uf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${uf(e,!0)};${e.x};${e.y}${t}`}},bp=class extends dt{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 we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Gb))this.addProtocol(s,Gb[s]);for(let s of Object.keys(Yb))this.addEncoding(s,Yb[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)}};bp=fi([je(0,Sn),je(1,va),je(2,wn)],bp);var df=[[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]],hE=[[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 dE(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 fE=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<df.length;++e)Pi.fill(0,df[e][0],df[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pi[e]:dE(e,hE)?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 Su{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new fE;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 f=t.charCodeAt(o);56320<=f&&f<=57343?c=(c-55296)*1024+f-56320+65536:i+=this.wcwidth(f)}let h=this.charProperties(c,s),p=Su.extractWidth(h);Su.extractShouldJoin(h)&&(p-=Su.extractWidth(s)),i+=p,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},pE=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 Vb(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 mo=2147483647,mE=256,w0=class vp{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>mE)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 vp;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 vp(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>mo?mo: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>mo?mo: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,mo):t}},go=[],gE=class{constructor(){this._state=0,this._active=go,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=go}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=go,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||go,!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",Iu(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=go,this._id=-1,this._state=0}}},Yn=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+=Iu(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}},xo=[],xE=class{constructor(){this._handlers=Object.create(null),this._active=xo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xo}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=xo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||xo,!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",Iu(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=xo,this._ident=0}},No=new w0;No.addParam(0);var Kb=class{constructor(e){this._handler=e,this._data="",this._params=No,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():No,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Iu(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=No,this._data="",this._hitLimit=!1,i));return this._params=No,this._data="",this._hitLimit=!1,t}},_E=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,bE=(function(){let e=new _E(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})(),vE=class extends dt{constructor(e=bE){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 w0,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(ii(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new gE),this._dcsParser=this._register(new xE),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],f=p?p.length-1:-1;for(;f>=0&&(c=p[f](this._params),c!==!0);f--)if(c instanceof Promise)return this._preserveStack(3,p,f,a,h),c;f<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 _=this._escHandlers[this._collect<<8|s],g=_?_.length-1:-1;for(;g>=0&&(c=_[g](),c!==!0);g--)if(c instanceof Promise)return this._preserveStack(4,_,g,a,h),c;g<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}}},yE=/^([\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})$/,SE=/^[\da-f]+$/;function Xb(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=yE.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),SE.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 ff(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 wE(e,t=16){let[i,s,a]=e;return`rgb:${ff(i,t)}/${ff(s,t)}/${ff(a,t)}`}var CE={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zs=131072,Zb=10;function Qb(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 Jb=5e3,ev=0,kE=class extends dt{constructor(e,t,i,s,a,o,c,h,p=new vE){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 qC,this._utf8Decoder=new WC,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ai.clone(),this._eraseAttrDataInternal=Ai.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),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 yp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:_.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,_,g)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:_,data:g})}),this._parser.setDcsHandlerFallback((f,_,g)=>{_==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:_,payload:g})}),this._parser.setPrintHandler((f,_,g)=>this.print(f,_,g)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(vu.IND,()=>this.index()),this._parser.setExecuteHandler(vu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(vu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Yn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Yn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Yn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Yn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Yn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Yn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Yn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Yn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Yn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Yn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Yn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Yn(f=>this.restoreCursorColor(f))),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 f in Hi)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Kb((f,_)=>this.requestStatusString(f,_)))}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"),Jb))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Jb} 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>zs&&(o=this._parseStack.position+zs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<zs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,zs))),c||this._dirtyRowTracker.clearRange(),e.length>zs)for(let f=o;f<e.length;f+=zs){let _=f+zs<e.length?f+zs:e.length,g=typeof e=="string"?this._stringDecoder.decode(e.substring(f,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,g))return this._preserveStack(s,a,g,f),this._logSlowResolvingAsync(i),i}else if(!c){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,a,f,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,f=this._coreService.modes.insertMode,_=this._curAttrData,g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);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),B=N?ma.extractWidth(b):0;if(b=S,c&&this._onA11yChar.fire(Is(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-B>h){if(p){let E=g,z=this._activeBuffer.x-B;for(this._activeBuffer.x=B,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),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&g instanceof ko&&g.copyCellsFrom(E,z,0,B,!1);z<h;)E.setCellFromCodepoint(z++,0,1,_)}else if(this._activeBuffer.x=h-1,a===2)continue}if(N&&this._activeBuffer.x){let E=g.getWidth(this._activeBuffer.x-1)?1:2;g.addCodepointToCell(this._activeBuffer.x-E,s,a);for(let z=a-B;--z>=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(f&&(g.insertCells(this._activeBuffer.x,a-B,this._activeBuffer.getNullCell(_)),g.getWidth(h-1)===2&&g.setCellFromCodepoint(h-1,0,1,_)),g.setCellFromCodepoint(this._activeBuffer.x++,s,a,_),a>0)for(;--a;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=b,this._activeBuffer.x<h&&i-t>0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Qb(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Kb(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Yn(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(Ai));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 f=0;f<o.length;){let _=o.codePointAt(f)||0;c[h++]=_,f+=_>65535?2:1}let p=h;for(let f=1;f<i;++f)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(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.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,pa),this._charsetService.setgCharset(1,pa),this._charsetService.setgCharset(2,pa),this._charsetService.setgCharset(3,pa);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:f,alt:_}=h,g=this._optionsService.rawOptions,b=(N,B)=>(c.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${N};${B}$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(g.convertEol)):b(S,0):S===1?b(S,v(s.applicationCursorKeys)):S===3?b(S,g.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(g.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(f===_)):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|=Fo.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=Ai.fg,e.bg=Ai.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|=Ai.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Ai.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|=Ai.fg&16777215,s.bg&=-67108864,s.bg|=Ai.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.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(`${pe.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=Ai.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(!Qb(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(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Zb&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Zb&&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(tv(o))if(a==="?")t.push({type:0,index:o});else{let c=Xb(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=Xb(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]);tv(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,pa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(CE[e[0]],Hi[e[1]]||pa),!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=Ai.clone(),this._eraseAttrDataInternal=Ai.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(`${pe.ESC}${c}${pe.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)}},yp=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&&(ev=e,e=t,t=ev),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};yp=fi([je(0,Sn)],yp);function tv(e){return 0<=e&&e<256}var EE=5e7,iv=12,NE=50,jE=class extends dt{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 we),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>EE)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>=iv?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>=iv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>NE&&(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()}},Sp=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)))}};Sp=fi([je(0,Sn)],Sp);var nv=!1,TE=class extends dt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new fl),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new J2,this.optionsService=this._register(new cE(e)),this._instantiationService.setService(wn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(xp)),this._instantiationService.setService(Sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(gp)),this._instantiationService.setService($y,this._logService),this.coreService=this._register(this._instantiationService.createInstance(_p)),this._instantiationService.setService(va,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(bp)),this._instantiationService.setService(Uy,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ma)),this._instantiationService.setService(KC,this.unicodeService),this._charsetService=this._instantiationService.createInstance(pE),this._instantiationService.setService(VC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Sp),this._instantiationService.setService(Fy,this._oscLinkService),this._inputHandler=this._register(new kE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ln.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ln.forward(this._bufferService.onResize,this._onResize)),this._register(ln.forward(this.coreService.onData,this._onData)),this._register(ln.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 jE((t,i)=>this._inputHandler.parse(t,i))),this._register(ln.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),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&&!nv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),nv=!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,y0),t=Math.max(t,S0),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(Vb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Vb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ii(()=>{for(let t of e)t.dispose()})}}},AE={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 RE(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=pe.ESC+"OA":a.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(a.key=pe.ESC+a.key);break;case 9:if(e.shiftKey){a.key=pe.ESC+"[Z";break}a.key=pe.HT,a.cancel=!0;break;case 13:a.key=e.altKey?pe.ESC+pe.CR:pe.CR,a.cancel=!0;break;case 27:a.key=pe.ESC,e.altKey&&(a.key=pe.ESC+pe.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"D":t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"C":t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"A":t?a.key=pe.ESC+"OA":a.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"B":t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=pe.ESC+"[2~");break;case 46:o?a.key=pe.ESC+"[3;"+(o+1)+"~":a.key=pe.ESC+"[3~";break;case 36:o?a.key=pe.ESC+"[1;"+(o+1)+"H":t?a.key=pe.ESC+"OH":a.key=pe.ESC+"[H";break;case 35:o?a.key=pe.ESC+"[1;"+(o+1)+"F":t?a.key=pe.ESC+"OF":a.key=pe.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=pe.ESC+"[5;"+(o+1)+"~":a.key=pe.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=pe.ESC+"[6;"+(o+1)+"~":a.key=pe.ESC+"[6~";break;case 112:o?a.key=pe.ESC+"[1;"+(o+1)+"P":a.key=pe.ESC+"OP";break;case 113:o?a.key=pe.ESC+"[1;"+(o+1)+"Q":a.key=pe.ESC+"OQ";break;case 114:o?a.key=pe.ESC+"[1;"+(o+1)+"R":a.key=pe.ESC+"OR";break;case 115:o?a.key=pe.ESC+"[1;"+(o+1)+"S":a.key=pe.ESC+"OS";break;case 116:o?a.key=pe.ESC+"[15;"+(o+1)+"~":a.key=pe.ESC+"[15~";break;case 117:o?a.key=pe.ESC+"[17;"+(o+1)+"~":a.key=pe.ESC+"[17~";break;case 118:o?a.key=pe.ESC+"[18;"+(o+1)+"~":a.key=pe.ESC+"[18~";break;case 119:o?a.key=pe.ESC+"[19;"+(o+1)+"~":a.key=pe.ESC+"[19~";break;case 120:o?a.key=pe.ESC+"[20;"+(o+1)+"~":a.key=pe.ESC+"[20~";break;case 121:o?a.key=pe.ESC+"[21;"+(o+1)+"~":a.key=pe.ESC+"[21~";break;case 122:o?a.key=pe.ESC+"[23;"+(o+1)+"~":a.key=pe.ESC+"[23~";break;case 123:o?a.key=pe.ESC+"[24;"+(o+1)+"~":a.key=pe.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=pe.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=pe.DEL:e.keyCode===219?a.key=pe.ESC:e.keyCode===220?a.key=pe.FS:e.keyCode===221&&(a.key=pe.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(c=AE[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(h)a.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(p);e.shiftKey&&(f=f.toUpperCase()),a.key=pe.ESC+f}else if(e.keyCode===32)a.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=pe.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=pe.US),e.key==="@"&&(a.key=pe.NUL));break}return a}var vi=0,DE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ru,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ru,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||(vi=this._search(t),vi===-1)||this._getKey(this._array[vi])!==t)return!1;do if(this._array[vi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(vi),!0;while(++vi<this._array.length&&this._getKey(this._array[vi])===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&&(vi=this._search(e),!(vi<0||vi>=this._array.length)&&this._getKey(this._array[vi])===e))do yield this._array[vi];while(++vi<this._array.length&&this._getKey(this._array[vi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vi=this._search(e),!(vi<0||vi>=this._array.length)&&this._getKey(this._array[vi])===e))do t(this._array[vi]);while(++vi<this._array.length&&this._getKey(this._array[vi])===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}},pf=0,rv=0,ME=class extends dt{constructor(){super(),this._decorations=new DE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ii(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new BE(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=>{pf=a.options.x??0,rv=pf+(a.options.width??1),e>=pf&&e<rv&&(!i||(a.options.layer??"bottom")===i)&&s(a)})}},BE=class extends $s{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),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=li.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=li.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},LE=1e3,OE=class{constructor(e,t=LE){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)}},sv=20,Du=class extends dt{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 OE(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(Xe(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ii(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<sv+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
74
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===sv+1&&(this._liveRegion.textContent+=$f.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(),f=this._rowElements[a];f&&(h.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=h,this._rowColumns.set(f,c)),f.setAttribute("aria-posinset",p),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}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:f})=>{let _=p instanceof Text?p.parentNode:p,g=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(_);if(!b)return console.warn("columns is null. Race condition?"),null;let v=f<b.length?b[f]:b.slice(-1)[0]+1;return v>=this._terminal.cols&&(++g,v=0),{row:g,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})`}};Du=fi([je(1,qp),je(2,ls),je(3,os)],Du);var wp=class extends dt{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 we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ii(()=>{var o;xa(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(Xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Xe(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 f,_;if(this._isMouseOut)return;let p=h==null?void 0:h.map(g=>({link:g}));(f=this._activeProviderReplies)==null||f.set(o,p),i=this._checkLinkProviderResult(o,e,i),((_=this._activeProviderReplies)==null?void 0:_.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 f=h;f<=p;f++){if(i.has(f)){a.splice(o--,1);break}i.add(f)}}}}_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&&zE(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,xa(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}}};wp=fi([je(1,Wp),je(2,os),je(3,Sn),je(4,Wy)],wp);function zE(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 PE=class extends TE{constructor(e={}){super(e),this._linkifier=this._register(new fl),this.browser=u0,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new fl),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(ME),this._instantiationService.setService(qo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(N2),this._instantiationService.setService(Wy,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(qf)),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(ln.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ln.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ln.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ln.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ii(()=>{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=ei.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${wE(a)}${o0.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ri.toColor(...t.color));else{let o=i;this._themeService.modifyColors(c=>c[o]=Ri.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(Du,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.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(pe.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(Xe(this.element,"copy",t=>{this.hasSelection()&&$C(t,this._selectionService)}));let e=t=>FC(t,this.textarea,this.coreService,this.optionsService);this._register(Xe(this.textarea,"paste",e)),this._register(Xe(this.element,"paste",e)),h0?this._register(Xe(this.element,"mousedown",t=>{t.button===2&&mb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Xe(this.element,"contextmenu",t=>{mb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Jp&&this._register(Xe(this.element,"auxclick",t=>{t.button===1&&Oy(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Xe(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(Xe(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",Uf.get()),p0||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(k2,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ls,this._coreBrowserService),this._register(Xe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(hp,this._document,this._helperContainer),this._instantiationService.setService(Hu,this._charSizeService),this._themeService=this._instantiationService.createInstance(mp),this._instantiationService.setService(gl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Tu),this._instantiationService.setService(qy,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(fp,this.rows,this.screenElement)),this._instantiationService.setService(os,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(op,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(dp),this._instantiationService.setService(Wp,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(wp,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(ap,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(pp,this.element,this.screenElement,s)),this._instantiationService.setService(ZC,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(ln.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(lp,this.screenElement)),this._register(Xe(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(Du,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ju,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ju,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(up,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(o){var f,_,g,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=(g=(_=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:_.device)==null?void 0:g.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(Xe(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(Xe(t,"wheel",o=>{var c,h,p,f,_;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,(f=(p=(h=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(o,!0);let g=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!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){Ly(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=RE(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===pe.ETX||i.key===pe.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)&&(IE(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(Ai));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(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.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(`${pe.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(`${pe.ESC}[6;${a};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function IE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var HE=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)}},UE=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)}},av=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 UE(t)}getNullCell(){return new hr}},$E=class extends dt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new av(this._core.buffers.normal,"normal"),this._alternate=new av(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)}},FE=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)}},qE=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}},WE=["cols","rows"],Nr=0,GE=class extends dt{constructor(e){super(),this._core=this._register(new PE(e)),this._addonManager=this._register(new HE),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(WE.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 FE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new qE(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 $E(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 Uf.get()},set promptLabel(e){Uf.set(e)},get tooMuchOutput(){return $f.get()},set tooMuchOutput(e){$f.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 YE=2,VE=1,KE=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 g;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:((g=this._terminal.options.overviewRuler)==null?void 0:g.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,f=s-h,_=a-p-t;return{cols:Math.max(YE,Math.floor(_/e.css.cell.width)),rows:Math.max(VE,Math.floor(f/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 Vi=0,Ki=0,Xi=0,di=0,dn;(e=>{function t(a,o,c,h){return h!==void 0?`#${ua(a)}${ua(o)}${ua(c)}${ua(h)}`:`#${ua(a)}${ua(o)}${ua(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 XE;(e=>{function t(p,f){if(di=(f.rgba&255)/255,di===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,g=f.rgba>>16&255,b=f.rgba>>8&255,v=p.rgba>>24&255,S=p.rgba>>16&255,N=p.rgba>>8&255;Vi=v+Math.round((_-v)*di),Ki=S+Math.round((g-S)*di),Xi=N+Math.round((b-N)*di);let B=dn.toCss(Vi,Ki,Xi),E=dn.toRgba(Vi,Ki,Xi);return{css:B,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,f,_){let g=wu.ensureContrastRatio(p.rgba,f.rgba,_);if(g)return dn.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(p){let f=(p.rgba|255)>>>0;return[Vi,Ki,Xi]=wu.toChannels(f),{css:dn.toCss(Vi,Ki,Xi),rgba:f}}e.opaque=a;function o(p,f){return di=Math.round(f*255),[Vi,Ki,Xi]=wu.toChannels(p.rgba),{css:dn.toCss(Vi,Ki,Xi,di),rgba:dn.toRgba(Vi,Ki,Xi,di)}}e.opacity=o;function c(p,f){return di=p.rgba&255,o(p,di*f/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(XE||(XE={}));var sn;(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 Vi=parseInt(a.slice(1,2).repeat(2),16),Ki=parseInt(a.slice(2,3).repeat(2),16),Xi=parseInt(a.slice(3,4).repeat(2),16),dn.toColor(Vi,Ki,Xi);case 5:return Vi=parseInt(a.slice(1,2).repeat(2),16),Ki=parseInt(a.slice(2,3).repeat(2),16),Xi=parseInt(a.slice(3,4).repeat(2),16),di=parseInt(a.slice(4,5).repeat(2),16),dn.toColor(Vi,Ki,Xi,di);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 Vi=parseInt(o[1]),Ki=parseInt(o[2]),Xi=parseInt(o[3]),di=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),dn.toColor(Vi,Ki,Xi,di);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),[Vi,Ki,Xi,di]=t.getImageData(0,0,1,1).data,di!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:dn.toRgba(Vi,Ki,Xi,di),css:a}}e.toColor=s})(sn||(sn={}));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,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),g=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+g*.0722}e.relativeLuminance2=i})(bn||(bn={}));var wu;(e=>{function t(c,h){if(di=(h&255)/255,di===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,g=c>>24&255,b=c>>16&255,v=c>>8&255;return Vi=g+Math.round((p-g)*di),Ki=b+Math.round((f-b)*di),Xi=v+Math.round((_-v)*di),dn.toRgba(Vi,Ki,Xi)}e.blend=t;function i(c,h,p){let f=bn.relativeLuminance(c>>8),_=bn.relativeLuminance(h>>8);if(ns(f,_)<p){if(_<f){let v=s(c,h,p),S=ns(f,bn.relativeLuminance(v>>8));if(S<p){let N=a(c,h,p),B=ns(f,bn.relativeLuminance(N>>8));return S>B?v:N}return v}let g=a(c,h,p),b=ns(f,bn.relativeLuminance(g>>8));if(b<p){let v=s(c,h,p),S=ns(f,bn.relativeLuminance(v>>8));return b>S?g:v}return g}}e.ensureContrastRatio=i;function s(c,h,p){let f=c>>24&255,_=c>>16&255,g=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=ns(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(f,_,g));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=ns(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(f,_,g));return(b<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let f=c>>24&255,_=c>>16&255,g=c>>8&255,b=h>>24&255,v=h>>16&255,S=h>>8&255,N=ns(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(f,_,g));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=ns(bn.relativeLuminance2(b,v,S),bn.relativeLuminance2(f,_,g));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})(wu||(wu={}));function ua(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ns(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ZE=Object.freeze((()=>{let e=[sn.toColor("#2e3436"),sn.toColor("#cc0000"),sn.toColor("#4e9a06"),sn.toColor("#c4a000"),sn.toColor("#3465a4"),sn.toColor("#75507b"),sn.toColor("#06989a"),sn.toColor("#d3d7cf"),sn.toColor("#555753"),sn.toColor("#ef2929"),sn.toColor("#8ae234"),sn.toColor("#fce94f"),sn.toColor("#729fcf"),sn.toColor("#ad7fa8"),sn.toColor("#34e2e2"),sn.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 lv(e,t,i){return Math.max(t,Math.min(e,i))}function QE(e){switch(e){case"&":return"&";case"<":return"<"}return e}var C0=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 f=o;f<=c;f++){let _=this._buffer.getLine(f);if(_){let g=f===e.start.y?h:0,b=f===e.end.y?p:_.length;for(let v=g;v<b;v++){let S=_.getCell(v,a===i?s:i);if(!S){console.warn(`Can't get cell at row=${f}, col=${v}`);continue}this._nextCell(S,a,f,v),a=S}}this._rowEnd(f,f===c)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,i,s){}_rowEnd(e,t){}_beforeSerialize(e,t,i){}_afterSerialize(){}_serializeString(e){return""}};function k0(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function rs(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function E0(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 JE=class extends C0{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&&!rs(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),f=p.getWidth()>1,_=!1;(p.getChars()&&f?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&rs(c,p)&&(_=!0),f&&(h.getChars()||h.getWidth()===0)&&rs(c,p)&&rs(h,p)&&(_=!0)),_||(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=!k0(e,t),a=!rs(e,t),o=!E0(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?!rs(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(rs(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&&(rs(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=f=>{f>0?i+=`\x1B[${f}C`:f<0&&(i+=`\x1B[${-f}D`)};h&&((f=>{f>0?i+=`\x1B[${f}B`:f<0&&(i+=`\x1B[${-f}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}},eN=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,i){let s=t.length,a=i===void 0?s:lv(i+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,i,s){return new JE(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 tN(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,f=t.scrollback,_=f===void 0?p:lv(f+e.rows,0,p);return s.serialize({start:{x:0,y:p-_},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(){}},tN=class extends C0{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=ZE}_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=!k0(e,t),a=!rs(e,t),o=!E0(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+=QE(e.getChars())}_serializeString(){return this._htmlContent}};const iN="__OWS_FRESH_SESSION__",nl="[REDACTED]",nN=[[/(authorization\s*:\s*bearer\s+)[^\s'"\x1b]+/gi,`$1${nl}`],[/(\bbearer\s+)[A-Za-z0-9._-]{12,}/gi,`$1${nl}`],[/(\btoken=)[^\s'"&\x1b]+/gi,`$1${nl}`],[/(OWS_PASSPHRASE\s*[=:]\s*)[^\s'"\x1b]+/gi,`$1${nl}`],[/(--passphrase[=\s]+)[^\s'"\x1b]+/gi,`$1${nl}`],[/(passphrase["']?\s*[:=]\s*["']?)[^\s'"\x1b]+/gi,`$1${nl}`]];function ov(e){let t=e;for(const[i,s]of nN)t=t.replace(i,s);return t}const cv="codex features enable image_generation";function rN(e,t){return e!=="cartoon"||!t?!1:!(t.codex.installed&&t.codex.imageGeneration==="enabled")}const sN={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"},aN="plotlink-terminal",lN=1,Fs="scrollback",uv=10*1024*1024;function em(){return new Promise((e,t)=>{const i=indexedDB.open(aN,lN);i.onupgradeneeded=()=>{const s=i.result;s.objectStoreNames.contains(Fs)||s.createObjectStore(Fs)},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})}async function rl(e,t){const i=t.length>uv?t.slice(-uv):t,s=await em();return new Promise((a,o)=>{const c=s.transaction(Fs,"readwrite");c.objectStore(Fs).put(i,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function oN(e){const t=await em();return new Promise((i,s)=>{const o=t.transaction(Fs,"readonly").objectStore(Fs).get(e);o.onsuccess=()=>{t.close(),i(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function mf(e){const t=await em();return new Promise((i,s)=>{const a=t.transaction(Fs,"readwrite");a.objectStore(Fs).delete(e),a.oncomplete=()=>{t.close(),i()},a.onerror=()=>{t.close(),s(a.error)}})}const Ii=new Map;function cN({token:e,storyName:t,authFetch:i,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:h,bypassStories:p,agentProviders:f,readiness:_,contentType:g,needsProviderRepair:b,onRepairProvider:v}){const S=w.useRef(null),N=w.useRef(i),[B,E]=w.useState([]),[z,I]=w.useState(new Set),[R,H]=w.useState(null),[D,ie]=w.useState(null),[ue,ve]=w.useState(!1),[L,re]=w.useState(!1),F=rN(g,_),Y=!!b,K=w.useRef(()=>{});w.useEffect(()=>{N.current=i},[i]);const $=w.useCallback(X=>{var _e;const{width:he}=X.container.getBoundingClientRect();if(!(he<50))try{X.fit.fit(),((_e=X.ws)==null?void 0:_e.readyState)===WebSocket.OPEN&&X.ws.send(JSON.stringify({type:"resize",cols:X.term.cols,rows:X.term.rows}))}catch{}},[]),T=w.useCallback(X=>{for(const[he,_e]of Ii)_e.container.style.display=he===X?"block":"none";if(X){const he=Ii.get(X);he&&setTimeout(()=>$(he),50)}},[$]),q=w.useRef({});w.useEffect(()=>{q.current=p||{}},[p]);const W=w.useRef({});w.useEffect(()=>{W.current=f||{}},[f]);const ge=w.useCallback((X,he,_e)=>{const Ae=window.location.protocol==="https:"?"wss:":"ws:",Oe=q.current[X]?"&bypass=true":"",He=W.current[X],Re=He?`&provider=${encodeURIComponent(He)}`:"",et=new WebSocket(`${Ae}//${window.location.host}/ws/terminal?story=${encodeURIComponent(X)}&token=${e}&resume=${_e}${Oe}${Re}`);et.onopen=()=>{he.connected=!0,he._retried=!1,I(ot=>{const Pe=new Set(ot);return Pe.delete(X),Pe}),et.send(JSON.stringify({type:"resize",cols:he.term.cols,rows:he.term.rows}))};let Ge=!0;et.onmessage=ot=>{if(Ge&&(Ge=!1,typeof ot.data=="string"&&ot.data===iN)){he.term.reset(),mf(X).catch(()=>{});return}he.term.write(typeof ot.data=="string"?ov(ot.data):ot.data)},et.onclose=ot=>{if(he.connected=!1,he.ws===et){he.ws=null;try{const Pe=he.serialize.serialize();rl(X,Pe).catch(()=>{})}catch{}if(ot.code===4e3&&!he._retried){he._retried=!0,he.term.write(`\r
|
|
99
|
+
\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r
|
|
100
|
+
`),K.current(X,he,!1);return}I(Pe=>new Set(Pe).add(X))}},he.term.onData(ot=>{et.readyState===WebSocket.OPEN&&et.send(ot)}),he.ws=et},[e]);w.useEffect(()=>{K.current=ge},[ge]);const j=w.useCallback(async(X,he)=>{if(!S.current||Ii.has(X))return;const{resume:_e=!1,autoConnect:Ae=!0}=he??{},Oe=document.createElement("div");Oe.style.width="100%",Oe.style.height="100%",Oe.style.display="none",Oe.style.paddingLeft="10px",Oe.style.boxSizing="border-box",S.current.appendChild(Oe);const He=new GE({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:sN,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),Re=new KE,et=new eN;He.loadAddon(Re),He.loadAddon(et),He.open(Oe);const Ge={term:He,fit:Re,serialize:et,ws:null,container:Oe,observer:null,connected:!1},ot=new ResizeObserver(()=>{var Be;const{width:Pe}=Oe.getBoundingClientRect();if(!(Pe<50))try{Re.fit(),((Be=Ge.ws)==null?void 0:Be.readyState)===WebSocket.OPEN&&Ge.ws.send(JSON.stringify({type:"resize",cols:He.cols,rows:He.rows}))}catch{}});ot.observe(Oe),Ge.observer=ot,Ii.set(X,Ge),E(Pe=>[...Pe,X]);try{const Pe=await oN(X);if(Pe){const Be=ov(Pe);He.write(Be),Be!==Pe&&rl(X,Be).catch(()=>{})}}catch{}Ae?ge(X,Ge,_e):I(Pe=>new Set(Pe).add(X)),setTimeout(()=>$(Ge),50)},[ge,$]),A=w.useCallback(async(X,he)=>{const _e=Ii.get(X);_e&&(_e.ws&&(_e.ws.close(),_e.ws=null),he||(await N.current(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{}),_e.term.clear()),ge(X,_e,he))},[ge]),Z=w.useCallback(X=>{const he=Ii.get(X);if(he){try{const _e=he.serialize.serialize();rl(X,_e).catch(()=>{})}catch{}he.observer.disconnect(),he.ws&&he.ws.close(),he.term.dispose(),he.container.remove(),Ii.delete(X),E(_e=>_e.filter(Ae=>Ae!==X)),I(_e=>{const Ae=new Set(_e);return Ae.delete(X),Ae}),i(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(X)}},[i,a]),k=w.useCallback(X=>{var _e;const he=Ii.get(X);he&&(((_e=he.ws)==null?void 0:_e.readyState)===WebSocket.OPEN&&he.ws.send(`exit
|
|
101
|
+
`),mf(X).catch(()=>{}),he.observer.disconnect(),he.ws&&he.ws.close(),he.term.dispose(),he.container.remove(),Ii.delete(X),E(Ae=>Ae.filter(Oe=>Oe!==X)),I(Ae=>{const Oe=new Set(Ae);return Oe.delete(X),Oe}),i(`/api/terminal/${encodeURIComponent(X)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(X))},[i,a]),oe=w.useCallback(async(X,he,_e)=>{const Ae=Ii.get(X);if(!Ae||Ii.has(he)||!(await N.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:X,newName:he,..._e??{}})})).ok)return!1;Ii.delete(X),Ii.set(he,Ae);try{const He=Ae.serialize.serialize();await mf(X),await rl(he,He)}catch{}return E(He=>He.map(Re=>Re===X?he:Re)),I(He=>{if(!He.has(X))return He;const Re=new Set(He);return Re.delete(X),Re.add(he),Re}),(Ae.connected||Ae.ws)&&(await N.current(`/api/terminal/${encodeURIComponent(he)}`,{method:"DELETE"}).catch(()=>{}),Ae.ws&&(Ae.ws.close(),Ae.ws=null),K.current(he,Ae,!0)),!0},[]);w.useEffect(()=>(h&&(h.current=oe),()=>{h&&(h.current=null)}),[h,oe]),w.useEffect(()=>{if(t){if(F){T(null);return}if(Y){T(null);return}Ii.has(t)?T(t):N.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(X=>X.ok?X.json():null).then(X=>{if(!Ii.has(t)){const he=(X==null?void 0:X.sessionId)&&!(X!=null&&X.running);j(t,{autoConnect:!he}),T(t)}}).catch(()=>{Ii.has(t)||(j(t),T(t))})}},[t,j,T,F,Y]),w.useEffect(()=>{const X=setInterval(()=>{for(const[he,_e]of Ii)if(_e.connected)try{const Ae=_e.serialize.serialize();rl(he,Ae).catch(()=>{})}catch{}},3e4);return()=>clearInterval(X)},[]),w.useEffect(()=>()=>{for(const[X,he]of Ii){try{const _e=he.serialize.serialize();rl(X,_e).catch(()=>{})}catch{}he.observer.disconnect(),he.ws&&he.ws.close(),he.term.dispose(),he.container.remove(),N.current(`/api/terminal/${encodeURIComponent(X)}`,{method:"DELETE"}).catch(()=>{})}Ii.clear()},[]);const ae=t?z.has(t):!1,V=B.length===0;return d.jsxs("div",{className:"h-full flex flex-col",children:[!V&&d.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[B.map(X=>d.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:[d.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${z.has(X)?"bg-amber-500":X===t?"bg-green-600":"bg-muted/50"}`}),d.jsx("span",{className:`truncate max-w-[120px] ${X.startsWith("_new_")?"italic":""}`,children:X.startsWith("_new_")?"Untitled":X}),d.jsx("button",{onClick:he=>{he.stopPropagation(),X.startsWith("_new_")?H(X):Z(X)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},X)),t!=null&&t.startsWith("_new_")?d.jsx("button",{onClick:()=>H(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))?d.jsx("button",{onClick:()=>ie(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]}),d.jsxs("div",{className:"relative flex-1 min-h-0",children:[d.jsx("div",{ref:S,className:"h-full"}),V&&!F&&!Y&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),d.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),F&&d.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:d.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Cartoon agent can't launch yet"}),d.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."}),_&&!_.codex.installed?d.jsxs("p",{className:"text-xs text-amber-700",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",d.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",d.jsx("span",{className:"font-mono",children:"codex login"}),"), then reopen this story."]}):Eu(_)?d.jsxs("p",{className:"text-xs text-amber-700","data-testid":"codex-auth-unknown-launch",children:[Fp," Then reopen this story."]}):d.jsxs("div",{className:"space-y-1",children:[d.jsx("p",{className:"text-xs text-amber-700",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this story:"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.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:cv}),d.jsx("button",{type:"button","data-testid":"copy-codex-enable-launch",onClick:async()=>{try{await navigator.clipboard.writeText(cv),ve(!0),setTimeout(()=>ve(!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:ue?"Copied!":"Copy"})]})]})]})}),Y&&!F&&d.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:d.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Set this cartoon story's provider"}),d.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."}),d.jsx("p",{className:"text-[11px] text-muted",children:"Only this story is changed. Other stories and fiction are not affected."}),d.jsx("button",{type:"button","data-testid":"repair-provider-codex",disabled:L,onClick:async()=>{if(!L){re(!0);try{await(v==null?void 0:v())}finally{re(!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:L?"Setting…":"Set this story's provider to Codex"})]})}),R&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),d.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),d.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d.jsx("button",{onClick:()=>H(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),d.jsx("button",{onClick:()=>{const X=R;H(null),k(X)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),D&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),d.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),d.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d.jsx("button",{onClick:()=>ie(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),d.jsx("button",{onClick:async()=>{const X=D;ie(null);try{(await N.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X})})).ok&&(Z(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"})]})]})}),ae&&t&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3",children:[d.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>A(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),d.jsx("button",{onClick:()=>A(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),d.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function uN(e,t){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const hN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fN={};function hv(e,t){return(fN.jsx?dN:hN).test(e)}const pN=/[ \t\n\f\r]/g;function mN(e){return typeof e=="object"?e.type==="text"?dv(e.value):!1:dv(e)}function dv(e){return e.replace(pN,"")===""}class Yo{constructor(t,i,s){this.normal=i,this.property=t,s&&(this.space=s)}}Yo.prototype.normal={};Yo.prototype.property={};Yo.prototype.space=void 0;function N0(e,t){const i={},s={};for(const a of e)Object.assign(i,a.property),Object.assign(s,a.normal);return new Yo(i,s,t)}function Cp(e){return e.toLowerCase()}class Ln{constructor(t,i){this.attribute=i,this.property=t}}Ln.prototype.attribute="";Ln.prototype.booleanish=!1;Ln.prototype.boolean=!1;Ln.prototype.commaOrSpaceSeparated=!1;Ln.prototype.commaSeparated=!1;Ln.prototype.defined=!1;Ln.prototype.mustUseProperty=!1;Ln.prototype.number=!1;Ln.prototype.overloadedBoolean=!1;Ln.prototype.property="";Ln.prototype.spaceSeparated=!1;Ln.prototype.space=void 0;let gN=0;const lt=ya(),Ti=ya(),kp=ya(),ye=ya(),Vt=ya(),ul=ya(),Vn=ya();function ya(){return 2**++gN}const Ep=Object.freeze(Object.defineProperty({__proto__:null,boolean:lt,booleanish:Ti,commaOrSpaceSeparated:Vn,commaSeparated:ul,number:ye,overloadedBoolean:kp,spaceSeparated:Vt},Symbol.toStringTag,{value:"Module"})),gf=Object.keys(Ep);class tm extends Ln{constructor(t,i,s,a){let o=-1;if(super(t,i),fv(this,"space",a),typeof s=="number")for(;++o<gf.length;){const c=gf[o];fv(this,gf[o],(s&Ep[c])===Ep[c])}}}tm.prototype.defined=!0;function fv(e,t,i){i&&(e[t]=i)}function _l(e){const t={},i={};for(const[s,a]of Object.entries(e.properties)){const o=new tm(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),t[s]=o,i[Cp(s)]=s,i[Cp(o.attribute)]=s}return new Yo(t,i,e.space)}const j0=_l({properties:{ariaActiveDescendant:null,ariaAtomic:Ti,ariaAutoComplete:null,ariaBusy:Ti,ariaChecked:Ti,ariaColCount:ye,ariaColIndex:ye,ariaColSpan:ye,ariaControls:Vt,ariaCurrent:null,ariaDescribedBy:Vt,ariaDetails:null,ariaDisabled:Ti,ariaDropEffect:Vt,ariaErrorMessage:null,ariaExpanded:Ti,ariaFlowTo:Vt,ariaGrabbed:Ti,ariaHasPopup:null,ariaHidden:Ti,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Vt,ariaLevel:ye,ariaLive:null,ariaModal:Ti,ariaMultiLine:Ti,ariaMultiSelectable:Ti,ariaOrientation:null,ariaOwns:Vt,ariaPlaceholder:null,ariaPosInSet:ye,ariaPressed:Ti,ariaReadOnly:Ti,ariaRelevant:null,ariaRequired:Ti,ariaRoleDescription:Vt,ariaRowCount:ye,ariaRowIndex:ye,ariaRowSpan:ye,ariaSelected:Ti,ariaSetSize:ye,ariaSort:null,ariaValueMax:ye,ariaValueMin:ye,ariaValueNow:ye,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function T0(e,t){return t in e?e[t]:t}function A0(e,t){return T0(e,t.toLowerCase())}const xN=_l({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ul,acceptCharset:Vt,accessKey:Vt,action:null,allow:null,allowFullScreen:lt,allowPaymentRequest:lt,allowUserMedia:lt,alt:null,as:null,async:lt,autoCapitalize:null,autoComplete:Vt,autoFocus:lt,autoPlay:lt,blocking:Vt,capture:null,charSet:null,checked:lt,cite:null,className:Vt,cols:ye,colSpan:null,content:null,contentEditable:Ti,controls:lt,controlsList:Vt,coords:ye|ul,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lt,defer:lt,dir:null,dirName:null,disabled:lt,download:kp,draggable:Ti,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lt,formTarget:null,headers:Vt,height:ye,hidden:kp,high:ye,href:null,hrefLang:null,htmlFor:Vt,httpEquiv:Vt,id:null,imageSizes:null,imageSrcSet:null,inert:lt,inputMode:null,integrity:null,is:null,isMap:lt,itemId:null,itemProp:Vt,itemRef:Vt,itemScope:lt,itemType:Vt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lt,low:ye,manifest:null,max:null,maxLength:ye,media:null,method:null,min:null,minLength:ye,multiple:lt,muted:lt,name:null,nonce:null,noModule:lt,noValidate:lt,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:lt,optimum:ye,pattern:null,ping:Vt,placeholder:null,playsInline:lt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lt,referrerPolicy:null,rel:Vt,required:lt,reversed:lt,rows:ye,rowSpan:ye,sandbox:Vt,scope:null,scoped:lt,seamless:lt,selected:lt,shadowRootClonable:lt,shadowRootDelegatesFocus:lt,shadowRootMode:null,shape:null,size:ye,sizes:null,slot:null,span:ye,spellCheck:Ti,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ye,step:null,style:null,tabIndex:ye,target:null,title:null,translate:null,type:null,typeMustMatch:lt,useMap:null,value:Ti,width:ye,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Vt,axis:null,background:null,bgColor:null,border:ye,borderColor:null,bottomMargin:ye,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lt,declare:lt,event:null,face:null,frame:null,frameBorder:null,hSpace:ye,leftMargin:ye,link:null,longDesc:null,lowSrc:null,marginHeight:ye,marginWidth:ye,noResize:lt,noHref:lt,noShade:lt,noWrap:lt,object:null,profile:null,prompt:null,rev:null,rightMargin:ye,rules:null,scheme:null,scrolling:Ti,standby:null,summary:null,text:null,topMargin:ye,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ye,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lt,disableRemotePlayback:lt,prefix:null,property:null,results:ye,security:null,unselectable:null},space:"html",transform:A0}),_N=_l({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:Vn,accentHeight:ye,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ye,amplitude:ye,arabicForm:null,ascent:ye,attributeName:null,attributeType:null,azimuth:ye,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ye,by:null,calcMode:null,capHeight:ye,className:Vt,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:ye,diffuseConstant:ye,direction:null,display:null,dur:null,divisor:ye,dominantBaseline:null,download:lt,dx:null,dy:null,edgeMode:null,editable:null,elevation:ye,enableBackground:null,end:null,event:null,exponent:ye,externalResourcesRequired:null,fill:null,fillOpacity:ye,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:ul,g2:ul,glyphName:ul,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ye,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ye,horizOriginX:ye,horizOriginY:ye,id:null,ideographic:ye,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ye,k:ye,k1:ye,k2:ye,k3:ye,k4:ye,kernelMatrix:Vn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ye,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:ye,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:ye,overlineThickness:ye,paintOrder:null,panose1:null,path:null,pathLength:ye,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Vt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ye,pointsAtY:ye,pointsAtZ:ye,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vn,rev:Vn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vn,requiredFeatures:Vn,requiredFonts:Vn,requiredFormats:Vn,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:ye,specularExponent:ye,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ye,strikethroughThickness:ye,string:null,stroke:null,strokeDashArray:Vn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ye,strokeOpacity:ye,strokeWidth:null,style:null,surfaceScale:ye,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Vn,tabIndex:ye,tableValues:null,target:null,targetX:ye,targetY:ye,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Vn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ye,underlineThickness:ye,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ye,values:null,vAlphabetic:ye,vMathematical:ye,vectorEffect:null,vHanging:ye,vIdeographic:ye,version:null,vertAdvY:ye,vertOriginX:ye,vertOriginY:ye,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ye,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:T0}),R0=_l({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()}}),D0=_l({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:A0}),M0=_l({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),bN={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"},vN=/[A-Z]/g,pv=/-[a-z]/g,yN=/^data[-\w.:]+$/i;function SN(e,t){const i=Cp(t);let s=t,a=Ln;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&yN.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(pv,CN);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!pv.test(o)){let c=o.replace(vN,wN);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=tm}return new a(s,t)}function wN(e){return"-"+e.toLowerCase()}function CN(e){return e.charAt(1).toUpperCase()}const kN=N0([j0,xN,R0,D0,M0],"html"),im=N0([j0,_N,R0,D0,M0],"svg");function EN(e){return e.join(" ").trim()}var sl={},xf,mv;function NN(){if(mv)return xf;mv=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
|
+
`,f="/",_="*",g="",b="comment",v="declaration";function S(B,E){if(typeof B!="string")throw new TypeError("First argument must be a string");if(!B)return[];E=E||{};var z=1,I=1;function R(K){var $=K.match(t);$&&(z+=$.length);var T=K.lastIndexOf(p);I=~T?K.length-T:I+K.length}function H(){var K={line:z,column:I};return function($){return $.position=new D(K),ve(),$}}function D(K){this.start=K,this.end={line:z,column:I},this.source=E.source}D.prototype.content=B;function ie(K){var $=new Error(E.source+":"+z+":"+I+": "+K);if($.reason=K,$.filename=E.source,$.line=z,$.column=I,$.source=B,!E.silent)throw $}function ue(K){var $=K.exec(B);if($){var T=$[0];return R(T),B=B.slice(T.length),$}}function ve(){ue(i)}function L(K){var $;for(K=K||[];$=re();)$!==!1&&K.push($);return K}function re(){var K=H();if(!(f!=B.charAt(0)||_!=B.charAt(1))){for(var $=2;g!=B.charAt($)&&(_!=B.charAt($)||f!=B.charAt($+1));)++$;if($+=2,g===B.charAt($-1))return ie("End of comment missing");var T=B.slice(2,$-2);return I+=2,R(T),B=B.slice($),I+=2,K({type:b,comment:T})}}function F(){var K=H(),$=ue(s);if($){if(re(),!ue(a))return ie("property missing ':'");var T=ue(o),q=K({type:v,property:N($[0].replace(e,g)),value:T?N(T[0].replace(e,g)):g});return ue(c),q}}function Y(){var K=[];L(K);for(var $;$=F();)$!==!1&&(K.push($),L(K));return K}return ve(),Y()}function N(B){return B?B.replace(h,g):g}return xf=S,xf}var gv;function jN(){if(gv)return sl;gv=1;var e=sl&&sl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(sl,"__esModule",{value:!0}),sl.default=i;const t=e(NN());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:f,value:_}=p;h?a(f,_,p):_&&(o=o||{},o[f]=_)}),o}return sl}var _o={},xv;function TN(){if(xv)return _o;xv=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,i=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||i.test(f)||e.test(f)},c=function(f,_){return _.toUpperCase()},h=function(f,_){return"".concat(_,"-")},p=function(f,_){return _===void 0&&(_={}),o(f)?f:(f=f.toLowerCase(),_.reactCompat?f=f.replace(a,h):f=f.replace(s,h),f.replace(t,c))};return _o.camelCase=p,_o}var bo,_v;function AN(){if(_v)return bo;_v=1;var e=bo&&bo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(jN()),i=TN();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,bo=s,bo}var RN=AN();const DN=Pu(RN),B0=L0("end"),nm=L0("start");function L0(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 O0(e){const t=nm(e),i=B0(e);if(t&&i)return{start:t,end:i}}function Do(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?bv(e.position):"start"in e||"end"in e?bv(e):"line"in e||"column"in e?Np(e):""}function Np(e){return vv(e&&e.line)+":"+vv(e&&e.column)}function bv(e){return Np(e&&e.start)+"-"+Np(e&&e.end)}function vv(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=Do(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 rm={}.hasOwnProperty,MN=new Map,BN=/[A-Z]/g,LN=new Set(["table","tbody","thead","tfoot","tr"]),ON=new Set(["td","th"]),z0="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function zN(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=WN(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=qN(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"?im:kN,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=P0(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function P0(e,t,i){if(t.type==="element")return PN(e,t,i);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return IN(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return UN(e,t,i);if(t.type==="mdxjsEsm")return HN(e,t);if(t.type==="root")return $N(e,t,i);if(t.type==="text")return FN(e,t)}function PN(e,t,i){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=im,e.schema=a),e.ancestors.push(t);const o=H0(e,t.tagName,!1),c=GN(e,t);let h=am(e,t);return LN.has(t.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!mN(p):!0})),I0(e,c,o,t),sm(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function IN(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)}Io(e,t.position)}function HN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Io(e,t.position)}function UN(e,t,i){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=im,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:H0(e,t.name,!0),c=YN(e,t),h=am(e,t);return I0(e,c,o,t),sm(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function $N(e,t,i){const s={};return sm(s,am(e,t)),e.create(t,e.Fragment,s,i)}function FN(e,t){return t.value}function I0(e,t,i,s){typeof i!="string"&&i!==e.Fragment&&e.passNode&&(t.node=s)}function sm(e,t){if(t.length>0){const i=t.length>1?t:t[0];i&&(e.children=i)}}function qN(e,t,i){return s;function s(a,o,c,h){const f=Array.isArray(c.children)?i:t;return h?f(o,c,h):f(o,c)}}function WN(e,t){return i;function i(s,a,o,c){const h=Array.isArray(o.children),p=nm(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 GN(e,t){const i={};let s,a;for(a in t.properties)if(a!=="children"&&rm.call(t.properties,a)){const o=VN(e,a,t.properties[a]);if(o){const[c,h]=o;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&ON.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 YN(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 Io(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 Io(e,t.position);else o=s.value===null?!0:s.value;i[a]=o}return i}function am(e,t){const i=[];let s=-1;const a=e.passKeys?new Map:MN;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 f=a.get(p)||0;c=p+"-"+f,a.set(p,f+1)}}const h=P0(e,o,c);h!==void 0&&i.push(h)}return i}function VN(e,t,i){const s=SN(e.schema,t);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=s.commaSeparated?uN(i):EN(i)),s.property==="style"){let a=typeof i=="object"?i:KN(e,String(i));return e.stylePropertyNameCase==="css"&&(a=XN(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?bN[s.property]||s.property:s.attribute,i]}}function KN(e,t){try{return DN(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=z0+"#cannot-parse-style-attribute",a}}function H0(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=hv(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=hv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return rm.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);Io(e)}function Io(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=z0+"#cannot-handle-mdx-estrees-without-createevaluater",i}function XN(e){const t={};let i;for(i in e)rm.call(e,i)&&(t[ZN(i)]=e[i]);return t}function ZN(e){let t=e.replace(BN,QN);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function QN(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"]},JN={};function lm(e,t){const i=JN,s=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,a=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return U0(e,s,a)}function U0(e,t,i){if(e5(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 yv(e.children,t,i)}return Array.isArray(e)?yv(e,t,i):""}function yv(e,t,i){const s=[];let a=-1;for(;++a<e.length;)s[a]=U0(e[a],t,i);return s.join("")}function e5(e){return!!(e&&typeof e=="object")}const Sv=document.createElement("i");function om(e){const t="&"+e+";";Sv.innerHTML=t;const i=Sv.textContent;return i.charCodeAt(i.length-1)===59&&e!=="semi"||i===t?!1:i}function Kn(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?(Kn(e,e.length,0,t),e):t}const wv={}.hasOwnProperty;function $0(e){const t={};let i=-1;for(;++i<e.length;)t5(t,e[i]);return t}function t5(e,t){let i;for(i in t){const a=(wv.call(e,i)?e[i]:void 0)||(e[i]={}),o=t[i];let c;if(o)for(c in o){wv.call(a,c)||(a[c]=[]);const h=o[c];i5(a[c],Array.isArray(h)?h:h?[h]:[])}}}function i5(e,t){let i=-1;const s=[];for(;++i<t.length;)(t[i].add==="after"?e:s).push(t[i]);Kn(e,0,0,s)}function F0(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 br(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yn=qs(/[A-Za-z]/),fn=qs(/[\dA-Za-z]/),n5=qs(/[#-'*+\--9=?A-Z^-~]/);function Mu(e){return e!==null&&(e<32||e===127)}const jp=qs(/\d/),r5=qs(/[\dA-Fa-f]/),s5=qs(/[!-/:-@[-`{-~]/);function Fe(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function xt(e){return e===-2||e===-1||e===32}const Fu=qs(new RegExp("\\p{P}|\\p{S}","u")),ba=qs(/\s/);function qs(e){return t;function t(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function bl(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 Ct(e,t,i,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return xt(p)?(e.enter(i),h(p)):t(p)}function h(p){return xt(p)&&o++<a?(e.consume(p),h):(e.exit(i),t(p))}}const a5={tokenize:l5};function l5(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"),Ct(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 Fe(h)?(e.consume(h),e.exit("chunkText"),o):(e.consume(h),c)}}const o5={tokenize:c5},Cv={tokenize:u5};function c5(e){const t=this,i=[];let s=0,a,o,c;return h;function h(I){if(s<i.length){const R=i[s];return t.containerState=R[1],e.attempt(R[0].continuation,p,f)(I)}return f(I)}function p(I){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&z();const R=t.events.length;let H=R,D;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){D=t.events[H][1].end;break}E(s);let ie=R;for(;ie<t.events.length;)t.events[ie][1].end={...D},ie++;return Kn(t.events,H+1,0,t.events.slice(R)),t.events.length=ie,f(I)}return h(I)}function f(I){if(s===i.length){if(!a)return b(I);if(a.currentConstruct&&a.currentConstruct.concrete)return S(I);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Cv,_,g)(I)}function _(I){return a&&z(),E(s),b(I)}function g(I){return t.parser.lazy[t.now().line]=s!==i.length,c=t.now().offset,S(I)}function b(I){return t.containerState={},e.attempt(Cv,v,S)(I)}function v(I){return s++,i.push([t.currentConstruct,t.containerState]),b(I)}function S(I){if(I===null){a&&z(),E(0),e.consume(I);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),N(I)}function N(I){if(I===null){B(e.exit("chunkFlow"),!0),E(0),e.consume(I);return}return Fe(I)?(e.consume(I),B(e.exit("chunkFlow")),s=0,t.interrupt=void 0,h):(e.consume(I),N)}function B(I,R){const H=t.sliceStream(I);if(R&&H.push(null),I.previous=o,o&&(o.next=I),o=I,a.defineSkip(I.start),a.write(H),t.parser.lazy[I.start.line]){let D=a.events.length;for(;D--;)if(a.events[D][1].start.offset<c&&(!a.events[D][1].end||a.events[D][1].end.offset>c))return;const ie=t.events.length;let ue=ie,ve,L;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(ve){L=t.events[ue][1].end;break}ve=!0}for(E(s),D=ie;D<t.events.length;)t.events[D][1].end={...L},D++;Kn(t.events,ue+1,0,t.events.slice(ie)),t.events.length=D}}function E(I){let R=i.length;for(;R-- >I;){const H=i[R];t.containerState=H[1],H[0].exit.call(t,e)}i.length=I}function z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function u5(e,t,i){return Ct(e,e.attempt(this.parser.constructs.document,t,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pl(e){if(e===null||Wt(e)||ba(e))return 1;if(Fu(e))return 2}function qu(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:h5,tokenize:d5};function h5(e,t){let i=-1,s,a,o,c,h,p,f,_;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 g={...e[s][1].end},b={...e[i][1].start};kv(g,-p),kv(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:g,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},f=[],e[s][1].end.offset-e[s][1].start.offset&&(f=ur(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=ur(f,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),f=ur(f,qu(t.parser.constructs.insideSpan.null,e.slice(s+1,i),t)),f=ur(f,[["exit",o,t],["enter",h,t],["exit",h,t],["exit",a,t]]),e[i][1].end.offset-e[i][1].start.offset?(_=2,f=ur(f,[["enter",e[i][1],t],["exit",e[i][1],t]])):_=0,Kn(e,s-1,i-s+3,f),i=s+f.length-_-2;break}}for(i=-1;++i<e.length;)e[i][1].type==="attentionSequence"&&(e[i][1].type="data");return e}function d5(e,t){const i=this.parser.constructs.attentionMarkers.null,s=this.previous,a=pl(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 f=e.exit("attentionSequence"),_=pl(p),g=!_||_===2&&a||i.includes(p),b=!a||a===2&&_||i.includes(s);return f._open=!!(o===42?g:g&&(a||!b)),f._close=!!(o===42?b:b&&(_||!g)),t(p)}}function kv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const f5={name:"autolink",tokenize:p5};function p5(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):f(v)}function c(v){return v===43||v===45||v===46||fn(v)?(s=1,h(v)):f(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,f(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||Mu(v)?i(v):(e.consume(v),p)}function f(v){return v===64?(e.consume(v),_):n5(v)?(e.consume(v),f):i(v)}function _(v){return fn(v)?g(v):i(v)}function g(v){return v===46?(e.consume(v),s=0,_):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:g;return e.consume(v),S}return i(v)}}const Vo={partial:!0,tokenize:m5};function m5(e,t,i){return s;function s(o){return xt(o)?Ct(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||Fe(o)?t(o):i(o)}}const q0={continuation:{tokenize:x5},exit:_5,name:"blockQuote",tokenize:g5};function g5(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 xt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function x5(e,t,i){const s=this;return a;function a(c){return xt(c)?Ct(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(q0,t,i)(c)}}function _5(e){e.exit("blockQuote")}const W0={name:"characterEscape",tokenize:b5};function b5(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 s5(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):i(o)}}const G0={name:"characterReference",tokenize:v5};function v5(e,t,i){const s=this;let a=0,o,c;return h;function h(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),p}function p(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),o=31,c=fn,_(g))}function f(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=r5,_):(e.enter("characterReferenceValue"),o=7,c=jp,_(g))}function _(g){if(g===59&&a){const b=e.exit("characterReferenceValue");return c===fn&&!om(s.sliceSerialize(b))?i(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&a++<o?(e.consume(g),_):i(g)}}const Ev={partial:!0,tokenize:S5},Nv={concrete:!0,name:"codeFenced",tokenize:y5};function y5(e,t,i){const s=this,a={partial:!0,tokenize:H};let o=0,c=0,h;return p;function p(D){return f(D)}function f(D){const ie=s.events[s.events.length-1];return o=ie&&ie[1].type==="linePrefix"?ie[2].sliceSerialize(ie[1],!0).length:0,h=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),_(D)}function _(D){return D===h?(c++,e.consume(D),_):c<3?i(D):(e.exit("codeFencedFenceSequence"),xt(D)?Ct(e,g,"whitespace")(D):g(D))}function g(D){return D===null||Fe(D)?(e.exit("codeFencedFence"),s.interrupt?t(D):e.check(Ev,N,R)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(D))}function b(D){return D===null||Fe(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(D)):xt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ct(e,v,"whitespace")(D)):D===96&&D===h?i(D):(e.consume(D),b)}function v(D){return D===null||Fe(D)?g(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),S(D))}function S(D){return D===null||Fe(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(D)):D===96&&D===h?i(D):(e.consume(D),S)}function N(D){return e.attempt(a,R,B)(D)}function B(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),E}function E(D){return o>0&&xt(D)?Ct(e,z,"linePrefix",o+1)(D):z(D)}function z(D){return D===null||Fe(D)?e.check(Ev,N,R)(D):(e.enter("codeFlowValue"),I(D))}function I(D){return D===null||Fe(D)?(e.exit("codeFlowValue"),z(D)):(e.consume(D),I)}function R(D){return e.exit("codeFenced"),t(D)}function H(D,ie,ue){let ve=0;return L;function L($){return D.enter("lineEnding"),D.consume($),D.exit("lineEnding"),re}function re($){return D.enter("codeFencedFence"),xt($)?Ct(D,F,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):F($)}function F($){return $===h?(D.enter("codeFencedFenceSequence"),Y($)):ue($)}function Y($){return $===h?(ve++,D.consume($),Y):ve>=c?(D.exit("codeFencedFenceSequence"),xt($)?Ct(D,K,"whitespace")($):K($)):ue($)}function K($){return $===null||Fe($)?(D.exit("codeFencedFence"),ie($)):ue($)}}}function S5(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 bf={name:"codeIndented",tokenize:C5},w5={partial:!0,tokenize:k5};function C5(e,t,i){const s=this;return a;function a(f){return e.enter("codeIndented"),Ct(e,o,"linePrefix",5)(f)}function o(f){const _=s.events[s.events.length-1];return _&&_[1].type==="linePrefix"&&_[2].sliceSerialize(_[1],!0).length>=4?c(f):i(f)}function c(f){return f===null?p(f):Fe(f)?e.attempt(w5,c,p)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||Fe(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),h)}function p(f){return e.exit("codeIndented"),t(f)}}function k5(e,t,i){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?i(c):Fe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ct(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):Fe(c)?a(c):i(c)}}const E5={name:"codeText",previous:j5,resolve:N5,tokenize:T5};function N5(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 j5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function T5(e,t,i){let s=0,a,o;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),h(g)}function h(g){return g===96?(e.consume(g),s++,h):(e.exit("codeTextSequence"),p(g))}function p(g){return g===null?i(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),p):g===96?(o=e.enter("codeTextSequence"),a=0,_(g)):Fe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("codeTextData"),f(g))}function f(g){return g===null||g===32||g===96||Fe(g)?(e.exit("codeTextData"),p(g)):(e.consume(g),f)}function _(g){return g===96?(e.consume(g),a++,_):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(o.type="codeTextData",f(g))}}class A5{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&&vo(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),vo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vo(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);vo(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vo(this.left,i.reverse())}}}function vo(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 Y0(e){const t={};let i=-1,s,a,o,c,h,p,f;const _=new A5(e);for(;++i<_.length;){for(;i in t;)i=t[i];if(s=_.get(i),i&&s[1].type==="chunkFlow"&&_.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,R5(_,i)),i=t[i],f=!0);else if(s[1]._container){for(o=i,a=void 0;o--;)if(c=_.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(_.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={..._.get(a)[1].start},h=_.slice(a,i),h.unshift(s),_.splice(a,i-a+1,h))}}return Kn(e,0,Number.POSITIVE_INFINITY,_.slice(0)),!f}function R5(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=[],f={};let _,g,b=-1,v=i,S=0,N=0;const B=[N];for(;v;){for(;e.get(++a)[1]!==v;);o.push(a),v._tokenizer||(_=s.sliceStream(v),v.next||_.push(null),g&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(_),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=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,B.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):B.pop(),b=B.length;b--;){const E=h.slice(B[b],B[b+1]),z=o.pop();p.push([z,z+E.length-1]),e.splice(z,2,E)}for(p.reverse(),b=-1;++b<p.length;)f[S+p[b][0]]=S+p[b][1],S+=p[b][1]-p[b][0]-1;return f}const D5={resolve:B5,tokenize:L5},M5={partial:!0,tokenize:O5};function B5(e){return Y0(e),e}function L5(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):Fe(h)?e.check(M5,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 O5(e,t,i){const s=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ct(e,o,"linePrefix")}function o(c){if(c===null||Fe(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 V0(e,t,i,s,a,o,c,h,p){const f=p||Number.POSITIVE_INFINITY;let _=0;return g;function g(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||Mu(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||Fe(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!_&&(E===null||E===41||Wt(E))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(s),t(E)):_<f&&E===40?(e.consume(E),_++,N):E===41?(e.consume(E),_--,N):E===null||E===32||E===40||Mu(E)?i(E):(e.consume(E),E===92?B:N)}function B(E){return E===40||E===41||E===92?(e.consume(E),N):N(E)}}function K0(e,t,i,s,a,o){const c=this;let h=0,p;return f;function f(v){return e.enter(s),e.enter(a),e.consume(v),e.exit(a),e.enter(o),_}function _(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):Fe(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),_):(e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||Fe(v)||h++>999?(e.exit("chunkString"),_(v)):(e.consume(v),p||(p=!xt(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(e.consume(v),h++,g):g(v)}}function X0(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),f(b))}function f(b){return b===c?(e.exit(o),p(c)):b===null?i(b):Fe(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ct(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),_(b))}function _(b){return b===c||b===null||Fe(b)?(e.exit("chunkString"),f(b)):(e.consume(b),b===92?g:_)}function g(b){return b===c||b===92?(e.consume(b),_):_(b)}}function Mo(e,t){let i;return s;function s(a){return Fe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i=!0,s):xt(a)?Ct(e,s,i?"linePrefix":"lineSuffix")(a):t(a)}}const z5={name:"definition",tokenize:I5},P5={partial:!0,tokenize:H5};function I5(e,t,i){const s=this;let a;return o;function o(v){return e.enter("definition"),c(v)}function c(v){return K0.call(s,e,h,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function h(v){return a=br(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 Wt(v)?Mo(e,f)(v):f(v)}function f(v){return V0(e,_,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function _(v){return e.attempt(P5,g,g)(v)}function g(v){return xt(v)?Ct(e,b,"whitespace")(v):b(v)}function b(v){return v===null||Fe(v)?(e.exit("definition"),s.parser.defined.push(a),t(v)):i(v)}}function H5(e,t,i){return s;function s(h){return Wt(h)?Mo(e,a)(h):i(h)}function a(h){return X0(e,o,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function o(h){return xt(h)?Ct(e,c,"whitespace")(h):c(h)}function c(h){return h===null||Fe(h)?t(h):i(h)}}const U5={name:"hardBreakEscape",tokenize:$5};function $5(e,t,i){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Fe(o)?(e.exit("hardBreakEscape"),t(o)):i(o)}}const F5={name:"headingAtx",resolve:q5,tokenize:W5};function q5(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"},Kn(e,s,i-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function W5(e,t,i){let s=0;return a;function a(_){return e.enter("atxHeading"),o(_)}function o(_){return e.enter("atxHeadingSequence"),c(_)}function c(_){return _===35&&s++<6?(e.consume(_),c):_===null||Wt(_)?(e.exit("atxHeadingSequence"),h(_)):i(_)}function h(_){return _===35?(e.enter("atxHeadingSequence"),p(_)):_===null||Fe(_)?(e.exit("atxHeading"),t(_)):xt(_)?Ct(e,h,"whitespace")(_):(e.enter("atxHeadingText"),f(_))}function p(_){return _===35?(e.consume(_),p):(e.exit("atxHeadingSequence"),h(_))}function f(_){return _===null||_===35||Wt(_)?(e.exit("atxHeadingText"),h(_)):(e.consume(_),f)}}const G5=["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"],jv=["pre","script","style","textarea"],Y5={concrete:!0,name:"htmlFlow",resolveTo:X5,tokenize:Z5},V5={partial:!0,tokenize:J5},K5={partial:!0,tokenize:Q5};function X5(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 Z5(e,t,i){const s=this;let a,o,c,h,p;return f;function f(k){return _(k)}function _(k){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(k),g}function g(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:j):yn(k)?(e.consume(k),c=String.fromCharCode(k),B):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:j):i(k)}function v(k){return k===45?(e.consume(k),s.interrupt?t:j):i(k)}function S(k){const oe="CDATA[";return k===oe.charCodeAt(h++)?(e.consume(k),h===oe.length?s.interrupt?t:F:S):i(k)}function N(k){return yn(k)?(e.consume(k),c=String.fromCharCode(k),B):i(k)}function B(k){if(k===null||k===47||k===62||Wt(k)){const oe=k===47,ae=c.toLowerCase();return!oe&&!o&&jv.includes(ae)?(a=1,s.interrupt?t(k):F(k)):G5.includes(c.toLowerCase())?(a=6,oe?(e.consume(k),E):s.interrupt?t(k):F(k)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?i(k):o?z(k):I(k))}return k===45||fn(k)?(e.consume(k),c+=String.fromCharCode(k),B):i(k)}function E(k){return k===62?(e.consume(k),s.interrupt?t:F):i(k)}function z(k){return xt(k)?(e.consume(k),z):L(k)}function I(k){return k===47?(e.consume(k),L):k===58||k===95||yn(k)?(e.consume(k),R):xt(k)?(e.consume(k),I):L(k)}function R(k){return k===45||k===46||k===58||k===95||fn(k)?(e.consume(k),R):H(k)}function H(k){return k===61?(e.consume(k),D):xt(k)?(e.consume(k),H):I(k)}function D(k){return k===null||k===60||k===61||k===62||k===96?i(k):k===34||k===39?(e.consume(k),p=k,ie):xt(k)?(e.consume(k),D):ue(k)}function ie(k){return k===p?(e.consume(k),p=null,ve):k===null||Fe(k)?i(k):(e.consume(k),ie)}function ue(k){return k===null||k===34||k===39||k===47||k===60||k===61||k===62||k===96||Wt(k)?H(k):(e.consume(k),ue)}function ve(k){return k===47||k===62||xt(k)?I(k):i(k)}function L(k){return k===62?(e.consume(k),re):i(k)}function re(k){return k===null||Fe(k)?F(k):xt(k)?(e.consume(k),re):i(k)}function F(k){return k===45&&a===2?(e.consume(k),T):k===60&&a===1?(e.consume(k),q):k===62&&a===4?(e.consume(k),A):k===63&&a===3?(e.consume(k),j):k===93&&a===5?(e.consume(k),ge):Fe(k)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(V5,Z,Y)(k)):k===null||Fe(k)?(e.exit("htmlFlowData"),Y(k)):(e.consume(k),F)}function Y(k){return e.check(K5,K,Z)(k)}function K(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),$}function $(k){return k===null||Fe(k)?Y(k):(e.enter("htmlFlowData"),F(k))}function T(k){return k===45?(e.consume(k),j):F(k)}function q(k){return k===47?(e.consume(k),c="",W):F(k)}function W(k){if(k===62){const oe=c.toLowerCase();return jv.includes(oe)?(e.consume(k),A):F(k)}return yn(k)&&c.length<8?(e.consume(k),c+=String.fromCharCode(k),W):F(k)}function ge(k){return k===93?(e.consume(k),j):F(k)}function j(k){return k===62?(e.consume(k),A):k===45&&a===2?(e.consume(k),j):F(k)}function A(k){return k===null||Fe(k)?(e.exit("htmlFlowData"),Z(k)):(e.consume(k),A)}function Z(k){return e.exit("htmlFlow"),t(k)}}function Q5(e,t,i){const s=this;return a;function a(c){return Fe(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 J5(e,t,i){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Vo,t,i)}}const ej={name:"htmlText",tokenize:tj};function tj(e,t,i){const s=this;let a,o,c;return h;function h(j){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(j),p}function p(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),H):j===63?(e.consume(j),I):yn(j)?(e.consume(j),ue):i(j)}function f(j){return j===45?(e.consume(j),_):j===91?(e.consume(j),o=0,S):yn(j)?(e.consume(j),z):i(j)}function _(j){return j===45?(e.consume(j),v):i(j)}function g(j){return j===null?i(j):j===45?(e.consume(j),b):Fe(j)?(c=g,q(j)):(e.consume(j),g)}function b(j){return j===45?(e.consume(j),v):g(j)}function v(j){return j===62?T(j):j===45?b(j):g(j)}function S(j){const A="CDATA[";return j===A.charCodeAt(o++)?(e.consume(j),o===A.length?N:S):i(j)}function N(j){return j===null?i(j):j===93?(e.consume(j),B):Fe(j)?(c=N,q(j)):(e.consume(j),N)}function B(j){return j===93?(e.consume(j),E):N(j)}function E(j){return j===62?T(j):j===93?(e.consume(j),E):N(j)}function z(j){return j===null||j===62?T(j):Fe(j)?(c=z,q(j)):(e.consume(j),z)}function I(j){return j===null?i(j):j===63?(e.consume(j),R):Fe(j)?(c=I,q(j)):(e.consume(j),I)}function R(j){return j===62?T(j):I(j)}function H(j){return yn(j)?(e.consume(j),D):i(j)}function D(j){return j===45||fn(j)?(e.consume(j),D):ie(j)}function ie(j){return Fe(j)?(c=ie,q(j)):xt(j)?(e.consume(j),ie):T(j)}function ue(j){return j===45||fn(j)?(e.consume(j),ue):j===47||j===62||Wt(j)?ve(j):i(j)}function ve(j){return j===47?(e.consume(j),T):j===58||j===95||yn(j)?(e.consume(j),L):Fe(j)?(c=ve,q(j)):xt(j)?(e.consume(j),ve):T(j)}function L(j){return j===45||j===46||j===58||j===95||fn(j)?(e.consume(j),L):re(j)}function re(j){return j===61?(e.consume(j),F):Fe(j)?(c=re,q(j)):xt(j)?(e.consume(j),re):ve(j)}function F(j){return j===null||j===60||j===61||j===62||j===96?i(j):j===34||j===39?(e.consume(j),a=j,Y):Fe(j)?(c=F,q(j)):xt(j)?(e.consume(j),F):(e.consume(j),K)}function Y(j){return j===a?(e.consume(j),a=void 0,$):j===null?i(j):Fe(j)?(c=Y,q(j)):(e.consume(j),Y)}function K(j){return j===null||j===34||j===39||j===60||j===61||j===96?i(j):j===47||j===62||Wt(j)?ve(j):(e.consume(j),K)}function $(j){return j===47||j===62||Wt(j)?ve(j):i(j)}function T(j){return j===62?(e.consume(j),e.exit("htmlTextData"),e.exit("htmlText"),t):i(j)}function q(j){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),W}function W(j){return xt(j)?Ct(e,ge,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):ge(j)}function ge(j){return e.enter("htmlTextData"),c(j)}}const cm={name:"labelEnd",resolveAll:sj,resolveTo:aj,tokenize:lj},ij={tokenize:oj},nj={tokenize:cj},rj={tokenize:uj};function sj(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&&Kn(e,0,e.length,i),e}function aj(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}},f={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},_={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",p,t],["enter",f,t]],h=ur(h,e.slice(o+1,o+s+3)),h=ur(h,[["enter",_,t]]),h=ur(h,qu(t.parser.constructs.insideSpan.null,e.slice(o+s+4,c-3),t)),h=ur(h,[["exit",_,t],e[c-2],e[c-1],["exit",f,t]]),h=ur(h,e.slice(c+1)),h=ur(h,[["exit",p,t]]),Kn(e,o,e.length,h),e}function lj(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?g(b):(c=s.parser.defined.includes(br(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(ij,_,c?_:g)(b):b===91?e.attempt(nj,_,c?f:g)(b):c?_(b):g(b)}function f(b){return e.attempt(rj,_,g)(b)}function _(b){return t(b)}function g(b){return o._balanced=!0,i(b)}}function oj(e,t,i){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),a}function a(g){return Wt(g)?Mo(e,o)(g):o(g)}function o(g){return g===41?_(g):V0(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return Wt(g)?Mo(e,p)(g):_(g)}function h(g){return i(g)}function p(g){return g===34||g===39||g===40?X0(e,f,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):_(g)}function f(g){return Wt(g)?Mo(e,_)(g):_(g)}function _(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):i(g)}}function cj(e,t,i){const s=this;return a;function a(h){return K0.call(s,e,o,c,"reference","referenceMarker","referenceString")(h)}function o(h){return s.parser.defined.includes(br(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(h):i(h)}function c(h){return i(h)}}function uj(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 hj={name:"labelStartImage",resolveAll:cm.resolveAll,tokenize:dj};function dj(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 fj={name:"labelStartLink",resolveAll:cm.resolveAll,tokenize:pj};function pj(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 vf={name:"lineEnding",tokenize:mj};function mj(e,t){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ct(e,t,"linePrefix")}}const Cu={name:"thematicBreak",tokenize:gj};function gj(e,t,i){let s=0,a;return o;function o(f){return e.enter("thematicBreak"),c(f)}function c(f){return a=f,h(f)}function h(f){return f===a?(e.enter("thematicBreakSequence"),p(f)):s>=3&&(f===null||Fe(f))?(e.exit("thematicBreak"),t(f)):i(f)}function p(f){return f===a?(e.consume(f),s++,p):(e.exit("thematicBreakSequence"),xt(f)?Ct(e,h,"whitespace")(f):h(f))}}const Bn={continuation:{tokenize:vj},exit:Sj,name:"list",tokenize:bj},xj={partial:!0,tokenize:wj},_j={partial:!0,tokenize:yj};function bj(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:jp(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(Cu,i,f)(v):f(v);if(!s.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(v)}return i(v)}function p(v){return jp(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"),f(v)):i(v)}function f(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||v,e.check(Vo,s.interrupt?i:_,e.attempt(xj,b,g))}function _(v){return s.containerState.initialBlankLine=!0,o++,b(v)}function g(v){return xt(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 vj(e,t,i){const s=this;return s.containerState._closeFlow=void 0,e.check(Vo,a,o);function a(h){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ct(e,t,"listItemIndent",s.containerState.size+1)(h)}function o(h){return s.containerState.furtherBlankLines||!xt(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(_j,t,c)(h))}function c(h){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ct(e,e.attempt(Bn,t,i),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function yj(e,t,i){const s=this;return Ct(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 Sj(e){e.exit(this.containerState.type)}function wj(e,t,i){const s=this;return Ct(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!xt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):i(o)}}const Tv={name:"setextUnderline",resolveTo:Cj,tokenize:kj};function Cj(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 kj(e,t,i){const s=this;let a;return o;function o(f){let _=s.events.length,g;for(;_--;)if(s.events[_][1].type!=="lineEnding"&&s.events[_][1].type!=="linePrefix"&&s.events[_][1].type!=="content"){g=s.events[_][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),a=f,c(f)):i(f)}function c(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===a?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),xt(f)?Ct(e,p,"lineSuffix")(f):p(f))}function p(f){return f===null||Fe(f)?(e.exit("setextHeadingLine"),t(f)):i(f)}}const Ej={tokenize:Nj};function Nj(e){const t=this,i=e.attempt(Vo,s,e.attempt(this.parser.constructs.flowInitial,a,Ct(e,e.attempt(this.parser.constructs.flow,a,e.attempt(D5,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 jj={resolveAll:Q0()},Tj=Z0("string"),Aj=Z0("text");function Z0(e){return{resolveAll:Q0(e==="text"?Rj: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(_){return f(_)?o(_):h(_)}function h(_){if(_===null){i.consume(_);return}return i.enter("data"),i.consume(_),p}function p(_){return f(_)?(i.exit("data"),o(_)):(i.consume(_),p)}function f(_){if(_===null)return!0;const g=a[_];let b=-1;if(g)for(;++b<g.length;){const v=g[b];if(!v.previous||v.previous.call(s,s.previous))return!0}return!1}}}function Q0(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 Rj(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 f=a[o];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(f===-2)p=!0,h++;else if(f!==-1){o++;break}}if(t._contentTypeTextTrailing&&i===e.length&&(h=0),h){const f={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={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(e.splice(i,0,["enter",f,t],["exit",f,t]),i+=2)}i++}return e}const Dj={42:Bn,43:Bn,45:Bn,48:Bn,49:Bn,50:Bn,51:Bn,52:Bn,53:Bn,54:Bn,55:Bn,56:Bn,57:Bn,62:q0},Mj={91:z5},Bj={[-2]:bf,[-1]:bf,32:bf},Lj={35:F5,42:Cu,45:[Tv,Cu],60:Y5,61:Tv,95:Cu,96:Nv,126:Nv},Oj={38:G0,92:W0},zj={[-5]:vf,[-4]:vf,[-3]:vf,33:hj,38:G0,42:Tp,60:[f5,ej],91:fj,92:[U5,W0],93:cm,95:Tp,96:E5},Pj={null:[Tp,jj]},Ij={null:[42,95]},Hj={null:[]},Uj=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ij,contentInitial:Mj,disable:Hj,document:Dj,flow:Lj,flowInitial:Bj,insideSpan:Pj,string:Oj,text:zj},Symbol.toStringTag,{value:"Module"}));function $j(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:ie(H),check:ie(D),consume:z,enter:I,exit:R,interrupt:ie(D,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:S,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:g};let _=t.tokenize.call(f,p);return t.resolveAll&&o.push(t),f;function g(re){return c=ur(c,re),B(),c[c.length-1]!==null?[]:(ue(t,0),f.events=qu(o,f.events,f),f.events)}function b(re,F){return qj(v(re),F)}function v(re){return Fj(c,re)}function S(){const{_bufferIndex:re,_index:F,line:Y,column:K,offset:$}=s;return{_bufferIndex:re,_index:F,line:Y,column:K,offset:$}}function N(re){a[re.line]=re.column,L()}function B(){let re;for(;s._index<c.length;){const F=c[s._index];if(typeof F=="string")for(re=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===re&&s._bufferIndex<F.length;)E(F.charCodeAt(s._bufferIndex));else E(F)}}function E(re){_=_(re)}function z(re){Fe(re)?(s.line++,s.column=1,s.offset+=re===-3?2:1,L()):re!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=re}function I(re,F){const Y=F||{};return Y.type=re,Y.start=S(),f.events.push(["enter",Y,f]),h.push(Y),Y}function R(re){const F=h.pop();return F.end=S(),f.events.push(["exit",F,f]),F}function H(re,F){ue(re,F.from)}function D(re,F){F.restore()}function ie(re,F){return Y;function Y(K,$,T){let q,W,ge,j;return Array.isArray(K)?Z(K):"tokenize"in K?Z([K]):A(K);function A(V){return X;function X(he){const _e=he!==null&&V[he],Ae=he!==null&&V.null,Oe=[...Array.isArray(_e)?_e:_e?[_e]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return Z(Oe)(he)}}function Z(V){return q=V,W=0,V.length===0?T:k(V[W])}function k(V){return X;function X(he){return j=ve(),ge=V,V.partial||(f.currentConstruct=V),V.name&&f.parser.constructs.disable.null.includes(V.name)?ae():V.tokenize.call(F?Object.assign(Object.create(f),F):f,p,oe,ae)(he)}}function oe(V){return re(ge,j),$}function ae(V){return j.restore(),++W<q.length?k(q[W]):T}}}function ue(re,F){re.resolveAll&&!o.includes(re)&&o.push(re),re.resolve&&Kn(f.events,F,f.events.length-F,re.resolve(f.events.slice(F),f)),re.resolveTo&&(f.events=re.resolveTo(f.events,f))}function ve(){const re=S(),F=f.previous,Y=f.currentConstruct,K=f.events.length,$=Array.from(h);return{from:K,restore:T};function T(){s=re,f.previous=F,f.currentConstruct=Y,f.events.length=K,h=$,L()}}function L(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function Fj(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 qj(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 Wj(e){const s={constructs:$0([Uj,...(e||{}).extensions||[]]),content:a(a5),defined:[],document:a(o5),flow:a(Ej),lazy:{},string:a(Tj),text:a(Aj)};return s;function a(o){return c;function c(h){return $j(s,o,h)}}}function Gj(e){for(;!Y0(e););return e}const Av=/[\0\t\n\r]/g;function Yj(){let e=1,t="",i=!0,s;return a;function a(o,c,h){const p=[];let f,_,g,b,v;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),g=0,t="",i&&(o.charCodeAt(0)===65279&&g++,i=void 0);g<o.length;){if(Av.lastIndex=g,f=Av.exec(o),b=f&&f.index!==void 0?f.index:o.length,v=o.charCodeAt(b),!f){t=o.slice(g);break}if(v===10&&g===b&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),g<b&&(p.push(o.slice(g,b)),e+=b-g),v){case 0:{p.push(65533),e++;break}case 9:{for(_=Math.ceil(e/4)*4,p.push(-2);e++<_;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}g=b+1}return h&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const Vj=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Kj(e){return e.replace(Vj,Xj)}function Xj(e,t,i){if(t)return t;if(i.charCodeAt(0)===35){const a=i.charCodeAt(1),o=a===120||a===88;return F0(i.slice(o?2:1),o?16:10)}return om(i)||e}const J0={}.hasOwnProperty;function Zj(e,t,i){return t&&typeof t=="object"&&(i=t,t=void 0),Qj(i)(Gj(Wj(i).document().write(Yj()(e,t,!0))))}function Qj(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ve),autolinkProtocol:ve,autolinkEmail:ve,atxHeading:o(Ge),blockQuote:o(Ae),characterEscape:ve,characterReference:ve,codeFenced:o(Oe),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Oe,c),codeText:o(He,c),codeTextData:ve,data:ve,codeFlowValue:ve,definition:o(Re),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(et),hardBreakEscape:o(ot),hardBreakTrailing:o(ot),htmlFlow:o(Pe,c),htmlFlowData:ve,htmlText:o(Pe,c),htmlTextData:ve,image:o(Be),label:c,link:o(Ve),listItem:o(kt),listItemValue:b,listOrdered:o(Nt,g),listUnordered:o(Nt),paragraph:o(pi),reference:k,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Ge),strong:o(Me),thematicBreak:o(ct)},exit:{atxHeading:p(),atxHeadingSequence:H,autolink:p(),autolinkEmail:_e,autolinkProtocol:he,blockQuote:p(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:V,characterReference:X,codeFenced:p(B),codeFencedFence:N,codeFencedFenceInfo:v,codeFencedFenceMeta:S,codeFlowValue:L,codeIndented:p(E),codeText:p($),codeTextData:L,data:L,definition:p(),definitionDestinationString:R,definitionLabelString:z,definitionTitleString:I,emphasis:p(),hardBreakEscape:p(F),hardBreakTrailing:p(F),htmlFlow:p(Y),htmlFlowData:L,htmlText:p(K),htmlTextData:L,image:p(q),label:ge,labelText:W,lineEnding:re,link:p(T),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:oe,resourceDestinationString:j,resourceTitleString:A,resource:Z,setextHeading:p(ue),setextHeadingLineSequence:ie,setextHeadingText:D,strong:p(),thematicBreak:p()}};eS(t,(e||{}).mdastExtensions||[]);const i={};return s;function s(ee){let xe={type:"root",children:[]};const Te={stack:[xe],tokenStack:[],config:t,enter:h,exit:f,buffer:c,resume:_,data:i},Ue=[];let Ye=-1;for(;++Ye<ee.length;)if(ee[Ye][1].type==="listOrdered"||ee[Ye][1].type==="listUnordered")if(ee[Ye][0]==="enter")Ue.push(Ye);else{const Kt=Ue.pop();Ye=a(ee,Kt,Ye)}for(Ye=-1;++Ye<ee.length;){const Kt=t[ee[Ye][0]];J0.call(Kt,ee[Ye][1].type)&&Kt[ee[Ye][1].type].call(Object.assign({sliceSerialize:ee[Ye][2].sliceSerialize},Te),ee[Ye][1])}if(Te.tokenStack.length>0){const Kt=Te.tokenStack[Te.tokenStack.length-1];(Kt[1]||Rv).call(Te,void 0,Kt[0])}for(xe.position={start:Ps(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:Ps(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},Ye=-1;++Ye<t.transforms.length;)xe=t.transforms[Ye](xe)||xe;return xe}function a(ee,xe,Te){let Ue=xe-1,Ye=-1,Kt=!1,mi,Lt,Et,Gt;for(;++Ue<=Te;){const ut=ee[Ue];switch(ut[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ut[0]==="enter"?Ye++:Ye--,Gt=void 0;break}case"lineEndingBlank":{ut[0]==="enter"&&(mi&&!Gt&&!Ye&&!Et&&(Et=Ue),Gt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Gt=void 0}if(!Ye&&ut[0]==="enter"&&ut[1].type==="listItemPrefix"||Ye===-1&&ut[0]==="exit"&&(ut[1].type==="listUnordered"||ut[1].type==="listOrdered")){if(mi){let $t=Ue;for(Lt=void 0;$t--;){const wt=ee[$t];if(wt[1].type==="lineEnding"||wt[1].type==="lineEndingBlank"){if(wt[0]==="exit")continue;Lt&&(ee[Lt][1].type="lineEndingBlank",Kt=!0),wt[1].type="lineEnding",Lt=$t}else if(!(wt[1].type==="linePrefix"||wt[1].type==="blockQuotePrefix"||wt[1].type==="blockQuotePrefixWhitespace"||wt[1].type==="blockQuoteMarker"||wt[1].type==="listItemIndent"))break}Et&&(!Lt||Et<Lt)&&(mi._spread=!0),mi.end=Object.assign({},Lt?ee[Lt][1].start:ut[1].end),ee.splice(Lt||Ue,0,["exit",mi,ut[2]]),Ue++,Te++}if(ut[1].type==="listItemPrefix"){const $t={type:"listItem",_spread:!1,start:Object.assign({},ut[1].start),end:void 0};mi=$t,ee.splice(Ue,0,["enter",$t,ut[2]]),Ue++,Te++,Et=void 0,Gt=!0}}}return ee[xe][1]._spread=Kt,Te}function o(ee,xe){return Te;function Te(Ue){h.call(this,ee(Ue),Ue),xe&&xe.call(this,Ue)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(ee,xe,Te){this.stack[this.stack.length-1].children.push(ee),this.stack.push(ee),this.tokenStack.push([xe,Te||void 0]),ee.position={start:Ps(xe.start),end:void 0}}function p(ee){return xe;function xe(Te){ee&&ee.call(this,Te),f.call(this,Te)}}function f(ee,xe){const Te=this.stack.pop(),Ue=this.tokenStack.pop();if(Ue)Ue[0].type!==ee.type&&(xe?xe.call(this,ee,Ue[0]):(Ue[1]||Rv).call(this,ee,Ue[0]));else throw new Error("Cannot close `"+ee.type+"` ("+Do({start:ee.start,end:ee.end})+"): it’s not open");Te.position.end=Ps(ee.end)}function _(){return lm(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function b(ee){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(ee),10),this.data.expectingFirstListItemValue=void 0}}function v(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=ee}function S(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=ee}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function B(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ee.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ee.replace(/(\r?\n|\r)$/g,"")}function z(ee){const xe=this.resume(),Te=this.stack[this.stack.length-1];Te.label=xe,Te.identifier=br(this.sliceSerialize(ee)).toLowerCase()}function I(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ee}function R(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ee}function H(ee){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Te=this.sliceSerialize(ee).length;xe.depth=Te}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function ie(ee){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(ee).codePointAt(0)===61?1:2}function ue(){this.data.setextHeadingSlurpLineEnding=void 0}function ve(ee){const Te=this.stack[this.stack.length-1].children;let Ue=Te[Te.length-1];(!Ue||Ue.type!=="text")&&(Ue=St(),Ue.position={start:Ps(ee.start),end:void 0},Te.push(Ue)),this.stack.push(Ue)}function L(ee){const xe=this.stack.pop();xe.value+=this.sliceSerialize(ee),xe.position.end=Ps(ee.end)}function re(ee){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Te=xe.children[xe.children.length-1];Te.position.end=Ps(ee.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(ve.call(this,ee),L.call(this,ee))}function F(){this.data.atHardBreak=!0}function Y(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ee}function K(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ee}function $(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ee}function T(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=xe,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function q(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=xe,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function W(ee){const xe=this.sliceSerialize(ee),Te=this.stack[this.stack.length-2];Te.label=Kj(xe),Te.identifier=br(xe).toLowerCase()}function ge(){const ee=this.stack[this.stack.length-1],xe=this.resume(),Te=this.stack[this.stack.length-1];if(this.data.inReference=!0,Te.type==="link"){const Ue=ee.children;Te.children=Ue}else Te.alt=xe}function j(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ee}function A(){const ee=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ee}function Z(){this.data.inReference=void 0}function k(){this.data.referenceType="collapsed"}function oe(ee){const xe=this.resume(),Te=this.stack[this.stack.length-1];Te.label=xe,Te.identifier=br(this.sliceSerialize(ee)).toLowerCase(),this.data.referenceType="full"}function ae(ee){this.data.characterReferenceType=ee.type}function V(ee){const xe=this.sliceSerialize(ee),Te=this.data.characterReferenceType;let Ue;Te?(Ue=F0(xe,Te==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ue=om(xe);const Ye=this.stack[this.stack.length-1];Ye.value+=Ue}function X(ee){const xe=this.stack.pop();xe.position.end=Ps(ee.end)}function he(ee){L.call(this,ee);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(ee)}function _e(ee){L.call(this,ee);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(ee)}function Ae(){return{type:"blockquote",children:[]}}function Oe(){return{type:"code",lang:null,meta:null,value:""}}function He(){return{type:"inlineCode",value:""}}function Re(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function et(){return{type:"emphasis",children:[]}}function Ge(){return{type:"heading",depth:0,children:[]}}function ot(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Be(){return{type:"image",title:null,url:"",alt:null}}function Ve(){return{type:"link",title:null,url:"",children:[]}}function Nt(ee){return{type:"list",ordered:ee.type==="listOrdered",start:null,spread:ee._spread,children:[]}}function kt(ee){return{type:"listItem",spread:ee._spread,checked:null,children:[]}}function pi(){return{type:"paragraph",children:[]}}function Me(){return{type:"strong",children:[]}}function St(){return{type:"text",value:""}}function ct(){return{type:"thematicBreak"}}}function Ps(e){return{line:e.line,column:e.column,offset:e.offset}}function eS(e,t){let i=-1;for(;++i<t.length;){const s=t[i];Array.isArray(s)?eS(e,s):Jj(e,s)}}function Jj(e,t){let i;for(i in t)if(J0.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 Rv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Do({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Do({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Do({start:t.start,end:t.end})+") is still open")}function eT(e){const t=this;t.parser=i;function i(s){return Zj(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function tT(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 iT(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:`
|
|
105
|
+
`}]}function nT(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 rT(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function sT(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function aT(e,t){const i=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=bl(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 f={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,f),e.applyData(t,f)}function lT(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 oT(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}}function tS(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 cT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return tS(e,t);const a={src:bl(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 uT(e,t){const i={src:bl(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 hT(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 dT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return tS(e,t);const a={href:bl(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 fT(e,t){const i={href:bl(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 pT(e,t,i){const s=e.all(t),a=i?mT(i):iS(t),o={},c=[];if(typeof t.checked=="boolean"){const _=s[0];let g;_&&_.type==="element"&&_.tagName==="p"?g=_:(g={type:"element",tagName:"p",properties:{},children:[]},s.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.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 _=s[h];(a||h!==0||_.type!=="element"||_.tagName!=="p")&&c.push({type:"text",value:`
|
|
107
|
+
`}),_.type==="element"&&_.tagName==="p"&&!a?c.push(..._.children):c.push(_)}const p=s[s.length-1];p&&(a||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
|
|
108
|
+
`});const f={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,f),e.applyData(t,f)}function mT(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=iS(i[s])}return t}function iS(e){const t=e.spread;return t??e.children.length>1}function gT(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 xT(e,t){const i={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function _T(e,t){const i={type:"root",children:e.wrap(e.all(t))};return e.patch(t,i),e.applyData(t,i)}function bT(e,t){const i={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function vT(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=nm(t.children[1]),p=B0(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 yT(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 f=[];for(;++p<h;){const g=t.children[p],b={},v=c?c[p]:void 0;v&&(b.align=v);let S={type:"element",tagName:o,properties:b,children:[]};g&&(S.children=e.all(g),e.patch(g,S),S=e.applyData(g,S)),f.push(S)}const _={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,_),e.applyData(t,_)}function ST(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}const Dv=9,Mv=32;function wT(e){const t=String(e),i=/\r?\n|\r/g;let s=i.exec(t),a=0;const o=[];for(;s;)o.push(Bv(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=i.exec(t);return o.push(Bv(t.slice(a),a>0,!1)),o.join("")}function Bv(e,t,i){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Dv||o===Mv;)s++,o=e.codePointAt(s)}if(i){let o=e.codePointAt(a-1);for(;o===Dv||o===Mv;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function CT(e,t){const i={type:"text",value:wT(String(t.value))};return e.patch(t,i),e.applyData(t,i)}function kT(e,t){const i={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,i),e.applyData(t,i)}const ET={blockquote:tT,break:iT,code:nT,delete:rT,emphasis:sT,footnoteReference:aT,heading:lT,html:oT,imageReference:cT,image:uT,inlineCode:hT,linkReference:dT,link:fT,listItem:pT,list:gT,paragraph:xT,root:_T,strong:bT,table:vT,tableCell:ST,tableRow:yT,text:CT,thematicBreak:kT,toml:cu,yaml:cu,definition:cu,footnoteDefinition:cu};function cu(){}const nS=-1,Wu=0,Bo=1,Bu=2,um=3,hm=4,dm=5,fm=6,rS=7,sS=8,Lv=typeof self=="object"?self:globalThis,NT=(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 Wu:case nS:return i(c,a);case Bo:{const h=i([],a);for(const p of c)h.push(s(p));return h}case Bu:{const h=i({},a);for(const[p,f]of c)h[s(p)]=s(f);return h}case um:return i(new Date(c),a);case hm:{const{source:h,flags:p}=c;return i(new RegExp(h,p),a)}case dm:{const h=i(new Map,a);for(const[p,f]of c)h.set(s(p),s(f));return h}case fm:{const h=i(new Set,a);for(const p of c)h.add(s(p));return h}case rS:{const{name:h,message:p}=c;return i(new Lv[h](p),a)}case sS: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 Lv[o](c),a)};return s},Ov=e=>NT(new Map,e)(0),al="",{toString:jT}={},{keys:TT}=Object,yo=e=>{const t=typeof e;if(t!=="object"||!e)return[Wu,t];const i=jT.call(e).slice(8,-1);switch(i){case"Array":return[Bo,al];case"Object":return[Bu,al];case"Date":return[um,al];case"RegExp":return[hm,al];case"Map":return[dm,al];case"Set":return[fm,al];case"DataView":return[Bo,i]}return i.includes("Array")?[Bo,i]:i.includes("Error")?[rS,i]:[Bu,i]},uu=([e,t])=>e===Wu&&(t==="function"||t==="symbol"),AT=(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]=yo(c);switch(h){case Wu:{let _=c;switch(p){case"bigint":h=sS,_=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);_=null;break;case"undefined":return a([nS],c)}return a([h,_],c)}case Bo:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const _=[],g=a([h,_],c);for(const b of c)_.push(o(b));return g}case Bu:{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 _=[],g=a([h,_],c);for(const b of TT(c))(e||!uu(yo(c[b])))&&_.push([o(b),o(c[b])]);return g}case um:return a([h,c.toISOString()],c);case hm:{const{source:_,flags:g}=c;return a([h,{source:_,flags:g}],c)}case dm:{const _=[],g=a([h,_],c);for(const[b,v]of c)(e||!(uu(yo(b))||uu(yo(v))))&&_.push([o(b),o(v)]);return g}case fm:{const _=[],g=a([h,_],c);for(const b of c)(e||!uu(yo(b)))&&_.push(o(b));return g}}const{message:f}=c;return a([h,{name:p,message:f}],c)};return o},zv=(e,{json:t,lossy:i}={})=>{const s=[];return AT(!(t||i),!!t,new Map,s)(e),s},Ho=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ov(zv(e,t)):structuredClone(e):(e,t)=>Ov(zv(e,t));function RT(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 DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function MT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=e.options.footnoteBackContent||RT,s=e.options.footnoteBackLabel||DT,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 f=e.footnoteById.get(e.footnoteOrder[p]);if(!f)continue;const _=e.all(f),g=String(f.identifier).toUpperCase(),b=bl(g.toLowerCase());let v=0;const S=[],N=e.footnoteCounts.get(g);for(;N!==void 0&&++v<=N;){S.length>0&&S.push({type:"text",value:" "});let z=typeof i=="string"?i:i(p,v);typeof z=="string"&&(z={type:"text",value:z}),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(z)?z:[z]})}const B=_[_.length-1];if(B&&B.type==="element"&&B.tagName==="p"){const z=B.children[B.children.length-1];z&&z.type==="text"?z.value+=" ":B.children.push({type:"text",value:" "}),B.children.push(...S)}else _.push(...S);const E={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(_,!0)};e.patch(f,E),h.push(E)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Ho(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 Gu=(function(e){if(e==null)return zT;if(typeof e=="function")return Yu(e);if(typeof e=="object")return Array.isArray(e)?BT(e):LT(e);if(typeof e=="string")return OT(e);throw new Error("Expected function, string, or object as test")});function BT(e){const t=[];let i=-1;for(;++i<e.length;)t[i]=Gu(e[i]);return Yu(s);function s(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function LT(e){const t=e;return Yu(i);function i(s){const a=s;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function OT(e){return Yu(t);function t(i){return i&&i.type===e}}function Yu(e){return t;function t(i,s,a){return!!(PT(i)&&e.call(this,i,typeof s=="number"?s:void 0,a||void 0))}}function zT(){return!0}function PT(e){return e!==null&&typeof e=="object"&&"type"in e}const aS=[],IT=!0,Ap=!1,HT="skip";function lS(e,t,i,s){let a;typeof t=="function"&&typeof i!="function"?(s=i,i=t):a=t;const o=Gu(a),c=s?-1:1;h(e,void 0,[])();function h(p,f,_){const g=p&&typeof p=="object"?p:{};if(typeof g.type=="string"){const v=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(p.type+(v?"<"+v+">":""))+")"})}return b;function b(){let v=aS,S,N,B;if((!t||o(p,f,_[_.length-1]||void 0))&&(v=UT(i(p,_)),v[0]===Ap))return v;if("children"in p&&p.children){const E=p;if(E.children&&v[0]!==HT)for(N=(s?E.children.length:-1)+c,B=_.concat(E);N>-1&&N<E.children.length;){const z=E.children[N];if(S=h(z,N,B)(),S[0]===Ap)return S;N=typeof S[1]=="number"?S[1]:N+c}}return v}}}function UT(e){return Array.isArray(e)?e:typeof e=="number"?[IT,e]:e==null?aS:[e]}function pm(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),lS(e,o,h,a);function h(p,f){const _=f[f.length-1],g=_?_.children.indexOf(p):void 0;return c(p,g,_)}}const Rp={}.hasOwnProperty,$T={};function FT(e,t){const i=t||$T,s=new Map,a=new Map,o=new Map,c={...ET,...i.handlers},h={all:f,applyData:WT,definitionById:s,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:p,options:i,patch:qT,wrap:YT};return pm(e,function(_){if(_.type==="definition"||_.type==="footnoteDefinition"){const g=_.type==="definition"?s:a,b=String(_.identifier).toUpperCase();g.has(b)||g.set(b,_)}}),h;function p(_,g){const b=_.type,v=h.handlers[b];if(Rp.call(h.handlers,b)&&v)return v(h,_,g);if(h.options.passThrough&&h.options.passThrough.includes(b)){if("children"in _){const{children:N,...B}=_,E=Ho(B);return E.children=h.all(_),E}return Ho(_)}return(h.options.unknownHandler||GT)(h,_,g)}function f(_){const g=[];if("children"in _){const b=_.children;let v=-1;for(;++v<b.length;){const S=h.one(b[v],_);if(S){if(v&&b[v-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=Pv(S.value)),!Array.isArray(S)&&S.type==="element")){const N=S.children[0];N&&N.type==="text"&&(N.value=Pv(N.value))}Array.isArray(S)?g.push(...S):g.push(S)}}}return g}}function qT(e,t){e.position&&(t.position=O0(e))}function WT(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,Ho(o)),"children"in i&&i.children&&a!==null&&a!==void 0&&(i.children=a)}return i}function GT(e,t){const i=t.data||{},s="value"in t&&!(Rp.call(i,"hProperties")||Rp.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 YT(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 Pv(e){let t=0,i=e.charCodeAt(t);for(;i===9||i===32;)t++,i=e.charCodeAt(t);return e.slice(t)}function Iv(e,t){const i=FT(e,t),s=i.one(e,void 0),a=MT(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 VT(e,t){return e&&"run"in e?async function(i,s){const a=Iv(i,{file:s,...t});await e.run(a,s)}:function(i,s){return Iv(i,{file:s,...e||t})}}function Hv(e){if(e)throw e}var yf,Uv;function KT(){if(Uv)return yf;Uv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var _=e.call(f,"constructor"),g=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!_&&!g)return!1;var b;for(b in f);return typeof b>"u"||e.call(f,b)},c=function(f,_){i&&_.name==="__proto__"?i(f,_.name,{enumerable:!0,configurable:!0,value:_.newValue,writable:!0}):f[_.name]=_.newValue},h=function(f,_){if(_==="__proto__")if(e.call(f,_)){if(s)return s(f,_).value}else return;return f[_]};return yf=function p(){var f,_,g,b,v,S,N=arguments[0],B=1,E=arguments.length,z=!1;for(typeof N=="boolean"&&(z=N,N=arguments[1]||{},B=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});B<E;++B)if(f=arguments[B],f!=null)for(_ in f)g=h(N,_),b=h(f,_),N!==b&&(z&&b&&(o(b)||(v=a(b)))?(v?(v=!1,S=g&&a(g)?g:[]):S=g&&o(g)?g:{},c(N,{name:_,newValue:p(z,S,b)})):typeof b<"u"&&c(N,{name:_,newValue:b}));return N},yf}var XT=KT();const Sf=Pu(XT);function Dp(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 ZT(){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,...f){const _=e[++o];let g=-1;if(p){c(p);return}for(;++g<a.length;)(f[g]===null||f[g]===void 0)&&(f[g]=a[g]);a=f,_?QT(_,h)(...f):c(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function QT(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(f){const _=f;if(h&&i)throw _;return a(_)}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 Tr={basename:JT,dirname:eA,extname:tA,join:iA,sep:"/"};function JT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ko(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 eA(e){if(Ko(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 tA(e){Ko(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 iA(...e){let t=-1,i;for(;++t<e.length;)Ko(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":nA(i)}function nA(e){Ko(e);const t=e.codePointAt(0)===47;let i=rA(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function rA(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 Ko(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const sA={cwd:aA};function aA(){return"/"}function Mp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function lA(e){if(typeof e=="string")e=new URL(e);else if(!Mp(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 oA(e)}function oA(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 wf=["history","path","basename","stem","extname","dirname"];class oS{constructor(t){let i;t?Mp(t)?i={path:t}:typeof t=="string"||cA(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":sA.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<wf.length;){const o=wf[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)wf.includes(a)||(this[a]=i[a])}get basename(){return typeof this.path=="string"?Tr.basename(this.path):void 0}set basename(t){kf(t,"basename"),Cf(t,"basename"),this.path=Tr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Tr.dirname(this.path):void 0}set dirname(t){$v(this.basename,"dirname"),this.path=Tr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Tr.extname(this.path):void 0}set extname(t){if(Cf(t,"extname"),$v(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=Tr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Mp(t)&&(t=lA(t)),kf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Tr.basename(this.path,this.extname):void 0}set stem(t){kf(t,"stem"),Cf(t,"stem"),this.path=Tr.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 Cf(e,t){if(e&&e.includes(Tr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Tr.sep+"`")}function kf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function $v(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function cA(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const uA=(function(e){const s=this.constructor.prototype,a=s[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,s),o}),hA={}.hasOwnProperty;class mm extends uA{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=ZT()}copy(){const t=new mm;let i=-1;for(;++i<this.attachers.length;){const s=this.attachers[i];t.use(...s)}return t.data(Sf(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(jf("data",this.frozen),this.namespace[t]=i,this):hA.call(this.namespace,t)&&this.namespace[t]||void 0:t?(jf("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=hu(t),s=this.parser||this.Parser;return Ef("parse",s),s(String(i),i)}process(t,i){const s=this;return this.freeze(),Ef("process",this.parser||this.Parser),Nf("process",this.compiler||this.Compiler),i?a(void 0,i):new Promise(a);function a(o,c){const h=hu(t),p=s.parse(h);s.run(p,h,function(_,g,b){if(_||!g||!b)return f(_);const v=g,S=s.stringify(v,b);pA(S)?b.value=S:b.result=S,f(_,b)});function f(_,g){_||!g?c(_):o?o(g):i(void 0,g)}}}processSync(t){let i=!1,s;return this.freeze(),Ef("processSync",this.parser||this.Parser),Nf("processSync",this.compiler||this.Compiler),this.process(t,a),qv("processSync","process",i),s;function a(o,c){i=!0,Hv(o),s=c}}run(t,i,s){Fv(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=hu(i);a.run(t,p,f);function f(_,g,b){const v=g||t;_?h(_):c?c(v):s(void 0,v,b)}}}runSync(t,i){let s=!1,a;return this.run(t,i,o),qv("runSync","run",s),a;function o(c,h){Hv(c),a=h,s=!0}}stringify(t,i){this.freeze();const s=hu(i),a=this.compiler||this.Compiler;return Nf("stringify",a),Fv(t),a(t,s)}use(t,...i){const s=this.attachers,a=this.namespace;if(jf("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(f){if(typeof f=="function")p(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[_,...g]=f;p(_,g)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))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(f.plugins),f.settings&&(a.settings=Sf(!0,a.settings,f.settings))}function h(f){let _=-1;if(f!=null)if(Array.isArray(f))for(;++_<f.length;){const g=f[_];o(g)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function p(f,_){let g=-1,b=-1;for(;++g<s.length;)if(s[g][0]===f){b=g;break}if(b===-1)s.push([f,..._]);else if(_.length>0){let[v,...S]=_;const N=s[b][1];Dp(N)&&Dp(v)&&(v=Sf(!0,N,v)),s[b]=[f,v,...S]}}}}const dA=new mm().freeze();function Ef(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Nf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function jf(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 Fv(e){if(!Dp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qv(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function hu(e){return fA(e)?e:new oS(e)}function fA(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function pA(e){return typeof e=="string"||mA(e)}function mA(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const gA="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Wv=[],Gv={allowDangerousHtml:!0},xA=/^(https?|ircs?|mailto|xmpp)$/i,_A=[{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 cS(e){const t=bA(e),i=vA(e);return yA(t.runSync(t.parse(i),i),e)}function bA(e){const t=e.rehypePlugins||Wv,i=e.remarkPlugins||Wv,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Gv}:Gv;return dA().use(eT).use(i).use(VT,s).use(t)}function vA(e){const t=e.children||"",i=new oS;return typeof t=="string"&&(i.value=t),i}function yA(e,t){const i=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,h=t.unwrapDisallowed,p=t.urlTransform||SA;for(const _ of _A)Object.hasOwn(t,_.from)&&(""+_.from+(_.to?"use `"+_.to+"` instead":"remove it")+gA+_.id,void 0);return pm(e,f),zN(e,{Fragment:d.Fragment,components:a,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function f(_,g,b){if(_.type==="raw"&&b&&typeof g=="number")return c?b.children.splice(g,1):b.children[g]={type:"text",value:_.value},g;if(_.type==="element"){let v;for(v in _f)if(Object.hasOwn(_f,v)&&Object.hasOwn(_.properties,v)){const S=_.properties[v],N=_f[v];(N===null||N.includes(_.tagName))&&(_.properties[v]=p(String(S||""),v,_))}}if(_.type==="element"){let v=i?!i.includes(_.tagName):o?o.includes(_.tagName):!1;if(!v&&s&&typeof g=="number"&&(v=!s(_,g,b)),v&&b&&typeof g=="number")return h&&_.children?b.children.splice(g,1,..._.children):b.children.splice(g,1),g}}}function SA(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||xA.test(e.slice(0,t))?e:""}function wA(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function uS(e,t,i){const a=Gu((i||{}).ignore||[]),o=CA(t);let c=-1;for(;++c<o.length;)lS(e,"text",h);function h(f,_){let g=-1,b;for(;++g<_.length;){const v=_[g],S=b?b.children:void 0;if(a(v,S?S.indexOf(v):void 0,b))return;b=v}if(b)return p(f,_)}function p(f,_){const g=_[_.length-1],b=o[c][0],v=o[c][1];let S=0;const B=g.children.indexOf(f);let E=!1,z=[];b.lastIndex=0;let I=b.exec(f.value);for(;I;){const R=I.index,H={index:I.index,input:I.input,stack:[..._,f]};let D=v(...I,H);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?b.lastIndex=R+1:(S!==R&&z.push({type:"text",value:f.value.slice(S,R)}),Array.isArray(D)?z.push(...D):D&&z.push(D),S=R+I[0].length,E=!0),!b.global)break;I=b.exec(f.value)}return E?(S<f.value.length&&z.push({type:"text",value:f.value.slice(S)}),g.children.splice(B,1,...z)):z=[f],B+z.length}}function CA(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([kA(a[0]),EA(a[1])])}return t}function kA(e){return typeof e=="string"?new RegExp(wA(e),"g"):e}function EA(e){return typeof e=="function"?e:function(){return e}}function NA(e){uS(e,[/\r?\n|\r/g,jA])}function jA(){return{type:"break"}}function hS(){return function(e){NA(e)}}function Yv(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",Af=["autolink","link","image","label"];function TA(){return{transforms:[OA],enter:{literalAutolink:RA,literalAutolinkEmail:Rf,literalAutolinkHttp:Rf,literalAutolinkWww:Rf},exit:{literalAutolink:LA,literalAutolinkEmail:BA,literalAutolinkHttp:DA,literalAutolinkWww:MA}}}function AA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Tf,notInConstruct:Af},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Tf,notInConstruct:Af},{character:":",before:"[ps]",after:"\\/",inConstruct:Tf,notInConstruct:Af}]}}function RA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Rf(e){this.config.enter.autolinkProtocol.call(this,e)}function DA(e){this.config.exit.autolinkProtocol.call(this,e)}function MA(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 BA(e){this.config.exit.autolinkEmail.call(this,e)}function LA(e){this.exit(e)}function OA(e){uS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,zA],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),PA]],{ignore:["link","linkReference"]})}function zA(e,t,i,s,a){let o="";if(!dS(a)||(/^w/i.test(t)&&(i=t+i,t="",o="http://"),!IA(i)))return!1;const c=HA(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 PA(e,t,i,s){return!dS(s,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function IA(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 HA(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=Yv(e,"(");let o=Yv(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 dS(e,t){const i=e.input.charCodeAt(e.index-1);return(e.index===0||ba(i)||Fu(i))&&(!t||i!==47)}fS.peek=KA;function UA(){this.buffer()}function $A(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function FA(){this.buffer()}function qA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function WA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=br(this.sliceSerialize(e)).toLowerCase(),i.label=t}function GA(e){this.exit(e)}function YA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=br(this.sliceSerialize(e)).toLowerCase(),i.label=t}function VA(e){this.exit(e)}function KA(){return"["}function fS(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 XA(){return{enter:{gfmFootnoteCallString:UA,gfmFootnoteCall:$A,gfmFootnoteDefinitionLabelString:FA,gfmFootnoteDefinition:qA},exit:{gfmFootnoteCallString:WA,gfmFootnoteCall:GA,gfmFootnoteDefinitionLabelString:YA,gfmFootnoteDefinition:VA}}}function ZA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:i,footnoteReference:fS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(s,a,o,c){const h=o.createTracker(c);let p=h.move("[^");const f=o.enter("footnoteDefinition"),_=o.enter("label");return p+=h.move(o.safe(o.associationId(s),{before:p,after:"]"})),_(),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?pS:QA))),f(),p}}function QA(e,t,i){return t===0?e:pS(e,t,i)}function pS(e,t,i){return(i?"":" ")+e}const JA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];mS.peek=rR;function eR(){return{canContainEols:["delete"],enter:{strikethrough:iR},exit:{strikethrough:nR}}}function tR(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:JA}],handlers:{delete:mS}}}function iR(e){this.enter({type:"delete",children:[]},e)}function nR(e){this.exit(e)}function mS(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 rR(){return"~"}function sR(e){return e.length}function aR(e,t){const i=t||{},s=(i.align||[]).concat(),a=i.stringLength||sR,o=[],c=[],h=[],p=[];let f=0,_=-1;for(;++_<e.length;){const N=[],B=[];let E=-1;for(e[_].length>f&&(f=e[_].length);++E<e[_].length;){const z=lR(e[_][E]);if(i.alignDelimiters!==!1){const I=a(z);B[E]=I,(p[E]===void 0||I>p[E])&&(p[E]=I)}N.push(z)}c[_]=N,h[_]=B}let g=-1;if(typeof s=="object"&&"length"in s)for(;++g<f;)o[g]=Vv(s[g]);else{const N=Vv(s);for(;++g<f;)o[g]=N}g=-1;const b=[],v=[];for(;++g<f;){const N=o[g];let B="",E="";N===99?(B=":",E=":"):N===108?B=":":N===114&&(E=":");let z=i.alignDelimiters===!1?1:Math.max(1,p[g]-B.length-E.length);const I=B+"-".repeat(z)+E;i.alignDelimiters!==!1&&(z=B.length+z+E.length,z>p[g]&&(p[g]=z),v[g]=z),b[g]=I}c.splice(1,0,b),h.splice(1,0,v),_=-1;const S=[];for(;++_<c.length;){const N=c[_],B=h[_];g=-1;const E=[];for(;++g<f;){const z=N[g]||"";let I="",R="";if(i.alignDelimiters!==!1){const H=p[g]-(B[g]||0),D=o[g];D===114?I=" ".repeat(H):D===99?H%2?(I=" ".repeat(H/2+.5),R=" ".repeat(H/2-.5)):(I=" ".repeat(H/2),R=I):R=" ".repeat(H)}i.delimiterStart!==!1&&!g&&E.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&z==="")&&(i.delimiterStart!==!1||g)&&E.push(" "),i.alignDelimiters!==!1&&E.push(I),E.push(z),i.alignDelimiters!==!1&&E.push(R),i.padding!==!1&&E.push(" "),(i.delimiterEnd!==!1||g!==f-1)&&E.push("|")}S.push(i.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return S.join(`
|
|
116
|
+
`)}function lR(e){return e==null?"":String(e)}function Vv(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 oR(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()),cR);return a(),c}function cR(e,t,i){return">"+(i?"":" ")+e}function uR(e,t){return Kv(e,t.inConstruct,!0)&&!Kv(e,t.notInConstruct,!1)}function Kv(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 Xv(e,t,i,s){let a=-1;for(;++a<i.unsafe.length;)if(i.unsafe[a].character===`
|
|
117
|
+
`&&uR(i.stack,i.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
118
|
+
`}function hR(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 dR(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 fR(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 pR(e,t,i,s){const a=fR(i),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(dR(e,i)){const g=i.enter("codeIndented"),b=i.indentLines(o,mR);return g(),b}const h=i.createTracker(s),p=a.repeat(Math.max(hR(o,a)+1,3)),f=i.enter("codeFenced");let _=h.move(p);if(e.lang){const g=i.enter(`codeFencedLang${c}`);_+=h.move(i.safe(e.lang,{before:_,after:" ",encode:["`"],...h.current()})),g()}if(e.lang&&e.meta){const g=i.enter(`codeFencedMeta${c}`);_+=h.move(" "),_+=h.move(i.safe(e.meta,{before:_,after:`
|
|
119
|
+
`,encode:["`"],...h.current()})),g()}return _+=h.move(`
|
|
120
|
+
`),o&&(_+=h.move(o+`
|
|
121
|
+
`)),_+=h.move(p),f(),_}function mR(e,t,i){return(i?"":" ")+e}function gm(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 gR(e,t,i,s){const a=gm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("definition");let h=i.enter("label");const p=i.createTracker(s);let f=p.move("[");return f+=p.move(i.safe(i.associationId(e),{before:f,after:"]",...p.current()})),f+=p.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(i.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(h=i.enter("destinationRaw"),f+=p.move(i.safe(e.url,{before:f,after:e.title?" ":`
|
|
122
|
+
`,...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(i.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),h()),c(),f}function xR(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 Uo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Lu(e,t,i){const s=pl(e),a=pl(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}}gS.peek=_R;function gS(e,t,i,s){const a=xR(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 f=p.charCodeAt(0),_=Lu(s.before.charCodeAt(s.before.length-1),f,a);_.inside&&(p=Uo(f)+p.slice(1));const g=p.charCodeAt(p.length-1),b=Lu(s.after.charCodeAt(0),g,a);b.inside&&(p=p.slice(0,-1)+Uo(g));const v=c.move(a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:_.outside},h+p+v}function _R(e,t,i){return i.options.emphasis||"*"}function bR(e,t){let i=!1;return pm(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return i=!0,Ap}),!!((!e.depth||e.depth<3)&&lm(e)&&(t.options.setext||i))}function vR(e,t,i,s){const a=Math.max(Math.min(6,e.depth||1),1),o=i.createTracker(s);if(bR(e,i)){const _=i.enter("headingSetext"),g=i.enter("phrasing"),b=i.containerPhrasing(e,{...o.current(),before:`
|
|
123
|
+
`,after:`
|
|
124
|
+
`});return g(),_(),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 f=i.containerPhrasing(e,{before:"# ",after:`
|
|
127
|
+
`,...o.current()});return/^[\t ]/.test(f)&&(f=Uo(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,i.options.closeAtx&&(f+=" "+c),p(),h(),f}xS.peek=yR;function xS(e){return e.value||""}function yR(){return"<"}_S.peek=SR;function _S(e,t,i,s){const a=gm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("image");let h=i.enter("label");const p=i.createTracker(s);let f=p.move("![");return f+=p.move(i.safe(e.alt,{before:f,after:"]",...p.current()})),f+=p.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(i.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(h=i.enter("destinationRaw"),f+=p.move(i.safe(e.url,{before:f,after:e.title?" ":")",...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(i.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),h()),f+=p.move(")"),c(),f}function SR(){return"!"}bS.peek=wR;function bS(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 f=i.safe(e.alt,{before:p,after:"]",...h.current()});p+=h.move(f+"]["),c();const _=i.stack;i.stack=[],c=i.enter("reference");const g=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=_,o(),a==="full"||!f||f!==g?p+=h.move(g+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function wR(){return"!"}vS.peek=CR;function vS(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 f=p.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(p.index+1)}}return a+s+a}function CR(){return"`"}function yS(e,t){const i=lm(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))}SS.peek=kR;function SS(e,t,i,s){const a=gm(i),o=a==='"'?"Quote":"Apostrophe",c=i.createTracker(s);let h,p;if(yS(e,i)){const _=i.stack;i.stack=[],h=i.enter("autolink");let g=c.move("<");return g+=c.move(i.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),h(),i.stack=_,g}h=i.enter("link"),p=i.enter("label");let f=c.move("[");return f+=c.move(i.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=i.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(i.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(p=i.enter("destinationRaw"),f+=c.move(i.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=i.enter(`title${o}`),f+=c.move(" "+a),f+=c.move(i.safe(e.title,{before:f,after:a,...c.current()})),f+=c.move(a),p()),f+=c.move(")"),h(),f}function kR(e,t,i){return yS(e,i)?"<":"["}wS.peek=ER;function wS(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 f=i.containerPhrasing(e,{before:p,after:"]",...h.current()});p+=h.move(f+"]["),c();const _=i.stack;i.stack=[],c=i.enter("reference");const g=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=_,o(),a==="full"||!f||f!==g?p+=h.move(g+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function ER(){return"["}function xm(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 NR(e){const t=xm(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 jR(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 CS(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 TR(e,t,i,s){const a=i.enter("list"),o=i.bulletCurrent;let c=e.ordered?jR(i):xm(i);const h=e.ordered?c==="."?")":".":NR(i);let p=t&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!e.ordered){const _=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&_&&(!_.children||!_.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),CS(i)===c&&_){let g=-1;for(;++g<e.children.length;){const b=e.children[g];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 f=i.containerFlow(e,s);return i.bulletLastUsed=c,i.bulletCurrent=o,a(),f}function AR(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 RR(e,t,i,s){const a=AR(i);let o=i.bulletCurrent||xm(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"),f=i.indentLines(i.containerFlow(e,h.current()),_);return p(),f;function _(g,b,v){return b?(v?"":" ".repeat(c))+g:(v?o:o+" ".repeat(c-o.length))+g}}function DR(e,t,i,s){const a=i.enter("paragraph"),o=i.enter("phrasing"),c=i.containerPhrasing(e,s);return o(),a(),c}const MR=Gu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function BR(e,t,i,s){return(e.children.some(function(c){return MR(c)})?i.containerPhrasing:i.containerFlow).call(i,e,s)}function LR(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}kS.peek=OR;function kS(e,t,i,s){const a=LR(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 f=p.charCodeAt(0),_=Lu(s.before.charCodeAt(s.before.length-1),f,a);_.inside&&(p=Uo(f)+p.slice(1));const g=p.charCodeAt(p.length-1),b=Lu(s.after.charCodeAt(0),g,a);b.inside&&(p=p.slice(0,-1)+Uo(g));const v=c.move(a+a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:_.outside},h+p+v}function OR(e,t,i){return i.options.strong||"*"}function zR(e,t,i,s){return i.safe(e.value,s)}function PR(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 IR(e,t,i){const s=(CS(i)+(i.options.ruleSpaces?" ":"")).repeat(PR(i));return i.options.ruleSpaces?s.slice(0,-1):s}const ES={blockquote:oR,break:Xv,code:pR,definition:gR,emphasis:gS,hardBreak:Xv,heading:vR,html:xS,image:_S,imageReference:bS,inlineCode:vS,link:SS,linkReference:wS,list:TR,listItem:RR,paragraph:DR,root:BR,strong:kS,text:zR,thematicBreak:IR};function HR(){return{enter:{table:UR,tableData:Zv,tableHeader:Zv,tableRow:FR},exit:{codeText:qR,table:$R,tableData:Df,tableHeader:Df,tableRow:Df}}}function UR(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 $R(e){this.exit(e),this.data.inTable=void 0}function FR(e){this.enter({type:"tableRow",children:[]},e)}function Df(e){this.exit(e)}function Zv(e){this.enter({type:"tableCell",children:[]},e)}function qR(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WR));const i=this.stack[this.stack.length-1];i.type,i.value=t,this.exit(e)}function WR(e,t){return t==="|"?t:e}function GR(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,B){return f(_(v,N,B),v.align)}function h(v,S,N,B){const E=g(v,N,B),z=f([E]);return z.slice(0,z.indexOf(`
|
|
129
|
+
`))}function p(v,S,N,B){const E=N.enter("tableCell"),z=N.enter("phrasing"),I=N.containerPhrasing(v,{...B,before:o,after:o});return z(),E(),I}function f(v,S){return aR(v,{align:S,alignDelimiters:s,padding:i,stringLength:a})}function _(v,S,N){const B=v.children;let E=-1;const z=[],I=S.enter("table");for(;++E<B.length;)z[E]=g(B[E],S,N);return I(),z}function g(v,S,N){const B=v.children;let E=-1;const z=[],I=S.enter("tableRow");for(;++E<B.length;)z[E]=p(B[E],v,S,N);return I(),z}function b(v,S,N){let B=ES.inlineCode(v,S,N);return N.stack.includes("tableCell")&&(B=B.replace(/\|/g,"\\$&")),B}}function YR(){return{exit:{taskListCheckValueChecked:Qv,taskListCheckValueUnchecked:Qv,paragraph:KR}}}function VR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:XR}}}function Qv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function KR(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 XR(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=ES.listItem(e,t,i,{...s,...h.current()});return o&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),p;function f(_){return _+c}}function ZR(){return[TA(),XA(),eR(),HR(),YR()]}function QR(e){return{extensions:[AA(),ZA(e),tR(),GR(e),VR()]}}const JR={tokenize:s3,partial:!0},NS={tokenize:a3,partial:!0},jS={tokenize:l3,partial:!0},TS={tokenize:o3,partial:!0},e3={tokenize:c3,partial:!0},AS={name:"wwwAutolink",tokenize:n3,previous:DS},RS={name:"protocolAutolink",tokenize:r3,previous:MS},cs={name:"emailAutolink",tokenize:i3,previous:BS},Br={};function t3(){return{text:Br}}let ha=48;for(;ha<123;)Br[ha]=cs,ha++,ha===58?ha=65:ha===91&&(ha=97);Br[43]=cs;Br[45]=cs;Br[46]=cs;Br[95]=cs;Br[72]=[cs,RS];Br[104]=[cs,RS];Br[87]=[cs,AS];Br[119]=[cs,AS];function i3(e,t,i){const s=this;let a,o;return c;function c(g){return!Bp(g)||!BS.call(s,s.previous)||_m(s.events)?i(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(g))}function h(g){return Bp(g)?(e.consume(g),h):g===64?(e.consume(g),p):i(g)}function p(g){return g===46?e.check(e3,_,f)(g):g===45||g===95||fn(g)?(o=!0,e.consume(g),p):_(g)}function f(g){return e.consume(g),a=!0,p}function _(g){return o&&a&&yn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):i(g)}}function n3(e,t,i){const s=this;return a;function a(c){return c!==87&&c!==119||!DS.call(s,s.previous)||_m(s.events)?i(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(JR,e.attempt(NS,e.attempt(jS,o),i),i)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function r3(e,t,i){const s=this;let a="",o=!1;return c;function c(g){return(g===72||g===104)&&MS.call(s,s.previous)&&!_m(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(g),e.consume(g),h):i(g)}function h(g){if(yn(g)&&a.length<5)return a+=String.fromCodePoint(g),e.consume(g),h;if(g===58){const b=a.toLowerCase();if(b==="http"||b==="https")return e.consume(g),p}return i(g)}function p(g){return g===47?(e.consume(g),o?f:(o=!0,p)):i(g)}function f(g){return g===null||Mu(g)||Wt(g)||ba(g)||Fu(g)?i(g):e.attempt(NS,e.attempt(jS,_),i)(g)}function _(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function s3(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 a3(e,t,i){let s,a,o;return c;function c(f){return f===46||f===95?e.check(TS,p,h)(f):f===null||Wt(f)||ba(f)||f!==45&&Fu(f)?p(f):(o=!0,e.consume(f),c)}function h(f){return f===95?s=!0:(a=s,s=void 0),e.consume(f),c}function p(f){return a||s||!o?i(f):t(f)}}function l3(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(TS,t,o)(c):c===null||Wt(c)||ba(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&s++,e.consume(c),a}}function o3(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||Wt(h)||ba(h)?t(h):i(h)}function a(h){return h===null||h===40||h===91||Wt(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 c3(e,t,i){return s;function s(o){return e.consume(o),a}function a(o){return fn(o)?i(o):t(o)}}function DS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Wt(e)}function MS(e){return!yn(e)}function BS(e){return!(e===47||Bp(e))}function Bp(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 u3={tokenize:_3,partial:!0};function h3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:m3,continuation:{tokenize:g3},exit:x3}},text:{91:{name:"gfmFootnoteCall",tokenize:p3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:d3,resolveTo:f3}}}}function d3(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 f=br(s.sliceSerialize({start:c.end,end:s.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?i(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function f3(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 p3(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return h;function h(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),p}function p(g){return g!==94?i(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(g){if(o>999||g===93&&!c||g===null||g===91||Wt(g))return i(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(br(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(g)}return Wt(g)||(c=!0),o++,e.consume(g),g===92?_:f}function _(g){return g===91||g===92||g===93?(e.consume(g),o++,f):f(g)}}function m3(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"),f}function f(S){return S===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",_):i(S)}function _(S){if(c>999||S===93&&!h||S===null||S===91||Wt(S))return i(S);if(S===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return o=br(s.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Wt(S)||(h=!0),c++,e.consume(S),S===92?g:_}function g(S){return S===91||S===92||S===93?(e.consume(S),c++,_):_(S)}function b(S){return S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ct(e,v,"gfmFootnoteDefinitionWhitespace")):i(S)}function v(S){return t(S)}}function g3(e,t,i){return e.check(Vo,t,e.attempt(u3,t,i))}function x3(e){e.exit("gfmFootnoteDefinition")}function _3(e,t,i){const s=this;return Ct(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 b3(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 f=p;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[p][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const _={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[p][1].end)},g={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[p][1].start)},b=[["enter",_,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",g,h]],v=h.parser.constructs.insideSpan.null;v&&Kn(b,b.length,0,qu(v,c.slice(f+1,p),h)),Kn(b,b.length,0,[["exit",g,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",_,h]]),Kn(c,f-1,p-f+3,b),p=f+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 f=this.previous,_=this.events;let g=0;return b;function b(S){return f===126&&_[_.length-1][1].type!=="characterEscape"?p(S):(c.enter("strikethroughSequenceTemporary"),v(S))}function v(S){const N=pl(f);if(S===126)return g>1?p(S):(c.consume(S),g++,v);if(g<2&&!i)return p(S);const B=c.exit("strikethroughSequenceTemporary"),E=pl(S);return B._open=!E||E===2&&!!N,B._close=!N||N===2&&!!E,h(S)}}}class v3{constructor(){this.map=[]}add(t,i,s){y3(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 y3(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 S3(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 w3(){return{flow:{null:{name:"table",tokenize:C3,resolveAll:k3}}}}function C3(e,t,i){const s=this;let a=0,o=0,c;return h;function h(L){let re=s.events.length-1;for(;re>-1;){const K=s.events[re][1].type;if(K==="lineEnding"||K==="linePrefix")re--;else break}const F=re>-1?s.events[re][1].type:null,Y=F==="tableHead"||F==="tableRow"?D:p;return Y===D&&s.parser.lazy[s.now().line]?i(L):Y(L)}function p(L){return e.enter("tableHead"),e.enter("tableRow"),f(L)}function f(L){return L===124||(c=!0,o+=1),_(L)}function _(L){return L===null?i(L):Fe(L)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),v):i(L):xt(L)?Ct(e,_,"whitespace")(L):(o+=1,c&&(c=!1,a+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,_):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||Wt(L)?(e.exit("data"),_(L)):(e.consume(L),L===92?b:g)}function b(L){return L===92||L===124?(e.consume(L),g):g(L)}function v(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?i(L):(e.enter("tableDelimiterRow"),c=!1,xt(L)?Ct(e,S,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):S(L))}function S(L){return L===45||L===58?B(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),N):H(L)}function N(L){return xt(L)?Ct(e,B,"whitespace")(L):B(L)}function B(L){return L===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),E):L===45?(o+=1,E(L)):L===null||Fe(L)?R(L):H(L)}function E(L){return L===45?(e.enter("tableDelimiterFiller"),z(L)):H(L)}function z(L){return L===45?(e.consume(L),z):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(L))}function I(L){return xt(L)?Ct(e,R,"whitespace")(L):R(L)}function R(L){return L===124?S(L):L===null||Fe(L)?!c||a!==o?H(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):H(L)}function H(L){return i(L)}function D(L){return e.enter("tableRow"),ie(L)}function ie(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),ie):L===null||Fe(L)?(e.exit("tableRow"),t(L)):xt(L)?Ct(e,ie,"whitespace")(L):(e.enter("data"),ue(L))}function ue(L){return L===null||L===124||Wt(L)?(e.exit("data"),ie(L)):(e.consume(L),L===92?ve:ue)}function ve(L){return L===92||L===124?(e.consume(L),ue):ue(L)}}function k3(e,t){let i=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,f,_,g;const b=new v3;for(;++i<e.length;){const v=e[i],S=v[1];v[0]==="enter"?S.type==="tableHead"?(h=!1,p!==0&&(Jv(b,t,p,f,_),_=void 0,p=0),f={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(i,0,[["enter",f,t]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(s=!0,g=void 0,o=[0,0,0,0],c=[0,i+1,0,0],h&&(h=!1,_={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},b.add(i,0,[["enter",_,t]])),a=S.type==="tableDelimiterRow"?2:_?3:1):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],g=du(b,t,o,a,void 0,g),o=[0,0,0,0]),c[2]=i)):S.type==="tableCellDivider"&&(s?s=!1:(o[1]!==0&&(c[0]=c[1],g=du(b,t,o,a,void 0,g)),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],g=du(b,t,o,a,i,g)):c[1]!==0&&(g=du(b,t,c,a,i,g)),a=0):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(c[3]=i)}for(p!==0&&Jv(b,t,p,f,_),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=S3(t.events,i))}return e}function du(e,t,i,s,a,o){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",h="tableContent";i[0]!==0&&(o.end=Object.assign({},ll(t.events,i[0])),e.add(i[0],0,[["exit",o,t]]));const p=ll(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 f=ll(t.events,i[2]),_=ll(t.events,i[3]),g={type:h,start:Object.assign({},f),end:Object.assign({},_)};if(e.add(i[2],0,[["enter",g,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",g,t]])}return a!==void 0&&(o.end=Object.assign({},ll(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Jv(e,t,i,s,a){const o=[],c=ll(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 ll(e,t){const i=e[t],s=i[0]==="enter"?"start":"end";return i[1][s]}const E3={name:"tasklistCheck",tokenize:j3};function N3(){return{text:{91:E3}}}function j3(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 Wt(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 Fe(p)?t(p):xt(p)?e.check({tokenize:T3},t,i)(p):i(p)}}function T3(e,t,i){return Ct(e,s,"whitespace");function s(a){return a===null?i(a):t(a)}}function A3(e){return $0([t3(),h3(),b3(e),w3(),N3()])}const R3={};function LS(e){const t=this,i=e||R3,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(A3(i)),o.push(ZR()),c.push(QR(i))}const da=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],ml={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...da,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...da],h2:[["className","sr-only"]],img:[...da,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...da,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...da],table:[...da],ul:[...da,["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"]},Hs={}.hasOwnProperty;function D3(e,t){let i={type:"root",children:[]};const s={schema:t?{...ml,...t}:ml,stack:[]},a=OS(s,e);return a&&(Array.isArray(a)?a.length===1?i=a[0]:i.children=a:i=a),i}function OS(e,t){if(t&&typeof t=="object"){const i=t;switch(typeof i.type=="string"?i.type:""){case"comment":return M3(e,i);case"doctype":return B3(e,i);case"element":return L3(e,i);case"root":return O3(e,i);case"text":return z3(e,i)}}}function M3(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 Xo(o,t),o}}function B3(e,t){if(e.schema.allowDoctypes){const i={type:"doctype"};return Xo(i,t),i}}function L3(e,t){const i=typeof t.tagName=="string"?t.tagName:"";e.stack.push(i);const s=zS(e,t.children),a=P3(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&&Hs.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 Xo(c,t),c}function O3(e,t){const s={type:"root",children:zS(e,t.children)};return Xo(s,t),s}function z3(e,t){const s={type:"text",value:typeof t.value=="string"?t.value:""};return Xo(s,t),s}function zS(e,t){const i=[];if(Array.isArray(t)){const s=t;let a=-1;for(;++a<s.length;){const o=OS(e,s[a]);o&&(Array.isArray(o)?i.push(...o):i.push(o))}}return i}function P3(e,t){const i=e.stack[e.stack.length-1],s=e.schema.attributes,a=e.schema.required,o=s&&Hs.call(s,i)?s[i]:void 0,c=s&&Hs.call(s,"*")?s["*"]:void 0,h=t&&typeof t=="object"?t:{},p={};let f;for(f in h)if(Hs.call(h,f)){const _=h[f];let g=ey(e,ty(o,f),f,_);g==null&&(g=ey(e,ty(c,f),f,_)),g!=null&&(p[f]=g)}if(a&&Hs.call(a,i)){const _=a[i];for(f in _)Hs.call(_,f)&&!Hs.call(p,f)&&(p[f]=_[f])}return p}function ey(e,t,i,s){return t?Array.isArray(s)?I3(e,t,i,s):PS(e,t,i,s):void 0}function I3(e,t,i,s){let a=-1;const o=[];for(;++a<s.length;){const c=PS(e,t,i,s[a]);(typeof c=="number"||typeof c=="string")&&o.push(c)}return o}function PS(e,t,i,s){if(!(typeof s!="boolean"&&typeof s!="number"&&typeof s!="string")&&H3(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 H3(e,t,i){const s=e.schema.protocols&&Hs.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 f=-1;for(;++f<s.length;){const _=s[f];if(o===_.length&&a.slice(0,_.length)===_)return!0}return!1}function Xo(e,t){const i=O0(t);t.data&&(e.data=Ho(t.data)),i&&(e.position=i)}function ty(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 IS(e){return function(t){return D3(t,e)}}const hl=["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"],ss=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function HS(e){return e.toLowerCase().replace(/[^a-z0-9+]/g,"")}const U3=Object.fromEntries(hl.map(e=>[HS(e),e])),$3={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 ku(e){if(!e)return null;const t=HS(e.trim());return t?U3[t]??$3[t]??null:null}function US(e,t){const i=t.startsWith("assets/")?t.slice(7):t;return`/api/stories/${e}/asset/${i}`}function bm(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(US(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 iy({storyName:e,assetPath:t,authFetch:i,alt:s,className:a}){const{url:o,loading:c,error:h}=bm(e,t,i);return h||!c&&!o?d.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center",children:d.jsx("span",{className:"text-xs text-muted",children:"Image not available"})}):o?d.jsx("img",{src:o,alt:s,className:a??"w-full rounded border border-border"}):d.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center","data-testid":"asset-loading",children:d.jsx("span",{className:"text-xs text-muted",children:"Loading image…"})})}function ny(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 jo(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),f=Math.max(1,i-2*h),_=Math.max(1,s-2*p),g=Math.max(a.minFontSize,a.maxFontSize),b=Math.max(1,Math.min(a.minFontSize,g)),v=N=>{const B=a.hasSpeaker?N*c:0,E=a.hasSpeaker?B*o:0,z=Math.max(1,_-E),I=a.fontWeight??400,R=ny((ie,ue)=>e(ie,ue,I),t,f,N),H=R.length*N*o,D=R.every(ie=>e(ie,N,I)<=f+.5);return{lines:R,ok:H<=z&&D}};if(typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&a.fontSize>0){const N=Math.max(1,a.fontSize),{lines:B,ok:E}=v(N);return{lines:B,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!E}}for(let N=g;N>=b;N-=.5){const{lines:B,ok:E}=v(N);if(E)return{lines:B,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!1}}return{lines:ny(e,t,f,b),fontSize:b,lineHeight:b*o,speakerFontSize:a.hasSpeaker?b*c:0,overflow:!0}}function F3(e){return{minFontSize:Math.max(1,e*.022),maxFontSize:Math.max(1,e*.05)}}const $S=["speech","narration","sfx"],q3=2;function Rr(e,t,i){return Math.min(i,Math.max(t,e))}function dl(e,t,i){return typeof e=="number"&&Number.isFinite(e)?Rr(e,t,i):void 0}function vm(e){if(!e||typeof e!="object")return;const t=e,i=t.mode==="manual"?"manual":t.mode==="auto"?"auto":void 0,s=dl(t.fontScale,.015,.12),a=t.fontWeight===700?700:t.fontWeight===400?400:void 0,o=dl(t.lineHeightFactor,.9,2),c=dl(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 Vu(e){if(!e||typeof e!="object")return;const t=e,i=dl(t.paddingX,0,.25),s=dl(t.paddingY,0,.25),a=dl(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 To(e,t,i,s){const{minFontSize:a,maxFontSize:o}=F3(t),c=vm(e.textStyle),h=Vu(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 FS(e,t,i){const s=Vu(e.bubbleStyle);return(s==null?void 0:s.cornerRadius)!==void 0?Math.min(t,i)*s.cornerRadius:void 0}function qS(e,t){const i=Math.min(e,t);return Math.max(0,Math.min(i*.4,i/2))}function ry(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 ym(e,t,i,s,a,o){const c=e+i/2,h=t+s/2,p=e+a.x*i,f=t+a.y*s;if(p>=e&&p<=e+i&&f>=t&&f<=t+s)return null;const _=p-c,g=f-h,b=Math.max(6,Math.min(i,s)*.3),v=o??qS(i,s);if(Math.abs(g)>=Math.abs(_)){const E=g>=0?t+s:t,{center:z,half:I}=ry(p,e,i,v,b);return{tip:{x:p,y:f},base1:{x:z-I,y:E},base2:{x:z+I,y:E}}}const S=_>=0?e+i:e,{center:N,half:B}=ry(f,t,s,v,b);return{tip:{x:p,y:f},base1:{x:S,y:N-B},base2:{x:S,y:N+B}}}function W3(e){return e.type!=="speech"||!e.tailAnchor?!1:ym(0,0,1,1,e.tailAnchor)!==null}function G3(e,t,i,s,a,o){const c=o??qS(i,s),h=e+i,p=t+s,f=!!a&&a.base1.y===t&&a.base2.y===t,_=!!a&&a.base1.x===h&&a.base2.x===h,g=!!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 f&&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}),_&&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}),g&&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 WS(e,t,i,s,a,o){const c=G3(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 Y3(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 sy=0;function Lp(e,t=.1,i=.1){return sy++,{id:`overlay-${Date.now()}-${sy}`,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 GS(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 fu=.05;function Zi(e){return typeof e=="number"&&Number.isFinite(e)}function V3(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 f=a?fu:Rr(o?1-t-fu:(1-t)/2,0,1),_=c?fu:Rr(h?1-i-fu:(1-i)/2,0,1);return{x:f,y:_}}let K3=0;function X3(e){if(!e||typeof e!="object")return null;const t=e,i=$S.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"?V3(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 f={id:typeof t.id=="string"&&t.id?t.id:`overlay-norm-${++K3}`,type:i,x:c,y:h,width:a,height:o,text:s};if(i==="speech"){f.speaker=typeof t.speaker=="string"?t.speaker:"";const b=t.tailAnchor;f.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&&(f.speaker=t.speaker);const _=vm(t.textStyle),g=Vu(t.bubbleStyle);return _&&(f.textStyle=_),g&&(f.bubbleStyle=g),f}function Z3(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&!!t.id&&$S.includes(t.type)&&Zi(t.x)&&Zi(t.y)&&Zi(t.width)&&Zi(t.height)&&typeof t.text=="string"}function Q3(e){const t=Array.isArray(e)?e:[],i=[],s=[];let a=!Array.isArray(e);return t.forEach((o,c)=>{const h=X3(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),Z3(o)||(a=!0)}),{overlays:i,changed:a,invalid:s}}function o4(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=vm(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=Vu(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 ay=new Set(["speech","narration"]),J3=.12;function ly(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 eD(e,t=J3){const i=[];for(let s=0;s<e.length;s++){const a=e[s];if(!(!ay.has(a==null?void 0:a.type)||!ly(a)))for(let o=s+1;o<e.length;o++){const c=e[o];if(!ay.has(c==null?void 0:c.type)||!ly(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 f=h*p,_=Math.min(a.width*a.height,c.width*c.height),g=_>0?f/_:0;g>=t&&i.push({indexA:s,indexB:o,idA:a.id,idB:c.id,ratio:g})}}return i}function vn(e){return e.kind==="text"}function tD(e){return!!e.finalImagePath||!!e.exportedAt?{key:"review",label:"Review final panel",opensEditor:!0}:e.cleanImagePath||vn(e)?{key:"letter",label:"Letter this cut",opensEditor:!0}:{key:"add-art",label:"Add clean art for this cut",opensEditor:!1}}function YS(e,t=q3){return!e.finalImagePath||!(e.overlays??[]).some(W3)?!1:(e.finalRendererVersion??0)<t}const oy=800;function VS(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 pu({cut:e}){return e.dialogue.length>0||e.narration||e.sfx?d.jsxs("div",{className:"space-y-1.5","data-testid":`cut-${e.id}-overlay`,children:[e.dialogue.map((i,s)=>d.jsxs("div",{className:"flex gap-2 text-xs",children:[d.jsxs("span",{className:"font-medium text-foreground flex-shrink-0",children:[i.speaker,":"]}),d.jsx("span",{className:"text-foreground",children:i.text})]},s)),e.narration&&d.jsx("div",{className:"border-l-2 border-border pl-3",children:d.jsx("p",{className:"text-xs text-muted italic",children:e.narration})}),e.sfx&&d.jsxs("p",{className:"text-xs font-mono text-muted",children:["SFX: ",e.sfx]})]}):null}function iD({cut:e,storyName:t,authFetch:i,onEditCut:s}){const a=!!e.finalImagePath,o=!!e.cleanImagePath,c=a||o,h=e.dialogue.length>0||!!e.narration||!!e.sfx,p=e.kind==="text";return d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-[10px] font-mono text-muted bg-surface border border-border rounded px-1.5 py-0.5",children:["#",e.id]}),d.jsx("span",{className:"text-[10px] font-mono text-muted",children:e.shotType}),e.characters.length>0&&d.jsx("span",{className:"text-[10px] text-muted truncate",children:e.characters.join(", ")})]}),a&&d.jsx(iy,{storyName:t,assetPath:e.finalImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),!a&&o&&d.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[d.jsx(iy,{storyName:t,assetPath:e.cleanImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),d.jsx("div",{className:"px-3 py-2 bg-surface/80 border-t border-border",children:d.jsx(pu,{cut:e})})]}),!c&&p&&d.jsxs("div",{className:"w-full border border-border rounded p-4 space-y-2",style:{background:e.background||void 0},"data-testid":`cut-${e.id}-textpanel`,children:[d.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Text panel"}),h?d.jsx(pu,{cut:e}):d.jsx("p",{className:"text-xs text-muted italic",children:"Empty text panel — open the editor to add text."})]}),!c&&!p&&d.jsxs("div",{className:"w-full bg-surface border border-dashed border-border rounded p-4 space-y-2","data-testid":`cut-${e.id}-pending`,children:[d.jsxs("div",{className:"aspect-video flex flex-col items-center justify-center gap-1 text-center",children:[d.jsx("span",{className:"text-xs text-muted font-medium",children:"Image pending"}),d.jsx("span",{className:"text-[10px] text-muted",children:"Planned image cut — generate & upload the art"})]}),h&&d.jsxs("div",{className:"border-t border-dashed border-border pt-2 space-y-1",children:[d.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Planned text (will be lettered onto the image)"}),d.jsx(pu,{cut:e})]})]}),e.description&&d.jsx("p",{className:"text-xs text-muted italic",children:e.description}),a&&d.jsx(pu,{cut:e}),s&&(()=>{const f=tD(e);return d.jsx("button",{type:"button","data-testid":`cut-${e.id}-cta`,"data-cut-action":f.key,onClick:()=>s(e.id,f.opensEditor),className:"w-full px-3 py-1.5 text-xs font-medium rounded bg-accent text-white hover:bg-accent-dim",children:f.label})})()]})}function nD({storyName:e,fileName:t,authFetch:i,onEditCut:s}){const[a,o]=w.useState(null),[c,h]=w.useState(!0),[p,f]=w.useState(null),_=t.replace(/\.md$/,""),g=w.useCallback(async()=>{h(!0),f(null);try{const b=await i(`/api/stories/${e}/cuts/${_}`);if(b.status===404){o(null),h(!1);return}if(!b.ok){const S=await b.json();f(S.error||"Failed to load cuts"),h(!1);return}const v=await b.json();o(v)}catch{f("Failed to load cuts")}finally{h(!1)}},[i,e,_]);return w.useEffect(()=>{g();const b=setInterval(g,5e3);return()=>clearInterval(b)},[g]),c&&!a?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Loading cuts..."}):p?d.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center","data-testid":"cuts-error",children:[d.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),d.jsx("p",{className:"text-xs text-error",children:p}),d.jsxs("p",{className:"text-xs text-muted max-w-sm",children:[_,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema shown in the cartoon writing instructions."]}),d.jsx("button",{onClick:g,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]}):!a||a.cuts.length===0?d.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center",children:[d.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),d.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]}):d.jsx("div",{className:"h-full overflow-y-auto",children:d.jsx("div",{className:"max-w-lg mx-auto px-4 py-6 space-y-6",children:a.cuts.map(b=>d.jsx(iD,{cut:b,storyName:e,authFetch:i,onEditCut:s},b.id))})})}const cy=/!\[[^\]]*\]\([^)]*\)/g,rD=/<!--[\s\S]*?-->/g,KS=200;function sD(e){const t=(e.match(cy)||[]).length,i=e.length,s=e.replace(rD," ").replace(cy," ").replace(/\s+/g," ").trim();return{imageCount:t,charCount:i,nonImageProse:s,nonImageProsePreview:s.slice(0,KS)}}function aD(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 cD(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 XS(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}`,f=`cut-${String(c+1).padStart(3,"0")}`;h.uploadedUrl||i.push(`${p}: not uploaded (no recorded uploaded URL)`),YS(h)&&i.push(aD(p));const _=Sm(e,f);if(_===null){i.push(`${p}: missing or incomplete markdown block`);continue}const g=[..._.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)].map(b=>b[1].trim());g.length===0?i.push(`${p}: block has no image reference`):g.length>1?i.push(`${p}: block must contain exactly one image reference`):h.uploadedUrl&&g[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 ZS(e,t){const i=t.length;if(i===0)return{stage:"not-started",issues:[],awaitingCount:0,totalCuts:0};if(cD(e,t))return{stage:"planning",issues:[],awaitingCount:0,totalCuts:i};const{ready:s,issues:a}=XS(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 f=`Cut ${p+1}`,_=`cut-${String(p+1).padStart(3,"0")}`,g=Sm(e,_);if(g===null)continue;!/!\[[^\]]*\]\([^)]*\)/.test(g)&&!t[p].uploadedUrl&&o.add(f)}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 uD(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,f)=>p-f);return`${c.length===1?`Cut ${c[0]}`:`Cuts ${c.join(", ")}`}: ${o}`}),...s]}function QS(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:uD(h)})}return o}const hD=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<hD)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(`
|
|
130
|
+
`).map(g=>g.trim()).filter(Boolean),p=h.filter(g=>/^([-*+]|\d+[.)])\s/.test(g)||Bf.test(g)).length,f=c.split(/\n\s*\n/).map(g=>g.trim()).filter(Boolean),_=f.some(g=>g.length>=120&&!/^([-*+]|\d+[.)])\s/.test(g)&&!Bf.test(g));h.length>0&&p/h.length>=.5||!_?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."):f.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 dD(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&&dD(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 fD={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 So(e,t){return`${e} / ${t} cut${t===1?"":"s"}`}function JS(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,_={plan:a,clean:o,letter:c,export:h,upload:p,publish:p&&i},g=["plan","clean","letter","export","upload","publish"],b=g.findIndex(z=>!_[z]),v=z=>s.needClean>0?So(z,s.needClean):"no image cuts",S={plan:So(s.total,s.total),clean:v(s.withClean),letter:So(s.withText,s.total),export:So(s.exported,s.total),upload:So(s.uploaded,s.total),publish:null},N=g.map((z,I)=>({key:z,label:fD[z],status:b===-1||I<b?"done":I===b?"current":"todo",detail:S[z]})),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."}[g[b]];return{steps:N,nextStep:E}}const pD="This is your story outline — not publishable. Ask AI to write the genesis next.";function mD(e){const{fileName:t,contentType:i,hasGenesis:s,isPublished:a,cutCount:o,cutProgress:c}=e,h=t==="structure.md",p=t==="genesis.md",f=/^plot-\d+\.md$/.test(t);if(h)return i!=="cartoon"?pD: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||f)&&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 _=c;if(_.withClean<_.needClean)return"Genesis has a cut plan — generate the clean images for its cuts next.";if(_.withText<_.total)return"Genesis clean art is ready — review the cuts and add speech bubbles & captions next.";if(_.exported<_.total)return"Genesis lettering is underway — export the final images next.";if(_.uploaded<_.total)return"Genesis final images are exported — upload them next, then prepare to publish."}}return null}function gD(e){const{stage:t,imageCount:i,hasNonImageProse:s}=e;if(t==="ready")return{possible:!0,recommended:!0,tone:"ok",headline:"Ready to publish",detail:"Every cut has an uploaded final image.",action:null};if(i===0&&s)return{possible:!1,recommended:!1,tone:"warning",headline:"Not recommended yet — this looks like planning/placeholder text",detail:"There are no images and the page is prose, so it reads as planning notes, not a finished episode.",action:"Prepare episode for publish after final images are uploaded."};switch(t){case"not-started":return{possible:!1,recommended:!1,tone:"info",headline:"Not started",detail:"This episode has no cuts planned yet.",action:"Plan its cuts, then create and upload images."};case"planning":return{possible:!1,recommended:!1,tone:"info",headline:"Not ready yet — prepare for publish",detail:"The cut plan is set, but the publish layout isn't built yet.",action:"Prepare the episode for publish."};case"awaiting-upload":return{possible:!1,recommended:!1,tone:"info",headline:"Waiting on image uploads",detail:"Some cuts still need a final uploaded image.",action:"Upload the remaining final images, then publish."};case"error":return{possible:!1,recommended:!1,tone:"blocker",headline:"Not publishable — needs fixes",detail:"Some cuts have problems that must be fixed before publishing.",action:"Open the technical details below to see what to fix."};default:return{possible:!1,recommended:!1,tone:"info",headline:"Checking readiness…",detail:"",action:null}}}const xD={...ml,attributes:{...ml.attributes,img:["src","alt","title"]}},_D={ok:"border-green-300 bg-green-50 text-green-800",info:"border-accent/30 bg-accent/5 text-foreground",warning:"border-amber-300 bg-amber-50 text-amber-800",blocker:"border-error/30 bg-error/5 text-error"};function bD({content:e,stage:t}){const i=sD(e),s=i.nonImageProse.length>KS,a=gD({stage:t,imageCount:i.imageCount,hasNonImageProse:i.nonImageProse.length>0});return d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"cartoon-publish-preview",children:[d.jsxs("div",{className:"px-4 py-2 border-b border-border text-[10px] text-muted flex flex-wrap items-center gap-x-3 gap-y-1","data-testid":"cartoon-publish-summary",children:[d.jsxs("span",{children:[i.imageCount," image",i.imageCount===1?"":"s"]}),d.jsxs("span",{children:[i.charCount.toLocaleString()," / 10,000 chars"]}),d.jsx("span",{className:`rounded-full px-2 py-0.5 font-medium ${a.possible?"bg-green-100 text-green-800":"bg-background text-muted"}`,"data-testid":"publish-possible",children:a.possible?"Publish possible":"Publish not possible yet"}),d.jsx("span",{className:`rounded-full px-2 py-0.5 font-medium ${a.recommended?"bg-green-100 text-green-800":a.tone==="warning"?"bg-amber-100 text-amber-800":"bg-background text-muted"}`,"data-testid":"publish-recommended",children:a.recommended?"Recommended":"Not recommended yet"})]}),d.jsxs("div",{className:`px-4 py-2 border-b text-[11px] ${_D[a.tone]}`,"data-testid":"cartoon-publish-verdict",children:[d.jsx("p",{className:"font-medium",children:a.headline}),a.detail&&d.jsx("p",{className:"mt-0.5 opacity-90",children:a.detail}),a.action&&d.jsxs("p",{className:"mt-0.5 opacity-90",children:["→ ",a.action]})]}),i.nonImageProse&&d.jsxs("div",{className:"px-4 py-2 border-b border-amber-300 bg-amber-50 text-[11px] text-amber-800","data-testid":"cartoon-nonimage-prose",children:[d.jsx("p",{className:"font-medium",children:"⚠ Non-image text in the published markdown:"}),d.jsxs("p",{className:"font-mono mt-1 whitespace-pre-wrap break-words",children:[i.nonImageProsePreview,s?"…":""]}),d.jsx("p",{className:"mt-1",children:"This text publishes verbatim around the comic images. Remove it (or re-run “Prepare episode for publish”) if it is planning or placeholder prose."})]}),d.jsx("div",{className:"max-w-lg mx-auto px-4 py-6",children:e.trim()?d.jsx("div",{className:"prose max-w-none",children:d.jsx(cS,{remarkPlugins:[hS,LS],rehypePlugins:[[IS,xD]],children:e})}):d.jsx("p",{className:"text-muted italic text-sm","data-testid":"cartoon-publish-empty",children:"No publish markdown yet — build it from the cut plan (Edit → Upload & Prepare for Publish)."})})]})}const vD="modulepreload",yD=function(e){return"/"+e},uy={},hy=function(t,i,s){let a=Promise.resolve();if(i&&i.length>0){let c=function(f){return Promise.all(f.map(_=>Promise.resolve(_).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};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(f=>{if(f=yD(f),f in uy)return;uy[f]=!0;const _=f.endsWith(".css"),g=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const b=document.createElement("link");if(b.rel=_?"stylesheet":vD,_||(b.as="script"),b.crossOrigin="",b.href=f,p&&b.setAttribute("nonce",p),document.head.appendChild(b),_)return new Promise((v,S)=>{b.addEventListener("load",v),b.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}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)})},Cm=[{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:[]}],SD="system-ui, sans-serif",wD=Cm.find(e=>e.family==="Noto Sans"),CD=Cm.find(e=>e.category==="display");function e1(e){return Cm.find(i=>i.category==="body"&&i.languages.includes(e))||wD}function t1(){return CD}function i1(e){const t=e.weights.join(";");return`https://fonts.googleapis.com/css2?family=${e.googleFontsId}:wght@${t}&display=swap`}function Ou(e){return`"${e.family}", ${SD}`}function kD(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 cl(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 ED(e){return!e.exported&&!e.uploaded?!1:e.baselineSig!==cl(e.current)}function km(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 ND(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 dy(e){const t=km(e);return t.map((i,s)=>{const{x:a,y:o}=ND(i.type,s,t.length),c=Lp(i.type,a,o),h=GS(i.type,a,o);return{...c,...h,text:i.text,...i.type==="speech"?{speaker:i.speaker??""}:{}}})}function Mn(e,t){return e*t}function fy(e,t){return t===0?0:e/t}function py(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=i1(e),document.head.appendChild(i)}const Ao={speech:"Speech",narration:"Narration",sfx:"SFX"},jD={speech:"border-foreground/40",narration:"border-muted/40",sfx:"border-accent/40"};function Lf(e){const t=(e.speaker||e.text||"").trim().replace(/\s+/g," ");return t?`“${t.length>18?`${t.slice(0,18)}…`:t}”`:Ao[e.type]}const my=.05,TD=[{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 mu(e,t,i){return Math.min(i,Math.max(t,e))}function AD({storyName:e,cut:t,plotFile:i,onSave:s,onClose:a,onExported:o,language:c="English",authFetch:h,targetLabel:p,returnOnSave:f=!1,workspaceVisible:_=!1,onToggleWorkspaceVisible:g}){var Et,Gt,ut,$t,wt,Cn,Yt,ni;const b=e1(c),v=t1(),S=Ou(b),N=Ou(v);w.useEffect(()=>{py(b),py(v)},[b,v]),w.useEffect(()=>{let U=!1;return Y(!1),(async()=>{try{const{ensureFontsReady:be}=await hy(async()=>{const{ensureFontsReady:Ie}=await import("./export-cut-Cj-cOtan.js");return{ensureFontsReady:Ie}},[]);await be([b.family,v.family])}catch{}U||Y(!0)})(),()=>{U=!0}},[b.family,v.family]);const B=bm(e,t.cleanImagePath,h),E=w.useMemo(()=>Q3(t.overlays),[t.overlays]),z=E.invalid.length,[I,R]=w.useState(!1),H=z===0&&E.changed&&E.overlays.length>0,[D,ie]=w.useState(()=>E.overlays),[ue,ve]=w.useState(()=>cl(E.overlays)),L=w.useRef(null),re=w.useCallback(U=>(be,Ie,Ee=400)=>{var rt;!L.current&&typeof document<"u"&&(L.current=document.createElement("canvas"));const Qe=(rt=L.current)==null?void 0:rt.getContext("2d");return Qe?(Qe.font=`${Ee} ${Ie}px ${U}`,Qe.measureText(be).width):be.length*Ie*.5},[]),[F,Y]=w.useState(!1),[K,$]=w.useState(null),[T,q]=w.useState(!1),[W,ge]=w.useState(!1),[j,A]=w.useState(null),[Z,k]=w.useState(null),[oe,ae]=w.useState(!1),[V,X]=w.useState({x:0,y:0,width:0,height:0}),he=w.useRef(null),_e=w.useRef(null),Ae=w.useRef(null),Oe=w.useCallback(()=>{const U=he.current;if(!U)return;const be=U.clientWidth,Ie=U.clientHeight;let Ee,Qe;if(t.kind==="text"){const ft=VS(t.aspectRatio)??{width:800,height:600};Ee=ft.width,Qe=ft.height}else{const ft=_e.current;if(!ft||!ft.naturalWidth)return;Ee=ft.naturalWidth,Qe=ft.naturalHeight}if(!be||!Ie)return;const rt=Math.min(be/Ee,Ie/Qe),tt=Ee*rt,Dt=Qe*rt;X({x:(be-tt)/2,y:(Ie-Dt)/2,width:tt,height:Dt})},[t.kind,t.aspectRatio]);w.useEffect(()=>{const U=he.current;if(!U)return;const be=new ResizeObserver(()=>Oe());return be.observe(U),()=>be.disconnect()},[Oe]);const He=w.useCallback(U=>{const be=GS(U.type,U.x,U.y),Ie=be.width,Ee=Math.max(.08,1-U.y);if(!U.text||!F||V.width<=0)return be;const Qe=U.type==="sfx"?N:S,rt=Mn(Ie,V.width);let tt=U.type==="sfx"?.08:.12;for(let Dt=0;Dt<24;Dt++){const ft=Math.min(tt,Ee),pt=Mn(ft,V.height);if(!jo(re(Qe),U.text,rt,pt,To({...U},V.height||300,rt,pt)).overflow||ft>=Ee)return{width:Ie,height:ft};tt+=.03}return{width:Ie,height:Math.min(tt,Ee)}},[F,V,re,S,N]),Re=w.useCallback(U=>{const be=Lp(U,.1+Math.random()*.3,.1+Math.random()*.3),Ie={...be,...He(be)};ie(Ee=>[...Ee,Ie]),$(Ie.id)},[He]),et=w.useCallback(U=>{const Ie={...Lp(U.type,.1+Math.random()*.3,.1+Math.random()*.3),text:U.text,...U.type==="speech"&&U.speaker?{speaker:U.speaker}:{}},Ee={...Ie,...He(Ie)};ie(Qe=>[...Qe,Ee]),$(Ee.id)},[He]),Ge=w.useCallback((U,be)=>{ie(Ie=>Ie.map(Ee=>Ee.id===U?{...Ee,...be}:Ee))},[]),ot=w.useCallback(U=>{var tt;const be=V.height||300,Ie=V.width>0?Mn(U.width,V.width):200,Ee=V.height>0?Mn(U.height,V.height):100,Qe=U.type==="sfx"?N:S,rt=jo(re(Qe),U.text,Ie,Ee,To({...U,textStyle:void 0},be,Ie,Ee));Ge(U.id,{textStyle:{mode:"manual",fontScale:rt.fontSize/Math.max(1,be),fontWeight:((tt=U.textStyle)==null?void 0:tt.fontWeight)??400,lineHeightFactor:rt.fontSize>0?rt.lineHeight/rt.fontSize:1.2,speakerScale:rt.fontSize>0&&rt.speakerFontSize>0?rt.speakerFontSize/rt.fontSize:.8}})},[V,N,S,re,Ge]),Pe=w.useCallback(U=>{ie(be=>be.filter(Ie=>Ie.id!==U)),$(null),q(!1)},[]),Be=w.useCallback(()=>{$(null),q(!1)},[]),Ve=w.useCallback((U,be)=>{U.stopPropagation(),$(be),q(!1)},[]),Nt=w.useCallback((U,be,Ie)=>{U.stopPropagation(),U.preventDefault();const Ee=D.find(Qe=>Qe.id===be);Ee&&($(be),Ae.current={id:be,mode:Ie,startX:U.clientX,startY:U.clientY,origX:Ee.x,origY:Ee.y,origW:Ee.width,origH:Ee.height})},[D]);w.useEffect(()=>{const U=Ie=>{const Ee=Ae.current;if(!Ee||V.width===0)return;const Qe=fy(Ie.clientX-Ee.startX,V.width),rt=fy(Ie.clientY-Ee.startY,V.height);if(Ee.mode==="move"){const tt=mu(Ee.origX+Qe,0,1-Ee.origW),Dt=mu(Ee.origY+rt,0,1-Ee.origH);Ge(Ee.id,{x:tt,y:Dt})}else{const tt=mu(Ee.origW+Qe,my,1-Ee.origX),Dt=mu(Ee.origH+rt,my,1-Ee.origY);Ge(Ee.id,{width:tt,height:Dt})}},be=()=>{Ae.current=null};return window.addEventListener("mousemove",U),window.addEventListener("mouseup",be),()=>{window.removeEventListener("mousemove",U),window.removeEventListener("mouseup",be)}},[V,Ge]);const kt=w.useCallback(async()=>{var U;k(null);try{const be=cl(D),Ie=((U=t.aiDraft)==null?void 0:U.status)==="generated"&&be!==(t.aiDraft.baseSig??"")?{...t.aiDraft,status:"edited",updatedAt:new Date().toISOString()}:t.aiDraft??void 0;await s(D,Ie??null),f&&a()}catch(be){k(be instanceof Error?be.message:"Failed to save overlays")}},[D,s,a,f,t.aiDraft]),pi=w.useCallback(async()=>{if(z>0&&!I){const U=z;A(`${U} overlay${U===1?"":"s"} from the cut plan ${U===1?"has":"have"} no usable position and cannot be exported — re-place ${U===1?"it":"them"} or discard ${U===1?"it":"them"} first.`);return}ge(!0),A(null);try{await s(D);const{exportCut:U,ensureFontsReady:be}=await hy(async()=>{const{exportCut:gi,ensureFontsReady:on}=await import("./export-cut-Cj-cOtan.js");return{exportCut:gi,ensureFontsReady:on}},[]),Ie=D.some(gi=>gi.type==="sfx"),Ee=[b.family,...Ie?[v.family]:[]],{ready:Qe,missing:rt}=await be(Ee);if(!Qe){A(`Fonts not loaded: ${rt.join(", ")}. Check your connection and retry.`),ge(!1);return}if(t.cleanImagePath&&!B.url){A(B.error?"Clean image failed to load — cannot export. Retry once it renders.":"Clean image still loading — wait for it to render, then export."),ge(!1);return}const tt=B.url,Dt=await U(tt,D,S,N,{narration:t.narration,dialogue:t.dialogue},t.kind==="text"?{background:t.background,aspectRatio:t.aspectRatio}:void 0),ft=new FormData,pt=Dt.type==="image/webp"?"webp":"jpg";ft.append("file",Dt,`cut-${t.id}.${pt}`);const Di=await h(`/api/stories/${e}/cuts/${i}/export-final/${t.id}`,{method:"POST",body:ft});if(Di.ok)ve(cl(D)),o==null||o();else{const gi=await Di.json();A(gi.error||"Export failed")}}catch(U){A(U instanceof Error?U.message:"Export failed")}finally{ge(!1)}},[t,B,D,e,i,b,v,S,N,h,s,o,z,I]),Me=D.find(U=>U.id===K),St=w.useMemo(()=>eD(D),[D]),ct=w.useRef(t.id);w.useEffect(()=>{ct.current!==t.id&&(ct.current=t.id,ve(cl(E.overlays)))},[t.id,E.overlays]);const ee=ED({exported:!!t.finalImagePath||!!t.exportedAt,uploaded:!!t.uploadedUrl||!!t.uploadedCid,baselineSig:ue,current:D}),xe=w.useMemo(()=>kD({...t,overlays:D},{staleExport:ee}),[t,D,ee]),Te=w.useMemo(()=>km(t),[t]),Ue=w.useMemo(()=>{const U={};for(const be of D){const Ie=Y3(be);let Ee=!1;if(F&&V.width>0&&be.text){const Qe=be.type==="sfx"?N:S,rt=Mn(be.width,V.width),tt=Mn(be.height,V.height);Ee=jo(re(Qe),be.text,rt,tt,To(be,V.height||300,rt,tt)).overflow}(Ie||Ee)&&(U[be.id]={outOfBounds:Ie,overflow:Ee})}return U},[D,F,V,re,S,N]),Ye=Object.keys(Ue).length,Kt=[{key:"clean-image",label:"Clean",done:xe.hasCleanImage},{key:"script-text",label:"Script",done:xe.hasScriptText},{key:"bubbles",label:xe.bubblesPlaced?`Bubbles ${xe.bubblesPlaced}`:"Bubbles",done:xe.bubblesPlaced>0},{key:"exported",label:"Exported",done:xe.exported},{key:"uploaded",label:"Uploaded",done:xe.uploaded}],mi=t.kind==="text",Lt=!t.cleanImagePath;return!mi&&Lt&&D.length===0&&!t.narration&&!((Et=t.dialogue)!=null&&Et.length)?d.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."}):d.jsxs("div",{className:"h-full flex flex-col","data-testid":"focused-lettering-editor",children:[d.jsxs("div",{className:"px-3 py-2 border-b border-border bg-surface/40 flex items-center justify-between gap-2 flex-wrap","data-testid":"lettering-toolbar",children:[d.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[d.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:"Back to cut review"}),d.jsx("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.16em] text-accent",children:"Focused lettering editor"}),d.jsx("span",{className:"text-[11px] font-mono text-muted",children:p??`Cut #${t.id}`}),d.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-[10px] text-muted","data-testid":"overlay-count",children:[D.length," overlays"]}),Kt.map(U=>d.jsxs("span",{"data-testid":`lettering-check-${U.key}`,"data-done":U.done?"true":"false",className:`rounded-full border px-2 py-0.5 text-[10px] ${U.done?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:[U.done?"✓ ":"○ ",U.label]},U.key)),((Gt=t.aiDraft)==null?void 0:Gt.status)==="generated"&&d.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"}),ee&&d.jsx("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-700","data-testid":"lettering-stale-chip",children:"Re-export needed"})]}),d.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap justify-end",children:[g&&d.jsx("button",{onClick:g,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:_?"Hide work area":"Show work area"}),d.jsx("button",{type:"button",onClick:()=>ae(U=>!U),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:oe?"Hide help":"Help"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>Re("speech"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-speech",children:"Speech"}),d.jsx("button",{onClick:()=>Re("narration"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-narration",children:"Narration"}),d.jsx("button",{onClick:()=>Re("sfx"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-sfx",children:"SFX"})]}),j&&d.jsx("span",{className:"text-[10px] text-error max-w-[18rem]",children:j}),Z&&d.jsx("span",{className:"text-[10px] text-error max-w-[18rem]",children:Z}),d.jsx("button",{onClick:pi,disabled:W,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:W?"Exporting...":"Export"}),d.jsx("button",{onClick:()=>{kt()},className:"px-2.5 py-1 text-[11px] bg-accent text-white rounded hover:bg-accent-dim","data-testid":"save-lettering-btn",children:"Save"}),d.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"})]})]}),oe&&d.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."}),z>0&&!I?d.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:[d.jsxs("span",{children:[z," overlay",z===1?"":"s"," ","from the cut plan ",z===1?"has":"have"," no usable position and cannot be exported. Re-place"," ",z===1?"it":"them",", or"]}),d.jsxs("button",{onClick:()=>R(!0),"data-testid":"discard-invalid-overlays",className:"px-1.5 py-0.5 border border-error/40 rounded hover:bg-error/10",children:["discard ",z," unplaceable overlay",z===1?"":"s"]})]}):z>0?d.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 ",z," unplaceable overlay",z===1?"":"s"," — the export will not include"," ",z===1?"it":"them","."]}):H?d.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,St.length>0&&d.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,": ",St.length," bubble"," ",St.length===1?"pair overlaps":"pairs overlap"," and may be hard to read —"," ",St.map(U=>`#${U.indexA+1} ${Lf(D[U.indexA])} ↔ #${U.indexB+1} ${Lf(D[U.indexB])}`).join("; "),". Move them apart, or export as-is if the overlap is intended."]}),ee&&d.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."}),Ye>0&&d.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:[Ye," bubble",Ye===1?"":"s"," may not export cleanly:"," ",Object.entries(Ue).map(([U,be])=>{const Ie=D.findIndex(Qe=>Qe.id===U),Ee=[be.outOfBounds?"outside image":null,be.overflow?"text overflow":null].filter(Boolean).join(", ");return`#${Ie+1} ${Lf(D[Ie])} (${Ee})`}).join("; "),". Resize or reposition before exporting."]}),d.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d.jsxs("div",{ref:he,className:"flex-1 min-w-0 relative overflow-hidden bg-[#f8f5ef]",onClick:Be,"data-testid":"editor-surface",children:[t.cleanImagePath&&B.error?d.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&&!B.url?d.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?d.jsx("img",{ref:_e,src:B.url,alt:`Cut ${t.id} clean`,className:"w-full h-full object-contain",draggable:!1,onLoad:Oe}):mi?V.width>0&&d.jsx("div",{className:"absolute flex items-center justify-center text-muted text-xs",style:{left:V.x,top:V.y,width:V.width,height:V.height,background:t.background||"#ffffff"},"data-testid":"text-panel-canvas",children:"Text panel"}):d.jsx("div",{className:"w-full h-full bg-white flex items-center justify-center text-muted text-xs",ref:U=>{if(U&&V.width===0){const be=U.getBoundingClientRect();be.width>0&&X({x:0,y:0,width:be.width,height:be.height})}},children:"Narration cut"}),V.width>0&&d.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":"balloon-layer",children:D.map(U=>{if(U.type!=="speech")return null;const be=V.x+Mn(U.x,V.width),Ie=V.y+Mn(U.y,V.height),Ee=Mn(U.width,V.width),Qe=Mn(U.height,V.height),rt=FS(U,Ee,Qe),tt=U.tailAnchor?ym(be,Ie,Ee,Qe,U.tailAnchor,rt):null,Dt=Math.max(1.5,V.height*.004),ft=U.id===K;return d.jsx("path",{"data-testid":`balloon-${U.id}`,d:WS(be,Ie,Ee,Qe,tt,rt),className:`fill-white/95 ${ft?"stroke-accent":"stroke-[#1a1a1a]"}`,strokeWidth:ft?Dt+.5:Dt,strokeLinejoin:"round"},U.id)})}),V.width>0&&D.map(U=>{const be=V.x+Mn(U.x,V.width),Ie=V.y+Mn(U.y,V.height),Ee=Mn(U.width,V.width),Qe=Mn(U.height,V.height),rt=U.id===K,tt=U.type==="speech",Dt=U.type==="narration",ft=!!Ue[U.id];return d.jsxs("div",{"data-testid":`overlay-${U.id}`,"data-warning":ft?"true":"false",onClick:pt=>Ve(pt,U.id),onMouseDown:pt=>Nt(pt,U.id,"move"),className:`absolute rounded cursor-move select-none ${tt?"":`border-2 ${jD[U.type]}`} ${Dt?"bg-[#f4efe6]/85 rounded-md":""} ${rt&&!tt?"ring-2 ring-accent":""} ${ft?"ring-2 ring-amber-500":""}`,style:{left:be,top:Ie,width:Ee,height:Qe},children:[(()=>{var on,Ui;const pt=U.type==="sfx"?N:S;if(!U.text)return d.jsx("span",{className:"text-[9px] px-1 text-muted truncate block pointer-events-none",style:{fontFamily:pt},children:Ao[U.type]});const Di=U.type!=="sfx"&&!!U.speaker;if(!F)return d.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 overflow-hidden pointer-events-none text-center break-words",style:{fontFamily:pt,fontSize:Math.max(9,Math.min(Qe*.05,16)),fontWeight:((on=U.textStyle)==null?void 0:on.fontWeight)??400},"data-testid":`overlay-text-${U.id}`,"data-fonts-ready":"false",children:Di?`${U.speaker}: ${U.text}`:U.text});const gi=jo(re(pt),U.text,Ee,Qe,To(U,V.height,Ee,Qe));return d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 overflow-hidden pointer-events-none text-center",style:{fontFamily:pt},"data-testid":`overlay-text-${U.id}`,"data-fonts-ready":"true",children:[Di&&d.jsx("span",{className:"font-bold text-[#3a3a3a] block",style:{fontSize:gi.speakerFontSize,lineHeight:1.2},children:U.speaker}),d.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:gi.fontSize,lineHeight:`${gi.lineHeight}px`,fontWeight:((Ui=U.textStyle)==null?void 0:Ui.fontWeight)??400},children:gi.lines.map((Mi,Xn)=>d.jsx("span",{className:"block",children:Mi},Xn))})]})})(),rt&&d.jsx("div",{onMouseDown:pt=>{pt.stopPropagation(),Nt(pt,U.id,"resize")},className:"absolute bottom-0 right-0 w-2 h-2 bg-accent cursor-se-resize","data-testid":`resize-${U.id}`})]},U.id)})]}),d.jsx("div",{className:"w-64 border-l border-border p-3 overflow-y-auto flex-shrink-0",children:Me?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("p",{className:"text-xs font-medium text-foreground",children:Ao[Me.type]}),d.jsxs("span",{className:"text-[10px] text-muted",children:["#",D.findIndex(U=>U.id===Me.id)+1]})]}),Me.speaker!==void 0&&d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Speaker"}),d.jsx("input",{value:Me.speaker||"",onChange:U=>Ge(Me.id,{speaker:U.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Text"}),d.jsx("textarea",{value:Me.text,onChange:U=>Ge(Me.id,{text:U.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"})]}),d.jsx("button",{onClick:()=>Ge(Me.id,He(Me)),"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"}),d.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-typography",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Typography"}),((ut=Me.textStyle)==null?void 0:ut.mode)==="manual"?d.jsx("button",{type:"button",onClick:()=>Ge(Me.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"}):d.jsx("button",{type:"button",onClick:()=>ot(Me),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"})]}),(($t=Me.textStyle)==null?void 0:$t.mode)==="manual"?d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Font size (% panel height)"}),d.jsx("input",{type:"number",step:"0.1",min:"1.5",max:"12",value:((Me.textStyle.fontScale??.032)*100).toFixed(1),onChange:U=>Ge(Me.id,{textStyle:{...Me.textStyle,mode:"manual",fontScale:Math.max(.015,Math.min(.12,(parseFloat(U.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Weight"}),d.jsxs("select",{value:String(Me.textStyle.fontWeight??400),onChange:U=>Ge(Me.id,{textStyle:{...Me.textStyle,mode:"manual",fontWeight:U.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:[d.jsx("option",{value:"400",children:"Regular"}),d.jsx("option",{value:"700",children:"Bold"})]})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Line height"}),d.jsx("input",{type:"number",step:"0.05",min:"0.9",max:"2",value:(Me.textStyle.lineHeightFactor??1.2).toFixed(2),onChange:U=>Ge(Me.id,{textStyle:{...Me.textStyle,mode:"manual",lineHeightFactor:Math.max(.9,Math.min(2,parseFloat(U.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"})]}),Me.type!=="sfx"&&d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Speaker scale"}),d.jsx("input",{type:"number",step:"0.05",min:"0.5",max:"1.5",value:(Me.textStyle.speakerScale??.8).toFixed(2),onChange:U=>Ge(Me.id,{textStyle:{...Me.textStyle,mode:"manual",speakerScale:Math.max(.5,Math.min(1.5,parseFloat(U.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"})]})]}):d.jsx("p",{className:"text-[10px] text-muted",children:"Auto-fit stays on by default and resizes text to the box."})]}),Me.type==="speech"&&(()=>{const U=Me.tailAnchor||{x:.5,y:1.2};return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Tail anchor"}),d.jsx("div",{className:"flex flex-wrap gap-1","data-testid":"inspector-tail-presets",children:TD.map(be=>d.jsx("button",{type:"button",onClick:()=>Ge(Me.id,{tailAnchor:be.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-${be.key}`,children:be.label},be.key))}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["x",d.jsx("input",{type:"number",step:"0.1",value:U.x,onChange:be=>Ge(Me.id,{tailAnchor:{...U,x:parseFloat(be.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"})]}),d.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["y",d.jsx("input",{type:"number",step:"0.1",value:U.y,onChange:be=>Ge(Me.id,{tailAnchor:{...U,y:parseFloat(be.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"})]})]})]})})(),Me.type!=="sfx"&&d.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-bubble-style",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Bubble controls"}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Padding X (% width)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((wt=Me.bubbleStyle)==null?void 0:wt.paddingX)??.06)*100).toFixed(0),onChange:U=>Ge(Me.id,{bubbleStyle:{...Me.bubbleStyle,paddingX:Math.max(0,Math.min(.25,(parseFloat(U.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Padding Y (% height)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((Cn=Me.bubbleStyle)==null?void 0:Cn.paddingY)??.08)*100).toFixed(0),onChange:U=>Ge(Me.id,{bubbleStyle:{...Me.bubbleStyle,paddingY:Math.max(0,Math.min(.25,(parseFloat(U.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Corner roundness (% short side)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"49",value:((((Yt=Me.bubbleStyle)==null?void 0:Yt.cornerRadius)??.4)*100).toFixed(0),onChange:U=>Ge(Me.id,{bubbleStyle:{...Me.bubbleStyle,cornerRadius:Math.max(0,Math.min(.49,(parseFloat(U.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"})]})]}),d.jsxs("div",{className:"text-[10px] text-muted","data-testid":"inspector-font",children:["Font:"," ",Me.type==="sfx"?v.family:b.family]}),d.jsxs("div",{className:"text-[10px] font-mono text-muted space-y-0.5",children:[d.jsxs("p",{children:["x: ",Me.x.toFixed(3),", y:"," ",Me.y.toFixed(3)]}),d.jsxs("p",{children:["w: ",Me.width.toFixed(3),", h:"," ",Me.height.toFixed(3)]})]}),d.jsx("button",{onClick:()=>{T?Pe(Me.id):q(!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"}),Te.length>0&&d.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3","data-testid":"script-insert-panel",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Add from script"}),d.jsx("div",{className:"flex flex-col gap-1",children:Te.map(U=>d.jsxs("button",{onClick:()=>et(U),"data-testid":`script-insert-${U.key}`,title:`Add ${U.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:[d.jsxs("span",{className:"font-medium text-accent",children:["+ ",Ao[U.type]]})," ",d.jsxs("span",{className:"text-muted",children:[U.speaker?`${U.speaker}: `:"",U.text.length>32?`${U.text.slice(0,32)}…`:U.text]})]},U.key))})]})]}):d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-xs text-muted","data-testid":"inspector-empty",children:"Select or add an overlay to inspect it."}),((ni=t.aiDraft)==null?void 0:ni.status)==="generated"&&d.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."}),Te.length>0&&d.jsxs("div",{className:"space-y-1.5","data-testid":"script-insert-panel",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Add from script"}),d.jsx("div",{className:"flex flex-col gap-1",children:Te.map(U=>d.jsxs("button",{onClick:()=>et(U),"data-testid":`script-insert-${U.key}`,title:`Add ${U.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:[d.jsxs("span",{className:"font-medium text-accent",children:["+ ",Ao[U.type]]})," ",d.jsxs("span",{className:"text-muted",children:[U.speaker?`${U.speaker}: `:"",U.text.length>32?`${U.text.slice(0,32)}…`:U.text]})]},U.key))})]})]})})]})]})}function gy(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=i1(e),document.head.appendChild(i)}function RD({storyName:e,assetPath:t,authFetch:i,alt:s,overlays:a,language:o="English",background:c,aspectRatio:h,className:p,onClick:f,testId:_}){const g=e1(o),b=t1(),v=Ou(g),S=Ou(b),N=bm(e,t,i),B=w.useRef(null),E=w.useMemo(()=>typeof document<"u"?document.createElement("canvas").getContext("2d"):null,[]),[z,I]=w.useState(!1),[R,H]=w.useState(()=>VS(h)??{width:800,height:600}),[D,ie]=w.useState({width:0,height:0});w.useEffect(()=>{gy(g),gy(b)},[g,b]),w.useEffect(()=>{let L=!1;return(async()=>{var re;try{(re=document.fonts)!=null&&re.load&&await Promise.all([document.fonts.load(`16px "${g.family}"`),document.fonts.load(`16px "${b.family}"`)])}catch{}L||I(!0)})(),()=>{L=!0}},[g.family,b.family]),w.useEffect(()=>{const L=B.current;if(!L)return;const re=new ResizeObserver(()=>{ie({width:L.clientWidth,height:L.clientHeight})});return re.observe(L),()=>re.disconnect()},[]);const ue=w.useCallback(L=>(re,F,Y=400)=>E?(E.font=`${Y} ${F}px ${L}`,E.measureText(re).width):re.length*F*.5,[E]),ve=d.jsx("div",{className:p??"w-full rounded border border-border bg-white","data-testid":_,ref:B,style:{aspectRatio:`${R.width} / ${R.height}`,maxHeight:"32rem"},children:d.jsxs("div",{className:"relative w-full h-full overflow-hidden rounded border border-border bg-white",children:[t?N.error||!N.loading&&!N.url?d.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?d.jsx("img",{src:N.url,alt:s,className:"absolute inset-0 w-full h-full object-contain",draggable:!1,onLoad:L=>{const re=L.currentTarget.naturalWidth||R.width,F=L.currentTarget.naturalHeight||R.height;re>0&&F>0&&H({width:re,height:F})}}):d.jsx("div",{className:"w-full h-full flex items-center justify-center text-[10px] text-muted bg-surface/40",children:"Loading image…"}):d.jsx("div",{className:"absolute inset-0",style:{background:c||"#101820"}}),D.width>0&&D.height>0&&a.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":_?`${_}-overlay-layer`:void 0,children:a.map(L=>{if(L.type!=="speech")return null;const re=L.x*D.width,F=L.y*D.height,Y=L.width*D.width,K=L.height*D.height,$=FS(L,Y,K),T=L.tailAnchor?ym(re,F,Y,K,L.tailAnchor,$):null,q=Math.max(1.25,D.height*.004);return d.jsx("path",{"data-testid":_?`${_}-overlay-${L.id}`:void 0,d:WS(re,F,Y,K,T,$),className:"fill-white/95 stroke-[#1a1a1a]",strokeWidth:q,strokeLinejoin:"round"},L.id)})}),a.map(L=>{var W;const re=L.x*D.width,F=L.y*D.height,Y=L.width*D.width,K=L.height*D.height,$=L.type==="sfx"?S:v,T=L.type==="speech";L.type;const q=L.type!=="sfx"&&!!L.speaker;return d.jsx("div",{className:`absolute rounded overflow-hidden ${T?"":"border-2"} ${L.type==="narration"?"border-muted/40 bg-[#f4efe6]/85 rounded-md":L.type==="sfx"?"border-accent/40":""}`,style:{left:re,top:F,width:Y,height:K},children:L.text?z?(()=>{var j;const ge=jo(ue($),L.text,Y,K,To(L,D.height,Y,K));return d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 text-center",style:{fontFamily:$},children:[q&&d.jsx("span",{className:"block font-bold text-[#3a3a3a]",style:{fontSize:ge.speakerFontSize,lineHeight:1.2},children:L.speaker}),d.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:ge.fontSize,lineHeight:`${ge.lineHeight}px`,fontWeight:((j=L.textStyle)==null?void 0:j.fontWeight)??400},children:ge.lines.map((A,Z)=>d.jsx("span",{className:"block",children:A},Z))})]})})():d.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 text-center break-words",style:{fontFamily:$,fontSize:Math.max(8,Math.min(K*.05,14)),fontWeight:((W=L.textStyle)==null?void 0:W.fontWeight)??400},children:q?`${L.speaker}: ${L.text}`:L.text}):d.jsx("span",{className:"block truncate px-1 text-[9px] text-muted",style:{fontFamily:$},children:L.type})},L.id)})]})]})});return f?d.jsx("button",{type:"button",onClick:f,className:"block w-full text-left","data-testid":_?`${_}-open`:void 0,children:ve}):ve}const DD={wide:"Wide",medium:"Medium","close-up":"Close-up","extreme-close-up":"Extreme close-up"},MD="No speech bubbles, captions, sound effects, narration, or any text or lettering in the image.",BD="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 LD(e){var a;const t=DD[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(BD),s.push(MD),s.join(`
|
|
131
|
+
`).trim()}function OD(e,t){return`assets/${e}/cut-${String(t).padStart(2,"0")}-clean.webp`}function xy(e,t){const i=OD(t,e.id);return[`Generate the clean image for cut ${e.id}.`,"","Image description:",LD(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(`
|
|
132
|
+
`)}const n1=12e3,zD=5,PD=6e4,ID=6e4,HD=5;function UD(e,t){return e===429?!0:!!t&&/rate[\s-]?limit/i.test(t)}function $D(e,t=n1){return Math.min(t*2**e,PD)}const r1=e=>new Promise(t=>setTimeout(t,e));async function FD(e,t={}){var c;const i=t.sleep??r1,s=t.maxRetries??zD,a=t.baseDelayMs??n1;let o=0;for(;;){const h=await e();if(h.ok||!UD(h.status,h.errorMessage)||o>=s)return h;const p=$D(o,a);o+=1,(c=t.onWaiting)==null||c.call(t,{attempt:o,maxRetries:s,waitMs:p}),await i(p)}}function qD(e={}){const t=e.limit??HD,i=e.windowMs??ID,s=e.sleep??r1,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 f=o[0]+i-a();f>0&&((p=e.onWaiting)==null||p.call(e,{waitMs:f}),await s(f)),c()}o.push(a())}}const zp=1024*1024;function _y(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 _y(e,"image/webp",s);if(a.type!=="image/webp")break;if(a.size<=zp)return a}catch{break}const i=[.85,.7,.5];for(const s of i){const a=await _y(e,"image/jpeg",s);if(a.size<=zp)return a}throw new Error("Cannot compress image under 1MB — reduce overlay count or image size")}const GD=["image/webp","image/jpeg"];function s1(e){return GD.includes(e.type)&&e.size<=zp}async function YD(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 Ku(e){if(s1(e))return e;const t=await YD(e);return WD(t)}function VD(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 KD(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(VD):[]}async function XD(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 ZD(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 QD(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function JD(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 eM({image:e,authFetch:t}){const i=ZD(`/api/codex/images/${encodeURIComponent(e.token)}`,t);return i?d.jsx("img",{src:i,alt:e.name,className:"w-16 h-16 flex-shrink-0 rounded border border-border object-cover bg-white"}):d.jsx("div",{className:"w-16 h-16 flex-shrink-0 rounded border border-border bg-surface"})}function tM({authFetch:e,cutId:t,onImport:i,onClose:s}){const[a,o]=w.useState(null),[c,h]=w.useState(null),[p,f]=w.useState(null),[_,g]=w.useState("");w.useEffect(()=>{let E=!1;return(async()=>{const z=await KD(e);E||o(z)})(),()=>{E=!0}},[e]);const b=_.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),f(E.token);try{const z=await XD(e,E);await i(z)}catch(z){h(z instanceof Error?z.message:"Could not import the generated image")}finally{f(null)}},B=a!==null&&a.length>0;return d.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-2","data-testid":`codex-picker-${t}`,children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Import a Codex-generated image"}),d.jsx("button",{onClick:s,"data-testid":`codex-picker-close-${t}`,className:"text-[11px] text-muted hover:text-foreground",children:"Close"})]}),B&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"search",value:_,onChange:E=>g(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"}),d.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&&d.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-loading-${t}`,children:"Looking for generated images…"}),a!==null&&a.length===0&&d.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."}),B&&v.length===0&&d.jsxs("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-no-match-${t}`,children:["No generated images match “",_.trim(),"”."]}),B&&v.length>0&&d.jsx("ul",{className:"space-y-1 max-h-72 overflow-y-auto",children:v.map(E=>d.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:[d.jsx(eM,{image:E,authFetch:e}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("p",{className:"text-[11px] text-foreground",children:[JD(E.mtimeMs,S)," · ",QD(E.size)]}),d.jsx("p",{className:"truncate text-[10px] font-mono text-muted",title:E.name,children:E.name})]}),d.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&&d.jsx("p",{className:"text-[11px] text-error",children:c})]})}function Em(e){var g;const{checklist:t,markdownReady:i=!1,published:s=!1}=e;if(!t||t.steps.length===0)return null;const a=((g=t.steps.find(b=>b.key==="upload"))==null?void 0:g.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}],f=p.find(b=>b.status==="current")??p.find(b=>b.status==="todo")??p[p.length-1]??null,_=p.filter(b=>b.status==="done").length;return{steps:p,activeStep:f,statusLabel:(f==null?void 0:f.label)??null,completedCount:_,totalCount:p.length,outstandingCount:p.filter(b=>b.status!=="done").length}}const iM={done:"✓",current:"▸",todo:"○"};function a1({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:f="cartoon-production-step",issuesTestId:_,issueGroupTestIdPrefix:g,detailsLabel:b,summaryTestId:v}){var R;const S=Em({checklist:e,markdownReady:t,published:i});if(!S)return null;const N=QS(s),B=N.reduce((H,D)=>H+D.lines.length,0),E=S.statusLabel??"Review cuts",z=`${S.completedCount} / ${S.totalCount} steps done`,I=b??(S.outstandingCount===0?"Production details":`${S.outstandingCount} step${S.outstandingCount===1?"":"s"} left`);return d.jsxs("div",{className:"rounded-lg border border-border bg-background/80 px-3 py-2","data-testid":h,children:[d.jsxs("div",{className:"flex flex-wrap items-start gap-2 justify-between",children:[d.jsxs("div",{className:"min-w-0 space-y-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px]",children:[d.jsx("span",{className:"font-medium text-foreground",children:a}),d.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]}),d.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted",children:z}),((R=S.activeStep)==null?void 0:R.detail)&&d.jsx("span",{className:"text-muted",children:S.activeStep.detail})]}),o?d.jsx("div",{className:"text-[10px] text-muted",children:o}):null]}),c?d.jsx("div",{className:"flex-shrink-0",children:c}):null]}),d.jsxs("details",{className:"mt-2","data-testid":p,children:[d.jsxs("summary",{className:"cursor-pointer select-none text-[10px] text-muted hover:text-foreground",children:[I,B>0?` · ${B} blocker${B===1?"":"s"}`:""]}),d.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[d.jsx("ol",{className:"flex flex-wrap gap-1.5",children:S.steps.map(H=>d.jsxs("li",{"data-testid":`${f}-${H.key}`,"data-status":H.status,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${H.status==="current"?"border-accent/40 bg-accent/10 text-accent":H.status==="done"?"border-border bg-background/70 text-foreground":"border-border/70 bg-background/40 text-muted"}`,children:[d.jsx("span",{"aria-hidden":!0,children:iM[H.status]}),d.jsx("span",{children:H.label}),H.detail&&d.jsxs("span",{className:"text-muted",children:["· ",H.detail]})]},H.key))}),N.length>0&&d.jsx("div",{className:"space-y-1.5","data-testid":_??`${f}-issues`,children:N.map(H=>d.jsxs("div",{"data-testid":`${g??`${f}-issue-group`}-${H.key}`,className:"text-[10px]",children:[d.jsx("p",{className:"font-medium text-amber-700",children:H.title}),d.jsx("ul",{className:"ml-3 list-disc text-muted",children:H.lines.map((D,ie)=>d.jsx("li",{children:D},ie))})]},H.key))})]})]})]})}function nM({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 d.jsx(a1,{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:d.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 l1(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 Lo(e){return(!!e.cleanImagePath||vn(e))&&km(e).length>0}function by(e){const t=new Date().toISOString();return{status:"generated",baseSig:cl(e),generatedAt:t,updatedAt:t}}function o1(e){return e.uploadedCid?"uploaded":e.finalImagePath||e.exportedAt?"lettered":e.cleanImagePath?"clean":vn(e)?"text":"missing"}const vy={muted:"text-muted",amber:"text-amber-700",green:"text-green-700",accent:"text-accent"},rM={muted:"bg-muted/40",amber:"bg-amber-500",green:"bg-green-600",accent:"bg-accent"};function sM(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 aM(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"}:Lo(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 lM({cut:e,storyName:t,plotFile:i,language:s,expanded:a,onToggle:o,authFetch:c,onUpdated:h,onOpenEditor:p,detectedLocalClean:f,onSyncClean:_,syncing:g,onAiDraft:b,aiDrafting:v,staleMessages:S,onRepairStale:N,repairing:B,conversionPng:E,onConvert:z,converting:I,rowRef:R,featured:H=!1}){var Ge,ot;const D=w.useRef(null),[ie,ue]=w.useState(!1),[ve,L]=w.useState(null),[re,F]=w.useState(!1),[Y,K]=w.useState(!1),[$,T]=w.useState(!1),[q,W]=w.useState(!1),ge=o1(e),j=S.length>0,A=!!E,Z=w.useCallback(async()=>{E&&(W(!0),await z(e.id,E),W(!1),h())},[E,z,e.id,h]),k=w.useCallback(async Pe=>{ue(!0),L(null);try{let Be=Pe;if(!s1(Pe))try{Be=await Ku(Pe)}catch(pi){return L(pi instanceof Error?pi.message:"Could not import image"),!1}const Ve=Be.type==="image/jpeg"?"jpg":"webp",Nt=new FormData;Nt.append("file",new File([Be],`clean.${Ve}`,{type:Be.type}));const kt=await c(`/api/stories/${t}/cuts/${i}/upload-clean/${e.id}`,{method:"POST",body:Nt});if(!kt.ok){const pi=await kt.json();return L(pi.error||"Upload failed"),!1}return h(),!0}catch{return L("Upload failed"),!1}finally{ue(!1)}},[c,t,i,e.id,h]),oe=sM(e,A,j),ae=e.cleanImagePath??E??null,V=((Ge=e.overlays)==null?void 0:Ge.length)??0,X=!vn(e)&&!!e.cleanImagePath&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&!j&&!A,he=!j&&!A&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&Lo(e),_e=(((ot=e.overlays)==null?void 0:ot.length)??0)>0?"Re-draft bubbles with AI":"AI draft bubbles",Ae=oe.key==="convert"?{label:q?"Converting…":"Convert image",onClick:Z,testid:`card-convert-${e.id}`}:oe.key==="review"?{label:"Review cut",onClick:p,testid:`card-review-${e.id}`}:oe.key==="text"?{label:"Add captions",onClick:p,testid:`card-letter-${e.id}`}:oe.key==="needs-image"?{label:"Add artwork",onClick:o,testid:`card-addart-${e.id}`}:null,Oe=aM(e),He=!!e.cleanImagePath||!!e.narration||e.dialogue.length>0||vn(e),Re=H?"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]",et=d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X?d.jsxs(d.Fragment,{children:[d.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:V>0?"Review lettering":"Open focused editor"}),he&&d.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…":_e})]}):Ae?d.jsx("button",{onClick:Ae.onClick,disabled:oe.key==="convert"&&(q||I),"data-testid":Ae.testid,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim disabled:opacity-50",children:Ae.label}):null,!X&&!Ae&&he&&d.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…":_e}),d.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 d.jsxs("div",{ref:R,"data-cut-row":e.id,className:`border rounded ${a?"border-accent/30":"border-border"}`,children:[d.jsxs("div",{className:"px-3 py-2 space-y-2","data-testid":`cut-card-${e.id}`,children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${rM[oe.tone]}`}),d.jsxs("span",{className:"font-medium text-xs text-foreground",children:["Cut ",String(e.id).padStart(2,"0")]}),d.jsxs("span",{className:"font-mono text-[10px] text-muted",children:["· ",e.shotType]}),d.jsx("span",{className:`ml-auto text-[10px] font-medium flex-shrink-0 ${vy[oe.tone]}`,"data-testid":`cut-card-status-${e.id}`,children:oe.label})]}),et,ae||vn(e)?d.jsx(RD,{storyName:t,assetPath:ae,authFetch:c,alt:`Cut ${e.id} artwork`,overlays:e.overlays,language:s,background:e.background,aspectRatio:e.aspectRatio,onClick:He?p:void 0,className:Re,testId:`cut-preview-${e.id}`}):d.jsx("div",{className:`${H?"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"}),d.jsxs("div",{className:`rounded border border-border/70 bg-surface/50 px-2 py-1.5 text-[11px] ${vy[Oe.tone]}`,"data-testid":`lettering-review-state-${e.id}`,children:[d.jsx("span",{className:"font-semibold",children:Oe.label}),d.jsxs("span",{className:"text-muted",children:[" · ",Oe.detail]})]}),d.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&&d.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border",children:[A&&d.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:[d.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."}),d.jsx("button",{onClick:Z,disabled:q||I,"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"})]}),j&&!A&&d.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((Pe,Be)=>d.jsx("p",{className:"text-[11px] text-error",children:Pe},Be)),d.jsx("button",{onClick:N,disabled:B,"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:B?"Repairing…":"Clear stale path"})]}),!vn(e)&&d.jsxs("div",{className:"mt-2 space-y-2",children:[d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(xy(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:re?"Copied!":"Copy Codex task"}),d.jsx("input",{ref:D,type:"file",accept:"image/webp,image/jpeg,image/png",className:"hidden",onChange:Pe=>{var Ve;const Be=(Ve=Pe.target.files)==null?void 0:Ve[0];Be&&k(Be),Pe.target.value=""}}),d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsx("button",{onClick:()=>{var Pe;return(Pe=D.current)==null?void 0:Pe.click()},disabled:ie,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:ie?"Uploading...":e.cleanImagePath?"Replace clean image":"Upload clean image"}),d.jsx("button",{onClick:()=>T(Pe=>!Pe),disabled:ie,"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:$?"Hide Codex images":"Import from Codex"})]}),$&&d.jsx(tM,{authFetch:c,cutId:e.id,onImport:async Pe=>{await k(Pe)&&T(!1)},onClose:()=>T(!1)}),!e.cleanImagePath&&d.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."}),ge==="missing"&&d.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-1","data-testid":`ask-codex-${e.id}`,children:[d.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Generate this cut in Codex"}),d.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"," ",d.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”."]}),d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(xy(e,i)),K(!0),setTimeout(()=>K(!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:Y?"Copied!":"Copy Codex task"})]}),ge==="missing"&&f&&d.jsx("button",{onClick:_,disabled:g,"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:g?"Syncing...":"Found local clean image — sync to cut plan"}),ve&&d.jsx("p",{className:"text-xs text-error mt-1",children:ve})]}),(e.cleanImagePath||e.narration||e.dialogue.length>0||vn(e))&&d.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&&d.jsxs("p",{className:"text-xs text-muted",children:["Characters: ",e.characters.join(", ")]}),e.dialogue.length>0&&d.jsx("div",{className:"text-xs text-muted",children:e.dialogue.map((Pe,Be)=>d.jsxs("p",{children:[d.jsxs("span",{className:"font-medium",children:[Pe.speaker,":"]})," ",Pe.text]},Be))}),e.narration&&d.jsx("p",{className:"text-xs text-muted italic",children:e.narration})]})]})}function yy({storyName:e,fileName:t,authFetch:i,language:s,uploadRetry:a,onCutsChanged:o,focusRequest:c,onFocusHandled:h,onFocusedLetteringModeChange:p,workspaceVisible:f=!1,onWorkspaceVisibleChange:_}){var Xt,At,ri;const[g,b]=w.useState(null),v=w.useRef(o);v.current=o;const S=w.useRef(h);S.current=h;const[N,B]=w.useState(!0),[E,z]=w.useState(null),[I,R]=w.useState(null),[H,D]=w.useState(null),[ie,ue]=w.useState(!1),[ve,L]=w.useState([]),[re,F]=w.useState(!1),[Y,K]=w.useState(""),[$,T]=w.useState({markdownReady:!1,published:!1}),[q,W]=w.useState(!1),[ge,j]=w.useState(!1),[A,Z]=w.useState(!1),[k,oe]=w.useState(null),[ae,V]=w.useState(null),[X,he]=w.useState(null),[_e,Ae]=w.useState(!1),[Oe,He]=w.useState(new Set),[Re,et]=w.useState(new Map),[Ge,ot]=w.useState(!1),[Pe,Be]=w.useState(null),[Ve,Nt]=w.useState(!1),[kt,pi]=w.useState(null),Me=w.useRef(new Map),St=w.useRef(null),ct=t.replace(/\.md$/,"");w.useEffect(()=>{var M;c&&St.current!==c.seq&&(St.current=c.seq,c.openEditor?D(c.cutId):(R(c.cutId),pi(c.cutId)),(M=S.current)==null||M.call(S))},[c]),w.useEffect(()=>(p==null||p(H!==null),()=>p==null?void 0:p(!1)),[H,p]),w.useEffect(()=>{var ne;if(kt==null)return;const M=Me.current.get(kt);M&&((ne=M.scrollIntoView)==null||ne.call(M,{behavior:"smooth",block:"center"}),pi(null))},[kt,g]);const ee=w.useCallback(async()=>{var M;try{const ne=await i(`/api/stories/${e}/cuts/${ct}`);if(ne.status===404){b(null);return}if(!ne.ok){const De=await ne.json();z(De.error||"Failed to load cuts");return}const me=await ne.json();b(me),z(null);try{const De=await i(`/api/stories/${e}/${t}`);if(De.ok){const Se=await De.json(),Ne=typeof(Se==null?void 0:Se.content)=="string"?Se.content:"",We=Array.isArray(me==null?void 0:me.cuts)?me.cuts:[],Ke=Ne.length>0&&XS(Ne,We).ready,vt=(Se==null?void 0:Se.status)==="published"||(Se==null?void 0:Se.status)==="published-not-indexed";T({markdownReady:Ke,published:vt})}else T({markdownReady:!1,published:!1})}catch{T({markdownReady:!1,published:!1})}(M=v.current)==null||M.call(v)}catch{z("Failed to load cuts")}finally{B(!1)}},[i,e,ct,t]),xe=w.useCallback(async M=>!!(await i(`/api/stories/${e}/cuts/${ct}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).ok,[i,e,ct]),Te=w.useCallback(async()=>{ot(!1);try{const M=await i(`/api/stories/${e}/cuts/${ct}/detect-clean-images`);if(!M.ok)return;const ne=await M.json();He(new Set(Array.isArray(ne.detected)?ne.detected:[]));const me=new Map,De=ne.stale;if(Array.isArray(De))for(const Se of De){if(typeof(Se==null?void 0:Se.cutId)!="number"||typeof(Se==null?void 0:Se.message)!="string")continue;const Ne=me.get(Se.cutId)??[];Ne.push(Se.message),me.set(Se.cutId,Ne)}et(me),ot(!0)}catch{}},[i,e,ct]),Ue=w.useCallback(async()=>{Be(null);try{const M=await i(`/api/stories/${e}/cuts/${ct}/asset-diagnostics`);if(!M.ok)return;const ne=await M.json();Be(Array.isArray(ne.diagnostics)?ne.diagnostics:null)}catch{}},[i,e,ct]),Ye=w.useCallback(async()=>{Nt(!0);try{await Promise.all([ee(),Te(),Ue()])}finally{Nt(!1)}},[ee,Te,Ue]),Kt=w.useCallback(async(M,ne={})=>{var Se;if(!g)return!1;const me=g.cuts.find(Ne=>Ne.id===M);if(!me||!Lo(me)||(((Se=me.overlays)==null?void 0:Se.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 De=dy(me);if(De.length===0)return V(`Cut ${me.id}: no script lines available to draft.`),!1;he(M),V(null);try{const Ne={...g,cuts:g.cuts.map(Ke=>Ke.id===M?{...Ke,overlays:De,aiDraft:by(De)}:Ke)};return await xe(Ne)?(V(`Cut ${me.id}: AI draft ready`),await ee(),ne.openEditor&&D(M),!0):(V(`Cut ${me.id}: AI draft failed`),!1)}finally{he(null)}},[g,xe,ee]),mi=w.useCallback(async()=>{if(!g)return;const M=g.cuts.filter(ne=>{var me;return Lo(ne)&&(((me=ne.overlays)==null?void 0:me.length)??0)===0&&!ne.finalImagePath&&!ne.uploadedCid&&!ne.uploadedUrl});if(M.length===0){V("No unlettered cuts need an AI draft");return}Ae(!0),V(null);try{const ne={...g,cuts:g.cuts.map(De=>{if(!M.some(Ne=>Ne.id===De.id))return De;const Se=dy(De);return Se.length>0?{...De,overlays:Se,aiDraft:by(Se)}:De})};if(!await xe(ne)){V("AI draft failed");return}V(`AI draft ready for ${M.length} cut${M.length===1?"":"s"}`),await ee()}finally{Ae(!1)}},[g,xe,ee]),Lt=w.useCallback(async()=>{W(!0),V(null),L([]);try{const M=await i(`/api/stories/${e}/cuts/${ct}/sync-clean-images`,{method:"POST"}),ne=await M.json().catch(()=>({}));if(!M.ok)V(ne.error||"Sync failed");else{const me=Array.isArray(ne.synced)?ne.synced.length:0,De=Array.isArray(ne.cleared)?ne.cleared.length:0,Se=Array.isArray(ne.rejected)?ne.rejected:[];Se.length>0&&L(Se.map(We=>`Cut ${We.cutId}: ${We.reason}`));const Ne=[];me>0&&Ne.push(`Synced ${me}`),De>0&&Ne.push(`Cleared ${De} stale path${De===1?"":"s"}`),V(Ne.length>0?Ne.join(", "):"No new clean images"),await ee(),await Te(),await Ue()}}catch{V("Sync failed")}W(!1)},[i,e,ct,ee,Te,Ue]),Et=w.useCallback(async(M,ne)=>{try{const me=await i(US(e,ne));if(!me.ok)return!1;const De=await me.blob(),Se=await Ku(new File([De],"clean.png",{type:De.type||"image/png"})),Ne=Se.type==="image/jpeg"?"jpg":"webp",We=new FormData;return We.append("file",new File([Se],`clean.${Ne}`,{type:Se.type})),(await i(`/api/stories/${e}/cuts/${ct}/upload-clean/${M}`,{method:"POST",body:We})).ok}catch{return!1}},[i,e,ct]),Gt=w.useCallback(async M=>{Z(!0),oe(null);let ne=0;const me=[];for(const De of M)await Et(De.cutId,De.pngPath)?ne++:me.push(De.cutId);await Ye(),Z(!1),oe(me.length===0?`Converted ${ne} image${ne===1?"":"s"} to WebP`:`Converted ${ne}; ${me.length} failed (Cut ${me.join(", ")}) — try Convert image on each`)},[Et,Ye]),ut=w.useCallback(async()=>{var Se;if(!g)return;F(!0),K(""),L([]);const M=g.cuts.filter(Ne=>Ne.finalImagePath&&!Ne.uploadedCid),ne=[],me=qD({sleep:a==null?void 0:a.sleep,onWaiting:({waitMs:Ne})=>K(`Upload limit reached — waiting ${Math.round(Ne/1e3)}s before continuing…`)});for(let Ne=0;Ne<M.length;Ne++){const We=M[Ne];K(`Uploading cut ${We.id} (${Ne+1}/${M.length})...`);try{const Ke=We.finalImagePath.startsWith("assets/")?We.finalImagePath.slice(7):We.finalImagePath,vt=await i(`/api/stories/${e}/asset/${Ke}`);if(!vt.ok){ne.push(`Cut ${We.id}: failed to fetch asset`);continue}const it=await vt.blob(),Ze=new FormData;Ze.append("file",it,`cut-${We.id}.${it.type==="image/webp"?"webp":"jpg"}`),await me();const Ot=await FD(async()=>{const si=await i("/api/publish/upload-plot-image",{method:"POST",body:Ze});if(si.ok){const{cid:On,url:Lr}=await si.json();return{ok:!0,status:si.status,cid:On,url:Lr}}const cn=await si.json().catch(()=>({}));return{ok:!1,status:si.status,errorMessage:cn.error}},{...a,onWaiting:({attempt:si,maxRetries:cn,waitMs:On})=>K(`Cut ${We.id} rate-limited — waiting ${Math.round(On/1e3)}s before retry ${si}/${cn}...`)});if(!Ot.ok){ne.push(`Cut ${We.id}: upload failed — ${Ot.errorMessage||"unknown"}`);continue}const{cid:yi,url:mn}=Ot;(await i(`/api/stories/${e}/cuts/${ct}/set-uploaded/${We.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cid:yi,url:mn})})).ok||ne.push(`Cut ${We.id}: failed to record upload`)}catch(Ke){ne.push(`Cut ${We.id}: ${Ke instanceof Error?Ke.message:"failed"}`)}}if(ne.length>0){L(ne),F(!1),K(""),ee();return}K("Preparing episode for publishing…");const De=await i(`/api/stories/${e}/cuts/${ct}/generate-markdown`,{method:"POST"});if(De.ok){const Ne=await De.json();((Se=Ne.warnings)==null?void 0:Se.length)>0&&L(Ne.warnings)}F(!1),K(""),ee()},[g,i,e,ct,a,ee]),$t=w.useCallback(async()=>{j(!0),V(null);try{const M=await i(`/api/stories/${e}/cuts/${ct}/repair-asset-paths`,{method:"POST"}),ne=await M.json().catch(()=>({}));if(!M.ok)V(ne.error||"Repair failed");else{const me=Array.isArray(ne.cleared)?ne.cleared.length:0;V(me>0?`Cleared ${me} stale path${me===1?"":"s"}`:"No stale paths to clear"),await ee(),await Te()}}catch{V("Repair failed")}j(!1)},[i,e,ct,ee,Te]),[wt,Cn]=w.useState(!1),Yt=w.useCallback(async(M,ne=!0)=>{if(g){Cn(!0);try{const me=g.cuts.reduce((Ke,vt)=>Math.max(Ke,vt.id),0)+1,De={id:me,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"},Se=[...g.cuts];Se.splice(Math.max(0,Math.min(M,Se.length)),0,De);const Ne={...g,cuts:Se},We=await i(`/api/stories/${e}/cuts/${ct}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ne)});if(We.ok)ne?D(me):R(me),await ee();else{const Ke=await We.json().catch(()=>({}));V(Ke.error||"Could not add text panel")}}catch{V("Could not add text panel")}Cn(!1)}},[g,i,e,ct,ee]),ni=w.useCallback(()=>Yt((g==null?void 0:g.cuts.length)??0,!0),[Yt,g]);if(w.useEffect(()=>{ee(),Te(),Ue()},[ee,Te,Ue]),N)return d.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading cuts..."});if(E)return d.jsxs("div",{className:"p-4 space-y-2","data-testid":"cuts-error",children:[d.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),d.jsx("p",{className:"text-xs text-error",children:E}),d.jsxs("p",{className:"text-xs text-muted",children:[ct,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema from the cartoon writing instructions."]}),d.jsx("button",{onClick:ee,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]});if(!g||g.cuts.length===0)return d.jsxs("div",{className:"p-4 text-center space-y-1",children:[d.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),d.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]});const U=H!==null?g.cuts.find(M=>M.id===H):null;if(U)return d.jsx(AD,{storyName:e,cut:U,plotFile:ct,language:s,authFetch:i,targetLabel:vn(U)?`Between-scene card ${U.id}`:`Cut ${String(U.id).padStart(2,"0")}`,returnOnSave:!0,workspaceVisible:f,onToggleWorkspaceVisible:_?()=>_(!f):void 0,onSave:async(M,ne)=>{const me={...g,cuts:g.cuts.map(Se=>Se.id===H?{...Se,overlays:M,aiDraft:ne??Se.aiDraft??null}:Se)};if(!await xe(me))throw new Error("Failed to save overlays")},onExported:()=>ee(),onClose:()=>{D(null),ee()}});const be=g.cuts.reduce((M,ne)=>{const me=o1(ne);return M[me]++,M},{missing:0,clean:0,lettered:0,uploaded:0,text:0}),Ie=g.cuts.filter(M=>!vn(M)).length,Ee=g.cuts.filter(M=>YS(M)).map(M=>M.id),Qe=JS({cuts:g.cuts,published:$.published}),rt=((Xt=Qe.steps.find(M=>M.key==="upload"))==null?void 0:Xt.status)==="done",tt=g.cuts.some(M=>M.finalImagePath&&!M.uploadedCid)||rt&&!$.markdownReady,Dt=cM(Qe,$.markdownReady,$.published),ft=(Pe??[]).filter(M=>M.state==="needs-conversion"&&M.convertiblePng).map(M=>({cutId:M.cutId,pngPath:M.convertiblePng})),pt=new Map(ft.map(M=>[M.cutId,M.pngPath])),Di=(Pe??[]).filter(M=>M.state==="needs-conversion"&&M.issue).map(M=>M.issue),gi=t==="genesis.md"?"Genesis / Episode 1":`Episode ${parseInt(((At=ct.match(/\d+/))==null?void 0:At[0])??"0",10)+1}`,on=typeof g.title=="string"?g.title:null,Ui=g.cuts.filter(M=>!vn(M)),Mi={cuts:g.cuts.length,artwork:Ui.filter(M=>M.cleanImagePath||pt.has(M.id)).length,converted:Ui.filter(M=>M.cleanImagePath&&/\.(webp|jpe?g)$/i.test(M.cleanImagePath)).length,lettered:g.cuts.filter(M=>{var ne;return(((ne=M.overlays)==null?void 0:ne.length)??0)>0||!!M.finalImagePath}).length,uploaded:g.cuts.filter(M=>M.uploadedCid||M.uploadedUrl).length},Xn=g.cuts.filter(M=>{var ne;return Lo(M)&&(((ne=M.overlays)==null?void 0:ne.length)??0)===0&&!M.finalImagePath&&!M.uploadedCid&&!M.uploadedUrl}).length,xi=oM(Pe);return d.jsxs("div",{className:"h-full min-h-[22rem] flex flex-col overflow-hidden","data-testid":"cut-list-panel",children:[d.jsx("div",{className:"px-3 py-2 border-b border-border flex-shrink-0","data-testid":"cut-board-header",children:d.jsxs("div",{className:"flex items-start gap-3 justify-between",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"font-serif text-foreground truncate",children:gi}),on&&d.jsxs("span",{className:"text-muted truncate",children:["· ",on]})]}),d.jsxs("div",{className:"mt-0.5 text-[10px] text-muted","data-testid":"cut-board-summary",children:[Mi.cuts," cuts · ",Mi.artwork," artwork found ·"," ",Mi.converted," converted · ",Mi.lettered," ","lettered · ",Mi.uploaded," uploaded"]})]}),Xn>0&&d.jsx("button",{onClick:mi,disabled:_e,"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:_e?"Drafting…":`AI draft all unlettered (${Xn})`})]})}),d.jsxs("details",{className:"border-b border-border bg-surface/35 flex-shrink-0","data-testid":"cut-workspace-tools",children:[d.jsx("summary",{className:"list-none cursor-pointer px-3 py-2 hover:bg-surface/50",children:d.jsxs("div",{className:"flex items-start gap-3 justify-between",children:[d.jsxs("div",{className:"min-w-0 space-y-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px]",children:[d.jsxs("span",{className:"rounded-full border border-accent/30 bg-background px-2 py-0.5 font-medium text-accent",children:["Workflow: ",Dt]}),xi&&d.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted","data-testid":"workspace-asset-summary",children:["Assets: ",xi]}),ft.length>0&&d.jsxs("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-amber-700",children:["Convert ",ft.length," PNG",ft.length===1?"":"s"]})]}),d.jsx("p",{className:"text-[10px] text-muted",children:"Per-cut actions stay on each card. Open workspace tools for publish prep, asset recovery, narration cards, and blocked-step details."})]}),d.jsx("span",{className:"flex-shrink-0 rounded border border-border bg-background px-2 py-1 text-[10px] text-muted",children:"Workspace tools"})]})}),d.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-3",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px]",children:[d.jsxs("span",{className:"font-mono text-muted",children:[g.cuts.length," cuts"]}),be.missing>0&&d.jsxs("span",{className:"text-muted",children:[be.missing," missing"]}),be.clean>0&&d.jsxs("span",{className:"text-green-700",children:[be.clean," clean"]}),be.lettered>0&&d.jsxs("span",{className:"text-amber-700",children:[be.lettered," lettered"]}),be.uploaded>0&&d.jsxs("span",{className:"text-green-700",children:[be.uploaded," uploaded"]}),be.text>0&&d.jsxs("span",{className:"text-accent",children:[be.text," text ",be.text===1?"panel":"panels"]}),d.jsx("button",{onClick:async()=>{ue(!0),L([]);try{const M=await i(`/api/stories/${e}/cuts/${ct}/generate-markdown`,{method:"POST"});if(M.ok){const ne=await M.json();L(ne.warnings||[])}}catch{}ue(!1)},disabled:ie,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:ie?"Preparing…":"Prepare episode for publish"}),d.jsx("button",{onClick:ni,disabled:wt,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:wt?"Adding…":"Add narration/text panel"}),d.jsx("button",{onClick:Ye,disabled:Ve,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:Ve?"Checking…":"Refresh assets"}),d.jsx("button",{onClick:Lt,disabled:q,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:q?"Syncing...":"Sync clean images"}),d.jsx("button",{onClick:ut,disabled:re||!(g!=null&&g.cuts.some(M=>M.finalImagePath&&!M.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:Y||"Upload & Prepare for Publish"})]}),d.jsxs("div",{className:"mt-1 text-[10px] text-muted",children:["Use ",d.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."]}),ft.length>0&&d.jsxs("div",{className:"rounded border border-amber-500/40 bg-amber-500/10 p-2 text-[11px]","data-testid":"convert-artwork",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-medium text-amber-700","data-testid":"convert-artwork-count",children:[ft.length," PNG image",ft.length===1?"":"s"," found"]}),d.jsx("button",{onClick:()=>Gt(ft),disabled:A,"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:A?"Converting…":"Convert all to WebP"})]}),d.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."}),k&&d.jsx("p",{className:"mt-1 text-[10px] text-muted","data-testid":"convert-result",children:k}),Di.length>0&&d.jsxs("details",{className:"mt-1","data-testid":"convert-technical-details",children:[d.jsx("summary",{className:"text-[10px] text-muted cursor-pointer",children:"Conversion notes"}),d.jsx("ul",{className:"mt-1 ml-3 list-disc text-[10px] text-muted",children:Di.map((M,ne)=>d.jsx("li",{children:M},ne))})]})]}),Pe&&Pe.length>0&&(()=>{const M=l1(Pe),ne=Pe.filter(me=>me.state==="missing");return d.jsxs("div",{className:"rounded border border-border bg-background p-2 text-[10px]","data-testid":"asset-diagnostics",children:[d.jsxs("span",{className:"text-muted","data-testid":"asset-diag-summary",children:["Assets: ",M.uploaded," uploaded · ",M.finalReady," final ·"," ",M.cleanReady," clean · ",M.planned," planned",M.needsConversion>0?` · ${M.needsConversion} needs conversion`:"",M.missing>0?` · ${M.missing} missing`:""]}),ne.length>0&&d.jsx("ul",{className:"mt-1 ml-3 list-disc text-error","data-testid":"asset-diag-issues",children:ne.map(me=>d.jsx("li",{children:me.issue},me.cutId))})]})})(),d.jsx(nM,{checklist:Qe,issues:ve,onFinish:ut,finishing:re,progressText:Y,canFinish:tt,markdownReady:$.markdownReady,published:$.published})]})]}),Ee.length>0&&d.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:[Ee.length===1?"Cut":"Cuts"," ",Ee.join(", ")," ",Ee.length===1?"was":"were"," lettered with an older speech-bubble style whose tail can show a visible seam. Re-export"," ",Ee.length===1?"it":"them"," (open lettering → Export) and re-upload before publishing so the bubble tails are seamless."]}),Ge&&Ie>0&&be.missing===0&&Re.size===0&&d.jsxs("div",{className:"px-3 py-1 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:[d.jsx("span",{"aria-hidden":!0,children:"✓"}),d.jsxs("span",{children:["All ",Ie," clean image",Ie===1?"":"s"," ","present — clean-asset generation is complete. Ready for lettering in OWS."]})]}),ae&&d.jsx("div",{className:"px-3 py-1 border-b border-border text-[10px] text-muted flex-shrink-0","data-testid":"sync-result",children:ae}),d.jsxs("div",{className:"flex-1 min-h-56 overflow-y-auto p-3 space-y-3","data-testid":"lettering-review-board",children:[g.cuts.map((M,ne)=>{var me;return d.jsxs(w.Fragment,{children:[d.jsx(Sy,{index:ne,beforeLabel:ne===0?"Episode opening":`After cut ${(me=g.cuts[ne-1])==null?void 0:me.id}`,afterLabel:`Before cut ${M.id}`,disabled:wt,onAdd:()=>Yt(ne)}),d.jsx(lM,{cut:M,storyName:e,plotFile:ct,language:s,expanded:I===M.id,onToggle:()=>R(I===M.id?null:M.id),authFetch:i,onUpdated:()=>{ee(),Te(),Ue()},onOpenEditor:()=>D(M.id),detectedLocalClean:Oe.has(M.id),onSyncClean:Lt,syncing:q,onAiDraft:()=>{Kt(M.id,{openEditor:!0})},aiDrafting:X===M.id,staleMessages:Re.get(M.id)??[],onRepairStale:$t,repairing:ge,conversionPng:pt.get(M.id)??null,onConvert:Et,converting:A,featured:ne===0,rowRef:De=>{De?Me.current.set(M.id,De):Me.current.delete(M.id)}})]},M.id)}),d.jsx(Sy,{index:g.cuts.length,beforeLabel:`After cut ${(ri=g.cuts[g.cuts.length-1])==null?void 0:ri.id}`,afterLabel:"Episode ending",disabled:wt,onAdd:()=>Yt(g.cuts.length)})]})]})}function Sy({index:e,beforeLabel:t,afterLabel:i,disabled:s,onAdd:a}){return d.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:[d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"font-medium text-foreground",children:"Between-scene lettering"}),d.jsxs("span",{className:"block truncate",children:[t," · ",i]})]}),d.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 oM(e){if(!e||e.length===0)return null;const t=l1(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 cM(e,t,i){var s;return((s=Em({checklist:e,markdownReady:t,published:i}))==null?void 0:s.statusLabel)??"Review cuts"}const uM=1024*1024,hM=["image/webp","image/jpeg"],dM="Cover: WebP or JPEG, max 1MB, 600×900 portrait recommended. Use clean cover art — avoid unreadable AI text or broken lettering.";function fM(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 wy(e){return e.size>uM?"Image exceeds 1MB limit":hM.includes(e.type)?null:"Only WebP and JPEG images are accepted"}async function pM(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 Pp(e){const t=e.match(/^#\s+(.+)$/m),i=t?t[1].trim():"";return i||null}function mM(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function $o(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 gM(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 Ip(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 Nm(e){var s;const t=Pp(e.fileContent);if(t)return!Ip(t);const i=((s=e.episodeTitle)==null?void 0:s.trim())||null;return!!i&&!Ip(i)}function jm(e){const{fileName:t,fileContent:i,storySlug:s,structureContent:a,contentType:o,episodeTitle:c}=e,h=Pp(i);if(t==="genesis.md"){const p=a?Pp(a):null;return(h??p??mM(s)).slice(0,60)}if(h)return h.slice(0,60);if(o==="cartoon"){const p=c==null?void 0:c.trim(),f=gM(t);return((p||f)??t.replace(/\.md$/,"")).slice(0,60)}return t.replace(/\.md$/,"").slice(0,60)}function xM(e){return!!(e!=null&&e.txHash)&&(e==null?void 0:e.plotIndex)!=null&&e.plotIndex>0}function _M(e){return xM(e)&&(e==null?void 0:e.status)!=="published-not-indexed"}function Cy(e,t,i){if(e[t]==="cartoon"&&!i)return"cartoon"}function bM(e,t,i){return!(e!=="cartoon"||t||!i||i.startsWith("_new_"))}function Of(e,t,i){if(e)return t[e]||i.get(e)||"fiction"}function zf(e){if(!e)return null;const t=Number(e);return Number.isFinite(t)?(t/1e18).toFixed(6):null}function vM(e){return!!e&&e.ready===!1}function yM(e){const t=zf(e.requiredBalance)??zf(e.creationFee),i=zf(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 SM={...ml,attributes:{...ml.attributes,img:["src","alt","title"]}},wM="https://ipfs.filebase.io/ipfs/";function CM(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 kM(e){const t=CM(e),i=[];for(const a of t)a.url.startsWith(wM)||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 EM(e){return e==="open-cuts"||e==="open-lettering"||e==="upload"||e==="refresh-assets"}function NM({storyName:e,fileName:t,authFetch:i,onPublish:s,publishingFile:a,walletAddress:o,contentType:c="fiction",language:h,genre:p,isNsfw:f,hasGenesis:_=!1,onViewProgress:g,onOpenFile:b,onViewPublish:v,focusedLetteringMode:S=!1,focusedLetteringWorkspaceVisible:N=!1,onFocusedLetteringModeChange:B,onFocusedLetteringWorkspaceVisibleChange:E,workflowActionRequest:z=null,onWorkflowActionHandled:I}){const[R,H]=w.useState(null),[D,ie]=w.useState(!1),[ue,ve]=w.useState("preview"),[L,re]=w.useState("publish"),[F,Y]=w.useState("text"),[K,$]=w.useState(null),T=w.useCallback((se,Ce)=>{ve("edit"),$(ke=>({cutId:se,openEditor:Ce,seq:((ke==null?void 0:ke.seq)??0)+1}))},[]),[q,W]=w.useState(""),[ge,j]=w.useState(!1),[A,Z]=w.useState(!1),[k,oe]=w.useState(!1),[ae,V]=w.useState(null),[X,he]=w.useState(""),[_e,Ae]=w.useState(""),[Oe,He]=w.useState(!1),[Re,et]=w.useState(null),[Ge,ot]=w.useState(0),[Pe,Be]=w.useState(0),[Ve,Nt]=w.useState(null),[kt,pi]=w.useState(null),[Me,St]=w.useState(null),[ct,ee]=w.useState(0),xe=w.useRef(null),Te=w.useRef(!1),[Ue,Ye]=w.useState(!1),[Kt,mi]=w.useState(hl[0]),[Lt,Et]=w.useState(ss[0]),[Gt,ut]=w.useState(!1),[$t,wt]=w.useState(null),[Cn,Yt]=w.useState(null),[ni,U]=w.useState(!1),[be,Ie]=w.useState(!1),[Ee,Qe]=w.useState(!1),[rt,tt]=w.useState(null),[Dt,ft]=w.useState(!1),pt=w.useRef(null),Di=w.useRef(null),[gi,on]=w.useState(!1),[Ui,Mi]=w.useState(null),[Xn,xi]=w.useState(null),[Xt,At]=w.useState("unknown"),ri=w.useRef(!1),[M,ne]=w.useState(!1),[me,De]=w.useState(!1),[Se,Ne]=w.useState(null),[We,Ke]=w.useState([]),[vt,it]=w.useState(null),Ze=w.useRef(null),Ot=w.useRef(null),yi=w.useRef(0),mn=w.useRef(!1);mn.current=EM(z==null?void 0:z.action);const Bi=w.useCallback(async()=>{if(!e||!t){H(null);return}const se=`${e}/${t}`,Ce=Ot.current!==se;Ce&&(Ot.current=se);try{const ke=await i(`/api/stories/${e}/${t}`);if(ke.ok){const Je=await ke.json();H(Je),(Ce||!Te.current)&&(W(Je.content??""),Ce&&(Z(!1),Te.current=!1))}}catch{}},[e,t,i]);w.useEffect(()=>{ie(!0),Bi().finally(()=>ie(!1))},[Bi]),w.useEffect(()=>{if(!e||!t||ue==="edit"&&A)return;const se=setInterval(Bi,3e3);return()=>clearInterval(se)},[e,t,Bi,ue,A]);const[si,cn]=w.useState(null),On=c==="cartoon"&&t==="genesis.md";w.useEffect(()=>{if(!On||!e){cn(null);return}let se=!1;return i(`/api/stories/${e}/cuts/genesis`).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{se||cn(Ce?Op(Ce.cuts||[]):null)}).catch(()=>{se||cn(null)}),()=>{se=!0}},[On,e,i]);const Lr=c==="cartoon"&&!!t&&/^plot-\d+\.md$/.test(t);w.useEffect(()=>{if(!Lr||!e||!t){et(null),ot(0),Be(0),Nt(null);return}let se=!1;const Ce=t.replace(/\.md$/,"");return Nt(null),(async()=>{try{const[ke,Je]=await Promise.all([i(`/api/stories/${e}/${t}`),i(`/api/stories/${e}/cuts/${Ce}`)]);if(se)return;if(!Je.ok){et("error"),ot(0),Be(0),Nt(null);return}const zt=await Je.json(),Li=zt.cuts||[],oi=ke.ok?(await ke.json()).content??"":"",En=ZS(oi,Li);se||(et(En.stage),ot(En.awaitingCount),Be(En.totalCuts),Nt(Op(Li)),St(typeof zt.title=="string"?zt.title:null))}catch{se||(et("error"),ot(0),Be(0),Nt(null))}})(),()=>{se=!0}},[Lr,e,t,i,R==null?void 0:R.content,R==null?void 0:R.status,ct]),w.useEffect(()=>{if(!e){pi(null);return}let se=!1;return i(`/api/stories/${e}/structure.md`).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{se||pi((Ce==null?void 0:Ce.content)??null)}).catch(()=>{}),()=>{se=!0}},[e,i]),w.useEffect(()=>{if(!e)return;const se=ku(p);let Ce=se??"";if(!se&&kt){const Je=kt.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);Je&&(Ce=ku(Je[1].replace(/\*+/g,"").trim())??"")}he(Ce);let ke=h&&ss.find(Je=>Je.toLowerCase()===h.toLowerCase())||"";if(!ke&&kt){const Je=kt.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);Je&&(ke=ss.find(zt=>zt.toLowerCase()===Je[1].replace(/\*+/g,"").trim().toLowerCase())||"")}Ae(ke),He(f??!1)},[e,p,h,f,kt]);const vr=w.useCallback(se=>{e&&i(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}).catch(()=>{})},[e,i]),Ft=w.useCallback(async()=>{if(!(!e||!t)){j(!0);try{(await i(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:q})})).ok&&(Z(!1),Te.current=!1,H(Ce=>Ce&&{...Ce,content:q}))}catch{}j(!1)}},[e,t,i,q]),$i=w.useCallback(async()=>{if(!e||!t)return;const se=t.replace(/\.md$/,"");try{(await i(`/api/stories/${e}/cuts/${se}/generate-markdown`,{method:"POST"})).ok&&(await Bi(),ee(ke=>ke+1))}catch{}},[e,t,i,Bi]);w.useEffect(()=>{if(z&&z.seq!==yi.current){switch(yi.current=z.seq,z.action){case"view-progress":g==null||g();break;case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":ve("edit"),Y("cuts");break;case"generate-markdown":$i();break;case"publish":ve("preview");break}I==null||I(z.seq)}},[z,g,$i,I]);const Si=w.useCallback(se=>{var Je;const Ce=(Je=se.target.files)==null?void 0:Je[0];if(!Ce)return;ri.current=!0,Mi(null),xi(null);const ke=wy(Ce);if(ke){wt(null),Yt(zt=>(zt&&URL.revokeObjectURL(zt),null)),pt.current&&(pt.current.value=""),tt(ke),At("invalid");return}wt(Ce),Yt(zt=>(zt&&URL.revokeObjectURL(zt),URL.createObjectURL(Ce))),tt(null),At("selected")},[]),Or=w.useCallback(async se=>{var ke;const Ce=(ke=se.target.files)==null?void 0:ke[0];if(Di.current&&(Di.current.value=""),!(!Ce||!e)){ri.current=!0,Mi(null),on(!0),tt(null);try{let Je;try{Je=await Ku(Ce)}catch(Qn){wt(null),Yt(ds=>(ds&&URL.revokeObjectURL(ds),null)),tt(Qn instanceof Error?Qn.message:"Could not import image");return}const zt=Je.type==="image/jpeg"?"jpg":"webp",Li=new File([Je],`cover.${zt}`,{type:Je.type}),oi=new FormData;oi.append("file",Li);const En=await i(`/api/stories/${e}/import-cover`,{method:"POST",body:oi});if(!En.ok){const Qn=await En.json().catch(()=>({}));tt(Qn.error||"Cover import failed");return}wt(Li),Yt(Qn=>(Qn&&URL.revokeObjectURL(Qn),URL.createObjectURL(Li))),xi(null),At("selected"),tt(null)}catch{tt("Cover import failed")}finally{on(!1)}}},[e,i]),zr=w.useCallback(async se=>{if(se.size>1024*1024){Ne("Image exceeds 1MB limit");return}if(!["image/webp","image/jpeg"].includes(se.type)){Ne("Only WebP and JPEG images are accepted");return}De(!0),Ne(null);try{const ke=new FormData;ke.append("file",se);const Je=await i("/api/publish/upload-plot-image",{method:"POST",body:ke});if(!Je.ok){const Li=await Je.json();throw new Error(Li.error||"Upload failed")}const zt=await Je.json();Ke(Li=>[...Li,{cid:zt.cid,url:zt.url}])}catch(ke){Ne(ke instanceof Error?ke.message:"Upload failed")}finally{De(!1),Ze.current&&(Ze.current.value="")}},[i]),Zt=w.useCallback(se=>{var ke;const Ce=(ke=se.target.files)==null?void 0:ke[0];Ce&&zr(Ce)},[zr]),Zn=w.useCallback(async()=>{if(R!=null&&R.storylineId){U(!0),tt(null),ft(!1);try{let se;if($t){const ke=new FormData;ke.append("file",$t);const Je=await i("/api/publish/upload-cover",{method:"POST",body:ke});if(!Je.ok){const Li=await Je.json();throw new Error(Li.error||"Cover upload failed")}se=(await Je.json()).cid}const Ce=await i("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:R.storylineId,...se!==void 0&&{coverCid:se},genre:Kt,language:Lt,isNsfw:Gt})});if(!Ce.ok){const ke=await Ce.json();throw new Error(ke.error||"Update failed")}ft(!0),wt(null),se!==void 0&&(Qe(!0),Yt(ke=>(ke&&URL.revokeObjectURL(ke),null)),At("unknown"),pt.current&&(pt.current.value="")),setTimeout(()=>ft(!1),3e3)}catch(se){tt(se instanceof Error?se.message:"Update failed")}finally{U(!1)}}},[R==null?void 0:R.storylineId,$t,Kt,Lt,Gt,i]);w.useEffect(()=>{Ye(!1),wt(null),Yt(null),tt(null),ft(!1),Ie(!1),ne(!1),Ke([]),Ne(null),Mi(null),xi(null),At("unknown"),ri.current=!1,Y(mn.current?"cuts":"text")},[e,t]),w.useEffect(()=>{if(t!=="genesis.md"||!e||!R||R.storylineId||R.status==="published"||R.status==="published-not-indexed"||ri.current)return;let se=!1;return(async()=>{try{const Ce=await i(`/api/stories/${e}/cover-asset`);if(se||!Ce.ok)return;const ke=await Ce.json();if(se)return;if(!(ke!=null&&ke.found)){At("none");return}if(!ke.valid){xi(ke.error||"Detected cover asset is invalid and was not used"),At("invalid");return}const Je=await i(`/api/stories/${e}/asset/${ke.path.replace(/^assets\//,"")}`);if(se||!Je.ok)return;const zt=await Je.blob(),Li=new File([zt],ke.path.split("/").pop()||"cover.webp",{type:ke.type});if(wy(Li)||se||ri.current)return;wt(Li),Yt(oi=>(oi&&URL.revokeObjectURL(oi),URL.createObjectURL(Li))),Mi(ke.path),At("detected")}catch{}})(),()=>{se=!0}},[e,t,R,R==null?void 0:R.status,R==null?void 0:R.storylineId,i]),w.useEffect(()=>{if(!Ue||!(R!=null&&R.storylineId))return;Ie(!1);const se="https://plotlink.xyz";let Ce=!1;return fetch(`${se}/api/storyline/${R.storylineId}`).then(ke=>ke.ok?ke.json():null).then(ke=>{if(!Ce){if(!ke){tt("Could not load current story metadata");return}if(ke.genre){const Je=ku(ke.genre);Je&&mi(Je)}if(ke.language){const Je=ss.find(zt=>zt.toLowerCase()===ke.language.toLowerCase());Je&&Et(Je)}ke.isNsfw!==void 0&&ut(!!ke.isNsfw),Qe(!!(ke.coverCid||ke.coverUrl||ke.cover)),Ie(!0)}}).catch(()=>{Ce||tt("Could not load current story metadata")}),()=>{Ce=!0}},[Ue,R==null?void 0:R.storylineId]),w.useEffect(()=>{if(ue!=="edit")return;const se=Ce=>{(Ce.metaKey||Ce.ctrlKey)&&Ce.key==="s"&&(Ce.preventDefault(),Ft())};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[ue,Ft]),w.useEffect(()=>{if((R==null?void 0:R.status)!=="published-not-indexed"||!R.publishedAt)return;const se=new Date(R.publishedAt).getTime(),Ce=300*1e3,ke=()=>{const zt=Math.max(0,Ce-(Date.now()-se));V(zt)};ke();const Je=setInterval(ke,1e3);return()=>clearInterval(Je)},[R==null?void 0:R.status,R==null?void 0:R.publishedAt]);const Pr=ae!==null&&ae<=0,Ws=ae!==null&&ae>0?`${Math.floor(ae/6e4)}:${String(Math.floor(ae%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),d.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(D&&!R)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const Ir=(ue==="edit"?q:(R==null?void 0:R.content)??"").length,wi=t==="genesis.md",dr=t?/^plot-\d+\.md$/.test(t):!1,Ci=c==="cartoon"&&dr,zn=c==="cartoon"&&wi,us=zn||Ci,Pn=(R==null?void 0:R.status)==="published"||(R==null?void 0:R.status)==="published-not-indexed",Zo=S&&us,vl=zn?si?si.total:null:Ci?Re===null?null:Pe:null,Sa=mD({fileName:t??"",contentType:c,hasGenesis:_,isPublished:Pn,cutCount:vl,cutProgress:zn?si:null}),wa=(zn||Ci)&&!Pn,Gs=wa?jm({fileName:t,fileContent:(R==null?void 0:R.content)??"",storySlug:e??"",structureContent:kt,contentType:"cartoon",episodeTitle:Me}):null,yl=!!Gs&&$o(Gs,t),Ys=Ci&&!Pn&&!Nm({fileContent:(R==null?void 0:R.content)??"",episodeTitle:Me}),gn=zn&&!Pn?wm((R==null?void 0:R.content)??""):null,Ca=!!gn&&gn.blockers.length>0,Sl="w-full max-w-[32rem] rounded-xl border px-3 py-3",hs={muted:"text-muted",accent:"text-accent",error:"text-error",success:"text-green-700"},Hr=se=>{if(!zn)return null;const Ce=fM({hasSelectedCover:!!$t,invalid:Xt==="invalid",attached:se});return d.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"cartoon-cover-status","data-state":Ce.state,children:[d.jsx("span",{className:`text-[11px] font-medium ${hs[Ce.tone]}`,children:Ce.label}),d.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cover-details",children:[d.jsx("summary",{className:"cursor-pointer select-none",children:"Cover tips"}),d.jsx("span",{className:"block mt-0.5","data-testid":"cartoon-cover-guidance",children:dM})]})]})},ka=yl||Ys,wl=()=>{if(!wa||!Gs)return null;const se=wi?"Story title":"Episode title";return d.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"publish-title-preview","data-raw":yl?"true":"false","data-blocked":ka?"true":"false",children:[d.jsxs("span",{className:"text-[11px] text-foreground",children:[d.jsxs("span",{className:"font-medium",children:[se,":"]})," ",d.jsx("span",{className:ka?"text-error font-medium":"text-foreground",children:Gs})]}),yl?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename."," ",wi?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," ","before publishing."]}):Ys?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",Gs,"” 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]})},Qo=()=>gn?d.jsxs("div",{className:"flex flex-col gap-1 rounded border border-border bg-surface/50 p-2","data-testid":"cartoon-genesis-readiness","data-blocked":Ca?"true":"false",children:[d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),d.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."}),gn.blockers.map((se,Ce)=>d.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:se},`b-${Ce}`)),gn.warnings.map((se,Ce)=>d.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:se},`w-${Ce}`))]}):null,fr=wi||dr?1e4:null,kn=!Pn&&fr!==null&&Ir>fr,Cl=(R==null?void 0:R.content)??"",yr=Pn?{count:0,warnings:[]}:kM(Cl),pr=d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden","data-testid":"prose-editor-shell",style:{background:"var(--paper-bg)"},children:[d.jsx("textarea",{ref:xe,value:q,onChange:se=>{W(se.target.value),Z(!0),Te.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"}),d.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:[d.jsx("span",{className:"text-xs text-muted",children:A?"Unsaved changes":"No changes"}),d.jsx("button",{onClick:Ft,disabled:!A||ge,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:ge?"Saving...":"Save"})]})]});return d.jsxs("div",{className:"h-full min-h-0 flex flex-col",children:[!Zo&&d.jsxs("div",{className:"border-b border-border",children:[d.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[g&&d.jsx("button",{onClick:g,"data-testid":"view-progress-btn",className:"text-accent hover:underline font-sans",title:"Story progress overview",children:"← Progress"}),d.jsxs("span",{children:[e,"/",t]}),(R==null?void 0:R.status)==="published"&&d.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(R==null?void 0:R.status)==="published-not-indexed"&&d.jsx("span",{className:"text-amber-700 font-medium",title:R.indexError,children:"Published (not indexed)"}),(R==null?void 0:R.status)==="pending"&&d.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:`text-xs font-mono ${kn?"text-error font-medium":"text-muted"}`,children:[Ir.toLocaleString(),fr!==null?`/${fr.toLocaleString()}`:" chars"]}),kn&&d.jsxs("span",{className:"text-error text-xs font-medium",children:[(Ir-fr).toLocaleString()," over limit"]})]})]}),d.jsxs("div",{className:"flex px-3 gap-1",children:[d.jsx("button",{onClick:()=>ve("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${ue==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),d.jsxs("button",{onClick:()=>ve("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${ue==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",A&&d.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),ue==="preview"?Ci?d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[d.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[d.jsx("button",{"data-testid":"cartoon-mode-publish",onClick:()=>re("publish"),className:`px-2 py-0.5 text-[11px] rounded ${L==="publish"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Publish Preview"}),d.jsx("button",{"data-testid":"cartoon-mode-inspect",onClick:()=>re("inspect"),className:`px-2 py-0.5 text-[11px] rounded ${L==="inspect"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cut Inspector"})]}),d.jsx("div",{className:"flex-1 min-h-0",children:L==="publish"?d.jsx(bD,{content:(R==null?void 0:R.content)??"",stage:Re}):d.jsx(nD,{storyName:e,fileName:t,authFetch:i,onEditCut:T})})]}):d.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?d.jsx("div",{className:"prose max-w-none",children:d.jsx(cS,{remarkPlugins:[hS,LS],rehypePlugins:[[IS,SM]],children:R.content})}):d.jsx("p",{className:"text-muted italic",children:"No content"})}):Ci?d.jsx("div",{className:"flex-1 min-h-[22rem] overflow-hidden",style:{background:"var(--paper-bg)"},children:d.jsx(yy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>ee(se=>se+1),focusRequest:K,onFocusHandled:()=>$(null),onFocusedLetteringModeChange:B,workspaceVisible:N,onWorkspaceVisibleChange:E})}):zn?d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[d.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[d.jsx("button",{"data-testid":"genesis-edit-mode-text",onClick:()=>Y("text"),className:`px-2 py-0.5 text-[11px] rounded ${F==="text"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Opening text"}),d.jsx("button",{"data-testid":"genesis-edit-mode-cuts",onClick:()=>Y("cuts"),className:`px-2 py-0.5 text-[11px] rounded ${F==="cuts"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cuts"})]}),d.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:F==="cuts"?d.jsx(yy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>ee(se=>se+1),focusRequest:K,onFocusHandled:()=>$(null),onFocusedLetteringModeChange:B,workspaceVisible:N,onWorkspaceVisibleChange:E}):pr})]}):pr,!Zo&&d.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"?d.jsx("p",{className:"text-muted text-xs italic","data-testid":"footer-guidance",children:Sa}):(R==null?void 0:R.status)==="published-not-indexed"?d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Pr&&d.jsx("button",{onClick:async()=>{if(!(!e||!t||!R.txHash)){oe(!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:""})}),Bi())}catch{}oe(!1)}},disabled:k,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:k?"Retrying...":`Retry Index${Ws?` (${Ws})`:""}`}),dr&&d.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,X,_e,Oe)},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&&d.jsx("a",{href:`https://basescan.org/tx/${R.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),d.jsx("p",{className:"text-muted text-xs",children:Pr?dr?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":dr?"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&&d.jsx("p",{className:"text-error text-xs",children:R.indexError})]}):(R==null?void 0:R.status)==="published"?d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"text-green-700",children:"Published"}),R.storylineId&&d.jsx("a",{href:(()=>{var ke;const se=`https://plotlink.xyz/story/${R.storylineId}`;if(!dr)return se;const Ce=R.plotIndex!=null&&R.plotIndex>0?R.plotIndex:parseInt(((ke=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:ke[1])??"1");return`${se}/${Ce}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),R.txHash&&d.jsx("a",{href:`https://basescan.org/tx/${R.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),wi&&o&&R.storylineId&&(!R.authorAddress||R.authorAddress.toLowerCase()===o.toLowerCase())&&d.jsx("button",{onClick:()=>Ye(se=>!se),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:Ue?"Close Edit":"Edit Story"})]}),Ue&&wi&&R.storylineId&&d.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),Hr(Ee),d.jsxs("div",{className:"flex items-start gap-3",children:[Cn&&d.jsxs("div",{className:"relative",children:[d.jsx("img",{src:Cn,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsx("button",{onClick:()=>{wt(null),Yt(null),xi(null),At("unknown"),pt.current&&(pt.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"})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("input",{ref:pt,type:"file",accept:"image/webp,image/jpeg",onChange:Si,className:"text-xs","data-testid":"cover-input"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"})]})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("select",{value:Kt,onChange:se=>mi(se.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:hl.map(se=>d.jsx("option",{value:se,children:se},se))}),d.jsx("select",{value:Lt,onChange:se=>Et(se.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:ss.map(se=>d.jsx("option",{value:se,children:se},se))})]}),d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:Gt,onChange:se=>ut(se.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:Zn,disabled:ni||!be,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:ni?"Saving...":be?"Save Changes":"Loading..."}),Dt&&d.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),rt&&d.jsx("span",{className:"text-error text-xs",children:rt})]})]})]}):d.jsxs("div",{className:"flex flex-col gap-2",children:[Ci&&Ve&&Ve.total>0&&d.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:[d.jsxs("span",{children:["Cuts:"," ",d.jsx("span",{className:"text-foreground font-medium",children:Ve.total})]}),d.jsxs("span",{children:["Clean:"," ",d.jsxs("span",{className:"text-foreground font-medium",children:[Ve.withClean,"/",Ve.needClean]})]}),d.jsxs("span",{children:["Lettered:"," ",d.jsxs("span",{className:"text-foreground font-medium",children:[Ve.withText,"/",Ve.total]})]}),d.jsxs("span",{children:["Uploaded:"," ",d.jsxs("span",{className:"text-foreground font-medium",children:[Ve.uploaded,"/",Ve.total]})]}),g&&d.jsx("button",{onClick:g,className:"ml-auto text-accent hover:underline","data-testid":"status-view-progress",children:"View progress →"})]}),zn&&si&&d.jsxs("div",{className:"text-xs text-muted","data-testid":"genesis-cuts-summary",children:["Episode 1 (Genesis) cuts: ",si.total," planned",si.total>0&&d.jsxs(d.Fragment,{children:[" ","· ",si.withClean," clean ·"," ",si.withText," lettered ·"," ",si.exported," exported ·"," ",si.uploaded," uploaded"]})]}),(zn||Ci)&&Sa&&d.jsxs("div",{className:`${Sl} flex flex-col gap-1 border-border bg-surface/50`,"data-testid":"cartoon-not-started",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-muted",children:vl===0?"Not started":"Next step"}),d.jsx("span",{className:"text-xs font-medium text-foreground",children:zn?"Genesis (Episode 1)":"Future episode"})]}),d.jsx("span",{className:"text-xs text-muted",children:Sa})]}),dr&&!Ci&&ue==="preview"&&d.jsxs("div",{children:[d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:M,onChange:se=>ne(se.target.checked),className:"rounded border-border"}),"Add illustrations in the plot"]}),M&&d.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[d.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 se;return(se=Ze.current)==null?void 0:se.click()},onDragOver:se=>{se.preventDefault(),se.stopPropagation()},onDrop:se=>{var ke;se.preventDefault(),se.stopPropagation();const Ce=(ke=se.dataTransfer.files)==null?void 0:ke[0];Ce&&zr(Ce)},children:[d.jsx("input",{ref:Ze,type:"file",accept:"image/webp,image/jpeg",onChange:Zt,className:"hidden"}),d.jsx("span",{className:"text-xs text-muted",children:me?"Uploading...":"Drop image here or click to browse"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB"})]}),Se&&d.jsx("span",{className:"text-error text-xs",children:Se}),We.map((se,Ce)=>d.jsxs("div",{className:"border border-border rounded p-2 flex flex-col gap-1 bg-surface",children:[d.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:"}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("code",{className:"flex-1 text-xs bg-background px-2 py-1 rounded font-mono break-all",children:[""]}),d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(``),it(Ce),setTimeout(()=>it(null),2e3)},className:"px-2 py-1 text-xs border border-border rounded hover:bg-surface shrink-0",children:vt===Ce?"Copied!":"Copy"})]})]},se.cid))]})]}),wi&&c!=="cartoon"&&!(ue==="edit"&&F==="cuts")&&d.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"prepublish-cover",children:[d.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Cover Image"," ",d.jsx("span",{className:"text-muted font-normal",children:"(optional)"})]}),Hr(!1),d.jsxs("div",{className:"flex items-start gap-3",children:[Cn&&d.jsxs("div",{className:"relative",children:[d.jsx("img",{src:Cn,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsx("button",{onClick:()=>{ri.current=!0,Mi(null),xi(null),At("unknown"),wt(null),Yt(se=>(se&&URL.revokeObjectURL(se),null)),pt.current&&(pt.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"})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("input",{ref:pt,type:"file",accept:"image/webp,image/jpeg",onChange:Si,className:"text-xs","data-testid":"prepublish-cover-input"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"}),d.jsx("input",{ref:Di,type:"file",accept:"image/png,image/webp,image/jpeg",onChange:Or,className:"hidden","data-testid":"prepublish-cover-import-input"}),d.jsx("button",{type:"button",onClick:()=>{var se;return(se=Di.current)==null?void 0:se.click()},disabled:gi,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:gi?"Importing…":"Import generated image (PNG ok)"}),$t&&d.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."}),Ui&&d.jsxs("span",{className:"text-accent text-xs","data-testid":"prepublish-cover-detected",children:["Auto-detected generated cover ",Ui," — pick a file to override."]}),Xn&&d.jsxs("span",{className:"text-amber-700 text-xs","data-testid":"prepublish-cover-detected-warning",children:[Xn," Use “Import generated image” below to convert/compress it, or pick a file."]}),c==="cartoon"&&Xt==="none"&&!$t&&d.jsxs("span",{className:"text-muted text-xs","data-testid":"prepublish-cover-none",children:["No generated cover detected. Create"," ",d.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."]}),rt&&d.jsx("span",{className:"text-error text-xs","data-testid":"prepublish-cover-error",children:rt})]})]})]}),!us&&wl(),!us&&Qo(),!us&&d.jsxs("div",{className:"flex items-center gap-2",children:[wi&&c!=="cartoon"&&d.jsxs(d.Fragment,{children:[d.jsxs("select",{value:X,"data-testid":"publish-genre-select",onChange:se=>{he(se.target.value),se.target.value&&vr({genre:se.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${X?"border-border":"border-amber-500"}`,children:[!X&&d.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select genre"}),hl.map(se=>d.jsx("option",{value:se,children:se},se))]}),d.jsxs("select",{value:_e,"data-testid":"publish-language-select",onChange:se=>{Ae(se.target.value),se.target.value&&vr({language:se.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${_e?"border-border":"border-amber-500"}`,children:[!_e&&d.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select language"}),ss.map(se=>d.jsx("option",{value:se,children:se},se))]})]}),d.jsx("button",{onClick:async()=>{if(!e||!t)return;if(yr.count>0){const Ce=`This plot contains ${yr.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(Ce))return}const se=wi?$t:null;se?await(s==null?void 0:s(e,t,X,_e,Oe,se))&&(ri.current=!0,Mi(null),xi(null),At("unknown"),wt(null),Yt(ke=>(ke&&URL.revokeObjectURL(ke),null)),pt.current&&(pt.current.value="")):s==null||s(e,t,X,_e,Oe)},disabled:!!a||kn||ka||Ca||wi&&(!X||!_e)||Ci&&Re!=="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"}),wi&&c==="cartoon"&&(!X||!_e)&&d.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"}),wi&&c!=="cartoon"&&!X&&d.jsx("span",{className:"text-amber-600 text-xs","data-testid":"genre-needs-metadata",children:"Needs metadata — choose a genre before publishing"}),wi&&c!=="cartoon"&&X&&!_e&&d.jsx("span",{className:"text-amber-600 text-xs","data-testid":"language-needs-metadata",children:"Needs metadata — choose a language before publishing"}),kn&&d.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"}),Ci&&Re==="error"&&d.jsx("span",{className:"text-error text-xs","data-testid":"publish-disabled-reason",children:"Fix the issues below before publishing"}),Ci&&Re==="planning"&&d.jsx("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:"Prepare the episode for publish to continue"}),Ci&&Re==="awaiting-upload"&&d.jsxs("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:["Upload all final images, then “Prepare episode for publish” — ",Ge," of ",Pe," ","still need an uploaded image"]})]}),us&&d.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 →"}),yr.warnings.length>0&&d.jsx("div",{className:"flex flex-col gap-0.5",children:yr.warnings.map((se,Ce)=>d.jsx("span",{className:"text-amber-600 text-xs",children:se},Ce))}),wi&&c!=="cartoon"&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:Oe,onChange:se=>{He(se.target.checked),vr({isNsfw:se.target.checked})},className:"rounded border-border"}),"This story contains adult content (18+)"]}),Oe&&d.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}function jM(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 c1(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(f=>!f.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 Hp({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 d.jsx("div",{className:`border px-3 py-3 sm:px-4 ${c}`,"data-testid":o,"data-state":t==="complete"?"complete":"active",children:d.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.14em] ${h}`,children:e}),d.jsx("p",{className:"mt-1 text-sm text-foreground",children:i}),a?d.jsx("p",{className:"mt-1 text-[11px] font-medium text-accent",children:a}):null]}),s?d.jsx("div",{className:"flex w-full justify-end sm:w-auto sm:flex-shrink-0",children:s}):null]})})}function Up({onClick:e,disabled:t,testId:i}){return d.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 u1({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 d.jsx(Hp,{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?d.jsx(Up,{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?d.jsx(Up,{testId:"workflow-coach-do",onClick:()=>t(e.uiAction,e.episodeFile)}):null;return d.jsx(Hp,{badge:e.stageLabel,summary:d.jsxs("span",{"data-testid":"workflow-coach-action",children:[d.jsx("span",{className:"font-semibold",children:"Next: "}),d.jsx("span",{children:e.action})]}),note:a?"Prompt copied.":void 0,testId:"cartoon-next-action",children:o})}function TM({progress:e,onOpenStoryInfo:t}){return d.jsx(Hp,{badge:"Story info",summary:d.jsxs("span",{"data-testid":"story-info-next-action",children:[d.jsx("span",{className:"font-semibold",children:"Next: "}),d.jsx("span",{children:jM(e)})]}),testId:"story-info-cta",children:d.jsx(Up,{testId:"story-info-next-action-btn",onClick:()=>t==null?void 0:t(),disabled:!t})})}function AM({progress:e,onCoachAction:t,onOpenStoryInfo:i}){return c1(e)==="story-info"?d.jsx(TM,{progress:e,onOpenStoryInfo:i}):d.jsx(u1,{coach:e.coach??null,onAction:t})}function RM({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]),[f,_]=w.useState(null);return f!==p&&(h(void 0),_(p)),w.useEffect(()=>{let g=!1;const b=i?`?focus=${encodeURIComponent(i)}`:"";return t(`/api/stories/${e}/progress${b}`).then(v=>v.ok?v.json():null).then(v=>{g||h(DM(v)?v:null)}).catch(()=>{g||h(null)}),()=>{g=!0}},[e,i,t,s]),c===void 0?null:c?d.jsx(AM,{progress:c,onCoachAction:a,onOpenStoryInfo:o}):d.jsx(u1,{coach:null,onAction:a})}function DM(e){return!!e&&!!e.metadata&&!!e.setup&&Array.isArray(e.episodes)}function MM({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 _=await t(`/api/stories/${e}/progress`),g=_.ok?await _.json():null;p||(o(g),h(!1))}catch{p||(o(null),h(!1))}})(),()=>{p=!0}},[e,t,s]),c?d.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)?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story progress."}):a.contentType==="cartoon"?d.jsx(HM,{progress:a,storyName:e,onOpenFile:i}):d.jsx(FM,{progress:a,storyName:e,onOpenFile:i})}function gu({label:e,value:t,tone:i="muted"}){const s=i==="ok"?"text-green-700":i==="warn"?"text-amber-700":"text-muted";return d.jsxs("span",{className:"text-[11px]",children:[d.jsxs("span",{className:"text-muted",children:[e,": "]}),d.jsx("span",{className:`font-medium ${s}`,children:t})]})}function h1({progress:e}){const t=e.contentType==="cartoon",i=e.cover==="present"?"ok":e.cover==="invalid"?"warn":"muted";return d.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h2",{className:"text-base font-serif text-foreground truncate",children:e.metadata.title||e.name}),d.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"})]}),d.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-1",children:[d.jsx(gu,{label:"Language",value:e.metadata.language||"Needs metadata",tone:e.metadata.language?"muted":"warn"}),d.jsx(gu,{label:"Genre",value:e.metadata.genre||"Needs metadata",tone:e.metadata.genre?"muted":"warn"}),e.metadata.isNsfw!=null&&d.jsx(gu,{label:"Adult",value:e.metadata.isNsfw?"Yes (18+)":"No"}),t&&d.jsx(gu,{label:"Cover",value:e.cover==="present"?"Ready":e.cover==="invalid"?"Invalid":"Missing",tone:i})]})]})}const d1={published:"✓",done:"●",current:"◉","needs-action":"●","not-started":"○"},zu={published:"text-green-700",done:"text-green-700",current:"text-accent","needs-action":"text-amber-700","not-started":"text-muted"},f1={published:"Published",done:"Complete",current:"Current","needs-action":"Needs action","not-started":"Not started"},BM={done:"✓",current:"◓",todo:"○"},LM={done:"text-green-700",current:"text-accent",todo:"text-muted"};function p1({item:e}){return d.jsxs("div",{className:"flex items-baseline gap-2 text-[11px]","data-testid":"checklist-item","data-status":e.status,children:[d.jsx("span",{className:`${LM[e.status]} flex-shrink-0`,"aria-hidden":!0,children:BM[e.status]}),d.jsx("span",{className:e.status==="todo"?"text-muted":"text-foreground",children:e.label}),e.detail&&d.jsxs("span",{className:"text-muted",children:["· ",e.detail]})]})}function ky({index:e,title:t,status:i,items:s,fileName:a,openFile:o}){const c=d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx("span",{className:`flex-shrink-0 ${zu[i]}`,"aria-hidden":!0,children:d1[i]}),d.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",t]}),a&&d.jsx("span",{className:"text-[10px] text-muted truncate",children:a}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${zu[i]} flex-shrink-0`,children:f1[i]})]});return d.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":i,children:[o?d.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,d.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:s.map((h,p)=>d.jsx(p1,{item:h},p))})]})}function OM(e,t){return e.published?"published":t?"current":e.state==="placeholder"?"not-started":(e.state==="blocked","needs-action")}function zM(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(PM(a));return s}function PM(e){return{label:e.label,status:e.status,detail:e.detail}}const IM={file:"genesis.md",label:"Episode 1 / Genesis",kind:"genesis",title:null,state:"placeholder",summary:"",published:!1,checklist:[],cuts:null};function HM({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=c1(e),f=[{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"}],_=p==="story-info"?"current":h?"needs-action":"done",g=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 d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[d.jsx(h1,{progress:e}),d.jsx("p",{className:"px-4 pt-3 pb-1 text-[11px] font-medium text-muted uppercase tracking-wider",children:"Production Progress"}),d.jsx(ky,{index:++S,title:"Define Story Info",status:_,items:f}),d.jsx(ky,{index:++S,title:"Story Whitepaper",status:g,fileName:"structure.md",openFile:a?()=>i(t,"structure.md"):void 0,items:[{label:"Planning document",status:a?"done":"todo",detail:a?null:"Not written yet"}]}),b?d.jsx(Pf,{index:++S,ep:b,isActive:p===b.file,storyName:t,onOpenFile:i}):d.jsx(Pf,{index:++S,ep:IM,isActive:p==="genesis.md",openingDone:!1,canOpen:!1,storyName:t,onOpenFile:i}),v.map(N=>d.jsx(Pf,{index:++S,ep:N,isActive:p===N.file,storyName:t,onOpenFile:i},N.file)),d.jsxs("div",{className:"px-4 py-2 text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[d.jsxs("span",{children:[e.summary.published," published"]}),d.jsxs("span",{children:[e.summary.readyToPublish," ready"]}),e.summary.placeholders>0&&d.jsxs("span",{children:[e.summary.placeholders," not started"]}),e.summary.blocked>0&&d.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function Pf({index:e,ep:t,isActive:i,storyName:s,onOpenFile:a,openingDone:o=!0,canOpen:c=!0}){var b;const h=OM(t,i),p=zM(t,o),f=Em({checklist:t.checklist?{steps:t.checklist,nextStep:null}:null,markdownReady:t.state==="ready"||t.published,published:t.published}),_=t.title?`${t.label} · ${t.title}`:t.label,g=d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx("span",{className:`flex-shrink-0 ${zu[h]}`,"aria-hidden":!0,children:d1[h]}),d.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",_]}),d.jsx("span",{className:"text-[10px] text-muted truncate",children:t.file}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${zu[h]} flex-shrink-0`,children:f1[h]})]});return d.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":h,children:[c?d.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:g}):d.jsx("div",{"data-state":t.state,children:g}),(f==null?void 0:f.statusLabel)&&d.jsxs("div",{className:"mt-1 ml-1 text-[10px] text-muted",children:[d.jsx("span",{className:"font-medium text-foreground",children:"Active step:"})," ",f.statusLabel,(b=f.activeStep)!=null&&b.detail?` · ${f.activeStep.detail}`:""]}),d.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:p.map((v,S)=>d.jsx(p1,{item:v},S))})]})}const UM={published:"✓",ready:"●","in-progress":"◐",planning:"○",placeholder:"○",blocked:"✕",draft:"○"},Ey={published:"text-green-700",ready:"text-green-700","in-progress":"text-accent",planning:"text-accent",placeholder:"text-muted",blocked:"text-error",draft:"text-muted"},$M={published:"Published",ready:"Ready","in-progress":"In progress",planning:"Planning",placeholder:"Not started",blocked:"Needs fixes",draft:"Draft"};function FM({progress:e,storyName:t,onOpenFile:i}){const[s,a]=w.useState(!1);return d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[d.jsx(h1,{progress:e}),e.nextAction&&d.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:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"Next: "}),d.jsx("span",{className:"text-muted",children:e.nextAction})]}),e.nextPrompt&&d.jsxs("div",{className:"flex items-start gap-1.5","data-testid":"progress-next-prompt",children:[d.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}),d.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"})]})]}),d.jsxs("div",{className:"px-4 py-2 border-b border-border flex flex-col gap-1",children:[d.jsx(Ny,{done:e.setup.hasStructure,label:"Story bible (structure.md)",onClick:e.setup.hasStructure?()=>i(t,"structure.md"):void 0}),d.jsx(Ny,{done:e.setup.hasGenesis,label:"Genesis written",onClick:e.setup.hasGenesis?()=>i(t,"genesis.md"):void 0})]}),d.jsxs("div",{className:"px-4 py-2",children:[d.jsx("p",{className:"text-[11px] font-medium text-muted uppercase tracking-wider mb-1.5",children:"Chapters"}),e.episodes.length===0?d.jsx("p",{className:"text-xs text-muted italic","data-testid":"progress-no-episodes",children:"No chapters yet — write the Genesis to start."}):d.jsx("ol",{className:"flex flex-col gap-1",children:e.episodes.map(o=>d.jsx("li",{children:d.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:[d.jsx("span",{className:`mt-0.5 ${Ey[o.state]}`,"aria-hidden":!0,children:UM[o.state]}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:o.label}),o.title&&d.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",o.title]}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${Ey[o.state]}`,children:$M[o.state]})]}),d.jsx("span",{className:"block text-[11px] text-muted",children:o.summary})]})]})},o.file))})]}),d.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:[d.jsxs("span",{children:[e.summary.published," published"]}),e.summary.blocked>0&&d.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function Ny({done:e,label:t,onClick:i}){const s=d.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:e?"text-green-700":"text-muted","aria-hidden":!0,children:e?"✓":"○"}),d.jsx("span",{className:e?"text-foreground":"text-muted",children:t})]});return i?d.jsx("button",{onClick:i,className:"text-left hover:underline",children:s}):d.jsx("div",{children:s})}const qM=[{key:"progress",label:"Progress"},{key:"story-info",label:"Story Info"},{key:"whitepaper",label:"Whitepaper"},{key:"genesis",label:"Genesis / Ep 1"},{key:"episodes",label:"Episodes"},{key:"publish",label:"Publish"}];function WM({storyTitle:e,active:t,onSelect:i}){return d.jsxs("div",{className:"flex-shrink-0 border-b border-border bg-surface/40","data-testid":"cartoon-workflow-nav",children:[d.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2",children:[d.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-accent",children:"Cartoon"}),d.jsx("span",{className:"text-xs font-serif text-foreground truncate",children:e})]}),d.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 overflow-x-auto",role:"tablist",children:qM.map(s=>{const a=s.key===t;return d.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 GM({storyName:e,authFetch:t,onSaved:i}){const[s,a]=w.useState(!0),[o,c]=w.useState(!1),[h,p]=w.useState(""),[f,_]=w.useState(""),[g,b]=w.useState(""),[v,S]=w.useState(""),[N,B]=w.useState(!1),[E,z]=w.useState("cartoon"),[I,R]=w.useState("unknown"),[H,D]=w.useState(!1),[ie,ue]=w.useState(!1),[ve,L]=w.useState(null),[re,F]=w.useState(!1),[Y,K]=w.useState(null),[$,T]=w.useState(!1),q=w.useRef(null);w.useEffect(()=>{let k=!1;return a(!0),c(!1),ue(!1),L(null),(async()=>{try{const[oe,ae]=await Promise.all([t(`/api/stories/${e}`),t(`/api/stories/${e}/progress`)]);if(!oe.ok){k||(c(!0),a(!1));return}const V=await oe.json(),X=ae.ok?await ae.json().catch(()=>null):null;if(k)return;p(V.title??""),_(V.description??""),b(ku(V.genre)??""),S(V.language&&ss.find(he=>he.toLowerCase()===V.language.toLowerCase())||""),B(!!V.isNsfw),z(V.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=w.useCallback(async()=>{D(!0),ue(!1),L(null);const k={title:h.trim(),description:f.trim(),genre:g,language:v,isNsfw:N};try{const oe=await t(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(oe.ok)ue(!0),i==null||i({genre:g,language:v,isNsfw:N});else{const ae=await oe.json().catch(()=>({}));L(ae.error||"Could not save story info.")}}catch{L("Could not save story info.")}D(!1)},[e,t,h,f,g,v,N,i]),ge=w.useCallback(async k=>{var ae;const oe=(ae=k.target.files)==null?void 0:ae[0];if(q.current&&(q.current.value=""),!!oe){F(!0),L(null);try{let V;try{V=await Ku(oe)}catch(Oe){L(Oe instanceof Error?Oe.message:"Could not import image");return}const X=V.type==="image/jpeg"?"jpg":"webp",he=new File([V],`cover.${X}`,{type:V.type}),_e=new FormData;_e.append("file",he);const Ae=await t(`/api/stories/${e}/import-cover`,{method:"POST",body:_e});if(!Ae.ok){const Oe=await Ae.json().catch(()=>({}));L(Oe.error||"Cover import failed.");return}R("present"),K(Oe=>(Oe&&URL.revokeObjectURL(Oe),URL.createObjectURL(he)))}catch{L("Cover import failed.")}finally{F(!1)}}},[e,t]),j=w.useCallback(()=>{var oe;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.`;(oe=navigator.clipboard)==null||oe.writeText(k).then(()=>{T(!0)}).catch(()=>{})},[h,e]);if(s)return d.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 d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story info."});const A=I==="present"?"Cover set":I==="invalid"?"Invalid cover — re-import a WebP/JPEG under 1MB":"Missing cover",Z=I==="present"?"text-green-700":I==="invalid"?"text-amber-700":"text-muted";return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"story-info-page",children:[d.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Story Info"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"These details appear on PlotLink when the story is published."}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-[10px]",children:[d.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"]}),d.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${g?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:["Genre ",g?"set":"needed"]}),d.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"]}),d.jsx("span",{className:`rounded-full border px-2 py-0.5 ${I==="present"?"border-green-700/30 bg-green-700/10 text-green-700":"border-border bg-background text-muted"}`,children:I==="present"?"Cover ready":"Cover missing"})]})]}),d.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[d.jsx("button",{type:"button",onClick:W,disabled:H,"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:H?"Saving…":"Save Story Info"}),ie&&d.jsx("span",{className:"text-[11px] text-green-700","data-testid":"story-info-saved",children:"Saved"}),ve&&d.jsx("span",{className:"text-[11px] text-error","data-testid":"story-info-error",children:ve})]})]}),d.jsxs("div",{className:"mt-4 flex flex-col gap-4 max-w-xl",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Public title"}),d.jsx("input",{type:"text",value:h,onChange:k=>{p(k.target.value),ue(!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"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Short description"}),d.jsx("textarea",{value:f,onChange:k=>{_(k.target.value),ue(!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"})]}),d.jsxs("div",{className:"flex flex-wrap gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Genre"}),d.jsxs("select",{value:g,onChange:k=>{b(k.target.value),ue(!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:[d.jsx("option",{value:"",children:"Needs metadata"}),hl.map(k=>d.jsx("option",{value:k,children:k},k))]})]}),d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Language"}),d.jsxs("select",{value:v,onChange:k=>{S(k.target.value),ue(!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:[d.jsx("option",{value:"",children:"Needs metadata"}),ss.map(k=>d.jsx("option",{value:k,children:k},k))]})]}),d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Content type"}),d.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"})]})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Cover image"}),d.jsxs("div",{className:"flex items-start gap-3",children:[Y&&d.jsx("img",{src:Y,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:`text-[11px] font-medium ${Z}`,"data-testid":"story-info-cover-status",children:A}),d.jsx("span",{className:"text-[10px] text-muted",children:"WebP or JPEG, max 1MB, 600×900 recommended."}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{type:"button",onClick:()=>{var k;return(k=q.current)==null?void 0:k.click()},disabled:re,"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:re?"Importing…":"Import cover"}),d.jsx("button",{type:"button",onClick:j,"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:$?"Copied!":"Ask agent for cover prompt"})]}),d.jsx("input",{ref:q,type:"file",accept:"image/*",onChange:ge,className:"hidden"})]})]})]}),d.jsxs("label",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"checkbox",checked:N,onChange:k=>{B(k.target.checked),ue(!1)},"data-testid":"story-info-nsfw"}),d.jsx("span",{className:"text-xs text-foreground",children:"This story contains adult content (18+)"})]})]})]})}function YM({storyName:e,authFetch:t,onOpenFile:i}){const[s,a]=w.useState(null),[o,c]=w.useState(!0);if(w.useEffect(()=>{let g=!1;return(async()=>{c(!0);try{const v=await t(`/api/stories/${e}/progress`),S=v.ok?await v.json():null;g||(a(Array.isArray(S==null?void 0:S.episodes)?S.episodes:null),c(!1))}catch{g||(a(null),c(!1))}})(),()=>{g=!0}},[e,t]),o)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"episodes-loading",children:"Loading episodes…"});if(!s)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load episodes."});const h=s.filter(g=>g.published).length,p=s.filter(g=>!g.published).length,f=s.filter(g=>g.state==="blocked").length,_=s.filter(g=>g.state==="ready").length;return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"episodes-page",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Episodes"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Genesis is Episode 1; each plot file is the next episode."}),d.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5 text-[10px]","data-testid":"episodes-summary",children:[d.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:[s.length," total"]}),d.jsxs("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-muted",children:[p," active"]}),d.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"]}),d.jsxs("span",{className:"rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-accent",children:[_," ready"]}),f>0&&d.jsxs("span",{className:"rounded-full border border-error/30 bg-error/10 px-2 py-0.5 text-error",children:[f," need fixes"]})]}),s.length===0?d.jsx("p",{className:"mt-4 text-xs text-muted italic","data-testid":"episodes-empty",children:"No episodes yet — write the Genesis to start Episode 1."}):d.jsx("ol",{className:"mt-3 flex flex-col gap-1",children:s.map(g=>d.jsx("li",{children:d.jsx("button",{onClick:()=>i(e,g.file),"data-testid":`episodes-row-${g.file}`,"data-state":g.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:g.label}),g.title&&d.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",g.title]}),d.jsx("span",{className:"ml-auto text-[10px] text-muted",children:g.file})]}),d.jsx("span",{className:"block text-[11px] text-muted",children:g.summary})]})})},g.file))})]})}function VM({storyName:e,authFetch:t,onOpenFile:i,onOpenStoryInfo:s,onPublish:a,publishingFile:o,genre:c,language:h,isNsfw:p,refreshKey:f=0}){var ot,Pe;const[_,g]=w.useState(null),[b,v]=w.useState(!0),[S,N]=w.useState(!1),[B,E]=w.useState(null),[z,I]=w.useState(null),[R,H]=w.useState(null),[D,ie]=w.useState(null),[ue,ve]=w.useState(null),L=async()=>{try{const Be=await t(`/api/stories/${e}/cover-asset`),Ve=Be.ok?await Be.json():null;if(!(Ve!=null&&Ve.found)||!Ve.valid||!Ve.path)return null;const Nt=await t(`/api/stories/${e}/asset/${String(Ve.path).replace(/^assets\//,"")}`);if(!Nt.ok)return null;const kt=await Nt.blob();return new File([kt],String(Ve.path).split("/").pop()||"cover.webp",{type:Ve.type||kt.type})}catch{return null}};w.useEffect(()=>{let Be=!1;return(async()=>{v(!0),N(!1);try{const Nt=await t(`/api/stories/${e}/progress`),kt=Nt.ok?await Nt.json():null;if(Be)return;!kt||!Array.isArray(kt.episodes)?(N(!0),g(null)):g(kt),v(!1)}catch{Be||(N(!0),g(null),v(!1))}})(),()=>{Be=!0}},[e,t,f]);const re=((Pe=(ot=_==null?void 0:_.episodes)==null?void 0:ot.find(Be=>!Be.published))==null?void 0:Pe.file)??null,F=re==="genesis.md",Y=JSON.stringify([re??"",f]),[K,$]=w.useState(null);if(K!==Y&&($(Y),I(null),H(null),ie(null),ve(null)),w.useEffect(()=>{if(!re)return;let Be=!1;const Ve=re.replace(/\.md$/,"");return(async()=>{var Nt;try{const kt=[t(`/api/stories/${e}/${re}`),t(`/api/stories/${e}/cuts/${Ve}`)];F&&kt.push(t(`/api/stories/${e}/structure.md`));const[pi,Me,St]=await Promise.all(kt);if(Be)return;if(I(pi.ok?(await pi.json()).content??"":""),Me.ok){const ct=await Me.json();if(Be)return;H(Array.isArray(ct.cuts)?ct.cuts:[]),ie(typeof ct.title=="string"?ct.title:null)}else H(null),ie(null);ve(F&&St&&St.ok?((Nt=await St.json())==null?void 0:Nt.content)??null:null)}catch{Be||(I(""),H(null),ie(null),ve(null))}})(),()=>{Be=!0}},[re,F,e,t,f]),b)return d.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||!_)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load publish readiness."});const T=_.episodes.find(Be=>!Be.published);if(!T)return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Publish"}),d.jsx("p",{className:"mt-2 text-xs text-green-700","data-testid":"publish-all-done",children:_.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=_.cover==="present",W=JS({cuts:R??[],published:T.published}),ge=T.state==="ready",j=T.state==="blocked",A=T.file==="genesis.md",Z=!A||!!c&&!!h,k=!!o&&o===T.file,oe=z!==null,ae=oe?jm({fileName:T.file,fileContent:z??"",storySlug:e,structureContent:ue,contentType:"cartoon",episodeTitle:D}):null,V=!!ae&&$o(ae,T.file),X=!A&&oe&&!Nm({fileContent:z??"",episodeTitle:D}),he=V||X,_e=A&&oe?wm(z??""):null,Ae=!!_e&&_e.blockers.length>0,Oe=!A&&oe&&R!==null?ZS(z??"",R):null,He=Oe&&Oe.stage==="error"?Oe.issues:[],et=ge&&Z&&(oe&&(A||R!==null))&&!he&&!Ae&&!k&&!!a,Ge=async()=>{if(!(!et||!a)){E(null);try{const Be=A?await L():null;await a(e,T.file,c??"",h??"",!!p,Be)}catch{E("Publish could not be started. Please try again.")}}};return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[d.jsxs("h2",{className:"text-base font-serif text-foreground",children:["Publish ",T.label]}),d.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."}),d.jsxs("div",{className:"mt-3 max-w-xl","data-testid":"publish-checklist",children:[d.jsx(a1,{checklist:W,markdownReady:ge,published:T.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"}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-[10px]",children:[d.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"]}),A&&d.jsxs("span",{className:`rounded-full border px-2 py-0.5 ${Z?"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: ",Z?"Ready":"Set genre & language"]})]})]}),ae&&d.jsxs("div",{className:"mt-4 flex flex-col gap-0.5 max-w-xl","data-testid":"publish-title-preview","data-raw":V?"true":"false","data-blocked":he?"true":"false",children:[d.jsxs("span",{className:"text-[11px] text-foreground",children:[d.jsxs("span",{className:"font-medium",children:[A?"Story title":"Episode title",":"]})," ",d.jsx("span",{className:he?"text-error font-medium":"text-foreground",children:ae})]}),V?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",A?"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?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",ae,"” 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]}),_e&&d.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":Ae?"true":"false",children:[d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),d.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."}),_e.blockers.map((Be,Ve)=>d.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:Be},`b-${Ve}`)),_e.warnings.map((Be,Ve)=>d.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:Be},`w-${Ve}`))]}),He.length>0&&d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.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"}),d.jsx("span",{className:"text-xs font-medium text-foreground",children:"Finish these workflow steps"})]}),QS(He).map(Be=>d.jsx("div",{className:"rounded-lg border border-error/15 bg-background/70 px-2.5 py-2","data-testid":`cartoon-issue-group-${Be.key}`,children:d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:Be.title})},Be.key)),d.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cartoon-technical-details",children:[d.jsx("summary",{className:"cursor-pointer select-none",children:"Technical details"}),d.jsx("ul",{className:"mt-1 ml-3 list-disc",children:He.map((Be,Ve)=>d.jsx("li",{className:"font-mono break-words",children:Be},Ve))})]})]}),d.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-xl",children:[!q&&d.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)"}),A&&!Z&&d.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)"}),!ge&&d.jsxs("button",{onClick:()=>i(e,T.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 ",T.label," to finish ",j?"and fix issues":"(letter / export / upload)"]}),d.jsx("button",{onClick:Ge,disabled:!et,"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:et?void 0:"Finish the remaining steps above first",children:k?"Publishing…":`Publish ${T.label} to PlotLink`}),ge?Z?he||Ae?d.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-title-blocked-reason",children:Ae?"Fix the Story opening issues above before publishing.":"Set a real reader-facing title above before publishing."}):null:d.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"publish-needs-metadata",children:"Set the genre and language in Story Info before publishing."}):d.jsx("p",{className:"text-[11px] text-muted","data-testid":"publish-blocked-reason",children:j?`Not publishable yet — ${T.summary.toLowerCase()}. Open the episode to fix the flagged cuts.`:`Not ready yet — ${T.summary.toLowerCase()}.`}),B&&d.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-error",children:B})]}),d.jsxs("details",{className:"mt-4 max-w-xl","data-testid":"publish-technical-details",children:[d.jsx("summary",{className:"text-[11px] text-muted cursor-pointer hover:text-foreground",children:"Technical validation details"}),d.jsxs("div",{className:"mt-1 text-[10px] text-muted space-y-0.5",children:[d.jsxs("p",{children:["Episode file: ",d.jsx("span",{className:"font-mono",children:T.file})]}),d.jsxs("p",{children:["State: ",T.state," — ",T.summary]}),d.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 KM(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 XM(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?$o(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=KM(i,s);return a?$o(a,t)||Ip(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 ZM(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 m1="plotlink-panel-ratio",QM=.6,jy=300,If=224,Hf=6;function JM(){try{const e=localStorage.getItem(m1);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return QM}function Ty(e,t){if(t<=0)return e;const i=jy/t,s=1-jy/t;return i>=s?.5:Math.min(s,Math.max(i,e))}function e4({token:e,authFetch:t}){const[i,s]=w.useState(null),[a,o]=w.useState(null),[c,h]=w.useState(null),[p,f]=w.useState(null),[_,g]=w.useState(0),[b,v]=w.useState(""),[S,N]=w.useState(null),[B,E]=w.useState(null),[z,I]=w.useState(JM),[R,H]=w.useState([]),[D,ie]=w.useState(!1),[ue,ve]=w.useState(""),[L,re]=w.useState(""),[F,Y]=w.useState(""),[K,$]=w.useState("English"),[T,q]=w.useState("normal"),[W,ge]=w.useState("claude"),[j,A]=w.useState(null),[Z,k]=w.useState(!1),[oe,ae]=w.useState({}),[V,X]=w.useState({}),[he,_e]=w.useState(new Set),[Ae,Oe]=w.useState(new Set),[He,Re]=w.useState({}),[et,Ge]=w.useState({}),[ot,Pe]=w.useState({}),[Be,Ve]=w.useState({}),[Nt,kt]=w.useState({}),[pi,Me]=w.useState({}),[St,ct]=w.useState(!1),[ee,xe]=w.useState(!0),[Te,Ue]=w.useState(null),Ye=w.useRef(new Map),Kt=w.useRef(new Map),mi=w.useRef(new Map),Lt=w.useRef(new Map),Et=w.useRef(new Set),Gt=w.useRef(0),ut=w.useRef(null),$t=w.useRef(null),wt=w.useRef(!1);w.useEffect(()=>{t("/api/wallet").then(M=>M.ok?M.json():null).then(M=>{M!=null&&M.address&&E(M.address)}).catch(()=>{})},[t]),w.useEffect(()=>{t("/api/agent/readiness").then(M=>M.ok?M.json():null).then(M=>{M&&A(M)}).catch(()=>{})},[t]),w.useEffect(()=>{try{localStorage.setItem(m1,String(z))}catch{}},[z]),w.useEffect(()=>{const M=()=>{if(!$t.current)return;const ne=$t.current.getBoundingClientRect().width-If-Hf;I(me=>Ty(me,ne))};return window.addEventListener("resize",M),M(),()=>window.removeEventListener("resize",M)},[]);const Cn=w.useCallback(()=>{ve(""),re(""),Y(""),q("normal"),ge("claude"),ie(!0)},[]),Yt=w.useCallback(async(M,ne,me,De)=>{const Se=ue.trim();if(!Se)return;const Ne=M==="cartoon"?"codex":De;try{const We=await t("/api/stories/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:Se,description:L.trim()||void 0,language:ne,genre:F||void 0,contentType:M,agentMode:me,agentProvider:Ne})});if(!We.ok)return;const Ke=await We.json();ie(!1),Re(vt=>({...vt,[Ke.name]:M})),Ge(vt=>({...vt,[Ke.name]:ne})),F&&Pe(vt=>({...vt,[Ke.name]:F})),X(vt=>({...vt,[Ke.name]:Ne})),me==="bypass"&&ae(vt=>({...vt,[Ke.name]:!0})),s(Ke.name),o(null)}catch{}},[t,ue,L,F]);w.useEffect(()=>{if(R.length===0)return;const M=setInterval(async()=>{try{const ne=await t("/api/stories");if(!ne.ok)return;const me=await ne.json(),De=new Set(me.stories.filter(Se=>Se.name!=="_example").map(Se=>Se.name));for(const Se of De)if(!Et.current.has(Se)&&R.length>0){const Ne=R[0],We=Ye.current.get(Ne)||"fiction",Ke=Kt.current.get(Ne)||"English",vt=mi.current.get(Ne)||"normal",it=Lt.current.get(Ne)||"claude";let Ze=!1;ut.current&&(Ze=await ut.current(Ne,Se,{contentType:We,language:Ke,agentMode:vt,agentProvider:it}).catch(()=>!1)),Ze&&(H(Ot=>Ot.slice(1)),Ye.current.delete(Ne),Kt.current.delete(Ne),mi.current.delete(Ne),Lt.current.delete(Ne),vt==="bypass"&&ae(Ot=>{const yi={...Ot,[Se]:!0};return delete yi[Ne],yi}),X(Ot=>{const yi={...Ot,[Se]:it};return delete yi[Ne],yi}),t(`/api/stories/${Se}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:We,language:Ke,agentMode:vt,agentProvider:it})}).catch(()=>{})),s(Se),o(null)}Et.current=De}catch{}},3e3);return()=>clearInterval(M)},[t,R]),w.useEffect(()=>{t("/api/stories").then(M=>{if(M.ok)return M.json()}).then(M=>{M!=null&&M.stories&&(Et.current=new Set(M.stories.filter(ne=>ne.name!=="_example").map(ne=>ne.name)))}).catch(()=>{})},[t]);const ni=w.useCallback((M,ne)=>{s(M),o(ne),h(null)},[]),U=w.useRef(null),be=w.useCallback(async M=>{var ne,me,De,Se;U.current=M,s(M),o(null),h(null);try{const Ne=await t(`/api/stories/${M}`);if(Ne.ok&&U.current===M){const We=await Ne.json();if(We.contentType==="cartoon")return;const Ke=We.files||[],it=((ne=Ke.map(Ze=>{var Ot;return{file:Ze.file,num:(Ot=Ze.file.match(/^plot-(\d+)\.md$/))==null?void 0:Ot[1]}}).filter(Ze=>Ze.num!=null).sort((Ze,Ot)=>parseInt(Ot.num)-parseInt(Ze.num))[0])==null?void 0:ne.file)??((me=Ke.find(Ze=>Ze.file==="genesis.md"))==null?void 0:me.file)??((De=Ke.find(Ze=>Ze.file==="structure.md"))==null?void 0:De.file)??((Se=Ke[0])==null?void 0:Se.file);it&&U.current===M&&o(it)}}catch{}},[t]),Ie=w.useCallback(M=>{M.preventDefault(),wt.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const ne=De=>{if(!wt.current||!$t.current)return;const Se=$t.current.getBoundingClientRect(),Ne=Se.width-If-Hf,We=De.clientX-Se.left-If;I(Ty(We/Ne,Ne))},me=()=>{wt.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",ne),window.removeEventListener("mouseup",me)};window.addEventListener("mousemove",ne),window.addEventListener("mouseup",me)},[]),Ee=w.useCallback(async(M,ne,me,De,Se,Ne)=>{var it;f(ne),v("Reading file..."),N(null);let We=!1,Ke=null,vt=!1;try{const Ze=await t(`/api/stories/${M}/${ne}`);if(!Ze.ok)throw new Error("Failed to read file");const Ot=await Ze.json(),yi=He[M];let mn=null,Bi=null;if(ne==="genesis.md")try{const Ft=await t(`/api/stories/${M}/structure.md`);Ft.ok&&(mn=(await Ft.json()).content??null)}catch{}else if(yi==="cartoon"&&ne.match(/^plot-\d+\.md$/))try{const Ft=await t(`/api/stories/${M}/cuts/${ne.replace(/\.md$/,"")}`);Ft.ok&&(Bi=(await Ft.json()).title??null)}catch{}const si=jm({fileName:ne,fileContent:Ot.content,storySlug:M,structureContent:mn,contentType:yi,episodeTitle:Bi});if(yi==="cartoon"&&$o(si,ne))return v(ne==="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(()=>{f(null),v("")},6e3),!1;if(yi==="cartoon"&&ne.match(/^plot-\d+\.md$/)&&!Nm({fileContent:Ot.content,episodeTitle:Bi}))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(()=>{f(null),v("")},6e3),!1;if(yi==="cartoon"&&ne==="genesis.md"){const Ft=wm(Ot.content).blockers;if(Ft.length>0)return v(`Genesis is the reader-facing Story opening — fix it before publishing: ${Ft[0]}`),setTimeout(()=>{f(null),v("")},6e3),!1}let cn;if(ne.match(/^plot-\d+\.md$/)){if(_M(Ot)){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(()=>{f(null),v("")},6e3);return}try{const Ft=await t(`/api/stories/${M}`);if(Ft.ok){const Si=(await Ft.json()).files.find(Or=>Or.file==="genesis.md"&&Or.storylineId);cn=Si==null?void 0:Si.storylineId}}catch{}if(!cn)return v("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),v("")},3e3),!1}v("Checking wallet balance...");try{const Ft=await t("/api/publish/preflight");if(Ft.ok){const $i=await Ft.json();if(vM($i))return N(yM($i)),f(null),v(""),!1}}catch{}v("Publishing...");const On=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:M,fileName:ne,title:si,content:Ot.content,genre:me,language:De,isNsfw:Se,storylineId:cn,...Cy(He,M,cn)?{contentType:Cy(He,M,cn)}:{}})});if(!On.ok){const Ft=await On.json();throw new Error(Ft.error||"Publish failed")}const Lr=(it=On.body)==null?void 0:it.getReader(),vr=new TextDecoder;if(Lr)for(;;){const{done:Ft,value:$i}=await Lr.read();if(Ft)break;const Or=vr.decode($i).split(`
|
|
141
|
+
`).filter(zr=>zr.startsWith("data: "));for(const zr of Or)try{const Zt=JSON.parse(zr.slice(6));if(Zt.step&&v(Zt.message||Zt.step),Zt.step==="done"&&Zt.txHash){if(vt=!0,await t(`/api/stories/${M}/${ne}/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:B})}),g(Zn=>Zn+1),Ne&&ne==="genesis.md"&&Zt.storylineId){v("Uploading cover...");let Zn=null;try{Zn=await pM(t,Zt.storylineId,Ne)}catch{}Zn||(We=!0)}if(yi==="cartoon"&&Zt.storylineId)try{const Zn=ne!=="genesis.md",Pr=`storylineId=${Zt.storylineId}`+(Zn&&Zt.plotIndex!=null?`&plotIndex=${Zt.plotIndex}`:""),Ws=await t(`/api/publish/public-title?${Pr}`);if(Ws.ok){const Ji=await Ws.json(),Ir=Zn?{plots:Ji.plotTitle!=null?[{plotIndex:Zt.plotIndex,title:Ji.plotTitle}]:[]}:{title:Ji.storylineTitle},wi=XM({fileName:ne,detail:Ir,plotIndex:Zt.plotIndex});wi.ok||(Ke=ZM(wi))}}catch{}}}catch{}}Ke&&N(Ke),v(We?"Published, but cover upload failed — set it later from Edit Story.":"Published!")}catch(Ze){const Ot=Ze instanceof Error?Ze.message:"Publish failed";v(`Error: ${Ot}`)}finally{setTimeout(()=>{f(null),v("")},3e3)}return vt&&!We},[t,He,B]),Qe=w.useCallback(M=>{M.startsWith("_new_")&&(H(ne=>ne.filter(me=>me!==M)),Ye.current.delete(M),Kt.current.delete(M),mi.current.delete(M),Lt.current.delete(M),ae(ne=>{if(!(M in ne))return ne;const me={...ne};return delete me[M],me}),X(ne=>{if(!(M in ne))return ne;const me={...ne};return delete me[M],me}))},[]);w.useEffect(()=>{const M=me=>{_e(new Set(me.filter(it=>it.hasStructure).map(it=>it.name))),Oe(new Set(me.filter(it=>it.hasGenesis).map(it=>it.name)));const De={},Se={},Ne={},We={},Ke={},vt={};for(const it of me)De[it.name]=it.contentType||"fiction",Se[it.name]=it.language,Ne[it.name]=it.genre,We[it.name]=it.isNsfw,Ke[it.name]=it.agentProvider,it.title&&(vt[it.name]=it.title);Re(De),Ge(Se),Pe(Ne),Ve(We),Me(Ke),kt(vt)};t("/api/stories").then(me=>me.ok?me.json():null).then(me=>{me!=null&&me.stories&&M(me.stories)}).catch(()=>{});const ne=setInterval(async()=>{try{const me=await t("/api/stories");if(me.ok){const De=await me.json();M(De.stories)}}catch{}},5e3);return()=>clearInterval(ne)},[t]);const rt=!!j&&j.codex.installed&&j.codex.imageGeneration==="enabled",tt=!!j&&!rt,Dt=w.useCallback(async()=>{try{await navigator.clipboard.writeText("codex features enable image_generation"),k(!0),setTimeout(()=>k(!1),2e3)}catch{}},[]),ft=w.useCallback(async()=>{if(!i||i.startsWith("_new_"))return;const M=i;if((await t(`/api/stories/${M}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:"cartoon",agentProvider:"codex"})})).ok){Me(me=>({...me,[M]:"codex"})),X(me=>({...me,[M]:"codex"}));try{const me=await t("/api/stories");if(me.ok){const De=await me.json();if(De!=null&&De.stories){const Se={};for(const Ne of De.stories)Se[Ne.name]=Ne.agentProvider;Me(Se)}}}catch{}}},[t,i]),pt=w.useCallback(M=>{i===M&&(s(null),o(null))},[i]),Di=i?V[i]??pi[i]:void 0,gi=Of(i,He,Ye.current),on=bM(gi,Di,i),Ui=!!i&&gi==="cartoon",Mi=c==="story-info"?"story-info":c==="episodes"?"episodes":c==="publish"?"publish":a==="structure.md"?"whitepaper":a==="genesis.md"?"genesis":a&&/^plot-\d+\.md$/.test(a)?"episodes":"progress",Xn=w.useCallback(M=>{const ne=i;if(ne)switch(M){case"progress":h(null),o(null);break;case"story-info":h("story-info");break;case"episodes":h("episodes");break;case"whitepaper":ni(ne,"structure.md");break;case"genesis":ni(ne,"genesis.md");break;case"publish":h("publish");break}},[i,ni]),xi=w.useCallback((M,ne)=>{const me=i;if(!me)return;const De=Se=>{Gt.current+=1,Ue({action:Se,seq:Gt.current})};switch(M){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(!ne)return;ni(me,ne),De(M);break}},[i,ni]),Xt=w.useCallback(M=>{i&&(M.genre!==void 0&&Pe(ne=>({...ne,[i]:M.genre||void 0})),M.language!==void 0&&Ge(ne=>({...ne,[i]:M.language||void 0})),M.isNsfw!==void 0&&Ve(ne=>({...ne,[i]:M.isNsfw})))},[i]),At=w.useCallback(M=>{ct(M),xe(!M)},[]),ri=St&&!ee;return d.jsxs("div",{ref:$t,className:"h-[calc(100vh-3.5rem)] flex","data-testid":ri?"stories-focused-lettering-mode":"stories-default-layout",children:[!ri&&d.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:d.jsx(zC,{authFetch:t,selectedStory:i,selectedFile:a,onSelectFile:ni,onNewStory:Cn,untitledSessions:R})}),!ri&&d.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${z} 0 0`},children:d.jsx(cN,{token:e,storyName:i,authFetch:t,onSelectStory:be,onDestroySession:Qe,onArchiveStory:pt,confirmedStories:he,renameRef:ut,bypassStories:oe,agentProviders:V,readiness:j,contentType:Of(i,He,Ye.current),needsProviderRepair:on,onRepairProvider:ft})}),!ri&&d.jsx("div",{onMouseDown:Ie,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Hf,cursor:"col-resize",background:"var(--border)"},children:d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),d.jsxs("div",{className:"min-w-0 min-h-0 flex flex-col",style:ri?{flex:"1 0 0"}:{flex:`${1-z} 0 0`},children:[!St&&Ui&&i&&d.jsx(WM,{storyTitle:Nt[i]||i,active:Mi,onSelect:Xn}),d.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:Ui&&c==="story-info"&&i?d.jsx(GM,{storyName:i,authFetch:t,onSaved:Xt}):Ui&&c==="episodes"&&i?d.jsx(YM,{storyName:i,authFetch:t,onOpenFile:ni}):Ui&&c==="publish"&&i?d.jsx(VM,{storyName:i,authFetch:t,onOpenFile:ni,onOpenStoryInfo:()=>h("story-info"),onPublish:Ee,publishingFile:p,genre:ot[i],language:et[i],isNsfw:Be[i],refreshKey:_}):i&&!a?d.jsx(MM,{storyName:i,authFetch:t,onOpenFile:ni}):d.jsx(NM,{storyName:i,fileName:a,authFetch:t,onPublish:Ee,publishingFile:p,walletAddress:B,contentType:Of(i,He,Ye.current)||"fiction",language:i?et[i]:void 0,genre:i?ot[i]:void 0,isNsfw:i?Be[i]:void 0,hasGenesis:i?Ae.has(i):!1,onViewProgress:()=>o(null),onOpenFile:M=>i&&ni(i,M),onViewPublish:()=>h("publish"),focusedLetteringMode:St,focusedLetteringWorkspaceVisible:ee,onFocusedLetteringModeChange:At,onFocusedLetteringWorkspaceVisibleChange:xe,workflowActionRequest:Te,onWorkflowActionHandled:M=>Ue(ne=>(ne==null?void 0:ne.seq)===M?null:ne)})}),!St&&Ui&&i&&d.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:d.jsx("div",{className:"pointer-events-auto rounded-xl border border-border/80 bg-background/95 shadow-lg backdrop-blur",children:d.jsx(RM,{storyName:i,fileName:c===null?a:null,authFetch:t,refreshKey:_,onCoachAction:xi,onOpenStoryInfo:()=>h("story-info")})})}),b&&d.jsx("div",{className:"shrink-0 px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:b}),S&&d.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:[d.jsx("span",{children:S}),d.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"})]})]}),D&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"bg-surface border border-border rounded-lg shadow-lg p-6 max-w-sm w-full space-y-4",children:[d.jsx("h3",{className:"text-sm font-serif font-medium text-foreground text-center",children:"New Story"}),d.jsxs("label",{className:"block space-y-1",children:[d.jsxs("span",{className:"text-[10px] font-medium text-muted",children:["Title ",d.jsx("span",{className:"text-accent",children:"*"})]}),d.jsx("input",{type:"text",value:ue,onChange:M=>ve(M.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Short description (optional)"}),d.jsx("input",{type:"text",value:L,onChange:M=>re(M.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"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Genre (optional)"}),d.jsxs("select",{value:F,onChange:M=>Y(M.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:[d.jsx("option",{value:"",children:"— Select later —"}),hl.map(M=>d.jsx("option",{value:M,children:M},M))]})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Language"}),d.jsx("select",{value:K,onChange:M=>$(M.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:ss.map(M=>d.jsx("option",{value:M,children:M},M))})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Agent mode"}),d.jsxs("select",{value:T,onChange:M=>q(M.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:[d.jsx("option",{value:"normal",children:"Normal (approve each action)"}),d.jsx("option",{value:"bypass",children:"Permissions Bypass (advanced)"})]}),T==="bypass"&&d.jsx("p",{className:"text-[10px] text-amber-700","data-testid":"agent-mode-warning",children:"Less safe: Claude can run actions without per-command approval."})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Provider"}),d.jsxs("select",{value:W,onChange:M=>ge(M.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:[d.jsx("option",{value:"claude",children:"🤖 Claude (default)"}),d.jsx("option",{value:"codex",children:"🎨 Codex"})]}),d.jsx("p",{className:"text-[10px] text-muted","data-testid":"agent-provider-helper",children:W==="codex"?"Codex can generate clean cartoon images directly in the terminal.":"Claude prepares image prompts; you generate and upload clean images externally."})]}),d.jsx("p",{className:"text-xs text-muted text-center",children:"Choose a content type to create"}),!ue.trim()&&d.jsx("p",{className:"text-[10px] text-amber-700 text-center","data-testid":"new-story-title-required",children:"Enter a title to create your story."}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("button",{onClick:()=>Yt("fiction",K,T,W),disabled:!ue.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:[d.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Fiction"}),d.jsx("p",{className:"text-[11px] text-muted",children:"Novels, short stories, poetry"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsxs("button",{onClick:()=>Yt("cartoon",K,T,"codex"),disabled:tt||!ue.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:[d.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Cartoon"}),d.jsx("p",{className:"text-[11px] text-muted",children:"Comics, manga, webtoons"}),d.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."})]}),j&&!j.codex.installed&&d.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."," ",d.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," ","then ",d.jsx("span",{className:"font-mono",children:"codex login"}),") to create cartoons."]}),Eu(j)&&d.jsx("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-auth-unknown",children:Fp}),j&&j.codex.installed&&!Eu(j)&&j.codex.imageGeneration!=="enabled"&&d.jsxs("div",{"data-testid":"cartoon-codex-warning",children:[d.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:"}),d.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[d.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"}),d.jsx("button",{type:"button","data-testid":"copy-codex-enable",onClick:Dt,className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:Z?"Copied!":"Copy"})]})]})]})]}),d.jsx("button",{onClick:()=>ie(!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 t4({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 f=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),_=await f.json();if(!f.ok)throw new Error(_.error||"Wallet creation failed");h(!0)}catch(f){o(f instanceof Error?f.message:"Wallet creation failed")}s(!1)};return w.useEffect(()=>{p()},[]),d.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[d.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),d.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),i&&d.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),d.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&&d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"text-accent text-2xl",children:"✓"}),d.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),d.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 i4({token:e,onLogout:t}){const[i,s]=w.useState("home"),[a,o]=w.useState(0),[c,h]=w.useState(null),p=w.useCallback(async(f,_)=>fetch(f,{..._,headers:{...(_==null?void 0:_.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return w.useEffect(()=>{fetch("/api/health").then(f=>f.json()).then(f=>{f.version&&h(f.version)}).catch(()=>{})},[]),w.useEffect(()=>{async function f(){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{}}f()},[e]),d.jsxs("div",{className:"flex h-screen flex-col",children:[d.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("button",{onClick:()=>{i!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:d.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),d.jsxs("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:["writer",c?` v${c}`:""]})]}),i!=="wallet-setup"&&d.jsxs("nav",{className:"flex items-center gap-4",children:[d.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${i==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),d.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${i==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),d.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${i==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),d.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),d.jsxs("main",{className:"flex-1 min-h-0",children:[i==="home"&&d.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[d.jsxs("div",{className:"text-center space-y-2",children:[d.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),d.jsx("p",{className:"text-muted text-sm",children:"Claude or Codex helps create your story. You publish it on-chain."})]}),d.jsxs("div",{className:"text-center space-y-3",children:[d.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&&d.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),d.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[d.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),d.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[d.jsxs("li",{children:["Open the ",d.jsx("strong",{children:"Stories"})," tab — your writing agent launches in the terminal"]}),d.jsx("li",{children:"Tell the agent your story idea — it brainstorms, outlines, and writes"}),d.jsx("li",{children:"Review the live preview as the agent creates files"}),d.jsxs("li",{children:["Click ",d.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),d.jsxs("li",{children:["Earn 5% royalties on every trade at ",d.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]}),d.jsx("p",{className:"text-[11px] text-muted",children:"Fiction defaults to Claude; cartoon mode uses Codex for clean-image generation."})]}),d.jsx("div",{className:"text-center",children:d.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"})}),d.jsx(My,{token:e})]}),i==="stories"&&d.jsx(e4,{token:e,authFetch:p}),i==="dashboard"&&d.jsx(BC,{token:e}),i==="wallet-setup"&&d.jsx(t4,{token:e,onComplete:()=>s("home")}),i==="settings"&&d.jsx(DC,{token:e,onLogout:t})]})]})}function n4(){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(f=>f.json()).then(f=>s(f.configured)).catch(()=>s(null))},[]),w.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(f=>{f.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async f=>{try{const _=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:f})}),g=await _.json();return _.ok?(localStorage.setItem("ows-token",g.token),t(g.token),null):g.error||"Login failed"}catch{return"Cannot connect to server"}},h=async f=>{try{const _=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:f})}),g=await _.json();return _.ok?(localStorage.setItem("ows-token",g.token),t(g.token),s(!0),null):g.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||i===null?d.jsx("div",{className:"flex h-screen items-center justify-center",children:d.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):i?e?d.jsx(i4,{token:e,onLogout:p}):d.jsx(AC,{onLogin:c}):d.jsx(RC,{onSetup:h})}TC.createRoot(document.getElementById("root")).render(d.jsx(yC.StrictMode,{children:d.jsx(n4,{})}));export{zp as M,To as a,FS as b,WD as c,G3 as d,jo as l,ym as s,VS as t,o4 as v};
|