plotlink-ows 1.0.33 → 1.2.94
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/README.md +4 -0
- package/app/lib/agent-command.ts +85 -0
- package/app/lib/agent-readiness.ts +133 -0
- package/app/lib/apply-schema.ts +55 -0
- package/app/lib/bubble-text.ts +160 -0
- package/app/lib/cartoon-coach.ts +198 -0
- package/app/lib/cartoon-markdown.ts +83 -0
- package/app/lib/cartoon-prompt.ts +122 -0
- package/app/lib/cartoon-readiness.ts +811 -0
- package/app/lib/clean-image-sync.ts +245 -0
- package/app/lib/codex-images.ts +152 -0
- package/app/lib/cut-asset-diagnostics.ts +120 -0
- package/app/lib/cuts.ts +302 -0
- package/app/lib/fonts.ts +109 -0
- package/app/lib/generate-claude-md.ts +8 -1
- package/app/lib/generate-story-instructions.ts +731 -0
- package/app/lib/image-asset-validate.ts +123 -0
- package/app/lib/lettering-status.ts +133 -0
- package/app/lib/overlays.ts +637 -0
- package/app/lib/paths.ts +10 -0
- package/app/lib/public-title.ts +65 -0
- package/app/lib/publish.ts +16 -2
- package/app/lib/story-progress.ts +243 -0
- package/app/lib/terminal-protocol.ts +16 -0
- package/app/lib/terminal-redact.ts +50 -0
- package/app/prisma/schema.sql +25 -0
- package/app/routes/agent.ts +42 -0
- package/app/routes/codex-images.ts +67 -0
- package/app/routes/publish.ts +203 -22
- package/app/routes/stories.ts +961 -5
- package/app/routes/terminal.ts +383 -31
- package/app/server.ts +47 -12
- package/app/vite.config.ts +6 -0
- package/app/web/components/CartoonPreview.tsx +267 -0
- package/app/web/components/CartoonPublishPage.tsx +407 -0
- package/app/web/components/CartoonPublishPreview.tsx +121 -0
- package/app/web/components/CartoonStepGuide.tsx +90 -0
- package/app/web/components/CartoonWorkflowNav.tsx +68 -0
- package/app/web/components/CodexImportPicker.tsx +230 -0
- package/app/web/components/CutListPanel.tsx +1299 -0
- package/app/web/components/EpisodesPage.tsx +80 -0
- package/app/web/components/FinishEpisodePanel.tsx +151 -0
- package/app/web/components/Layout.tsx +7 -4
- package/app/web/components/LetteringEditor.tsx +1141 -0
- package/app/web/components/PreviewPanel.tsx +951 -78
- package/app/web/components/Settings.tsx +63 -0
- package/app/web/components/StoriesPage.tsx +710 -33
- package/app/web/components/StoryBrowser.tsx +22 -14
- package/app/web/components/StoryInfoPage.tsx +266 -0
- package/app/web/components/StoryProgressPanel.tsx +516 -0
- package/app/web/components/TerminalPanel.tsx +233 -11
- package/app/web/components/WorkflowCoach.tsx +128 -0
- package/app/web/components/asset-image.tsx +114 -0
- package/app/web/components/asset-test-utils.ts +44 -0
- package/app/web/components/export-cut.ts +320 -0
- package/app/web/dist/assets/export-cut-nKQ_n2-J.js +1 -0
- package/app/web/dist/assets/index-BAZGwVwj.js +143 -0
- package/app/web/dist/assets/index-DoXH2OlP.css +32 -0
- package/app/web/dist/index.html +2 -2
- package/app/web/lib/cartoon-publish-summary.ts +43 -0
- package/app/web/lib/codex-import.ts +94 -0
- package/app/web/lib/image-compress.ts +53 -0
- package/app/web/lib/import-image.ts +58 -0
- package/app/web/lib/publish-helpers.ts +385 -0
- package/app/web/lib/upload-retry.ts +130 -0
- package/app/web/lib/verify-public-title.ts +105 -0
- package/app/web/styles.css +9 -0
- package/bin/plotlink-ows.js +53 -16
- package/bin/startup-plan.cjs +58 -0
- package/lib/genres.ts +92 -0
- package/package.json +60 -20
- package/scripts/gen-schema-sql.mjs +49 -0
- package/scripts/package-hygiene.mjs +116 -0
- package/scripts/preflight.mjs +173 -0
- package/scripts/start-smoke.mjs +128 -0
- package/app/node_modules/.prisma/local-client/client.d.ts +0 -1
- package/app/node_modules/.prisma/local-client/client.js +0 -5
- package/app/node_modules/.prisma/local-client/default.d.ts +0 -1
- package/app/node_modules/.prisma/local-client/default.js +0 -5
- package/app/node_modules/.prisma/local-client/edge.d.ts +0 -1
- package/app/node_modules/.prisma/local-client/edge.js +0 -184
- package/app/node_modules/.prisma/local-client/index-browser.js +0 -173
- package/app/node_modules/.prisma/local-client/index.d.ts +0 -3304
- package/app/node_modules/.prisma/local-client/index.js +0 -207
- package/app/node_modules/.prisma/local-client/libquery_engine-darwin-arm64.dylib.node +0 -0
- package/app/node_modules/.prisma/local-client/package.json +0 -183
- package/app/node_modules/.prisma/local-client/query_engine_bg.js +0 -2
- package/app/node_modules/.prisma/local-client/query_engine_bg.wasm +0 -0
- package/app/node_modules/.prisma/local-client/runtime/edge-esm.js +0 -35
- package/app/node_modules/.prisma/local-client/runtime/edge.js +0 -35
- package/app/node_modules/.prisma/local-client/runtime/index-browser.d.ts +0 -370
- package/app/node_modules/.prisma/local-client/runtime/index-browser.js +0 -17
- package/app/node_modules/.prisma/local-client/runtime/library.d.ts +0 -3982
- package/app/node_modules/.prisma/local-client/runtime/library.js +0 -147
- package/app/node_modules/.prisma/local-client/runtime/react-native.js +0 -84
- package/app/node_modules/.prisma/local-client/runtime/wasm-compiler-edge.js +0 -85
- package/app/node_modules/.prisma/local-client/runtime/wasm-engine-edge.js +0 -38
- package/app/node_modules/.prisma/local-client/schema.prisma +0 -21
- package/app/node_modules/.prisma/local-client/wasm-edge-light-loader.mjs +0 -5
- package/app/node_modules/.prisma/local-client/wasm-worker-loader.mjs +0 -5
- package/app/node_modules/.prisma/local-client/wasm.d.ts +0 -1
- package/app/node_modules/.prisma/local-client/wasm.js +0 -191
- package/app/web/dist/assets/index-B-2Ft7Yv.css +0 -32
- package/app/web/dist/assets/index-DxATSk7X.js +0 -134
- package/packages/cli/node_modules/commander/LICENSE +0 -22
- package/packages/cli/node_modules/commander/Readme.md +0 -1149
- package/packages/cli/node_modules/commander/esm.mjs +0 -16
- package/packages/cli/node_modules/commander/index.js +0 -24
- package/packages/cli/node_modules/commander/lib/argument.js +0 -149
- package/packages/cli/node_modules/commander/lib/command.js +0 -2662
- package/packages/cli/node_modules/commander/lib/error.js +0 -39
- package/packages/cli/node_modules/commander/lib/help.js +0 -709
- package/packages/cli/node_modules/commander/lib/option.js +0 -367
- package/packages/cli/node_modules/commander/lib/suggestSimilar.js +0 -101
- package/packages/cli/node_modules/commander/package-support.json +0 -16
- package/packages/cli/node_modules/commander/package.json +0 -82
- package/packages/cli/node_modules/commander/typings/esm.d.mts +0 -3
- package/packages/cli/node_modules/commander/typings/index.d.ts +0 -1045
- package/packages/cli/node_modules/resolve-from/index.d.ts +0 -31
- package/packages/cli/node_modules/resolve-from/index.js +0 -47
- package/packages/cli/node_modules/resolve-from/license +0 -9
- package/packages/cli/node_modules/resolve-from/package.json +0 -36
- package/packages/cli/node_modules/resolve-from/readme.md +0 -72
- package/packages/cli/node_modules/tsup/LICENSE +0 -21
- package/packages/cli/node_modules/tsup/README.md +0 -75
- package/packages/cli/node_modules/tsup/assets/cjs_shims.js +0 -13
- package/packages/cli/node_modules/tsup/assets/esm_shims.js +0 -9
- package/packages/cli/node_modules/tsup/assets/package.json +0 -3
- package/packages/cli/node_modules/tsup/dist/chunk-DI5BO6XE.js +0 -153
- package/packages/cli/node_modules/tsup/dist/chunk-JZ25TPTY.js +0 -42
- package/packages/cli/node_modules/tsup/dist/chunk-PEEXUWMS.js +0 -6
- package/packages/cli/node_modules/tsup/dist/chunk-TWFEYLU4.js +0 -352
- package/packages/cli/node_modules/tsup/dist/chunk-VGC3FXLU.js +0 -203
- package/packages/cli/node_modules/tsup/dist/cli-default.js +0 -12
- package/packages/cli/node_modules/tsup/dist/cli-main.js +0 -8
- package/packages/cli/node_modules/tsup/dist/cli-node.js +0 -14
- package/packages/cli/node_modules/tsup/dist/index.d.ts +0 -511
- package/packages/cli/node_modules/tsup/dist/index.js +0 -1711
- package/packages/cli/node_modules/tsup/dist/rollup.js +0 -6949
- package/packages/cli/node_modules/tsup/package.json +0 -99
- package/packages/cli/node_modules/tsup/schema.json +0 -362
- package/public/screenshot-1.png +0 -0
- package/public/screenshot-2.png +0 -0
- package/public/screenshot-3.png +0 -0
- package/scripts/e2e-verify.ts +0 -1100
|
@@ -0,0 +1,143 @@
|
|
|
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 Du(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},to={};/**
|
|
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 Kx;function Qw(){if(Kx)return to;Kx=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 to.Fragment=t,to.jsx=i,to.jsxs=i,to}var Vx;function Jw(){return Vx||(Vx=1,qd.exports=Qw()),qd.exports}var f=Jw(),Wd={exports:{}},et={};/**
|
|
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 Xx;function eC(){if(Xx)return et;Xx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function v(R){return R===null||typeof R!="object"?null:(R=b&&R[b]||R["@@iterator"],typeof R=="function"?R:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,A={};function T(R,Y,w){this.props=R,this.context=Y,this.refs=A,this.updater=w||y}T.prototype.isReactComponent={},T.prototype.setState=function(R,Y){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,Y,"setState")},T.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function L(){}L.prototype=T.prototype;function O(R,Y,w){this.props=R,this.context=Y,this.refs=A,this.updater=w||y}var J=O.prototype=new L;J.constructor=O,E(J,T.prototype),J.isPureReactComponent=!0;var $=Array.isArray;function M(){}var X={H:null,A:null,T:null,S:null},he=Object.prototype.hasOwnProperty;function ye(R,Y,w){var ae=w.ref;return{$$typeof:e,type:R,key:Y,ref:ae!==void 0?ae:null,props:w}}function U(R,Y){return ye(R.type,Y,R.props)}function se(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function W(R){var Y={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(w){return Y[w]})}var G=/\/+/g;function Z(R,Y){return typeof R=="object"&&R!==null&&R.key!=null?W(""+R.key):Y.toString(36)}function I(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(M,M):(R.status="pending",R.then(function(Y){R.status==="pending"&&(R.status="fulfilled",R.value=Y)},function(Y){R.status==="pending"&&(R.status="rejected",R.reason=Y)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function j(R,Y,w,ae,ie){var oe=typeof R;(oe==="undefined"||oe==="boolean")&&(R=null);var F=!1;if(R===null)F=!0;else switch(oe){case"bigint":case"string":case"number":F=!0;break;case"object":switch(R.$$typeof){case e:case t:F=!0;break;case x:return F=R._init,j(F(R._payload),Y,w,ae,ie)}}if(F)return ie=ie(R),F=ae===""?"."+Z(R,0):ae,$(ie)?(w="",F!=null&&(w=F.replace(G,"$&/")+"/"),j(ie,Y,w,"",function(De){return De})):ie!=null&&(se(ie)&&(ie=U(ie,w+(ie.key==null||R&&R.key===ie.key?"":(""+ie.key).replace(G,"$&/")+"/")+F)),Y.push(ie)),1;F=0;var ue=ae===""?".":ae+":";if($(R))for(var be=0;be<R.length;be++)ae=R[be],oe=ue+Z(ae,be),F+=j(ae,Y,w,oe,ie);else if(be=v(R),typeof be=="function")for(R=be.call(R),be=0;!(ae=R.next()).done;)ae=ae.value,oe=ue+Z(ae,be++),F+=j(ae,Y,w,oe,ie);else if(oe==="object"){if(typeof R.then=="function")return j(I(R),Y,w,ae,ie);throw Y=String(R),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return F}function z(R,Y,w){if(R==null)return R;var ae=[],ie=0;return j(R,ae,"","",function(oe){return Y.call(w,oe,ie++)}),ae}function B(R){if(R._status===-1){var Y=R._result;Y=Y(),Y.then(function(w){(R._status===0||R._status===-1)&&(R._status=1,R._result=w)},function(w){(R._status===0||R._status===-1)&&(R._status=2,R._result=w)}),R._status===-1&&(R._status=0,R._result=Y)}if(R._status===1)return R._result.default;throw R._result}var _e=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},N={map:z,forEach:function(R,Y,w){z(R,function(){Y.apply(this,arguments)},w)},count:function(R){var Y=0;return z(R,function(){Y++}),Y},toArray:function(R){return z(R,function(Y){return Y})||[]},only:function(R){if(!se(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return et.Activity=_,et.Children=N,et.Component=T,et.Fragment=i,et.Profiler=a,et.PureComponent=O,et.StrictMode=s,et.Suspense=p,et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=X,et.__COMPILER_RUNTIME={__proto__:null,c:function(R){return X.H.useMemoCache(R)}},et.cache=function(R){return function(){return R.apply(null,arguments)}},et.cacheSignal=function(){return null},et.cloneElement=function(R,Y,w){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var ae=E({},R.props),ie=R.key;if(Y!=null)for(oe in Y.key!==void 0&&(ie=""+Y.key),Y)!he.call(Y,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&Y.ref===void 0||(ae[oe]=Y[oe]);var oe=arguments.length-2;if(oe===1)ae.children=w;else if(1<oe){for(var F=Array(oe),ue=0;ue<oe;ue++)F[ue]=arguments[ue+2];ae.children=F}return ye(R.type,ie,ae)},et.createContext=function(R){return R={$$typeof:c,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:o,_context:R},R},et.createElement=function(R,Y,w){var ae,ie={},oe=null;if(Y!=null)for(ae in Y.key!==void 0&&(oe=""+Y.key),Y)he.call(Y,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(ie[ae]=Y[ae]);var F=arguments.length-2;if(F===1)ie.children=w;else if(1<F){for(var ue=Array(F),be=0;be<F;be++)ue[be]=arguments[be+2];ie.children=ue}if(R&&R.defaultProps)for(ae in F=R.defaultProps,F)ie[ae]===void 0&&(ie[ae]=F[ae]);return ye(R,oe,ie)},et.createRef=function(){return{current:null}},et.forwardRef=function(R){return{$$typeof:h,render:R}},et.isValidElement=se,et.lazy=function(R){return{$$typeof:x,_payload:{_status:-1,_result:R},_init:B}},et.memo=function(R,Y){return{$$typeof:d,type:R,compare:Y===void 0?null:Y}},et.startTransition=function(R){var Y=X.T,w={};X.T=w;try{var ae=R(),ie=X.S;ie!==null&&ie(w,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(M,_e)}catch(oe){_e(oe)}finally{Y!==null&&w.types!==null&&(Y.types=w.types),X.T=Y}},et.unstable_useCacheRefresh=function(){return X.H.useCacheRefresh()},et.use=function(R){return X.H.use(R)},et.useActionState=function(R,Y,w){return X.H.useActionState(R,Y,w)},et.useCallback=function(R,Y){return X.H.useCallback(R,Y)},et.useContext=function(R){return X.H.useContext(R)},et.useDebugValue=function(){},et.useDeferredValue=function(R,Y){return X.H.useDeferredValue(R,Y)},et.useEffect=function(R,Y){return X.H.useEffect(R,Y)},et.useEffectEvent=function(R){return X.H.useEffectEvent(R)},et.useId=function(){return X.H.useId()},et.useImperativeHandle=function(R,Y,w){return X.H.useImperativeHandle(R,Y,w)},et.useInsertionEffect=function(R,Y){return X.H.useInsertionEffect(R,Y)},et.useLayoutEffect=function(R,Y){return X.H.useLayoutEffect(R,Y)},et.useMemo=function(R,Y){return X.H.useMemo(R,Y)},et.useOptimistic=function(R,Y){return X.H.useOptimistic(R,Y)},et.useReducer=function(R,Y,w){return X.H.useReducer(R,Y,w)},et.useRef=function(R){return X.H.useRef(R)},et.useState=function(R){return X.H.useState(R)},et.useSyncExternalStore=function(R,Y,w){return X.H.useSyncExternalStore(R,Y,w)},et.useTransition=function(){return X.H.useTransition()},et.version="19.2.3",et}var Zx;function Lp(){return Zx||(Zx=1,Wd.exports=eC()),Wd.exports}var C=Lp();const tC=Du(C);var Gd={exports:{}},io={},Yd={exports:{}},Kd={};/**
|
|
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 Qx;function iC(){return Qx||(Qx=1,(function(e){function t(j,z){var B=j.length;j.push(z);e:for(;0<B;){var _e=B-1>>>1,N=j[_e];if(0<a(N,z))j[_e]=z,j[B]=N,B=_e;else break e}}function i(j){return j.length===0?null:j[0]}function s(j){if(j.length===0)return null;var z=j[0],B=j.pop();if(B!==z){j[0]=B;e:for(var _e=0,N=j.length,R=N>>>1;_e<R;){var Y=2*(_e+1)-1,w=j[Y],ae=Y+1,ie=j[ae];if(0>a(w,B))ae<N&&0>a(ie,w)?(j[_e]=ie,j[ae]=B,_e=ae):(j[_e]=w,j[Y]=B,_e=Y);else if(ae<N&&0>a(ie,B))j[_e]=ie,j[ae]=B,_e=ae;else break e}}return z}function a(j,z){var B=j.sortIndex-z.sortIndex;return B!==0?B:j.id-z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var p=[],d=[],x=1,_=null,b=3,v=!1,y=!1,E=!1,A=!1,T=typeof setTimeout=="function"?setTimeout:null,L=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function J(j){for(var z=i(d);z!==null;){if(z.callback===null)s(d);else if(z.startTime<=j)s(d),z.sortIndex=z.expirationTime,t(p,z);else break;z=i(d)}}function $(j){if(E=!1,J(j),!y)if(i(p)!==null)y=!0,M||(M=!0,W());else{var z=i(d);z!==null&&I($,z.startTime-j)}}var M=!1,X=-1,he=5,ye=-1;function U(){return A?!0:!(e.unstable_now()-ye<he)}function se(){if(A=!1,M){var j=e.unstable_now();ye=j;var z=!0;try{e:{y=!1,E&&(E=!1,L(X),X=-1),v=!0;var B=b;try{t:{for(J(j),_=i(p);_!==null&&!(_.expirationTime>j&&U());){var _e=_.callback;if(typeof _e=="function"){_.callback=null,b=_.priorityLevel;var N=_e(_.expirationTime<=j);if(j=e.unstable_now(),typeof N=="function"){_.callback=N,J(j),z=!0;break t}_===i(p)&&s(p),J(j)}else s(p);_=i(p)}if(_!==null)z=!0;else{var R=i(d);R!==null&&I($,R.startTime-j),z=!1}}break e}finally{_=null,b=B,v=!1}z=void 0}}finally{z?W():M=!1}}}var W;if(typeof O=="function")W=function(){O(se)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,Z=G.port2;G.port1.onmessage=se,W=function(){Z.postMessage(null)}}else W=function(){T(se,0)};function I(j,z){X=T(function(){j(e.unstable_now())},z)}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(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):he=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(j){switch(b){case 1:case 2:case 3:var z=3;break;default:z=b}var B=b;b=z;try{return j()}finally{b=B}},e.unstable_requestPaint=function(){A=!0},e.unstable_runWithPriority=function(j,z){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var B=b;b=j;try{return z()}finally{b=B}},e.unstable_scheduleCallback=function(j,z,B){var _e=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?_e+B:_e):B=_e,j){case 1:var N=-1;break;case 2:N=250;break;case 5:N=1073741823;break;case 4:N=1e4;break;default:N=5e3}return N=B+N,j={id:x++,callback:z,priorityLevel:j,startTime:B,expirationTime:N,sortIndex:-1},B>_e?(j.sortIndex=B,t(d,j),i(p)===null&&j===i(d)&&(E?(L(X),X=-1):E=!0,I($,B-_e))):(j.sortIndex=N,t(p,j),y||v||(y=!0,M||(M=!0,W()))),j},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(j){var z=b;return function(){var B=b;b=z;try{return j.apply(this,arguments)}finally{b=B}}}})(Kd)),Kd}var Jx;function nC(){return Jx||(Jx=1,Yd.exports=iC()),Yd.exports}var Vd={exports:{}},Xi={};/**
|
|
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 eb;function rC(){if(eb)return Xi;eb=1;var e=Lp();function t(p){var d="https://react.dev/errors/"+p;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)d+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+p+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var s={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(p,d,x){var _=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:_==null?null:""+_,children:p,containerInfo:d,implementation:x}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,d){if(p==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return Xi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,Xi.createPortal=function(p,d){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(t(299));return o(p,d,null,x)},Xi.flushSync=function(p){var d=c.T,x=s.p;try{if(c.T=null,s.p=2,p)return p()}finally{c.T=d,s.p=x,s.d.f()}},Xi.preconnect=function(p,d){typeof p=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,s.d.C(p,d))},Xi.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},Xi.preinit=function(p,d){if(typeof p=="string"&&d&&typeof d.as=="string"){var x=d.as,_=h(x,d.crossOrigin),b=typeof d.integrity=="string"?d.integrity:void 0,v=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;x==="style"?s.d.S(p,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:_,integrity:b,fetchPriority:v}):x==="script"&&s.d.X(p,{crossOrigin:_,integrity:b,fetchPriority:v,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},Xi.preinitModule=function(p,d){if(typeof p=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var x=h(d.as,d.crossOrigin);s.d.M(p,{crossOrigin:x,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&s.d.M(p)},Xi.preload=function(p,d){if(typeof p=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var x=d.as,_=h(x,d.crossOrigin);s.d.L(p,x,{crossOrigin:_,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},Xi.preloadModule=function(p,d){if(typeof p=="string")if(d){var x=h(d.as,d.crossOrigin);s.d.m(p,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:x,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else s.d.m(p)},Xi.requestFormReset=function(p){s.d.r(p)},Xi.unstable_batchedUpdates=function(p,d){return p(d)},Xi.useFormState=function(p,d,x){return c.H.useFormState(p,d,x)},Xi.useFormStatus=function(){return c.H.useHostTransitionStatus()},Xi.version="19.2.3",Xi}var tb;function sC(){if(tb)return Vd.exports;tb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vd.exports=rC(),Vd.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 ib;function aC(){if(ib)return io;ib=1;var e=nC(),t=Lp(),i=sC();function s(n){var r="https://react.dev/errors/"+n;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function o(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function c(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function h(n){if(n.tag===31){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function p(n){if(o(n)!==n)throw Error(s(188))}function d(n){var r=n.alternate;if(!r){if(r=o(n),r===null)throw Error(s(188));return r!==n?null:n}for(var l=n,u=r;;){var m=l.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){l=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===l)return p(m),n;if(g===u)return p(m),r;g=g.sibling}throw Error(s(188))}if(l.return!==u.return)l=m,u=g;else{for(var S=!1,k=m.child;k;){if(k===l){S=!0,l=m,u=g;break}if(k===u){S=!0,u=m,l=g;break}k=k.sibling}if(!S){for(k=g.child;k;){if(k===l){S=!0,l=g,u=m;break}if(k===u){S=!0,u=g,l=m;break}k=k.sibling}if(!S)throw Error(s(189))}}if(l.alternate!==u)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:r}function x(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n;for(n=n.child;n!==null;){if(r=x(n),r!==null)return r;n=n.sibling}return null}var _=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),O=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),he=Symbol.for("react.lazy"),ye=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),se=Symbol.iterator;function W(n){return n===null||typeof n!="object"?null:(n=se&&n[se]||n["@@iterator"],typeof n=="function"?n:null)}var G=Symbol.for("react.client.reference");function Z(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===G?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case E:return"Fragment";case T:return"Profiler";case A:return"StrictMode";case $:return"Suspense";case M:return"SuspenseList";case ye:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case y:return"Portal";case O:return n.displayName||"Context";case L:return(n._context.displayName||"Context")+".Consumer";case J:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case X:return r=n.displayName||null,r!==null?r:Z(n.type)||"Memo";case he:r=n._payload,n=n._init;try{return Z(n(r))}catch{}}return null}var I=Array.isArray,j=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},_e=[],N=-1;function R(n){return{current:n}}function Y(n){0>N||(n.current=_e[N],_e[N]=null,N--)}function w(n,r){N++,_e[N]=n.current,n.current=r}var ae=R(null),ie=R(null),oe=R(null),F=R(null);function ue(n,r){switch(w(oe,r),w(ie,n),w(ae,null),r.nodeType){case 9:case 11:n=(n=r.documentElement)&&(n=n.namespaceURI)?_x(n):0;break;default:if(n=r.tagName,r=r.namespaceURI)r=_x(r),n=xx(r,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y(ae),w(ae,n)}function be(){Y(ae),Y(ie),Y(oe)}function De(n){n.memoizedState!==null&&w(F,n);var r=ae.current,l=xx(r,n.type);r!==l&&(w(ie,n),w(ae,l))}function Ee(n){ie.current===n&&(Y(ae),Y(ie)),F.current===n&&(Y(F),Zl._currentValue=B)}var Be,je;function Ze(n){if(Be===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);Be=r&&r[1]||"",je=-1<l.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+Be+n+je}var we=!1;function tt(n,r){if(!n||we)return"";we=!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(ne){var Q=ne}Reflect.construct(n,[],fe)}else{try{fe.call()}catch(ne){Q=ne}n.call(fe.prototype)}}else{try{throw Error()}catch(ne){Q=ne}(fe=n())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(ne){if(ne&&Q&&typeof ne.stack=="string")return[ne.stack,Q.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=u.DetermineComponentFrameRoot(),S=g[0],k=g[1];if(S&&k){var D=S.split(`
|
|
44
|
+
`),V=k.split(`
|
|
45
|
+
`);for(m=u=0;u<D.length&&!D[u].includes("DetermineComponentFrameRoot");)u++;for(;m<V.length&&!V[m].includes("DetermineComponentFrameRoot");)m++;if(u===D.length||m===V.length)for(u=D.length-1,m=V.length-1;1<=u&&0<=m&&D[u]!==V[m];)m--;for(;1<=u&&0<=m;u--,m--)if(D[u]!==V[m]){if(u!==1||m!==1)do if(u--,m--,0>m||D[u]!==V[m]){var le=`
|
|
46
|
+
`+D[u].replace(" at new "," at ");return n.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",n.displayName)),le}while(1<=u&&0<=m);break}}}finally{we=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?Ze(l):""}function mt(n,r){switch(n.tag){case 26:case 27:case 5:return Ze(n.type);case 16:return Ze("Lazy");case 13:return n.child!==r&&r!==null?Ze("Suspense Fallback"):Ze("Suspense");case 19:return Ze("SuspenseList");case 0:case 15:return tt(n.type,!1);case 11:return tt(n.type.render,!1);case 1:return tt(n.type,!0);case 31:return Ze("Activity");default:return""}}function Ge(n){try{var r="",l=null;do r+=mt(n,l),l=n,n=n.return;while(n);return r}catch(u){return`
|
|
47
|
+
Error generating stack: `+u.message+`
|
|
48
|
+
`+u.stack}}var Ae=Object.prototype.hasOwnProperty,Ve=e.unstable_scheduleCallback,Mt=e.unstable_cancelCallback,zt=e.unstable_shouldYield,ai=e.unstable_requestPaint,wt=e.unstable_now,hi=e.unstable_getCurrentPriorityLevel,re=e.unstable_ImmediatePriority,xe=e.unstable_UserBlockingPriority,Pe=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,Qe=e.unstable_IdlePriority,H=e.log,ge=e.unstable_setDisableYieldValue,Te=null,me=null;function He(n){if(typeof H=="function"&&ge(n),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(Te,n)}catch{}}var Oe=Math.clz32?Math.clz32:Dt,ut=Math.log,it=Math.LN2;function Dt(n){return n>>>=0,n===0?32:31-(ut(n)/it|0)|0}var Bt=256,di=262144,kt=4194304;function Ci(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 fi(n,r,l){var u=n.pendingLanes;if(u===0)return 0;var m=0,g=n.suspendedLanes,S=n.pingedLanes;n=n.warmLanes;var k=u&134217727;return k!==0?(u=k&~g,u!==0?m=Ci(u):(S&=k,S!==0?m=Ci(S):l||(l=k&~n,l!==0&&(m=Ci(l))))):(k=u&~g,k!==0?m=Ci(k):S!==0?m=Ci(S):l||(l=u&~n,l!==0&&(m=Ci(l)))),m===0?0:r!==0&&r!==m&&(r&g)===0&&(g=m&-m,l=r&-r,g>=l||g===32&&(l&4194048)!==0)?r:m}function Gt(n,r){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&r)===0}function fn(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 de(){var n=kt;return kt<<=1,(kt&62914560)===0&&(kt=4194304),n}function Re(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function We(n,r){n.pendingLanes|=r,r!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function st(n,r,l,u,m,g){var S=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 k=n.entanglements,D=n.expirationTimes,V=n.hiddenUpdates;for(l=S&~l;0<l;){var le=31-Oe(l),fe=1<<le;k[le]=0,D[le]=-1;var Q=V[le];if(Q!==null)for(V[le]=null,le=0;le<Q.length;le++){var ne=Q[le];ne!==null&&(ne.lane&=-536870913)}l&=~fe}u!==0&&nt(n,u,0),g!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=g&~(S&~r))}function nt(n,r,l){n.pendingLanes|=r,n.suspendedLanes&=~r;var u=31-Oe(r);n.entangledLanes|=r,n.entanglements[u]=n.entanglements[u]|1073741824|l&261930}function te(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-Oe(l),m=1<<u;m&r|n[u]&r&&(n[u]|=r),l&=~m}}function Ce(n,r){var l=r&-r;return l=(l&42)!==0?1:Le(l),(l&(n.suspendedLanes|r))!==0?0:l}function Le(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 ft(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function bt(){var n=z.p;return n!==0?n:(n=window.event,n===void 0?32:Ux(n.type))}function pt(n,r){var l=z.p;try{return z.p=n,r()}finally{z.p=l}}var Tt=Math.random().toString(36).slice(2),Je="__reactFiber$"+Tt,ot="__reactProps$"+Tt,Xe="__reactContainer$"+Tt,Et="__reactEvents$"+Tt,$t="__reactListeners$"+Tt,pi="__reactHandles$"+Tt,fr="__reactResources$"+Tt,pn="__reactMarker$"+Tt;function jr(n){delete n[Je],delete n[ot],delete n[Et],delete n[$t],delete n[pi]}function mi(n){var r=n[Je];if(r)return r;for(var l=n.parentNode;l;){if(r=l[Xe]||l[Je]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=kx(n);n!==null;){if(l=n[Je])return l;n=kx(n)}return r}n=l,l=n.parentNode}return null}function li(n){if(n=n[Je]||n[Xe]){var r=n.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return n}return null}function Pn(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n.stateNode;throw Error(s(33))}function nr(n){var r=n[fr];return r||(r=n[fr]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function ct(n){n[pn]=!0}var In=new Set,rr={};function tn(n,r){Hn(n,r),Hn(n+"Capture",r)}function Hn(n,r){for(rr[n]=r,n=0;n<r.length;n++)In.add(r[n])}var Xt=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]*$"),Un={},ts={};function ha(n){return Ae.call(ts,n)?!0:Ae.call(Un,n)?!1:Xt.test(n)?ts[n]=!0:(Un[n]=!0,!1)}function pr(n,r,l){if(ha(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 Ar(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 nn(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 kn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function da(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ki(n,r,l){var u=Object.getOwnPropertyDescriptor(n.constructor.prototype,r);if(!n.hasOwnProperty(r)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var m=u.get,g=u.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(n,r,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function sr(n){if(!n._valueTracker){var r=da(n)?"checked":"value";n._valueTracker=Ki(n,r,""+n[r])}}function Vi(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return n&&(u=da(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function rn(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 fa=/[\n"\\]/g;function ki(n){return n.replace(fa,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function pa(n,r,l,u,m,g,S,k){n.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?n.type=S:n.removeAttribute("type"),r!=null?S==="number"?(r===0&&n.value===""||n.value!=r)&&(n.value=""+kn(r)):n.value!==""+kn(r)&&(n.value=""+kn(r)):S!=="submit"&&S!=="reset"||n.removeAttribute("value"),r!=null?ga(n,S,kn(r)):l!=null?ga(n,S,kn(l)):u!=null&&n.removeAttribute("value"),m==null&&g!=null&&(n.defaultChecked=!!g),m!=null&&(n.checked=m&&typeof m!="function"&&typeof m!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?n.name=""+kn(k):n.removeAttribute("name")}function ma(n,r,l,u,m,g,S,k){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(n.type=g),r!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){sr(n);return}l=l!=null?""+kn(l):"",r=r!=null?""+kn(r):l,k||r===n.value||(n.value=r),n.defaultValue=r}u=u??m,u=typeof u!="function"&&typeof u!="symbol"&&!!u,n.checked=k?n.checked:!!u,n.defaultChecked=!!u,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(n.name=S),sr(n)}function ga(n,r,l){r==="number"&&rn(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function $n(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=""+kn(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 _a(n,r,l){if(r!=null&&(r=""+kn(r),r!==n.value&&(n.value=r),l==null)){n.defaultValue!==r&&(n.defaultValue=r);return}n.defaultValue=l!=null?""+kn(l):""}function fl(n,r,l,u){if(r==null){if(u!=null){if(l!=null)throw Error(s(92));if(I(u)){if(1<u.length)throw Error(s(93));u=u[0]}l=u}l==null&&(l=""),r=l}l=kn(r),n.defaultValue=l,u=n.textContent,u===l&&u!==""&&u!==null&&(n.value=u),sr(n)}function Fn(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var Po=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 Io(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||Po.has(r)?r==="float"?n.cssFloat=l:n[r]=(""+l).trim():n[r]=l+"px"}function Ho(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&&Io(n,m,u)}else for(var g in r)r.hasOwnProperty(g)&&Io(n,g,r[g])}function xa(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 pl=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"]]),Wu=/^[\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 ba(n){return Wu.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function sn(){}var is=null;function ml(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ar=null,Rr=null;function ee(n){var r=li(n);if(r&&(n=r.stateNode)){var l=n[ot]||null;e:switch(n=r.stateNode,r.type){case"input":if(pa(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="'+ki(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==n&&u.form===n.form){var m=u[ot]||null;if(!m)throw Error(s(90));pa(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&&Vi(u)}break e;case"textarea":_a(n,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&$n(n,!!l.multiple,r,!1)}}}var Se=!1;function Ne(n,r,l){if(Se)return n(r,l);Se=!0;try{var u=n(r);return u}finally{if(Se=!1,(ar!==null||Rr!==null)&&(Ec(),ar&&(r=ar,n=Rr,Rr=ar=null,ee(r),n)))for(r=0;r<n.length;r++)ee(n[r])}}function Ke(n,r){var l=n.stateNode;if(l===null)return null;var u=l[ot]||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 Nt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gi=!1;if(Nt)try{var En={};Object.defineProperty(En,"passive",{get:function(){gi=!0}}),window.addEventListener("test",En,En),window.removeEventListener("test",En,En)}catch{gi=!1}var an=null,lr=null,Ls=null;function xm(){if(Ls)return Ls;var n,r=lr,l=r.length,u,m="value"in an?an.value:an.textContent,g=m.length;for(n=0;n<l&&r[n]===m[n];n++);var S=l-n;for(u=1;u<=S&&r[l-u]===m[g-u];u++);return Ls=m.slice(n,1<u?1-u:void 0)}function Uo(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 $o(){return!0}function bm(){return!1}function mn(n){function r(l,u,m,g,S){this._reactName=l,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var k in n)n.hasOwnProperty(k)&&(l=n[k],this[k]=l?l(g):g[k]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?$o:bm,this.isPropagationStopped=bm,this}return _(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=$o)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=$o)},persist:function(){},isPersistent:$o}),r}var Os={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fo=mn(Os),gl=_({},Os,{view:0,detail:0}),XS=mn(gl),Gu,Yu,_l,qo=_({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vu,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!==_l&&(_l&&n.type==="mousemove"?(Gu=n.screenX-_l.screenX,Yu=n.screenY-_l.screenY):Yu=Gu=0,_l=n),Gu)},movementY:function(n){return"movementY"in n?n.movementY:Yu}}),vm=mn(qo),ZS=_({},qo,{dataTransfer:0}),QS=mn(ZS),JS=_({},gl,{relatedTarget:0}),Ku=mn(JS),e1=_({},Os,{animationName:0,elapsedTime:0,pseudoElement:0}),t1=mn(e1),i1=_({},Os,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),n1=mn(i1),r1=_({},Os,{data:0}),ym=mn(r1),s1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},a1={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"},l1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function o1(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=l1[n])?!!r[n]:!1}function Vu(){return o1}var c1=_({},gl,{key:function(n){if(n.key){var r=s1[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Uo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?a1[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vu,charCode:function(n){return n.type==="keypress"?Uo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Uo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),u1=mn(c1),h1=_({},qo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Sm=mn(h1),d1=_({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vu}),f1=mn(d1),p1=_({},Os,{propertyName:0,elapsedTime:0,pseudoElement:0}),m1=mn(p1),g1=_({},qo,{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}),_1=mn(g1),x1=_({},Os,{newState:0,oldState:0}),b1=mn(x1),v1=[9,13,27,32],Xu=Nt&&"CompositionEvent"in window,xl=null;Nt&&"documentMode"in document&&(xl=document.documentMode);var y1=Nt&&"TextEvent"in window&&!xl,wm=Nt&&(!Xu||xl&&8<xl&&11>=xl),Cm=" ",km=!1;function Em(n,r){switch(n){case"keyup":return v1.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Nm(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var va=!1;function S1(n,r){switch(n){case"compositionend":return Nm(r);case"keypress":return r.which!==32?null:(km=!0,Cm);case"textInput":return n=r.data,n===Cm&&km?null:n;default:return null}}function w1(n,r){if(va)return n==="compositionend"||!Xu&&Em(n,r)?(n=xm(),Ls=lr=an=null,va=!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 wm&&r.locale!=="ko"?null:r.data;default:return null}}var C1={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 Tm(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!C1[n.type]:r==="textarea"}function jm(n,r,l,u){ar?Rr?Rr.push(u):Rr=[u]:ar=u,r=Dc(r,"onChange"),0<r.length&&(l=new Fo("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var bl=null,vl=null;function k1(n){hx(n,0)}function Wo(n){var r=Pn(n);if(Vi(r))return n}function Am(n,r){if(n==="change")return r}var Rm=!1;if(Nt){var Zu;if(Nt){var Qu="oninput"in document;if(!Qu){var Mm=document.createElement("div");Mm.setAttribute("oninput","return;"),Qu=typeof Mm.oninput=="function"}Zu=Qu}else Zu=!1;Rm=Zu&&(!document.documentMode||9<document.documentMode)}function Dm(){bl&&(bl.detachEvent("onpropertychange",Bm),vl=bl=null)}function Bm(n){if(n.propertyName==="value"&&Wo(vl)){var r=[];jm(r,vl,n,ml(n)),Ne(k1,r)}}function E1(n,r,l){n==="focusin"?(Dm(),bl=r,vl=l,bl.attachEvent("onpropertychange",Bm)):n==="focusout"&&Dm()}function N1(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Wo(vl)}function T1(n,r){if(n==="click")return Wo(r)}function j1(n,r){if(n==="input"||n==="change")return Wo(r)}function A1(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Nn=typeof Object.is=="function"?Object.is:A1;function yl(n,r){if(Nn(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(!Ae.call(r,m)||!Nn(n[m],r[m]))return!1}return!0}function Lm(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Om(n,r){var l=Lm(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=Lm(l)}}function zm(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?zm(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Pm(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var r=rn(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=rn(n.document)}return r}function Ju(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 R1=Nt&&"documentMode"in document&&11>=document.documentMode,ya=null,eh=null,Sl=null,th=!1;function Im(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;th||ya==null||ya!==rn(u)||(u=ya,"selectionStart"in u&&Ju(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}),Sl&&yl(Sl,u)||(Sl=u,u=Dc(eh,"onSelect"),0<u.length&&(r=new Fo("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=ya)))}function zs(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Sa={animationend:zs("Animation","AnimationEnd"),animationiteration:zs("Animation","AnimationIteration"),animationstart:zs("Animation","AnimationStart"),transitionrun:zs("Transition","TransitionRun"),transitionstart:zs("Transition","TransitionStart"),transitioncancel:zs("Transition","TransitionCancel"),transitionend:zs("Transition","TransitionEnd")},ih={},Hm={};Nt&&(Hm=document.createElement("div").style,"AnimationEvent"in window||(delete Sa.animationend.animation,delete Sa.animationiteration.animation,delete Sa.animationstart.animation),"TransitionEvent"in window||delete Sa.transitionend.transition);function Ps(n){if(ih[n])return ih[n];if(!Sa[n])return n;var r=Sa[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in Hm)return ih[n]=r[l];return n}var Um=Ps("animationend"),$m=Ps("animationiteration"),Fm=Ps("animationstart"),M1=Ps("transitionrun"),D1=Ps("transitionstart"),B1=Ps("transitioncancel"),qm=Ps("transitionend"),Wm=new Map,nh="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(" ");nh.push("scrollEnd");function or(n,r){Wm.set(n,r),tn(r,[n])}var Go=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)},qn=[],wa=0,rh=0;function Yo(){for(var n=wa,r=rh=wa=0;r<n;){var l=qn[r];qn[r++]=null;var u=qn[r];qn[r++]=null;var m=qn[r];qn[r++]=null;var g=qn[r];if(qn[r++]=null,u!==null&&m!==null){var S=u.pending;S===null?m.next=m:(m.next=S.next,S.next=m),u.pending=m}g!==0&&Gm(l,m,g)}}function Ko(n,r,l,u){qn[wa++]=n,qn[wa++]=r,qn[wa++]=l,qn[wa++]=u,rh|=u,n.lanes|=u,n=n.alternate,n!==null&&(n.lanes|=u)}function sh(n,r,l,u){return Ko(n,r,l,u),Vo(n)}function Is(n,r){return Ko(n,null,null,r),Vo(n)}function Gm(n,r,l){n.lanes|=l;var u=n.alternate;u!==null&&(u.lanes|=l);for(var m=!1,g=n.return;g!==null;)g.childLanes|=l,u=g.alternate,u!==null&&(u.childLanes|=l),g.tag===22&&(n=g.stateNode,n===null||n._visibility&1||(m=!0)),n=g,g=g.return;return n.tag===3?(g=n.stateNode,m&&r!==null&&(m=31-Oe(l),n=g.hiddenUpdates,u=n[m],u===null?n[m]=[r]:u.push(r),r.lane=l|536870912),g):null}function Vo(n){if(50<ql)throw ql=0,pd=null,Error(s(185));for(var r=n.return;r!==null;)n=r,r=n.return;return n.tag===3?n.stateNode:null}var Ca={};function L1(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 Tn(n,r,l,u){return new L1(n,r,l,u)}function ah(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Mr(n,r){var l=n.alternate;return l===null?(l=Tn(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 Ym(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 Xo(n,r,l,u,m,g){var S=0;if(u=n,typeof n=="function")ah(n)&&(S=1);else if(typeof n=="string")S=Hw(n,l,ae.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case ye:return n=Tn(31,l,r,m),n.elementType=ye,n.lanes=g,n;case E:return Hs(l.children,m,g,r);case A:S=8,m|=24;break;case T:return n=Tn(12,l,r,m|2),n.elementType=T,n.lanes=g,n;case $:return n=Tn(13,l,r,m),n.elementType=$,n.lanes=g,n;case M:return n=Tn(19,l,r,m),n.elementType=M,n.lanes=g,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case O:S=10;break e;case L:S=9;break e;case J:S=11;break e;case X:S=14;break e;case he:S=16,u=null;break e}S=29,l=Error(s(130,n===null?"null":typeof n,"")),u=null}return r=Tn(S,l,r,m),r.elementType=n,r.type=u,r.lanes=g,r}function Hs(n,r,l,u){return n=Tn(7,n,u,r),n.lanes=l,n}function lh(n,r,l){return n=Tn(6,n,null,r),n.lanes=l,n}function Km(n){var r=Tn(18,null,null,0);return r.stateNode=n,r}function oh(n,r,l){return r=Tn(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}var Vm=new WeakMap;function Wn(n,r){if(typeof n=="object"&&n!==null){var l=Vm.get(n);return l!==void 0?l:(r={value:n,source:r,stack:Ge(r)},Vm.set(n,r),r)}return{value:n,source:r,stack:Ge(r)}}var ka=[],Ea=0,Zo=null,wl=0,Gn=[],Yn=0,ns=null,mr=1,gr="";function Dr(n,r){ka[Ea++]=wl,ka[Ea++]=Zo,Zo=n,wl=r}function Xm(n,r,l){Gn[Yn++]=mr,Gn[Yn++]=gr,Gn[Yn++]=ns,ns=n;var u=mr;n=gr;var m=32-Oe(u)-1;u&=~(1<<m),l+=1;var g=32-Oe(r)+m;if(30<g){var S=m-m%5;g=(u&(1<<S)-1).toString(32),u>>=S,m-=S,mr=1<<32-Oe(r)+m|l<<m|u,gr=g+n}else mr=1<<g|l<<m|u,gr=n}function ch(n){n.return!==null&&(Dr(n,1),Xm(n,1,0))}function uh(n){for(;n===Zo;)Zo=ka[--Ea],ka[Ea]=null,wl=ka[--Ea],ka[Ea]=null;for(;n===ns;)ns=Gn[--Yn],Gn[Yn]=null,gr=Gn[--Yn],Gn[Yn]=null,mr=Gn[--Yn],Gn[Yn]=null}function Zm(n,r){Gn[Yn++]=mr,Gn[Yn++]=gr,Gn[Yn++]=ns,mr=r.id,gr=r.overflow,ns=n}var Ui=null,Yt=null,St=!1,rs=null,Kn=!1,hh=Error(s(519));function ss(n){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Cl(Wn(r,n)),hh}function Qm(n){var r=n.stateNode,l=n.type,u=n.memoizedProps;switch(r[Je]=n,r[ot]=u,l){case"dialog":_t("cancel",r),_t("close",r);break;case"iframe":case"object":case"embed":_t("load",r);break;case"video":case"audio":for(l=0;l<Gl.length;l++)_t(Gl[l],r);break;case"source":_t("error",r);break;case"img":case"image":case"link":_t("error",r),_t("load",r);break;case"details":_t("toggle",r);break;case"input":_t("invalid",r),ma(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":_t("invalid",r);break;case"textarea":_t("invalid",r),fl(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||mx(r.textContent,l)?(u.popover!=null&&(_t("beforetoggle",r),_t("toggle",r)),u.onScroll!=null&&_t("scroll",r),u.onScrollEnd!=null&&_t("scrollend",r),u.onClick!=null&&(r.onclick=sn),r=!0):r=!1,r||ss(n,!0)}function Jm(n){for(Ui=n.return;Ui;)switch(Ui.tag){case 5:case 31:case 13:Kn=!1;return;case 27:case 3:Kn=!0;return;default:Ui=Ui.return}}function Na(n){if(n!==Ui)return!1;if(!St)return Jm(n),St=!0,!1;var r=n.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||jd(n.type,n.memoizedProps)),l=!l),l&&Yt&&ss(n),Jm(n),r===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Yt=Cx(n)}else if(r===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Yt=Cx(n)}else r===27?(r=Yt,bs(n.type)?(n=Bd,Bd=null,Yt=n):Yt=r):Yt=Ui?Xn(n.stateNode.nextSibling):null;return!0}function Us(){Yt=Ui=null,St=!1}function dh(){var n=rs;return n!==null&&(bn===null?bn=n:bn.push.apply(bn,n),rs=null),n}function Cl(n){rs===null?rs=[n]:rs.push(n)}var fh=R(null),$s=null,Br=null;function as(n,r,l){w(fh,r._currentValue),r._currentValue=l}function Lr(n){n._currentValue=fh.current,Y(fh)}function ph(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 mh(n,r,l,u){var m=n.child;for(m!==null&&(m.return=n);m!==null;){var g=m.dependencies;if(g!==null){var S=m.child;g=g.firstContext;e:for(;g!==null;){var k=g;g=m;for(var D=0;D<r.length;D++)if(k.context===r[D]){g.lanes|=l,k=g.alternate,k!==null&&(k.lanes|=l),ph(g.return,l,n),u||(S=null);break e}g=k.next}}else if(m.tag===18){if(S=m.return,S===null)throw Error(s(341));S.lanes|=l,g=S.alternate,g!==null&&(g.lanes|=l),ph(S,l,n),S=null}else S=m.child;if(S!==null)S.return=m;else for(S=m;S!==null;){if(S===n){S=null;break}if(m=S.sibling,m!==null){m.return=S.return,S=m;break}S=S.return}m=S}}function Ta(n,r,l,u){n=null;for(var m=r,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var S=m.alternate;if(S===null)throw Error(s(387));if(S=S.memoizedProps,S!==null){var k=m.type;Nn(m.pendingProps.value,S.value)||(n!==null?n.push(k):n=[k])}}else if(m===F.current){if(S=m.alternate,S===null)throw Error(s(387));S.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(n!==null?n.push(Zl):n=[Zl])}m=m.return}n!==null&&mh(r,n,l,u),r.flags|=262144}function Qo(n){for(n=n.firstContext;n!==null;){if(!Nn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Fs(n){$s=n,Br=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function $i(n){return eg($s,n)}function Jo(n,r){return $s===null&&Fs(n),eg(n,r)}function eg(n,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},Br===null){if(n===null)throw Error(s(308));Br=r,n.dependencies={lanes:0,firstContext:r},n.flags|=524288}else Br=Br.next=r;return l}var O1=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()})}},z1=e.unstable_scheduleCallback,P1=e.unstable_NormalPriority,_i={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gh(){return{controller:new O1,data:new Map,refCount:0}}function kl(n){n.refCount--,n.refCount===0&&z1(P1,function(){n.controller.abort()})}var El=null,_h=0,ja=0,Aa=null;function I1(n,r){if(El===null){var l=El=[];_h=0,ja=vd(),Aa={status:"pending",value:void 0,then:function(u){l.push(u)}}}return _h++,r.then(tg,tg),r}function tg(){if(--_h===0&&El!==null){Aa!==null&&(Aa.status="fulfilled");var n=El;El=null,ja=0,Aa=null;for(var r=0;r<n.length;r++)(0,n[r])()}}function H1(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 ig=j.S;j.S=function(n,r){I_=wt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&I1(n,r),ig!==null&&ig(n,r)};var qs=R(null);function xh(){var n=qs.current;return n!==null?n:Ft.pooledCache}function ec(n,r){r===null?w(qs,qs.current):w(qs,r.pool)}function ng(){var n=xh();return n===null?null:{parent:_i._currentValue,pool:n}}var Ra=Error(s(460)),bh=Error(s(474)),tc=Error(s(542)),ic={then:function(){}};function rg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function sg(n,r,l){switch(l=n[l],l===void 0?n.push(r):l!==r&&(r.then(sn,sn),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,lg(n),n;default:if(typeof r.status=="string")r.then(sn,sn);else{if(n=Ft,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,lg(n),n}throw Gs=r,Ra}}function Ws(n){try{var r=n._init;return r(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Gs=l,Ra):l}}var Gs=null;function ag(){if(Gs===null)throw Error(s(459));var n=Gs;return Gs=null,n}function lg(n){if(n===Ra||n===tc)throw Error(s(483))}var Ma=null,Nl=0;function nc(n){var r=Nl;return Nl+=1,Ma===null&&(Ma=[]),sg(Ma,n,r)}function Tl(n,r){r=r.props.ref,n.ref=r!==void 0?r:null}function rc(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 og(n){function r(q,P){if(n){var K=q.deletions;K===null?(q.deletions=[P],q.flags|=16):K.push(P)}}function l(q,P){if(!n)return null;for(;P!==null;)r(q,P),P=P.sibling;return null}function u(q){for(var P=new Map;q!==null;)q.key!==null?P.set(q.key,q):P.set(q.index,q),q=q.sibling;return P}function m(q,P){return q=Mr(q,P),q.index=0,q.sibling=null,q}function g(q,P,K){return q.index=K,n?(K=q.alternate,K!==null?(K=K.index,K<P?(q.flags|=67108866,P):K):(q.flags|=67108866,P)):(q.flags|=1048576,P)}function S(q){return n&&q.alternate===null&&(q.flags|=67108866),q}function k(q,P,K,ce){return P===null||P.tag!==6?(P=lh(K,q.mode,ce),P.return=q,P):(P=m(P,K),P.return=q,P)}function D(q,P,K,ce){var Ue=K.type;return Ue===E?le(q,P,K.props.children,ce,K.key):P!==null&&(P.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===he&&Ws(Ue)===P.type)?(P=m(P,K.props),Tl(P,K),P.return=q,P):(P=Xo(K.type,K.key,K.props,null,q.mode,ce),Tl(P,K),P.return=q,P)}function V(q,P,K,ce){return P===null||P.tag!==4||P.stateNode.containerInfo!==K.containerInfo||P.stateNode.implementation!==K.implementation?(P=oh(K,q.mode,ce),P.return=q,P):(P=m(P,K.children||[]),P.return=q,P)}function le(q,P,K,ce,Ue){return P===null||P.tag!==7?(P=Hs(K,q.mode,ce,Ue),P.return=q,P):(P=m(P,K),P.return=q,P)}function fe(q,P,K){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=lh(""+P,q.mode,K),P.return=q,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return K=Xo(P.type,P.key,P.props,null,q.mode,K),Tl(K,P),K.return=q,K;case y:return P=oh(P,q.mode,K),P.return=q,P;case he:return P=Ws(P),fe(q,P,K)}if(I(P)||W(P))return P=Hs(P,q.mode,K,null),P.return=q,P;if(typeof P.then=="function")return fe(q,nc(P),K);if(P.$$typeof===O)return fe(q,Jo(q,P),K);rc(q,P)}return null}function Q(q,P,K,ce){var Ue=P!==null?P.key:null;if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return Ue!==null?null:k(q,P,""+K,ce);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case v:return K.key===Ue?D(q,P,K,ce):null;case y:return K.key===Ue?V(q,P,K,ce):null;case he:return K=Ws(K),Q(q,P,K,ce)}if(I(K)||W(K))return Ue!==null?null:le(q,P,K,ce,null);if(typeof K.then=="function")return Q(q,P,nc(K),ce);if(K.$$typeof===O)return Q(q,P,Jo(q,K),ce);rc(q,K)}return null}function ne(q,P,K,ce,Ue){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return q=q.get(K)||null,k(P,q,""+ce,Ue);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case v:return q=q.get(ce.key===null?K:ce.key)||null,D(P,q,ce,Ue);case y:return q=q.get(ce.key===null?K:ce.key)||null,V(P,q,ce,Ue);case he:return ce=Ws(ce),ne(q,P,K,ce,Ue)}if(I(ce)||W(ce))return q=q.get(K)||null,le(P,q,ce,Ue,null);if(typeof ce.then=="function")return ne(q,P,K,nc(ce),Ue);if(ce.$$typeof===O)return ne(q,P,K,Jo(P,ce),Ue);rc(P,ce)}return null}function ze(q,P,K,ce){for(var Ue=null,jt=null,Ie=P,at=P=0,yt=null;Ie!==null&&at<K.length;at++){Ie.index>at?(yt=Ie,Ie=null):yt=Ie.sibling;var At=Q(q,Ie,K[at],ce);if(At===null){Ie===null&&(Ie=yt);break}n&&Ie&&At.alternate===null&&r(q,Ie),P=g(At,P,at),jt===null?Ue=At:jt.sibling=At,jt=At,Ie=yt}if(at===K.length)return l(q,Ie),St&&Dr(q,at),Ue;if(Ie===null){for(;at<K.length;at++)Ie=fe(q,K[at],ce),Ie!==null&&(P=g(Ie,P,at),jt===null?Ue=Ie:jt.sibling=Ie,jt=Ie);return St&&Dr(q,at),Ue}for(Ie=u(Ie);at<K.length;at++)yt=ne(Ie,q,at,K[at],ce),yt!==null&&(n&&yt.alternate!==null&&Ie.delete(yt.key===null?at:yt.key),P=g(yt,P,at),jt===null?Ue=yt:jt.sibling=yt,jt=yt);return n&&Ie.forEach(function(Cs){return r(q,Cs)}),St&&Dr(q,at),Ue}function qe(q,P,K,ce){if(K==null)throw Error(s(151));for(var Ue=null,jt=null,Ie=P,at=P=0,yt=null,At=K.next();Ie!==null&&!At.done;at++,At=K.next()){Ie.index>at?(yt=Ie,Ie=null):yt=Ie.sibling;var Cs=Q(q,Ie,At.value,ce);if(Cs===null){Ie===null&&(Ie=yt);break}n&&Ie&&Cs.alternate===null&&r(q,Ie),P=g(Cs,P,at),jt===null?Ue=Cs:jt.sibling=Cs,jt=Cs,Ie=yt}if(At.done)return l(q,Ie),St&&Dr(q,at),Ue;if(Ie===null){for(;!At.done;at++,At=K.next())At=fe(q,At.value,ce),At!==null&&(P=g(At,P,at),jt===null?Ue=At:jt.sibling=At,jt=At);return St&&Dr(q,at),Ue}for(Ie=u(Ie);!At.done;at++,At=K.next())At=ne(Ie,q,at,At.value,ce),At!==null&&(n&&At.alternate!==null&&Ie.delete(At.key===null?at:At.key),P=g(At,P,at),jt===null?Ue=At:jt.sibling=At,jt=At);return n&&Ie.forEach(function(Zw){return r(q,Zw)}),St&&Dr(q,at),Ue}function Ht(q,P,K,ce){if(typeof K=="object"&&K!==null&&K.type===E&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case v:e:{for(var Ue=K.key;P!==null;){if(P.key===Ue){if(Ue=K.type,Ue===E){if(P.tag===7){l(q,P.sibling),ce=m(P,K.props.children),ce.return=q,q=ce;break e}}else if(P.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===he&&Ws(Ue)===P.type){l(q,P.sibling),ce=m(P,K.props),Tl(ce,K),ce.return=q,q=ce;break e}l(q,P);break}else r(q,P);P=P.sibling}K.type===E?(ce=Hs(K.props.children,q.mode,ce,K.key),ce.return=q,q=ce):(ce=Xo(K.type,K.key,K.props,null,q.mode,ce),Tl(ce,K),ce.return=q,q=ce)}return S(q);case y:e:{for(Ue=K.key;P!==null;){if(P.key===Ue)if(P.tag===4&&P.stateNode.containerInfo===K.containerInfo&&P.stateNode.implementation===K.implementation){l(q,P.sibling),ce=m(P,K.children||[]),ce.return=q,q=ce;break e}else{l(q,P);break}else r(q,P);P=P.sibling}ce=oh(K,q.mode,ce),ce.return=q,q=ce}return S(q);case he:return K=Ws(K),Ht(q,P,K,ce)}if(I(K))return ze(q,P,K,ce);if(W(K)){if(Ue=W(K),typeof Ue!="function")throw Error(s(150));return K=Ue.call(K),qe(q,P,K,ce)}if(typeof K.then=="function")return Ht(q,P,nc(K),ce);if(K.$$typeof===O)return Ht(q,P,Jo(q,K),ce);rc(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,P!==null&&P.tag===6?(l(q,P.sibling),ce=m(P,K),ce.return=q,q=ce):(l(q,P),ce=lh(K,q.mode,ce),ce.return=q,q=ce),S(q)):l(q,P)}return function(q,P,K,ce){try{Nl=0;var Ue=Ht(q,P,K,ce);return Ma=null,Ue}catch(Ie){if(Ie===Ra||Ie===tc)throw Ie;var jt=Tn(29,Ie,null,q.mode);return jt.lanes=ce,jt.return=q,jt}finally{}}}var Ys=og(!0),cg=og(!1),ls=!1;function vh(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yh(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 os(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function cs(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=Vo(n),Gm(n,null,l),r}return Ko(n,u,r,l),Vo(n)}function jl(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,te(n,l)}}function Sh(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var m=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var S={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?m=g=S:g=g.next=S,l=l.next}while(l!==null);g===null?m=g=r:g=g.next=r}else m=g=r;l={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}var wh=!1;function Al(){if(wh){var n=Aa;if(n!==null)throw n}}function Rl(n,r,l,u){wh=!1;var m=n.updateQueue;ls=!1;var g=m.firstBaseUpdate,S=m.lastBaseUpdate,k=m.shared.pending;if(k!==null){m.shared.pending=null;var D=k,V=D.next;D.next=null,S===null?g=V:S.next=V,S=D;var le=n.alternate;le!==null&&(le=le.updateQueue,k=le.lastBaseUpdate,k!==S&&(k===null?le.firstBaseUpdate=V:k.next=V,le.lastBaseUpdate=D))}if(g!==null){var fe=m.baseState;S=0,le=V=D=null,k=g;do{var Q=k.lane&-536870913,ne=Q!==k.lane;if(ne?(vt&Q)===Q:(u&Q)===Q){Q!==0&&Q===ja&&(wh=!0),le!==null&&(le=le.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var ze=n,qe=k;Q=r;var Ht=l;switch(qe.tag){case 1:if(ze=qe.payload,typeof ze=="function"){fe=ze.call(Ht,fe,Q);break e}fe=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=qe.payload,Q=typeof ze=="function"?ze.call(Ht,fe,Q):ze,Q==null)break e;fe=_({},fe,Q);break e;case 2:ls=!0}}Q=k.callback,Q!==null&&(n.flags|=64,ne&&(n.flags|=8192),ne=m.callbacks,ne===null?m.callbacks=[Q]:ne.push(Q))}else ne={lane:Q,tag:k.tag,payload:k.payload,callback:k.callback,next:null},le===null?(V=le=ne,D=fe):le=le.next=ne,S|=Q;if(k=k.next,k===null){if(k=m.shared.pending,k===null)break;ne=k,k=ne.next,ne.next=null,m.lastBaseUpdate=ne,m.shared.pending=null}}while(!0);le===null&&(D=fe),m.baseState=D,m.firstBaseUpdate=V,m.lastBaseUpdate=le,g===null&&(m.shared.lanes=0),ps|=S,n.lanes=S,n.memoizedState=fe}}function ug(n,r){if(typeof n!="function")throw Error(s(191,n));n.call(r)}function hg(n,r){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)ug(l[n],r)}var Da=R(null),sc=R(0);function dg(n,r){n=qr,w(sc,n),w(Da,r),qr=n|r.baseLanes}function Ch(){w(sc,qr),w(Da,Da.current)}function kh(){qr=sc.current,Y(Da),Y(sc)}var jn=R(null),Vn=null;function us(n){var r=n.alternate;w(oi,oi.current&1),w(jn,n),Vn===null&&(r===null||Da.current!==null||r.memoizedState!==null)&&(Vn=n)}function Eh(n){w(oi,oi.current),w(jn,n),Vn===null&&(Vn=n)}function fg(n){n.tag===22?(w(oi,oi.current),w(jn,n),Vn===null&&(Vn=n)):hs()}function hs(){w(oi,oi.current),w(jn,jn.current)}function An(n){Y(jn),Vn===n&&(Vn=null),Y(oi)}var oi=R(0);function ac(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Md(l)||Dd(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 Or=0,rt=null,Pt=null,xi=null,lc=!1,Ba=!1,Ks=!1,oc=0,Ml=0,La=null,U1=0;function ti(){throw Error(s(321))}function Nh(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Nn(n[l],r[l]))return!1;return!0}function Th(n,r,l,u,m,g){return Or=g,rt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,j.H=n===null||n.memoizedState===null?Xg:Fh,Ks=!1,g=l(u,m),Ks=!1,Ba&&(g=mg(r,l,u,m)),pg(n),g}function pg(n){j.H=Ll;var r=Pt!==null&&Pt.next!==null;if(Or=0,xi=Pt=rt=null,lc=!1,Ml=0,La=null,r)throw Error(s(300));n===null||bi||(n=n.dependencies,n!==null&&Qo(n)&&(bi=!0))}function mg(n,r,l,u){rt=n;var m=0;do{if(Ba&&(La=null),Ml=0,Ba=!1,25<=m)throw Error(s(301));if(m+=1,xi=Pt=null,n.updateQueue!=null){var g=n.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}j.H=Zg,g=r(l,u)}while(Ba);return g}function $1(){var n=j.H,r=n.useState()[0];return r=typeof r.then=="function"?Dl(r):r,n=n.useState()[0],(Pt!==null?Pt.memoizedState:null)!==n&&(rt.flags|=1024),r}function jh(){var n=oc!==0;return oc=0,n}function Ah(n,r,l){r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~l}function Rh(n){if(lc){for(n=n.memoizedState;n!==null;){var r=n.queue;r!==null&&(r.pending=null),n=n.next}lc=!1}Or=0,xi=Pt=rt=null,Ba=!1,Ml=oc=0,La=null}function ln(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xi===null?rt.memoizedState=xi=n:xi=xi.next=n,xi}function ci(){if(Pt===null){var n=rt.alternate;n=n!==null?n.memoizedState:null}else n=Pt.next;var r=xi===null?rt.memoizedState:xi.next;if(r!==null)xi=r,Pt=n;else{if(n===null)throw rt.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},xi===null?rt.memoizedState=xi=n:xi=xi.next=n}return xi}function cc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Dl(n){var r=Ml;return Ml+=1,La===null&&(La=[]),n=sg(La,n,r),r=rt,(xi===null?r.memoizedState:xi.next)===null&&(r=r.alternate,j.H=r===null||r.memoizedState===null?Xg:Fh),n}function uc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Dl(n);if(n.$$typeof===O)return $i(n)}throw Error(s(438,String(n)))}function Mh(n){var r=null,l=rt.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var u=rt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(m){return m.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=cc(),rt.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(n),u=0;u<n;u++)l[u]=U;return r.index++,l}function zr(n,r){return typeof r=="function"?r(n):r}function hc(n){var r=ci();return Dh(r,Pt,n)}function Dh(n,r,l){var u=n.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=l;var m=n.baseQueue,g=u.pending;if(g!==null){if(m!==null){var S=m.next;m.next=g.next,g.next=S}r.baseQueue=m=g,u.pending=null}if(g=n.baseState,m===null)n.memoizedState=g;else{r=m.next;var k=S=null,D=null,V=r,le=!1;do{var fe=V.lane&-536870913;if(fe!==V.lane?(vt&fe)===fe:(Or&fe)===fe){var Q=V.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),fe===ja&&(le=!0);else if((Or&Q)===Q){V=V.next,Q===ja&&(le=!0);continue}else fe={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},D===null?(k=D=fe,S=g):D=D.next=fe,rt.lanes|=Q,ps|=Q;fe=V.action,Ks&&l(g,fe),g=V.hasEagerState?V.eagerState:l(g,fe)}else Q={lane:fe,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},D===null?(k=D=Q,S=g):D=D.next=Q,rt.lanes|=fe,ps|=fe;V=V.next}while(V!==null&&V!==r);if(D===null?S=g:D.next=k,!Nn(g,n.memoizedState)&&(bi=!0,le&&(l=Aa,l!==null)))throw l;n.memoizedState=g,n.baseState=S,n.baseQueue=D,u.lastRenderedState=g}return m===null&&(u.lanes=0),[n.memoizedState,u.dispatch]}function Bh(n){var r=ci(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=l.dispatch,m=l.pending,g=r.memoizedState;if(m!==null){l.pending=null;var S=m=m.next;do g=n(g,S.action),S=S.next;while(S!==m);Nn(g,r.memoizedState)||(bi=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function gg(n,r,l){var u=rt,m=ci(),g=St;if(g){if(l===void 0)throw Error(s(407));l=l()}else l=r();var S=!Nn((Pt||m).memoizedState,l);if(S&&(m.memoizedState=l,bi=!0),m=m.queue,zh(bg.bind(null,u,m,n),[n]),m.getSnapshot!==r||S||xi!==null&&xi.memoizedState.tag&1){if(u.flags|=2048,Oa(9,{destroy:void 0},xg.bind(null,u,m,l,r),null),Ft===null)throw Error(s(349));g||(Or&127)!==0||_g(u,r,l)}return l}function _g(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=rt.updateQueue,r===null?(r=cc(),rt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function xg(n,r,l,u){r.value=l,r.getSnapshot=u,vg(r)&&yg(n)}function bg(n,r,l){return l(function(){vg(r)&&yg(n)})}function vg(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Nn(n,l)}catch{return!0}}function yg(n){var r=Is(n,2);r!==null&&vn(r,n,2)}function Lh(n){var r=ln();if(typeof n=="function"){var l=n;if(n=l(),Ks){He(!0);try{l()}finally{He(!1)}}}return r.memoizedState=r.baseState=n,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:n},r}function Sg(n,r,l,u){return n.baseState=l,Dh(n,Pt,typeof u=="function"?u:zr)}function F1(n,r,l,u,m){if(pc(n))throw Error(s(485));if(n=r.action,n!==null){var g={payload:m,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};j.T!==null?l(!0):g.isTransition=!1,u(g),l=r.pending,l===null?(g.next=r.pending=g,wg(r,g)):(g.next=l.next,r.pending=l.next=g)}}function wg(n,r){var l=r.action,u=r.payload,m=n.state;if(r.isTransition){var g=j.T,S={};j.T=S;try{var k=l(m,u),D=j.S;D!==null&&D(S,k),Cg(n,r,k)}catch(V){Oh(n,r,V)}finally{g!==null&&S.types!==null&&(g.types=S.types),j.T=g}}else try{g=l(m,u),Cg(n,r,g)}catch(V){Oh(n,r,V)}}function Cg(n,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){kg(n,r,u)},function(u){return Oh(n,r,u)}):kg(n,r,l)}function kg(n,r,l){r.status="fulfilled",r.value=l,Eg(r),n.state=l,r=n.pending,r!==null&&(l=r.next,l===r?n.pending=null:(l=l.next,r.next=l,wg(n,l)))}function Oh(n,r,l){var u=n.pending;if(n.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=l,Eg(r),r=r.next;while(r!==u)}n.action=null}function Eg(n){n=n.listeners;for(var r=0;r<n.length;r++)(0,n[r])()}function Ng(n,r){return r}function Tg(n,r){if(St){var l=Ft.formState;if(l!==null){e:{var u=rt;if(St){if(Yt){t:{for(var m=Yt,g=Kn;m.nodeType!==8;){if(!g){m=null;break t}if(m=Xn(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){Yt=Xn(m.nextSibling),u=m.data==="F!";break e}}ss(u)}u=!1}u&&(r=l[0])}}return l=ln(),l.memoizedState=l.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ng,lastRenderedState:r},l.queue=u,l=Yg.bind(null,rt,u),u.dispatch=l,u=Lh(!1),g=$h.bind(null,rt,!1,u.queue),u=ln(),m={state:r,dispatch:null,action:n,pending:null},u.queue=m,l=F1.bind(null,rt,m,g,l),m.dispatch=l,u.memoizedState=n,[r,l,!1]}function jg(n){var r=ci();return Ag(r,Pt,n)}function Ag(n,r,l){if(r=Dh(n,r,Ng)[0],n=hc(zr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=Dl(r)}catch(S){throw S===Ra?tc:S}else u=r;r=ci();var m=r.queue,g=m.dispatch;return l!==r.memoizedState&&(rt.flags|=2048,Oa(9,{destroy:void 0},q1.bind(null,m,l),null)),[u,g,n]}function q1(n,r){n.action=r}function Rg(n){var r=ci(),l=Pt;if(l!==null)return Ag(r,l,n);ci(),r=r.memoizedState,l=ci();var u=l.queue.dispatch;return l.memoizedState=n,[r,u,!1]}function Oa(n,r,l,u){return n={tag:n,create:l,deps:u,inst:r,next:null},r=rt.updateQueue,r===null&&(r=cc(),rt.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n),n}function Mg(){return ci().memoizedState}function dc(n,r,l,u){var m=ln();rt.flags|=n,m.memoizedState=Oa(1|r,{destroy:void 0},l,u===void 0?null:u)}function fc(n,r,l,u){var m=ci();u=u===void 0?null:u;var g=m.memoizedState.inst;Pt!==null&&u!==null&&Nh(u,Pt.memoizedState.deps)?m.memoizedState=Oa(r,g,l,u):(rt.flags|=n,m.memoizedState=Oa(1|r,g,l,u))}function Dg(n,r){dc(8390656,8,n,r)}function zh(n,r){fc(2048,8,n,r)}function W1(n){rt.flags|=4;var r=rt.updateQueue;if(r===null)r=cc(),rt.updateQueue=r,r.events=[n];else{var l=r.events;l===null?r.events=[n]:l.push(n)}}function Bg(n){var r=ci().memoizedState;return W1({ref:r,nextImpl:n}),function(){if((Rt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function Lg(n,r){return fc(4,2,n,r)}function Og(n,r){return fc(4,4,n,r)}function zg(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 Pg(n,r,l){l=l!=null?l.concat([n]):null,fc(4,4,zg.bind(null,r,n),l)}function Ph(){}function Ig(n,r){var l=ci();r=r===void 0?null:r;var u=l.memoizedState;return r!==null&&Nh(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function Hg(n,r){var l=ci();r=r===void 0?null:r;var u=l.memoizedState;if(r!==null&&Nh(r,u[1]))return u[0];if(u=n(),Ks){He(!0);try{n()}finally{He(!1)}}return l.memoizedState=[u,r],u}function Ih(n,r,l){return l===void 0||(Or&1073741824)!==0&&(vt&261930)===0?n.memoizedState=r:(n.memoizedState=l,n=U_(),rt.lanes|=n,ps|=n,l)}function Ug(n,r,l,u){return Nn(l,r)?l:Da.current!==null?(n=Ih(n,l,u),Nn(n,r)||(bi=!0),n):(Or&42)===0||(Or&1073741824)!==0&&(vt&261930)===0?(bi=!0,n.memoizedState=l):(n=U_(),rt.lanes|=n,ps|=n,r)}function $g(n,r,l,u,m){var g=z.p;z.p=g!==0&&8>g?g:8;var S=j.T,k={};j.T=k,$h(n,!1,r,l);try{var D=m(),V=j.S;if(V!==null&&V(k,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var le=H1(D,u);Bl(n,r,le,Dn(n))}else Bl(n,r,u,Dn(n))}catch(fe){Bl(n,r,{then:function(){},status:"rejected",reason:fe},Dn())}finally{z.p=g,S!==null&&k.types!==null&&(S.types=k.types),j.T=S}}function G1(){}function Hh(n,r,l,u){if(n.tag!==5)throw Error(s(476));var m=Fg(n).queue;$g(n,m,r,B,l===null?G1:function(){return qg(n),l(u)})}function Fg(n){var r=n.memoizedState;if(r!==null)return r;r={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:B},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:l},next:null},n.memoizedState=r,n=n.alternate,n!==null&&(n.memoizedState=r),r}function qg(n){var r=Fg(n);r.next===null&&(r=n.alternate.memoizedState),Bl(n,r.next.queue,{},Dn())}function Uh(){return $i(Zl)}function Wg(){return ci().memoizedState}function Gg(){return ci().memoizedState}function Y1(n){for(var r=n.return;r!==null;){switch(r.tag){case 24:case 3:var l=Dn();n=os(l);var u=cs(r,n,l);u!==null&&(vn(u,r,l),jl(u,r,l)),r={cache:gh()},n.payload=r;return}r=r.return}}function K1(n,r,l){var u=Dn();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},pc(n)?Kg(r,l):(l=sh(n,r,l,u),l!==null&&(vn(l,n,u),Vg(l,r,u)))}function Yg(n,r,l){var u=Dn();Bl(n,r,l,u)}function Bl(n,r,l,u){var m={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(pc(n))Kg(r,m);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,k=g(S,l);if(m.hasEagerState=!0,m.eagerState=k,Nn(k,S))return Ko(n,r,m,0),Ft===null&&Yo(),!1}catch{}finally{}if(l=sh(n,r,m,u),l!==null)return vn(l,n,u),Vg(l,r,u),!0}return!1}function $h(n,r,l,u){if(u={lane:2,revertLane:vd(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},pc(n)){if(r)throw Error(s(479))}else r=sh(n,l,u,2),r!==null&&vn(r,n,2)}function pc(n){var r=n.alternate;return n===rt||r!==null&&r===rt}function Kg(n,r){Ba=lc=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function Vg(n,r,l){if((l&4194048)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,te(n,l)}}var Ll={readContext:$i,use:uc,useCallback:ti,useContext:ti,useEffect:ti,useImperativeHandle:ti,useLayoutEffect:ti,useInsertionEffect:ti,useMemo:ti,useReducer:ti,useRef:ti,useState:ti,useDebugValue:ti,useDeferredValue:ti,useTransition:ti,useSyncExternalStore:ti,useId:ti,useHostTransitionStatus:ti,useFormState:ti,useActionState:ti,useOptimistic:ti,useMemoCache:ti,useCacheRefresh:ti};Ll.useEffectEvent=ti;var Xg={readContext:$i,use:uc,useCallback:function(n,r){return ln().memoizedState=[n,r===void 0?null:r],n},useContext:$i,useEffect:Dg,useImperativeHandle:function(n,r,l){l=l!=null?l.concat([n]):null,dc(4194308,4,zg.bind(null,r,n),l)},useLayoutEffect:function(n,r){return dc(4194308,4,n,r)},useInsertionEffect:function(n,r){dc(4,2,n,r)},useMemo:function(n,r){var l=ln();r=r===void 0?null:r;var u=n();if(Ks){He(!0);try{n()}finally{He(!1)}}return l.memoizedState=[u,r],u},useReducer:function(n,r,l){var u=ln();if(l!==void 0){var m=l(r);if(Ks){He(!0);try{l(r)}finally{He(!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=K1.bind(null,rt,n),[u.memoizedState,n]},useRef:function(n){var r=ln();return n={current:n},r.memoizedState=n},useState:function(n){n=Lh(n);var r=n.queue,l=Yg.bind(null,rt,r);return r.dispatch=l,[n.memoizedState,l]},useDebugValue:Ph,useDeferredValue:function(n,r){var l=ln();return Ih(l,n,r)},useTransition:function(){var n=Lh(!1);return n=$g.bind(null,rt,n.queue,!0,!1),ln().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,r,l){var u=rt,m=ln();if(St){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ft===null)throw Error(s(349));(vt&127)!==0||_g(u,r,l)}m.memoizedState=l;var g={value:l,getSnapshot:r};return m.queue=g,Dg(bg.bind(null,u,g,n),[n]),u.flags|=2048,Oa(9,{destroy:void 0},xg.bind(null,u,g,l,r),null),l},useId:function(){var n=ln(),r=Ft.identifierPrefix;if(St){var l=gr,u=mr;l=(u&~(1<<32-Oe(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=U1++,r="_"+r+"r_"+l.toString(32)+"_";return n.memoizedState=r},useHostTransitionStatus:Uh,useFormState:Tg,useActionState:Tg,useOptimistic:function(n){var r=ln();r.memoizedState=r.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=$h.bind(null,rt,!0,l),l.dispatch=r,[n,r]},useMemoCache:Mh,useCacheRefresh:function(){return ln().memoizedState=Y1.bind(null,rt)},useEffectEvent:function(n){var r=ln(),l={impl:n};return r.memoizedState=l,function(){if((Rt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},Fh={readContext:$i,use:uc,useCallback:Ig,useContext:$i,useEffect:zh,useImperativeHandle:Pg,useInsertionEffect:Lg,useLayoutEffect:Og,useMemo:Hg,useReducer:hc,useRef:Mg,useState:function(){return hc(zr)},useDebugValue:Ph,useDeferredValue:function(n,r){var l=ci();return Ug(l,Pt.memoizedState,n,r)},useTransition:function(){var n=hc(zr)[0],r=ci().memoizedState;return[typeof n=="boolean"?n:Dl(n),r]},useSyncExternalStore:gg,useId:Wg,useHostTransitionStatus:Uh,useFormState:jg,useActionState:jg,useOptimistic:function(n,r){var l=ci();return Sg(l,Pt,n,r)},useMemoCache:Mh,useCacheRefresh:Gg};Fh.useEffectEvent=Bg;var Zg={readContext:$i,use:uc,useCallback:Ig,useContext:$i,useEffect:zh,useImperativeHandle:Pg,useInsertionEffect:Lg,useLayoutEffect:Og,useMemo:Hg,useReducer:Bh,useRef:Mg,useState:function(){return Bh(zr)},useDebugValue:Ph,useDeferredValue:function(n,r){var l=ci();return Pt===null?Ih(l,n,r):Ug(l,Pt.memoizedState,n,r)},useTransition:function(){var n=Bh(zr)[0],r=ci().memoizedState;return[typeof n=="boolean"?n:Dl(n),r]},useSyncExternalStore:gg,useId:Wg,useHostTransitionStatus:Uh,useFormState:Rg,useActionState:Rg,useOptimistic:function(n,r){var l=ci();return Pt!==null?Sg(l,Pt,n,r):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:Mh,useCacheRefresh:Gg};Zg.useEffectEvent=Bg;function qh(n,r,l,u){r=n.memoizedState,l=l(u,r),l=l==null?r:_({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Wh={enqueueSetState:function(n,r,l){n=n._reactInternals;var u=Dn(),m=os(u);m.payload=r,l!=null&&(m.callback=l),r=cs(n,m,u),r!==null&&(vn(r,n,u),jl(r,n,u))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=Dn(),m=os(u);m.tag=1,m.payload=r,l!=null&&(m.callback=l),r=cs(n,m,u),r!==null&&(vn(r,n,u),jl(r,n,u))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Dn(),u=os(l);u.tag=2,r!=null&&(u.callback=r),r=cs(n,u,l),r!==null&&(vn(r,n,l),jl(r,n,l))}};function Qg(n,r,l,u,m,g,S){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,S):r.prototype&&r.prototype.isPureReactComponent?!yl(l,u)||!yl(m,g):!0}function Jg(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&&Wh.enqueueReplaceState(r,r.state,null)}function Vs(n,r){var l=r;if("ref"in r){l={};for(var u in r)u!=="ref"&&(l[u]=r[u])}if(n=n.defaultProps){l===r&&(l=_({},l));for(var m in n)l[m]===void 0&&(l[m]=n[m])}return l}function e_(n){Go(n)}function t_(n){console.error(n)}function i_(n){Go(n)}function mc(n,r){try{var l=n.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function n_(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 Gh(n,r,l){return l=os(l),l.tag=3,l.payload={element:null},l.callback=function(){mc(n,r)},l}function r_(n){return n=os(n),n.tag=3,n}function s_(n,r,l,u){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var g=u.value;n.payload=function(){return m(g)},n.callback=function(){n_(r,l,u)}}var S=l.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(n.callback=function(){n_(r,l,u),typeof m!="function"&&(ms===null?ms=new Set([this]):ms.add(this));var k=u.stack;this.componentDidCatch(u.value,{componentStack:k!==null?k:""})})}function V1(n,r,l,u,m){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=l.alternate,r!==null&&Ta(r,l,m,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Vn===null?Nc():l.alternate===null&&ii===0&&(ii=3),l.flags&=-257,l.flags|=65536,l.lanes=m,u===ic?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([u]):r.add(u),_d(n,u,m)),!1;case 22:return l.flags|=65536,u===ic?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)),_d(n,u,m)),!1}throw Error(s(435,l.tag))}return _d(n,u,m),Nc(),!1}if(St)return r=jn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=m,u!==hh&&(n=Error(s(422),{cause:u}),Cl(Wn(n,l)))):(u!==hh&&(r=Error(s(423),{cause:u}),Cl(Wn(r,l))),n=n.current.alternate,n.flags|=65536,m&=-m,n.lanes|=m,u=Wn(u,l),m=Gh(n.stateNode,u,m),Sh(n,m),ii!==4&&(ii=2)),!1;var g=Error(s(520),{cause:u});if(g=Wn(g,l),Fl===null?Fl=[g]:Fl.push(g),ii!==4&&(ii=2),r===null)return!0;u=Wn(u,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,n=m&-m,l.lanes|=n,n=Gh(l.stateNode,u,n),Sh(l,n),!1;case 1:if(r=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(ms===null||!ms.has(g))))return l.flags|=65536,m&=-m,l.lanes|=m,m=r_(m),s_(m,n,l,u),Sh(l,m),!1}l=l.return}while(l!==null);return!1}var Yh=Error(s(461)),bi=!1;function Fi(n,r,l,u){r.child=n===null?cg(r,null,l,u):Ys(r,n.child,l,u)}function a_(n,r,l,u,m){l=l.render;var g=r.ref;if("ref"in u){var S={};for(var k in u)k!=="ref"&&(S[k]=u[k])}else S=u;return Fs(r),u=Th(n,r,l,S,g,m),k=jh(),n!==null&&!bi?(Ah(n,r,m),Pr(n,r,m)):(St&&k&&ch(r),r.flags|=1,Fi(n,r,u,m),r.child)}function l_(n,r,l,u,m){if(n===null){var g=l.type;return typeof g=="function"&&!ah(g)&&g.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=g,o_(n,r,g,u,m)):(n=Xo(l.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,!td(n,m)){var S=g.memoizedProps;if(l=l.compare,l=l!==null?l:yl,l(S,u)&&n.ref===r.ref)return Pr(n,r,m)}return r.flags|=1,n=Mr(g,u),n.ref=r.ref,n.return=r,r.child=n}function o_(n,r,l,u,m){if(n!==null){var g=n.memoizedProps;if(yl(g,u)&&n.ref===r.ref)if(bi=!1,r.pendingProps=u=g,td(n,m))(n.flags&131072)!==0&&(bi=!0);else return r.lanes=n.lanes,Pr(n,r,m)}return Kh(n,r,l,u,m)}function c_(n,r,l,u){var m=u.children,g=n!==null?n.memoizedState:null;if(n===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,n!==null){for(u=r.child=n.child,m=0;u!==null;)m=m|u.lanes|u.childLanes,u=u.sibling;u=m&~g}else u=0,r.child=null;return u_(n,r,g,l,u)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},n!==null&&ec(r,g!==null?g.cachePool:null),g!==null?dg(r,g):Ch(),fg(r);else return u=r.lanes=536870912,u_(n,r,g!==null?g.baseLanes|l:l,l,u)}else g!==null?(ec(r,g.cachePool),dg(r,g),hs(),r.memoizedState=null):(n!==null&&ec(r,null),Ch(),hs());return Fi(n,r,m,l),r.child}function Ol(n,r){return n!==null&&n.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function u_(n,r,l,u,m){var g=xh();return g=g===null?null:{parent:_i._currentValue,pool:g},r.memoizedState={baseLanes:l,cachePool:g},n!==null&&ec(r,null),Ch(),fg(r),n!==null&&Ta(n,r,u,!0),r.childLanes=m,null}function gc(n,r){return r=xc({mode:r.mode,children:r.children},n.mode),r.ref=n.ref,n.child=r,r.return=n,r}function h_(n,r,l){return Ys(r,n.child,null,l),n=gc(r,r.pendingProps),n.flags|=2,An(r),r.memoizedState=null,n}function X1(n,r,l){var u=r.pendingProps,m=(r.flags&128)!==0;if(r.flags&=-129,n===null){if(St){if(u.mode==="hidden")return n=gc(r,u),r.lanes=536870912,Ol(null,n);if(Eh(r),(n=Yt)?(n=wx(n,Kn),n=n!==null&&n.data==="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:ns!==null?{id:mr,overflow:gr}:null,retryLane:536870912,hydrationErrors:null},l=Km(n),l.return=r,r.child=l,Ui=r,Yt=null)):n=null,n===null)throw ss(r);return r.lanes=536870912,null}return gc(r,u)}var g=n.memoizedState;if(g!==null){var S=g.dehydrated;if(Eh(r),m)if(r.flags&256)r.flags&=-257,r=h_(n,r,l);else if(r.memoizedState!==null)r.child=n.child,r.flags|=128,r=null;else throw Error(s(558));else if(bi||Ta(n,r,l,!1),m=(l&n.childLanes)!==0,bi||m){if(u=Ft,u!==null&&(S=Ce(u,l),S!==0&&S!==g.retryLane))throw g.retryLane=S,Is(n,S),vn(u,n,S),Yh;Nc(),r=h_(n,r,l)}else n=g.treeContext,Yt=Xn(S.nextSibling),Ui=r,St=!0,rs=null,Kn=!1,n!==null&&Zm(r,n),r=gc(r,u),r.flags|=4096;return r}return n=Mr(n.child,{mode:u.mode,children:u.children}),n.ref=r.ref,r.child=n,n.return=r,n}function _c(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 Kh(n,r,l,u,m){return Fs(r),l=Th(n,r,l,u,void 0,m),u=jh(),n!==null&&!bi?(Ah(n,r,m),Pr(n,r,m)):(St&&u&&ch(r),r.flags|=1,Fi(n,r,l,m),r.child)}function d_(n,r,l,u,m,g){return Fs(r),r.updateQueue=null,l=mg(r,u,l,m),pg(n),u=jh(),n!==null&&!bi?(Ah(n,r,g),Pr(n,r,g)):(St&&u&&ch(r),r.flags|=1,Fi(n,r,l,g),r.child)}function f_(n,r,l,u,m){if(Fs(r),r.stateNode===null){var g=Ca,S=l.contextType;typeof S=="object"&&S!==null&&(g=$i(S)),g=new l(u,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Wh,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=u,g.state=r.memoizedState,g.refs={},vh(r),S=l.contextType,g.context=typeof S=="object"&&S!==null?$i(S):Ca,g.state=r.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(qh(r,l,S,u),g.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Wh.enqueueReplaceState(g,g.state,null),Rl(r,u,g,m),Al(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(n===null){g=r.stateNode;var k=r.memoizedProps,D=Vs(l,k);g.props=D;var V=g.context,le=l.contextType;S=Ca,typeof le=="object"&&le!==null&&(S=$i(le));var fe=l.getDerivedStateFromProps;le=typeof fe=="function"||typeof g.getSnapshotBeforeUpdate=="function",k=r.pendingProps!==k,le||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(k||V!==S)&&Jg(r,g,u,S),ls=!1;var Q=r.memoizedState;g.state=Q,Rl(r,u,g,m),Al(),V=r.memoizedState,k||Q!==V||ls?(typeof fe=="function"&&(qh(r,l,fe,u),V=r.memoizedState),(D=ls||Qg(r,l,D,u,Q,V,S))?(le||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=V),g.props=u,g.state=V,g.context=S,u=D):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{g=r.stateNode,yh(n,r),S=r.memoizedProps,le=Vs(l,S),g.props=le,fe=r.pendingProps,Q=g.context,V=l.contextType,D=Ca,typeof V=="object"&&V!==null&&(D=$i(V)),k=l.getDerivedStateFromProps,(V=typeof k=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==fe||Q!==D)&&Jg(r,g,u,D),ls=!1,Q=r.memoizedState,g.state=Q,Rl(r,u,g,m),Al();var ne=r.memoizedState;S!==fe||Q!==ne||ls||n!==null&&n.dependencies!==null&&Qo(n.dependencies)?(typeof k=="function"&&(qh(r,l,k,u),ne=r.memoizedState),(le=ls||Qg(r,l,le,u,Q,ne,D)||n!==null&&n.dependencies!==null&&Qo(n.dependencies))?(V||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(u,ne,D),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(u,ne,D)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===n.memoizedProps&&Q===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&Q===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=ne),g.props=u,g.state=ne,g.context=D,u=le):(typeof g.componentDidUpdate!="function"||S===n.memoizedProps&&Q===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&Q===n.memoizedState||(r.flags|=1024),u=!1)}return g=u,_c(n,r),u=(r.flags&128)!==0,g||u?(g=r.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,n!==null&&u?(r.child=Ys(r,n.child,null,m),r.child=Ys(r,null,l,m)):Fi(n,r,l,m),r.memoizedState=g.state,n=r.child):n=Pr(n,r,m),n}function p_(n,r,l,u){return Us(),r.flags|=256,Fi(n,r,l,u),r.child}var Vh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Xh(n){return{baseLanes:n,cachePool:ng()}}function Zh(n,r,l){return n=n!==null?n.childLanes&~l:0,r&&(n|=Mn),n}function m_(n,r,l){var u=r.pendingProps,m=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=n!==null&&n.memoizedState===null?!1:(oi.current&2)!==0),S&&(m=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,n===null){if(St){if(m?us(r):hs(),(n=Yt)?(n=wx(n,Kn),n=n!==null&&n.data!=="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:ns!==null?{id:mr,overflow:gr}:null,retryLane:536870912,hydrationErrors:null},l=Km(n),l.return=r,r.child=l,Ui=r,Yt=null)):n=null,n===null)throw ss(r);return Dd(n)?r.lanes=32:r.lanes=536870912,null}var k=u.children;return u=u.fallback,m?(hs(),m=r.mode,k=xc({mode:"hidden",children:k},m),u=Hs(u,m,l,null),k.return=r,u.return=r,k.sibling=u,r.child=k,u=r.child,u.memoizedState=Xh(l),u.childLanes=Zh(n,S,l),r.memoizedState=Vh,Ol(null,u)):(us(r),Qh(r,k))}var D=n.memoizedState;if(D!==null&&(k=D.dehydrated,k!==null)){if(g)r.flags&256?(us(r),r.flags&=-257,r=Jh(n,r,l)):r.memoizedState!==null?(hs(),r.child=n.child,r.flags|=128,r=null):(hs(),k=u.fallback,m=r.mode,u=xc({mode:"visible",children:u.children},m),k=Hs(k,m,l,null),k.flags|=2,u.return=r,k.return=r,u.sibling=k,r.child=u,Ys(r,n.child,null,l),u=r.child,u.memoizedState=Xh(l),u.childLanes=Zh(n,S,l),r.memoizedState=Vh,r=Ol(null,u));else if(us(r),Dd(k)){if(S=k.nextSibling&&k.nextSibling.dataset,S)var V=S.dgst;S=V,u=Error(s(419)),u.stack="",u.digest=S,Cl({value:u,source:null,stack:null}),r=Jh(n,r,l)}else if(bi||Ta(n,r,l,!1),S=(l&n.childLanes)!==0,bi||S){if(S=Ft,S!==null&&(u=Ce(S,l),u!==0&&u!==D.retryLane))throw D.retryLane=u,Is(n,u),vn(S,n,u),Yh;Md(k)||Nc(),r=Jh(n,r,l)}else Md(k)?(r.flags|=192,r.child=n.child,r=null):(n=D.treeContext,Yt=Xn(k.nextSibling),Ui=r,St=!0,rs=null,Kn=!1,n!==null&&Zm(r,n),r=Qh(r,u.children),r.flags|=4096);return r}return m?(hs(),k=u.fallback,m=r.mode,D=n.child,V=D.sibling,u=Mr(D,{mode:"hidden",children:u.children}),u.subtreeFlags=D.subtreeFlags&65011712,V!==null?k=Mr(V,k):(k=Hs(k,m,l,null),k.flags|=2),k.return=r,u.return=r,u.sibling=k,r.child=u,Ol(null,u),u=r.child,k=n.child.memoizedState,k===null?k=Xh(l):(m=k.cachePool,m!==null?(D=_i._currentValue,m=m.parent!==D?{parent:D,pool:D}:m):m=ng(),k={baseLanes:k.baseLanes|l,cachePool:m}),u.memoizedState=k,u.childLanes=Zh(n,S,l),r.memoizedState=Vh,Ol(n.child,u)):(us(r),l=n.child,n=l.sibling,l=Mr(l,{mode:"visible",children:u.children}),l.return=r,l.sibling=null,n!==null&&(S=r.deletions,S===null?(r.deletions=[n],r.flags|=16):S.push(n)),r.child=l,r.memoizedState=null,l)}function Qh(n,r){return r=xc({mode:"visible",children:r},n.mode),r.return=n,n.child=r}function xc(n,r){return n=Tn(22,n,null,r),n.lanes=0,n}function Jh(n,r,l){return Ys(r,n.child,null,l),n=Qh(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function g_(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),ph(n.return,r,l)}function ed(n,r,l,u,m,g){var S=n.memoizedState;S===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:m,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=u,S.tail=l,S.tailMode=m,S.treeForkCount=g)}function __(n,r,l){var u=r.pendingProps,m=u.revealOrder,g=u.tail;u=u.children;var S=oi.current,k=(S&2)!==0;if(k?(S=S&1|2,r.flags|=128):S&=1,w(oi,S),Fi(n,r,u,l),u=St?wl:0,!k&&n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&g_(n,l,r);else if(n.tag===19)g_(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&&ac(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),ed(r,!1,m,l,g,u);break;case"backwards":case"unstable_legacy-backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&ac(n)===null){r.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}ed(r,!0,l,null,g,u);break;case"together":ed(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function Pr(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),ps|=r.lanes,(l&r.childLanes)===0)if(n!==null){if(Ta(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=Mr(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Mr(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function td(n,r){return(n.lanes&r)!==0?!0:(n=n.dependencies,!!(n!==null&&Qo(n)))}function Z1(n,r,l){switch(r.tag){case 3:ue(r,r.stateNode.containerInfo),as(r,_i,n.memoizedState.cache),Us();break;case 27:case 5:De(r);break;case 4:ue(r,r.stateNode.containerInfo);break;case 10:as(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Eh(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(us(r),r.flags|=128,null):(l&r.child.childLanes)!==0?m_(n,r,l):(us(r),n=Pr(n,r,l),n!==null?n.sibling:null);us(r);break;case 19:var m=(n.flags&128)!==0;if(u=(l&r.childLanes)!==0,u||(Ta(n,r,l,!1),u=(l&r.childLanes)!==0),m){if(u)return __(n,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),w(oi,oi.current),u)break;return null;case 22:return r.lanes=0,c_(n,r,l,r.pendingProps);case 24:as(r,_i,n.memoizedState.cache)}return Pr(n,r,l)}function x_(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps)bi=!0;else{if(!td(n,l)&&(r.flags&128)===0)return bi=!1,Z1(n,r,l);bi=(n.flags&131072)!==0}else bi=!1,St&&(r.flags&1048576)!==0&&Xm(r,wl,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(n=Ws(r.elementType),r.type=n,typeof n=="function")ah(n)?(u=Vs(n,u),r.tag=1,r=f_(null,r,n,u,l)):(r.tag=0,r=Kh(null,r,n,u,l));else{if(n!=null){var m=n.$$typeof;if(m===J){r.tag=11,r=a_(null,r,n,u,l);break e}else if(m===X){r.tag=14,r=l_(null,r,n,u,l);break e}}throw r=Z(n)||n,Error(s(306,r,""))}}return r;case 0:return Kh(n,r,r.type,r.pendingProps,l);case 1:return u=r.type,m=Vs(u,r.pendingProps),f_(n,r,u,m,l);case 3:e:{if(ue(r,r.stateNode.containerInfo),n===null)throw Error(s(387));u=r.pendingProps;var g=r.memoizedState;m=g.element,yh(n,r),Rl(r,u,null,l);var S=r.memoizedState;if(u=S.cache,as(r,_i,u),u!==g.cache&&mh(r,[_i],l,!0),Al(),u=S.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=p_(n,r,u,l);break e}else if(u!==m){m=Wn(Error(s(424)),r),Cl(m),r=p_(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(Yt=Xn(n.firstChild),Ui=r,St=!0,rs=null,Kn=!0,l=cg(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Us(),u===m){r=Pr(n,r,l);break e}Fi(n,r,u,l)}r=r.child}return r;case 26:return _c(n,r),n===null?(l=jx(r.type,null,r.pendingProps,null))?r.memoizedState=l:St||(l=r.type,n=r.pendingProps,u=Bc(oe.current).createElement(l),u[Je]=r,u[ot]=n,qi(u,l,n),ct(u),r.stateNode=u):r.memoizedState=jx(r.type,n.memoizedProps,r.pendingProps,n.memoizedState),null;case 27:return De(r),n===null&&St&&(u=r.stateNode=Ex(r.type,r.pendingProps,oe.current),Ui=r,Kn=!0,m=Yt,bs(r.type)?(Bd=m,Yt=Xn(u.firstChild)):Yt=m),Fi(n,r,r.pendingProps.children,l),_c(n,r),n===null&&(r.flags|=4194304),r.child;case 5:return n===null&&St&&((m=u=Yt)&&(u=Nw(u,r.type,r.pendingProps,Kn),u!==null?(r.stateNode=u,Ui=r,Yt=Xn(u.firstChild),Kn=!1,m=!0):m=!1),m||ss(r)),De(r),m=r.type,g=r.pendingProps,S=n!==null?n.memoizedProps:null,u=g.children,jd(m,g)?u=null:S!==null&&jd(m,S)&&(r.flags|=32),r.memoizedState!==null&&(m=Th(n,r,$1,null,null,l),Zl._currentValue=m),_c(n,r),Fi(n,r,u,l),r.child;case 6:return n===null&&St&&((n=l=Yt)&&(l=Tw(l,r.pendingProps,Kn),l!==null?(r.stateNode=l,Ui=r,Yt=null,n=!0):n=!1),n||ss(r)),null;case 13:return m_(n,r,l);case 4:return ue(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Ys(r,null,u,l):Fi(n,r,u,l),r.child;case 11:return a_(n,r,r.type,r.pendingProps,l);case 7:return Fi(n,r,r.pendingProps,l),r.child;case 8:return Fi(n,r,r.pendingProps.children,l),r.child;case 12:return Fi(n,r,r.pendingProps.children,l),r.child;case 10:return u=r.pendingProps,as(r,r.type,u.value),Fi(n,r,u.children,l),r.child;case 9:return m=r.type._context,u=r.pendingProps.children,Fs(r),m=$i(m),u=u(m),r.flags|=1,Fi(n,r,u,l),r.child;case 14:return l_(n,r,r.type,r.pendingProps,l);case 15:return o_(n,r,r.type,r.pendingProps,l);case 19:return __(n,r,l);case 31:return X1(n,r,l);case 22:return c_(n,r,l,r.pendingProps);case 24:return Fs(r),u=$i(_i),n===null?(m=xh(),m===null&&(m=Ft,g=gh(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=l),m=g),r.memoizedState={parent:u,cache:m},vh(r),as(r,_i,m)):((n.lanes&l)!==0&&(yh(n,r),Rl(r,null,null,l),Al()),m=n.memoizedState,g=r.memoizedState,m.parent!==u?(m={parent:u,cache:u},r.memoizedState=m,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=m),as(r,_i,u)):(u=g.cache,as(r,_i,u),u!==m.cache&&mh(r,[_i],l,!0))),Fi(n,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Ir(n){n.flags|=4}function id(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(W_())n.flags|=8192;else throw Gs=ic,bh}else n.flags&=-16777217}function b_(n,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!Bx(r))if(W_())n.flags|=8192;else throw Gs=ic,bh}function bc(n,r){r!==null&&(n.flags|=4),n.flags&16384&&(r=n.tag!==22?de():536870912,n.lanes|=r,Ha|=r)}function zl(n,r){if(!St)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function Kt(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 Q1(n,r,l){var u=r.pendingProps;switch(uh(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(r),null;case 1:return Kt(r),null;case 3:return l=r.stateNode,u=null,n!==null&&(u=n.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),Lr(_i),be(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(Na(r)?Ir(r):n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,dh())),Kt(r),null;case 26:var m=r.type,g=r.memoizedState;return n===null?(Ir(r),g!==null?(Kt(r),b_(r,g)):(Kt(r),id(r,m,null,u,l))):g?g!==n.memoizedState?(Ir(r),Kt(r),b_(r,g)):(Kt(r),r.flags&=-16777217):(n=n.memoizedProps,n!==u&&Ir(r),Kt(r),id(r,m,n,u,l)),null;case 27:if(Ee(r),l=oe.current,m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Kt(r),null}n=ae.current,Na(r)?Qm(r):(n=Ex(m,u,l),r.stateNode=n,Ir(r))}return Kt(r),null;case 5:if(Ee(r),m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Kt(r),null}if(g=ae.current,Na(r))Qm(r);else{var S=Bc(oe.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?S.createElement("select",{is:u.is}):S.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?S.createElement(m,{is:u.is}):S.createElement(m)}}g[Je]=r,g[ot]=u;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(qi(g,m,u),m){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Ir(r)}}return Kt(r),id(r,r.type,n===null?null:n.memoizedProps,r.pendingProps,l),null;case 6:if(n&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(n=oe.current,Na(r)){if(n=r.stateNode,l=r.memoizedProps,u=null,m=Ui,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}n[Je]=r,n=!!(n.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||mx(n.nodeValue,l)),n||ss(r,!0)}else n=Bc(n).createTextNode(u),n[Je]=r,r.stateNode=n}return Kt(r),null;case 31:if(l=r.memoizedState,n===null||n.memoizedState!==null){if(u=Na(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[Je]=r}else Us(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Kt(r),n=!1}else l=dh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return r.flags&256?(An(r),r):(An(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Kt(r),null;case 13:if(u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(m=Na(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[Je]=r}else Us(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Kt(r),m=!1}else m=dh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=m),m=!0;if(!m)return r.flags&256?(An(r),r):(An(r),null)}return An(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,n=n!==null&&n.memoizedState!==null,l&&(u=r.child,m=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(m=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==m&&(u.flags|=2048)),l!==n&&l&&(r.child.flags|=8192),bc(r,r.updateQueue),Kt(r),null);case 4:return be(),n===null&&Cd(r.stateNode.containerInfo),Kt(r),null;case 10:return Lr(r.type),Kt(r),null;case 19:if(Y(oi),u=r.memoizedState,u===null)return Kt(r),null;if(m=(r.flags&128)!==0,g=u.rendering,g===null)if(m)zl(u,!1);else{if(ii!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(g=ac(n),g!==null){for(r.flags|=128,zl(u,!1),n=g.updateQueue,r.updateQueue=n,bc(r,n),r.subtreeFlags=0,n=l,l=r.child;l!==null;)Ym(l,n),l=l.sibling;return w(oi,oi.current&1|2),St&&Dr(r,u.treeForkCount),r.child}n=n.sibling}u.tail!==null&&wt()>Cc&&(r.flags|=128,m=!0,zl(u,!1),r.lanes=4194304)}else{if(!m)if(n=ac(g),n!==null){if(r.flags|=128,m=!0,n=n.updateQueue,r.updateQueue=n,bc(r,n),zl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!St)return Kt(r),null}else 2*wt()-u.renderingStartTime>Cc&&l!==536870912&&(r.flags|=128,m=!0,zl(u,!1),r.lanes=4194304);u.isBackwards?(g.sibling=r.child,r.child=g):(n=u.last,n!==null?n.sibling=g:r.child=g,u.last=g)}return u.tail!==null?(n=u.tail,u.rendering=n,u.tail=n.sibling,u.renderingStartTime=wt(),n.sibling=null,l=oi.current,w(oi,m?l&1|2:l&1),St&&Dr(r,u.treeForkCount),n):(Kt(r),null);case 22:case 23:return An(r),kh(),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&&(Kt(r),r.subtreeFlags&6&&(r.flags|=8192)):Kt(r),l=r.updateQueue,l!==null&&bc(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&&Y(qs),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Lr(_i),Kt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function J1(n,r){switch(uh(r),r.tag){case 1:return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Lr(_i),be(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 26:case 27:case 5:return Ee(r),null;case 31:if(r.memoizedState!==null){if(An(r),r.alternate===null)throw Error(s(340));Us()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 13:if(An(r),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Us()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Y(oi),null;case 4:return be(),null;case 10:return Lr(r.type),null;case 22:case 23:return An(r),kh(),n!==null&&Y(qs),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 24:return Lr(_i),null;case 25:return null;default:return null}}function v_(n,r){switch(uh(r),r.tag){case 3:Lr(_i),be();break;case 26:case 27:case 5:Ee(r);break;case 4:be();break;case 31:r.memoizedState!==null&&An(r);break;case 13:An(r);break;case 19:Y(oi);break;case 10:Lr(r.type);break;case 22:case 23:An(r),kh(),n!==null&&Y(qs);break;case 24:Lr(_i)}}function Pl(n,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var m=u.next;l=m;do{if((l.tag&n)===n){u=void 0;var g=l.create,S=l.inst;u=g(),S.destroy=u}l=l.next}while(l!==m)}}catch(k){Ot(r,r.return,k)}}function ds(n,r,l){try{var u=r.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var g=m.next;u=g;do{if((u.tag&n)===n){var S=u.inst,k=S.destroy;if(k!==void 0){S.destroy=void 0,m=r;var D=l,V=k;try{V()}catch(le){Ot(m,D,le)}}}u=u.next}while(u!==g)}}catch(le){Ot(r,r.return,le)}}function y_(n){var r=n.updateQueue;if(r!==null){var l=n.stateNode;try{hg(r,l)}catch(u){Ot(n,n.return,u)}}}function S_(n,r,l){l.props=Vs(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(u){Ot(n,r,u)}}function Il(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){Ot(n,r,m)}}function _r(n,r){var l=n.ref,u=n.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(m){Ot(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){Ot(n,r,m)}else l.current=null}function w_(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){Ot(n,n.return,m)}}function nd(n,r,l){try{var u=n.stateNode;yw(u,n.type,l,r),u[ot]=r}catch(m){Ot(n,n.return,m)}}function C_(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&bs(n.type)||n.tag===4}function rd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||C_(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&&bs(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 sd(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=sn));else if(u!==4&&(u===27&&bs(n.type)&&(l=n.stateNode,r=null),n=n.child,n!==null))for(sd(n,r,l),n=n.sibling;n!==null;)sd(n,r,l),n=n.sibling}function vc(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&&bs(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(vc(n,r,l),n=n.sibling;n!==null;)vc(n,r,l),n=n.sibling}function k_(n){var r=n.stateNode,l=n.memoizedProps;try{for(var u=n.type,m=r.attributes;m.length;)r.removeAttributeNode(m[0]);qi(r,u,l),r[Je]=n,r[ot]=l}catch(g){Ot(n,n.return,g)}}var Hr=!1,vi=!1,ad=!1,E_=typeof WeakSet=="function"?WeakSet:Set,Ri=null;function ew(n,r){if(n=n.containerInfo,Nd=Uc,n=Pm(n),Ju(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var S=0,k=-1,D=-1,V=0,le=0,fe=n,Q=null;t:for(;;){for(var ne;fe!==l||m!==0&&fe.nodeType!==3||(k=S+m),fe!==g||u!==0&&fe.nodeType!==3||(D=S+u),fe.nodeType===3&&(S+=fe.nodeValue.length),(ne=fe.firstChild)!==null;)Q=fe,fe=ne;for(;;){if(fe===n)break t;if(Q===l&&++V===m&&(k=S),Q===g&&++le===u&&(D=S),(ne=fe.nextSibling)!==null)break;fe=Q,Q=fe.parentNode}fe=ne}l=k===-1||D===-1?null:{start:k,end:D}}else l=null}l=l||{start:0,end:0}}else l=null;for(Td={focusedElem:n,selectionRange:l},Uc=!1,Ri=r;Ri!==null;)if(r=Ri,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Ri=n;else for(;Ri!==null;){switch(r=Ri,g=r.alternate,n=r.flags,r.tag){case 0:if((n&4)!==0&&(n=r.updateQueue,n=n!==null?n.events:null,n!==null))for(l=0;l<n.length;l++)m=n[l],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&g!==null){n=void 0,l=r,m=g.memoizedProps,g=g.memoizedState,u=l.stateNode;try{var ze=Vs(l.type,m);n=u.getSnapshotBeforeUpdate(ze,g),u.__reactInternalSnapshotBeforeUpdate=n}catch(qe){Ot(l,l.return,qe)}}break;case 3:if((n&1024)!==0){if(n=r.stateNode.containerInfo,l=n.nodeType,l===9)Rd(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Rd(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,Ri=n;break}Ri=r.return}}function N_(n,r,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:$r(n,l),u&4&&Pl(5,l);break;case 1:if($r(n,l),u&4)if(n=l.stateNode,r===null)try{n.componentDidMount()}catch(S){Ot(l,l.return,S)}else{var m=Vs(l.type,r.memoizedProps);r=r.memoizedState;try{n.componentDidUpdate(m,r,n.__reactInternalSnapshotBeforeUpdate)}catch(S){Ot(l,l.return,S)}}u&64&&y_(l),u&512&&Il(l,l.return);break;case 3:if($r(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{hg(n,r)}catch(S){Ot(l,l.return,S)}}break;case 27:r===null&&u&4&&k_(l);case 26:case 5:$r(n,l),r===null&&u&4&&w_(l),u&512&&Il(l,l.return);break;case 12:$r(n,l);break;case 31:$r(n,l),u&4&&A_(n,l);break;case 13:$r(n,l),u&4&&R_(n,l),u&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=cw.bind(null,l),jw(n,l))));break;case 22:if(u=l.memoizedState!==null||Hr,!u){r=r!==null&&r.memoizedState!==null||vi,m=Hr;var g=vi;Hr=u,(vi=r)&&!g?Fr(n,l,(l.subtreeFlags&8772)!==0):$r(n,l),Hr=m,vi=g}break;case 30:break;default:$r(n,l)}}function T_(n){var r=n.alternate;r!==null&&(n.alternate=null,T_(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&jr(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 Zt=null,gn=!1;function Ur(n,r,l){for(l=l.child;l!==null;)j_(n,r,l),l=l.sibling}function j_(n,r,l){if(me&&typeof me.onCommitFiberUnmount=="function")try{me.onCommitFiberUnmount(Te,l)}catch{}switch(l.tag){case 26:vi||_r(l,r),Ur(n,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:vi||_r(l,r);var u=Zt,m=gn;bs(l.type)&&(Zt=l.stateNode,gn=!1),Ur(n,r,l),Kl(l.stateNode),Zt=u,gn=m;break;case 5:vi||_r(l,r);case 6:if(u=Zt,m=gn,Zt=null,Ur(n,r,l),Zt=u,gn=m,Zt!==null)if(gn)try{(Zt.nodeType===9?Zt.body:Zt.nodeName==="HTML"?Zt.ownerDocument.body:Zt).removeChild(l.stateNode)}catch(g){Ot(l,r,g)}else try{Zt.removeChild(l.stateNode)}catch(g){Ot(l,r,g)}break;case 18:Zt!==null&&(gn?(n=Zt,yx(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),Ka(n)):yx(Zt,l.stateNode));break;case 4:u=Zt,m=gn,Zt=l.stateNode.containerInfo,gn=!0,Ur(n,r,l),Zt=u,gn=m;break;case 0:case 11:case 14:case 15:ds(2,l,r),vi||ds(4,l,r),Ur(n,r,l);break;case 1:vi||(_r(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"&&S_(l,r,u)),Ur(n,r,l);break;case 21:Ur(n,r,l);break;case 22:vi=(u=vi)||l.memoizedState!==null,Ur(n,r,l),vi=u;break;default:Ur(n,r,l)}}function A_(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Ka(n)}catch(l){Ot(r,r.return,l)}}}function R_(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Ka(n)}catch(l){Ot(r,r.return,l)}}function tw(n){switch(n.tag){case 31:case 13:case 19:var r=n.stateNode;return r===null&&(r=n.stateNode=new E_),r;case 22:return n=n.stateNode,r=n._retryCache,r===null&&(r=n._retryCache=new E_),r;default:throw Error(s(435,n.tag))}}function yc(n,r){var l=tw(n);r.forEach(function(u){if(!l.has(u)){l.add(u);var m=uw.bind(null,n,u);u.then(m,m)}})}function _n(n,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var m=l[u],g=n,S=r,k=S;e:for(;k!==null;){switch(k.tag){case 27:if(bs(k.type)){Zt=k.stateNode,gn=!1;break e}break;case 5:Zt=k.stateNode,gn=!1;break e;case 3:case 4:Zt=k.stateNode.containerInfo,gn=!0;break e}k=k.return}if(Zt===null)throw Error(s(160));j_(g,S,m),Zt=null,gn=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)M_(r,n),r=r.sibling}var cr=null;function M_(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:_n(r,n),xn(n),u&4&&(ds(3,n,n.return),Pl(3,n),ds(5,n,n.return));break;case 1:_n(r,n),xn(n),u&512&&(vi||l===null||_r(l,l.return)),u&64&&Hr&&(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=cr;if(_n(r,n),xn(n),u&512&&(vi||l===null||_r(l,l.return)),u&4){var g=l!==null?l.memoizedState:null;if(u=n.memoizedState,l===null)if(u===null)if(n.stateNode===null){e:{u=n.type,l=n.memoizedProps,m=m.ownerDocument||m;t:switch(u){case"title":g=m.getElementsByTagName("title")[0],(!g||g[pn]||g[Je]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(u),m.head.insertBefore(g,m.querySelector("head > title"))),qi(g,u,l),g[Je]=n,ct(g),u=g;break e;case"link":var S=Mx("link","href",m).get(u+(l.href||""));if(S){for(var k=0;k<S.length;k++)if(g=S[k],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){S.splice(k,1);break t}}g=m.createElement(u),qi(g,u,l),m.head.appendChild(g);break;case"meta":if(S=Mx("meta","content",m).get(u+(l.content||""))){for(k=0;k<S.length;k++)if(g=S[k],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){S.splice(k,1);break t}}g=m.createElement(u),qi(g,u,l),m.head.appendChild(g);break;default:throw Error(s(468,u))}g[Je]=n,ct(g),u=g}n.stateNode=u}else Dx(m,n.type,n.stateNode);else n.stateNode=Rx(m,u,n.memoizedProps);else g!==u?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,u===null?Dx(m,n.type,n.stateNode):Rx(m,u,n.memoizedProps)):u===null&&n.stateNode!==null&&nd(n,n.memoizedProps,l.memoizedProps)}break;case 27:_n(r,n),xn(n),u&512&&(vi||l===null||_r(l,l.return)),l!==null&&u&4&&nd(n,n.memoizedProps,l.memoizedProps);break;case 5:if(_n(r,n),xn(n),u&512&&(vi||l===null||_r(l,l.return)),n.flags&32){m=n.stateNode;try{Fn(m,"")}catch(ze){Ot(n,n.return,ze)}}u&4&&n.stateNode!=null&&(m=n.memoizedProps,nd(n,m,l!==null?l.memoizedProps:m)),u&1024&&(ad=!0);break;case 6:if(_n(r,n),xn(n),u&4){if(n.stateNode===null)throw Error(s(162));u=n.memoizedProps,l=n.stateNode;try{l.nodeValue=u}catch(ze){Ot(n,n.return,ze)}}break;case 3:if(zc=null,m=cr,cr=Lc(r.containerInfo),_n(r,n),cr=m,xn(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Ka(r.containerInfo)}catch(ze){Ot(n,n.return,ze)}ad&&(ad=!1,D_(n));break;case 4:u=cr,cr=Lc(n.stateNode.containerInfo),_n(r,n),xn(n),cr=u;break;case 12:_n(r,n),xn(n);break;case 31:_n(r,n),xn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,yc(n,u)));break;case 13:_n(r,n),xn(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(wc=wt()),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,yc(n,u)));break;case 22:m=n.memoizedState!==null;var D=l!==null&&l.memoizedState!==null,V=Hr,le=vi;if(Hr=V||m,vi=le||D,_n(r,n),vi=le,Hr=V,xn(n),u&8192)e:for(r=n.stateNode,r._visibility=m?r._visibility&-2:r._visibility|1,m&&(l===null||D||Hr||vi||Xs(n)),l=null,r=n;;){if(r.tag===5||r.tag===26){if(l===null){D=l=r;try{if(g=D.stateNode,m)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{k=D.stateNode;var fe=D.memoizedProps.style,Q=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;k.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(ze){Ot(D,D.return,ze)}}}else if(r.tag===6){if(l===null){D=r;try{D.stateNode.nodeValue=m?"":D.memoizedProps}catch(ze){Ot(D,D.return,ze)}}}else if(r.tag===18){if(l===null){D=r;try{var ne=D.stateNode;m?Sx(ne,!0):Sx(D.stateNode,!1)}catch(ze){Ot(D,D.return,ze)}}}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,yc(n,l))));break;case 19:_n(r,n),xn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,yc(n,u)));break;case 30:break;case 21:break;default:_n(r,n),xn(n)}}function xn(n){var r=n.flags;if(r&2){try{for(var l,u=n.return;u!==null;){if(C_(u)){l=u;break}u=u.return}if(l==null)throw Error(s(160));switch(l.tag){case 27:var m=l.stateNode,g=rd(n);vc(n,g,m);break;case 5:var S=l.stateNode;l.flags&32&&(Fn(S,""),l.flags&=-33);var k=rd(n);vc(n,k,S);break;case 3:case 4:var D=l.stateNode.containerInfo,V=rd(n);sd(n,V,D);break;default:throw Error(s(161))}}catch(le){Ot(n,n.return,le)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function D_(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var r=n;D_(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),n=n.sibling}}function $r(n,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)N_(n,r.alternate,r),r=r.sibling}function Xs(n){for(n=n.child;n!==null;){var r=n;switch(r.tag){case 0:case 11:case 14:case 15:ds(4,r,r.return),Xs(r);break;case 1:_r(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&S_(r,r.return,l),Xs(r);break;case 27:Kl(r.stateNode);case 26:case 5:_r(r,r.return),Xs(r);break;case 22:r.memoizedState===null&&Xs(r);break;case 30:Xs(r);break;default:Xs(r)}n=n.sibling}}function Fr(n,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,m=n,g=r,S=g.flags;switch(g.tag){case 0:case 11:case 15:Fr(m,g,l),Pl(4,g);break;case 1:if(Fr(m,g,l),u=g,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(V){Ot(u,u.return,V)}if(u=g,m=u.updateQueue,m!==null){var k=u.stateNode;try{var D=m.shared.hiddenCallbacks;if(D!==null)for(m.shared.hiddenCallbacks=null,m=0;m<D.length;m++)ug(D[m],k)}catch(V){Ot(u,u.return,V)}}l&&S&64&&y_(g),Il(g,g.return);break;case 27:k_(g);case 26:case 5:Fr(m,g,l),l&&u===null&&S&4&&w_(g),Il(g,g.return);break;case 12:Fr(m,g,l);break;case 31:Fr(m,g,l),l&&S&4&&A_(m,g);break;case 13:Fr(m,g,l),l&&S&4&&R_(m,g);break;case 22:g.memoizedState===null&&Fr(m,g,l),Il(g,g.return);break;case 30:break;default:Fr(m,g,l)}r=r.sibling}}function ld(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&&kl(l))}function od(n,r){n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&kl(n))}function ur(n,r,l,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)B_(n,r,l,u),r=r.sibling}function B_(n,r,l,u){var m=r.flags;switch(r.tag){case 0:case 11:case 15:ur(n,r,l,u),m&2048&&Pl(9,r);break;case 1:ur(n,r,l,u);break;case 3:ur(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&&kl(n)));break;case 12:if(m&2048){ur(n,r,l,u),n=r.stateNode;try{var g=r.memoizedProps,S=g.id,k=g.onPostCommit;typeof k=="function"&&k(S,r.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(D){Ot(r,r.return,D)}}else ur(n,r,l,u);break;case 31:ur(n,r,l,u);break;case 13:ur(n,r,l,u);break;case 23:break;case 22:g=r.stateNode,S=r.alternate,r.memoizedState!==null?g._visibility&2?ur(n,r,l,u):Hl(n,r):g._visibility&2?ur(n,r,l,u):(g._visibility|=2,za(n,r,l,u,(r.subtreeFlags&10256)!==0||!1)),m&2048&&ld(S,r);break;case 24:ur(n,r,l,u),m&2048&&od(r.alternate,r);break;default:ur(n,r,l,u)}}function za(n,r,l,u,m){for(m=m&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=n,S=r,k=l,D=u,V=S.flags;switch(S.tag){case 0:case 11:case 15:za(g,S,k,D,m),Pl(8,S);break;case 23:break;case 22:var le=S.stateNode;S.memoizedState!==null?le._visibility&2?za(g,S,k,D,m):Hl(g,S):(le._visibility|=2,za(g,S,k,D,m)),m&&V&2048&&ld(S.alternate,S);break;case 24:za(g,S,k,D,m),m&&V&2048&&od(S.alternate,S);break;default:za(g,S,k,D,m)}r=r.sibling}}function Hl(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:Hl(l,u),m&2048&&ld(u.alternate,u);break;case 24:Hl(l,u),m&2048&&od(u.alternate,u);break;default:Hl(l,u)}r=r.sibling}}var Ul=8192;function Pa(n,r,l){if(n.subtreeFlags&Ul)for(n=n.child;n!==null;)L_(n,r,l),n=n.sibling}function L_(n,r,l){switch(n.tag){case 26:Pa(n,r,l),n.flags&Ul&&n.memoizedState!==null&&Uw(l,cr,n.memoizedState,n.memoizedProps);break;case 5:Pa(n,r,l);break;case 3:case 4:var u=cr;cr=Lc(n.stateNode.containerInfo),Pa(n,r,l),cr=u;break;case 22:n.memoizedState===null&&(u=n.alternate,u!==null&&u.memoizedState!==null?(u=Ul,Ul=16777216,Pa(n,r,l),Ul=u):Pa(n,r,l));break;default:Pa(n,r,l)}}function O_(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 $l(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];Ri=u,P_(u,n)}O_(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)z_(n),n=n.sibling}function z_(n){switch(n.tag){case 0:case 11:case 15:$l(n),n.flags&2048&&ds(9,n,n.return);break;case 3:$l(n);break;case 12:$l(n);break;case 22:var r=n.stateNode;n.memoizedState!==null&&r._visibility&2&&(n.return===null||n.return.tag!==13)?(r._visibility&=-3,Sc(n)):$l(n);break;default:$l(n)}}function Sc(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];Ri=u,P_(u,n)}O_(n)}for(n=n.child;n!==null;){switch(r=n,r.tag){case 0:case 11:case 15:ds(8,r,r.return),Sc(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,Sc(r));break;default:Sc(r)}n=n.sibling}}function P_(n,r){for(;Ri!==null;){var l=Ri;switch(l.tag){case 0:case 11:case 15:ds(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:kl(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,Ri=u;else e:for(l=n;Ri!==null;){u=Ri;var m=u.sibling,g=u.return;if(T_(u),u===l){Ri=null;break e}if(m!==null){m.return=g,Ri=m;break e}Ri=g}}}var iw={getCacheForType:function(n){var r=$i(_i),l=r.data.get(n);return l===void 0&&(l=n(),r.data.set(n,l)),l},cacheSignal:function(){return $i(_i).controller.signal}},nw=typeof WeakMap=="function"?WeakMap:Map,Rt=0,Ft=null,gt=null,vt=0,Lt=0,Rn=null,fs=!1,Ia=!1,cd=!1,qr=0,ii=0,ps=0,Zs=0,ud=0,Mn=0,Ha=0,Fl=null,bn=null,hd=!1,wc=0,I_=0,Cc=1/0,kc=null,ms=null,Ei=0,gs=null,Ua=null,Wr=0,dd=0,fd=null,H_=null,ql=0,pd=null;function Dn(){return(Rt&2)!==0&&vt!==0?vt&-vt:j.T!==null?vd():bt()}function U_(){if(Mn===0)if((vt&536870912)===0||St){var n=di;di<<=1,(di&3932160)===0&&(di=262144),Mn=n}else Mn=536870912;return n=jn.current,n!==null&&(n.flags|=32),Mn}function vn(n,r,l){(n===Ft&&(Lt===2||Lt===9)||n.cancelPendingCommit!==null)&&($a(n,0),_s(n,vt,Mn,!1)),We(n,l),((Rt&2)===0||n!==Ft)&&(n===Ft&&((Rt&2)===0&&(Zs|=l),ii===4&&_s(n,vt,Mn,!1)),xr(n))}function $_(n,r,l){if((Rt&6)!==0)throw Error(s(327));var u=!l&&(r&127)===0&&(r&n.expiredLanes)===0||Gt(n,r),m=u?aw(n,r):gd(n,r,!0),g=u;do{if(m===0){Ia&&!u&&_s(n,r,0,!1);break}else{if(l=n.current.alternate,g&&!rw(l)){m=gd(n,r,!1),g=!1;continue}if(m===2){if(g=r,n.errorRecoveryDisabledLanes&g)var S=0;else S=n.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var k=n;m=Fl;var D=k.current.memoizedState.isDehydrated;if(D&&($a(k,S).flags|=256),S=gd(k,S,!1),S!==2){if(cd&&!D){k.errorRecoveryDisabledLanes|=g,Zs|=g,m=4;break e}g=bn,bn=m,g!==null&&(bn===null?bn=g:bn.push.apply(bn,g))}m=S}if(g=!1,m!==2)continue}}if(m===1){$a(n,0),_s(n,r,0,!0);break}e:{switch(u=n,g=m,g){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:_s(u,r,Mn,!fs);break e;case 2:bn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(m=wc+300-wt(),10<m)){if(_s(u,r,Mn,!fs),fi(u,0,!0)!==0)break e;Wr=r,u.timeoutHandle=bx(F_.bind(null,u,l,bn,kc,hd,r,Mn,Zs,Ha,fs,g,"Throttled",-0,0),m);break e}F_(u,l,bn,kc,hd,r,Mn,Zs,Ha,fs,g,null,-0,0)}}break}while(!0);xr(n)}function F_(n,r,l,u,m,g,S,k,D,V,le,fe,Q,ne){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:sn},L_(r,g,fe);var ze=(g&62914560)===g?wc-wt():(g&4194048)===g?I_-wt():0;if(ze=$w(fe,ze),ze!==null){Wr=g,n.cancelPendingCommit=ze(Z_.bind(null,n,r,g,l,u,m,S,k,D,le,fe,null,Q,ne)),_s(n,g,S,!V);return}}Z_(n,r,g,l,u,m,S,k,D)}function rw(n){for(var r=n;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var u=0;u<l.length;u++){var m=l[u],g=m.getSnapshot;m=m.value;try{if(!Nn(g(),m))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function _s(n,r,l,u){r&=~ud,r&=~Zs,n.suspendedLanes|=r,n.pingedLanes&=~r,u&&(n.warmLanes|=r),u=n.expirationTimes;for(var m=r;0<m;){var g=31-Oe(m),S=1<<g;u[g]=-1,m&=~S}l!==0&&nt(n,l,r)}function Ec(){return(Rt&6)===0?(Wl(0),!1):!0}function md(){if(gt!==null){if(Lt===0)var n=gt.return;else n=gt,Br=$s=null,Rh(n),Ma=null,Nl=0,n=gt;for(;n!==null;)v_(n.alternate,n),n=n.return;gt=null}}function $a(n,r){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,Cw(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),Wr=0,md(),Ft=n,gt=l=Mr(n.current,null),vt=r,Lt=0,Rn=null,fs=!1,Ia=Gt(n,r),cd=!1,Ha=Mn=ud=Zs=ps=ii=0,bn=Fl=null,hd=!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-Oe(u),g=1<<m;r|=n[m],u&=~g}return qr=r,Yo(),l}function q_(n,r){rt=null,j.H=Ll,r===Ra||r===tc?(r=ag(),Lt=3):r===bh?(r=ag(),Lt=4):Lt=r===Yh?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Rn=r,gt===null&&(ii=1,mc(n,Wn(r,n.current)))}function W_(){var n=jn.current;return n===null?!0:(vt&4194048)===vt?Vn===null:(vt&62914560)===vt||(vt&536870912)!==0?n===Vn:!1}function G_(){var n=j.H;return j.H=Ll,n===null?Ll:n}function Y_(){var n=j.A;return j.A=iw,n}function Nc(){ii=4,fs||(vt&4194048)!==vt&&jn.current!==null||(Ia=!0),(ps&134217727)===0&&(Zs&134217727)===0||Ft===null||_s(Ft,vt,Mn,!1)}function gd(n,r,l){var u=Rt;Rt|=2;var m=G_(),g=Y_();(Ft!==n||vt!==r)&&(kc=null,$a(n,r)),r=!1;var S=ii;e:do try{if(Lt!==0&>!==null){var k=gt,D=Rn;switch(Lt){case 8:md(),S=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(r=!0);var V=Lt;if(Lt=0,Rn=null,Fa(n,k,D,V),l&&Ia){S=0;break e}break;default:V=Lt,Lt=0,Rn=null,Fa(n,k,D,V)}}sw(),S=ii;break}catch(le){q_(n,le)}while(!0);return r&&n.shellSuspendCounter++,Br=$s=null,Rt=u,j.H=m,j.A=g,gt===null&&(Ft=null,vt=0,Yo()),S}function sw(){for(;gt!==null;)K_(gt)}function aw(n,r){var l=Rt;Rt|=2;var u=G_(),m=Y_();Ft!==n||vt!==r?(kc=null,Cc=wt()+500,$a(n,r)):Ia=Gt(n,r);e:do try{if(Lt!==0&>!==null){r=gt;var g=Rn;t:switch(Lt){case 1:Lt=0,Rn=null,Fa(n,r,g,1);break;case 2:case 9:if(rg(g)){Lt=0,Rn=null,V_(r);break}r=function(){Lt!==2&&Lt!==9||Ft!==n||(Lt=7),xr(n)},g.then(r,r);break e;case 3:Lt=7;break e;case 4:Lt=5;break e;case 7:rg(g)?(Lt=0,Rn=null,V_(r)):(Lt=0,Rn=null,Fa(n,r,g,7));break;case 5:var S=null;switch(gt.tag){case 26:S=gt.memoizedState;case 5:case 27:var k=gt;if(S?Bx(S):k.stateNode.complete){Lt=0,Rn=null;var D=k.sibling;if(D!==null)gt=D;else{var V=k.return;V!==null?(gt=V,Tc(V)):gt=null}break t}}Lt=0,Rn=null,Fa(n,r,g,5);break;case 6:Lt=0,Rn=null,Fa(n,r,g,6);break;case 8:md(),ii=6;break e;default:throw Error(s(462))}}lw();break}catch(le){q_(n,le)}while(!0);return Br=$s=null,j.H=u,j.A=m,Rt=l,gt!==null?0:(Ft=null,vt=0,Yo(),ii)}function lw(){for(;gt!==null&&!zt();)K_(gt)}function K_(n){var r=x_(n.alternate,n,qr);n.memoizedProps=n.pendingProps,r===null?Tc(n):gt=r}function V_(n){var r=n,l=r.alternate;switch(r.tag){case 15:case 0:r=d_(l,r,r.pendingProps,r.type,void 0,vt);break;case 11:r=d_(l,r,r.pendingProps,r.type.render,r.ref,vt);break;case 5:Rh(r);default:v_(l,r),r=gt=Ym(r,qr),r=x_(l,r,qr)}n.memoizedProps=n.pendingProps,r===null?Tc(n):gt=r}function Fa(n,r,l,u){Br=$s=null,Rh(r),Ma=null,Nl=0;var m=r.return;try{if(V1(n,m,r,l,vt)){ii=1,mc(n,Wn(l,n.current)),gt=null;return}}catch(g){if(m!==null)throw gt=m,g;ii=1,mc(n,Wn(l,n.current)),gt=null;return}r.flags&32768?(St||u===1?n=!0:Ia||(vt&536870912)!==0?n=!1:(fs=n=!0,(u===2||u===9||u===3||u===6)&&(u=jn.current,u!==null&&u.tag===13&&(u.flags|=16384))),X_(r,n)):Tc(r)}function Tc(n){var r=n;do{if((r.flags&32768)!==0){X_(r,fs);return}n=r.return;var l=Q1(r.alternate,r,qr);if(l!==null){gt=l;return}if(r=r.sibling,r!==null){gt=r;return}gt=r=n}while(r!==null);ii===0&&(ii=5)}function X_(n,r){do{var l=J1(n.alternate,n);if(l!==null){l.flags&=32767,gt=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(n=n.sibling,n!==null)){gt=n;return}gt=n=l}while(n!==null);ii=6,gt=null}function Z_(n,r,l,u,m,g,S,k,D){n.cancelPendingCommit=null;do jc();while(Ei!==0);if((Rt&6)!==0)throw Error(s(327));if(r!==null){if(r===n.current)throw Error(s(177));if(g=r.lanes|r.childLanes,g|=rh,st(n,l,g,S,k,D),n===Ft&&(gt=Ft=null,vt=0),Ua=r,gs=n,Wr=l,dd=g,fd=m,H_=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,hw(Pe,function(){return ix(),null})):(n.callbackNode=null,n.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=j.T,j.T=null,m=z.p,z.p=2,S=Rt,Rt|=4;try{ew(n,r,l)}finally{Rt=S,z.p=m,j.T=u}}Ei=1,Q_(),J_(),ex()}}function Q_(){if(Ei===1){Ei=0;var n=gs,r=Ua,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=j.T,j.T=null;var u=z.p;z.p=2;var m=Rt;Rt|=4;try{M_(r,n);var g=Td,S=Pm(n.containerInfo),k=g.focusedElem,D=g.selectionRange;if(S!==k&&k&&k.ownerDocument&&zm(k.ownerDocument.documentElement,k)){if(D!==null&&Ju(k)){var V=D.start,le=D.end;if(le===void 0&&(le=V),"selectionStart"in k)k.selectionStart=V,k.selectionEnd=Math.min(le,k.value.length);else{var fe=k.ownerDocument||document,Q=fe&&fe.defaultView||window;if(Q.getSelection){var ne=Q.getSelection(),ze=k.textContent.length,qe=Math.min(D.start,ze),Ht=D.end===void 0?qe:Math.min(D.end,ze);!ne.extend&&qe>Ht&&(S=Ht,Ht=qe,qe=S);var q=Om(k,qe),P=Om(k,Ht);if(q&&P&&(ne.rangeCount!==1||ne.anchorNode!==q.node||ne.anchorOffset!==q.offset||ne.focusNode!==P.node||ne.focusOffset!==P.offset)){var K=fe.createRange();K.setStart(q.node,q.offset),ne.removeAllRanges(),qe>Ht?(ne.addRange(K),ne.extend(P.node,P.offset)):(K.setEnd(P.node,P.offset),ne.addRange(K))}}}}for(fe=[],ne=k;ne=ne.parentNode;)ne.nodeType===1&&fe.push({element:ne,left:ne.scrollLeft,top:ne.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k<fe.length;k++){var ce=fe[k];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}Uc=!!Nd,Td=Nd=null}finally{Rt=m,z.p=u,j.T=l}}n.current=r,Ei=2}}function J_(){if(Ei===2){Ei=0;var n=gs,r=Ua,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=j.T,j.T=null;var u=z.p;z.p=2;var m=Rt;Rt|=4;try{N_(n,r.alternate,r)}finally{Rt=m,z.p=u,j.T=l}}Ei=3}}function ex(){if(Ei===4||Ei===3){Ei=0,ai();var n=gs,r=Ua,l=Wr,u=H_;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ei=5:(Ei=0,Ua=gs=null,tx(n,n.pendingLanes));var m=n.pendingLanes;if(m===0&&(ms=null),ft(l),r=r.stateNode,me&&typeof me.onCommitFiberRoot=="function")try{me.onCommitFiberRoot(Te,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=j.T,m=z.p,z.p=2,j.T=null;try{for(var g=n.onRecoverableError,S=0;S<u.length;S++){var k=u[S];g(k.value,{componentStack:k.stack})}}finally{j.T=r,z.p=m}}(Wr&3)!==0&&jc(),xr(n),m=n.pendingLanes,(l&261930)!==0&&(m&42)!==0?n===pd?ql++:(ql=0,pd=n):ql=0,Wl(0)}}function tx(n,r){(n.pooledCacheLanes&=r)===0&&(r=n.pooledCache,r!=null&&(n.pooledCache=null,kl(r)))}function jc(){return Q_(),J_(),ex(),ix()}function ix(){if(Ei!==5)return!1;var n=gs,r=dd;dd=0;var l=ft(Wr),u=j.T,m=z.p;try{z.p=32>l?32:l,j.T=null,l=fd,fd=null;var g=gs,S=Wr;if(Ei=0,Ua=gs=null,Wr=0,(Rt&6)!==0)throw Error(s(331));var k=Rt;if(Rt|=4,z_(g.current),B_(g,g.current,S,l),Rt=k,Wl(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(Te,g)}catch{}return!0}finally{z.p=m,j.T=u,tx(n,r)}}function nx(n,r,l){r=Wn(l,r),r=Gh(n.stateNode,r,2),n=cs(n,r,2),n!==null&&(We(n,2),xr(n))}function Ot(n,r,l){if(n.tag===3)nx(n,n,l);else for(;r!==null;){if(r.tag===3){nx(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ms===null||!ms.has(u))){n=Wn(l,n),l=r_(2),u=cs(r,l,2),u!==null&&(s_(l,u,r,n),We(u,2),xr(u));break}}r=r.return}}function _d(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new nw;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)||(cd=!0,m.add(l),n=ow.bind(null,n,r,l),r.then(n,n))}function ow(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,Ft===n&&(vt&l)===l&&(ii===4||ii===3&&(vt&62914560)===vt&&300>wt()-wc?(Rt&2)===0&&$a(n,0):ud|=l,Ha===vt&&(Ha=0)),xr(n)}function rx(n,r){r===0&&(r=de()),n=Is(n,r),n!==null&&(We(n,r),xr(n))}function cw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),rx(n,l)}function uw(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),rx(n,l)}function hw(n,r){return Ve(n,r)}var Ac=null,qa=null,xd=!1,Rc=!1,bd=!1,xs=0;function xr(n){n!==qa&&n.next===null&&(qa===null?Ac=qa=n:qa=qa.next=n),Rc=!0,xd||(xd=!0,fw())}function Wl(n,r){if(!bd&&Rc){bd=!0;do for(var l=!1,u=Ac;u!==null;){if(n!==0){var m=u.pendingLanes;if(m===0)var g=0;else{var S=u.suspendedLanes,k=u.pingedLanes;g=(1<<31-Oe(42|n)+1)-1,g&=m&~(S&~k),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,ox(u,g))}else g=vt,g=fi(u,u===Ft?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Gt(u,g)||(l=!0,ox(u,g));u=u.next}while(l);bd=!1}}function dw(){sx()}function sx(){Rc=xd=!1;var n=0;xs!==0&&ww()&&(n=xs);for(var r=wt(),l=null,u=Ac;u!==null;){var m=u.next,g=ax(u,r);g===0?(u.next=null,l===null?Ac=m:l.next=m,m===null&&(qa=l)):(l=u,(n!==0||(g&3)!==0)&&(Rc=!0)),u=m}Ei!==0&&Ei!==5||Wl(n),xs!==0&&(xs=0)}function ax(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,m=n.expirationTimes,g=n.pendingLanes&-62914561;0<g;){var S=31-Oe(g),k=1<<S,D=m[S];D===-1?((k&l)===0||(k&u)!==0)&&(m[S]=fn(k,r)):D<=r&&(n.expiredLanes|=k),g&=~k}if(r=Ft,l=vt,l=fi(n,n===r?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u=n.callbackNode,l===0||n===r&&(Lt===2||Lt===9)||n.cancelPendingCommit!==null)return u!==null&&u!==null&&Mt(u),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||Gt(n,l)){if(r=l&-l,r===n.callbackPriority)return r;switch(u!==null&&Mt(u),ft(l)){case 2:case 8:l=xe;break;case 32:l=Pe;break;case 268435456:l=Qe;break;default:l=Pe}return u=lx.bind(null,n),l=Ve(l,u),n.callbackPriority=r,n.callbackNode=l,r}return u!==null&&u!==null&&Mt(u),n.callbackPriority=2,n.callbackNode=null,2}function lx(n,r){if(Ei!==0&&Ei!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(jc()&&n.callbackNode!==l)return null;var u=vt;return u=fi(n,n===Ft?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u===0?null:($_(n,u,r),ax(n,wt()),n.callbackNode!=null&&n.callbackNode===l?lx.bind(null,n):null)}function ox(n,r){if(jc())return null;$_(n,r,!0)}function fw(){kw(function(){(Rt&6)!==0?Ve(re,dw):sx()})}function vd(){if(xs===0){var n=ja;n===0&&(n=Bt,Bt<<=1,(Bt&261888)===0&&(Bt=256)),xs=n}return xs}function cx(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:ba(""+n)}function ux(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 pw(n,r,l,u,m){if(r==="submit"&&l&&l.stateNode===m){var g=cx((m[ot]||null).action),S=u.submitter;S&&(r=(r=S[ot]||null)?cx(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var k=new Fo("action","action",null,u,m);n.push({event:k,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(xs!==0){var D=S?ux(m,S):new FormData(m);Hh(l,{pending:!0,data:D,method:m.method,action:g},null,D)}}else typeof g=="function"&&(k.preventDefault(),D=S?ux(m,S):new FormData(m),Hh(l,{pending:!0,data:D,method:m.method,action:g},g,D))},currentTarget:m}]})}}for(var yd=0;yd<nh.length;yd++){var Sd=nh[yd],mw=Sd.toLowerCase(),gw=Sd[0].toUpperCase()+Sd.slice(1);or(mw,"on"+gw)}or(Um,"onAnimationEnd"),or($m,"onAnimationIteration"),or(Fm,"onAnimationStart"),or("dblclick","onDoubleClick"),or("focusin","onFocus"),or("focusout","onBlur"),or(M1,"onTransitionRun"),or(D1,"onTransitionStart"),or(B1,"onTransitionCancel"),or(qm,"onTransitionEnd"),Hn("onMouseEnter",["mouseout","mouseover"]),Hn("onMouseLeave",["mouseout","mouseover"]),Hn("onPointerEnter",["pointerout","pointerover"]),Hn("onPointerLeave",["pointerout","pointerover"]),tn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tn("onBeforeInput",["compositionend","keypress","textInput","paste"]),tn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gl="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(" "),_w=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Gl));function hx(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var u=n[l],m=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var S=u.length-1;0<=S;S--){var k=u[S],D=k.instance,V=k.currentTarget;if(k=k.listener,D!==g&&m.isPropagationStopped())break e;g=k,m.currentTarget=V;try{g(m)}catch(le){Go(le)}m.currentTarget=null,g=D}else for(S=0;S<u.length;S++){if(k=u[S],D=k.instance,V=k.currentTarget,k=k.listener,D!==g&&m.isPropagationStopped())break e;g=k,m.currentTarget=V;try{g(m)}catch(le){Go(le)}m.currentTarget=null,g=D}}}}function _t(n,r){var l=r[Et];l===void 0&&(l=r[Et]=new Set);var u=n+"__bubble";l.has(u)||(dx(r,n,2,!1),l.add(u))}function wd(n,r,l){var u=0;r&&(u|=4),dx(l,n,u,r)}var Mc="_reactListening"+Math.random().toString(36).slice(2);function Cd(n){if(!n[Mc]){n[Mc]=!0,In.forEach(function(l){l!=="selectionchange"&&(_w.has(l)||wd(l,!1,n),wd(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Mc]||(r[Mc]=!0,wd("selectionchange",!1,r))}}function dx(n,r,l,u){switch(Ux(r)){case 2:var m=Ww;break;case 8:m=Gw;break;default:m=Id}l=m.bind(null,r,l,n),m=void 0,!gi||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 kd(n,r,l,u,m){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var S=u.tag;if(S===3||S===4){var k=u.stateNode.containerInfo;if(k===m)break;if(S===4)for(S=u.return;S!==null;){var D=S.tag;if((D===3||D===4)&&S.stateNode.containerInfo===m)return;S=S.return}for(;k!==null;){if(S=mi(k),S===null)return;if(D=S.tag,D===5||D===6||D===26||D===27){u=g=S;continue e}k=k.parentNode}}u=u.return}Ne(function(){var V=g,le=ml(l),fe=[];e:{var Q=Wm.get(n);if(Q!==void 0){var ne=Fo,ze=n;switch(n){case"keypress":if(Uo(l)===0)break e;case"keydown":case"keyup":ne=u1;break;case"focusin":ze="focus",ne=Ku;break;case"focusout":ze="blur",ne=Ku;break;case"beforeblur":case"afterblur":ne=Ku;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":ne=vm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ne=QS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ne=f1;break;case Um:case $m:case Fm:ne=t1;break;case qm:ne=m1;break;case"scroll":case"scrollend":ne=XS;break;case"wheel":ne=_1;break;case"copy":case"cut":case"paste":ne=n1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ne=Sm;break;case"toggle":case"beforetoggle":ne=b1}var qe=(r&4)!==0,Ht=!qe&&(n==="scroll"||n==="scrollend"),q=qe?Q!==null?Q+"Capture":null:Q;qe=[];for(var P=V,K;P!==null;){var ce=P;if(K=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||K===null||q===null||(ce=Ke(P,q),ce!=null&&qe.push(Yl(P,ce,K))),Ht)break;P=P.return}0<qe.length&&(Q=new ne(Q,ze,null,l,le),fe.push({event:Q,listeners:qe}))}}if((r&7)===0){e:{if(Q=n==="mouseover"||n==="pointerover",ne=n==="mouseout"||n==="pointerout",Q&&l!==is&&(ze=l.relatedTarget||l.fromElement)&&(mi(ze)||ze[Xe]))break e;if((ne||Q)&&(Q=le.window===le?le:(Q=le.ownerDocument)?Q.defaultView||Q.parentWindow:window,ne?(ze=l.relatedTarget||l.toElement,ne=V,ze=ze?mi(ze):null,ze!==null&&(Ht=o(ze),qe=ze.tag,ze!==Ht||qe!==5&&qe!==27&&qe!==6)&&(ze=null)):(ne=null,ze=V),ne!==ze)){if(qe=vm,ce="onMouseLeave",q="onMouseEnter",P="mouse",(n==="pointerout"||n==="pointerover")&&(qe=Sm,ce="onPointerLeave",q="onPointerEnter",P="pointer"),Ht=ne==null?Q:Pn(ne),K=ze==null?Q:Pn(ze),Q=new qe(ce,P+"leave",ne,l,le),Q.target=Ht,Q.relatedTarget=K,ce=null,mi(le)===V&&(qe=new qe(q,P+"enter",ze,l,le),qe.target=K,qe.relatedTarget=Ht,ce=qe),Ht=ce,ne&&ze)t:{for(qe=xw,q=ne,P=ze,K=0,ce=q;ce;ce=qe(ce))K++;ce=0;for(var Ue=P;Ue;Ue=qe(Ue))ce++;for(;0<K-ce;)q=qe(q),K--;for(;0<ce-K;)P=qe(P),ce--;for(;K--;){if(q===P||P!==null&&q===P.alternate){qe=q;break t}q=qe(q),P=qe(P)}qe=null}else qe=null;ne!==null&&fx(fe,Q,ne,qe,!1),ze!==null&&Ht!==null&&fx(fe,Ht,ze,qe,!0)}}e:{if(Q=V?Pn(V):window,ne=Q.nodeName&&Q.nodeName.toLowerCase(),ne==="select"||ne==="input"&&Q.type==="file")var jt=Am;else if(Tm(Q))if(Rm)jt=j1;else{jt=N1;var Ie=E1}else ne=Q.nodeName,!ne||ne.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?V&&xa(V.elementType)&&(jt=Am):jt=T1;if(jt&&(jt=jt(n,V))){jm(fe,jt,l,le);break e}Ie&&Ie(n,Q,V),n==="focusout"&&V&&Q.type==="number"&&V.memoizedProps.value!=null&&ga(Q,"number",Q.value)}switch(Ie=V?Pn(V):window,n){case"focusin":(Tm(Ie)||Ie.contentEditable==="true")&&(ya=Ie,eh=V,Sl=null);break;case"focusout":Sl=eh=ya=null;break;case"mousedown":th=!0;break;case"contextmenu":case"mouseup":case"dragend":th=!1,Im(fe,l,le);break;case"selectionchange":if(R1)break;case"keydown":case"keyup":Im(fe,l,le)}var at;if(Xu)e:{switch(n){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else va?Em(n,l)&&(yt="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(yt="onCompositionStart");yt&&(wm&&l.locale!=="ko"&&(va||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&va&&(at=xm()):(an=le,lr="value"in an?an.value:an.textContent,va=!0)),Ie=Dc(V,yt),0<Ie.length&&(yt=new ym(yt,n,null,l,le),fe.push({event:yt,listeners:Ie}),at?yt.data=at:(at=Nm(l),at!==null&&(yt.data=at)))),(at=y1?S1(n,l):w1(n,l))&&(yt=Dc(V,"onBeforeInput"),0<yt.length&&(Ie=new ym("onBeforeInput","beforeinput",null,l,le),fe.push({event:Ie,listeners:yt}),Ie.data=at)),pw(fe,n,V,l,le)}hx(fe,r)})}function Yl(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Dc(n,r){for(var l=r+"Capture",u=[];n!==null;){var m=n,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=Ke(n,l),m!=null&&u.unshift(Yl(n,m,g)),m=Ke(n,r),m!=null&&u.push(Yl(n,m,g))),n.tag===3)return u;n=n.return}return[]}function xw(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function fx(n,r,l,u,m){for(var g=r._reactName,S=[];l!==null&&l!==u;){var k=l,D=k.alternate,V=k.stateNode;if(k=k.tag,D!==null&&D===u)break;k!==5&&k!==26&&k!==27||V===null||(D=V,m?(V=Ke(l,g),V!=null&&S.unshift(Yl(l,V,D))):m||(V=Ke(l,g),V!=null&&S.push(Yl(l,V,D)))),l=l.return}S.length!==0&&n.push({event:r,listeners:S})}var bw=/\r\n?/g,vw=/\u0000|\uFFFD/g;function px(n){return(typeof n=="string"?n:""+n).replace(bw,`
|
|
49
|
+
`).replace(vw,"")}function mx(n,r){return r=px(r),px(n)===r}function It(n,r,l,u,m,g){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Fn(n,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Fn(n,""+u);break;case"className":Ar(n,"class",u);break;case"tabIndex":Ar(n,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Ar(n,l,u);break;case"style":Ho(n,u,g);break;case"data":if(r!=="object"){Ar(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=ba(""+u),n.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){n.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(r!=="input"&&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=ba(""+u),n.setAttribute(l,u);break;case"onClick":u!=null&&(n.onclick=sn);break;case"onScroll":u!=null&&_t("scroll",n);break;case"onScrollEnd":u!=null&&_t("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=ba(""+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":_t("beforetoggle",n),_t("toggle",n),pr(n,"popover",u);break;case"xlinkActuate":nn(n,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":nn(n,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":nn(n,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":nn(n,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":nn(n,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":nn(n,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":nn(n,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":nn(n,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":nn(n,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":pr(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=pl.get(l)||l,pr(n,l,u))}}function Ed(n,r,l,u,m,g){switch(l){case"style":Ho(n,u,g);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(m.children!=null)throw Error(s(60));n.innerHTML=l}}break;case"children":typeof u=="string"?Fn(n,u):(typeof u=="number"||typeof u=="bigint")&&Fn(n,""+u);break;case"onScroll":u!=null&&_t("scroll",n);break;case"onScrollEnd":u!=null&&_t("scrollend",n);break;case"onClick":u!=null&&(n.onclick=sn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!rr.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),r=l.slice(2,m?l.length-7:void 0),g=n[ot]||null,g=g!=null?g[l]:null,typeof g=="function"&&n.removeEventListener(r,g,m),typeof u=="function")){typeof g!="function"&&g!==null&&(l in n?n[l]=null:n.hasAttribute(l)&&n.removeAttribute(l)),n.addEventListener(r,u,m);break e}l in n?n[l]=u:u===!0?n.setAttribute(l,""):pr(n,l,u)}}}function qi(n,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":_t("error",n),_t("load",n);var u=!1,m=!1,g;for(g in l)if(l.hasOwnProperty(g)){var S=l[g];if(S!=null)switch(g){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:It(n,r,g,S,l,null)}}m&&It(n,r,"srcSet",l.srcSet,l,null),u&&It(n,r,"src",l.src,l,null);return;case"input":_t("invalid",n);var k=g=S=m=null,D=null,V=null;for(u in l)if(l.hasOwnProperty(u)){var le=l[u];if(le!=null)switch(u){case"name":m=le;break;case"type":S=le;break;case"checked":D=le;break;case"defaultChecked":V=le;break;case"value":g=le;break;case"defaultValue":k=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,r));break;default:It(n,r,u,le,l,null)}}ma(n,g,k,D,V,S,m,!1);return;case"select":_t("invalid",n),u=S=g=null;for(m in l)if(l.hasOwnProperty(m)&&(k=l[m],k!=null))switch(m){case"value":g=k;break;case"defaultValue":S=k;break;case"multiple":u=k;default:It(n,r,m,k,l,null)}r=g,l=S,n.multiple=!!u,r!=null?$n(n,!!u,r,!1):l!=null&&$n(n,!!u,l,!0);return;case"textarea":_t("invalid",n),g=m=u=null;for(S in l)if(l.hasOwnProperty(S)&&(k=l[S],k!=null))switch(S){case"value":u=k;break;case"defaultValue":m=k;break;case"children":g=k;break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(s(91));break;default:It(n,r,S,k,l,null)}fl(n,u,m,g);return;case"option":for(D in l)if(l.hasOwnProperty(D)&&(u=l[D],u!=null))switch(D){case"selected":n.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:It(n,r,D,u,l,null)}return;case"dialog":_t("beforetoggle",n),_t("toggle",n),_t("cancel",n),_t("close",n);break;case"iframe":case"object":_t("load",n);break;case"video":case"audio":for(u=0;u<Gl.length;u++)_t(Gl[u],n);break;case"image":_t("error",n),_t("load",n);break;case"details":_t("toggle",n);break;case"embed":case"source":case"link":_t("error",n),_t("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(V in l)if(l.hasOwnProperty(V)&&(u=l[V],u!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:It(n,r,V,u,l,null)}return;default:if(xa(r)){for(le in l)l.hasOwnProperty(le)&&(u=l[le],u!==void 0&&Ed(n,r,le,u,l,void 0));return}}for(k in l)l.hasOwnProperty(k)&&(u=l[k],u!=null&&It(n,r,k,u,l,null))}function yw(n,r,l,u){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,S=null,k=null,D=null,V=null,le=null;for(ne in l){var fe=l[ne];if(l.hasOwnProperty(ne)&&fe!=null)switch(ne){case"checked":break;case"value":break;case"defaultValue":D=fe;default:u.hasOwnProperty(ne)||It(n,r,ne,null,u,fe)}}for(var Q in u){var ne=u[Q];if(fe=l[Q],u.hasOwnProperty(Q)&&(ne!=null||fe!=null))switch(Q){case"type":g=ne;break;case"name":m=ne;break;case"checked":V=ne;break;case"defaultChecked":le=ne;break;case"value":S=ne;break;case"defaultValue":k=ne;break;case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(s(137,r));break;default:ne!==fe&&It(n,r,Q,ne,u,fe)}}pa(n,S,k,D,V,le,g,m);return;case"select":ne=S=k=Q=null;for(g in l)if(D=l[g],l.hasOwnProperty(g)&&D!=null)switch(g){case"value":break;case"multiple":ne=D;default:u.hasOwnProperty(g)||It(n,r,g,null,u,D)}for(m in u)if(g=u[m],D=l[m],u.hasOwnProperty(m)&&(g!=null||D!=null))switch(m){case"value":Q=g;break;case"defaultValue":k=g;break;case"multiple":S=g;default:g!==D&&It(n,r,m,g,u,D)}r=k,l=S,u=ne,Q!=null?$n(n,!!l,Q,!1):!!u!=!!l&&(r!=null?$n(n,!!l,r,!0):$n(n,!!l,l?[]:"",!1));return;case"textarea":ne=Q=null;for(k in l)if(m=l[k],l.hasOwnProperty(k)&&m!=null&&!u.hasOwnProperty(k))switch(k){case"value":break;case"children":break;default:It(n,r,k,null,u,m)}for(S in u)if(m=u[S],g=l[S],u.hasOwnProperty(S)&&(m!=null||g!=null))switch(S){case"value":Q=m;break;case"defaultValue":ne=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(s(91));break;default:m!==g&&It(n,r,S,m,u,g)}_a(n,Q,ne);return;case"option":for(var ze in l)if(Q=l[ze],l.hasOwnProperty(ze)&&Q!=null&&!u.hasOwnProperty(ze))switch(ze){case"selected":n.selected=!1;break;default:It(n,r,ze,null,u,Q)}for(D in u)if(Q=u[D],ne=l[D],u.hasOwnProperty(D)&&Q!==ne&&(Q!=null||ne!=null))switch(D){case"selected":n.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:It(n,r,D,Q,u,ne)}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)Q=l[qe],l.hasOwnProperty(qe)&&Q!=null&&!u.hasOwnProperty(qe)&&It(n,r,qe,null,u,Q);for(V in u)if(Q=u[V],ne=l[V],u.hasOwnProperty(V)&&Q!==ne&&(Q!=null||ne!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(s(137,r));break;default:It(n,r,V,Q,u,ne)}return;default:if(xa(r)){for(var Ht in l)Q=l[Ht],l.hasOwnProperty(Ht)&&Q!==void 0&&!u.hasOwnProperty(Ht)&&Ed(n,r,Ht,void 0,u,Q);for(le in u)Q=u[le],ne=l[le],!u.hasOwnProperty(le)||Q===ne||Q===void 0&&ne===void 0||Ed(n,r,le,Q,u,ne);return}}for(var q in l)Q=l[q],l.hasOwnProperty(q)&&Q!=null&&!u.hasOwnProperty(q)&&It(n,r,q,null,u,Q);for(fe in u)Q=u[fe],ne=l[fe],!u.hasOwnProperty(fe)||Q===ne||Q==null&&ne==null||It(n,r,fe,Q,u,ne)}function gx(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sw(){if(typeof performance.getEntriesByType=="function"){for(var n=0,r=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var m=l[u],g=m.transferSize,S=m.initiatorType,k=m.duration;if(g&&k&&gx(S)){for(S=0,k=m.responseEnd,u+=1;u<l.length;u++){var D=l[u],V=D.startTime;if(V>k)break;var le=D.transferSize,fe=D.initiatorType;le&&gx(fe)&&(D=D.responseEnd,S+=le*(D<k?1:(k-V)/(D-V)))}if(--u,r+=8*(g+S)/(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 Nd=null,Td=null;function Bc(n){return n.nodeType===9?n:n.ownerDocument}function _x(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 xx(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 jd(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 Ad=null;function ww(){var n=window.event;return n&&n.type==="popstate"?n===Ad?!1:(Ad=n,!0):(Ad=null,!1)}var bx=typeof setTimeout=="function"?setTimeout:void 0,Cw=typeof clearTimeout=="function"?clearTimeout:void 0,vx=typeof Promise=="function"?Promise:void 0,kw=typeof queueMicrotask=="function"?queueMicrotask:typeof vx<"u"?function(n){return vx.resolve(null).then(n).catch(Ew)}:bx;function Ew(n){setTimeout(function(){throw n})}function bs(n){return n==="head"}function yx(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),Ka(r);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")Kl(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,Kl(l);for(var g=l.firstChild;g;){var S=g.nextSibling,k=g.nodeName;g[pn]||k==="SCRIPT"||k==="STYLE"||k==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=S}}else l==="body"&&Kl(n.ownerDocument.body);l=m}while(l);Ka(r)}function Sx(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 Rd(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":Rd(l),jr(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function Nw(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[pn])switch(r){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(g=n.getAttribute("rel"),g==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(g!==m.rel||n.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||n.getAttribute("title")!==(m.title==null?null:m.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(g=n.getAttribute("src"),(g!==(m.src==null?null:m.src)||n.getAttribute("type")!==(m.type==null?null:m.type)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(r==="input"&&n.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&n.getAttribute("name")===g)return n}else return n;if(n=Xn(n.nextSibling),n===null)break}return null}function Tw(n,r,l){if(r==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!l||(n=Xn(n.nextSibling),n===null))return null;return n}function wx(n,r){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!r||(n=Xn(n.nextSibling),n===null))return null;return n}function Md(n){return n.data==="$?"||n.data==="$~"}function Dd(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function jw(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 Xn(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 Bd=null;function Cx(n){n=n.nextSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"||l==="/&"){if(r===0)return Xn(n.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}n=n.nextSibling}return null}function kx(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 Ex(n,r,l){switch(r=Bc(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 Kl(n){for(var r=n.attributes;r.length;)n.removeAttributeNode(r[0]);jr(n)}var Zn=new Map,Nx=new Set;function Lc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Gr=z.d;z.d={f:Aw,r:Rw,D:Mw,C:Dw,L:Bw,m:Lw,X:zw,S:Ow,M:Pw};function Aw(){var n=Gr.f(),r=Ec();return n||r}function Rw(n){var r=li(n);r!==null&&r.tag===5&&r.type==="form"?qg(r):Gr.r(n)}var Wa=typeof document>"u"?null:document;function Tx(n,r,l){var u=Wa;if(u&&typeof r=="string"&&r){var m=ki(r);m='link[rel="'+n+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),Nx.has(m)||(Nx.add(m),n={rel:n,crossOrigin:l,href:r},u.querySelector(m)===null&&(r=u.createElement("link"),qi(r,"link",n),ct(r),u.head.appendChild(r)))}}function Mw(n){Gr.D(n),Tx("dns-prefetch",n,null)}function Dw(n,r){Gr.C(n,r),Tx("preconnect",n,r)}function Bw(n,r,l){Gr.L(n,r,l);var u=Wa;if(u&&n&&r){var m='link[rel="preload"][as="'+ki(r)+'"]';r==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+ki(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+ki(l.imageSizes)+'"]')):m+='[href="'+ki(n)+'"]';var g=m;switch(r){case"style":g=Ga(n);break;case"script":g=Ya(n)}Zn.has(g)||(n=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:n,as:r},l),Zn.set(g,n),u.querySelector(m)!==null||r==="style"&&u.querySelector(Vl(g))||r==="script"&&u.querySelector(Xl(g))||(r=u.createElement("link"),qi(r,"link",n),ct(r),u.head.appendChild(r)))}}function Lw(n,r){Gr.m(n,r);var l=Wa;if(l&&n){var u=r&&typeof r.as=="string"?r.as:"script",m='link[rel="modulepreload"][as="'+ki(u)+'"][href="'+ki(n)+'"]',g=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ya(n)}if(!Zn.has(g)&&(n=_({rel:"modulepreload",href:n},r),Zn.set(g,n),l.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Xl(g)))return}u=l.createElement("link"),qi(u,"link",n),ct(u),l.head.appendChild(u)}}}function Ow(n,r,l){Gr.S(n,r,l);var u=Wa;if(u&&n){var m=nr(u).hoistableStyles,g=Ga(n);r=r||"default";var S=m.get(g);if(!S){var k={loading:0,preload:null};if(S=u.querySelector(Vl(g)))k.loading=5;else{n=_({rel:"stylesheet",href:n,"data-precedence":r},l),(l=Zn.get(g))&&Ld(n,l);var D=S=u.createElement("link");ct(D),qi(D,"link",n),D._p=new Promise(function(V,le){D.onload=V,D.onerror=le}),D.addEventListener("load",function(){k.loading|=1}),D.addEventListener("error",function(){k.loading|=2}),k.loading|=4,Oc(S,r,u)}S={type:"stylesheet",instance:S,count:1,state:k},m.set(g,S)}}}function zw(n,r){Gr.X(n,r);var l=Wa;if(l&&n){var u=nr(l).hoistableScripts,m=Ya(n),g=u.get(m);g||(g=l.querySelector(Xl(m)),g||(n=_({src:n,async:!0},r),(r=Zn.get(m))&&Od(n,r),g=l.createElement("script"),ct(g),qi(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function Pw(n,r){Gr.M(n,r);var l=Wa;if(l&&n){var u=nr(l).hoistableScripts,m=Ya(n),g=u.get(m);g||(g=l.querySelector(Xl(m)),g||(n=_({src:n,async:!0,type:"module"},r),(r=Zn.get(m))&&Od(n,r),g=l.createElement("script"),ct(g),qi(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function jx(n,r,l,u){var m=(m=oe.current)?Lc(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=Ga(l.href),l=nr(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=Ga(l.href);var g=nr(m).hoistableStyles,S=g.get(n);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(n,S),(g=m.querySelector(Vl(n)))&&!g._p&&(S.instance=g,S.state.loading=5),Zn.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},Zn.set(n,l),g||Iw(m,n,l,S.state))),r&&u===null)throw Error(s(528,""));return S}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=Ya(l),l=nr(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 Ga(n){return'href="'+ki(n)+'"'}function Vl(n){return'link[rel="stylesheet"]['+n+"]"}function Ax(n){return _({},n,{"data-precedence":n.precedence,precedence:null})}function Iw(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}),qi(r,"link",l),ct(r),n.head.appendChild(r))}function Ya(n){return'[src="'+ki(n)+'"]'}function Xl(n){return"script[async]"+n}function Rx(n,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=n.querySelector('style[data-href~="'+ki(l.href)+'"]');if(u)return r.instance=u,ct(u),u;var m=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(n.ownerDocument||n).createElement("style"),ct(u),qi(u,"style",m),Oc(u,l.precedence,n),r.instance=u;case"stylesheet":m=Ga(l.href);var g=n.querySelector(Vl(m));if(g)return r.state.loading|=4,r.instance=g,ct(g),g;u=Ax(l),(m=Zn.get(m))&&Ld(u,m),g=(n.ownerDocument||n).createElement("link"),ct(g);var S=g;return S._p=new Promise(function(k,D){S.onload=k,S.onerror=D}),qi(g,"link",u),r.state.loading|=4,Oc(g,l.precedence,n),r.instance=g;case"script":return g=Ya(l.src),(m=n.querySelector(Xl(g)))?(r.instance=m,ct(m),m):(u=l,(m=Zn.get(g))&&(u=_({},l),Od(u,m)),n=n.ownerDocument||n,m=n.createElement("script"),ct(m),qi(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,Oc(u,l.precedence,n));return r.instance}function Oc(n,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,g=m,S=0;S<u.length;S++){var k=u[S];if(k.dataset.precedence===r)g=k;else if(g!==m)break}g?g.parentNode.insertBefore(n,g.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(n,r.firstChild))}function Ld(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.title==null&&(n.title=r.title)}function Od(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.integrity==null&&(n.integrity=r.integrity)}var zc=null;function Mx(n,r,l){if(zc===null){var u=new Map,m=zc=new Map;m.set(l,u)}else m=zc,u=m.get(l),u||(u=new Map,m.set(l,u));if(u.has(n))return u;for(u.set(n,null),l=l.getElementsByTagName(n),m=0;m<l.length;m++){var g=l[m];if(!(g[pn]||g[Je]||n==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=n+S;var k=u.get(S);k?k.push(g):u.set(S,[g])}}return u}function Dx(n,r,l){n=n.ownerDocument||n,n.head.insertBefore(l,r==="title"?n.querySelector("head > title"):null)}function Hw(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 Bx(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function Uw(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=Ga(u.href),g=r.querySelector(Vl(m));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(n.count++,n=Pc.bind(n),r.then(n,n)),l.state.loading|=4,l.instance=g,ct(g);return}g=r.ownerDocument||r,u=Ax(u),(m=Zn.get(m))&&Ld(u,m),g=g.createElement("link"),ct(g);var S=g;S._p=new Promise(function(k,D){S.onload=k,S.onerror=D}),qi(g,"link",u),l.instance=g}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=Pc.bind(n),r.addEventListener("load",l),r.addEventListener("error",l))}}var zd=0;function $w(n,r){return n.stylesheets&&n.count===0&&Hc(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var u=setTimeout(function(){if(n.stylesheets&&Hc(n,n.stylesheets),n.unsuspend){var g=n.unsuspend;n.unsuspend=null,g()}},6e4+r);0<n.imgBytes&&zd===0&&(zd=62500*Sw());var m=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Hc(n,n.stylesheets),n.unsuspend)){var g=n.unsuspend;n.unsuspend=null,g()}},(n.imgBytes>zd?50:800)+r);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Pc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Hc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Ic=null;function Hc(n,r){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Ic=new Map,r.forEach(Fw,n),Ic=null,Pc.call(n))}function Fw(n,r){if(!(r.state.loading&4)){var l=Ic.get(n);if(l)var u=l.get(null);else{l=new Map,Ic.set(n,l);for(var m=n.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var S=m[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(l.set(S.dataset.precedence,S),u=S)}u&&l.set(null,u)}m=r.instance,S=m.getAttribute("data-precedence"),g=l.get(S)||u,g===u&&l.set(null,m),l.set(S,m),this.count++,u=Pc.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),g?g.parentNode.insertBefore(m,g.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(m,n.firstChild)),r.state.loading|=4}}var Zl={$$typeof:O,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function qw(n,r,l,u,m,g,S,k,D){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=Re(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Re(0),this.hiddenUpdates=Re(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Lx(n,r,l,u,m,g,S,k,D,V,le,fe){return n=new qw(n,r,l,S,D,V,le,fe,k),r=1,g===!0&&(r|=24),g=Tn(3,null,null,r),n.current=g,g.stateNode=n,r=gh(),r.refCount++,n.pooledCache=r,r.refCount++,g.memoizedState={element:u,isDehydrated:l,cache:r},vh(g),n}function Ox(n){return n?(n=Ca,n):Ca}function zx(n,r,l,u,m,g){m=Ox(m),u.context===null?u.context=m:u.pendingContext=m,u=os(r),u.payload={element:l},g=g===void 0?null:g,g!==null&&(u.callback=g),l=cs(n,u,r),l!==null&&(vn(l,n,r),jl(l,n,r))}function Px(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Pd(n,r){Px(n,r),(n=n.alternate)&&Px(n,r)}function Ix(n){if(n.tag===13||n.tag===31){var r=Is(n,67108864);r!==null&&vn(r,n,67108864),Pd(n,67108864)}}function Hx(n){if(n.tag===13||n.tag===31){var r=Dn();r=Le(r);var l=Is(n,r);l!==null&&vn(l,n,r),Pd(n,r)}}var Uc=!0;function Ww(n,r,l,u){var m=j.T;j.T=null;var g=z.p;try{z.p=2,Id(n,r,l,u)}finally{z.p=g,j.T=m}}function Gw(n,r,l,u){var m=j.T;j.T=null;var g=z.p;try{z.p=8,Id(n,r,l,u)}finally{z.p=g,j.T=m}}function Id(n,r,l,u){if(Uc){var m=Hd(u);if(m===null)kd(n,r,u,$c,l),$x(n,u);else if(Kw(m,n,r,l,u))u.stopPropagation();else if($x(n,u),r&4&&-1<Yw.indexOf(n)){for(;m!==null;){var g=li(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=Ci(g.pendingLanes);if(S!==0){var k=g;for(k.pendingLanes|=2,k.entangledLanes|=2;S;){var D=1<<31-Oe(S);k.entanglements[1]|=D,S&=~D}xr(g),(Rt&6)===0&&(Cc=wt()+500,Wl(0))}}break;case 31:case 13:k=Is(g,2),k!==null&&vn(k,g,2),Ec(),Pd(g,2)}if(g=Hd(u),g===null&&kd(n,r,u,$c,l),g===m)break;m=g}m!==null&&u.stopPropagation()}else kd(n,r,u,null,l)}}function Hd(n){return n=ml(n),Ud(n)}var $c=null;function Ud(n){if($c=null,n=mi(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 $c=n,null}function Ux(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(hi()){case re:return 2;case xe:return 8;case Pe:case Fe:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var $d=!1,vs=null,ys=null,Ss=null,Ql=new Map,Jl=new Map,ws=[],Yw="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 $x(n,r){switch(n){case"focusin":case"focusout":vs=null;break;case"dragenter":case"dragleave":ys=null;break;case"mouseover":case"mouseout":Ss=null;break;case"pointerover":case"pointerout":Ql.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jl.delete(r.pointerId)}}function eo(n,r,l,u,m,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},r!==null&&(r=li(r),r!==null&&Ix(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function Kw(n,r,l,u,m){switch(r){case"focusin":return vs=eo(vs,n,r,l,u,m),!0;case"dragenter":return ys=eo(ys,n,r,l,u,m),!0;case"mouseover":return Ss=eo(Ss,n,r,l,u,m),!0;case"pointerover":var g=m.pointerId;return Ql.set(g,eo(Ql.get(g)||null,n,r,l,u,m)),!0;case"gotpointercapture":return g=m.pointerId,Jl.set(g,eo(Jl.get(g)||null,n,r,l,u,m)),!0}return!1}function Fx(n){var r=mi(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,pt(n.priority,function(){Hx(l)});return}}else if(r===31){if(r=h(l),r!==null){n.blockedOn=r,pt(n.priority,function(){Hx(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 Fc(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Hd(n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);is=u,l.target.dispatchEvent(u),is=null}else return r=li(l),r!==null&&Ix(r),n.blockedOn=l,!1;r.shift()}return!0}function qx(n,r,l){Fc(n)&&l.delete(r)}function Vw(){$d=!1,vs!==null&&Fc(vs)&&(vs=null),ys!==null&&Fc(ys)&&(ys=null),Ss!==null&&Fc(Ss)&&(Ss=null),Ql.forEach(qx),Jl.forEach(qx)}function qc(n,r){n.blockedOn===r&&(n.blockedOn=null,$d||($d=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Vw)))}var Wc=null;function Wx(n){Wc!==n&&(Wc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Wc===n&&(Wc=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(Ud(u||l)===null)continue;break}var g=li(l);g!==null&&(n.splice(r,3),r-=3,Hh(g,{pending:!0,data:m,method:l.method,action:u},u,m))}}))}function Ka(n){function r(D){return qc(D,n)}vs!==null&&qc(vs,n),ys!==null&&qc(ys,n),Ss!==null&&qc(Ss,n),Ql.forEach(r),Jl.forEach(r);for(var l=0;l<ws.length;l++){var u=ws[l];u.blockedOn===n&&(u.blockedOn=null)}for(;0<ws.length&&(l=ws[0],l.blockedOn===null);)Fx(l),l.blockedOn===null&&ws.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var m=l[u],g=l[u+1],S=m[ot]||null;if(typeof g=="function")S||Wx(l);else if(S){var k=null;if(g&&g.hasAttribute("formAction")){if(m=g,S=g[ot]||null)k=S.formAction;else if(Ud(m)!==null)continue}else k=S.action;typeof k=="function"?l[u+1]=k:(l.splice(u,3),u-=3),Wx(l)}}}function Gx(){function n(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return m=S})},focusReset:"manual",scroll:"manual"})}function r(){m!==null&&(m(),m=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,m=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),m!==null&&(m(),m=null)}}}function Fd(n){this._internalRoot=n}Gc.prototype.render=Fd.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));var l=r.current,u=Dn();zx(l,u,n,r,null,null)},Gc.prototype.unmount=Fd.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;zx(n.current,2,null,n,null,null),Ec(),r[Xe]=null}};function Gc(n){this._internalRoot=n}Gc.prototype.unstable_scheduleHydration=function(n){if(n){var r=bt();n={blockedOn:null,target:n,priority:r};for(var l=0;l<ws.length&&r!==0&&r<ws[l].priority;l++);ws.splice(l,0,n),l===0&&Fx(n)}};var Yx=t.version;if(Yx!=="19.2.3")throw Error(s(527,Yx,"19.2.3"));z.findDOMNode=function(n){var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=d(r),n=n!==null?x(n):null,n=n===null?null:n.stateNode,n};var Xw={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:j,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yc.isDisabled&&Yc.supportsFiber)try{Te=Yc.inject(Xw),me=Yc}catch{}}return io.createRoot=function(n,r){if(!a(n))throw Error(s(299));var l=!1,u="",m=e_,g=t_,S=i_;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(m=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=Lx(n,1,!1,null,null,l,u,null,m,g,S,Gx),n[Xe]=r.current,Cd(n),new Fd(r)},io.hydrateRoot=function(n,r,l){if(!a(n))throw Error(s(299));var u=!1,m="",g=e_,S=t_,k=i_,D=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(S=l.onCaughtError),l.onRecoverableError!==void 0&&(k=l.onRecoverableError),l.formState!==void 0&&(D=l.formState)),r=Lx(n,1,!0,r,l??null,u,m,D,g,S,k,Gx),r.context=Ox(null),l=r.current,u=Dn(),u=Le(u),m=os(u),m.callback=null,cs(l,m,u),l=u,r.current.lanes=l,We(r,l),xr(r),n[Xe]=r.current,Cd(n),new Gc(r)},io.version="19.2.3",io}var nb;function lC(){if(nb)return Gd.exports;nb=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(),Gd.exports=aC(),Gd.exports}var oC=lC();const cC=Du(oC);function uC({onLogin:e}){const[t,i]=C.useState(""),[s,a]=C.useState(null),[o,c]=C.useState(!1),h=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const d=await e(t);d&&a(d),c(!1)};return f.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:f.jsxs("div",{className:"w-full max-w-sm",children:[f.jsxs("div",{className:"border-border rounded border p-6",children:[f.jsxs("div",{className:"mb-6 text-center",children:[f.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),f.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),f.jsxs("form",{onSubmit:h,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),f.jsx("input",{type:"password",value:t,onChange:p=>i(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&f.jsx("p",{className:"text-error text-xs",children:s}),f.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),f.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function hC({onSetup:e}){const[t,i]=C.useState(""),[s,a]=C.useState(""),[o,c]=C.useState(null),[h,p]=C.useState(!1),d=async x=>{if(x.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return f.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:f.jsx("div",{className:"w-full max-w-sm",children:f.jsxs("div",{className:"border-border rounded border p-6",children:[f.jsxs("div",{className:"mb-6 text-center",children:[f.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),f.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),f.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),f.jsxs("form",{onSubmit:d,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),f.jsx("input",{type:"password",value:t,onChange:x=>i(x.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),f.jsx("input",{type:"password",value:s,onChange:x=>a(x.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&f.jsx("p",{className:"text-error text-xs",children:o}),f.jsx("button",{type:"submit",disabled:h||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:h?"setting up...":"create passphrase"})]})]})})})}const rb="http://localhost:7777";function yy({token:e}){const[t,i]=C.useState(null),[s,a]=C.useState(!1),[o,c]=C.useState(!1),[h,p]=C.useState(null),d=(y,E)=>fetch(y,{...E,headers:{...E==null?void 0:E.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),x=()=>{d(`${rb}/api/wallet`).then(y=>y.json()).then(y=>i(y)).catch(()=>i({exists:!1,error:"Failed to load wallet"}))};C.useEffect(()=>{x()},[]);const _=async()=>{a(!0),p(null);try{const y=await d(`${rb}/api/wallet/create`,{method:"POST"}),E=await y.json();if(!y.ok)throw new Error(E.error||"Creation failed");x()}catch(y){p(y instanceof Error?y.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},v=y=>`${y.slice(0,6)}...${y.slice(-4)}`;return f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&f.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),h&&f.jsx("p",{className:"text-error text-xs",children:h}),f.jsx("button",{onClick:_,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&&t.exists&&t.address&&f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),f.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:v(t.address)}),f.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),f.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"ETH"}),f.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"USDC"}),f.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"PLOT"}),f.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Network"}),f.jsx("span",{className:"text-foreground",children:"Base"})]})]}),f.jsxs("div",{className:"border-border border-t pt-3",children:[f.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),f.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),f.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Su(e){return!!e&&e.codex.installed&&e.codex.auth==="unknown"}const Op="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]=C.useState(""),[a,o]=C.useState(""),[c,h]=C.useState(null),[p,d]=C.useState(!1),[x,_]=C.useState(!1),[b,v]=C.useState(null),[y,E]=C.useState("AI Writer"),[A,T]=C.useState(""),[L,O]=C.useState(""),[J,$]=C.useState(!1),[M,X]=C.useState(null),[he,ye]=C.useState(""),[U,se]=C.useState(null),[W,G]=C.useState(!1),[Z,I]=C.useState(null),[j,z]=C.useState(null),[B,_e]=C.useState(null),N=C.useCallback((ie,oe)=>fetch(ie,{...oe,headers:{...oe==null?void 0:oe.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);C.useEffect(()=>{N("/api/settings/link-status").then(ie=>ie.json()).then(ie=>v(ie)).catch(()=>v({linked:!1}))},[]),C.useEffect(()=>{N("/api/agent/readiness").then(ie=>ie.ok?ie.json():null).then(ie=>{ie&&_e(ie)}).catch(()=>{})},[]);const R=async()=>{if(!y.trim()){X("Agent name is required");return}if(!A.trim()){X("Description is required");return}$(!0),X(null);try{const ie=await N("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:y,description:A,...L.trim()&&{genre:L}})}),oe=await ie.json();if(!ie.ok)throw new Error(oe.error||"Registration failed");v({linked:!0,agentId:oe.agentId,owsWallet:oe.owsWallet,txHash:oe.txHash})}catch(ie){X(ie instanceof Error?ie.message:"Registration failed")}$(!1)},Y=async()=>{if(!he.trim()||!/^0x[a-fA-F0-9]{40}$/.test(he)){I("Enter a valid wallet address (0x...)");return}G(!0),I(null),se(null);try{const ie=await N("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:he})}),oe=await ie.json();if(!ie.ok)throw new Error(oe.error||"Failed to generate binding code");se(oe)}catch(ie){I(ie instanceof Error?ie.message:"Failed to generate binding code")}G(!1)},w=async(ie,oe)=>{await navigator.clipboard.writeText(ie),z(oe),setTimeout(()=>z(null),2e3)},ae=async()=>{if(h(null),d(!1),!i||i.length<4){h("Passphrase must be at least 4 characters");return}if(i!==a){h("Passphrases do not match");return}_(!0);try{const ie=await N("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:i})});if(!ie.ok){const oe=await ie.json();throw new Error(oe.error||"Reset failed")}d(!0),s(""),o(""),setTimeout(()=>d(!1),3e3)}catch(ie){h(ie instanceof Error?ie.message:"Reset failed")}_(!1)};return f.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[f.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),f.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&f.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&f.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&f.jsx("p",{className:"text-muted text-xs",children:f.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),f.jsx("p",{className:"text-muted text-xs",children:f.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),f.jsx("input",{value:y,onChange:ie=>E(ie.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),f.jsx("input",{value:A,onChange:ie=>T(ie.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),f.jsx("input",{value:L,onChange:ie=>O(ie.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"})]}),M&&f.jsx("p",{className:"text-error text-xs",children:M}),f.jsx("button",{onClick:R,disabled:J||!y.trim()||!A.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:J?"Registering...":"Register Agent Identity"})]})]}),f.jsxs("div",{className:"border-border rounded border p-4","data-testid":"provider-readiness",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Providers"}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Claude"}),f.jsx("span",{className:"text-muted text-xs",children:B!=null&&B.claude.installed?"Installed":"Not detected"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex"}),f.jsx("span",{className:"text-muted text-xs",children:B!=null&&B.codex.installed?"Installed":"Not detected"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex version"}),f.jsx("span",{className:"text-muted text-xs font-mono",children:(B==null?void 0:B.codex.version)??"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Image generation"}),f.jsx("span",{className:"text-muted text-xs",children:(B==null?void 0:B.codex.imageGeneration)??"unknown"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Codex auth"}),f.jsx("span",{className:"text-muted text-xs","data-testid":"codex-auth-status",children:B!=null&&B.codex.installed?B.codex.auth==="ok"?"ok":"unclear":"—"})]}),Su(B)&&f.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"codex-auth-unknown-settings",children:Op}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-foreground text-sm",children:"Last checked"}),f.jsx("span",{className:"text-muted text-xs",children:B!=null&&B.checkedAt?new Date(B.checkedAt).toLocaleString():"—"})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?f.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",f.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),f.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[f.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),f.jsx("p",{children:'2. Click "Generate Binding Code"'}),f.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),f.jsx("input",{value:he,onChange:ie=>ye(ie.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"}),Z&&f.jsx("p",{className:"text-error text-xs",children:Z}),f.jsx("button",{onClick:Y,disabled:W||!he.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:W?"Generating...":"Generate Binding Code"}),U&&f.jsxs("div",{className:"space-y-3 mt-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),f.jsx("button",{onClick:()=>w(U.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:j==="signature"?"Copied!":"Copy"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),f.jsx("button",{onClick:()=>w(U.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:j==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&f.jsxs("div",{children:[f.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),f.jsx("button",{onClick:()=>w(String(U.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:j==="agentId"?"Copied!":"Copy"})]})]}),f.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),f.jsx(yy,{token:e}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("input",{type:"password",value:i,onChange:ie=>s(ie.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),f.jsx("input",{type:"password",value:a,onChange:ie=>o(ie.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&f.jsx("p",{className:"text-error text-xs",children:c}),p&&f.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),f.jsx("button",{onClick:ae,disabled:x||!i.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:x?"updating...":"update passphrase"})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),f.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const fC="http://localhost:7777";function pC({token:e}){const[t,i]=C.useState(null),s=(h,p)=>fetch(h,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${fC}/api/dashboard`).then(h=>h.json()).then(i)};C.useEffect(()=>{a()},[]);const o=h=>`${h.slice(0,6)}...${h.slice(-4)}`,c=h=>{if(!h)return"Unknown date";const p=new Date(h);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?f.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[f.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),f.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[f.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),f.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Address"}),f.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"ETH Balance"}),f.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"USDC Balance"}),f.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),f.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Royalties earned"}),f.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),f.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),f.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[f.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),f.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),f.jsxs("div",{className:"flex justify-between text-xs",children:[f.jsx("span",{className:"text-muted",children:"Stories published"}),f.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),f.jsxs("div",{className:"border-border rounded border p-4",children:[f.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?f.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):f.jsx("div",{className:"space-y-3",children:t.stories.published.map(h=>f.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{children:[h.genre&&f.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:h.genre}),f.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:h.title}),f.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:h.storyName})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[h.hasNotIndexed&&f.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),f.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[h.publishedFiles," published"]})]})]}),f.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium",children:h.plotCount}),f.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:h.storylineId?`#${h.storylineId}`:"—"}),f.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),f.jsxs("div",{className:"rounded bg-background p-1.5",children:[f.jsx("div",{className:"text-foreground text-sm font-medium",children:h.totalGasCostEth??"—"}),f.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),f.jsx("div",{className:"mt-2 space-y-1",children:h.files.map(p=>f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),f.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&f.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),f.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-muted",children:c(h.latestPublishedAt)}),h.storylineId&&f.jsx("a",{href:`https://plotlink.xyz/story/${h.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},h.id))})]}),t.stories.pendingFiles>0&&f.jsx("div",{className:"border-border rounded border p-4",children:f.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const mC={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},gC={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function _C({authFetch:e,selectedStory:t,selectedFile:i,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,h]=C.useState([]),[p,d]=C.useState([]),[x,_]=C.useState(new Set),[b,v]=C.useState(!1),y=C.useCallback(async()=>{try{const $=await e("/api/stories");if($.ok){const M=await $.json();h(M.stories)}}catch{}},[e]),E=C.useCallback(async()=>{try{const $=await e("/api/stories/archived");if($.ok){const M=await $.json();d(M.stories)}}catch{}},[e]),A=C.useCallback(async $=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})})).ok&&(E(),y())}catch{}},[e,E,y]);C.useEffect(()=>{y();const $=setInterval(y,5e3);return()=>clearInterval($)},[y]),C.useEffect(()=>{b&&E()},[b,E]),C.useEffect(()=>{t&&_($=>new Set($).add(t))},[t]);const T=$=>{_(M=>{const X=new Set(M);return X.has($)?X.delete($):X.add($),X})},L=$=>{var X;const M=$.map(he=>{var ye;return{file:he.file,num:(ye=he.file.match(/^plot-(\d+)\.md$/))==null?void 0:ye[1]}}).filter(he=>he.num!=null).sort((he,ye)=>parseInt(ye.num)-parseInt(he.num));return M.length>0?M[0].file:$.some(he=>he.file==="genesis.md")?"genesis.md":$.some(he=>he.file==="structure.md")?"structure.md":((X=$[0])==null?void 0:X.file)??null},O=$=>{if(T($.name),$.contentType==="cartoon")s($.name,"");else{const M=L($.files);M&&s($.name,M)}},J=$=>{const M=X=>{if(X==="structure.md")return 0;if(X==="genesis.md")return 1;const he=X.match(/^plot-(\d+)\.md$/);return he?2+parseInt(he[1]):100};return[...$].sort((X,he)=>M(X.file)-M(he.file))};return b?f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),f.jsx("span",{className:"text-xs text-muted",children:p.length})]}),f.jsx("div",{className:"px-3 py-2 border-b border-border",children:f.jsxs("button",{onClick:()=>v(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[f.jsx("span",{children:"←"}),f.jsx("span",{children:"Back"})]})}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?f.jsx("div",{className:"p-3 text-sm text-muted",children:f.jsx("p",{children:"No archived stories."})}):p.map($=>f.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[f.jsx("span",{className:"text-sm font-medium truncate",title:$.name,children:$.title||$.name}),f.jsx("button",{onClick:()=>A($.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},$.name))})]}):f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),f.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&f.jsx("div",{className:"px-3 py-2 border-b border-border",children:f.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[f.jsx("span",{children:"+"}),f.jsx("span",{children:"New Story"})]})}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map($=>f.jsx("div",{children:f.jsxs("button",{onClick:()=>s($,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===$?"bg-surface":""}`,children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),f.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},$)),c.length===0&&o.length===0?f.jsxs("div",{className:"p-3 text-sm text-muted",children:[f.jsx("p",{children:"No stories yet."}),f.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter($=>$.name!=="_example").map($=>f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>O($),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[f.jsx("span",{className:"text-xs text-muted",children:x.has($.name)?"▼":"▶"}),f.jsx("span",{className:"font-medium truncate",title:$.name,children:$.title||$.name}),$.contentType==="cartoon"&&f.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),f.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[$.publishedCount,"/",$.files.length]})]}),x.has($.name)&&f.jsx("div",{className:"pl-4",children:J($.files).map(M=>{const X=t===$.name&&i===M.file;return f.jsxs("button",{onClick:()=>s($.name,M.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${X?"bg-surface font-medium":""}`,children:[f.jsx("span",{className:gC[M.status],children:mC[M.status]}),f.jsx("span",{className:"truncate font-mono",children:M.file})]},M.file)})})]},$.name))]}),f.jsx("div",{className:"px-3 py-2 border-t border-border",children:f.jsx("button",{onClick:()=>v(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:f.jsx("span",{children:"Archives"})})})]})}/**
|
|
50
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
51
|
+
* @license MIT
|
|
52
|
+
*
|
|
53
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
54
|
+
* @license MIT
|
|
55
|
+
*
|
|
56
|
+
* Originally forked from (with the author's permission):
|
|
57
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
58
|
+
* http://bellard.org/jslinux/
|
|
59
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
60
|
+
*/var Sy=Object.defineProperty,xC=Object.getOwnPropertyDescriptor,bC=(e,t)=>{for(var i in t)Sy(e,i,{get:t[i],enumerable:!0})},si=(e,t,i,s)=>{for(var a=s>1?void 0:s?xC(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&&Sy(t,i,a),a},Me=(e,t)=>(i,s)=>t(i,s,e),sb="Terminal input",Of={get:()=>sb,set:e=>sb=e},ab="Too much output to announce, navigate to rows manually to read",zf={get:()=>ab,set:e=>ab=e};function vC(e){return e.replace(/\r?\n/g,"\r")}function yC(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function SC(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function wC(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");wy(a,t,i,s)}}function wy(e,t,i,s){e=vC(e),e=yC(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Cy(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 lb(e,t,i,s,a){Cy(e,t,i),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function js(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Bu(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 CC=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}},kC=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,a,o,c,h,p=0,d=0;if(this.interim[0]){let b=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let y=0,E;for(;(E=this.interim[++y]&63)&&y<4;)v<<=6,v|=E;let A=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,T=A-y;for(;d<T;){if(d>=i)return 0;if(E=e[d++],(E&192)!==128){d--,b=!0;break}else this.interim[y++]=E,v<<=6,v|=E&63}b||(A===2?v<128?d--:t[s++]=v:A===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let x=i-4,_=d;for(;_<i;){for(;_<x&&!((a=e[_])&128)&&!((o=e[_+1])&128)&&!((c=e[_+2])&128)&&!((h=e[_+3])&128);)t[s++]=a,t[s++]=o,t[s++]=c,t[s++]=h,_+=4;if(a=e[_++],a<128)t[s++]=a;else if((a&224)===192){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=i)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(h=e[_++],(h&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},ky="",Rs=" ",Ao=class Ey{constructor(){this.fg=0,this.bg=0,this.extended=new wu}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 Ey;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}},wu=class Ny{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 Ny(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ir=class Ty extends Ao{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wu,this.combinedData=""}static fromCharData(t){let i=new Ty;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?js(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()]}},ob="di$target",Pf="di$dependencies",Xd=new Map;function EC(e){return e[Pf]||[]}function Hi(e){if(Xd.has(e))return Xd.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");NC(t,i,a)};return t._id=e,Xd.set(e,t),t}function NC(e,t,i){t[ob]===t?t[Pf].push({id:e,index:i}):(t[Pf]=[{id:e,index:i}],t[ob]=t)}var hn=Hi("BufferService"),jy=Hi("CoreMouseService"),ca=Hi("CoreService"),TC=Hi("CharsetService"),zp=Hi("InstantiationService"),Ay=Hi("LogService"),dn=Hi("OptionsService"),Ry=Hi("OscLinkService"),jC=Hi("UnicodeService"),Ro=Hi("DecorationService"),If=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var x;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new ir,c=i.getTrimmedLength(),h=-1,p=-1,d=!1;for(let _=0;_<c;_++)if(!(p===-1&&!i.hasContent(_))){if(i.loadCell(_,o),o.hasExtendedAttrs()&&o.extended.urlId)if(p===-1){p=_,h=o.extended.urlId;continue}else d=o.extended.urlId!==h;else p!==-1&&(d=!0);if(d||p!==-1&&_===c-1){let b=(x=this._oscLinkService.getLinkData(h))==null?void 0:x.uri;if(b){let v={start:{x:p+1,y:e},end:{x:_+(!d&&_===c-1?1:0),y:e}},y=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let E=new URL(b);["http:","https:"].includes(E.protocol)||(y=!0)}catch{y=!0}y||s.push({text:b,range:v,activate:(E,A)=>a?a.activate(E,A,v):AC(E,A),hover:(E,A)=>{var T;return(T=a==null?void 0:a.hover)==null?void 0:T.call(a,E,A,v)},leave:(E,A)=>{var T;return(T=a==null?void 0:a.leave)==null?void 0:T.call(a,E,A,v)}})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,h=o.extended.urlId):(p=-1,h=-1)}}t(s)}};If=si([Me(0,hn),Me(1,dn),Me(2,Ry)],If);function AC(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 Lu=Hi("CharSizeService"),Qr=Hi("CoreBrowserService"),Pp=Hi("MouseService"),Jr=Hi("RenderService"),RC=Hi("SelectionService"),My=Hi("CharacterJoinerService"),cl=Hi("ThemeService"),Dy=Hi("LinkProviderService"),MC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cb.isErrorNoTelemetry(e)?new cb(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)}},DC=new MC;function hu(e){BC(e)||DC.onUnexpectedError(e)}var Hf="Canceled";function BC(e){return e instanceof LC?!0:e instanceof Error&&e.name===Hf&&e.message===Hf}var LC=class extends Error{constructor(){super(Hf),this.name=this.message}};function OC(e){return new Error(`Illegal argument: ${e}`)}var cb=class Uf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Uf)return t;let i=new Uf;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},$f=class By extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,By.prototype)}};function Bn(e,t=0){return e[e.length-(1+t)]}var zC;(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})(zC||(zC={}));function PC(e,t){let i=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(i,arguments))),a}}var Ly;(e=>{function t(J){return J&&typeof J=="object"&&typeof J[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*a(J){yield J}e.single=a;function o(J){return t(J)?J:a(J)}e.wrap=o;function c(J){return J||i}e.from=c;function*h(J){for(let $=J.length-1;$>=0;$--)yield J[$]}e.reverse=h;function p(J){return!J||J[Symbol.iterator]().next().done===!0}e.isEmpty=p;function d(J){return J[Symbol.iterator]().next().value}e.first=d;function x(J,$){let M=0;for(let X of J)if($(X,M++))return!0;return!1}e.some=x;function _(J,$){for(let M of J)if($(M))return M}e.find=_;function*b(J,$){for(let M of J)$(M)&&(yield M)}e.filter=b;function*v(J,$){let M=0;for(let X of J)yield $(X,M++)}e.map=v;function*y(J,$){let M=0;for(let X of J)yield*$(X,M++)}e.flatMap=y;function*E(...J){for(let $ of J)yield*$}e.concat=E;function A(J,$,M){let X=M;for(let he of J)X=$(X,he);return X}e.reduce=A;function*T(J,$,M=J.length){for($<0&&($+=J.length),M<0?M+=J.length:M>J.length&&(M=J.length);$<M;$++)yield J[$]}e.slice=T;function L(J,$=Number.POSITIVE_INFINITY){let M=[];if($===0)return[M,J];let X=J[Symbol.iterator]();for(let he=0;he<$;he++){let ye=X.next();if(ye.done)return[M,e.empty()];M.push(ye.value)}return[M,{[Symbol.iterator](){return X}}]}e.consume=L;async function O(J){let $=[];for await(let M of J)$.push(M);return Promise.resolve($)}e.asyncToArray=O})(Ly||(Ly={}));function aa(e){if(Ly.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 IC(...e){return Qt(()=>aa(e))}function Qt(e){return{dispose:PC(()=>{e()})}}var Oy=class zy{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{aa(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?zy.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)}};Oy.DISABLE_DISPOSED_WARNING=!1;var Ms=Oy,dt=class{constructor(){this._store=new Ms,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 al=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}},Zr=typeof window=="object"?window:globalThis,Ff=class qf{constructor(t){this.element=t,this.next=qf.Undefined,this.prev=qf.Undefined}};Ff.Undefined=new Ff(void 0);var Jt=Ff,ub=class{constructor(){this._first=Jt.Undefined,this._last=Jt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Jt.Undefined}clear(){let e=this._first;for(;e!==Jt.Undefined;){let t=e.next;e.prev=Jt.Undefined,e.next=Jt.Undefined,e=t}this._first=Jt.Undefined,this._last=Jt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new Jt(e);if(this._first===Jt.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!==Jt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Jt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Jt.Undefined&&e.next!==Jt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Jt.Undefined&&e.next===Jt.Undefined?(this._first=Jt.Undefined,this._last=Jt.Undefined):e.next===Jt.Undefined?(this._last=this._last.prev,this._last.next=Jt.Undefined):e.prev===Jt.Undefined&&(this._first=this._first.next,this._first.prev=Jt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Jt.Undefined;)yield e.element,e=e.next}},HC=globalThis.performance&&typeof globalThis.performance.now=="function",UC=class Py{static create(t){return new Py(t)}constructor(t){this._now=HC&&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}},Yi;(e=>{e.None=()=>dt.None;function t(W,G){return _(W,()=>{},0,void 0,!0,void 0,G)}e.defer=t;function i(W){return(G,Z=null,I)=>{let j=!1,z;return z=W(B=>{if(!j)return z?z.dispose():j=!0,G.call(Z,B)},null,I),j&&z.dispose(),z}}e.once=i;function s(W,G,Z){return d((I,j=null,z)=>W(B=>I.call(j,G(B)),null,z),Z)}e.map=s;function a(W,G,Z){return d((I,j=null,z)=>W(B=>{G(B),I.call(j,B)},null,z),Z)}e.forEach=a;function o(W,G,Z){return d((I,j=null,z)=>W(B=>G(B)&&I.call(j,B),null,z),Z)}e.filter=o;function c(W){return W}e.signal=c;function h(...W){return(G,Z=null,I)=>{let j=IC(...W.map(z=>z(B=>G.call(Z,B))));return x(j,I)}}e.any=h;function p(W,G,Z,I){let j=Z;return s(W,z=>(j=G(j,z),j),I)}e.reduce=p;function d(W,G){let Z,I={onWillAddFirstListener(){Z=W(j.fire,j)},onDidRemoveLastListener(){Z==null||Z.dispose()}},j=new ke(I);return G==null||G.add(j),j.event}function x(W,G){return G instanceof Array?G.push(W):G&&G.add(W),W}function _(W,G,Z=100,I=!1,j=!1,z,B){let _e,N,R,Y=0,w,ae={leakWarningThreshold:z,onWillAddFirstListener(){_e=W(oe=>{Y++,N=G(N,oe),I&&!R&&(ie.fire(N),N=void 0),w=()=>{let F=N;N=void 0,R=void 0,(!I||Y>1)&&ie.fire(F),Y=0},typeof Z=="number"?(clearTimeout(R),R=setTimeout(w,Z)):R===void 0&&(R=0,queueMicrotask(w))})},onWillRemoveListener(){j&&Y>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,_e.dispose()}},ie=new ke(ae);return B==null||B.add(ie),ie.event}e.debounce=_;function b(W,G=0,Z){return e.debounce(W,(I,j)=>I?(I.push(j),I):[j],G,void 0,!0,void 0,Z)}e.accumulate=b;function v(W,G=(I,j)=>I===j,Z){let I=!0,j;return o(W,z=>{let B=I||!G(z,j);return I=!1,j=z,B},Z)}e.latch=v;function y(W,G,Z){return[e.filter(W,G,Z),e.filter(W,I=>!G(I),Z)]}e.split=y;function E(W,G=!1,Z=[],I){let j=Z.slice(),z=W(N=>{j?j.push(N):_e.fire(N)});I&&I.add(z);let B=()=>{j==null||j.forEach(N=>_e.fire(N)),j=null},_e=new ke({onWillAddFirstListener(){z||(z=W(N=>_e.fire(N)),I&&I.add(z))},onDidAddFirstListener(){j&&(G?setTimeout(B):B())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return I&&I.add(_e),_e.event}e.buffer=E;function A(W,G){return(Z,I,j)=>{let z=G(new L);return W(function(B){let _e=z.evaluate(B);_e!==T&&Z.call(I,_e)},void 0,j)}}e.chain=A;let T=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(G){return this.steps.push(G),this}forEach(G){return this.steps.push(Z=>(G(Z),Z)),this}filter(G){return this.steps.push(Z=>G(Z)?Z:T),this}reduce(G,Z){let I=Z;return this.steps.push(j=>(I=G(I,j),I)),this}latch(G=(Z,I)=>Z===I){let Z=!0,I;return this.steps.push(j=>{let z=Z||!G(j,I);return Z=!1,I=j,z?j:T}),this}evaluate(G){for(let Z of this.steps)if(G=Z(G),G===T)break;return G}}function O(W,G,Z=I=>I){let I=(..._e)=>B.fire(Z(..._e)),j=()=>W.on(G,I),z=()=>W.removeListener(G,I),B=new ke({onWillAddFirstListener:j,onDidRemoveLastListener:z});return B.event}e.fromNodeEventEmitter=O;function J(W,G,Z=I=>I){let I=(..._e)=>B.fire(Z(..._e)),j=()=>W.addEventListener(G,I),z=()=>W.removeEventListener(G,I),B=new ke({onWillAddFirstListener:j,onDidRemoveLastListener:z});return B.event}e.fromDOMEventEmitter=J;function $(W){return new Promise(G=>i(W)(G))}e.toPromise=$;function M(W){let G=new ke;return W.then(Z=>{G.fire(Z)},()=>{G.fire(void 0)}).finally(()=>{G.dispose()}),G.event}e.fromPromise=M;function X(W,G){return W(Z=>G.fire(Z))}e.forward=X;function he(W,G,Z){return G(Z),W(I=>G(I))}e.runAndSubscribe=he;class ye{constructor(G,Z){this._observable=G,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{G.addObserver(this)},onDidRemoveLastListener:()=>{G.removeObserver(this)}};this.emitter=new ke(I),Z&&Z.add(this.emitter)}beginUpdate(G){this._counter++}handlePossibleChange(G){}handleChange(G,Z){this._hasChanged=!0}endUpdate(G){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(W,G){return new ye(W,G).emitter.event}e.fromObservable=U;function se(W){return(G,Z,I)=>{let j=0,z=!1,B={beginUpdate(){j++},endUpdate(){j--,j===0&&(W.reportChanges(),z&&(z=!1,G.call(Z)))},handlePossibleChange(){},handleChange(){z=!0}};W.addObserver(B),W.reportChanges();let _e={dispose(){W.removeObserver(B)}};return I instanceof Ms?I.add(_e):Array.isArray(I)&&I.push(_e),_e}}e.fromObservableLight=se})(Yi||(Yi={}));var Wf=class Gf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Gf._idPool++}`,Gf.all.add(this)}start(t){this._stopWatch=new UC,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}}};Wf.all=new Set,Wf._idPool=0;var $C=Wf,FC=-1,Iy=class Hy{constructor(t,i,s=(Hy._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 GC(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}};Iy._idPool=1;var qC=Iy,WC=class Uy{constructor(t){this.value=t}static create(){let t=new Error;return new Uy(t.stack??"")}print(){console.warn(this.value.split(`
|
|
67
|
+
`).slice(2).join(`
|
|
68
|
+
`))}},GC=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},YC=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},KC=0,Zd=class{constructor(e){this.value=e,this.id=KC++}},VC=2,XC,ke=class{constructor(t){var i,s,a,o;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new qC((t==null?void 0:t.onListenerError)??hu,((s=this._options)==null?void 0:s.leakWarningThreshold)??FC):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new $C(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,i,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var h,p,d,x,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new YC(`${b}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((h=this._options)==null?void 0:h.onListenerError)||hu)(y),dt.None}if(this._disposed)return dt.None;i&&(t=t.bind(i));let a=new Zd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=WC.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zd?(this._deliveryQueue??(this._deliveryQueue=new ZC),this._listeners=[this._listeners,a]):this._listeners.push(a):((d=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||d.call(p,this),this._listeners=a,(_=(x=this._options)==null?void 0:x.onDidAddFirstListener)==null||_.call(x,this)),this._size++;let c=Qt(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ms?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*VC<=i.length){let d=0;for(let x=0;x<i.length;x++)i[x]?i[d++]=i[x]:a&&(this._deliveryQueue.end--,d<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=d}}_deliver(t,i){var a;if(!t)return;let s=((a=this._options)==null?void 0:a.onListenerError)||hu;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 Zd)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}},ZC=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}},Yf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Yf.INSTANCE=new Yf;var Ip=Yf;function QC(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Ip.INSTANCE.onDidChangeZoomLevel;function JC(e){return Ip.INSTANCE.getZoomFactor(e)}Ip.INSTANCE.onDidChangeFullscreen;var ul=typeof navigator=="object"?navigator.userAgent:"",Kf=ul.indexOf("Firefox")>=0,ek=ul.indexOf("AppleWebKit")>=0,Hp=ul.indexOf("Chrome")>=0,tk=!Hp&&ul.indexOf("Safari")>=0;ul.indexOf("Electron/")>=0;ul.indexOf("Android")>=0;var Qd=!1;if(typeof Zr.matchMedia=="function"){let e=Zr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Zr.matchMedia("(display-mode: fullscreen)");Qd=e.matches,QC(Zr,e,({matches:i})=>{Qd&&t.matches||(Qd=i)})}var il="en",Vf=!1,Xf=!1,du=!1,$y=!1,Kc,fu=il,hb=il,ik,hr,sa=globalThis,Gi,xy;typeof sa.vscode<"u"&&typeof sa.vscode.process<"u"?Gi=sa.vscode.process:typeof process<"u"&&typeof((xy=process==null?void 0:process.versions)==null?void 0:xy.node)=="string"&&(Gi=process);var by,nk=typeof((by=Gi==null?void 0:Gi.versions)==null?void 0:by.electron)=="string",rk=nk&&(Gi==null?void 0:Gi.type)==="renderer",vy;if(typeof Gi=="object"){Vf=Gi.platform==="win32",Xf=Gi.platform==="darwin",du=Gi.platform==="linux",du&&Gi.env.SNAP&&Gi.env.SNAP_REVISION,Gi.env.CI||Gi.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Kc=il,fu=il;let e=Gi.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Kc=t.userLocale,hb=t.osLocale,fu=t.resolvedLanguage||il,ik=(vy=t.languagePack)==null?void 0:vy.translationsConfigFile}catch{}$y=!0}else typeof navigator=="object"&&!rk?(hr=navigator.userAgent,Vf=hr.indexOf("Windows")>=0,Xf=hr.indexOf("Macintosh")>=0,(hr.indexOf("Macintosh")>=0||hr.indexOf("iPad")>=0||hr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,du=hr.indexOf("Linux")>=0,(hr==null?void 0:hr.indexOf("Mobi"))>=0,fu=globalThis._VSCODE_NLS_LANGUAGE||il,Kc=navigator.language.toLowerCase(),hb=Kc):console.error("Unable to resolve platform.");var Fy=Vf,Er=Xf,sk=du,db=$y,Nr=hr,ks=fu,ak;(e=>{function t(){return ks}e.value=t;function i(){return ks.length===2?ks==="en":ks.length>=3?ks[0]==="e"&&ks[1]==="n"&&ks[2]==="-":!1}e.isDefaultVariant=i;function s(){return ks==="en"}e.isDefault=s})(ak||(ak={}));var lk=typeof sa.postMessage=="function"&&!sa.importScripts;(()=>{if(lk){let e=[];sa.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}),sa.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var ok=!!(Nr&&Nr.indexOf("Chrome")>=0);Nr&&Nr.indexOf("Firefox")>=0;!ok&&Nr&&Nr.indexOf("Safari")>=0;Nr&&Nr.indexOf("Edg/")>=0;Nr&&Nr.indexOf("Android")>=0;var Va=typeof navigator=="object"?navigator:{};db||document.queryCommandSupported&&document.queryCommandSupported("copy")||Va&&Va.clipboard&&Va.clipboard.writeText,db||Va&&Va.clipboard&&Va.clipboard.readText;var Up=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}},Jd=new Up,fb=new Up,pb=new Up,ck=new Array(230),qy;(e=>{function t(h){return Jd.keyCodeToStr(h)}e.toString=t;function i(h){return Jd.strToKeyCode(h)}e.fromString=i;function s(h){return fb.keyCodeToStr(h)}e.toUserSettingsUS=s;function a(h){return pb.keyCodeToStr(h)}e.toUserSettingsGeneral=a;function o(h){return fb.strToKeyCode(h)||pb.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 Jd.keyCodeToStr(h)}e.toElectronAccelerator=c})(qy||(qy={}));var uk=class Wy{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 Wy&&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 hk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},hk=class{constructor(e){if(e.length===0)throw OC("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 qy.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Kf)switch(t){case 59:return 85;case 60:if(sk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Er)return 57;break}else if(ek&&(Er&&t===93||!Er&&t===92))return 57;return ck[t]||0}var fk=Er?256:2048,pk=512,mk=1024,gk=Er?2048:256,mb=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|=fk),this.altKey&&(t|=pk),this.shiftKey&&(t|=mk),this.metaKey&&(t|=gk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new uk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},gb=new WeakMap;function _k(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 xk=class{static getSameOriginWindowChain(e){let t=gb.get(e);if(!t){t=[],gb.set(e,t);let i=e,s;do s=_k(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}}},Vc=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=xk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},_b=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(Hp){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?Kf&&!Er?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")tk&&Fy?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?Kf&&!Er?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()}},Gy=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),bk;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof vk?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Yi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gy})})(bk||(bk={}));var vk=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?Gy:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$p=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 $f("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new $f("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},yk=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 $f("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=Qt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Sk;(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})(Sk||(Sk={}));var xb=class Jn{static fromArray(t){return new Jn(i=>{i.emitMany(t)})}static fromPromise(t){return new Jn(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Jn(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Jn(async i=>{await Promise.all(t.map(async s=>{for await(let a of s)i.emitOne(a)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Yi.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 Jn(async s=>{for await(let a of t)s.emitOne(i(a))})}map(t){return Jn.map(this,t)}static filter(t,i){return new Jn(async s=>{for await(let a of t)i(a)&&s.emitOne(a)})}filter(t){return Jn.filter(this,t)}static coalesce(t){return Jn.filter(t,i=>!!i)}coalesce(){return Jn.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Jn.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())}};xb.EMPTY=xb.fromArray([]);var{getWindow:wr,getWindowId:wk,onDidRegisterWindow:Ck}=(function(){let e=new Map,t={window:Zr,disposables:new Ms};e.set(Zr.vscodeWindowId,t);let i=new ke,s=new ke,a=new ke;function o(c,h){return(typeof c=="number"?e.get(c):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return dt.None;let h=new Ms,p={window:c,disposables:h.add(new Ms)};return e.set(c.vscodeWindowId,p),h.add(Qt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(Ye(c,Mi.BEFORE_UNLOAD,()=>{a.fire(c)})),i.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var d;let h=c;if((d=h==null?void 0:h.ownerDocument)!=null&&d.defaultView)return h.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Zr},getDocument(c){return wr(c).document}}})(),kk=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 Ye(e,t,i,s){return new kk(e,t,i,s)}var bb=function(e,t,i,s){return Ye(e,t,i,s)},Fp,Ek=class extends yk{constructor(e){super(),this.defaultTarget=e&&wr(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},vb=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){hu(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(vb.sort),c.shift().execute();s.set(o,!1)};Fp=(o,c,h=0)=>{let p=wk(o),d=new vb(c,h),x=e.get(p);return x||(x=[],e.set(p,x)),x.push(d),i.get(p)||(i.set(p,!0),o.requestAnimationFrame(()=>a(p))),d}})();function Nk(e){let t=e.getBoundingClientRect(),i=wr(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Mi={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"},Tk=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=yn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yn(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=yn(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=yn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yn(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 yn(e){return typeof e=="number"?`${e}px`:e}function bo(e){return new Tk(e)}var Yy=class{constructor(){this._hooks=new Ms,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(Qt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=wr(e)}this._hooks.add(Ye(o,Mi.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ye(o,Mi.POINTER_UP,c=>this.stopMonitoring(!0)))}};function jk(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 yr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(yr||(yr={}));var po=class Zi extends dt{constructor(){super(),this.dispatched=!1,this.targets=new ub,this.ignoreTargets=new ub,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Yi.runAndSubscribe(Ck,({window:t,disposables:i})=>{i.add(Ye(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ye(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ye(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Zr,disposables:this._store}))}static addTarget(t){if(!Zi.isTouchDevice())return dt.None;Zi.INSTANCE||(Zi.INSTANCE=new Zi);let i=Zi.INSTANCE.targets.push(t);return Qt(i)}static ignoreTarget(t){if(!Zi.isTouchDevice())return dt.None;Zi.INSTANCE||(Zi.INSTANCE=new Zi);let i=Zi.INSTANCE.ignoreTargets.push(t);return Qt(i)}static isTouchDevice(){return"ontouchstart"in Zr||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(yr.Start,o.target);c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),a=Object.keys(this.activeTouches).length;for(let o=0,c=i.changedTouches.length;o<c;o++){let h=i.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],d=Date.now()-p.initialTimeStamp;if(d<Zi.HOLD_DELAY&&Math.abs(p.initialPageX-Bn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Bn(p.rollingPageY))<30){let x=this.newGestureEvent(yr.Tap,p.initialTarget);x.pageX=Bn(p.rollingPageX),x.pageY=Bn(p.rollingPageY),this.dispatchEvent(x)}else if(d>=Zi.HOLD_DELAY&&Math.abs(p.initialPageX-Bn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Bn(p.rollingPageY))<30){let x=this.newGestureEvent(yr.Contextmenu,p.initialTarget);x.pageX=Bn(p.rollingPageX),x.pageY=Bn(p.rollingPageY),this.dispatchEvent(x)}else if(a===1){let x=Bn(p.rollingPageX),_=Bn(p.rollingPageY),b=Bn(p.rollingTimestamps)-p.rollingTimestamps[0],v=x-p.rollingPageX[0],y=_-p.rollingPageY[0],E=[...this.targets].filter(A=>p.initialTarget instanceof Node&&A.contains(p.initialTarget));this.inertia(t,E,s,Math.abs(v)/b,v>0?1:-1,x,Math.abs(y)/b,y>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(yr.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===yr.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Zi.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===yr.Change||t.type===yr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;i.push([a,s])}i.sort((s,a)=>s[0]-a[0]);for(let[s,a]of i)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,a,o,c,h,p,d){this.handle=Fp(t,()=>{let x=Date.now(),_=x-s,b=0,v=0,y=!0;a+=Zi.SCROLL_FRICTION*_,h+=Zi.SCROLL_FRICTION*_,a>0&&(y=!1,b=o*a*_),h>0&&(y=!1,v=p*h*_);let E=this.newGestureEvent(yr.Change);E.translationX=b,E.translationY=v,i.forEach(A=>A.dispatchEvent(E)),y||this.inertia(t,i,x,a,o,c+b,h,p,d+v)})}onTouchMove(t){let i=Date.now();for(let s=0,a=t.changedTouches.length;s<a;s++){let o=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let c=this.activeTouches[o.identifier],h=this.newGestureEvent(yr.Change,c.initialTarget);h.translationX=o.pageX-Bn(c.rollingPageX),h.translationY=o.pageY-Bn(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)}};po.SCROLL_FRICTION=-.005,po.HOLD_DELAY=700,po.CLEAR_TAP_COUNT_TIME=400,si([jk],po,"isTouchDevice",1);var Ak=po,qp=class extends dt{onclick(e,t){this._register(Ye(e,Mi.CLICK,i=>t(new Vc(wr(e),i))))}onmousedown(e,t){this._register(Ye(e,Mi.MOUSE_DOWN,i=>t(new Vc(wr(e),i))))}onmouseover(e,t){this._register(Ye(e,Mi.MOUSE_OVER,i=>t(new Vc(wr(e),i))))}onmouseleave(e,t){this._register(Ye(e,Mi.MOUSE_LEAVE,i=>t(new Vc(wr(e),i))))}onkeydown(e,t){this._register(Ye(e,Mi.KEY_DOWN,i=>t(new mb(i))))}onkeyup(e,t){this._register(Ye(e,Mi.KEY_UP,i=>t(new mb(i))))}oninput(e,t){this._register(Ye(e,Mi.INPUT,t))}onblur(e,t){this._register(Ye(e,Mi.BLUR,t))}onfocus(e,t){this._register(Ye(e,Mi.FOCUS,t))}onchange(e,t){this._register(Ye(e,Mi.CHANGE,t))}ignoreGesture(e){return Ak.ignoreTarget(e)}},yb=11,Rk=class extends qp{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=yb+"px",this.domNode.style.height=yb+"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 Yy),this._register(bb(this.bgDomNode,Mi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bb(this.domNode,Mi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ek),this._pointerdownScheduleRepeatTimer=this._register(new $p)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,wr(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()}},Mk=class Zf{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 Zf(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 Zf(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}}},Dk=class extends dt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Mk(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 wb(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=wb.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)))}},Sb=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ef(e,t){let i=t-e;return function(s){return e+i*Ok(s)}}function Bk(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var wb=class Qf{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),Bk(ef(t,a),ef(o,i),.33)}return ef(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 Sb(s,a,!1)}return new Sb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Qf.start(t,i,s)}static start(t,i,s){s=s+10;let a=Date.now()-10;return new Qf(t,i,a,s)}};function Lk(e){return Math.pow(e,3)}function Ok(e){return 1-Lk(1-e)}var zk=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 $p)}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":"")))}},Pk=140,Ky=class extends qp{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 zk(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Yy),this._shouldRender=!0,this.domNode=bo(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(Ye(this.domNode.domNode,Mi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Rk(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=bo(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(Ye(this.slider.domNode,Mi.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=Nk(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(Fy&&c>Pk){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()}},Vy=class Jf{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 Jf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,a,o){let c=Math.max(0,s-t),h=Math.max(0,c-2*i),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(s*h/a))),x=(h-d)/(a-s),_=o*x;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:x,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Jf._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)}},Ik=class extends Ky{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Vy(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}},Hk=class extends Ky{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Vy(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}},Uk=500,Cb=50,$k=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},ep=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(Hp){let i=wr(t.browserEvent),s=JC(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 $k(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,a)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(i.deltaX),h=Math.abs(i.deltaY),p=Math.max(Math.min(a,c),1),d=Math.max(Math.min(o,h),1),x=Math.max(a,c),_=Math.max(o,h);x%p===0&&_%d===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ep.INSTANCE=new ep;var Fk=ep,qk=class extends qp{constructor(e,t,i){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=Gk(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 Hk(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Ik(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=bo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=bo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=bo(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 $p),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aa(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,Er&&(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 _b(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=aa(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new _b(i))};this._mouseWheelToDispose.push(Ye(this._listenOnDomNode,Mi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=Fk.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=!Er&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),d={};if(o){let x=Cb*o,_=p.scrollTop-(x<0?Math.floor(x):Math.ceil(x));this._verticalScrollbar.writeScrollPosition(d,_)}if(c){let x=Cb*c,_=p.scrollLeft-(x<0?Math.floor(x):Math.ceil(x));this._horizontalScrollbar.writeScrollPosition(d,_)}d=this._scrollable.validateScrollPosition(d),(p.scrollLeft!==d.scrollLeft||p.scrollTop!==d.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(d):this._scrollable.setScrollPositionNow(d),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",a=t?" top":"",o=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Uk)}},Wk=class extends qk{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 Gk(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,Er&&(t.className+=" mac"),t}var tp=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 ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Dk({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Fp(s.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Wk(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Yi.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Qt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Qt(()=>this._styleElement.remove())),this._register(Yi.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
69
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};tp=si([Me(2,hn),Me(3,Qr),Me(4,jy),Me(5,cl),Me(6,dn),Me(7,Jr)],tp);var ip=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(Qt(()=>{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()}};ip=si([Me(1,hn),Me(2,Qr),Me(3,Ro),Me(4,Jr)],ip);var Yk=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)}},br={full:0,left:0,center:0,right:0},Es={full:0,left:0,center:0,right:0},no={full:0,left:0,center:0,right:0},Cu=class extends dt{constructor(e,t,i,s,a,o,c,h){var d;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=h,this._colorZoneStore=new Yk,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(d=this._viewportElement.parentElement)==null||d.insertBefore(this._canvas,this._viewportElement),this._register(Qt(()=>{var x;return(x=this._canvas)==null?void 0:x.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Es.full=this._canvas.width,Es.left=e,Es.center=t,Es.right=e,this._refreshDrawHeightConstants(),no.full=1,no.left=1,no.center=1+Es.left,no.right=1+Es.left+Es.center}_refreshDrawHeightConstants(){br.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);br.left=t,br.center=t,br.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*br.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*br.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*br.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*br.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(no[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-br[e.position||"full"]/2),Es[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+br[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}))}};Cu=si([Me(2,hn),Me(3,Ro),Me(4,Jr),Me(5,dn),Me(6,cl),Me(7,Qr)],Cu);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 pu;(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=""))(pu||(pu={}));var Xy;(e=>e.ST=`${pe.ESC}\\`)(Xy||(Xy={}));var np=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)}}};np=si([Me(2,hn),Me(3,dn),Me(4,ca),Me(5,Jr)],np);var Di=0,Bi=0,Li=0,ni=0,kb={css:"#00000000",rgba:0},wi;(e=>{function t(a,o,c,h){return h!==void 0?`#${Qs(a)}${Qs(o)}${Qs(c)}${Qs(h)}`:`#${Qs(a)}${Qs(o)}${Qs(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})(wi||(wi={}));var Vt;(e=>{function t(p,d){if(ni=(d.rgba&255)/255,ni===1)return{css:d.css,rgba:d.rgba};let x=d.rgba>>24&255,_=d.rgba>>16&255,b=d.rgba>>8&255,v=p.rgba>>24&255,y=p.rgba>>16&255,E=p.rgba>>8&255;Di=v+Math.round((x-v)*ni),Bi=y+Math.round((_-y)*ni),Li=E+Math.round((b-E)*ni);let A=wi.toCss(Di,Bi,Li),T=wi.toRgba(Di,Bi,Li);return{css:A,rgba:T}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,d,x){let _=mu.ensureContrastRatio(p.rgba,d.rgba,x);if(_)return wi.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let d=(p.rgba|255)>>>0;return[Di,Bi,Li]=mu.toChannels(d),{css:wi.toCss(Di,Bi,Li),rgba:d}}e.opaque=a;function o(p,d){return ni=Math.round(d*255),[Di,Bi,Li]=mu.toChannels(p.rgba),{css:wi.toCss(Di,Bi,Li,ni),rgba:wi.toRgba(Di,Bi,Li,ni)}}e.opacity=o;function c(p,d){return ni=p.rgba&255,o(p,ni*d/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(Vt||(Vt={}));var ei;(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 Di=parseInt(a.slice(1,2).repeat(2),16),Bi=parseInt(a.slice(2,3).repeat(2),16),Li=parseInt(a.slice(3,4).repeat(2),16),wi.toColor(Di,Bi,Li);case 5:return Di=parseInt(a.slice(1,2).repeat(2),16),Bi=parseInt(a.slice(2,3).repeat(2),16),Li=parseInt(a.slice(3,4).repeat(2),16),ni=parseInt(a.slice(4,5).repeat(2),16),wi.toColor(Di,Bi,Li,ni);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 Di=parseInt(o[1]),Bi=parseInt(o[2]),Li=parseInt(o[3]),ni=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),wi.toColor(Di,Bi,Li,ni);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),[Di,Bi,Li,ni]=t.getImageData(0,0,1,1).data,ni!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:wi.toRgba(Di,Bi,Li,ni),css:a}}e.toColor=s})(ei||(ei={}));var on;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return d*.2126+x*.7152+_*.0722}e.relativeLuminance2=i})(on||(on={}));var mu;(e=>{function t(c,h){if(ni=(h&255)/255,ni===1)return h;let p=h>>24&255,d=h>>16&255,x=h>>8&255,_=c>>24&255,b=c>>16&255,v=c>>8&255;return Di=_+Math.round((p-_)*ni),Bi=b+Math.round((d-b)*ni),Li=v+Math.round((x-v)*ni),wi.toRgba(Di,Bi,Li)}e.blend=t;function i(c,h,p){let d=on.relativeLuminance(c>>8),x=on.relativeLuminance(h>>8);if(Yr(d,x)<p){if(x<d){let v=s(c,h,p),y=Yr(d,on.relativeLuminance(v>>8));if(y<p){let E=a(c,h,p),A=Yr(d,on.relativeLuminance(E>>8));return y>A?v:E}return v}let _=a(c,h,p),b=Yr(d,on.relativeLuminance(_>>8));if(b<p){let v=s(c,h,p),y=Yr(d,on.relativeLuminance(v>>8));return b>y?_:v}return _}}e.ensureContrastRatio=i;function s(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,E=Yr(on.relativeLuminance2(b,v,y),on.relativeLuminance2(d,x,_));for(;E<p&&(b>0||v>0||y>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),y-=Math.max(0,Math.ceil(y*.1)),E=Yr(on.relativeLuminance2(b,v,y),on.relativeLuminance2(d,x,_));return(b<<24|v<<16|y<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,E=Yr(on.relativeLuminance2(b,v,y),on.relativeLuminance2(d,x,_));for(;E<p&&(b<255||v<255||y<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),E=Yr(on.relativeLuminance2(b,v,y),on.relativeLuminance2(d,x,_));return(b<<24|v<<16|y<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(mu||(mu={}));function Qs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Yr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Kk=class extends Ao{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()]}},ku=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ir}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),a=0,o=0,c=0,h=t.getFg(0),p=t.getBg(0);for(let d=0;d<t.getTrimmedLength();d++)if(t.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(d-a>1){let x=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_<x.length;_++)i.push(x[_])}a=d,c=o,h=this._workCell.fg,p=this._workCell.bg}o+=this._workCell.getChars().length||Rs.length}if(this._bufferService.cols-a>1){let d=this._getJoinedRanges(s,c,o,t,a);for(let x=0;x<d.length;x++)i.push(d[x])}return i}_getJoinedRanges(e,t,i,s,a){let o=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(o)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(o);for(let d=0;d<p.length;d++)ku._mergeRanges(c,p[d])}catch(p){console.error(p)}return this._stringRangesToCellRanges(c,s,a),c}_stringRangesToCellRanges(e,t,i){let s=0,a=!1,o=0,c=e[s];if(c){for(let h=i;h<this._bufferService.cols;h++){let p=t.getWidth(h),d=t.getString(h).length||Rs.length;if(p!==0){if(!a&&c[0]<=o&&(c[0]=h,a=!0),c[1]<=o){if(c[1]=h,c=e[++s],!c)break;c[0]<=o?(c[0]=h,a=!0):a=!1}o+=d}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let a=e[s];if(i){if(t[1]<=a[0])return e[s-1][1]=t[1],e;if(t[1]<=a[1])return e[s-1][1]=Math.max(t[1],a[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=a[0])return e.splice(s,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ku=si([Me(0,hn)],ku);function Vk(e){return 57508<=e&&e<=57558}function Xk(e){return 9472<=e&&e<=9631}function Zk(e){return Vk(e)||Xk(e)}function Qk(){return{css:{canvas:Xc(),cell:Xc()},device:{canvas:Xc(),cell:Xc(),char:{width:0,height:0,left:0,top:0}}}}function Xc(){return{width:0,height:0}}var rp=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 ir,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,a,o,c,h,p,d,x){let _=[],b=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,y=e.getNoBgTrimmedLength();i&&y<o+1&&(y=o+1);let E,A=0,T="",L=0,O=0,J=0,$=0,M=!1,X=0,he=!1,ye=0,U=0,se=[],W=d!==-1&&x!==-1;for(let G=0;G<y;G++){e.loadCell(G,this._workCell);let Z=this._workCell.getWidth();if(Z===0)continue;let I=!1,j=G>=U,z=G,B=this._workCell;if(b.length>0&&G===b[0][0]&&j){let je=b.shift(),Ze=this._isCellInSelection(je[0],t);for(L=je[0]+1;L<je[1];L++)j&&(j=Ze===this._isCellInSelection(L,t));j&&(j=!i||o<je[0]||o>=je[1]),j?(I=!0,B=new Kk(this._workCell,e.translateToString(!0,je[0],je[1]),je[1]-je[0]),z=je[1]-1,Z=B.getWidth()):U=je[1]}let _e=this._isCellInSelection(G,t),N=i&&G===o,R=W&&G>=d&&G<=x,Y=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,je=>{Y=!0});let w=B.getChars()||Rs;if(w===" "&&(B.isUnderline()||B.isOverline())&&(w=" "),ye=Z*h-p.get(w,B.isBold(),B.isItalic()),!E)E=this._document.createElement("span");else if(A&&(_e&&he||!_e&&!he&&B.bg===O)&&(_e&&he&&v.selectionForeground||B.fg===J)&&B.extended.ext===$&&R===M&&ye===X&&!N&&!I&&!Y&&j){B.isInvisible()?T+=Rs:T+=w,A++;continue}else A&&(E.textContent=T),E=this._document.createElement("span"),A=0,T="";if(O=B.bg,J=B.fg,$=B.extended.ext,M=R,X=ye,he=_e,I&&o>=G&&o<=z&&(o=G),!this._coreService.isCursorHidden&&N&&this._coreService.isCursorInitialized){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&se.push("xterm-cursor-blink"),se.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline");break}}if(B.isBold()&&se.push("xterm-bold"),B.isItalic()&&se.push("xterm-italic"),B.isDim()&&se.push("xterm-dim"),B.isInvisible()?T=Rs:T=B.getChars()||Rs,B.isUnderline()&&(se.push(`xterm-underline-${B.extended.underlineStyle}`),T===" "&&(T=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${Ao.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let je=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&je<8&&(je+=8),E.style.textDecorationColor=v.ansi[je].css}B.isOverline()&&(se.push("xterm-overline"),T===" "&&(T=" ")),B.isStrikethrough()&&se.push("xterm-strikethrough"),R&&(E.style.textDecoration="underline");let ae=B.getFgColor(),ie=B.getFgColorMode(),oe=B.getBgColor(),F=B.getBgColorMode(),ue=!!B.isInverse();if(ue){let je=ae;ae=oe,oe=je;let Ze=ie;ie=F,F=Ze}let be,De,Ee=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,je=>{je.options.layer!=="top"&&Ee||(je.backgroundColorRGB&&(F=50331648,oe=je.backgroundColorRGB.rgba>>8&16777215,be=je.backgroundColorRGB),je.foregroundColorRGB&&(ie=50331648,ae=je.foregroundColorRGB.rgba>>8&16777215,De=je.foregroundColorRGB),Ee=je.options.layer==="top")}),!Ee&&_e&&(be=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,oe=be.rgba>>8&16777215,F=50331648,Ee=!0,v.selectionForeground&&(ie=50331648,ae=v.selectionForeground.rgba>>8&16777215,De=v.selectionForeground)),Ee&&se.push("xterm-decoration-top");let Be;switch(F){case 16777216:case 33554432:Be=v.ansi[oe],se.push(`xterm-bg-${oe}`);break;case 50331648:Be=wi.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(E,`background-color:#${Eb((oe>>>0).toString(16),"0",6)}`);break;case 0:default:ue?(Be=v.foreground,se.push("xterm-bg-257")):Be=v.background}switch(be||B.isDim()&&(be=Vt.multiplyOpacity(Be,.5)),ie){case 16777216:case 33554432:B.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(E,Be,v.ansi[ae],B,be,void 0)||se.push(`xterm-fg-${ae}`);break;case 50331648:let je=wi.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(E,Be,je,B,be,De)||this._addStyle(E,`color:#${Eb(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(E,Be,v.foreground,B,be,De)||ue&&se.push("xterm-fg-257")}se.length&&(E.className=se.join(" "),se.length=0),!N&&!I&&!Y&&j?A++:E.textContent=T,ye!==this.defaultSpacing&&(E.style.letterSpacing=`${ye}px`),_.push(E),G=z}return E&&A&&(E.textContent=T),_}_applyMinimumContrast(e,t,i,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Zk(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=Vt.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]}};rp=si([Me(1,My),Me(2,dn),Me(3,Qr),Me(4,ca),Me(5,Ro),Me(6,cl)],rp);function Eb(e,t,i){for(;e.length<i;)e=t+e;return e}var Jk=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}},e2=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 t2(){return new e2}var tf="xterm-dom-renderer-owner-",Qn="xterm-rows",Zc="xterm-fg-",Nb="xterm-bg-",ro="xterm-focus",Qc="xterm-selection",i2=1,sp=class extends dt{constructor(e,t,i,s,a,o,c,h,p,d,x,_,b,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=d,this._bufferService=x,this._coreService=_,this._coreBrowserService=b,this._themeService=v,this._terminalClass=i2++,this._rowElements=[],this._selectionRenderModel=t2(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Qn),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(Qc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Qk(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(y=>this._injectCss(y))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(rp,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(y=>this._handleLinkHover(y))),this._register(this._linkifier2.onHideLinkUnderline(y=>this._handleLinkLeave(y))),this._register(Qt(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Jk(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} .${Qn} 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} .${Qn} { 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} .${Qn} .xterm-dim { color: ${Vt.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} .${Qn}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Qn}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Qn}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Qn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Qn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Qn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Qn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Qn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Qc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Qc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Qc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Zc}${o} { color: ${c.css}; }${this._terminalSelector} .${Zc}${o}.xterm-dim { color: ${Vt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Nb}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Zc}257 { color: ${Vt.opaque(e.background).css}; }${this._terminalSelector} .${Zc}257.xterm-dim { color: ${Vt.multiplyOpacity(Vt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Nb}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(ro),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ro),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let p=e[0]>t[0];h.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,d=o===a?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(o,p,d));let x=c-o-1;if(h.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,x)),o!==c){let _=a===c?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,i,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,a=Math.min(i.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let d=p+i.ydisp,x=this._rowElements[p],_=i.lines.get(d);if(!x||!_)break;x.replaceChildren(...this._rowFactory.createRow(_,d,d===s,c,h,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,a,o){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,d=Math.min(h.x,a-1),x=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let y=v+h.ydisp,E=this._rowElements[v],A=h.lines.get(y);if(!E||!A)break;E.replaceChildren(...this._rowFactory.createRow(A,y,y===p,_,b,d,x,this.dimensions.css.cell.width,this._widthCache,o?v===i?e:0:-1,o?(v===s?t:a)-1:-1))}}};sp=si([Me(7,zp),Me(8,Lu),Me(9,dn),Me(10,hn),Me(11,ca),Me(12,Qr),Me(13,cl)],sp);var ap=class extends dt{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new r2(this._optionsService))}catch{this._measureStrategy=this._register(new n2(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())}};ap=si([Me(2,dn)],ap);var Zy=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)}},n2=class extends Zy{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}},r2=class extends Zy{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}},s2=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 a2(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Yi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ye(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ye(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}},a2=class extends dt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new al),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Qt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ye(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)}},l2=class extends dt{constructor(){super(),this.linkProviders=[],this._register(Qt(()=>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 Wp(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 o2(e,t,i,s,a,o,c,h,p){if(!o)return;let d=Wp(e,t,i);if(d)return d[0]=Math.ceil((d[0]+(p?c/2:0))/c),d[1]=Math.ceil(d[1]/h),d[0]=Math.min(Math.max(d[0],1),s+(p?1:0)),d[1]=Math.min(Math.max(d[1],1),a),d}var lp=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,a){return o2(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=Wp(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])}}};lp=si([Me(0,Jr),Me(1,Lu)],lp);var c2=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=[]}},Qy={};bC(Qy,{getSafariVersion:()=>h2,isChromeOS:()=>i0,isFirefox:()=>Jy,isIpad:()=>d2,isIphone:()=>f2,isLegacyEdge:()=>u2,isLinux:()=>Gp,isMac:()=>Eu,isNode:()=>Ou,isSafari:()=>e0,isWindows:()=>t0});var Ou=typeof process<"u"&&"title"in process,Mo=Ou?"node":navigator.userAgent,Do=Ou?"node":navigator.platform,Jy=Mo.includes("Firefox"),u2=Mo.includes("Edge"),e0=/^((?!chrome|android).)*safari/i.test(Mo);function h2(){if(!e0)return 0;let e=Mo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Eu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Do),d2=Do==="iPad",f2=Do==="iPhone",t0=["Windows","Win16","Win32","WinCE"].includes(Do),Gp=Do.indexOf("Linux")>=0,i0=/\bCrOS\b/.test(Mo),n0=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()}},p2=class extends n0{_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())}}},m2=class extends n0{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Nu=!Ou&&"requestIdleCallback"in window?m2:p2,g2=class{constructor(){this._queue=new Nu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},op=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 al),this._pausedResizeTask=new g2,this._observerDisposable=this._register(new al),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new c2((d,x)=>this._renderRows(d,x),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _2(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Qt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var d;return(d=this._renderer.value)==null?void 0:d.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=Qt(()=>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()}};op=si([Me(2,dn),Me(3,Lu),Me(4,ca),Me(5,Ro),Me(6,hn),Me(7,Qr),Me(8,cl)],op);var _2=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 x2(e,t,i,s){let a=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return y2(a,o,e,t,i,s)+zu(o,t,i,s)+S2(a,o,e,t,i,s);let c;if(o===t)return c=a>e?"D":"C",Co(Math.abs(a-e),wo(c,s));c=o>t?"D":"C";let h=Math.abs(o-t),p=v2(o>t?e:a,i)+(h-1)*i.cols+1+b2(o>t?a:e);return Co(p,wo(c,s))}function b2(e,t){return e-1}function v2(e,t){return t.cols-e}function y2(e,t,i,s,a,o){return zu(t,s,a,o).length===0?"":Co(s0(e,t,e,t-la(t,a),!1,a).length,wo("D",o))}function zu(e,t,i,s){let a=e-la(e,i),o=t-la(t,i),c=Math.abs(a-o)-w2(e,t,i);return Co(c,wo(r0(e,t),s))}function S2(e,t,i,s,a,o){let c;zu(t,s,a,o).length>0?c=s-la(s,a):c=t;let h=s,p=C2(e,t,i,s,a,o);return Co(s0(e,c,i,h,p==="C",a).length,wo(p,o))}function w2(e,t,i){var c;let s=0,a=e-la(e,i),o=t-la(t,i);for(let h=0;h<Math.abs(a-o);h++){let p=r0(e,t)==="A"?-1:1;(c=i.buffer.lines.get(a+p*h))!=null&&c.isWrapped&&s++}return s}function la(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 C2(e,t,i,s,a,o){let c;return zu(i,s,a,o).length>0?c=s-la(s,a):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function r0(e,t){return e>t?"A":"B"}function s0(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 wo(e,t){let i=t?"O":"[";return pe.ESC+i+e}function Co(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var k2=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 Tb(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 nf=50,E2=15,N2=50,T2=500,j2=" ",A2=new RegExp(j2,"g"),cp=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 ir,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new k2(this._bufferService),this._activeSelectionMode=0,this._register(Qt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let h=i.translateBufferLineToString(c,!0,a,o);s.push(h)}}else{let a=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],a));for(let o=e[1]+1;o<=t[1]-1;o++){let c=i.lines.get(o),h=i.translateBufferLineToString(o,!0);c!=null&&c.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let o=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(a=>a.replace(A2," ")).join(t0?`\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())),Gp&&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=Tb(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=Wp(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,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(E2-1)))}shouldForceSelection(e){return Eu?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(),N2)}_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&&!(Eu&&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<T2&&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=x2(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:a>1&&t!==s&&(i+=a-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(o,e[0]),p=h,d=e[0]-h,x=0,_=0,b=0,v=0;if(c.charAt(h)===" "){for(;h>0&&c.charAt(h-1)===" ";)h--;for(;p<c.length&&c.charAt(p+1)===" ";)p++}else{let A=e[0],T=e[0];o.getWidth(A)===0&&(x++,A--),o.getWidth(T)===2&&(_++,T++);let L=o.getString(T).length;for(L>1&&(v+=L-1,p+=L-1);A>0&&h>0&&!this._isCharWordSeparator(o.loadCell(A-1,this._workCell));){o.loadCell(A-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(x++,A--):O>1&&(b+=O-1,h-=O-1),h--,A--}for(;T<o.length&&p+1<c.length&&!this._isCharWordSeparator(o.loadCell(T+1,this._workCell));){o.loadCell(T+1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,T++):O>1&&(v+=O-1,p+=O-1),p++,T++}}p++;let y=h+d-x+b,E=Math.min(this._bufferService.cols,p-h+x+_-b-v);if(!(!t&&c.slice(h,p).trim()==="")){if(i&&y===0&&o.getCodePoint(0)!==32){let A=a.lines.get(e[1]-1);if(A&&o.isWrapped&&A.getCodePoint(this._bufferService.cols-1)!==32){let T=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(T){let L=this._bufferService.cols-T.start;y-=L,E+=L}}}if(s&&y+E===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let A=a.lines.get(e[1]+1);if(A!=null&&A.isWrapped&&A.getCodePoint(0)!==32){let T=this._getWordAt([0,e[1]+1],!1,!1,!0);T&&(E+=T.length)}}return{start:y,length:E}}}_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=Tb(i,this._bufferService.cols)}};cp=si([Me(3,hn),Me(4,ca),Me(5,Pp),Me(6,dn),Me(7,Jr),Me(8,Qr)],cp);var jb=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={}}},Ab=class{constructor(){this._color=new jb,this._css=new jb}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()}},Ni=Object.freeze((()=>{let e=[ei.toColor("#2e3436"),ei.toColor("#cc0000"),ei.toColor("#4e9a06"),ei.toColor("#c4a000"),ei.toColor("#3465a4"),ei.toColor("#75507b"),ei.toColor("#06989a"),ei.toColor("#d3d7cf"),ei.toColor("#555753"),ei.toColor("#ef2929"),ei.toColor("#8ae234"),ei.toColor("#fce94f"),ei.toColor("#729fcf"),ei.toColor("#ad7fa8"),ei.toColor("#34e2e2"),ei.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:wi.toCss(s,a,o),rgba:wi.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:wi.toCss(s,s,s),rgba:wi.toRgba(s,s,s)})}return e})()),ia=ei.toColor("#ffffff"),mo=ei.toColor("#000000"),Rb=ei.toColor("#ffffff"),Mb=mo,so={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},R2=ia,up=class extends dt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ab,this._halfContrastCache=new Ab,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ia,background:mo,cursor:Rb,cursorAccent:Mb,selectionForeground:void 0,selectionBackgroundTransparent:so,selectionBackgroundOpaque:Vt.blend(mo,so),selectionInactiveBackgroundTransparent:so,selectionInactiveBackgroundOpaque:Vt.blend(mo,so),scrollbarSliderBackground:Vt.opacity(ia,.2),scrollbarSliderHoverBackground:Vt.opacity(ia,.4),scrollbarSliderActiveBackground:Vt.opacity(ia,.5),overviewRulerBorder:ia,ansi:Ni.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,ia),t.background=Ut(e.background,mo),t.cursor=Vt.blend(t.background,Ut(e.cursor,Rb)),t.cursorAccent=Vt.blend(t.background,Ut(e.cursorAccent,Mb)),t.selectionBackgroundTransparent=Ut(e.selectionBackground,so),t.selectionBackgroundOpaque=Vt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ut(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Vt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ut(e.selectionForeground,kb):void 0,t.selectionForeground===kb&&(t.selectionForeground=void 0),Vt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Vt.opacity(t.selectionBackgroundTransparent,.3)),Vt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Vt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ut(e.scrollbarSliderBackground,Vt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ut(e.scrollbarSliderHoverBackground,Vt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ut(e.scrollbarSliderActiveBackground,Vt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ut(e.overviewRulerBorder,R2),t.ansi=Ni.slice(),t.ansi[0]=Ut(e.black,Ni[0]),t.ansi[1]=Ut(e.red,Ni[1]),t.ansi[2]=Ut(e.green,Ni[2]),t.ansi[3]=Ut(e.yellow,Ni[3]),t.ansi[4]=Ut(e.blue,Ni[4]),t.ansi[5]=Ut(e.magenta,Ni[5]),t.ansi[6]=Ut(e.cyan,Ni[6]),t.ansi[7]=Ut(e.white,Ni[7]),t.ansi[8]=Ut(e.brightBlack,Ni[8]),t.ansi[9]=Ut(e.brightRed,Ni[9]),t.ansi[10]=Ut(e.brightGreen,Ni[10]),t.ansi[11]=Ut(e.brightYellow,Ni[11]),t.ansi[12]=Ut(e.brightBlue,Ni[12]),t.ansi[13]=Ut(e.brightMagenta,Ni[13]),t.ansi[14]=Ut(e.brightCyan,Ni[14]),t.ansi[15]=Ut(e.brightWhite,Ni[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],Ni[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()}}};up=si([Me(0,dn)],up);function Ut(e,t){if(e!==void 0)try{return ei.toColor(e)}catch{}return t}var M2=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)}},D2=class{constructor(){this._services=new M2,this._services.set(zp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=EC(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)}},B2={trace:0,debug:1,info:2,warn:3,error:4,off:5},L2="xterm.js: ",hp=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=B2[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?"":L2)+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)}};hp=si([Me(0,dn)],hp);var Db=class extends dt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let a=t-1;a>=0;a--)this.set(e+a+i,this.get(e+a));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ht=3,Si=Object.freeze(new Ao),Jc=0,rf=2,go=class a0{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ht);let a=i||ir.fromCharData([0,ky,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?js(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?js(i&2097151):""}isProtected(t){return this._data[t*ht+2]&536870912}loadCell(t,i){return Jc=t*ht,i.content=this._data[Jc+0],i.fg=this._data[Jc+1],i.bg=this._data[Jc+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]+=js(i):a&2097151?(this._combined[t]=js(a&2097151)+js(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 ir;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 ir;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*rf<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*rf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*rf<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 a0(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 d=0;d<ht;d++)this._data[(s+p)*ht+d]=c[(i+p)*ht+d];c[(i+p)*ht+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}else for(let p=0;p<a;p++){for(let d=0;d<ht;d++)this._data[(s+p)*ht+d]=c[(i+p)*ht+d];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 d=parseInt(h[p],10);d>=i&&(this._combined[d-i+s]=t._combined[d])}}translateToString(t,i,s,a){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;i<s;){let c=this._data[i*ht+0],h=c&2097151,p=c&2097152?this._combined[i]:h?js(h):Rs;if(o+=p,a)for(let d=0;d<p.length;++d)a.push(i);i+=c>>22||1}return a&&a.push(i),o}};function O2(e,t,i,s,a,o){let c=[];for(let h=0;h<e.length-1;h++){let p=h,d=e.get(++p);if(!d.isWrapped)continue;let x=[e.get(h)];for(;p<e.length&&d.isWrapped;)x.push(d),d=e.get(++p);if(!o&&s>=h&&s<p){h+=x.length-1;continue}let _=0,b=ko(x,_,t),v=1,y=0;for(;v<x.length;){let A=ko(x,v,t),T=A-y,L=i-b,O=Math.min(T,L);x[_].copyCellsFrom(x[v],y,b,O,!1),b+=O,b===i&&(_++,b=0),y+=O,y===A&&(v++,y=0),b===0&&_!==0&&x[_-1].getWidth(i-1)===2&&(x[_].copyCellsFrom(x[_-1],i-1,b++,1,!1),x[_-1].setCell(i-1,a))}x[_].replaceCells(b,i,a);let E=0;for(let A=x.length-1;A>0&&(A>_||x[A].getTrimmedLength()===0);A--)E++;E>0&&(c.push(h+x.length-E),c.push(E)),h+=x.length-1}return c}function z2(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 P2(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 I2(e,t,i){let s=[],a=e.map((p,d)=>ko(e,d,t)).reduce((p,d)=>p+d),o=0,c=0,h=0;for(;h<a;){if(a-h<i){s.push(a-h);break}o+=i;let p=ko(e,c,t);o>p&&(o-=p,c++);let d=e[c].getWidth(o-1)===2;d&&o--;let x=d?i-1:i;s.push(x),h+=x}return s}function ko(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 l0=class o0{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=o0._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};l0._nextId=1;var H2=l0,Ai={},na=Ai.B;Ai[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ai.A={"#":"£"};Ai.B=void 0;Ai[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ai.C=Ai[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ai.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ai.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ai.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ai.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ai.E=Ai[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ai.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ai.H=Ai[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ai["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Bb=4294967295,Lb=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=Si.clone(),this.savedCharset=na,this.markers=[],this._nullCell=ir.fromCharData([0,ky,1,0]),this._whitespaceCell=ir.fromCharData([0,Rs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Nu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Db(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 wu),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 wu),this._whitespaceCell}getBlankLine(e,t){return new go(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>Bb?Bb:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Si);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 Db(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Si),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 go(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 go(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=O2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Si),i);if(s.length>0){let a=z2(this.lines,s);P2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Si),a=i;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new go(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(Si),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 O=this.ybase+this.y;if(O>=c&&O<c+p.length)continue}let d=p[p.length-1].getTrimmedLength(),x=I2(p,this._cols,e),_=x.length-p.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+_):b=Math.max(0,this.lines.length-this.lines.maxLength+_);let v=[];for(let O=0;O<_;O++){let J=this.getBlankLine(Si,!0);v.push(J)}v.length>0&&(a.push({start:c+p.length+o,newLines:v}),o+=v.length),p.push(...v);let y=x.length-1,E=x[y];E===0&&(y--,E=x[y]);let A=p.length-_-1,T=d;for(;A>=0;){let O=Math.min(T,E);if(p[y]===void 0)break;if(p[y].copyCellsFrom(p[A],T-O,E-O,O,!0),E-=O,E===0&&(y--,E=x[y]),T-=O,T===0){A--;let J=Math.max(A,0);T=ko(p,J,this._cols)}}for(let O=0;O<p.length;O++)x[O]<e&&p[O].setCell(x[O],s);let L=_-b;for(;L-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}if(a.length>0){let c=[],h=[];for(let E=0;E<this.lines.length;E++)h.push(this.lines.get(E));let p=this.lines.length,d=p-1,x=0,_=a[x];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let b=0;for(let E=Math.min(this.lines.maxLength-1,p+o-1);E>=0;E--)if(_&&_.start>d+b){for(let A=_.newLines.length-1;A>=0;A--)this.lines.set(E--,_.newLines[A]);E++,c.push({index:d+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++x]}else this.lines.set(E,h[d--]);let v=0;for(let E=c.length-1;E>=0;E--)c[E].index+=v,this.lines.onInsertEmitter.fire(c[E]),v+=c[E].amount;let y=Math.max(0,p+o-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}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 H2(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)}},U2=class extends dt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Lb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Lb(!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)}},c0=2,u0=1,dp=class extends dt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,c0),this.rows=Math.max(e.rawOptions.rows||0,u0),this.buffers=this._register(new U2(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))}};dp=si([Me(0,dn)],dp);var Xa={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:Eu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},$2=["normal","bold","100","200","300","400","500","600","700","800","900"],F2=class extends dt{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...Xa};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(Qt(()=>{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 Xa))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Xa))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=Xa[e]),!q2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Xa[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=$2.includes(t)?t:Xa[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 q2(e){return e==="block"||e==="underline"||e==="bar"}function _o(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]&&_o(e[s],t-1);return i}var Ob=Object.freeze({insertMode:!1}),zb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fp=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 ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_o(Ob),this.decPrivateModes=_o(zb)}reset(){this.modes=_o(Ob),this.decPrivateModes=_o(zb)}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))}};fp=si([Me(0,hn),Me(1,Ay),Me(2,dn)],fp);var Pb={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 sf(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 af=String.fromCharCode,Ib={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${af(t[0])}${af(t[1])}${af(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},pp=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 ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pb))this.addProtocol(s,Pb[s]);for(let s of Object.keys(Ib))this.addEncoding(s,Ib[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)}};pp=si([Me(0,hn),Me(1,ca),Me(2,dn)],pp);var lf=[[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]],W2=[[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]],Ti;function G2(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 Y2=class{constructor(){if(this.version="6",!Ti){Ti=new Uint8Array(65536),Ti.fill(1),Ti[0]=0,Ti.fill(0,1,32),Ti.fill(0,127,160),Ti.fill(2,4352,4448),Ti[9001]=2,Ti[9002]=2,Ti.fill(2,11904,42192),Ti[12351]=1,Ti.fill(2,44032,55204),Ti.fill(2,63744,64256),Ti.fill(2,65040,65050),Ti.fill(2,65072,65136),Ti.fill(2,65280,65377),Ti.fill(2,65504,65511);for(let e=0;e<lf.length;++e)Ti.fill(0,lf[e][0],lf[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ti[e]:G2(e,W2)?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=ra.extractWidth(t);a===0?s=!1:a>i&&(i=a)}return ra.createPropertyValue(0,i,s)}},ra=class gu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new Y2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,a=t.length;for(let o=0;o<a;++o){let c=t.charCodeAt(o);if(55296<=c&&c<=56319){if(++o>=a)return i+this.wcwidth(c);let d=t.charCodeAt(o);56320<=d&&d<=57343?c=(c-55296)*1024+d-56320+65536:i+=this.wcwidth(d)}let h=this.charProperties(c,s),p=gu.extractWidth(h);gu.extractShouldJoin(h)&&(p-=gu.extractWidth(s)),i+=p,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},K2=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 Hb(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 ao=2147483647,V2=256,h0=class mp{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>V2)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 mp;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 mp(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>ao?ao: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>ao?ao: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,ao):t}},lo=[],X2=class{constructor(){this._state=0,this._active=lo,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=lo}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=lo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||lo,!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",Bu(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=lo,this._id=-1,this._state=0}}},Ln=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+=Bu(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}},oo=[],Z2=class{constructor(){this._handlers=Object.create(null),this._active=oo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oo}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=oo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||oo,!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",Bu(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=oo,this._ident=0}},xo=new h0;xo.addParam(0);var Ub=class{constructor(e){this._handler=e,this._data="",this._params=xo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():xo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Bu(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=xo,this._data="",this._hitLimit=!1,i));return this._params=xo,this._data="",this._hitLimit=!1,t}},Q2=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}},er=160,J2=(function(){let e=new Q2(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(er,0,2,0),e.add(er,8,5,8),e.add(er,6,0,6),e.add(er,11,0,11),e.add(er,13,13,13),e})(),eE=class extends dt{constructor(e=J2){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 h0,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(Qt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new X2),this._dcsParser=this._register(new Z2),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:er)],a>>4){case 2:for(let b=h+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s<er){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<er){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<er){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<er){this._printHandler(e,h,b),h=b-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],d=p?p.length-1:-1;for(;d>=0&&(c=p[d](this._params),c!==!0);d--)if(c instanceof Promise)return this._preserveStack(3,p,d,a,h),c;d<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let x=this._escHandlers[this._collect<<8|s],_=x?x.length-1:-1;for(;_>=0&&(c=x[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,x,_,a,h),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=h+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s<er){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<er){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}}},tE=/^([\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})$/,iE=/^[\da-f]+$/;function $b(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=tE.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),iE.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 of(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 nE(e,t=16){let[i,s,a]=e;return`rgb:${of(i,t)}/${of(s,t)}/${of(a,t)}`}var rE={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ns=131072,Fb=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 Wb=5e3,Gb=0,sE=class extends dt{constructor(e,t,i,s,a,o,c,h,p=new eE){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 CC,this._utf8Decoder=new kC,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Si.clone(),this._eraseAttrDataInternal=Si.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new gp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,x)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:x.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,x,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:x,data:_})}),this._parser.setDcsHandlerFallback((d,x,_)=>{x==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:x,payload:_})}),this._parser.setPrintHandler((d,x,_)=>this.print(d,x,_)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(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(pu.IND,()=>this.index()),this._parser.setExecuteHandler(pu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(pu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ln(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Ln(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Ln(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Ln(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Ln(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Ln(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Ln(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Ln(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Ln(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Ln(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Ln(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Ln(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Ai)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Ub((d,x)=>this.requestStatusString(d,x)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Wb))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Wb} 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>Ns&&(o=this._parseStack.position+Ns)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(d=>d.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ns&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ns))),c||this._dirtyRowTracker.clearRange(),e.length>Ns)for(let d=o;d<e.length;d+=Ns){let x=d+Ns<e.length?d+Ns:e.length,_=typeof e=="string"?this._stringDecoder.decode(e.substring(d,x),this._parseBuffer):this._utf8Decoder.decode(e.subarray(d,x),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,_))return this._preserveStack(s,a,_,d),this._logSlowResolvingAsync(i),i}else if(!c){let d=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,a,d,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,i){let s,a,o=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,x=this._curAttrData,_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,x);let b=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&o){let T=o[String.fromCharCode(s)];T&&(s=T.charCodeAt(0))}let y=this._unicodeService.charProperties(s,b);a=ra.extractWidth(y);let E=ra.extractShouldJoin(y),A=E?ra.extractWidth(b):0;if(b=y,c&&this._onA11yChar.fire(js(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-A>h){if(p){let T=_,L=this._activeBuffer.x-A;for(this._activeBuffer.x=A,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),A>0&&_ instanceof go&&_.copyCellsFrom(T,L,0,A,!1);L<h;)T.setCellFromCodepoint(L++,0,1,x)}else if(this._activeBuffer.x=h-1,a===2)continue}if(E&&this._activeBuffer.x){let T=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-T,s,a);for(let L=a-A;--L>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,x);continue}if(d&&(_.insertCells(this._activeBuffer.x,a-A,this._activeBuffer.getNullCell(x)),_.getWidth(h-1)===2&&_.setCellFromCodepoint(h-1,0,1,x)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,x),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,x)}this._parser.precedingJoinState=b,this._activeBuffer.x<h&&i-t>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,x),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>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 Ub(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ln(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(Si));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=ra.extractWidth(t),a=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),c=new Uint32Array(o.length*i),h=0;for(let d=0;d<o.length;){let x=o.codePointAt(d)||0;c[h++]=x,d+=x>65535?2:1}let p=h;for(let d=1;d<i;++d)c.copyWithin(p,0,h),p+=h;return this.print(c,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(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,na),this._charsetService.setgCharset(1,na),this._charsetService.setgCharset(2,na),this._charsetService.setgCharset(3,na);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){(E=>(E[E.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",E[E.SET=1]="SET",E[E.RESET=2]="RESET",E[E.PERMANENTLY_SET=3]="PERMANENTLY_SET",E[E.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:d,alt:x}=h,_=this._optionsService.rawOptions,b=(E,A)=>(c.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${E};${A}$y`),!0),v=E=>E?1:2,y=e.params[0];return t?y===2?b(y,4):y===4?b(y,v(c.modes.insertMode)):y===12?b(y,3):y===20?b(y,v(_.convertEol)):b(y,0):y===1?b(y,v(s.applicationCursorKeys)):y===3?b(y,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):y===6?b(y,v(s.origin)):y===7?b(y,v(s.wraparound)):y===8?b(y,3):y===9?b(y,v(a==="X10")):y===12?b(y,v(_.cursorBlink)):y===25?b(y,v(!c.isCursorHidden)):y===45?b(y,v(s.reverseWraparound)):y===66?b(y,v(s.applicationKeypad)):y===67?b(y,4):y===1e3?b(y,v(a==="VT200")):y===1002?b(y,v(a==="DRAG")):y===1003?b(y,v(a==="ANY")):y===1004?b(y,v(s.sendFocus)):y===1005?b(y,4):y===1006?b(y,v(o==="SGR")):y===1015?b(y,4):y===1016?b(y,v(o==="SGR_PIXELS")):y===1048?b(y,1):y===47||y===1047||y===1049?b(y,v(d===x)):y===2004?b(y,v(s.bracketedPasteMode)):y===2026?b(y,v(s.synchronizedOutput)):b(y,0)}_updateAttrColor(e,t,i,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ao.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=Si.fg,e.bg=Si.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|=Si.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Si.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|=Si.fg&16777215,s.bg&=-67108864,s.bg|=Si.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=Si.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>Fb&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Fb&&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(Yb(o))if(a==="?")t.push({type:0,index:o});else{let c=$b(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=$b(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]);Yb(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,na),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(rE[e[0]],Ai[e[1]]||na),!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=Si.clone(),this._eraseAttrDataInternal=Si.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 ir;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)}},gp=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&&(Gb=e,e=t,t=Gb),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gp=si([Me(0,hn)],gp);function Yb(e){return 0<=e&&e<256}var aE=5e7,Kb=12,lE=50,oE=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 ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>aE)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>=Kb?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>=Kb)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>lE&&(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()}},_p=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)))}};_p=si([Me(0,hn)],_p);var Vb=!1,cE=class extends dt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new al),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new D2,this.optionsService=this._register(new F2(e)),this._instantiationService.setService(dn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(dp)),this._instantiationService.setService(hn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(hp)),this._instantiationService.setService(Ay,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fp)),this._instantiationService.setService(ca,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(pp)),this._instantiationService.setService(jy,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ra)),this._instantiationService.setService(jC,this.unicodeService),this._charsetService=this._instantiationService.createInstance(K2),this._instantiationService.setService(TC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_p),this._instantiationService.setService(Ry,this._oscLinkService),this._inputHandler=this._register(new sE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Yi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Yi.forward(this._bufferService.onResize,this._onResize)),this._register(Yi.forward(this.coreService.onData,this._onData)),this._register(Yi.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 oE((t,i)=>this._inputHandler.parse(t,i))),this._register(Yi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Vb&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Vb=!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,c0),t=Math.max(t,u0),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(Hb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Hb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Qt(()=>{for(let t of e)t.dispose()})}}},uE={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 hE(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=uE[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,d=String.fromCharCode(p);e.shiftKey&&(d=d.toUpperCase()),a.key=pe.ESC+d}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 ui=0,dE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Nu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Nu,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||(ui=this._search(t),ui===-1)||this._getKey(this._array[ui])!==t)return!1;do if(this._array[ui]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ui),!0;while(++ui<this._array.length&&this._getKey(this._array[ui])===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&&(ui=this._search(e),!(ui<0||ui>=this._array.length)&&this._getKey(this._array[ui])===e))do yield this._array[ui];while(++ui<this._array.length&&this._getKey(this._array[ui])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ui=this._search(e),!(ui<0||ui>=this._array.length)&&this._getKey(this._array[ui])===e))do t(this._array[ui]);while(++ui<this._array.length&&this._getKey(this._array[ui])===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}},cf=0,Xb=0,fE=class extends dt{constructor(){super(),this._decorations=new dE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Qt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new pE(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=>{cf=a.options.x??0,Xb=cf+(a.options.width??1),e>=cf&&e<Xb&&(!i||(a.options.layer??"bottom")===i)&&s(a)})}},pE=class extends Ms{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ei.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ei.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},mE=1e3,gE=class{constructor(e,t=mE){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)}},Zb=20,Tu=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 gE(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(Ye(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Qt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Zb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
74
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Zb+1&&(this._liveRegion.textContent+=zf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let a=e;a<=t;a++){let o=i.lines.get(i.ydisp+a),c=[],h=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(i.ydisp+a+1).toString(),d=this._rowElements[a];d&&(h.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=h,this._rowColumns.set(d,c)),d.setAttribute("aria-posinset",p),d.setAttribute("aria-setsize",s),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=i.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,h;if(t===0?(c=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(c=this._rowElements.shift(),h=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let a=({node:p,offset:d})=>{let x=p instanceof Text?p.parentNode:p,_=parseInt(x==null?void 0:x.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(x);if(!b)return console.warn("columns is null. Race condition?"),null;let v=d<b.length?b[d]:b.slice(-1)[0]+1;return v>=this._terminal.cols&&(++_,v=0),{row:_,column:v}},o=a(t),c=a(i);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var a,o;e.style.transform="";let t=e.getBoundingClientRect().width,i=(o=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:o[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Tu=si([Me(1,zp),Me(2,Qr),Me(3,Jr)],Tu);var xp=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 ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Qt(()=>{var o;aa(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(Ye(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ye(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ye(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ye(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let a=i[s];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,a;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(o=>{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(i=this._checkLinkProviderResult(o,e,i)):c.provideLinks(e.y,h=>{var d,x;if(this._isMouseOut)return;let p=h==null?void 0:h.map(_=>({link:_}));(d=this._activeProviderReplies)==null||d.set(o,p),i=this._checkLinkProviderResult(o,e,i),((x=this._activeProviderReplies)==null?void 0:x.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let a=t.get(s);if(a)for(let o=0;o<a.length;o++){let c=a[o],h=c.link.range.start.y<e?0:c.link.range.start.x,p=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let d=h;d<=p;d++){if(i.has(d)){a.splice(o--,1);break}i.add(d)}}}}_checkLinkProviderResult(e,t,i){var o;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(a=!0);if(!a&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let h=(o=this._activeProviderReplies.get(c))==null?void 0:o.find(p=>this._linkAtPosition(p.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&_E(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,aa(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}}};xp=si([Me(1,Pp),Me(2,Jr),Me(3,hn),Me(4,Dy)],xp);function _E(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 xE=class extends cE{constructor(e={}){super(e),this._linkifier=this._register(new al),this.browser=Qy,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new al),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(fE),this._instantiationService.setService(Ro,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(l2),this._instantiationService.setService(Dy,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(If)),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(Yi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Yi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Yi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Yi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Qt(()=>{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=Vt.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${nE(a)}${Xy.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=wi.toColor(...t.color));else{let o=i;this._themeService.modifyColors(c=>c[o]=wi.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(Tu,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(Ye(this.element,"copy",t=>{this.hasSelection()&&SC(t,this._selectionService)}));let e=t=>wC(t,this.textarea,this.coreService,this.optionsService);this._register(Ye(this.textarea,"paste",e)),this._register(Ye(this.element,"paste",e)),Jy?this._register(Ye(this.element,"mousedown",t=>{t.button===2&&lb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ye(this.element,"contextmenu",t=>{lb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Gp&&this._register(Ye(this.element,"auxclick",t=>{t.button===1&&Cy(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ye(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ye(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ye(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ye(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ye(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ye(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ye(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(Ye(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",Of.get()),i0||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(s2,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Qr,this._coreBrowserService),this._register(Ye(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ye(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ap,this._document,this._helperContainer),this._instantiationService.setService(Lu,this._charSizeService),this._themeService=this._instantiationService.createInstance(up),this._instantiationService.setService(cl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ku),this._instantiationService.setService(My,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(op,this.rows,this.screenElement)),this._instantiationService.setService(Jr,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(np,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lp),this._instantiationService.setService(Pp,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(xp,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(tp,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(cp,this.element,this.screenElement,s)),this._instantiationService.setService(RC,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(Yi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(ip,this.screenElement)),this._register(Ye(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(Tu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(sp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(o){var d,x,_,b,v;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let h,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(h=3,o.button!==void 0&&(h=o.button<3?o.button:3)):h=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,h=o.button<3?o.button:3;break;case"mousedown":p=1,h=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let y=o.deltaY;if(y===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(x=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:x.device)==null?void 0:_.cell)==null?void 0:b.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=y<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(Ye(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(Ye(t,"wheel",o=>{var c,h,p,d,x;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(d=(p=(h=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:d.height,(x=e._coreBrowserService)==null?void 0:x.dpr)===0)return this.cancel(o,!0);let _=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){wy(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=hE(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)&&(bE(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(Si));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 bE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var vE=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)}},yE=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 ir)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Qb=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 yE(t)}getNullCell(){return new ir}},SE=class extends dt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new Qb(this._core.buffers.normal,"normal"),this._alternate=new Qb(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)}},wE=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)}},CE=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}},kE=["cols","rows"],vr=0,EE=class extends dt{constructor(e){super(),this._core=this._register(new xE(e)),this._addonManager=this._register(new vE),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(kE.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 wE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new CE(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 SE(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 Of.get()},set promptLabel(e){Of.set(e)},get tooMuchOutput(){return zf.get()},set tooMuchOutput(e){zf.set(e)}}}_verifyIntegers(...e){for(vr of e)if(vr===1/0||isNaN(vr)||vr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(vr of e)if(vr&&(vr===1/0||isNaN(vr)||vr%1!==0||vr<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 NE=2,TE=1,jE=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),a=Math.max(0,parseInt(i.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},h=c.top+c.bottom,p=c.right+c.left,d=s-h,x=a-p-t;return{cols:Math.max(NE,Math.floor(x/e.css.cell.width)),rows:Math.max(TE,Math.floor(d/e.css.cell.height))}}};/**
|
|
87
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
88
|
+
* @license MIT
|
|
89
|
+
*
|
|
90
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
91
|
+
* @license MIT
|
|
92
|
+
*
|
|
93
|
+
* Originally forked from (with the author's permission):
|
|
94
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
95
|
+
* http://bellard.org/jslinux/
|
|
96
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
97
|
+
*/var Oi=0,zi=0,Pi=0,ri=0,Qi;(e=>{function t(a,o,c,h){return h!==void 0?`#${Js(a)}${Js(o)}${Js(c)}${Js(h)}`:`#${Js(a)}${Js(o)}${Js(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})(Qi||(Qi={}));var AE;(e=>{function t(p,d){if(ri=(d.rgba&255)/255,ri===1)return{css:d.css,rgba:d.rgba};let x=d.rgba>>24&255,_=d.rgba>>16&255,b=d.rgba>>8&255,v=p.rgba>>24&255,y=p.rgba>>16&255,E=p.rgba>>8&255;Oi=v+Math.round((x-v)*ri),zi=y+Math.round((_-y)*ri),Pi=E+Math.round((b-E)*ri);let A=Qi.toCss(Oi,zi,Pi),T=Qi.toRgba(Oi,zi,Pi);return{css:A,rgba:T}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,d,x){let _=_u.ensureContrastRatio(p.rgba,d.rgba,x);if(_)return Qi.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let d=(p.rgba|255)>>>0;return[Oi,zi,Pi]=_u.toChannels(d),{css:Qi.toCss(Oi,zi,Pi),rgba:d}}e.opaque=a;function o(p,d){return ri=Math.round(d*255),[Oi,zi,Pi]=_u.toChannels(p.rgba),{css:Qi.toCss(Oi,zi,Pi,ri),rgba:Qi.toRgba(Oi,zi,Pi,ri)}}e.opacity=o;function c(p,d){return ri=p.rgba&255,o(p,ri*d/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(AE||(AE={}));var Wi;(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 Oi=parseInt(a.slice(1,2).repeat(2),16),zi=parseInt(a.slice(2,3).repeat(2),16),Pi=parseInt(a.slice(3,4).repeat(2),16),Qi.toColor(Oi,zi,Pi);case 5:return Oi=parseInt(a.slice(1,2).repeat(2),16),zi=parseInt(a.slice(2,3).repeat(2),16),Pi=parseInt(a.slice(3,4).repeat(2),16),ri=parseInt(a.slice(4,5).repeat(2),16),Qi.toColor(Oi,zi,Pi,ri);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 Oi=parseInt(o[1]),zi=parseInt(o[2]),Pi=parseInt(o[3]),ri=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Qi.toColor(Oi,zi,Pi,ri);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),[Oi,zi,Pi,ri]=t.getImageData(0,0,1,1).data,ri!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Qi.toRgba(Oi,zi,Pi,ri),css:a}}e.toColor=s})(Wi||(Wi={}));var cn;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return d*.2126+x*.7152+_*.0722}e.relativeLuminance2=i})(cn||(cn={}));var _u;(e=>{function t(c,h){if(ri=(h&255)/255,ri===1)return h;let p=h>>24&255,d=h>>16&255,x=h>>8&255,_=c>>24&255,b=c>>16&255,v=c>>8&255;return Oi=_+Math.round((p-_)*ri),zi=b+Math.round((d-b)*ri),Pi=v+Math.round((x-v)*ri),Qi.toRgba(Oi,zi,Pi)}e.blend=t;function i(c,h,p){let d=cn.relativeLuminance(c>>8),x=cn.relativeLuminance(h>>8);if(Kr(d,x)<p){if(x<d){let v=s(c,h,p),y=Kr(d,cn.relativeLuminance(v>>8));if(y<p){let E=a(c,h,p),A=Kr(d,cn.relativeLuminance(E>>8));return y>A?v:E}return v}let _=a(c,h,p),b=Kr(d,cn.relativeLuminance(_>>8));if(b<p){let v=s(c,h,p),y=Kr(d,cn.relativeLuminance(v>>8));return b>y?_:v}return _}}e.ensureContrastRatio=i;function s(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,E=Kr(cn.relativeLuminance2(b,v,y),cn.relativeLuminance2(d,x,_));for(;E<p&&(b>0||v>0||y>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),y-=Math.max(0,Math.ceil(y*.1)),E=Kr(cn.relativeLuminance2(b,v,y),cn.relativeLuminance2(d,x,_));return(b<<24|v<<16|y<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let d=c>>24&255,x=c>>16&255,_=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,E=Kr(cn.relativeLuminance2(b,v,y),cn.relativeLuminance2(d,x,_));for(;E<p&&(b<255||v<255||y<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),E=Kr(cn.relativeLuminance2(b,v,y),cn.relativeLuminance2(d,x,_));return(b<<24|v<<16|y<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(_u||(_u={}));function Js(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Kr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var RE=Object.freeze((()=>{let e=[Wi.toColor("#2e3436"),Wi.toColor("#cc0000"),Wi.toColor("#4e9a06"),Wi.toColor("#c4a000"),Wi.toColor("#3465a4"),Wi.toColor("#75507b"),Wi.toColor("#06989a"),Wi.toColor("#d3d7cf"),Wi.toColor("#555753"),Wi.toColor("#ef2929"),Wi.toColor("#8ae234"),Wi.toColor("#fce94f"),Wi.toColor("#729fcf"),Wi.toColor("#ad7fa8"),Wi.toColor("#34e2e2"),Wi.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:Qi.toCss(s,a,o),rgba:Qi.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Qi.toCss(s,s,s),rgba:Qi.toRgba(s,s,s)})}return e})());function Jb(e,t,i){return Math.max(t,Math.min(e,i))}function ME(e){switch(e){case"&":return"&";case"<":return"<"}return e}var d0=class{constructor(e){this._buffer=e}serialize(e,t){let i=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=i,o=e.start.y,c=e.end.y,h=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let d=o;d<=c;d++){let x=this._buffer.getLine(d);if(x){let _=d===e.start.y?h:0,b=d===e.end.y?p:x.length;for(let v=_;v<b;v++){let y=x.getCell(v,a===i?s:i);if(!y){console.warn(`Can't get cell at row=${d}, col=${v}`);continue}this._nextCell(y,a,d,v),a=y}}this._rowEnd(d,d===c)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,i,s){}_rowEnd(e,t){}_beforeSerialize(e,t,i){}_afterSerialize(){}_serializeString(e){return""}};function f0(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function Vr(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function p0(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 DE=class extends d0{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&&!Vr(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let i="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)i=`\r
|
|
98
|
+
`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{i="";let c=a.getCell(a.length-1,this._thisRowLastChar),h=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),d=p.getWidth()>1,x=!1;(p.getChars()&&d?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Vr(c,p)&&(x=!0),d&&(h.getChars()||h.getWidth()===0)&&Vr(c,p)&&Vr(h,p)&&(x=!0)),x||(i="-".repeat(this._nullCellCount+1),i+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(i+="\x1B[A",i+=`\x1B[${a.length-this._nullCellCount}C`,i+=`\x1B[${this._nullCellCount}X`,i+=`\x1B[${a.length-this._nullCellCount}D`,i+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=i,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let i=[],s=!f0(e,t),a=!Vr(e,t),o=!p0(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?!Vr(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Vr(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&&(Vr(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let i="";for(let o=0;o<t;o++)i+=this._allRows[o],o+1<t&&(i+=this._allRowSeparators[o]);if(!e){let o=this._buffer.baseY+this._buffer.cursorY,c=this._buffer.cursorX,h=o!==this._lastCursorRow||c!==this._lastCursorCol,p=d=>{d>0?i+=`\x1B[${d}C`:d<0&&(i+=`\x1B[${-d}D`)};h&&((d=>{d>0?i+=`\x1B[${d}B`:d<0&&(i+=`\x1B[${-d}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(i+=`\x1B[${a.join(";")}m`),i}},BE=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,i){let s=t.length,a=i===void 0?s:Jb(i+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,i,s){return new DE(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 LE(i,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=i.length,d=t.scrollback,x=d===void 0?p:Jb(d+e.rows,0,p);return s.serialize({start:{x:0,y:p-x},end:{x:e.cols,y:p-1}})}let c=(h=this._terminal)==null?void 0:h.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",i=e.modes;if(i.applicationCursorKeysMode&&(t+="\x1B[?1h"),i.applicationKeypadMode&&(t+="\x1B[?66h"),i.bracketedPasteMode&&(t+="\x1B[?2004h"),i.insertMode&&(t+="\x1B[4h"),i.originMode&&(t+="\x1B[?6h"),i.reverseWraparoundMode&&(t+="\x1B[?45h"),i.sendFocusMode&&(t+="\x1B[?1004h"),i.wraparoundMode===!1&&(t+="\x1B[?7l"),i.mouseTrackingMode!=="none")switch(i.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let i=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${i}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},LE=class extends d0{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=RE}_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=!f0(e,t),a=!Vr(e,t),o=!p0(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+=ME(e.getChars())}_serializeString(){return this._htmlContent}};const OE="__OWS_FRESH_SESSION__",Za="[REDACTED]",zE=[[/(authorization\s*:\s*bearer\s+)[^\s'"\x1b]+/gi,`$1${Za}`],[/(\bbearer\s+)[A-Za-z0-9._-]{12,}/gi,`$1${Za}`],[/(\btoken=)[^\s'"&\x1b]+/gi,`$1${Za}`],[/(OWS_PASSPHRASE\s*[=:]\s*)[^\s'"\x1b]+/gi,`$1${Za}`],[/(--passphrase[=\s]+)[^\s'"\x1b]+/gi,`$1${Za}`],[/(passphrase["']?\s*[:=]\s*["']?)[^\s'"\x1b]+/gi,`$1${Za}`]];function ev(e){let t=e;for(const[i,s]of zE)t=t.replace(i,s);return t}const tv="codex features enable image_generation";function PE(e,t){return e!=="cartoon"||!t?!1:!(t.codex.installed&&t.codex.imageGeneration==="enabled")}const IE={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"},HE="plotlink-terminal",UE=1,Ds="scrollback",iv=10*1024*1024;function Yp(){return new Promise((e,t)=>{const i=indexedDB.open(HE,UE);i.onupgradeneeded=()=>{const s=i.result;s.objectStoreNames.contains(Ds)||s.createObjectStore(Ds)},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})}async function Qa(e,t){const i=t.length>iv?t.slice(-iv):t,s=await Yp();return new Promise((a,o)=>{const c=s.transaction(Ds,"readwrite");c.objectStore(Ds).put(i,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function $E(e){const t=await Yp();return new Promise((i,s)=>{const o=t.transaction(Ds,"readonly").objectStore(Ds).get(e);o.onsuccess=()=>{t.close(),i(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function uf(e){const t=await Yp();return new Promise((i,s)=>{const a=t.transaction(Ds,"readwrite");a.objectStore(Ds).delete(e),a.oncomplete=()=>{t.close(),i()},a.onerror=()=>{t.close(),s(a.error)}})}const ji=new Map;function FE({token:e,storyName:t,authFetch:i,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:h,bypassStories:p,agentProviders:d,readiness:x,contentType:_,needsProviderRepair:b,onRepairProvider:v}){const y=C.useRef(null),E=C.useRef(i),[A,T]=C.useState([]),[L,O]=C.useState(new Set),[J,$]=C.useState(null),[M,X]=C.useState(null),[he,ye]=C.useState(!1),[U,se]=C.useState(!1),W=PE(_,x),G=!!b,Z=C.useRef(()=>{});C.useEffect(()=>{E.current=i},[i]);const I=C.useCallback(F=>{var be;const{width:ue}=F.container.getBoundingClientRect();if(!(ue<50))try{F.fit.fit(),((be=F.ws)==null?void 0:be.readyState)===WebSocket.OPEN&&F.ws.send(JSON.stringify({type:"resize",cols:F.term.cols,rows:F.term.rows}))}catch{}},[]),j=C.useCallback(F=>{for(const[ue,be]of ji)be.container.style.display=ue===F?"block":"none";if(F){const ue=ji.get(F);ue&&setTimeout(()=>I(ue),50)}},[I]),z=C.useRef({});C.useEffect(()=>{z.current=p||{}},[p]);const B=C.useRef({});C.useEffect(()=>{B.current=d||{}},[d]);const _e=C.useCallback((F,ue,be)=>{const De=window.location.protocol==="https:"?"wss:":"ws:",Ee=z.current[F]?"&bypass=true":"",Be=B.current[F],je=Be?`&provider=${encodeURIComponent(Be)}`:"",Ze=new WebSocket(`${De}//${window.location.host}/ws/terminal?story=${encodeURIComponent(F)}&token=${e}&resume=${be}${Ee}${je}`);Ze.onopen=()=>{ue.connected=!0,ue._retried=!1,O(tt=>{const mt=new Set(tt);return mt.delete(F),mt}),Ze.send(JSON.stringify({type:"resize",cols:ue.term.cols,rows:ue.term.rows}))};let we=!0;Ze.onmessage=tt=>{if(we&&(we=!1,typeof tt.data=="string"&&tt.data===OE)){ue.term.reset(),uf(F).catch(()=>{});return}ue.term.write(typeof tt.data=="string"?ev(tt.data):tt.data)},Ze.onclose=tt=>{if(ue.connected=!1,ue.ws===Ze){ue.ws=null;try{const mt=ue.serialize.serialize();Qa(F,mt).catch(()=>{})}catch{}if(tt.code===4e3&&!ue._retried){ue._retried=!0,ue.term.write(`\r
|
|
99
|
+
\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r
|
|
100
|
+
`),Z.current(F,ue,!1);return}O(mt=>new Set(mt).add(F))}},ue.term.onData(tt=>{Ze.readyState===WebSocket.OPEN&&Ze.send(tt)}),ue.ws=Ze},[e]);C.useEffect(()=>{Z.current=_e},[_e]);const N=C.useCallback(async(F,ue)=>{if(!y.current||ji.has(F))return;const{resume:be=!1,autoConnect:De=!0}=ue??{},Ee=document.createElement("div");Ee.style.width="100%",Ee.style.height="100%",Ee.style.display="none",Ee.style.paddingLeft="10px",Ee.style.boxSizing="border-box",y.current.appendChild(Ee);const Be=new EE({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:IE,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),je=new jE,Ze=new BE;Be.loadAddon(je),Be.loadAddon(Ze),Be.open(Ee);const we={term:Be,fit:je,serialize:Ze,ws:null,container:Ee,observer:null,connected:!1},tt=new ResizeObserver(()=>{var Ge;const{width:mt}=Ee.getBoundingClientRect();if(!(mt<50))try{je.fit(),((Ge=we.ws)==null?void 0:Ge.readyState)===WebSocket.OPEN&&we.ws.send(JSON.stringify({type:"resize",cols:Be.cols,rows:Be.rows}))}catch{}});tt.observe(Ee),we.observer=tt,ji.set(F,we),T(mt=>[...mt,F]);try{const mt=await $E(F);if(mt){const Ge=ev(mt);Be.write(Ge),Ge!==mt&&Qa(F,Ge).catch(()=>{})}}catch{}De?_e(F,we,be):O(mt=>new Set(mt).add(F)),setTimeout(()=>I(we),50)},[_e,I]),R=C.useCallback(async(F,ue)=>{const be=ji.get(F);be&&(be.ws&&(be.ws.close(),be.ws=null),ue||(await E.current(`/api/terminal/${encodeURIComponent(F)}`,{method:"DELETE"}).catch(()=>{}),be.term.clear()),_e(F,be,ue))},[_e]),Y=C.useCallback(F=>{const ue=ji.get(F);if(ue){try{const be=ue.serialize.serialize();Qa(F,be).catch(()=>{})}catch{}ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),ji.delete(F),T(be=>be.filter(De=>De!==F)),O(be=>{const De=new Set(be);return De.delete(F),De}),i(`/api/terminal/${encodeURIComponent(F)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(F)}},[i,a]),w=C.useCallback(F=>{var be;const ue=ji.get(F);ue&&(((be=ue.ws)==null?void 0:be.readyState)===WebSocket.OPEN&&ue.ws.send(`exit
|
|
101
|
+
`),uf(F).catch(()=>{}),ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),ji.delete(F),T(De=>De.filter(Ee=>Ee!==F)),O(De=>{const Ee=new Set(De);return Ee.delete(F),Ee}),i(`/api/terminal/${encodeURIComponent(F)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(F))},[i,a]),ae=C.useCallback(async(F,ue,be)=>{const De=ji.get(F);if(!De||ji.has(ue)||!(await E.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:F,newName:ue,...be??{}})})).ok)return!1;ji.delete(F),ji.set(ue,De);try{const Be=De.serialize.serialize();await uf(F),await Qa(ue,Be)}catch{}return T(Be=>Be.map(je=>je===F?ue:je)),O(Be=>{if(!Be.has(F))return Be;const je=new Set(Be);return je.delete(F),je.add(ue),je}),(De.connected||De.ws)&&(await E.current(`/api/terminal/${encodeURIComponent(ue)}`,{method:"DELETE"}).catch(()=>{}),De.ws&&(De.ws.close(),De.ws=null),Z.current(ue,De,!0)),!0},[]);C.useEffect(()=>(h&&(h.current=ae),()=>{h&&(h.current=null)}),[h,ae]),C.useEffect(()=>{if(t){if(W){j(null);return}if(G){j(null);return}ji.has(t)?j(t):E.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(F=>F.ok?F.json():null).then(F=>{if(!ji.has(t)){const ue=(F==null?void 0:F.sessionId)&&!(F!=null&&F.running);N(t,{autoConnect:!ue}),j(t)}}).catch(()=>{ji.has(t)||(N(t),j(t))})}},[t,N,j,W,G]),C.useEffect(()=>{const F=setInterval(()=>{for(const[ue,be]of ji)if(be.connected)try{const De=be.serialize.serialize();Qa(ue,De).catch(()=>{})}catch{}},3e4);return()=>clearInterval(F)},[]),C.useEffect(()=>()=>{for(const[F,ue]of ji){try{const be=ue.serialize.serialize();Qa(F,be).catch(()=>{})}catch{}ue.observer.disconnect(),ue.ws&&ue.ws.close(),ue.term.dispose(),ue.container.remove(),E.current(`/api/terminal/${encodeURIComponent(F)}`,{method:"DELETE"}).catch(()=>{})}ji.clear()},[]);const ie=t?L.has(t):!1,oe=A.length===0;return f.jsxs("div",{className:"h-full flex flex-col",children:[!oe&&f.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[A.map(F=>f.jsxs("div",{onClick:()=>s==null?void 0:s(F),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${F===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${L.has(F)?"bg-amber-500":F===t?"bg-green-600":"bg-muted/50"}`}),f.jsx("span",{className:`truncate max-w-[120px] ${F.startsWith("_new_")?"italic":""}`,children:F.startsWith("_new_")?"Untitled":F}),f.jsx("button",{onClick:ue=>{ue.stopPropagation(),F.startsWith("_new_")?$(F):Y(F)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},F)),t!=null&&t.startsWith("_new_")?f.jsx("button",{onClick:()=>$(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?f.jsx("button",{onClick:()=>X(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),f.jsxs("div",{className:"relative flex-1 min-h-0",children:[f.jsx("div",{ref:y,className:"h-full"}),oe&&!W&&!G&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),f.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),W&&f.jsx("div",{"data-testid":"cartoon-launch-blocked",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Cartoon agent can't launch yet"}),f.jsx("p",{className:"text-xs text-muted",children:"This is a cartoon story. The writing agent needs Codex with image generation enabled before it can start, because the clean-image step relies on image generation support."}),x&&!x.codex.installed?f.jsxs("p",{className:"text-xs text-amber-700",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",f.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",f.jsx("span",{className:"font-mono",children:"codex login"}),"), then reopen this story."]}):Su(x)?f.jsxs("p",{className:"text-xs text-amber-700","data-testid":"codex-auth-unknown-launch",children:[Op," Then reopen this story."]}):f.jsxs("div",{className:"space-y-1",children:[f.jsx("p",{className:"text-xs text-amber-700",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this story:"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:tv}),f.jsx("button",{type:"button","data-testid":"copy-codex-enable-launch",onClick:async()=>{try{await navigator.clipboard.writeText(tv),ye(!0),setTimeout(()=>ye(!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:he?"Copied!":"Copy"})]})]})]})}),G&&!W&&f.jsx("div",{"data-testid":"legacy-cartoon-provider-repair",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Set this cartoon story's provider"}),f.jsx("p",{className:"text-xs text-muted",children:"This cartoon story was created before provider tracking, so it has no provider recorded and would launch with Claude — which can't generate the clean images cartoons need. Set this story's provider to Codex to continue."}),f.jsx("p",{className:"text-[11px] text-muted",children:"Only this story is changed. Other stories and fiction are not affected."}),f.jsx("button",{type:"button","data-testid":"repair-provider-codex",disabled:U,onClick:async()=>{if(!U){se(!0);try{await(v==null?void 0:v())}finally{se(!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:U?"Setting…":"Set this story's provider to Codex"})]})}),J&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),f.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("button",{onClick:()=>$(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),f.jsx("button",{onClick:()=>{const F=J;$(null),w(F)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),M&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[f.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),f.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("button",{onClick:()=>X(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),f.jsx("button",{onClick:async()=>{const F=M;X(null);try{(await E.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F})})).ok&&(Y(F),o==null||o(F))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),ie&&t&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"text-center space-y-3",children:[f.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>R(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),f.jsx("button",{onClick:()=>R(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),f.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function qE(e,t){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const WE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YE={};function nv(e,t){return(YE.jsx?GE:WE).test(e)}const KE=/[ \t\n\f\r]/g;function VE(e){return typeof e=="object"?e.type==="text"?rv(e.value):!1:rv(e)}function rv(e){return e.replace(KE,"")===""}class Bo{constructor(t,i,s){this.normal=i,this.property=t,s&&(this.space=s)}}Bo.prototype.normal={};Bo.prototype.property={};Bo.prototype.space=void 0;function m0(e,t){const i={},s={};for(const a of e)Object.assign(i,a.property),Object.assign(s,a.normal);return new Bo(i,s,t)}function bp(e){return e.toLowerCase()}class Cn{constructor(t,i){this.attribute=i,this.property=t}}Cn.prototype.attribute="";Cn.prototype.booleanish=!1;Cn.prototype.boolean=!1;Cn.prototype.commaOrSpaceSeparated=!1;Cn.prototype.commaSeparated=!1;Cn.prototype.defined=!1;Cn.prototype.mustUseProperty=!1;Cn.prototype.number=!1;Cn.prototype.overloadedBoolean=!1;Cn.prototype.property="";Cn.prototype.spaceSeparated=!1;Cn.prototype.space=void 0;let XE=0;const lt=ua(),yi=ua(),vp=ua(),ve=ua(),Wt=ua(),nl=ua(),On=ua();function ua(){return 2**++XE}const yp=Object.freeze(Object.defineProperty({__proto__:null,boolean:lt,booleanish:yi,commaOrSpaceSeparated:On,commaSeparated:nl,number:ve,overloadedBoolean:vp,spaceSeparated:Wt},Symbol.toStringTag,{value:"Module"})),hf=Object.keys(yp);class Kp extends Cn{constructor(t,i,s,a){let o=-1;if(super(t,i),sv(this,"space",a),typeof s=="number")for(;++o<hf.length;){const c=hf[o];sv(this,hf[o],(s&yp[c])===yp[c])}}}Kp.prototype.defined=!0;function sv(e,t,i){i&&(e[t]=i)}function hl(e){const t={},i={};for(const[s,a]of Object.entries(e.properties)){const o=new Kp(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),t[s]=o,i[bp(s)]=s,i[bp(o.attribute)]=s}return new Bo(t,i,e.space)}const g0=hl({properties:{ariaActiveDescendant:null,ariaAtomic:yi,ariaAutoComplete:null,ariaBusy:yi,ariaChecked:yi,ariaColCount:ve,ariaColIndex:ve,ariaColSpan:ve,ariaControls:Wt,ariaCurrent:null,ariaDescribedBy:Wt,ariaDetails:null,ariaDisabled:yi,ariaDropEffect:Wt,ariaErrorMessage:null,ariaExpanded:yi,ariaFlowTo:Wt,ariaGrabbed:yi,ariaHasPopup:null,ariaHidden:yi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Wt,ariaLevel:ve,ariaLive:null,ariaModal:yi,ariaMultiLine:yi,ariaMultiSelectable:yi,ariaOrientation:null,ariaOwns:Wt,ariaPlaceholder:null,ariaPosInSet:ve,ariaPressed:yi,ariaReadOnly:yi,ariaRelevant:null,ariaRequired:yi,ariaRoleDescription:Wt,ariaRowCount:ve,ariaRowIndex:ve,ariaRowSpan:ve,ariaSelected:yi,ariaSetSize:ve,ariaSort:null,ariaValueMax:ve,ariaValueMin:ve,ariaValueNow:ve,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function _0(e,t){return t in e?e[t]:t}function x0(e,t){return _0(e,t.toLowerCase())}const ZE=hl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:nl,acceptCharset:Wt,accessKey:Wt,action:null,allow:null,allowFullScreen:lt,allowPaymentRequest:lt,allowUserMedia:lt,alt:null,as:null,async:lt,autoCapitalize:null,autoComplete:Wt,autoFocus:lt,autoPlay:lt,blocking:Wt,capture:null,charSet:null,checked:lt,cite:null,className:Wt,cols:ve,colSpan:null,content:null,contentEditable:yi,controls:lt,controlsList:Wt,coords:ve|nl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lt,defer:lt,dir:null,dirName:null,disabled:lt,download:vp,draggable:yi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lt,formTarget:null,headers:Wt,height:ve,hidden:vp,high:ve,href:null,hrefLang:null,htmlFor:Wt,httpEquiv:Wt,id:null,imageSizes:null,imageSrcSet:null,inert:lt,inputMode:null,integrity:null,is:null,isMap:lt,itemId:null,itemProp:Wt,itemRef:Wt,itemScope:lt,itemType:Wt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lt,low:ve,manifest:null,max:null,maxLength:ve,media:null,method:null,min:null,minLength:ve,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:ve,pattern:null,ping:Wt,placeholder:null,playsInline:lt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lt,referrerPolicy:null,rel:Wt,required:lt,reversed:lt,rows:ve,rowSpan:ve,sandbox:Wt,scope:null,scoped:lt,seamless:lt,selected:lt,shadowRootClonable:lt,shadowRootDelegatesFocus:lt,shadowRootMode:null,shape:null,size:ve,sizes:null,slot:null,span:ve,spellCheck:yi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ve,step:null,style:null,tabIndex:ve,target:null,title:null,translate:null,type:null,typeMustMatch:lt,useMap:null,value:yi,width:ve,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Wt,axis:null,background:null,bgColor:null,border:ve,borderColor:null,bottomMargin:ve,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:ve,leftMargin:ve,link:null,longDesc:null,lowSrc:null,marginHeight:ve,marginWidth:ve,noResize:lt,noHref:lt,noShade:lt,noWrap:lt,object:null,profile:null,prompt:null,rev:null,rightMargin:ve,rules:null,scheme:null,scrolling:yi,standby:null,summary:null,text:null,topMargin:ve,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ve,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lt,disableRemotePlayback:lt,prefix:null,property:null,results:ve,security:null,unselectable:null},space:"html",transform:x0}),QE=hl({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:On,accentHeight:ve,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ve,amplitude:ve,arabicForm:null,ascent:ve,attributeName:null,attributeType:null,azimuth:ve,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ve,by:null,calcMode:null,capHeight:ve,className:Wt,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:ve,diffuseConstant:ve,direction:null,display:null,dur:null,divisor:ve,dominantBaseline:null,download:lt,dx:null,dy:null,edgeMode:null,editable:null,elevation:ve,enableBackground:null,end:null,event:null,exponent:ve,externalResourcesRequired:null,fill:null,fillOpacity:ve,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:nl,g2:nl,glyphName:nl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ve,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ve,horizOriginX:ve,horizOriginY:ve,id:null,ideographic:ve,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ve,k:ve,k1:ve,k2:ve,k3:ve,k4:ve,kernelMatrix:On,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ve,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:ve,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:ve,overlineThickness:ve,paintOrder:null,panose1:null,path:null,pathLength:ve,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Wt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ve,pointsAtY:ve,pointsAtZ:ve,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:On,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:On,rev:On,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:On,requiredFeatures:On,requiredFonts:On,requiredFormats:On,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:ve,specularExponent:ve,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ve,strikethroughThickness:ve,string:null,stroke:null,strokeDashArray:On,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ve,strokeOpacity:ve,strokeWidth:null,style:null,surfaceScale:ve,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:On,tabIndex:ve,tableValues:null,target:null,targetX:ve,targetY:ve,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:On,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ve,underlineThickness:ve,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ve,values:null,vAlphabetic:ve,vMathematical:ve,vectorEffect:null,vHanging:ve,vIdeographic:ve,version:null,vertAdvY:ve,vertOriginX:ve,vertOriginY:ve,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ve,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:_0}),b0=hl({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()}}),v0=hl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:x0}),y0=hl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),JE={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"},eN=/[A-Z]/g,av=/-[a-z]/g,tN=/^data[-\w.:]+$/i;function iN(e,t){const i=bp(t);let s=t,a=Cn;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&tN.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(av,rN);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!av.test(o)){let c=o.replace(eN,nN);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Kp}return new a(s,t)}function nN(e){return"-"+e.toLowerCase()}function rN(e){return e.charAt(1).toUpperCase()}const sN=m0([g0,ZE,b0,v0,y0],"html"),Vp=m0([g0,QE,b0,v0,y0],"svg");function aN(e){return e.join(" ").trim()}var Ja={},df,lv;function lN(){if(lv)return df;lv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,i=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
|
|
102
|
+
`,d="/",x="*",_="",b="comment",v="declaration";function y(A,T){if(typeof A!="string")throw new TypeError("First argument must be a string");if(!A)return[];T=T||{};var L=1,O=1;function J(Z){var I=Z.match(t);I&&(L+=I.length);var j=Z.lastIndexOf(p);O=~j?Z.length-j:O+Z.length}function $(){var Z={line:L,column:O};return function(I){return I.position=new M(Z),ye(),I}}function M(Z){this.start=Z,this.end={line:L,column:O},this.source=T.source}M.prototype.content=A;function X(Z){var I=new Error(T.source+":"+L+":"+O+": "+Z);if(I.reason=Z,I.filename=T.source,I.line=L,I.column=O,I.source=A,!T.silent)throw I}function he(Z){var I=Z.exec(A);if(I){var j=I[0];return J(j),A=A.slice(j.length),I}}function ye(){he(i)}function U(Z){var I;for(Z=Z||[];I=se();)I!==!1&&Z.push(I);return Z}function se(){var Z=$();if(!(d!=A.charAt(0)||x!=A.charAt(1))){for(var I=2;_!=A.charAt(I)&&(x!=A.charAt(I)||d!=A.charAt(I+1));)++I;if(I+=2,_===A.charAt(I-1))return X("End of comment missing");var j=A.slice(2,I-2);return O+=2,J(j),A=A.slice(I),O+=2,Z({type:b,comment:j})}}function W(){var Z=$(),I=he(s);if(I){if(se(),!he(a))return X("property missing ':'");var j=he(o),z=Z({type:v,property:E(I[0].replace(e,_)),value:j?E(j[0].replace(e,_)):_});return he(c),z}}function G(){var Z=[];U(Z);for(var I;I=W();)I!==!1&&(Z.push(I),U(Z));return Z}return ye(),G()}function E(A){return A?A.replace(h,_):_}return df=y,df}var ov;function oN(){if(ov)return Ja;ov=1;var e=Ja&&Ja.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ja,"__esModule",{value:!0}),Ja.default=i;const t=e(lN());function i(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),h=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:d,value:x}=p;h?a(d,x,p):x&&(o=o||{},o[d]=x)}),o}return Ja}var co={},cv;function cN(){if(cv)return co;cv=1,Object.defineProperty(co,"__esModule",{value:!0}),co.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,i=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(d){return!d||i.test(d)||e.test(d)},c=function(d,x){return x.toUpperCase()},h=function(d,x){return"".concat(x,"-")},p=function(d,x){return x===void 0&&(x={}),o(d)?d:(d=d.toLowerCase(),x.reactCompat?d=d.replace(a,h):d=d.replace(s,h),d.replace(t,c))};return co.camelCase=p,co}var uo,uv;function uN(){if(uv)return uo;uv=1;var e=uo&&uo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(oN()),i=cN();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,uo=s,uo}var hN=uN();const dN=Du(hN),S0=w0("end"),Xp=w0("start");function w0(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 C0(e){const t=Xp(e),i=S0(e);if(t&&i)return{start:t,end:i}}function vo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hv(e.position):"start"in e||"end"in e?hv(e):"line"in e||"column"in e?Sp(e):""}function Sp(e){return dv(e&&e.line)+":"+dv(e&&e.column)}function hv(e){return Sp(e&&e.start)+"-"+Sp(e&&e.end)}function dv(e){return e&&typeof e=="number"?e:1}class en 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=vo(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}}en.prototype.file="";en.prototype.name="";en.prototype.reason="";en.prototype.message="";en.prototype.stack="";en.prototype.column=void 0;en.prototype.line=void 0;en.prototype.ancestors=void 0;en.prototype.cause=void 0;en.prototype.fatal=void 0;en.prototype.place=void 0;en.prototype.ruleId=void 0;en.prototype.source=void 0;const Zp={}.hasOwnProperty,fN=new Map,pN=/[A-Z]/g,mN=new Set(["table","tbody","thead","tfoot","tr"]),gN=new Set(["td","th"]),k0="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _N(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=kN(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=CN(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"?Vp:sN,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=E0(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function E0(e,t,i){if(t.type==="element")return xN(e,t,i);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return bN(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return yN(e,t,i);if(t.type==="mdxjsEsm")return vN(e,t);if(t.type==="root")return SN(e,t,i);if(t.type==="text")return wN(e,t)}function xN(e,t,i){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Vp,e.schema=a),e.ancestors.push(t);const o=T0(e,t.tagName,!1),c=EN(e,t);let h=Jp(e,t);return mN.has(t.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!VE(p):!0})),N0(e,c,o,t),Qp(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function bN(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)}Eo(e,t.position)}function vN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Eo(e,t.position)}function yN(e,t,i){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Vp,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:T0(e,t.name,!0),c=NN(e,t),h=Jp(e,t);return N0(e,c,o,t),Qp(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function SN(e,t,i){const s={};return Qp(s,Jp(e,t)),e.create(t,e.Fragment,s,i)}function wN(e,t){return t.value}function N0(e,t,i,s){typeof i!="string"&&i!==e.Fragment&&e.passNode&&(t.node=s)}function Qp(e,t){if(t.length>0){const i=t.length>1?t:t[0];i&&(e.children=i)}}function CN(e,t,i){return s;function s(a,o,c,h){const d=Array.isArray(c.children)?i:t;return h?d(o,c,h):d(o,c)}}function kN(e,t){return i;function i(s,a,o,c){const h=Array.isArray(o.children),p=Xp(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 EN(e,t){const i={};let s,a;for(a in t.properties)if(a!=="children"&&Zp.call(t.properties,a)){const o=TN(e,a,t.properties[a]);if(o){const[c,h]=o;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&gN.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 NN(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 Eo(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 Eo(e,t.position);else o=s.value===null?!0:s.value;i[a]=o}return i}function Jp(e,t){const i=[];let s=-1;const a=e.passKeys?new Map:fN;for(;++s<t.children.length;){const o=t.children[s];let c;if(e.passKeys){const p=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(p){const d=a.get(p)||0;c=p+"-"+d,a.set(p,d+1)}}const h=E0(e,o,c);h!==void 0&&i.push(h)}return i}function TN(e,t,i){const s=iN(e.schema,t);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=s.commaSeparated?qE(i):aN(i)),s.property==="style"){let a=typeof i=="object"?i:jN(e,String(i));return e.stylePropertyNameCase==="css"&&(a=AN(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?JE[s.property]||s.property:s.attribute,i]}}function jN(e,t){try{return dN(t,{reactCompat:!0})}catch(i){if(e.ignoreInvalidStyle)return{};const s=i,a=new en("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=k0+"#cannot-parse-style-attribute",a}}function T0(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=nv(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=nv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return Zp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);Eo(e)}function Eo(e,t){const i=new en("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=k0+"#cannot-handle-mdx-estrees-without-createevaluater",i}function AN(e){const t={};let i;for(i in e)Zp.call(e,i)&&(t[RN(i)]=e[i]);return t}function RN(e){let t=e.replace(pN,MN);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function MN(e){return"-"+e.toLowerCase()}const ff={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"]},DN={};function em(e,t){const i=DN,s=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,a=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return j0(e,s,a)}function j0(e,t,i){if(BN(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 fv(e.children,t,i)}return Array.isArray(e)?fv(e,t,i):""}function fv(e,t,i){const s=[];let a=-1;for(;++a<e.length;)s[a]=j0(e[a],t,i);return s.join("")}function BN(e){return!!(e&&typeof e=="object")}const pv=document.createElement("i");function tm(e){const t="&"+e+";";pv.innerHTML=t;const i=pv.textContent;return i.charCodeAt(i.length-1)===59&&e!=="semi"||i===t?!1:i}function zn(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 tr(e,t){return e.length>0?(zn(e,e.length,0,t),e):t}const mv={}.hasOwnProperty;function A0(e){const t={};let i=-1;for(;++i<e.length;)LN(t,e[i]);return t}function LN(e,t){let i;for(i in t){const a=(mv.call(e,i)?e[i]:void 0)||(e[i]={}),o=t[i];let c;if(o)for(c in o){mv.call(a,c)||(a[c]=[]);const h=o[c];ON(a[c],Array.isArray(h)?h:h?[h]:[])}}}function ON(e,t){let i=-1;const s=[];for(;++i<t.length;)(t[i].add==="after"?e:s).push(t[i]);zn(e,0,0,s)}function R0(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 dr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const un=Bs(/[A-Za-z]/),Ji=Bs(/[\dA-Za-z]/),zN=Bs(/[#-'*+\--9=?A-Z^-~]/);function ju(e){return e!==null&&(e<32||e===127)}const wp=Bs(/\d/),PN=Bs(/[\dA-Fa-f]/),IN=Bs(/[!-/:-@[-`{-~]/);function $e(e){return e!==null&&e<-2}function qt(e){return e!==null&&(e<0||e===32)}function xt(e){return e===-2||e===-1||e===32}const Pu=Bs(new RegExp("\\p{P}|\\p{S}","u")),oa=Bs(/\s/);function Bs(e){return t;function t(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function dl(e){const t=[];let i=-1,s=0,a=0;for(;++i<e.length;){const o=e.charCodeAt(i);let c="";if(o===37&&Ji(e.charCodeAt(i+1))&&Ji(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 HN={tokenize:UN};function UN(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 $e(h)?(e.consume(h),e.exit("chunkText"),o):(e.consume(h),c)}}const $N={tokenize:FN},gv={tokenize:qN};function FN(e){const t=this,i=[];let s=0,a,o,c;return h;function h(O){if(s<i.length){const J=i[s];return t.containerState=J[1],e.attempt(J[0].continuation,p,d)(O)}return d(O)}function p(O){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&L();const J=t.events.length;let $=J,M;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){M=t.events[$][1].end;break}T(s);let X=J;for(;X<t.events.length;)t.events[X][1].end={...M},X++;return zn(t.events,$+1,0,t.events.slice(J)),t.events.length=X,d(O)}return h(O)}function d(O){if(s===i.length){if(!a)return b(O);if(a.currentConstruct&&a.currentConstruct.concrete)return y(O);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(gv,x,_)(O)}function x(O){return a&&L(),T(s),b(O)}function _(O){return t.parser.lazy[t.now().line]=s!==i.length,c=t.now().offset,y(O)}function b(O){return t.containerState={},e.attempt(gv,v,y)(O)}function v(O){return s++,i.push([t.currentConstruct,t.containerState]),b(O)}function y(O){if(O===null){a&&L(),T(0),e.consume(O);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),E(O)}function E(O){if(O===null){A(e.exit("chunkFlow"),!0),T(0),e.consume(O);return}return $e(O)?(e.consume(O),A(e.exit("chunkFlow")),s=0,t.interrupt=void 0,h):(e.consume(O),E)}function A(O,J){const $=t.sliceStream(O);if(J&&$.push(null),O.previous=o,o&&(o.next=O),o=O,a.defineSkip(O.start),a.write($),t.parser.lazy[O.start.line]){let M=a.events.length;for(;M--;)if(a.events[M][1].start.offset<c&&(!a.events[M][1].end||a.events[M][1].end.offset>c))return;const X=t.events.length;let he=X,ye,U;for(;he--;)if(t.events[he][0]==="exit"&&t.events[he][1].type==="chunkFlow"){if(ye){U=t.events[he][1].end;break}ye=!0}for(T(s),M=X;M<t.events.length;)t.events[M][1].end={...U},M++;zn(t.events,he+1,0,t.events.slice(X)),t.events.length=M}}function T(O){let J=i.length;for(;J-- >O;){const $=i[J];t.containerState=$[1],$[0].exit.call(t,e)}i.length=O}function L(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function qN(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 ll(e){if(e===null||qt(e)||oa(e))return 1;if(Pu(e))return 2}function Iu(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 Cp={name:"attention",resolveAll:WN,tokenize:GN};function WN(e,t){let i=-1,s,a,o,c,h,p,d,x;for(;++i<e.length;)if(e[i][0]==="enter"&&e[i][1].type==="attentionSequence"&&e[i][1]._close){for(s=i;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[i][1]).charCodeAt(0)){if((e[s][1]._close||e[i][1]._open)&&(e[i][1].end.offset-e[i][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[i][1].end.offset-e[i][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[i][1].end.offset-e[i][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[i][1].start};_v(_,-p),_v(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...e[i][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[i][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[s][1].end={...c.start},e[i][1].start={...h.end},d=[],e[s][1].end.offset-e[s][1].start.offset&&(d=tr(d,[["enter",e[s][1],t],["exit",e[s][1],t]])),d=tr(d,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),d=tr(d,Iu(t.parser.constructs.insideSpan.null,e.slice(s+1,i),t)),d=tr(d,[["exit",o,t],["enter",h,t],["exit",h,t],["exit",a,t]]),e[i][1].end.offset-e[i][1].start.offset?(x=2,d=tr(d,[["enter",e[i][1],t],["exit",e[i][1],t]])):x=0,zn(e,s-1,i-s+3,d),i=s+d.length-x-2;break}}for(i=-1;++i<e.length;)e[i][1].type==="attentionSequence"&&(e[i][1].type="data");return e}function GN(e,t){const i=this.parser.constructs.attentionMarkers.null,s=this.previous,a=ll(s);let o;return c;function c(p){return o=p,e.enter("attentionSequence"),h(p)}function h(p){if(p===o)return e.consume(p),h;const d=e.exit("attentionSequence"),x=ll(p),_=!x||x===2&&a||i.includes(p),b=!a||a===2&&x||i.includes(s);return d._open=!!(o===42?_:_&&(a||!b)),d._close=!!(o===42?b:b&&(x||!_)),t(p)}}function _v(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const YN={name:"autolink",tokenize:KN};function KN(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 un(v)?(e.consume(v),c):v===64?i(v):d(v)}function c(v){return v===43||v===45||v===46||Ji(v)?(s=1,h(v)):d(v)}function h(v){return v===58?(e.consume(v),s=0,p):(v===43||v===45||v===46||Ji(v))&&s++<32?(e.consume(v),h):(s=0,d(v))}function p(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||ju(v)?i(v):(e.consume(v),p)}function d(v){return v===64?(e.consume(v),x):zN(v)?(e.consume(v),d):i(v)}function x(v){return Ji(v)?_(v):i(v)}function _(v){return v===46?(e.consume(v),s=0,x):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):b(v)}function b(v){if((v===45||Ji(v))&&s++<63){const y=v===45?b:_;return e.consume(v),y}return i(v)}}const Lo={partial:!0,tokenize:VN};function VN(e,t,i){return s;function s(o){return xt(o)?Ct(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||$e(o)?t(o):i(o)}}const M0={continuation:{tokenize:ZN},exit:QN,name:"blockQuote",tokenize:XN};function XN(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 ZN(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(M0,t,i)(c)}}function QN(e){e.exit("blockQuote")}const D0={name:"characterEscape",tokenize:JN};function JN(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 IN(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):i(o)}}const B0={name:"characterReference",tokenize:e5};function e5(e,t,i){const s=this;let a=0,o,c;return h;function h(_){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(_),e.exit("characterReferenceMarker"),p}function p(_){return _===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(_),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,c=Ji,x(_))}function d(_){return _===88||_===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(_),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=PN,x):(e.enter("characterReferenceValue"),o=7,c=wp,x(_))}function x(_){if(_===59&&a){const b=e.exit("characterReferenceValue");return c===Ji&&!tm(s.sliceSerialize(b))?i(_):(e.enter("characterReferenceMarker"),e.consume(_),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(_)&&a++<o?(e.consume(_),x):i(_)}}const xv={partial:!0,tokenize:i5},bv={concrete:!0,name:"codeFenced",tokenize:t5};function t5(e,t,i){const s=this,a={partial:!0,tokenize:$};let o=0,c=0,h;return p;function p(M){return d(M)}function d(M){const X=s.events[s.events.length-1];return o=X&&X[1].type==="linePrefix"?X[2].sliceSerialize(X[1],!0).length:0,h=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(M)}function x(M){return M===h?(c++,e.consume(M),x):c<3?i(M):(e.exit("codeFencedFenceSequence"),xt(M)?Ct(e,_,"whitespace")(M):_(M))}function _(M){return M===null||$e(M)?(e.exit("codeFencedFence"),s.interrupt?t(M):e.check(xv,E,J)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(M))}function b(M){return M===null||$e(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),_(M)):xt(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ct(e,v,"whitespace")(M)):M===96&&M===h?i(M):(e.consume(M),b)}function v(M){return M===null||$e(M)?_(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===null||$e(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),_(M)):M===96&&M===h?i(M):(e.consume(M),y)}function E(M){return e.attempt(a,J,A)(M)}function A(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),T}function T(M){return o>0&&xt(M)?Ct(e,L,"linePrefix",o+1)(M):L(M)}function L(M){return M===null||$e(M)?e.check(xv,E,J)(M):(e.enter("codeFlowValue"),O(M))}function O(M){return M===null||$e(M)?(e.exit("codeFlowValue"),L(M)):(e.consume(M),O)}function J(M){return e.exit("codeFenced"),t(M)}function $(M,X,he){let ye=0;return U;function U(I){return M.enter("lineEnding"),M.consume(I),M.exit("lineEnding"),se}function se(I){return M.enter("codeFencedFence"),xt(I)?Ct(M,W,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):W(I)}function W(I){return I===h?(M.enter("codeFencedFenceSequence"),G(I)):he(I)}function G(I){return I===h?(ye++,M.consume(I),G):ye>=c?(M.exit("codeFencedFenceSequence"),xt(I)?Ct(M,Z,"whitespace")(I):Z(I)):he(I)}function Z(I){return I===null||$e(I)?(M.exit("codeFencedFence"),X(I)):he(I)}}}function i5(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 pf={name:"codeIndented",tokenize:r5},n5={partial:!0,tokenize:s5};function r5(e,t,i){const s=this;return a;function a(d){return e.enter("codeIndented"),Ct(e,o,"linePrefix",5)(d)}function o(d){const x=s.events[s.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?c(d):i(d)}function c(d){return d===null?p(d):$e(d)?e.attempt(n5,c,p)(d):(e.enter("codeFlowValue"),h(d))}function h(d){return d===null||$e(d)?(e.exit("codeFlowValue"),c(d)):(e.consume(d),h)}function p(d){return e.exit("codeIndented"),t(d)}}function s5(e,t,i){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?i(c):$e(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):$e(c)?a(c):i(c)}}const a5={name:"codeText",previous:o5,resolve:l5,tokenize:c5};function l5(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 o5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function c5(e,t,i){let s=0,a,o;return c;function c(_){return e.enter("codeText"),e.enter("codeTextSequence"),h(_)}function h(_){return _===96?(e.consume(_),s++,h):(e.exit("codeTextSequence"),p(_))}function p(_){return _===null?i(_):_===32?(e.enter("space"),e.consume(_),e.exit("space"),p):_===96?(o=e.enter("codeTextSequence"),a=0,x(_)):$e(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):(e.enter("codeTextData"),d(_))}function d(_){return _===null||_===32||_===96||$e(_)?(e.exit("codeTextData"),p(_)):(e.consume(_),d)}function x(_){return _===96?(e.consume(_),a++,x):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(_)):(o.type="codeTextData",d(_))}}class u5{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&&ho(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),ho(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ho(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);ho(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ho(this.left,i.reverse())}}}function ho(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 L0(e){const t={};let i=-1,s,a,o,c,h,p,d;const x=new u5(e);for(;++i<x.length;){for(;i in t;)i=t[i];if(s=x.get(i),i&&s[1].type==="chunkFlow"&&x.get(i-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,o=0,o<p.length&&p[o][1].type==="lineEndingBlank"&&(o+=2),o<p.length&&p[o][1].type==="content"))for(;++o<p.length&&p[o][1].type!=="content";)p[o][1].type==="chunkText"&&(p[o][1]._isInFirstContentOfListItem=!0,o++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,h5(x,i)),i=t[i],d=!0);else if(s[1]._container){for(o=i,a=void 0;o--;)if(c=x.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(x.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(s[1].end={...x.get(a)[1].start},h=x.slice(a,i),h.unshift(s),x.splice(a,i-a+1,h))}}return zn(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!d}function h5(e,t){const i=e.get(t)[1],s=e.get(t)[2];let a=t-1;const o=[];let c=i._tokenizer;c||(c=s.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,p=[],d={};let x,_,b=-1,v=i,y=0,E=0;const A=[E];for(;v;){for(;e.get(++a)[1]!==v;);o.push(a),v._tokenizer||(x=s.sliceStream(v),v.next||x.push(null),_&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(x),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),_=v,v=v.next}for(v=i;++b<h.length;)h[b][0]==="exit"&&h[b-1][0]==="enter"&&h[b][1].type===h[b-1][1].type&&h[b][1].start.line!==h[b][1].end.line&&(E=b+1,A.push(E),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):A.pop(),b=A.length;b--;){const T=h.slice(A[b],A[b+1]),L=o.pop();p.push([L,L+T.length-1]),e.splice(L,2,T)}for(p.reverse(),b=-1;++b<p.length;)d[y+p[b][0]]=y+p[b][1],y+=p[b][1]-p[b][0]-1;return d}const d5={resolve:p5,tokenize:m5},f5={partial:!0,tokenize:g5};function p5(e){return L0(e),e}function m5(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):$e(h)?e.check(f5,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 g5(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||$e(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 O0(e,t,i,s,a,o,c,h,p){const d=p||Number.POSITIVE_INFINITY;let x=0;return _;function _(T){return T===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(T),e.exit(o),b):T===null||T===32||T===41||ju(T)?i(T):(e.enter(s),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),E(T))}function b(T){return T===62?(e.enter(o),e.consume(T),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(h),e.enter("chunkString",{contentType:"string"}),v(T))}function v(T){return T===62?(e.exit("chunkString"),e.exit(h),b(T)):T===null||T===60||$e(T)?i(T):(e.consume(T),T===92?y:v)}function y(T){return T===60||T===62||T===92?(e.consume(T),v):v(T)}function E(T){return!x&&(T===null||T===41||qt(T))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(s),t(T)):x<d&&T===40?(e.consume(T),x++,E):T===41?(e.consume(T),x--,E):T===null||T===32||T===40||ju(T)?i(T):(e.consume(T),T===92?A:E)}function A(T){return T===40||T===41||T===92?(e.consume(T),E):E(T)}}function z0(e,t,i,s,a,o){const c=this;let h=0,p;return d;function d(v){return e.enter(s),e.enter(a),e.consume(v),e.exit(a),e.enter(o),x}function x(v){return h>999||v===null||v===91||v===93&&!p||v===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?i(v):v===93?(e.exit(o),e.enter(a),e.consume(v),e.exit(a),e.exit(s),t):$e(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),_(v))}function _(v){return v===null||v===91||v===93||$e(v)||h++>999?(e.exit("chunkString"),x(v)):(e.consume(v),p||(p=!xt(v)),v===92?b:_)}function b(v){return v===91||v===92||v===93?(e.consume(v),h++,_):_(v)}}function P0(e,t,i,s,a,o){let c;return h;function h(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):i(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),d(b))}function d(b){return b===c?(e.exit(o),p(c)):b===null?i(b):$e(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ct(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===c||b===null||$e(b)?(e.exit("chunkString"),d(b)):(e.consume(b),b===92?_:x)}function _(b){return b===c||b===92?(e.consume(b),x):x(b)}}function yo(e,t){let i;return s;function s(a){return $e(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 _5={name:"definition",tokenize:b5},x5={partial:!0,tokenize:v5};function b5(e,t,i){const s=this;let a;return o;function o(v){return e.enter("definition"),c(v)}function c(v){return z0.call(s,e,h,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function h(v){return a=dr(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 qt(v)?yo(e,d)(v):d(v)}function d(v){return O0(e,x,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function x(v){return e.attempt(x5,_,_)(v)}function _(v){return xt(v)?Ct(e,b,"whitespace")(v):b(v)}function b(v){return v===null||$e(v)?(e.exit("definition"),s.parser.defined.push(a),t(v)):i(v)}}function v5(e,t,i){return s;function s(h){return qt(h)?yo(e,a)(h):i(h)}function a(h){return P0(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||$e(h)?t(h):i(h)}}const y5={name:"hardBreakEscape",tokenize:S5};function S5(e,t,i){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return $e(o)?(e.exit("hardBreakEscape"),t(o)):i(o)}}const w5={name:"headingAtx",resolve:C5,tokenize:k5};function C5(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"},zn(e,s,i-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function k5(e,t,i){let s=0;return a;function a(x){return e.enter("atxHeading"),o(x)}function o(x){return e.enter("atxHeadingSequence"),c(x)}function c(x){return x===35&&s++<6?(e.consume(x),c):x===null||qt(x)?(e.exit("atxHeadingSequence"),h(x)):i(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),p(x)):x===null||$e(x)?(e.exit("atxHeading"),t(x)):xt(x)?Ct(e,h,"whitespace")(x):(e.enter("atxHeadingText"),d(x))}function p(x){return x===35?(e.consume(x),p):(e.exit("atxHeadingSequence"),h(x))}function d(x){return x===null||x===35||qt(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),d)}}const E5=["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"],vv=["pre","script","style","textarea"],N5={concrete:!0,name:"htmlFlow",resolveTo:A5,tokenize:R5},T5={partial:!0,tokenize:D5},j5={partial:!0,tokenize:M5};function A5(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 R5(e,t,i){const s=this;let a,o,c,h,p;return d;function d(w){return x(w)}function x(w){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(w),_}function _(w){return w===33?(e.consume(w),b):w===47?(e.consume(w),o=!0,E):w===63?(e.consume(w),a=3,s.interrupt?t:N):un(w)?(e.consume(w),c=String.fromCharCode(w),A):i(w)}function b(w){return w===45?(e.consume(w),a=2,v):w===91?(e.consume(w),a=5,h=0,y):un(w)?(e.consume(w),a=4,s.interrupt?t:N):i(w)}function v(w){return w===45?(e.consume(w),s.interrupt?t:N):i(w)}function y(w){const ae="CDATA[";return w===ae.charCodeAt(h++)?(e.consume(w),h===ae.length?s.interrupt?t:W:y):i(w)}function E(w){return un(w)?(e.consume(w),c=String.fromCharCode(w),A):i(w)}function A(w){if(w===null||w===47||w===62||qt(w)){const ae=w===47,ie=c.toLowerCase();return!ae&&!o&&vv.includes(ie)?(a=1,s.interrupt?t(w):W(w)):E5.includes(c.toLowerCase())?(a=6,ae?(e.consume(w),T):s.interrupt?t(w):W(w)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?i(w):o?L(w):O(w))}return w===45||Ji(w)?(e.consume(w),c+=String.fromCharCode(w),A):i(w)}function T(w){return w===62?(e.consume(w),s.interrupt?t:W):i(w)}function L(w){return xt(w)?(e.consume(w),L):U(w)}function O(w){return w===47?(e.consume(w),U):w===58||w===95||un(w)?(e.consume(w),J):xt(w)?(e.consume(w),O):U(w)}function J(w){return w===45||w===46||w===58||w===95||Ji(w)?(e.consume(w),J):$(w)}function $(w){return w===61?(e.consume(w),M):xt(w)?(e.consume(w),$):O(w)}function M(w){return w===null||w===60||w===61||w===62||w===96?i(w):w===34||w===39?(e.consume(w),p=w,X):xt(w)?(e.consume(w),M):he(w)}function X(w){return w===p?(e.consume(w),p=null,ye):w===null||$e(w)?i(w):(e.consume(w),X)}function he(w){return w===null||w===34||w===39||w===47||w===60||w===61||w===62||w===96||qt(w)?$(w):(e.consume(w),he)}function ye(w){return w===47||w===62||xt(w)?O(w):i(w)}function U(w){return w===62?(e.consume(w),se):i(w)}function se(w){return w===null||$e(w)?W(w):xt(w)?(e.consume(w),se):i(w)}function W(w){return w===45&&a===2?(e.consume(w),j):w===60&&a===1?(e.consume(w),z):w===62&&a===4?(e.consume(w),R):w===63&&a===3?(e.consume(w),N):w===93&&a===5?(e.consume(w),_e):$e(w)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(T5,Y,G)(w)):w===null||$e(w)?(e.exit("htmlFlowData"),G(w)):(e.consume(w),W)}function G(w){return e.check(j5,Z,Y)(w)}function Z(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),I}function I(w){return w===null||$e(w)?G(w):(e.enter("htmlFlowData"),W(w))}function j(w){return w===45?(e.consume(w),N):W(w)}function z(w){return w===47?(e.consume(w),c="",B):W(w)}function B(w){if(w===62){const ae=c.toLowerCase();return vv.includes(ae)?(e.consume(w),R):W(w)}return un(w)&&c.length<8?(e.consume(w),c+=String.fromCharCode(w),B):W(w)}function _e(w){return w===93?(e.consume(w),N):W(w)}function N(w){return w===62?(e.consume(w),R):w===45&&a===2?(e.consume(w),N):W(w)}function R(w){return w===null||$e(w)?(e.exit("htmlFlowData"),Y(w)):(e.consume(w),R)}function Y(w){return e.exit("htmlFlow"),t(w)}}function M5(e,t,i){const s=this;return a;function a(c){return $e(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 D5(e,t,i){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Lo,t,i)}}const B5={name:"htmlText",tokenize:L5};function L5(e,t,i){const s=this;let a,o,c;return h;function h(N){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),d):N===47?(e.consume(N),$):N===63?(e.consume(N),O):un(N)?(e.consume(N),he):i(N)}function d(N){return N===45?(e.consume(N),x):N===91?(e.consume(N),o=0,y):un(N)?(e.consume(N),L):i(N)}function x(N){return N===45?(e.consume(N),v):i(N)}function _(N){return N===null?i(N):N===45?(e.consume(N),b):$e(N)?(c=_,z(N)):(e.consume(N),_)}function b(N){return N===45?(e.consume(N),v):_(N)}function v(N){return N===62?j(N):N===45?b(N):_(N)}function y(N){const R="CDATA[";return N===R.charCodeAt(o++)?(e.consume(N),o===R.length?E:y):i(N)}function E(N){return N===null?i(N):N===93?(e.consume(N),A):$e(N)?(c=E,z(N)):(e.consume(N),E)}function A(N){return N===93?(e.consume(N),T):E(N)}function T(N){return N===62?j(N):N===93?(e.consume(N),T):E(N)}function L(N){return N===null||N===62?j(N):$e(N)?(c=L,z(N)):(e.consume(N),L)}function O(N){return N===null?i(N):N===63?(e.consume(N),J):$e(N)?(c=O,z(N)):(e.consume(N),O)}function J(N){return N===62?j(N):O(N)}function $(N){return un(N)?(e.consume(N),M):i(N)}function M(N){return N===45||Ji(N)?(e.consume(N),M):X(N)}function X(N){return $e(N)?(c=X,z(N)):xt(N)?(e.consume(N),X):j(N)}function he(N){return N===45||Ji(N)?(e.consume(N),he):N===47||N===62||qt(N)?ye(N):i(N)}function ye(N){return N===47?(e.consume(N),j):N===58||N===95||un(N)?(e.consume(N),U):$e(N)?(c=ye,z(N)):xt(N)?(e.consume(N),ye):j(N)}function U(N){return N===45||N===46||N===58||N===95||Ji(N)?(e.consume(N),U):se(N)}function se(N){return N===61?(e.consume(N),W):$e(N)?(c=se,z(N)):xt(N)?(e.consume(N),se):ye(N)}function W(N){return N===null||N===60||N===61||N===62||N===96?i(N):N===34||N===39?(e.consume(N),a=N,G):$e(N)?(c=W,z(N)):xt(N)?(e.consume(N),W):(e.consume(N),Z)}function G(N){return N===a?(e.consume(N),a=void 0,I):N===null?i(N):$e(N)?(c=G,z(N)):(e.consume(N),G)}function Z(N){return N===null||N===34||N===39||N===60||N===61||N===96?i(N):N===47||N===62||qt(N)?ye(N):(e.consume(N),Z)}function I(N){return N===47||N===62||qt(N)?ye(N):i(N)}function j(N){return N===62?(e.consume(N),e.exit("htmlTextData"),e.exit("htmlText"),t):i(N)}function z(N){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),B}function B(N){return xt(N)?Ct(e,_e,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):_e(N)}function _e(N){return e.enter("htmlTextData"),c(N)}}const im={name:"labelEnd",resolveAll:I5,resolveTo:H5,tokenize:U5},O5={tokenize:$5},z5={tokenize:F5},P5={tokenize:q5};function I5(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&&zn(e,0,e.length,i),e}function H5(e,t){let i=e.length,s=0,a,o,c,h;for(;i--;)if(a=e[i][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[i][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[i][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=i,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(c=i);const p={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},x={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",p,t],["enter",d,t]],h=tr(h,e.slice(o+1,o+s+3)),h=tr(h,[["enter",x,t]]),h=tr(h,Iu(t.parser.constructs.insideSpan.null,e.slice(o+s+4,c-3),t)),h=tr(h,[["exit",x,t],e[c-2],e[c-1],["exit",d,t]]),h=tr(h,e.slice(c+1)),h=tr(h,[["exit",p,t]]),zn(e,o,e.length,h),e}function U5(e,t,i){const s=this;let a=s.events.length,o,c;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){o=s.events[a][1];break}return h;function h(b){return o?o._inactive?_(b):(c=s.parser.defined.includes(dr(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(O5,x,c?x:_)(b):b===91?e.attempt(z5,x,c?d:_)(b):c?x(b):_(b)}function d(b){return e.attempt(P5,x,_)(b)}function x(b){return t(b)}function _(b){return o._balanced=!0,i(b)}}function $5(e,t,i){return s;function s(_){return e.enter("resource"),e.enter("resourceMarker"),e.consume(_),e.exit("resourceMarker"),a}function a(_){return qt(_)?yo(e,o)(_):o(_)}function o(_){return _===41?x(_):O0(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(_)}function c(_){return qt(_)?yo(e,p)(_):x(_)}function h(_){return i(_)}function p(_){return _===34||_===39||_===40?P0(e,d,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(_):x(_)}function d(_){return qt(_)?yo(e,x)(_):x(_)}function x(_){return _===41?(e.enter("resourceMarker"),e.consume(_),e.exit("resourceMarker"),e.exit("resource"),t):i(_)}}function F5(e,t,i){const s=this;return a;function a(h){return z0.call(s,e,o,c,"reference","referenceMarker","referenceString")(h)}function o(h){return s.parser.defined.includes(dr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(h):i(h)}function c(h){return i(h)}}function q5(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 W5={name:"labelStartImage",resolveAll:im.resolveAll,tokenize:G5};function G5(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 Y5={name:"labelStartLink",resolveAll:im.resolveAll,tokenize:K5};function K5(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 mf={name:"lineEnding",tokenize:V5};function V5(e,t){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ct(e,t,"linePrefix")}}const xu={name:"thematicBreak",tokenize:X5};function X5(e,t,i){let s=0,a;return o;function o(d){return e.enter("thematicBreak"),c(d)}function c(d){return a=d,h(d)}function h(d){return d===a?(e.enter("thematicBreakSequence"),p(d)):s>=3&&(d===null||$e(d))?(e.exit("thematicBreak"),t(d)):i(d)}function p(d){return d===a?(e.consume(d),s++,p):(e.exit("thematicBreakSequence"),xt(d)?Ct(e,h,"whitespace")(d):h(d))}}const wn={continuation:{tokenize:eT},exit:iT,name:"list",tokenize:J5},Z5={partial:!0,tokenize:nT},Q5={partial:!0,tokenize:tT};function J5(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 y=s.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!s.containerState.marker||v===s.containerState.marker:wp(v)){if(s.containerState.type||(s.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(xu,i,d)(v):d(v);if(!s.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(v)}return i(v)}function p(v){return wp(v)&&++c<10?(e.consume(v),p):(!s.interrupt||c<2)&&(s.containerState.marker?v===s.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),d(v)):i(v)}function d(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||v,e.check(Lo,s.interrupt?i:x,e.attempt(Z5,b,_))}function x(v){return s.containerState.initialBlankLine=!0,o++,b(v)}function _(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 eT(e,t,i){const s=this;return s.containerState._closeFlow=void 0,e.check(Lo,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(Q5,t,c)(h))}function c(h){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ct(e,e.attempt(wn,t,i),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function tT(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 iT(e){e.exit(this.containerState.type)}function nT(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 yv={name:"setextUnderline",resolveTo:rT,tokenize:sT};function rT(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 sT(e,t,i){const s=this;let a;return o;function o(d){let x=s.events.length,_;for(;x--;)if(s.events[x][1].type!=="lineEnding"&&s.events[x][1].type!=="linePrefix"&&s.events[x][1].type!=="content"){_=s.events[x][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=d,c(d)):i(d)}function c(d){return e.enter("setextHeadingLineSequence"),h(d)}function h(d){return d===a?(e.consume(d),h):(e.exit("setextHeadingLineSequence"),xt(d)?Ct(e,p,"lineSuffix")(d):p(d))}function p(d){return d===null||$e(d)?(e.exit("setextHeadingLine"),t(d)):i(d)}}const aT={tokenize:lT};function lT(e){const t=this,i=e.attempt(Lo,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 oT={resolveAll:H0()},cT=I0("string"),uT=I0("text");function I0(e){return{resolveAll:H0(e==="text"?hT:void 0),tokenize:t};function t(i){const s=this,a=this.parser.constructs[e],o=i.attempt(a,c,h);return c;function c(x){return d(x)?o(x):h(x)}function h(x){if(x===null){i.consume(x);return}return i.enter("data"),i.consume(x),p}function p(x){return d(x)?(i.exit("data"),o(x)):(i.consume(x),p)}function d(x){if(x===null)return!0;const _=a[x];let b=-1;if(_)for(;++b<_.length;){const v=_[b];if(!v.previous||v.previous.call(s,s.previous))return!0}return!1}}}function H0(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 hT(e,t){let i=0;for(;++i<=e.length;)if((i===e.length||e[i][1].type==="lineEnding")&&e[i-1][1].type==="data"){const s=e[i-1][1],a=t.sliceStream(s);let o=a.length,c=-1,h=0,p;for(;o--;){const d=a[o];if(typeof d=="string"){for(c=d.length;d.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(d===-2)p=!0,h++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&i===e.length&&(h=0),h){const d={type:i===e.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-h,offset:s.end.offset-h},end:{...s.end}};s.end={...d.start},s.start.offset===s.end.offset?Object.assign(s,d):(e.splice(i,0,["enter",d,t],["exit",d,t]),i+=2)}i++}return e}const dT={42:wn,43:wn,45:wn,48:wn,49:wn,50:wn,51:wn,52:wn,53:wn,54:wn,55:wn,56:wn,57:wn,62:M0},fT={91:_5},pT={[-2]:pf,[-1]:pf,32:pf},mT={35:w5,42:xu,45:[yv,xu],60:N5,61:yv,95:xu,96:bv,126:bv},gT={38:B0,92:D0},_T={[-5]:mf,[-4]:mf,[-3]:mf,33:W5,38:B0,42:Cp,60:[YN,B5],91:Y5,92:[y5,D0],93:im,95:Cp,96:a5},xT={null:[Cp,oT]},bT={null:[42,95]},vT={null:[]},yT=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:bT,contentInitial:fT,disable:vT,document:dT,flow:mT,flowInitial:pT,insideSpan:xT,string:gT,text:_T},Symbol.toStringTag,{value:"Module"}));function ST(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:X($),check:X(M),consume:L,enter:O,exit:J,interrupt:X(M,{interrupt:!0})},d={code:null,containerState:{},defineSkip:E,events:[],now:y,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:_};let x=t.tokenize.call(d,p);return t.resolveAll&&o.push(t),d;function _(se){return c=tr(c,se),A(),c[c.length-1]!==null?[]:(he(t,0),d.events=Iu(o,d.events,d),d.events)}function b(se,W){return CT(v(se),W)}function v(se){return wT(c,se)}function y(){const{_bufferIndex:se,_index:W,line:G,column:Z,offset:I}=s;return{_bufferIndex:se,_index:W,line:G,column:Z,offset:I}}function E(se){a[se.line]=se.column,U()}function A(){let se;for(;s._index<c.length;){const W=c[s._index];if(typeof W=="string")for(se=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===se&&s._bufferIndex<W.length;)T(W.charCodeAt(s._bufferIndex));else T(W)}}function T(se){x=x(se)}function L(se){$e(se)?(s.line++,s.column=1,s.offset+=se===-3?2:1,U()):se!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),d.previous=se}function O(se,W){const G=W||{};return G.type=se,G.start=y(),d.events.push(["enter",G,d]),h.push(G),G}function J(se){const W=h.pop();return W.end=y(),d.events.push(["exit",W,d]),W}function $(se,W){he(se,W.from)}function M(se,W){W.restore()}function X(se,W){return G;function G(Z,I,j){let z,B,_e,N;return Array.isArray(Z)?Y(Z):"tokenize"in Z?Y([Z]):R(Z);function R(oe){return F;function F(ue){const be=ue!==null&&oe[ue],De=ue!==null&&oe.null,Ee=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(De)?De:De?[De]:[]];return Y(Ee)(ue)}}function Y(oe){return z=oe,B=0,oe.length===0?j:w(oe[B])}function w(oe){return F;function F(ue){return N=ye(),_e=oe,oe.partial||(d.currentConstruct=oe),oe.name&&d.parser.constructs.disable.null.includes(oe.name)?ie():oe.tokenize.call(W?Object.assign(Object.create(d),W):d,p,ae,ie)(ue)}}function ae(oe){return se(_e,N),I}function ie(oe){return N.restore(),++B<z.length?w(z[B]):j}}}function he(se,W){se.resolveAll&&!o.includes(se)&&o.push(se),se.resolve&&zn(d.events,W,d.events.length-W,se.resolve(d.events.slice(W),d)),se.resolveTo&&(d.events=se.resolveTo(d.events,d))}function ye(){const se=y(),W=d.previous,G=d.currentConstruct,Z=d.events.length,I=Array.from(h);return{from:Z,restore:j};function j(){s=se,d.previous=W,d.currentConstruct=G,d.events.length=Z,h=I,U()}}function U(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function wT(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 CT(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 kT(e){const s={constructs:A0([yT,...(e||{}).extensions||[]]),content:a(HN),defined:[],document:a($N),flow:a(aT),lazy:{},string:a(cT),text:a(uT)};return s;function a(o){return c;function c(h){return ST(s,o,h)}}}function ET(e){for(;!L0(e););return e}const Sv=/[\0\t\n\r]/g;function NT(){let e=1,t="",i=!0,s;return a;function a(o,c,h){const p=[];let d,x,_,b,v;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),_=0,t="",i&&(o.charCodeAt(0)===65279&&_++,i=void 0);_<o.length;){if(Sv.lastIndex=_,d=Sv.exec(o),b=d&&d.index!==void 0?d.index:o.length,v=o.charCodeAt(b),!d){t=o.slice(_);break}if(v===10&&_===b&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),_<b&&(p.push(o.slice(_,b)),e+=b-_),v){case 0:{p.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,p.push(-2);e++<x;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}_=b+1}return h&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const TT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function jT(e){return e.replace(TT,AT)}function AT(e,t,i){if(t)return t;if(i.charCodeAt(0)===35){const a=i.charCodeAt(1),o=a===120||a===88;return R0(i.slice(o?2:1),o?16:10)}return tm(i)||e}const U0={}.hasOwnProperty;function RT(e,t,i){return t&&typeof t=="object"&&(i=t,t=void 0),MT(i)(ET(kT(i).document().write(NT()(e,t,!0))))}function MT(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ae),autolinkProtocol:ye,autolinkEmail:ye,atxHeading:o(we),blockQuote:o(De),characterEscape:ye,characterReference:ye,codeFenced:o(Ee),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Ee,c),codeText:o(Be,c),codeTextData:ye,data:ye,codeFlowValue:ye,definition:o(je),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(Ze),hardBreakEscape:o(tt),hardBreakTrailing:o(tt),htmlFlow:o(mt,c),htmlFlowData:ye,htmlText:o(mt,c),htmlTextData:ye,image:o(Ge),label:c,link:o(Ae),listItem:o(Mt),listItemValue:b,listOrdered:o(Ve,_),listUnordered:o(Ve),paragraph:o(zt),reference:w,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(we),strong:o(ai),thematicBreak:o(hi)},exit:{atxHeading:p(),atxHeadingSequence:$,autolink:p(),autolinkEmail:be,autolinkProtocol:ue,blockQuote:p(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:oe,characterReference:F,codeFenced:p(A),codeFencedFence:E,codeFencedFenceInfo:v,codeFencedFenceMeta:y,codeFlowValue:U,codeIndented:p(T),codeText:p(I),codeTextData:U,data:U,definition:p(),definitionDestinationString:J,definitionLabelString:L,definitionTitleString:O,emphasis:p(),hardBreakEscape:p(W),hardBreakTrailing:p(W),htmlFlow:p(G),htmlFlowData:U,htmlText:p(Z),htmlTextData:U,image:p(z),label:_e,labelText:B,lineEnding:se,link:p(j),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:ae,resourceDestinationString:N,resourceTitleString:R,resource:Y,setextHeading:p(he),setextHeadingLineSequence:X,setextHeadingText:M,strong:p(),thematicBreak:p()}};$0(t,(e||{}).mdastExtensions||[]);const i={};return s;function s(re){let xe={type:"root",children:[]};const Pe={stack:[xe],tokenStack:[],config:t,enter:h,exit:d,buffer:c,resume:x,data:i},Fe=[];let Qe=-1;for(;++Qe<re.length;)if(re[Qe][1].type==="listOrdered"||re[Qe][1].type==="listUnordered")if(re[Qe][0]==="enter")Fe.push(Qe);else{const H=Fe.pop();Qe=a(re,H,Qe)}for(Qe=-1;++Qe<re.length;){const H=t[re[Qe][0]];U0.call(H,re[Qe][1].type)&&H[re[Qe][1].type].call(Object.assign({sliceSerialize:re[Qe][2].sliceSerialize},Pe),re[Qe][1])}if(Pe.tokenStack.length>0){const H=Pe.tokenStack[Pe.tokenStack.length-1];(H[1]||wv).call(Pe,void 0,H[0])}for(xe.position={start:Ts(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:Ts(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},Qe=-1;++Qe<t.transforms.length;)xe=t.transforms[Qe](xe)||xe;return xe}function a(re,xe,Pe){let Fe=xe-1,Qe=-1,H=!1,ge,Te,me,He;for(;++Fe<=Pe;){const Oe=re[Fe];switch(Oe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Oe[0]==="enter"?Qe++:Qe--,He=void 0;break}case"lineEndingBlank":{Oe[0]==="enter"&&(ge&&!He&&!Qe&&!me&&(me=Fe),He=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:He=void 0}if(!Qe&&Oe[0]==="enter"&&Oe[1].type==="listItemPrefix"||Qe===-1&&Oe[0]==="exit"&&(Oe[1].type==="listUnordered"||Oe[1].type==="listOrdered")){if(ge){let ut=Fe;for(Te=void 0;ut--;){const it=re[ut];if(it[1].type==="lineEnding"||it[1].type==="lineEndingBlank"){if(it[0]==="exit")continue;Te&&(re[Te][1].type="lineEndingBlank",H=!0),it[1].type="lineEnding",Te=ut}else if(!(it[1].type==="linePrefix"||it[1].type==="blockQuotePrefix"||it[1].type==="blockQuotePrefixWhitespace"||it[1].type==="blockQuoteMarker"||it[1].type==="listItemIndent"))break}me&&(!Te||me<Te)&&(ge._spread=!0),ge.end=Object.assign({},Te?re[Te][1].start:Oe[1].end),re.splice(Te||Fe,0,["exit",ge,Oe[2]]),Fe++,Pe++}if(Oe[1].type==="listItemPrefix"){const ut={type:"listItem",_spread:!1,start:Object.assign({},Oe[1].start),end:void 0};ge=ut,re.splice(Fe,0,["enter",ut,Oe[2]]),Fe++,Pe++,me=void 0,He=!0}}}return re[xe][1]._spread=H,Pe}function o(re,xe){return Pe;function Pe(Fe){h.call(this,re(Fe),Fe),xe&&xe.call(this,Fe)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(re,xe,Pe){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([xe,Pe||void 0]),re.position={start:Ts(xe.start),end:void 0}}function p(re){return xe;function xe(Pe){re&&re.call(this,Pe),d.call(this,Pe)}}function d(re,xe){const Pe=this.stack.pop(),Fe=this.tokenStack.pop();if(Fe)Fe[0].type!==re.type&&(xe?xe.call(this,re,Fe[0]):(Fe[1]||wv).call(this,re,Fe[0]));else throw new Error("Cannot close `"+re.type+"` ("+vo({start:re.start,end:re.end})+"): it’s not open");Pe.position.end=Ts(re.end)}function x(){return em(this.stack.pop())}function _(){this.data.expectingFirstListItemValue=!0}function b(re){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function v(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=re}function y(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=re}function E(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function A(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.value=re.replace(/(\r?\n|\r)$/g,"")}function L(re){const xe=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=xe,Pe.identifier=dr(this.sliceSerialize(re)).toLowerCase()}function O(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.title=re}function J(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.url=re}function $(re){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Pe=this.sliceSerialize(re).length;xe.depth=Pe}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function X(re){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function he(){this.data.setextHeadingSlurpLineEnding=void 0}function ye(re){const Pe=this.stack[this.stack.length-1].children;let Fe=Pe[Pe.length-1];(!Fe||Fe.type!=="text")&&(Fe=wt(),Fe.position={start:Ts(re.start),end:void 0},Pe.push(Fe)),this.stack.push(Fe)}function U(re){const xe=this.stack.pop();xe.value+=this.sliceSerialize(re),xe.position.end=Ts(re.end)}function se(re){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Pe=xe.children[xe.children.length-1];Pe.position.end=Ts(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(ye.call(this,re),U.call(this,re))}function W(){this.data.atHardBreak=!0}function G(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.value=re}function Z(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.value=re}function I(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.value=re}function j(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=xe,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function z(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=xe,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function B(re){const xe=this.sliceSerialize(re),Pe=this.stack[this.stack.length-2];Pe.label=jT(xe),Pe.identifier=dr(xe).toLowerCase()}function _e(){const re=this.stack[this.stack.length-1],xe=this.resume(),Pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Pe.type==="link"){const Fe=re.children;Pe.children=Fe}else Pe.alt=xe}function N(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.url=re}function R(){const re=this.resume(),xe=this.stack[this.stack.length-1];xe.title=re}function Y(){this.data.inReference=void 0}function w(){this.data.referenceType="collapsed"}function ae(re){const xe=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=xe,Pe.identifier=dr(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function ie(re){this.data.characterReferenceType=re.type}function oe(re){const xe=this.sliceSerialize(re),Pe=this.data.characterReferenceType;let Fe;Pe?(Fe=R0(xe,Pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Fe=tm(xe);const Qe=this.stack[this.stack.length-1];Qe.value+=Fe}function F(re){const xe=this.stack.pop();xe.position.end=Ts(re.end)}function ue(re){U.call(this,re);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(re)}function be(re){U.call(this,re);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(re)}function De(){return{type:"blockquote",children:[]}}function Ee(){return{type:"code",lang:null,meta:null,value:""}}function Be(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ze(){return{type:"emphasis",children:[]}}function we(){return{type:"heading",depth:0,children:[]}}function tt(){return{type:"break"}}function mt(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Ae(){return{type:"link",title:null,url:"",children:[]}}function Ve(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function Mt(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function zt(){return{type:"paragraph",children:[]}}function ai(){return{type:"strong",children:[]}}function wt(){return{type:"text",value:""}}function hi(){return{type:"thematicBreak"}}}function Ts(e){return{line:e.line,column:e.column,offset:e.offset}}function $0(e,t){let i=-1;for(;++i<t.length;){const s=t[i];Array.isArray(s)?$0(e,s):DT(e,s)}}function DT(e,t){let i;for(i in t)if(U0.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 wv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vo({start:t.start,end:t.end})+") is still open")}function BT(e){const t=this;t.parser=i;function i(s){return RT(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function LT(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 OT(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:`
|
|
105
|
+
`}]}function zT(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 PT(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function IT(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function HT(e,t){const i=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=dl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,h=e.footnoteCounts.get(s);h===void 0?(h=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,h+=1,e.footnoteCounts.set(s,h);const p={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+a,id:i+"fnref-"+a+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const d={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,d),e.applyData(t,d)}function UT(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 $T(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}}function F0(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 FT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return F0(e,t);const a={src:dl(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 qT(e,t){const i={src:dl(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 WT(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 GT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return F0(e,t);const a={href:dl(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 YT(e,t){const i={href:dl(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 KT(e,t,i){const s=e.all(t),a=i?VT(i):q0(t),o={},c=[];if(typeof t.checked=="boolean"){const x=s[0];let _;x&&x.type==="element"&&x.tagName==="p"?_=x:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let h=-1;for(;++h<s.length;){const x=s[h];(a||h!==0||x.type!=="element"||x.tagName!=="p")&&c.push({type:"text",value:`
|
|
107
|
+
`}),x.type==="element"&&x.tagName==="p"&&!a?c.push(...x.children):c.push(x)}const p=s[s.length-1];p&&(a||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
|
|
108
|
+
`});const d={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,d),e.applyData(t,d)}function VT(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=q0(i[s])}return t}function q0(e){const t=e.spread;return t??e.children.length>1}function XT(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 ZT(e,t){const i={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function QT(e,t){const i={type:"root",children:e.wrap(e.all(t))};return e.patch(t,i),e.applyData(t,i)}function JT(e,t){const i={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function ej(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=Xp(t.children[1]),p=S0(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 tj(e,t,i){const s=i?i.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=i&&i.type==="table"?i.align:void 0,h=c?c.length:t.children.length;let p=-1;const d=[];for(;++p<h;){const _=t.children[p],b={},v=c?c[p]:void 0;v&&(b.align=v);let y={type:"element",tagName:o,properties:b,children:[]};_&&(y.children=e.all(_),e.patch(_,y),y=e.applyData(_,y)),d.push(y)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,x),e.applyData(t,x)}function ij(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}const Cv=9,kv=32;function nj(e){const t=String(e),i=/\r?\n|\r/g;let s=i.exec(t),a=0;const o=[];for(;s;)o.push(Ev(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=i.exec(t);return o.push(Ev(t.slice(a),a>0,!1)),o.join("")}function Ev(e,t,i){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cv||o===kv;)s++,o=e.codePointAt(s)}if(i){let o=e.codePointAt(a-1);for(;o===Cv||o===kv;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function rj(e,t){const i={type:"text",value:nj(String(t.value))};return e.patch(t,i),e.applyData(t,i)}function sj(e,t){const i={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,i),e.applyData(t,i)}const aj={blockquote:LT,break:OT,code:zT,delete:PT,emphasis:IT,footnoteReference:HT,heading:UT,html:$T,imageReference:FT,image:qT,inlineCode:WT,linkReference:GT,link:YT,listItem:KT,list:XT,paragraph:ZT,root:QT,strong:JT,table:ej,tableCell:ij,tableRow:tj,text:rj,thematicBreak:sj,toml:eu,yaml:eu,definition:eu,footnoteDefinition:eu};function eu(){}const W0=-1,Hu=0,So=1,Au=2,nm=3,rm=4,sm=5,am=6,G0=7,Y0=8,Nv=typeof self=="object"?self:globalThis,lj=(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 Hu:case W0:return i(c,a);case So:{const h=i([],a);for(const p of c)h.push(s(p));return h}case Au:{const h=i({},a);for(const[p,d]of c)h[s(p)]=s(d);return h}case nm:return i(new Date(c),a);case rm:{const{source:h,flags:p}=c;return i(new RegExp(h,p),a)}case sm:{const h=i(new Map,a);for(const[p,d]of c)h.set(s(p),s(d));return h}case am:{const h=i(new Set,a);for(const p of c)h.add(s(p));return h}case G0:{const{name:h,message:p}=c;return i(new Nv[h](p),a)}case Y0: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 Nv[o](c),a)};return s},Tv=e=>lj(new Map,e)(0),el="",{toString:oj}={},{keys:cj}=Object,fo=e=>{const t=typeof e;if(t!=="object"||!e)return[Hu,t];const i=oj.call(e).slice(8,-1);switch(i){case"Array":return[So,el];case"Object":return[Au,el];case"Date":return[nm,el];case"RegExp":return[rm,el];case"Map":return[sm,el];case"Set":return[am,el];case"DataView":return[So,i]}return i.includes("Array")?[So,i]:i.includes("Error")?[G0,i]:[Au,i]},tu=([e,t])=>e===Hu&&(t==="function"||t==="symbol"),uj=(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]=fo(c);switch(h){case Hu:{let x=c;switch(p){case"bigint":h=Y0,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);x=null;break;case"undefined":return a([W0],c)}return a([h,x],c)}case So:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const x=[],_=a([h,x],c);for(const b of c)x.push(o(b));return _}case Au:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const x=[],_=a([h,x],c);for(const b of cj(c))(e||!tu(fo(c[b])))&&x.push([o(b),o(c[b])]);return _}case nm:return a([h,c.toISOString()],c);case rm:{const{source:x,flags:_}=c;return a([h,{source:x,flags:_}],c)}case sm:{const x=[],_=a([h,x],c);for(const[b,v]of c)(e||!(tu(fo(b))||tu(fo(v))))&&x.push([o(b),o(v)]);return _}case am:{const x=[],_=a([h,x],c);for(const b of c)(e||!tu(fo(b)))&&x.push(o(b));return _}}const{message:d}=c;return a([h,{name:p,message:d}],c)};return o},jv=(e,{json:t,lossy:i}={})=>{const s=[];return uj(!(t||i),!!t,new Map,s)(e),s},No=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Tv(jv(e,t)):structuredClone(e):(e,t)=>Tv(jv(e,t));function hj(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 dj(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function fj(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=e.options.footnoteBackContent||hj,s=e.options.footnoteBackLabel||dj,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let p=-1;for(;++p<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[p]);if(!d)continue;const x=e.all(d),_=String(d.identifier).toUpperCase(),b=dl(_.toLowerCase());let v=0;const y=[],E=e.footnoteCounts.get(_);for(;E!==void 0&&++v<=E;){y.length>0&&y.push({type:"text",value:" "});let L=typeof i=="string"?i:i(p,v);typeof L=="string"&&(L={type:"text",value:L}),y.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(L)?L:[L]})}const A=x[x.length-1];if(A&&A.type==="element"&&A.tagName==="p"){const L=A.children[A.children.length-1];L&&L.type==="text"?L.value+=" ":A.children.push({type:"text",value:" "}),A.children.push(...y)}else x.push(...y);const T={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(x,!0)};e.patch(d,T),h.push(T)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...No(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 Uu=(function(e){if(e==null)return _j;if(typeof e=="function")return $u(e);if(typeof e=="object")return Array.isArray(e)?pj(e):mj(e);if(typeof e=="string")return gj(e);throw new Error("Expected function, string, or object as test")});function pj(e){const t=[];let i=-1;for(;++i<e.length;)t[i]=Uu(e[i]);return $u(s);function s(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function mj(e){const t=e;return $u(i);function i(s){const a=s;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function gj(e){return $u(t);function t(i){return i&&i.type===e}}function $u(e){return t;function t(i,s,a){return!!(xj(i)&&e.call(this,i,typeof s=="number"?s:void 0,a||void 0))}}function _j(){return!0}function xj(e){return e!==null&&typeof e=="object"&&"type"in e}const K0=[],bj=!0,kp=!1,vj="skip";function V0(e,t,i,s){let a;typeof t=="function"&&typeof i!="function"?(s=i,i=t):a=t;const o=Uu(a),c=s?-1:1;h(e,void 0,[])();function h(p,d,x){const _=p&&typeof p=="object"?p:{};if(typeof _.type=="string"){const v=typeof _.tagName=="string"?_.tagName:typeof _.name=="string"?_.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(p.type+(v?"<"+v+">":""))+")"})}return b;function b(){let v=K0,y,E,A;if((!t||o(p,d,x[x.length-1]||void 0))&&(v=yj(i(p,x)),v[0]===kp))return v;if("children"in p&&p.children){const T=p;if(T.children&&v[0]!==vj)for(E=(s?T.children.length:-1)+c,A=x.concat(T);E>-1&&E<T.children.length;){const L=T.children[E];if(y=h(L,E,A)(),y[0]===kp)return y;E=typeof y[1]=="number"?y[1]:E+c}}return v}}}function yj(e){return Array.isArray(e)?e:typeof e=="number"?[bj,e]:e==null?K0:[e]}function lm(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),V0(e,o,h,a);function h(p,d){const x=d[d.length-1],_=x?x.children.indexOf(p):void 0;return c(p,_,x)}}const Ep={}.hasOwnProperty,Sj={};function wj(e,t){const i=t||Sj,s=new Map,a=new Map,o=new Map,c={...aj,...i.handlers},h={all:d,applyData:kj,definitionById:s,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:p,options:i,patch:Cj,wrap:Nj};return lm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const _=x.type==="definition"?s:a,b=String(x.identifier).toUpperCase();_.has(b)||_.set(b,x)}}),h;function p(x,_){const b=x.type,v=h.handlers[b];if(Ep.call(h.handlers,b)&&v)return v(h,x,_);if(h.options.passThrough&&h.options.passThrough.includes(b)){if("children"in x){const{children:E,...A}=x,T=No(A);return T.children=h.all(x),T}return No(x)}return(h.options.unknownHandler||Ej)(h,x,_)}function d(x){const _=[];if("children"in x){const b=x.children;let v=-1;for(;++v<b.length;){const y=h.one(b[v],x);if(y){if(v&&b[v-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=Av(y.value)),!Array.isArray(y)&&y.type==="element")){const E=y.children[0];E&&E.type==="text"&&(E.value=Av(E.value))}Array.isArray(y)?_.push(...y):_.push(y)}}}return _}}function Cj(e,t){e.position&&(t.position=C0(e))}function kj(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,No(o)),"children"in i&&i.children&&a!==null&&a!==void 0&&(i.children=a)}return i}function Ej(e,t){const i=t.data||{},s="value"in t&&!(Ep.call(i,"hProperties")||Ep.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 Nj(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 Av(e){let t=0,i=e.charCodeAt(t);for(;i===9||i===32;)t++,i=e.charCodeAt(t);return e.slice(t)}function Rv(e,t){const i=wj(e,t),s=i.one(e,void 0),a=fj(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 Tj(e,t){return e&&"run"in e?async function(i,s){const a=Rv(i,{file:s,...t});await e.run(a,s)}:function(i,s){return Rv(i,{file:s,...e||t})}}function Mv(e){if(e)throw e}var gf,Dv;function jj(){if(Dv)return gf;Dv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var x=e.call(d,"constructor"),_=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!x&&!_)return!1;var b;for(b in d);return typeof b>"u"||e.call(d,b)},c=function(d,x){i&&x.name==="__proto__"?i(d,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):d[x.name]=x.newValue},h=function(d,x){if(x==="__proto__")if(e.call(d,x)){if(s)return s(d,x).value}else return;return d[x]};return gf=function p(){var d,x,_,b,v,y,E=arguments[0],A=1,T=arguments.length,L=!1;for(typeof E=="boolean"&&(L=E,E=arguments[1]||{},A=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});A<T;++A)if(d=arguments[A],d!=null)for(x in d)_=h(E,x),b=h(d,x),E!==b&&(L&&b&&(o(b)||(v=a(b)))?(v?(v=!1,y=_&&a(_)?_:[]):y=_&&o(_)?_:{},c(E,{name:x,newValue:p(L,y,b)})):typeof b<"u"&&c(E,{name:x,newValue:b}));return E},gf}var Aj=jj();const _f=Du(Aj);function Np(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 Rj(){const e=[],t={run:i,use:s};return t;function i(...a){let o=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...a);function h(p,...d){const x=e[++o];let _=-1;if(p){c(p);return}for(;++_<a.length;)(d[_]===null||d[_]===void 0)&&(d[_]=a[_]);a=d,x?Mj(x,h)(...d):c(null,...d)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function Mj(e,t){let i;return s;function s(...c){const h=e.length>c.length;let p;h&&c.push(a);try{p=e.apply(this,c)}catch(d){const x=d;if(h&&i)throw x;return a(x)}h||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...h){i||(i=!0,t(c,...h))}function o(c){a(null,c)}}const Sr={basename:Dj,dirname:Bj,extname:Lj,join:Oj,sep:"/"};function Dj(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Oo(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 Bj(e){if(Oo(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 Lj(e){Oo(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 Oj(...e){let t=-1,i;for(;++t<e.length;)Oo(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":zj(i)}function zj(e){Oo(e);const t=e.codePointAt(0)===47;let i=Pj(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function Pj(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 Oo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Ij={cwd:Hj};function Hj(){return"/"}function Tp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Uj(e){if(typeof e=="string")e=new URL(e);else if(!Tp(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 $j(e)}function $j(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 xf=["history","path","basename","stem","extname","dirname"];class X0{constructor(t){let i;t?Tp(t)?i={path:t}:typeof t=="string"||Fj(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":Ij.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<xf.length;){const o=xf[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)xf.includes(a)||(this[a]=i[a])}get basename(){return typeof this.path=="string"?Sr.basename(this.path):void 0}set basename(t){vf(t,"basename"),bf(t,"basename"),this.path=Sr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Sr.dirname(this.path):void 0}set dirname(t){Bv(this.basename,"dirname"),this.path=Sr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Sr.extname(this.path):void 0}set extname(t){if(bf(t,"extname"),Bv(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=Sr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Tp(t)&&(t=Uj(t)),vf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Sr.basename(this.path,this.extname):void 0}set stem(t){vf(t,"stem"),bf(t,"stem"),this.path=Sr.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 en(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 bf(e,t){if(e&&e.includes(Sr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Sr.sep+"`")}function vf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Bv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Fj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const qj=(function(e){const s=this.constructor.prototype,a=s[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,s),o}),Wj={}.hasOwnProperty;class om extends qj{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=Rj()}copy(){const t=new om;let i=-1;for(;++i<this.attachers.length;){const s=this.attachers[i];t.use(...s)}return t.data(_f(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(wf("data",this.frozen),this.namespace[t]=i,this):Wj.call(this.namespace,t)&&this.namespace[t]||void 0:t?(wf("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=iu(t),s=this.parser||this.Parser;return yf("parse",s),s(String(i),i)}process(t,i){const s=this;return this.freeze(),yf("process",this.parser||this.Parser),Sf("process",this.compiler||this.Compiler),i?a(void 0,i):new Promise(a);function a(o,c){const h=iu(t),p=s.parse(h);s.run(p,h,function(x,_,b){if(x||!_||!b)return d(x);const v=_,y=s.stringify(v,b);Kj(y)?b.value=y:b.result=y,d(x,b)});function d(x,_){x||!_?c(x):o?o(_):i(void 0,_)}}}processSync(t){let i=!1,s;return this.freeze(),yf("processSync",this.parser||this.Parser),Sf("processSync",this.compiler||this.Compiler),this.process(t,a),Ov("processSync","process",i),s;function a(o,c){i=!0,Mv(o),s=c}}run(t,i,s){Lv(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=iu(i);a.run(t,p,d);function d(x,_,b){const v=_||t;x?h(x):c?c(v):s(void 0,v,b)}}}runSync(t,i){let s=!1,a;return this.run(t,i,o),Ov("runSync","run",s),a;function o(c,h){Mv(c),a=h,s=!0}}stringify(t,i){this.freeze();const s=iu(i),a=this.compiler||this.Compiler;return Sf("stringify",a),Lv(t),a(t,s)}use(t,...i){const s=this.attachers,a=this.namespace;if(wf("use",this.frozen),t!=null)if(typeof t=="function")p(t,i);else if(typeof t=="object")Array.isArray(t)?h(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(d){if(typeof d=="function")p(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[x,..._]=d;p(x,_)}else c(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function c(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(d.plugins),d.settings&&(a.settings=_f(!0,a.settings,d.settings))}function h(d){let x=-1;if(d!=null)if(Array.isArray(d))for(;++x<d.length;){const _=d[x];o(_)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function p(d,x){let _=-1,b=-1;for(;++_<s.length;)if(s[_][0]===d){b=_;break}if(b===-1)s.push([d,...x]);else if(x.length>0){let[v,...y]=x;const E=s[b][1];Np(E)&&Np(v)&&(v=_f(!0,E,v)),s[b]=[d,v,...y]}}}}const Gj=new om().freeze();function yf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function wf(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 Lv(e){if(!Np(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ov(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function iu(e){return Yj(e)?e:new X0(e)}function Yj(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Kj(e){return typeof e=="string"||Vj(e)}function Vj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Xj="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",zv=[],Pv={allowDangerousHtml:!0},Zj=/^(https?|ircs?|mailto|xmpp)$/i,Qj=[{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 Z0(e){const t=Jj(e),i=eA(e);return tA(t.runSync(t.parse(i),i),e)}function Jj(e){const t=e.rehypePlugins||zv,i=e.remarkPlugins||zv,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Pv}:Pv;return Gj().use(BT).use(i).use(Tj,s).use(t)}function eA(e){const t=e.children||"",i=new X0;return typeof t=="string"&&(i.value=t),i}function tA(e,t){const i=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,h=t.unwrapDisallowed,p=t.urlTransform||iA;for(const x of Qj)Object.hasOwn(t,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+Xj+x.id,void 0);return lm(e,d),_N(e,{Fragment:f.Fragment,components:a,ignoreInvalidStyle:!0,jsx:f.jsx,jsxs:f.jsxs,passKeys:!0,passNode:!0});function d(x,_,b){if(x.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:x.value},_;if(x.type==="element"){let v;for(v in ff)if(Object.hasOwn(ff,v)&&Object.hasOwn(x.properties,v)){const y=x.properties[v],E=ff[v];(E===null||E.includes(x.tagName))&&(x.properties[v]=p(String(y||""),v,x))}}if(x.type==="element"){let v=i?!i.includes(x.tagName):o?o.includes(x.tagName):!1;if(!v&&s&&typeof _=="number"&&(v=!s(x,_,b)),v&&b&&typeof _=="number")return h&&x.children?b.children.splice(_,1,...x.children):b.children.splice(_,1),_}}}function iA(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||Zj.test(e.slice(0,t))?e:""}function nA(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Q0(e,t,i){const a=Uu((i||{}).ignore||[]),o=rA(t);let c=-1;for(;++c<o.length;)V0(e,"text",h);function h(d,x){let _=-1,b;for(;++_<x.length;){const v=x[_],y=b?b.children:void 0;if(a(v,y?y.indexOf(v):void 0,b))return;b=v}if(b)return p(d,x)}function p(d,x){const _=x[x.length-1],b=o[c][0],v=o[c][1];let y=0;const A=_.children.indexOf(d);let T=!1,L=[];b.lastIndex=0;let O=b.exec(d.value);for(;O;){const J=O.index,$={index:O.index,input:O.input,stack:[...x,d]};let M=v(...O,$);if(typeof M=="string"&&(M=M.length>0?{type:"text",value:M}:void 0),M===!1?b.lastIndex=J+1:(y!==J&&L.push({type:"text",value:d.value.slice(y,J)}),Array.isArray(M)?L.push(...M):M&&L.push(M),y=J+O[0].length,T=!0),!b.global)break;O=b.exec(d.value)}return T?(y<d.value.length&&L.push({type:"text",value:d.value.slice(y)}),_.children.splice(A,1,...L)):L=[d],A+L.length}}function rA(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([sA(a[0]),aA(a[1])])}return t}function sA(e){return typeof e=="string"?new RegExp(nA(e),"g"):e}function aA(e){return typeof e=="function"?e:function(){return e}}function lA(e){Q0(e,[/\r?\n|\r/g,oA])}function oA(){return{type:"break"}}function J0(){return function(e){lA(e)}}function Iv(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 Cf="phrasing",kf=["autolink","link","image","label"];function cA(){return{transforms:[gA],enter:{literalAutolink:hA,literalAutolinkEmail:Ef,literalAutolinkHttp:Ef,literalAutolinkWww:Ef},exit:{literalAutolink:mA,literalAutolinkEmail:pA,literalAutolinkHttp:dA,literalAutolinkWww:fA}}}function uA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Cf,notInConstruct:kf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Cf,notInConstruct:kf},{character:":",before:"[ps]",after:"\\/",inConstruct:Cf,notInConstruct:kf}]}}function hA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ef(e){this.config.enter.autolinkProtocol.call(this,e)}function dA(e){this.config.exit.autolinkProtocol.call(this,e)}function fA(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 pA(e){this.config.exit.autolinkEmail.call(this,e)}function mA(e){this.exit(e)}function gA(e){Q0(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,_A],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),xA]],{ignore:["link","linkReference"]})}function _A(e,t,i,s,a){let o="";if(!eS(a)||(/^w/i.test(t)&&(i=t+i,t="",o="http://"),!bA(i)))return!1;const c=vA(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 xA(e,t,i,s){return!eS(s,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function bA(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function vA(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=Iv(e,"(");let o=Iv(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 eS(e,t){const i=e.input.charCodeAt(e.index-1);return(e.index===0||oa(i)||Pu(i))&&(!t||i!==47)}tS.peek=jA;function yA(){this.buffer()}function SA(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function wA(){this.buffer()}function CA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function kA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=dr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function EA(e){this.exit(e)}function NA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=dr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function TA(e){this.exit(e)}function jA(){return"["}function tS(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 AA(){return{enter:{gfmFootnoteCallString:yA,gfmFootnoteCall:SA,gfmFootnoteDefinitionLabelString:wA,gfmFootnoteDefinition:CA},exit:{gfmFootnoteCallString:kA,gfmFootnoteCall:EA,gfmFootnoteDefinitionLabelString:NA,gfmFootnoteDefinition:TA}}}function RA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:i,footnoteReference:tS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(s,a,o,c){const h=o.createTracker(c);let p=h.move("[^");const d=o.enter("footnoteDefinition"),x=o.enter("label");return p+=h.move(o.safe(o.associationId(s),{before:p,after:"]"})),x(),p+=h.move("]:"),s.children&&s.children.length>0&&(h.shift(4),p+=h.move((t?`
|
|
115
|
+
`:" ")+o.indentLines(o.containerFlow(s,h.current()),t?iS:MA))),d(),p}}function MA(e,t,i){return t===0?e:iS(e,t,i)}function iS(e,t,i){return(i?"":" ")+e}const DA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];nS.peek=PA;function BA(){return{canContainEols:["delete"],enter:{strikethrough:OA},exit:{strikethrough:zA}}}function LA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:DA}],handlers:{delete:nS}}}function OA(e){this.enter({type:"delete",children:[]},e)}function zA(e){this.exit(e)}function nS(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 PA(){return"~"}function IA(e){return e.length}function HA(e,t){const i=t||{},s=(i.align||[]).concat(),a=i.stringLength||IA,o=[],c=[],h=[],p=[];let d=0,x=-1;for(;++x<e.length;){const E=[],A=[];let T=-1;for(e[x].length>d&&(d=e[x].length);++T<e[x].length;){const L=UA(e[x][T]);if(i.alignDelimiters!==!1){const O=a(L);A[T]=O,(p[T]===void 0||O>p[T])&&(p[T]=O)}E.push(L)}c[x]=E,h[x]=A}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_<d;)o[_]=Hv(s[_]);else{const E=Hv(s);for(;++_<d;)o[_]=E}_=-1;const b=[],v=[];for(;++_<d;){const E=o[_];let A="",T="";E===99?(A=":",T=":"):E===108?A=":":E===114&&(T=":");let L=i.alignDelimiters===!1?1:Math.max(1,p[_]-A.length-T.length);const O=A+"-".repeat(L)+T;i.alignDelimiters!==!1&&(L=A.length+L+T.length,L>p[_]&&(p[_]=L),v[_]=L),b[_]=O}c.splice(1,0,b),h.splice(1,0,v),x=-1;const y=[];for(;++x<c.length;){const E=c[x],A=h[x];_=-1;const T=[];for(;++_<d;){const L=E[_]||"";let O="",J="";if(i.alignDelimiters!==!1){const $=p[_]-(A[_]||0),M=o[_];M===114?O=" ".repeat($):M===99?$%2?(O=" ".repeat($/2+.5),J=" ".repeat($/2-.5)):(O=" ".repeat($/2),J=O):J=" ".repeat($)}i.delimiterStart!==!1&&!_&&T.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&L==="")&&(i.delimiterStart!==!1||_)&&T.push(" "),i.alignDelimiters!==!1&&T.push(O),T.push(L),i.alignDelimiters!==!1&&T.push(J),i.padding!==!1&&T.push(" "),(i.delimiterEnd!==!1||_!==d-1)&&T.push("|")}y.push(i.delimiterEnd===!1?T.join("").replace(/ +$/,""):T.join(""))}return y.join(`
|
|
116
|
+
`)}function UA(e){return e==null?"":String(e)}function Hv(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 $A(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()),FA);return a(),c}function FA(e,t,i){return">"+(i?"":" ")+e}function qA(e,t){return Uv(e,t.inConstruct,!0)&&!Uv(e,t.notInConstruct,!1)}function Uv(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 $v(e,t,i,s){let a=-1;for(;++a<i.unsafe.length;)if(i.unsafe[a].character===`
|
|
117
|
+
`&&qA(i.stack,i.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
118
|
+
`}function WA(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 GA(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 YA(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 KA(e,t,i,s){const a=YA(i),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(GA(e,i)){const _=i.enter("codeIndented"),b=i.indentLines(o,VA);return _(),b}const h=i.createTracker(s),p=a.repeat(Math.max(WA(o,a)+1,3)),d=i.enter("codeFenced");let x=h.move(p);if(e.lang){const _=i.enter(`codeFencedLang${c}`);x+=h.move(i.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),_()}if(e.lang&&e.meta){const _=i.enter(`codeFencedMeta${c}`);x+=h.move(" "),x+=h.move(i.safe(e.meta,{before:x,after:`
|
|
119
|
+
`,encode:["`"],...h.current()})),_()}return x+=h.move(`
|
|
120
|
+
`),o&&(x+=h.move(o+`
|
|
121
|
+
`)),x+=h.move(p),d(),x}function VA(e,t,i){return(i?"":" ")+e}function cm(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 XA(e,t,i,s){const a=cm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("definition");let h=i.enter("label");const p=i.createTracker(s);let d=p.move("[");return d+=p.move(i.safe(i.associationId(e),{before:d,after:"]",...p.current()})),d+=p.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),d+=p.move("<"),d+=p.move(i.safe(e.url,{before:d,after:">",...p.current()})),d+=p.move(">")):(h=i.enter("destinationRaw"),d+=p.move(i.safe(e.url,{before:d,after:e.title?" ":`
|
|
122
|
+
`,...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),d+=p.move(" "+a),d+=p.move(i.safe(e.title,{before:d,after:a,...p.current()})),d+=p.move(a),h()),c(),d}function ZA(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 To(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ru(e,t,i){const s=ll(e),a=ll(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}}rS.peek=QA;function rS(e,t,i,s){const a=ZA(i),o=i.enter("emphasis"),c=i.createTracker(s),h=c.move(a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const d=p.charCodeAt(0),x=Ru(s.before.charCodeAt(s.before.length-1),d,a);x.inside&&(p=To(d)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Ru(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+To(_));const v=c.move(a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},h+p+v}function QA(e,t,i){return i.options.emphasis||"*"}function JA(e,t){let i=!1;return lm(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return i=!0,kp}),!!((!e.depth||e.depth<3)&&em(e)&&(t.options.setext||i))}function eR(e,t,i,s){const a=Math.max(Math.min(6,e.depth||1),1),o=i.createTracker(s);if(JA(e,i)){const x=i.enter("headingSetext"),_=i.enter("phrasing"),b=i.containerPhrasing(e,{...o.current(),before:`
|
|
123
|
+
`,after:`
|
|
124
|
+
`});return _(),x(),b+`
|
|
125
|
+
`+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
|
|
126
|
+
`))+1))}const c="#".repeat(a),h=i.enter("headingAtx"),p=i.enter("phrasing");o.move(c+" ");let d=i.containerPhrasing(e,{before:"# ",after:`
|
|
127
|
+
`,...o.current()});return/^[\t ]/.test(d)&&(d=To(d.charCodeAt(0))+d.slice(1)),d=d?c+" "+d:c,i.options.closeAtx&&(d+=" "+c),p(),h(),d}sS.peek=tR;function sS(e){return e.value||""}function tR(){return"<"}aS.peek=iR;function aS(e,t,i,s){const a=cm(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("image");let h=i.enter("label");const p=i.createTracker(s);let d=p.move("![");return d+=p.move(i.safe(e.alt,{before:d,after:"]",...p.current()})),d+=p.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),d+=p.move("<"),d+=p.move(i.safe(e.url,{before:d,after:">",...p.current()})),d+=p.move(">")):(h=i.enter("destinationRaw"),d+=p.move(i.safe(e.url,{before:d,after:e.title?" ":")",...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),d+=p.move(" "+a),d+=p.move(i.safe(e.title,{before:d,after:a,...p.current()})),d+=p.move(a),h()),d+=p.move(")"),c(),d}function iR(){return"!"}lS.peek=nR;function lS(e,t,i,s){const a=e.referenceType,o=i.enter("imageReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("![");const d=i.safe(e.alt,{before:p,after:"]",...h.current()});p+=h.move(d+"]["),c();const x=i.stack;i.stack=[],c=i.enter("reference");const _=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=x,o(),a==="full"||!d||d!==_?p+=h.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function nR(){return"!"}oS.peek=rR;function oS(e,t,i){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o<i.unsafe.length;){const c=i.unsafe[o],h=i.compilePattern(c);let p;if(c.atBreak)for(;p=h.exec(s);){let d=p.index;s.charCodeAt(d)===10&&s.charCodeAt(d-1)===13&&d--,s=s.slice(0,d)+" "+s.slice(p.index+1)}}return a+s+a}function rR(){return"`"}function cS(e,t){const i=em(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))}uS.peek=sR;function uS(e,t,i,s){const a=cm(i),o=a==='"'?"Quote":"Apostrophe",c=i.createTracker(s);let h,p;if(cS(e,i)){const x=i.stack;i.stack=[],h=i.enter("autolink");let _=c.move("<");return _+=c.move(i.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),h(),i.stack=x,_}h=i.enter("link"),p=i.enter("label");let d=c.move("[");return d+=c.move(i.containerPhrasing(e,{before:d,after:"](",...c.current()})),d+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=i.enter("destinationLiteral"),d+=c.move("<"),d+=c.move(i.safe(e.url,{before:d,after:">",...c.current()})),d+=c.move(">")):(p=i.enter("destinationRaw"),d+=c.move(i.safe(e.url,{before:d,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=i.enter(`title${o}`),d+=c.move(" "+a),d+=c.move(i.safe(e.title,{before:d,after:a,...c.current()})),d+=c.move(a),p()),d+=c.move(")"),h(),d}function sR(e,t,i){return cS(e,i)?"<":"["}hS.peek=aR;function hS(e,t,i,s){const a=e.referenceType,o=i.enter("linkReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("[");const d=i.containerPhrasing(e,{before:p,after:"]",...h.current()});p+=h.move(d+"]["),c();const x=i.stack;i.stack=[],c=i.enter("reference");const _=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=x,o(),a==="full"||!d||d!==_?p+=h.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function aR(){return"["}function um(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 lR(e){const t=um(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 oR(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 dS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function cR(e,t,i,s){const a=i.enter("list"),o=i.bulletCurrent;let c=e.ordered?oR(i):um(i);const h=e.ordered?c==="."?")":".":lR(i);let p=t&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(p=!0),dS(i)===c&&x){let _=-1;for(;++_<e.children.length;){const b=e.children[_];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=h),i.bulletCurrent=c;const d=i.containerFlow(e,s);return i.bulletLastUsed=c,i.bulletCurrent=o,a(),d}function uR(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 hR(e,t,i,s){const a=uR(i);let o=i.bulletCurrent||um(i);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(i.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=i.createTracker(s);h.move(o+" ".repeat(c-o.length)),h.shift(c);const p=i.enter("listItem"),d=i.indentLines(i.containerFlow(e,h.current()),x);return p(),d;function x(_,b,v){return b?(v?"":" ".repeat(c))+_:(v?o:o+" ".repeat(c-o.length))+_}}function dR(e,t,i,s){const a=i.enter("paragraph"),o=i.enter("phrasing"),c=i.containerPhrasing(e,s);return o(),a(),c}const fR=Uu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function pR(e,t,i,s){return(e.children.some(function(c){return fR(c)})?i.containerPhrasing:i.containerFlow).call(i,e,s)}function mR(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fS.peek=gR;function fS(e,t,i,s){const a=mR(i),o=i.enter("strong"),c=i.createTracker(s),h=c.move(a+a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const d=p.charCodeAt(0),x=Ru(s.before.charCodeAt(s.before.length-1),d,a);x.inside&&(p=To(d)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Ru(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+To(_));const v=c.move(a+a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},h+p+v}function gR(e,t,i){return i.options.strong||"*"}function _R(e,t,i,s){return i.safe(e.value,s)}function xR(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function bR(e,t,i){const s=(dS(i)+(i.options.ruleSpaces?" ":"")).repeat(xR(i));return i.options.ruleSpaces?s.slice(0,-1):s}const pS={blockquote:$A,break:$v,code:KA,definition:XA,emphasis:rS,hardBreak:$v,heading:eR,html:sS,image:aS,imageReference:lS,inlineCode:oS,link:uS,linkReference:hS,list:cR,listItem:hR,paragraph:dR,root:pR,strong:fS,text:_R,thematicBreak:bR};function vR(){return{enter:{table:yR,tableData:Fv,tableHeader:Fv,tableRow:wR},exit:{codeText:CR,table:SR,tableData:Nf,tableHeader:Nf,tableRow:Nf}}}function yR(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 SR(e){this.exit(e),this.data.inTable=void 0}function wR(e){this.enter({type:"tableRow",children:[]},e)}function Nf(e){this.exit(e)}function Fv(e){this.enter({type:"tableCell",children:[]},e)}function CR(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,kR));const i=this.stack[this.stack.length-1];i.type,i.value=t,this.exit(e)}function kR(e,t){return t==="|"?t:e}function ER(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,y,E,A){return d(x(v,E,A),v.align)}function h(v,y,E,A){const T=_(v,E,A),L=d([T]);return L.slice(0,L.indexOf(`
|
|
129
|
+
`))}function p(v,y,E,A){const T=E.enter("tableCell"),L=E.enter("phrasing"),O=E.containerPhrasing(v,{...A,before:o,after:o});return L(),T(),O}function d(v,y){return HA(v,{align:y,alignDelimiters:s,padding:i,stringLength:a})}function x(v,y,E){const A=v.children;let T=-1;const L=[],O=y.enter("table");for(;++T<A.length;)L[T]=_(A[T],y,E);return O(),L}function _(v,y,E){const A=v.children;let T=-1;const L=[],O=y.enter("tableRow");for(;++T<A.length;)L[T]=p(A[T],v,y,E);return O(),L}function b(v,y,E){let A=pS.inlineCode(v,y,E);return E.stack.includes("tableCell")&&(A=A.replace(/\|/g,"\\$&")),A}}function NR(){return{exit:{taskListCheckValueChecked:qv,taskListCheckValueUnchecked:qv,paragraph:jR}}}function TR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:AR}}}function qv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function jR(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 AR(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=pS.listItem(e,t,i,{...s,...h.current()});return o&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),p;function d(x){return x+c}}function RR(){return[cA(),AA(),BA(),vR(),NR()]}function MR(e){return{extensions:[uA(),RA(e),LA(),ER(e),TR()]}}const DR={tokenize:IR,partial:!0},mS={tokenize:HR,partial:!0},gS={tokenize:UR,partial:!0},_S={tokenize:$R,partial:!0},BR={tokenize:FR,partial:!0},xS={name:"wwwAutolink",tokenize:zR,previous:vS},bS={name:"protocolAutolink",tokenize:PR,previous:yS},es={name:"emailAutolink",tokenize:OR,previous:SS},Tr={};function LR(){return{text:Tr}}let ea=48;for(;ea<123;)Tr[ea]=es,ea++,ea===58?ea=65:ea===91&&(ea=97);Tr[43]=es;Tr[45]=es;Tr[46]=es;Tr[95]=es;Tr[72]=[es,bS];Tr[104]=[es,bS];Tr[87]=[es,xS];Tr[119]=[es,xS];function OR(e,t,i){const s=this;let a,o;return c;function c(_){return!jp(_)||!SS.call(s,s.previous)||hm(s.events)?i(_):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(_))}function h(_){return jp(_)?(e.consume(_),h):_===64?(e.consume(_),p):i(_)}function p(_){return _===46?e.check(BR,x,d)(_):_===45||_===95||Ji(_)?(o=!0,e.consume(_),p):x(_)}function d(_){return e.consume(_),a=!0,p}function x(_){return o&&a&&un(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(_)):i(_)}}function zR(e,t,i){const s=this;return a;function a(c){return c!==87&&c!==119||!vS.call(s,s.previous)||hm(s.events)?i(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(DR,e.attempt(mS,e.attempt(gS,o),i),i)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function PR(e,t,i){const s=this;let a="",o=!1;return c;function c(_){return(_===72||_===104)&&yS.call(s,s.previous)&&!hm(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(_),e.consume(_),h):i(_)}function h(_){if(un(_)&&a.length<5)return a+=String.fromCodePoint(_),e.consume(_),h;if(_===58){const b=a.toLowerCase();if(b==="http"||b==="https")return e.consume(_),p}return i(_)}function p(_){return _===47?(e.consume(_),o?d:(o=!0,p)):i(_)}function d(_){return _===null||ju(_)||qt(_)||oa(_)||Pu(_)?i(_):e.attempt(mS,e.attempt(gS,x),i)(_)}function x(_){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(_)}}function IR(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 HR(e,t,i){let s,a,o;return c;function c(d){return d===46||d===95?e.check(_S,p,h)(d):d===null||qt(d)||oa(d)||d!==45&&Pu(d)?p(d):(o=!0,e.consume(d),c)}function h(d){return d===95?s=!0:(a=s,s=void 0),e.consume(d),c}function p(d){return a||s||!o?i(d):t(d)}}function UR(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(_S,t,o)(c):c===null||qt(c)||oa(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&s++,e.consume(c),a}}function $R(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||qt(h)||oa(h)?t(h):i(h)}function a(h){return h===null||h===40||h===91||qt(h)||oa(h)?t(h):s(h)}function o(h){return un(h)?c(h):i(h)}function c(h){return h===59?(e.consume(h),s):un(h)?(e.consume(h),c):i(h)}}function FR(e,t,i){return s;function s(o){return e.consume(o),a}function a(o){return Ji(o)?i(o):t(o)}}function vS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||qt(e)}function yS(e){return!un(e)}function SS(e){return!(e===47||jp(e))}function jp(e){return e===43||e===45||e===46||e===95||Ji(e)}function hm(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 qR={tokenize:QR,partial:!0};function WR(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:VR,continuation:{tokenize:XR},exit:ZR}},text:{91:{name:"gfmFootnoteCall",tokenize:KR},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:GR,resolveTo:YR}}}}function GR(e,t,i){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return h;function h(p){if(!c||!c._balanced)return i(p);const d=dr(s.sliceSerialize({start:c.end,end:s.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?i(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function YR(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 KR(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return h;function h(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?i(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(_){if(o>999||_===93&&!c||_===null||_===91||qt(_))return i(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(dr(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(_)}return qt(_)||(c=!0),o++,e.consume(_),_===92?x:d}function x(_){return _===91||_===92||_===93?(e.consume(_),o++,d):d(_)}}function VR(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,h;return p;function p(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):i(y)}function x(y){if(c>999||y===93&&!h||y===null||y===91||qt(y))return i(y);if(y===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=dr(s.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return qt(y)||(h=!0),c++,e.consume(y),y===92?_:x}function _(y){return y===91||y===92||y===93?(e.consume(y),c++,x):x(y)}function b(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ct(e,v,"gfmFootnoteDefinitionWhitespace")):i(y)}function v(y){return t(y)}}function XR(e,t,i){return e.check(Lo,t,e.attempt(qR,t,i))}function ZR(e){e.exit("gfmFootnoteDefinition")}function QR(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 JR(e){let i=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return i==null&&(i=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,h){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let d=p;for(;d--;)if(c[d][0]==="exit"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[d][1].end.offset-c[d][1].start.offset){c[p][1].type="strikethroughSequence",c[d][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[d][1].start),end:Object.assign({},c[p][1].end)},_={type:"strikethroughText",start:Object.assign({},c[d][1].end),end:Object.assign({},c[p][1].start)},b=[["enter",x,h],["enter",c[d][1],h],["exit",c[d][1],h],["enter",_,h]],v=h.parser.constructs.insideSpan.null;v&&zn(b,b.length,0,Iu(v,c.slice(d+1,p),h)),zn(b,b.length,0,[["exit",_,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",x,h]]),zn(c,d-1,p-d+3,b),p=d+b.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function o(c,h,p){const d=this.previous,x=this.events;let _=0;return b;function b(y){return d===126&&x[x.length-1][1].type!=="characterEscape"?p(y):(c.enter("strikethroughSequenceTemporary"),v(y))}function v(y){const E=ll(d);if(y===126)return _>1?p(y):(c.consume(y),_++,v);if(_<2&&!i)return p(y);const A=c.exit("strikethroughSequenceTemporary"),T=ll(y);return A._open=!T||T===2&&!!E,A._close=!E||E===2&&!!T,h(y)}}}class e3{constructor(){this.map=[]}add(t,i,s){t3(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 t3(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 i3(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 n3(){return{flow:{null:{name:"table",tokenize:r3,resolveAll:s3}}}}function r3(e,t,i){const s=this;let a=0,o=0,c;return h;function h(U){let se=s.events.length-1;for(;se>-1;){const Z=s.events[se][1].type;if(Z==="lineEnding"||Z==="linePrefix")se--;else break}const W=se>-1?s.events[se][1].type:null,G=W==="tableHead"||W==="tableRow"?M:p;return G===M&&s.parser.lazy[s.now().line]?i(U):G(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),d(U)}function d(U){return U===124||(c=!0,o+=1),x(U)}function x(U){return U===null?i(U):$e(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),v):i(U):xt(U)?Ct(e,x,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,x):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||qt(U)?(e.exit("data"),x(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function v(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?i(U):(e.enter("tableDelimiterRow"),c=!1,xt(U)?Ct(e,y,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):y(U))}function y(U){return U===45||U===58?A(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),E):$(U)}function E(U){return xt(U)?Ct(e,A,"whitespace")(U):A(U)}function A(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),T):U===45?(o+=1,T(U)):U===null||$e(U)?J(U):$(U)}function T(U){return U===45?(e.enter("tableDelimiterFiller"),L(U)):$(U)}function L(U){return U===45?(e.consume(U),L):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),O):(e.exit("tableDelimiterFiller"),O(U))}function O(U){return xt(U)?Ct(e,J,"whitespace")(U):J(U)}function J(U){return U===124?y(U):U===null||$e(U)?!c||a!==o?$(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):$(U)}function $(U){return i(U)}function M(U){return e.enter("tableRow"),X(U)}function X(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),X):U===null||$e(U)?(e.exit("tableRow"),t(U)):xt(U)?Ct(e,X,"whitespace")(U):(e.enter("data"),he(U))}function he(U){return U===null||U===124||qt(U)?(e.exit("data"),X(U)):(e.consume(U),U===92?ye:he)}function ye(U){return U===92||U===124?(e.consume(U),he):he(U)}}function s3(e,t){let i=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,d,x,_;const b=new e3;for(;++i<e.length;){const v=e[i],y=v[1];v[0]==="enter"?y.type==="tableHead"?(h=!1,p!==0&&(Wv(b,t,p,d,x),x=void 0,p=0),d={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},b.add(i,0,[["enter",d,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(s=!0,_=void 0,o=[0,0,0,0],c=[0,i+1,0,0],h&&(h=!1,x={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},b.add(i,0,[["enter",x,t]])),a=y.type==="tableDelimiterRow"?2:x?3:1):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],_=nu(b,t,o,a,void 0,_),o=[0,0,0,0]),c[2]=i)):y.type==="tableCellDivider"&&(s?s=!1:(o[1]!==0&&(c[0]=c[1],_=nu(b,t,o,a,void 0,_)),o=c,c=[o[1],i,0,0])):y.type==="tableHead"?(h=!0,p=i):y.type==="tableRow"||y.type==="tableDelimiterRow"?(p=i,o[1]!==0?(c[0]=c[1],_=nu(b,t,o,a,i,_)):c[1]!==0&&(_=nu(b,t,c,a,i,_)),a=0):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(c[3]=i)}for(p!==0&&Wv(b,t,p,d,x),b.consume(t.events),i=-1;++i<t.events.length;){const v=t.events[i];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=i3(t.events,i))}return e}function nu(e,t,i,s,a,o){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",h="tableContent";i[0]!==0&&(o.end=Object.assign({},tl(t.events,i[0])),e.add(i[0],0,[["exit",o,t]]));const p=tl(t.events,i[1]);if(o={type:c,start:Object.assign({},p),end:Object.assign({},p)},e.add(i[1],0,[["enter",o,t]]),i[2]!==0){const d=tl(t.events,i[2]),x=tl(t.events,i[3]),_={type:h,start:Object.assign({},d),end:Object.assign({},x)};if(e.add(i[2],0,[["enter",_,t]]),s!==2){const b=t.events[i[2]],v=t.events[i[3]];if(b[1].end=Object.assign({},v[1].end),b[1].type="chunkText",b[1].contentType="text",i[3]>i[2]+1){const y=i[2]+1,E=i[3]-i[2]-1;e.add(y,E,[])}}e.add(i[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},tl(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Wv(e,t,i,s,a){const o=[],c=tl(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 tl(e,t){const i=e[t],s=i[0]==="enter"?"start":"end";return i[1][s]}const a3={name:"tasklistCheck",tokenize:o3};function l3(){return{text:{91:a3}}}function o3(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 qt(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 $e(p)?t(p):xt(p)?e.check({tokenize:c3},t,i)(p):i(p)}}function c3(e,t,i){return Ct(e,s,"whitespace");function s(a){return a===null?i(a):t(a)}}function u3(e){return A0([LR(),WR(),JR(e),n3(),l3()])}const h3={};function wS(e){const t=this,i=e||h3,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(u3(i)),o.push(RR()),c.push(MR(i))}const ta=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],ol={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...ta,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...ta],h2:[["className","sr-only"]],img:[...ta,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...ta,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...ta],table:[...ta],ul:[...ta,["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"]},As={}.hasOwnProperty;function d3(e,t){let i={type:"root",children:[]};const s={schema:t?{...ol,...t}:ol,stack:[]},a=CS(s,e);return a&&(Array.isArray(a)?a.length===1?i=a[0]:i.children=a:i=a),i}function CS(e,t){if(t&&typeof t=="object"){const i=t;switch(typeof i.type=="string"?i.type:""){case"comment":return f3(e,i);case"doctype":return p3(e,i);case"element":return m3(e,i);case"root":return g3(e,i);case"text":return _3(e,i)}}}function f3(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 zo(o,t),o}}function p3(e,t){if(e.schema.allowDoctypes){const i={type:"doctype"};return zo(i,t),i}}function m3(e,t){const i=typeof t.tagName=="string"?t.tagName:"";e.stack.push(i);const s=kS(e,t.children),a=x3(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&&As.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 zo(c,t),c}function g3(e,t){const s={type:"root",children:kS(e,t.children)};return zo(s,t),s}function _3(e,t){const s={type:"text",value:typeof t.value=="string"?t.value:""};return zo(s,t),s}function kS(e,t){const i=[];if(Array.isArray(t)){const s=t;let a=-1;for(;++a<s.length;){const o=CS(e,s[a]);o&&(Array.isArray(o)?i.push(...o):i.push(o))}}return i}function x3(e,t){const i=e.stack[e.stack.length-1],s=e.schema.attributes,a=e.schema.required,o=s&&As.call(s,i)?s[i]:void 0,c=s&&As.call(s,"*")?s["*"]:void 0,h=t&&typeof t=="object"?t:{},p={};let d;for(d in h)if(As.call(h,d)){const x=h[d];let _=Gv(e,Yv(o,d),d,x);_==null&&(_=Gv(e,Yv(c,d),d,x)),_!=null&&(p[d]=_)}if(a&&As.call(a,i)){const x=a[i];for(d in x)As.call(x,d)&&!As.call(p,d)&&(p[d]=x[d])}return p}function Gv(e,t,i,s){return t?Array.isArray(s)?b3(e,t,i,s):ES(e,t,i,s):void 0}function b3(e,t,i,s){let a=-1;const o=[];for(;++a<s.length;){const c=ES(e,t,i,s[a]);(typeof c=="number"||typeof c=="string")&&o.push(c)}return o}function ES(e,t,i,s){if(!(typeof s!="boolean"&&typeof s!="number"&&typeof s!="string")&&v3(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 v3(e,t,i){const s=e.schema.protocols&&As.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!s||s.length===0)return!0;const a=String(i),o=a.indexOf(":"),c=a.indexOf("?"),h=a.indexOf("#"),p=a.indexOf("/");if(o<0||p>-1&&o>p||c>-1&&o>c||h>-1&&o>h)return!0;let d=-1;for(;++d<s.length;){const x=s[d];if(o===x.length&&a.slice(0,x.length)===x)return!0}return!1}function zo(e,t){const i=C0(t);t.data&&(e.data=No(t.data)),i&&(e.position=i)}function Yv(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 NS(e){return function(t){return d3(t,e)}}const rl=["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"],Xr=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function TS(e){return e.toLowerCase().replace(/[^a-z0-9+]/g,"")}const y3=Object.fromEntries(rl.map(e=>[TS(e),e])),S3={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 bu(e){if(!e)return null;const t=TS(e.trim());return t?y3[t]??S3[t]??null:null}function jS(e,t){const i=t.startsWith("assets/")?t.slice(7):t;return`/api/stories/${e}/asset/${i}`}function AS(e,t,i){const[s,a]=C.useState({url:null,loading:!!t,error:!1});return C.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(jS(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 Ap({storyName:e,assetPath:t,authFetch:i,alt:s,className:a}){const{url:o,loading:c,error:h}=AS(e,t,i);return h||!c&&!o?f.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center",children:f.jsx("span",{className:"text-xs text-muted",children:"Image not available"})}):o?f.jsx("img",{src:o,alt:s,className:a??"w-full rounded border border-border"}):f.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center","data-testid":"asset-loading",children:f.jsx("span",{className:"text-xs text-muted",children:"Loading image…"})})}function Kv(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 ru(e,t,i,s,a){const o=a.lineHeightFactor??1.2,c=a.speakerScale??.8,h=a.paddingX??Math.max(2,i*.06),p=a.paddingY??Math.max(2,s*.08),d=Math.max(1,i-2*h),x=Math.max(1,s-2*p),_=Math.max(a.minFontSize,a.maxFontSize),b=Math.max(1,Math.min(a.minFontSize,_)),v=E=>{const A=a.hasSpeaker?E*c:0,T=a.hasSpeaker?A*o:0,L=Math.max(1,x-T),O=a.fontWeight??400,J=Kv((X,he)=>e(X,he,O),t,d,E),$=J.length*E*o,M=J.every(X=>e(X,E,O)<=d+.5);return{lines:J,ok:$<=L&&M}};if(typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&a.fontSize>0){const E=Math.max(1,a.fontSize),{lines:A,ok:T}=v(E);return{lines:A,fontSize:E,lineHeight:E*o,speakerFontSize:a.hasSpeaker?E*c:0,overflow:!T}}for(let E=_;E>=b;E-=.5){const{lines:A,ok:T}=v(E);if(T)return{lines:A,fontSize:E,lineHeight:E*o,speakerFontSize:a.hasSpeaker?E*c:0,overflow:!1}}return{lines:Kv(e,t,d,b),fontSize:b,lineHeight:b*o,speakerFontSize:a.hasSpeaker?b*c:0,overflow:!0}}function w3(e){return{minFontSize:Math.max(1,e*.022),maxFontSize:Math.max(1,e*.05)}}const RS=["speech","narration","sfx"],C3=2;function Cr(e,t,i){return Math.min(i,Math.max(t,e))}function sl(e,t,i){return typeof e=="number"&&Number.isFinite(e)?Cr(e,t,i):void 0}function dm(e){if(!e||typeof e!="object")return;const t=e,i=t.mode==="manual"?"manual":t.mode==="auto"?"auto":void 0,s=sl(t.fontScale,.015,.12),a=t.fontWeight===700?700:t.fontWeight===400?400:void 0,o=sl(t.lineHeightFactor,.9,2),c=sl(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 Fu(e){if(!e||typeof e!="object")return;const t=e,i=sl(t.paddingX,0,.25),s=sl(t.paddingY,0,.25),a=sl(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 su(e,t,i,s){const{minFontSize:a,maxFontSize:o}=w3(t),c=dm(e.textStyle),h=Fu(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 k3(e,t,i){const s=Fu(e.bubbleStyle);return(s==null?void 0:s.cornerRadius)!==void 0?Math.min(t,i)*s.cornerRadius:void 0}function MS(e,t){const i=Math.min(e,t);return Math.max(0,Math.min(i*.4,i/2))}function Vv(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?Cr(e,h,p):t+i/2,half:c}}function DS(e,t,i,s,a,o){const c=e+i/2,h=t+s/2,p=e+a.x*i,d=t+a.y*s;if(p>=e&&p<=e+i&&d>=t&&d<=t+s)return null;const x=p-c,_=d-h,b=Math.max(6,Math.min(i,s)*.3),v=o??MS(i,s);if(Math.abs(_)>=Math.abs(x)){const T=_>=0?t+s:t,{center:L,half:O}=Vv(p,e,i,v,b);return{tip:{x:p,y:d},base1:{x:L-O,y:T},base2:{x:L+O,y:T}}}const y=x>=0?e+i:e,{center:E,half:A}=Vv(d,t,s,v,b);return{tip:{x:p,y:d},base1:{x:y,y:E-A},base2:{x:y,y:E+A}}}function E3(e){return e.type!=="speech"||!e.tailAnchor?!1:DS(0,0,1,1,e.tailAnchor)!==null}function N3(e,t,i,s,a,o){const c=o??MS(i,s),h=e+i,p=t+s,d=!!a&&a.base1.y===t&&a.base2.y===t,x=!!a&&a.base1.x===h&&a.base2.x===h,_=!!a&&a.base1.y===p&&a.base2.y===p,b=!!a&&a.base1.x===e&&a.base2.x===e,v=[{k:"M",x:e+c,y:t}];return d&&a&&v.push({k:"L",x:a.base1.x,y:t},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base2.x,y:t}),v.push({k:"L",x:h-c,y:t},{k:"A",cornerX:h,cornerY:t,x:h,y:t+c,r:c}),x&&a&&v.push({k:"L",x:h,y:a.base1.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:h,y:a.base2.y}),v.push({k:"L",x:h,y:p-c},{k:"A",cornerX:h,cornerY:p,x:h-c,y:p,r:c}),_&&a&&v.push({k:"L",x:a.base2.x,y:p},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base1.x,y:p}),v.push({k:"L",x:e+c,y:p},{k:"A",cornerX:e,cornerY:p,x:e,y:p-c,r:c}),b&&a&&v.push({k:"L",x:e,y:a.base2.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:e,y:a.base1.y}),v.push({k:"L",x:e,y:t+c},{k:"A",cornerX:e,cornerY:t,x:e+c,y:t,r:c}),v}function T3(e,t,i,s,a,o){const c=N3(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 j3(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 Xv=0;function Zv(e,t=.1,i=.1){return Xv++,{id:`overlay-${Date.now()}-${Xv}`,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 A3(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 au=.05;function Ii(e){return typeof e=="number"&&Number.isFinite(e)}function R3(e,t,i){const s=e.toLowerCase(),a=/\bleft\b/.test(s),o=/\bright\b/.test(s),c=/\b(?:top|upper)\b/.test(s),h=/\b(?:bottom|lower)\b/.test(s),p=/\b(?:center|centre|middle)\b/.test(s);if(!a&&!o&&!c&&!h&&!p)return null;const d=a?au:Cr(o?1-t-au:(1-t)/2,0,1),x=c?au:Cr(h?1-i-au:(1-i)/2,0,1);return{x:d,y:x}}let M3=0;function D3(e){if(!e||typeof e!="object")return null;const t=e,i=RS.includes(t.type)?t.type:"speech",s=typeof t.text=="string"?t.text:"";let a=Ii(t.width)&&t.width>0?t.width:i==="sfx"?.15:.4,o=Ii(t.height)&&t.height>0?t.height:i==="sfx"?.08:.16,c,h;if(Ii(t.x)&&Ii(t.y))c=t.x,h=t.y;else{const b=typeof t.position=="string"?R3(t.position,a,o):null;if(!b)return null;c=b.x,h=b.y}c=Cr(c,0,1),h=Cr(h,0,1),a=Cr(a,.02,1),o=Cr(o,.02,1);const d={id:typeof t.id=="string"&&t.id?t.id:`overlay-norm-${++M3}`,type:i,x:c,y:h,width:a,height:o,text:s};if(i==="speech"){d.speaker=typeof t.speaker=="string"?t.speaker:"";const b=t.tailAnchor;d.tailAnchor=b&&Ii(b.x)&&Ii(b.y)?{x:b.x,y:b.y}:{x:.5,y:1.2}}else typeof t.speaker=="string"&&t.speaker&&(d.speaker=t.speaker);const x=dm(t.textStyle),_=Fu(t.bubbleStyle);return x&&(d.textStyle=x),_&&(d.bubbleStyle=_),d}function B3(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&!!t.id&&RS.includes(t.type)&&Ii(t.x)&&Ii(t.y)&&Ii(t.width)&&Ii(t.height)&&typeof t.text=="string"}function L3(e){const t=Array.isArray(e)?e:[],i=[],s=[];let a=!Array.isArray(e);return t.forEach((o,c)=>{const h=D3(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),B3(o)||(a=!0)}),{overlays:i,changed:a,invalid:s}}function qD(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(Ii(i==null?void 0:i.x)&&Ii(i==null?void 0:i.y)&&Ii(i==null?void 0:i.width)&&Ii(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=dm(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=Fu(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 Qv=new Set(["speech","narration"]),O3=.12;function Jv(e){return Ii(e==null?void 0:e.x)&&Ii(e==null?void 0:e.y)&&Ii(e==null?void 0:e.width)&&Ii(e==null?void 0:e.height)&&e.width>0&&e.height>0}function z3(e,t=O3){const i=[];for(let s=0;s<e.length;s++){const a=e[s];if(!(!Qv.has(a==null?void 0:a.type)||!Jv(a)))for(let o=s+1;o<e.length;o++){const c=e[o];if(!Qv.has(c==null?void 0:c.type)||!Jv(c))continue;const h=Math.min(a.x+a.width,c.x+c.width)-Math.max(a.x,c.x),p=Math.min(a.y+a.height,c.y+c.height)-Math.max(a.y,c.y);if(h<=0||p<=0)continue;const d=h*p,x=Math.min(a.width*a.height,c.width*c.height),_=x>0?d/x:0;_>=t&&i.push({indexA:s,indexB:o,idA:a.id,idB:c.id,ratio:_})}}return i}function kr(e){return e.kind==="text"}function P3(e){return!!e.finalImagePath||!!e.exportedAt?{key:"review",label:"Review final panel",opensEditor:!0}:e.cleanImagePath||kr(e)?{key:"letter",label:"Letter this cut",opensEditor:!0}:{key:"add-art",label:"Add clean art for this cut",opensEditor:!1}}function BS(e,t=C3){return!e.finalImagePath||!(e.overlays??[]).some(E3)?!1:(e.finalRendererVersion??0)<t}const ey=800;function I3(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:ey,height:Math.round(ey*s/i)}}function lu({cut:e}){return e.dialogue.length>0||e.narration||e.sfx?f.jsxs("div",{className:"space-y-1.5","data-testid":`cut-${e.id}-overlay`,children:[e.dialogue.map((i,s)=>f.jsxs("div",{className:"flex gap-2 text-xs",children:[f.jsxs("span",{className:"font-medium text-foreground flex-shrink-0",children:[i.speaker,":"]}),f.jsx("span",{className:"text-foreground",children:i.text})]},s)),e.narration&&f.jsx("div",{className:"border-l-2 border-border pl-3",children:f.jsx("p",{className:"text-xs text-muted italic",children:e.narration})}),e.sfx&&f.jsxs("p",{className:"text-xs font-mono text-muted",children:["SFX: ",e.sfx]})]}):null}function H3({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 f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-[10px] font-mono text-muted bg-surface border border-border rounded px-1.5 py-0.5",children:["#",e.id]}),f.jsx("span",{className:"text-[10px] font-mono text-muted",children:e.shotType}),e.characters.length>0&&f.jsx("span",{className:"text-[10px] text-muted truncate",children:e.characters.join(", ")})]}),a&&f.jsx(Ap,{storyName:t,assetPath:e.finalImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),!a&&o&&f.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[f.jsx(Ap,{storyName:t,assetPath:e.cleanImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),f.jsx("div",{className:"px-3 py-2 bg-surface/80 border-t border-border",children:f.jsx(lu,{cut:e})})]}),!c&&p&&f.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:[f.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Text panel"}),h?f.jsx(lu,{cut:e}):f.jsx("p",{className:"text-xs text-muted italic",children:"Empty text panel — open the editor to add text."})]}),!c&&!p&&f.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:[f.jsxs("div",{className:"aspect-video flex flex-col items-center justify-center gap-1 text-center",children:[f.jsx("span",{className:"text-xs text-muted font-medium",children:"Image pending"}),f.jsx("span",{className:"text-[10px] text-muted",children:"Planned image cut — generate & upload the art"})]}),h&&f.jsxs("div",{className:"border-t border-dashed border-border pt-2 space-y-1",children:[f.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Planned text (will be lettered onto the image)"}),f.jsx(lu,{cut:e})]})]}),e.description&&f.jsx("p",{className:"text-xs text-muted italic",children:e.description}),a&&f.jsx(lu,{cut:e}),s&&(()=>{const d=P3(e);return f.jsx("button",{type:"button","data-testid":`cut-${e.id}-cta`,"data-cut-action":d.key,onClick:()=>s(e.id,d.opensEditor),className:"w-full px-3 py-1.5 text-xs font-medium rounded bg-accent text-white hover:bg-accent-dim",children:d.label})})()]})}function U3({storyName:e,fileName:t,authFetch:i,onEditCut:s}){const[a,o]=C.useState(null),[c,h]=C.useState(!0),[p,d]=C.useState(null),x=t.replace(/\.md$/,""),_=C.useCallback(async()=>{h(!0),d(null);try{const b=await i(`/api/stories/${e}/cuts/${x}`);if(b.status===404){o(null),h(!1);return}if(!b.ok){const y=await b.json();d(y.error||"Failed to load cuts"),h(!1);return}const v=await b.json();o(v)}catch{d("Failed to load cuts")}finally{h(!1)}},[i,e,x]);return C.useEffect(()=>{_();const b=setInterval(_,5e3);return()=>clearInterval(b)},[_]),c&&!a?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Loading cuts..."}):p?f.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center","data-testid":"cuts-error",children:[f.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),f.jsx("p",{className:"text-xs text-error",children:p}),f.jsxs("p",{className:"text-xs text-muted max-w-sm",children:[x,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema shown in the cartoon writing instructions."]}),f.jsx("button",{onClick:_,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]}):!a||a.cuts.length===0?f.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center",children:[f.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),f.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]}):f.jsx("div",{className:"h-full overflow-y-auto",children:f.jsx("div",{className:"max-w-lg mx-auto px-4 py-6 space-y-6",children:a.cuts.map(b=>f.jsx(H3,{cut:b,storyName:e,authFetch:i,onEditCut:s},b.id))})})}const ty=/!\[[^\]]*\]\([^)]*\)/g,$3=/<!--[\s\S]*?-->/g,LS=200;function F3(e){const t=(e.match(ty)||[]).length,i=e.length,s=e.replace($3," ").replace(ty," ").replace(/\s+/g," ").trim();return{imageCount:t,charCount:i,nonImageProse:s,nonImageProsePreview:s.slice(0,LS)}}function q3(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 W3=[/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 G3(e){for(const t of W3){const i=e.match(t);if(i)return i[0]}return null}function fm(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 Y3(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(fm(e,s)===null)return!0}return!1}function OS(e,t){const i=[];if(t.length===0)return{ready:!1,issues:["This episode has no cuts planned yet — plan and produce its cuts before publishing."]};for(let c=0;c<t.length;c++){const h=t[c],p=`Cut ${c+1}`,d=`cut-${String(c+1).padStart(3,"0")}`;h.uploadedUrl||i.push(`${p}: not uploaded (no recorded uploaded URL)`),BS(h)&&i.push(q3(p));const x=fm(e,d);if(x===null){i.push(`${p}: missing or incomplete markdown block`);continue}const _=[...x.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)].map(b=>b[1].trim());_.length===0?i.push(`${p}: block has no image reference`):_.length>1?i.push(`${p}: block must contain exactly one image reference`):h.uploadedUrl&&_[0]!==h.uploadedUrl&&i.push(`${p}: image URL does not match the recorded uploaded URL`)}/awaiting upload|image pending|final image pending|pending upload/i.test(e)&&i.push("Markdown contains awaiting-upload placeholders");const s=G3(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(Y3(e,t))return{stage:"planning",issues:[],awaitingCount:0,totalCuts:i};const{ready:s,issues:a}=OS(e,t);if(s)return{stage:"ready",issues:[],awaitingCount:0,totalCuts:i};const o=new Set;for(let p=0;p<t.length;p++){const d=`Cut ${p+1}`,x=`cut-${String(p+1).padStart(3,"0")}`,_=fm(e,x);if(_===null)continue;!/!\[[^\]]*\]\([^)]*\)/.test(_)&&!t[p].uploadedUrl&&o.add(d)}const c=new Set(["Markdown contains awaiting-upload placeholders"]);for(const p of o)c.add(`${p}: not uploaded (no recorded uploaded URL)`),c.add(`${p}: block has no image reference`);const h=a.filter(p=>!c.has(p));return h.length>0?{stage:"error",issues:h,awaitingCount:o.size,totalCuts:i}:{stage:"awaiting-upload",issues:[],awaitingCount:o.size,totalCuts:i}}const Tf=[{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 K3(e){const t=new Map,i=[],s=[];for(const o of e){const c=o.match(/^Cut (\d+): (.+)$/);if(c){const h=c[2];t.has(h)||(t.set(h,[]),i.push(h)),t.get(h).push(Number(c[1]))}else s.push(o)}return[...i.map(o=>{const c=t.get(o).slice().sort((p,d)=>p-d);return`${c.length===1?`Cut ${c[0]}`:`Cuts ${c.join(", ")}`}: ${o}`}),...s]}function PS(e){const t=c=>{var h;return((h=Tf.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=[...Tf.map(c=>c.key),"other"],a=c=>{var h;return((h=Tf.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:K3(h)})}return o}const V3=220,jf=/^(genre|logline|synopsis|premise|setting|tone|theme|themes|summary|hook|characters?|cast|arc|status|word\s*count|length|title)\b\s*[:\-–]/i;function pm(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<V3)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(_=>_.trim()).filter(Boolean),p=h.filter(_=>/^([-*+]|\d+[.)])\s/.test(_)||jf.test(_)).length,d=c.split(/\n\s*\n/).map(_=>_.trim()).filter(Boolean),x=d.some(_=>_.length>=120&&!/^([-*+]|\d+[.)])\s/.test(_)&&!jf.test(_));h.length>0&&p/h.length>=.5||!x?t.push("This reads like a synopsis or outline. Write the Genesis as a reader-facing opening scene that sets up the first beat and stakes, then bridges into Episode 01 — not a logline, genre pitch, or character list."):d.filter(b=>b.length>=40&&!/^([-*+]|\d+[.)])\s/.test(b)&&!jf.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 X3(e){return/\.(webp|jpe?g)$/i.test(e)}function Rp(e){var c;let t=0,i=0,s=0,a=0,o=0;for(const h of e)kr(h)||(t++,h.cleanImagePath&&X3(h.cleanImagePath)&&(i++,(((c=h.overlays)==null?void 0:c.length)??0)>0&&s++)),h.finalImagePath&&h.exportedAt&&a++,h.uploadedUrl&&o++;return{total:e.length,needClean:t,withClean:i,withText:s,exported:a,uploaded:o}}const Z3={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 ou(e,t){return`${e} / ${t} cut${t===1?"":"s"}`}function Q3(e){const{cuts:t,published:i=!1}=e,s=Rp(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.needClean,h=c&&s.exported===s.total,p=h&&s.uploaded===s.total,x={plan:a,clean:o,letter:c,export:h,upload:p,publish:p&&i},_=["plan","clean","letter","export","upload","publish"],b=_.findIndex(L=>!x[L]),v=L=>s.needClean>0?ou(L,s.needClean):"no image cuts",y={plan:ou(s.total,s.total),clean:v(s.withClean),letter:v(s.withText),export:ou(s.exported,s.total),upload:ou(s.uploaded,s.total),publish:null},E=_.map((L,O)=>({key:L,label:Z3[L],status:b===-1||O<b?"done":O===b?"current":"todo",detail:y[L]})),T=b===-1?"Published — this episode is live on PlotLink.":{plan:"Plan the episode's cuts to begin.",clean:"Create a clean image for each cut — artwork only, no text or bubbles.",letter:"Open each cut in the lettering editor and place its speech bubbles and captions.",export:"Export the lettered final image for each cut.",upload:"Upload the exported final images so they're ready to publish.",publish:"Preview the episode, then publish to PlotLink."}[_[b]];return{steps:E,nextStep:T}}const J3="This is your story outline — not publishable. Ask AI to write the genesis next.";function eM(e){const{fileName:t,contentType:i,hasGenesis:s,isPublished:a,cutCount:o,cutProgress:c}=e,h=t==="structure.md",p=t==="genesis.md",d=/^plot-\d+\.md$/.test(t);if(h)return i!=="cartoon"?J3:s?"Your story outline is set. Genesis (Episode 1) already exists — review its opening and cuts; you don't need to write the Genesis again.":"This is your story outline — not publishable. Write the Genesis opening (Episode 1) next.";if(i==="cartoon"&&!a&&(p||d)&&o!==null){if(o===0)return p?"Genesis is your Episode 1 opening. Plan its cuts, then generate clean images for them.":"This episode hasn't been started — expand its cut plan before preparing it for publish.";if(p&&c){const x=c;if(x.withClean<x.needClean)return"Genesis has a cut plan — generate the clean images for its cuts next.";if(x.withText<x.needClean)return"Genesis clean art is ready — review the cuts and add speech bubbles & captions next.";if(x.exported<x.total)return"Genesis lettering is underway — export the final images next.";if(x.uploaded<x.total)return"Genesis final images are exported — upload them next, then prepare to publish."}}return null}function tM(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 iM={...ol,attributes:{...ol.attributes,img:["src","alt","title"]}},nM={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 rM({content:e,stage:t}){const i=F3(e),s=i.nonImageProse.length>LS,a=tM({stage:t,imageCount:i.imageCount,hasNonImageProse:i.nonImageProse.length>0});return f.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"cartoon-publish-preview",children:[f.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:[f.jsxs("span",{children:[i.imageCount," image",i.imageCount===1?"":"s"]}),f.jsxs("span",{children:[i.charCount.toLocaleString()," / 10,000 chars"]}),f.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"}),f.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"})]}),f.jsxs("div",{className:`px-4 py-2 border-b text-[11px] ${nM[a.tone]}`,"data-testid":"cartoon-publish-verdict",children:[f.jsx("p",{className:"font-medium",children:a.headline}),a.detail&&f.jsx("p",{className:"mt-0.5 opacity-90",children:a.detail}),a.action&&f.jsxs("p",{className:"mt-0.5 opacity-90",children:["→ ",a.action]})]}),i.nonImageProse&&f.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:[f.jsx("p",{className:"font-medium",children:"⚠ Non-image text in the published markdown:"}),f.jsxs("p",{className:"font-mono mt-1 whitespace-pre-wrap break-words",children:[i.nonImageProsePreview,s?"…":""]}),f.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."})]}),f.jsx("div",{className:"max-w-lg mx-auto px-4 py-6",children:e.trim()?f.jsx("div",{className:"prose max-w-none",children:f.jsx(Z0,{remarkPlugins:[J0,wS],rehypePlugins:[[NS,iM]],children:e})}):f.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 sM="modulepreload",aM=function(e){return"/"+e},iy={},ny=function(t,i,s){let a=Promise.resolve();if(i&&i.length>0){let c=function(d){return Promise.all(d.map(x=>Promise.resolve(x).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));a=c(i.map(d=>{if(d=aM(d),d in iy)return;iy[d]=!0;const x=d.endsWith(".css"),_=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${_}`))return;const b=document.createElement("link");if(b.rel=x?"stylesheet":sM,x||(b.as="script"),b.crossOrigin="",b.href=d,p&&b.setAttribute("nonce",p),document.head.appendChild(b),x)return new Promise((v,y)=>{b.addEventListener("load",v),b.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&o(h.reason);return t().catch(o)})},mm=[{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:[]}],lM="system-ui, sans-serif",oM=mm.find(e=>e.family==="Noto Sans"),cM=mm.find(e=>e.category==="display");function uM(e){return mm.find(i=>i.category==="body"&&i.languages.includes(e))||oM}function hM(){return cM}function dM(e){const t=e.weights.join(";");return`https://fonts.googleapis.com/css2?family=${e.googleFontsId}:wght@${t}&display=swap`}function ry(e){return`"${e.family}", ${lM}`}function fM(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 vu(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 pM(e){return!e.exported&&!e.uploaded?!1:e.baselineSig!==vu(e.current)}function IS(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 Sn(e,t){return e*t}function sy(e,t){return t===0?0:e/t}function ay(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=dM(e),document.head.appendChild(i)}const yu={speech:"Speech",narration:"Narration",sfx:"SFX"},mM={speech:"border-foreground/40",narration:"border-muted/40",sfx:"border-accent/40"};function Af(e){const t=(e.speaker||e.text||"").trim().replace(/\s+/g," ");return t?`“${t.length>18?`${t.slice(0,18)}…`:t}”`:yu[e.type]}const ly=.05,gM=[{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 cu(e,t,i){return Math.min(i,Math.max(t,e))}function _M({storyName:e,cut:t,plotFile:i,onSave:s,onClose:a,onExported:o,language:c="English",authFetch:h}){var hi,re,xe,Pe,Fe,Qe;const p=uM(c),d=hM(),x=ry(p),_=ry(d);C.useEffect(()=>{ay(p),ay(d)},[p,d]),C.useEffect(()=>{let H=!1;return ye(!1),(async()=>{try{const{ensureFontsReady:ge}=await ny(async()=>{const{ensureFontsReady:Te}=await import("./export-cut-nKQ_n2-J.js");return{ensureFontsReady:Te}},[]);await ge([p.family,d.family])}catch{}H||ye(!0)})(),()=>{H=!0}},[p.family,d.family]);const b=AS(e,t.cleanImagePath,h),v=C.useMemo(()=>L3(t.overlays),[t.overlays]),y=v.invalid.length,[E,A]=C.useState(!1),T=y===0&&v.changed&&v.overlays.length>0,[L,O]=C.useState(()=>v.overlays),[J,$]=C.useState(()=>vu(v.overlays)),M=C.useRef(null),X=C.useCallback(H=>(ge,Te,me=400)=>{var Oe;!M.current&&typeof document<"u"&&(M.current=document.createElement("canvas"));const He=(Oe=M.current)==null?void 0:Oe.getContext("2d");return He?(He.font=`${me} ${Te}px ${H}`,He.measureText(ge).width):ge.length*Te*.5},[]),[he,ye]=C.useState(!1),[U,se]=C.useState(null),[W,G]=C.useState(!1),[Z,I]=C.useState(!1),[j,z]=C.useState(null),[B,_e]=C.useState({x:0,y:0,width:0,height:0}),N=C.useRef(null),R=C.useRef(null),Y=C.useRef(null),w=C.useCallback(()=>{const H=N.current;if(!H)return;const ge=H.clientWidth,Te=H.clientHeight;let me,He;if(t.kind==="text"){const Dt=I3(t.aspectRatio)??{width:800,height:600};me=Dt.width,He=Dt.height}else{const Dt=R.current;if(!Dt||!Dt.naturalWidth)return;me=Dt.naturalWidth,He=Dt.naturalHeight}if(!ge||!Te)return;const Oe=Math.min(ge/me,Te/He),ut=me*Oe,it=He*Oe;_e({x:(ge-ut)/2,y:(Te-it)/2,width:ut,height:it})},[t.kind,t.aspectRatio]);C.useEffect(()=>{const H=N.current;if(!H)return;const ge=new ResizeObserver(()=>w());return ge.observe(H),()=>ge.disconnect()},[w]);const ae=C.useCallback(H=>{const ge=A3(H.type,H.x,H.y),Te=ge.width,me=Math.max(.08,1-H.y);if(!H.text||!he||B.width<=0)return ge;const He=H.type==="sfx"?_:x,Oe=Sn(Te,B.width);let ut=H.type==="sfx"?.08:.12;for(let it=0;it<24;it++){const Dt=Math.min(ut,me),Bt=Sn(Dt,B.height);if(!ru(X(He),H.text,Oe,Bt,su({...H},B.height||300,Oe,Bt)).overflow||Dt>=me)return{width:Te,height:Dt};ut+=.03}return{width:Te,height:Math.min(ut,me)}},[he,B,X,x,_]),ie=C.useCallback(H=>{const ge=Zv(H,.1+Math.random()*.3,.1+Math.random()*.3),Te={...ge,...ae(ge)};O(me=>[...me,Te]),se(Te.id)},[ae]),oe=C.useCallback(H=>{const Te={...Zv(H.type,.1+Math.random()*.3,.1+Math.random()*.3),text:H.text,...H.type==="speech"&&H.speaker?{speaker:H.speaker}:{}},me={...Te,...ae(Te)};O(He=>[...He,me]),se(me.id)},[ae]),F=C.useCallback((H,ge)=>{O(Te=>Te.map(me=>me.id===H?{...me,...ge}:me))},[]),ue=C.useCallback(H=>{var ut;const ge=B.height||300,Te=B.width>0?Sn(H.width,B.width):200,me=B.height>0?Sn(H.height,B.height):100,He=H.type==="sfx"?_:x,Oe=ru(X(He),H.text,Te,me,su({...H,textStyle:void 0},ge,Te,me));F(H.id,{textStyle:{mode:"manual",fontScale:Oe.fontSize/Math.max(1,ge),fontWeight:((ut=H.textStyle)==null?void 0:ut.fontWeight)??400,lineHeightFactor:Oe.fontSize>0?Oe.lineHeight/Oe.fontSize:1.2,speakerScale:Oe.fontSize>0&&Oe.speakerFontSize>0?Oe.speakerFontSize/Oe.fontSize:.8}})},[B,_,x,X,F]),be=C.useCallback(H=>{O(ge=>ge.filter(Te=>Te.id!==H)),se(null),G(!1)},[]),De=C.useCallback(()=>{se(null),G(!1)},[]),Ee=C.useCallback((H,ge)=>{H.stopPropagation(),se(ge),G(!1)},[]),Be=C.useCallback((H,ge,Te)=>{H.stopPropagation(),H.preventDefault();const me=L.find(He=>He.id===ge);me&&(se(ge),Y.current={id:ge,mode:Te,startX:H.clientX,startY:H.clientY,origX:me.x,origY:me.y,origW:me.width,origH:me.height})},[L]);C.useEffect(()=>{const H=Te=>{const me=Y.current;if(!me||B.width===0)return;const He=sy(Te.clientX-me.startX,B.width),Oe=sy(Te.clientY-me.startY,B.height);if(me.mode==="move"){const ut=cu(me.origX+He,0,1-me.origW),it=cu(me.origY+Oe,0,1-me.origH);F(me.id,{x:ut,y:it})}else{const ut=cu(me.origW+He,ly,1-me.origX),it=cu(me.origH+Oe,ly,1-me.origY);F(me.id,{width:ut,height:it})}},ge=()=>{Y.current=null};return window.addEventListener("mousemove",H),window.addEventListener("mouseup",ge),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",ge)}},[B,F]);const je=C.useCallback(()=>{s(L)},[L,s]),Ze=C.useCallback(async()=>{if(y>0&&!E){const H=y;z(`${H} overlay${H===1?"":"s"} from the cut plan ${H===1?"has":"have"} no usable position and cannot be exported — re-place ${H===1?"it":"them"} or discard ${H===1?"it":"them"} first.`);return}I(!0),z(null);try{await s(L);const{exportCut:H,ensureFontsReady:ge}=await ny(async()=>{const{exportCut:kt,ensureFontsReady:Ci}=await import("./export-cut-nKQ_n2-J.js");return{exportCut:kt,ensureFontsReady:Ci}},[]),Te=L.some(kt=>kt.type==="sfx"),me=[p.family,...Te?[d.family]:[]],{ready:He,missing:Oe}=await ge(me);if(!He){z(`Fonts not loaded: ${Oe.join(", ")}. Check your connection and retry.`),I(!1);return}if(t.cleanImagePath&&!b.url){z(b.error?"Clean image failed to load — cannot export. Retry once it renders.":"Clean image still loading — wait for it to render, then export."),I(!1);return}const ut=b.url,it=await H(ut,L,x,_,{narration:t.narration,dialogue:t.dialogue},t.kind==="text"?{background:t.background,aspectRatio:t.aspectRatio}:void 0),Dt=new FormData,Bt=it.type==="image/webp"?"webp":"jpg";Dt.append("file",it,`cut-${t.id}.${Bt}`);const di=await h(`/api/stories/${e}/cuts/${i}/export-final/${t.id}`,{method:"POST",body:Dt});if(di.ok)$(vu(L)),o==null||o();else{const kt=await di.json();z(kt.error||"Export failed")}}catch(H){z(H instanceof Error?H.message:"Export failed")}finally{I(!1)}},[t,b,L,e,i,p,d,x,_,h,s,o,y,E]),we=L.find(H=>H.id===U),tt=C.useMemo(()=>z3(L),[L]),mt=C.useRef(t.id);C.useEffect(()=>{mt.current!==t.id&&(mt.current=t.id,$(vu(v.overlays)))},[t.id,v.overlays]);const Ge=pM({exported:!!t.finalImagePath||!!t.exportedAt,uploaded:!!t.uploadedUrl||!!t.uploadedCid,baselineSig:J,current:L}),Ae=C.useMemo(()=>fM({...t,overlays:L},{staleExport:Ge}),[t,L,Ge]),Ve=C.useMemo(()=>IS(t),[t]),Mt=C.useMemo(()=>{const H={};for(const ge of L){const Te=j3(ge);let me=!1;if(he&&B.width>0&&ge.text){const He=ge.type==="sfx"?_:x,Oe=Sn(ge.width,B.width),ut=Sn(ge.height,B.height);me=ru(X(He),ge.text,Oe,ut,su(ge,B.height||300,Oe,ut)).overflow}(Te||me)&&(H[ge.id]={outOfBounds:Te,overflow:me})}return H},[L,he,B,X,x,_]),zt=Object.keys(Mt).length,ai=t.kind==="text",wt=!t.cleanImagePath;return!ai&&wt&&L.length===0&&!t.narration&&!((hi=t.dialogue)!=null&&hi.length)?f.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted",children:"No clean image — upload one first, or add overlays for a narration cut."}):f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-xs font-mono text-muted",children:["Cut #",t.id]}),f.jsxs("span",{className:"text-[10px] text-muted","data-testid":"overlay-count",children:[L.length," overlays"]}),f.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[f.jsx("button",{onClick:()=>ie("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"}),f.jsx("button",{onClick:()=>ie("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"}),f.jsx("button",{onClick:()=>ie("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"})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[j&&f.jsx("span",{className:"text-[10px] text-error",children:j}),f.jsx("button",{onClick:Ze,disabled:Z,className:"px-3 py-1 text-xs border border-accent text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"export-btn",children:Z?"Exporting...":"Export"}),f.jsx("button",{onClick:je,className:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-accent-dim",children:"Save"}),f.jsx("button",{onClick:a,className:"px-3 py-1 text-xs text-muted hover:text-foreground border border-border rounded",children:"Close"})]})]}),y>0&&!E?f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-error/10 text-[10px] text-error flex items-center gap-2 flex-wrap","data-testid":"overlay-repair-note",children:[f.jsxs("span",{children:[y," overlay",y===1?"":"s"," from the cut plan ",y===1?"has":"have"," no usable position and cannot be exported. Re-place ",y===1?"it":"them",", or"]}),f.jsxs("button",{onClick:()=>A(!0),"data-testid":"discard-invalid-overlays",className:"px-1.5 py-0.5 border border-error/40 rounded hover:bg-error/10",children:["discard ",y," unplaceable overlay",y===1?"":"s"]})]}):y>0?f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:["Discarded ",y," unplaceable overlay",y===1?"":"s"," — the export will not include ",y===1?"it":"them","."]}):T?f.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:"Auto-placed overlays from the cut plan — review their positions before exporting."}):null,tt.length>0&&f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-overlap-warning",children:["Cut #",t.id,": ",tt.length," bubble ",tt.length===1?"pair overlaps":"pairs overlap"," and may be hard to read —"," ",tt.map(H=>`#${H.indexA+1} ${Af(L[H.indexA])} ↔ #${H.indexB+1} ${Af(L[H.indexB])}`).join("; "),". Move them apart, or export as-is if the overlap is intended."]}),f.jsx("div",{className:"px-3 py-1 border-b border-border flex items-center gap-3 flex-wrap text-[10px] text-muted","data-testid":"lettering-checklist",children:[["clean-image","Clean image",Ae.hasCleanImage],["script-text","Script text",Ae.hasScriptText],["bubbles",`Bubbles placed${Ae.bubblesPlaced?` (${Ae.bubblesPlaced})`:""}`,Ae.bubblesPlaced>0],["exported","Final exported",Ae.exported],["uploaded","Uploaded",Ae.uploaded]].map(([H,ge,Te])=>f.jsxs("span",{"data-testid":`lettering-check-${H}`,"data-done":Te?"true":"false",className:`flex items-center gap-1 ${Te?"text-green-700":"text-muted/70"}`,children:[f.jsx("span",{"aria-hidden":!0,children:Te?"✓":"○"}),ge]},H))}),Ge&&f.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-stale-export-warning",children:"Bubbles changed since the last export — re-export this cut and upload the new final image before publishing."}),zt>0&&f.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-export-warning",children:[zt," bubble",zt===1?"":"s"," may not export cleanly:"," ",Object.entries(Mt).map(([H,ge])=>{const Te=L.findIndex(He=>He.id===H),me=[ge.outOfBounds?"outside image":null,ge.overflow?"text overflow":null].filter(Boolean).join(", ");return`#${Te+1} ${Af(L[Te])} (${me})`}).join("; "),". Resize or reposition before exporting."]}),f.jsxs("div",{className:"flex-1 min-h-0 flex",children:[f.jsxs("div",{ref:N,className:"flex-1 min-w-0 relative overflow-hidden",onClick:De,"data-testid":"editor-surface",children:[t.cleanImagePath&&b.error?f.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-error",children:"Clean image not available"}):t.cleanImagePath&&!b.url?f.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-loading",children:"Loading clean image…"}):t.cleanImagePath?f.jsx("img",{ref:R,src:b.url,alt:`Cut ${t.id} clean`,className:"w-full h-full object-contain",draggable:!1,onLoad:w}):ai?B.width>0&&f.jsx("div",{className:"absolute flex items-center justify-center text-muted text-xs",style:{left:B.x,top:B.y,width:B.width,height:B.height,background:t.background||"#ffffff"},"data-testid":"text-panel-canvas",children:"Text panel"}):f.jsx("div",{className:"w-full h-full bg-white flex items-center justify-center text-muted text-xs",ref:H=>{if(H&&B.width===0){const ge=H.getBoundingClientRect();ge.width>0&&_e({x:0,y:0,width:ge.width,height:ge.height})}},children:"Narration cut"}),B.width>0&&f.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":"balloon-layer",children:L.map(H=>{if(H.type!=="speech")return null;const ge=B.x+Sn(H.x,B.width),Te=B.y+Sn(H.y,B.height),me=Sn(H.width,B.width),He=Sn(H.height,B.height),Oe=k3(H,me,He),ut=H.tailAnchor?DS(ge,Te,me,He,H.tailAnchor,Oe):null,it=Math.max(1.5,B.height*.004),Dt=H.id===U;return f.jsx("path",{"data-testid":`balloon-${H.id}`,d:T3(ge,Te,me,He,ut,Oe),className:`fill-white/95 ${Dt?"stroke-accent":"stroke-[#1a1a1a]"}`,strokeWidth:Dt?it+.5:it,strokeLinejoin:"round"},H.id)})}),B.width>0&&L.map(H=>{const ge=B.x+Sn(H.x,B.width),Te=B.y+Sn(H.y,B.height),me=Sn(H.width,B.width),He=Sn(H.height,B.height),Oe=H.id===U,ut=H.type==="speech",it=H.type==="narration",Dt=!!Mt[H.id];return f.jsxs("div",{"data-testid":`overlay-${H.id}`,"data-warning":Dt?"true":"false",onClick:Bt=>Ee(Bt,H.id),onMouseDown:Bt=>Be(Bt,H.id,"move"),className:`absolute rounded cursor-move select-none ${ut?"":`border-2 ${mM[H.type]}`} ${it?"bg-[#f4efe6]/85 rounded-md":""} ${Oe&&!ut?"ring-2 ring-accent":""} ${Dt?"ring-2 ring-amber-500":""}`,style:{left:ge,top:Te,width:me,height:He},children:[(()=>{var Ci,fi;const Bt=H.type==="sfx"?_:x;if(!H.text)return f.jsx("span",{className:"text-[9px] px-1 text-muted truncate block pointer-events-none",style:{fontFamily:Bt},children:yu[H.type]});const di=H.type!=="sfx"&&!!H.speaker;if(!he)return f.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 overflow-hidden pointer-events-none text-center break-words",style:{fontFamily:Bt,fontSize:Math.max(9,Math.min(He*.05,16)),fontWeight:((Ci=H.textStyle)==null?void 0:Ci.fontWeight)??400},"data-testid":`overlay-text-${H.id}`,"data-fonts-ready":"false",children:di?`${H.speaker}: ${H.text}`:H.text});const kt=ru(X(Bt),H.text,me,He,su(H,B.height,me,He));return f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 overflow-hidden pointer-events-none text-center",style:{fontFamily:Bt},"data-testid":`overlay-text-${H.id}`,"data-fonts-ready":"true",children:[di&&f.jsx("span",{className:"font-bold text-[#3a3a3a] block",style:{fontSize:kt.speakerFontSize,lineHeight:1.2},children:H.speaker}),f.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:kt.fontSize,lineHeight:`${kt.lineHeight}px`,fontWeight:((fi=H.textStyle)==null?void 0:fi.fontWeight)??400},children:kt.lines.map((Gt,fn)=>f.jsx("span",{className:"block",children:Gt},fn))})]})})(),Oe&&f.jsx("div",{onMouseDown:Bt=>{Bt.stopPropagation(),Be(Bt,H.id,"resize")},className:"absolute bottom-0 right-0 w-2 h-2 bg-accent cursor-se-resize","data-testid":`resize-${H.id}`})]},H.id)})]}),f.jsxs("div",{className:"w-52 border-l border-border p-3 overflow-y-auto flex-shrink-0",children:[Ve.length>0&&f.jsxs("div",{className:"mb-3 space-y-1.5","data-testid":"script-insert-panel",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"From script"}),f.jsx("div",{className:"flex flex-col gap-1",children:Ve.map(H=>f.jsxs("button",{onClick:()=>oe(H),"data-testid":`script-insert-${H.key}`,title:`Add ${H.type} overlay with this text`,className:"text-left px-2 py-1 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5",children:[f.jsxs("span",{className:"font-medium text-accent",children:["+ ",yu[H.type]]})," ",f.jsxs("span",{className:"text-muted",children:[H.speaker?`${H.speaker}: `:"",H.text.length>32?`${H.text.slice(0,32)}…`:H.text]})]},H.key))})]}),we?f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-xs font-medium text-foreground",children:yu[we.type]}),we.speaker!==void 0&&f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Speaker"}),f.jsx("input",{value:we.speaker||"",onChange:H=>F(we.id,{speaker:H.target.value}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",placeholder:"Character name","data-testid":"inspector-speaker"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Text"}),f.jsx("textarea",{value:we.text,onChange:H=>F(we.id,{text:H.target.value}),rows:3,className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent resize-none focus:border-accent focus:outline-none",placeholder:"Overlay text","data-testid":"inspector-text"})]}),f.jsx("button",{onClick:()=>F(we.id,ae(we)),"data-testid":"inspector-fit-text",className:"w-full px-2 py-1 text-[11px] border border-border rounded hover:border-accent hover:text-accent",title:"Resize this overlay so its text fits without overflowing",children:"Fit box to text"}),f.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-typography",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Typography"}),((re=we.textStyle)==null?void 0:re.mode)==="manual"?f.jsx("button",{type:"button",onClick:()=>F(we.id,{textStyle:void 0}),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"inspector-text-auto",children:"Auto-fit"}):f.jsx("button",{type:"button",onClick:()=>ue(we),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"})]}),((xe=we.textStyle)==null?void 0:xe.mode)==="manual"?f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Font size (% panel height)"}),f.jsx("input",{type:"number",step:"0.1",min:"1.5",max:"12",value:((we.textStyle.fontScale??.032)*100).toFixed(1),onChange:H=>F(we.id,{textStyle:{...we.textStyle,mode:"manual",fontScale:Math.max(.015,Math.min(.12,(parseFloat(H.target.value)||3.2)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-scale"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Weight"}),f.jsxs("select",{value:String(we.textStyle.fontWeight??400),onChange:H=>F(we.id,{textStyle:{...we.textStyle,mode:"manual",fontWeight:H.target.value==="700"?700:400}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-weight",children:[f.jsx("option",{value:"400",children:"Regular"}),f.jsx("option",{value:"700",children:"Bold"})]})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Line height"}),f.jsx("input",{type:"number",step:"0.05",min:"0.9",max:"2",value:(we.textStyle.lineHeightFactor??1.2).toFixed(2),onChange:H=>F(we.id,{textStyle:{...we.textStyle,mode:"manual",lineHeightFactor:Math.max(.9,Math.min(2,parseFloat(H.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"})]}),we.type!=="sfx"&&f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Speaker scale"}),f.jsx("input",{type:"number",step:"0.05",min:"0.5",max:"1.5",value:(we.textStyle.speakerScale??.8).toFixed(2),onChange:H=>F(we.id,{textStyle:{...we.textStyle,mode:"manual",speakerScale:Math.max(.5,Math.min(1.5,parseFloat(H.target.value)||.8))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-speaker-scale"})]})]}):f.jsx("p",{className:"text-[10px] text-muted",children:"Auto-fit stays on by default and resizes text to the box."})]}),we.type==="speech"&&(()=>{const H=we.tailAnchor||{x:.5,y:1.2};return f.jsxs("div",{className:"space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Tail anchor"}),f.jsx("div",{className:"flex flex-wrap gap-1","data-testid":"inspector-tail-presets",children:gM.map(ge=>f.jsx("button",{type:"button",onClick:()=>F(we.id,{tailAnchor:ge.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-${ge.key}`,children:ge.label},ge.key))}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["x",f.jsx("input",{type:"number",step:"0.1",value:H.x,onChange:ge=>F(we.id,{tailAnchor:{...H,x:parseFloat(ge.target.value)||0}}),className:"w-14 px-1 py-0.5 text-[10px] border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-tail-x"})]}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["y",f.jsx("input",{type:"number",step:"0.1",value:H.y,onChange:ge=>F(we.id,{tailAnchor:{...H,y:parseFloat(ge.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"})]})]})]})})(),we.type!=="sfx"&&f.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-bubble-style",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Bubble controls"}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Padding X (% width)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((Pe=we.bubbleStyle)==null?void 0:Pe.paddingX)??.06)*100).toFixed(0),onChange:H=>F(we.id,{bubbleStyle:{...we.bubbleStyle,paddingX:Math.max(0,Math.min(.25,(parseFloat(H.target.value)||6)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-x"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Padding Y (% height)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((Fe=we.bubbleStyle)==null?void 0:Fe.paddingY)??.08)*100).toFixed(0),onChange:H=>F(we.id,{bubbleStyle:{...we.bubbleStyle,paddingY:Math.max(0,Math.min(.25,(parseFloat(H.target.value)||8)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-y"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] text-muted",children:"Corner roundness (% short side)"}),f.jsx("input",{type:"number",step:"1",min:"0",max:"49",value:((((Qe=we.bubbleStyle)==null?void 0:Qe.cornerRadius)??.4)*100).toFixed(0),onChange:H=>F(we.id,{bubbleStyle:{...we.bubbleStyle,cornerRadius:Math.max(0,Math.min(.49,(parseFloat(H.target.value)||40)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-corner-radius"})]})]}),f.jsxs("div",{className:"text-[10px] text-muted","data-testid":"inspector-font",children:["Font: ",we.type==="sfx"?d.family:p.family]}),f.jsxs("div",{className:"text-[10px] font-mono text-muted space-y-0.5",children:[f.jsxs("p",{children:["x: ",we.x.toFixed(3),", y: ",we.y.toFixed(3)]}),f.jsxs("p",{children:["w: ",we.width.toFixed(3),", h: ",we.height.toFixed(3)]})]}),f.jsx("button",{onClick:()=>{W?be(we.id):G(!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:W?"Click again to delete":"Delete"})]}):f.jsx("p",{className:"text-xs text-muted","data-testid":"inspector-empty",children:"Select an overlay to inspect."})]})]})]})}const xM={wide:"Wide",medium:"Medium","close-up":"Close-up","extreme-close-up":"Extreme close-up"},bM="No speech bubbles, captions, sound effects, narration, or any text or lettering in the image.",vM="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 yM(e){var a;const t=xM[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(vM),s.push(bM),s.join(`
|
|
131
|
+
`).trim()}function SM(e,t){return`assets/${e}/cut-${String(t).padStart(2,"0")}-clean.webp`}function oy(e,t){const i=SM(t,e.id);return[`Generate the clean image for cut ${e.id}.`,"","Image description:",yM(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
|
+
`)}function wM(e,t){const i=`${t}.cuts.json`,s=IS(e),a=s.length>0?s.map(o=>o.type==="speech"?`- speech — ${o.speaker||"Speaker"}: "${o.text}"`:o.type==="narration"?`- narration: ${o.text}`:`- sfx: ${o.text}`).join(`
|
|
133
|
+
`):"- (no dialogue/narration/SFX recorded for this cut — add a caption only if the scene needs one)";return[`Draft the speech bubbles and captions for cut ${e.id} of ${t}.`,"","Script to letter:",a,"","How to draft it:",`- Edit cut ${e.id}'s "overlays" array in ${i}: add one overlay per line above — "type":"speech" for dialogue (also set "speaker"), "narration" for captions, "sfx" for sound effects, with the line's text.`,"- Position each overlay with x, y, width, height as 0–1 fractions of the panel, roughly where it belongs over the art, and keep bubbles clear of faces.","- These are DRAFT positions only: do NOT export or upload. The writer reviews and adjusts them in the OWS lettering editor, then exports the final image there."].join(`
|
|
134
|
+
`)}const HS=12e3,CM=5,kM=6e4,EM=6e4,NM=5;function TM(e,t){return e===429?!0:!!t&&/rate[\s-]?limit/i.test(t)}function jM(e,t=HS){return Math.min(t*2**e,kM)}const US=e=>new Promise(t=>setTimeout(t,e));async function AM(e,t={}){var c;const i=t.sleep??US,s=t.maxRetries??CM,a=t.baseDelayMs??HS;let o=0;for(;;){const h=await e();if(h.ok||!TM(h.status,h.errorMessage)||o>=s)return h;const p=jM(o,a);o+=1,(c=t.onWaiting)==null||c.call(t,{attempt:o,maxRetries:s,waitMs:p}),await i(p)}}function RM(e={}){const t=e.limit??NM,i=e.windowMs??EM,s=e.sleep??US,a=e.now??(()=>Date.now()),o=[],c=()=>{const h=a()-i;for(;o.length&&o[0]<=h;)o.shift()};return async function(){var p;if(c(),o.length>=t){const d=o[0]+i-a();d>0&&((p=e.onWaiting)==null||p.call(e,{waitMs:d}),await s(d)),c()}o.push(a())}}const Mp=1024*1024;function cy(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 MM(e){const t=[.9,.8,.7,.6];for(const s of t)try{const a=await cy(e,"image/webp",s);if(a.type!=="image/webp")break;if(a.size<=Mp)return a}catch{break}const i=[.85,.7,.5];for(const s of i){const a=await cy(e,"image/jpeg",s);if(a.size<=Mp)return a}throw new Error("Cannot compress image under 1MB — reduce overlay count or image size")}const DM=["image/webp","image/jpeg"];function $S(e){return DM.includes(e.type)&&e.size<=Mp}async function BM(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 qu(e){if($S(e))return e;const t=await BM(e);return MM(t)}function LM(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 OM(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(LM):[]}async function zM(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 PM(e,t){const[i,s]=C.useState(null);return C.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 IM(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function HM(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 UM({image:e,authFetch:t}){const i=PM(`/api/codex/images/${encodeURIComponent(e.token)}`,t);return i?f.jsx("img",{src:i,alt:e.name,className:"w-16 h-16 flex-shrink-0 rounded border border-border object-cover bg-white"}):f.jsx("div",{className:"w-16 h-16 flex-shrink-0 rounded border border-border bg-surface"})}function $M({authFetch:e,cutId:t,onImport:i,onClose:s}){const[a,o]=C.useState(null),[c,h]=C.useState(null),[p,d]=C.useState(null),[x,_]=C.useState("");C.useEffect(()=>{let T=!1;return(async()=>{const L=await OM(e);T||o(L)})(),()=>{T=!0}},[e]);const b=x.trim().toLowerCase(),v=C.useMemo(()=>a?b?a.filter(T=>T.name.toLowerCase().includes(b)):a:[],[a,b]),y=Date.now(),E=async T=>{h(null),d(T.token);try{const L=await zM(e,T);await i(L)}catch(L){h(L instanceof Error?L.message:"Could not import the generated image")}finally{d(null)}},A=a!==null&&a.length>0;return f.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-2","data-testid":`codex-picker-${t}`,children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Import a Codex-generated image"}),f.jsx("button",{onClick:s,"data-testid":`codex-picker-close-${t}`,className:"text-[11px] text-muted hover:text-foreground",children:"Close"})]}),A&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"search",value:x,onChange:T=>_(T.target.value),placeholder:"Filter by file name…","data-testid":`codex-picker-search-${t}`,className:"min-w-0 flex-1 px-2 py-1 text-[11px] border border-border rounded bg-transparent focus:border-accent focus:outline-none"}),f.jsx("span",{className:"text-[10px] text-muted whitespace-nowrap","data-testid":`codex-picker-count-${t}`,children:b?`${v.length} of ${a.length}`:`${a.length} image${a.length===1?"":"s"}`})]}),a===null&&f.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-loading-${t}`,children:"Looking for generated images…"}),a!==null&&a.length===0&&f.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-empty-${t}`,children:"No generated images found in the Codex cache yet. Generate art in Codex, then reopen this list — or use “Upload clean image” to pick a file."}),A&&v.length===0&&f.jsxs("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-no-match-${t}`,children:["No generated images match “",x.trim(),"”."]}),A&&v.length>0&&f.jsx("ul",{className:"space-y-1 max-h-72 overflow-y-auto",children:v.map(T=>f.jsxs("li",{"data-testid":`codex-image-${T.token}`,className:"flex items-center gap-2 rounded border border-border bg-background/40 p-1.5",children:[f.jsx(UM,{image:T,authFetch:e}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("p",{className:"text-[11px] text-foreground",children:[HM(T.mtimeMs,y)," · ",IM(T.size)]}),f.jsx("p",{className:"truncate text-[10px] font-mono text-muted",title:T.name,children:T.name})]}),f.jsx("button",{onClick:()=>E(T),disabled:p!==null,"data-testid":`codex-import-${T.token}`,className:"px-2 py-1 text-[11px] border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:p===T.token?"Importing…":"Import to this cut"})]},T.token))}),c&&f.jsx("p",{className:"text-[11px] text-error",children:c})]})}const FM={done:"✓",current:"▸",todo:"○"};function qM({checklist:e,issues:t,onFinish:i,finishing:s,progressText:a,canFinish:o,markdownReady:c=!1,published:h=!1}){var E;if(!e||e.steps.length===0)return null;const p=PS(t),d=((E=e.steps.find(A=>A.key==="upload"))==null?void 0:E.status)==="done",x=d&&c&&!h,_=h||c?"done":d?"current":"todo",b=h?"done":x?"current":"todo",v=[...e.steps.filter(A=>A.key!=="publish"),{key:"assemble",label:"Episode sequence prepared",status:_,detail:null},{key:"ready",label:h?"Published to PlotLink":"Ready to publish",status:b,detail:null}],y=s?a||"Finishing…":h?"Published ✓":x?"Episode ready to publish":"Finish episode";return f.jsxs("div",{className:"px-3 py-2 border-b border-border bg-surface/50 space-y-2 flex-shrink-0","data-testid":"finish-episode-panel",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Finish episode"}),e.nextStep&&f.jsxs("span",{className:"text-[10px] text-muted truncate","data-testid":"finish-next-step",children:["Next: ",e.nextStep]})]}),f.jsx("ol",{className:"flex flex-wrap gap-1.5",children:v.map(A=>f.jsxs("li",{"data-testid":`finish-step-${A.key}`,"data-status":A.status,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${A.status==="current"?"border-accent/40 bg-accent/10 text-accent":A.status==="done"?"border-border bg-background/70 text-foreground":"border-border/70 bg-background/40 text-muted"}`,children:[f.jsx("span",{"aria-hidden":!0,children:FM[A.status]}),f.jsx("span",{children:A.label}),A.detail&&f.jsxs("span",{className:"text-muted",children:["· ",A.detail]})]},A.key))}),f.jsx("button",{onClick:i,disabled:s||!o,"data-testid":"finish-episode-btn",title:"Upload the exported final panels, then prepare the episode for publishing — picks up where it left off",className:"px-3 py-1 text-xs border border-accent/40 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:y}),p.length>0&&f.jsx("div",{className:"space-y-1.5","data-testid":"finish-issues",children:p.map(A=>f.jsxs("div",{"data-testid":`finish-issue-group-${A.key}`,className:"text-[10px]",children:[f.jsx("p",{className:"font-medium text-amber-700",children:A.title}),f.jsx("ul",{className:"ml-3 list-disc text-muted",children:A.lines.map((T,L)=>f.jsx("li",{children:T},L))})]},A.key))})]})}function WM(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 FS(e){return e.uploadedCid?"uploaded":e.finalImagePath||e.exportedAt?"lettered":e.cleanImagePath?"clean":kr(e)?"text":"missing"}const GM={muted:"text-muted",amber:"text-amber-700",green:"text-green-700",accent:"text-accent"},YM={muted:"bg-muted/40",amber:"bg-amber-500",green:"bg-green-600",accent:"bg-accent"};function KM(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"}:kr(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 VM({cut:e,storyName:t,plotFile:i,expanded:s,onToggle:a,authFetch:o,onUpdated:c,onOpenEditor:h,detectedLocalClean:p,onSyncClean:d,syncing:x,staleMessages:_,onRepairStale:b,repairing:v,conversionPng:y,onConvert:E,converting:A,rowRef:T}){var De;const L=C.useRef(null),[O,J]=C.useState(!1),[$,M]=C.useState(null),[X,he]=C.useState(!1),[ye,U]=C.useState(!1),[se,W]=C.useState(!1),[G,Z]=C.useState(!1),[I,j]=C.useState("manual"),[z,B]=C.useState(!1),_e=FS(e),N=_.length>0,R=!!y,Y=C.useCallback(async()=>{y&&(Z(!0),await E(e.id,y),Z(!1),c())},[y,E,e.id,c]),w=C.useCallback(async Ee=>{J(!0),M(null);try{let Be=Ee;if(!$S(Ee))try{Be=await qu(Ee)}catch(tt){return M(tt instanceof Error?tt.message:"Could not import image"),!1}const je=Be.type==="image/jpeg"?"jpg":"webp",Ze=new FormData;Ze.append("file",new File([Be],`clean.${je}`,{type:Be.type}));const we=await o(`/api/stories/${t}/cuts/${i}/upload-clean/${e.id}`,{method:"POST",body:Ze});if(!we.ok){const tt=await we.json();return M(tt.error||"Upload failed"),!1}return c(),!0}catch{return M("Upload failed"),!1}finally{J(!1)}},[o,t,i,e.id,c]),ae=KM(e,R,N),ie=e.cleanImagePath??y??null,oe=((De=e.overlays)==null?void 0:De.length)??0,F=!kr(e)&&!!e.cleanImagePath&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&!N&&!R,ue=C.useCallback(()=>{var Ee;(Ee=navigator.clipboard)==null||Ee.writeText(wM(e,i)),B(!0),setTimeout(()=>B(!1),2e3)},[e,i]),be=ae.key==="convert"?{label:G?"Converting…":"Convert image",onClick:Y,testid:`card-convert-${e.id}`}:ae.key==="review"?{label:"Review cut",onClick:h,testid:`card-review-${e.id}`}:ae.key==="text"?{label:"Add captions",onClick:h,testid:`card-letter-${e.id}`}:ae.key==="needs-image"?{label:"Add artwork",onClick:a,testid:`card-addart-${e.id}`}:null;return f.jsxs("div",{ref:T,"data-cut-row":e.id,className:`border rounded ${s?"border-accent/30":"border-border"}`,children:[f.jsxs("div",{className:"px-3 py-2 space-y-2","data-testid":`cut-card-${e.id}`,children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[f.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${YM[ae.tone]}`}),f.jsxs("span",{className:"font-medium text-xs text-foreground",children:["Cut ",String(e.id).padStart(2,"0")]}),f.jsxs("span",{className:"font-mono text-[10px] text-muted",children:["· ",e.shotType]}),f.jsx("span",{className:`ml-auto text-[10px] font-medium flex-shrink-0 ${GM[ae.tone]}`,"data-testid":`cut-card-status-${e.id}`,children:ae.label})]}),ie?f.jsx(Ap,{storyName:t,assetPath:ie,authFetch:o,alt:`Cut ${e.id} artwork`,className:"w-full max-h-44 object-contain rounded border border-border bg-white"}):f.jsx("div",{className:"w-full h-20 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:kr(e)?"Text panel — no artwork needed":"No artwork yet"}),f.jsx("button",{onClick:a,"data-testid":`cut-desc-${e.id}`,className:"block w-full text-left text-[11px] text-muted hover:text-foreground",children:e.description||"No description"}),F&&f.jsxs("div",{className:"space-y-1","data-testid":`lettering-${e.id}`,children:[f.jsx("div",{className:"text-[10px] font-medium text-muted uppercase tracking-wider",children:"Lettering"}),f.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-foreground",children:[f.jsx("input",{type:"radio",name:`lettering-mode-${e.id}`,checked:I==="manual",onChange:()=>j("manual"),"data-testid":`lettering-mode-manual-${e.id}`}),"Manual — I place bubbles myself"]}),f.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-foreground",children:[f.jsx("input",{type:"radio",name:`lettering-mode-${e.id}`,checked:I==="ai",onChange:()=>j("ai"),"data-testid":`lettering-mode-ai-${e.id}`}),"AI draft — ask the agent to place initial bubbles"]}),I==="ai"&&f.jsx("p",{className:"text-[10px] text-muted",children:"Paste it to your agent, then review the draft bubbles here and export the final cut."})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[F?I==="manual"?f.jsx("button",{onClick:h,"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:oe>0?"Review lettering":"Add speech bubbles"}):f.jsx("button",{onClick:ue,"data-testid":`copy-lettering-${e.id}`,className:"px-2.5 py-1 text-[11px] font-medium rounded border border-accent/40 text-accent hover:bg-accent/5",children:z?"Copied!":"Copy AI lettering prompt"}):be?f.jsx("button",{onClick:be.onClick,disabled:ae.key==="convert"&&(G||A),"data-testid":be.testid,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim disabled:opacity-50",children:be.label}):null,f.jsx("button",{onClick:a,"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:s?"Hide details":"Open details"})]})]}),s&&f.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border",children:[R&&f.jsxs("div",{className:"mt-2 rounded border border-amber-500/40 bg-amber-500/10 p-2 space-y-1","data-testid":`needs-conversion-${e.id}`,children:[f.jsx("p",{className:"text-[11px] text-amber-800",children:"This cut’s artwork is a PNG. Convert it to WebP so it can be lettered and published."}),f.jsx("button",{onClick:Y,disabled:G||A,"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:G?"Converting…":"Convert image"})]}),N&&!R&&f.jsxs("div",{className:"mt-2 rounded border border-error/40 bg-error/5 p-2 space-y-1","data-testid":`stale-asset-${e.id}`,children:[_.map((Ee,Be)=>f.jsx("p",{className:"text-[11px] text-error",children:Ee},Be)),f.jsx("button",{onClick:b,disabled:v,"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:v?"Repairing…":"Clear stale path"})]}),!kr(e)&&f.jsxs("div",{className:"mt-2 space-y-2",children:[f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(oy(e,i)),he(!0),setTimeout(()=>he(!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:X?"Copied!":"Copy Codex task"}),f.jsx("input",{ref:L,type:"file",accept:"image/webp,image/jpeg,image/png",className:"hidden",onChange:Ee=>{var je;const Be=(je=Ee.target.files)==null?void 0:je[0];Be&&w(Be),Ee.target.value=""}}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("button",{onClick:()=>{var Ee;return(Ee=L.current)==null?void 0:Ee.click()},disabled:O,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:O?"Uploading...":e.cleanImagePath?"Replace clean image":"Upload clean image"}),f.jsx("button",{onClick:()=>W(Ee=>!Ee),disabled:O,"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:se?"Hide Codex images":"Import from Codex"})]}),se&&f.jsx($M,{authFetch:o,cutId:e.id,onImport:async Ee=>{await w(Ee)&&W(!1)},onClose:()=>W(!1)}),!e.cleanImagePath&&f.jsx("p",{className:"text-xs text-muted","data-testid":`clean-image-handoff-${e.id}`,children:"Generate this cut in Codex, then import the cached PNG with “Import from Codex” — or upload an image manually. Letter it next."}),_e==="missing"&&f.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-1","data-testid":`ask-codex-${e.id}`,children:[f.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Generate this cut in Codex"}),f.jsxs("p",{className:"text-[10px] text-muted",children:["Copy the task below and paste it into Codex. Codex usually saves a PNG to its image cache — bring it into this cut with “Import from Codex” above (the PNG becomes a WebP automatically). If Codex instead writes a WebP/JPEG at"," ",f.jsxs("span",{className:"font-mono",children:["assets/",i,"/cut-",String(e.id).padStart(2,"0"),"-clean.webp"]}),", it’s picked up by “Sync clean images”."]}),f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(oy(e,i)),U(!0),setTimeout(()=>U(!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:ye?"Copied!":"Copy Codex task"})]}),_e==="missing"&&p&&f.jsx("button",{onClick:d,disabled:x,"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:x?"Syncing...":"Found local clean image — sync to cut plan"}),$&&f.jsx("p",{className:"text-xs text-error mt-1",children:$})]}),(e.cleanImagePath||e.narration||e.dialogue.length>0||kr(e))&&f.jsx("button",{onClick:h,"data-testid":`open-editor-${e.id}`,className:"px-3 py-1.5 text-xs border border-accent/30 text-accent rounded hover:bg-accent/5",children:"Open editor"}),e.characters.length>0&&f.jsxs("p",{className:"text-xs text-muted",children:["Characters: ",e.characters.join(", ")]}),e.dialogue.length>0&&f.jsx("div",{className:"text-xs text-muted",children:e.dialogue.map((Ee,Be)=>f.jsxs("p",{children:[f.jsxs("span",{className:"font-medium",children:[Ee.speaker,":"]})," ",Ee.text]},Be))}),e.narration&&f.jsx("p",{className:"text-xs text-muted italic",children:e.narration})]})]})}function uy({storyName:e,fileName:t,authFetch:i,language:s,uploadRetry:a,onCutsChanged:o,focusRequest:c,onFocusHandled:h}){var Gt,fn;const[p,d]=C.useState(null),x=C.useRef(o);x.current=o;const _=C.useRef(h);_.current=h;const[b,v]=C.useState(!0),[y,E]=C.useState(null),[A,T]=C.useState(null),[L,O]=C.useState(null),[J,$]=C.useState(!1),[M,X]=C.useState([]),[he,ye]=C.useState(!1),[U,se]=C.useState(""),[W,G]=C.useState({markdownReady:!1,published:!1}),[Z,I]=C.useState(!1),[j,z]=C.useState(!1),[B,_e]=C.useState(!1),[N,R]=C.useState(null),[Y,w]=C.useState(null),[ae,ie]=C.useState(new Set),[oe,F]=C.useState(new Map),[ue,be]=C.useState(!1),[De,Ee]=C.useState(null),[Be,je]=C.useState(!1),[Ze,we]=C.useState(null),tt=C.useRef(new Map),mt=C.useRef(null),Ge=t.replace(/\.md$/,"");C.useEffect(()=>{var de;c&&mt.current!==c.seq&&(mt.current=c.seq,c.openEditor?O(c.cutId):(T(c.cutId),we(c.cutId)),(de=_.current)==null||de.call(_))},[c]),C.useEffect(()=>{var Re;if(Ze==null)return;const de=tt.current.get(Ze);de&&((Re=de.scrollIntoView)==null||Re.call(de,{behavior:"smooth",block:"center"}),we(null))},[Ze,p]);const Ae=C.useCallback(async()=>{var de;try{const Re=await i(`/api/stories/${e}/cuts/${Ge}`);if(Re.status===404){d(null);return}if(!Re.ok){const st=await Re.json();E(st.error||"Failed to load cuts");return}const We=await Re.json();d(We),E(null);try{const st=await i(`/api/stories/${e}/${t}`);if(st.ok){const nt=await st.json(),te=typeof(nt==null?void 0:nt.content)=="string"?nt.content:"",Ce=Array.isArray(We==null?void 0:We.cuts)?We.cuts:[],Le=te.length>0&&OS(te,Ce).ready,ft=(nt==null?void 0:nt.status)==="published"||(nt==null?void 0:nt.status)==="published-not-indexed";G({markdownReady:Le,published:ft})}else G({markdownReady:!1,published:!1})}catch{G({markdownReady:!1,published:!1})}(de=x.current)==null||de.call(x)}catch{E("Failed to load cuts")}finally{v(!1)}},[i,e,Ge,t]),Ve=C.useCallback(async()=>{be(!1);try{const de=await i(`/api/stories/${e}/cuts/${Ge}/detect-clean-images`);if(!de.ok)return;const Re=await de.json();ie(new Set(Array.isArray(Re.detected)?Re.detected:[]));const We=new Map,st=Re.stale;if(Array.isArray(st))for(const nt of st){if(typeof(nt==null?void 0:nt.cutId)!="number"||typeof(nt==null?void 0:nt.message)!="string")continue;const te=We.get(nt.cutId)??[];te.push(nt.message),We.set(nt.cutId,te)}F(We),be(!0)}catch{}},[i,e,Ge]),Mt=C.useCallback(async()=>{Ee(null);try{const de=await i(`/api/stories/${e}/cuts/${Ge}/asset-diagnostics`);if(!de.ok)return;const Re=await de.json();Ee(Array.isArray(Re.diagnostics)?Re.diagnostics:null)}catch{}},[i,e,Ge]),zt=C.useCallback(async()=>{je(!0);try{await Promise.all([Ae(),Ve(),Mt()])}finally{je(!1)}},[Ae,Ve,Mt]),ai=C.useCallback(async()=>{I(!0),w(null),X([]);try{const de=await i(`/api/stories/${e}/cuts/${Ge}/sync-clean-images`,{method:"POST"}),Re=await de.json().catch(()=>({}));if(!de.ok)w(Re.error||"Sync failed");else{const We=Array.isArray(Re.synced)?Re.synced.length:0,st=Array.isArray(Re.cleared)?Re.cleared.length:0,nt=Array.isArray(Re.rejected)?Re.rejected:[];nt.length>0&&X(nt.map(Ce=>`Cut ${Ce.cutId}: ${Ce.reason}`));const te=[];We>0&&te.push(`Synced ${We}`),st>0&&te.push(`Cleared ${st} stale path${st===1?"":"s"}`),w(te.length>0?te.join(", "):"No new clean images"),await Ae(),await Ve(),await Mt()}}catch{w("Sync failed")}I(!1)},[i,e,Ge,Ae,Ve,Mt]),wt=C.useCallback(async(de,Re)=>{try{const We=await i(jS(e,Re));if(!We.ok)return!1;const st=await We.blob(),nt=await qu(new File([st],"clean.png",{type:st.type||"image/png"})),te=nt.type==="image/jpeg"?"jpg":"webp",Ce=new FormData;return Ce.append("file",new File([nt],`clean.${te}`,{type:nt.type})),(await i(`/api/stories/${e}/cuts/${Ge}/upload-clean/${de}`,{method:"POST",body:Ce})).ok}catch{return!1}},[i,e,Ge]),hi=C.useCallback(async de=>{_e(!0),R(null);let Re=0;const We=[];for(const st of de)await wt(st.cutId,st.pngPath)?Re++:We.push(st.cutId);await zt(),_e(!1),R(We.length===0?`Converted ${Re} image${Re===1?"":"s"} to WebP`:`Converted ${Re}; ${We.length} failed (Cut ${We.join(", ")}) — try Convert image on each`)},[wt,zt]),re=C.useCallback(async()=>{var nt;if(!p)return;ye(!0),se(""),X([]);const de=p.cuts.filter(te=>te.finalImagePath&&!te.uploadedCid),Re=[],We=RM({sleep:a==null?void 0:a.sleep,onWaiting:({waitMs:te})=>se(`Upload limit reached — waiting ${Math.round(te/1e3)}s before continuing…`)});for(let te=0;te<de.length;te++){const Ce=de[te];se(`Uploading cut ${Ce.id} (${te+1}/${de.length})...`);try{const Le=Ce.finalImagePath.startsWith("assets/")?Ce.finalImagePath.slice(7):Ce.finalImagePath,ft=await i(`/api/stories/${e}/asset/${Le}`);if(!ft.ok){Re.push(`Cut ${Ce.id}: failed to fetch asset`);continue}const bt=await ft.blob(),pt=new FormData;pt.append("file",bt,`cut-${Ce.id}.${bt.type==="image/webp"?"webp":"jpg"}`),await We();const Tt=await AM(async()=>{const Et=await i("/api/publish/upload-plot-image",{method:"POST",body:pt});if(Et.ok){const{cid:pi,url:fr}=await Et.json();return{ok:!0,status:Et.status,cid:pi,url:fr}}const $t=await Et.json().catch(()=>({}));return{ok:!1,status:Et.status,errorMessage:$t.error}},{...a,onWaiting:({attempt:Et,maxRetries:$t,waitMs:pi})=>se(`Cut ${Ce.id} rate-limited — waiting ${Math.round(pi/1e3)}s before retry ${Et}/${$t}...`)});if(!Tt.ok){Re.push(`Cut ${Ce.id}: upload failed — ${Tt.errorMessage||"unknown"}`);continue}const{cid:Je,url:ot}=Tt;(await i(`/api/stories/${e}/cuts/${Ge}/set-uploaded/${Ce.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cid:Je,url:ot})})).ok||Re.push(`Cut ${Ce.id}: failed to record upload`)}catch(Le){Re.push(`Cut ${Ce.id}: ${Le instanceof Error?Le.message:"failed"}`)}}if(Re.length>0){X(Re),ye(!1),se(""),Ae();return}se("Preparing episode for publishing…");const st=await i(`/api/stories/${e}/cuts/${Ge}/generate-markdown`,{method:"POST"});if(st.ok){const te=await st.json();((nt=te.warnings)==null?void 0:nt.length)>0&&X(te.warnings)}ye(!1),se(""),Ae()},[p,i,e,Ge,a,Ae]),xe=C.useCallback(async()=>{z(!0),w(null);try{const de=await i(`/api/stories/${e}/cuts/${Ge}/repair-asset-paths`,{method:"POST"}),Re=await de.json().catch(()=>({}));if(!de.ok)w(Re.error||"Repair failed");else{const We=Array.isArray(Re.cleared)?Re.cleared.length:0;w(We>0?`Cleared ${We} stale path${We===1?"":"s"}`:"No stale paths to clear"),await Ae(),await Ve()}}catch{w("Repair failed")}z(!1)},[i,e,Ge,Ae,Ve]),[Pe,Fe]=C.useState(!1),Qe=C.useCallback(async()=>{if(p){Fe(!0);try{const de=p.cuts.reduce((nt,te)=>Math.max(nt,te.id),0)+1,Re={id:de,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"},We={...p,cuts:[...p.cuts,Re]},st=await i(`/api/stories/${e}/cuts/${Ge}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(We)});if(st.ok)T(de),await Ae();else{const nt=await st.json().catch(()=>({}));w(nt.error||"Could not add text panel")}}catch{w("Could not add text panel")}Fe(!1)}},[p,i,e,Ge,Ae]);if(C.useEffect(()=>{Ae(),Ve(),Mt()},[Ae,Ve,Mt]),b)return f.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading cuts..."});if(y)return f.jsxs("div",{className:"p-4 space-y-2","data-testid":"cuts-error",children:[f.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),f.jsx("p",{className:"text-xs text-error",children:y}),f.jsxs("p",{className:"text-xs text-muted",children:[Ge,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema from the cartoon writing instructions."]}),f.jsx("button",{onClick:Ae,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]});if(!p||p.cuts.length===0)return f.jsxs("div",{className:"p-4 text-center space-y-1",children:[f.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),f.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]});const H=L!==null?p.cuts.find(de=>de.id===L):null;if(H)return f.jsx(_M,{storyName:e,cut:H,plotFile:Ge,language:s,authFetch:i,onSave:async de=>{const Re={...p,cuts:p.cuts.map(st=>st.id===L?{...st,overlays:de}:st)},We=await i(`/api/stories/${e}/cuts/${Ge}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Re)});if(!We.ok){const st=await We.json().catch(()=>({}));throw new Error(st.error||"Failed to save overlays")}},onExported:()=>Ae(),onClose:()=>{O(null),Ae()}});const ge=p.cuts.reduce((de,Re)=>{const We=FS(Re);return de[We]++,de},{missing:0,clean:0,lettered:0,uploaded:0,text:0}),Te=p.cuts.filter(de=>!kr(de)).length,me=p.cuts.filter(de=>BS(de)).map(de=>de.id),He=Q3({cuts:p.cuts,published:W.published}),Oe=((Gt=He.steps.find(de=>de.key==="upload"))==null?void 0:Gt.status)==="done",ut=p.cuts.some(de=>de.finalImagePath&&!de.uploadedCid)||Oe&&!W.markdownReady,it=(De??[]).filter(de=>de.state==="needs-conversion"&&de.convertiblePng).map(de=>({cutId:de.cutId,pngPath:de.convertiblePng})),Dt=new Map(it.map(de=>[de.cutId,de.pngPath])),Bt=(De??[]).filter(de=>de.state==="needs-conversion"&&de.issue).map(de=>de.issue),di=t==="genesis.md"?"Genesis / Episode 1":`Episode ${parseInt(((fn=Ge.match(/\d+/))==null?void 0:fn[0])??"0",10)+1}`,kt=typeof p.title=="string"?p.title:null,Ci=p.cuts.filter(de=>!kr(de)),fi={cuts:p.cuts.length,artwork:Ci.filter(de=>de.cleanImagePath||Dt.has(de.id)).length,converted:Ci.filter(de=>de.cleanImagePath&&/\.(webp|jpe?g)$/i.test(de.cleanImagePath)).length,lettered:p.cuts.filter(de=>{var Re;return(((Re=de.overlays)==null?void 0:Re.length)??0)>0||!!de.finalImagePath}).length,uploaded:p.cuts.filter(de=>de.uploadedCid||de.uploadedUrl).length};return f.jsxs("div",{className:"h-full min-h-[22rem] flex flex-col overflow-hidden","data-testid":"cut-list-panel",children:[f.jsxs("div",{className:"px-3 py-2 border-b border-border flex-shrink-0","data-testid":"cut-board-header",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:"font-serif text-foreground truncate",children:di}),kt&&f.jsxs("span",{className:"text-muted truncate",children:["· ",kt]})]}),f.jsxs("div",{className:"mt-0.5 text-[10px] text-muted","data-testid":"cut-board-summary",children:[fi.cuts," cuts · ",fi.artwork," artwork found · ",fi.converted," converted · ",fi.lettered," lettered · ",fi.uploaded," uploaded"]})]}),f.jsxs("details",{className:"border-b border-border flex-shrink-0","data-testid":"cut-advanced",children:[f.jsx("summary",{className:"px-3 py-1.5 text-[10px] text-muted cursor-pointer hover:text-foreground",children:"Technical details"}),f.jsxs("div",{className:"px-3 py-2 flex flex-wrap items-center gap-2 text-[10px]",children:[f.jsxs("span",{className:"font-mono text-muted",children:[p.cuts.length," cuts"]}),ge.missing>0&&f.jsxs("span",{className:"text-muted",children:[ge.missing," missing"]}),ge.clean>0&&f.jsxs("span",{className:"text-green-700",children:[ge.clean," clean"]}),ge.lettered>0&&f.jsxs("span",{className:"text-amber-700",children:[ge.lettered," lettered"]}),ge.uploaded>0&&f.jsxs("span",{className:"text-green-700",children:[ge.uploaded," uploaded"]}),ge.text>0&&f.jsxs("span",{className:"text-accent",children:[ge.text," text ",ge.text===1?"panel":"panels"]}),f.jsx("button",{onClick:async()=>{$(!0),X([]);try{const de=await i(`/api/stories/${e}/cuts/${Ge}/generate-markdown`,{method:"POST"});if(de.ok){const Re=await de.json();X(Re.warnings||[])}}catch{}$(!1)},disabled:J,className:"ml-auto px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"generate-markdown-btn",title:"Build the publish-ready episode from the uploaded cut images",children:J?"Preparing…":"Prepare episode for publish"}),f.jsx("button",{onClick:Qe,disabled:Pe,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:Pe?"Adding…":"Add narration/text panel"}),f.jsx("button",{onClick:zt,disabled:Be,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:Be?"Checking…":"Refresh assets"}),f.jsx("button",{onClick:ai,disabled:Z,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:Z?"Syncing...":"Sync clean images"}),f.jsx("button",{onClick:re,disabled:he||!(p!=null&&p.cuts.some(de=>de.finalImagePath&&!de.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:U||"Upload & Prepare for Publish"})]})]}),f.jsxs("div",{className:"px-3 py-2 border-b border-border bg-surface/40 flex-shrink-0","data-testid":"cartoon-workflow-help",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted",children:[f.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"1. Letter"}),f.jsx("span",{"aria-hidden":!0,children:"→"}),f.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"2. Export"}),f.jsx("span",{"aria-hidden":!0,children:"→"}),f.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"3. Upload"}),f.jsx("span",{"aria-hidden":!0,children:"→"}),f.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"4. Prepare episode for publish"})]}),f.jsxs("div",{className:"mt-1 text-[10px] text-muted",children:["Use ",f.jsx("span",{className:"text-accent",children:"Add narration/text panel"})," for a narration or title card. It becomes a solid card exported as a final image."]})]}),me.length>0&&f.jsxs("div",{className:"px-3 py-1.5 border-b border-amber-500/40 bg-amber-500/10 text-[10px] text-amber-700 flex-shrink-0","data-testid":"stale-bubble-export-warning",children:[me.length===1?"Cut":"Cuts"," ",me.join(", ")," ",me.length===1?"was":"were"," lettered with an older speech-bubble style whose tail can show a visible seam. Re-export ",me.length===1?"it":"them"," (open lettering → Export) and re-upload before publishing so the bubble tails are seamless."]}),ue&&Te>0&&ge.missing===0&&oe.size===0&&f.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:[f.jsx("span",{"aria-hidden":!0,children:"✓"}),f.jsxs("span",{children:["All ",Te," clean image",Te===1?"":"s"," present — clean-asset generation is complete. Ready for lettering in OWS."]})]}),Y&&f.jsx("div",{className:"px-3 py-1 border-b border-border text-[10px] text-muted flex-shrink-0","data-testid":"sync-result",children:Y}),it.length>0&&f.jsxs("div",{className:"px-3 py-2 border-b border-amber-500/40 bg-amber-500/10 text-[11px] flex-shrink-0","data-testid":"convert-artwork",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("span",{className:"font-medium text-amber-700","data-testid":"convert-artwork-count",children:[it.length," PNG image",it.length===1?"":"s"," found"]}),f.jsx("button",{onClick:()=>hi(it),disabled:B,"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:B?"Converting…":"Convert all to WebP"})]}),f.jsx("p",{className:"mt-1 text-[10px] text-muted",children:"PNG artwork is fine while drafting. Convert it before lettering/export so PlotLink can publish it safely."}),N&&f.jsx("p",{className:"mt-1 text-[10px] text-muted","data-testid":"convert-result",children:N}),Bt.length>0&&f.jsxs("details",{className:"mt-1","data-testid":"convert-technical-details",children:[f.jsx("summary",{className:"text-[10px] text-muted cursor-pointer",children:"Technical details"}),f.jsx("ul",{className:"mt-1 ml-3 list-disc text-[10px] text-muted",children:Bt.map((de,Re)=>f.jsx("li",{children:de},Re))})]})]}),De&&De.length>0&&(()=>{const de=WM(De),Re=De.filter(We=>We.state==="missing");return f.jsxs("div",{className:"px-3 py-1.5 border-b border-border bg-surface/40 text-[10px] flex-shrink-0","data-testid":"asset-diagnostics",children:[f.jsxs("span",{className:"text-muted","data-testid":"asset-diag-summary",children:["Assets: ",de.uploaded," uploaded · ",de.finalReady," final · ",de.cleanReady," clean · ",de.planned," planned",de.needsConversion>0?` · ${de.needsConversion} needs conversion`:"",de.missing>0?` · ${de.missing} missing`:""]}),Re.length>0&&f.jsx("ul",{className:"mt-1 ml-3 list-disc text-error","data-testid":"asset-diag-issues",children:Re.map(We=>f.jsx("li",{children:We.issue},We.cutId))})]})})(),f.jsx(qM,{checklist:He,issues:M,onFinish:re,finishing:he,progressText:U,canFinish:ut,markdownReady:W.markdownReady,published:W.published}),f.jsx("div",{className:"flex-1 min-h-56 overflow-y-auto p-3 space-y-2","data-testid":"cut-list-scroll",children:p.cuts.map(de=>f.jsx(VM,{cut:de,storyName:e,plotFile:Ge,expanded:A===de.id,onToggle:()=>T(A===de.id?null:de.id),authFetch:i,onUpdated:()=>{Ae(),Ve(),Mt()},onOpenEditor:()=>O(de.id),detectedLocalClean:ae.has(de.id),onSyncClean:ai,syncing:Z,staleMessages:oe.get(de.id)??[],onRepairStale:xe,repairing:j,conversionPng:Dt.get(de.id)??null,onConvert:wt,converting:B,rowRef:Re=>{Re?tt.current.set(de.id,Re):tt.current.delete(de.id)}},de.id))})]})}function qS({coach:e,onAction:t,className:i=""}){const[s,a]=C.useState(null),o=s!==null&&s===(e==null?void 0:e.prompt);return e?f.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 bg-accent/5 border-b border-accent/30 text-xs ${i}`,"data-testid":"workflow-coach","data-stage":e.stageLabel,"data-action-kind":e.actionKind,"data-ui-action":e.uiAction??"",children:[f.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-accent flex-shrink-0","data-testid":"workflow-coach-stage",children:e.stageLabel}),f.jsxs("span",{className:"min-w-0 flex-1 text-foreground","data-testid":"workflow-coach-action",children:[f.jsx("span",{className:"text-muted",children:"Next: "}),f.jsx("span",{className:"font-medium",children:e.action})]}),e.actionKind==="agent"&&e.prompt?f.jsx("button",{onClick:()=>{var h;if(!e.prompt)return;const c=e.prompt;(h=navigator.clipboard)==null||h.writeText(c).then(()=>a(c)).catch(()=>{})},"data-testid":"workflow-coach-copy",className:"flex-shrink-0 rounded bg-accent px-2.5 py-1 text-[11px] font-medium text-white hover:bg-accent-dim transition-colors",children:o?"Copied!":"Copy prompt"}):e.actionKind==="ui"&&e.uiAction?f.jsx("button",{onClick:()=>t(e.uiAction,e.episodeFile),"data-testid":"workflow-coach-do",className:"flex-shrink-0 rounded bg-accent px-2.5 py-1 text-[11px] font-medium text-white hover:bg-accent-dim transition-colors",children:e.action}):null]}):null}function XM({storyName:e,fileName:t,authFetch:i,refreshKey:s=0,onAction:a}){const[o,c]=C.useState(null),h=JSON.stringify([e,t??"",s]),[p,d]=C.useState(null);return p!==h&&(c(null),d(h)),C.useEffect(()=>{let x=!1;const _=t?`?focus=${encodeURIComponent(t)}`:"";return i(`/api/stories/${e}/progress${_}`).then(b=>b.ok?b.json():null).then(b=>{x||c((b==null?void 0:b.coach)??null)}).catch(()=>{}),()=>{x=!0}},[e,t,i,s]),f.jsx(qS,{coach:o,onAction:a})}const ZM=1024*1024,QM=["image/webp","image/jpeg"],JM="Cover: WebP or JPEG, max 1MB, 600×900 portrait recommended. Use clean cover art — avoid unreadable AI text or broken lettering.";function eD(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 hy(e){return e.size>ZM?"Image exceeds 1MB limit":QM.includes(e.type)?null:"Only WebP and JPEG images are accepted"}async function tD(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 Dp(e){const t=e.match(/^#\s+(.+)$/m),i=t?t[1].trim():"";return i||null}function iD(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function jo(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 nD(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 Bp(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 gm(e){var s;const t=Dp(e.fileContent);if(t)return!Bp(t);const i=((s=e.episodeTitle)==null?void 0:s.trim())||null;return!!i&&!Bp(i)}function _m(e){const{fileName:t,fileContent:i,storySlug:s,structureContent:a,contentType:o,episodeTitle:c}=e,h=Dp(i);if(t==="genesis.md"){const p=a?Dp(a):null;return(h??p??iD(s)).slice(0,60)}if(h)return h.slice(0,60);if(o==="cartoon"){const p=c==null?void 0:c.trim(),d=nD(t);return((p||d)??t.replace(/\.md$/,"")).slice(0,60)}return t.replace(/\.md$/,"").slice(0,60)}function rD(e){return!!(e!=null&&e.txHash)&&(e==null?void 0:e.plotIndex)!=null&&e.plotIndex>0}function sD(e){return rD(e)&&(e==null?void 0:e.status)!=="published-not-indexed"}function dy(e,t,i){if(e[t]==="cartoon"&&!i)return"cartoon"}function aD(e,t,i){return!(e!=="cartoon"||t||!i||i.startsWith("_new_"))}function Rf(e,t,i){if(e)return t[e]||i.get(e)||"fiction"}function Mf(e){if(!e)return null;const t=Number(e);return Number.isFinite(t)?(t/1e18).toFixed(6):null}function lD(e){return!!e&&e.ready===!1}function oD(e){const t=Mf(e.requiredBalance)??Mf(e.creationFee),i=Mf(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 cD={...ol,attributes:{...ol.attributes,img:["src","alt","title"]}},uD="https://ipfs.filebase.io/ipfs/";function hD(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 dD(e){const t=hD(e),i=[];for(const a of t)a.url.startsWith(uD)||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 fD({storyName:e,fileName:t,authFetch:i,onPublish:s,publishingFile:a,walletAddress:o,contentType:c="fiction",language:h,genre:p,isNsfw:d,hasGenesis:x=!1,onViewProgress:_,onOpenFile:b,onViewPublish:v}){const[y,E]=C.useState(null),[A,T]=C.useState(!1),[L,O]=C.useState("preview"),[J,$]=C.useState("publish"),[M,X]=C.useState("text"),[he,ye]=C.useState(null),U=C.useCallback((ee,Se)=>{O("edit"),ye(Ne=>({cutId:ee,openEditor:Se,seq:((Ne==null?void 0:Ne.seq)??0)+1}))},[]),[se,W]=C.useState(""),[G,Z]=C.useState(!1),[I,j]=C.useState(!1),[z,B]=C.useState(!1),[_e,N]=C.useState(null),[R,Y]=C.useState(""),[w,ae]=C.useState(""),[ie,oe]=C.useState(!1),[F,ue]=C.useState(null),[be,De]=C.useState(0),[Ee,Be]=C.useState(0),[je,Ze]=C.useState(null),[we,tt]=C.useState(null),[mt,Ge]=C.useState(null),[Ae,Ve]=C.useState(0),Mt=C.useRef(null),zt=C.useRef(!1),[ai,wt]=C.useState(!1),[hi,re]=C.useState(rl[0]),[xe,Pe]=C.useState(Xr[0]),[Fe,Qe]=C.useState(!1),[H,ge]=C.useState(null),[Te,me]=C.useState(null),[He,Oe]=C.useState(!1),[ut,it]=C.useState(!1),[Dt,Bt]=C.useState(!1),[di,kt]=C.useState(null),[Ci,fi]=C.useState(!1),Gt=C.useRef(null),fn=C.useRef(null),[de,Re]=C.useState(!1),[We,st]=C.useState(null),[nt,te]=C.useState(null),[Ce,Le]=C.useState("unknown"),ft=C.useRef(!1),[bt,pt]=C.useState(!1),[Tt,Je]=C.useState(!1),[ot,Xe]=C.useState(null),[Et,$t]=C.useState([]),[pi,fr]=C.useState(null),pn=C.useRef(null),jr=C.useRef(null),mi=C.useCallback(async()=>{if(!e||!t){E(null);return}const ee=`${e}/${t}`,Se=jr.current!==ee;Se&&(jr.current=ee);try{const Ne=await i(`/api/stories/${e}/${t}`);if(Ne.ok){const Ke=await Ne.json();E(Ke),(Se||!zt.current)&&(W(Ke.content??""),Se&&(j(!1),zt.current=!1))}}catch{}},[e,t,i]);C.useEffect(()=>{T(!0),mi().finally(()=>T(!1))},[mi]),C.useEffect(()=>{if(!e||!t||L==="edit"&&I)return;const ee=setInterval(mi,3e3);return()=>clearInterval(ee)},[e,t,mi,L,I]);const[li,Pn]=C.useState(null),nr=c==="cartoon"&&t==="genesis.md";C.useEffect(()=>{if(!nr||!e){Pn(null);return}let ee=!1;return i(`/api/stories/${e}/cuts/genesis`).then(Se=>Se.ok?Se.json():null).then(Se=>{ee||Pn(Se?Rp(Se.cuts||[]):null)}).catch(()=>{ee||Pn(null)}),()=>{ee=!0}},[nr,e,i]);const ct=c==="cartoon"&&!!t&&/^plot-\d+\.md$/.test(t);C.useEffect(()=>{if(!ct||!e||!t){ue(null),De(0),Be(0),Ze(null);return}let ee=!1;const Se=t.replace(/\.md$/,"");return Ze(null),(async()=>{try{const[Ne,Ke]=await Promise.all([i(`/api/stories/${e}/${t}`),i(`/api/stories/${e}/cuts/${Se}`)]);if(ee)return;if(!Ke.ok){ue("error"),De(0),Be(0),Ze(null);return}const Nt=await Ke.json(),gi=Nt.cuts||[],En=Ne.ok?(await Ne.json()).content??"":"",an=zS(En,gi);ee||(ue(an.stage),De(an.awaitingCount),Be(an.totalCuts),Ze(Rp(gi)),Ge(typeof Nt.title=="string"?Nt.title:null))}catch{ee||(ue("error"),De(0),Be(0),Ze(null))}})(),()=>{ee=!0}},[ct,e,t,i,y==null?void 0:y.content,y==null?void 0:y.status,Ae]),C.useEffect(()=>{if(!e){tt(null);return}let ee=!1;return i(`/api/stories/${e}/structure.md`).then(Se=>Se.ok?Se.json():null).then(Se=>{ee||tt((Se==null?void 0:Se.content)??null)}).catch(()=>{}),()=>{ee=!0}},[e,i]),C.useEffect(()=>{if(!e)return;const ee=bu(p);let Se=ee??"";if(!ee&&we){const Ke=we.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);Ke&&(Se=bu(Ke[1].replace(/\*+/g,"").trim())??"")}Y(Se);let Ne=h&&Xr.find(Ke=>Ke.toLowerCase()===h.toLowerCase())||"";if(!Ne&&we){const Ke=we.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);Ke&&(Ne=Xr.find(Nt=>Nt.toLowerCase()===Ke[1].replace(/\*+/g,"").trim().toLowerCase())||"")}ae(Ne),oe(d??!1)},[e,p,h,d,we]);const In=C.useCallback(ee=>{e&&i(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}).catch(()=>{})},[e,i]),rr=C.useCallback(async()=>{if(!(!e||!t)){Z(!0);try{(await i(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:se})})).ok&&(j(!1),zt.current=!1,E(Se=>Se&&{...Se,content:se}))}catch{}Z(!1)}},[e,t,i,se]),tn=C.useCallback(async()=>{if(!e||!t)return;const ee=t.replace(/\.md$/,"");try{(await i(`/api/stories/${e}/cuts/${ee}/generate-markdown`,{method:"POST"})).ok&&(await mi(),Ve(Ne=>Ne+1))}catch{}},[e,t,i,mi]),Hn=C.useCallback((ee,Se)=>{if(ee==="view-progress"){_==null||_();return}if(Se&&Se!==t){b==null||b(Se);return}switch(ee){case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":O("edit"),X("cuts");break;case"generate-markdown":tn();break;case"publish":O("preview");break}},[t,_,b,tn]),Xt=C.useCallback(ee=>{var Ke;const Se=(Ke=ee.target.files)==null?void 0:Ke[0];if(!Se)return;ft.current=!0,st(null),te(null);const Ne=hy(Se);if(Ne){ge(null),me(Nt=>(Nt&&URL.revokeObjectURL(Nt),null)),Gt.current&&(Gt.current.value=""),kt(Ne),Le("invalid");return}ge(Se),me(Nt=>(Nt&&URL.revokeObjectURL(Nt),URL.createObjectURL(Se))),kt(null),Le("selected")},[]),Un=C.useCallback(async ee=>{var Ne;const Se=(Ne=ee.target.files)==null?void 0:Ne[0];if(fn.current&&(fn.current.value=""),!(!Se||!e)){ft.current=!0,st(null),Re(!0),kt(null);try{let Ke;try{Ke=await qu(Se)}catch(lr){ge(null),me(Ls=>(Ls&&URL.revokeObjectURL(Ls),null)),kt(lr instanceof Error?lr.message:"Could not import image");return}const Nt=Ke.type==="image/jpeg"?"jpg":"webp",gi=new File([Ke],`cover.${Nt}`,{type:Ke.type}),En=new FormData;En.append("file",gi);const an=await i(`/api/stories/${e}/import-cover`,{method:"POST",body:En});if(!an.ok){const lr=await an.json().catch(()=>({}));kt(lr.error||"Cover import failed");return}ge(gi),me(lr=>(lr&&URL.revokeObjectURL(lr),URL.createObjectURL(gi))),te(null),Le("selected"),kt(null)}catch{kt("Cover import failed")}finally{Re(!1)}}},[e,i]),ts=C.useCallback(async ee=>{if(ee.size>1024*1024){Xe("Image exceeds 1MB limit");return}if(!["image/webp","image/jpeg"].includes(ee.type)){Xe("Only WebP and JPEG images are accepted");return}Je(!0),Xe(null);try{const Ne=new FormData;Ne.append("file",ee);const Ke=await i("/api/publish/upload-plot-image",{method:"POST",body:Ne});if(!Ke.ok){const gi=await Ke.json();throw new Error(gi.error||"Upload failed")}const Nt=await Ke.json();$t(gi=>[...gi,{cid:Nt.cid,url:Nt.url}])}catch(Ne){Xe(Ne instanceof Error?Ne.message:"Upload failed")}finally{Je(!1),pn.current&&(pn.current.value="")}},[i]),ha=C.useCallback(ee=>{var Ne;const Se=(Ne=ee.target.files)==null?void 0:Ne[0];Se&&ts(Se)},[ts]),pr=C.useCallback(async()=>{if(y!=null&&y.storylineId){Oe(!0),kt(null),fi(!1);try{let ee;if(H){const Ne=new FormData;Ne.append("file",H);const Ke=await i("/api/publish/upload-cover",{method:"POST",body:Ne});if(!Ke.ok){const gi=await Ke.json();throw new Error(gi.error||"Cover upload failed")}ee=(await Ke.json()).cid}const Se=await i("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:y.storylineId,...ee!==void 0&&{coverCid:ee},genre:hi,language:xe,isNsfw:Fe})});if(!Se.ok){const Ne=await Se.json();throw new Error(Ne.error||"Update failed")}fi(!0),ge(null),ee!==void 0&&(Bt(!0),me(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),Le("unknown"),Gt.current&&(Gt.current.value="")),setTimeout(()=>fi(!1),3e3)}catch(ee){kt(ee instanceof Error?ee.message:"Update failed")}finally{Oe(!1)}}},[y==null?void 0:y.storylineId,H,hi,xe,Fe,i]);C.useEffect(()=>{wt(!1),ge(null),me(null),kt(null),fi(!1),it(!1),pt(!1),$t([]),Xe(null),st(null),te(null),Le("unknown"),ft.current=!1,X("text")},[e,t]),C.useEffect(()=>{if(t!=="genesis.md"||!e||!y||y.storylineId||y.status==="published"||y.status==="published-not-indexed"||ft.current)return;let ee=!1;return(async()=>{try{const Se=await i(`/api/stories/${e}/cover-asset`);if(ee||!Se.ok)return;const Ne=await Se.json();if(ee)return;if(!(Ne!=null&&Ne.found)){Le("none");return}if(!Ne.valid){te(Ne.error||"Detected cover asset is invalid and was not used"),Le("invalid");return}const Ke=await i(`/api/stories/${e}/asset/${Ne.path.replace(/^assets\//,"")}`);if(ee||!Ke.ok)return;const Nt=await Ke.blob(),gi=new File([Nt],Ne.path.split("/").pop()||"cover.webp",{type:Ne.type});if(hy(gi)||ee||ft.current)return;ge(gi),me(En=>(En&&URL.revokeObjectURL(En),URL.createObjectURL(gi))),st(Ne.path),Le("detected")}catch{}})(),()=>{ee=!0}},[e,t,y,y==null?void 0:y.status,y==null?void 0:y.storylineId,i]),C.useEffect(()=>{if(!ai||!(y!=null&&y.storylineId))return;it(!1);const ee="https://plotlink.xyz";let Se=!1;return fetch(`${ee}/api/storyline/${y.storylineId}`).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{if(!Se){if(!Ne){kt("Could not load current story metadata");return}if(Ne.genre){const Ke=bu(Ne.genre);Ke&&re(Ke)}if(Ne.language){const Ke=Xr.find(Nt=>Nt.toLowerCase()===Ne.language.toLowerCase());Ke&&Pe(Ke)}Ne.isNsfw!==void 0&&Qe(!!Ne.isNsfw),Bt(!!(Ne.coverCid||Ne.coverUrl||Ne.cover)),it(!0)}}).catch(()=>{Se||kt("Could not load current story metadata")}),()=>{Se=!0}},[ai,y==null?void 0:y.storylineId]),C.useEffect(()=>{if(L!=="edit")return;const ee=Se=>{(Se.metaKey||Se.ctrlKey)&&Se.key==="s"&&(Se.preventDefault(),rr())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[L,rr]),C.useEffect(()=>{if((y==null?void 0:y.status)!=="published-not-indexed"||!y.publishedAt)return;const ee=new Date(y.publishedAt).getTime(),Se=300*1e3,Ne=()=>{const Nt=Math.max(0,Se-(Date.now()-ee));N(Nt)};Ne();const Ke=setInterval(Ne,1e3);return()=>clearInterval(Ke)},[y==null?void 0:y.status,y==null?void 0:y.publishedAt]);const Ar=_e!==null&&_e<=0,nn=_e!==null&&_e>0?`${Math.floor(_e/6e4)}:${String(Math.floor(_e%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),f.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(A&&!y)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const da=(L==="edit"?se:(y==null?void 0:y.content)??"").length,Ki=t==="genesis.md",sr=t?/^plot-\d+\.md$/.test(t):!1,Vi=c==="cartoon"&&sr,rn=c==="cartoon"&&Ki,fa=rn||Vi,ki=(y==null?void 0:y.status)==="published"||(y==null?void 0:y.status)==="published-not-indexed",pa=rn?li?li.total:null:Vi?F===null?null:Ee:null,ma=eM({fileName:t??"",contentType:c,hasGenesis:x,isPublished:ki,cutCount:pa,cutProgress:rn?li:null}),ga=(rn||Vi)&&!ki,$n=ga?_m({fileName:t,fileContent:(y==null?void 0:y.content)??"",storySlug:e??"",structureContent:we,contentType:"cartoon",episodeTitle:mt}):null,_a=!!$n&&jo($n,t),fl=Vi&&!ki&&!gm({fileContent:(y==null?void 0:y.content)??"",episodeTitle:mt}),Fn=rn&&!ki?pm((y==null?void 0:y.content)??""):null,Po=!!Fn&&Fn.blockers.length>0,Io="w-full max-w-[32rem] rounded-xl border px-3 py-3",Ho={muted:"text-muted",accent:"text-accent",error:"text-error",success:"text-green-700"},xa=ee=>{if(!rn)return null;const Se=eD({hasSelectedCover:!!H,invalid:Ce==="invalid",attached:ee});return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"cartoon-cover-status","data-state":Se.state,children:[f.jsx("span",{className:`text-[11px] font-medium ${Ho[Se.tone]}`,children:Se.label}),f.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cover-details",children:[f.jsx("summary",{className:"cursor-pointer select-none",children:"Cover tips"}),f.jsx("span",{className:"block mt-0.5","data-testid":"cartoon-cover-guidance",children:JM})]})]})},pl=_a||fl,Wu=()=>{if(!ga||!$n)return null;const ee=Ki?"Story title":"Episode title";return f.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"publish-title-preview","data-raw":_a?"true":"false","data-blocked":pl?"true":"false",children:[f.jsxs("span",{className:"text-[11px] text-foreground",children:[f.jsxs("span",{className:"font-medium",children:[ee,":"]})," ",f.jsx("span",{className:pl?"text-error font-medium":"text-foreground",children:$n})]}),_a?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",Ki?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," before publishing."]}):fl?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",$n,"” 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]})},ba=()=>Fn?f.jsxs("div",{className:"flex flex-col gap-1 rounded border border-border bg-surface/50 p-2","data-testid":"cartoon-genesis-readiness","data-blocked":Po?"true":"false",children:[f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),f.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),Fn.blockers.map((ee,Se)=>f.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:ee},`b-${Se}`)),Fn.warnings.map((ee,Se)=>f.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:ee},`w-${Se}`))]}):null,sn=Ki||sr?1e4:null,is=!ki&&sn!==null&&da>sn,ml=(y==null?void 0:y.content)??"",ar=ki?{count:0,warnings:[]}:dD(ml),Rr=f.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[f.jsx("textarea",{ref:Mt,value:se,onChange:ee=>{W(ee.target.value),j(!0),zt.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}),f.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[f.jsx("span",{className:"text-xs text-muted",children:I?"Unsaved changes":"No changes"}),f.jsx("button",{onClick:rr,disabled:!I||G,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:G?"Saving...":"Save"})]})]});return f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"border-b border-border",children:[f.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[_&&f.jsx("button",{onClick:_,"data-testid":"view-progress-btn",className:"text-accent hover:underline font-sans",title:"Story progress overview",children:"← Progress"}),f.jsxs("span",{children:[e,"/",t]}),(y==null?void 0:y.status)==="published"&&f.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(y==null?void 0:y.status)==="published-not-indexed"&&f.jsx("span",{className:"text-amber-700 font-medium",title:y.indexError,children:"Published (not indexed)"}),(y==null?void 0:y.status)==="pending"&&f.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:`text-xs font-mono ${is?"text-error font-medium":"text-muted"}`,children:[da.toLocaleString(),sn!==null?`/${sn.toLocaleString()}`:" chars"]}),is&&f.jsxs("span",{className:"text-error text-xs font-medium",children:[(da-sn).toLocaleString()," over limit"]})]})]}),f.jsxs("div",{className:"flex px-3 gap-1",children:[f.jsx("button",{onClick:()=>O("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${L==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),f.jsxs("button",{onClick:()=>O("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${L==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",I&&f.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),c==="cartoon"&&e&&t&&f.jsx(XM,{storyName:e,fileName:t,authFetch:i,refreshKey:Ae,onAction:Hn}),L==="preview"?Vi?f.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[f.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[f.jsx("button",{"data-testid":"cartoon-mode-publish",onClick:()=>$("publish"),className:`px-2 py-0.5 text-[11px] rounded ${J==="publish"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Publish Preview"}),f.jsx("button",{"data-testid":"cartoon-mode-inspect",onClick:()=>$("inspect"),className:`px-2 py-0.5 text-[11px] rounded ${J==="inspect"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cut Inspector"})]}),f.jsx("div",{className:"flex-1 min-h-0",children:J==="publish"?f.jsx(rM,{content:(y==null?void 0:y.content)??"",stage:F}):f.jsx(U3,{storyName:e,fileName:t,authFetch:i,onEditCut:U})})]}):f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:y!=null&&y.content?f.jsx("div",{className:"prose max-w-none",children:f.jsx(Z0,{remarkPlugins:[J0,wS],rehypePlugins:[[NS,cD]],children:y.content})}):f.jsx("p",{className:"text-muted italic",children:"No content"})}):Vi?f.jsx("div",{className:"flex-1 min-h-[22rem] overflow-hidden",style:{background:"var(--paper-bg)"},children:f.jsx(uy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>Ve(ee=>ee+1),focusRequest:he,onFocusHandled:()=>ye(null)})}):rn?f.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[f.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[f.jsx("button",{"data-testid":"genesis-edit-mode-text",onClick:()=>X("text"),className:`px-2 py-0.5 text-[11px] rounded ${M==="text"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Opening text"}),f.jsx("button",{"data-testid":"genesis-edit-mode-cuts",onClick:()=>X("cuts"),className:`px-2 py-0.5 text-[11px] rounded ${M==="cuts"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cuts"})]}),f.jsx("div",{className:"flex-1 min-h-0",children:M==="cuts"?f.jsx(uy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>Ve(ee=>ee+1),focusRequest:he,onFocusHandled:()=>ye(null)}):Rr})]}):Rr,f.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?f.jsx("p",{className:"text-muted text-xs italic","data-testid":"footer-guidance",children:ma}):(y==null?void 0:y.status)==="published-not-indexed"?f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Ar&&f.jsx("button",{onClick:async()=>{if(!(!e||!t||!y.txHash)){B(!0);try{(await(await i("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:y.txHash,content:y.content,storylineId:y.storylineId})})).json()).ok&&(await i(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:y.txHash,storylineId:y.storylineId,contentCid:"",gasCost:""})}),mi())}catch{}B(!1)}},disabled:z,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:z?"Retrying...":`Retry Index${nn?` (${nn})`:""}`}),sr&&f.jsx("button",{onClick:()=>{!e||!t||!window.confirm(`This episode is already on-chain — try “Retry Index” first.
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
Create a new on-chain chapter anyway?`)||s==null||s(e,t,R,w,ie)},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"}),y.txHash&&f.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),f.jsx("p",{className:"text-muted text-xs",children:Ar?sr?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":sr?"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."}),y.indexError&&f.jsx("p",{className:"text-error text-xs",children:y.indexError})]}):(y==null?void 0:y.status)==="published"?f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:"text-green-700",children:"Published"}),y.storylineId&&f.jsx("a",{href:(()=>{var Ne;const ee=`https://plotlink.xyz/story/${y.storylineId}`;if(!sr)return ee;const Se=y.plotIndex!=null&&y.plotIndex>0?y.plotIndex:parseInt(((Ne=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:Ne[1])??"1");return`${ee}/${Se}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),y.txHash&&f.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),Ki&&o&&y.storylineId&&(!y.authorAddress||y.authorAddress.toLowerCase()===o.toLowerCase())&&f.jsx("button",{onClick:()=>wt(ee=>!ee),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:ai?"Close Edit":"Edit Story"})]}),ai&&Ki&&y.storylineId&&f.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),xa(Dt),f.jsxs("div",{className:"flex items-start gap-3",children:[Te&&f.jsxs("div",{className:"relative",children:[f.jsx("img",{src:Te,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsx("button",{onClick:()=>{ge(null),me(null),te(null),Le("unknown"),Gt.current&&(Gt.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("input",{ref:Gt,type:"file",accept:"image/webp,image/jpeg",onChange:Xt,className:"text-xs","data-testid":"cover-input"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("select",{value:hi,onChange:ee=>re(ee.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:rl.map(ee=>f.jsx("option",{value:ee,children:ee},ee))}),f.jsx("select",{value:xe,onChange:ee=>Pe(ee.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xr.map(ee=>f.jsx("option",{value:ee,children:ee},ee))})]}),f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:Fe,onChange:ee=>Qe(ee.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:pr,disabled:He||!ut,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:He?"Saving...":ut?"Save Changes":"Loading..."}),Ci&&f.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),di&&f.jsx("span",{className:"text-error text-xs",children:di})]})]})]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[Vi&&je&&je.total>0&&f.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted","data-testid":"cartoon-status-summary",children:[f.jsxs("span",{children:["Cuts: ",f.jsx("span",{className:"text-foreground font-medium",children:je.total})]}),f.jsxs("span",{children:["Clean: ",f.jsxs("span",{className:"text-foreground font-medium",children:[je.withClean,"/",je.needClean]})]}),f.jsxs("span",{children:["Lettered: ",f.jsxs("span",{className:"text-foreground font-medium",children:[je.withText,"/",je.needClean]})]}),f.jsxs("span",{children:["Uploaded: ",f.jsxs("span",{className:"text-foreground font-medium",children:[je.uploaded,"/",je.total]})]}),_&&f.jsx("button",{onClick:_,className:"ml-auto text-accent hover:underline","data-testid":"status-view-progress",children:"View progress →"})]}),rn&&li&&f.jsxs("div",{className:"text-xs text-muted","data-testid":"genesis-cuts-summary",children:["Episode 1 (Genesis) cuts: ",li.total," planned",li.total>0&&f.jsxs(f.Fragment,{children:[" ","· ",li.withClean," clean"," ","· ",li.withText," lettered"," ","· ",li.exported," exported"," ","· ",li.uploaded," uploaded"]})]}),(rn||Vi)&&ma&&f.jsxs("div",{className:`${Io} flex flex-col gap-1 border-border bg-surface/50`,"data-testid":"cartoon-not-started",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-muted",children:pa===0?"Not started":"Next step"}),f.jsx("span",{className:"text-xs font-medium text-foreground",children:rn?"Genesis (Episode 1)":"Future episode"})]}),f.jsx("span",{className:"text-xs text-muted",children:ma})]}),sr&&!Vi&&L==="preview"&&f.jsxs("div",{children:[f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:bt,onChange:ee=>pt(ee.target.checked),className:"rounded border-border"}),"Add illustrations in the plot"]}),bt&&f.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[f.jsxs("div",{className:"border-2 border-dashed border-border rounded p-3 flex flex-col items-center gap-1.5 cursor-pointer hover:border-accent transition-colors",onClick:()=>{var ee;return(ee=pn.current)==null?void 0:ee.click()},onDragOver:ee=>{ee.preventDefault(),ee.stopPropagation()},onDrop:ee=>{var Ne;ee.preventDefault(),ee.stopPropagation();const Se=(Ne=ee.dataTransfer.files)==null?void 0:Ne[0];Se&&ts(Se)},children:[f.jsx("input",{ref:pn,type:"file",accept:"image/webp,image/jpeg",onChange:ha,className:"hidden"}),f.jsx("span",{className:"text-xs text-muted",children:Tt?"Uploading...":"Drop image here or click to browse"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB"})]}),ot&&f.jsx("span",{className:"text-error text-xs",children:ot}),Et.map((ee,Se)=>f.jsxs("div",{className:"border border-border rounded p-2 flex flex-col gap-1 bg-surface",children:[f.jsx("span",{className:"text-xs text-green-700",children:"Image uploaded! Copy the markdown below and paste it where you want the illustration to appear in your plot:"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsxs("code",{className:"flex-1 text-xs bg-background px-2 py-1 rounded font-mono break-all",children:[""]}),f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(``),fr(Se),setTimeout(()=>fr(null),2e3)},className:"px-2 py-1 text-xs border border-border rounded hover:bg-surface shrink-0",children:pi===Se?"Copied!":"Copy"})]})]},ee.cid))]})]}),Ki&&c!=="cartoon"&&!(L==="edit"&&M==="cuts")&&f.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"prepublish-cover",children:[f.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Cover Image ",f.jsx("span",{className:"text-muted font-normal",children:"(optional)"})]}),xa(!1),f.jsxs("div",{className:"flex items-start gap-3",children:[Te&&f.jsxs("div",{className:"relative",children:[f.jsx("img",{src:Te,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsx("button",{onClick:()=>{ft.current=!0,st(null),te(null),Le("unknown"),ge(null),me(ee=>(ee&&URL.revokeObjectURL(ee),null)),Gt.current&&(Gt.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("input",{ref:Gt,type:"file",accept:"image/webp,image/jpeg",onChange:Xt,className:"text-xs","data-testid":"prepublish-cover-input"}),f.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"}),f.jsx("input",{ref:fn,type:"file",accept:"image/png,image/webp,image/jpeg",onChange:Un,className:"hidden","data-testid":"prepublish-cover-import-input"}),f.jsx("button",{type:"button",onClick:()=>{var ee;return(ee=fn.current)==null?void 0:ee.click()},disabled:de,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:de?"Importing…":"Import generated image (PNG ok)"}),H&&f.jsx("span",{className:"text-green-700 text-xs","data-testid":"prepublish-cover-will-upload",children:"This cover will be uploaded as the PlotLink storyline cover when you publish."}),We&&f.jsxs("span",{className:"text-accent text-xs","data-testid":"prepublish-cover-detected",children:["Auto-detected generated cover ",We," — pick a file to override."]}),nt&&f.jsxs("span",{className:"text-amber-700 text-xs","data-testid":"prepublish-cover-detected-warning",children:[nt," Use “Import generated image” below to convert/compress it, or pick a file."]}),c==="cartoon"&&Ce==="none"&&!H&&f.jsxs("span",{className:"text-muted text-xs","data-testid":"prepublish-cover-none",children:["No generated cover detected. Create ",f.jsx("span",{className:"font-mono",children:"assets/cover.webp"})," or use “Import generated image” — it will be uploaded as the PlotLink storyline cover when you publish."]}),di&&f.jsx("span",{className:"text-error text-xs","data-testid":"prepublish-cover-error",children:di})]})]})]}),!fa&&Wu(),!fa&&ba(),!fa&&f.jsxs("div",{className:"flex items-center gap-2",children:[Ki&&c!=="cartoon"&&f.jsxs(f.Fragment,{children:[f.jsxs("select",{value:R,"data-testid":"publish-genre-select",onChange:ee=>{Y(ee.target.value),ee.target.value&&In({genre:ee.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${R?"border-border":"border-amber-500"}`,children:[!R&&f.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select genre"}),rl.map(ee=>f.jsx("option",{value:ee,children:ee},ee))]}),f.jsxs("select",{value:w,"data-testid":"publish-language-select",onChange:ee=>{ae(ee.target.value),ee.target.value&&In({language:ee.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${w?"border-border":"border-amber-500"}`,children:[!w&&f.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select language"}),Xr.map(ee=>f.jsx("option",{value:ee,children:ee},ee))]})]}),f.jsx("button",{onClick:async()=>{if(!e||!t)return;if(ar.count>0){const Se=`This plot contains ${ar.count} illustration(s). Content is immutable after publishing — image references cannot be changed or removed.
|
|
139
|
+
|
|
140
|
+
Please verify illustrations appear correctly in Preview before continuing.
|
|
141
|
+
|
|
142
|
+
Publish now?`;if(!window.confirm(Se))return}const ee=Ki?H:null;ee?await(s==null?void 0:s(e,t,R,w,ie,ee))&&(ft.current=!0,st(null),te(null),Le("unknown"),ge(null),me(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),Gt.current&&(Gt.current.value="")):s==null||s(e,t,R,w,ie)},disabled:!!a||is||pl||Po||Ki&&(!R||!w)||Vi&&F!=="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"}),Ki&&c==="cartoon"&&(!R||!w)&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"cartoon-metadata-needs-story-info",children:"Set the genre and language in Story Info before publishing"}),Ki&&c!=="cartoon"&&!R&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"genre-needs-metadata",children:"Needs metadata — choose a genre before publishing"}),Ki&&c!=="cartoon"&&R&&!w&&f.jsx("span",{className:"text-amber-600 text-xs","data-testid":"language-needs-metadata",children:"Needs metadata — choose a language before publishing"}),is&&f.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"}),Vi&&F==="error"&&f.jsx("span",{className:"text-error text-xs","data-testid":"publish-disabled-reason",children:"Fix the issues below before publishing"}),Vi&&F==="planning"&&f.jsx("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:"Prepare the episode for publish to continue"}),Vi&&F==="awaiting-upload"&&f.jsxs("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:["Upload all final images, then “Prepare episode for publish” — ",be," of ",Ee," still need an uploaded image"]})]}),fa&&f.jsx("button",{onClick:()=>v==null?void 0:v(),"data-testid":"cartoon-review-publish",className:"self-start rounded border border-accent/40 px-3 py-1 text-xs text-accent hover:bg-accent/5 transition-colors",children:"Review publish checklist →"}),ar.warnings.length>0&&f.jsx("div",{className:"flex flex-col gap-0.5",children:ar.warnings.map((ee,Se)=>f.jsx("span",{className:"text-amber-600 text-xs",children:ee},Se))}),Ki&&c!=="cartoon"&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:ie,onChange:ee=>{oe(ee.target.checked),In({isNsfw:ee.target.checked})},className:"rounded border-border"}),"This story contains adult content (18+)"]}),ie&&f.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}function pD({storyName:e,authFetch:t,onOpenFile:i,refreshKey:s=0}){const[a,o]=C.useState(null),[c,h]=C.useState(!0);return C.useEffect(()=>{let p=!1;return(async()=>{h(!0);try{const x=await t(`/api/stories/${e}/progress`),_=x.ok?await x.json():null;p||(o(_),h(!1))}catch{p||(o(null),h(!1))}})(),()=>{p=!0}},[e,t,s]),c?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"progress-loading",children:"Loading progress…"}):!a||!a.metadata||!Array.isArray(a.episodes)?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story progress."}):a.contentType==="cartoon"?f.jsx(SD,{progress:a,storyName:e,onOpenFile:i}):f.jsx(kD,{progress:a,storyName:e,onOpenFile:i})}function uu({label:e,value:t,tone:i="muted"}){const s=i==="ok"?"text-green-700":i==="warn"?"text-amber-700":"text-muted";return f.jsxs("span",{className:"text-[11px]",children:[f.jsxs("span",{className:"text-muted",children:[e,": "]}),f.jsx("span",{className:`font-medium ${s}`,children:t})]})}function WS({progress:e}){const t=e.contentType==="cartoon",i=e.cover==="present"?"ok":e.cover==="invalid"?"warn":"muted";return f.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-base font-serif text-foreground truncate",children:e.metadata.title||e.name}),f.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${t?"bg-accent/10 text-accent":"bg-surface text-muted"}`,children:t?"Cartoon":"Fiction"})]}),f.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-1",children:[f.jsx(uu,{label:"Language",value:e.metadata.language||"Needs metadata",tone:e.metadata.language?"muted":"warn"}),f.jsx(uu,{label:"Genre",value:e.metadata.genre||"Needs metadata",tone:e.metadata.genre?"muted":"warn"}),e.metadata.isNsfw!=null&&f.jsx(uu,{label:"Adult",value:e.metadata.isNsfw?"Yes (18+)":"No"}),t&&f.jsx(uu,{label:"Cover",value:e.cover==="present"?"Ready":e.cover==="invalid"?"Invalid":"Missing",tone:i})]})]})}const GS={published:"✓",done:"●",current:"◉","needs-action":"●","not-started":"○"},Mu={published:"text-green-700",done:"text-green-700",current:"text-accent","needs-action":"text-amber-700","not-started":"text-muted"},YS={published:"Published",done:"Complete",current:"Current","needs-action":"Needs action","not-started":"Not started"},mD={done:"✓",current:"◓",todo:"○"},gD={done:"text-green-700",current:"text-accent",todo:"text-muted"};function KS({item:e}){return f.jsxs("div",{className:"flex items-baseline gap-2 text-[11px]","data-testid":"checklist-item","data-status":e.status,children:[f.jsx("span",{className:`${gD[e.status]} flex-shrink-0`,"aria-hidden":!0,children:mD[e.status]}),f.jsx("span",{className:e.status==="todo"?"text-muted":"text-foreground",children:e.label}),e.detail&&f.jsxs("span",{className:"text-muted",children:["· ",e.detail]})]})}function fy({index:e,title:t,status:i,items:s,fileName:a,openFile:o,cta:c}){const h=f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:`flex-shrink-0 ${Mu[i]}`,"aria-hidden":!0,children:GS[i]}),f.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",t]}),a&&f.jsx("span",{className:"text-[10px] text-muted truncate",children:a}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${Mu[i]} flex-shrink-0`,children:YS[i]})]});return f.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":i,children:[o?f.jsx("button",{onClick:o,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5","data-testid":`section-open-${e}`,children:h}):h,f.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:s.map((p,d)=>f.jsx(KS,{item:p},d))}),c&&f.jsx("div",{className:"mt-2 ml-1","data-testid":"section-cta",children:c})]})}function _D(e,t){return e.published?"published":t?"current":e.state==="placeholder"?"not-started":(e.state==="blocked","needs-action")}function xD(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(bD(a));return s}function bD(e){return{label:e.label,status:e.status,detail:e.detail}}const vD={file:"genesis.md",label:"Episode 1 / Genesis",kind:"genesis",title:null,state:"placeholder",summary:"",published:!1,checklist:[],cuts:null};function yD(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 SD({progress:e,storyName:t,onOpenFile:i}){const s=e.coach??null,a=e.metadata,o=e.setup.hasStructure,c=e.setup.hasGenesis,h=e.cover==="present",p=!a.title||!a.language||!a.genre,d=p||!h,x=e.episodes.find(M=>!M.published)??null,_=!!x&&x.state!=="ready";let b;o?c?p?b="story-info":_&&(s!=null&&s.episodeFile)?b=s.episodeFile:h?b=(s==null?void 0:s.episodeFile)??null:b="story-info":b="genesis.md":b="whitepaper";const v=s?f.jsx(qS,{coach:s,onAction:(M,X)=>{M!=="view-progress"&&X&&i(t,X)}}):null,y=f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent/5 border border-accent/30 rounded text-xs","data-testid":"story-info-cta",children:[f.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-accent flex-shrink-0",children:"Story info"}),f.jsxs("span",{className:"min-w-0 flex-1 text-foreground",children:[f.jsx("span",{className:"text-muted",children:"Next: "}),f.jsx("span",{className:"font-medium",children:yD(e)})]})]}),E=M=>M!==b?null:b==="story-info"?y:v,A=[{label:"Public title",status:a.title?"done":"todo",detail:a.title??null},{label:"Language",status:a.language?"done":"todo",detail:a.language??null},{label:"Genre",status:a.genre?"done":"todo",detail:a.genre??null},{label:"Cover image",status:h?"done":"todo",detail:e.cover==="invalid"?"Invalid — re-import":h?null:"Missing"}],T=b==="story-info"?"current":d?"needs-action":"done",L=o?"done":b==="whitepaper"?"current":"not-started",O=e.episodes.find(M=>M.kind==="genesis")??null,J=e.episodes.filter(M=>M.kind==="plot");let $=0;return f.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[f.jsx(WS,{progress:e}),f.jsx("p",{className:"px-4 pt-3 pb-1 text-[11px] font-medium text-muted uppercase tracking-wider",children:"Production Progress"}),f.jsx(fy,{index:++$,title:"Define Story Info",status:T,items:A,cta:E("story-info")??void 0}),f.jsx(fy,{index:++$,title:"Story Whitepaper",status:L,fileName:"structure.md",openFile:o?()=>i(t,"structure.md"):void 0,items:[{label:"Planning document",status:o?"done":"todo",detail:o?null:"Not written yet"}],cta:E("whitepaper")??void 0}),O?f.jsx(Df,{index:++$,ep:O,isActive:b===O.file,storyName:t,onOpenFile:i,cta:E(O.file)??void 0}):f.jsx(Df,{index:++$,ep:vD,isActive:b==="genesis.md",openingDone:!1,canOpen:!1,storyName:t,onOpenFile:i,cta:E("genesis.md")??void 0}),J.map(M=>f.jsx(Df,{index:++$,ep:M,isActive:b===M.file,storyName:t,onOpenFile:i,cta:E(M.file)??void 0},M.file)),b===null&&v&&f.jsx("div",{className:"px-4 py-2.5 border-b border-border","data-testid":"workflow-next-episode",children:f.jsx("div",{className:"ml-1","data-testid":"section-cta",children:v})}),f.jsxs("div",{className:"px-4 py-2 text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[f.jsxs("span",{children:[e.summary.published," published"]}),f.jsxs("span",{children:[e.summary.readyToPublish," ready"]}),e.summary.placeholders>0&&f.jsxs("span",{children:[e.summary.placeholders," not started"]}),e.summary.blocked>0&&f.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function Df({index:e,ep:t,isActive:i,storyName:s,onOpenFile:a,cta:o,openingDone:c=!0,canOpen:h=!0}){const p=_D(t,i),d=xD(t,c),x=t.title?`${t.label} · ${t.title}`:t.label,_=f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:`flex-shrink-0 ${Mu[p]}`,"aria-hidden":!0,children:GS[p]}),f.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",x]}),f.jsx("span",{className:"text-[10px] text-muted truncate",children:t.file}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${Mu[p]} flex-shrink-0`,children:YS[p]})]});return f.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":p,children:[h?f.jsx("button",{onClick:()=>a(s,t.file),"data-testid":`progress-episode-${t.file}`,"data-state":t.state,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5",children:_}):f.jsx("div",{"data-state":t.state,children:_}),f.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:d.map((b,v)=>f.jsx(KS,{item:b},v))}),o&&f.jsx("div",{className:"mt-2 ml-1","data-testid":"section-cta",children:o})]})}const wD={published:"✓",ready:"●","in-progress":"◐",planning:"○",placeholder:"○",blocked:"✕",draft:"○"},py={published:"text-green-700",ready:"text-green-700","in-progress":"text-accent",planning:"text-accent",placeholder:"text-muted",blocked:"text-error",draft:"text-muted"},CD={published:"Published",ready:"Ready","in-progress":"In progress",planning:"Planning",placeholder:"Not started",blocked:"Needs fixes",draft:"Draft"};function kD({progress:e,storyName:t,onOpenFile:i}){const[s,a]=C.useState(!1);return f.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[f.jsx(WS,{progress:e}),e.nextAction&&f.jsxs("div",{className:"px-4 py-2 border-b border-accent/30 bg-accent/5 text-xs space-y-1.5","data-testid":"progress-next-action",children:[f.jsxs("div",{children:[f.jsx("span",{className:"font-medium text-foreground",children:"Next: "}),f.jsx("span",{className:"text-muted",children:e.nextAction})]}),e.nextPrompt&&f.jsxs("div",{className:"flex items-start gap-1.5","data-testid":"progress-next-prompt",children:[f.jsx("code",{className:"flex-1 rounded border border-border bg-surface px-1.5 py-1 text-[10px] text-foreground break-words",children:e.nextPrompt}),f.jsx("button",{onClick:()=>{var o;e.nextPrompt&&((o=navigator.clipboard)==null||o.writeText(e.nextPrompt).then(()=>{a(!0)}).catch(()=>{}))},"data-testid":"copy-next-prompt",className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors flex-shrink-0",children:s?"Copied!":"Copy"})]})]}),f.jsxs("div",{className:"px-4 py-2 border-b border-border flex flex-col gap-1",children:[f.jsx(my,{done:e.setup.hasStructure,label:"Story bible (structure.md)",onClick:e.setup.hasStructure?()=>i(t,"structure.md"):void 0}),f.jsx(my,{done:e.setup.hasGenesis,label:"Genesis written",onClick:e.setup.hasGenesis?()=>i(t,"genesis.md"):void 0})]}),f.jsxs("div",{className:"px-4 py-2",children:[f.jsx("p",{className:"text-[11px] font-medium text-muted uppercase tracking-wider mb-1.5",children:"Chapters"}),e.episodes.length===0?f.jsx("p",{className:"text-xs text-muted italic","data-testid":"progress-no-episodes",children:"No chapters yet — write the Genesis to start."}):f.jsx("ol",{className:"flex flex-col gap-1",children:e.episodes.map(o=>f.jsx("li",{children:f.jsxs("button",{onClick:()=>i(t,o.file),"data-testid":`progress-episode-${o.file}`,"data-state":o.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:[f.jsx("span",{className:`mt-0.5 ${py[o.state]}`,"aria-hidden":!0,children:wD[o.state]}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:o.label}),o.title&&f.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",o.title]}),f.jsx("span",{className:`ml-auto text-[10px] font-medium ${py[o.state]}`,children:CD[o.state]})]}),f.jsx("span",{className:"block text-[11px] text-muted",children:o.summary})]})]})},o.file))})]}),f.jsxs("div",{className:"px-4 py-2 border-t border-border text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[f.jsxs("span",{children:[e.summary.published," published"]}),e.summary.blocked>0&&f.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function my({done:e,label:t,onClick:i}){const s=f.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:e?"text-green-700":"text-muted","aria-hidden":!0,children:e?"✓":"○"}),f.jsx("span",{className:e?"text-foreground":"text-muted",children:t})]});return i?f.jsx("button",{onClick:i,className:"text-left hover:underline",children:s}):f.jsx("div",{children:s})}const ED=[{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 ND({storyTitle:e,active:t,onSelect:i}){return f.jsxs("div",{className:"flex-shrink-0 border-b border-border bg-surface/40","data-testid":"cartoon-workflow-nav",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2",children:[f.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-accent",children:"Cartoon"}),f.jsx("span",{className:"text-xs font-serif text-foreground truncate",children:e})]}),f.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 overflow-x-auto",role:"tablist",children:ED.map(s=>{const a=s.key===t;return f.jsx("button",{role:"tab","aria-selected":a,"data-testid":`nav-tab-${s.key}`,"data-active":a,onClick:()=>i(s.key),className:`flex-shrink-0 rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors ${a?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:s.label},s.key)})})]})}function TD({storyName:e,authFetch:t,onSaved:i}){const[s,a]=C.useState(!0),[o,c]=C.useState(!1),[h,p]=C.useState(""),[d,x]=C.useState(""),[_,b]=C.useState(""),[v,y]=C.useState(""),[E,A]=C.useState(!1),[T,L]=C.useState("cartoon"),[O,J]=C.useState("unknown"),[$,M]=C.useState(!1),[X,he]=C.useState(!1),[ye,U]=C.useState(null),[se,W]=C.useState(!1),[G,Z]=C.useState(null),[I,j]=C.useState(!1),z=C.useRef(null);C.useEffect(()=>{let w=!1;return a(!0),c(!1),he(!1),U(null),(async()=>{try{const[ae,ie]=await Promise.all([t(`/api/stories/${e}`),t(`/api/stories/${e}/progress`)]);if(!ae.ok){w||(c(!0),a(!1));return}const oe=await ae.json(),F=ie.ok?await ie.json().catch(()=>null):null;if(w)return;p(oe.title??""),x(oe.description??""),b(bu(oe.genre)??""),y(oe.language&&Xr.find(ue=>ue.toLowerCase()===oe.language.toLowerCase())||""),A(!!oe.isNsfw),L(oe.contentType==="fiction"?"fiction":"cartoon"),J((F==null?void 0:F.cover)??"unknown"),a(!1)}catch{w||(c(!0),a(!1))}})(),()=>{w=!0}},[e,t]);const B=C.useCallback(async()=>{M(!0),he(!1),U(null);const w={title:h.trim(),description:d.trim(),genre:_,language:v,isNsfw:E};try{const ae=await t(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(ae.ok)he(!0),i==null||i({genre:_,language:v,isNsfw:E});else{const ie=await ae.json().catch(()=>({}));U(ie.error||"Could not save story info.")}}catch{U("Could not save story info.")}M(!1)},[e,t,h,d,_,v,E,i]),_e=C.useCallback(async w=>{var ie;const ae=(ie=w.target.files)==null?void 0:ie[0];if(z.current&&(z.current.value=""),!!ae){W(!0),U(null);try{let oe;try{oe=await qu(ae)}catch(Ee){U(Ee instanceof Error?Ee.message:"Could not import image");return}const F=oe.type==="image/jpeg"?"jpg":"webp",ue=new File([oe],`cover.${F}`,{type:oe.type}),be=new FormData;be.append("file",ue);const De=await t(`/api/stories/${e}/import-cover`,{method:"POST",body:be});if(!De.ok){const Ee=await De.json().catch(()=>({}));U(Ee.error||"Cover import failed.");return}J("present"),Z(Ee=>(Ee&&URL.revokeObjectURL(Ee),URL.createObjectURL(ue)))}catch{U("Cover import failed.")}finally{W(!1)}}},[e,t]),N=C.useCallback(()=>{var ae;const w=`Generate a cover image for this story (${h||e}) and save it as assets/cover.webp — portrait 600x900, WebP, under 1MB. Don't publish.`;(ae=navigator.clipboard)==null||ae.writeText(w).then(()=>{j(!0)}).catch(()=>{})},[h,e]);if(s)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"story-info-loading",children:"Loading story info…"});if(o)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story info."});const R=O==="present"?"Cover set":O==="invalid"?"Invalid cover — re-import a WebP/JPEG under 1MB":"Missing cover",Y=O==="present"?"text-green-700":O==="invalid"?"text-amber-700":"text-muted";return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"story-info-page",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Story Info"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"These details appear on PlotLink when the story is published."}),f.jsxs("div",{className:"mt-4 flex flex-col gap-4 max-w-xl",children:[f.jsxs("label",{className:"flex flex-col gap-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Public title"}),f.jsx("input",{type:"text",value:h,onChange:w=>{p(w.target.value),he(!1)},"data-testid":"story-info-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"flex flex-col gap-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Short description"}),f.jsx("textarea",{value:d,onChange:w=>{x(w.target.value),he(!1)},rows:3,"data-testid":"story-info-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none resize-y"})]}),f.jsxs("div",{className:"flex flex-wrap gap-4",children:[f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Genre"}),f.jsxs("select",{value:_,onChange:w=>{b(w.target.value),he(!1)},"data-testid":"story-info-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"Needs metadata"}),rl.map(w=>f.jsx("option",{value:w,children:w},w))]})]}),f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Language"}),f.jsxs("select",{value:v,onChange:w=>{y(w.target.value),he(!1)},"data-testid":"story-info-language",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"Needs metadata"}),Xr.map(w=>f.jsx("option",{value:w,children:w},w))]})]}),f.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Content type"}),f.jsx("span",{className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-surface text-muted","data-testid":"story-info-content-type",title:"Content type is locked after creation.",children:T==="cartoon"?"Cartoon · locked":"Fiction · locked"})]})]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Cover image"}),f.jsxs("div",{className:"flex items-start gap-3",children:[G&&f.jsx("img",{src:G,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:`text-[11px] font-medium ${Y}`,"data-testid":"story-info-cover-status",children:R}),f.jsx("span",{className:"text-[10px] text-muted",children:"WebP or JPEG, max 1MB, 600×900 recommended."}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{type:"button",onClick:()=>{var w;return(w=z.current)==null?void 0:w.click()},disabled:se,"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:se?"Importing…":"Import cover"}),f.jsx("button",{type:"button",onClick:N,"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:I?"Copied!":"Ask agent for cover prompt"})]}),f.jsx("input",{ref:z,type:"file",accept:"image/*",onChange:_e,className:"hidden"})]})]})]}),f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:E,onChange:w=>{A(w.target.checked),he(!1)},"data-testid":"story-info-nsfw"}),f.jsx("span",{className:"text-xs text-foreground",children:"This story contains adult content (18+)"})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{type:"button",onClick:B,disabled:$,"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:$?"Saving…":"Save Story Info"}),X&&f.jsx("span",{className:"text-[11px] text-green-700","data-testid":"story-info-saved",children:"Saved"}),ye&&f.jsx("span",{className:"text-[11px] text-error","data-testid":"story-info-error",children:ye})]})]})]})}function jD({storyName:e,authFetch:t,onOpenFile:i}){const[s,a]=C.useState(null),[o,c]=C.useState(!0);return C.useEffect(()=>{let h=!1;return(async()=>{c(!0);try{const d=await t(`/api/stories/${e}/progress`),x=d.ok?await d.json():null;h||(a(Array.isArray(x==null?void 0:x.episodes)?x.episodes:null),c(!1))}catch{h||(a(null),c(!1))}})(),()=>{h=!0}},[e,t]),o?f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"episodes-loading",children:"Loading episodes…"}):s?f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"episodes-page",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Episodes"}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Genesis is Episode 1; each plot file is the next episode."}),s.length===0?f.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."}):f.jsx("ol",{className:"mt-3 flex flex-col gap-1",children:s.map(h=>f.jsx("li",{children:f.jsx("button",{onClick:()=>i(e,h.file),"data-testid":`episodes-row-${h.file}`,"data-state":h.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-foreground",children:h.label}),h.title&&f.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",h.title]}),f.jsx("span",{className:"ml-auto text-[10px] text-muted",children:h.file})]}),f.jsx("span",{className:"block text-[11px] text-muted",children:h.summary})]})})},h.file))})]}):f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load episodes."})}function AD({storyName:e,authFetch:t,onOpenFile:i,onOpenStoryInfo:s,onPublish:a,publishingFile:o,genre:c,language:h,isNsfw:p,refreshKey:d=0}){var mt,Ge;const[x,_]=C.useState(null),[b,v]=C.useState(!0),[y,E]=C.useState(!1),[A,T]=C.useState(null),[L,O]=C.useState(null),[J,$]=C.useState(null),[M,X]=C.useState(null),[he,ye]=C.useState(null),U=async()=>{try{const Ae=await t(`/api/stories/${e}/cover-asset`),Ve=Ae.ok?await Ae.json():null;if(!(Ve!=null&&Ve.found)||!Ve.valid||!Ve.path)return null;const Mt=await t(`/api/stories/${e}/asset/${String(Ve.path).replace(/^assets\//,"")}`);if(!Mt.ok)return null;const zt=await Mt.blob();return new File([zt],String(Ve.path).split("/").pop()||"cover.webp",{type:Ve.type||zt.type})}catch{return null}};C.useEffect(()=>{let Ae=!1;return(async()=>{v(!0),E(!1);try{const Mt=await t(`/api/stories/${e}/progress`),zt=Mt.ok?await Mt.json():null;if(Ae)return;!zt||!Array.isArray(zt.episodes)?(E(!0),_(null)):_(zt),v(!1)}catch{Ae||(E(!0),_(null),v(!1))}})(),()=>{Ae=!0}},[e,t,d]);const se=((Ge=(mt=x==null?void 0:x.episodes)==null?void 0:mt.find(Ae=>!Ae.published))==null?void 0:Ge.file)??null,W=se==="genesis.md",G=JSON.stringify([se??"",d]),[Z,I]=C.useState(null);if(Z!==G&&(I(G),O(null),$(null),X(null),ye(null)),C.useEffect(()=>{if(!se)return;let Ae=!1;const Ve=se.replace(/\.md$/,"");return(async()=>{var Mt;try{const zt=[t(`/api/stories/${e}/${se}`),t(`/api/stories/${e}/cuts/${Ve}`)];W&&zt.push(t(`/api/stories/${e}/structure.md`));const[ai,wt,hi]=await Promise.all(zt);if(Ae)return;if(O(ai.ok?(await ai.json()).content??"":""),wt.ok){const re=await wt.json();if(Ae)return;$(Array.isArray(re.cuts)?re.cuts:[]),X(typeof re.title=="string"?re.title:null)}else $(null),X(null);ye(W&&hi&&hi.ok?((Mt=await hi.json())==null?void 0:Mt.content)??null:null)}catch{Ae||(O(""),$(null),X(null),ye(null))}})(),()=>{Ae=!0}},[se,W,e,t,d]),b)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"publish-page-loading",children:"Loading publish readiness…"});if(y||!x)return f.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load publish readiness."});const j=x.episodes.find(Ae=>!Ae.published);if(!j)return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[f.jsx("h2",{className:"text-base font-serif text-foreground",children:"Publish"}),f.jsx("p",{className:"mt-2 text-xs text-green-700","data-testid":"publish-all-done",children:x.episodes.length>0?"All episodes are published to PlotLink. Plan the next episode to continue.":"No episodes yet — write the Genesis (Episode 1) to begin."})]});const z=j.cuts,B=x.cover==="present",_e=[{label:"Opening text ready",status:"done"},{label:"Cut plan",status:z&&z.total>0?"done":"todo",detail:z?`${z.total} cut${z.total===1?"":"s"} planned`:"not started"},{label:"Clean images converted",status:z&&z.needClean>0&&z.withClean===z.needClean?"done":"todo",detail:z?`${z.withClean} / ${z.needClean}`:null},{label:"Cuts lettered",status:z&&z.needClean>0&&z.withText===z.needClean?"done":"todo",detail:z?`${z.withText} / ${z.needClean}`:null},{label:"Final images exported",status:z&&z.total>0&&z.exported===z.total?"done":"todo",detail:z?`${z.exported} / ${z.total}`:null},{label:"Final images uploaded",status:z&&z.total>0&&z.uploaded===z.total?"done":"todo",detail:z?`${z.uploaded} / ${z.total}`:null},{label:"Cover image",status:B?"done":"todo",detail:B?null:"recommended before publishing"},{label:"Publish to PlotLink",status:j.published?"done":"todo"}],N=j.state==="ready",R=j.state==="blocked",Y=j.file==="genesis.md",w=!Y||!!c&&!!h,ae=!!o&&o===j.file,ie=L!==null,oe=ie?_m({fileName:j.file,fileContent:L??"",storySlug:e,structureContent:he,contentType:"cartoon",episodeTitle:M}):null,F=!!oe&&jo(oe,j.file),ue=!Y&&ie&&!gm({fileContent:L??"",episodeTitle:M}),be=F||ue,De=Y&&ie?pm(L??""):null,Ee=!!De&&De.blockers.length>0,Be=!Y&&ie&&J!==null?zS(L??"",J):null,je=Be&&Be.stage==="error"?Be.issues:[],we=N&&w&&(ie&&(Y||J!==null))&&!be&&!Ee&&!ae&&!!a,tt=async()=>{if(!(!we||!a)){T(null);try{const Ae=Y?await U():null;await a(e,j.file,c??"",h??"",!!p,Ae)}catch{T("Publish could not be started. Please try again.")}}};return f.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[f.jsxs("h2",{className:"text-base font-serif text-foreground",children:["Publish ",j.label]}),f.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Finalize this episode: convert, letter, export, upload, then publish to PlotLink."}),f.jsx("ul",{className:"mt-3 flex flex-col gap-1.5 max-w-xl","data-testid":"publish-checklist",children:_e.map((Ae,Ve)=>f.jsxs("li",{className:"flex items-baseline gap-2 text-xs","data-testid":"publish-check","data-status":Ae.status,children:[f.jsx("span",{className:`flex-shrink-0 ${Ae.status==="done"?"text-green-700":"text-muted"}`,"aria-hidden":!0,children:Ae.status==="done"?"✓":"○"}),f.jsx("span",{className:Ae.status==="done"?"text-foreground":"text-muted",children:Ae.label}),Ae.detail&&f.jsxs("span",{className:"text-muted",children:["· ",Ae.detail]})]},Ve))}),oe&&f.jsxs("div",{className:"mt-4 flex flex-col gap-0.5 max-w-xl","data-testid":"publish-title-preview","data-raw":F?"true":"false","data-blocked":be?"true":"false",children:[f.jsxs("span",{className:"text-[11px] text-foreground",children:[f.jsxs("span",{className:"font-medium",children:[Y?"Story title":"Episode title",":"]})," ",f.jsx("span",{className:be?"text-error font-medium":"text-foreground",children:oe})]}),F?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",Y?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," before publishing."]}):ue?f.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",oe,"” 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]}),De&&f.jsxs("div",{className:"mt-4 flex flex-col gap-1 rounded border border-border bg-surface/50 p-2 max-w-xl","data-testid":"cartoon-genesis-readiness","data-blocked":Ee?"true":"false",children:[f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),f.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),De.blockers.map((Ae,Ve)=>f.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:Ae},`b-${Ve}`)),De.warnings.map((Ae,Ve)=>f.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:Ae},`w-${Ve}`))]}),je.length>0&&f.jsxs("div",{className:"mt-4 flex flex-col gap-2 rounded-xl border border-error/30 bg-error/5 px-3 py-3 max-w-xl","data-testid":"cartoon-publish-issues",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"rounded-full bg-error px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-white",children:"Before publish"}),f.jsx("span",{className:"text-xs font-medium text-foreground",children:"Finish these workflow steps"})]}),PS(je).map(Ae=>f.jsx("div",{className:"rounded-lg border border-error/15 bg-background/70 px-2.5 py-2","data-testid":`cartoon-issue-group-${Ae.key}`,children:f.jsx("span",{className:"text-[11px] font-medium text-foreground",children:Ae.title})},Ae.key)),f.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cartoon-technical-details",children:[f.jsx("summary",{className:"cursor-pointer select-none",children:"Technical details"}),f.jsx("ul",{className:"mt-1 ml-3 list-disc",children:je.map((Ae,Ve)=>f.jsx("li",{className:"font-mono break-words",children:Ae},Ve))})]})]}),f.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-xl",children:[!B&&f.jsx("button",{onClick:s,"data-testid":"publish-add-cover",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Add a cover image (Story Info)"}),Y&&!w&&f.jsx("button",{onClick:s,"data-testid":"publish-set-metadata",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Set genre & language (Story Info)"}),!N&&f.jsxs("button",{onClick:()=>i(e,j.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 ",j.label," to finish ",R?"and fix issues":"(letter / export / upload)"]}),f.jsx("button",{onClick:tt,disabled:!we,"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:we?void 0:"Finish the remaining steps above first",children:ae?"Publishing…":`Publish ${j.label} to PlotLink`}),N?w?be||Ee?f.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-title-blocked-reason",children:Ee?"Fix the Story opening issues above before publishing.":"Set a real reader-facing title above before publishing."}):null:f.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"publish-needs-metadata",children:"Set the genre and language in Story Info before publishing."}):f.jsx("p",{className:"text-[11px] text-muted","data-testid":"publish-blocked-reason",children:R?`Not publishable yet — ${j.summary.toLowerCase()}. Open the episode to fix the flagged cuts.`:`Not ready yet — ${j.summary.toLowerCase()}.`}),A&&f.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-error",children:A})]}),f.jsxs("details",{className:"mt-4 max-w-xl","data-testid":"publish-technical-details",children:[f.jsx("summary",{className:"text-[11px] text-muted cursor-pointer hover:text-foreground",children:"Technical validation details"}),f.jsxs("div",{className:"mt-1 text-[10px] text-muted space-y-0.5",children:[f.jsxs("p",{children:["Episode file: ",f.jsx("span",{className:"font-mono",children:j.file})]}),f.jsxs("p",{children:["State: ",j.state," — ",j.summary]}),f.jsx("p",{children:"Per-cut production (cut plan, clean images, lettering, export, upload) happens in the episode’s cut workspace; open it above to finish any remaining step."})]})]})]})}function RD(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 MD(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?jo(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=RD(i,s);return a?jo(a,t)||Bp(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 DD(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 VS="plotlink-panel-ratio",BD=.6,gy=300,Bf=224,Lf=6;function LD(){try{const e=localStorage.getItem(VS);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return BD}function _y(e,t){if(t<=0)return e;const i=gy/t,s=1-gy/t;return i>=s?.5:Math.min(s,Math.max(i,e))}function OD({token:e,authFetch:t}){const[i,s]=C.useState(null),[a,o]=C.useState(null),[c,h]=C.useState(null),[p,d]=C.useState(null),[x,_]=C.useState(0),[b,v]=C.useState(""),[y,E]=C.useState(null),[A,T]=C.useState(null),[L,O]=C.useState(LD),[J,$]=C.useState([]),[M,X]=C.useState(!1),[he,ye]=C.useState(""),[U,se]=C.useState(""),[W,G]=C.useState(""),[Z,I]=C.useState("English"),[j,z]=C.useState("normal"),[B,_e]=C.useState("claude"),[N,R]=C.useState(null),[Y,w]=C.useState(!1),[ae,ie]=C.useState({}),[oe,F]=C.useState({}),[ue,be]=C.useState(new Set),[De,Ee]=C.useState(new Set),[Be,je]=C.useState({}),[Ze,we]=C.useState({}),[tt,mt]=C.useState({}),[Ge,Ae]=C.useState({}),[Ve,Mt]=C.useState({}),[zt,ai]=C.useState({}),wt=C.useRef(new Map),hi=C.useRef(new Map),re=C.useRef(new Map),xe=C.useRef(new Map),Pe=C.useRef(new Set),Fe=C.useRef(null),Qe=C.useRef(null),H=C.useRef(!1);C.useEffect(()=>{t("/api/wallet").then(te=>te.ok?te.json():null).then(te=>{te!=null&&te.address&&T(te.address)}).catch(()=>{})},[t]),C.useEffect(()=>{t("/api/agent/readiness").then(te=>te.ok?te.json():null).then(te=>{te&&R(te)}).catch(()=>{})},[t]),C.useEffect(()=>{try{localStorage.setItem(VS,String(L))}catch{}},[L]),C.useEffect(()=>{const te=()=>{if(!Qe.current)return;const Ce=Qe.current.getBoundingClientRect().width-Bf-Lf;O(Le=>_y(Le,Ce))};return window.addEventListener("resize",te),te(),()=>window.removeEventListener("resize",te)},[]);const ge=C.useCallback(()=>{ye(""),se(""),G(""),z("normal"),_e("claude"),X(!0)},[]),Te=C.useCallback(async(te,Ce,Le,ft)=>{const bt=he.trim();if(!bt)return;const pt=te==="cartoon"?"codex":ft;try{const Tt=await t("/api/stories/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:bt,description:U.trim()||void 0,language:Ce,genre:W||void 0,contentType:te,agentMode:Le,agentProvider:pt})});if(!Tt.ok)return;const Je=await Tt.json();X(!1),je(ot=>({...ot,[Je.name]:te})),we(ot=>({...ot,[Je.name]:Ce})),W&&mt(ot=>({...ot,[Je.name]:W})),F(ot=>({...ot,[Je.name]:pt})),Le==="bypass"&&ie(ot=>({...ot,[Je.name]:!0})),s(Je.name),o(null)}catch{}},[t,he,U,W]);C.useEffect(()=>{if(J.length===0)return;const te=setInterval(async()=>{try{const Ce=await t("/api/stories");if(!Ce.ok)return;const Le=await Ce.json(),ft=new Set(Le.stories.filter(bt=>bt.name!=="_example").map(bt=>bt.name));for(const bt of ft)if(!Pe.current.has(bt)&&J.length>0){const pt=J[0],Tt=wt.current.get(pt)||"fiction",Je=hi.current.get(pt)||"English",ot=re.current.get(pt)||"normal",Xe=xe.current.get(pt)||"claude";let Et=!1;Fe.current&&(Et=await Fe.current(pt,bt,{contentType:Tt,language:Je,agentMode:ot,agentProvider:Xe}).catch(()=>!1)),Et&&($($t=>$t.slice(1)),wt.current.delete(pt),hi.current.delete(pt),re.current.delete(pt),xe.current.delete(pt),ot==="bypass"&&ie($t=>{const pi={...$t,[bt]:!0};return delete pi[pt],pi}),F($t=>{const pi={...$t,[bt]:Xe};return delete pi[pt],pi}),t(`/api/stories/${bt}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:Tt,language:Je,agentMode:ot,agentProvider:Xe})}).catch(()=>{})),s(bt),o(null)}Pe.current=ft}catch{}},3e3);return()=>clearInterval(te)},[t,J]),C.useEffect(()=>{t("/api/stories").then(te=>{if(te.ok)return te.json()}).then(te=>{te!=null&&te.stories&&(Pe.current=new Set(te.stories.filter(Ce=>Ce.name!=="_example").map(Ce=>Ce.name)))}).catch(()=>{})},[t]);const me=C.useCallback((te,Ce)=>{s(te),o(Ce),h(null)},[]),He=C.useRef(null),Oe=C.useCallback(async te=>{var Ce,Le,ft,bt;He.current=te,s(te),o(null),h(null);try{const pt=await t(`/api/stories/${te}`);if(pt.ok&&He.current===te){const Tt=await pt.json();if(Tt.contentType==="cartoon")return;const Je=Tt.files||[],Xe=((Ce=Je.map(Et=>{var $t;return{file:Et.file,num:($t=Et.file.match(/^plot-(\d+)\.md$/))==null?void 0:$t[1]}}).filter(Et=>Et.num!=null).sort((Et,$t)=>parseInt($t.num)-parseInt(Et.num))[0])==null?void 0:Ce.file)??((Le=Je.find(Et=>Et.file==="genesis.md"))==null?void 0:Le.file)??((ft=Je.find(Et=>Et.file==="structure.md"))==null?void 0:ft.file)??((bt=Je[0])==null?void 0:bt.file);Xe&&He.current===te&&o(Xe)}}catch{}},[t]),ut=C.useCallback(te=>{te.preventDefault(),H.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const Ce=ft=>{if(!H.current||!Qe.current)return;const bt=Qe.current.getBoundingClientRect(),pt=bt.width-Bf-Lf,Tt=ft.clientX-bt.left-Bf;O(_y(Tt/pt,pt))},Le=()=>{H.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",Ce),window.removeEventListener("mouseup",Le)};window.addEventListener("mousemove",Ce),window.addEventListener("mouseup",Le)},[]),it=C.useCallback(async(te,Ce,Le,ft,bt,pt)=>{var Xe;d(Ce),v("Reading file..."),E(null);let Tt=!1,Je=null,ot=!1;try{const Et=await t(`/api/stories/${te}/${Ce}`);if(!Et.ok)throw new Error("Failed to read file");const $t=await Et.json(),pi=Be[te];let fr=null,pn=null;if(Ce==="genesis.md")try{const ct=await t(`/api/stories/${te}/structure.md`);ct.ok&&(fr=(await ct.json()).content??null)}catch{}else if(pi==="cartoon"&&Ce.match(/^plot-\d+\.md$/))try{const ct=await t(`/api/stories/${te}/cuts/${Ce.replace(/\.md$/,"")}`);ct.ok&&(pn=(await ct.json()).title??null)}catch{}const jr=_m({fileName:Ce,fileContent:$t.content,storySlug:te,structureContent:fr,contentType:pi,episodeTitle:pn});if(pi==="cartoon"&&jo(jr,Ce))return v(Ce==="genesis.md"?"Add a real “# Title” heading to genesis.md before publishing — it would otherwise publish as a raw filename.":"Set an episode title in the cut plan before publishing — it would otherwise publish as a raw filename."),setTimeout(()=>{d(null),v("")},6e3),!1;if(pi==="cartoon"&&Ce.match(/^plot-\d+\.md$/)&&!gm({fileContent:$t.content,episodeTitle:pn}))return v("Set a real episode title in the cut plan (or add a “# Title” to the episode) before publishing — a generic “Episode NN” placeholder can’t be published."),setTimeout(()=>{d(null),v("")},6e3),!1;if(pi==="cartoon"&&Ce==="genesis.md"){const ct=pm($t.content).blockers;if(ct.length>0)return v(`Genesis is the reader-facing Story opening — fix it before publishing: ${ct[0]}`),setTimeout(()=>{d(null),v("")},6e3),!1}let mi;if(Ce.match(/^plot-\d+\.md$/)){if(sD($t)){v("Already published on PlotLink — republishing would create a duplicate chapter. Open it on PlotLink instead (or use Retry Index if it isn't showing yet)."),setTimeout(()=>{d(null),v("")},6e3);return}try{const ct=await t(`/api/stories/${te}`);if(ct.ok){const rr=(await ct.json()).files.find(tn=>tn.file==="genesis.md"&&tn.storylineId);mi=rr==null?void 0:rr.storylineId}}catch{}if(!mi)return v("Error: Publish genesis first to create the storyline"),setTimeout(()=>{d(null),v("")},3e3),!1}v("Checking wallet balance...");try{const ct=await t("/api/publish/preflight");if(ct.ok){const In=await ct.json();if(lD(In))return E(oD(In)),d(null),v(""),!1}}catch{}v("Publishing...");const li=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:te,fileName:Ce,title:jr,content:$t.content,genre:Le,language:ft,isNsfw:bt,storylineId:mi,...dy(Be,te,mi)?{contentType:dy(Be,te,mi)}:{}})});if(!li.ok){const ct=await li.json();throw new Error(ct.error||"Publish failed")}const Pn=(Xe=li.body)==null?void 0:Xe.getReader(),nr=new TextDecoder;if(Pn)for(;;){const{done:ct,value:In}=await Pn.read();if(ct)break;const tn=nr.decode(In).split(`
|
|
143
|
+
`).filter(Hn=>Hn.startsWith("data: "));for(const Hn of tn)try{const Xt=JSON.parse(Hn.slice(6));if(Xt.step&&v(Xt.message||Xt.step),Xt.step==="done"&&Xt.txHash){if(ot=!0,await t(`/api/stories/${te}/${Ce}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:Xt.txHash,storylineId:Xt.storylineId,plotIndex:Xt.plotIndex,contentCid:Xt.contentCid,gasCost:Xt.gasCost,indexError:Xt.indexError,authorAddress:A})}),_(Un=>Un+1),pt&&Ce==="genesis.md"&&Xt.storylineId){v("Uploading cover...");let Un=null;try{Un=await tD(t,Xt.storylineId,pt)}catch{}Un||(Tt=!0)}if(pi==="cartoon"&&Xt.storylineId)try{const Un=Ce!=="genesis.md",ts=`storylineId=${Xt.storylineId}`+(Un&&Xt.plotIndex!=null?`&plotIndex=${Xt.plotIndex}`:""),ha=await t(`/api/publish/public-title?${ts}`);if(ha.ok){const pr=await ha.json(),Ar=Un?{plots:pr.plotTitle!=null?[{plotIndex:Xt.plotIndex,title:pr.plotTitle}]:[]}:{title:pr.storylineTitle},nn=MD({fileName:Ce,detail:Ar,plotIndex:Xt.plotIndex});nn.ok||(Je=DD(nn))}}catch{}}}catch{}}Je&&E(Je),v(Tt?"Published, but cover upload failed — set it later from Edit Story.":"Published!")}catch(Et){const $t=Et instanceof Error?Et.message:"Publish failed";v(`Error: ${$t}`)}finally{setTimeout(()=>{d(null),v("")},3e3)}return ot&&!Tt},[t,Be,A]),Dt=C.useCallback(te=>{te.startsWith("_new_")&&($(Ce=>Ce.filter(Le=>Le!==te)),wt.current.delete(te),hi.current.delete(te),re.current.delete(te),xe.current.delete(te),ie(Ce=>{if(!(te in Ce))return Ce;const Le={...Ce};return delete Le[te],Le}),F(Ce=>{if(!(te in Ce))return Ce;const Le={...Ce};return delete Le[te],Le}))},[]);C.useEffect(()=>{const te=Le=>{be(new Set(Le.filter(Xe=>Xe.hasStructure).map(Xe=>Xe.name))),Ee(new Set(Le.filter(Xe=>Xe.hasGenesis).map(Xe=>Xe.name)));const ft={},bt={},pt={},Tt={},Je={},ot={};for(const Xe of Le)ft[Xe.name]=Xe.contentType||"fiction",bt[Xe.name]=Xe.language,pt[Xe.name]=Xe.genre,Tt[Xe.name]=Xe.isNsfw,Je[Xe.name]=Xe.agentProvider,Xe.title&&(ot[Xe.name]=Xe.title);je(ft),we(bt),mt(pt),Ae(Tt),ai(Je),Mt(ot)};t("/api/stories").then(Le=>Le.ok?Le.json():null).then(Le=>{Le!=null&&Le.stories&&te(Le.stories)}).catch(()=>{});const Ce=setInterval(async()=>{try{const Le=await t("/api/stories");if(Le.ok){const ft=await Le.json();te(ft.stories)}}catch{}},5e3);return()=>clearInterval(Ce)},[t]);const Bt=!!N&&N.codex.installed&&N.codex.imageGeneration==="enabled",di=!!N&&!Bt,kt=C.useCallback(async()=>{try{await navigator.clipboard.writeText("codex features enable image_generation"),w(!0),setTimeout(()=>w(!1),2e3)}catch{}},[]),Ci=C.useCallback(async()=>{if(!i||i.startsWith("_new_"))return;const te=i;if((await t(`/api/stories/${te}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:"cartoon",agentProvider:"codex"})})).ok){ai(Le=>({...Le,[te]:"codex"})),F(Le=>({...Le,[te]:"codex"}));try{const Le=await t("/api/stories");if(Le.ok){const ft=await Le.json();if(ft!=null&&ft.stories){const bt={};for(const pt of ft.stories)bt[pt.name]=pt.agentProvider;ai(bt)}}}catch{}}},[t,i]),fi=C.useCallback(te=>{i===te&&(s(null),o(null))},[i]),Gt=i?oe[i]??zt[i]:void 0,fn=Rf(i,Be,wt.current),de=aD(fn,Gt,i),Re=!!i&&fn==="cartoon",We=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",st=C.useCallback(te=>{const Ce=i;if(Ce)switch(te){case"progress":h(null),o(null);break;case"story-info":h("story-info");break;case"episodes":h("episodes");break;case"whitepaper":me(Ce,"structure.md");break;case"genesis":me(Ce,"genesis.md");break;case"publish":h("publish");break}},[i,me]),nt=C.useCallback(te=>{i&&(te.genre!==void 0&&mt(Ce=>({...Ce,[i]:te.genre||void 0})),te.language!==void 0&&we(Ce=>({...Ce,[i]:te.language||void 0})),te.isNsfw!==void 0&&Ae(Ce=>({...Ce,[i]:te.isNsfw})))},[i]);return f.jsxs("div",{ref:Qe,className:"h-[calc(100vh-3.5rem)] flex",children:[f.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:f.jsx(_C,{authFetch:t,selectedStory:i,selectedFile:a,onSelectFile:me,onNewStory:ge,untitledSessions:J})}),f.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${L} 0 0`},children:f.jsx(FE,{token:e,storyName:i,authFetch:t,onSelectStory:Oe,onDestroySession:Dt,onArchiveStory:fi,confirmedStories:ue,renameRef:Fe,bypassStories:ae,agentProviders:oe,readiness:N,contentType:Rf(i,Be,wt.current),needsProviderRepair:de,onRepairProvider:Ci})}),f.jsx("div",{onMouseDown:ut,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Lf,cursor:"col-resize",background:"var(--border)"},children:f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),f.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),f.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-L} 0 0`},children:[Re&&i&&f.jsx(ND,{storyTitle:Ve[i]||i,active:We,onSelect:st}),Re&&c==="story-info"&&i?f.jsx(TD,{storyName:i,authFetch:t,onSaved:nt}):Re&&c==="episodes"&&i?f.jsx(jD,{storyName:i,authFetch:t,onOpenFile:me}):Re&&c==="publish"&&i?f.jsx(AD,{storyName:i,authFetch:t,onOpenFile:me,onOpenStoryInfo:()=>h("story-info"),onPublish:it,publishingFile:p,genre:tt[i],language:Ze[i],isNsfw:Ge[i],refreshKey:x}):i&&!a?f.jsx(pD,{storyName:i,authFetch:t,onOpenFile:me}):f.jsx(fD,{storyName:i,fileName:a,authFetch:t,onPublish:it,publishingFile:p,walletAddress:A,contentType:Rf(i,Be,wt.current)||"fiction",language:i?Ze[i]:void 0,genre:i?tt[i]:void 0,isNsfw:i?Ge[i]:void 0,hasGenesis:i?De.has(i):!1,onViewProgress:()=>o(null),onOpenFile:te=>i&&me(i,te),onViewPublish:()=>h("publish")}),b&&f.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:b}),y&&f.jsxs("div",{className:"px-3 py-2 bg-error/10 border-t border-error/40 text-xs text-error flex items-start justify-between gap-3","data-testid":"publish-block-error",role:"alert",children:[f.jsx("span",{children:y}),f.jsx("button",{type:"button",onClick:()=>E(null),className:"shrink-0 text-error/70 hover:text-error underline","data-testid":"publish-block-error-dismiss",children:"Dismiss"})]})]}),M&&f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:f.jsxs("div",{className:"bg-surface border border-border rounded-lg shadow-lg p-6 max-w-sm w-full space-y-4",children:[f.jsx("h3",{className:"text-sm font-serif font-medium text-foreground text-center",children:"New Story"}),f.jsxs("label",{className:"block space-y-1",children:[f.jsxs("span",{className:"text-[10px] font-medium text-muted",children:["Title ",f.jsx("span",{className:"text-accent",children:"*"})]}),f.jsx("input",{type:"text",value:he,onChange:te=>ye(te.target.value),placeholder:"e.g. 신의 세포","data-testid":"new-story-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Short description (optional)"}),f.jsx("input",{type:"text",value:U,onChange:te=>se(te.target.value),placeholder:"One line about the story","data-testid":"new-story-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Genre (optional)"}),f.jsxs("select",{value:W,onChange:te=>G(te.target.value),"data-testid":"new-story-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[f.jsx("option",{value:"",children:"— Select later —"}),rl.map(te=>f.jsx("option",{value:te,children:te},te))]})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Language"}),f.jsx("select",{value:Z,onChange:te=>I(te.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:Xr.map(te=>f.jsx("option",{value:te,children:te},te))})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Agent mode"}),f.jsxs("select",{value:j,onChange:te=>z(te.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-mode-select",children:[f.jsx("option",{value:"normal",children:"Normal (approve each action)"}),f.jsx("option",{value:"bypass",children:"Permissions Bypass (advanced)"})]}),j==="bypass"&&f.jsx("p",{className:"text-[10px] text-amber-700","data-testid":"agent-mode-warning",children:"Less safe: Claude can run actions without per-command approval."})]}),f.jsxs("label",{className:"block space-y-1",children:[f.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Provider"}),f.jsxs("select",{value:B,onChange:te=>_e(te.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-provider-select",children:[f.jsx("option",{value:"claude",children:"🤖 Claude (default)"}),f.jsx("option",{value:"codex",children:"🎨 Codex"})]}),f.jsx("p",{className:"text-[10px] text-muted","data-testid":"agent-provider-helper",children:B==="codex"?"Codex can generate clean cartoon images directly in the terminal.":"Claude prepares image prompts; you generate and upload clean images externally."})]}),f.jsx("p",{className:"text-xs text-muted text-center",children:"Choose a content type to create"}),!he.trim()&&f.jsx("p",{className:"text-[10px] text-amber-700 text-center","data-testid":"new-story-title-required",children:"Enter a title to create your story."}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("button",{onClick:()=>Te("fiction",Z,j,B),disabled:!he.trim(),"data-testid":"create-fiction",className:"border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[f.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Fiction"}),f.jsx("p",{className:"text-[11px] text-muted",children:"Novels, short stories, poetry"})]}),f.jsxs("div",{className:"space-y-1",children:[f.jsxs("button",{onClick:()=>Te("cartoon",Z,j,"codex"),disabled:di||!he.trim(),"data-testid":"create-cartoon",className:"w-full border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[f.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Cartoon"}),f.jsx("p",{className:"text-[11px] text-muted",children:"Comics, manga, webtoons"}),f.jsx("p",{className:"text-[11px] text-muted","data-testid":"cartoon-codex-note",children:"Cartoon mode requires Codex because the clean-image step needs image generation support."})]}),N&&!N.codex.installed&&f.jsxs("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-warning",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",f.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",f.jsx("span",{className:"font-mono",children:"codex login"}),") to create cartoons."]}),Su(N)&&f.jsx("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-auth-unknown",children:Op}),N&&N.codex.installed&&!Su(N)&&N.codex.imageGeneration!=="enabled"&&f.jsxs("div",{"data-testid":"cartoon-codex-warning",children:[f.jsx("p",{className:"text-[11px] text-amber-700 text-left",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this dialog:"}),f.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[f.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:"codex features enable image_generation"}),f.jsx("button",{type:"button","data-testid":"copy-codex-enable",onClick:kt,className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:Y?"Copied!":"Copy"})]})]})]})]}),f.jsx("button",{onClick:()=>X(!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 zD({token:e,onComplete:t}){const[i,s]=C.useState(!1),[a,o]=C.useState(null),[c,h]=C.useState(!1),p=async()=>{s(!0),o(null);try{const d=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),x=await d.json();if(!d.ok)throw new Error(x.error||"Wallet creation failed");h(!0)}catch(d){o(d instanceof Error?d.message:"Wallet creation failed")}s(!1)};return C.useEffect(()=>{p()},[]),f.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[f.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),f.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),i&&f.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),f.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"text-accent text-2xl",children:"✓"}),f.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),f.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function PD({token:e,onLogout:t}){const[i,s]=C.useState("home"),[a,o]=C.useState(0),[c,h]=C.useState(null),p=C.useCallback(async(d,x)=>fetch(d,{...x,headers:{...(x==null?void 0:x.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return C.useEffect(()=>{fetch("/api/health").then(d=>d.json()).then(d=>{d.version&&h(d.version)}).catch(()=>{})},[]),C.useEffect(()=>{async function d(){try{if(!(await(await p("/api/wallet")).json()).exists){s("wallet-setup");return}const b=await p("/api/stories");if(b.ok){const v=await b.json();o(v.stories.filter(y=>y.name!=="_example").length)}}catch{}}d()},[e]),f.jsxs("div",{className:"flex h-screen flex-col",children:[f.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{onClick:()=>{i!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:f.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),f.jsxs("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:["writer",c?` v${c}`:""]})]}),i!=="wallet-setup"&&f.jsxs("nav",{className:"flex items-center gap-4",children:[f.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${i==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),f.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${i==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),f.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${i==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),f.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),f.jsxs("main",{className:"flex-1 min-h-0",children:[i==="home"&&f.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[f.jsxs("div",{className:"text-center space-y-2",children:[f.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),f.jsx("p",{className:"text-muted text-sm",children:"Claude or Codex helps create your story. You publish it on-chain."})]}),f.jsxs("div",{className:"text-center space-y-3",children:[f.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&f.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),f.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[f.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),f.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[f.jsxs("li",{children:["Open the ",f.jsx("strong",{children:"Stories"})," tab — your writing agent launches in the terminal"]}),f.jsx("li",{children:"Tell the agent your story idea — it brainstorms, outlines, and writes"}),f.jsx("li",{children:"Review the live preview as the agent creates files"}),f.jsxs("li",{children:["Click ",f.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),f.jsxs("li",{children:["Earn 5% royalties on every trade at ",f.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]}),f.jsx("p",{className:"text-[11px] text-muted",children:"Fiction defaults to Claude; cartoon mode uses Codex for clean-image generation."})]}),f.jsx("div",{className:"text-center",children:f.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),f.jsx(yy,{token:e})]}),i==="stories"&&f.jsx(OD,{token:e,authFetch:p}),i==="dashboard"&&f.jsx(pC,{token:e}),i==="wallet-setup"&&f.jsx(zD,{token:e,onComplete:()=>s("home")}),i==="settings"&&f.jsx(dC,{token:e,onLogout:t})]})]})}function ID(){const[e,t]=C.useState(()=>localStorage.getItem("ows-token")),[i,s]=C.useState(null),[a,o]=C.useState(!0);C.useEffect(()=>{fetch("/api/auth/status").then(d=>d.json()).then(d=>s(d.configured)).catch(()=>s(null))},[]),C.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(d=>{d.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async d=>{try{const x=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:d})}),_=await x.json();return x.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},h=async d=>{try{const x=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:d})}),_=await x.json();return x.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||i===null?f.jsx("div",{className:"flex h-screen items-center justify-center",children:f.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):i?e?f.jsx(PD,{token:e,onLogout:p}):f.jsx(uC,{onLogin:c}):f.jsx(hC,{onSetup:h})}cC.createRoot(document.getElementById("root")).render(f.jsx(tC.StrictMode,{children:f.jsx(ID,{})}));export{Mp as M,su as a,k3 as b,MM as c,N3 as d,ru as l,DS as s,I3 as t,qD as v};
|