diff --git a/app/routes/stories.ts b/app/routes/stories.ts index af5b204..f51d82a 100644 --- a/app/routes/stories.ts +++ b/app/routes/stories.ts @@ -101,6 +101,59 @@ stories.get("/", (c) => { return c.json({ stories: result }); }); +const ARCHIVED_DIR = path.join(STORIES_DIR, ".archived"); + +/** GET /api/stories/archived — list archived stories */ +stories.get("/archived", (c) => { + if (!fs.existsSync(ARCHIVED_DIR)) { + return c.json({ stories: [] }); + } + + const dirs = fs.readdirSync(ARCHIVED_DIR, { withFileTypes: true }) + .filter((d) => d.isDirectory() && !d.name.startsWith(".")) + .map((d) => d.name) + .sort(); + + const result = dirs.map((name) => scanStory(path.join(ARCHIVED_DIR, name), name)); + return c.json({ stories: result }); +}); + +/** POST /api/stories/archive — move story to .archived/ */ +stories.post("/archive", async (c) => { + const body = await c.req.json<{ name: string }>(); + const name = safeName(body.name); + if (!name) return c.json({ error: "Invalid story name" }, 400); + + const src = path.join(STORIES_DIR, name); + if (!fs.existsSync(src)) return c.json({ error: "Story not found" }, 404); + if (!fs.existsSync(path.join(src, "structure.md"))) { + return c.json({ error: "Only stories with structure.md can be archived" }, 400); + } + + fs.mkdirSync(ARCHIVED_DIR, { recursive: true }); + const dest = path.join(ARCHIVED_DIR, name); + if (fs.existsSync(dest)) return c.json({ error: "Already archived" }, 409); + + fs.renameSync(src, dest); + return c.json({ ok: true }); +}); + +/** POST /api/stories/restore — move story back from .archived/ */ +stories.post("/restore", async (c) => { + const body = await c.req.json<{ name: string }>(); + const name = safeName(body.name); + if (!name) return c.json({ error: "Invalid story name" }, 400); + + const src = path.join(ARCHIVED_DIR, name); + if (!fs.existsSync(src)) return c.json({ error: "Archived story not found" }, 404); + + const dest = path.join(STORIES_DIR, name); + if (fs.existsSync(dest)) return c.json({ error: "Story already exists" }, 409); + + fs.renameSync(src, dest); + return c.json({ ok: true }); +}); + /** GET /api/stories/:name — single story detail */ stories.get("/:name", (c) => { const name = safeName(c.req.param("name")); diff --git a/app/web/components/StoriesPage.tsx b/app/web/components/StoriesPage.tsx index 17834dc..c6e5887 100644 --- a/app/web/components/StoriesPage.tsx +++ b/app/web/components/StoriesPage.tsx @@ -278,6 +278,42 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { } }, []); + // Track confirmed stories (those with structure.md) for Archive gating + const [confirmedStories, setConfirmedStories] = useState>(new Set()); + useEffect(() => { + authFetch("/api/stories").then((res) => res.ok ? res.json() : null).then((data) => { + if (data?.stories) { + setConfirmedStories(new Set( + (data.stories as { name: string; hasStructure: boolean }[]) + .filter((s) => s.hasStructure) + .map((s) => s.name) + )); + } + }).catch(() => {}); + const interval = setInterval(async () => { + try { + const res = await authFetch("/api/stories"); + if (res.ok) { + const data = await res.json(); + setConfirmedStories(new Set( + (data.stories as { name: string; hasStructure: boolean }[]) + .filter((s) => s.hasStructure) + .map((s) => s.name) + )); + } + } catch { /* ignore */ } + }, 5000); + return () => clearInterval(interval); + }, [authFetch]); + + const handleArchiveStory = useCallback((name: string) => { + // Archive API already called by TerminalPanel — just clear selection + if (selectedStory === name) { + setSelectedStory(null); + setSelectedFile(null); + } + }, [selectedStory]); + return (
{/* Story Browser Sidebar */} @@ -294,7 +330,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { {/* Terminal — sized by ratio of available space */}
- +
{/* Drag Handle */} diff --git a/app/web/components/StoryBrowser.tsx b/app/web/components/StoryBrowser.tsx index ed283c8..6889b9d 100644 --- a/app/web/components/StoryBrowser.tsx +++ b/app/web/components/StoryBrowser.tsx @@ -42,7 +42,9 @@ const STATUS_COLOR: Record = { export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectFile, onNewStory, untitledSessions = [] }: StoryBrowserProps) { const [stories, setStories] = useState([]); + const [archivedStories, setArchivedStories] = useState([]); const [expanded, setExpanded] = useState>(new Set()); + const [showArchives, setShowArchives] = useState(false); const loadStories = useCallback(async () => { try { @@ -54,6 +56,30 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF } catch { /* ignore */ } }, [authFetch]); + const loadArchivedStories = useCallback(async () => { + try { + const res = await authFetch("/api/stories/archived"); + if (res.ok) { + const data = await res.json(); + setArchivedStories(data.stories); + } + } catch { /* ignore */ } + }, [authFetch]); + + const handleRestore = useCallback(async (name: string) => { + try { + const res = await authFetch("/api/stories/restore", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ name }), + }); + if (res.ok) { + loadArchivedStories(); + loadStories(); + } + } catch { /* ignore */ } + }, [authFetch, loadArchivedStories, loadStories]); + useEffect(() => { // eslint-disable-next-line react-hooks/set-state-in-effect -- initial load + polling loadStories(); @@ -61,6 +87,14 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF return () => clearInterval(interval); }, [loadStories]); + // Load archived stories when archives view is shown + useEffect(() => { + if (showArchives) { + // eslint-disable-next-line react-hooks/set-state-in-effect -- initial load for archives + loadArchivedStories(); + } + }, [showArchives, loadArchivedStories]); + // Auto-expand selected story useEffect(() => { if (selectedStory) { @@ -111,6 +145,45 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF return [...files].sort((a, b) => order(a.file) - order(b.file)); }; + if (showArchives) { + return ( +
+
+ Archives + {archivedStories.length} +
+
+ +
+
+ {archivedStories.length === 0 ? ( +
+

No archived stories.

+
+ ) : ( + archivedStories.map((story) => ( +
+ {story.title || story.name} + +
+ )) + )} +
+
+ ); + } + return (
@@ -184,6 +257,14 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF )) )}
+
+ +
); } diff --git a/app/web/components/TerminalPanel.tsx b/app/web/components/TerminalPanel.tsx index 3b29f8b..01d3a36 100644 --- a/app/web/components/TerminalPanel.tsx +++ b/app/web/components/TerminalPanel.tsx @@ -10,6 +10,8 @@ interface TerminalPanelProps { authFetch: (url: string, opts?: RequestInit) => Promise; onSelectStory?: (storyName: string) => void; onDestroySession?: (storyName: string) => void; + onArchiveStory?: (storyName: string) => void; + confirmedStories?: Set; } interface TerminalSession { @@ -103,12 +105,13 @@ async function deleteScrollback(storyName: string): Promise { // Sessions live outside React state to avoid ref-in-effect lint issues const sessions = new Map(); -export function TerminalPanel({ token, storyName, authFetch, onSelectStory, onDestroySession }: TerminalPanelProps) { +export function TerminalPanel({ token, storyName, authFetch, onSelectStory, onDestroySession, onArchiveStory, confirmedStories }: TerminalPanelProps) { const wrapperRef = useRef(null); const authFetchRef = useRef(authFetch); const [sessionList, setSessionList] = useState([]); const [disconnected, setDisconnected] = useState>(new Set()); const [confirmingDiscard, setConfirmingDiscard] = useState(null); + const [confirmingArchive, setConfirmingArchive] = useState(null); const connectWsRef = useRef<(name: string, session: TerminalSession, resume: boolean) => void>(() => {}); @@ -424,15 +427,22 @@ export function TerminalPanel({ token, storyName, authFetch, onSelectStory, onDe
)) } - {/* Cancel button for active untitled session */} - {storyName?.startsWith("_new_") && ( + {/* Cancel button for untitled / Archive button for confirmed stories */} + {storyName?.startsWith("_new_") ? ( - )} + ) : storyName && onArchiveStory && confirmedStories?.has(storyName) ? ( + + ) : null} )} @@ -480,6 +490,46 @@ export function TerminalPanel({ token, storyName, authFetch, onSelectStory, onDe )} + {/* Archive confirmation overlay */} + {confirmingArchive && ( +
+
+

Archive this story?

+

+ You can restore it later from the Archives view. +

+
+ + +
+
+
+ )} + {/* Reconnect overlay */} {isDisconnected && storyName && (
diff --git a/app/web/dist/assets/index-9QhAhFuv.js b/app/web/dist/assets/index-9QhAhFuv.js new file mode 100644 index 0000000..f8bf1d7 --- /dev/null +++ b/app/web/dist/assets/index-9QhAhFuv.js @@ -0,0 +1,130 @@ +(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 n(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=n(a);fetch(a.href,o)}})();function gu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fh={exports:{}},ql={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Kg;function mx(){if(Kg)return ql;Kg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(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 f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return ql.Fragment=t,ql.jsx=n,ql.jsxs=n,ql}var Xg;function _x(){return Xg||(Xg=1,Fh.exports=mx()),Fh.exports}var S=_x(),qh={exports:{}},we={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var $g;function gx(){if($g)return we;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=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"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function y(T){return T===null||typeof T!="object"?null:(T=b&&T[b]||T["@@iterator"],typeof T=="function"?T:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,N={};function M(T,X,C){this.props=T,this.context=X,this.refs=N,this.updater=C||x}M.prototype.isReactComponent={},M.prototype.setState=function(T,X){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,X,"setState")},M.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function G(){}G.prototype=M.prototype;function U(T,X,C){this.props=T,this.context=X,this.refs=N,this.updater=C||x}var Q=U.prototype=new G;Q.constructor=U,E(Q,M.prototype),Q.isPureReactComponent=!0;var K=Array.isArray;function O(){}var ee={H:null,A:null,T:null,S:null},oe=Object.prototype.hasOwnProperty;function de(T,X,C){var se=C.ref;return{$$typeof:e,type:T,key:X,ref:se!==void 0?se:null,props:C}}function q(T,X){return de(T.type,X,T.props)}function B(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function D(T){var X={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(C){return X[C]})}var j=/\/+/g;function P(T,X){return typeof T=="object"&&T!==null&&T.key!=null?D(""+T.key):X.toString(36)}function L(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(O,O):(T.status="pending",T.then(function(X){T.status==="pending"&&(T.status="fulfilled",T.value=X)},function(X){T.status==="pending"&&(T.status="rejected",T.reason=X)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function A(T,X,C,se,pe){var he=typeof T;(he==="undefined"||he==="boolean")&&(T=null);var be=!1;if(T===null)be=!0;else switch(he){case"bigint":case"string":case"number":be=!0;break;case"object":switch(T.$$typeof){case e:case t:be=!0;break;case g:return be=T._init,A(be(T._payload),X,C,se,pe)}}if(be)return pe=pe(T),be=se===""?"."+P(T,0):se,K(pe)?(C="",be!=null&&(C=be.replace(j,"$&/")+"/"),A(pe,X,C,"",function(jt){return jt})):pe!=null&&(B(pe)&&(pe=q(pe,C+(pe.key==null||T&&T.key===pe.key?"":(""+pe.key).replace(j,"$&/")+"/")+be)),X.push(pe)),1;be=0;var Te=se===""?".":se+":";if(K(T))for(var Re=0;Re>>1,k=A[le];if(0>>1;lea(C,Y))sea(pe,C)?(A[le]=pe,A[se]=Y,le=se):(A[le]=C,A[X]=Y,le=X);else if(sea(pe,Y))A[le]=pe,A[se]=Y,le=se;else break e}}return I}function a(A,I){var Y=A.sortIndex-I.sortIndex;return Y!==0?Y:A.id-I.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,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,E=!1,N=!1,M=typeof setTimeout=="function"?setTimeout:null,G=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function Q(A){for(var I=n(h);I!==null;){if(I.callback===null)s(h);else if(I.startTime<=A)s(h),I.sortIndex=I.expirationTime,t(p,I);else break;I=n(h)}}function K(A){if(E=!1,Q(A),!x)if(n(p)!==null)x=!0,O||(O=!0,D());else{var I=n(h);I!==null&&L(K,I.startTime-A)}}var O=!1,ee=-1,oe=5,de=-1;function q(){return N?!0:!(e.unstable_now()-deA&&q());){var le=_.callback;if(typeof le=="function"){_.callback=null,b=_.priorityLevel;var k=le(_.expirationTime<=A);if(A=e.unstable_now(),typeof k=="function"){_.callback=k,Q(A),I=!0;break t}_===n(p)&&s(p),Q(A)}else s(p);_=n(p)}if(_!==null)I=!0;else{var T=n(h);T!==null&&L(K,T.startTime-A),I=!1}}break e}finally{_=null,b=Y,y=!1}I=void 0}}finally{I?D():O=!1}}}var D;if(typeof U=="function")D=function(){U(B)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,P=j.port2;j.port1.onmessage=B,D=function(){P.postMessage(null)}}else D=function(){M(B,0)};function L(A,I){ee=M(function(){A(e.unstable_now())},I)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125le?(A.sortIndex=Y,t(h,A),n(p)===null&&A===n(h)&&(E?(G(ee),ee=-1):E=!0,L(K,Y-le))):(A.sortIndex=k,t(p,A),x||y||(x=!0,O||(O=!0,D()))),A},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(A){var I=b;return function(){var Y=b;b=I;try{return A.apply(this,arguments)}finally{b=Y}}}})(Vh)),Vh}var Qg;function bx(){return Qg||(Qg=1,Yh.exports=yx()),Yh.exports}var Kh={exports:{}},Vt={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jg;function Sx(){if(Jg)return Vt;Jg=1;var e=Sd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Kh.exports=Sx(),Kh.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var tv;function wx(){if(tv)return Wl;tv=1;var e=bx(),t=Sd(),n=xx();function s(i){var r="https://react.dev/errors/"+i;if(1k||(i.current=le[k],le[k]=null,k--)}function C(i,r){k++,le[k]=i.current,i.current=r}var se=T(null),pe=T(null),he=T(null),be=T(null);function Te(i,r){switch(C(he,r),C(pe,i),C(se,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?_g(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=_g(r),i=gg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}X(se),C(se,i)}function Re(){X(se),X(pe),X(he)}function jt(i){i.memoizedState!==null&&C(be,i);var r=se.current,l=gg(r,i.type);r!==l&&(C(pe,i),C(se,l))}function Zt(i){pe.current===i&&(X(se),X(pe)),be.current===i&&(X(be),Ul._currentValue=Y)}var ai,He;function yi(i){if(ai===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ai=r&&r[1]||"",He=-1)":-1d||R[u]!==W[d]){var Z=` +`+R[u].replace(" at new "," at ");return i.displayName&&Z.includes("")&&(Z=Z.replace("",i.displayName)),Z}while(1<=u&&0<=d);break}}}finally{Gr=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?yi(l):""}function Ca(i,r){switch(i.tag){case 26:case 27:case 5:return yi(i.type);case 16:return yi("Lazy");case 13:return i.child!==r&&r!==null?yi("Suspense Fallback"):yi("Suspense");case 19:return yi("SuspenseList");case 0:case 15:return Zr(i.type,!1);case 11:return Zr(i.type.render,!1);case 1:return Zr(i.type,!0);case 31:return yi("Activity");default:return""}}function ka(i){try{var r="",l=null;do r+=Ca(i,l),l=i,i=i.return;while(i);return r}catch(u){return` +Error generating stack: `+u.message+` +`+u.stack}}var Qr=Object.prototype.hasOwnProperty,Jr=e.unstable_scheduleCallback,Zs=e.unstable_cancelCallback,Tu=e.unstable_shouldYield,Au=e.unstable_requestPaint,Qt=e.unstable_now,Du=e.unstable_getCurrentPriorityLevel,J=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,Se=e.unstable_NormalPriority,Me=e.unstable_LowPriority,qe=e.unstable_IdlePriority,bi=e.log,fn=e.unstable_setDisableYieldValue,Jt=null,xt=null;function oi(i){if(typeof bi=="function"&&fn(i),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(Jt,i)}catch{}}var Ge=Math.clz32?Math.clz32:t0,Hn=Math.log,Ki=Math.LN2;function t0(i){return i>>>=0,i===0?32:31-(Hn(i)/Ki|0)|0}var Ea=256,Ta=262144,Aa=4194304;function yr(i){var r=i&42;if(r!==0)return r;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Da(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=yr(u):(v&=w,v!==0?d=yr(v):l||(l=w&~i,l!==0&&(d=yr(l))))):(w=u&~m,w!==0?d=yr(w):v!==0?d=yr(v):l||(l=u&~i,l!==0&&(d=yr(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function Qs(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function i0(i,r){switch(i){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 Zd(){var i=Aa;return Aa<<=1,(Aa&62914560)===0&&(Aa=4194304),i}function Ru(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Js(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function n0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,R=i.expirationTimes,W=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var u0=/[\n"\\]/g;function Ni(i){return i.replace(u0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ou(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Bi(r)):i.value!==""+Bi(r)&&(i.value=""+Bi(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?ju(i,v,Bi(r)):l!=null?ju(i,v,Bi(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Bi(w):i.removeAttribute("name")}function cp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){zu(i);return}l=l!=null?""+Bi(l):"",r=r!=null?""+Bi(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),zu(i)}function ju(i,r,l){r==="number"&&Ba(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function ss(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mn)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Fu=!1}var Pn=null,qu=null,La=null;function gp(){if(La)return La;var i,r=qu,l=r.length,u,d="value"in Pn?Pn.value:Pn.textContent,m=d.length;for(i=0;i=ll),wp=" ",Cp=!1;function kp(i,r){switch(i){case"keyup":return j0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ep(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var us=!1;function U0(i,r){switch(i){case"compositionend":return Ep(r);case"keypress":return r.which!==32?null:(Cp=!0,wp);case"textInput":return i=r.data,i===wp&&Cp?null:i;default:return null}}function P0(i,r){if(us)return i==="compositionend"||!Xu&&kp(i,r)?(i=gp(),La=qu=Pn=null,us=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Lp(l)}}function Op(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Op(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function jp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ba(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ba(i.document)}return r}function Zu(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var X0=mn&&"documentMode"in document&&11>=document.documentMode,cs=null,Qu=null,cl=null,Ju=!1;function Hp(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ju||cs==null||cs!==Ba(u)||(u=cs,"selectionStart"in u&&Zu(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}),cl&&ul(cl,u)||(cl=u,u=Ao(Qu,"onSelect"),0>=v,d-=v,Ji=1<<32-Ge(r)+d|l<ke?(Oe=_e,_e=null):Oe=_e.sibling;var Ie=V(H,_e,F[ke],te);if(Ie===null){_e===null&&(_e=Oe);break}i&&_e&&Ie.alternate===null&&r(H,_e),z=m(Ie,z,ke),Pe===null?ge=Ie:Pe.sibling=Ie,Pe=Ie,_e=Oe}if(ke===F.length)return l(H,_e),je&&gn(H,ke),ge;if(_e===null){for(;keke?(Oe=_e,_e=null):Oe=_e.sibling;var or=V(H,_e,Ie.value,te);if(or===null){_e===null&&(_e=Oe);break}i&&_e&&or.alternate===null&&r(H,_e),z=m(or,z,ke),Pe===null?ge=or:Pe.sibling=or,Pe=or,_e=Oe}if(Ie.done)return l(H,_e),je&&gn(H,ke),ge;if(_e===null){for(;!Ie.done;ke++,Ie=F.next())Ie=ie(H,Ie.value,te),Ie!==null&&(z=m(Ie,z,ke),Pe===null?ge=Ie:Pe.sibling=Ie,Pe=Ie);return je&&gn(H,ke),ge}for(_e=u(_e);!Ie.done;ke++,Ie=F.next())Ie=$(_e,H,ke,Ie.value,te),Ie!==null&&(i&&Ie.alternate!==null&&_e.delete(Ie.key===null?ke:Ie.key),z=m(Ie,z,ke),Pe===null?ge=Ie:Pe.sibling=Ie,Pe=Ie);return i&&_e.forEach(function(px){return r(H,px)}),je&&gn(H,ke),ge}function Xe(H,z,F,te){if(typeof F=="object"&&F!==null&&F.type===E&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ge=F.key;z!==null;){if(z.key===ge){if(ge=F.type,ge===E){if(z.tag===7){l(H,z.sibling),te=d(z,F.props.children),te.return=H,H=te;break e}}else if(z.elementType===ge||typeof ge=="object"&&ge!==null&&ge.$$typeof===oe&&Rr(ge)===z.type){l(H,z.sibling),te=d(z,F.props),_l(te,F),te.return=H,H=te;break e}l(H,z);break}else r(H,z);z=z.sibling}F.type===E?(te=kr(F.props.children,H.mode,te,F.key),te.return=H,H=te):(te=Wa(F.type,F.key,F.props,null,H.mode,te),_l(te,F),te.return=H,H=te)}return v(H);case x:e:{for(ge=F.key;z!==null;){if(z.key===ge)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(H,z.sibling),te=d(z,F.children||[]),te.return=H,H=te;break e}else{l(H,z);break}else r(H,z);z=z.sibling}te=lc(F,H.mode,te),te.return=H,H=te}return v(H);case oe:return F=Rr(F),Xe(H,z,F,te)}if(L(F))return me(H,z,F,te);if(D(F)){if(ge=D(F),typeof ge!="function")throw Error(s(150));return F=ge.call(F),ye(H,z,F,te)}if(typeof F.then=="function")return Xe(H,z,Za(F),te);if(F.$$typeof===U)return Xe(H,z,Ka(H,F),te);Qa(H,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(H,z.sibling),te=d(z,F),te.return=H,H=te):(l(H,z),te=sc(F,H.mode,te),te.return=H,H=te),v(H)):l(H,z)}return function(H,z,F,te){try{ml=0;var ge=Xe(H,z,F,te);return Ss=null,ge}catch(_e){if(_e===bs||_e===$a)throw _e;var Pe=xi(29,_e,null,H.mode);return Pe.lanes=te,Pe.return=H,Pe}finally{}}}var Br=am(!0),om=am(!1),Yn=!1;function vc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Vn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Kn(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(Fe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=qa(i),Yp(i,null,l),r}return Fa(i,u,r,l),qa(i)}function gl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Jd(i,l)}}function bc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var Sc=!1;function vl(){if(Sc){var i=ys;if(i!==null)throw i}}function yl(i,r,l,u){Sc=!1;var d=i.updateQueue;Yn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var R=w,W=R.next;R.next=null,v===null?m=W:v.next=W,v=R;var Z=i.alternate;Z!==null&&(Z=Z.updateQueue,w=Z.lastBaseUpdate,w!==v&&(w===null?Z.firstBaseUpdate=W:w.next=W,Z.lastBaseUpdate=R))}if(m!==null){var ie=d.baseState;v=0,Z=W=R=null,w=m;do{var V=w.lane&-536870913,$=V!==w.lane;if($?(ze&V)===V:(u&V)===V){V!==0&&V===vs&&(Sc=!0),Z!==null&&(Z=Z.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var me=i,ye=w;V=r;var Xe=l;switch(ye.tag){case 1:if(me=ye.payload,typeof me=="function"){ie=me.call(Xe,ie,V);break e}ie=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=ye.payload,V=typeof me=="function"?me.call(Xe,ie,V):me,V==null)break e;ie=_({},ie,V);break e;case 2:Yn=!0}}V=w.callback,V!==null&&(i.flags|=64,$&&(i.flags|=8192),$=d.callbacks,$===null?d.callbacks=[V]:$.push(V))}else $={lane:V,tag:w.tag,payload:w.payload,callback:w.callback,next:null},Z===null?(W=Z=$,R=ie):Z=Z.next=$,v|=V;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;$=w,w=$.next,$.next=null,d.lastBaseUpdate=$,d.shared.pending=null}}while(!0);Z===null&&(R=ie),d.baseState=R,d.firstBaseUpdate=W,d.lastBaseUpdate=Z,m===null&&(d.shared.lanes=0),Qn|=v,i.lanes=v,i.memoizedState=ie}}function um(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function cm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=A.T,w={};A.T=w,Pc(i,!1,r,l);try{var R=d(),W=A.S;if(W!==null&&W(w,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var Z=n1(R,u);xl(i,r,Z,Ti(i))}else xl(i,r,u,Ti(i))}catch(ie){xl(i,r,{then:function(){},status:"rejected",reason:ie},Ti())}finally{I.p=m,v!==null&&w.types!==null&&(v.types=w.types),A.T=v}}function u1(){}function Hc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Fm(i).queue;Im(i,d,r,Y,l===null?u1:function(){return qm(i),l(u)})}function Fm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:Y},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function qm(i){var r=Fm(i);r.next===null&&(r=i.alternate.memoizedState),xl(i,r.next.queue,{},Ti())}function Uc(){return Pt(Ul)}function Wm(){return dt().memoizedState}function Ym(){return dt().memoizedState}function c1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ti();i=Vn(l);var u=Kn(r,i,l);u!==null&&(mi(u,r,l),gl(u,r,l)),r={cache:pc()},i.payload=r;return}r=r.return}}function h1(i,r,l){var u=Ti();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},oo(i)?Km(r,l):(l=nc(i,r,l,u),l!==null&&(mi(l,i,u),Xm(l,r,u)))}function Vm(i,r,l){var u=Ti();xl(i,r,l,u)}function xl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(oo(i))Km(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,Si(w,v))return Fa(i,r,d,0),Ze===null&&Ia(),!1}catch{}finally{}if(l=nc(i,r,d,u),l!==null)return mi(l,i,u),Xm(l,r,u),!0}return!1}function Pc(i,r,l,u){if(u={lane:2,revertLane:vh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},oo(i)){if(r)throw Error(s(479))}else r=nc(i,l,u,2),r!==null&&mi(r,i,2)}function oo(i){var r=i.alternate;return i===Ce||r!==null&&r===Ce}function Km(i,r){ws=to=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Xm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Jd(i,l)}}var wl={readContext:Pt,use:ro,useCallback:at,useContext:at,useEffect:at,useImperativeHandle:at,useLayoutEffect:at,useInsertionEffect:at,useMemo:at,useReducer:at,useRef:at,useState:at,useDebugValue:at,useDeferredValue:at,useTransition:at,useSyncExternalStore:at,useId:at,useHostTransitionStatus:at,useFormState:at,useActionState:at,useOptimistic:at,useMemoCache:at,useCacheRefresh:at};wl.useEffectEvent=at;var $m={readContext:Pt,use:ro,useCallback:function(i,r){return ei().memoizedState=[i,r===void 0?null:r],i},useContext:Pt,useEffect:Bm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,lo(4194308,4,Om.bind(null,r,i),l)},useLayoutEffect:function(i,r){return lo(4194308,4,i,r)},useInsertionEffect:function(i,r){lo(4,2,i,r)},useMemo:function(i,r){var l=ei();r=r===void 0?null:r;var u=i();if(Nr){oi(!0);try{i()}finally{oi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=ei();if(l!==void 0){var d=l(r);if(Nr){oi(!0);try{l(r)}finally{oi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=h1.bind(null,Ce,i),[u.memoizedState,i]},useRef:function(i){var r=ei();return i={current:i},r.memoizedState=i},useState:function(i){i=Nc(i);var r=i.queue,l=Vm.bind(null,Ce,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Oc,useDeferredValue:function(i,r){var l=ei();return jc(l,i,r)},useTransition:function(){var i=Nc(!1);return i=Im.bind(null,Ce,i.queue,!0,!1),ei().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ce,d=ei();if(je){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(ze&127)!==0||_m(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Bm(vm.bind(null,u,m,i),[i]),u.flags|=2048,ks(9,{destroy:void 0},gm.bind(null,u,m,l,r),null),l},useId:function(){var i=ei(),r=Ze.identifierPrefix;if(je){var l=en,u=Ji;l=(u&~(1<<32-Ge(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=io++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Ht]=r,m[ui]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Ft(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&wn(r)}}return tt(r),eh(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&wn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=he.current,_s(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Ut,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Ht]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||pg(i.nodeValue,l)),i||qn(r,!0)}else i=Do(i).createTextNode(u),i[Ht]=r,r.stateNode=i}return tt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=_s(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Ht]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),i=!1}else l=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Ci(r),r):(Ci(r),null);if((r.flags&128)!==0)throw Error(s(558))}return tt(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=_s(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Ht]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),d=!1}else d=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(Ci(r),r):(Ci(r),null)}return Ci(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),po(r,r.updateQueue),tt(r),null);case 4:return Re(),i===null&&xh(r.stateNode.containerInfo),tt(r),null;case 10:return yn(r.type),tt(r),null;case 19:if(X(ft),u=r.memoizedState,u===null)return tt(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)kl(u,!1);else{if(ot!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=eo(i),m!==null){for(r.flags|=128,kl(u,!1),i=m.updateQueue,r.updateQueue=i,po(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Vp(l,i),l=l.sibling;return C(ft,ft.current&1|2),je&&gn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Qt()>yo&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304)}else{if(!d)if(i=eo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,po(r,i),kl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!je)return tt(r),null}else 2*Qt()-u.renderingStartTime>yo&&l!==536870912&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Qt(),i.sibling=null,l=ft.current,C(ft,d?l&1|2:l&1),je&&gn(r,u.treeForkCount),i):(tt(r),null);case 22:case 23:return Ci(r),wc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(tt(r),r.subtreeFlags&6&&(r.flags|=8192)):tt(r),l=r.updateQueue,l!==null&&po(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&X(Dr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),yn(mt),tt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function _1(i,r){switch(oc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return yn(mt),Re(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return Zt(r),null;case 31:if(r.memoizedState!==null){if(Ci(r),r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Ci(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return X(ft),null;case 4:return Re(),null;case 10:return yn(r.type),null;case 22:case 23:return Ci(r),wc(),i!==null&&X(Dr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return yn(mt),null;case 25:return null;default:return null}}function y_(i,r){switch(oc(r),r.tag){case 3:yn(mt),Re();break;case 26:case 27:case 5:Zt(r);break;case 4:Re();break;case 31:r.memoizedState!==null&&Ci(r);break;case 13:Ci(r);break;case 19:X(ft);break;case 10:yn(r.type);break;case 22:case 23:Ci(r),wc(),i!==null&&X(Dr);break;case 24:yn(mt)}}function El(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ye(r,r.return,w)}}function Gn(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var R=l,W=w;try{W()}catch(Z){Ye(d,R,Z)}}}u=u.next}while(u!==m)}}catch(Z){Ye(r,r.return,Z)}}function b_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{cm(r,l)}catch(u){Ye(i,i.return,u)}}}function S_(i,r,l){l.props=Lr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ye(i,r,u)}}function Tl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ye(i,r,d)}}function tn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ye(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ye(i,r,d)}else l.current=null}function x_(i){var r=i.type,l=i.memoizedProps,u=i.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(d){Ye(i,i.return,d)}}function th(i,r,l){try{var u=i.stateNode;H1(u,i.type,l,r),u[ui]=r}catch(d){Ye(i,i.return,d)}}function w_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&nr(i.type)||i.tag===4}function ih(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||w_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&nr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function nh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=pn));else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(nh(i,r,l),i=i.sibling;i!==null;)nh(i,r,l),i=i.sibling}function mo(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(mo(i,r,l),i=i.sibling;i!==null;)mo(i,r,l),i=i.sibling}function C_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Ft(r,u,l),r[Ht]=i,r[ui]=l}catch(m){Ye(i,i.return,m)}}var Cn=!1,vt=!1,rh=!1,k_=typeof WeakSet=="function"?WeakSet:Set,At=null;function g1(i,r){if(i=i.containerInfo,kh=Oo,i=jp(i),Zu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,R=-1,W=0,Z=0,ie=i,V=null;t:for(;;){for(var $;ie!==l||d!==0&&ie.nodeType!==3||(w=v+d),ie!==m||u!==0&&ie.nodeType!==3||(R=v+u),ie.nodeType===3&&(v+=ie.nodeValue.length),($=ie.firstChild)!==null;)V=ie,ie=$;for(;;){if(ie===i)break t;if(V===l&&++W===d&&(w=v),V===m&&++Z===u&&(R=v),($=ie.nextSibling)!==null)break;ie=V,V=ie.parentNode}ie=$}l=w===-1||R===-1?null:{start:w,end:R}}else l=null}l=l||{start:0,end:0}}else l=null;for(Eh={focusedElem:i,selectionRange:l},Oo=!1,At=r;At!==null;)if(r=At,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,At=i;else for(;At!==null;){switch(r=At,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Ft(m,u,l),m[Ht]=i,Tt(m),u=m;break e;case"link":var v=Mg("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=ye,ye=v);var H=zp(w,ye),z=zp(w,Xe);if(H&&z&&($.rangeCount!==1||$.anchorNode!==H.node||$.anchorOffset!==H.offset||$.focusNode!==z.node||$.focusOffset!==z.offset)){var F=ie.createRange();F.setStart(H.node,H.offset),$.removeAllRanges(),ye>Xe?($.addRange(F),$.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),$.addRange(F))}}}}for(ie=[],$=w;$=$.parentNode;)$.nodeType===1&&ie.push({element:$,left:$.scrollLeft,top:$.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,A.T=null,l=hh,hh=null;var m=er,v=Dn;if(wt=0,Rs=er=null,Dn=0,(Fe&6)!==0)throw Error(s(331));var w=Fe;if(Fe|=4,O_(m.current),N_(m,m.current,v,l),Fe=w,Nl(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(Jt,m)}catch{}return!0}finally{I.p=d,A.T=u,eg(i,r)}}function ig(i,r,l){r=zi(l,r),r=Wc(i.stateNode,r,2),i=Kn(i,r,2),i!==null&&(Js(i,2),nn(i))}function Ye(i,r,l){if(i.tag===3)ig(i,i,l);else for(;r!==null;){if(r.tag===3){ig(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Jn===null||!Jn.has(u))){i=zi(l,i),l=n_(2),u=Kn(r,l,2),u!==null&&(r_(l,u,r,i),Js(u,2),nn(u));break}}r=r.return}}function mh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new b1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(ah=!0,d.add(l),i=k1.bind(null,i,r,l),r.then(i,i))}function k1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(ze&l)===l&&(ot===4||ot===3&&(ze&62914560)===ze&&300>Qt()-vo?(Fe&2)===0&&Ms(i,0):oh|=l,Ds===ze&&(Ds=0)),nn(i)}function ng(i,r){r===0&&(r=Zd()),i=Cr(i,r),i!==null&&(Js(i,r),nn(i))}function E1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),ng(i,l)}function T1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),ng(i,l)}function A1(i,r){return Jr(i,r)}var ko=null,Ns=null,_h=!1,Eo=!1,gh=!1,ir=0;function nn(i){i!==Ns&&i.next===null&&(Ns===null?ko=Ns=i:Ns=Ns.next=i),Eo=!0,_h||(_h=!0,R1())}function Nl(i,r){if(!gh&&Eo){gh=!0;do for(var l=!1,u=ko;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-Ge(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ag(u,m))}else m=ze,m=Da(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||Qs(u,m)||(l=!0,ag(u,m));u=u.next}while(l);gh=!1}}function D1(){rg()}function rg(){Eo=_h=!1;var i=0;ir!==0&&P1()&&(i=ir);for(var r=Qt(),l=null,u=ko;u!==null;){var d=u.next,m=sg(u,r);m===0?(u.next=null,l===null?ko=d:l.next=d,d===null&&(Ns=l)):(l=u,(i!==0||(m&3)!==0)&&(Eo=!0)),u=d}wt!==0&&wt!==5||Nl(i),ir!==0&&(ir=0)}function sg(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var Z=R.transferSize,ie=R.initiatorType;Z&&mg(ie)&&(R=R.responseEnd,v+=Z*(R"u"?null:document;function Tg(i,r,l){var u=Ls;if(u&&typeof r=="string"&&r){var d=Ni(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Eg.has(d)||(Eg.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function $1(i){Rn.D(i),Tg("dns-prefetch",i,null)}function G1(i,r){Rn.C(i,r),Tg("preconnect",i,r)}function Z1(i,r,l){Rn.L(i,r,l);var u=Ls;if(u&&i&&r){var d='link[rel="preload"][as="'+Ni(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Ni(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Ni(l.imageSizes)+'"]')):d+='[href="'+Ni(i)+'"]';var m=d;switch(r){case"style":m=zs(i);break;case"script":m=Os(i)}Ii.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Ii.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(jl(m))||r==="script"&&u.querySelector(Hl(m))||(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function Q1(i,r){Rn.m(i,r);var l=Ls;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Ni(u)+'"][href="'+Ni(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Os(i)}if(!Ii.has(m)&&(i=_({rel:"modulepreload",href:i},r),Ii.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Hl(m)))return}u=l.createElement("link"),Ft(u,"link",i),Tt(u),l.head.appendChild(u)}}}function J1(i,r,l){Rn.S(i,r,l);var u=Ls;if(u&&i){var d=ns(u).hoistableStyles,m=zs(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(jl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Ii.get(m))&&Nh(i,l);var R=v=u.createElement("link");Tt(R),Ft(R,"link",i),R._p=new Promise(function(W,Z){R.onload=W,R.onerror=Z}),R.addEventListener("load",function(){w.loading|=1}),R.addEventListener("error",function(){w.loading|=2}),w.loading|=4,Mo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function ex(i,r){Rn.X(i,r);var l=Ls;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(Hl(d)),m||(i=_({src:i,async:!0},r),(r=Ii.get(d))&&Lh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function tx(i,r){Rn.M(i,r);var l=Ls;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(Hl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Ii.get(d))&&Lh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Ag(i,r,l,u){var d=(d=he.current)?Ro(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=zs(l.href),l=ns(d).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"){i=zs(l.href);var m=ns(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(jl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Ii.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ii.set(i,l),m||ix(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}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=Os(l),l=ns(d).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,i))}}function zs(i){return'href="'+Ni(i)+'"'}function jl(i){return'link[rel="stylesheet"]['+i+"]"}function Dg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function ix(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Ft(r,"link",l),Tt(r),i.head.appendChild(r))}function Os(i){return'[src="'+Ni(i)+'"]'}function Hl(i){return"script[async]"+i}function Rg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Ni(l.href)+'"]');if(u)return r.instance=u,Tt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Tt(u),Ft(u,"style",d),Mo(u,l.precedence,i),r.instance=u;case"stylesheet":d=zs(l.href);var m=i.querySelector(jl(d));if(m)return r.state.loading|=4,r.instance=m,Tt(m),m;u=Dg(l),(d=Ii.get(d))&&Nh(u,d),m=(i.ownerDocument||i).createElement("link"),Tt(m);var v=m;return v._p=new Promise(function(w,R){v.onload=w,v.onerror=R}),Ft(m,"link",u),r.state.loading|=4,Mo(m,l.precedence,i),r.instance=m;case"script":return m=Os(l.src),(d=i.querySelector(Hl(m)))?(r.instance=d,Tt(d),d):(u=l,(d=Ii.get(m))&&(u=_({},l),Lh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Tt(d),Ft(d,"link",u),i.head.appendChild(d),r.instance=d);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,Mo(u,l.precedence,i));return r.instance}function Mo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function nx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){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 i=r.disabled,typeof r.precedence=="string"&&i==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 Ng(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function rx(i,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 d=zs(u.href),m=r.querySelector(jl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=No.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Tt(m);return}m=r.ownerDocument||r,u=Dg(u),(d=Ii.get(d))&&Nh(u,d),m=m.createElement("link"),Tt(m);var v=m;v._p=new Promise(function(w,R){v.onload=w,v.onerror=R}),Ft(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=No.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var zh=0;function sx(i,r){return i.stylesheets&&i.count===0&&zo(i,i.stylesheets),0zh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function No(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zo(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Lo=null;function zo(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Lo=new Map,r.forEach(lx,i),Lo=null,No.call(i))}function lx(i,r){if(!(r.state.loading&4)){var l=Lo.get(i);if(l)var u=l.get(null);else{l=new Map,Lo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wh.exports=wx(),Wh.exports}var kx=Cx();const Ex=gu(kx);function Tx({onLogin:e}){const[t,n]=ne.useState(""),[s,a]=ne.useState(null),[o,c]=ne.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(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&&S.jsx("p",{className:"text-error text-xs",children:s}),S.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"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Ax({onSetup:e}){const[t,n]=ne.useState(""),[s,a]=ne.useState(""),[o,c]=ne.useState(null),[f,p]=ne.useState(!1),h=async g=>{if(g.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 S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.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."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.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"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.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&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!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:f?"setting up...":"create passphrase"})]})]})})})}const nv="http://localhost:7777";function Zy({token:e}){const[t,n]=ne.useState(null),[s,a]=ne.useState(!1),[o,c]=ne.useState(!1),[f,p]=ne.useState(null),h=(x,E)=>fetch(x,{...E,headers:{...E==null?void 0:E.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${nv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};ne.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${nv}/api/wallet/create`,{method:"POST"}),E=await x.json();if(!x.ok)throw new Error(E.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.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&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.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"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.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 Dx({token:e,onLogout:t}){const[n,s]=ne.useState(""),[a,o]=ne.useState(""),[c,f]=ne.useState(null),[p,h]=ne.useState(!1),[g,_]=ne.useState(!1),[b,y]=ne.useState(null),[x,E]=ne.useState("AI Writer"),[N,M]=ne.useState(""),[G,U]=ne.useState(""),[Q,K]=ne.useState(!1),[O,ee]=ne.useState(null),[oe,de]=ne.useState(""),[q,B]=ne.useState(null),[D,j]=ne.useState(!1),[P,L]=ne.useState(null),[A,I]=ne.useState(null),Y=ne.useCallback((C,se)=>fetch(C,{...se,headers:{...se==null?void 0:se.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);ne.useEffect(()=>{Y("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const le=async()=>{if(!x.trim()){ee("Agent name is required");return}if(!N.trim()){ee("Description is required");return}K(!0),ee(null);try{const C=await Y("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:N,...G.trim()&&{genre:G}})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Registration failed");y({linked:!0,agentId:se.agentId,owsWallet:se.owsWallet})}catch(C){ee(C instanceof Error?C.message:"Registration failed")}K(!1)},k=async()=>{if(!oe.trim()||!/^0x[a-fA-F0-9]{40}$/.test(oe)){L("Enter a valid wallet address (0x...)");return}j(!0),L(null),B(null);try{const C=await Y("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:oe})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Failed to generate binding code");B(se)}catch(C){L(C instanceof Error?C.message:"Failed to generate binding code")}j(!1)},T=async(C,se)=>{await navigator.clipboard.writeText(C),I(se),setTimeout(()=>I(null),2e3)},X=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await Y("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const se=await C.json();throw new Error(se.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/agents/${b.agentId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.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."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>E(C.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"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:N,onChange:C=>M(C.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"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:G,onChange:C=>U(C.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"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:le,disabled:Q||!x.trim()||!N.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:Q?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.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."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:oe,onChange:C=>de(C.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"}),P&&S.jsx("p",{className:"text-error text-xs",children:P}),S.jsx("button",{onClick:k,disabled:D||!oe.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:D?"Generating...":"Generate Binding Code"}),q&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:q.signature}),S.jsx("button",{onClick:()=>T(q.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:q.owsWallet}),S.jsx("button",{onClick:()=>T(q.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="wallet"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste both values in the "Link AI Writer" section.'})]})]})]}),S.jsx(Zy,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.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"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.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&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:X,disabled:g||!n.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:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.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 Rx="http://localhost:7777";function Mx({token:e}){const[t,n]=ne.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Rx}/api/dashboard`).then(f=>f.json()).then(n)};ne.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.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))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Bx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Nx={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function Lx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=ne.useState([]),[p,h]=ne.useState([]),[g,_]=ne.useState(new Set),[b,y]=ne.useState(!1),x=ne.useCallback(async()=>{try{const K=await e("/api/stories");if(K.ok){const O=await K.json();f(O.stories)}}catch{}},[e]),E=ne.useCallback(async()=>{try{const K=await e("/api/stories/archived");if(K.ok){const O=await K.json();h(O.stories)}}catch{}},[e]),N=ne.useCallback(async K=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K})})).ok&&(E(),x())}catch{}},[e,E,x]);ne.useEffect(()=>{x();const K=setInterval(x,5e3);return()=>clearInterval(K)},[x]),ne.useEffect(()=>{b&&E()},[b,E]),ne.useEffect(()=>{t&&_(K=>new Set(K).add(t))},[t]);const M=K=>{var ee;const O=K.map(oe=>{var de;return{file:oe.file,num:(de=oe.file.match(/^plot-(\d+)\.md$/))==null?void 0:de[1]}}).filter(oe=>oe.num!=null).sort((oe,de)=>parseInt(de.num)-parseInt(oe.num));return O.length>0?O[0].file:K.some(oe=>oe.file==="genesis.md")?"genesis.md":K.some(oe=>oe.file==="structure.md")?"structure.md":((ee=K[0])==null?void 0:ee.file)??null},G=K=>{_(O=>{const ee=new Set(O);return ee.has(K)?ee.delete(K):ee.add(K),ee})},U=K=>{if(G(K.name),!g.has(K.name)){const O=M(K.files);O&&s(K.name,O)}},Q=K=>{const O=ee=>{if(ee==="structure.md")return 0;if(ee==="genesis.md")return 1;const oe=ee.match(/^plot-(\d+)\.md$/);return oe?2+parseInt(oe[1]):100};return[...K].sort((ee,oe)=>O(ee.file)-O(oe.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!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:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(K=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:K.name,children:K.title||K.name}),S.jsx("button",{onClick:()=>N(K.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},K.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.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:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(K=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(K,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===K?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},K)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(K=>K.name!=="_example").map(K=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>U(K),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(K.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:K.name,children:K.title||K.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[K.publishedCount,"/",K.files.length]})]}),g.has(K.name)&&S.jsx("div",{className:"pl-4",children:Q(K.files).map(O=>{const ee=t===K.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(K.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ee?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Nx[O.status],children:Bx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},K.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!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:S.jsx("span",{children:"Archives"})})})]})}/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var Qy=Object.defineProperty,zx=Object.getOwnPropertyDescriptor,Ox=(e,t)=>{for(var n in t)Qy(e,n,{get:t[n],enumerable:!0})},ht=(e,t,n,s)=>{for(var a=s>1?void 0:s?zx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&Qy(t,n,a),a},fe=(e,t)=>(n,s)=>t(n,s,e),rv="Terminal input",Tf={get:()=>rv,set:e=>rv=e},sv="Too much output to announce, navigate to rows manually to read",Af={get:()=>sv,set:e=>sv=e};function jx(e){return e.replace(/\r?\n/g,"\r")}function Hx(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Ux(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Px(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");Jy(a,t,n,s)}}function Jy(e,t,n,s){e=jx(e),e=Hx(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function eb(e,t,n){let s=n.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 lv(e,t,n,s,a){eb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function dr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function vu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Ix=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)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=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Fx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,E;for(;(E=this.interim[++x]&63)&&x<4;)y<<=6,y|=E;let N=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=N-x;for(;h=n)return 0;if(E=e[h++],(E&192)!==128){h--,b=!0;break}else this.interim[x++]=E,y<<=6,y|=E&63}b||(N===2?y<128?h--:t[s++]=y:N===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)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(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)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(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},tb="",mr=" ",_a=class ib{constructor(){this.fg=0,this.bg=0,this.extended=new ou}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 ib;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}},ou=class nb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new nb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Vi=class rb extends _a{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ou,this.combinedData=""}static fromCharData(t){let n=new rb;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let 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:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},av="di$target",Df="di$dependencies",Xh=new Map;function qx(e){return e[Df]||[]}function Ot(e){if(Xh.has(e))return Xh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Wx(t,n,a)};return t._id=e,Xh.set(e,t),t}function Wx(e,t,n){t[av]===t?t[Df].push({id:e,index:n}):(t[Df]=[{id:e,index:n}],t[av]=t)}var si=Ot("BufferService"),sb=Ot("CoreMouseService"),Xr=Ot("CoreService"),Yx=Ot("CharsetService"),xd=Ot("InstantiationService"),lb=Ot("LogService"),li=Ot("OptionsService"),ab=Ot("OscLinkService"),Vx=Ot("UnicodeService"),ga=Ot("DecorationService"),Rf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Vi,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(E,N,y):Kx(E,N),hover:(E,N)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,E,N,y)},leave:(E,N)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,E,N,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Rf=ht([fe(0,si),fe(1,li),fe(2,ab)],Rf);function Kx(e,t){if(confirm(`Do you want to navigate to ${t}? + +WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var yu=Ot("CharSizeService"),zn=Ot("CoreBrowserService"),wd=Ot("MouseService"),On=Ot("RenderService"),Xx=Ot("SelectionService"),ob=Ot("CharacterJoinerService"),Ks=Ot("ThemeService"),ub=Ot("LinkProviderService"),$x=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ov.isErrorNoTelemetry(e)?new ov(e.message+` + +`+e.stack):new Error(e.message+` + +`+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)}},Gx=new $x;function eu(e){Zx(e)||Gx.onUnexpectedError(e)}var Mf="Canceled";function Zx(e){return e instanceof Qx?!0:e instanceof Error&&e.name===Mf&&e.message===Mf}var Qx=class extends Error{constructor(){super(Mf),this.name=this.message}};function Jx(e){return new Error(`Illegal argument: ${e}`)}var ov=class Bf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Bf)return t;let n=new Bf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Nf=class cb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,cb.prototype)}};function Ai(e,t=0){return e[e.length-(1+t)]}var ew;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;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})(ew||(ew={}));function tw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var hb;(e=>{function t(Q){return Q&&typeof Q=="object"&&typeof Q[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Q){yield Q}e.single=a;function o(Q){return t(Q)?Q:a(Q)}e.wrap=o;function c(Q){return Q||n}e.from=c;function*f(Q){for(let K=Q.length-1;K>=0;K--)yield Q[K]}e.reverse=f;function p(Q){return!Q||Q[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Q){return Q[Symbol.iterator]().next().value}e.first=h;function g(Q,K){let O=0;for(let ee of Q)if(K(ee,O++))return!0;return!1}e.some=g;function _(Q,K){for(let O of Q)if(K(O))return O}e.find=_;function*b(Q,K){for(let O of Q)K(O)&&(yield O)}e.filter=b;function*y(Q,K){let O=0;for(let ee of Q)yield K(ee,O++)}e.map=y;function*x(Q,K){let O=0;for(let ee of Q)yield*K(ee,O++)}e.flatMap=x;function*E(...Q){for(let K of Q)yield*K}e.concat=E;function N(Q,K,O){let ee=O;for(let oe of Q)ee=K(ee,oe);return ee}e.reduce=N;function*M(Q,K,O=Q.length){for(K<0&&(K+=Q.length),O<0?O+=Q.length:O>Q.length&&(O=Q.length);K1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function iw(...e){return rt(()=>Yr(e))}function rt(e){return{dispose:tw(()=>{e()})}}var fb=class db{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{Yr(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?db.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)}};fb.DISABLE_DISPOSED_WARNING=!1;var _r=fb,De=class{constructor(){this._store=new _r,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)}};De.None=Object.freeze({dispose(){}});var Ys=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}},Ln=typeof window=="object"?window:globalThis,Lf=class zf{constructor(t){this.element=t,this.next=zf.Undefined,this.prev=zf.Undefined}};Lf.Undefined=new Lf(void 0);var st=Lf,uv=class{constructor(){this._first=st.Undefined,this._last=st.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===st.Undefined}clear(){let e=this._first;for(;e!==st.Undefined;){let t=e.next;e.prev=st.Undefined,e.next=st.Undefined,e=t}this._first=st.Undefined,this._last=st.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new st(e);if(this._first===st.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==st.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==st.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==st.Undefined&&e.next!==st.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===st.Undefined&&e.next===st.Undefined?(this._first=st.Undefined,this._last=st.Undefined):e.next===st.Undefined?(this._last=this._last.prev,this._last.next=st.Undefined):e.prev===st.Undefined&&(this._first=this._first.next,this._first.prev=st.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==st.Undefined;)yield e.element,e=e.next}},nw=globalThis.performance&&typeof globalThis.performance.now=="function",rw=class pb{static create(t){return new pb(t)}constructor(t){this._now=nw&&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}},Yt;(e=>{e.None=()=>De.None;function t(D,j){return _(D,()=>{},0,void 0,!0,void 0,j)}e.defer=t;function n(D){return(j,P=null,L)=>{let A=!1,I;return I=D(Y=>{if(!A)return I?I.dispose():A=!0,j.call(P,Y)},null,L),A&&I.dispose(),I}}e.once=n;function s(D,j,P){return h((L,A=null,I)=>D(Y=>L.call(A,j(Y)),null,I),P)}e.map=s;function a(D,j,P){return h((L,A=null,I)=>D(Y=>{j(Y),L.call(A,Y)},null,I),P)}e.forEach=a;function o(D,j,P){return h((L,A=null,I)=>D(Y=>j(Y)&&L.call(A,Y),null,I),P)}e.filter=o;function c(D){return D}e.signal=c;function f(...D){return(j,P=null,L)=>{let A=iw(...D.map(I=>I(Y=>j.call(P,Y))));return g(A,L)}}e.any=f;function p(D,j,P,L){let A=P;return s(D,I=>(A=j(A,I),A),L)}e.reduce=p;function h(D,j){let P,L={onWillAddFirstListener(){P=D(A.fire,A)},onDidRemoveLastListener(){P==null||P.dispose()}},A=new ue(L);return j==null||j.add(A),A.event}function g(D,j){return j instanceof Array?j.push(D):j&&j.add(D),D}function _(D,j,P=100,L=!1,A=!1,I,Y){let le,k,T,X=0,C,se={leakWarningThreshold:I,onWillAddFirstListener(){le=D(he=>{X++,k=j(k,he),L&&!T&&(pe.fire(k),k=void 0),C=()=>{let be=k;k=void 0,T=void 0,(!L||X>1)&&pe.fire(be),X=0},typeof P=="number"?(clearTimeout(T),T=setTimeout(C,P)):T===void 0&&(T=0,queueMicrotask(C))})},onWillRemoveListener(){A&&X>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,le.dispose()}},pe=new ue(se);return Y==null||Y.add(pe),pe.event}e.debounce=_;function b(D,j=0,P){return e.debounce(D,(L,A)=>L?(L.push(A),L):[A],j,void 0,!0,void 0,P)}e.accumulate=b;function y(D,j=(L,A)=>L===A,P){let L=!0,A;return o(D,I=>{let Y=L||!j(I,A);return L=!1,A=I,Y},P)}e.latch=y;function x(D,j,P){return[e.filter(D,j,P),e.filter(D,L=>!j(L),P)]}e.split=x;function E(D,j=!1,P=[],L){let A=P.slice(),I=D(k=>{A?A.push(k):le.fire(k)});L&&L.add(I);let Y=()=>{A==null||A.forEach(k=>le.fire(k)),A=null},le=new ue({onWillAddFirstListener(){I||(I=D(k=>le.fire(k)),L&&L.add(I))},onDidAddFirstListener(){A&&(j?setTimeout(Y):Y())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return L&&L.add(le),le.event}e.buffer=E;function N(D,j){return(P,L,A)=>{let I=j(new G);return D(function(Y){let le=I.evaluate(Y);le!==M&&P.call(L,le)},void 0,A)}}e.chain=N;let M=Symbol("HaltChainable");class G{constructor(){this.steps=[]}map(j){return this.steps.push(j),this}forEach(j){return this.steps.push(P=>(j(P),P)),this}filter(j){return this.steps.push(P=>j(P)?P:M),this}reduce(j,P){let L=P;return this.steps.push(A=>(L=j(L,A),L)),this}latch(j=(P,L)=>P===L){let P=!0,L;return this.steps.push(A=>{let I=P||!j(A,L);return P=!1,L=A,I?A:M}),this}evaluate(j){for(let P of this.steps)if(j=P(j),j===M)break;return j}}function U(D,j,P=L=>L){let L=(...le)=>Y.fire(P(...le)),A=()=>D.on(j,L),I=()=>D.removeListener(j,L),Y=new ue({onWillAddFirstListener:A,onDidRemoveLastListener:I});return Y.event}e.fromNodeEventEmitter=U;function Q(D,j,P=L=>L){let L=(...le)=>Y.fire(P(...le)),A=()=>D.addEventListener(j,L),I=()=>D.removeEventListener(j,L),Y=new ue({onWillAddFirstListener:A,onDidRemoveLastListener:I});return Y.event}e.fromDOMEventEmitter=Q;function K(D){return new Promise(j=>n(D)(j))}e.toPromise=K;function O(D){let j=new ue;return D.then(P=>{j.fire(P)},()=>{j.fire(void 0)}).finally(()=>{j.dispose()}),j.event}e.fromPromise=O;function ee(D,j){return D(P=>j.fire(P))}e.forward=ee;function oe(D,j,P){return j(P),D(L=>j(L))}e.runAndSubscribe=oe;class de{constructor(j,P){this._observable=j,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{j.addObserver(this)},onDidRemoveLastListener:()=>{j.removeObserver(this)}};this.emitter=new ue(L),P&&P.add(this.emitter)}beginUpdate(j){this._counter++}handlePossibleChange(j){}handleChange(j,P){this._hasChanged=!0}endUpdate(j){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function q(D,j){return new de(D,j).emitter.event}e.fromObservable=q;function B(D){return(j,P,L)=>{let A=0,I=!1,Y={beginUpdate(){A++},endUpdate(){A--,A===0&&(D.reportChanges(),I&&(I=!1,j.call(P)))},handlePossibleChange(){},handleChange(){I=!0}};D.addObserver(Y),D.reportChanges();let le={dispose(){D.removeObserver(Y)}};return L instanceof _r?L.add(le):Array.isArray(L)&&L.push(le),le}}e.fromObservableLight=B})(Yt||(Yt={}));var Of=class jf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${jf._idPool++}`,jf.all.add(this)}start(t){this._stopWatch=new rw,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}}};Of.all=new Set,Of._idPool=0;var sw=Of,lw=-1,mb=class _b{constructor(t,n,s=(_b._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new cw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||eu)(x),De.None}if(this._disposed)return De.None;n&&(t=t.bind(n));let a=new $h(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=ow.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof $h?(this._deliveryQueue??(this._deliveryQueue=new pw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=rt(()=>{o==null||o(),this._removeListener(a)});return s instanceof _r?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,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=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.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--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*fw<=n.length){let h=0;for(let g=0;g0}},pw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Hf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ue,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ue,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Hf.INSTANCE=new Hf;var Cd=Hf;function mw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Cd.INSTANCE.onDidChangeZoomLevel;function _w(e){return Cd.INSTANCE.getZoomFactor(e)}Cd.INSTANCE.onDidChangeFullscreen;var Xs=typeof navigator=="object"?navigator.userAgent:"",Uf=Xs.indexOf("Firefox")>=0,gw=Xs.indexOf("AppleWebKit")>=0,kd=Xs.indexOf("Chrome")>=0,vw=!kd&&Xs.indexOf("Safari")>=0;Xs.indexOf("Electron/")>=0;Xs.indexOf("Android")>=0;var Gh=!1;if(typeof Ln.matchMedia=="function"){let e=Ln.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ln.matchMedia("(display-mode: fullscreen)");Gh=e.matches,mw(Ln,e,({matches:n})=>{Gh&&t.matches||(Gh=n)})}var qs="en",Pf=!1,If=!1,tu=!1,vb=!1,qo,iu=qs,cv=qs,yw,Zi,Wr=globalThis,Wt,Xy;typeof Wr.vscode<"u"&&typeof Wr.vscode.process<"u"?Wt=Wr.vscode.process:typeof process<"u"&&typeof((Xy=process==null?void 0:process.versions)==null?void 0:Xy.node)=="string"&&(Wt=process);var $y,bw=typeof(($y=Wt==null?void 0:Wt.versions)==null?void 0:$y.electron)=="string",Sw=bw&&(Wt==null?void 0:Wt.type)==="renderer",Gy;if(typeof Wt=="object"){Pf=Wt.platform==="win32",If=Wt.platform==="darwin",tu=Wt.platform==="linux",tu&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,qo=qs,iu=qs;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);qo=t.userLocale,cv=t.osLocale,iu=t.resolvedLanguage||qs,yw=(Gy=t.languagePack)==null?void 0:Gy.translationsConfigFile}catch{}vb=!0}else typeof navigator=="object"&&!Sw?(Zi=navigator.userAgent,Pf=Zi.indexOf("Windows")>=0,If=Zi.indexOf("Macintosh")>=0,(Zi.indexOf("Macintosh")>=0||Zi.indexOf("iPad")>=0||Zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tu=Zi.indexOf("Linux")>=0,(Zi==null?void 0:Zi.indexOf("Mobi"))>=0,iu=globalThis._VSCODE_NLS_LANGUAGE||qs,qo=navigator.language.toLowerCase(),cv=qo):console.error("Unable to resolve platform.");var yb=Pf,un=If,xw=tu,hv=vb,cn=Zi,ur=iu,ww;(e=>{function t(){return ur}e.value=t;function n(){return ur.length===2?ur==="en":ur.length>=3?ur[0]==="e"&&ur[1]==="n"&&ur[2]==="-":!1}e.isDefaultVariant=n;function s(){return ur==="en"}e.isDefault=s})(ww||(ww={}));var Cw=typeof Wr.postMessage=="function"&&!Wr.importScripts;(()=>{if(Cw){let e=[];Wr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Wr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var kw=!!(cn&&cn.indexOf("Chrome")>=0);cn&&cn.indexOf("Firefox")>=0;!kw&&cn&&cn.indexOf("Safari")>=0;cn&&cn.indexOf("Edg/")>=0;cn&&cn.indexOf("Android")>=0;var Hs=typeof navigator=="object"?navigator:{};hv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Hs&&Hs.clipboard&&Hs.clipboard.writeText,hv||Hs&&Hs.clipboard&&Hs.clipboard.readText;var Ed=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}},Zh=new Ed,fv=new Ed,dv=new Ed,Ew=new Array(230),bb;(e=>{function t(f){return Zh.keyCodeToStr(f)}e.toString=t;function n(f){return Zh.strToKeyCode(f)}e.fromString=n;function s(f){return fv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return dv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return fv.strToKeyCode(f)||dv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Zh.keyCodeToStr(f)}e.toElectronAccelerator=c})(bb||(bb={}));var Tw=class Sb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Sb&&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",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Aw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Aw=class{constructor(e){if(e.length===0)throw Jx("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof jw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Yt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:xb})})(Ow||(Ow={}));var jw=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?xb:(this._emitter||(this._emitter=new ue),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Td=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 Nf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Nf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Hw=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,n=globalThis){if(this.isDisposed)throw new Nf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=rt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Uw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Uw||(Uw={}));var gv=class qi{static fromArray(t){return new qi(n=>{n.emitMany(t)})}static fromPromise(t){return new qi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new qi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new qi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ue,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{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new qi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return qi.map(this,t)}static filter(t,n){return new qi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return qi.filter(this,t)}static coalesce(t){return qi.filter(t,n=>!!n)}coalesce(){return qi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return qi.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())}};gv.EMPTY=gv.fromArray([]);var{getWindow:on,getWindowId:Pw,onDidRegisterWindow:Iw}=(function(){let e=new Map,t={window:Ln,disposables:new _r};e.set(Ln.vscodeWindowId,t);let n=new ue,s=new ue,a=new ue;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return De.None;let f=new _r,p={window:c,disposables:f.add(new _r)};return e.set(c.vscodeWindowId,p),f.add(rt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(xe(c,Dt.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Ln},getDocument(c){return on(c).document}}})(),Fw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function xe(e,t,n,s){return new Fw(e,t,n,s)}var vv=function(e,t,n,s){return xe(e,t,n,s)},Ad,qw=class extends Hw{constructor(e){super(),this.defaultTarget=e&&on(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},yv=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){eu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.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(yv.sort),c.shift().execute();s.set(o,!1)};Ad=(o,c,f=0)=>{let p=Pw(o),h=new yv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Ww(e){let t=e.getBoundingClientRect(),n=on(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Dt={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"},Yw=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=_i(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_i(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_i(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_i(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_i(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_i(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_i(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_i(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_i(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_i(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_i(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=_i(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=_i(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_i(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 _i(e){return typeof e=="number"?`${e}px`:e}function la(e){return new Yw(e)}var wb=class{constructor(){this._hooks=new _r,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(rt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=on(e)}this._hooks.add(xe(o,Dt.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(xe(o,Dt.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Vw(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[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 ln;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ln||(ln={}));var ta=class Kt extends De{constructor(){super(),this.dispatched=!1,this.targets=new uv,this.ignoreTargets=new uv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Yt.runAndSubscribe(Iw,({window:t,disposables:n})=>{n.add(xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Ln,disposables:this._store}))}static addTarget(t){if(!Kt.isTouchDevice())return De.None;Kt.INSTANCE||(Kt.INSTANCE=new Kt);let n=Kt.INSTANCE.targets.push(t);return rt(n)}static ignoreTarget(t){if(!Kt.isTouchDevice())return De.None;Kt.INSTANCE||(Kt.INSTANCE=new Kt);let n=Kt.INSTANCE.ignoreTargets.push(t);return rt(n)}static isTouchDevice(){return"ontouchstart"in Ln||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=Kt.HOLD_DELAY&&Math.abs(p.initialPageX-Ai(p.rollingPageX))<30&&Math.abs(p.initialPageY-Ai(p.rollingPageY))<30){let g=this.newGestureEvent(ln.Contextmenu,p.initialTarget);g.pageX=Ai(p.rollingPageX),g.pageY=Ai(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Ai(p.rollingPageX),_=Ai(p.rollingPageY),b=Ai(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],E=[...this.targets].filter(N=>p.initialTarget instanceof Node&&N.contains(p.initialTarget));this.inertia(t,E,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(ln.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===ln.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Kt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===ln.Change||t.type===ln.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];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;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Ad(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=Kt.SCROLL_FRICTION*_,f+=Kt.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let E=this.newGestureEvent(ln.Change);E.translationX=b,E.translationY=y,n.forEach(N=>N.dispatchEvent(E)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ta.SCROLL_FRICTION=-.005,ta.HOLD_DELAY=700,ta.CLEAR_TAP_COUNT_TIME=400,ht([Vw],ta,"isTouchDevice",1);var Kw=ta,Dd=class extends De{onclick(e,t){this._register(xe(e,Dt.CLICK,n=>t(new Wo(on(e),n))))}onmousedown(e,t){this._register(xe(e,Dt.MOUSE_DOWN,n=>t(new Wo(on(e),n))))}onmouseover(e,t){this._register(xe(e,Dt.MOUSE_OVER,n=>t(new Wo(on(e),n))))}onmouseleave(e,t){this._register(xe(e,Dt.MOUSE_LEAVE,n=>t(new Wo(on(e),n))))}onkeydown(e,t){this._register(xe(e,Dt.KEY_DOWN,n=>t(new pv(n))))}onkeyup(e,t){this._register(xe(e,Dt.KEY_UP,n=>t(new pv(n))))}oninput(e,t){this._register(xe(e,Dt.INPUT,t))}onblur(e,t){this._register(xe(e,Dt.BLUR,t))}onfocus(e,t){this._register(xe(e,Dt.FOCUS,t))}onchange(e,t){this._register(xe(e,Dt.CHANGE,t))}ignoreGesture(e){return Kw.ignoreTarget(e)}},bv=11,Xw=class extends Dd{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=bv+"px",this.domNode.style.height=bv+"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 wb),this._register(vv(this.bgDomNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(vv(this.domNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new qw),this._pointerdownScheduleRepeatTimer=this._register(new Td)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,on(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},$w=class Ff{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}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,n){return new Ff(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ff(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,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,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:f,scrollTopChanged:p}}},Gw=class extends De{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ue),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $w(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 n=this._state.withScrollDimensions(e,t);this._setState(n,!!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 n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new xv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=xv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Sv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Qh(e,t){let n=t-e;return function(s){return e+n*Jw(s)}}function Zw(e,t,n){return function(s){return s2.5*s){let a,o;return t{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":"")))}},tC=140,Cb=class extends Dd{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 eC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new wb),this._shouldRender=!0,this.domNode=la(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(xe(this.domNode.domNode,Dt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Xw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=la(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(xe(this.slider.domNode,Dt.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,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Ww(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);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),n=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-n);if(yb&&c>tC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{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()}},kb=class Wf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),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 Wf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Wf._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 n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Yf.INSTANCE=new Yf;var lC=Yf,aC=class extends Dd{constructor(e,t,n){super(),this._onScroll=this._register(new ue),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ue),this.onWillScroll=this._onWillScroll.event,this._options=uC(t),this._scrollable=n,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 nC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new iC(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=la(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=la(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=la(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 Td),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Yr(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,un&&(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 _v(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Yr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new _v(n))};this._mouseWheelToDispose.push(xe(this._listenOnDomNode,Dt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=lC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!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 f=!un&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!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(),h={};if(o){let g=wv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=wv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!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,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||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(),rC)}},oC=class extends aC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function uC(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,un&&(t.className+=" mac"),t}var Vf=class extends De{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new ue),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Gw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Ad(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new oC(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(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Yt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(rt(()=>this._styleElement.remove())),this._register(Yt.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(` +`)})),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(h=>this._handleScroll(h)))}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),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Vf=ht([fe(2,si),fe(3,zn),fe(4,sb),fe(5,Ks),fe(6,li),fe(7,On)],Vf);var Kf=class extends De{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,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(rt(()=>{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 n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Kf=ht([fe(1,si),fe(2,zn),fe(3,ga),fe(4,On)],Kf);var cC=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=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},rn={full:0,left:0,center:0,right:0},cr={full:0,left:0,center:0,right:0},Yl={full:0,left:0,center:0,right:0},uu=class extends De{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new cC,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(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(rt(()=>{var g;return(g=this._canvas)==null?void 0:g.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);cr.full=this._canvas.width,cr.left=e,cr.center=t,cr.right=e,this._refreshDrawHeightConstants(),Yl.full=1,Yl.left=1,Yl.center=1+cr.left,Yl.right=1+cr.left+cr.center}_refreshDrawHeightConstants(){rn.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);rn.left=t,rn.center=t,rn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.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(Yl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-rn[e.position||"full"]/2),cr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+rn[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}))}};uu=ht([fe(2,si),fe(3,ga),fe(4,On),fe(5,li),fe(6,Ks),fe(7,zn)],uu);var re;(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=` +`,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=""))(re||(re={}));var nu;(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="Ÿ"))(nu||(nu={}));var Eb;(e=>e.ST=`${re.ESC}\\`)(Eb||(Eb={}));var Xf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,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 n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!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,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Xf=ht([fe(2,si),fe(3,li),fe(4,Xr),fe(5,On)],Xf);var Rt=0,Mt=0,Bt=0,ut=0,Cv={css:"#00000000",rgba:0},St;(e=>{function t(a,o,c,f){return f!==void 0?`#${jr(a)}${jr(o)}${jr(c)}${jr(f)}`:`#${jr(a)}${jr(o)}${jr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(St||(St={}));var it;(e=>{function t(p,h){if(ut=(h.rgba&255)/255,ut===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,E=p.rgba>>8&255;Rt=y+Math.round((g-y)*ut),Mt=x+Math.round((_-x)*ut),Bt=E+Math.round((b-E)*ut);let N=St.toCss(Rt,Mt,Bt),M=St.toRgba(Rt,Mt,Bt);return{css:N,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=ru.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return St.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Rt,Mt,Bt]=ru.toChannels(h),{css:St.toCss(Rt,Mt,Bt),rgba:h}}e.opaque=a;function o(p,h){return ut=Math.round(h*255),[Rt,Mt,Bt]=ru.toChannels(p.rgba),{css:St.toCss(Rt,Mt,Bt,ut),rgba:St.toRgba(Rt,Mt,Bt,ut)}}e.opacity=o;function c(p,h){return ut=p.rgba&255,o(p,ut*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(it||(it={}));var lt;(e=>{let t,n;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",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Rt=parseInt(a.slice(1,2).repeat(2),16),Mt=parseInt(a.slice(2,3).repeat(2),16),Bt=parseInt(a.slice(3,4).repeat(2),16),St.toColor(Rt,Mt,Bt);case 5:return Rt=parseInt(a.slice(1,2).repeat(2),16),Mt=parseInt(a.slice(2,3).repeat(2),16),Bt=parseInt(a.slice(3,4).repeat(2),16),ut=parseInt(a.slice(4,5).repeat(2),16),St.toColor(Rt,Mt,Bt,ut);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 Rt=parseInt(o[1]),Mt=parseInt(o[2]),Bt=parseInt(o[3]),ut=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),St.toColor(Rt,Mt,Bt,ut);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Rt,Mt,Bt,ut]=t.getImageData(0,0,1,1).data,ut!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:St.toRgba(Rt,Mt,Bt,ut),css:a}}e.toColor=s})(lt||(lt={}));var ii;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ii||(ii={}));var ru;(e=>{function t(c,f){if(ut=(f&255)/255,ut===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Rt=_+Math.round((p-_)*ut),Mt=b+Math.round((h-b)*ut),Bt=y+Math.round((g-y)*ut),St.toRgba(Rt,Mt,Bt)}e.blend=t;function n(c,f,p){let h=ii.relativeLuminance(c>>8),g=ii.relativeLuminance(f>>8);if(Mn(h,g)>8));if(x>8));return x>N?y:E}return y}let _=a(c,f,p),b=Mn(h,ii.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,E=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));for(;E0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),E=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,E=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));for(;E>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(ru||(ru={}));function jr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Mn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=q,I=j,Y=this._workCell;if(b.length>0&&j===b[0][0]&&A){let He=b.shift(),yi=this._isCellInSelection(He[0],t);for(G=He[0]+1;G=He[1]),A?(L=!0,Y=new hC(this._workCell,e.translateToString(!0,He[0],He[1]),He[1]-He[0]),I=He[1]-1,P=Y.getWidth()):q=He[1]}let le=this._isCellInSelection(j,t),k=n&&j===o,T=D&&j>=h&&j<=g,X=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,He=>{X=!0});let C=Y.getChars()||mr;if(C===" "&&(Y.isUnderline()||Y.isOverline())&&(C=" "),de=P*f-p.get(C,Y.isBold(),Y.isItalic()),!E)E=this._document.createElement("span");else if(N&&(le&&oe||!le&&!oe&&Y.bg===U)&&(le&&oe&&y.selectionForeground||Y.fg===Q)&&Y.extended.ext===K&&T===O&&de===ee&&!k&&!L&&!X&&A){Y.isInvisible()?M+=mr:M+=C,N++;continue}else N&&(E.textContent=M),E=this._document.createElement("span"),N=0,M="";if(U=Y.bg,Q=Y.fg,K=Y.extended.ext,O=T,ee=de,oe=le,L&&o>=j&&o<=I&&(o=j),!this._coreService.isCursorHidden&&k&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&B.push("xterm-cursor-blink"),B.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(Y.isBold()&&B.push("xterm-bold"),Y.isItalic()&&B.push("xterm-italic"),Y.isDim()&&B.push("xterm-dim"),Y.isInvisible()?M=mr:M=Y.getChars()||mr,Y.isUnderline()&&(B.push(`xterm-underline-${Y.extended.underlineStyle}`),M===" "&&(M=" "),!Y.isUnderlineColorDefault()))if(Y.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${_a.toColorRGB(Y.getUnderlineColor()).join(",")})`;else{let He=Y.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Y.isBold()&&He<8&&(He+=8),E.style.textDecorationColor=y.ansi[He].css}Y.isOverline()&&(B.push("xterm-overline"),M===" "&&(M=" ")),Y.isStrikethrough()&&B.push("xterm-strikethrough"),T&&(E.style.textDecoration="underline");let se=Y.getFgColor(),pe=Y.getFgColorMode(),he=Y.getBgColor(),be=Y.getBgColorMode(),Te=!!Y.isInverse();if(Te){let He=se;se=he,he=He;let yi=pe;pe=be,be=yi}let Re,jt,Zt=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,He=>{He.options.layer!=="top"&&Zt||(He.backgroundColorRGB&&(be=50331648,he=He.backgroundColorRGB.rgba>>8&16777215,Re=He.backgroundColorRGB),He.foregroundColorRGB&&(pe=50331648,se=He.foregroundColorRGB.rgba>>8&16777215,jt=He.foregroundColorRGB),Zt=He.options.layer==="top")}),!Zt&&le&&(Re=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,he=Re.rgba>>8&16777215,be=50331648,Zt=!0,y.selectionForeground&&(pe=50331648,se=y.selectionForeground.rgba>>8&16777215,jt=y.selectionForeground)),Zt&&B.push("xterm-decoration-top");let ai;switch(be){case 16777216:case 33554432:ai=y.ansi[he],B.push(`xterm-bg-${he}`);break;case 50331648:ai=St.toColor(he>>16,he>>8&255,he&255),this._addStyle(E,`background-color:#${kv((he>>>0).toString(16),"0",6)}`);break;case 0:default:Te?(ai=y.foreground,B.push("xterm-bg-257")):ai=y.background}switch(Re||Y.isDim()&&(Re=it.multiplyOpacity(ai,.5)),pe){case 16777216:case 33554432:Y.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(E,ai,y.ansi[se],Y,Re,void 0)||B.push(`xterm-fg-${se}`);break;case 50331648:let He=St.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(E,ai,He,Y,Re,jt)||this._addStyle(E,`color:#${kv(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(E,ai,y.foreground,Y,Re,jt)||Te&&B.push("xterm-fg-257")}B.length&&(E.className=B.join(" "),B.length=0),!k&&!L&&!X&&A?N++:E.textContent=M,de!==this.defaultSpacing&&(E.style.letterSpacing=`${de}px`),_.push(E),j=I}return E&&N&&(E.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||pC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=it.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};$f=ht([fe(1,ob),fe(2,li),fe(3,zn),fe(4,Xr),fe(5,ga),fe(6,Ks)],$f);function kv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},gC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function vC(){return new gC}var Jh="xterm-dom-renderer-owner-",Fi="xterm-rows",Vo="xterm-fg-",Ev="xterm-bg-",Vl="xterm-focus",Ko="xterm-selection",yC=1,Gf=class extends De{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=yC++,this._rowElements=[],this._selectionRenderModel=vC(),this.onRequestRedraw=this._register(new ue).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fi),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(Ko),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=mC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance($f,document),this._element.classList.add(Jh+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(rt(()=>{this._element.classList.remove(Jh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new _C(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Fi} 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} .${Fi} { 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} .${Fi} .xterm-dim { color: ${it.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 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} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ko} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ko} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ko} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Vo}${o} { color: ${c.css}; }${this._terminalSelector} .${Vo}${o}.xterm-dim { color: ${it.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Ev}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Vo}257 { color: ${it.opaque(e.background).css}; }${this._terminalSelector} .${Vo}257.xterm-dim { color: ${it.multiplyOpacity(it.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ev}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 n=this._rowElements.length;n<=t;n++){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(Vl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.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,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-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 n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Jh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,E=this._rowElements[y],N=f.lines.get(x);if(!E||!N)break;E.replaceChildren(...this._rowFactory.createRow(N,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Gf=ht([fe(7,xd),fe(8,yu),fe(9,li),fe(10,si),fe(11,Xr),fe(12,zn),fe(13,Ks)],Gf);var Zf=class extends De{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ue),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new SC(this._optionsService))}catch{this._measureStrategy=this._register(new bC(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())}};Zf=ht([fe(2,li)],Zf);var Tb=class extends De{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)}},bC=class extends Tb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},SC=class extends Tb{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}},xC=class extends De{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new wC(this._window)),this._onDprChange=this._register(new ue),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ue),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Yt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(xe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},wC=class extends De{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ys),this._onDprChange=this._register(new ue),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=xe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},CC=class extends De{constructor(){super(),this.linkProviders=[],this._register(rt(()=>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 Rd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function kC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Rd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var Qf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return kC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Rd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Qf=ht([fe(0,On),fe(1,yu)],Qf);var EC=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,n){this._rowCount=n,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=[]}},Ab={};Ox(Ab,{getSafariVersion:()=>AC,isChromeOS:()=>Bb,isFirefox:()=>Db,isIpad:()=>DC,isIphone:()=>RC,isLegacyEdge:()=>TC,isLinux:()=>Md,isMac:()=>hu,isNode:()=>bu,isSafari:()=>Rb,isWindows:()=>Mb});var bu=typeof process<"u"&&"title"in process,va=bu?"node":navigator.userAgent,ya=bu?"node":navigator.platform,Db=va.includes("Firefox"),TC=va.includes("Edge"),Rb=/^((?!chrome|android).)*safari/i.test(va);function AC(){if(!Rb)return 0;let e=va.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var hu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ya),DC=ya==="iPad",RC=ya==="iPhone",Mb=["Windows","Win16","Win32","WinCE"].includes(ya),Md=ya.indexOf("Linux")>=0,Bb=/\bCrOS\b/.test(va),Nb=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){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()}},MC=class extends Nb{_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())}}},BC=class extends Nb{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fu=!bu&&"requestIdleCallback"in window?BC:MC,NC=class{constructor(){this._queue=new fu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Jf=class extends De{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Ys),this._pausedResizeTask=new NC,this._observerDisposable=this._register(new Ys),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 ue),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ue),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ue),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ue),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new EC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new LC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.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(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=rt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),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 n;return(n=this._renderer.value)==null?void 0:n.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,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Jf=ht([fe(2,li),fe(3,yu),fe(4,Xr),fe(5,ga),fe(6,si),fe(7,zn),fe(8,Ks)],Jf);var LC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function zC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return HC(a,o,e,t,n,s)+Su(o,t,n,s)+UC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ha(Math.abs(a-e),ca(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=jC(o>t?e:a,n)+(f-1)*n.cols+1+OC(o>t?a:e);return ha(p,ca(c,s))}function OC(e,t){return e-1}function jC(e,t){return t.cols-e}function HC(e,t,n,s,a,o){return Su(t,s,a,o).length===0?"":ha(zb(e,t,e,t-Vr(t,a),!1,a).length,ca("D",o))}function Su(e,t,n,s){let a=e-Vr(e,n),o=t-Vr(t,n),c=Math.abs(a-o)-PC(e,t,n);return ha(c,ca(Lb(e,t),s))}function UC(e,t,n,s,a,o){let c;Su(t,s,a,o).length>0?c=s-Vr(s,a):c=t;let f=s,p=IC(e,t,n,s,a,o);return ha(zb(e,c,n,f,p==="C",a).length,ca(p,o))}function PC(e,t,n){var c;let s=0,a=e-Vr(e,n),o=t-Vr(t,n);for(let f=0;f=0&&e0?c=s-Vr(s,a):c=t,e=n&&ct?"A":"B"}function zb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function ca(e,t){let n=t?"O":"[";return re.ESC+n+e}function ha(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._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 Tv(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 ef=50,qC=15,WC=50,YC=500,VC=" ",KC=new RegExp(VC,"g"),ed=class extends De{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Vi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ue),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ue),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ue),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ue),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new FC(this._bufferService),this._activeSelectionMode=0,this._register(rt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(KC," ")).join(Mb?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Md&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Tv(n,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=Rd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-ef),ef),t/=ef,t/Math.abs(t)+Math.round(t*(qC-1)))}shouldForceSelection(e){return hu?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(),WC)}_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&&!(hu&&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]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]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&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,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),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=G-1,p+=G-1);N>0&&f>0&&!this._isCharWordSeparator(o.loadCell(N-1,this._workCell));){o.loadCell(N-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,N--):U>1&&(b+=U-1,f-=U-1),f--,N--}for(;M1&&(y+=U-1,p+=U-1),p++,M++}}p++;let x=f+h-g+b,E=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let N=a.lines.get(e[1]-1);if(N&&o.isWrapped&&N.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let G=this._bufferService.cols-M.start;x-=G,E+=G}}}if(s&&x+E===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let N=a.lines.get(e[1]+1);if(N!=null&&N.isWrapped&&N.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(E+=M.length)}}return{start:x,length:E}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Tv(n,this._bufferService.cols)}};ed=ht([fe(3,si),fe(4,Xr),fe(5,wd),fe(6,li),fe(7,On),fe(8,zn)],ed);var Av=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Dv=class{constructor(){this._color=new Av,this._css=new Av}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ct=Object.freeze((()=>{let e=[lt.toColor("#2e3436"),lt.toColor("#cc0000"),lt.toColor("#4e9a06"),lt.toColor("#c4a000"),lt.toColor("#3465a4"),lt.toColor("#75507b"),lt.toColor("#06989a"),lt.toColor("#d3d7cf"),lt.toColor("#555753"),lt.toColor("#ef2929"),lt.toColor("#8ae234"),lt.toColor("#fce94f"),lt.toColor("#729fcf"),lt.toColor("#ad7fa8"),lt.toColor("#34e2e2"),lt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:St.toCss(s,a,o),rgba:St.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:St.toCss(s,s,s),rgba:St.toRgba(s,s,s)})}return e})()),Ir=lt.toColor("#ffffff"),ia=lt.toColor("#000000"),Rv=lt.toColor("#ffffff"),Mv=ia,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},XC=Ir,td=class extends De{constructor(e){super(),this._optionsService=e,this._contrastCache=new Dv,this._halfContrastCache=new Dv,this._onChangeColors=this._register(new ue),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ir,background:ia,cursor:Rv,cursorAccent:Mv,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:it.blend(ia,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:it.blend(ia,Kl),scrollbarSliderBackground:it.opacity(Ir,.2),scrollbarSliderHoverBackground:it.opacity(Ir,.4),scrollbarSliderActiveBackground:it.opacity(Ir,.5),overviewRulerBorder:Ir,ansi:Ct.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=$e(e.foreground,Ir),t.background=$e(e.background,ia),t.cursor=it.blend(t.background,$e(e.cursor,Rv)),t.cursorAccent=it.blend(t.background,$e(e.cursorAccent,Mv)),t.selectionBackgroundTransparent=$e(e.selectionBackground,Kl),t.selectionBackgroundOpaque=it.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=$e(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=it.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?$e(e.selectionForeground,Cv):void 0,t.selectionForeground===Cv&&(t.selectionForeground=void 0),it.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=it.opacity(t.selectionBackgroundTransparent,.3)),it.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=it.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=$e(e.scrollbarSliderBackground,it.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=$e(e.scrollbarSliderHoverBackground,it.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=$e(e.scrollbarSliderActiveBackground,it.opacity(t.foreground,.5)),t.overviewRulerBorder=$e(e.overviewRulerBorder,XC),t.ansi=Ct.slice(),t.ansi[0]=$e(e.black,Ct[0]),t.ansi[1]=$e(e.red,Ct[1]),t.ansi[2]=$e(e.green,Ct[2]),t.ansi[3]=$e(e.yellow,Ct[3]),t.ansi[4]=$e(e.blue,Ct[4]),t.ansi[5]=$e(e.magenta,Ct[5]),t.ansi[6]=$e(e.cyan,Ct[6]),t.ansi[7]=$e(e.white,Ct[7]),t.ansi[8]=$e(e.brightBlack,Ct[8]),t.ansi[9]=$e(e.brightRed,Ct[9]),t.ansi[10]=$e(e.brightGreen,Ct[10]),t.ansi[11]=$e(e.brightYellow,Ct[11]),t.ansi[12]=$e(e.brightBlue,Ct[12]),t.ansi[13]=$e(e.brightMagenta,Ct[13]),t.ansi[14]=$e(e.brightCyan,Ct[14]),t.ansi[15]=$e(e.brightWhite,Ct[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){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=n.length>0?n[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)}},ZC={trace:0,debug:1,info:2,warn:3,error:4,off:5},QC="xterm.js: ",id=class extends De{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=ZC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-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>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Ae+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ae+0]=t|2097152|n[2]<<22):this._data[t*Ae+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let n=this._data[t*Ae+0];return n&2097152?this._combined[t]:n&2097151?dr(n&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,n){return Xo=t*Ae,n.content=this._data[Xo+0],n.fg=this._data[Xo+1],n.bg=this._data[Xo+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Ae+0]=n.content,this._data[t*Ae+1]=n.fg,this._data[t*Ae+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Ae+0]=n|s<<22,this._data[t*Ae+1]=a.fg,this._data[t*Ae+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Ae+0];a&2097152?this._combined[t]+=dr(n):a&2097151?(this._combined[t]=dr(a&2097151)+dr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Ae+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.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&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*tf=0;--t)if(this._data[t*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function JC(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(N>_||g[N].getTrimmedLength()===0);N--)E++;E>0&&(c.push(f+g.length-E),c.push(E)),f+=g.length-1}return c}function e2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cfa(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function fa(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var jb=class Hb{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Hb._nextId++,this._onDispose=this.register(new ue),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Yr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};jb._nextId=1;var n2=jb,Et={},Fr=Et.B;Et[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Et.A={"#":"£"};Et.B=void 0;Et[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Et.C=Et[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Et.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Et.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Et.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Et.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Et.E=Et[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Et.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Et.H=Et[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Et["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Nv=4294967295,Lv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=bt.clone(),this.savedCharset=Fr,this.markers=[],this._nullCell=Vi.fromCharData([0,tb,1,0]),this._whitespaceCell=Vi.fromCharData([0,mr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Bv(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 ou),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 ou),this._whitespaceCell}getBlankLine(e,t){return new na(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&&eNv?Nv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=bt);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 Bv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(bt),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new na(e,n)));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(a0&&(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.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._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=JC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(bt),n);if(s.length>0){let a=e2(this.lines,s);t2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(bt),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let U=this.ybase+this.y;if(U>=c&&U0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,E=g[x];E===0&&(x--,E=g[x]);let N=p.length-_-1,M=h;for(;N>=0;){let U=Math.min(M,E);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[N],M-U,E-U,U,!0),E-=U,E===0&&(x--,E=g[x]),M-=U,M===0){N--;let Q=Math.max(N,0);M=fa(p,Q,this._cols)}}for(let U=0;U0;)this.ybase===0?this.y0){let c=[],f=[];for(let E=0;E=0;E--)if(_&&_.start>h+b){for(let N=_.newLines.length-1;N>=0;N--)this.lines.set(E--,_.newLines[N]);E++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(E,f[h--]);let y=0;for(let E=c.length-1;E>=0;E--)c[E].index+=y,this.lines.onInsertEmitter.fire(c[E]),y+=c[E].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);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?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},r2=class extends De{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ue),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 Lv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Lv(!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)}},Ub=2,Pb=1,nd=class extends De{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ue),this.onResize=this._onResize.event,this._onScroll=this._register(new ue),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Ub),this.rows=Math.max(e.rawOptions.rows||0,Pb),this.buffers=this._register(new r2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=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:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};nd=ht([fe(0,li)],nd);var Us={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:hu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},s2=["normal","bold","100","200","300","400","500","600","700","800","900"],l2=class extends De{constructor(e){super(),this._onOptionChange=this._register(new ue),this.onOptionChange=this._onOptionChange.event;let t={...Us};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(rt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Us[e]),!a2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Us[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=s2.includes(t)?t:Us[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 a2(e){return e==="block"||e==="underline"||e==="bar"}function ra(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&ra(e[s],t-1);return n}var zv=Object.freeze({insertMode:!1}),Ov=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),rd=class extends De{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ue),this.onData=this._onData.event,this._onUserInput=this._register(new ue),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ue),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ue),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ra(zv),this.decPrivateModes=ra(Ov)}reset(){this.modes=ra(zv),this.decPrivateModes=ra(Ov)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(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))}};rd=ht([fe(0,si),fe(1,lb),fe(2,li)],rd);var jv={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 nf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var rf=String.fromCharCode,Hv={DEFAULT:e=>{let t=[nf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${rf(t[0])}${rf(t[1])}${rf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.x};${e.y}${t}`}},sd=class extends De{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ue),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(jv))this.addProtocol(s,jv[s]);for(let s of Object.keys(Hv))this.addEncoding(s,Hv[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,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,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,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};sd=ht([fe(0,si),fe(1,Xr),fe(2,li)],sd);var sf=[[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]],o2=[[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]],kt;function u2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return qr.createPropertyValue(0,n,s)}},qr=class su{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ue,this.onChange=this._onChange.event;let t=new c2;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,n,s=!1){return(t&16777215)<<3|(n&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 n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=su.extractWidth(f);su.extractShouldJoin(f)&&(p-=su.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},h2=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 Uv(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),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Xl=2147483647,f2=256,Ib=class ld{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>f2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new ld;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&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>Xl?Xl: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>Xl?Xl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,Xl):t}},$l=[],d2=class{constructor(){this._state=0,this._active=$l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=$l}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=$l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||$l,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=$l,this._id=-1,this._state=0}}},Di=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Gl=[],p2=class{constructor(){this._handlers=Object.create(null),this._active=Gl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=Gl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Gl,this._ident=0}},sa=new Ib;sa.addParam(0);var Pv=class{constructor(e){this._handler=e,this._data="",this._params=sa,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():sa,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=sa,this._data="",this._hitLimit=!1,n));return this._params=sa,this._data="",this._hitLimit=!1,t}},m2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(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(n(128,144),c,3,0),e.addMany(n(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(n(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(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(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(Wi,0,2,0),e.add(Wi,8,5,8),e.add(Wi,6,0,6),e.add(Wi,11,0,11),e.add(Wi,13,13,13),e})(),g2=class extends De{constructor(e=_2){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 Ib,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},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(rt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new d2),this._dcsParser=this._register(new p2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=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 n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];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 n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];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,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){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(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[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,n),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,n),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 f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<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(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),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=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function lf(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function b2(e,t=16){let[n,s,a]=e;return`rgb:${lf(n,t)}/${lf(s,t)}/${lf(a,t)}`}var S2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},hr=131072,Fv=10;function qv(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 Wv=5e3,Yv=0,x2=class extends De{constructor(e,t,n,s,a,o,c,f,p=new g2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Ix,this._utf8Decoder=new Fx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=bt.clone(),this._eraseAttrDataInternal=bt.clone(),this._onRequestBell=this._register(new ue),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ue),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ue),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ue),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ue),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ue),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ue),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ue),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ue),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ue),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ue),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ue),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ue),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 ad(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(re.BEL,()=>this.bell()),this._parser.setExecuteHandler(re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(re.BS,()=>this.backspace()),this._parser.setExecuteHandler(re.HT,()=>this.tab()),this._parser.setExecuteHandler(re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nu.IND,()=>this.index()),this._parser.setExecuteHandler(nu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Di(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Di(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Di(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Di(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Di(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Di(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Di(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Di(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Di(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Di(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Di(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Di(h=>this.restoreCursorColor(h))),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 h in Et)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Pv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Wv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Wv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>hr&&(o=this._parseStack.position+hr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthhr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,G=this._activeBuffer.x-N;for(this._activeBuffer.x=N,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),N>0&&_ instanceof na&&_.copyCellsFrom(M,G,0,N,!1);G=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-N,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>qv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Pv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Di(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,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let 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.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(re.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(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||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(E,N)=>(c.triggerDataEvent(`${re.ESC}[${t?"":"?"}${E};${N}$y`),!0),y=E=>E?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=_a.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){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),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=bt.fg,e.bg=bt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=bt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=bt.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=bt.fg&16777215,s.bg&=-67108864,s.bg|=bt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${re.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[?${t};${n}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=bt.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!qv(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(`${re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Fv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Fv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Vv(o))if(a==="?")t.push({type:0,index:o});else{let c=Iv(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 n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[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 n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=Iv(n[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=[],n=e.split(";");for(let s=0;s=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=bt.clone(),this._eraseAttrDataInternal=bt.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 Vi;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._coreService.triggerDataEvent(`${re.ESC}${c}${re.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(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)}},ad=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Yv=e,e=t,t=Yv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ad=ht([fe(0,si)],ad);function Vv(e){return 0<=e&&e<256}var w2=5e7,Kv=12,C2=50,k2=class extends De{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 ue),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>w2)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 n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=Kv?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Kv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>C2&&(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()}},od=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 f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),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(n),data:n,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 n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,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 n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};od=ht([fe(0,si)],od);var Xv=!1,E2=class extends De{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ys),this._onBinary=this._register(new ue),this.onBinary=this._onBinary.event,this._onData=this._register(new ue),this.onData=this._onData.event,this._onLineFeed=this._register(new ue),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ue),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ue),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ue),this._instantiationService=new GC,this.optionsService=this._register(new l2(e)),this._instantiationService.setService(li,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(nd)),this._instantiationService.setService(si,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(id)),this._instantiationService.setService(lb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(Xr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(sb,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qr)),this._instantiationService.setService(Vx,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h2),this._instantiationService.setService(Yx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(od),this._instantiationService.setService(ab,this._oscLinkService),this._inputHandler=this._register(new x2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Yt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Yt.forward(this._bufferService.onResize,this._onResize)),this._register(Yt.forward(this.coreService.onData,this._onData)),this._register(Yt.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 k2((t,n)=>this._inputHandler.parse(t,n))),this._register(Yt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ue),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&&!Xv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Xv=!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,Ub),t=Math.max(t,Pb),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(Uv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Uv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rt(()=>{for(let t of e)t.dispose()})}}},T2={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 A2(e,t,n,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=re.ESC+"OA":a.key=re.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=re.ESC+"OD":a.key=re.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=re.ESC+"OC":a.key=re.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=re.ESC+"OB":a.key=re.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":re.DEL,e.altKey&&(a.key=re.ESC+a.key);break;case 9:if(e.shiftKey){a.key=re.ESC+"[Z";break}a.key=re.HT,a.cancel=!0;break;case 13:a.key=e.altKey?re.ESC+re.CR:re.CR,a.cancel=!0;break;case 27:a.key=re.ESC,e.altKey&&(a.key=re.ESC+re.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"D":t?a.key=re.ESC+"OD":a.key=re.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"C":t?a.key=re.ESC+"OC":a.key=re.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"A":t?a.key=re.ESC+"OA":a.key=re.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"B":t?a.key=re.ESC+"OB":a.key=re.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=re.ESC+"[2~");break;case 46:o?a.key=re.ESC+"[3;"+(o+1)+"~":a.key=re.ESC+"[3~";break;case 36:o?a.key=re.ESC+"[1;"+(o+1)+"H":t?a.key=re.ESC+"OH":a.key=re.ESC+"[H";break;case 35:o?a.key=re.ESC+"[1;"+(o+1)+"F":t?a.key=re.ESC+"OF":a.key=re.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=re.ESC+"[5;"+(o+1)+"~":a.key=re.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=re.ESC+"[6;"+(o+1)+"~":a.key=re.ESC+"[6~";break;case 112:o?a.key=re.ESC+"[1;"+(o+1)+"P":a.key=re.ESC+"OP";break;case 113:o?a.key=re.ESC+"[1;"+(o+1)+"Q":a.key=re.ESC+"OQ";break;case 114:o?a.key=re.ESC+"[1;"+(o+1)+"R":a.key=re.ESC+"OR";break;case 115:o?a.key=re.ESC+"[1;"+(o+1)+"S":a.key=re.ESC+"OS";break;case 116:o?a.key=re.ESC+"[15;"+(o+1)+"~":a.key=re.ESC+"[15~";break;case 117:o?a.key=re.ESC+"[17;"+(o+1)+"~":a.key=re.ESC+"[17~";break;case 118:o?a.key=re.ESC+"[18;"+(o+1)+"~":a.key=re.ESC+"[18~";break;case 119:o?a.key=re.ESC+"[19;"+(o+1)+"~":a.key=re.ESC+"[19~";break;case 120:o?a.key=re.ESC+"[20;"+(o+1)+"~":a.key=re.ESC+"[20~";break;case 121:o?a.key=re.ESC+"[21;"+(o+1)+"~":a.key=re.ESC+"[21~";break;case 122:o?a.key=re.ESC+"[23;"+(o+1)+"~":a.key=re.ESC+"[23~";break;case 123:o?a.key=re.ESC+"[24;"+(o+1)+"~":a.key=re.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=re.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=re.DEL:e.keyCode===219?a.key=re.ESC:e.keyCode===220?a.key=re.FS:e.keyCode===221&&(a.key=re.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=T2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=re.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=re.ESC+h}else if(e.keyCode===32)a.key=re.ESC+(e.ctrlKey?re.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=re.ESC+p,a.cancel=!0}}else n&&!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=re.US),e.key==="@"&&(a.key=re.NUL));break}return a}var pt=0,D2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fu,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,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];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||(pt=this._search(t),pt===-1)||this._getKey(this._array[pt])!==t)return!1;do if(this._array[pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pt),!0;while(++pta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do yield this._array[pt];while(++pt=this._array.length)&&this._getKey(this._array[pt])===e))do t(this._array[pt]);while(++pt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},af=0,$v=0,R2=class extends De{constructor(){super(),this._decorations=new D2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ue),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ue),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new M2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let 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{af=a.options.x??0,$v=af+(a.options.width??1),e>=af&&e<$v&&(!n||(a.options.layer??"bottom")===n)&&s(a)})}},M2=class extends _r{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ue),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ue),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=lt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=lt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},B2=1e3,N2=class{constructor(e,t=B2){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?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)}},Gv=20,du=class extends De{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,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;othis._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 N2(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(` +`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(xe(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(rt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Gv+1&&(this._liveRegion.textContent+=Af.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.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 f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);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;te;)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{var o;Yr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(xe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&L2(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,Yr(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 n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{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)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.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,n){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(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){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(n,t.text)}_linkAtPosition(e,t){let n=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 n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.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,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};ud=ht([fe(1,wd),fe(2,On),fe(3,si),fe(4,ub)],ud);function L2(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 z2=class extends E2{constructor(e={}){super(e),this._linkifier=this._register(new Ys),this.browser=Ab,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ys),this._onCursorMove=this._register(new ue),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ue),this.onKey=this._onKey.event,this._onRender=this._register(new ue),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ue),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ue),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ue),this.onBell=this._onBell.event,this._onFocus=this._register(new ue),this._onBlur=this._register(new ue),this._onA11yCharEmitter=this._register(new ue),this._onA11yTabEmitter=this._register(new ue),this._onWillOpen=this._register(new ue),this._setup(),this._decorationService=this._instantiationService.createInstance(R2),this._instantiationService.setService(ga,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(CC),this._instantiationService.setService(ub,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Rf)),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(Yt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Yt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Yt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Yt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(rt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=it.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${re.ESC}]${s};${b2(a)}${Eb.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=St.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=St.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.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(re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(xe(this.element,"copy",t=>{this.hasSelection()&&Ux(t,this._selectionService)}));let e=t=>Px(t,this.textarea,this.coreService,this.optionsService);this._register(xe(this.textarea,"paste",e)),this._register(xe(this.element,"paste",e)),Db?this._register(xe(this.element,"mousedown",t=>{t.button===2&&lv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(xe(this.element,"contextmenu",t=>{lv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Md&&this._register(xe(this.element,"auxclick",t=>{t.button===1&&eb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(xe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(xe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Tf.get()),Bb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zn,this._coreBrowserService),this._register(xe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Zf,this._document,this._helperContainer),this._instantiationService.setService(yu,this._charSizeService),this._themeService=this._instantiationService.createInstance(td),this._instantiationService.setService(Ks,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(cu),this._instantiationService.setService(ob,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Jf,this.rows,this.screenElement)),this._instantiationService.setService(On,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(Xf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Qf),this._instantiationService.setService(wd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(ud,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(Vf,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(ed,this.element,this.screenElement,s)),this._instantiationService.setService(Xx,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(Yt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Kf,this.screenElement)),this._register(xe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(xe(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(xe(t,"wheel",o=>{var c,f,p,h,g;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,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=re.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 n;(n=this._renderService)==null||n.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){Jy(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=A2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===re.ETX||n.key===re.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(O2(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 n;(n=this._charSizeService)==null||n.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=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Vi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Zv=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 H2(t)}getNullCell(){return new Vi}},U2=class extends De{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ue),this.onBufferChange=this._onBufferChange.event,this._normal=new Zv(this._core.buffers.normal,"normal"),this._alternate=new Zv(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)}},P2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,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)}},I2=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}},F2=["cols","rows"],sn=0,q2=class extends De{constructor(e){super(),this._core=this._register(new z2(e)),this._addonManager=this._register(new j2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(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:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(F2.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 P2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new I2(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 U2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`,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 Tf.get()},set promptLabel(e){Tf.set(e)},get tooMuchOutput(){return Af.get()},set tooMuchOutput(e){Af.set(e)}}}_verifyIntegers(...e){for(sn of e)if(sn===1/0||isNaN(sn)||sn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(sn of e)if(sn&&(sn===1/0||isNaN(sn)||sn%1!==0||sn<0))throw new Error("This API only accepts positive integers")}};/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var W2=2,Y2=1,V2=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,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.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"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(W2,Math.floor(g/e.css.cell.width)),rows:Math.max(Y2,Math.floor(h/e.css.cell.height))}}};/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var Nt=0,Lt=0,zt=0,ct=0,Xt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Hr(a)}${Hr(o)}${Hr(c)}${Hr(f)}`:`#${Hr(a)}${Hr(o)}${Hr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(Xt||(Xt={}));var K2;(e=>{function t(p,h){if(ct=(h.rgba&255)/255,ct===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,E=p.rgba>>8&255;Nt=y+Math.round((g-y)*ct),Lt=x+Math.round((_-x)*ct),zt=E+Math.round((b-E)*ct);let N=Xt.toCss(Nt,Lt,zt),M=Xt.toRgba(Nt,Lt,zt);return{css:N,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=lu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return Xt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Nt,Lt,zt]=lu.toChannels(h),{css:Xt.toCss(Nt,Lt,zt),rgba:h}}e.opaque=a;function o(p,h){return ct=Math.round(h*255),[Nt,Lt,zt]=lu.toChannels(p.rgba),{css:Xt.toCss(Nt,Lt,zt,ct),rgba:Xt.toRgba(Nt,Lt,zt,ct)}}e.opacity=o;function c(p,h){return ct=p.rgba&255,o(p,ct*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(K2||(K2={}));var qt;(e=>{let t,n;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",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Nt=parseInt(a.slice(1,2).repeat(2),16),Lt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),Xt.toColor(Nt,Lt,zt);case 5:return Nt=parseInt(a.slice(1,2).repeat(2),16),Lt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),ct=parseInt(a.slice(4,5).repeat(2),16),Xt.toColor(Nt,Lt,zt,ct);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 Nt=parseInt(o[1]),Lt=parseInt(o[2]),zt=parseInt(o[3]),ct=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Xt.toColor(Nt,Lt,zt,ct);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Nt,Lt,zt,ct]=t.getImageData(0,0,1,1).data,ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Xt.toRgba(Nt,Lt,zt,ct),css:a}}e.toColor=s})(qt||(qt={}));var ni;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ni||(ni={}));var lu;(e=>{function t(c,f){if(ct=(f&255)/255,ct===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Nt=_+Math.round((p-_)*ct),Lt=b+Math.round((h-b)*ct),zt=y+Math.round((g-y)*ct),Xt.toRgba(Nt,Lt,zt)}e.blend=t;function n(c,f,p){let h=ni.relativeLuminance(c>>8),g=ni.relativeLuminance(f>>8);if(Bn(h,g)>8));if(x>8));return x>N?y:E}return y}let _=a(c,f,p),b=Bn(h,ni.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,E=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));for(;E0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),E=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,E=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));for(;E>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(lu||(lu={}));function Hr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Bn(e,t){return e{let e=[qt.toColor("#2e3436"),qt.toColor("#cc0000"),qt.toColor("#4e9a06"),qt.toColor("#c4a000"),qt.toColor("#3465a4"),qt.toColor("#75507b"),qt.toColor("#06989a"),qt.toColor("#d3d7cf"),qt.toColor("#555753"),qt.toColor("#ef2929"),qt.toColor("#8ae234"),qt.toColor("#fce94f"),qt.toColor("#729fcf"),qt.toColor("#ad7fa8"),qt.toColor("#34e2e2"),qt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:Xt.toCss(s,a,o),rgba:Xt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Xt.toCss(s,s,s),rgba:Xt.toRgba(s,s,s)})}return e})());function Qv(e,t,n){return Math.max(t,Math.min(e,n))}function $2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Fb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Nn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";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)n=`\r +`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Nn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Nn(c,p)&&Nn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\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++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!qb(e,t),a=!Nn(e,t),o=!Wb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Nn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Nn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Nn(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=n,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 n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}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&&(n+=`\x1B[${a.join(";")}m`),n}},Z2=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:Qv(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new G2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new Q2(n,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=n.length,h=t.scrollback,g=h===void 0?p:Qv(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.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="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.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 n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}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(){}},Q2=class extends Fb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=X2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.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+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!qb(e,t),a=!Nn(e,t),o=!Wb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"":""),a?this._currentRow+=" ":this._currentRow+=$2(e.getChars())}_serializeString(){return this._htmlContent}};const J2={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"},ek="plotlink-terminal",tk=1,gr="scrollback",Jv=10*1024*1024;function Bd(){return new Promise((e,t)=>{const n=indexedDB.open(ek,tk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(gr)||s.createObjectStore(gr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function $o(e,t){const n=t.length>Jv?t.slice(-Jv):t,s=await Bd();return new Promise((a,o)=>{const c=s.transaction(gr,"readwrite");c.objectStore(gr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function ik(e){const t=await Bd();return new Promise((n,s)=>{const o=t.transaction(gr,"readonly").objectStore(gr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function nk(e){const t=await Bd();return new Promise((n,s)=>{const a=t.transaction(gr,"readwrite");a.objectStore(gr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const ti=new Map;function rk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c}){const f=ne.useRef(null),p=ne.useRef(n),[h,g]=ne.useState([]),[_,b]=ne.useState(new Set),[y,x]=ne.useState(null),[E,N]=ne.useState(null),M=ne.useRef(()=>{});ne.useEffect(()=>{p.current=n},[n]);const G=ne.useCallback(B=>{var j;const{width:D}=B.container.getBoundingClientRect();if(!(D<50))try{B.fit.fit(),((j=B.ws)==null?void 0:j.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),U=ne.useCallback(B=>{for(const[D,j]of ti)j.container.style.display=D===B?"block":"none";if(B){const D=ti.get(B);D&&setTimeout(()=>G(D),50)}},[G]),Q=ne.useCallback((B,D,j)=>{const P=window.location.protocol==="https:"?"wss:":"ws:",L=new WebSocket(`${P}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${j}`);L.onopen=()=>{D.connected=!0,D._retried=!1,b(A=>{const I=new Set(A);return I.delete(B),I}),L.send(JSON.stringify({type:"resize",cols:D.term.cols,rows:D.term.rows}))},L.onmessage=A=>{D.term.write(A.data)},L.onclose=A=>{if(D.connected=!1,D.ws===L){D.ws=null;try{const I=D.serialize.serialize();$o(B,I).catch(()=>{})}catch{}if(A.code===4e3&&!D._retried){D._retried=!0,D.term.write(`\r +\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r +`),M.current(B,D,!1);return}b(I=>new Set(I).add(B))}},D.term.onData(A=>{L.readyState===WebSocket.OPEN&&L.send(A)}),D.ws=L},[e]);ne.useEffect(()=>{M.current=Q},[Q]);const K=ne.useCallback(async(B,D)=>{if(!f.current||ti.has(B))return;const{resume:j=!1,autoConnect:P=!0}=D??{},L=document.createElement("div");L.style.width="100%",L.style.height="100%",L.style.display="none",L.style.paddingLeft="10px",L.style.boxSizing="border-box",f.current.appendChild(L);const A=new q2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:J2,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),I=new V2,Y=new Z2;A.loadAddon(I),A.loadAddon(Y),A.open(L);const le={term:A,fit:I,serialize:Y,ws:null,container:L,observer:null,connected:!1},k=new ResizeObserver(()=>{var X;const{width:T}=L.getBoundingClientRect();if(!(T<50))try{I.fit(),((X=le.ws)==null?void 0:X.readyState)===WebSocket.OPEN&&le.ws.send(JSON.stringify({type:"resize",cols:A.cols,rows:A.rows}))}catch{}});k.observe(L),le.observer=k,ti.set(B,le),g(T=>[...T,B]);try{const T=await ik(B);T&&A.write(T)}catch{}P?Q(B,le,j):b(T=>new Set(T).add(B)),setTimeout(()=>G(le),50)},[Q,G]),O=ne.useCallback(async(B,D)=>{const j=ti.get(B);j&&(j.ws&&(j.ws.close(),j.ws=null),D||(await p.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),j.term.clear()),Q(B,j,D))},[Q]),ee=ne.useCallback(B=>{const D=ti.get(B);if(D){try{const j=D.serialize.serialize();$o(B,j).catch(()=>{})}catch{}D.observer.disconnect(),D.ws&&D.ws.close(),D.term.dispose(),D.container.remove(),ti.delete(B),g(j=>j.filter(P=>P!==B)),b(j=>{const P=new Set(j);return P.delete(B),P}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),oe=ne.useCallback(B=>{var j;const D=ti.get(B);D&&(((j=D.ws)==null?void 0:j.readyState)===WebSocket.OPEN&&D.ws.send(`exit +`),nk(B).catch(()=>{}),D.observer.disconnect(),D.ws&&D.ws.close(),D.term.dispose(),D.container.remove(),ti.delete(B),g(P=>P.filter(L=>L!==B)),b(P=>{const L=new Set(P);return L.delete(B),L}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]);ne.useEffect(()=>{t&&(ti.has(t)?U(t):p.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!ti.has(t)){const D=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);K(t,{autoConnect:!D}),U(t)}}).catch(()=>{ti.has(t)||(K(t),U(t))}))},[t,K,U]),ne.useEffect(()=>{const B=setInterval(()=>{for(const[D,j]of ti)if(j.connected)try{const P=j.serialize.serialize();$o(D,P).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),ne.useEffect(()=>()=>{for(const[B,D]of ti){try{const j=D.serialize.serialize();$o(B,j).catch(()=>{})}catch{}D.observer.disconnect(),D.ws&&D.ws.close(),D.term.dispose(),D.container.remove(),p.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}ti.clear()},[]);const de=t?_.has(t):!1,q=h.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!q&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[h.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${_.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:D=>{D.stopPropagation(),B.startsWith("_new_")?x(B):ee(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>x(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))?S.jsx("button",{onClick:()=>N(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]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:f,className:"h-full"}),q&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),y&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>x(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=y;x(null),oe(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),E&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>N(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=E;N(null);try{(await p.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ee(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),de&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>O(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>O(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function sk(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ak=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ok={};function ey(e,t){return(ok.jsx?ak:lk).test(e)}const uk=/[ \t\n\f\r]/g;function ck(e){return typeof e=="object"?e.type==="text"?ty(e.value):!1:ty(e)}function ty(e){return e.replace(uk,"")===""}class ba{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}ba.prototype.normal={};ba.prototype.property={};ba.prototype.space=void 0;function Yb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new ba(n,s,t)}function cd(e){return e.toLowerCase()}class vi{constructor(t,n){this.attribute=n,this.property=t}}vi.prototype.attribute="";vi.prototype.booleanish=!1;vi.prototype.boolean=!1;vi.prototype.commaOrSpaceSeparated=!1;vi.prototype.commaSeparated=!1;vi.prototype.defined=!1;vi.prototype.mustUseProperty=!1;vi.prototype.number=!1;vi.prototype.overloadedBoolean=!1;vi.prototype.property="";vi.prototype.spaceSeparated=!1;vi.prototype.space=void 0;let hk=0;const Ee=$r(),yt=$r(),hd=$r(),ae=$r(),Je=$r(),Ws=$r(),Ri=$r();function $r(){return 2**++hk}const fd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ee,booleanish:yt,commaOrSpaceSeparated:Ri,commaSeparated:Ws,number:ae,overloadedBoolean:hd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),of=Object.keys(fd);class Nd extends vi{constructor(t,n,s,a){let o=-1;if(super(t,n),iy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&_k.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ny,yk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ny.test(o)){let c=o.replace(mk,vk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Nd}return new a(s,t)}function vk(e){return"-"+e.toLowerCase()}function yk(e){return e.charAt(1).toUpperCase()}const bk=Yb([Vb,fk,$b,Gb,Zb],"html"),Ld=Yb([Vb,dk,$b,Gb,Zb],"svg");function Sk(e){return e.join(" ").trim()}var Ps={},uf,ry;function xk(){if(ry)return uf;ry=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` +`,h="/",g="*",_="",b="comment",y="declaration";function x(N,M){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];M=M||{};var G=1,U=1;function Q(P){var L=P.match(t);L&&(G+=L.length);var A=P.lastIndexOf(p);U=~A?P.length-A:U+P.length}function K(){var P={line:G,column:U};return function(L){return L.position=new O(P),de(),L}}function O(P){this.start=P,this.end={line:G,column:U},this.source=M.source}O.prototype.content=N;function ee(P){var L=new Error(M.source+":"+G+":"+U+": "+P);if(L.reason=P,L.filename=M.source,L.line=G,L.column=U,L.source=N,!M.silent)throw L}function oe(P){var L=P.exec(N);if(L){var A=L[0];return Q(A),N=N.slice(A.length),L}}function de(){oe(n)}function q(P){var L;for(P=P||[];L=B();)L!==!1&&P.push(L);return P}function B(){var P=K();if(!(h!=N.charAt(0)||g!=N.charAt(1))){for(var L=2;_!=N.charAt(L)&&(g!=N.charAt(L)||h!=N.charAt(L+1));)++L;if(L+=2,_===N.charAt(L-1))return ee("End of comment missing");var A=N.slice(2,L-2);return U+=2,Q(A),N=N.slice(L),U+=2,P({type:b,comment:A})}}function D(){var P=K(),L=oe(s);if(L){if(B(),!oe(a))return ee("property missing ':'");var A=oe(o),I=P({type:y,property:E(L[0].replace(e,_)),value:A?E(A[0].replace(e,_)):_});return oe(c),I}}function j(){var P=[];q(P);for(var L;L=D();)L!==!1&&(P.push(L),q(P));return P}return de(),j()}function E(N){return N?N.replace(f,_):_}return uf=x,uf}var sy;function wk(){if(sy)return Ps;sy=1;var e=Ps&&Ps.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=n;const t=e(xk());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Ps}var Zl={},ly;function Ck(){if(ly)return Zl;ly=1,Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return Zl.camelCase=p,Zl}var Ql,ay;function kk(){if(ay)return Ql;ay=1;var e=Ql&&Ql.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(wk()),n=Ck();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,Ql=s,Ql}var Ek=kk();const Tk=gu(Ek),Qb=Jb("end"),zd=Jb("start");function Jb(e){return t;function t(n){const s=n&&n.position&&n.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 eS(e){const t=zd(e),n=Qb(e);if(t&&n)return{start:t,end:n}}function aa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?oy(e.position):"start"in e||"end"in e?oy(e):"line"in e||"column"in e?dd(e):""}function dd(e){return uy(e&&e.line)+":"+uy(e&&e.column)}function oy(e){return dd(e&&e.start)+"-"+dd(e&&e.end)}function uy(e){return e&&typeof e=="number"?e:1}class Gt extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),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 f=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=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=aa(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}}Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;const Od={}.hasOwnProperty,Ak=new Map,Dk=/[A-Z]/g,Rk=new Set(["table","tbody","thead","tfoot","tr"]),Mk=new Set(["td","th"]),tS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=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=Pk(n,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=Uk(n,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:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ld:bk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=iS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function iS(e,t,n){if(t.type==="element")return Nk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Lk(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Ok(e,t,n);if(t.type==="mdxjsEsm")return zk(e,t);if(t.type==="root")return jk(e,t,n);if(t.type==="text")return Hk(e,t)}function Nk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Ld,e.schema=a),e.ancestors.push(t);const o=rS(e,t.tagName,!1),c=Ik(e,t);let f=Hd(e,t);return Rk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!ck(p):!0})),nS(e,c,o,t),jd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Lk(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)}da(e,t.position)}function zk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);da(e,t.position)}function Ok(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Ld,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:rS(e,t.name,!0),c=Fk(e,t),f=Hd(e,t);return nS(e,c,o,t),jd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function jk(e,t,n){const s={};return jd(s,Hd(e,t)),e.create(t,e.Fragment,s,n)}function Hk(e,t){return t.value}function nS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function jd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Uk(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Pk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=zd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function Ik(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Od.call(t.properties,a)){const o=qk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Mk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Fk(e,t){const n={};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 f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else da(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 f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else da(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Hd(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Ak;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Mi(e,e.length,0,t),e):t}const fy={}.hasOwnProperty;function lS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Qi(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ri=vr(/[A-Za-z]/),$t=vr(/[\dA-Za-z]/),Qk=vr(/[#-'*+\--9=?A-Z^-~]/);function pu(e){return e!==null&&(e<32||e===127)}const pd=vr(/\d/),Jk=vr(/[\dA-Fa-f]/),eE=vr(/[!-/:-@[-`{-~]/);function ve(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Le(e){return e===-2||e===-1||e===32}const xu=vr(new RegExp("\\p{P}|\\p{S}","u")),Kr=vr(/\s/);function vr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gs(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Le(p)?(e.enter(n),f(p)):t(p)}function f(p){return Le(p)&&o++c))return;const ee=t.events.length;let oe=ee,de,q;for(;oe--;)if(t.events[oe][0]==="exit"&&t.events[oe][1].type==="chunkFlow"){if(de){q=t.events[oe][1].end;break}de=!0}for(M(s),O=ee;OU;){const K=n[Q];t.containerState=K[1],K[0].exit.call(t,e)}n.length=U}function G(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function sE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vs(e){if(e===null||Qe(e)||Kr(e))return 1;if(xu(e))return 2}function wu(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};py(_,-p),py(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Yi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Yi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Yi(h,wu(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Yi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Yi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Mi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Le(O)?Ue(e,G,"linePrefix",o+1)(O):G(O)}function G(O){return O===null||ve(O)?e.check(my,E,Q)(O):(e.enter("codeFlowValue"),U(O))}function U(O){return O===null||ve(O)?(e.exit("codeFlowValue"),G(O)):(e.consume(O),U)}function Q(O){return e.exit("codeFenced"),t(O)}function K(O,ee,oe){let de=0;return q;function q(L){return O.enter("lineEnding"),O.consume(L),O.exit("lineEnding"),B}function B(L){return O.enter("codeFencedFence"),Le(L)?Ue(O,D,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):D(L)}function D(L){return L===f?(O.enter("codeFencedFenceSequence"),j(L)):oe(L)}function j(L){return L===f?(de++,O.consume(L),j):de>=c?(O.exit("codeFencedFenceSequence"),Le(L)?Ue(O,P,"whitespace")(L):P(L)):oe(L)}function P(L){return L===null||ve(L)?(O.exit("codeFencedFence"),ee(L)):oe(L)}}}function gE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const hf={name:"codeIndented",tokenize:yE},vE={partial:!0,tokenize:bE};function yE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):ve(h)?e.attempt(vE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||ve(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function bE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):ve(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):ve(c)?a(c):n(c)}}const SE={name:"codeText",previous:wE,resolve:xE,tokenize:CE};function xE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=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 tthis.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,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&Jl(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),Jl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jl(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=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function fS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||pu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),E(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||ve(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function E(M){return!g&&(M===null||M===41||Qe(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):ve(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||ve(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Le(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function pS(e,t,n,s,a,o){let c;return f;function f(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):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):ve(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||ve(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function oa(e,t){let n;return s;function s(a){return ve(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Le(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const BE={name:"definition",tokenize:LE},NE={partial:!0,tokenize:zE};function LE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return dS.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Qi(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?oa(e,h)(y):h(y)}function h(y){return fS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(NE,_,_)(y)}function _(y){return Le(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||ve(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function zE(e,t,n){return s;function s(f){return Qe(f)?oa(e,a)(f):n(f)}function a(f){return pS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Le(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||ve(f)?t(f):n(f)}}const OE={name:"hardBreakEscape",tokenize:jE};function jE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ve(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const HE={name:"headingAtx",resolve:UE,tokenize:PE};function UE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Mi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function PE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||ve(g)?(e.exit("atxHeading"),t(g)):Le(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const IE=["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"],gy=["pre","script","style","textarea"],FE={concrete:!0,name:"htmlFlow",resolveTo:YE,tokenize:VE},qE={partial:!0,tokenize:XE},WE={partial:!0,tokenize:KE};function YE(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 VE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,s.interrupt?t:k):ri(C)?(e.consume(C),c=String.fromCharCode(C),N):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):ri(C)?(e.consume(C),a=4,s.interrupt?t:k):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:k):n(C)}function x(C){const se="CDATA[";return C===se.charCodeAt(f++)?(e.consume(C),f===se.length?s.interrupt?t:D:x):n(C)}function E(C){return ri(C)?(e.consume(C),c=String.fromCharCode(C),N):n(C)}function N(C){if(C===null||C===47||C===62||Qe(C)){const se=C===47,pe=c.toLowerCase();return!se&&!o&&gy.includes(pe)?(a=1,s.interrupt?t(C):D(C)):IE.includes(c.toLowerCase())?(a=6,se?(e.consume(C),M):s.interrupt?t(C):D(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?G(C):U(C))}return C===45||$t(C)?(e.consume(C),c+=String.fromCharCode(C),N):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:D):n(C)}function G(C){return Le(C)?(e.consume(C),G):q(C)}function U(C){return C===47?(e.consume(C),q):C===58||C===95||ri(C)?(e.consume(C),Q):Le(C)?(e.consume(C),U):q(C)}function Q(C){return C===45||C===46||C===58||C===95||$t(C)?(e.consume(C),Q):K(C)}function K(C){return C===61?(e.consume(C),O):Le(C)?(e.consume(C),K):U(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,ee):Le(C)?(e.consume(C),O):oe(C)}function ee(C){return C===p?(e.consume(C),p=null,de):C===null||ve(C)?n(C):(e.consume(C),ee)}function oe(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?K(C):(e.consume(C),oe)}function de(C){return C===47||C===62||Le(C)?U(C):n(C)}function q(C){return C===62?(e.consume(C),B):n(C)}function B(C){return C===null||ve(C)?D(C):Le(C)?(e.consume(C),B):n(C)}function D(C){return C===45&&a===2?(e.consume(C),A):C===60&&a===1?(e.consume(C),I):C===62&&a===4?(e.consume(C),T):C===63&&a===3?(e.consume(C),k):C===93&&a===5?(e.consume(C),le):ve(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(qE,X,j)(C)):C===null||ve(C)?(e.exit("htmlFlowData"),j(C)):(e.consume(C),D)}function j(C){return e.check(WE,P,X)(C)}function P(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),L}function L(C){return C===null||ve(C)?j(C):(e.enter("htmlFlowData"),D(C))}function A(C){return C===45?(e.consume(C),k):D(C)}function I(C){return C===47?(e.consume(C),c="",Y):D(C)}function Y(C){if(C===62){const se=c.toLowerCase();return gy.includes(se)?(e.consume(C),T):D(C)}return ri(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),Y):D(C)}function le(C){return C===93?(e.consume(C),k):D(C)}function k(C){return C===62?(e.consume(C),T):C===45&&a===2?(e.consume(C),k):D(C)}function T(C){return C===null||ve(C)?(e.exit("htmlFlowData"),X(C)):(e.consume(C),T)}function X(C){return e.exit("htmlFlow"),t(C)}}function KE(e,t,n){const s=this;return a;function a(c){return ve(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function XE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Sa,t,n)}}const $E={name:"htmlText",tokenize:GE};function GE(e,t,n){const s=this;let a,o,c;return f;function f(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),p}function p(k){return k===33?(e.consume(k),h):k===47?(e.consume(k),K):k===63?(e.consume(k),U):ri(k)?(e.consume(k),oe):n(k)}function h(k){return k===45?(e.consume(k),g):k===91?(e.consume(k),o=0,x):ri(k)?(e.consume(k),G):n(k)}function g(k){return k===45?(e.consume(k),y):n(k)}function _(k){return k===null?n(k):k===45?(e.consume(k),b):ve(k)?(c=_,I(k)):(e.consume(k),_)}function b(k){return k===45?(e.consume(k),y):_(k)}function y(k){return k===62?A(k):k===45?b(k):_(k)}function x(k){const T="CDATA[";return k===T.charCodeAt(o++)?(e.consume(k),o===T.length?E:x):n(k)}function E(k){return k===null?n(k):k===93?(e.consume(k),N):ve(k)?(c=E,I(k)):(e.consume(k),E)}function N(k){return k===93?(e.consume(k),M):E(k)}function M(k){return k===62?A(k):k===93?(e.consume(k),M):E(k)}function G(k){return k===null||k===62?A(k):ve(k)?(c=G,I(k)):(e.consume(k),G)}function U(k){return k===null?n(k):k===63?(e.consume(k),Q):ve(k)?(c=U,I(k)):(e.consume(k),U)}function Q(k){return k===62?A(k):U(k)}function K(k){return ri(k)?(e.consume(k),O):n(k)}function O(k){return k===45||$t(k)?(e.consume(k),O):ee(k)}function ee(k){return ve(k)?(c=ee,I(k)):Le(k)?(e.consume(k),ee):A(k)}function oe(k){return k===45||$t(k)?(e.consume(k),oe):k===47||k===62||Qe(k)?de(k):n(k)}function de(k){return k===47?(e.consume(k),A):k===58||k===95||ri(k)?(e.consume(k),q):ve(k)?(c=de,I(k)):Le(k)?(e.consume(k),de):A(k)}function q(k){return k===45||k===46||k===58||k===95||$t(k)?(e.consume(k),q):B(k)}function B(k){return k===61?(e.consume(k),D):ve(k)?(c=B,I(k)):Le(k)?(e.consume(k),B):de(k)}function D(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),a=k,j):ve(k)?(c=D,I(k)):Le(k)?(e.consume(k),D):(e.consume(k),P)}function j(k){return k===a?(e.consume(k),a=void 0,L):k===null?n(k):ve(k)?(c=j,I(k)):(e.consume(k),j)}function P(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Qe(k)?de(k):(e.consume(k),P)}function L(k){return k===47||k===62||Qe(k)?de(k):n(k)}function A(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function I(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),Y}function Y(k){return Le(k)?Ue(e,le,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):le(k)}function le(k){return e.enter("htmlTextData"),c(k)}}const Id={name:"labelEnd",resolveAll:e5,resolveTo:t5,tokenize:i5},ZE={tokenize:n5},QE={tokenize:r5},JE={tokenize:s5};function e5(e){let t=-1;const n=[];for(;++t=3&&(h===null||ve(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Le(h)?Ue(e,f,"whitespace")(h):f(h))}}const gi={continuation:{tokenize:m5},exit:g5,name:"list",tokenize:p5},f5={partial:!0,tokenize:v5},d5={partial:!0,tokenize:_5};function p5(e,t,n){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 f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:pd(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(au,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return pd(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Sa,s.interrupt?n:g,e.attempt(f5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Le(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function m5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Sa,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Le(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(d5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(gi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function _5(e,t,n){const s=this;return Ue(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):n(o)}}function g5(e){e.exit(this.containerState.type)}function v5(e,t,n){const s=this;return Ue(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!Le(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const vy={name:"setextUnderline",resolveTo:y5,tokenize:b5};function y5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);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 b5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Le(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||ve(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const S5={tokenize:x5};function x5(e){const t=this,n=e.attempt(Sa,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(TE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const w5={resolveAll:_S()},C5=mS("string"),k5=mS("text");function mS(e){return{resolveAll:_S(e==="text"?E5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function _S(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function E5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const T5={42:gi,43:gi,45:gi,48:gi,49:gi,50:gi,51:gi,52:gi,53:gi,54:gi,55:gi,56:gi,57:gi,62:oS},A5={91:BE},D5={[-2]:hf,[-1]:hf,32:hf},R5={35:HE,42:au,45:[vy,au],60:FE,61:vy,95:au,96:_y,126:_y},M5={38:cS,92:uS},B5={[-5]:ff,[-4]:ff,[-3]:ff,33:l5,38:cS,42:md,60:[oE,$E],91:o5,92:[OE,uS],93:Id,95:md,96:SE},N5={null:[md,w5]},L5={null:[42,95]},z5={null:[]},O5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:L5,contentInitial:A5,disable:z5,document:T5,flow:R5,flowInitial:D5,insideSpan:N5,string:M5,text:B5},Symbol.toStringTag,{value:"Module"}));function j5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:ee(K),check:ee(O),consume:G,enter:U,exit:Q,interrupt:ee(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:E,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(B){return c=Yi(c,B),N(),c[c.length-1]!==null?[]:(oe(t,0),h.events=wu(o,h.events,h),h.events)}function b(B,D){return U5(y(B),D)}function y(B){return H5(c,B)}function x(){const{_bufferIndex:B,_index:D,line:j,column:P,offset:L}=s;return{_bufferIndex:B,_index:D,line:j,column:P,offset:L}}function E(B){a[B.line]=B.column,q()}function N(){let B;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function U5(e,t){let n=-1;const s=[];let a;for(;++n0){const bi=Se.tokenStack[Se.tokenStack.length-1];(bi[1]||by).call(Se,void 0,bi[0])}for(ce.position={start:fr(J.length>0?J[0][1].start:{line:1,column:1,offset:0}),end:fr(J.length>0?J[J.length-2][1].end:{line:1,column:1,offset:0})},qe=-1;++qe0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};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 J5(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=Gs(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function iT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function yS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="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 rT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return yS(e,t);const a={src:Gs(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 sT(e,t){const n={src:Gs(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function lT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function aT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return yS(e,t);const a={href:Gs(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 oT(e,t){const n={href:Gs(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function uT(e,t,n){const s=e.all(t),a=n?cT(n):bS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={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 f=-1;for(;++f1}function hT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=zd(t.children[1]),p=Qb(t.children[t.children.length-1]);f&&p&&(c.position={start:f,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 _T(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(wy(t.slice(a),a>0,!1)),o.join("")}function wy(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Sy||o===xy;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Sy||o===xy;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function yT(e,t){const n={type:"text",value:vT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function bT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const ST={blockquote:G5,break:Z5,code:Q5,delete:J5,emphasis:eT,footnoteReference:tT,heading:iT,html:nT,imageReference:rT,image:sT,inlineCode:lT,linkReference:aT,link:oT,listItem:uT,list:hT,paragraph:fT,root:dT,strong:pT,table:mT,tableCell:gT,tableRow:_T,text:yT,thematicBreak:bT,toml:Go,yaml:Go,definition:Go,footnoteDefinition:Go};function Go(){}const SS=-1,Cu=0,ua=1,mu=2,Fd=3,qd=4,Wd=5,Yd=6,xS=7,wS=8,Cy=typeof self=="object"?self:globalThis,xT=(e,t)=>{const n=(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 Cu:case SS:return n(c,a);case ua:{const f=n([],a);for(const p of c)f.push(s(p));return f}case mu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Fd:return n(new Date(c),a);case qd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Wd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Yd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case xS:{const{name:f,message:p}=c;return n(new Cy[f](p),a)}case wS:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Cy[o](c),a)};return s},ky=e=>xT(new Map,e)(0),Is="",{toString:wT}={},{keys:CT}=Object,ea=e=>{const t=typeof e;if(t!=="object"||!e)return[Cu,t];const n=wT.call(e).slice(8,-1);switch(n){case"Array":return[ua,Is];case"Object":return[mu,Is];case"Date":return[Fd,Is];case"RegExp":return[qd,Is];case"Map":return[Wd,Is];case"Set":return[Yd,Is];case"DataView":return[ua,n]}return n.includes("Array")?[ua,n]:n.includes("Error")?[xS,n]:[mu,n]},Zo=([e,t])=>e===Cu&&(t==="function"||t==="symbol"),kT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=ea(c);switch(f){case Cu:{let g=c;switch(p){case"bigint":f=wS,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([SS],c)}return a([f,g],c)}case ua:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case mu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of CT(c))(e||!Zo(ea(c[b])))&&g.push([o(b),o(c[b])]);return _}case Fd:return a([f,c.toISOString()],c);case qd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Wd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(Zo(ea(b))||Zo(ea(y))))&&g.push([o(b),o(y)]);return _}case Yd:{const g=[],_=a([f,g],c);for(const b of c)(e||!Zo(ea(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Ey=(e,{json:t,lossy:n}={})=>{const s=[];return kT(!(t||n),!!t,new Map,s)(e),s},pa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ky(Ey(e,t)):structuredClone(e):(e,t)=>ky(Ey(e,t));function ET(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function TT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function AT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ET,s=e.options.footnoteBackLabel||TT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let G=typeof n=="string"?n:n(p,y);typeof G=="string"&&(G={type:"text",value:G}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(G)?G:[G]})}const N=g[g.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const G=N.children[N.children.length-1];G&&G.type==="text"?G.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...pa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` +`}]}}const ku=(function(e){if(e==null)return BT;if(typeof e=="function")return Eu(e);if(typeof e=="object")return Array.isArray(e)?DT(e):RT(e);if(typeof e=="string")return MT(e);throw new Error("Expected function, string, or object as test")});function DT(e){const t=[];let n=-1;for(;++n":""))+")"})}return b;function b(){let y=CS,x,E,N;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=OT(n(p,g)),y[0]===_d))return y;if("children"in p&&p.children){const M=p;if(M.children&&y[0]!==zT)for(E=(s?M.children.length:-1)+c,N=g.concat(M);E>-1&&E0&&n.push({type:"text",value:` +`}),n}function Ty(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ay(e,t){const n=HT(e,t),s=n.one(e,void 0),a=AT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` +`},a),o}function qT(e,t){return e&&"run"in e?async function(n,s){const a=Ay(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Ay(n,{file:s,...e||t})}}function Dy(e){if(e)throw e}var df,Ry;function WT(){if(Ry)return df;Ry=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return df=function p(){var h,g,_,b,y,x,E=arguments[0],N=1,M=arguments.length,G=!1;for(typeof E=="boolean"&&(G=E,E=arguments[1]||{},N=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});Nc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const an={basename:XT,dirname:$T,extname:GT,join:ZT,sep:"/"};function XT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xa(e);let n=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){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function $T(e){if(xa(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function GT(e){xa(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function ZT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function JT(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function xa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const e3={cwd:t3};function t3(){return"/"}function yd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function i3(e){if(typeof e=="string")e=new URL(e);else if(!yd(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 n3(e)}function n3(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 n=-1;for(;++n0){let[y,...x]=g;const E=s[b][1];vd(E)&&vd(y)&&(y=pf(!0,E,y)),s[b]=[h,y,...x]}}}}const a3=new Kd().freeze();function vf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bf(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 By(e){if(!vd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ny(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qo(e){return o3(e)?e:new ES(e)}function o3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function u3(e){return typeof e=="string"||c3(e)}function c3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const h3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ly=[],zy={allowDangerousHtml:!0},f3=/^(https?|ircs?|mailto|xmpp)$/i,d3=[{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 p3(e){const t=m3(e),n=_3(e);return g3(t.runSync(t.parse(n),n),e)}function m3(e){const t=e.rehypePlugins||Ly,n=e.remarkPlugins||Ly,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...zy}:zy;return a3().use($5).use(n).use(qT,s).use(t)}function _3(e){const t=e.children||"",n=new ES;return typeof t=="string"&&(n.value=t),n}function g3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||v3;for(const g of d3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+h3+g.id,void 0);return Vd(e,h),Bk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in cf)if(Object.hasOwn(cf,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],E=cf[y];(E===null||E.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function v3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||f3.test(e.slice(0,t))?e:""}function y3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function TS(e,t,n){const a=ku((n||{}).ignore||[]),o=b3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Q+1:(x!==Q&&G.push({type:"text",value:h.value.slice(x,Q)}),Array.isArray(O)?G.push(...O):O&&G.push(O),x=Q+U[0].length,M=!0),!b.global)break;U=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Oy(e,"(");let o=Oy(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function AS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Kr(n)||xu(n))&&(!t||n!==47)}DS.peek=V3;function H3(){this.buffer()}function U3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function P3(){this.buffer()}function I3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function F3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function q3(e){this.exit(e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(){return"["}function DS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function K3(){return{enter:{gfmFootnoteCallString:H3,gfmFootnoteCall:U3,gfmFootnoteDefinitionLabelString:P3,gfmFootnoteDefinition:I3},exit:{gfmFootnoteCallString:F3,gfmFootnoteCall:q3,gfmFootnoteDefinitionLabelString:W3,gfmFootnoteDefinition:Y3}}}function X3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:DS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` +`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?RS:$3))),h(),p}}function $3(e,t,n){return t===0?e:RS(e,t,n)}function RS(e,t,n){return(n?"":" ")+e}const G3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];MS.peek=tA;function Z3(){return{canContainEols:["delete"],enter:{strikethrough:J3},exit:{strikethrough:eA}}}function Q3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:G3}],handlers:{delete:MS}}}function J3(e){this.enter({type:"delete",children:[]},e)}function eA(e){this.exit(e)}function MS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function tA(){return"~"}function iA(e){return e.length}function nA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||iA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Mp[M])&&(p[M]=U)}E.push(G)}c[g]=E,f[g]=N}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=G),y[_]=G),b[_]=U}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),lA);return a(),c}function lA(e,t,n){return">"+(n?"":" ")+e}function aA(e,t){return Hy(e,t.inConstruct,!0)&&!Hy(e,t.notInConstruct,!1)}function Hy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function uA(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 cA(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 hA(e,t,n,s){const a=cA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(uA(e,n)){const _=n.enter("codeIndented"),b=n.indentLines(o,fA);return _(),b}const f=n.createTracker(s),p=a.repeat(Math.max(oA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` +`,encode:["`"],...f.current()})),_()}return g+=f.move(` +`),o&&(g+=f.move(o+` +`)),g+=f.move(p),h(),g}function fA(e,t,n){return(n?"":" ")+e}function Xd(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 dA(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` +`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function pA(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 ma(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,t,n){const s=Vs(e),a=Vs(t);return s===void 0?a===void 0?n==="_"?{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}}BS.peek=mA;function BS(e,t,n,s){const a=pA(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=ma(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=_u(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+ma(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function mA(e,t,n){return n.options.emphasis||"*"}function _A(e,t){let n=!1;return Vd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,_d}),!!((!e.depth||e.depth<3)&&Ud(e)&&(t.options.setext||n))}function gA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(_A(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` +`,after:` +`});return _(),g(),b+` +`+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` +`))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` +`,...o.current()});return/^[\t ]/.test(h)&&(h=ma(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}NS.peek=vA;function NS(e){return e.value||""}function vA(){return"<"}LS.peek=yA;function LS(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function yA(){return"!"}zS.peek=bA;function zS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function bA(){return"!"}OS.peek=SA;function OS(e,t,n){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\u007F]/.test(e.url))}HS.peek=xA;function HS(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(jS(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function xA(e,t,n){return jS(e,n)?"<":"["}US.peek=wA;function US(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function wA(){return"["}function $d(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 CA(e){const t=$d(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function kA(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 PS(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 EA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?kA(n):$d(n);const f=e.ordered?c==="."?")":".":CA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),PS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.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 f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function DA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const RA=ku(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function MA(e,t,n,s){return(e.children.some(function(c){return RA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function BA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}IS.peek=NA;function IS(e,t,n,s){const a=BA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=ma(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=_u(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+ma(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function NA(e,t,n){return n.options.strong||"*"}function LA(e,t,n,s){return n.safe(e.value,s)}function zA(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 OA(e,t,n){const s=(PS(n)+(n.options.ruleSpaces?" ":"")).repeat(zA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const FS={blockquote:sA,break:Uy,code:hA,definition:dA,emphasis:BS,hardBreak:Uy,heading:gA,html:NS,image:LS,imageReference:zS,inlineCode:OS,link:HS,linkReference:US,list:EA,listItem:AA,paragraph:DA,root:MA,strong:IS,text:LA,thematicBreak:OA};function jA(){return{enter:{table:HA,tableData:Py,tableHeader:Py,tableRow:PA},exit:{codeText:IA,table:UA,tableData:Cf,tableHeader:Cf,tableRow:Cf}}}function HA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function UA(e){this.exit(e),this.data.inTable=void 0}function PA(e){this.enter({type:"tableRow",children:[]},e)}function Cf(e){this.exit(e)}function Py(e){this.enter({type:"tableCell",children:[]},e)}function IA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,FA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function FA(e,t){return t==="|"?t:e}function qA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,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:f}};function c(y,x,E,N){return h(g(y,E,N),y.align)}function f(y,x,E,N){const M=_(y,E,N),G=h([M]);return G.slice(0,G.indexOf(` +`))}function p(y,x,E,N){const M=E.enter("tableCell"),G=E.enter("phrasing"),U=E.containerPhrasing(y,{...N,before:o,after:o});return G(),M(),U}function h(y,x){return nA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,E){const N=y.children;let M=-1;const G=[],U=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const aD={tokenize:mD,partial:!0};function oD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:fD,continuation:{tokenize:dD},exit:pD}},text:{91:{name:"gfmFootnoteCall",tokenize:hD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:uD,resolveTo:cD}}}}function uD(e,t,n){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 f;function f(p){if(!c||!c._balanced)return n(p);const h=Qi(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function cD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+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)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+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(n,e.length-n+1,...f),e}function hD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Qi(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function fD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||Qe(x))return n(x);if(x===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Qi(s.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Qe(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function dD(e,t,n){return e.check(Sa,t,e.attempt(aD,t,n))}function pD(e){e.exit("gfmFootnoteDefinition")}function mD(e,t,n){const s=this;return Ue(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):n(o)}}function _D(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const N=c.exit("strikethroughSequenceTemporary"),M=Vs(x);return N._open=!M||M===2&&!!E,N._close=!E||E===2&&!!M,f(x)}}}class gD{constructor(){this.map=[]}add(t,n,s){vD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][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 vD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const P=s.events[B][1].type;if(P==="lineEnding"||P==="linePrefix")B--;else break}const D=B>-1?s.events[B][1].type:null,j=D==="tableHead"||D==="tableRow"?O:p;return j===O&&s.parser.lazy[s.now().line]?n(q):j(q)}function p(q){return e.enter("tableHead"),e.enter("tableRow"),h(q)}function h(q){return q===124||(c=!0,o+=1),g(q)}function g(q){return q===null?n(q):ve(q)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(q),e.exit("lineEnding"),y):n(q):Le(q)?Ue(e,g,"whitespace")(q):(o+=1,c&&(c=!1,a+=1),q===124?(e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(q)))}function _(q){return q===null||q===124||Qe(q)?(e.exit("data"),g(q)):(e.consume(q),q===92?b:_)}function b(q){return q===92||q===124?(e.consume(q),_):_(q)}function y(q){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(q):(e.enter("tableDelimiterRow"),c=!1,Le(q)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):x(q))}function x(q){return q===45||q===58?N(q):q===124?(c=!0,e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),E):K(q)}function E(q){return Le(q)?Ue(e,N,"whitespace")(q):N(q)}function N(q){return q===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(q),e.exit("tableDelimiterMarker"),M):q===45?(o+=1,M(q)):q===null||ve(q)?Q(q):K(q)}function M(q){return q===45?(e.enter("tableDelimiterFiller"),G(q)):K(q)}function G(q){return q===45?(e.consume(q),G):q===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(q),e.exit("tableDelimiterMarker"),U):(e.exit("tableDelimiterFiller"),U(q))}function U(q){return Le(q)?Ue(e,Q,"whitespace")(q):Q(q)}function Q(q){return q===124?x(q):q===null||ve(q)?!c||a!==o?K(q):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(q)):K(q)}function K(q){return n(q)}function O(q){return e.enter("tableRow"),ee(q)}function ee(q){return q===124?(e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),ee):q===null||ve(q)?(e.exit("tableRow"),t(q)):Le(q)?Ue(e,ee,"whitespace")(q):(e.enter("data"),oe(q))}function oe(q){return q===null||q===124||Qe(q)?(e.exit("data"),ee(q)):(e.consume(q),q===92?de:oe)}function de(q){return q===92||q===124?(e.consume(q),oe):oe(q)}}function xD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new gD;for(;++nn[2]+1){const x=n[2]+1,E=n[3]-n[2]-1;e.add(x,E,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Fs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Fy(e,t,n,s,a){const o=[],c=Fs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Fs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const wD={name:"tasklistCheck",tokenize:kD};function CD(){return{text:{91:wD}}}function kD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(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):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return ve(p)?t(p):Le(p)?e.check({tokenize:ED},t,n)(p):n(p)}}function ED(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function TD(e){return lS([QA(),oD(),_D(e),bD(),CD()])}const AD={};function DD(e){const t=this,n=e||AD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(TD(n)),o.push(XA()),c.push($A(n))}const Pr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],qy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Pr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Pr],h2:[["className","sr-only"]],img:[...Pr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Pr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Pr],table:[...Pr],ul:[...Pr,["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"]},pr={}.hasOwnProperty;function RD(e,t){let n={type:"root",children:[]};const s={schema:t?{...qy,...t}:qy,stack:[]},a=ZS(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function ZS(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return MD(e,n);case"doctype":return BD(e,n);case"element":return ND(e,n);case"root":return LD(e,n);case"text":return zD(e,n)}}}function MD(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return wa(o,t),o}}function BD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return wa(n,t),n}}function ND(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=QS(e,t.children),a=OD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&pr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function UD(e){return function(t){return RD(t,e)}}function PD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a}){const[o,c]=ne.useState(null),[f,p]=ne.useState(!1),[h,g]=ne.useState("preview"),[_,b]=ne.useState(""),[y,x]=ne.useState(!1),[E,N]=ne.useState(!1),[M,G]=ne.useState(!1),[U,Q]=ne.useState(null),K=ne.useRef(null),O=ne.useRef(!1),ee=ne.useRef(null),oe=ne.useCallback(async()=>{if(!e||!t){c(null);return}const le=`${e}/${t}`,k=ee.current!==le;k&&(ee.current=le);try{const T=await n(`/api/stories/${e}/${t}`);if(T.ok){const X=await T.json();c(X),(k||!O.current)&&(b(X.content??""),k&&(N(!1),O.current=!1))}}catch{}},[e,t,n]);ne.useEffect(()=>{p(!0),oe().finally(()=>p(!1))},[oe]),ne.useEffect(()=>{if(!e||!t||h==="edit"&&E)return;const le=setInterval(oe,3e3);return()=>clearInterval(le)},[e,t,oe,h,E]);const de=ne.useCallback(async()=>{if(!(!e||!t)){x(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:_})})).ok&&(N(!1),O.current=!1,c(k=>k&&{...k,content:_}))}catch{}x(!1)}},[e,t,n,_]);ne.useEffect(()=>{if(h!=="edit")return;const le=k=>{(k.metaKey||k.ctrlKey)&&k.key==="s"&&(k.preventDefault(),de())};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[h,de]),ne.useEffect(()=>{if((o==null?void 0:o.status)!=="published-not-indexed"||!o.publishedAt)return;const le=new Date(o.publishedAt).getTime(),k=300*1e3,T=()=>{const C=Math.max(0,k-(Date.now()-le));Q(C)};T();const X=setInterval(T,1e3);return()=>clearInterval(X)},[o==null?void 0:o.status,o==null?void 0:o.publishedAt]);const q=U!==null&&U<=0,B=U!==null&&U>0?`${Math.floor(U/6e4)}:${String(Math.floor(U%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(f&&!o)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const j=(h==="edit"?_:(o==null?void 0:o.content)??"").length,P=t==="genesis.md",L=t?/^plot-\d+\.md$/.test(t):!1,A=(o==null?void 0:o.status)==="published"||(o==null?void 0:o.status)==="published-not-indexed",I=P?1e3:L?1e4:null,Y=!A&&I!==null&&j>I;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(o==null?void 0:o.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(o==null?void 0:o.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:o.indexError,children:"Published (not indexed)"}),(o==null?void 0:o.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${Y?"text-error font-medium":"text-muted"}`,children:[j.toLocaleString(),I!==null?`/${I.toLocaleString()}`:" chars"]}),Y&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(j-I).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>g("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>g("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",E&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),h==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:o!=null&&o.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(p3,{remarkPlugins:[k3,DD],rehypePlugins:[UD],children:o.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:K,value:_,onChange:le=>{b(le.target.value),N(!0),O.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}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:E?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:de,disabled:!E||y,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:y?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(o==null?void 0:o.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!q&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!o.txHash)){G(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:o.txHash,content:o.content,storylineId:o.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:o.txHash,storylineId:o.storylineId,contentCid:"",gasCost:""})}),oe())}catch{}G(!1)}},disabled:M,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:M?"Retrying...":`Retry Index${B?` (${B})`:""}`}),L&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),o.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:q?L?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":L?"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."}),o.indexError&&S.jsx("p",{className:"text-error text-xs",children:o.indexError})]}):(o==null?void 0:o.status)==="published"?S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),o.storylineId&&S.jsx("a",{href:(()=>{var T;const le=`https://plotlink.xyz/story/${o.storylineId}`;if(!L)return le;const k=o.plotIndex!=null&&o.plotIndex>0?o.plotIndex:parseInt(((T=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:T[1])??"1");return`${le}/${k}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),o.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}):S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t)),disabled:!!a||Y,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"}),Y&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]})})]})}const e0="plotlink-panel-ratio",ID=.6,Vy=300,kf=224,Ef=6;function FD(){try{const e=localStorage.getItem(e0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return ID}function Ky(e,t){if(t<=0)return e;const n=Vy/t,s=1-Vy/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function qD({token:e,authFetch:t}){const[n,s]=ne.useState(null),[a,o]=ne.useState(null),[c,f]=ne.useState(null),[p,h]=ne.useState(""),[g,_]=ne.useState(FD),[b,y]=ne.useState([]),x=ne.useRef(new Set),E=ne.useRef(null),N=ne.useRef(!1);ne.useEffect(()=>{try{localStorage.setItem(e0,String(g))}catch{}},[g]),ne.useEffect(()=>{const B=()=>{if(!E.current)return;const D=E.current.getBoundingClientRect().width-kf-Ef;_(j=>Ky(j,D))};return window.addEventListener("resize",B),B(),()=>window.removeEventListener("resize",B)},[]);const M=ne.useCallback(()=>{const B=`_new_${Date.now()}`;y(D=>[...D,B]),s(B),o(null)},[]);ne.useEffect(()=>{if(b.length===0)return;const B=setInterval(async()=>{try{const D=await t("/api/stories");if(!D.ok)return;const j=await D.json(),P=new Set(j.stories.filter(L=>L.name!=="_example").map(L=>L.name));for(const L of P)!x.current.has(L)&&b.length>0&&(y(A=>A.slice(1)),s(L),o(null));x.current=P}catch{}},3e3);return()=>clearInterval(B)},[t,b]),ne.useEffect(()=>{t("/api/stories").then(B=>{if(B.ok)return B.json()}).then(B=>{B!=null&&B.stories&&(x.current=new Set(B.stories.filter(D=>D.name!=="_example").map(D=>D.name)))}).catch(()=>{})},[t]);const G=ne.useCallback((B,D)=>{s(B),o(D)},[]),U=ne.useRef(null),Q=ne.useCallback(async B=>{var D,j,P,L;U.current=B,s(B),o(null);try{const A=await t(`/api/stories/${B}`);if(A.ok&&U.current===B){const Y=(await A.json()).files||[],k=((D=Y.map(T=>{var X;return{file:T.file,num:(X=T.file.match(/^plot-(\d+)\.md$/))==null?void 0:X[1]}}).filter(T=>T.num!=null).sort((T,X)=>parseInt(X.num)-parseInt(T.num))[0])==null?void 0:D.file)??((j=Y.find(T=>T.file==="genesis.md"))==null?void 0:j.file)??((P=Y.find(T=>T.file==="structure.md"))==null?void 0:P.file)??((L=Y[0])==null?void 0:L.file);k&&U.current===B&&o(k)}}catch{}},[t]),K=ne.useCallback(B=>{B.preventDefault(),N.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const D=P=>{if(!N.current||!E.current)return;const L=E.current.getBoundingClientRect(),A=L.width-kf-Ef,I=P.clientX-L.left-kf;_(Ky(I/A,A))},j=()=>{N.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",D),window.addEventListener("mouseup",j)},[]),O=ne.useCallback(async(B,D)=>{var j;f(D),h("Reading file...");try{const P=await t(`/api/stories/${B}/${D}`);if(!P.ok)throw new Error("Failed to read file");const L=await P.json(),A=L.content.match(/^#\s+(.+)$/m),I=A?A[1].slice(0,60):D.replace(".md","");let Y="Fiction";try{const C=await t(`/api/stories/${B}/structure.md`);if(C.ok){const pe=(await C.json()).content.match(/genre[:\s]+(.+)/i);pe&&(Y=pe[1].trim().slice(0,30))}}catch{}let le;if(D.match(/^plot-\d+\.md$/)){try{const C=await t(`/api/stories/${B}`);if(C.ok){const pe=(await C.json()).files.find(he=>he.file==="genesis.md"&&he.storylineId);le=pe==null?void 0:pe.storylineId}}catch{}if(!le){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const k=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:B,fileName:D,title:I,content:L.content,genre:Y,storylineId:le})});if(!k.ok){const C=await k.json();throw new Error(C.error||"Publish failed")}const T=(j=k.body)==null?void 0:j.getReader(),X=new TextDecoder;if(T)for(;;){const{done:C,value:se}=await T.read();if(C)break;const he=X.decode(se).split(` +`).filter(be=>be.startsWith("data: "));for(const be of he)try{const Te=JSON.parse(be.slice(6));Te.step&&h(Te.message||Te.step),Te.step==="done"&&Te.txHash&&await t(`/api/stories/${B}/${D}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:Te.txHash,storylineId:Te.storylineId,plotIndex:Te.plotIndex,contentCid:Te.contentCid,gasCost:Te.gasCost,indexError:Te.indexError})})}catch{}}h("Published!")}catch(P){const L=P instanceof Error?P.message:"Publish failed";h(`Error: ${L}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),ee=ne.useCallback(B=>{B.startsWith("_new_")&&y(D=>D.filter(j=>j!==B))},[]),[oe,de]=ne.useState(new Set);ne.useEffect(()=>{t("/api/stories").then(D=>D.ok?D.json():null).then(D=>{D!=null&&D.stories&&de(new Set(D.stories.filter(j=>j.hasStructure).map(j=>j.name)))}).catch(()=>{});const B=setInterval(async()=>{try{const D=await t("/api/stories");if(D.ok){const j=await D.json();de(new Set(j.stories.filter(P=>P.hasStructure).map(P=>P.name)))}}catch{}},5e3);return()=>clearInterval(B)},[t]);const q=ne.useCallback(B=>{n===B&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:E,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(Lx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:G,onNewStory:M,untitledSessions:b})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${g} 0 0`},children:S.jsx(rk,{token:e,storyName:n,authFetch:t,onSelectStory:Q,onDestroySession:ee,onArchiveStory:q,confirmedStories:oe})}),S.jsx("div",{onMouseDown:K,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Ef,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-g} 0 0`},children:[S.jsx(PD,{storyName:n,fileName:a,authFetch:t,onPublish:O,publishingFile:c}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function WD({token:e,onComplete:t}){const[n,s]=ne.useState(!1),[a,o]=ne.useState(null),[c,f]=ne.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return ne.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.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&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.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 YD({token:e,onLogout:t}){const[n,s]=ne.useState("home"),[a,o]=ne.useState(0),c=ne.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return ne.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.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&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx(Zy,{token:e})]}),n==="stories"&&S.jsx(qD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Mx,{token:e}),n==="wallet-setup"&&S.jsx(WD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Dx,{token:e,onLogout:t})]})]})}function VD(){const[e,t]=ne.useState(()=>localStorage.getItem("ows-token")),[n,s]=ne.useState(null),[a,o]=ne.useState(!0);ne.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),ne.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.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||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(YD,{token:e,onLogout:p}):S.jsx(Tx,{onLogin:c}):S.jsx(Ax,{onSetup:f})}Ex.createRoot(document.getElementById("root")).render(S.jsx(vx.StrictMode,{children:S.jsx(VD,{})})); diff --git a/app/web/dist/assets/index-k9t26Frd.css b/app/web/dist/assets/index-DHjiVVCV.css similarity index 65% rename from app/web/dist/assets/index-k9t26Frd.css rename to app/web/dist/assets/index-DHjiVVCV.css index 3a6b6e6..56036a5 100644 --- a/app/web/dist/assets/index-k9t26Frd.css +++ b/app/web/dist/assets/index-DHjiVVCV.css @@ -29,4 +29,4 @@ * The original design remains. The terminal itself * has been extended to include xterm CSI codes, among * other features. - */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-700:oklch(50.5% .213 27.518);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent;font-family:Inter,system-ui,-apple-system,sans-serif;line-height:1.5}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.start\!{inset-inline-start:var(--spacing)!important}.end{inset-inline-end:var(--spacing)}.top-1{top:calc(var(--spacing) * 1)}.right-1{right:calc(var(--spacing) * 1)}.z-10{z-index:10}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);margin-top:1.2em;margin-bottom:1.2em;font-size:1.25em;line-height:1.6}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);font-weight:500;text-decoration:underline}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:decimal}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:disc}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-counters);font-weight:400}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.25em;font-weight:600}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em;font-style:italic;font-weight:500}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:0;margin-bottom:.888889em;font-size:2.25em;font-weight:800;line-height:1.11111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:900}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:2em;margin-bottom:1em;font-size:1.5em;font-weight:700;line-height:1.33333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:800}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.6em;margin-bottom:.6em;font-size:1.25em;font-weight:600;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em;display:block}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;border-radius:.3125rem;padding-inline-start:.375em;font-family:inherit;font-size:.875em;font-weight:500}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-size:.875em;font-weight:600}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);padding-top:.857143em;padding-inline-end:1.14286em;padding-bottom:.857143em;border-radius:.375rem;margin-top:1.71429em;margin-bottom:1.71429em;padding-inline-start:1.14286em;font-size:.875em;font-weight:400;line-height:1.71429;overflow-x:auto}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;background-color:#0000;border-width:0;border-radius:0;padding:0}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){table-layout:auto;width:100%;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.71429}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);vertical-align:bottom;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em;font-weight:600}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);margin-top:.857143em;font-size:.875em;line-height:1.42857}.prose{--tw-prose-body:oklch(37.3% .034 259.733);--tw-prose-headings:oklch(21% .034 264.665);--tw-prose-lead:oklch(44.6% .03 256.802);--tw-prose-links:oklch(21% .034 264.665);--tw-prose-bold:oklch(21% .034 264.665);--tw-prose-counters:oklch(55.1% .027 264.364);--tw-prose-bullets:oklch(87.2% .01 258.338);--tw-prose-hr:oklch(92.8% .006 264.531);--tw-prose-quotes:oklch(21% .034 264.665);--tw-prose-quote-borders:oklch(92.8% .006 264.531);--tw-prose-captions:oklch(55.1% .027 264.364);--tw-prose-kbd:oklch(21% .034 264.665);--tw-prose-kbd-shadows:oklab(21% -.00316127 -.0338527/.1);--tw-prose-code:oklch(21% .034 264.665);--tw-prose-pre-code:oklch(92.8% .006 264.531);--tw-prose-pre-bg:oklch(27.8% .033 256.848);--tw-prose-th-borders:oklch(87.2% .01 258.338);--tw-prose-td-borders:oklch(92.8% .006 264.531);--tw-prose-invert-body:oklch(87.2% .01 258.338);--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:oklch(70.7% .022 261.325);--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:oklch(70.7% .022 261.325);--tw-prose-invert-bullets:oklch(44.6% .03 256.802);--tw-prose-invert-hr:oklch(37.3% .034 259.733);--tw-prose-invert-quotes:oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders:oklch(37.3% .034 259.733);--tw-prose-invert-captions:oklch(70.7% .022 261.325);--tw-prose-invert-kbd:#fff;--tw-prose-invert-kbd-shadows:#ffffff1a;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:oklch(44.6% .03 256.802);--tw-prose-invert-td-borders:oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.571429em;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.table{display:table}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-14{height:calc(var(--spacing) * 14)}.h-\[calc\(100vh-3\.5rem\)\]{height:calc(100vh - 3.5rem)}.h-full{height:100%}.h-screen{height:100vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-56{width:calc(var(--spacing) * 56)}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[120px\]{max-width:120px}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-accent{border-color:#8b4513}.border-accent-dim\/30{border-color:#6b34104d}.border-accent\/30{border-color:#8b45134d}.border-amber-600\/30{border-color:#dd74004d}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/30{border-color:color-mix(in oklab,var(--color-amber-600) 30%,transparent)}}.border-border{border-color:#d4c5b0}.border-green-700\/30{border-color:#0081384d}@supports (color:color-mix(in lab,red,red)){.border-green-700\/30{border-color:color-mix(in oklab,var(--color-green-700) 30%,transparent)}}.border-red-700\/30{border-color:#bf000f4d}@supports (color:color-mix(in lab,red,red)){.border-red-700\/30{border-color:color-mix(in oklab,var(--color-red-700) 30%,transparent)}}.border-transparent{border-color:#0000}.bg-accent{background-color:#8b4513}.bg-accent\/10{background-color:#8b45131a}.bg-amber-500{background-color:var(--color-amber-500)}.bg-background{background-color:#e8dfd0}.bg-error{background-color:#c33}.bg-green-600{background-color:var(--color-green-600)}.bg-muted\/50{background-color:#8b735580}.bg-surface{background-color:#f0ebe1}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-16{padding-right:calc(var(--spacing) * 16)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-serif{font-family:var(--font-serif)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-all{word-break:break-all}.text-accent{color:#8b4513}.text-accent-dim{color:#6b3410}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-error{color:#c33}.text-foreground{color:#2c1810}.text-green-700{color:var(--color-green-700)}.text-muted{color:#8b7355}.text-red-700{color:var(--color-red-700)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\:text-muted\/50::placeholder{color:#8b735580}@media(hover:hover){.hover\:border-accent:hover{border-color:#8b4513}.hover\:border-error:hover{border-color:#c33}.hover\:bg-accent-dim:hover{background-color:#6b3410}.hover\:bg-accent\/10:hover{background-color:#8b45131a}.hover\:bg-border\/50:hover{background-color:#d4c5b080}.hover\:bg-surface:hover{background-color:#f0ebe1}.hover\:text-accent:hover{color:#8b4513}.hover\:text-error:hover{color:#c33}.hover\:text-foreground:hover{color:#2c1810}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-accent:focus{border-color:#8b4513}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#e8dfd0;--bg-surface:#f0ebe1;--bg-shelf:#ddd3c2;--text:#2c1810;--text-muted:#8b7355;--accent:#8b4513;--accent-dim:#6b3410;--border:#d4c5b0;--error:#c33;--paper-bg:#f5f0e8}body{background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,-apple-system,sans-serif}::selection{background:var(--accent);color:#fff}h1,h2,h3,h4{font-family:Lora,Georgia,Times New Roman,serif}.prose{--tw-prose-body:var(--text);--tw-prose-headings:var(--text);--tw-prose-links:var(--accent);--tw-prose-bold:var(--text);--tw-prose-quotes:var(--text-muted);--tw-prose-quote-borders:var(--border);--tw-prose-code:var(--text);--tw-prose-hr:var(--border)}.prose,.prose p,.prose li,.prose blockquote{font-family:Lora,Georgia,Times New Roman,serif}code,pre{font-family:Geist Mono,ui-monospace,monospace}.xterm .xterm-dim{opacity:1!important;color:#8b7355!important}.xterm,.xterm-viewport{border:none!important;outline:none!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} + */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-700:oklch(50.5% .213 27.518);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent;font-family:Inter,system-ui,-apple-system,sans-serif;line-height:1.5}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.start\!{inset-inline-start:var(--spacing)!important}.end{inset-inline-end:var(--spacing)}.top-1{top:calc(var(--spacing) * 1)}.right-1{right:calc(var(--spacing) * 1)}.z-10{z-index:10}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);margin-top:1.2em;margin-bottom:1.2em;font-size:1.25em;line-height:1.6}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);font-weight:500;text-decoration:underline}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:decimal}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:disc}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-counters);font-weight:400}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.25em;font-weight:600}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em;font-style:italic;font-weight:500}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:0;margin-bottom:.888889em;font-size:2.25em;font-weight:800;line-height:1.11111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:900}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:2em;margin-bottom:1em;font-size:1.5em;font-weight:700;line-height:1.33333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:800}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.6em;margin-bottom:.6em;font-size:1.25em;font-weight:600;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em;display:block}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;border-radius:.3125rem;padding-inline-start:.375em;font-family:inherit;font-size:.875em;font-weight:500}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-size:.875em;font-weight:600}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);padding-top:.857143em;padding-inline-end:1.14286em;padding-bottom:.857143em;border-radius:.375rem;margin-top:1.71429em;margin-bottom:1.71429em;padding-inline-start:1.14286em;font-size:.875em;font-weight:400;line-height:1.71429;overflow-x:auto}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;background-color:#0000;border-width:0;border-radius:0;padding:0}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){table-layout:auto;width:100%;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.71429}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);vertical-align:bottom;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em;font-weight:600}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);margin-top:.857143em;font-size:.875em;line-height:1.42857}.prose{--tw-prose-body:oklch(37.3% .034 259.733);--tw-prose-headings:oklch(21% .034 264.665);--tw-prose-lead:oklch(44.6% .03 256.802);--tw-prose-links:oklch(21% .034 264.665);--tw-prose-bold:oklch(21% .034 264.665);--tw-prose-counters:oklch(55.1% .027 264.364);--tw-prose-bullets:oklch(87.2% .01 258.338);--tw-prose-hr:oklch(92.8% .006 264.531);--tw-prose-quotes:oklch(21% .034 264.665);--tw-prose-quote-borders:oklch(92.8% .006 264.531);--tw-prose-captions:oklch(55.1% .027 264.364);--tw-prose-kbd:oklch(21% .034 264.665);--tw-prose-kbd-shadows:oklab(21% -.00316127 -.0338527/.1);--tw-prose-code:oklch(21% .034 264.665);--tw-prose-pre-code:oklch(92.8% .006 264.531);--tw-prose-pre-bg:oklch(27.8% .033 256.848);--tw-prose-th-borders:oklch(87.2% .01 258.338);--tw-prose-td-borders:oklch(92.8% .006 264.531);--tw-prose-invert-body:oklch(87.2% .01 258.338);--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:oklch(70.7% .022 261.325);--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:oklch(70.7% .022 261.325);--tw-prose-invert-bullets:oklch(44.6% .03 256.802);--tw-prose-invert-hr:oklch(37.3% .034 259.733);--tw-prose-invert-quotes:oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders:oklch(37.3% .034 259.733);--tw-prose-invert-captions:oklch(70.7% .022 261.325);--tw-prose-invert-kbd:#fff;--tw-prose-invert-kbd-shadows:#ffffff1a;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:oklch(44.6% .03 256.802);--tw-prose-invert-td-borders:oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.571429em;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.table{display:table}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-14{height:calc(var(--spacing) * 14)}.h-\[calc\(100vh-3\.5rem\)\]{height:calc(100vh - 3.5rem)}.h-full{height:100%}.h-screen{height:100vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-56{width:calc(var(--spacing) * 56)}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[120px\]{max-width:120px}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-accent{border-color:#8b4513}.border-accent-dim\/30{border-color:#6b34104d}.border-accent\/30{border-color:#8b45134d}.border-amber-600\/30{border-color:#dd74004d}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/30{border-color:color-mix(in oklab,var(--color-amber-600) 30%,transparent)}}.border-border{border-color:#d4c5b0}.border-green-700\/30{border-color:#0081384d}@supports (color:color-mix(in lab,red,red)){.border-green-700\/30{border-color:color-mix(in oklab,var(--color-green-700) 30%,transparent)}}.border-red-700\/30{border-color:#bf000f4d}@supports (color:color-mix(in lab,red,red)){.border-red-700\/30{border-color:color-mix(in oklab,var(--color-red-700) 30%,transparent)}}.border-transparent{border-color:#0000}.bg-accent{background-color:#8b4513}.bg-accent\/10{background-color:#8b45131a}.bg-amber-500{background-color:var(--color-amber-500)}.bg-background{background-color:#e8dfd0}.bg-error{background-color:#c33}.bg-green-600{background-color:var(--color-green-600)}.bg-muted\/50{background-color:#8b735580}.bg-surface{background-color:#f0ebe1}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-16{padding-right:calc(var(--spacing) * 16)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-serif{font-family:var(--font-serif)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-all{word-break:break-all}.text-accent{color:#8b4513}.text-accent-dim{color:#6b3410}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-error{color:#c33}.text-foreground{color:#2c1810}.text-green-700{color:var(--color-green-700)}.text-muted{color:#8b7355}.text-red-700{color:var(--color-red-700)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\:text-muted\/50::placeholder{color:#8b735580}@media(hover:hover){.hover\:border-accent:hover{border-color:#8b4513}.hover\:border-error:hover{border-color:#c33}.hover\:bg-accent-dim:hover{background-color:#6b3410}.hover\:bg-accent\/10:hover{background-color:#8b45131a}.hover\:bg-border\/50:hover{background-color:#d4c5b080}.hover\:bg-surface:hover{background-color:#f0ebe1}.hover\:text-accent:hover{color:#8b4513}.hover\:text-accent-dim:hover{color:#6b3410}.hover\:text-error:hover{color:#c33}.hover\:text-foreground:hover{color:#2c1810}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-accent:focus{border-color:#8b4513}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#e8dfd0;--bg-surface:#f0ebe1;--bg-shelf:#ddd3c2;--text:#2c1810;--text-muted:#8b7355;--accent:#8b4513;--accent-dim:#6b3410;--border:#d4c5b0;--error:#c33;--paper-bg:#f5f0e8}body{background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,-apple-system,sans-serif}::selection{background:var(--accent);color:#fff}h1,h2,h3,h4{font-family:Lora,Georgia,Times New Roman,serif}.prose{--tw-prose-body:var(--text);--tw-prose-headings:var(--text);--tw-prose-links:var(--accent);--tw-prose-bold:var(--text);--tw-prose-quotes:var(--text-muted);--tw-prose-quote-borders:var(--border);--tw-prose-code:var(--text);--tw-prose-hr:var(--border)}.prose,.prose p,.prose li,.prose blockquote{font-family:Lora,Georgia,Times New Roman,serif}code,pre{font-family:Geist Mono,ui-monospace,monospace}.xterm .xterm-dim{opacity:1!important;color:#8b7355!important}.xterm,.xterm-viewport{border:none!important;outline:none!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} diff --git a/app/web/dist/assets/index-utAhzv0p.js b/app/web/dist/assets/index-utAhzv0p.js deleted file mode 100644 index 9e94a06..0000000 --- a/app/web/dist/assets/index-utAhzv0p.js +++ /dev/null @@ -1,130 +0,0 @@ -(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 n(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=n(a);fetch(a.href,o)}})();function gu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fh={exports:{}},ql={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Kg;function mx(){if(Kg)return ql;Kg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(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 f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return ql.Fragment=t,ql.jsx=n,ql.jsxs=n,ql}var Xg;function _x(){return Xg||(Xg=1,Fh.exports=mx()),Fh.exports}var x=_x(),qh={exports:{}},we={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var $g;function gx(){if($g)return we;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=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"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),S=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=S&&A[S]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,D={};function T(A,K,C){this.props=A,this.context=K,this.refs=D,this.updater=C||b}T.prototype.isReactComponent={},T.prototype.setState=function(A,K){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,K,"setState")},T.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function X(){}X.prototype=T.prototype;function U(A,K,C){this.props=A,this.context=K,this.refs=D,this.updater=C||b}var te=U.prototype=new X;te.constructor=U,k(te,T.prototype),te.isPureReactComponent=!0;var ae=Array.isArray;function O(){}var H={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function ie(A,K,C){var se=C.ref;return{$$typeof:e,type:A,key:K,ref:se!==void 0?se:null,props:C}}function L(A,K){return ie(A.type,K,A.props)}function Z(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function j(A){var K={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(C){return K[C]})}var F=/\/+/g;function $(A,K){return typeof A=="object"&&A!==null&&A.key!=null?j(""+A.key):K.toString(36)}function z(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(O,O):(A.status="pending",A.then(function(K){A.status==="pending"&&(A.status="fulfilled",A.value=K)},function(K){A.status==="pending"&&(A.status="rejected",A.reason=K)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function M(A,K,C,se,fe){var pe=typeof A;(pe==="undefined"||pe==="boolean")&&(A=null);var xe=!1;if(A===null)xe=!0;else switch(pe){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(A.$$typeof){case e:case t:xe=!0;break;case g:return xe=A._init,M(xe(A._payload),K,C,se,fe)}}if(xe)return fe=fe(A),xe=se===""?"."+$(A,0):se,ae(fe)?(C="",xe!=null&&(C=xe.replace(F,"$&/")+"/"),M(fe,K,C,"",function(Ht){return Ht})):fe!=null&&(Z(fe)&&(fe=L(fe,C+(fe.key==null||A&&A.key===fe.key?"":(""+fe.key).replace(F,"$&/")+"/")+xe)),K.push(fe)),1;xe=0;var Ye=se===""?".":se+":";if(ae(A))for(var De=0;De>>1,E=M[ue];if(0>>1;uea(C,W))sea(fe,C)?(M[ue]=fe,M[se]=W,ue=se):(M[ue]=C,M[K]=W,ue=K);else if(sea(fe,W))M[ue]=fe,M[se]=W,ue=se;else break e}}return I}function a(M,I){var W=M.sortIndex-I.sortIndex;return W!==0?W:M.id-I.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,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,S=3,y=!1,b=!1,k=!1,D=!1,T=typeof setTimeout=="function"?setTimeout:null,X=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function te(M){for(var I=n(h);I!==null;){if(I.callback===null)s(h);else if(I.startTime<=M)s(h),I.sortIndex=I.expirationTime,t(p,I);else break;I=n(h)}}function ae(M){if(k=!1,te(M),!b)if(n(p)!==null)b=!0,O||(O=!0,j());else{var I=n(h);I!==null&&z(ae,I.startTime-M)}}var O=!1,H=-1,P=5,ie=-1;function L(){return D?!0:!(e.unstable_now()-ieM&&L());){var ue=_.callback;if(typeof ue=="function"){_.callback=null,S=_.priorityLevel;var E=ue(_.expirationTime<=M);if(M=e.unstable_now(),typeof E=="function"){_.callback=E,te(M),I=!0;break t}_===n(p)&&s(p),te(M)}else s(p);_=n(p)}if(_!==null)I=!0;else{var A=n(h);A!==null&&z(ae,A.startTime-M),I=!1}}break e}finally{_=null,S=W,y=!1}I=void 0}}finally{I?j():O=!1}}}var j;if(typeof U=="function")j=function(){U(Z)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,$=F.port2;F.port1.onmessage=Z,j=function(){$.postMessage(null)}}else j=function(){T(Z,0)};function z(M,I){H=T(function(){M(e.unstable_now())},I)}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(M){M.callback=null},e.unstable_forceFrameRate=function(M){0>M||125ue?(M.sortIndex=W,t(h,M),n(p)===null&&M===n(h)&&(k?(X(H),H=-1):k=!0,z(ae,W-ue))):(M.sortIndex=E,t(p,M),b||y||(b=!0,O||(O=!0,j()))),M},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(M){var I=S;return function(){var W=S;S=I;try{return M.apply(this,arguments)}finally{S=W}}}})(Vh)),Vh}var Qg;function Sx(){return Qg||(Qg=1,Yh.exports=yx()),Yh.exports}var Kh={exports:{}},Vt={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jg;function bx(){if(Jg)return Vt;Jg=1;var e=bd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Kh.exports=bx(),Kh.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var tv;function wx(){if(tv)return Wl;tv=1;var e=Sx(),t=bd(),n=xx();function s(i){var r="https://react.dev/errors/"+i;if(1E||(i.current=ue[E],ue[E]=null,E--)}function C(i,r){E++,ue[E]=i.current,i.current=r}var se=A(null),fe=A(null),pe=A(null),xe=A(null);function Ye(i,r){switch(C(pe,r),C(fe,i),C(se,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?_g(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=_g(r),i=gg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(se),C(se,i)}function De(){K(se),K(fe),K(pe)}function Ht(i){i.memoizedState!==null&&C(xe,i);var r=se.current,l=gg(r,i.type);r!==l&&(C(fe,i),C(se,l))}function Zt(i){fe.current===i&&(K(se),K(fe)),xe.current===i&&(K(xe),Ul._currentValue=W)}var ai,He;function yi(i){if(ai===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ai=r&&r[1]||"",He=-1)":-1d||R[u]!==Y[d]){var Q=` -`+R[u].replace(" at new "," at ");return i.displayName&&Q.includes("")&&(Q=Q.replace("",i.displayName)),Q}while(1<=u&&0<=d);break}}}finally{Gr=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?yi(l):""}function Ca(i,r){switch(i.tag){case 26:case 27:case 5:return yi(i.type);case 16:return yi("Lazy");case 13:return i.child!==r&&r!==null?yi("Suspense Fallback"):yi("Suspense");case 19:return yi("SuspenseList");case 0:case 15:return Zr(i.type,!1);case 11:return Zr(i.type.render,!1);case 1:return Zr(i.type,!0);case 31:return yi("Activity");default:return""}}function ka(i){try{var r="",l=null;do r+=Ca(i,l),l=i,i=i.return;while(i);return r}catch(u){return` -Error generating stack: `+u.message+` -`+u.stack}}var Qr=Object.prototype.hasOwnProperty,Jr=e.unstable_scheduleCallback,Zs=e.unstable_cancelCallback,Tu=e.unstable_shouldYield,Au=e.unstable_requestPaint,Qt=e.unstable_now,Du=e.unstable_getCurrentPriorityLevel,J=e.unstable_ImmediatePriority,he=e.unstable_UserBlockingPriority,Se=e.unstable_NormalPriority,Re=e.unstable_LowPriority,Fe=e.unstable_IdlePriority,Si=e.log,fn=e.unstable_setDisableYieldValue,Jt=null,xt=null;function oi(i){if(typeof Si=="function"&&fn(i),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(Jt,i)}catch{}}var Ge=Math.clz32?Math.clz32:t0,jn=Math.log,Ki=Math.LN2;function t0(i){return i>>>=0,i===0?32:31-(jn(i)/Ki|0)|0}var Ea=256,Ta=262144,Aa=4194304;function yr(i){var r=i&42;if(r!==0)return r;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Da(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=yr(u):(v&=w,v!==0?d=yr(v):l||(l=w&~i,l!==0&&(d=yr(l))))):(w=u&~m,w!==0?d=yr(w):v!==0?d=yr(v):l||(l=u&~i,l!==0&&(d=yr(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function Qs(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function i0(i,r){switch(i){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 Zd(){var i=Aa;return Aa<<=1,(Aa&62914560)===0&&(Aa=4194304),i}function Ru(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Js(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function n0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,R=i.expirationTimes,Y=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var u0=/[\n"\\]/g;function Li(i){return i.replace(u0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ou(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Bi(r)):i.value!==""+Bi(r)&&(i.value=""+Bi(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Hu(i,v,Bi(r)):l!=null?Hu(i,v,Bi(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Bi(w):i.removeAttribute("name")}function cp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){zu(i);return}l=l!=null?""+Bi(l):"",r=r!=null?""+Bi(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),zu(i)}function Hu(i,r,l){r==="number"&&Ba(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function ss(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mn)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Fu=!1}var Pn=null,qu=null,Na=null;function gp(){if(Na)return Na;var i,r=qu,l=r.length,u,d="value"in Pn?Pn.value:Pn.textContent,m=d.length;for(i=0;i=ll),wp=" ",Cp=!1;function kp(i,r){switch(i){case"keyup":return H0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ep(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var us=!1;function U0(i,r){switch(i){case"compositionend":return Ep(r);case"keypress":return r.which!==32?null:(Cp=!0,wp);case"textInput":return i=r.data,i===wp&&Cp?null:i;default:return null}}function P0(i,r){if(us)return i==="compositionend"||!Xu&&kp(i,r)?(i=gp(),Na=qu=Pn=null,us=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Np(l)}}function Op(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Op(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Hp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ba(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ba(i.document)}return r}function Zu(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var X0=mn&&"documentMode"in document&&11>=document.documentMode,cs=null,Qu=null,cl=null,Ju=!1;function jp(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ju||cs==null||cs!==Ba(u)||(u=cs,"selectionStart"in u&&Zu(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}),cl&&ul(cl,u)||(cl=u,u=Ao(Qu,"onSelect"),0>=v,d-=v,Ji=1<<32-Ge(r)+d|l<ke?(ze=_e,_e=null):ze=_e.sibling;var Pe=V(N,_e,q[ke],ee);if(Pe===null){_e===null&&(_e=ze);break}i&&_e&&Pe.alternate===null&&r(N,_e),B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe,_e=ze}if(ke===q.length)return l(N,_e),Oe&&gn(N,ke),ge;if(_e===null){for(;keke?(ze=_e,_e=null):ze=_e.sibling;var or=V(N,_e,Pe.value,ee);if(or===null){_e===null&&(_e=ze);break}i&&_e&&or.alternate===null&&r(N,_e),B=m(or,B,ke),Ue===null?ge=or:Ue.sibling=or,Ue=or,_e=ze}if(Pe.done)return l(N,_e),Oe&&gn(N,ke),ge;if(_e===null){for(;!Pe.done;ke++,Pe=q.next())Pe=ne(N,Pe.value,ee),Pe!==null&&(B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe);return Oe&&gn(N,ke),ge}for(_e=u(_e);!Pe.done;ke++,Pe=q.next())Pe=G(_e,N,ke,Pe.value,ee),Pe!==null&&(i&&Pe.alternate!==null&&_e.delete(Pe.key===null?ke:Pe.key),B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe);return i&&_e.forEach(function(px){return r(N,px)}),Oe&&gn(N,ke),ge}function Xe(N,B,q,ee){if(typeof q=="object"&&q!==null&&q.type===k&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case y:e:{for(var ge=q.key;B!==null;){if(B.key===ge){if(ge=q.type,ge===k){if(B.tag===7){l(N,B.sibling),ee=d(B,q.props.children),ee.return=N,N=ee;break e}}else if(B.elementType===ge||typeof ge=="object"&&ge!==null&&ge.$$typeof===P&&Rr(ge)===B.type){l(N,B.sibling),ee=d(B,q.props),_l(ee,q),ee.return=N,N=ee;break e}l(N,B);break}else r(N,B);B=B.sibling}q.type===k?(ee=kr(q.props.children,N.mode,ee,q.key),ee.return=N,N=ee):(ee=Wa(q.type,q.key,q.props,null,N.mode,ee),_l(ee,q),ee.return=N,N=ee)}return v(N);case b:e:{for(ge=q.key;B!==null;){if(B.key===ge)if(B.tag===4&&B.stateNode.containerInfo===q.containerInfo&&B.stateNode.implementation===q.implementation){l(N,B.sibling),ee=d(B,q.children||[]),ee.return=N,N=ee;break e}else{l(N,B);break}else r(N,B);B=B.sibling}ee=lc(q,N.mode,ee),ee.return=N,N=ee}return v(N);case P:return q=Rr(q),Xe(N,B,q,ee)}if(z(q))return me(N,B,q,ee);if(j(q)){if(ge=j(q),typeof ge!="function")throw Error(s(150));return q=ge.call(q),ye(N,B,q,ee)}if(typeof q.then=="function")return Xe(N,B,Za(q),ee);if(q.$$typeof===U)return Xe(N,B,Ka(N,q),ee);Qa(N,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,B!==null&&B.tag===6?(l(N,B.sibling),ee=d(B,q),ee.return=N,N=ee):(l(N,B),ee=sc(q,N.mode,ee),ee.return=N,N=ee),v(N)):l(N,B)}return function(N,B,q,ee){try{ml=0;var ge=Xe(N,B,q,ee);return bs=null,ge}catch(_e){if(_e===Ss||_e===$a)throw _e;var Ue=xi(29,_e,null,N.mode);return Ue.lanes=ee,Ue.return=N,Ue}finally{}}}var Br=am(!0),om=am(!1),Yn=!1;function vc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Vn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Kn(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(Ie&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=qa(i),Yp(i,null,l),r}return Fa(i,u,r,l),qa(i)}function gl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Jd(i,l)}}function Sc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var bc=!1;function vl(){if(bc){var i=ys;if(i!==null)throw i}}function yl(i,r,l,u){bc=!1;var d=i.updateQueue;Yn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var R=w,Y=R.next;R.next=null,v===null?m=Y:v.next=Y,v=R;var Q=i.alternate;Q!==null&&(Q=Q.updateQueue,w=Q.lastBaseUpdate,w!==v&&(w===null?Q.firstBaseUpdate=Y:w.next=Y,Q.lastBaseUpdate=R))}if(m!==null){var ne=d.baseState;v=0,Q=Y=R=null,w=m;do{var V=w.lane&-536870913,G=V!==w.lane;if(G?(Ne&V)===V:(u&V)===V){V!==0&&V===vs&&(bc=!0),Q!==null&&(Q=Q.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var me=i,ye=w;V=r;var Xe=l;switch(ye.tag){case 1:if(me=ye.payload,typeof me=="function"){ne=me.call(Xe,ne,V);break e}ne=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=ye.payload,V=typeof me=="function"?me.call(Xe,ne,V):me,V==null)break e;ne=_({},ne,V);break e;case 2:Yn=!0}}V=w.callback,V!==null&&(i.flags|=64,G&&(i.flags|=8192),G=d.callbacks,G===null?d.callbacks=[V]:G.push(V))}else G={lane:V,tag:w.tag,payload:w.payload,callback:w.callback,next:null},Q===null?(Y=Q=G,R=ne):Q=Q.next=G,v|=V;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;G=w,w=G.next,G.next=null,d.lastBaseUpdate=G,d.shared.pending=null}}while(!0);Q===null&&(R=ne),d.baseState=R,d.firstBaseUpdate=Y,d.lastBaseUpdate=Q,m===null&&(d.shared.lanes=0),Qn|=v,i.lanes=v,i.memoizedState=ne}}function um(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function cm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=M.T,w={};M.T=w,Pc(i,!1,r,l);try{var R=d(),Y=M.S;if(Y!==null&&Y(w,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var Q=n1(R,u);xl(i,r,Q,Ti(i))}else xl(i,r,u,Ti(i))}catch(ne){xl(i,r,{then:function(){},status:"rejected",reason:ne},Ti())}finally{I.p=m,v!==null&&w.types!==null&&(v.types=w.types),M.T=v}}function u1(){}function jc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Fm(i).queue;Im(i,d,r,W,l===null?u1:function(){return qm(i),l(u)})}function Fm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bn,lastRenderedState:W},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function qm(i){var r=Fm(i);r.next===null&&(r=i.alternate.memoizedState),xl(i,r.next.queue,{},Ti())}function Uc(){return Pt(Ul)}function Wm(){return dt().memoizedState}function Ym(){return dt().memoizedState}function c1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ti();i=Vn(l);var u=Kn(r,i,l);u!==null&&(mi(u,r,l),gl(u,r,l)),r={cache:pc()},i.payload=r;return}r=r.return}}function h1(i,r,l){var u=Ti();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},oo(i)?Km(r,l):(l=nc(i,r,l,u),l!==null&&(mi(l,i,u),Xm(l,r,u)))}function Vm(i,r,l){var u=Ti();xl(i,r,l,u)}function xl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(oo(i))Km(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,bi(w,v))return Fa(i,r,d,0),Ze===null&&Ia(),!1}catch{}finally{}if(l=nc(i,r,d,u),l!==null)return mi(l,i,u),Xm(l,r,u),!0}return!1}function Pc(i,r,l,u){if(u={lane:2,revertLane:vh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},oo(i)){if(r)throw Error(s(479))}else r=nc(i,l,u,2),r!==null&&mi(r,i,2)}function oo(i){var r=i.alternate;return i===Ce||r!==null&&r===Ce}function Km(i,r){ws=to=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Xm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Jd(i,l)}}var wl={readContext:Pt,use:ro,useCallback:at,useContext:at,useEffect:at,useImperativeHandle:at,useLayoutEffect:at,useInsertionEffect:at,useMemo:at,useReducer:at,useRef:at,useState:at,useDebugValue:at,useDeferredValue:at,useTransition:at,useSyncExternalStore:at,useId:at,useHostTransitionStatus:at,useFormState:at,useActionState:at,useOptimistic:at,useMemoCache:at,useCacheRefresh:at};wl.useEffectEvent=at;var $m={readContext:Pt,use:ro,useCallback:function(i,r){return ei().memoizedState=[i,r===void 0?null:r],i},useContext:Pt,useEffect:Bm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,lo(4194308,4,Om.bind(null,r,i),l)},useLayoutEffect:function(i,r){return lo(4194308,4,i,r)},useInsertionEffect:function(i,r){lo(4,2,i,r)},useMemo:function(i,r){var l=ei();r=r===void 0?null:r;var u=i();if(Lr){oi(!0);try{i()}finally{oi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=ei();if(l!==void 0){var d=l(r);if(Lr){oi(!0);try{l(r)}finally{oi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=h1.bind(null,Ce,i),[u.memoizedState,i]},useRef:function(i){var r=ei();return i={current:i},r.memoizedState=i},useState:function(i){i=Lc(i);var r=i.queue,l=Vm.bind(null,Ce,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Oc,useDeferredValue:function(i,r){var l=ei();return Hc(l,i,r)},useTransition:function(){var i=Lc(!1);return i=Im.bind(null,Ce,i.queue,!0,!1),ei().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ce,d=ei();if(Oe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(Ne&127)!==0||_m(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Bm(vm.bind(null,u,m,i),[i]),u.flags|=2048,ks(9,{destroy:void 0},gm.bind(null,u,m,l,r),null),l},useId:function(){var i=ei(),r=Ze.identifierPrefix;if(Oe){var l=en,u=Ji;l=(u&~(1<<32-Ge(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=io++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[jt]=r,m[ui]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Ft(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&wn(r)}}return tt(r),eh(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&wn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=pe.current,_s(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Ut,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[jt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||pg(i.nodeValue,l)),i||qn(r,!0)}else i=Do(i).createTextNode(u),i[jt]=r,r.stateNode=i}return tt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=_s(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[jt]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),i=!1}else l=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Ci(r),r):(Ci(r),null);if((r.flags&128)!==0)throw Error(s(558))}return tt(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=_s(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[jt]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),d=!1}else d=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(Ci(r),r):(Ci(r),null)}return Ci(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),po(r,r.updateQueue),tt(r),null);case 4:return De(),i===null&&xh(r.stateNode.containerInfo),tt(r),null;case 10:return yn(r.type),tt(r),null;case 19:if(K(ft),u=r.memoizedState,u===null)return tt(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)kl(u,!1);else{if(ot!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=eo(i),m!==null){for(r.flags|=128,kl(u,!1),i=m.updateQueue,r.updateQueue=i,po(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Vp(l,i),l=l.sibling;return C(ft,ft.current&1|2),Oe&&gn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Qt()>yo&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304)}else{if(!d)if(i=eo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,po(r,i),kl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Oe)return tt(r),null}else 2*Qt()-u.renderingStartTime>yo&&l!==536870912&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Qt(),i.sibling=null,l=ft.current,C(ft,d?l&1|2:l&1),Oe&&gn(r,u.treeForkCount),i):(tt(r),null);case 22:case 23:return Ci(r),wc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(tt(r),r.subtreeFlags&6&&(r.flags|=8192)):tt(r),l=r.updateQueue,l!==null&&po(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Dr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),yn(mt),tt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function _1(i,r){switch(oc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return yn(mt),De(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return Zt(r),null;case 31:if(r.memoizedState!==null){if(Ci(r),r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Ci(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(ft),null;case 4:return De(),null;case 10:return yn(r.type),null;case 22:case 23:return Ci(r),wc(),i!==null&&K(Dr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return yn(mt),null;case 25:return null;default:return null}}function y_(i,r){switch(oc(r),r.tag){case 3:yn(mt),De();break;case 26:case 27:case 5:Zt(r);break;case 4:De();break;case 31:r.memoizedState!==null&&Ci(r);break;case 13:Ci(r);break;case 19:K(ft);break;case 10:yn(r.type);break;case 22:case 23:Ci(r),wc(),i!==null&&K(Dr);break;case 24:yn(mt)}}function El(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){We(r,r.return,w)}}function Gn(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var R=l,Y=w;try{Y()}catch(Q){We(d,R,Q)}}}u=u.next}while(u!==m)}}catch(Q){We(r,r.return,Q)}}function S_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{cm(r,l)}catch(u){We(i,i.return,u)}}}function b_(i,r,l){l.props=Nr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){We(i,r,u)}}function Tl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){We(i,r,d)}}function tn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){We(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){We(i,r,d)}else l.current=null}function x_(i){var r=i.type,l=i.memoizedProps,u=i.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(d){We(i,i.return,d)}}function th(i,r,l){try{var u=i.stateNode;j1(u,i.type,l,r),u[ui]=r}catch(d){We(i,i.return,d)}}function w_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&nr(i.type)||i.tag===4}function ih(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||w_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&nr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function nh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=pn));else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(nh(i,r,l),i=i.sibling;i!==null;)nh(i,r,l),i=i.sibling}function mo(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(mo(i,r,l),i=i.sibling;i!==null;)mo(i,r,l),i=i.sibling}function C_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Ft(r,u,l),r[jt]=i,r[ui]=l}catch(m){We(i,i.return,m)}}var Cn=!1,vt=!1,rh=!1,k_=typeof WeakSet=="function"?WeakSet:Set,At=null;function g1(i,r){if(i=i.containerInfo,kh=Oo,i=Hp(i),Zu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,R=-1,Y=0,Q=0,ne=i,V=null;t:for(;;){for(var G;ne!==l||d!==0&&ne.nodeType!==3||(w=v+d),ne!==m||u!==0&&ne.nodeType!==3||(R=v+u),ne.nodeType===3&&(v+=ne.nodeValue.length),(G=ne.firstChild)!==null;)V=ne,ne=G;for(;;){if(ne===i)break t;if(V===l&&++Y===d&&(w=v),V===m&&++Q===u&&(R=v),(G=ne.nextSibling)!==null)break;ne=V,V=ne.parentNode}ne=G}l=w===-1||R===-1?null:{start:w,end:R}}else l=null}l=l||{start:0,end:0}}else l=null;for(Eh={focusedElem:i,selectionRange:l},Oo=!1,At=r;At!==null;)if(r=At,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,At=i;else for(;At!==null;){switch(r=At,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Ft(m,u,l),m[jt]=i,Tt(m),u=m;break e;case"link":var v=Mg("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=ye,ye=v);var N=zp(w,ye),B=zp(w,Xe);if(N&&B&&(G.rangeCount!==1||G.anchorNode!==N.node||G.anchorOffset!==N.offset||G.focusNode!==B.node||G.focusOffset!==B.offset)){var q=ne.createRange();q.setStart(N.node,N.offset),G.removeAllRanges(),ye>Xe?(G.addRange(q),G.extend(B.node,B.offset)):(q.setEnd(B.node,B.offset),G.addRange(q))}}}}for(ne=[],G=w;G=G.parentNode;)G.nodeType===1&&ne.push({element:G,left:G.scrollLeft,top:G.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,M.T=null,l=hh,hh=null;var m=er,v=Dn;if(wt=0,Rs=er=null,Dn=0,(Ie&6)!==0)throw Error(s(331));var w=Ie;if(Ie|=4,O_(m.current),L_(m,m.current,v,l),Ie=w,Ll(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(Jt,m)}catch{}return!0}finally{I.p=d,M.T=u,eg(i,r)}}function ig(i,r,l){r=zi(l,r),r=Wc(i.stateNode,r,2),i=Kn(i,r,2),i!==null&&(Js(i,2),nn(i))}function We(i,r,l){if(i.tag===3)ig(i,i,l);else for(;r!==null;){if(r.tag===3){ig(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Jn===null||!Jn.has(u))){i=zi(l,i),l=n_(2),u=Kn(r,l,2),u!==null&&(r_(l,u,r,i),Js(u,2),nn(u));break}}r=r.return}}function mh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new S1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(ah=!0,d.add(l),i=k1.bind(null,i,r,l),r.then(i,i))}function k1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(Ne&l)===l&&(ot===4||ot===3&&(Ne&62914560)===Ne&&300>Qt()-vo?(Ie&2)===0&&Ms(i,0):oh|=l,Ds===Ne&&(Ds=0)),nn(i)}function ng(i,r){r===0&&(r=Zd()),i=Cr(i,r),i!==null&&(Js(i,r),nn(i))}function E1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),ng(i,l)}function T1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),ng(i,l)}function A1(i,r){return Jr(i,r)}var ko=null,Ls=null,_h=!1,Eo=!1,gh=!1,ir=0;function nn(i){i!==Ls&&i.next===null&&(Ls===null?ko=Ls=i:Ls=Ls.next=i),Eo=!0,_h||(_h=!0,R1())}function Ll(i,r){if(!gh&&Eo){gh=!0;do for(var l=!1,u=ko;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-Ge(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ag(u,m))}else m=Ne,m=Da(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||Qs(u,m)||(l=!0,ag(u,m));u=u.next}while(l);gh=!1}}function D1(){rg()}function rg(){Eo=_h=!1;var i=0;ir!==0&&P1()&&(i=ir);for(var r=Qt(),l=null,u=ko;u!==null;){var d=u.next,m=sg(u,r);m===0?(u.next=null,l===null?ko=d:l.next=d,d===null&&(Ls=l)):(l=u,(i!==0||(m&3)!==0)&&(Eo=!0)),u=d}wt!==0&&wt!==5||Ll(i),ir!==0&&(ir=0)}function sg(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var Q=R.transferSize,ne=R.initiatorType;Q&&mg(ne)&&(R=R.responseEnd,v+=Q*(R"u"?null:document;function Tg(i,r,l){var u=Ns;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Eg.has(d)||(Eg.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function $1(i){Rn.D(i),Tg("dns-prefetch",i,null)}function G1(i,r){Rn.C(i,r),Tg("preconnect",i,r)}function Z1(i,r,l){Rn.L(i,r,l);var u=Ns;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=zs(i);break;case"script":m=Os(i)}Ii.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Ii.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Hl(m))||r==="script"&&u.querySelector(jl(m))||(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function Q1(i,r){Rn.m(i,r);var l=Ns;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Os(i)}if(!Ii.has(m)&&(i=_({rel:"modulepreload",href:i},r),Ii.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(jl(m)))return}u=l.createElement("link"),Ft(u,"link",i),Tt(u),l.head.appendChild(u)}}}function J1(i,r,l){Rn.S(i,r,l);var u=Ns;if(u&&i){var d=ns(u).hoistableStyles,m=zs(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Hl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Ii.get(m))&&Lh(i,l);var R=v=u.createElement("link");Tt(R),Ft(R,"link",i),R._p=new Promise(function(Y,Q){R.onload=Y,R.onerror=Q}),R.addEventListener("load",function(){w.loading|=1}),R.addEventListener("error",function(){w.loading|=2}),w.loading|=4,Mo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function ex(i,r){Rn.X(i,r);var l=Ns;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0},r),(r=Ii.get(d))&&Nh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function tx(i,r){Rn.M(i,r);var l=Ns;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Ii.get(d))&&Nh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Ag(i,r,l,u){var d=(d=pe.current)?Ro(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=zs(l.href),l=ns(d).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"){i=zs(l.href);var m=ns(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Hl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Ii.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ii.set(i,l),m||ix(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}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=Os(l),l=ns(d).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,i))}}function zs(i){return'href="'+Li(i)+'"'}function Hl(i){return'link[rel="stylesheet"]['+i+"]"}function Dg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function ix(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Ft(r,"link",l),Tt(r),i.head.appendChild(r))}function Os(i){return'[src="'+Li(i)+'"]'}function jl(i){return"script[async]"+i}function Rg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Tt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Tt(u),Ft(u,"style",d),Mo(u,l.precedence,i),r.instance=u;case"stylesheet":d=zs(l.href);var m=i.querySelector(Hl(d));if(m)return r.state.loading|=4,r.instance=m,Tt(m),m;u=Dg(l),(d=Ii.get(d))&&Lh(u,d),m=(i.ownerDocument||i).createElement("link"),Tt(m);var v=m;return v._p=new Promise(function(w,R){v.onload=w,v.onerror=R}),Ft(m,"link",u),r.state.loading|=4,Mo(m,l.precedence,i),r.instance=m;case"script":return m=Os(l.src),(d=i.querySelector(jl(m)))?(r.instance=d,Tt(d),d):(u=l,(d=Ii.get(m))&&(u=_({},l),Nh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Tt(d),Ft(d,"link",u),i.head.appendChild(d),r.instance=d);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,Mo(u,l.precedence,i));return r.instance}function Mo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function nx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){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 i=r.disabled,typeof r.precedence=="string"&&i==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 Lg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function rx(i,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 d=zs(u.href),m=r.querySelector(Hl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Lo.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Tt(m);return}m=r.ownerDocument||r,u=Dg(u),(d=Ii.get(d))&&Lh(u,d),m=m.createElement("link"),Tt(m);var v=m;v._p=new Promise(function(w,R){v.onload=w,v.onerror=R}),Ft(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Lo.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var zh=0;function sx(i,r){return i.stylesheets&&i.count===0&&zo(i,i.stylesheets),0zh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Lo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zo(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var No=null;function zo(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,No=new Map,r.forEach(lx,i),No=null,Lo.call(i))}function lx(i,r){if(!(r.state.loading&4)){var l=No.get(i);if(l)var u=l.get(null);else{l=new Map,No.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wh.exports=wx(),Wh.exports}var kx=Cx();const Ex=gu(kx);function Tx({onLogin:e}){const[t,n]=le.useState(""),[s,a]=le.useState(null),[o,c]=le.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsxs("div",{className:"w-full max-w-sm",children:[x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),x.jsxs("form",{onSubmit:f,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:p=>n(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&&x.jsx("p",{className:"text-error text-xs",children:s}),x.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"})]})]}),x.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Ax({onSetup:e}){const[t,n]=le.useState(""),[s,a]=le.useState(""),[o,c]=le.useState(null),[f,p]=le.useState(!1),h=async g=>{if(g.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 x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsx("div",{className:"w-full max-w-sm",children:x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),x.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."}),x.jsxs("form",{onSubmit:h,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:g=>n(g.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"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),x.jsx("input",{type:"password",value:s,onChange:g=>a(g.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&&x.jsx("p",{className:"text-error text-xs",children:o}),x.jsx("button",{type:"submit",disabled:f||!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:f?"setting up...":"create passphrase"})]})]})})})}const nv="http://localhost:7777";function Zy({token:e}){const[t,n]=le.useState(null),[s,a]=le.useState(!1),[o,c]=le.useState(!1),[f,p]=le.useState(null),h=(b,k)=>fetch(b,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${nv}/api/wallet`).then(b=>b.json()).then(b=>n(b)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};le.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const b=await h(`${nv}/api/wallet/create`,{method:"POST"}),k=await b.json();if(!b.ok)throw new Error(k.error||"Creation failed");g()}catch(b){p(b instanceof Error?b.message:"Failed to create wallet")}a(!1)},S=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=b=>`${b.slice(0,6)}...${b.slice(-4)}`;return x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&x.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&x.jsx("p",{className:"text-error text-xs",children:f}),x.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&&x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),x.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"})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),x.jsx("button",{onClick:S,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),x.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC"}),x.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"PLOT"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Network"}),x.jsx("span",{className:"text-foreground",children:"Base"})]})]}),x.jsxs("div",{className:"border-border border-t pt-3",children:[x.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),x.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),x.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 Dx({token:e,onLogout:t}){const[n,s]=le.useState(""),[a,o]=le.useState(""),[c,f]=le.useState(null),[p,h]=le.useState(!1),[g,_]=le.useState(!1),[S,y]=le.useState(null),[b,k]=le.useState("AI Writer"),[D,T]=le.useState(""),[X,U]=le.useState(""),[te,ae]=le.useState(!1),[O,H]=le.useState(null),[P,ie]=le.useState(""),[L,Z]=le.useState(null),[j,F]=le.useState(!1),[$,z]=le.useState(null),[M,I]=le.useState(null),W=le.useCallback((C,se)=>fetch(C,{...se,headers:{...se==null?void 0:se.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);le.useEffect(()=>{W("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ue=async()=>{if(!b.trim()){H("Agent name is required");return}if(!D.trim()){H("Description is required");return}ae(!0),H(null);try{const C=await W("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:b,description:D,...X.trim()&&{genre:X}})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Registration failed");y({linked:!0,agentId:se.agentId,owsWallet:se.owsWallet})}catch(C){H(C instanceof Error?C.message:"Registration failed")}ae(!1)},E=async()=>{if(!P.trim()||!/^0x[a-fA-F0-9]{40}$/.test(P)){z("Enter a valid wallet address (0x...)");return}F(!0),z(null),Z(null);try{const C=await W("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:P})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Failed to generate binding code");Z(se)}catch(C){z(C instanceof Error?C.message:"Failed to generate binding code")}F(!1)},A=async(C,se)=>{await navigator.clipboard.writeText(C),I(se),setTimeout(()=>I(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await W("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const se=await C.json();throw new Error(se.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return x.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),S!=null&&S.linked?x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),x.jsxs("span",{className:"text-muted text-xs",children:["Agent #",S.agentId]})]}),S.owsWallet&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",S.owsWallet.slice(0,6),"...",S.owsWallet.slice(-4)]}),S.owner&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",S.owner.slice(0,6),"...",S.owner.slice(-4)]}),x.jsx("p",{className:"text-muted text-xs",children:x.jsx("a",{href:`https://plotlink.xyz/agents/${S.agentId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):x.jsxs("div",{className:"space-y-3",children:[x.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."}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),x.jsx("input",{value:b,onChange:C=>k(C.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"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),x.jsx("input",{value:D,onChange:C=>T(C.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"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),x.jsx("input",{value:X,onChange:C=>U(C.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"})]}),O&&x.jsx("p",{className:"text-error text-xs",children:O}),x.jsx("button",{onClick:ue,disabled:te||!b.trim()||!D.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:te?"Registering...":"Register Agent Identity"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),S!=null&&S.owner?x.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",x.jsxs("span",{className:"font-mono",children:[S.owner.slice(0,6),"...",S.owner.slice(-4)]})]}):x.jsxs("div",{className:"space-y-3",children:[x.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."}),x.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[x.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),x.jsx("p",{children:'2. Click "Generate Binding Code"'}),x.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),x.jsx("input",{value:P,onChange:C=>ie(C.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"}),$&&x.jsx("p",{className:"text-error text-xs",children:$}),x.jsx("button",{onClick:E,disabled:j||!P.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?"Generating...":"Generate Binding Code"}),L&&x.jsxs("div",{className:"space-y-3 mt-3",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:L.signature}),x.jsx("button",{onClick:()=>A(L.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="signature"?"Copied!":"Copy"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:L.owsWallet}),x.jsx("button",{onClick:()=>A(L.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="wallet"?"Copied!":"Copy"})]})]}),x.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste both values in the "Link AI Writer" section.'})]})]})]}),x.jsx(Zy,{token:e}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),x.jsxs("div",{className:"space-y-3",children:[x.jsx("input",{type:"password",value:n,onChange:C=>s(C.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"}),x.jsx("input",{type:"password",value:a,onChange:C=>o(C.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&&x.jsx("p",{className:"text-error text-xs",children:c}),p&&x.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),x.jsx("button",{onClick:K,disabled:g||!n.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:g?"updating...":"update passphrase"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),x.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 Rx="http://localhost:7777";function Mx({token:e}){const[t,n]=le.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Rx}/api/dashboard`).then(f=>f.json()).then(n)};le.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?x.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),x.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Address"}),x.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH Balance"}),x.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC Balance"}),x.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),x.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Royalties earned"}),x.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),x.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),x.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[x.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),x.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Stories published"}),x.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?x.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):x.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>x.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[x.jsxs("div",{className:"flex items-start justify-between",children:[x.jsxs("div",{children:[f.genre&&x.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),x.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),x.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&x.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),x.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),x.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),x.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),x.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>x.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),x.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&x.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))}),x.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[x.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&x.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&x.jsx("div",{className:"border-border rounded border p-4",children:x.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):x.jsx("div",{className:"flex h-full items-center justify-center",children:x.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Bx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Lx={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function Nx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=le.useState([]),[p,h]=le.useState(new Set),g=le.useCallback(async()=>{try{const k=await e("/api/stories");if(k.ok){const D=await k.json();f(D.stories)}}catch{}},[e]);le.useEffect(()=>{g();const k=setInterval(g,5e3);return()=>clearInterval(k)},[g]),le.useEffect(()=>{t&&h(k=>new Set(k).add(t))},[t]);const _=k=>{var T;const D=k.map(X=>{var U;return{file:X.file,num:(U=X.file.match(/^plot-(\d+)\.md$/))==null?void 0:U[1]}}).filter(X=>X.num!=null).sort((X,U)=>parseInt(U.num)-parseInt(X.num));return D.length>0?D[0].file:k.some(X=>X.file==="genesis.md")?"genesis.md":k.some(X=>X.file==="structure.md")?"structure.md":((T=k[0])==null?void 0:T.file)??null},S=k=>{h(D=>{const T=new Set(D);return T.has(k)?T.delete(k):T.add(k),T})},y=k=>{if(S(k.name),!p.has(k.name)){const D=_(k.files);D&&s(k.name,D)}},b=k=>{const D=T=>{if(T==="structure.md")return 0;if(T==="genesis.md")return 1;const X=T.match(/^plot-(\d+)\.md$/);return X?2+parseInt(X[1]):100};return[...k].sort((T,X)=>D(T.file)-D(X.file))};return x.jsxs("div",{className:"h-full flex flex-col",children:[x.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[x.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),x.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&x.jsx("div",{className:"px-3 py-2 border-b border-border",children:x.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:[x.jsx("span",{children:"+"}),x.jsx("span",{children:"New Story"})]})}),x.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(k=>x.jsx("div",{children:x.jsxs("button",{onClick:()=>s(k,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===k?"bg-surface":""}`,children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),x.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},k)),c.length===0&&o.length===0?x.jsxs("div",{className:"p-3 text-sm text-muted",children:[x.jsx("p",{children:"No stories yet."}),x.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(k=>k.name!=="_example").map(k=>x.jsxs("div",{children:[x.jsxs("button",{onClick:()=>y(k),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[x.jsx("span",{className:"text-xs text-muted",children:p.has(k.name)?"▼":"▶"}),x.jsx("span",{className:"font-medium truncate",title:k.name,children:k.title||k.name}),x.jsxs("span",{className:"ml-auto text-xs text-muted",children:[k.publishedCount,"/",k.files.length]})]}),p.has(k.name)&&x.jsx("div",{className:"pl-4",children:b(k.files).map(D=>{const T=t===k.name&&n===D.file;return x.jsxs("button",{onClick:()=>s(k.name,D.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${T?"bg-surface font-medium":""}`,children:[x.jsx("span",{className:Lx[D.status],children:Bx[D.status]}),x.jsx("span",{className:"truncate font-mono",children:D.file})]},D.file)})})]},k.name))]})]})}/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var Qy=Object.defineProperty,zx=Object.getOwnPropertyDescriptor,Ox=(e,t)=>{for(var n in t)Qy(e,n,{get:t[n],enumerable:!0})},ht=(e,t,n,s)=>{for(var a=s>1?void 0:s?zx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&Qy(t,n,a),a},de=(e,t)=>(n,s)=>t(n,s,e),rv="Terminal input",Tf={get:()=>rv,set:e=>rv=e},sv="Too much output to announce, navigate to rows manually to read",Af={get:()=>sv,set:e=>sv=e};function Hx(e){return e.replace(/\r?\n/g,"\r")}function jx(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Ux(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Px(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");Jy(a,t,n,s)}}function Jy(e,t,n,s){e=Hx(e),e=jx(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function eS(e,t,n){let s=n.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 lv(e,t,n,s,a){eS(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function dr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function vu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Ix=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)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=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Fx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let S=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let b=0,k;for(;(k=this.interim[++b]&63)&&b<4;)y<<=6,y|=k;let D=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,T=D-b;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,S=!0;break}else this.interim[b++]=k,y<<=6,y|=k&63}S||(D===2?y<128?h--:t[s++]=y:D===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)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(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)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(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},tS="",mr=" ",_a=class iS{constructor(){this.fg=0,this.bg=0,this.extended=new ou}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 iS;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}},ou=class nS{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new nS(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Vi=class rS extends _a{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ou,this.combinedData=""}static fromCharData(t){let n=new rS;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let 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:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},av="di$target",Df="di$dependencies",Xh=new Map;function qx(e){return e[Df]||[]}function Ot(e){if(Xh.has(e))return Xh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Wx(t,n,a)};return t._id=e,Xh.set(e,t),t}function Wx(e,t,n){t[av]===t?t[Df].push({id:e,index:n}):(t[Df]=[{id:e,index:n}],t[av]=t)}var si=Ot("BufferService"),sS=Ot("CoreMouseService"),Xr=Ot("CoreService"),Yx=Ot("CharsetService"),xd=Ot("InstantiationService"),lS=Ot("LogService"),li=Ot("OptionsService"),aS=Ot("OscLinkService"),Vx=Ot("UnicodeService"),ga=Ot("DecorationService"),Rf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Vi,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,D,y):Kx(k,D),hover:(k,D)=>{var T;return(T=a==null?void 0:a.hover)==null?void 0:T.call(a,k,D,y)},leave:(k,D)=>{var T;return(T=a==null?void 0:a.leave)==null?void 0:T.call(a,k,D,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Rf=ht([de(0,si),de(1,li),de(2,aS)],Rf);function Kx(e,t){if(confirm(`Do you want to navigate to ${t}? - -WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var yu=Ot("CharSizeService"),zn=Ot("CoreBrowserService"),wd=Ot("MouseService"),On=Ot("RenderService"),Xx=Ot("SelectionService"),oS=Ot("CharacterJoinerService"),Ks=Ot("ThemeService"),uS=Ot("LinkProviderService"),$x=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ov.isErrorNoTelemetry(e)?new ov(e.message+` - -`+e.stack):new Error(e.message+` - -`+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)}},Gx=new $x;function eu(e){Zx(e)||Gx.onUnexpectedError(e)}var Mf="Canceled";function Zx(e){return e instanceof Qx?!0:e instanceof Error&&e.name===Mf&&e.message===Mf}var Qx=class extends Error{constructor(){super(Mf),this.name=this.message}};function Jx(e){return new Error(`Illegal argument: ${e}`)}var ov=class Bf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Bf)return t;let n=new Bf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Lf=class cS extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,cS.prototype)}};function Ai(e,t=0){return e[e.length-(1+t)]}var ew;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;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})(ew||(ew={}));function tw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var hS;(e=>{function t(te){return te&&typeof te=="object"&&typeof te[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(te){yield te}e.single=a;function o(te){return t(te)?te:a(te)}e.wrap=o;function c(te){return te||n}e.from=c;function*f(te){for(let ae=te.length-1;ae>=0;ae--)yield te[ae]}e.reverse=f;function p(te){return!te||te[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(te){return te[Symbol.iterator]().next().value}e.first=h;function g(te,ae){let O=0;for(let H of te)if(ae(H,O++))return!0;return!1}e.some=g;function _(te,ae){for(let O of te)if(ae(O))return O}e.find=_;function*S(te,ae){for(let O of te)ae(O)&&(yield O)}e.filter=S;function*y(te,ae){let O=0;for(let H of te)yield ae(H,O++)}e.map=y;function*b(te,ae){let O=0;for(let H of te)yield*ae(H,O++)}e.flatMap=b;function*k(...te){for(let ae of te)yield*ae}e.concat=k;function D(te,ae,O){let H=O;for(let P of te)H=ae(H,P);return H}e.reduce=D;function*T(te,ae,O=te.length){for(ae<0&&(ae+=te.length),O<0?O+=te.length:O>te.length&&(O=te.length);ae1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function iw(...e){return rt(()=>Yr(e))}function rt(e){return{dispose:tw(()=>{e()})}}var fS=class dS{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{Yr(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?dS.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)}};fS.DISABLE_DISPOSED_WARNING=!1;var _r=fS,Ae=class{constructor(){this._store=new _r,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)}};Ae.None=Object.freeze({dispose(){}});var Ys=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}},Nn=typeof window=="object"?window:globalThis,Nf=class zf{constructor(t){this.element=t,this.next=zf.Undefined,this.prev=zf.Undefined}};Nf.Undefined=new Nf(void 0);var st=Nf,uv=class{constructor(){this._first=st.Undefined,this._last=st.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===st.Undefined}clear(){let e=this._first;for(;e!==st.Undefined;){let t=e.next;e.prev=st.Undefined,e.next=st.Undefined,e=t}this._first=st.Undefined,this._last=st.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new st(e);if(this._first===st.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==st.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==st.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==st.Undefined&&e.next!==st.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===st.Undefined&&e.next===st.Undefined?(this._first=st.Undefined,this._last=st.Undefined):e.next===st.Undefined?(this._last=this._last.prev,this._last.next=st.Undefined):e.prev===st.Undefined&&(this._first=this._first.next,this._first.prev=st.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==st.Undefined;)yield e.element,e=e.next}},nw=globalThis.performance&&typeof globalThis.performance.now=="function",rw=class pS{static create(t){return new pS(t)}constructor(t){this._now=nw&&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}},Yt;(e=>{e.None=()=>Ae.None;function t(j,F){return _(j,()=>{},0,void 0,!0,void 0,F)}e.defer=t;function n(j){return(F,$=null,z)=>{let M=!1,I;return I=j(W=>{if(!M)return I?I.dispose():M=!0,F.call($,W)},null,z),M&&I.dispose(),I}}e.once=n;function s(j,F,$){return h((z,M=null,I)=>j(W=>z.call(M,F(W)),null,I),$)}e.map=s;function a(j,F,$){return h((z,M=null,I)=>j(W=>{F(W),z.call(M,W)},null,I),$)}e.forEach=a;function o(j,F,$){return h((z,M=null,I)=>j(W=>F(W)&&z.call(M,W),null,I),$)}e.filter=o;function c(j){return j}e.signal=c;function f(...j){return(F,$=null,z)=>{let M=iw(...j.map(I=>I(W=>F.call($,W))));return g(M,z)}}e.any=f;function p(j,F,$,z){let M=$;return s(j,I=>(M=F(M,I),M),z)}e.reduce=p;function h(j,F){let $,z={onWillAddFirstListener(){$=j(M.fire,M)},onDidRemoveLastListener(){$==null||$.dispose()}},M=new ce(z);return F==null||F.add(M),M.event}function g(j,F){return F instanceof Array?F.push(j):F&&F.add(j),j}function _(j,F,$=100,z=!1,M=!1,I,W){let ue,E,A,K=0,C,se={leakWarningThreshold:I,onWillAddFirstListener(){ue=j(pe=>{K++,E=F(E,pe),z&&!A&&(fe.fire(E),E=void 0),C=()=>{let xe=E;E=void 0,A=void 0,(!z||K>1)&&fe.fire(xe),K=0},typeof $=="number"?(clearTimeout(A),A=setTimeout(C,$)):A===void 0&&(A=0,queueMicrotask(C))})},onWillRemoveListener(){M&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,ue.dispose()}},fe=new ce(se);return W==null||W.add(fe),fe.event}e.debounce=_;function S(j,F=0,$){return e.debounce(j,(z,M)=>z?(z.push(M),z):[M],F,void 0,!0,void 0,$)}e.accumulate=S;function y(j,F=(z,M)=>z===M,$){let z=!0,M;return o(j,I=>{let W=z||!F(I,M);return z=!1,M=I,W},$)}e.latch=y;function b(j,F,$){return[e.filter(j,F,$),e.filter(j,z=>!F(z),$)]}e.split=b;function k(j,F=!1,$=[],z){let M=$.slice(),I=j(E=>{M?M.push(E):ue.fire(E)});z&&z.add(I);let W=()=>{M==null||M.forEach(E=>ue.fire(E)),M=null},ue=new ce({onWillAddFirstListener(){I||(I=j(E=>ue.fire(E)),z&&z.add(I))},onDidAddFirstListener(){M&&(F?setTimeout(W):W())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return z&&z.add(ue),ue.event}e.buffer=k;function D(j,F){return($,z,M)=>{let I=F(new X);return j(function(W){let ue=I.evaluate(W);ue!==T&&$.call(z,ue)},void 0,M)}}e.chain=D;let T=Symbol("HaltChainable");class X{constructor(){this.steps=[]}map(F){return this.steps.push(F),this}forEach(F){return this.steps.push($=>(F($),$)),this}filter(F){return this.steps.push($=>F($)?$:T),this}reduce(F,$){let z=$;return this.steps.push(M=>(z=F(z,M),z)),this}latch(F=($,z)=>$===z){let $=!0,z;return this.steps.push(M=>{let I=$||!F(M,z);return $=!1,z=M,I?M:T}),this}evaluate(F){for(let $ of this.steps)if(F=$(F),F===T)break;return F}}function U(j,F,$=z=>z){let z=(...ue)=>W.fire($(...ue)),M=()=>j.on(F,z),I=()=>j.removeListener(F,z),W=new ce({onWillAddFirstListener:M,onDidRemoveLastListener:I});return W.event}e.fromNodeEventEmitter=U;function te(j,F,$=z=>z){let z=(...ue)=>W.fire($(...ue)),M=()=>j.addEventListener(F,z),I=()=>j.removeEventListener(F,z),W=new ce({onWillAddFirstListener:M,onDidRemoveLastListener:I});return W.event}e.fromDOMEventEmitter=te;function ae(j){return new Promise(F=>n(j)(F))}e.toPromise=ae;function O(j){let F=new ce;return j.then($=>{F.fire($)},()=>{F.fire(void 0)}).finally(()=>{F.dispose()}),F.event}e.fromPromise=O;function H(j,F){return j($=>F.fire($))}e.forward=H;function P(j,F,$){return F($),j(z=>F(z))}e.runAndSubscribe=P;class ie{constructor(F,$){this._observable=F,this._counter=0,this._hasChanged=!1;let z={onWillAddFirstListener:()=>{F.addObserver(this)},onDidRemoveLastListener:()=>{F.removeObserver(this)}};this.emitter=new ce(z),$&&$.add(this.emitter)}beginUpdate(F){this._counter++}handlePossibleChange(F){}handleChange(F,$){this._hasChanged=!0}endUpdate(F){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function L(j,F){return new ie(j,F).emitter.event}e.fromObservable=L;function Z(j){return(F,$,z)=>{let M=0,I=!1,W={beginUpdate(){M++},endUpdate(){M--,M===0&&(j.reportChanges(),I&&(I=!1,F.call($)))},handlePossibleChange(){},handleChange(){I=!0}};j.addObserver(W),j.reportChanges();let ue={dispose(){j.removeObserver(W)}};return z instanceof _r?z.add(ue):Array.isArray(z)&&z.push(ue),ue}}e.fromObservableLight=Z})(Yt||(Yt={}));var Of=class Hf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Hf._idPool++}`,Hf.all.add(this)}start(t){this._stopWatch=new rw,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}}};Of.all=new Set,Of._idPool=0;var sw=Of,lw=-1,mS=class _S{constructor(t,n,s=(_S._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let S=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(S);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new cw(`${S}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||eu)(b),Ae.None}if(this._disposed)return Ae.None;n&&(t=t.bind(n));let a=new $h(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=ow.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof $h?(this._deliveryQueue??(this._deliveryQueue=new pw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=rt(()=>{o==null||o(),this._removeListener(a)});return s instanceof _r?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,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=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.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--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*fw<=n.length){let h=0;for(let g=0;g0}},pw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ce,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ce,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};jf.INSTANCE=new jf;var Cd=jf;function mw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Cd.INSTANCE.onDidChangeZoomLevel;function _w(e){return Cd.INSTANCE.getZoomFactor(e)}Cd.INSTANCE.onDidChangeFullscreen;var Xs=typeof navigator=="object"?navigator.userAgent:"",Uf=Xs.indexOf("Firefox")>=0,gw=Xs.indexOf("AppleWebKit")>=0,kd=Xs.indexOf("Chrome")>=0,vw=!kd&&Xs.indexOf("Safari")>=0;Xs.indexOf("Electron/")>=0;Xs.indexOf("Android")>=0;var Gh=!1;if(typeof Nn.matchMedia=="function"){let e=Nn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Nn.matchMedia("(display-mode: fullscreen)");Gh=e.matches,mw(Nn,e,({matches:n})=>{Gh&&t.matches||(Gh=n)})}var qs="en",Pf=!1,If=!1,tu=!1,vS=!1,qo,iu=qs,cv=qs,yw,Zi,Wr=globalThis,Wt,Xy;typeof Wr.vscode<"u"&&typeof Wr.vscode.process<"u"?Wt=Wr.vscode.process:typeof process<"u"&&typeof((Xy=process==null?void 0:process.versions)==null?void 0:Xy.node)=="string"&&(Wt=process);var $y,Sw=typeof(($y=Wt==null?void 0:Wt.versions)==null?void 0:$y.electron)=="string",bw=Sw&&(Wt==null?void 0:Wt.type)==="renderer",Gy;if(typeof Wt=="object"){Pf=Wt.platform==="win32",If=Wt.platform==="darwin",tu=Wt.platform==="linux",tu&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,qo=qs,iu=qs;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);qo=t.userLocale,cv=t.osLocale,iu=t.resolvedLanguage||qs,yw=(Gy=t.languagePack)==null?void 0:Gy.translationsConfigFile}catch{}vS=!0}else typeof navigator=="object"&&!bw?(Zi=navigator.userAgent,Pf=Zi.indexOf("Windows")>=0,If=Zi.indexOf("Macintosh")>=0,(Zi.indexOf("Macintosh")>=0||Zi.indexOf("iPad")>=0||Zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tu=Zi.indexOf("Linux")>=0,(Zi==null?void 0:Zi.indexOf("Mobi"))>=0,iu=globalThis._VSCODE_NLS_LANGUAGE||qs,qo=navigator.language.toLowerCase(),cv=qo):console.error("Unable to resolve platform.");var yS=Pf,un=If,xw=tu,hv=vS,cn=Zi,ur=iu,ww;(e=>{function t(){return ur}e.value=t;function n(){return ur.length===2?ur==="en":ur.length>=3?ur[0]==="e"&&ur[1]==="n"&&ur[2]==="-":!1}e.isDefaultVariant=n;function s(){return ur==="en"}e.isDefault=s})(ww||(ww={}));var Cw=typeof Wr.postMessage=="function"&&!Wr.importScripts;(()=>{if(Cw){let e=[];Wr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Wr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var kw=!!(cn&&cn.indexOf("Chrome")>=0);cn&&cn.indexOf("Firefox")>=0;!kw&&cn&&cn.indexOf("Safari")>=0;cn&&cn.indexOf("Edg/")>=0;cn&&cn.indexOf("Android")>=0;var js=typeof navigator=="object"?navigator:{};hv||document.queryCommandSupported&&document.queryCommandSupported("copy")||js&&js.clipboard&&js.clipboard.writeText,hv||js&&js.clipboard&&js.clipboard.readText;var Ed=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}},Zh=new Ed,fv=new Ed,dv=new Ed,Ew=new Array(230),SS;(e=>{function t(f){return Zh.keyCodeToStr(f)}e.toString=t;function n(f){return Zh.strToKeyCode(f)}e.fromString=n;function s(f){return fv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return dv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return fv.strToKeyCode(f)||dv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Zh.keyCodeToStr(f)}e.toElectronAccelerator=c})(SS||(SS={}));var Tw=class bS{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof bS&&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",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Aw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Aw=class{constructor(e){if(e.length===0)throw Jx("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Hw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Yt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:xS})})(Ow||(Ow={}));var Hw=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?xS:(this._emitter||(this._emitter=new ce),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Td=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 Lf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Lf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},jw=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,n=globalThis){if(this.isDisposed)throw new Lf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=rt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Uw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Uw||(Uw={}));var gv=class qi{static fromArray(t){return new qi(n=>{n.emitMany(t)})}static fromPromise(t){return new qi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new qi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new qi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ce,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{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new qi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return qi.map(this,t)}static filter(t,n){return new qi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return qi.filter(this,t)}static coalesce(t){return qi.filter(t,n=>!!n)}coalesce(){return qi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return qi.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())}};gv.EMPTY=gv.fromArray([]);var{getWindow:on,getWindowId:Pw,onDidRegisterWindow:Iw}=(function(){let e=new Map,t={window:Nn,disposables:new _r};e.set(Nn.vscodeWindowId,t);let n=new ce,s=new ce,a=new ce;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Ae.None;let f=new _r,p={window:c,disposables:f.add(new _r)};return e.set(c.vscodeWindowId,p),f.add(rt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(be(c,Dt.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Nn},getDocument(c){return on(c).document}}})(),Fw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,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 be(e,t,n,s){return new Fw(e,t,n,s)}var vv=function(e,t,n,s){return be(e,t,n,s)},Ad,qw=class extends jw{constructor(e){super(),this.defaultTarget=e&&on(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},yv=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){eu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.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(yv.sort),c.shift().execute();s.set(o,!1)};Ad=(o,c,f=0)=>{let p=Pw(o),h=new yv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Ww(e){let t=e.getBoundingClientRect(),n=on(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Dt={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"},Yw=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=_i(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_i(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_i(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_i(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_i(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_i(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_i(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_i(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_i(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_i(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_i(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=_i(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=_i(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_i(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 _i(e){return typeof e=="number"?`${e}px`:e}function la(e){return new Yw(e)}var wS=class{constructor(){this._hooks=new _r,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(rt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=on(e)}this._hooks.add(be(o,Dt.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(be(o,Dt.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Vw(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[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 ln;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ln||(ln={}));var ta=class Kt extends Ae{constructor(){super(),this.dispatched=!1,this.targets=new uv,this.ignoreTargets=new uv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Yt.runAndSubscribe(Iw,({window:t,disposables:n})=>{n.add(be(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(be(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(be(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Nn,disposables:this._store}))}static addTarget(t){if(!Kt.isTouchDevice())return Ae.None;Kt.INSTANCE||(Kt.INSTANCE=new Kt);let n=Kt.INSTANCE.targets.push(t);return rt(n)}static ignoreTarget(t){if(!Kt.isTouchDevice())return Ae.None;Kt.INSTANCE||(Kt.INSTANCE=new Kt);let n=Kt.INSTANCE.ignoreTargets.push(t);return rt(n)}static isTouchDevice(){return"ontouchstart"in Nn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=Kt.HOLD_DELAY&&Math.abs(p.initialPageX-Ai(p.rollingPageX))<30&&Math.abs(p.initialPageY-Ai(p.rollingPageY))<30){let g=this.newGestureEvent(ln.Contextmenu,p.initialTarget);g.pageX=Ai(p.rollingPageX),g.pageY=Ai(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Ai(p.rollingPageX),_=Ai(p.rollingPageY),S=Ai(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],b=_-p.rollingPageY[0],k=[...this.targets].filter(D=>p.initialTarget instanceof Node&&D.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/S,y>0?1:-1,g,Math.abs(b)/S,b>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(ln.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===ln.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Kt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===ln.Change||t.type===ln.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];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;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Ad(t,()=>{let g=Date.now(),_=g-s,S=0,y=0,b=!0;a+=Kt.SCROLL_FRICTION*_,f+=Kt.SCROLL_FRICTION*_,a>0&&(b=!1,S=o*a*_),f>0&&(b=!1,y=p*f*_);let k=this.newGestureEvent(ln.Change);k.translationX=S,k.translationY=y,n.forEach(D=>D.dispatchEvent(k)),b||this.inertia(t,n,g,a,o,c+S,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ta.SCROLL_FRICTION=-.005,ta.HOLD_DELAY=700,ta.CLEAR_TAP_COUNT_TIME=400,ht([Vw],ta,"isTouchDevice",1);var Kw=ta,Dd=class extends Ae{onclick(e,t){this._register(be(e,Dt.CLICK,n=>t(new Wo(on(e),n))))}onmousedown(e,t){this._register(be(e,Dt.MOUSE_DOWN,n=>t(new Wo(on(e),n))))}onmouseover(e,t){this._register(be(e,Dt.MOUSE_OVER,n=>t(new Wo(on(e),n))))}onmouseleave(e,t){this._register(be(e,Dt.MOUSE_LEAVE,n=>t(new Wo(on(e),n))))}onkeydown(e,t){this._register(be(e,Dt.KEY_DOWN,n=>t(new pv(n))))}onkeyup(e,t){this._register(be(e,Dt.KEY_UP,n=>t(new pv(n))))}oninput(e,t){this._register(be(e,Dt.INPUT,t))}onblur(e,t){this._register(be(e,Dt.BLUR,t))}onfocus(e,t){this._register(be(e,Dt.FOCUS,t))}onchange(e,t){this._register(be(e,Dt.CHANGE,t))}ignoreGesture(e){return Kw.ignoreTarget(e)}},Sv=11,Xw=class extends Dd{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=Sv+"px",this.domNode.style.height=Sv+"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 wS),this._register(vv(this.bgDomNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(vv(this.domNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new qw),this._pointerdownScheduleRepeatTimer=this._register(new Td)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,on(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},$w=class Ff{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}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,n){return new Ff(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ff(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,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,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:f,scrollTopChanged:p}}},Gw=class extends Ae{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $w(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 n=this._state.withScrollDimensions(e,t);this._setState(n,!!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 n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new xv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=xv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},bv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Qh(e,t){let n=t-e;return function(s){return e+n*Jw(s)}}function Zw(e,t,n){return function(s){return s2.5*s){let a,o;return t{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":"")))}},tC=140,CS=class extends Dd{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 eC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new wS),this._shouldRender=!0,this.domNode=la(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(be(this.domNode.domNode,Dt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Xw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=la(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(be(this.slider.domNode,Dt.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,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Ww(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);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),n=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-n);if(yS&&c>tC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{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()}},kS=class Wf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),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 Wf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Wf._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 n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Yf.INSTANCE=new Yf;var lC=Yf,aC=class extends Dd{constructor(e,t,n){super(),this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ce),this.onWillScroll=this._onWillScroll.event,this._options=uC(t),this._scrollable=n,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 nC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new iC(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=la(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=la(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=la(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 Td),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Yr(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,un&&(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 _v(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Yr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new _v(n))};this._mouseWheelToDispose.push(be(this._listenOnDomNode,Dt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=lC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!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 f=!un&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!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(),h={};if(o){let g=wv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=wv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!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,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||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(),rC)}},oC=class extends aC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function uC(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,un&&(t.className+=" mac"),t}var Vf=class extends Ae{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Gw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Ad(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new oC(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(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Yt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(rt(()=>this._styleElement.remove())),this._register(Yt.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(` -`)})),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(h=>this._handleScroll(h)))}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),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Vf=ht([de(2,si),de(3,zn),de(4,sS),de(5,Ks),de(6,li),de(7,On)],Vf);var Kf=class extends Ae{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,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(rt(()=>{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 n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Kf=ht([de(1,si),de(2,zn),de(3,ga),de(4,On)],Kf);var cC=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=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},rn={full:0,left:0,center:0,right:0},cr={full:0,left:0,center:0,right:0},Yl={full:0,left:0,center:0,right:0},uu=class extends Ae{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new cC,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(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(rt(()=>{var g;return(g=this._canvas)==null?void 0:g.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);cr.full=this._canvas.width,cr.left=e,cr.center=t,cr.right=e,this._refreshDrawHeightConstants(),Yl.full=1,Yl.left=1,Yl.center=1+cr.left,Yl.right=1+cr.left+cr.center}_refreshDrawHeightConstants(){rn.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);rn.left=t,rn.center=t,rn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.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(Yl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-rn[e.position||"full"]/2),cr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+rn[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}))}};uu=ht([de(2,si),de(3,ga),de(4,On),de(5,li),de(6,Ks),de(7,zn)],uu);var re;(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=` -`,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=""))(re||(re={}));var nu;(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="Ÿ"))(nu||(nu={}));var ES;(e=>e.ST=`${re.ESC}\\`)(ES||(ES={}));var Xf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,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 n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!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,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Xf=ht([de(2,si),de(3,li),de(4,Xr),de(5,On)],Xf);var Rt=0,Mt=0,Bt=0,ut=0,Cv={css:"#00000000",rgba:0},bt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Hr(a)}${Hr(o)}${Hr(c)}${Hr(f)}`:`#${Hr(a)}${Hr(o)}${Hr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(bt||(bt={}));var it;(e=>{function t(p,h){if(ut=(h.rgba&255)/255,ut===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,S=h.rgba>>8&255,y=p.rgba>>24&255,b=p.rgba>>16&255,k=p.rgba>>8&255;Rt=y+Math.round((g-y)*ut),Mt=b+Math.round((_-b)*ut),Bt=k+Math.round((S-k)*ut);let D=bt.toCss(Rt,Mt,Bt),T=bt.toRgba(Rt,Mt,Bt);return{css:D,rgba:T}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=ru.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return bt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Rt,Mt,Bt]=ru.toChannels(h),{css:bt.toCss(Rt,Mt,Bt),rgba:h}}e.opaque=a;function o(p,h){return ut=Math.round(h*255),[Rt,Mt,Bt]=ru.toChannels(p.rgba),{css:bt.toCss(Rt,Mt,Bt,ut),rgba:bt.toRgba(Rt,Mt,Bt,ut)}}e.opacity=o;function c(p,h){return ut=p.rgba&255,o(p,ut*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(it||(it={}));var lt;(e=>{let t,n;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",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Rt=parseInt(a.slice(1,2).repeat(2),16),Mt=parseInt(a.slice(2,3).repeat(2),16),Bt=parseInt(a.slice(3,4).repeat(2),16),bt.toColor(Rt,Mt,Bt);case 5:return Rt=parseInt(a.slice(1,2).repeat(2),16),Mt=parseInt(a.slice(2,3).repeat(2),16),Bt=parseInt(a.slice(3,4).repeat(2),16),ut=parseInt(a.slice(4,5).repeat(2),16),bt.toColor(Rt,Mt,Bt,ut);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 Rt=parseInt(o[1]),Mt=parseInt(o[2]),Bt=parseInt(o[3]),ut=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),bt.toColor(Rt,Mt,Bt,ut);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Rt,Mt,Bt,ut]=t.getImageData(0,0,1,1).data,ut!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:bt.toRgba(Rt,Mt,Bt,ut),css:a}}e.toColor=s})(lt||(lt={}));var ii;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ii||(ii={}));var ru;(e=>{function t(c,f){if(ut=(f&255)/255,ut===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,S=c>>16&255,y=c>>8&255;return Rt=_+Math.round((p-_)*ut),Mt=S+Math.round((h-S)*ut),Bt=y+Math.round((g-y)*ut),bt.toRgba(Rt,Mt,Bt)}e.blend=t;function n(c,f,p){let h=ii.relativeLuminance(c>>8),g=ii.relativeLuminance(f>>8);if(Mn(h,g)>8));if(b>8));return b>D?y:k}return y}let _=a(c,f,p),S=Mn(h,ii.relativeLuminance(_>>8));if(S>8));return S>b?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,S=f>>24&255,y=f>>16&255,b=f>>8&255,k=Mn(ii.relativeLuminance2(S,y,b),ii.relativeLuminance2(h,g,_));for(;k0||y>0||b>0);)S-=Math.max(0,Math.ceil(S*.1)),y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),k=Mn(ii.relativeLuminance2(S,y,b),ii.relativeLuminance2(h,g,_));return(S<<24|y<<16|b<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,S=f>>24&255,y=f>>16&255,b=f>>8&255,k=Mn(ii.relativeLuminance2(S,y,b),ii.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(ru||(ru={}));function Hr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Mn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=L,I=F,W=this._workCell;if(S.length>0&&F===S[0][0]&&M){let He=S.shift(),yi=this._isCellInSelection(He[0],t);for(X=He[0]+1;X=He[1]),M?(z=!0,W=new hC(this._workCell,e.translateToString(!0,He[0],He[1]),He[1]-He[0]),I=He[1]-1,$=W.getWidth()):L=He[1]}let ue=this._isCellInSelection(F,t),E=n&&F===o,A=j&&F>=h&&F<=g,K=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,He=>{K=!0});let C=W.getChars()||mr;if(C===" "&&(W.isUnderline()||W.isOverline())&&(C=" "),ie=$*f-p.get(C,W.isBold(),W.isItalic()),!k)k=this._document.createElement("span");else if(D&&(ue&&P||!ue&&!P&&W.bg===U)&&(ue&&P&&y.selectionForeground||W.fg===te)&&W.extended.ext===ae&&A===O&&ie===H&&!E&&!z&&!K&&M){W.isInvisible()?T+=mr:T+=C,D++;continue}else D&&(k.textContent=T),k=this._document.createElement("span"),D=0,T="";if(U=W.bg,te=W.fg,ae=W.extended.ext,O=A,H=ie,P=ue,z&&o>=F&&o<=I&&(o=F),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(Z.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&Z.push("xterm-cursor-blink"),Z.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":Z.push("xterm-cursor-outline");break;case"block":Z.push("xterm-cursor-block");break;case"bar":Z.push("xterm-cursor-bar");break;case"underline":Z.push("xterm-cursor-underline");break}}if(W.isBold()&&Z.push("xterm-bold"),W.isItalic()&&Z.push("xterm-italic"),W.isDim()&&Z.push("xterm-dim"),W.isInvisible()?T=mr:T=W.getChars()||mr,W.isUnderline()&&(Z.push(`xterm-underline-${W.extended.underlineStyle}`),T===" "&&(T=" "),!W.isUnderlineColorDefault()))if(W.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${_a.toColorRGB(W.getUnderlineColor()).join(",")})`;else{let He=W.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&W.isBold()&&He<8&&(He+=8),k.style.textDecorationColor=y.ansi[He].css}W.isOverline()&&(Z.push("xterm-overline"),T===" "&&(T=" ")),W.isStrikethrough()&&Z.push("xterm-strikethrough"),A&&(k.style.textDecoration="underline");let se=W.getFgColor(),fe=W.getFgColorMode(),pe=W.getBgColor(),xe=W.getBgColorMode(),Ye=!!W.isInverse();if(Ye){let He=se;se=pe,pe=He;let yi=fe;fe=xe,xe=yi}let De,Ht,Zt=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,He=>{He.options.layer!=="top"&&Zt||(He.backgroundColorRGB&&(xe=50331648,pe=He.backgroundColorRGB.rgba>>8&16777215,De=He.backgroundColorRGB),He.foregroundColorRGB&&(fe=50331648,se=He.foregroundColorRGB.rgba>>8&16777215,Ht=He.foregroundColorRGB),Zt=He.options.layer==="top")}),!Zt&&ue&&(De=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,pe=De.rgba>>8&16777215,xe=50331648,Zt=!0,y.selectionForeground&&(fe=50331648,se=y.selectionForeground.rgba>>8&16777215,Ht=y.selectionForeground)),Zt&&Z.push("xterm-decoration-top");let ai;switch(xe){case 16777216:case 33554432:ai=y.ansi[pe],Z.push(`xterm-bg-${pe}`);break;case 50331648:ai=bt.toColor(pe>>16,pe>>8&255,pe&255),this._addStyle(k,`background-color:#${kv((pe>>>0).toString(16),"0",6)}`);break;case 0:default:Ye?(ai=y.foreground,Z.push("xterm-bg-257")):ai=y.background}switch(De||W.isDim()&&(De=it.multiplyOpacity(ai,.5)),fe){case 16777216:case 33554432:W.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(k,ai,y.ansi[se],W,De,void 0)||Z.push(`xterm-fg-${se}`);break;case 50331648:let He=bt.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(k,ai,He,W,De,Ht)||this._addStyle(k,`color:#${kv(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ai,y.foreground,W,De,Ht)||Ye&&Z.push("xterm-fg-257")}Z.length&&(k.className=Z.join(" "),Z.length=0),!E&&!z&&!K&&M?D++:k.textContent=T,ie!==this.defaultSpacing&&(k.style.letterSpacing=`${ie}px`),_.push(k),F=I}return k&&D&&(k.textContent=T),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||pC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=it.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};$f=ht([de(1,oS),de(2,li),de(3,zn),de(4,Xr),de(5,ga),de(6,Ks)],$f);function kv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},gC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function vC(){return new gC}var Jh="xterm-dom-renderer-owner-",Fi="xterm-rows",Vo="xterm-fg-",Ev="xterm-bg-",Vl="xterm-focus",Ko="xterm-selection",yC=1,Gf=class extends Ae{constructor(e,t,n,s,a,o,c,f,p,h,g,_,S,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=S,this._themeService=y,this._terminalClass=yC++,this._rowElements=[],this._selectionRenderModel=vC(),this.onRequestRedraw=this._register(new ce).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fi),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(Ko),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=mC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance($f,document),this._element.classList.add(Jh+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(rt(()=>{this._element.classList.remove(Jh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new _C(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Fi} 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} .${Fi} { 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} .${Fi} .xterm-dim { color: ${it.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 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} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ko} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ko} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ko} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Vo}${o} { color: ${c.css}; }${this._terminalSelector} .${Vo}${o}.xterm-dim { color: ${it.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Ev}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Vo}257 { color: ${it.opaque(e.background).css}; }${this._terminalSelector} .${Vo}257.xterm-dim { color: ${it.multiplyOpacity(it.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ev}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 n=this._rowElements.length;n<=t;n++){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(Vl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.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,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-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 n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Jh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let b=y+f.ydisp,k=this._rowElements[y],D=f.lines.get(b);if(!k||!D)break;k.replaceChildren(...this._rowFactory.createRow(D,b,b===p,_,S,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Gf=ht([de(7,xd),de(8,yu),de(9,li),de(10,si),de(11,Xr),de(12,zn),de(13,Ks)],Gf);var Zf=class extends Ae{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ce),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new bC(this._optionsService))}catch{this._measureStrategy=this._register(new SC(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())}};Zf=ht([de(2,li)],Zf);var TS=class extends Ae{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)}},SC=class extends TS{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},bC=class extends TS{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}},xC=class extends Ae{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new wC(this._window)),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ce),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Yt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(be(this._textarea,"focus",()=>this._isFocused=!0)),this._register(be(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}},wC=class extends Ae{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ys),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=be(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)}},CC=class extends Ae{constructor(){super(),this.linkProviders=[],this._register(rt(()=>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 Rd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function kC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Rd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var Qf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return kC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Rd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Qf=ht([de(0,On),de(1,yu)],Qf);var EC=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,n){this._rowCount=n,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=[]}},AS={};Ox(AS,{getSafariVersion:()=>AC,isChromeOS:()=>BS,isFirefox:()=>DS,isIpad:()=>DC,isIphone:()=>RC,isLegacyEdge:()=>TC,isLinux:()=>Md,isMac:()=>hu,isNode:()=>Su,isSafari:()=>RS,isWindows:()=>MS});var Su=typeof process<"u"&&"title"in process,va=Su?"node":navigator.userAgent,ya=Su?"node":navigator.platform,DS=va.includes("Firefox"),TC=va.includes("Edge"),RS=/^((?!chrome|android).)*safari/i.test(va);function AC(){if(!RS)return 0;let e=va.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var hu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ya),DC=ya==="iPad",RC=ya==="iPhone",MS=["Windows","Win16","Win32","WinCE"].includes(ya),Md=ya.indexOf("Linux")>=0,BS=/\bCrOS\b/.test(va),LS=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){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()}},MC=class extends LS{_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())}}},BC=class extends LS{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fu=!Su&&"requestIdleCallback"in window?BC:MC,LC=class{constructor(){this._queue=new fu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Jf=class extends Ae{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Ys),this._pausedResizeTask=new LC,this._observerDisposable=this._register(new Ys),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 ce),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ce),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ce),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new EC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new NC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.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(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=rt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),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 n;return(n=this._renderer.value)==null?void 0:n.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,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Jf=ht([de(2,li),de(3,yu),de(4,Xr),de(5,ga),de(6,si),de(7,zn),de(8,Ks)],Jf);var NC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function zC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return jC(a,o,e,t,n,s)+bu(o,t,n,s)+UC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ha(Math.abs(a-e),ca(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=HC(o>t?e:a,n)+(f-1)*n.cols+1+OC(o>t?a:e);return ha(p,ca(c,s))}function OC(e,t){return e-1}function HC(e,t){return t.cols-e}function jC(e,t,n,s,a,o){return bu(t,s,a,o).length===0?"":ha(zS(e,t,e,t-Vr(t,a),!1,a).length,ca("D",o))}function bu(e,t,n,s){let a=e-Vr(e,n),o=t-Vr(t,n),c=Math.abs(a-o)-PC(e,t,n);return ha(c,ca(NS(e,t),s))}function UC(e,t,n,s,a,o){let c;bu(t,s,a,o).length>0?c=s-Vr(s,a):c=t;let f=s,p=IC(e,t,n,s,a,o);return ha(zS(e,c,n,f,p==="C",a).length,ca(p,o))}function PC(e,t,n){var c;let s=0,a=e-Vr(e,n),o=t-Vr(t,n);for(let f=0;f=0&&e0?c=s-Vr(s,a):c=t,e=n&&ct?"A":"B"}function zS(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function ca(e,t){let n=t?"O":"[";return re.ESC+n+e}function ha(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._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 Tv(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 ef=50,qC=15,WC=50,YC=500,VC=" ",KC=new RegExp(VC,"g"),ed=class extends Ae{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Vi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ce),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ce),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new FC(this._bufferService),this._activeSelectionMode=0,this._register(rt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(KC," ")).join(MS?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Md&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Tv(n,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=Rd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-ef),ef),t/=ef,t/Math.abs(t)+Math.round(t*(qC-1)))}shouldForceSelection(e){return hu?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(),WC)}_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&&!(hu&&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]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]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&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,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),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,S=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=X-1,p+=X-1);D>0&&f>0&&!this._isCharWordSeparator(o.loadCell(D-1,this._workCell));){o.loadCell(D-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,D--):U>1&&(S+=U-1,f-=U-1),f--,D--}for(;T1&&(y+=U-1,p+=U-1),p++,T++}}p++;let b=f+h-g+S,k=Math.min(this._bufferService.cols,p-f+g+_-S-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&b===0&&o.getCodePoint(0)!==32){let D=a.lines.get(e[1]-1);if(D&&o.isWrapped&&D.getCodePoint(this._bufferService.cols-1)!==32){let T=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(T){let X=this._bufferService.cols-T.start;b-=X,k+=X}}}if(s&&b+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let D=a.lines.get(e[1]+1);if(D!=null&&D.isWrapped&&D.getCodePoint(0)!==32){let T=this._getWordAt([0,e[1]+1],!1,!1,!0);T&&(k+=T.length)}}return{start:b,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Tv(n,this._bufferService.cols)}};ed=ht([de(3,si),de(4,Xr),de(5,wd),de(6,li),de(7,On),de(8,zn)],ed);var Av=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Dv=class{constructor(){this._color=new Av,this._css=new Av}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ct=Object.freeze((()=>{let e=[lt.toColor("#2e3436"),lt.toColor("#cc0000"),lt.toColor("#4e9a06"),lt.toColor("#c4a000"),lt.toColor("#3465a4"),lt.toColor("#75507b"),lt.toColor("#06989a"),lt.toColor("#d3d7cf"),lt.toColor("#555753"),lt.toColor("#ef2929"),lt.toColor("#8ae234"),lt.toColor("#fce94f"),lt.toColor("#729fcf"),lt.toColor("#ad7fa8"),lt.toColor("#34e2e2"),lt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:bt.toCss(s,a,o),rgba:bt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:bt.toCss(s,s,s),rgba:bt.toRgba(s,s,s)})}return e})()),Ir=lt.toColor("#ffffff"),ia=lt.toColor("#000000"),Rv=lt.toColor("#ffffff"),Mv=ia,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},XC=Ir,td=class extends Ae{constructor(e){super(),this._optionsService=e,this._contrastCache=new Dv,this._halfContrastCache=new Dv,this._onChangeColors=this._register(new ce),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ir,background:ia,cursor:Rv,cursorAccent:Mv,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:it.blend(ia,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:it.blend(ia,Kl),scrollbarSliderBackground:it.opacity(Ir,.2),scrollbarSliderHoverBackground:it.opacity(Ir,.4),scrollbarSliderActiveBackground:it.opacity(Ir,.5),overviewRulerBorder:Ir,ansi:Ct.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=$e(e.foreground,Ir),t.background=$e(e.background,ia),t.cursor=it.blend(t.background,$e(e.cursor,Rv)),t.cursorAccent=it.blend(t.background,$e(e.cursorAccent,Mv)),t.selectionBackgroundTransparent=$e(e.selectionBackground,Kl),t.selectionBackgroundOpaque=it.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=$e(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=it.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?$e(e.selectionForeground,Cv):void 0,t.selectionForeground===Cv&&(t.selectionForeground=void 0),it.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=it.opacity(t.selectionBackgroundTransparent,.3)),it.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=it.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=$e(e.scrollbarSliderBackground,it.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=$e(e.scrollbarSliderHoverBackground,it.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=$e(e.scrollbarSliderActiveBackground,it.opacity(t.foreground,.5)),t.overviewRulerBorder=$e(e.overviewRulerBorder,XC),t.ansi=Ct.slice(),t.ansi[0]=$e(e.black,Ct[0]),t.ansi[1]=$e(e.red,Ct[1]),t.ansi[2]=$e(e.green,Ct[2]),t.ansi[3]=$e(e.yellow,Ct[3]),t.ansi[4]=$e(e.blue,Ct[4]),t.ansi[5]=$e(e.magenta,Ct[5]),t.ansi[6]=$e(e.cyan,Ct[6]),t.ansi[7]=$e(e.white,Ct[7]),t.ansi[8]=$e(e.brightBlack,Ct[8]),t.ansi[9]=$e(e.brightRed,Ct[9]),t.ansi[10]=$e(e.brightGreen,Ct[10]),t.ansi[11]=$e(e.brightYellow,Ct[11]),t.ansi[12]=$e(e.brightBlue,Ct[12]),t.ansi[13]=$e(e.brightMagenta,Ct[13]),t.ansi[14]=$e(e.brightCyan,Ct[14]),t.ansi[15]=$e(e.brightWhite,Ct[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){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=n.length>0?n[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)}},ZC={trace:0,debug:1,info:2,warn:3,error:4,off:5},QC="xterm.js: ",id=class extends Ae{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=ZC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-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>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Te+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Te+0]=t|2097152|n[2]<<22):this._data[t*Te+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Te+0]>>22}hasWidth(t){return this._data[t*Te+0]&12582912}getFg(t){return this._data[t*Te+1]}getBg(t){return this._data[t*Te+2]}hasContent(t){return this._data[t*Te+0]&4194303}getCodePoint(t){let n=this._data[t*Te+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Te+0]&2097152}getString(t){let n=this._data[t*Te+0];return n&2097152?this._combined[t]:n&2097151?dr(n&2097151):""}isProtected(t){return this._data[t*Te+2]&536870912}loadCell(t,n){return Xo=t*Te,n.content=this._data[Xo+0],n.fg=this._data[Xo+1],n.bg=this._data[Xo+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Te+0]=n.content,this._data[t*Te+1]=n.fg,this._data[t*Te+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Te+0]=n|s<<22,this._data[t*Te+1]=a.fg,this._data[t*Te+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Te+0];a&2097152?this._combined[t]+=dr(n):a&2097151?(this._combined[t]=dr(a&2097151)+dr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Te+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.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&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*tf=0;--t)if(this._data[t*Te+0]&4194303)return t+(this._data[t*Te+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Te+0]&4194303||this._data[t*Te+2]&50331648)return t+(this._data[t*Te+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function JC(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(D>_||g[D].getTrimmedLength()===0);D--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function e2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cfa(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function fa(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var HS=class jS{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=jS._nextId++,this._onDispose=this.register(new ce),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Yr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};HS._nextId=1;var n2=HS,Et={},Fr=Et.B;Et[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Et.A={"#":"£"};Et.B=void 0;Et[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Et.C=Et[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Et.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Et.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Et.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Et.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Et.E=Et[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Et.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Et.H=Et[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Et["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Lv=4294967295,Nv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=St.clone(),this.savedCharset=Fr,this.markers=[],this._nullCell=Vi.fromCharData([0,tS,1,0]),this._whitespaceCell=Vi.fromCharData([0,mr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Bv(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 ou),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 ou),this._whitespaceCell}getBlankLine(e,t){return new na(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&&eLv?Lv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=St);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 Bv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(St),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new na(e,n)));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(a0&&(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.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._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=JC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(St),n);if(s.length>0){let a=e2(this.lines,s);t2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(St),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let U=this.ybase+this.y;if(U>=c&&U0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let b=g.length-1,k=g[b];k===0&&(b--,k=g[b]);let D=p.length-_-1,T=h;for(;D>=0;){let U=Math.min(T,k);if(p[b]===void 0)break;if(p[b].copyCellsFrom(p[D],T-U,k-U,U,!0),k-=U,k===0&&(b--,k=g[b]),T-=U,T===0){D--;let te=Math.max(D,0);T=fa(p,te,this._cols)}}for(let U=0;U0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+S){for(let D=_.newLines.length-1;D>=0;D--)this.lines.set(k--,_.newLines[D]);k++,c.push({index:h+1,amount:_.newLines.length}),S+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let b=Math.max(0,p+o-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);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?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},r2=class extends Ae{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ce),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 Nv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Nv(!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)}},US=2,PS=1,nd=class extends Ae{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,US),this.rows=Math.max(e.rawOptions.rows||0,PS),this.buffers=this._register(new r2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=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:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};nd=ht([de(0,li)],nd);var Us={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:hu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},s2=["normal","bold","100","200","300","400","500","600","700","800","900"],l2=class extends Ae{constructor(e){super(),this._onOptionChange=this._register(new ce),this.onOptionChange=this._onOptionChange.event;let t={...Us};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(rt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Us[e]),!a2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Us[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=s2.includes(t)?t:Us[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 a2(e){return e==="block"||e==="underline"||e==="bar"}function ra(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&ra(e[s],t-1);return n}var zv=Object.freeze({insertMode:!1}),Ov=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),rd=class extends Ae{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ce),this.onData=this._onData.event,this._onUserInput=this._register(new ce),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ce),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ra(zv),this.decPrivateModes=ra(Ov)}reset(){this.modes=ra(zv),this.decPrivateModes=ra(Ov)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(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))}};rd=ht([de(0,si),de(1,lS),de(2,li)],rd);var Hv={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 nf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var rf=String.fromCharCode,jv={DEFAULT:e=>{let t=[nf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${rf(t[0])}${rf(t[1])}${rf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.x};${e.y}${t}`}},sd=class extends Ae{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ce),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Hv))this.addProtocol(s,Hv[s]);for(let s of Object.keys(jv))this.addEncoding(s,jv[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,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,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,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};sd=ht([de(0,si),de(1,Xr),de(2,li)],sd);var sf=[[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]],o2=[[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]],kt;function u2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return qr.createPropertyValue(0,n,s)}},qr=class su{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ce,this.onChange=this._onChange.event;let t=new c2;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,n,s=!1){return(t&16777215)<<3|(n&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 n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=su.extractWidth(f);su.extractShouldJoin(f)&&(p-=su.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},h2=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 Uv(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),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Xl=2147483647,f2=256,IS=class ld{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>f2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new ld;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&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>Xl?Xl: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>Xl?Xl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,Xl):t}},$l=[],d2=class{constructor(){this._state=0,this._active=$l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=$l}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=$l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||$l,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=$l,this._id=-1,this._state=0}}},Di=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Gl=[],p2=class{constructor(){this._handlers=Object.create(null),this._active=Gl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=Gl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Gl,this._ident=0}},sa=new IS;sa.addParam(0);var Pv=class{constructor(e){this._handler=e,this._data="",this._params=sa,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():sa,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=sa,this._data="",this._hitLimit=!1,n));return this._params=sa,this._data="",this._hitLimit=!1,t}},m2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(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(n(128,144),c,3,0),e.addMany(n(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(n(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(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(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(Wi,0,2,0),e.add(Wi,8,5,8),e.add(Wi,6,0,6),e.add(Wi,11,0,11),e.add(Wi,13,13,13),e})(),g2=class extends Ae{constructor(e=_2){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 IS,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},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(rt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new d2),this._dcsParser=this._register(new p2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=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 n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];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 n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];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,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){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(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[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,n),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,n),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 f=o;f>4){case 2:for(let S=f+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s=t||(s=e[S])<32||s>126&&s=t||(s=e[S])<32||s>126&&s=t||(s=e[S])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<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(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),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 S=f+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s=t||(s=e[S])<32||s>127&&s>4:o>>8}return s}}function lf(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function S2(e,t=16){let[n,s,a]=e;return`rgb:${lf(n,t)}/${lf(s,t)}/${lf(a,t)}`}var b2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},hr=131072,Fv=10;function qv(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 Wv=5e3,Yv=0,x2=class extends Ae{constructor(e,t,n,s,a,o,c,f,p=new g2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Ix,this._utf8Decoder=new Fx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=St.clone(),this._eraseAttrDataInternal=St.clone(),this._onRequestBell=this._register(new ce),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ce),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ce),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ce),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ce),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ce),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ce),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ce),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ce),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 ad(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(re.BEL,()=>this.bell()),this._parser.setExecuteHandler(re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(re.BS,()=>this.backspace()),this._parser.setExecuteHandler(re.HT,()=>this.tab()),this._parser.setExecuteHandler(re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nu.IND,()=>this.index()),this._parser.setExecuteHandler(nu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Di(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Di(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Di(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Di(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Di(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Di(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Di(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Di(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Di(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Di(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Di(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Di(h=>this.restoreCursorColor(h))),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 h in Et)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Pv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Wv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Wv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>hr&&(o=this._parseStack.position+hr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthhr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let S=this._parser.precedingJoinState;for(let y=t;yf){if(p){let T=_,X=this._activeBuffer.x-D;for(this._activeBuffer.x=D,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),D>0&&_ instanceof na&&_.copyCellsFrom(T,X,0,D,!1);X=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-D,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=S,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>qv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Pv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Di(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,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let 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.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(re.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,S=(k,D)=>(c.triggerDataEvent(`${re.ESC}[${t?"":"?"}${k};${D}$y`),!0),y=k=>k?1:2,b=e.params[0];return t?b===2?S(b,4):b===4?S(b,y(c.modes.insertMode)):b===12?S(b,3):b===20?S(b,y(_.convertEol)):S(b,0):b===1?S(b,y(s.applicationCursorKeys)):b===3?S(b,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):b===6?S(b,y(s.origin)):b===7?S(b,y(s.wraparound)):b===8?S(b,3):b===9?S(b,y(a==="X10")):b===12?S(b,y(_.cursorBlink)):b===25?S(b,y(!c.isCursorHidden)):b===45?S(b,y(s.reverseWraparound)):b===66?S(b,y(s.applicationKeypad)):b===67?S(b,4):b===1e3?S(b,y(a==="VT200")):b===1002?S(b,y(a==="DRAG")):b===1003?S(b,y(a==="ANY")):b===1004?S(b,y(s.sendFocus)):b===1005?S(b,4):b===1006?S(b,y(o==="SGR")):b===1015?S(b,4):b===1016?S(b,y(o==="SGR_PIXELS")):b===1048?S(b,1):b===47||b===1047||b===1049?S(b,y(h===g)):b===2004?S(b,y(s.bracketedPasteMode)):b===2026?S(b,y(s.synchronizedOutput)):S(b,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=_a.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){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),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=St.fg,e.bg=St.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=St.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=St.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=St.fg&16777215,s.bg&=-67108864,s.bg|=St.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${re.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[?${t};${n}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=St.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!qv(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(`${re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Fv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Fv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Vv(o))if(a==="?")t.push({type:0,index:o});else{let c=Iv(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 n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[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 n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=Iv(n[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=[],n=e.split(";");for(let s=0;s=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=St.clone(),this._eraseAttrDataInternal=St.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 Vi;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._coreService.triggerDataEvent(`${re.ESC}${c}${re.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(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)}},ad=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Yv=e,e=t,t=Yv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ad=ht([de(0,si)],ad);function Vv(e){return 0<=e&&e<256}var w2=5e7,Kv=12,C2=50,k2=class extends Ae{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 ce),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>w2)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 n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=Kv?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Kv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>C2&&(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()}},od=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 f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),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(n),data:n,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 n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,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 n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};od=ht([de(0,si)],od);var Xv=!1,E2=class extends Ae{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ys),this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onData=this._register(new ce),this.onData=this._onData.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ce),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ce),this._instantiationService=new GC,this.optionsService=this._register(new l2(e)),this._instantiationService.setService(li,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(nd)),this._instantiationService.setService(si,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(id)),this._instantiationService.setService(lS,this._logService),this.coreService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(Xr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(sS,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qr)),this._instantiationService.setService(Vx,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h2),this._instantiationService.setService(Yx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(od),this._instantiationService.setService(aS,this._oscLinkService),this._inputHandler=this._register(new x2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Yt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Yt.forward(this._bufferService.onResize,this._onResize)),this._register(Yt.forward(this.coreService.onData,this._onData)),this._register(Yt.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 k2((t,n)=>this._inputHandler.parse(t,n))),this._register(Yt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ce),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&&!Xv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Xv=!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,US),t=Math.max(t,PS),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(Uv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Uv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rt(()=>{for(let t of e)t.dispose()})}}},T2={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 A2(e,t,n,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=re.ESC+"OA":a.key=re.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=re.ESC+"OD":a.key=re.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=re.ESC+"OC":a.key=re.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=re.ESC+"OB":a.key=re.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":re.DEL,e.altKey&&(a.key=re.ESC+a.key);break;case 9:if(e.shiftKey){a.key=re.ESC+"[Z";break}a.key=re.HT,a.cancel=!0;break;case 13:a.key=e.altKey?re.ESC+re.CR:re.CR,a.cancel=!0;break;case 27:a.key=re.ESC,e.altKey&&(a.key=re.ESC+re.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"D":t?a.key=re.ESC+"OD":a.key=re.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"C":t?a.key=re.ESC+"OC":a.key=re.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"A":t?a.key=re.ESC+"OA":a.key=re.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"B":t?a.key=re.ESC+"OB":a.key=re.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=re.ESC+"[2~");break;case 46:o?a.key=re.ESC+"[3;"+(o+1)+"~":a.key=re.ESC+"[3~";break;case 36:o?a.key=re.ESC+"[1;"+(o+1)+"H":t?a.key=re.ESC+"OH":a.key=re.ESC+"[H";break;case 35:o?a.key=re.ESC+"[1;"+(o+1)+"F":t?a.key=re.ESC+"OF":a.key=re.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=re.ESC+"[5;"+(o+1)+"~":a.key=re.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=re.ESC+"[6;"+(o+1)+"~":a.key=re.ESC+"[6~";break;case 112:o?a.key=re.ESC+"[1;"+(o+1)+"P":a.key=re.ESC+"OP";break;case 113:o?a.key=re.ESC+"[1;"+(o+1)+"Q":a.key=re.ESC+"OQ";break;case 114:o?a.key=re.ESC+"[1;"+(o+1)+"R":a.key=re.ESC+"OR";break;case 115:o?a.key=re.ESC+"[1;"+(o+1)+"S":a.key=re.ESC+"OS";break;case 116:o?a.key=re.ESC+"[15;"+(o+1)+"~":a.key=re.ESC+"[15~";break;case 117:o?a.key=re.ESC+"[17;"+(o+1)+"~":a.key=re.ESC+"[17~";break;case 118:o?a.key=re.ESC+"[18;"+(o+1)+"~":a.key=re.ESC+"[18~";break;case 119:o?a.key=re.ESC+"[19;"+(o+1)+"~":a.key=re.ESC+"[19~";break;case 120:o?a.key=re.ESC+"[20;"+(o+1)+"~":a.key=re.ESC+"[20~";break;case 121:o?a.key=re.ESC+"[21;"+(o+1)+"~":a.key=re.ESC+"[21~";break;case 122:o?a.key=re.ESC+"[23;"+(o+1)+"~":a.key=re.ESC+"[23~";break;case 123:o?a.key=re.ESC+"[24;"+(o+1)+"~":a.key=re.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=re.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=re.DEL:e.keyCode===219?a.key=re.ESC:e.keyCode===220?a.key=re.FS:e.keyCode===221&&(a.key=re.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=T2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=re.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=re.ESC+h}else if(e.keyCode===32)a.key=re.ESC+(e.ctrlKey?re.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=re.ESC+p,a.cancel=!0}}else n&&!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=re.US),e.key==="@"&&(a.key=re.NUL));break}return a}var pt=0,D2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fu,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,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];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||(pt=this._search(t),pt===-1)||this._getKey(this._array[pt])!==t)return!1;do if(this._array[pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pt),!0;while(++pta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pt=this._search(e),!(pt<0||pt>=this._array.length)&&this._getKey(this._array[pt])===e))do yield this._array[pt];while(++pt=this._array.length)&&this._getKey(this._array[pt])===e))do t(this._array[pt]);while(++pt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},af=0,$v=0,R2=class extends Ae{constructor(){super(),this._decorations=new D2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ce),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ce),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new M2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let 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{af=a.options.x??0,$v=af+(a.options.width??1),e>=af&&e<$v&&(!n||(a.options.layer??"bottom")===n)&&s(a)})}},M2=class extends _r{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ce),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ce),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=lt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=lt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},B2=1e3,L2=class{constructor(e,t=B2){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?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)}},Gv=20,du=class extends Ae{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,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;othis._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 L2(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(` -`))),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(be(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(rt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Gv+1&&(this._liveRegion.textContent+=Af.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.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 f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let S=this._rowColumns.get(g);if(!S)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);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;te;)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{var o;Yr(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(be(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(be(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(be(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(be(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&N2(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,Yr(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 n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{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)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.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,n){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(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){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(n,t.text)}_linkAtPosition(e,t){let n=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 n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.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,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};ud=ht([de(1,wd),de(2,On),de(3,si),de(4,uS)],ud);function N2(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 z2=class extends E2{constructor(e={}){super(e),this._linkifier=this._register(new Ys),this.browser=AS,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ys),this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ce),this.onKey=this._onKey.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ce),this.onBell=this._onBell.event,this._onFocus=this._register(new ce),this._onBlur=this._register(new ce),this._onA11yCharEmitter=this._register(new ce),this._onA11yTabEmitter=this._register(new ce),this._onWillOpen=this._register(new ce),this._setup(),this._decorationService=this._instantiationService.createInstance(R2),this._instantiationService.setService(ga,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(CC),this._instantiationService.setService(uS,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Rf)),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(Yt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Yt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Yt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Yt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(rt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=it.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${re.ESC}]${s};${S2(a)}${ES.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=bt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=bt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.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(re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"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(be(this.element,"copy",t=>{this.hasSelection()&&Ux(t,this._selectionService)}));let e=t=>Px(t,this.textarea,this.coreService,this.optionsService);this._register(be(this.textarea,"paste",e)),this._register(be(this.element,"paste",e)),DS?this._register(be(this.element,"mousedown",t=>{t.button===2&&lv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(be(this.element,"contextmenu",t=>{lv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Md&&this._register(be(this.element,"auxclick",t=>{t.button===1&&eS(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(be(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(be(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(be(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(be(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(be(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(be(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(be(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(be(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Tf.get()),BS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zn,this._coreBrowserService),this._register(be(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(be(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Zf,this._document,this._helperContainer),this._instantiationService.setService(yu,this._charSizeService),this._themeService=this._instantiationService.createInstance(td),this._instantiationService.setService(Ks,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(cu),this._instantiationService.setService(oS,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Jf,this.rows,this.screenElement)),this._instantiationService.setService(On,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(Xf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Qf),this._instantiationService.setService(wd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(ud,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(Vf,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(ed,this.element,this.screenElement,s)),this._instantiationService.setService(Xx,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(Yt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Kf,this.screenElement)),this._register(be(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,S,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let b=o.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(o,(S=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:S.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=b<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(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(be(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(be(t,"wheel",o=>{var c,f,p,h,g;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,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=re.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 n;(n=this._renderService)==null||n.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){Jy(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=A2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===re.ETX||n.key===re.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(O2(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 n;(n=this._charSizeService)==null||n.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=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Vi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Zv=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 j2(t)}getNullCell(){return new Vi}},U2=class extends Ae{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ce),this.onBufferChange=this._onBufferChange.event,this._normal=new Zv(this._core.buffers.normal,"normal"),this._alternate=new Zv(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)}},P2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,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)}},I2=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}},F2=["cols","rows"],sn=0,q2=class extends Ae{constructor(e){super(),this._core=this._register(new z2(e)),this._addonManager=this._register(new H2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(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:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(F2.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 P2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new I2(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 U2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,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 Tf.get()},set promptLabel(e){Tf.set(e)},get tooMuchOutput(){return Af.get()},set tooMuchOutput(e){Af.set(e)}}}_verifyIntegers(...e){for(sn of e)if(sn===1/0||isNaN(sn)||sn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(sn of e)if(sn&&(sn===1/0||isNaN(sn)||sn%1!==0||sn<0))throw new Error("This API only accepts positive integers")}};/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var W2=2,Y2=1,V2=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,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.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"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(W2,Math.floor(g/e.css.cell.width)),rows:Math.max(Y2,Math.floor(h/e.css.cell.height))}}};/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var Lt=0,Nt=0,zt=0,ct=0,Xt;(e=>{function t(a,o,c,f){return f!==void 0?`#${jr(a)}${jr(o)}${jr(c)}${jr(f)}`:`#${jr(a)}${jr(o)}${jr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(Xt||(Xt={}));var K2;(e=>{function t(p,h){if(ct=(h.rgba&255)/255,ct===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,S=h.rgba>>8&255,y=p.rgba>>24&255,b=p.rgba>>16&255,k=p.rgba>>8&255;Lt=y+Math.round((g-y)*ct),Nt=b+Math.round((_-b)*ct),zt=k+Math.round((S-k)*ct);let D=Xt.toCss(Lt,Nt,zt),T=Xt.toRgba(Lt,Nt,zt);return{css:D,rgba:T}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=lu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return Xt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Lt,Nt,zt]=lu.toChannels(h),{css:Xt.toCss(Lt,Nt,zt),rgba:h}}e.opaque=a;function o(p,h){return ct=Math.round(h*255),[Lt,Nt,zt]=lu.toChannels(p.rgba),{css:Xt.toCss(Lt,Nt,zt,ct),rgba:Xt.toRgba(Lt,Nt,zt,ct)}}e.opacity=o;function c(p,h){return ct=p.rgba&255,o(p,ct*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(K2||(K2={}));var qt;(e=>{let t,n;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",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Lt=parseInt(a.slice(1,2).repeat(2),16),Nt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),Xt.toColor(Lt,Nt,zt);case 5:return Lt=parseInt(a.slice(1,2).repeat(2),16),Nt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),ct=parseInt(a.slice(4,5).repeat(2),16),Xt.toColor(Lt,Nt,zt,ct);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 Lt=parseInt(o[1]),Nt=parseInt(o[2]),zt=parseInt(o[3]),ct=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Xt.toColor(Lt,Nt,zt,ct);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Lt,Nt,zt,ct]=t.getImageData(0,0,1,1).data,ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Xt.toRgba(Lt,Nt,zt,ct),css:a}}e.toColor=s})(qt||(qt={}));var ni;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ni||(ni={}));var lu;(e=>{function t(c,f){if(ct=(f&255)/255,ct===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,S=c>>16&255,y=c>>8&255;return Lt=_+Math.round((p-_)*ct),Nt=S+Math.round((h-S)*ct),zt=y+Math.round((g-y)*ct),Xt.toRgba(Lt,Nt,zt)}e.blend=t;function n(c,f,p){let h=ni.relativeLuminance(c>>8),g=ni.relativeLuminance(f>>8);if(Bn(h,g)>8));if(b>8));return b>D?y:k}return y}let _=a(c,f,p),S=Bn(h,ni.relativeLuminance(_>>8));if(S>8));return S>b?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,S=f>>24&255,y=f>>16&255,b=f>>8&255,k=Bn(ni.relativeLuminance2(S,y,b),ni.relativeLuminance2(h,g,_));for(;k0||y>0||b>0);)S-=Math.max(0,Math.ceil(S*.1)),y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),k=Bn(ni.relativeLuminance2(S,y,b),ni.relativeLuminance2(h,g,_));return(S<<24|y<<16|b<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,S=f>>24&255,y=f>>16&255,b=f>>8&255,k=Bn(ni.relativeLuminance2(S,y,b),ni.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(lu||(lu={}));function jr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Bn(e,t){return e{let e=[qt.toColor("#2e3436"),qt.toColor("#cc0000"),qt.toColor("#4e9a06"),qt.toColor("#c4a000"),qt.toColor("#3465a4"),qt.toColor("#75507b"),qt.toColor("#06989a"),qt.toColor("#d3d7cf"),qt.toColor("#555753"),qt.toColor("#ef2929"),qt.toColor("#8ae234"),qt.toColor("#fce94f"),qt.toColor("#729fcf"),qt.toColor("#ad7fa8"),qt.toColor("#34e2e2"),qt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:Xt.toCss(s,a,o),rgba:Xt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Xt.toCss(s,s,s),rgba:Xt.toRgba(s,s,s)})}return e})());function Qv(e,t,n){return Math.max(t,Math.min(e,n))}function $2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var FS=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,S=h===e.end.y?p:g.length;for(let y=_;y0&&!Ln(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";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)n=`\r -`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Ln(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Ln(c,p)&&Ln(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\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++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!qS(e,t),a=!Ln(e,t),o=!WS(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Ln(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Ln(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Ln(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=n,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 n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}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&&(n+=`\x1B[${a.join(";")}m`),n}},Z2=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:Qv(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new G2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new Q2(n,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=n.length,h=t.scrollback,g=h===void 0?p:Qv(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.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="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.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 n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}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(){}},Q2=class extends FS{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=X2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.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+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!qS(e,t),a=!Ln(e,t),o=!WS(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=$2(e.getChars())}_serializeString(){return this._htmlContent}};const J2={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"},ek="plotlink-terminal",tk=1,gr="scrollback",Jv=10*1024*1024;function Bd(){return new Promise((e,t)=>{const n=indexedDB.open(ek,tk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(gr)||s.createObjectStore(gr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function $o(e,t){const n=t.length>Jv?t.slice(-Jv):t,s=await Bd();return new Promise((a,o)=>{const c=s.transaction(gr,"readwrite");c.objectStore(gr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function ik(e){const t=await Bd();return new Promise((n,s)=>{const o=t.transaction(gr,"readonly").objectStore(gr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function nk(e){const t=await Bd();return new Promise((n,s)=>{const a=t.transaction(gr,"readwrite");a.objectStore(gr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const ti=new Map;function rk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a}){const o=le.useRef(null),c=le.useRef(n),[f,p]=le.useState([]),[h,g]=le.useState(new Set),[_,S]=le.useState(null),y=le.useRef(()=>{});le.useEffect(()=>{c.current=n},[n]);const b=le.useCallback(H=>{var ie;const{width:P}=H.container.getBoundingClientRect();if(!(P<50))try{H.fit.fit(),((ie=H.ws)==null?void 0:ie.readyState)===WebSocket.OPEN&&H.ws.send(JSON.stringify({type:"resize",cols:H.term.cols,rows:H.term.rows}))}catch{}},[]),k=le.useCallback(H=>{for(const[P,ie]of ti)ie.container.style.display=P===H?"block":"none";if(H){const P=ti.get(H);P&&setTimeout(()=>b(P),50)}},[b]),D=le.useCallback((H,P,ie)=>{const L=window.location.protocol==="https:"?"wss:":"ws:",Z=new WebSocket(`${L}//${window.location.host}/ws/terminal?story=${encodeURIComponent(H)}&token=${e}&resume=${ie}`);Z.onopen=()=>{P.connected=!0,P._retried=!1,g(j=>{const F=new Set(j);return F.delete(H),F}),Z.send(JSON.stringify({type:"resize",cols:P.term.cols,rows:P.term.rows}))},Z.onmessage=j=>{P.term.write(j.data)},Z.onclose=j=>{if(P.connected=!1,P.ws===Z){P.ws=null;try{const F=P.serialize.serialize();$o(H,F).catch(()=>{})}catch{}if(j.code===4e3&&!P._retried){P._retried=!0,P.term.write(`\r -\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r -`),y.current(H,P,!1);return}g(F=>new Set(F).add(H))}},P.term.onData(j=>{Z.readyState===WebSocket.OPEN&&Z.send(j)}),P.ws=Z},[e]);le.useEffect(()=>{y.current=D},[D]);const T=le.useCallback(async(H,P)=>{if(!o.current||ti.has(H))return;const{resume:ie=!1,autoConnect:L=!0}=P??{},Z=document.createElement("div");Z.style.width="100%",Z.style.height="100%",Z.style.display="none",Z.style.paddingLeft="10px",Z.style.boxSizing="border-box",o.current.appendChild(Z);const j=new q2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:J2,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),F=new V2,$=new Z2;j.loadAddon(F),j.loadAddon($),j.open(Z);const z={term:j,fit:F,serialize:$,ws:null,container:Z,observer:null,connected:!1},M=new ResizeObserver(()=>{var W;const{width:I}=Z.getBoundingClientRect();if(!(I<50))try{F.fit(),((W=z.ws)==null?void 0:W.readyState)===WebSocket.OPEN&&z.ws.send(JSON.stringify({type:"resize",cols:j.cols,rows:j.rows}))}catch{}});M.observe(Z),z.observer=M,ti.set(H,z),p(I=>[...I,H]);try{const I=await ik(H);I&&j.write(I)}catch{}L?D(H,z,ie):g(I=>new Set(I).add(H)),setTimeout(()=>b(z),50)},[D,b]),X=le.useCallback(async(H,P)=>{const ie=ti.get(H);ie&&(ie.ws&&(ie.ws.close(),ie.ws=null),P||(await c.current(`/api/terminal/${encodeURIComponent(H)}`,{method:"DELETE"}).catch(()=>{}),ie.term.clear()),D(H,ie,P))},[D]),U=le.useCallback(H=>{const P=ti.get(H);if(P){try{const ie=P.serialize.serialize();$o(H,ie).catch(()=>{})}catch{}P.observer.disconnect(),P.ws&&P.ws.close(),P.term.dispose(),P.container.remove(),ti.delete(H),p(ie=>ie.filter(L=>L!==H)),g(ie=>{const L=new Set(ie);return L.delete(H),L}),n(`/api/terminal/${encodeURIComponent(H)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(H)}},[n,a]),te=le.useCallback(H=>{var ie;const P=ti.get(H);P&&(((ie=P.ws)==null?void 0:ie.readyState)===WebSocket.OPEN&&P.ws.send(`exit -`),nk(H).catch(()=>{}),P.observer.disconnect(),P.ws&&P.ws.close(),P.term.dispose(),P.container.remove(),ti.delete(H),p(L=>L.filter(Z=>Z!==H)),g(L=>{const Z=new Set(L);return Z.delete(H),Z}),n(`/api/terminal/${encodeURIComponent(H)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(H))},[n,a]);le.useEffect(()=>{t&&(ti.has(t)?k(t):c.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(H=>H.ok?H.json():null).then(H=>{if(!ti.has(t)){const P=(H==null?void 0:H.sessionId)&&!(H!=null&&H.running);T(t,{autoConnect:!P}),k(t)}}).catch(()=>{ti.has(t)||(T(t),k(t))}))},[t,T,k]),le.useEffect(()=>{const H=setInterval(()=>{for(const[P,ie]of ti)if(ie.connected)try{const L=ie.serialize.serialize();$o(P,L).catch(()=>{})}catch{}},3e4);return()=>clearInterval(H)},[]),le.useEffect(()=>()=>{for(const[H,P]of ti){try{const ie=P.serialize.serialize();$o(H,ie).catch(()=>{})}catch{}P.observer.disconnect(),P.ws&&P.ws.close(),P.term.dispose(),P.container.remove(),c.current(`/api/terminal/${encodeURIComponent(H)}`,{method:"DELETE"}).catch(()=>{})}ti.clear()},[]);const ae=t?h.has(t):!1,O=f.length===0;return x.jsxs("div",{className:"h-full flex flex-col",children:[!O&&x.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[f.map(H=>x.jsxs("div",{onClick:()=>s==null?void 0:s(H),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${H===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[x.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${h.has(H)?"bg-amber-500":H===t?"bg-green-600":"bg-muted/50"}`}),x.jsx("span",{className:`truncate max-w-[120px] ${H.startsWith("_new_")?"italic":""}`,children:H.startsWith("_new_")?"Untitled":H}),x.jsx("button",{onClick:P=>{P.stopPropagation(),H.startsWith("_new_")?S(H):U(H)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},H)),(t==null?void 0:t.startsWith("_new_"))&&x.jsx("button",{onClick:()=>S(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 ×"})]}),x.jsxs("div",{className:"relative flex-1 min-h-0",children:[x.jsx("div",{ref:o,className:"h-full"}),O&&x.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:x.jsxs("div",{className:"text-center",children:[x.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),x.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),_&&x.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:x.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[x.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),x.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),x.jsxs("div",{className:"flex items-center justify-center gap-2",children:[x.jsx("button",{onClick:()=>S(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),x.jsx("button",{onClick:()=>{const H=_;S(null),te(H)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),ae&&t&&x.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:x.jsxs("div",{className:"text-center space-y-3",children:[x.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:()=>X(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),x.jsx("button",{onClick:()=>X(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),x.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function sk(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ak=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ok={};function ey(e,t){return(ok.jsx?ak:lk).test(e)}const uk=/[ \t\n\f\r]/g;function ck(e){return typeof e=="object"?e.type==="text"?ty(e.value):!1:ty(e)}function ty(e){return e.replace(uk,"")===""}class Sa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Sa.prototype.normal={};Sa.prototype.property={};Sa.prototype.space=void 0;function YS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Sa(n,s,t)}function cd(e){return e.toLowerCase()}class vi{constructor(t,n){this.attribute=n,this.property=t}}vi.prototype.attribute="";vi.prototype.booleanish=!1;vi.prototype.boolean=!1;vi.prototype.commaOrSpaceSeparated=!1;vi.prototype.commaSeparated=!1;vi.prototype.defined=!1;vi.prototype.mustUseProperty=!1;vi.prototype.number=!1;vi.prototype.overloadedBoolean=!1;vi.prototype.property="";vi.prototype.spaceSeparated=!1;vi.prototype.space=void 0;let hk=0;const Ee=$r(),yt=$r(),hd=$r(),oe=$r(),Je=$r(),Ws=$r(),Ri=$r();function $r(){return 2**++hk}const fd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ee,booleanish:yt,commaOrSpaceSeparated:Ri,commaSeparated:Ws,number:oe,overloadedBoolean:hd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),of=Object.keys(fd);class Ld extends vi{constructor(t,n,s,a){let o=-1;if(super(t,n),iy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&_k.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ny,yk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ny.test(o)){let c=o.replace(mk,vk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Ld}return new a(s,t)}function vk(e){return"-"+e.toLowerCase()}function yk(e){return e.charAt(1).toUpperCase()}const Sk=YS([VS,fk,$S,GS,ZS],"html"),Nd=YS([VS,dk,$S,GS,ZS],"svg");function bk(e){return e.join(" ").trim()}var Ps={},uf,ry;function xk(){if(ry)return uf;ry=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` -`,h="/",g="*",_="",S="comment",y="declaration";function b(D,T){if(typeof D!="string")throw new TypeError("First argument must be a string");if(!D)return[];T=T||{};var X=1,U=1;function te($){var z=$.match(t);z&&(X+=z.length);var M=$.lastIndexOf(p);U=~M?$.length-M:U+$.length}function ae(){var $={line:X,column:U};return function(z){return z.position=new O($),ie(),z}}function O($){this.start=$,this.end={line:X,column:U},this.source=T.source}O.prototype.content=D;function H($){var z=new Error(T.source+":"+X+":"+U+": "+$);if(z.reason=$,z.filename=T.source,z.line=X,z.column=U,z.source=D,!T.silent)throw z}function P($){var z=$.exec(D);if(z){var M=z[0];return te(M),D=D.slice(M.length),z}}function ie(){P(n)}function L($){var z;for($=$||[];z=Z();)z!==!1&&$.push(z);return $}function Z(){var $=ae();if(!(h!=D.charAt(0)||g!=D.charAt(1))){for(var z=2;_!=D.charAt(z)&&(g!=D.charAt(z)||h!=D.charAt(z+1));)++z;if(z+=2,_===D.charAt(z-1))return H("End of comment missing");var M=D.slice(2,z-2);return U+=2,te(M),D=D.slice(z),U+=2,$({type:S,comment:M})}}function j(){var $=ae(),z=P(s);if(z){if(Z(),!P(a))return H("property missing ':'");var M=P(o),I=$({type:y,property:k(z[0].replace(e,_)),value:M?k(M[0].replace(e,_)):_});return P(c),I}}function F(){var $=[];L($);for(var z;z=j();)z!==!1&&($.push(z),L($));return $}return ie(),F()}function k(D){return D?D.replace(f,_):_}return uf=b,uf}var sy;function wk(){if(sy)return Ps;sy=1;var e=Ps&&Ps.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=n;const t=e(xk());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Ps}var Zl={},ly;function Ck(){if(ly)return Zl;ly=1,Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return Zl.camelCase=p,Zl}var Ql,ay;function kk(){if(ay)return Ql;ay=1;var e=Ql&&Ql.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(wk()),n=Ck();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,Ql=s,Ql}var Ek=kk();const Tk=gu(Ek),QS=JS("end"),zd=JS("start");function JS(e){return t;function t(n){const s=n&&n.position&&n.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 eb(e){const t=zd(e),n=QS(e);if(t&&n)return{start:t,end:n}}function aa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?oy(e.position):"start"in e||"end"in e?oy(e):"line"in e||"column"in e?dd(e):""}function dd(e){return uy(e&&e.line)+":"+uy(e&&e.column)}function oy(e){return dd(e&&e.start)+"-"+dd(e&&e.end)}function uy(e){return e&&typeof e=="number"?e:1}class Gt extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),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 f=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=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=aa(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}}Gt.prototype.file="";Gt.prototype.name="";Gt.prototype.reason="";Gt.prototype.message="";Gt.prototype.stack="";Gt.prototype.column=void 0;Gt.prototype.line=void 0;Gt.prototype.ancestors=void 0;Gt.prototype.cause=void 0;Gt.prototype.fatal=void 0;Gt.prototype.place=void 0;Gt.prototype.ruleId=void 0;Gt.prototype.source=void 0;const Od={}.hasOwnProperty,Ak=new Map,Dk=/[A-Z]/g,Rk=new Set(["table","tbody","thead","tfoot","tr"]),Mk=new Set(["td","th"]),tb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=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=Pk(n,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=Uk(n,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:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Nd:Sk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=ib(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function ib(e,t,n){if(t.type==="element")return Lk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Nk(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Ok(e,t,n);if(t.type==="mdxjsEsm")return zk(e,t);if(t.type==="root")return Hk(e,t,n);if(t.type==="text")return jk(e,t)}function Lk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Nd,e.schema=a),e.ancestors.push(t);const o=rb(e,t.tagName,!1),c=Ik(e,t);let f=jd(e,t);return Rk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!ck(p):!0})),nb(e,c,o,t),Hd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Nk(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)}da(e,t.position)}function zk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);da(e,t.position)}function Ok(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Nd,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:rb(e,t.name,!0),c=Fk(e,t),f=jd(e,t);return nb(e,c,o,t),Hd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Hk(e,t,n){const s={};return Hd(s,jd(e,t)),e.create(t,e.Fragment,s,n)}function jk(e,t){return t.value}function nb(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Hd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Uk(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Pk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=zd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function Ik(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Od.call(t.properties,a)){const o=qk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Mk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Fk(e,t){const n={};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 f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else da(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 f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else da(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function jd(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Ak;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Mi(e,e.length,0,t),e):t}const fy={}.hasOwnProperty;function lb(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Qi(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ri=vr(/[A-Za-z]/),$t=vr(/[\dA-Za-z]/),Qk=vr(/[#-'*+\--9=?A-Z^-~]/);function pu(e){return e!==null&&(e<32||e===127)}const pd=vr(/\d/),Jk=vr(/[\dA-Fa-f]/),eE=vr(/[!-/:-@[-`{-~]/);function ve(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Le(e){return e===-2||e===-1||e===32}const xu=vr(new RegExp("\\p{P}|\\p{S}","u")),Kr=vr(/\s/);function vr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gs(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function je(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Le(p)?(e.enter(n),f(p)):t(p)}function f(p){return Le(p)&&o++c))return;const H=t.events.length;let P=H,ie,L;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(ie){L=t.events[P][1].end;break}ie=!0}for(T(s),O=H;OU;){const ae=n[te];t.containerState=ae[1],ae[0].exit.call(t,e)}n.length=U}function X(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function sE(e,t,n){return je(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vs(e){if(e===null||Qe(e)||Kr(e))return 1;if(xu(e))return 2}function wu(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},S={...e[n][1].start};py(_,-p),py(S,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:S},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Yi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Yi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Yi(h,wu(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Yi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Yi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Mi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Le(O)?je(e,X,"linePrefix",o+1)(O):X(O)}function X(O){return O===null||ve(O)?e.check(my,k,te)(O):(e.enter("codeFlowValue"),U(O))}function U(O){return O===null||ve(O)?(e.exit("codeFlowValue"),X(O)):(e.consume(O),U)}function te(O){return e.exit("codeFenced"),t(O)}function ae(O,H,P){let ie=0;return L;function L(z){return O.enter("lineEnding"),O.consume(z),O.exit("lineEnding"),Z}function Z(z){return O.enter("codeFencedFence"),Le(z)?je(O,j,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):j(z)}function j(z){return z===f?(O.enter("codeFencedFenceSequence"),F(z)):P(z)}function F(z){return z===f?(ie++,O.consume(z),F):ie>=c?(O.exit("codeFencedFenceSequence"),Le(z)?je(O,$,"whitespace")(z):$(z)):P(z)}function $(z){return z===null||ve(z)?(O.exit("codeFencedFence"),H(z)):P(z)}}}function gE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const hf={name:"codeIndented",tokenize:yE},vE={partial:!0,tokenize:SE};function yE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),je(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):ve(h)?e.attempt(vE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||ve(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function SE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):ve(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):je(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):ve(c)?a(c):n(c)}}const bE={name:"codeText",previous:wE,resolve:xE,tokenize:CE};function xE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=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 tthis.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,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&Jl(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),Jl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jl(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=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function fb(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(T){return T===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(T),e.exit(o),S):T===null||T===32||T===41||pu(T)?n(T):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(T))}function S(T){return T===62?(e.enter(o),e.consume(T),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===62?(e.exit("chunkString"),e.exit(f),S(T)):T===null||T===60||ve(T)?n(T):(e.consume(T),T===92?b:y)}function b(T){return T===60||T===62||T===92?(e.consume(T),y):y(T)}function k(T){return!g&&(T===null||T===41||Qe(T))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(T)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):ve(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||ve(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Le(y)),y===92?S:_)}function S(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function pb(e,t,n,s,a,o){let c;return f;function f(S){return S===34||S===39||S===40?(e.enter(s),e.enter(a),e.consume(S),e.exit(a),c=S===40?41:S,p):n(S)}function p(S){return S===c?(e.enter(a),e.consume(S),e.exit(a),e.exit(s),t):(e.enter(o),h(S))}function h(S){return S===c?(e.exit(o),p(c)):S===null?n(S):ve(S)?(e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),je(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(S))}function g(S){return S===c||S===null||ve(S)?(e.exit("chunkString"),h(S)):(e.consume(S),S===92?_:g)}function _(S){return S===c||S===92?(e.consume(S),g):g(S)}}function oa(e,t){let n;return s;function s(a){return ve(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Le(a)?je(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const BE={name:"definition",tokenize:NE},LE={partial:!0,tokenize:zE};function NE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return db.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Qi(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?oa(e,h)(y):h(y)}function h(y){return fb(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(LE,_,_)(y)}function _(y){return Le(y)?je(e,S,"whitespace")(y):S(y)}function S(y){return y===null||ve(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function zE(e,t,n){return s;function s(f){return Qe(f)?oa(e,a)(f):n(f)}function a(f){return pb(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Le(f)?je(e,c,"whitespace")(f):c(f)}function c(f){return f===null||ve(f)?t(f):n(f)}}const OE={name:"hardBreakEscape",tokenize:HE};function HE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ve(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const jE={name:"headingAtx",resolve:UE,tokenize:PE};function UE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Mi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function PE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||ve(g)?(e.exit("atxHeading"),t(g)):Le(g)?je(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const IE=["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"],gy=["pre","script","style","textarea"],FE={concrete:!0,name:"htmlFlow",resolveTo:YE,tokenize:VE},qE={partial:!0,tokenize:XE},WE={partial:!0,tokenize:KE};function YE(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 VE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),S):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):ri(C)?(e.consume(C),c=String.fromCharCode(C),D):n(C)}function S(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,b):ri(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function b(C){const se="CDATA[";return C===se.charCodeAt(f++)?(e.consume(C),f===se.length?s.interrupt?t:j:b):n(C)}function k(C){return ri(C)?(e.consume(C),c=String.fromCharCode(C),D):n(C)}function D(C){if(C===null||C===47||C===62||Qe(C)){const se=C===47,fe=c.toLowerCase();return!se&&!o&&gy.includes(fe)?(a=1,s.interrupt?t(C):j(C)):IE.includes(c.toLowerCase())?(a=6,se?(e.consume(C),T):s.interrupt?t(C):j(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?X(C):U(C))}return C===45||$t(C)?(e.consume(C),c+=String.fromCharCode(C),D):n(C)}function T(C){return C===62?(e.consume(C),s.interrupt?t:j):n(C)}function X(C){return Le(C)?(e.consume(C),X):L(C)}function U(C){return C===47?(e.consume(C),L):C===58||C===95||ri(C)?(e.consume(C),te):Le(C)?(e.consume(C),U):L(C)}function te(C){return C===45||C===46||C===58||C===95||$t(C)?(e.consume(C),te):ae(C)}function ae(C){return C===61?(e.consume(C),O):Le(C)?(e.consume(C),ae):U(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,H):Le(C)?(e.consume(C),O):P(C)}function H(C){return C===p?(e.consume(C),p=null,ie):C===null||ve(C)?n(C):(e.consume(C),H)}function P(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?ae(C):(e.consume(C),P)}function ie(C){return C===47||C===62||Le(C)?U(C):n(C)}function L(C){return C===62?(e.consume(C),Z):n(C)}function Z(C){return C===null||ve(C)?j(C):Le(C)?(e.consume(C),Z):n(C)}function j(C){return C===45&&a===2?(e.consume(C),M):C===60&&a===1?(e.consume(C),I):C===62&&a===4?(e.consume(C),A):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),ue):ve(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(qE,K,F)(C)):C===null||ve(C)?(e.exit("htmlFlowData"),F(C)):(e.consume(C),j)}function F(C){return e.check(WE,$,K)(C)}function $(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),z}function z(C){return C===null||ve(C)?F(C):(e.enter("htmlFlowData"),j(C))}function M(C){return C===45?(e.consume(C),E):j(C)}function I(C){return C===47?(e.consume(C),c="",W):j(C)}function W(C){if(C===62){const se=c.toLowerCase();return gy.includes(se)?(e.consume(C),A):j(C)}return ri(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),W):j(C)}function ue(C){return C===93?(e.consume(C),E):j(C)}function E(C){return C===62?(e.consume(C),A):C===45&&a===2?(e.consume(C),E):j(C)}function A(C){return C===null||ve(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),A)}function K(C){return e.exit("htmlFlow"),t(C)}}function KE(e,t,n){const s=this;return a;function a(c){return ve(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function XE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ba,t,n)}}const $E={name:"htmlText",tokenize:GE};function GE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),ae):E===63?(e.consume(E),U):ri(E)?(e.consume(E),P):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,b):ri(E)?(e.consume(E),X):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),S):ve(E)?(c=_,I(E)):(e.consume(E),_)}function S(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?M(E):E===45?S(E):_(E)}function b(E){const A="CDATA[";return E===A.charCodeAt(o++)?(e.consume(E),o===A.length?k:b):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),D):ve(E)?(c=k,I(E)):(e.consume(E),k)}function D(E){return E===93?(e.consume(E),T):k(E)}function T(E){return E===62?M(E):E===93?(e.consume(E),T):k(E)}function X(E){return E===null||E===62?M(E):ve(E)?(c=X,I(E)):(e.consume(E),X)}function U(E){return E===null?n(E):E===63?(e.consume(E),te):ve(E)?(c=U,I(E)):(e.consume(E),U)}function te(E){return E===62?M(E):U(E)}function ae(E){return ri(E)?(e.consume(E),O):n(E)}function O(E){return E===45||$t(E)?(e.consume(E),O):H(E)}function H(E){return ve(E)?(c=H,I(E)):Le(E)?(e.consume(E),H):M(E)}function P(E){return E===45||$t(E)?(e.consume(E),P):E===47||E===62||Qe(E)?ie(E):n(E)}function ie(E){return E===47?(e.consume(E),M):E===58||E===95||ri(E)?(e.consume(E),L):ve(E)?(c=ie,I(E)):Le(E)?(e.consume(E),ie):M(E)}function L(E){return E===45||E===46||E===58||E===95||$t(E)?(e.consume(E),L):Z(E)}function Z(E){return E===61?(e.consume(E),j):ve(E)?(c=Z,I(E)):Le(E)?(e.consume(E),Z):ie(E)}function j(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,F):ve(E)?(c=j,I(E)):Le(E)?(e.consume(E),j):(e.consume(E),$)}function F(E){return E===a?(e.consume(E),a=void 0,z):E===null?n(E):ve(E)?(c=F,I(E)):(e.consume(E),F)}function $(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Qe(E)?ie(E):(e.consume(E),$)}function z(E){return E===47||E===62||Qe(E)?ie(E):n(E)}function M(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function I(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),W}function W(E){return Le(E)?je(e,ue,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):ue(E)}function ue(E){return e.enter("htmlTextData"),c(E)}}const Id={name:"labelEnd",resolveAll:e5,resolveTo:t5,tokenize:i5},ZE={tokenize:n5},QE={tokenize:r5},JE={tokenize:s5};function e5(e){let t=-1;const n=[];for(;++t=3&&(h===null||ve(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Le(h)?je(e,f,"whitespace")(h):f(h))}}const gi={continuation:{tokenize:m5},exit:g5,name:"list",tokenize:p5},f5={partial:!0,tokenize:v5},d5={partial:!0,tokenize:_5};function p5(e,t,n){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 f;function f(y){const b=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(b==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:pd(y)){if(s.containerState.type||(s.containerState.type=b,e.enter(b,{_container:!0})),b==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(au,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return pd(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(ba,s.interrupt?n:g,e.attempt(f5,S,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,S(y)}function _(y){return Le(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),S):n(y)}function S(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function m5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(ba,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,je(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Le(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(d5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,je(e,e.attempt(gi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function _5(e,t,n){const s=this;return je(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):n(o)}}function g5(e){e.exit(this.containerState.type)}function v5(e,t,n){const s=this;return je(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!Le(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const vy={name:"setextUnderline",resolveTo:y5,tokenize:S5};function y5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);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 S5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Le(h)?je(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||ve(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const b5={tokenize:x5};function x5(e){const t=this,n=e.attempt(ba,s,e.attempt(this.parser.constructs.flowInitial,a,je(e,e.attempt(this.parser.constructs.flow,a,e.attempt(TE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const w5={resolveAll:_b()},C5=mb("string"),k5=mb("text");function mb(e){return{resolveAll:_b(e==="text"?E5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let S=-1;if(_)for(;++S<_.length;){const y=_[S];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function _b(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function E5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const T5={42:gi,43:gi,45:gi,48:gi,49:gi,50:gi,51:gi,52:gi,53:gi,54:gi,55:gi,56:gi,57:gi,62:ob},A5={91:BE},D5={[-2]:hf,[-1]:hf,32:hf},R5={35:jE,42:au,45:[vy,au],60:FE,61:vy,95:au,96:_y,126:_y},M5={38:cb,92:ub},B5={[-5]:ff,[-4]:ff,[-3]:ff,33:l5,38:cb,42:md,60:[oE,$E],91:o5,92:[OE,ub],93:Id,95:md,96:bE},L5={null:[md,w5]},N5={null:[42,95]},z5={null:[]},O5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:N5,contentInitial:A5,disable:z5,document:T5,flow:R5,flowInitial:D5,insideSpan:L5,string:M5,text:B5},Symbol.toStringTag,{value:"Module"}));function H5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:H(ae),check:H(O),consume:X,enter:U,exit:te,interrupt:H(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:b,parser:e,previous:null,sliceSerialize:S,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(Z){return c=Yi(c,Z),D(),c[c.length-1]!==null?[]:(P(t,0),h.events=wu(o,h.events,h),h.events)}function S(Z,j){return U5(y(Z),j)}function y(Z){return j5(c,Z)}function b(){const{_bufferIndex:Z,_index:j,line:F,column:$,offset:z}=s;return{_bufferIndex:Z,_index:j,line:F,column:$,offset:z}}function k(Z){a[Z.line]=Z.column,L()}function D(){let Z;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function U5(e,t){let n=-1;const s=[];let a;for(;++n0){const Si=Se.tokenStack[Se.tokenStack.length-1];(Si[1]||Sy).call(Se,void 0,Si[0])}for(he.position={start:fr(J.length>0?J[0][1].start:{line:1,column:1,offset:0}),end:fr(J.length>0?J[J.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};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 J5(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=Gs(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function iT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function yb(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="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 rT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return yb(e,t);const a={src:Gs(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 sT(e,t){const n={src:Gs(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function lT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function aT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return yb(e,t);const a={href:Gs(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 oT(e,t){const n={href:Gs(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function uT(e,t,n){const s=e.all(t),a=n?cT(n):Sb(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={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 f=-1;for(;++f1}function hT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=zd(t.children[1]),p=QS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,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 _T(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(wy(t.slice(a),a>0,!1)),o.join("")}function wy(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===by||o===xy;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===by||o===xy;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function yT(e,t){const n={type:"text",value:vT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function ST(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const bT={blockquote:G5,break:Z5,code:Q5,delete:J5,emphasis:eT,footnoteReference:tT,heading:iT,html:nT,imageReference:rT,image:sT,inlineCode:lT,linkReference:aT,link:oT,listItem:uT,list:hT,paragraph:fT,root:dT,strong:pT,table:mT,tableCell:gT,tableRow:_T,text:yT,thematicBreak:ST,toml:Go,yaml:Go,definition:Go,footnoteDefinition:Go};function Go(){}const bb=-1,Cu=0,ua=1,mu=2,Fd=3,qd=4,Wd=5,Yd=6,xb=7,wb=8,Cy=typeof self=="object"?self:globalThis,xT=(e,t)=>{const n=(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 Cu:case bb:return n(c,a);case ua:{const f=n([],a);for(const p of c)f.push(s(p));return f}case mu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Fd:return n(new Date(c),a);case qd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Wd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Yd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case xb:{const{name:f,message:p}=c;return n(new Cy[f](p),a)}case wb:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Cy[o](c),a)};return s},ky=e=>xT(new Map,e)(0),Is="",{toString:wT}={},{keys:CT}=Object,ea=e=>{const t=typeof e;if(t!=="object"||!e)return[Cu,t];const n=wT.call(e).slice(8,-1);switch(n){case"Array":return[ua,Is];case"Object":return[mu,Is];case"Date":return[Fd,Is];case"RegExp":return[qd,Is];case"Map":return[Wd,Is];case"Set":return[Yd,Is];case"DataView":return[ua,n]}return n.includes("Array")?[ua,n]:n.includes("Error")?[xb,n]:[mu,n]},Zo=([e,t])=>e===Cu&&(t==="function"||t==="symbol"),kT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=ea(c);switch(f){case Cu:{let g=c;switch(p){case"bigint":f=wb,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([bb],c)}return a([f,g],c)}case ua:{if(p){let S=c;return p==="DataView"?S=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(S=new Uint8Array(c)),a([p,[...S]],c)}const g=[],_=a([f,g],c);for(const S of c)g.push(o(S));return _}case mu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const S of CT(c))(e||!Zo(ea(c[S])))&&g.push([o(S),o(c[S])]);return _}case Fd:return a([f,c.toISOString()],c);case qd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Wd:{const g=[],_=a([f,g],c);for(const[S,y]of c)(e||!(Zo(ea(S))||Zo(ea(y))))&&g.push([o(S),o(y)]);return _}case Yd:{const g=[],_=a([f,g],c);for(const S of c)(e||!Zo(ea(S)))&&g.push(o(S));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Ey=(e,{json:t,lossy:n}={})=>{const s=[];return kT(!(t||n),!!t,new Map,s)(e),s},pa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ky(Ey(e,t)):structuredClone(e):(e,t)=>ky(Ey(e,t));function ET(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function TT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function AT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ET,s=e.options.footnoteBackLabel||TT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&b.push({type:"text",value:" "});let X=typeof n=="string"?n:n(p,y);typeof X=="string"&&(X={type:"text",value:X}),b.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+S+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(X)?X:[X]})}const D=g[g.length-1];if(D&&D.type==="element"&&D.tagName==="p"){const X=D.children[D.children.length-1];X&&X.type==="text"?X.value+=" ":D.children.push({type:"text",value:" "}),D.children.push(...b)}else g.push(...b);const T={type:"element",tagName:"li",properties:{id:t+"fn-"+S},children:e.wrap(g,!0)};e.patch(h,T),f.push(T)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...pa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` -`}]}}const ku=(function(e){if(e==null)return BT;if(typeof e=="function")return Eu(e);if(typeof e=="object")return Array.isArray(e)?DT(e):RT(e);if(typeof e=="string")return MT(e);throw new Error("Expected function, string, or object as test")});function DT(e){const t=[];let n=-1;for(;++n":""))+")"})}return S;function S(){let y=Cb,b,k,D;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=OT(n(p,g)),y[0]===_d))return y;if("children"in p&&p.children){const T=p;if(T.children&&y[0]!==zT)for(k=(s?T.children.length:-1)+c,D=g.concat(T);k>-1&&k0&&n.push({type:"text",value:` -`}),n}function Ty(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ay(e,t){const n=jT(e,t),s=n.one(e,void 0),a=AT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function qT(e,t){return e&&"run"in e?async function(n,s){const a=Ay(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Ay(n,{file:s,...e||t})}}function Dy(e){if(e)throw e}var df,Ry;function WT(){if(Ry)return df;Ry=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var S;for(S in h);return typeof S>"u"||e.call(h,S)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return df=function p(){var h,g,_,S,y,b,k=arguments[0],D=1,T=arguments.length,X=!1;for(typeof k=="boolean"&&(X=k,k=arguments[1]||{},D=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Dc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const an={basename:XT,dirname:$T,extname:GT,join:ZT,sep:"/"};function XT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xa(e);let n=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){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function $T(e){if(xa(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function GT(e){xa(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function ZT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function JT(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function xa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const e3={cwd:t3};function t3(){return"/"}function yd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function i3(e){if(typeof e=="string")e=new URL(e);else if(!yd(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 n3(e)}function n3(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 n=-1;for(;++n0){let[y,...b]=g;const k=s[S][1];vd(k)&&vd(y)&&(y=pf(!0,k,y)),s[S]=[h,y,...b]}}}}const a3=new Kd().freeze();function vf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Sf(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 By(e){if(!vd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ly(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qo(e){return o3(e)?e:new Eb(e)}function o3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function u3(e){return typeof e=="string"||c3(e)}function c3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const h3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ny=[],zy={allowDangerousHtml:!0},f3=/^(https?|ircs?|mailto|xmpp)$/i,d3=[{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 p3(e){const t=m3(e),n=_3(e);return g3(t.runSync(t.parse(n),n),e)}function m3(e){const t=e.rehypePlugins||Ny,n=e.remarkPlugins||Ny,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...zy}:zy;return a3().use($5).use(n).use(qT,s).use(t)}function _3(e){const t=e.children||"",n=new Eb;return typeof t=="string"&&(n.value=t),n}function g3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||v3;for(const g of d3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+h3+g.id,void 0);return Vd(e,h),Bk(e,{Fragment:x.Fragment,components:a,ignoreInvalidStyle:!0,jsx:x.jsx,jsxs:x.jsxs,passKeys:!0,passNode:!0});function h(g,_,S){if(g.type==="raw"&&S&&typeof _=="number")return c?S.children.splice(_,1):S.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in cf)if(Object.hasOwn(cf,y)&&Object.hasOwn(g.properties,y)){const b=g.properties[y],k=cf[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(b||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,S)),y&&S&&typeof _=="number")return f&&g.children?S.children.splice(_,1,...g.children):S.children.splice(_,1),_}}}function v3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||f3.test(e.slice(0,t))?e:""}function y3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Tb(e,t,n){const a=ku((n||{}).ignore||[]),o=S3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?S.lastIndex=te+1:(b!==te&&X.push({type:"text",value:h.value.slice(b,te)}),Array.isArray(O)?X.push(...O):O&&X.push(O),b=te+U[0].length,T=!0),!S.global)break;U=S.exec(h.value)}return T?(b?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Oy(e,"(");let o=Oy(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function Ab(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Kr(n)||xu(n))&&(!t||n!==47)}Db.peek=V3;function j3(){this.buffer()}function U3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function P3(){this.buffer()}function I3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function F3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function q3(e){this.exit(e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(){return"["}function Db(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function K3(){return{enter:{gfmFootnoteCallString:j3,gfmFootnoteCall:U3,gfmFootnoteDefinitionLabelString:P3,gfmFootnoteDefinition:I3},exit:{gfmFootnoteCallString:F3,gfmFootnoteCall:q3,gfmFootnoteDefinitionLabelString:W3,gfmFootnoteDefinition:Y3}}}function X3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Db},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` -`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?Rb:$3))),h(),p}}function $3(e,t,n){return t===0?e:Rb(e,t,n)}function Rb(e,t,n){return(n?"":" ")+e}const G3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Mb.peek=tA;function Z3(){return{canContainEols:["delete"],enter:{strikethrough:J3},exit:{strikethrough:eA}}}function Q3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:G3}],handlers:{delete:Mb}}}function J3(e){this.enter({type:"delete",children:[]},e)}function eA(e){this.exit(e)}function Mb(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function tA(){return"~"}function iA(e){return e.length}function nA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||iA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Tp[T])&&(p[T]=U)}k.push(X)}c[g]=k,f[g]=D}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=X),y[_]=X),S[_]=U}c.splice(1,0,S),f.splice(1,0,y),g=-1;const b=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),lA);return a(),c}function lA(e,t,n){return">"+(n?"":" ")+e}function aA(e,t){return jy(e,t.inConstruct,!0)&&!jy(e,t.notInConstruct,!1)}function jy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function uA(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 cA(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 hA(e,t,n,s){const a=cA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(uA(e,n)){const _=n.enter("codeIndented"),S=n.indentLines(o,fA);return _(),S}const f=n.createTracker(s),p=a.repeat(Math.max(oA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` -`,encode:["`"],...f.current()})),_()}return g+=f.move(` -`),o&&(g+=f.move(o+` -`)),g+=f.move(p),h(),g}function fA(e,t,n){return(n?"":" ")+e}function Xd(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 dA(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` -`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function pA(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 ma(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,t,n){const s=Vs(e),a=Vs(t);return s===void 0?a===void 0?n==="_"?{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}}Bb.peek=mA;function Bb(e,t,n,s){const a=pA(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=ma(h)+p.slice(1));const _=p.charCodeAt(p.length-1),S=_u(s.after.charCodeAt(0),_,a);S.inside&&(p=p.slice(0,-1)+ma(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:S.outside,before:g.outside},f+p+y}function mA(e,t,n){return n.options.emphasis||"*"}function _A(e,t){let n=!1;return Vd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,_d}),!!((!e.depth||e.depth<3)&&Ud(e)&&(t.options.setext||n))}function gA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(_A(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),S=n.containerPhrasing(e,{...o.current(),before:` -`,after:` -`});return _(),g(),S+` -`+(a===1?"=":"-").repeat(S.length-(Math.max(S.lastIndexOf("\r"),S.lastIndexOf(` -`))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=ma(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}Lb.peek=vA;function Lb(e){return e.value||""}function vA(){return"<"}Nb.peek=yA;function Nb(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function yA(){return"!"}zb.peek=SA;function zb(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function SA(){return"!"}Ob.peek=bA;function Ob(e,t,n){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\u007F]/.test(e.url))}jb.peek=xA;function jb(e,t,n,s){const a=Xd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(Hb(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function xA(e,t,n){return Hb(e,n)?"<":"["}Ub.peek=wA;function Ub(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function wA(){return"["}function $d(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 CA(e){const t=$d(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function kA(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 Pb(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 EA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?kA(n):$d(n);const f=e.ordered?c==="."?")":".":CA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),Pb(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.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 f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,S,y){return S?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function DA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const RA=ku(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function MA(e,t,n,s){return(e.children.some(function(c){return RA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function BA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ib.peek=LA;function Ib(e,t,n,s){const a=BA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=ma(h)+p.slice(1));const _=p.charCodeAt(p.length-1),S=_u(s.after.charCodeAt(0),_,a);S.inside&&(p=p.slice(0,-1)+ma(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:S.outside,before:g.outside},f+p+y}function LA(e,t,n){return n.options.strong||"*"}function NA(e,t,n,s){return n.safe(e.value,s)}function zA(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 OA(e,t,n){const s=(Pb(n)+(n.options.ruleSpaces?" ":"")).repeat(zA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const Fb={blockquote:sA,break:Uy,code:hA,definition:dA,emphasis:Bb,hardBreak:Uy,heading:gA,html:Lb,image:Nb,imageReference:zb,inlineCode:Ob,link:jb,linkReference:Ub,list:EA,listItem:AA,paragraph:DA,root:MA,strong:Ib,text:NA,thematicBreak:OA};function HA(){return{enter:{table:jA,tableData:Py,tableHeader:Py,tableRow:PA},exit:{codeText:IA,table:UA,tableData:Cf,tableHeader:Cf,tableRow:Cf}}}function jA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function UA(e){this.exit(e),this.data.inTable=void 0}function PA(e){this.enter({type:"tableRow",children:[]},e)}function Cf(e){this.exit(e)}function Py(e){this.enter({type:"tableCell",children:[]},e)}function IA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,FA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function FA(e,t){return t==="|"?t:e}function qA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:S,table:c,tableCell:p,tableRow:f}};function c(y,b,k,D){return h(g(y,k,D),y.align)}function f(y,b,k,D){const T=_(y,k,D),X=h([T]);return X.slice(0,X.indexOf(` -`))}function p(y,b,k,D){const T=k.enter("tableCell"),X=k.enter("phrasing"),U=k.containerPhrasing(y,{...D,before:o,after:o});return X(),T(),U}function h(y,b){return nA(y,{align:b,alignDelimiters:s,padding:n,stringLength:a})}function g(y,b,k){const D=y.children;let T=-1;const X=[],U=b.enter("table");for(;++T0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const aD={tokenize:mD,partial:!0};function oD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:fD,continuation:{tokenize:dD},exit:pD}},text:{91:{name:"gfmFootnoteCall",tokenize:hD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:uD,resolveTo:cD}}}}function uD(e,t,n){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 f;function f(p){if(!c||!c._balanced)return n(p);const h=Qi(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function cD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+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)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+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(n,e.length-n+1,...f),e}function hD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const S=e.exit("gfmFootnoteCallString");return a.includes(Qi(s.sliceSerialize(S)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function fD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(b)}function g(b){if(c>999||b===93&&!f||b===null||b===91||Qe(b))return n(b);if(b===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Qi(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),S}return Qe(b)||(f=!0),c++,e.consume(b),b===92?_:g}function _(b){return b===91||b===92||b===93?(e.consume(b),c++,g):g(b)}function S(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),a.includes(o)||a.push(o),je(e,y,"gfmFootnoteDefinitionWhitespace")):n(b)}function y(b){return t(b)}}function dD(e,t,n){return e.check(ba,t,e.attempt(aD,t,n))}function pD(e){e.exit("gfmFootnoteDefinition")}function mD(e,t,n){const s=this;return je(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):n(o)}}function _D(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(b):(c.consume(b),_++,y);if(_<2&&!n)return p(b);const D=c.exit("strikethroughSequenceTemporary"),T=Vs(b);return D._open=!T||T===2&&!!k,D._close=!k||k===2&&!!T,f(b)}}}class gD{constructor(){this.map=[]}add(t,n,s){vD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][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 vD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const $=s.events[Z][1].type;if($==="lineEnding"||$==="linePrefix")Z--;else break}const j=Z>-1?s.events[Z][1].type:null,F=j==="tableHead"||j==="tableRow"?O:p;return F===O&&s.parser.lazy[s.now().line]?n(L):F(L)}function p(L){return e.enter("tableHead"),e.enter("tableRow"),h(L)}function h(L){return L===124||(c=!0,o+=1),g(L)}function g(L){return L===null?n(L):ve(L)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),y):n(L):Le(L)?je(e,g,"whitespace")(L):(o+=1,c&&(c=!1,a+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(L)))}function _(L){return L===null||L===124||Qe(L)?(e.exit("data"),g(L)):(e.consume(L),L===92?S:_)}function S(L){return L===92||L===124?(e.consume(L),_):_(L)}function y(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(L):(e.enter("tableDelimiterRow"),c=!1,Le(L)?je(e,b,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):b(L))}function b(L){return L===45||L===58?D(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),k):ae(L)}function k(L){return Le(L)?je(e,D,"whitespace")(L):D(L)}function D(L){return L===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),T):L===45?(o+=1,T(L)):L===null||ve(L)?te(L):ae(L)}function T(L){return L===45?(e.enter("tableDelimiterFiller"),X(L)):ae(L)}function X(L){return L===45?(e.consume(L),X):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),U):(e.exit("tableDelimiterFiller"),U(L))}function U(L){return Le(L)?je(e,te,"whitespace")(L):te(L)}function te(L){return L===124?b(L):L===null||ve(L)?!c||a!==o?ae(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):ae(L)}function ae(L){return n(L)}function O(L){return e.enter("tableRow"),H(L)}function H(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),H):L===null||ve(L)?(e.exit("tableRow"),t(L)):Le(L)?je(e,H,"whitespace")(L):(e.enter("data"),P(L))}function P(L){return L===null||L===124||Qe(L)?(e.exit("data"),H(L)):(e.consume(L),L===92?ie:P)}function ie(L){return L===92||L===124?(e.consume(L),P):P(L)}}function xD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const S=new gD;for(;++nn[2]+1){const b=n[2]+1,k=n[3]-n[2]-1;e.add(b,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Fs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Fy(e,t,n,s,a){const o=[],c=Fs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Fs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const wD={name:"tasklistCheck",tokenize:kD};function CD(){return{text:{91:wD}}}function kD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(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):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return ve(p)?t(p):Le(p)?e.check({tokenize:ED},t,n)(p):n(p)}}function ED(e,t,n){return je(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function TD(e){return lb([QA(),oD(),_D(e),SD(),CD()])}const AD={};function DD(e){const t=this,n=e||AD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(TD(n)),o.push(XA()),c.push($A(n))}const Pr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],qy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Pr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Pr],h2:[["className","sr-only"]],img:[...Pr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Pr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Pr],table:[...Pr],ul:[...Pr,["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"]},pr={}.hasOwnProperty;function RD(e,t){let n={type:"root",children:[]};const s={schema:t?{...qy,...t}:qy,stack:[]},a=Zb(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function Zb(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return MD(e,n);case"doctype":return BD(e,n);case"element":return LD(e,n);case"root":return ND(e,n);case"text":return zD(e,n)}}}function MD(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return wa(o,t),o}}function BD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return wa(n,t),n}}function LD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=Qb(e,t.children),a=OD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&pr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function UD(e){return function(t){return RD(t,e)}}function PD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a}){const[o,c]=le.useState(null),[f,p]=le.useState(!1),[h,g]=le.useState("preview"),[_,S]=le.useState(""),[y,b]=le.useState(!1),[k,D]=le.useState(!1),[T,X]=le.useState(!1),[U,te]=le.useState(null),ae=le.useRef(null),O=le.useRef(!1),H=le.useRef(null),P=le.useCallback(async()=>{if(!e||!t){c(null);return}const ue=`${e}/${t}`,E=H.current!==ue;E&&(H.current=ue);try{const A=await n(`/api/stories/${e}/${t}`);if(A.ok){const K=await A.json();c(K),(E||!O.current)&&(S(K.content??""),E&&(D(!1),O.current=!1))}}catch{}},[e,t,n]);le.useEffect(()=>{p(!0),P().finally(()=>p(!1))},[P]),le.useEffect(()=>{if(!e||!t||h==="edit"&&k)return;const ue=setInterval(P,3e3);return()=>clearInterval(ue)},[e,t,P,h,k]);const ie=le.useCallback(async()=>{if(!(!e||!t)){b(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:_})})).ok&&(D(!1),O.current=!1,c(E=>E&&{...E,content:_}))}catch{}b(!1)}},[e,t,n,_]);le.useEffect(()=>{if(h!=="edit")return;const ue=E=>{(E.metaKey||E.ctrlKey)&&E.key==="s"&&(E.preventDefault(),ie())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[h,ie]),le.useEffect(()=>{if((o==null?void 0:o.status)!=="published-not-indexed"||!o.publishedAt)return;const ue=new Date(o.publishedAt).getTime(),E=300*1e3,A=()=>{const C=Math.max(0,E-(Date.now()-ue));te(C)};A();const K=setInterval(A,1e3);return()=>clearInterval(K)},[o==null?void 0:o.status,o==null?void 0:o.publishedAt]);const L=U!==null&&U<=0,Z=U!==null&&U>0?`${Math.floor(U/6e4)}:${String(Math.floor(U%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return x.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:x.jsxs("div",{className:"text-center",children:[x.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),x.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(f&&!o)return x.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const F=(h==="edit"?_:(o==null?void 0:o.content)??"").length,$=t==="genesis.md",z=t?/^plot-\d+\.md$/.test(t):!1,M=(o==null?void 0:o.status)==="published"||(o==null?void 0:o.status)==="published-not-indexed",I=$?1e3:z?1e4:null,W=!M&&I!==null&&F>I;return x.jsxs("div",{className:"h-full flex flex-col",children:[x.jsxs("div",{className:"border-b border-border",children:[x.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[x.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[x.jsxs("span",{children:[e,"/",t]}),(o==null?void 0:o.status)==="published"&&x.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(o==null?void 0:o.status)==="published-not-indexed"&&x.jsx("span",{className:"text-amber-700 font-medium",title:o.indexError,children:"Published (not indexed)"}),(o==null?void 0:o.status)==="pending"&&x.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("span",{className:`text-xs font-mono ${W?"text-error font-medium":"text-muted"}`,children:[F.toLocaleString(),I!==null?`/${I.toLocaleString()}`:" chars"]}),W&&x.jsxs("span",{className:"text-error text-xs font-medium",children:[(F-I).toLocaleString()," over limit"]})]})]}),x.jsxs("div",{className:"flex px-3 gap-1",children:[x.jsx("button",{onClick:()=>g("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),x.jsxs("button",{onClick:()=>g("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",k&&x.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),h==="preview"?x.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:o!=null&&o.content?x.jsx("div",{className:"prose max-w-none",children:x.jsx(p3,{remarkPlugins:[k3,DD],rehypePlugins:[UD],children:o.content})}):x.jsx("p",{className:"text-muted italic",children:"No content"})}):x.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[x.jsx("textarea",{ref:ae,value:_,onChange:ue=>{S(ue.target.value),D(!0),O.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}),x.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[x.jsx("span",{className:"text-xs text-muted",children:k?"Unsaved changes":"No changes"}),x.jsx("button",{onClick:ie,disabled:!k||y,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:y?"Saving...":"Save"})]})]}),x.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?x.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(o==null?void 0:o.status)==="published-not-indexed"?x.jsxs("div",{className:"flex flex-col gap-1",children:[x.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[x.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!L&&x.jsx("button",{onClick:async()=>{if(!(!e||!t||!o.txHash)){X(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:o.txHash,content:o.content,storylineId:o.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:o.txHash,storylineId:o.storylineId,contentCid:"",gasCost:""})}),P())}catch{}X(!1)}},disabled:T,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:T?"Retrying...":`Retry Index${Z?` (${Z})`:""}`}),z&&x.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),o.txHash&&x.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),x.jsx("p",{className:"text-muted text-xs",children:L?z?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":z?"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."}),o.indexError&&x.jsx("p",{className:"text-error text-xs",children:o.indexError})]}):(o==null?void 0:o.status)==="published"?x.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[x.jsx("span",{className:"text-green-700",children:"Published"}),o.storylineId&&x.jsx("a",{href:(()=>{var A;const ue=`https://plotlink.xyz/story/${o.storylineId}`;if(!z)return ue;const E=o.plotIndex!=null&&o.plotIndex>0?o.plotIndex:parseInt(((A=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:A[1])??"1");return`${ue}/${E}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),o.txHash&&x.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}):x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t)),disabled:!!a||W,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"}),W&&x.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]})})]})}const e0="plotlink-panel-ratio",ID=.6,Vy=300,kf=224,Ef=6;function FD(){try{const e=localStorage.getItem(e0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return ID}function Ky(e,t){if(t<=0)return e;const n=Vy/t,s=1-Vy/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function qD({token:e,authFetch:t}){const[n,s]=le.useState(null),[a,o]=le.useState(null),[c,f]=le.useState(null),[p,h]=le.useState(""),[g,_]=le.useState(FD),[S,y]=le.useState([]),b=le.useRef(new Set),k=le.useRef(null),D=le.useRef(!1);le.useEffect(()=>{try{localStorage.setItem(e0,String(g))}catch{}},[g]),le.useEffect(()=>{const P=()=>{if(!k.current)return;const ie=k.current.getBoundingClientRect().width-kf-Ef;_(L=>Ky(L,ie))};return window.addEventListener("resize",P),P(),()=>window.removeEventListener("resize",P)},[]);const T=le.useCallback(()=>{const P=`_new_${Date.now()}`;y(ie=>[...ie,P]),s(P),o(null)},[]);le.useEffect(()=>{if(S.length===0)return;const P=setInterval(async()=>{try{const ie=await t("/api/stories");if(!ie.ok)return;const L=await ie.json(),Z=new Set(L.stories.filter(j=>j.name!=="_example").map(j=>j.name));for(const j of Z)!b.current.has(j)&&S.length>0&&(y(F=>F.slice(1)),s(j),o(null));b.current=Z}catch{}},3e3);return()=>clearInterval(P)},[t,S]),le.useEffect(()=>{t("/api/stories").then(P=>{if(P.ok)return P.json()}).then(P=>{P!=null&&P.stories&&(b.current=new Set(P.stories.filter(ie=>ie.name!=="_example").map(ie=>ie.name)))}).catch(()=>{})},[t]);const X=le.useCallback((P,ie)=>{s(P),o(ie)},[]),U=le.useRef(null),te=le.useCallback(async P=>{var ie,L,Z,j;U.current=P,s(P),o(null);try{const F=await t(`/api/stories/${P}`);if(F.ok&&U.current===P){const z=(await F.json()).files||[],I=((ie=z.map(W=>{var ue;return{file:W.file,num:(ue=W.file.match(/^plot-(\d+)\.md$/))==null?void 0:ue[1]}}).filter(W=>W.num!=null).sort((W,ue)=>parseInt(ue.num)-parseInt(W.num))[0])==null?void 0:ie.file)??((L=z.find(W=>W.file==="genesis.md"))==null?void 0:L.file)??((Z=z.find(W=>W.file==="structure.md"))==null?void 0:Z.file)??((j=z[0])==null?void 0:j.file);I&&U.current===P&&o(I)}}catch{}},[t]),ae=le.useCallback(P=>{P.preventDefault(),D.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const ie=Z=>{if(!D.current||!k.current)return;const j=k.current.getBoundingClientRect(),F=j.width-kf-Ef,$=Z.clientX-j.left-kf;_(Ky($/F,F))},L=()=>{D.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",L)};window.addEventListener("mousemove",ie),window.addEventListener("mouseup",L)},[]),O=le.useCallback(async(P,ie)=>{var L;f(ie),h("Reading file...");try{const Z=await t(`/api/stories/${P}/${ie}`);if(!Z.ok)throw new Error("Failed to read file");const j=await Z.json(),F=j.content.match(/^#\s+(.+)$/m),$=F?F[1].slice(0,60):ie.replace(".md","");let z="Fiction";try{const E=await t(`/api/stories/${P}/structure.md`);if(E.ok){const K=(await E.json()).content.match(/genre[:\s]+(.+)/i);K&&(z=K[1].trim().slice(0,30))}}catch{}let M;if(ie.match(/^plot-\d+\.md$/)){try{const E=await t(`/api/stories/${P}`);if(E.ok){const K=(await E.json()).files.find(C=>C.file==="genesis.md"&&C.storylineId);M=K==null?void 0:K.storylineId}}catch{}if(!M){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const I=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:P,fileName:ie,title:$,content:j.content,genre:z,storylineId:M})});if(!I.ok){const E=await I.json();throw new Error(E.error||"Publish failed")}const W=(L=I.body)==null?void 0:L.getReader(),ue=new TextDecoder;if(W)for(;;){const{done:E,value:A}=await W.read();if(E)break;const C=ue.decode(A).split(` -`).filter(se=>se.startsWith("data: "));for(const se of C)try{const fe=JSON.parse(se.slice(6));fe.step&&h(fe.message||fe.step),fe.step==="done"&&fe.txHash&&await t(`/api/stories/${P}/${ie}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:fe.txHash,storylineId:fe.storylineId,plotIndex:fe.plotIndex,contentCid:fe.contentCid,gasCost:fe.gasCost,indexError:fe.indexError})})}catch{}}h("Published!")}catch(Z){const j=Z instanceof Error?Z.message:"Publish failed";h(`Error: ${j}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),H=le.useCallback(P=>{P.startsWith("_new_")&&y(ie=>ie.filter(L=>L!==P))},[]);return x.jsxs("div",{ref:k,className:"h-[calc(100vh-3.5rem)] flex",children:[x.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:x.jsx(Nx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:X,onNewStory:T,untitledSessions:S})}),x.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${g} 0 0`},children:x.jsx(rk,{token:e,storyName:n,authFetch:t,onSelectStory:te,onDestroySession:H})}),x.jsx("div",{onMouseDown:ae,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Ef,cursor:"col-resize",background:"var(--border)"},children:x.jsxs("div",{className:"flex flex-col gap-1",children:[x.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),x.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),x.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),x.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-g} 0 0`},children:[x.jsx(PD,{storyName:n,fileName:a,authFetch:t,onPublish:O,publishingFile:c}),p&&x.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function WD({token:e,onComplete:t}){const[n,s]=le.useState(!1),[a,o]=le.useState(null),[c,f]=le.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return le.useEffect(()=>{p()},[]),x.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[x.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),x.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&x.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&x.jsxs("div",{className:"space-y-4",children:[x.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),x.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&&x.jsxs("div",{className:"space-y-4",children:[x.jsx("div",{className:"text-accent text-2xl",children:"✓"}),x.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),x.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 YD({token:e,onLogout:t}){const[n,s]=le.useState("home"),[a,o]=le.useState(0),c=le.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return le.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(S=>S.name!=="_example").length)}}catch{}}f()},[e]),x.jsxs("div",{className:"flex h-screen flex-col",children:[x.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:x.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),x.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&x.jsxs("nav",{className:"flex items-center gap-4",children:[x.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),x.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),x.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),x.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),x.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&x.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[x.jsxs("div",{className:"text-center space-y-2",children:[x.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),x.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),x.jsxs("div",{className:"text-center space-y-3",children:[x.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&&x.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),x.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[x.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),x.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[x.jsxs("li",{children:["Open the ",x.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),x.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),x.jsx("li",{children:"Review the live preview as Claude creates files"}),x.jsxs("li",{children:["Click ",x.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),x.jsxs("li",{children:["Earn 5% royalties on every trade at ",x.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),x.jsx(Zy,{token:e})]}),n==="stories"&&x.jsx(qD,{token:e,authFetch:c}),n==="dashboard"&&x.jsx(Mx,{token:e}),n==="wallet-setup"&&x.jsx(WD,{token:e,onComplete:()=>s("home")}),n==="settings"&&x.jsx(Dx,{token:e,onLogout:t})]})]})}function VD(){const[e,t]=le.useState(()=>localStorage.getItem("ows-token")),[n,s]=le.useState(null),[a,o]=le.useState(!0);le.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),le.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.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||n===null?x.jsx("div",{className:"flex h-screen items-center justify-center",children:x.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?x.jsx(YD,{token:e,onLogout:p}):x.jsx(Tx,{onLogin:c}):x.jsx(Ax,{onSetup:f})}Ex.createRoot(document.getElementById("root")).render(x.jsx(vx.StrictMode,{children:x.jsx(VD,{})})); diff --git a/app/web/dist/index.html b/app/web/dist/index.html index fad48d8..1953778 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -7,8 +7,8 @@ - - + +
diff --git a/package.json b/package.json index 90fe887..8fdc67c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plotlink-ows", - "version": "1.0.12", + "version": "1.0.13", "bin": { "plotlink-ows": "./bin/plotlink-ows.js" },