From 6951fbb51400682725562883441ae430888f0941 Mon Sep 17 00:00:00 2001 From: Project7 Date: Sun, 31 May 2026 00:14:29 +0000 Subject: [PATCH 1/5] [#254] Wire provider selection into New Story flow Add a Provider choice (Claude default / Codex) to the New Story modal, persisted to .story.json as agentProvider via the existing metadata endpoint. Defaults to Claude so fiction behaviour is unchanged. Helper text clarifies that Codex can generate clean cartoon images directly in the terminal, while Claude only prepares prompts for you to generate and upload images externally. Bumps version to 1.0.39. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/web/components/StoriesPage.test.tsx | 127 ++++++++++++++++++ app/web/components/StoriesPage.tsx | 32 ++++- .../{index-J_XBhN4y.js => index-sJfBa0bG.js} | 76 +++++------ app/web/dist/index.html | 2 +- package-lock.json | 4 +- package.json | 2 +- 6 files changed, 197 insertions(+), 46 deletions(-) create mode 100644 app/web/components/StoriesPage.test.tsx rename app/web/dist/assets/{index-J_XBhN4y.js => index-sJfBa0bG.js} (76%) diff --git a/app/web/components/StoriesPage.test.tsx b/app/web/components/StoriesPage.test.tsx new file mode 100644 index 0000000..b2e58b4 --- /dev/null +++ b/app/web/components/StoriesPage.test.tsx @@ -0,0 +1,127 @@ +import { describe, it, expect, vi, afterEach, beforeAll } from "vitest"; +import { render, screen, cleanup, waitFor, fireEvent } from "@testing-library/react"; +import { StoriesPage } from "./StoriesPage"; + +// Capture props passed to the mocked child panels so tests can drive the +// new-story flow (open modal, expose renameRef) without real terminals. +const childProps = vi.hoisted(() => ({ + onNewStory: null as null | (() => void), + renameRef: null as null | { current: ((o: string, n: string) => Promise) | null }, +})); + +vi.mock("./StoryBrowser", () => ({ + StoryBrowser: (props: { onNewStory: () => void }) => { + childProps.onNewStory = props.onNewStory; + return New Story; + }, +})); + +vi.mock("./TerminalPanel", () => ({ + TerminalPanel: (props: { renameRef: { current: ((o: string, n: string) => Promise) | null } }) => { + childProps.renameRef = props.renameRef; + // Provide a rename implementation so the polling effect proceeds. + props.renameRef.current = () => Promise.resolve(true); + return ; + }, +})); + +vi.mock("./PreviewPanel", () => ({ + PreviewPanel: () => , +})); + +beforeAll(() => { + global.ResizeObserver = class { + observe() {} + unobserve() {} + disconnect() {} + } as unknown as typeof ResizeObserver; +}); + +afterEach(() => { + cleanup(); + vi.useRealTimers(); + childProps.onNewStory = null; + childProps.renameRef = null; +}); + +interface FetchCall { url: string; body: unknown } + +// authFetch that records every call. /api/stories starts empty, then returns a +// single new story ("my-tale") so the polling effect fires the metadata POST. +function makeAuthFetch() { + const calls: FetchCall[] = []; + let storiesAppeared = false; + const fn = vi.fn().mockImplementation((url: string, opts?: RequestInit) => { + let body: unknown; + try { body = opts?.body ? JSON.parse(opts.body as string) : undefined; } catch { /* ignore */ } + calls.push({ url, body }); + if (url === "/api/wallet") { + return Promise.resolve({ ok: true, json: () => Promise.resolve({ address: "0xabc" }) }); + } + if (url === "/api/stories" && !opts) { + const stories = storiesAppeared + ? [{ name: "my-tale", hasStructure: false }] + : []; + return Promise.resolve({ ok: true, json: () => Promise.resolve({ stories }) }); + } + // metadata POST or anything else + return Promise.resolve({ ok: true, json: () => Promise.resolve({ ok: true }) }); + }); + return { fn, calls, appear: () => { storiesAppeared = true; } }; +} + +function metadataBodyFor(calls: FetchCall[]): Record | undefined { + const call = calls.find((c) => c.url.includes("/metadata")); + return call?.body as Record | undefined; +} + +describe("StoriesPage new-story provider selection", () => { + async function createStory(opts: { provider?: "claude" | "codex"; contentTypeLabel: string }) { + const { fn, calls, appear } = makeAuthFetch(); + render(); + + // Open the new-story modal. + fireEvent.click(screen.getByTestId("mock-new-story")); + + // Provider control defaults to Claude. + const select = screen.getByTestId("agent-provider-select") as HTMLSelectElement; + expect(select.value).toBe("claude"); + if (opts.provider) { + fireEvent.change(select, { target: { value: opts.provider } }); + } + + // Pick a content type → registers the pending session in the maps. + fireEvent.click(screen.getByText(opts.contentTypeLabel)); + + // Now make a story "appear" and let the 3s poll run. + appear(); + await waitFor( + () => { expect(metadataBodyFor(calls)).toBeDefined(); }, + { timeout: 5000 }, + ); + return metadataBodyFor(calls)!; + } + + it("persists agentProvider 'codex' when Codex is selected (cartoon)", async () => { + const body = await createStory({ provider: "codex", contentTypeLabel: "Cartoon" }); + expect(body).toMatchObject({ contentType: "cartoon", agentProvider: "codex" }); + }, 10000); + + it("defaults agentProvider to 'claude' when the provider control is untouched", async () => { + const body = await createStory({ contentTypeLabel: "Fiction" }); + expect(body).toMatchObject({ contentType: "fiction", agentProvider: "claude" }); + }, 10000); + + it("toggles provider helper text when switching to Codex", () => { + render(); + fireEvent.click(screen.getByTestId("mock-new-story")); + + const helper = screen.getByTestId("agent-provider-helper"); + expect(helper.textContent).toContain("Claude prepares image prompts"); + + fireEvent.change(screen.getByTestId("agent-provider-select"), { target: { value: "codex" } }); + expect(screen.getByTestId("agent-provider-helper").textContent).toContain( + "Codex can generate clean cartoon images", + ); + }); +}); diff --git a/app/web/components/StoriesPage.tsx b/app/web/components/StoriesPage.tsx index 6bbc48a..2b42262 100644 --- a/app/web/components/StoriesPage.tsx +++ b/app/web/components/StoriesPage.tsx @@ -46,6 +46,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const [showNewStoryModal, setShowNewStoryModal] = useState(false); const [newStoryLanguage, setNewStoryLanguage] = useState("English"); const [newStoryAgentMode, setNewStoryAgentMode] = useState<"normal" | "bypass">("normal"); + const [newStoryAgentProvider, setNewStoryAgentProvider] = useState<"claude" | "codex">("claude"); const [bypassStories, setBypassStories] = useState>({}); // Track confirmed stories (those with structure.md) for Archive gating const [confirmedStories, setConfirmedStories] = useState>(new Set()); @@ -54,6 +55,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const contentTypeMap = useRef>(new Map()); const languageMap = useRef>(new Map()); const agentModeMap = useRef>(new Map()); + const agentProviderMap = useRef>(new Map()); const knownStoriesRef = useRef>(new Set()); const renameRef = useRef<((oldName: string, newName: string) => Promise) | null>(null); const containerRef = useRef(null); @@ -87,15 +89,17 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const handleNewStory = useCallback(() => { setNewStoryAgentMode("normal"); + setNewStoryAgentProvider("claude"); setShowNewStoryModal(true); }, []); - const handleCreateStory = useCallback((contentType: "fiction" | "cartoon", language: string, agentMode: "normal" | "bypass") => { + const handleCreateStory = useCallback((contentType: "fiction" | "cartoon", language: string, agentMode: "normal" | "bypass", agentProvider: "claude" | "codex") => { setShowNewStoryModal(false); const id = `_new_${Date.now()}`; contentTypeMap.current.set(id, contentType); languageMap.current.set(id, language); agentModeMap.current.set(id, agentMode); + agentProviderMap.current.set(id, agentProvider); if (agentMode === "bypass") { setBypassStories((prev) => ({ ...prev, [id]: true })); } @@ -131,9 +135,11 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const ct = contentTypeMap.current.get(oldName) || "fiction"; const lang = languageMap.current.get(oldName) || "English"; const mode = agentModeMap.current.get(oldName) || "normal"; + const provider = agentProviderMap.current.get(oldName) || "claude"; contentTypeMap.current.delete(oldName); languageMap.current.delete(oldName); agentModeMap.current.delete(oldName); + agentProviderMap.current.delete(oldName); if (mode === "bypass") { setBypassStories((prev) => { const next = { ...prev, [name]: true }; @@ -144,7 +150,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { authFetch(`/api/stories/${name}/metadata`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ contentType: ct, language: lang, agentMode: mode }), + body: JSON.stringify({ contentType: ct, language: lang, agentMode: mode, agentProvider: provider }), }).catch(() => {}); } setSelectedStory(name); @@ -331,6 +337,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { contentTypeMap.current.delete(name); languageMap.current.delete(name); agentModeMap.current.delete(name); + agentProviderMap.current.delete(name); setBypassStories((prev) => { if (!(name in prev)) return prev; const next = { ...prev }; @@ -457,17 +464,34 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) {
+ {newStoryAgentProvider === "codex" + ? "Codex can generate clean cartoon images directly in the terminal." + : "Claude prepares image prompts; you generate and upload clean images externally."} +
Choose a content type
Fiction
Novels, short stories, poetry
Cartoon
ze?($e=xe,xe=null):$e=xe.sibling;var Xe=G(H,xe,q[ze],ne);if(Xe===null){xe===null&&(xe=$e);break}i&&xe&&Xe.alternate===null&&r(H,xe),O=m(Xe,O,ze),Ge===null?ke=Xe:Ge.sibling=Xe,Ge=Xe,xe=$e}if(ze===q.length)return l(H,xe),Ye&&Un(H,ze),ke;if(xe===null){for(;zeze?($e=xe,xe=null):$e=xe.sibling;var Br=G(H,xe,Xe.value,ne);if(Br===null){xe===null&&(xe=$e);break}i&&xe&&Br.alternate===null&&r(H,xe),O=m(Br,O,ze),Ge===null?ke=Br:Ge.sibling=Br,Ge=Br,xe=$e}if(Xe.done)return l(H,xe),Ye&&Un(H,ze),ke;if(xe===null){for(;!Xe.done;ze++,Xe=q.next())Xe=re(H,Xe.value,ne),Xe!==null&&(O=m(Xe,O,ze),Ge===null?ke=Xe:Ge.sibling=Xe,Ge=Xe);return Ye&&Un(H,ze),ke}for(xe=c(xe);!Xe.done;ze++,Xe=q.next())Xe=Z(xe,H,ze,Xe.value,ne),Xe!==null&&(i&&Xe.alternate!==null&&xe.delete(Xe.key===null?ze:Xe.key),O=m(Xe,O,ze),Ge===null?ke=Xe:Ge.sibling=Xe,Ge=Xe);return i&&xe.forEach(function(L1){return r(H,L1)}),Ye&&Un(H,ze),ke}function rt(H,O,q,ne){if(typeof q=="object"&&q!==null&&q.type===T&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case b:e:{for(var ke=q.key;O!==null;){if(O.key===ke){if(ke=q.type,ke===T){if(O.tag===7){l(H,O.sibling),ne=p(O,q.props.children),ne.return=H,H=ne;break e}}else if(O.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===ce&&ns(ke)===O.type){l(H,O.sibling),ne=p(O,q.props),Ul(ne,q),ne.return=H,H=ne;break e}l(H,O);break}else r(H,O);O=O.sibling}q.type===T?(ne=Qr(q.props.children,H.mode,ne,q.key),ne.return=H,H=ne):(ne=fo(q.type,q.key,q.props,null,H.mode,ne),Ul(ne,q),ne.return=H,H=ne)}return x(H);case S:e:{for(ke=q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===q.containerInfo&&O.stateNode.implementation===q.implementation){l(H,O.sibling),ne=p(O,q.children||[]),ne.return=H,H=ne;break e}else{l(H,O);break}else r(H,O);O=O.sibling}ne=wu(q,H.mode,ne),ne.return=H,H=ne}return x(H);case ce:return q=ns(q),rt(H,O,q,ne)}if(A(q))return _e(H,O,q,ne);if($(q)){if(ke=$(q),typeof ke!="function")throw Error(s(150));return q=ke.call(q),De(H,O,q,ne)}if(typeof q.then=="function")return rt(H,O,bo(q),ne);if(q.$$typeof===P)return rt(H,O,go(H,q),ne);xo(H,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,O!==null&&O.tag===6?(l(H,O.sibling),ne=p(O,q),ne.return=H,H=ne):(l(H,O),ne=Su(q,H.mode,ne),ne.return=H,H=ne),x(H)):l(H,O)}return function(H,O,q,ne){try{Il=0;var ke=rt(H,O,q,ne);return Ys=null,ke}catch(xe){if(xe===$s||xe===vo)throw xe;var Ge=Pi(29,xe,null,H.mode);return Ge.lanes=ne,Ge.return=H,Ge}finally{}}}var ss=bm(!0),xm=bm(!1),gr=!1;function Ou(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zu(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 _r(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function vr(i,r,l){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Ze&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=ho(i),rm(i,null,l),r}return uo(i,c,r,l),ho(i)}function Fl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}function ju(i,r){var l=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var p=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var x={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?p=m=x:m=m.next=x,l=l.next}while(l!==null);m===null?p=m=r:m=m.next=r}else p=m=r;l={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:m,shared:c.shared,callbacks:c.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var Hu=!1;function ql(){if(Hu){var i=Ws;if(i!==null)throw i}}function Wl(i,r,l,c){Hu=!1;var p=i.updateQueue;gr=!1;var m=p.firstBaseUpdate,x=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var N=C,W=N.next;N.next=null,x===null?m=W:x.next=W,x=N;var te=i.alternate;te!==null&&(te=te.updateQueue,C=te.lastBaseUpdate,C!==x&&(C===null?te.firstBaseUpdate=W:C.next=W,te.lastBaseUpdate=N))}if(m!==null){var re=p.baseState;x=0,te=W=N=null,C=m;do{var G=C.lane&-536870913,Z=G!==C.lane;if(Z?(We&G)===G:(c&G)===G){G!==0&&G===qs&&(Hu=!0),te!==null&&(te=te.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var _e=i,De=C;G=r;var rt=l;switch(De.tag){case 1:if(_e=De.payload,typeof _e=="function"){re=_e.call(rt,re,G);break e}re=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=De.payload,G=typeof _e=="function"?_e.call(rt,re,G):_e,G==null)break e;re=g({},re,G);break e;case 2:gr=!0}}G=C.callback,G!==null&&(i.flags|=64,Z&&(i.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[G]:Z.push(G))}else Z={lane:G,tag:C.tag,payload:C.payload,callback:C.callback,next:null},te===null?(W=te=Z,N=re):te=te.next=Z,x|=G;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);te===null&&(N=re),p.baseState=N,p.firstBaseUpdate=W,p.lastBaseUpdate=te,m===null&&(p.shared.lanes=0),wr|=x,i.lanes=x,i.memoizedState=re}}function Sm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function wm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var x=E.T,C={};E.T=C,nh(i,!1,r,l);try{var N=p(),W=E.S;if(W!==null&&W(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var te=wS(N,c);Vl(i,r,te,Wi(i))}else Vl(i,r,c,Wi(i))}catch(re){Vl(i,r,{then:function(){},status:"rejected",reason:re},Wi())}finally{j.p=m,x!==null&&C.types!==null&&(x.types=C.types),E.T=x}}function DS(){}function th(i,r,l,c){if(i.tag!==5)throw Error(s(476));var p=tg(i).queue;eg(i,p,r,U,l===null?DS:function(){return ig(i),l(c)})}function tg(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:U},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function ig(i){var r=tg(i);r.next===null&&(r=i.alternate.memoizedState),Vl(i,r.next.queue,{},Wi())}function ih(){return si(ua)}function ng(){return Tt().memoizedState}function rg(){return Tt().memoizedState}function RS(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Wi();i=_r(l);var c=vr(r,i,l);c!==null&&(Ni(c,r,l),Fl(c,r,l)),r={cache:Nu()},i.payload=r;return}r=r.return}}function NS(i,r,l){var c=Wi();l={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},No(i)?lg(r,l):(l=bu(i,r,l,c),l!==null&&(Ni(l,i,c),ag(l,r,c)))}function sg(i,r,l){var c=Wi();Vl(i,r,l,c)}function Vl(i,r,l,c){var p={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(No(i))lg(r,p);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var x=r.lastRenderedState,C=m(x,l);if(p.hasEagerState=!0,p.eagerState=C,Hi(C,x))return uo(i,r,p,0),lt===null&&co(),!1}catch{}finally{}if(l=bu(i,r,p,c),l!==null)return Ni(l,i,c),ag(l,r,c),!0}return!1}function nh(i,r,l,c){if(c={lane:2,revertLane:Oh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},No(i)){if(r)throw Error(s(479))}else r=bu(i,l,c,2),r!==null&&Ni(r,i,2)}function No(i){var r=i.alternate;return i===Oe||r!==null&&r===Oe}function lg(i,r){Ks=Co=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function ag(i,r,l){if((l&4194048)!==0){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}var Kl={readContext:si,use:To,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};Kl.useEffectEvent=bt;var og={readContext:si,use:To,useCallback:function(i,r){return yi().memoizedState=[i,r===void 0?null:r],i},useContext:si,useEffect:$m,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,Do(4194308,4,Gm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return Do(4194308,4,i,r)},useInsertionEffect:function(i,r){Do(4,2,i,r)},useMemo:function(i,r){var l=yi();r=r===void 0?null:r;var c=i();if(ls){hi(!0);try{i()}finally{hi(!1)}}return l.memoizedState=[c,r],c},useReducer:function(i,r,l){var c=yi();if(l!==void 0){var p=l(r);if(ls){hi(!0);try{l(r)}finally{hi(!1)}}}else p=r;return c.memoizedState=c.baseState=p,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:p},c.queue=i,i=i.dispatch=NS.bind(null,Oe,i),[c.memoizedState,i]},useRef:function(i){var r=yi();return i={current:i},r.memoizedState=i},useState:function(i){i=Xu(i);var r=i.queue,l=sg.bind(null,Oe,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Ju,useDeferredValue:function(i,r){var l=yi();return eh(l,i,r)},useTransition:function(){var i=Xu(!1);return i=eg.bind(null,Oe,i.queue,!0,!1),yi().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var c=Oe,p=yi();if(Ye){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),lt===null)throw Error(s(349));(We&127)!==0||Dm(c,r,l)}p.memoizedState=l;var m={value:l,getSnapshot:r};return p.queue=m,$m(Nm.bind(null,c,m,i),[i]),c.flags|=2048,Xs(9,{destroy:void 0},Rm.bind(null,c,m,l,r),null),l},useId:function(){var i=yi(),r=lt.identifierPrefix;if(Ye){var l=wn,c=Sn;l=(c&~(1<<32-Je(c)-1)).toString(32)+l,r="_"+r+"R_"+l,l=ko++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof c.is=="string"?x.createElement("select",{is:c.is}):x.createElement("select"),c.multiple?m.multiple=!0:c.size&&(m.size=c.size);break;default:m=typeof c.is=="string"?x.createElement(p,{is:c.is}):x.createElement(p)}}m[jt]=r,m[Ht]=c;e:for(x=r.child;x!==null;){if(x.tag===5||x.tag===6)m.appendChild(x.stateNode);else if(x.tag!==4&&x.tag!==27&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===r)break e;for(;x.sibling===null;){if(x.return===null||x.return===r)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}r.stateNode=m;e:switch(ai(m,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Vn(r)}}return ft(r),_h(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==c&&Vn(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(i=ae.current,Us(r)){if(i=r.stateNode,l=r.memoizedProps,c=null,p=ri,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}i[jt]=r,i=!!(i.nodeValue===l||c!==null&&c.suppressHydrationWarning===!0||T_(i.nodeValue,l)),i||pr(r,!0)}else i=Zo(i).createTextNode(c),i[jt]=r,r.stateNode=i}return ft(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(c=Us(r),l!==null){if(i===null){if(!c)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[jt]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ft(r),i=!1}else l=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Ui(r),r):(Ui(r),null);if((r.flags&128)!==0)throw Error(s(558))}return ft(r),null;case 13:if(c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(p=Us(r),c!==null&&c.dehydrated!==null){if(i===null){if(!p)throw Error(s(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(s(317));p[jt]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ft(r),p=!1}else p=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Ui(r),r):(Ui(r),null)}return Ui(r),(r.flags&128)!==0?(r.lanes=l,r):(l=c!==null,i=i!==null&&i.memoizedState!==null,l&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),m=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),m!==p&&(c.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),zo(r,r.updateQueue),ft(r),null);case 4:return Se(),i===null&&Ph(r.stateNode.containerInfo),ft(r),null;case 10:return qn(r.type),ft(r),null;case 19:if(K(Et),c=r.memoizedState,c===null)return ft(r),null;if(p=(r.flags&128)!==0,m=c.rendering,m===null)if(p)Xl(c,!1);else{if(xt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=wo(i),m!==null){for(r.flags|=128,Xl(c,!1),i=m.updateQueue,r.updateQueue=i,zo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)sm(l,i),l=l.sibling;return w(Et,Et.current&1|2),Ye&&Un(r,c.treeForkCount),r.child}i=i.sibling}c.tail!==null&&ut()>Uo&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304)}else{if(!p)if(i=wo(m),i!==null){if(r.flags|=128,p=!0,i=i.updateQueue,r.updateQueue=i,zo(r,i),Xl(c,!0),c.tail===null&&c.tailMode==="hidden"&&!m.alternate&&!Ye)return ft(r),null}else 2*ut()-c.renderingStartTime>Uo&&l!==536870912&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304);c.isBackwards?(m.sibling=r.child,r.child=m):(i=c.last,i!==null?i.sibling=m:r.child=m,c.last=m)}return c.tail!==null?(i=c.tail,c.rendering=i,c.tail=i.sibling,c.renderingStartTime=ut(),i.sibling=null,l=Et.current,w(Et,p?l&1|2:l&1),Ye&&Un(r,c.treeForkCount),i):(ft(r),null);case 22:case 23:return Ui(r),Iu(),c=r.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(l&536870912)!==0&&(r.flags&128)===0&&(ft(r),r.subtreeFlags&6&&(r.flags|=8192)):ft(r),l=r.updateQueue,l!==null&&zo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==l&&(r.flags|=2048),i!==null&&K(is),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),qn(Rt),ft(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function zS(i,r){switch(ku(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return qn(Rt),Se(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return we(r),null;case 31:if(r.memoizedState!==null){if(Ui(r),r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Ui(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(Et),null;case 4:return Se(),null;case 10:return qn(r.type),null;case 22:case 23:return Ui(r),Iu(),i!==null&&K(is),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return qn(Rt),null;case 25:return null;default:return null}}function Mg(i,r){switch(ku(r),r.tag){case 3:qn(Rt),Se();break;case 26:case 27:case 5:we(r);break;case 4:Se();break;case 31:r.memoizedState!==null&&Ui(r);break;case 13:Ui(r);break;case 19:K(Et);break;case 10:qn(r.type);break;case 22:case 23:Ui(r),Iu(),i!==null&&K(is);break;case 24:qn(Rt)}}function Zl(i,r){try{var l=r.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var p=c.next;l=p;do{if((l.tag&i)===i){c=void 0;var m=l.create,x=l.inst;c=m(),x.destroy=c}l=l.next}while(l!==p)}}catch(C){tt(r,r.return,C)}}function xr(i,r,l){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var m=p.next;c=m;do{if((c.tag&i)===i){var x=c.inst,C=x.destroy;if(C!==void 0){x.destroy=void 0,p=r;var N=l,W=C;try{W()}catch(te){tt(p,N,te)}}}c=c.next}while(c!==m)}}catch(te){tt(r,r.return,te)}}function Bg(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{wm(r,l)}catch(c){tt(i,i.return,c)}}}function Lg(i,r,l){l.props=as(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(c){tt(i,r,c)}}function Ql(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var c=i.stateNode;break;case 30:c=i.stateNode;break;default:c=i.stateNode}typeof l=="function"?i.refCleanup=l(c):l.current=c}}catch(p){tt(i,r,p)}}function Cn(i,r){var l=i.ref,c=i.refCleanup;if(l!==null)if(typeof c=="function")try{c()}catch(p){tt(i,r,p)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){tt(i,r,p)}else l.current=null}function Og(i){var r=i.type,l=i.memoizedProps,c=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&c.focus();break e;case"img":l.src?c.src=l.src:l.srcSet&&(c.srcset=l.srcSet)}}catch(p){tt(i,i.return,p)}}function vh(i,r,l){try{var c=i.stateNode;r1(c,i.type,l,r),c[Ht]=r}catch(p){tt(i,i.return,p)}}function zg(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ar(i.type)||i.tag===4}function yh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||zg(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&&Ar(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 bh(i,r,l){var c=i.tag;if(c===5||c===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=Hn));else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(bh(i,r,l),i=i.sibling;i!==null;)bh(i,r,l),i=i.sibling}function jo(i,r,l){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(jo(i,r,l),i=i.sibling;i!==null;)jo(i,r,l),i=i.sibling}function jg(i){var r=i.stateNode,l=i.memoizedProps;try{for(var c=i.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);ai(r,c,l),r[jt]=i,r[Ht]=l}catch(m){tt(i,i.return,m)}}var Kn=!1,Bt=!1,xh=!1,Hg=typeof WeakSet=="function"?WeakSet:Set,Kt=null;function jS(i,r){if(i=i.containerInfo,Fh=rc,i=Xp(i),pu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var p=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var x=0,C=-1,N=-1,W=0,te=0,re=i,G=null;t:for(;;){for(var Z;re!==l||p!==0&&re.nodeType!==3||(C=x+p),re!==m||c!==0&&re.nodeType!==3||(N=x+c),re.nodeType===3&&(x+=re.nodeValue.length),(Z=re.firstChild)!==null;)G=re,re=Z;for(;;){if(re===i)break t;if(G===l&&++W===p&&(C=x),G===m&&++te===c&&(N=x),(Z=re.nextSibling)!==null)break;re=G,G=re.parentNode}re=Z}l=C===-1||N===-1?null:{start:C,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(qh={focusedElem:i,selectionRange:l},rc=!1,Kt=r;Kt!==null;)if(r=Kt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Kt=i;else for(;Kt!==null;){switch(r=Kt,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"))),ai(m,c,l),m[jt]=i,Vt(m),c=m;break e;case"link":var x=W_("link","href",p).get(c+(l.href||""));if(x){for(var C=0;Crt&&(x=rt,rt=De,De=x);var H=Kp(C,De),O=Kp(C,rt);if(H&&O&&(Z.rangeCount!==1||Z.anchorNode!==H.node||Z.anchorOffset!==H.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var q=re.createRange();q.setStart(H.node,H.offset),Z.removeAllRanges(),De>rt?(Z.addRange(q),Z.extend(O.node,O.offset)):(q.setEnd(O.node,O.offset),Z.addRange(q))}}}}for(re=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&re.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cl?32:l,E.T=null,l=Ah,Ah=null;var m=kr,x=Jn;if(It=0,tl=kr=null,Jn=0,(Ze&6)!==0)throw Error(s(331));var C=Ze;if(Ze|=4,Gg(m.current),Yg(m,m.current,x,l),Ze=C,ra(0,!1),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(Yt,m)}catch{}return!0}finally{j.p=p,E.T=c,f_(i,r)}}function m_(i,r,l){r=en(l,r),r=ah(i.stateNode,r,2),i=vr(i,r,2),i!==null&&(or(i,2),kn(i))}function tt(i,r,l){if(i.tag===3)m_(i,i,l);else for(;r!==null;){if(r.tag===3){m_(r,i,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Cr===null||!Cr.has(c))){i=en(l,i),l=gg(2),c=vr(r,l,2),c!==null&&(_g(l,c,r,i),or(c,2),kn(c));break}}r=r.return}}function Mh(i,r,l){var c=i.pingCache;if(c===null){c=i.pingCache=new IS;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(l)||(Ch=!0,p.add(l),i=$S.bind(null,i,r,l),r.then(i,i))}function $S(i,r,l){var c=i.pingCache;c!==null&&c.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,lt===i&&(We&l)===l&&(xt===4||xt===3&&(We&62914560)===We&&300>ut()-Io?(Ze&2)===0&&il(i,0):kh|=l,el===We&&(el=0)),kn(i)}function g_(i,r){r===0&&(r=Xa()),i=Zr(i,r),i!==null&&(or(i,r),kn(i))}function YS(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),g_(i,l)}function VS(i,r){var l=0;switch(i.tag){case 31:case 13:var c=i.stateNode,p=i.memoizedState;p!==null&&(l=p.retryLane);break;case 19:c=i.stateNode;break;case 22:c=i.stateNode._retryCache;break;default:throw Error(s(314))}c!==null&&c.delete(r),g_(i,l)}function KS(i,r){return Qe(i,r)}var Vo=null,rl=null,Bh=!1,Ko=!1,Lh=!1,Tr=0;function kn(i){i!==rl&&i.next===null&&(rl===null?Vo=rl=i:rl=rl.next=i),Ko=!0,Bh||(Bh=!0,XS())}function ra(i,r){if(!Lh&&Ko){Lh=!0;do for(var l=!1,c=Vo;c!==null;){if(i!==0){var p=c.pendingLanes;if(p===0)var m=0;else{var x=c.suspendedLanes,C=c.pingedLanes;m=(1<<31-Je(42|i)+1)-1,m&=p&~(x&~C),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,b_(c,m))}else m=We,m=ks(c,c===lt?m:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(m&3)===0||Yr(c,m)||(l=!0,b_(c,m));c=c.next}while(l);Lh=!1}}function GS(){__()}function __(){Ko=Bh=!1;var i=0;Tr!==0&&l1()&&(i=Tr);for(var r=ut(),l=null,c=Vo;c!==null;){var p=c.next,m=v_(c,r);m===0?(c.next=null,l===null?Vo=p:l.next=p,p===null&&(rl=l)):(l=c,(i!==0||(m&3)!==0)&&(Ko=!0)),c=p}It!==0&&It!==5||ra(i),Tr!==0&&(Tr=0)}function v_(i,r){for(var l=i.suspendedLanes,c=i.pingedLanes,p=i.expirationTimes,m=i.pendingLanes&-62914561;0C)break;var te=N.transferSize,re=N.initiatorType;te&&A_(re)&&(N=N.responseEnd,x+=te*(N"u"?null:document;function I_(i,r,l){var c=sl;if(c&&typeof r=="string"&&r){var p=Qi(r);p='link[rel="'+i+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),P_.has(p)||(P_.add(p),i={rel:i,crossOrigin:l,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),ai(r,"link",i),Vt(r),c.head.appendChild(r)))}}function m1(i){er.D(i),I_("dns-prefetch",i,null)}function g1(i,r){er.C(i,r),I_("preconnect",i,r)}function _1(i,r,l){er.L(i,r,l);var c=sl;if(c&&i&&r){var p='link[rel="preload"][as="'+Qi(r)+'"]';r==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+Qi(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+Qi(l.imageSizes)+'"]')):p+='[href="'+Qi(i)+'"]';var m=p;switch(r){case"style":m=ll(i);break;case"script":m=al(i)}an.has(m)||(i=g({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),an.set(m,i),c.querySelector(p)!==null||r==="style"&&c.querySelector(oa(m))||r==="script"&&c.querySelector(ca(m))||(r=c.createElement("link"),ai(r,"link",i),Vt(r),c.head.appendChild(r)))}}function v1(i,r){er.m(i,r);var l=sl;if(l&&i){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+Qi(c)+'"][href="'+Qi(i)+'"]',m=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=al(i)}if(!an.has(m)&&(i=g({rel:"modulepreload",href:i},r),an.set(m,i),l.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ca(m)))return}c=l.createElement("link"),ai(c,"link",i),Vt(c),l.head.appendChild(c)}}}function y1(i,r,l){er.S(i,r,l);var c=sl;if(c&&i){var p=As(c).hoistableStyles,m=ll(i);r=r||"default";var x=p.get(m);if(!x){var C={loading:0,preload:null};if(x=c.querySelector(oa(m)))C.loading=5;else{i=g({rel:"stylesheet",href:i,"data-precedence":r},l),(l=an.get(m))&&Xh(i,l);var N=x=c.createElement("link");Vt(N),ai(N,"link",i),N._p=new Promise(function(W,te){N.onload=W,N.onerror=te}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Jo(x,r,c)}x={type:"stylesheet",instance:x,count:1,state:C},p.set(m,x)}}}function b1(i,r){er.X(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0},r),(r=an.get(p))&&Zh(i,r),m=l.createElement("script"),Vt(m),ai(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function x1(i,r){er.M(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0,type:"module"},r),(r=an.get(p))&&Zh(i,r),m=l.createElement("script"),Vt(m),ai(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function U_(i,r,l,c){var p=(p=ae.current)?Qo(p):null;if(!p)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=ll(l.href),l=As(p).hoistableStyles,c=l.get(r),c||(c={type:"style",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=ll(l.href);var m=As(p).hoistableStyles,x=m.get(i);if(x||(p=p.ownerDocument||p,x={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,x),(m=p.querySelector(oa(i)))&&!m._p&&(x.instance=m,x.state.loading=5),an.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},an.set(i,l),m||S1(p,i,l,x.state))),r&&c===null)throw Error(s(528,""));return x}if(r&&c!==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=al(l),l=As(p).hoistableScripts,c=l.get(r),c||(c={type:"script",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function ll(i){return'href="'+Qi(i)+'"'}function oa(i){return'link[rel="stylesheet"]['+i+"]"}function F_(i){return g({},i,{"data-precedence":i.precedence,precedence:null})}function S1(i,r,l,c){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=i.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),ai(r,"link",l),Vt(r),i.head.appendChild(r))}function al(i){return'[src="'+Qi(i)+'"]'}function ca(i){return"script[async]"+i}function q_(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var c=i.querySelector('style[data-href~="'+Qi(l.href)+'"]');if(c)return r.instance=c,Vt(c),c;var p=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),Vt(c),ai(c,"style",p),Jo(c,l.precedence,i),r.instance=c;case"stylesheet":p=ll(l.href);var m=i.querySelector(oa(p));if(m)return r.state.loading|=4,r.instance=m,Vt(m),m;c=F_(l),(p=an.get(p))&&Xh(c,p),m=(i.ownerDocument||i).createElement("link"),Vt(m);var x=m;return x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),ai(m,"link",c),r.state.loading|=4,Jo(m,l.precedence,i),r.instance=m;case"script":return m=al(l.src),(p=i.querySelector(ca(m)))?(r.instance=p,Vt(p),p):(c=l,(p=an.get(m))&&(c=g({},l),Zh(c,p)),i=i.ownerDocument||i,p=i.createElement("script"),Vt(p),ai(p,"link",c),i.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Jo(c,l.precedence,i));return r.instance}function Jo(i,r,l){for(var c=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,m=p,x=0;x title"):null)}function w1(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 Y_(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function C1(i,r,l,c){if(l.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=ll(c.href),m=r.querySelector(oa(p));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=tc.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Vt(m);return}m=r.ownerDocument||r,c=F_(c),(p=an.get(p))&&Xh(c,p),m=m.createElement("link"),Vt(m);var x=m;x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),ai(m,"link",c),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=tc.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var Qh=0;function k1(i,r){return i.stylesheets&&i.count===0&&nc(i,i.stylesheets),0Qh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function tc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nc(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ic=null;function nc(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ic=new Map,r.forEach(E1,i),ic=null,tc.call(i))}function E1(i,r){if(!(r.state.loading&4)){var l=ic.get(i);if(l)var c=l.get(null);else{l=new Map,ic.set(i,l);for(var p=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(),ad.exports=q1(),ad.exports}var $1=W1();const Y1=Uc($1);function V1({onLogin:e}){const[t,n]=L.useState(""),[s,a]=L.useState(null),[o,u]=L.useState(!1),d=async f=>{if(f.preventDefault(),!t.trim())return;u(!0),a(null);const h=await e(t);h&&a(h),u(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsxs("div",{className:"w-full max-w-sm",children:[v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),v.jsxs("form",{onSubmit:d,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:f=>n(f.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&&v.jsx("p",{className:"text-error text-xs",children:s}),v.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"})]})]}),v.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function K1({onSetup:e}){const[t,n]=L.useState(""),[s,a]=L.useState(""),[o,u]=L.useState(null),[d,f]=L.useState(!1),h=async _=>{if(_.preventDefault(),!t.trim()||t.length<4){u("Passphrase must be at least 4 characters");return}if(t!==s){u("Passphrases do not match");return}f(!0),u(null);const g=await e(t);g&&u(g),f(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsx("div",{className:"w-full max-w-sm",children:v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),v.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."}),v.jsxs("form",{onSubmit:h,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:_=>n(_.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),v.jsx("input",{type:"password",value:s,onChange:_=>a(_.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&v.jsx("p",{className:"text-error text-xs",children:o}),v.jsx("button",{type:"submit",disabled:d||!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:d?"setting up...":"create passphrase"})]})]})})})}const gv="http://localhost:7777";function xb({token:e}){const[t,n]=L.useState(null),[s,a]=L.useState(!1),[o,u]=L.useState(!1),[d,f]=L.useState(null),h=(S,T)=>fetch(S,{...T,headers:{...T==null?void 0:T.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),_=()=>{h(`${gv}/api/wallet`).then(S=>S.json()).then(S=>n(S)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};L.useEffect(()=>{_()},[]);const g=async()=>{a(!0),f(null);try{const S=await h(`${gv}/api/wallet/create`,{method:"POST"}),T=await S.json();if(!S.ok)throw new Error(T.error||"Creation failed");_()}catch(S){f(S instanceof Error?S.message:"Failed to create wallet")}a(!1)},y=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),u(!0),setTimeout(()=>u(!1),2e3))},b=S=>`${S.slice(0,6)}...${S.slice(-4)}`;return v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&v.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),d&&v.jsx("p",{className:"text-error text-xs",children:d}),v.jsx("button",{onClick:g,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&&v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),v.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"})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:b(t.address)}),v.jsx("button",{onClick:y,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),v.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC"}),v.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"PLOT"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Network"}),v.jsx("span",{className:"text-foreground",children:"Base"})]})]}),v.jsxs("div",{className:"border-border border-t pt-3",children:[v.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),v.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),v.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 G1({token:e,onLogout:t}){const[n,s]=L.useState(""),[a,o]=L.useState(""),[u,d]=L.useState(null),[f,h]=L.useState(!1),[_,g]=L.useState(!1),[y,b]=L.useState(null),[S,T]=L.useState("AI Writer"),[B,D]=L.useState(""),[X,P]=L.useState(""),[J,I]=L.useState(!1),[M,Q]=L.useState(null),[ce,me]=L.useState(""),[z,ie]=L.useState(null),[$,F]=L.useState(!1),[Y,A]=L.useState(null),[E,j]=L.useState(null),U=L.useCallback((w,V)=>fetch(w,{...V,headers:{...V==null?void 0:V.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);L.useEffect(()=>{U("/api/settings/link-status").then(w=>w.json()).then(w=>b(w)).catch(()=>b({linked:!1}))},[]);const le=async()=>{if(!S.trim()){Q("Agent name is required");return}if(!B.trim()){Q("Description is required");return}I(!0),Q(null);try{const w=await U("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:S,description:B,...X.trim()&&{genre:X}})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Registration failed");b({linked:!0,agentId:V.agentId,owsWallet:V.owsWallet,txHash:V.txHash})}catch(w){Q(w instanceof Error?w.message:"Registration failed")}I(!1)},k=async()=>{if(!ce.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ce)){A("Enter a valid wallet address (0x...)");return}F(!0),A(null),ie(null);try{const w=await U("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ce})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Failed to generate binding code");ie(V)}catch(w){A(w instanceof Error?w.message:"Failed to generate binding code")}F(!1)},R=async(w,V)=>{await navigator.clipboard.writeText(w),j(V),setTimeout(()=>j(null),2e3)},K=async()=>{if(d(null),h(!1),!n||n.length<4){d("Passphrase must be at least 4 characters");return}if(n!==a){d("Passphrases do not match");return}g(!0);try{const w=await U("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!w.ok){const V=await w.json();throw new Error(V.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(w){d(w instanceof Error?w.message:"Reset failed")}g(!1)};return v.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),y!=null&&y.linked?v.jsxs("div",{className:"space-y-2",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),v.jsxs("span",{className:"text-muted text-xs",children:["Agent #",y.agentId]})]}),y.owsWallet&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",y.owsWallet.slice(0,6),"...",y.owsWallet.slice(-4)]}),y.owner&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",y.owner.slice(0,6),"...",y.owner.slice(-4)]}),y.txHash&&v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://plotlink.xyz/profile/${y.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),v.jsx("input",{value:S,onChange:w=>T(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),v.jsx("input",{value:B,onChange:w=>D(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),v.jsx("input",{value:X,onChange:w=>P(w.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),M&&v.jsx("p",{className:"text-error text-xs",children:M}),v.jsx("button",{onClick:le,disabled:J||!S.trim()||!B.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:J?"Registering...":"Register Agent Identity"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),y!=null&&y.owner?v.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",v.jsxs("span",{className:"font-mono",children:[y.owner.slice(0,6),"...",y.owner.slice(-4)]})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[v.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),v.jsx("p",{children:'2. Click "Generate Binding Code"'}),v.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),v.jsx("input",{value:ce,onChange:w=>me(w.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),Y&&v.jsx("p",{className:"text-error text-xs",children:Y}),v.jsx("button",{onClick:k,disabled:$||!ce.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:$?"Generating...":"Generate Binding Code"}),z&&v.jsxs("div",{className:"space-y-3 mt-3",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.signature}),v.jsx("button",{onClick:()=>R(z.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:E==="signature"?"Copied!":"Copy"})]})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.owsWallet}),v.jsx("button",{onClick:()=>R(z.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:E==="wallet"?"Copied!":"Copy"})]})]}),z.agentId&&v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:z.agentId}),v.jsx("button",{onClick:()=>R(String(z.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:E==="agentId"?"Copied!":"Copy"})]})]}),v.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),v.jsx(xb,{token:e}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("input",{type:"password",value:n,onChange:w=>s(w.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"}),v.jsx("input",{type:"password",value:a,onChange:w=>o(w.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"}),u&&v.jsx("p",{className:"text-error text-xs",children:u}),f&&v.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),v.jsx("button",{onClick:K,disabled:_||!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:_?"updating...":"update passphrase"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),v.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 X1="http://localhost:7777";function Z1({token:e}){const[t,n]=L.useState(null),s=(d,f)=>fetch(d,{...f,headers:{...f==null?void 0:f.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${X1}/api/dashboard`).then(d=>d.json()).then(n)};L.useEffect(()=>{a()},[]);const o=d=>`${d.slice(0,6)}...${d.slice(-4)}`,u=d=>{if(!d)return"Unknown date";const f=new Date(d);return isNaN(f.getTime())?"Unknown date":f.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?v.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),v.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Address"}),v.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH Balance"}),v.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC Balance"}),v.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),v.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Royalties earned"}),v.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),v.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),v.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[v.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),v.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Stories published"}),v.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?v.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):v.jsx("div",{className:"space-y-3",children:t.stories.published.map(d=>v.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[v.jsxs("div",{className:"flex items-start justify-between",children:[v.jsxs("div",{children:[d.genre&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:d.genre}),v.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:d.title}),v.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:d.storyName})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[d.hasNotIndexed&&v.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),v.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[d.publishedFiles," published"]})]})]}),v.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.plotCount}),v.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:d.storylineId?`#${d.storylineId}`:"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.totalGasCostEth??"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),v.jsx("div",{className:"mt-2 space-y-1",children:d.files.map(f=>v.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[v.jsxs("div",{className:"flex items-center gap-1.5",children:[v.jsx("span",{className:f.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:f.status==="published-not-indexed"?"⚠":"✓"}),v.jsx("span",{className:"text-muted font-mono",children:f.file})]}),f.txHash&&v.jsxs("a",{href:`https://basescan.org/tx/${f.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",f.txHash.slice(0,8),"..."]})]},f.file))}),v.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[v.jsx("span",{className:"text-muted",children:u(d.latestPublishedAt)}),d.storylineId&&v.jsx("a",{href:`https://plotlink.xyz/story/${d.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},d.id))})]}),t.stories.pendingFiles>0&&v.jsx("div",{className:"border-border rounded border p-4",children:v.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):v.jsx("div",{className:"flex h-full items-center justify-center",children:v.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Q1={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},J1={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function ew({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[u,d]=L.useState([]),[f,h]=L.useState([]),[_,g]=L.useState(new Set),[y,b]=L.useState(!1),S=L.useCallback(async()=>{try{const I=await e("/api/stories");if(I.ok){const M=await I.json();d(M.stories)}}catch{}},[e]),T=L.useCallback(async()=>{try{const I=await e("/api/stories/archived");if(I.ok){const M=await I.json();h(M.stories)}}catch{}},[e]),B=L.useCallback(async I=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I})})).ok&&(T(),S())}catch{}},[e,T,S]);L.useEffect(()=>{S();const I=setInterval(S,5e3);return()=>clearInterval(I)},[S]),L.useEffect(()=>{y&&T()},[y,T]),L.useEffect(()=>{t&&g(I=>new Set(I).add(t))},[t]);const D=I=>{var Q;const M=I.map(ce=>{var me;return{file:ce.file,num:(me=ce.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ce=>ce.num!=null).sort((ce,me)=>parseInt(me.num)-parseInt(ce.num));return M.length>0?M[0].file:I.some(ce=>ce.file==="genesis.md")?"genesis.md":I.some(ce=>ce.file==="structure.md")?"structure.md":((Q=I[0])==null?void 0:Q.file)??null},X=I=>{g(M=>{const Q=new Set(M);return Q.has(I)?Q.delete(I):Q.add(I),Q})},P=I=>{if(X(I.name),!_.has(I.name)){const M=D(I.files);M&&s(I.name,M)}},J=I=>{const M=Q=>{if(Q==="structure.md")return 0;if(Q==="genesis.md")return 1;const ce=Q.match(/^plot-(\d+)\.md$/);return ce?2+parseInt(ce[1]):100};return[...I].sort((Q,ce)=>M(Q.file)-M(ce.file))};return y?v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),v.jsx("span",{className:"text-xs text-muted",children:f.length})]}),v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.jsxs("button",{onClick:()=>b(!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:[v.jsx("span",{children:"←"}),v.jsx("span",{children:"Back"})]})}),v.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?v.jsx("div",{className:"p-3 text-sm text-muted",children:v.jsx("p",{children:"No archived stories."})}):f.map(I=>v.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[v.jsx("span",{className:"text-sm font-medium truncate",title:I.name,children:I.title||I.name}),v.jsx("button",{onClick:()=>B(I.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},I.name))})]}):v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),v.jsx("span",{className:"text-xs text-muted",children:u.length})]}),a&&v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.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:[v.jsx("span",{children:"+"}),v.jsx("span",{children:"New Story"})]})}),v.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(I=>v.jsx("div",{children:v.jsxs("button",{onClick:()=>s(I,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===I?"bg-surface":""}`,children:[v.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),v.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},I)),u.length===0&&o.length===0?v.jsxs("div",{className:"p-3 text-sm text-muted",children:[v.jsx("p",{children:"No stories yet."}),v.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):u.filter(I=>I.name!=="_example").map(I=>v.jsxs("div",{children:[v.jsxs("button",{onClick:()=>P(I),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[v.jsx("span",{className:"text-xs text-muted",children:_.has(I.name)?"▼":"▶"}),v.jsx("span",{className:"font-medium truncate",title:I.name,children:I.title||I.name}),I.contentType==="cartoon"&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),v.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[I.publishedCount,"/",I.files.length]})]}),_.has(I.name)&&v.jsx("div",{className:"pl-4",children:J(I.files).map(M=>{const Q=t===I.name&&n===M.file;return v.jsxs("button",{onClick:()=>s(I.name,M.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${Q?"bg-surface font-medium":""}`,children:[v.jsx("span",{className:J1[M.status],children:Q1[M.status]}),v.jsx("span",{className:"truncate font-mono",children:M.file})]},M.file)})})]},I.name))]}),v.jsx("div",{className:"px-3 py-2 border-t border-border",children:v.jsx("button",{onClick:()=>b(!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:v.jsx("span",{children:"Archives"})})})]})}/** +`+c.stack}}var wt=Object.prototype.hasOwnProperty,Dt=e.unstable_scheduleCallback,Ti=e.unstable_cancelCallback,Ai=e.unstable_shouldYield,ut=e.unstable_requestPaint,Ze=e.unstable_now,Gt=e.unstable_getCurrentPriorityLevel,ie=e.unstable_ImmediatePriority,de=e.unstable_UserBlockingPriority,we=e.unstable_NormalPriority,Ne=e.unstable_LowPriority,Ie=e.unstable_IdlePriority,It=e.log,_t=e.unstable_setDisableYieldValue,Xt=null,ft=null;function mi(i){if(typeof It=="function"&&_t(i),ft&&typeof ft.setStrictMode=="function")try{ft.setStrictMode(Xt,i)}catch{}}var Je=Math.clz32?Math.clz32:Cs,wn=Math.log,Di=Math.LN2;function Cs(i){return i>>>=0,i===0?32:31-(wn(i)/Di|0)|0}var Wr=256,Qi=262144,$r=4194304;function mn(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 ks(i,r,l){var c=i.pendingLanes;if(c===0)return 0;var p=0,m=i.suspendedLanes,x=i.pingedLanes;i=i.warmLanes;var C=c&134217727;return C!==0?(c=C&~m,c!==0?p=mn(c):(x&=C,x!==0?p=mn(x):l||(l=C&~i,l!==0&&(p=mn(l))))):(C=c&~m,C!==0?p=mn(C):x!==0?p=mn(x):l||(l=c&~i,l!==0&&(p=mn(l)))),p===0?0:r!==0&&r!==p&&(r&m)===0&&(m=p&-p,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:p}function Yr(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function wl(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 Xa(){var i=$r;return $r<<=1,($r&62914560)===0&&($r=4194304),i}function Cl(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function or(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Za(i,r,l,c,p,m){var x=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 C=i.entanglements,N=i.expirationTimes,$=i.hiddenUpdates;for(l=x&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var DS=/[\n"\\]/g;function en(i){return i.replace(DS,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Jc(i,r,l,c,p,m,x,C){i.name="",x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?i.type=x:i.removeAttribute("type"),r!=null?x==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ji(r)):i.value!==""+Ji(r)&&(i.value=""+Ji(r)):x!=="submit"&&x!=="reset"||i.removeAttribute("value"),r!=null?eu(i,x,Ji(r)):l!=null?eu(i,x,Ji(l)):c!=null&&i.removeAttribute("value"),p==null&&m!=null&&(i.defaultChecked=!!m),p!=null&&(i.checked=p&&typeof p!="function"&&typeof p!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+Ji(C):i.removeAttribute("name")}function wp(i,r,l,c,p,m,x,C){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)){Qc(i);return}l=l!=null?""+Ji(l):"",r=r!=null?""+Ji(r):l,C||r===i.value||(i.value=r),i.defaultValue=r}c=c??p,c=typeof c!="function"&&typeof c!="symbol"&&!!c,i.checked=C?i.checked:!!c,i.defaultChecked=!!c,x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(i.name=x),Qc(i)}function eu(i,r,l){r==="number"&&eo(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function Rs(i,r,l,c){if(i=i.options,r){r={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),su=!1;if(Pn)try{var Al={};Object.defineProperty(Al,"passive",{get:function(){su=!0}}),window.addEventListener("test",Al,Al),window.removeEventListener("test",Al,Al)}catch{su=!1}var hr=null,lu=null,io=null;function Rp(){if(io)return io;var i,r=lu,l=r.length,c,p="value"in hr?hr.value:hr.textContent,m=p.length;for(i=0;i=Nl),zp=" ",jp=!1;function Hp(i,r){switch(i){case"keyup":return n0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pp(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ls=!1;function s0(i,r){switch(i){case"compositionend":return Pp(r);case"keypress":return r.which!==32?null:(jp=!0,zp);case"textInput":return i=r.data,i===zp&&jp?null:i;default:return null}}function l0(i,r){if(Ls)return i==="compositionend"||!hu&&Hp(i,r)?(i=Rp(),io=lu=hr=null,Ls=!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=c}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Vp(l)}}function Gp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Gp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Xp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=eo(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=eo(i.document)}return r}function pu(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 p0=Pn&&"documentMode"in document&&11>=document.documentMode,Os=null,mu=null,Ol=null,gu=!1;function Zp(i,r,l){var c=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;gu||Os==null||Os!==eo(c)||(c=Os,"selectionStart"in c&&pu(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Ol&&Ll(Ol,c)||(Ol=c,c=Xo(mu,"onSelect"),0>=x,p-=x,Cn=1<<32-Je(r)+p|l<Le?($e=be,be=null):$e=be.sibling;var Xe=K(H,be,W[Le],ne);if(Xe===null){be===null&&(be=$e);break}i&&be&&Xe.alternate===null&&r(H,be),O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe,be=$e}if(Le===W.length)return l(H,be),Ye&&Un(H,Le),Ce;if(be===null){for(;LeLe?($e=be,be=null):$e=be.sibling;var Br=K(H,be,Xe.value,ne);if(Br===null){be===null&&(be=$e);break}i&&be&&Br.alternate===null&&r(H,be),O=m(Br,O,Le),Ge===null?Ce=Br:Ge.sibling=Br,Ge=Br,be=$e}if(Xe.done)return l(H,be),Ye&&Un(H,Le),Ce;if(be===null){for(;!Xe.done;Le++,Xe=W.next())Xe=re(H,Xe.value,ne),Xe!==null&&(O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe);return Ye&&Un(H,Le),Ce}for(be=c(be);!Xe.done;Le++,Xe=W.next())Xe=Z(be,H,Le,Xe.value,ne),Xe!==null&&(i&&Xe.alternate!==null&&be.delete(Xe.key===null?Le:Xe.key),O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe);return i&&be.forEach(function(L1){return r(H,L1)}),Ye&&Un(H,Le),Ce}function rt(H,O,W,ne){if(typeof W=="object"&&W!==null&&W.type===T&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case b:e:{for(var Ce=W.key;O!==null;){if(O.key===Ce){if(Ce=W.type,Ce===T){if(O.tag===7){l(H,O.sibling),ne=p(O,W.props.children),ne.return=H,H=ne;break e}}else if(O.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ue&&ns(Ce)===O.type){l(H,O.sibling),ne=p(O,W.props),Ul(ne,W),ne.return=H,H=ne;break e}l(H,O);break}else r(H,O);O=O.sibling}W.type===T?(ne=Qr(W.props.children,H.mode,ne,W.key),ne.return=H,H=ne):(ne=fo(W.type,W.key,W.props,null,H.mode,ne),Ul(ne,W),ne.return=H,H=ne)}return x(H);case S:e:{for(Ce=W.key;O!==null;){if(O.key===Ce)if(O.tag===4&&O.stateNode.containerInfo===W.containerInfo&&O.stateNode.implementation===W.implementation){l(H,O.sibling),ne=p(O,W.children||[]),ne.return=H,H=ne;break e}else{l(H,O);break}else r(H,O);O=O.sibling}ne=wu(W,H.mode,ne),ne.return=H,H=ne}return x(H);case ue:return W=ns(W),rt(H,O,W,ne)}if(A(W))return ve(H,O,W,ne);if(F(W)){if(Ce=F(W),typeof Ce!="function")throw Error(s(150));return W=Ce.call(W),Ee(H,O,W,ne)}if(typeof W.then=="function")return rt(H,O,bo(W),ne);if(W.$$typeof===P)return rt(H,O,go(H,W),ne);xo(H,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,O!==null&&O.tag===6?(l(H,O.sibling),ne=p(O,W),ne.return=H,H=ne):(l(H,O),ne=Su(W,H.mode,ne),ne.return=H,H=ne),x(H)):l(H,O)}return function(H,O,W,ne){try{Il=0;var Ce=rt(H,O,W,ne);return Ys=null,Ce}catch(be){if(be===$s||be===vo)throw be;var Ge=Fi(29,be,null,H.mode);return Ge.lanes=ne,Ge.return=H,Ge}finally{}}}var ss=bm(!0),xm=bm(!1),gr=!1;function Ou(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zu(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 _r(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function vr(i,r,l){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Qe&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=ho(i),rm(i,null,l),r}return uo(i,c,r,l),ho(i)}function Fl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}function ju(i,r){var l=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var p=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var x={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?p=m=x:m=m.next=x,l=l.next}while(l!==null);m===null?p=m=r:m=m.next=r}else p=m=r;l={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:m,shared:c.shared,callbacks:c.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var Hu=!1;function ql(){if(Hu){var i=Ws;if(i!==null)throw i}}function Wl(i,r,l,c){Hu=!1;var p=i.updateQueue;gr=!1;var m=p.firstBaseUpdate,x=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var N=C,$=N.next;N.next=null,x===null?m=$:x.next=$,x=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,C=ee.lastBaseUpdate,C!==x&&(C===null?ee.firstBaseUpdate=$:C.next=$,ee.lastBaseUpdate=N))}if(m!==null){var re=p.baseState;x=0,ee=$=N=null,C=m;do{var K=C.lane&-536870913,Z=K!==C.lane;if(Z?(We&K)===K:(c&K)===K){K!==0&&K===qs&&(Hu=!0),ee!==null&&(ee=ee.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var ve=i,Ee=C;K=r;var rt=l;switch(Ee.tag){case 1:if(ve=Ee.payload,typeof ve=="function"){re=ve.call(rt,re,K);break e}re=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ee.payload,K=typeof ve=="function"?ve.call(rt,re,K):ve,K==null)break e;re=g({},re,K);break e;case 2:gr=!0}}K=C.callback,K!==null&&(i.flags|=64,Z&&(i.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[K]:Z.push(K))}else Z={lane:K,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ee===null?($=ee=Z,N=re):ee=ee.next=Z,x|=K;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);ee===null&&(N=re),p.baseState=N,p.firstBaseUpdate=$,p.lastBaseUpdate=ee,m===null&&(p.shared.lanes=0),wr|=x,i.lanes=x,i.memoizedState=re}}function Sm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function wm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var x=k.T,C={};k.T=C,nh(i,!1,r,l);try{var N=p(),$=k.S;if($!==null&&$(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=w0(N,c);Vl(i,r,ee,Vi(i))}else Vl(i,r,c,Vi(i))}catch(re){Vl(i,r,{then:function(){},status:"rejected",reason:re},Vi())}finally{j.p=m,x!==null&&C.types!==null&&(x.types=C.types),k.T=x}}function D0(){}function th(i,r,l,c){if(i.tag!==5)throw Error(s(476));var p=tg(i).queue;eg(i,p,r,U,l===null?D0:function(){return ig(i),l(c)})}function tg(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:U},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function ig(i){var r=tg(i);r.next===null&&(r=i.alternate.memoizedState),Vl(i,r.next.queue,{},Vi())}function ih(){return ci(ua)}function ng(){return Nt().memoizedState}function rg(){return Nt().memoizedState}function R0(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Vi();i=_r(l);var c=vr(r,i,l);c!==null&&(Oi(c,r,l),Fl(c,r,l)),r={cache:Nu()},i.payload=r;return}r=r.return}}function N0(i,r,l){var c=Vi();l={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},No(i)?lg(r,l):(l=bu(i,r,l,c),l!==null&&(Oi(l,i,c),ag(l,r,c)))}function sg(i,r,l){var c=Vi();Vl(i,r,l,c)}function Vl(i,r,l,c){var p={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(No(i))lg(r,p);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var x=r.lastRenderedState,C=m(x,l);if(p.hasEagerState=!0,p.eagerState=C,Ui(C,x))return uo(i,r,p,0),at===null&&co(),!1}catch{}finally{}if(l=bu(i,r,p,c),l!==null)return Oi(l,i,c),ag(l,r,c),!0}return!1}function nh(i,r,l,c){if(c={lane:2,revertLane:Oh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},No(i)){if(r)throw Error(s(479))}else r=bu(i,l,c,2),r!==null&&Oi(r,i,2)}function No(i){var r=i.alternate;return i===Be||r!==null&&r===Be}function lg(i,r){Ks=Co=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function ag(i,r,l){if((l&4194048)!==0){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}var Kl={readContext:ci,use:To,useCallback:Ct,useContext:Ct,useEffect:Ct,useImperativeHandle:Ct,useLayoutEffect:Ct,useInsertionEffect:Ct,useMemo:Ct,useReducer:Ct,useRef:Ct,useState:Ct,useDebugValue:Ct,useDeferredValue:Ct,useTransition:Ct,useSyncExternalStore:Ct,useId:Ct,useHostTransitionStatus:Ct,useFormState:Ct,useActionState:Ct,useOptimistic:Ct,useMemoCache:Ct,useCacheRefresh:Ct};Kl.useEffectEvent=Ct;var og={readContext:ci,use:To,useCallback:function(i,r){return xi().memoizedState=[i,r===void 0?null:r],i},useContext:ci,useEffect:$m,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,Do(4194308,4,Gm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return Do(4194308,4,i,r)},useInsertionEffect:function(i,r){Do(4,2,i,r)},useMemo:function(i,r){var l=xi();r=r===void 0?null:r;var c=i();if(ls){mi(!0);try{i()}finally{mi(!1)}}return l.memoizedState=[c,r],c},useReducer:function(i,r,l){var c=xi();if(l!==void 0){var p=l(r);if(ls){mi(!0);try{l(r)}finally{mi(!1)}}}else p=r;return c.memoizedState=c.baseState=p,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:p},c.queue=i,i=i.dispatch=N0.bind(null,Be,i),[c.memoizedState,i]},useRef:function(i){var r=xi();return i={current:i},r.memoizedState=i},useState:function(i){i=Xu(i);var r=i.queue,l=sg.bind(null,Be,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Ju,useDeferredValue:function(i,r){var l=xi();return eh(l,i,r)},useTransition:function(){var i=Xu(!1);return i=eg.bind(null,Be,i.queue,!0,!1),xi().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var c=Be,p=xi();if(Ye){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),at===null)throw Error(s(349));(We&127)!==0||Dm(c,r,l)}p.memoizedState=l;var m={value:l,getSnapshot:r};return p.queue=m,$m(Nm.bind(null,c,m,i),[i]),c.flags|=2048,Xs(9,{destroy:void 0},Rm.bind(null,c,m,l,r),null),l},useId:function(){var i=xi(),r=at.identifierPrefix;if(Ye){var l=kn,c=Cn;l=(c&~(1<<32-Je(c)-1)).toString(32)+l,r="_"+r+"R_"+l,l=ko++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof c.is=="string"?x.createElement("select",{is:c.is}):x.createElement("select"),c.multiple?m.multiple=!0:c.size&&(m.size=c.size);break;default:m=typeof c.is=="string"?x.createElement(p,{is:c.is}):x.createElement(p)}}m[Ut]=r,m[Ft]=c;e:for(x=r.child;x!==null;){if(x.tag===5||x.tag===6)m.appendChild(x.stateNode);else if(x.tag!==4&&x.tag!==27&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===r)break e;for(;x.sibling===null;){if(x.return===null||x.return===r)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}r.stateNode=m;e:switch(hi(m,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Vn(r)}}return mt(r),_h(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==c&&Vn(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(i=ae.current,Us(r)){if(i=r.stateNode,l=r.memoizedProps,c=null,p=oi,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}i[Ut]=r,i=!!(i.nodeValue===l||c!==null&&c.suppressHydrationWarning===!0||T_(i.nodeValue,l)),i||pr(r,!0)}else i=Zo(i).createTextNode(c),i[Ut]=r,r.stateNode=i}return mt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(c=Us(r),l!==null){if(i===null){if(!c)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Ut]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mt(r),i=!1}else l=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Wi(r),r):(Wi(r),null);if((r.flags&128)!==0)throw Error(s(558))}return mt(r),null;case 13:if(c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(p=Us(r),c!==null&&c.dehydrated!==null){if(i===null){if(!p)throw Error(s(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(s(317));p[Ut]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mt(r),p=!1}else p=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Wi(r),r):(Wi(r),null)}return Wi(r),(r.flags&128)!==0?(r.lanes=l,r):(l=c!==null,i=i!==null&&i.memoizedState!==null,l&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),m=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),m!==p&&(c.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),zo(r,r.updateQueue),mt(r),null);case 4:return xe(),i===null&&Ph(r.stateNode.containerInfo),mt(r),null;case 10:return qn(r.type),mt(r),null;case 19:if(Y(Rt),c=r.memoizedState,c===null)return mt(r),null;if(p=(r.flags&128)!==0,m=c.rendering,m===null)if(p)Xl(c,!1);else{if(kt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=wo(i),m!==null){for(r.flags|=128,Xl(c,!1),i=m.updateQueue,r.updateQueue=i,zo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)sm(l,i),l=l.sibling;return w(Rt,Rt.current&1|2),Ye&&Un(r,c.treeForkCount),r.child}i=i.sibling}c.tail!==null&&Ze()>Uo&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304)}else{if(!p)if(i=wo(m),i!==null){if(r.flags|=128,p=!0,i=i.updateQueue,r.updateQueue=i,zo(r,i),Xl(c,!0),c.tail===null&&c.tailMode==="hidden"&&!m.alternate&&!Ye)return mt(r),null}else 2*Ze()-c.renderingStartTime>Uo&&l!==536870912&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304);c.isBackwards?(m.sibling=r.child,r.child=m):(i=c.last,i!==null?i.sibling=m:r.child=m,c.last=m)}return c.tail!==null?(i=c.tail,c.rendering=i,c.tail=i.sibling,c.renderingStartTime=Ze(),i.sibling=null,l=Rt.current,w(Rt,p?l&1|2:l&1),Ye&&Un(r,c.treeForkCount),i):(mt(r),null);case 22:case 23:return Wi(r),Iu(),c=r.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(l&536870912)!==0&&(r.flags&128)===0&&(mt(r),r.subtreeFlags&6&&(r.flags|=8192)):mt(r),l=r.updateQueue,l!==null&&zo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==l&&(r.flags|=2048),i!==null&&Y(is),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),qn(Bt),mt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function z0(i,r){switch(ku(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return qn(Bt),xe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return ct(r),null;case 31:if(r.memoizedState!==null){if(Wi(r),r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Wi(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return Y(Rt),null;case 4:return xe(),null;case 10:return qn(r.type),null;case 22:case 23:return Wi(r),Iu(),i!==null&&Y(is),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return qn(Bt),null;case 25:return null;default:return null}}function Mg(i,r){switch(ku(r),r.tag){case 3:qn(Bt),xe();break;case 26:case 27:case 5:ct(r);break;case 4:xe();break;case 31:r.memoizedState!==null&&Wi(r);break;case 13:Wi(r);break;case 19:Y(Rt);break;case 10:qn(r.type);break;case 22:case 23:Wi(r),Iu(),i!==null&&Y(is);break;case 24:qn(Bt)}}function Zl(i,r){try{var l=r.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var p=c.next;l=p;do{if((l.tag&i)===i){c=void 0;var m=l.create,x=l.inst;c=m(),x.destroy=c}l=l.next}while(l!==p)}}catch(C){tt(r,r.return,C)}}function xr(i,r,l){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var m=p.next;c=m;do{if((c.tag&i)===i){var x=c.inst,C=x.destroy;if(C!==void 0){x.destroy=void 0,p=r;var N=l,$=C;try{$()}catch(ee){tt(p,N,ee)}}}c=c.next}while(c!==m)}}catch(ee){tt(r,r.return,ee)}}function Bg(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{wm(r,l)}catch(c){tt(i,i.return,c)}}}function Lg(i,r,l){l.props=as(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(c){tt(i,r,c)}}function Ql(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var c=i.stateNode;break;case 30:c=i.stateNode;break;default:c=i.stateNode}typeof l=="function"?i.refCleanup=l(c):l.current=c}}catch(p){tt(i,r,p)}}function En(i,r){var l=i.ref,c=i.refCleanup;if(l!==null)if(typeof c=="function")try{c()}catch(p){tt(i,r,p)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){tt(i,r,p)}else l.current=null}function Og(i){var r=i.type,l=i.memoizedProps,c=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&c.focus();break e;case"img":l.src?c.src=l.src:l.srcSet&&(c.srcset=l.srcSet)}}catch(p){tt(i,i.return,p)}}function vh(i,r,l){try{var c=i.stateNode;r1(c,i.type,l,r),c[Ft]=r}catch(p){tt(i,i.return,p)}}function zg(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ar(i.type)||i.tag===4}function yh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||zg(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&&Ar(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 bh(i,r,l){var c=i.tag;if(c===5||c===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=Hn));else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(bh(i,r,l),i=i.sibling;i!==null;)bh(i,r,l),i=i.sibling}function jo(i,r,l){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(jo(i,r,l),i=i.sibling;i!==null;)jo(i,r,l),i=i.sibling}function jg(i){var r=i.stateNode,l=i.memoizedProps;try{for(var c=i.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);hi(r,c,l),r[Ut]=i,r[Ft]=l}catch(m){tt(i,i.return,m)}}var Kn=!1,zt=!1,xh=!1,Hg=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function j0(i,r){if(i=i.containerInfo,Fh=rc,i=Xp(i),pu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var p=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var x=0,C=-1,N=-1,$=0,ee=0,re=i,K=null;t:for(;;){for(var Z;re!==l||p!==0&&re.nodeType!==3||(C=x+p),re!==m||c!==0&&re.nodeType!==3||(N=x+c),re.nodeType===3&&(x+=re.nodeValue.length),(Z=re.firstChild)!==null;)K=re,re=Z;for(;;){if(re===i)break t;if(K===l&&++$===p&&(C=x),K===m&&++ee===c&&(N=x),(Z=re.nextSibling)!==null)break;re=K,K=re.parentNode}re=Z}l=C===-1||N===-1?null:{start:C,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(qh={focusedElem:i,selectionRange:l},rc=!1,Qt=r;Qt!==null;)if(r=Qt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Qt=i;else for(;Qt!==null;){switch(r=Qt,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"))),hi(m,c,l),m[Ut]=i,Zt(m),c=m;break e;case"link":var x=W_("link","href",p).get(c+(l.href||""));if(x){for(var C=0;Crt&&(x=rt,rt=Ee,Ee=x);var H=Kp(C,Ee),O=Kp(C,rt);if(H&&O&&(Z.rangeCount!==1||Z.anchorNode!==H.node||Z.anchorOffset!==H.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var W=re.createRange();W.setStart(H.node,H.offset),Z.removeAllRanges(),Ee>rt?(Z.addRange(W),Z.extend(O.node,O.offset)):(W.setEnd(O.node,O.offset),Z.addRange(W))}}}}for(re=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&re.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cl?32:l,k.T=null,l=Ah,Ah=null;var m=kr,x=Jn;if(Wt=0,tl=kr=null,Jn=0,(Qe&6)!==0)throw Error(s(331));var C=Qe;if(Qe|=4,Gg(m.current),Yg(m,m.current,x,l),Qe=C,ra(0,!1),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(Xt,m)}catch{}return!0}finally{j.p=p,k.T=c,f_(i,r)}}function m_(i,r,l){r=nn(l,r),r=ah(i.stateNode,r,2),i=vr(i,r,2),i!==null&&(or(i,2),Tn(i))}function tt(i,r,l){if(i.tag===3)m_(i,i,l);else for(;r!==null;){if(r.tag===3){m_(r,i,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Cr===null||!Cr.has(c))){i=nn(l,i),l=gg(2),c=vr(r,l,2),c!==null&&(_g(l,c,r,i),or(c,2),Tn(c));break}}r=r.return}}function Mh(i,r,l){var c=i.pingCache;if(c===null){c=i.pingCache=new I0;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(l)||(Ch=!0,p.add(l),i=$0.bind(null,i,r,l),r.then(i,i))}function $0(i,r,l){var c=i.pingCache;c!==null&&c.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,at===i&&(We&l)===l&&(kt===4||kt===3&&(We&62914560)===We&&300>Ze()-Io?(Qe&2)===0&&il(i,0):kh|=l,el===We&&(el=0)),Tn(i)}function g_(i,r){r===0&&(r=Xa()),i=Zr(i,r),i!==null&&(or(i,r),Tn(i))}function Y0(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),g_(i,l)}function V0(i,r){var l=0;switch(i.tag){case 31:case 13:var c=i.stateNode,p=i.memoizedState;p!==null&&(l=p.retryLane);break;case 19:c=i.stateNode;break;case 22:c=i.stateNode._retryCache;break;default:throw Error(s(314))}c!==null&&c.delete(r),g_(i,l)}function K0(i,r){return Dt(i,r)}var Vo=null,rl=null,Bh=!1,Ko=!1,Lh=!1,Tr=0;function Tn(i){i!==rl&&i.next===null&&(rl===null?Vo=rl=i:rl=rl.next=i),Ko=!0,Bh||(Bh=!0,X0())}function ra(i,r){if(!Lh&&Ko){Lh=!0;do for(var l=!1,c=Vo;c!==null;){if(i!==0){var p=c.pendingLanes;if(p===0)var m=0;else{var x=c.suspendedLanes,C=c.pingedLanes;m=(1<<31-Je(42|i)+1)-1,m&=p&~(x&~C),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,b_(c,m))}else m=We,m=ks(c,c===at?m:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(m&3)===0||Yr(c,m)||(l=!0,b_(c,m));c=c.next}while(l);Lh=!1}}function G0(){__()}function __(){Ko=Bh=!1;var i=0;Tr!==0&&l1()&&(i=Tr);for(var r=Ze(),l=null,c=Vo;c!==null;){var p=c.next,m=v_(c,r);m===0?(c.next=null,l===null?Vo=p:l.next=p,p===null&&(rl=l)):(l=c,(i!==0||(m&3)!==0)&&(Ko=!0)),c=p}Wt!==0&&Wt!==5||ra(i),Tr!==0&&(Tr=0)}function v_(i,r){for(var l=i.suspendedLanes,c=i.pingedLanes,p=i.expirationTimes,m=i.pendingLanes&-62914561;0C)break;var ee=N.transferSize,re=N.initiatorType;ee&&A_(re)&&(N=N.responseEnd,x+=ee*(N"u"?null:document;function I_(i,r,l){var c=sl;if(c&&typeof r=="string"&&r){var p=en(r);p='link[rel="'+i+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),P_.has(p)||(P_.add(p),i={rel:i,crossOrigin:l,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),hi(r,"link",i),Zt(r),c.head.appendChild(r)))}}function m1(i){er.D(i),I_("dns-prefetch",i,null)}function g1(i,r){er.C(i,r),I_("preconnect",i,r)}function _1(i,r,l){er.L(i,r,l);var c=sl;if(c&&i&&r){var p='link[rel="preload"][as="'+en(r)+'"]';r==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+en(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+en(l.imageSizes)+'"]')):p+='[href="'+en(i)+'"]';var m=p;switch(r){case"style":m=ll(i);break;case"script":m=al(i)}cn.has(m)||(i=g({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),cn.set(m,i),c.querySelector(p)!==null||r==="style"&&c.querySelector(oa(m))||r==="script"&&c.querySelector(ca(m))||(r=c.createElement("link"),hi(r,"link",i),Zt(r),c.head.appendChild(r)))}}function v1(i,r){er.m(i,r);var l=sl;if(l&&i){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+en(c)+'"][href="'+en(i)+'"]',m=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=al(i)}if(!cn.has(m)&&(i=g({rel:"modulepreload",href:i},r),cn.set(m,i),l.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ca(m)))return}c=l.createElement("link"),hi(c,"link",i),Zt(c),l.head.appendChild(c)}}}function y1(i,r,l){er.S(i,r,l);var c=sl;if(c&&i){var p=As(c).hoistableStyles,m=ll(i);r=r||"default";var x=p.get(m);if(!x){var C={loading:0,preload:null};if(x=c.querySelector(oa(m)))C.loading=5;else{i=g({rel:"stylesheet",href:i,"data-precedence":r},l),(l=cn.get(m))&&Xh(i,l);var N=x=c.createElement("link");Zt(N),hi(N,"link",i),N._p=new Promise(function($,ee){N.onload=$,N.onerror=ee}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Jo(x,r,c)}x={type:"stylesheet",instance:x,count:1,state:C},p.set(m,x)}}}function b1(i,r){er.X(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0},r),(r=cn.get(p))&&Zh(i,r),m=l.createElement("script"),Zt(m),hi(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function x1(i,r){er.M(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0,type:"module"},r),(r=cn.get(p))&&Zh(i,r),m=l.createElement("script"),Zt(m),hi(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function U_(i,r,l,c){var p=(p=ae.current)?Qo(p):null;if(!p)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=ll(l.href),l=As(p).hoistableStyles,c=l.get(r),c||(c={type:"style",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=ll(l.href);var m=As(p).hoistableStyles,x=m.get(i);if(x||(p=p.ownerDocument||p,x={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,x),(m=p.querySelector(oa(i)))&&!m._p&&(x.instance=m,x.state.loading=5),cn.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},cn.set(i,l),m||S1(p,i,l,x.state))),r&&c===null)throw Error(s(528,""));return x}if(r&&c!==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=al(l),l=As(p).hoistableScripts,c=l.get(r),c||(c={type:"script",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function ll(i){return'href="'+en(i)+'"'}function oa(i){return'link[rel="stylesheet"]['+i+"]"}function F_(i){return g({},i,{"data-precedence":i.precedence,precedence:null})}function S1(i,r,l,c){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=i.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),hi(r,"link",l),Zt(r),i.head.appendChild(r))}function al(i){return'[src="'+en(i)+'"]'}function ca(i){return"script[async]"+i}function q_(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var c=i.querySelector('style[data-href~="'+en(l.href)+'"]');if(c)return r.instance=c,Zt(c),c;var p=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),Zt(c),hi(c,"style",p),Jo(c,l.precedence,i),r.instance=c;case"stylesheet":p=ll(l.href);var m=i.querySelector(oa(p));if(m)return r.state.loading|=4,r.instance=m,Zt(m),m;c=F_(l),(p=cn.get(p))&&Xh(c,p),m=(i.ownerDocument||i).createElement("link"),Zt(m);var x=m;return x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),hi(m,"link",c),r.state.loading|=4,Jo(m,l.precedence,i),r.instance=m;case"script":return m=al(l.src),(p=i.querySelector(ca(m)))?(r.instance=p,Zt(p),p):(c=l,(p=cn.get(m))&&(c=g({},l),Zh(c,p)),i=i.ownerDocument||i,p=i.createElement("script"),Zt(p),hi(p,"link",c),i.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Jo(c,l.precedence,i));return r.instance}function Jo(i,r,l){for(var c=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,m=p,x=0;x title"):null)}function w1(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 Y_(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function C1(i,r,l,c){if(l.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=ll(c.href),m=r.querySelector(oa(p));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=tc.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Zt(m);return}m=r.ownerDocument||r,c=F_(c),(p=cn.get(p))&&Xh(c,p),m=m.createElement("link"),Zt(m);var x=m;x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),hi(m,"link",c),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=tc.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var Qh=0;function k1(i,r){return i.stylesheets&&i.count===0&&nc(i,i.stylesheets),0Qh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function tc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nc(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ic=null;function nc(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ic=new Map,r.forEach(E1,i),ic=null,tc.call(i))}function E1(i,r){if(!(r.state.loading&4)){var l=ic.get(i);if(l)var c=l.get(null);else{l=new Map,ic.set(i,l);for(var p=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(),ad.exports=q1(),ad.exports}var $1=W1();const Y1=Uc($1);function V1({onLogin:e}){const[t,n]=B.useState(""),[s,a]=B.useState(null),[o,u]=B.useState(!1),d=async f=>{if(f.preventDefault(),!t.trim())return;u(!0),a(null);const h=await e(t);h&&a(h),u(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsxs("div",{className:"w-full max-w-sm",children:[v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),v.jsxs("form",{onSubmit:d,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:f=>n(f.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&&v.jsx("p",{className:"text-error text-xs",children:s}),v.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"})]})]}),v.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function K1({onSetup:e}){const[t,n]=B.useState(""),[s,a]=B.useState(""),[o,u]=B.useState(null),[d,f]=B.useState(!1),h=async _=>{if(_.preventDefault(),!t.trim()||t.length<4){u("Passphrase must be at least 4 characters");return}if(t!==s){u("Passphrases do not match");return}f(!0),u(null);const g=await e(t);g&&u(g),f(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsx("div",{className:"w-full max-w-sm",children:v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),v.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."}),v.jsxs("form",{onSubmit:h,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:_=>n(_.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),v.jsx("input",{type:"password",value:s,onChange:_=>a(_.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&v.jsx("p",{className:"text-error text-xs",children:o}),v.jsx("button",{type:"submit",disabled:d||!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:d?"setting up...":"create passphrase"})]})]})})})}const gv="http://localhost:7777";function xb({token:e}){const[t,n]=B.useState(null),[s,a]=B.useState(!1),[o,u]=B.useState(!1),[d,f]=B.useState(null),h=(S,T)=>fetch(S,{...T,headers:{...T==null?void 0:T.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),_=()=>{h(`${gv}/api/wallet`).then(S=>S.json()).then(S=>n(S)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};B.useEffect(()=>{_()},[]);const g=async()=>{a(!0),f(null);try{const S=await h(`${gv}/api/wallet/create`,{method:"POST"}),T=await S.json();if(!S.ok)throw new Error(T.error||"Creation failed");_()}catch(S){f(S instanceof Error?S.message:"Failed to create wallet")}a(!1)},y=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),u(!0),setTimeout(()=>u(!1),2e3))},b=S=>`${S.slice(0,6)}...${S.slice(-4)}`;return v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&v.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),d&&v.jsx("p",{className:"text-error text-xs",children:d}),v.jsx("button",{onClick:g,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&&v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),v.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"})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:b(t.address)}),v.jsx("button",{onClick:y,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),v.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC"}),v.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"PLOT"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Network"}),v.jsx("span",{className:"text-foreground",children:"Base"})]})]}),v.jsxs("div",{className:"border-border border-t pt-3",children:[v.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),v.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),v.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 G1({token:e,onLogout:t}){const[n,s]=B.useState(""),[a,o]=B.useState(""),[u,d]=B.useState(null),[f,h]=B.useState(!1),[_,g]=B.useState(!1),[y,b]=B.useState(null),[S,T]=B.useState("AI Writer"),[L,D]=B.useState(""),[X,P]=B.useState(""),[J,I]=B.useState(!1),[M,Q]=B.useState(null),[ue,me]=B.useState(""),[z,te]=B.useState(null),[F,q]=B.useState(!1),[G,A]=B.useState(null),[k,j]=B.useState(null),U=B.useCallback((w,V)=>fetch(w,{...V,headers:{...V==null?void 0:V.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);B.useEffect(()=>{U("/api/settings/link-status").then(w=>w.json()).then(w=>b(w)).catch(()=>b({linked:!1}))},[]);const le=async()=>{if(!S.trim()){Q("Agent name is required");return}if(!L.trim()){Q("Description is required");return}I(!0),Q(null);try{const w=await U("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:S,description:L,...X.trim()&&{genre:X}})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Registration failed");b({linked:!0,agentId:V.agentId,owsWallet:V.owsWallet,txHash:V.txHash})}catch(w){Q(w instanceof Error?w.message:"Registration failed")}I(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){A("Enter a valid wallet address (0x...)");return}q(!0),A(null),te(null);try{const w=await U("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Failed to generate binding code");te(V)}catch(w){A(w instanceof Error?w.message:"Failed to generate binding code")}q(!1)},R=async(w,V)=>{await navigator.clipboard.writeText(w),j(V),setTimeout(()=>j(null),2e3)},Y=async()=>{if(d(null),h(!1),!n||n.length<4){d("Passphrase must be at least 4 characters");return}if(n!==a){d("Passphrases do not match");return}g(!0);try{const w=await U("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!w.ok){const V=await w.json();throw new Error(V.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(w){d(w instanceof Error?w.message:"Reset failed")}g(!1)};return v.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),y!=null&&y.linked?v.jsxs("div",{className:"space-y-2",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),v.jsxs("span",{className:"text-muted text-xs",children:["Agent #",y.agentId]})]}),y.owsWallet&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",y.owsWallet.slice(0,6),"...",y.owsWallet.slice(-4)]}),y.owner&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",y.owner.slice(0,6),"...",y.owner.slice(-4)]}),y.txHash&&v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://plotlink.xyz/profile/${y.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),v.jsx("input",{value:S,onChange:w=>T(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),v.jsx("input",{value:L,onChange:w=>D(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),v.jsx("input",{value:X,onChange:w=>P(w.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),M&&v.jsx("p",{className:"text-error text-xs",children:M}),v.jsx("button",{onClick:le,disabled:J||!S.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:J?"Registering...":"Register Agent Identity"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),y!=null&&y.owner?v.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",v.jsxs("span",{className:"font-mono",children:[y.owner.slice(0,6),"...",y.owner.slice(-4)]})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[v.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),v.jsx("p",{children:'2. Click "Generate Binding Code"'}),v.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),v.jsx("input",{value:ue,onChange:w=>me(w.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"}),G&&v.jsx("p",{className:"text-error text-xs",children:G}),v.jsx("button",{onClick:E,disabled:F||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:F?"Generating...":"Generate Binding Code"}),z&&v.jsxs("div",{className:"space-y-3 mt-3",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.signature}),v.jsx("button",{onClick:()=>R(z.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:k==="signature"?"Copied!":"Copy"})]})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.owsWallet}),v.jsx("button",{onClick:()=>R(z.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:k==="wallet"?"Copied!":"Copy"})]})]}),z.agentId&&v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:z.agentId}),v.jsx("button",{onClick:()=>R(String(z.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:k==="agentId"?"Copied!":"Copy"})]})]}),v.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),v.jsx(xb,{token:e}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("input",{type:"password",value:n,onChange:w=>s(w.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"}),v.jsx("input",{type:"password",value:a,onChange:w=>o(w.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"}),u&&v.jsx("p",{className:"text-error text-xs",children:u}),f&&v.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),v.jsx("button",{onClick:Y,disabled:_||!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:_?"updating...":"update passphrase"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),v.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 X1="http://localhost:7777";function Z1({token:e}){const[t,n]=B.useState(null),s=(d,f)=>fetch(d,{...f,headers:{...f==null?void 0:f.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${X1}/api/dashboard`).then(d=>d.json()).then(n)};B.useEffect(()=>{a()},[]);const o=d=>`${d.slice(0,6)}...${d.slice(-4)}`,u=d=>{if(!d)return"Unknown date";const f=new Date(d);return isNaN(f.getTime())?"Unknown date":f.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?v.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),v.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Address"}),v.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH Balance"}),v.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC Balance"}),v.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),v.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Royalties earned"}),v.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),v.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),v.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[v.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),v.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Stories published"}),v.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?v.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):v.jsx("div",{className:"space-y-3",children:t.stories.published.map(d=>v.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[v.jsxs("div",{className:"flex items-start justify-between",children:[v.jsxs("div",{children:[d.genre&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:d.genre}),v.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:d.title}),v.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:d.storyName})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[d.hasNotIndexed&&v.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),v.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[d.publishedFiles," published"]})]})]}),v.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.plotCount}),v.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:d.storylineId?`#${d.storylineId}`:"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.totalGasCostEth??"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),v.jsx("div",{className:"mt-2 space-y-1",children:d.files.map(f=>v.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[v.jsxs("div",{className:"flex items-center gap-1.5",children:[v.jsx("span",{className:f.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:f.status==="published-not-indexed"?"⚠":"✓"}),v.jsx("span",{className:"text-muted font-mono",children:f.file})]}),f.txHash&&v.jsxs("a",{href:`https://basescan.org/tx/${f.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",f.txHash.slice(0,8),"..."]})]},f.file))}),v.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[v.jsx("span",{className:"text-muted",children:u(d.latestPublishedAt)}),d.storylineId&&v.jsx("a",{href:`https://plotlink.xyz/story/${d.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},d.id))})]}),t.stories.pendingFiles>0&&v.jsx("div",{className:"border-border rounded border p-4",children:v.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):v.jsx("div",{className:"flex h-full items-center justify-center",children:v.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Q1={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},J1={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function ew({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[u,d]=B.useState([]),[f,h]=B.useState([]),[_,g]=B.useState(new Set),[y,b]=B.useState(!1),S=B.useCallback(async()=>{try{const I=await e("/api/stories");if(I.ok){const M=await I.json();d(M.stories)}}catch{}},[e]),T=B.useCallback(async()=>{try{const I=await e("/api/stories/archived");if(I.ok){const M=await I.json();h(M.stories)}}catch{}},[e]),L=B.useCallback(async I=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I})})).ok&&(T(),S())}catch{}},[e,T,S]);B.useEffect(()=>{S();const I=setInterval(S,5e3);return()=>clearInterval(I)},[S]),B.useEffect(()=>{y&&T()},[y,T]),B.useEffect(()=>{t&&g(I=>new Set(I).add(t))},[t]);const D=I=>{var Q;const M=I.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return M.length>0?M[0].file:I.some(ue=>ue.file==="genesis.md")?"genesis.md":I.some(ue=>ue.file==="structure.md")?"structure.md":((Q=I[0])==null?void 0:Q.file)??null},X=I=>{g(M=>{const Q=new Set(M);return Q.has(I)?Q.delete(I):Q.add(I),Q})},P=I=>{if(X(I.name),!_.has(I.name)){const M=D(I.files);M&&s(I.name,M)}},J=I=>{const M=Q=>{if(Q==="structure.md")return 0;if(Q==="genesis.md")return 1;const ue=Q.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...I].sort((Q,ue)=>M(Q.file)-M(ue.file))};return y?v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),v.jsx("span",{className:"text-xs text-muted",children:f.length})]}),v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.jsxs("button",{onClick:()=>b(!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:[v.jsx("span",{children:"←"}),v.jsx("span",{children:"Back"})]})}),v.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?v.jsx("div",{className:"p-3 text-sm text-muted",children:v.jsx("p",{children:"No archived stories."})}):f.map(I=>v.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[v.jsx("span",{className:"text-sm font-medium truncate",title:I.name,children:I.title||I.name}),v.jsx("button",{onClick:()=>L(I.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},I.name))})]}):v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),v.jsx("span",{className:"text-xs text-muted",children:u.length})]}),a&&v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.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:[v.jsx("span",{children:"+"}),v.jsx("span",{children:"New Story"})]})}),v.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(I=>v.jsx("div",{children:v.jsxs("button",{onClick:()=>s(I,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===I?"bg-surface":""}`,children:[v.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),v.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},I)),u.length===0&&o.length===0?v.jsxs("div",{className:"p-3 text-sm text-muted",children:[v.jsx("p",{children:"No stories yet."}),v.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):u.filter(I=>I.name!=="_example").map(I=>v.jsxs("div",{children:[v.jsxs("button",{onClick:()=>P(I),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[v.jsx("span",{className:"text-xs text-muted",children:_.has(I.name)?"▼":"▶"}),v.jsx("span",{className:"font-medium truncate",title:I.name,children:I.title||I.name}),I.contentType==="cartoon"&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),v.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[I.publishedCount,"/",I.files.length]})]}),_.has(I.name)&&v.jsx("div",{className:"pl-4",children:J(I.files).map(M=>{const Q=t===I.name&&n===M.file;return v.jsxs("button",{onClick:()=>s(I.name,M.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${Q?"bg-surface font-medium":""}`,children:[v.jsx("span",{className:J1[M.status],children:Q1[M.status]}),v.jsx("span",{className:"truncate font-mono",children:M.file})]},M.file)})})]},I.name))]}),v.jsx("div",{className:"px-3 py-2 border-t border-border",children:v.jsx("button",{onClick:()=>b(!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:v.jsx("span",{children:"Archives"})})})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -57,22 +57,22 @@ Error generating stack: `+c.message+` * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Sb=Object.defineProperty,tw=Object.getOwnPropertyDescriptor,iw=(e,t)=>{for(var n in t)Sb(e,n,{get:t[n],enumerable:!0})},Ct=(e,t,n,s)=>{for(var a=s>1?void 0:s?tw(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(a=(s?u(t,n,a):u(a))||a);return s&&a&&Sb(t,n,a),a},ge=(e,t)=>(n,s)=>t(n,s,e),_v="Terminal input",Wd={get:()=>_v,set:e=>_v=e},vv="Too much output to announce, navigate to rows manually to read",$d={get:()=>vv,set:e=>vv=e};function nw(e){return e.replace(/\r?\n/g,"\r")}function rw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function lw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");wb(a,t,n,s)}}function wb(e,t,n,s){e=nw(e),e=rw(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Cb(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 yv(e,t,n,s,a){Cb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Hr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Fc(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 aw=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=u,s;let d=e.charCodeAt(o);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},ow=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,u,d,f=0,h=0;if(this.interim[0]){let y=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let S=0,T;for(;(T=this.interim[++S]&63)&&S<4;)b<<=6,b|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=B-S;for(;h=n)return 0;if(T=e[h++],(T&192)!==128){h--,y=!0;break}else this.interim[S++]=T,b<<=6,b|=T&63}y||(B===2?b<128?h--:t[s++]=b:B===3?b<2048||b>=55296&&b<=57343||b===65279||(t[s++]=b):b<65536||b>1114111||(t[s++]=b)),this.interim.fill(0)}let _=n-4,g=h;for(;g=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(f=(a&31)<<6|o&63,f<128){g--;continue}t[s++]=f}else if((a&240)===224){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(f=(a&15)<<12|(o&63)<<6|u&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[s++]=f}else if((a&248)===240){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=u,s;if(d=e[g++],(d&192)!==128){g--;continue}if(f=(a&7)<<18|(o&63)<<12|(u&63)<<6|d&63,f<65536||f>1114111)continue;t[s++]=f}}return s}},kb="",Ir=" ",Fa=class Eb{constructor(){this.fg=0,this.bg=0,this.extended=new Nc}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 Eb;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}},Nc=class Tb{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 Tb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dn=class Ab extends Fa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nc,this.combinedData=""}static fromCharData(t){let n=new Ab;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?Hr(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()]}},bv="di$target",Yd="di$dependencies",hd=new Map;function cw(e){return e[Yd]||[]}function ii(e){if(hd.has(e))return hd.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");uw(t,n,a)};return t._id=e,hd.set(e,t),t}function uw(e,t,n){t[bv]===t?t[Yd].push({id:e,index:n}):(t[Yd]=[{id:e,index:n}],t[bv]=t)}var wi=ii("BufferService"),Db=ii("CoreMouseService"),Ss=ii("CoreService"),hw=ii("CharsetService"),If=ii("InstantiationService"),Rb=ii("LogService"),Ci=ii("OptionsService"),Nb=ii("OscLinkService"),dw=ii("UnicodeService"),qa=ii("DecorationService"),Vd=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var _;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new dn,u=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;ga?a.activate(T,B,b):fw(T,B),hover:(T,B)=>{var D;return(D=a==null?void 0:a.hover)==null?void 0:D.call(a,T,B,b)},leave:(T,B)=>{var D;return(D=a==null?void 0:a.leave)==null?void 0:D.call(a,T,B,b)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(f=g,d=o.extended.urlId):(f=-1,d=-1)}}t(s)}};Vd=Ct([ge(0,wi),ge(1,Ci),ge(2,Nb)],Vd);function fw(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Sb=Object.defineProperty,tw=Object.getOwnPropertyDescriptor,iw=(e,t)=>{for(var n in t)Sb(e,n,{get:t[n],enumerable:!0})},At=(e,t,n,s)=>{for(var a=s>1?void 0:s?tw(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(a=(s?u(t,n,a):u(a))||a);return s&&a&&Sb(t,n,a),a},ge=(e,t)=>(n,s)=>t(n,s,e),_v="Terminal input",Wd={get:()=>_v,set:e=>_v=e},vv="Too much output to announce, navigate to rows manually to read",$d={get:()=>vv,set:e=>vv=e};function nw(e){return e.replace(/\r?\n/g,"\r")}function rw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function lw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");wb(a,t,n,s)}}function wb(e,t,n,s){e=nw(e),e=rw(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Cb(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 yv(e,t,n,s,a){Cb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Hr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Fc(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 aw=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=u,s;let d=e.charCodeAt(o);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},ow=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,u,d,f=0,h=0;if(this.interim[0]){let y=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let S=0,T;for(;(T=this.interim[++S]&63)&&S<4;)b<<=6,b|=T;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=L-S;for(;h=n)return 0;if(T=e[h++],(T&192)!==128){h--,y=!0;break}else this.interim[S++]=T,b<<=6,b|=T&63}y||(L===2?b<128?h--:t[s++]=b:L===3?b<2048||b>=55296&&b<=57343||b===65279||(t[s++]=b):b<65536||b>1114111||(t[s++]=b)),this.interim.fill(0)}let _=n-4,g=h;for(;g=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(f=(a&31)<<6|o&63,f<128){g--;continue}t[s++]=f}else if((a&240)===224){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(f=(a&15)<<12|(o&63)<<6|u&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[s++]=f}else if((a&248)===240){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=u,s;if(d=e[g++],(d&192)!==128){g--;continue}if(f=(a&7)<<18|(o&63)<<12|(u&63)<<6|d&63,f<65536||f>1114111)continue;t[s++]=f}}return s}},kb="",Ir=" ",Fa=class Eb{constructor(){this.fg=0,this.bg=0,this.extended=new Nc}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 Eb;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}},Nc=class Tb{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 Tb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},pn=class Ab extends Fa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nc,this.combinedData=""}static fromCharData(t){let n=new Ab;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?Hr(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()]}},bv="di$target",Yd="di$dependencies",hd=new Map;function cw(e){return e[Yd]||[]}function li(e){if(hd.has(e))return hd.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");uw(t,n,a)};return t._id=e,hd.set(e,t),t}function uw(e,t,n){t[bv]===t?t[Yd].push({id:e,index:n}):(t[Yd]=[{id:e,index:n}],t[bv]=t)}var ki=li("BufferService"),Db=li("CoreMouseService"),Ss=li("CoreService"),hw=li("CharsetService"),If=li("InstantiationService"),Rb=li("LogService"),Ei=li("OptionsService"),Nb=li("OscLinkService"),dw=li("UnicodeService"),qa=li("DecorationService"),Vd=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var _;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new pn,u=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;ga?a.activate(T,L,b):fw(T,L),hover:(T,L)=>{var D;return(D=a==null?void 0:a.hover)==null?void 0:D.call(a,T,L,b)},leave:(T,L)=>{var D;return(D=a==null?void 0:a.leave)==null?void 0:D.call(a,T,L,b)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(f=g,d=o.extended.urlId):(f=-1,d=-1)}}t(s)}};Vd=At([ge(0,ki),ge(1,Ei),ge(2,Nb)],Vd);function fw(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 qc=ii("CharSizeService"),sr=ii("CoreBrowserService"),Uf=ii("MouseService"),lr=ii("RenderService"),pw=ii("SelectionService"),Mb=ii("CharacterJoinerService"),yl=ii("ThemeService"),Bb=ii("LinkProviderService"),mw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xv.isErrorNoTelemetry(e)?new xv(e.message+` +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 qc=li("CharSizeService"),sr=li("CoreBrowserService"),Uf=li("MouseService"),lr=li("RenderService"),pw=li("SelectionService"),Mb=li("CharacterJoinerService"),yl=li("ThemeService"),Bb=li("LinkProviderService"),mw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xv.isErrorNoTelemetry(e)?new xv(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)}},gw=new mw;function wc(e){_w(e)||gw.onUnexpectedError(e)}var Kd="Canceled";function _w(e){return e instanceof vw?!0:e instanceof Error&&e.name===Kd&&e.message===Kd}var vw=class extends Error{constructor(){super(Kd),this.name=this.message}};function yw(e){return new Error(`Illegal argument: ${e}`)}var xv=class Gd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gd)return t;let n=new Gd;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Xd=class Lb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Lb.prototype)}};function $i(e,t=0){return e[e.length-(1+t)]}var bw;(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})(bw||(bw={}));function xw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var Ob;(e=>{function t(J){return J&&typeof J=="object"&&typeof J[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(J){yield J}e.single=a;function o(J){return t(J)?J:a(J)}e.wrap=o;function u(J){return J||n}e.from=u;function*d(J){for(let I=J.length-1;I>=0;I--)yield J[I]}e.reverse=d;function f(J){return!J||J[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(J){return J[Symbol.iterator]().next().value}e.first=h;function _(J,I){let M=0;for(let Q of J)if(I(Q,M++))return!0;return!1}e.some=_;function g(J,I){for(let M of J)if(I(M))return M}e.find=g;function*y(J,I){for(let M of J)I(M)&&(yield M)}e.filter=y;function*b(J,I){let M=0;for(let Q of J)yield I(Q,M++)}e.map=b;function*S(J,I){let M=0;for(let Q of J)yield*I(Q,M++)}e.flatMap=S;function*T(...J){for(let I of J)yield*I}e.concat=T;function B(J,I,M){let Q=M;for(let ce of J)Q=I(Q,ce);return Q}e.reduce=B;function*D(J,I,M=J.length){for(I<0&&(I+=J.length),M<0?M+=J.length:M>J.length&&(M=J.length);I1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Sw(...e){return gt(()=>ys(e))}function gt(e){return{dispose:xw(()=>{e()})}}var zb=class jb{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{ys(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?jb.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)}};zb.DISABLE_DISPOSED_WARNING=!1;var Ur=zb,Pe=class{constructor(){this._store=new Ur,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)}};Pe.None=Object.freeze({dispose(){}});var _l=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}},rr=typeof window=="object"?window:globalThis,Zd=class Qd{constructor(t){this.element=t,this.next=Qd.Undefined,this.prev=Qd.Undefined}};Zd.Undefined=new Zd(void 0);var _t=Zd,Sv=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.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!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},ww=globalThis.performance&&typeof globalThis.performance.now=="function",Cw=class Hb{static create(t){return new Hb(t)}constructor(t){this._now=ww&&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}},ui;(e=>{e.None=()=>Pe.None;function t($,F){return g($,()=>{},0,void 0,!0,void 0,F)}e.defer=t;function n($){return(F,Y=null,A)=>{let E=!1,j;return j=$(U=>{if(!E)return j?j.dispose():E=!0,F.call(Y,U)},null,A),E&&j.dispose(),j}}e.once=n;function s($,F,Y){return h((A,E=null,j)=>$(U=>A.call(E,F(U)),null,j),Y)}e.map=s;function a($,F,Y){return h((A,E=null,j)=>$(U=>{F(U),A.call(E,U)},null,j),Y)}e.forEach=a;function o($,F,Y){return h((A,E=null,j)=>$(U=>F(U)&&A.call(E,U),null,j),Y)}e.filter=o;function u($){return $}e.signal=u;function d(...$){return(F,Y=null,A)=>{let E=Sw(...$.map(j=>j(U=>F.call(Y,U))));return _(E,A)}}e.any=d;function f($,F,Y,A){let E=Y;return s($,j=>(E=F(E,j),E),A)}e.reduce=f;function h($,F){let Y,A={onWillAddFirstListener(){Y=$(E.fire,E)},onDidRemoveLastListener(){Y==null||Y.dispose()}},E=new pe(A);return F==null||F.add(E),E.event}function _($,F){return F instanceof Array?F.push($):F&&F.add($),$}function g($,F,Y=100,A=!1,E=!1,j,U){let le,k,R,K=0,w,V={leakWarningThreshold:j,onWillAddFirstListener(){le=$(ae=>{K++,k=F(k,ae),A&&!R&&(ue.fire(k),k=void 0),w=()=>{let ve=k;k=void 0,R=void 0,(!A||K>1)&&ue.fire(ve),K=0},typeof Y=="number"?(clearTimeout(R),R=setTimeout(w,Y)):R===void 0&&(R=0,queueMicrotask(w))})},onWillRemoveListener(){E&&K>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,le.dispose()}},ue=new pe(V);return U==null||U.add(ue),ue.event}e.debounce=g;function y($,F=0,Y){return e.debounce($,(A,E)=>A?(A.push(E),A):[E],F,void 0,!0,void 0,Y)}e.accumulate=y;function b($,F=(A,E)=>A===E,Y){let A=!0,E;return o($,j=>{let U=A||!F(j,E);return A=!1,E=j,U},Y)}e.latch=b;function S($,F,Y){return[e.filter($,F,Y),e.filter($,A=>!F(A),Y)]}e.split=S;function T($,F=!1,Y=[],A){let E=Y.slice(),j=$(k=>{E?E.push(k):le.fire(k)});A&&A.add(j);let U=()=>{E==null||E.forEach(k=>le.fire(k)),E=null},le=new pe({onWillAddFirstListener(){j||(j=$(k=>le.fire(k)),A&&A.add(j))},onDidAddFirstListener(){E&&(F?setTimeout(U):U())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return A&&A.add(le),le.event}e.buffer=T;function B($,F){return(Y,A,E)=>{let j=F(new X);return $(function(U){let le=j.evaluate(U);le!==D&&Y.call(A,le)},void 0,E)}}e.chain=B;let D=Symbol("HaltChainable");class X{constructor(){this.steps=[]}map(F){return this.steps.push(F),this}forEach(F){return this.steps.push(Y=>(F(Y),Y)),this}filter(F){return this.steps.push(Y=>F(Y)?Y:D),this}reduce(F,Y){let A=Y;return this.steps.push(E=>(A=F(A,E),A)),this}latch(F=(Y,A)=>Y===A){let Y=!0,A;return this.steps.push(E=>{let j=Y||!F(E,A);return Y=!1,A=E,j?E:D}),this}evaluate(F){for(let Y of this.steps)if(F=Y(F),F===D)break;return F}}function P($,F,Y=A=>A){let A=(...le)=>U.fire(Y(...le)),E=()=>$.on(F,A),j=()=>$.removeListener(F,A),U=new pe({onWillAddFirstListener:E,onDidRemoveLastListener:j});return U.event}e.fromNodeEventEmitter=P;function J($,F,Y=A=>A){let A=(...le)=>U.fire(Y(...le)),E=()=>$.addEventListener(F,A),j=()=>$.removeEventListener(F,A),U=new pe({onWillAddFirstListener:E,onDidRemoveLastListener:j});return U.event}e.fromDOMEventEmitter=J;function I($){return new Promise(F=>n($)(F))}e.toPromise=I;function M($){let F=new pe;return $.then(Y=>{F.fire(Y)},()=>{F.fire(void 0)}).finally(()=>{F.dispose()}),F.event}e.fromPromise=M;function Q($,F){return $(Y=>F.fire(Y))}e.forward=Q;function ce($,F,Y){return F(Y),$(A=>F(A))}e.runAndSubscribe=ce;class me{constructor(F,Y){this._observable=F,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{F.addObserver(this)},onDidRemoveLastListener:()=>{F.removeObserver(this)}};this.emitter=new pe(A),Y&&Y.add(this.emitter)}beginUpdate(F){this._counter++}handlePossibleChange(F){}handleChange(F,Y){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 z($,F){return new me($,F).emitter.event}e.fromObservable=z;function ie($){return(F,Y,A)=>{let E=0,j=!1,U={beginUpdate(){E++},endUpdate(){E--,E===0&&($.reportChanges(),j&&(j=!1,F.call(Y)))},handlePossibleChange(){},handleChange(){j=!0}};$.addObserver(U),$.reportChanges();let le={dispose(){$.removeObserver(U)}};return A instanceof Ur?A.add(le):Array.isArray(A)&&A.push(le),le}}e.fromObservableLight=ie})(ui||(ui={}));var Jd=class ef{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ef._idPool++}`,ef.all.add(this)}start(t){this._stopWatch=new Cw,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}}};Jd.all=new Set,Jd._idPool=0;var kw=Jd,Ew=-1,Pb=class Ib{constructor(t,n,s=(Ib._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{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)}},gw=new mw;function wc(e){_w(e)||gw.onUnexpectedError(e)}var Kd="Canceled";function _w(e){return e instanceof vw?!0:e instanceof Error&&e.name===Kd&&e.message===Kd}var vw=class extends Error{constructor(){super(Kd),this.name=this.message}};function yw(e){return new Error(`Illegal argument: ${e}`)}var xv=class Gd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gd)return t;let n=new Gd;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Xd=class Lb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Lb.prototype)}};function Ki(e,t=0){return e[e.length-(1+t)]}var bw;(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})(bw||(bw={}));function xw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var Ob;(e=>{function t(J){return J&&typeof J=="object"&&typeof J[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(J){yield J}e.single=a;function o(J){return t(J)?J:a(J)}e.wrap=o;function u(J){return J||n}e.from=u;function*d(J){for(let I=J.length-1;I>=0;I--)yield J[I]}e.reverse=d;function f(J){return!J||J[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(J){return J[Symbol.iterator]().next().value}e.first=h;function _(J,I){let M=0;for(let Q of J)if(I(Q,M++))return!0;return!1}e.some=_;function g(J,I){for(let M of J)if(I(M))return M}e.find=g;function*y(J,I){for(let M of J)I(M)&&(yield M)}e.filter=y;function*b(J,I){let M=0;for(let Q of J)yield I(Q,M++)}e.map=b;function*S(J,I){let M=0;for(let Q of J)yield*I(Q,M++)}e.flatMap=S;function*T(...J){for(let I of J)yield*I}e.concat=T;function L(J,I,M){let Q=M;for(let ue of J)Q=I(Q,ue);return Q}e.reduce=L;function*D(J,I,M=J.length){for(I<0&&(I+=J.length),M<0?M+=J.length:M>J.length&&(M=J.length);I1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Sw(...e){return yt(()=>ys(e))}function yt(e){return{dispose:xw(()=>{e()})}}var zb=class jb{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{ys(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?jb.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)}};zb.DISABLE_DISPOSED_WARNING=!1;var Ur=zb,He=class{constructor(){this._store=new Ur,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)}};He.None=Object.freeze({dispose(){}});var _l=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}},rr=typeof window=="object"?window:globalThis,Zd=class Qd{constructor(t){this.element=t,this.next=Qd.Undefined,this.prev=Qd.Undefined}};Zd.Undefined=new Zd(void 0);var bt=Zd,Sv=class{constructor(){this._first=bt.Undefined,this._last=bt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===bt.Undefined}clear(){let e=this._first;for(;e!==bt.Undefined;){let t=e.next;e.prev=bt.Undefined,e.next=bt.Undefined,e=t}this._first=bt.Undefined,this._last=bt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new bt(e);if(this._first===bt.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!==bt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==bt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==bt.Undefined&&e.next!==bt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===bt.Undefined&&e.next===bt.Undefined?(this._first=bt.Undefined,this._last=bt.Undefined):e.next===bt.Undefined?(this._last=this._last.prev,this._last.next=bt.Undefined):e.prev===bt.Undefined&&(this._first=this._first.next,this._first.prev=bt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==bt.Undefined;)yield e.element,e=e.next}},ww=globalThis.performance&&typeof globalThis.performance.now=="function",Cw=class Hb{static create(t){return new Hb(t)}constructor(t){this._now=ww&&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}},pi;(e=>{e.None=()=>He.None;function t(F,q){return g(F,()=>{},0,void 0,!0,void 0,q)}e.defer=t;function n(F){return(q,G=null,A)=>{let k=!1,j;return j=F(U=>{if(!k)return j?j.dispose():k=!0,q.call(G,U)},null,A),k&&j.dispose(),j}}e.once=n;function s(F,q,G){return h((A,k=null,j)=>F(U=>A.call(k,q(U)),null,j),G)}e.map=s;function a(F,q,G){return h((A,k=null,j)=>F(U=>{q(U),A.call(k,U)},null,j),G)}e.forEach=a;function o(F,q,G){return h((A,k=null,j)=>F(U=>q(U)&&A.call(k,U),null,j),G)}e.filter=o;function u(F){return F}e.signal=u;function d(...F){return(q,G=null,A)=>{let k=Sw(...F.map(j=>j(U=>q.call(G,U))));return _(k,A)}}e.any=d;function f(F,q,G,A){let k=G;return s(F,j=>(k=q(k,j),k),A)}e.reduce=f;function h(F,q){let G,A={onWillAddFirstListener(){G=F(k.fire,k)},onDidRemoveLastListener(){G==null||G.dispose()}},k=new pe(A);return q==null||q.add(k),k.event}function _(F,q){return q instanceof Array?q.push(F):q&&q.add(F),F}function g(F,q,G=100,A=!1,k=!1,j,U){let le,E,R,Y=0,w,V={leakWarningThreshold:j,onWillAddFirstListener(){le=F(ae=>{Y++,E=q(E,ae),A&&!R&&(he.fire(E),E=void 0),w=()=>{let _e=E;E=void 0,R=void 0,(!A||Y>1)&&he.fire(_e),Y=0},typeof G=="number"?(clearTimeout(R),R=setTimeout(w,G)):R===void 0&&(R=0,queueMicrotask(w))})},onWillRemoveListener(){k&&Y>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,le.dispose()}},he=new pe(V);return U==null||U.add(he),he.event}e.debounce=g;function y(F,q=0,G){return e.debounce(F,(A,k)=>A?(A.push(k),A):[k],q,void 0,!0,void 0,G)}e.accumulate=y;function b(F,q=(A,k)=>A===k,G){let A=!0,k;return o(F,j=>{let U=A||!q(j,k);return A=!1,k=j,U},G)}e.latch=b;function S(F,q,G){return[e.filter(F,q,G),e.filter(F,A=>!q(A),G)]}e.split=S;function T(F,q=!1,G=[],A){let k=G.slice(),j=F(E=>{k?k.push(E):le.fire(E)});A&&A.add(j);let U=()=>{k==null||k.forEach(E=>le.fire(E)),k=null},le=new pe({onWillAddFirstListener(){j||(j=F(E=>le.fire(E)),A&&A.add(j))},onDidAddFirstListener(){k&&(q?setTimeout(U):U())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return A&&A.add(le),le.event}e.buffer=T;function L(F,q){return(G,A,k)=>{let j=q(new X);return F(function(U){let le=j.evaluate(U);le!==D&&G.call(A,le)},void 0,k)}}e.chain=L;let D=Symbol("HaltChainable");class X{constructor(){this.steps=[]}map(q){return this.steps.push(q),this}forEach(q){return this.steps.push(G=>(q(G),G)),this}filter(q){return this.steps.push(G=>q(G)?G:D),this}reduce(q,G){let A=G;return this.steps.push(k=>(A=q(A,k),A)),this}latch(q=(G,A)=>G===A){let G=!0,A;return this.steps.push(k=>{let j=G||!q(k,A);return G=!1,A=k,j?k:D}),this}evaluate(q){for(let G of this.steps)if(q=G(q),q===D)break;return q}}function P(F,q,G=A=>A){let A=(...le)=>U.fire(G(...le)),k=()=>F.on(q,A),j=()=>F.removeListener(q,A),U=new pe({onWillAddFirstListener:k,onDidRemoveLastListener:j});return U.event}e.fromNodeEventEmitter=P;function J(F,q,G=A=>A){let A=(...le)=>U.fire(G(...le)),k=()=>F.addEventListener(q,A),j=()=>F.removeEventListener(q,A),U=new pe({onWillAddFirstListener:k,onDidRemoveLastListener:j});return U.event}e.fromDOMEventEmitter=J;function I(F){return new Promise(q=>n(F)(q))}e.toPromise=I;function M(F){let q=new pe;return F.then(G=>{q.fire(G)},()=>{q.fire(void 0)}).finally(()=>{q.dispose()}),q.event}e.fromPromise=M;function Q(F,q){return F(G=>q.fire(G))}e.forward=Q;function ue(F,q,G){return q(G),F(A=>q(A))}e.runAndSubscribe=ue;class me{constructor(q,G){this._observable=q,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{q.addObserver(this)},onDidRemoveLastListener:()=>{q.removeObserver(this)}};this.emitter=new pe(A),G&&G.add(this.emitter)}beginUpdate(q){this._counter++}handlePossibleChange(q){}handleChange(q,G){this._hasChanged=!0}endUpdate(q){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function z(F,q){return new me(F,q).emitter.event}e.fromObservable=z;function te(F){return(q,G,A)=>{let k=0,j=!1,U={beginUpdate(){k++},endUpdate(){k--,k===0&&(F.reportChanges(),j&&(j=!1,q.call(G)))},handlePossibleChange(){},handleChange(){j=!0}};F.addObserver(U),F.reportChanges();let le={dispose(){F.removeObserver(U)}};return A instanceof Ur?A.add(le):Array.isArray(A)&&A.push(le),le}}e.fromObservableLight=te})(pi||(pi={}));var Jd=class ef{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ef._idPool++}`,ef.all.add(this)}start(t){this._stopWatch=new Cw,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}}};Jd.all=new Set,Jd._idPool=0;var kw=Jd,Ew=-1,Pb=class Ib{constructor(t,n,s=(Ib._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 d,f,h,_,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new Rw(`${y}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((d=this._options)==null?void 0:d.onListenerError)||wc)(S),Pe.None}if(this._disposed)return Pe.None;n&&(t=t.bind(n));let a=new dd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=Aw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof dd?(this._deliveryQueue??(this._deliveryQueue=new Lw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=a,(g=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||g.call(_,this)),this._size++;let u=gt(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ur?s.add(u):Array.isArray(s)&&s.push(u),u}),this._event}_removeListener(t){var o,u,d,f;if((u=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||u.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,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*Mw<=n.length){let h=0;for(let _=0;_0}},Lw=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}},tf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new pe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new pe,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}};tf.INSTANCE=new tf;var Ff=tf;function Ow(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ff.INSTANCE.onDidChangeZoomLevel;function zw(e){return Ff.INSTANCE.getZoomFactor(e)}Ff.INSTANCE.onDidChangeFullscreen;var bl=typeof navigator=="object"?navigator.userAgent:"",nf=bl.indexOf("Firefox")>=0,jw=bl.indexOf("AppleWebKit")>=0,qf=bl.indexOf("Chrome")>=0,Hw=!qf&&bl.indexOf("Safari")>=0;bl.indexOf("Electron/")>=0;bl.indexOf("Android")>=0;var fd=!1;if(typeof rr.matchMedia=="function"){let e=rr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=rr.matchMedia("(display-mode: fullscreen)");fd=e.matches,Ow(rr,e,({matches:n})=>{fd&&t.matches||(fd=n)})}var ml="en",rf=!1,sf=!1,Cc=!1,Fb=!1,hc,kc=ml,wv=ml,Pw,yn,vs=globalThis,ci,vb;typeof vs.vscode<"u"&&typeof vs.vscode.process<"u"?ci=vs.vscode.process:typeof process<"u"&&typeof((vb=process==null?void 0:process.versions)==null?void 0:vb.node)=="string"&&(ci=process);var yb,Iw=typeof((yb=ci==null?void 0:ci.versions)==null?void 0:yb.electron)=="string",Uw=Iw&&(ci==null?void 0:ci.type)==="renderer",bb;if(typeof ci=="object"){rf=ci.platform==="win32",sf=ci.platform==="darwin",Cc=ci.platform==="linux",Cc&&ci.env.SNAP&&ci.env.SNAP_REVISION,ci.env.CI||ci.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hc=ml,kc=ml;let e=ci.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);hc=t.userLocale,wv=t.osLocale,kc=t.resolvedLanguage||ml,Pw=(bb=t.languagePack)==null?void 0:bb.translationsConfigFile}catch{}Fb=!0}else typeof navigator=="object"&&!Uw?(yn=navigator.userAgent,rf=yn.indexOf("Windows")>=0,sf=yn.indexOf("Macintosh")>=0,(yn.indexOf("Macintosh")>=0||yn.indexOf("iPad")>=0||yn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Cc=yn.indexOf("Linux")>=0,(yn==null?void 0:yn.indexOf("Mobi"))>=0,kc=globalThis._VSCODE_NLS_LANGUAGE||ml,hc=navigator.language.toLowerCase(),wv=hc):console.error("Unable to resolve platform.");var qb=rf,Nn=sf,Fw=Cc,Cv=Fb,Mn=yn,Lr=kc,qw;(e=>{function t(){return Lr}e.value=t;function n(){return Lr.length===2?Lr==="en":Lr.length>=3?Lr[0]==="e"&&Lr[1]==="n"&&Lr[2]==="-":!1}e.isDefaultVariant=n;function s(){return Lr==="en"}e.isDefault=s})(qw||(qw={}));var Ww=typeof vs.postMessage=="function"&&!vs.importScripts;(()=>{if(Ww){let e=[];vs.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}),vs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var $w=!!(Mn&&Mn.indexOf("Chrome")>=0);Mn&&Mn.indexOf("Firefox")>=0;!$w&&Mn&&Mn.indexOf("Safari")>=0;Mn&&Mn.indexOf("Edg/")>=0;Mn&&Mn.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Cv||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Cv||cl&&cl.clipboard&&cl.clipboard.readText;var Wf=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}},pd=new Wf,kv=new Wf,Ev=new Wf,Yw=new Array(230),Wb;(e=>{function t(d){return pd.keyCodeToStr(d)}e.toString=t;function n(d){return pd.strToKeyCode(d)}e.fromString=n;function s(d){return kv.keyCodeToStr(d)}e.toUserSettingsUS=s;function a(d){return Ev.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function o(d){return kv.strToKeyCode(d)||Ev.strToKeyCode(d)}e.fromUserSettings=o;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pd.keyCodeToStr(d)}e.toElectronAccelerator=u})(Wb||(Wb={}));var Vw=class $b{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 $b&&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 Kw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kw=class{constructor(e){if(e.length===0)throw yw("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 nC?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ui.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Yb})})(iC||(iC={}));var nC=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?Yb:(this._emitter||(this._emitter=new pe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$f=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 Xd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Xd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},rC=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 Xd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=gt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},sC;(e=>{async function t(s){let a,o=await Promise.all(s.map(u=>u.then(d=>d,d=>{a||(a=d)})));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(u){o(u)}})}e.withAsyncBody=n})(sC||(sC={}));var Rv=class cn{static fromArray(t){return new cn(n=>{n.emitMany(t)})}static fromPromise(t){return new cn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new cn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new cn(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 pe,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 cn(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return cn.map(this,t)}static filter(t,n){return new cn(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return cn.filter(this,t)}static coalesce(t){return cn.filter(t,n=>!!n)}coalesce(){return cn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return cn.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())}};Rv.EMPTY=Rv.fromArray([]);var{getWindow:Rn,getWindowId:lC,onDidRegisterWindow:aC}=(function(){let e=new Map,t={window:rr,disposables:new Ur};e.set(rr.vscodeWindowId,t);let n=new pe,s=new pe,a=new pe;function o(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Pe.None;let d=new Ur,f={window:u,disposables:d.add(new Ur)};return e.set(u.vscodeWindowId,f),d.add(gt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(Me(u,Gt.BEFORE_UNLOAD,()=>{a.fire(u)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:o,getWindow(u){var h;let d=u;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=u;return f!=null&&f.view?f.view.window:rr},getDocument(u){return Rn(u).document}}})(),oC=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 Me(e,t,n,s){return new oC(e,t,n,s)}var Nv=function(e,t,n,s){return Me(e,t,n,s)},Yf,cC=class extends rC{constructor(e){super(),this.defaultTarget=e&&Rn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Mv=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){wc(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 u=e.get(o)??[];for(t.set(o,u),e.set(o,[]),s.set(o,!0);u.length>0;)u.sort(Mv.sort),u.shift().execute();s.set(o,!1)};Yf=(o,u,d=0)=>{let f=lC(o),h=new Mv(u,d),_=e.get(f);return _||(_=[],e.set(f,_)),_.push(h),n.get(f)||(n.set(f,!0),o.requestAnimationFrame(()=>a(f))),h}})();function uC(e){let t=e.getBoundingClientRect(),n=Rn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Gt={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"},hC=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=Mi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Mi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Mi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Mi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Mi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Mi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Mi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Mi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Mi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Mi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Mi(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=Mi(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=Mi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Mi(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 Mi(e){return typeof e=="number"?`${e}px`:e}function Ma(e){return new hC(e)}var Vb=class{constructor(){this._hooks=new Ur,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(gt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Rn(e)}this._hooks.add(Me(o,Gt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Me(o,Gt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function dC(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(...u){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,u)}),this[o]}}var An;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(An||(An={}));var Ta=class fi extends Pe{constructor(){super(),this.dispatched=!1,this.targets=new Sv,this.ignoreTargets=new Sv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ui.runAndSubscribe(aC,({window:t,disposables:n})=>{n.add(Me(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Me(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Me(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:rr,disposables:this._store}))}static addTarget(t){if(!fi.isTouchDevice())return Pe.None;fi.INSTANCE||(fi.INSTANCE=new fi);let n=fi.INSTANCE.targets.push(t);return gt(n)}static ignoreTarget(t){if(!fi.isTouchDevice())return Pe.None;fi.INSTANCE||(fi.INSTANCE=new fi);let n=fi.INSTANCE.ignoreTargets.push(t);return gt(n)}static isTouchDevice(){return"ontouchstart"in rr||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=fi.HOLD_DELAY&&Math.abs(f.initialPageX-$i(f.rollingPageX))<30&&Math.abs(f.initialPageY-$i(f.rollingPageY))<30){let _=this.newGestureEvent(An.Contextmenu,f.initialTarget);_.pageX=$i(f.rollingPageX),_.pageY=$i(f.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=$i(f.rollingPageX),g=$i(f.rollingPageY),y=$i(f.rollingTimestamps)-f.rollingTimestamps[0],b=_-f.rollingPageX[0],S=g-f.rollingPageY[0],T=[...this.targets].filter(B=>f.initialTarget instanceof Node&&B.contains(f.initialTarget));this.inertia(t,T,s,Math.abs(b)/y,b>0?1:-1,_,Math.abs(S)/y,S>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(An.End,f.initialTarget)),delete this.activeTouches[d.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===An.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>fi.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===An.Change||t.type===An.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,u,d,f,h){this.handle=Yf(t,()=>{let _=Date.now(),g=_-s,y=0,b=0,S=!0;a+=fi.SCROLL_FRICTION*g,d+=fi.SCROLL_FRICTION*g,a>0&&(S=!1,y=o*a*g),d>0&&(S=!1,b=f*d*g);let T=this.newGestureEvent(An.Change);T.translationX=y,T.translationY=b,n.forEach(B=>B.dispatchEvent(T)),S||this.inertia(t,n,_,a,o,u+y,d,f,h+b)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(o.pageX),u.rollingPageY.push(o.pageY),u.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,Ct([dC],Ta,"isTouchDevice",1);var fC=Ta,Vf=class extends Pe{onclick(e,t){this._register(Me(e,Gt.CLICK,n=>t(new dc(Rn(e),n))))}onmousedown(e,t){this._register(Me(e,Gt.MOUSE_DOWN,n=>t(new dc(Rn(e),n))))}onmouseover(e,t){this._register(Me(e,Gt.MOUSE_OVER,n=>t(new dc(Rn(e),n))))}onmouseleave(e,t){this._register(Me(e,Gt.MOUSE_LEAVE,n=>t(new dc(Rn(e),n))))}onkeydown(e,t){this._register(Me(e,Gt.KEY_DOWN,n=>t(new Tv(n))))}onkeyup(e,t){this._register(Me(e,Gt.KEY_UP,n=>t(new Tv(n))))}oninput(e,t){this._register(Me(e,Gt.INPUT,t))}onblur(e,t){this._register(Me(e,Gt.BLUR,t))}onfocus(e,t){this._register(Me(e,Gt.FOCUS,t))}onchange(e,t){this._register(Me(e,Gt.CHANGE,t))}ignoreGesture(e){return fC.ignoreTarget(e)}},Bv=11,pC=class extends Vf{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 Vb),this._register(Nv(this.bgDomNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nv(this.domNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cC),this._pointerdownScheduleRepeatTimer=this._register(new $f)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Rn(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()}},mC=class lf{constructor(t,n,s,a,o,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,u=u|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),d+o>u&&(d=u-o),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=u,this.scrollTop=d}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 lf(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 lf(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,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=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:u,scrollHeightChanged:d,scrollTopChanged:f}}},gC=class extends Pe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new mC(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 Ov(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=Ov.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)))}},Lv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function md(e,t){let n=t-e;return function(s){return e+n*yC(s)}}function _C(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":"")))}},xC=140,Kb=class extends Vf{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 bC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vb),this._shouldRender=!0,this.domNode=Ma(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(Me(this.domNode.domNode,Gt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new pC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Ma(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(Me(this.slider.domNode,Gt.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=uC(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),u=Math.abs(o-n);if(qb&&u>xC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},Gb=class of{constructor(t,n,s,a,o,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new of(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 u=Math.max(0,s-t),d=Math.max(0,u-2*n),f=a>0&&a>s;if(!f)return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*d/a))),_=(d-h)/(a-s),g=o*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:_,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=of._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),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(a,u),1),h=Math.max(Math.min(o,d),1),_=Math.max(a,u),g=Math.max(o,d);_%f===0&&g%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};cf.INSTANCE=new cf;var EC=cf,TC=class extends Vf{constructor(e,t,n){super(),this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new pe),this.onWillScroll=this._onWillScroll.event,this._options=DC(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 wC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new SC(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=Ma(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ma(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ma(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 $f),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ys(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,Nn&&(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 Dv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ys(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Dv(n))};this._mouseWheelToDispose.push(Me(this._listenOnDomNode,Gt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=EC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+o===0?u=o=0:Math.abs(o)>=Math.abs(u)?u=0:o=0),this._options.flipAxes&&([o,u]=[u,o]);let d=!Nn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(o){let _=zv*o,g=f.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(h,g)}if(u){let _=zv*u,g=f.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.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(),CC)}},AC=class extends TC{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 DC(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,Nn&&(t.className+=" mac"),t}var uf=class extends Pe{constructor(e,t,n,s,a,o,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new gC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Yf(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new AC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),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(ui.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(gt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(gt(()=>this._styleElement.remove())),this._register(ui.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}};uf=Ct([ge(2,wi),ge(3,sr),ge(4,Db),ge(5,yl),ge(6,Ci),ge(7,lr)],uf);var hf=class extends Pe{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(gt(()=>{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()}};hf=Ct([ge(1,wi),ge(2,sr),ge(3,qa),ge(4,lr)],hf);var RC=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)}},En={full:0,left:0,center:0,right:0},Or={full:0,left:0,center:0,right:0},ga={full:0,left:0,center:0,right:0},Mc=class extends Pe{constructor(e,t,n,s,a,o,u,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new RC,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(gt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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);Or.full=this._canvas.width,Or.left=e,Or.center=t,Or.right=e,this._refreshDrawHeightConstants(),ga.full=1,ga.left=1,ga.center=1+Or.left,ga.right=1+Or.left+Or.center}_refreshDrawHeightConstants(){En.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);En.left=t,En.center=t,En.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.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(ga[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-En[e.position||"full"]/2),Or[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+En[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}))}};Mc=Ct([ge(2,wi),ge(3,qa),ge(4,lr),ge(5,Ci),ge(6,yl),ge(7,sr)],Mc);var se;(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=""))(se||(se={}));var Ec;(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=""))(Ec||(Ec={}));var Xb;(e=>e.ST=`${se.ESC}\\`)(Xb||(Xb={}));var df=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)}}};df=Ct([ge(2,wi),ge(3,Ci),ge(4,Ss),ge(5,lr)],df);var Xt=0,Zt=0,Qt=0,St=0,jv={css:"#00000000",rgba:0},zt;(e=>{function t(a,o,u,d){return d!==void 0?`#${us(a)}${us(o)}${us(u)}${us(d)}`:`#${us(a)}${us(o)}${us(u)}`}e.toCss=t;function n(a,o,u,d=255){return(a<<24|o<<16|u<<8|d)>>>0}e.toRgba=n;function s(a,o,u,d){return{css:e.toCss(a,o,u,d),rgba:e.toRgba(a,o,u,d)}}e.toColor=s})(zt||(zt={}));var pt;(e=>{function t(f,h){if(St=(h.rgba&255)/255,St===1)return{css:h.css,rgba:h.rgba};let _=h.rgba>>24&255,g=h.rgba>>16&255,y=h.rgba>>8&255,b=f.rgba>>24&255,S=f.rgba>>16&255,T=f.rgba>>8&255;Xt=b+Math.round((_-b)*St),Zt=S+Math.round((g-S)*St),Qt=T+Math.round((y-T)*St);let B=zt.toCss(Xt,Zt,Qt),D=zt.toRgba(Xt,Zt,Qt);return{css:B,rgba:D}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,h,_){let g=Tc.ensureContrastRatio(f.rgba,h.rgba,_);if(g)return zt.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(f){let h=(f.rgba|255)>>>0;return[Xt,Zt,Qt]=Tc.toChannels(h),{css:zt.toCss(Xt,Zt,Qt),rgba:h}}e.opaque=a;function o(f,h){return St=Math.round(h*255),[Xt,Zt,Qt]=Tc.toChannels(f.rgba),{css:zt.toCss(Xt,Zt,Qt,St),rgba:zt.toRgba(Xt,Zt,Qt,St)}}e.opacity=o;function u(f,h){return St=f.rgba&255,o(f,St*h/255)}e.multiplyOpacity=u;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(pt||(pt={}));var vt;(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 Xt=parseInt(a.slice(1,2).repeat(2),16),Zt=parseInt(a.slice(2,3).repeat(2),16),Qt=parseInt(a.slice(3,4).repeat(2),16),zt.toColor(Xt,Zt,Qt);case 5:return Xt=parseInt(a.slice(1,2).repeat(2),16),Zt=parseInt(a.slice(2,3).repeat(2),16),Qt=parseInt(a.slice(3,4).repeat(2),16),St=parseInt(a.slice(4,5).repeat(2),16),zt.toColor(Xt,Zt,Qt,St);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 Xt=parseInt(o[1]),Zt=parseInt(o[2]),Qt=parseInt(o[3]),St=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),zt.toColor(Xt,Zt,Qt,St);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),[Xt,Zt,Qt,St]=t.getImageData(0,0,1,1).data,St!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:zt.toRgba(Xt,Zt,Qt,St),css:a}}e.toColor=s})(vt||(vt={}));var bi;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let u=s/255,d=a/255,f=o/255,h=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+_*.7152+g*.0722}e.relativeLuminance2=n})(bi||(bi={}));var Tc;(e=>{function t(u,d){if(St=(d&255)/255,St===1)return d;let f=d>>24&255,h=d>>16&255,_=d>>8&255,g=u>>24&255,y=u>>16&255,b=u>>8&255;return Xt=g+Math.round((f-g)*St),Zt=y+Math.round((h-y)*St),Qt=b+Math.round((_-b)*St),zt.toRgba(Xt,Zt,Qt)}e.blend=t;function n(u,d,f){let h=bi.relativeLuminance(u>>8),_=bi.relativeLuminance(d>>8);if(tr(h,_)>8));if(S>8));return S>B?b:T}return b}let g=a(u,d,f),y=tr(h,bi.relativeLuminance(g>>8));if(y>8));return y>S?g:b}return g}}e.ensureContrastRatio=n;function s(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));for(;T0||b>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));return(y<<24|b<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));for(;T>>0}e.increaseLuminance=a;function o(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=o})(Tc||(Tc={}));function us(e){let t=e.toString(16);return t.length<2?"0"+t:t}function tr(e,t){return e1){let _=this._getJoinedRanges(s,u,o,t,a);for(let g=0;g<_.length;g++)n.push(_[g])}a=h,u=o,d=this._workCell.fg,f=this._workCell.bg}o+=this._workCell.getChars().length||Ir.length}if(this._bufferService.cols-a>1){let h=this._getJoinedRanges(s,u,o,t,a);for(let _=0;_=z,j=F,U=this._workCell;if(y.length>0&&F===y[0][0]&&E){let ye=y.shift(),Ne=this._isCellInSelection(ye[0],t);for(X=ye[0]+1;X=ye[1]),E?(A=!0,U=new NC(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),j=ye[1]-1,Y=U.getWidth()):z=ye[1]}let le=this._isCellInSelection(F,t),k=n&&F===o,R=$&&F>=h&&F<=_,K=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,ye=>{K=!0});let w=U.getChars()||Ir;if(w===" "&&(U.isUnderline()||U.isOverline())&&(w=" "),me=Y*d-f.get(w,U.isBold(),U.isItalic()),!T)T=this._document.createElement("span");else if(B&&(le&&ce||!le&&!ce&&U.bg===P)&&(le&&ce&&b.selectionForeground||U.fg===J)&&U.extended.ext===I&&R===M&&me===Q&&!k&&!A&&!K&&E){U.isInvisible()?D+=Ir:D+=w,B++;continue}else B&&(T.textContent=D),T=this._document.createElement("span"),B=0,D="";if(P=U.bg,J=U.fg,I=U.extended.ext,M=R,Q=me,ce=le,A&&o>=F&&o<=j&&(o=F),!this._coreService.isCursorHidden&&k&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ie.push("xterm-cursor-blink"),ie.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(U.isBold()&&ie.push("xterm-bold"),U.isItalic()&&ie.push("xterm-italic"),U.isDim()&&ie.push("xterm-dim"),U.isInvisible()?D=Ir:D=U.getChars()||Ir,U.isUnderline()&&(ie.push(`xterm-underline-${U.extended.underlineStyle}`),D===" "&&(D=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Fa.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let ye=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&ye<8&&(ye+=8),T.style.textDecorationColor=b.ansi[ye].css}U.isOverline()&&(ie.push("xterm-overline"),D===" "&&(D=" ")),U.isStrikethrough()&&ie.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let V=U.getFgColor(),ue=U.getFgColorMode(),ae=U.getBgColor(),ve=U.getBgColorMode(),Be=!!U.isInverse();if(Be){let ye=V;V=ae,ae=ye;let Ne=ue;ue=ve,ve=Ne}let Se,he,we=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,ye=>{ye.options.layer!=="top"&&we||(ye.backgroundColorRGB&&(ve=50331648,ae=ye.backgroundColorRGB.rgba>>8&16777215,Se=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ue=50331648,V=ye.foregroundColorRGB.rgba>>8&16777215,he=ye.foregroundColorRGB),we=ye.options.layer==="top")}),!we&&le&&(Se=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ae=Se.rgba>>8&16777215,ve=50331648,we=!0,b.selectionForeground&&(ue=50331648,V=b.selectionForeground.rgba>>8&16777215,he=b.selectionForeground)),we&&ie.push("xterm-decoration-top");let Ee;switch(ve){case 16777216:case 33554432:Ee=b.ansi[ae],ie.push(`xterm-bg-${ae}`);break;case 50331648:Ee=zt.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(T,`background-color:#${Hv((ae>>>0).toString(16),"0",6)}`);break;case 0:default:Be?(Ee=b.foreground,ie.push("xterm-bg-257")):Ee=b.background}switch(Se||U.isDim()&&(Se=pt.multiplyOpacity(Ee,.5)),ue){case 16777216:case 33554432:U.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(T,Ee,b.ansi[V],U,Se,void 0)||ie.push(`xterm-fg-${V}`);break;case 50331648:let ye=zt.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(T,Ee,ye,U,Se,he)||this._addStyle(T,`color:#${Hv(V.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(T,Ee,b.foreground,U,Se,he)||Be&&ie.push("xterm-fg-257")}ie.length&&(T.className=ie.join(" "),ie.length=0),!k&&!A&&!K&&E?B++:T.textContent=D,me!==this.defaultSpacing&&(T.style.letterSpacing=`${me}px`),g.push(T),F=j}return T&&B&&(T.textContent=D),g}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||LC(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!a&&!o&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=pt.ensureContrastRatio(a||t,o||n,f),u.setColor((a||t).rgba,(o||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.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]}};ff=Ct([ge(1,Mb),ge(2,Ci),ge(3,sr),ge(4,Ss),ge(5,qa),ge(6,yl)],ff);function Hv(e,t,n){for(;e.length0&&(this._flat[s]=u),u}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let u=0;t&&(u|=1),n&&(u|=2),o=this._measure(e,u),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}},jC=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,u=n[1]-a,d=Math.max(o,0),f=Math.min(u,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,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 HC(){return new jC}var gd="xterm-dom-renderer-owner-",on="xterm-rows",pc="xterm-fg-",Pv="xterm-bg-",_a="xterm-focus",mc="xterm-selection",PC=1,pf=class extends Pe{constructor(e,t,n,s,a,o,u,d,f,h,_,g,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=u,this._charSizeService=f,this._optionsService=h,this._bufferService=_,this._coreService=g,this._coreBrowserService=y,this._themeService=b,this._terminalClass=PC++,this._rowElements=[],this._selectionRenderModel=HC(),this.onRequestRedraw=this._register(new pe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(on),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(mc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(ff,document),this._element.classList.add(gd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(gt(()=>{this._element.classList.remove(gd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new zC(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} .${on} 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} .${on} { 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} .${on} .xterm-dim { color: ${pt.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} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${mc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,u]of e.ansi.entries())t+=`${this._terminalSelector} .${pc}${o} { color: ${u.css}; }${this._terminalSelector} .${pc}${o}.xterm-dim { color: ${pt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Pv}${o} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${pc}257 { color: ${pt.opaque(e.background).css}; }${this._terminalSelector} .${pc}257.xterm-dim { color: ${pt.multiplyOpacity(pt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Pv}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(_a),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(_a),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,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(o,f?t[0]:e[0],f?e[0]:t[0],u-o+1))}else{let f=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(o,f,h));let _=u-o-1;if(d.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==u){let g=a===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return o+u>this.dimensions.css.canvas.width&&(u=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=`${u}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,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,_=this._rowElements[f],g=n.lines.get(h);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,h,h===s,u,d,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gd}${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 u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,a-1),_=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let S=b+d.ydisp,T=this._rowElements[b],B=d.lines.get(S);if(!T||!B)break;T.replaceChildren(...this._rowFactory.createRow(B,S,S===f,g,y,h,_,this.dimensions.css.cell.width,this._widthCache,o?b===n?e:0:-1,o?(b===s?t:a)-1:-1))}}};pf=Ct([ge(7,If),ge(8,qc),ge(9,Ci),ge(10,wi),ge(11,Ss),ge(12,sr),ge(13,yl)],pf);var mf=class extends Pe{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new pe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new UC(this._optionsService))}catch{this._measureStrategy=this._register(new IC(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())}};mf=Ct([ge(2,Ci)],mf);var Zb=class extends Pe{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)}},IC=class extends Zb{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}},UC=class extends Zb{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}},FC=class extends Pe{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 qC(this._window)),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new pe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(ui.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Me(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Me(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}},qC=class extends Pe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new _l),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(gt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Me(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)}},WC=class extends Pe{constructor(){super(),this.linkProviders=[],this._register(gt(()=>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 Kf(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),u=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-u]}function $C(e,t,n,s,a,o,u,d,f){if(!o)return;let h=Kf(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?u/2:0))/u),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),s+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var gf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return $C(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=Kf(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])}}};gf=Ct([ge(0,lr),ge(1,qc)],gf);var YC=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=[]}},Qb={};iw(Qb,{getSafariVersion:()=>KC,isChromeOS:()=>ix,isFirefox:()=>Jb,isIpad:()=>GC,isIphone:()=>XC,isLegacyEdge:()=>VC,isLinux:()=>Gf,isMac:()=>Lc,isNode:()=>Wc,isSafari:()=>ex,isWindows:()=>tx});var Wc=typeof process<"u"&&"title"in process,Wa=Wc?"node":navigator.userAgent,$a=Wc?"node":navigator.platform,Jb=Wa.includes("Firefox"),VC=Wa.includes("Edge"),ex=/^((?!chrome|android).)*safari/i.test(Wa);function KC(){if(!ex)return 0;let e=Wa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Lc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($a),GC=$a==="iPad",XC=$a==="iPhone",tx=["Windows","Win16","Win32","WinCE"].includes($a),Gf=$a.indexOf("Linux")>=0,ix=/\bCrOS\b/.test(Wa),nx=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()}},ZC=class extends nx{_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())}}},QC=class extends nx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Oc=!Wc&&"requestIdleCallback"in window?QC:ZC,JC=class{constructor(){this._queue=new Oc}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_f=class extends Pe{constructor(e,t,n,s,a,o,u,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new _l),this._pausedResizeTask=new JC,this._observerDisposable=this._register(new _l),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 pe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new pe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new pe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new YC((h,_)=>this._renderRows(h,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ek(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(gt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.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=gt(()=>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()}};_f=Ct([ge(2,Ci),ge(3,qc),ge(4,Ss),ge(5,qa),ge(6,wi),ge(7,sr),ge(8,yl)],_f);var ek=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 tk(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return rk(a,o,e,t,n,s)+$c(o,t,n,s)+sk(a,o,e,t,n,s);let u;if(o===t)return u=a>e?"D":"C",ja(Math.abs(a-e),za(u,s));u=o>t?"D":"C";let d=Math.abs(o-t),f=nk(o>t?e:a,n)+(d-1)*n.cols+1+ik(o>t?a:e);return ja(f,za(u,s))}function ik(e,t){return e-1}function nk(e,t){return t.cols-e}function rk(e,t,n,s,a,o){return $c(t,s,a,o).length===0?"":ja(sx(e,t,e,t-bs(t,a),!1,a).length,za("D",o))}function $c(e,t,n,s){let a=e-bs(e,n),o=t-bs(t,n),u=Math.abs(a-o)-lk(e,t,n);return ja(u,za(rx(e,t),s))}function sk(e,t,n,s,a,o){let u;$c(t,s,a,o).length>0?u=s-bs(s,a):u=t;let d=s,f=ak(e,t,n,s,a,o);return ja(sx(e,u,n,d,f==="C",a).length,za(f,o))}function lk(e,t,n){var u;let s=0,a=e-bs(e,n),o=t-bs(t,n);for(let d=0;d=0&&e0?u=s-bs(s,a):u=t,e=n&&ut?"A":"B"}function sx(e,t,n,s,a,o){let u=e,d=t,f="";for(;(u!==n||d!==s)&&d>=0&&do.cols-1?(f+=o.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!a&&u<0&&(f+=o.buffer.translateBufferLineToString(d,!1,0,e+1),u=o.cols-1,e=u,d--);return f+o.buffer.translateBufferLineToString(d,!1,e,u)}function za(e,t){let n=t?"O":"[";return se.ESC+n+e}function ja(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 Iv(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 _d=50,ck=15,uk=50,hk=500,dk=" ",fk=new RegExp(dk,"g"),vf=class extends Pe{constructor(e,t,n,s,a,o,u,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=u,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new pe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new pe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new pe),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 ok(this._bufferService),this._activeSelectionMode=0,this._register(gt(()=>{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(fk," ")).join(tx?`\r +`))}},Dw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Rw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Nw=0,dd=class{constructor(e){this.value=e,this.id=Nw++}},Mw=2,Bw,pe=class{constructor(t){var n,s,a,o;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new Tw((t==null?void 0:t.onListenerError)??wc,((s=this._options)==null?void 0:s.leakWarningThreshold)??Ew):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new kw(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,n,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||s.call(n),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,n,s)=>{var d,f,h,_,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new Rw(`${y}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((d=this._options)==null?void 0:d.onListenerError)||wc)(S),He.None}if(this._disposed)return He.None;n&&(t=t.bind(n));let a=new dd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=Aw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof dd?(this._deliveryQueue??(this._deliveryQueue=new Lw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=a,(g=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||g.call(_,this)),this._size++;let u=yt(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ur?s.add(u):Array.isArray(s)&&s.push(u),u}),this._event}_removeListener(t){var o,u,d,f;if((u=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||u.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,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*Mw<=n.length){let h=0;for(let _=0;_0}},Lw=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}},tf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new pe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new pe,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}};tf.INSTANCE=new tf;var Ff=tf;function Ow(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ff.INSTANCE.onDidChangeZoomLevel;function zw(e){return Ff.INSTANCE.getZoomFactor(e)}Ff.INSTANCE.onDidChangeFullscreen;var bl=typeof navigator=="object"?navigator.userAgent:"",nf=bl.indexOf("Firefox")>=0,jw=bl.indexOf("AppleWebKit")>=0,qf=bl.indexOf("Chrome")>=0,Hw=!qf&&bl.indexOf("Safari")>=0;bl.indexOf("Electron/")>=0;bl.indexOf("Android")>=0;var fd=!1;if(typeof rr.matchMedia=="function"){let e=rr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=rr.matchMedia("(display-mode: fullscreen)");fd=e.matches,Ow(rr,e,({matches:n})=>{fd&&t.matches||(fd=n)})}var ml="en",rf=!1,sf=!1,Cc=!1,Fb=!1,hc,kc=ml,wv=ml,Pw,xn,vs=globalThis,fi,vb;typeof vs.vscode<"u"&&typeof vs.vscode.process<"u"?fi=vs.vscode.process:typeof process<"u"&&typeof((vb=process==null?void 0:process.versions)==null?void 0:vb.node)=="string"&&(fi=process);var yb,Iw=typeof((yb=fi==null?void 0:fi.versions)==null?void 0:yb.electron)=="string",Uw=Iw&&(fi==null?void 0:fi.type)==="renderer",bb;if(typeof fi=="object"){rf=fi.platform==="win32",sf=fi.platform==="darwin",Cc=fi.platform==="linux",Cc&&fi.env.SNAP&&fi.env.SNAP_REVISION,fi.env.CI||fi.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hc=ml,kc=ml;let e=fi.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);hc=t.userLocale,wv=t.osLocale,kc=t.resolvedLanguage||ml,Pw=(bb=t.languagePack)==null?void 0:bb.translationsConfigFile}catch{}Fb=!0}else typeof navigator=="object"&&!Uw?(xn=navigator.userAgent,rf=xn.indexOf("Windows")>=0,sf=xn.indexOf("Macintosh")>=0,(xn.indexOf("Macintosh")>=0||xn.indexOf("iPad")>=0||xn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Cc=xn.indexOf("Linux")>=0,(xn==null?void 0:xn.indexOf("Mobi"))>=0,kc=globalThis._VSCODE_NLS_LANGUAGE||ml,hc=navigator.language.toLowerCase(),wv=hc):console.error("Unable to resolve platform.");var qb=rf,Bn=sf,Fw=Cc,Cv=Fb,Ln=xn,Lr=kc,qw;(e=>{function t(){return Lr}e.value=t;function n(){return Lr.length===2?Lr==="en":Lr.length>=3?Lr[0]==="e"&&Lr[1]==="n"&&Lr[2]==="-":!1}e.isDefaultVariant=n;function s(){return Lr==="en"}e.isDefault=s})(qw||(qw={}));var Ww=typeof vs.postMessage=="function"&&!vs.importScripts;(()=>{if(Ww){let e=[];vs.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}),vs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var $w=!!(Ln&&Ln.indexOf("Chrome")>=0);Ln&&Ln.indexOf("Firefox")>=0;!$w&&Ln&&Ln.indexOf("Safari")>=0;Ln&&Ln.indexOf("Edg/")>=0;Ln&&Ln.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Cv||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Cv||cl&&cl.clipboard&&cl.clipboard.readText;var Wf=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}},pd=new Wf,kv=new Wf,Ev=new Wf,Yw=new Array(230),Wb;(e=>{function t(d){return pd.keyCodeToStr(d)}e.toString=t;function n(d){return pd.strToKeyCode(d)}e.fromString=n;function s(d){return kv.keyCodeToStr(d)}e.toUserSettingsUS=s;function a(d){return Ev.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function o(d){return kv.strToKeyCode(d)||Ev.strToKeyCode(d)}e.fromUserSettings=o;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pd.keyCodeToStr(d)}e.toElectronAccelerator=u})(Wb||(Wb={}));var Vw=class $b{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 $b&&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 Kw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kw=class{constructor(e){if(e.length===0)throw yw("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 nC?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:pi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Yb})})(iC||(iC={}));var nC=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?Yb:(this._emitter||(this._emitter=new pe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$f=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 Xd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Xd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},rC=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 Xd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=yt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},sC;(e=>{async function t(s){let a,o=await Promise.all(s.map(u=>u.then(d=>d,d=>{a||(a=d)})));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(u){o(u)}})}e.withAsyncBody=n})(sC||(sC={}));var Rv=class hn{static fromArray(t){return new hn(n=>{n.emitMany(t)})}static fromPromise(t){return new hn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new hn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new hn(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 pe,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 hn(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return hn.map(this,t)}static filter(t,n){return new hn(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return hn.filter(this,t)}static coalesce(t){return hn.filter(t,n=>!!n)}coalesce(){return hn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return hn.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())}};Rv.EMPTY=Rv.fromArray([]);var{getWindow:Mn,getWindowId:lC,onDidRegisterWindow:aC}=(function(){let e=new Map,t={window:rr,disposables:new Ur};e.set(rr.vscodeWindowId,t);let n=new pe,s=new pe,a=new pe;function o(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return He.None;let d=new Ur,f={window:u,disposables:d.add(new Ur)};return e.set(u.vscodeWindowId,f),d.add(yt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(Ae(u,Jt.BEFORE_UNLOAD,()=>{a.fire(u)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:o,getWindow(u){var h;let d=u;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=u;return f!=null&&f.view?f.view.window:rr},getDocument(u){return Mn(u).document}}})(),oC=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 Ae(e,t,n,s){return new oC(e,t,n,s)}var Nv=function(e,t,n,s){return Ae(e,t,n,s)},Yf,cC=class extends rC{constructor(e){super(),this.defaultTarget=e&&Mn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Mv=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){wc(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 u=e.get(o)??[];for(t.set(o,u),e.set(o,[]),s.set(o,!0);u.length>0;)u.sort(Mv.sort),u.shift().execute();s.set(o,!1)};Yf=(o,u,d=0)=>{let f=lC(o),h=new Mv(u,d),_=e.get(f);return _||(_=[],e.set(f,_)),_.push(h),n.get(f)||(n.set(f,!0),o.requestAnimationFrame(()=>a(f))),h}})();function uC(e){let t=e.getBoundingClientRect(),n=Mn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Jt={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"},hC=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=zi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=zi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=zi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=zi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=zi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=zi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=zi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=zi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=zi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=zi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=zi(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=zi(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=zi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=zi(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 zi(e){return typeof e=="number"?`${e}px`:e}function Ma(e){return new hC(e)}var Vb=class{constructor(){this._hooks=new Ur,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(yt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Mn(e)}this._hooks.add(Ae(o,Jt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ae(o,Jt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function dC(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(...u){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,u)}),this[o]}}var Rn;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Rn||(Rn={}));var Ta=class _i extends He{constructor(){super(),this.dispatched=!1,this.targets=new Sv,this.ignoreTargets=new Sv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(pi.runAndSubscribe(aC,({window:t,disposables:n})=>{n.add(Ae(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ae(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ae(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:rr,disposables:this._store}))}static addTarget(t){if(!_i.isTouchDevice())return He.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.targets.push(t);return yt(n)}static ignoreTarget(t){if(!_i.isTouchDevice())return He.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.ignoreTargets.push(t);return yt(n)}static isTouchDevice(){return"ontouchstart"in rr||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=_i.HOLD_DELAY&&Math.abs(f.initialPageX-Ki(f.rollingPageX))<30&&Math.abs(f.initialPageY-Ki(f.rollingPageY))<30){let _=this.newGestureEvent(Rn.Contextmenu,f.initialTarget);_.pageX=Ki(f.rollingPageX),_.pageY=Ki(f.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=Ki(f.rollingPageX),g=Ki(f.rollingPageY),y=Ki(f.rollingTimestamps)-f.rollingTimestamps[0],b=_-f.rollingPageX[0],S=g-f.rollingPageY[0],T=[...this.targets].filter(L=>f.initialTarget instanceof Node&&L.contains(f.initialTarget));this.inertia(t,T,s,Math.abs(b)/y,b>0?1:-1,_,Math.abs(S)/y,S>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(Rn.End,f.initialTarget)),delete this.activeTouches[d.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===Rn.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>_i.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Rn.Change||t.type===Rn.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,u,d,f,h){this.handle=Yf(t,()=>{let _=Date.now(),g=_-s,y=0,b=0,S=!0;a+=_i.SCROLL_FRICTION*g,d+=_i.SCROLL_FRICTION*g,a>0&&(S=!1,y=o*a*g),d>0&&(S=!1,b=f*d*g);let T=this.newGestureEvent(Rn.Change);T.translationX=y,T.translationY=b,n.forEach(L=>L.dispatchEvent(T)),S||this.inertia(t,n,_,a,o,u+y,d,f,h+b)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(o.pageX),u.rollingPageY.push(o.pageY),u.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,At([dC],Ta,"isTouchDevice",1);var fC=Ta,Vf=class extends He{onclick(e,t){this._register(Ae(e,Jt.CLICK,n=>t(new dc(Mn(e),n))))}onmousedown(e,t){this._register(Ae(e,Jt.MOUSE_DOWN,n=>t(new dc(Mn(e),n))))}onmouseover(e,t){this._register(Ae(e,Jt.MOUSE_OVER,n=>t(new dc(Mn(e),n))))}onmouseleave(e,t){this._register(Ae(e,Jt.MOUSE_LEAVE,n=>t(new dc(Mn(e),n))))}onkeydown(e,t){this._register(Ae(e,Jt.KEY_DOWN,n=>t(new Tv(n))))}onkeyup(e,t){this._register(Ae(e,Jt.KEY_UP,n=>t(new Tv(n))))}oninput(e,t){this._register(Ae(e,Jt.INPUT,t))}onblur(e,t){this._register(Ae(e,Jt.BLUR,t))}onfocus(e,t){this._register(Ae(e,Jt.FOCUS,t))}onchange(e,t){this._register(Ae(e,Jt.CHANGE,t))}ignoreGesture(e){return fC.ignoreTarget(e)}},Bv=11,pC=class extends Vf{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 Vb),this._register(Nv(this.bgDomNode,Jt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nv(this.domNode,Jt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cC),this._pointerdownScheduleRepeatTimer=this._register(new $f)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Mn(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()}},mC=class lf{constructor(t,n,s,a,o,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,u=u|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),d+o>u&&(d=u-o),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=u,this.scrollTop=d}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 lf(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 lf(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,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=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:u,scrollHeightChanged:d,scrollTopChanged:f}}},gC=class extends He{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new mC(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 Ov(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=Ov.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)))}},Lv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function md(e,t){let n=t-e;return function(s){return e+n*yC(s)}}function _C(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":"")))}},xC=140,Kb=class extends Vf{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 bC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vb),this._shouldRender=!0,this.domNode=Ma(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(Ae(this.domNode.domNode,Jt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new pC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Ma(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(Ae(this.slider.domNode,Jt.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=uC(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),u=Math.abs(o-n);if(qb&&u>xC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},Gb=class of{constructor(t,n,s,a,o,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new of(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 u=Math.max(0,s-t),d=Math.max(0,u-2*n),f=a>0&&a>s;if(!f)return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*d/a))),_=(d-h)/(a-s),g=o*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:_,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=of._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),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(a,u),1),h=Math.max(Math.min(o,d),1),_=Math.max(a,u),g=Math.max(o,d);_%f===0&&g%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};cf.INSTANCE=new cf;var EC=cf,TC=class extends Vf{constructor(e,t,n){super(),this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new pe),this.onWillScroll=this._onWillScroll.event,this._options=DC(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 wC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new SC(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=Ma(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ma(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ma(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 $f),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ys(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,Bn&&(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 Dv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ys(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Dv(n))};this._mouseWheelToDispose.push(Ae(this._listenOnDomNode,Jt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=EC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+o===0?u=o=0:Math.abs(o)>=Math.abs(u)?u=0:o=0),this._options.flipAxes&&([o,u]=[u,o]);let d=!Bn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(o){let _=zv*o,g=f.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(h,g)}if(u){let _=zv*u,g=f.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.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(),CC)}},AC=class extends TC{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 DC(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,Bn&&(t.className+=" mac"),t}var uf=class extends He{constructor(e,t,n,s,a,o,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new gC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Yf(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new AC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),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(pi.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(yt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(yt(()=>this._styleElement.remove())),this._register(pi.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}};uf=At([ge(2,ki),ge(3,sr),ge(4,Db),ge(5,yl),ge(6,Ei),ge(7,lr)],uf);var hf=class extends He{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(yt(()=>{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()}};hf=At([ge(1,ki),ge(2,sr),ge(3,qa),ge(4,lr)],hf);var RC=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)}},An={full:0,left:0,center:0,right:0},Or={full:0,left:0,center:0,right:0},ga={full:0,left:0,center:0,right:0},Mc=class extends He{constructor(e,t,n,s,a,o,u,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new RC,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(yt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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);Or.full=this._canvas.width,Or.left=e,Or.center=t,Or.right=e,this._refreshDrawHeightConstants(),ga.full=1,ga.left=1,ga.center=1+Or.left,ga.right=1+Or.left+Or.center}_refreshDrawHeightConstants(){An.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);An.left=t,An.center=t,An.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.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(ga[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-An[e.position||"full"]/2),Or[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+An[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}))}};Mc=At([ge(2,ki),ge(3,qa),ge(4,lr),ge(5,Ei),ge(6,yl),ge(7,sr)],Mc);var se;(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=""))(se||(se={}));var Ec;(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=""))(Ec||(Ec={}));var Xb;(e=>e.ST=`${se.ESC}\\`)(Xb||(Xb={}));var df=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)}}};df=At([ge(2,ki),ge(3,Ei),ge(4,Ss),ge(5,lr)],df);var ei=0,ti=0,ii=0,Et=0,jv={css:"#00000000",rgba:0},Pt;(e=>{function t(a,o,u,d){return d!==void 0?`#${us(a)}${us(o)}${us(u)}${us(d)}`:`#${us(a)}${us(o)}${us(u)}`}e.toCss=t;function n(a,o,u,d=255){return(a<<24|o<<16|u<<8|d)>>>0}e.toRgba=n;function s(a,o,u,d){return{css:e.toCss(a,o,u,d),rgba:e.toRgba(a,o,u,d)}}e.toColor=s})(Pt||(Pt={}));var gt;(e=>{function t(f,h){if(Et=(h.rgba&255)/255,Et===1)return{css:h.css,rgba:h.rgba};let _=h.rgba>>24&255,g=h.rgba>>16&255,y=h.rgba>>8&255,b=f.rgba>>24&255,S=f.rgba>>16&255,T=f.rgba>>8&255;ei=b+Math.round((_-b)*Et),ti=S+Math.round((g-S)*Et),ii=T+Math.round((y-T)*Et);let L=Pt.toCss(ei,ti,ii),D=Pt.toRgba(ei,ti,ii);return{css:L,rgba:D}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,h,_){let g=Tc.ensureContrastRatio(f.rgba,h.rgba,_);if(g)return Pt.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(f){let h=(f.rgba|255)>>>0;return[ei,ti,ii]=Tc.toChannels(h),{css:Pt.toCss(ei,ti,ii),rgba:h}}e.opaque=a;function o(f,h){return Et=Math.round(h*255),[ei,ti,ii]=Tc.toChannels(f.rgba),{css:Pt.toCss(ei,ti,ii,Et),rgba:Pt.toRgba(ei,ti,ii,Et)}}e.opacity=o;function u(f,h){return Et=f.rgba&255,o(f,Et*h/255)}e.multiplyOpacity=u;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(gt||(gt={}));var xt;(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 ei=parseInt(a.slice(1,2).repeat(2),16),ti=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),Pt.toColor(ei,ti,ii);case 5:return ei=parseInt(a.slice(1,2).repeat(2),16),ti=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),Et=parseInt(a.slice(4,5).repeat(2),16),Pt.toColor(ei,ti,ii,Et);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 ei=parseInt(o[1]),ti=parseInt(o[2]),ii=parseInt(o[3]),Et=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Pt.toColor(ei,ti,ii,Et);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),[ei,ti,ii,Et]=t.getImageData(0,0,1,1).data,Et!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Pt.toRgba(ei,ti,ii,Et),css:a}}e.toColor=s})(xt||(xt={}));var Si;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let u=s/255,d=a/255,f=o/255,h=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+_*.7152+g*.0722}e.relativeLuminance2=n})(Si||(Si={}));var Tc;(e=>{function t(u,d){if(Et=(d&255)/255,Et===1)return d;let f=d>>24&255,h=d>>16&255,_=d>>8&255,g=u>>24&255,y=u>>16&255,b=u>>8&255;return ei=g+Math.round((f-g)*Et),ti=y+Math.round((h-y)*Et),ii=b+Math.round((_-b)*Et),Pt.toRgba(ei,ti,ii)}e.blend=t;function n(u,d,f){let h=Si.relativeLuminance(u>>8),_=Si.relativeLuminance(d>>8);if(tr(h,_)>8));if(S>8));return S>L?b:T}return b}let g=a(u,d,f),y=tr(h,Si.relativeLuminance(g>>8));if(y>8));return y>S?g:b}return g}}e.ensureContrastRatio=n;function s(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));for(;T0||b>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));return(y<<24|b<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));for(;T>>0}e.increaseLuminance=a;function o(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=o})(Tc||(Tc={}));function us(e){let t=e.toString(16);return t.length<2?"0"+t:t}function tr(e,t){return e1){let _=this._getJoinedRanges(s,u,o,t,a);for(let g=0;g<_.length;g++)n.push(_[g])}a=h,u=o,d=this._workCell.fg,f=this._workCell.bg}o+=this._workCell.getChars().length||Ir.length}if(this._bufferService.cols-a>1){let h=this._getJoinedRanges(s,u,o,t,a);for(let _=0;_=z,j=q,U=this._workCell;if(y.length>0&&q===y[0][0]&&k){let oe=y.shift(),Se=this._isCellInSelection(oe[0],t);for(X=oe[0]+1;X=oe[1]),k?(A=!0,U=new NC(this._workCell,e.translateToString(!0,oe[0],oe[1]),oe[1]-oe[0]),j=oe[1]-1,G=U.getWidth()):z=oe[1]}let le=this._isCellInSelection(q,t),E=n&&q===o,R=F&&q>=h&&q<=_,Y=!1;this._decorationService.forEachDecorationAtCell(q,t,void 0,oe=>{Y=!0});let w=U.getChars()||Ir;if(w===" "&&(U.isUnderline()||U.isOverline())&&(w=" "),me=G*d-f.get(w,U.isBold(),U.isItalic()),!T)T=this._document.createElement("span");else if(L&&(le&&ue||!le&&!ue&&U.bg===P)&&(le&&ue&&b.selectionForeground||U.fg===J)&&U.extended.ext===I&&R===M&&me===Q&&!E&&!A&&!Y&&k){U.isInvisible()?D+=Ir:D+=w,L++;continue}else L&&(T.textContent=D),T=this._document.createElement("span"),L=0,D="";if(P=U.bg,J=U.fg,I=U.extended.ext,M=R,Q=me,ue=le,A&&o>=q&&o<=j&&(o=q),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&te.push("xterm-cursor-blink"),te.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline");break}}if(U.isBold()&&te.push("xterm-bold"),U.isItalic()&&te.push("xterm-italic"),U.isDim()&&te.push("xterm-dim"),U.isInvisible()?D=Ir:D=U.getChars()||Ir,U.isUnderline()&&(te.push(`xterm-underline-${U.extended.underlineStyle}`),D===" "&&(D=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Fa.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let oe=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&oe<8&&(oe+=8),T.style.textDecorationColor=b.ansi[oe].css}U.isOverline()&&(te.push("xterm-overline"),D===" "&&(D=" ")),U.isStrikethrough()&&te.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let V=U.getFgColor(),he=U.getFgColorMode(),ae=U.getBgColor(),_e=U.getBgColorMode(),De=!!U.isInverse();if(De){let oe=V;V=ae,ae=oe;let Se=he;he=_e,_e=Se}let xe,Ke,ct=!1;this._decorationService.forEachDecorationAtCell(q,t,void 0,oe=>{oe.options.layer!=="top"&&ct||(oe.backgroundColorRGB&&(_e=50331648,ae=oe.backgroundColorRGB.rgba>>8&16777215,xe=oe.backgroundColorRGB),oe.foregroundColorRGB&&(he=50331648,V=oe.foregroundColorRGB.rgba>>8&16777215,Ke=oe.foregroundColorRGB),ct=oe.options.layer==="top")}),!ct&&le&&(xe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ae=xe.rgba>>8&16777215,_e=50331648,ct=!0,b.selectionForeground&&(he=50331648,V=b.selectionForeground.rgba>>8&16777215,Ke=b.selectionForeground)),ct&&te.push("xterm-decoration-top");let St;switch(_e){case 16777216:case 33554432:St=b.ansi[ae],te.push(`xterm-bg-${ae}`);break;case 50331648:St=Pt.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(T,`background-color:#${Hv((ae>>>0).toString(16),"0",6)}`);break;case 0:default:De?(St=b.foreground,te.push("xterm-bg-257")):St=b.background}switch(xe||U.isDim()&&(xe=gt.multiplyOpacity(St,.5)),he){case 16777216:case 33554432:U.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(T,St,b.ansi[V],U,xe,void 0)||te.push(`xterm-fg-${V}`);break;case 50331648:let oe=Pt.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(T,St,oe,U,xe,Ke)||this._addStyle(T,`color:#${Hv(V.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(T,St,b.foreground,U,xe,Ke)||De&&te.push("xterm-fg-257")}te.length&&(T.className=te.join(" "),te.length=0),!E&&!A&&!Y&&k?L++:T.textContent=D,me!==this.defaultSpacing&&(T.style.letterSpacing=`${me}px`),g.push(T),q=j}return T&&L&&(T.textContent=D),g}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||LC(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!a&&!o&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=gt.ensureContrastRatio(a||t,o||n,f),u.setColor((a||t).rgba,(o||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.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]}};ff=At([ge(1,Mb),ge(2,Ei),ge(3,sr),ge(4,Ss),ge(5,qa),ge(6,yl)],ff);function Hv(e,t,n){for(;e.length0&&(this._flat[s]=u),u}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let u=0;t&&(u|=1),n&&(u|=2),o=this._measure(e,u),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}},jC=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,u=n[1]-a,d=Math.max(o,0),f=Math.min(u,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,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 HC(){return new jC}var gd="xterm-dom-renderer-owner-",un="xterm-rows",pc="xterm-fg-",Pv="xterm-bg-",_a="xterm-focus",mc="xterm-selection",PC=1,pf=class extends He{constructor(e,t,n,s,a,o,u,d,f,h,_,g,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=u,this._charSizeService=f,this._optionsService=h,this._bufferService=_,this._coreService=g,this._coreBrowserService=y,this._themeService=b,this._terminalClass=PC++,this._rowElements=[],this._selectionRenderModel=HC(),this.onRequestRedraw=this._register(new pe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(un),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(mc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(ff,document),this._element.classList.add(gd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(yt(()=>{this._element.classList.remove(gd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new zC(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} .${un} 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} .${un} { 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} .${un} .xterm-dim { color: ${gt.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} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${mc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,u]of e.ansi.entries())t+=`${this._terminalSelector} .${pc}${o} { color: ${u.css}; }${this._terminalSelector} .${pc}${o}.xterm-dim { color: ${gt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Pv}${o} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${pc}257 { color: ${gt.opaque(e.background).css}; }${this._terminalSelector} .${pc}257.xterm-dim { color: ${gt.multiplyOpacity(gt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Pv}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(_a),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(_a),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,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(o,f?t[0]:e[0],f?e[0]:t[0],u-o+1))}else{let f=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(o,f,h));let _=u-o-1;if(d.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==u){let g=a===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return o+u>this.dimensions.css.canvas.width&&(u=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=`${u}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,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,_=this._rowElements[f],g=n.lines.get(h);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,h,h===s,u,d,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gd}${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 u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,a-1),_=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let S=b+d.ydisp,T=this._rowElements[b],L=d.lines.get(S);if(!T||!L)break;T.replaceChildren(...this._rowFactory.createRow(L,S,S===f,g,y,h,_,this.dimensions.css.cell.width,this._widthCache,o?b===n?e:0:-1,o?(b===s?t:a)-1:-1))}}};pf=At([ge(7,If),ge(8,qc),ge(9,Ei),ge(10,ki),ge(11,Ss),ge(12,sr),ge(13,yl)],pf);var mf=class extends He{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new pe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new UC(this._optionsService))}catch{this._measureStrategy=this._register(new IC(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())}};mf=At([ge(2,Ei)],mf);var Zb=class extends He{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)}},IC=class extends Zb{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}},UC=class extends Zb{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}},FC=class extends He{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 qC(this._window)),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new pe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(pi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ae(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ae(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}},qC=class extends He{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new _l),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(yt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ae(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)}},WC=class extends He{constructor(){super(),this.linkProviders=[],this._register(yt(()=>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 Kf(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),u=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-u]}function $C(e,t,n,s,a,o,u,d,f){if(!o)return;let h=Kf(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?u/2:0))/u),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),s+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var gf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return $C(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=Kf(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])}}};gf=At([ge(0,lr),ge(1,qc)],gf);var YC=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=[]}},Qb={};iw(Qb,{getSafariVersion:()=>KC,isChromeOS:()=>ix,isFirefox:()=>Jb,isIpad:()=>GC,isIphone:()=>XC,isLegacyEdge:()=>VC,isLinux:()=>Gf,isMac:()=>Lc,isNode:()=>Wc,isSafari:()=>ex,isWindows:()=>tx});var Wc=typeof process<"u"&&"title"in process,Wa=Wc?"node":navigator.userAgent,$a=Wc?"node":navigator.platform,Jb=Wa.includes("Firefox"),VC=Wa.includes("Edge"),ex=/^((?!chrome|android).)*safari/i.test(Wa);function KC(){if(!ex)return 0;let e=Wa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Lc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($a),GC=$a==="iPad",XC=$a==="iPhone",tx=["Windows","Win16","Win32","WinCE"].includes($a),Gf=$a.indexOf("Linux")>=0,ix=/\bCrOS\b/.test(Wa),nx=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()}},ZC=class extends nx{_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())}}},QC=class extends nx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Oc=!Wc&&"requestIdleCallback"in window?QC:ZC,JC=class{constructor(){this._queue=new Oc}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_f=class extends He{constructor(e,t,n,s,a,o,u,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new _l),this._pausedResizeTask=new JC,this._observerDisposable=this._register(new _l),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 pe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new pe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new pe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new YC((h,_)=>this._renderRows(h,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ek(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(yt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.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=yt(()=>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()}};_f=At([ge(2,Ei),ge(3,qc),ge(4,Ss),ge(5,qa),ge(6,ki),ge(7,sr),ge(8,yl)],_f);var ek=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 tk(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return rk(a,o,e,t,n,s)+$c(o,t,n,s)+sk(a,o,e,t,n,s);let u;if(o===t)return u=a>e?"D":"C",ja(Math.abs(a-e),za(u,s));u=o>t?"D":"C";let d=Math.abs(o-t),f=nk(o>t?e:a,n)+(d-1)*n.cols+1+ik(o>t?a:e);return ja(f,za(u,s))}function ik(e,t){return e-1}function nk(e,t){return t.cols-e}function rk(e,t,n,s,a,o){return $c(t,s,a,o).length===0?"":ja(sx(e,t,e,t-bs(t,a),!1,a).length,za("D",o))}function $c(e,t,n,s){let a=e-bs(e,n),o=t-bs(t,n),u=Math.abs(a-o)-lk(e,t,n);return ja(u,za(rx(e,t),s))}function sk(e,t,n,s,a,o){let u;$c(t,s,a,o).length>0?u=s-bs(s,a):u=t;let d=s,f=ak(e,t,n,s,a,o);return ja(sx(e,u,n,d,f==="C",a).length,za(f,o))}function lk(e,t,n){var u;let s=0,a=e-bs(e,n),o=t-bs(t,n);for(let d=0;d=0&&e0?u=s-bs(s,a):u=t,e=n&&ut?"A":"B"}function sx(e,t,n,s,a,o){let u=e,d=t,f="";for(;(u!==n||d!==s)&&d>=0&&do.cols-1?(f+=o.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!a&&u<0&&(f+=o.buffer.translateBufferLineToString(d,!1,0,e+1),u=o.cols-1,e=u,d--);return f+o.buffer.translateBufferLineToString(d,!1,e,u)}function za(e,t){let n=t?"O":"[";return se.ESC+n+e}function ja(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 Iv(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 _d=50,ck=15,uk=50,hk=500,dk=" ",fk=new RegExp(dk,"g"),vf=class extends He{constructor(e,t,n,s,a,o,u,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=u,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new pn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new pe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new pe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new pe),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 ok(this._bufferService),this._activeSelectionMode=0,this._register(yt(()=>{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(fk," ")).join(tx?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Gf&&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=Iv(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=Kf(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,-_d),_d),t/=_d,t/Math.abs(t)+Math.round(t*(ck-1)))}shouldForceSelection(e){return Lc?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(),uk)}_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&&!(Lc&&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 u=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(o,e[0]),f=d,h=e[0]-d,_=0,g=0,y=0,b=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;f1&&(b+=X-1,f+=X-1);B>0&&d>0&&!this._isCharWordSeparator(o.loadCell(B-1,this._workCell));){o.loadCell(B-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,B--):P>1&&(y+=P-1,d-=P-1),d--,B--}for(;D1&&(b+=P-1,f+=P-1),f++,D++}}f++;let S=d+h-_+y,T=Math.min(this._bufferService.cols,f-d+_+g-y-b);if(!(!t&&u.slice(d,f).trim()==="")){if(n&&S===0&&o.getCodePoint(0)!==32){let B=a.lines.get(e[1]-1);if(B&&o.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let X=this._bufferService.cols-D.start;S-=X,T+=X}}}if(s&&S+T===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let B=a.lines.get(e[1]+1);if(B!=null&&B.isWrapped&&B.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(T+=D.length)}}return{start:S,length:T}}}_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=Iv(n,this._bufferService.cols)}};vf=Ct([ge(3,wi),ge(4,Ss),ge(5,Uf),ge(6,Ci),ge(7,lr),ge(8,sr)],vf);var Uv=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={}}},Fv=class{constructor(){this._color=new Uv,this._css=new Uv}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()}},Ut=Object.freeze((()=>{let e=[vt.toColor("#2e3436"),vt.toColor("#cc0000"),vt.toColor("#4e9a06"),vt.toColor("#c4a000"),vt.toColor("#3465a4"),vt.toColor("#75507b"),vt.toColor("#06989a"),vt.toColor("#d3d7cf"),vt.toColor("#555753"),vt.toColor("#ef2929"),vt.toColor("#8ae234"),vt.toColor("#fce94f"),vt.toColor("#729fcf"),vt.toColor("#ad7fa8"),vt.toColor("#34e2e2"),vt.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:zt.toCss(s,a,o),rgba:zt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:zt.toCss(s,s,s),rgba:zt.toRgba(s,s,s)})}return e})()),ps=vt.toColor("#ffffff"),Aa=vt.toColor("#000000"),qv=vt.toColor("#ffffff"),Wv=Aa,va={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},pk=ps,yf=class extends Pe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Fv,this._halfContrastCache=new Fv,this._onChangeColors=this._register(new pe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ps,background:Aa,cursor:qv,cursorAccent:Wv,selectionForeground:void 0,selectionBackgroundTransparent:va,selectionBackgroundOpaque:pt.blend(Aa,va),selectionInactiveBackgroundTransparent:va,selectionInactiveBackgroundOpaque:pt.blend(Aa,va),scrollbarSliderBackground:pt.opacity(ps,.2),scrollbarSliderHoverBackground:pt.opacity(ps,.4),scrollbarSliderActiveBackground:pt.opacity(ps,.5),overviewRulerBorder:ps,ansi:Ut.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=st(e.foreground,ps),t.background=st(e.background,Aa),t.cursor=pt.blend(t.background,st(e.cursor,qv)),t.cursorAccent=pt.blend(t.background,st(e.cursorAccent,Wv)),t.selectionBackgroundTransparent=st(e.selectionBackground,va),t.selectionBackgroundOpaque=pt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,jv):void 0,t.selectionForeground===jv&&(t.selectionForeground=void 0),pt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pt.opacity(t.selectionBackgroundTransparent,.3)),pt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,pt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,pt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,pt.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,pk),t.ansi=Ut.slice(),t.ansi[0]=st(e.black,Ut[0]),t.ansi[1]=st(e.red,Ut[1]),t.ansi[2]=st(e.green,Ut[2]),t.ansi[3]=st(e.yellow,Ut[3]),t.ansi[4]=st(e.blue,Ut[4]),t.ansi[5]=st(e.magenta,Ut[5]),t.ansi[6]=st(e.cyan,Ut[6]),t.ansi[7]=st(e.white,Ut[7]),t.ansi[8]=st(e.brightBlack,Ut[8]),t.ansi[9]=st(e.brightRed,Ut[9]),t.ansi[10]=st(e.brightGreen,Ut[10]),t.ansi[11]=st(e.brightYellow,Ut[11]),t.ansi[12]=st(e.brightBlue,Ut[12]),t.ansi[13]=st(e.brightMagenta,Ut[13]),t.ansi[14]=st(e.brightCyan,Ut[14]),t.ansi[15]=st(e.brightWhite,Ut[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-u.index),s=[];for(let o of n){let u=this._services.get(o.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(u)}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)}},_k={trace:0,debug:1,info:2,warn:3,error:4,off:5},vk="xterm.js: ",bf=class extends Pe{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=_k[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*He+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*He+0]=t|2097152|n[2]<<22):this._data[t*He+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*He+0]>>22}hasWidth(t){return this._data[t*He+0]&12582912}getFg(t){return this._data[t*He+1]}getBg(t){return this._data[t*He+2]}hasContent(t){return this._data[t*He+0]&4194303}getCodePoint(t){let n=this._data[t*He+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*He+0]&2097152}getString(t){let n=this._data[t*He+0];return n&2097152?this._combined[t]:n&2097151?Hr(n&2097151):""}isProtected(t){return this._data[t*He+2]&536870912}loadCell(t,n){return gc=t*He,n.content=this._data[gc+0],n.fg=this._data[gc+1],n.bg=this._data[gc+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*He+0]=n.content,this._data[t*He+1]=n.fg,this._data[t*He+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*He+0]=n|s<<22,this._data[t*He+1]=a.fg,this._data[t*He+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*He+0];a&2097152?this._combined[t]+=Hr(n):a&2097151?(this._combined[t]=Hr(a&2097151)+Hr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*He+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[d]}let o=Object.keys(this._extendedAttrs);for(let u=0;u=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*vd=0;--t)if(this._data[t*He+0]&4194303)return t+(this._data[t*He+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*He+0]&4194303||this._data[t*He+2]&50331648)return t+(this._data[t*He+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let u=t._data;if(o)for(let f=a-1;f>=0;f--){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 yk(e,t,n,s,a,o){let u=[];for(let d=0;d=d&&s0&&(B>g||_[B].getTrimmedLength()===0);B--)T++;T>0&&(u.push(d+_.length-T),u.push(T)),d+=_.length-1}return u}function bk(e,t){let n=[],s=0,a=t[s],o=0;for(let u=0;uHa(e,h,t)).reduce((f,h)=>f+h),o=0,u=0,d=0;for(;df&&(o-=f,u++);let h=e[u].getWidth(o-1)===2;h&&o--;let _=h?n-1:n;s.push(_),d+=_}return s}function Ha(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 ax=class ox{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ox._nextId++,this._onDispose=this.register(new pe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ys(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ax._nextId=1;var wk=ax,Wt={},ms=Wt.B;Wt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Wt.A={"#":"£"};Wt.B=void 0;Wt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Wt.C=Wt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Wt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Wt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Wt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Wt.E=Wt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Wt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Wt.H=Wt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Yv=4294967295,Vv=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=Ot.clone(),this.savedCharset=ms,this.markers=[],this._nullCell=dn.fromCharData([0,kb,1,0]),this._whitespaceCell=dn.fromCharData([0,Ir,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Oc,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $v(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 Nc),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 Nc),this._whitespaceCell}getBlankLine(e,t){return new Da(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&&eYv?Yv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ot);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 $v(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ot),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 Da(e,n)));else for(let u=this._rows;u>t;u--)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(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,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=yk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ot),n);if(s.length>0){let a=bk(this.lines,s);xk(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ot),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),f.unshift(d);if(!n){let P=this.ybase+this.y;if(P>=u&&P0&&(a.push({start:u+f.length+o,newLines:b}),o+=b.length),f.push(...b);let S=_.length-1,T=_[S];T===0&&(S--,T=_[S]);let B=f.length-g-1,D=h;for(;B>=0;){let P=Math.min(D,T);if(f[S]===void 0)break;if(f[S].copyCellsFrom(f[B],D-P,T-P,P,!0),T-=P,T===0&&(S--,T=_[S]),D-=P,D===0){B--;let J=Math.max(B,0);D=Ha(f,J,this._cols)}}for(let P=0;P0;)this.ybase===0?this.y0){let u=[],d=[];for(let T=0;T=0;T--)if(g&&g.start>h+y){for(let B=g.newLines.length-1;B>=0;B--)this.lines.set(T--,g.newLines[B]);T++,u.push({index:h+1,amount:g.newLines.length}),y+=g.newLines.length,g=a[++_]}else this.lines.set(T,d[h--]);let b=0;for(let T=u.length-1;T>=0;T--)u[T].index+=b,this.lines.onInsertEmitter.fire(u[T]),b+=u[T].amount;let S=Math.max(0,f+o-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}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)}},Ck=class extends Pe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new pe),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 Vv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Vv(!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)}},cx=2,ux=1,xf=class extends Pe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new pe),this.onResize=this._onResize.event,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,cx),this.rows=Math.max(e.rawOptions.rows||0,ux),this.buffers=this._register(new Ck(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 u=n.lines.isFull;o===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=o-a+1;n.lines.shiftElements(a+1,u-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))}};xf=Ct([ge(0,Ci)],xf);var ul={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:Lc,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},kk=["normal","bold","100","200","300","400","500","600","700","800","900"],Ek=class extends Pe{constructor(e){super(),this._onOptionChange=this._register(new pe),this.onOptionChange=this._onOptionChange.event;let t={...ul};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(gt(()=>{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 ul))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in ul))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=ul[e]),!Tk(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=kk.includes(t)?t:ul[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 Tk(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 Kv=Object.freeze({insertMode:!1}),Gv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Sf=class extends Pe{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 pe),this.onData=this._onData.event,this._onUserInput=this._register(new pe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new pe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new pe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ra(Kv),this.decPrivateModes=Ra(Gv)}reset(){this.modes=Ra(Kv),this.decPrivateModes=Ra(Gv)}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))}};Sf=Ct([ge(0,wi),ge(1,Rb),ge(2,Ci)],Sf);var Xv={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 yd(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 bd=String.fromCharCode,Zv={DEFAULT:e=>{let t=[yd(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${bd(t[0])}${bd(t[1])}${bd(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yd(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yd(e,!0)};${e.x};${e.y}${t}`}},wf=class extends Pe{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 pe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Xv))this.addProtocol(s,Xv[s]);for(let s of Object.keys(Zv))this.addEncoding(s,Zv[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)}};wf=Ct([ge(0,wi),ge(1,Ss),ge(2,Ci)],wf);var xd=[[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]],Ak=[[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]],Ft;function Dk(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=_s.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return _s.createPropertyValue(0,n,s)}},_s=class Ac{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new pe,this.onChange=this._onChange.event;let t=new Rk;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(u);let h=t.charCodeAt(o);56320<=h&&h<=57343?u=(u-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let d=this.charProperties(u,s),f=Ac.extractWidth(d);Ac.extractShouldJoin(d)&&(f-=Ac.extractWidth(s)),n+=f,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},Nk=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 Qv(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 ya=2147483647,Mk=256,hx=class Cf{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>Mk)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 Cf;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>ya?ya: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>ya?ya: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,ya):t}},ba=[],Bk=class{constructor(){this._state=0,this._active=ba,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=ba}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=ba,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ba,!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",Fc(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=ba,this._id=-1,this._state=0}}},Yi=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+=Fc(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}},xa=[],Lk=class{constructor(){this._handlers=Object.create(null),this._active=xa,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xa}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=xa,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||xa,!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",Fc(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=xa,this._ident=0}},Na=new hx;Na.addParam(0);var Jv=class{constructor(e){this._handler=e,this._data="",this._params=Na,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Na,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Fc(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=Na,this._data="",this._hitLimit=!1,n));return this._params=Na,this._data="",this._hitLimit=!1,t}},Ok=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;af),n=(d,f)=>t.slice(d,f),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in o)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,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(un,0,2,0),e.add(un,8,5,8),e.add(un,6,0,6),e.add(un,11,0,11),e.add(un,13,13,13),e})(),jk=class extends Pe{constructor(e=zk){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 hx,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(gt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Bk),this._dcsParser=this._register(new Lk),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,u;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 d=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(u=d[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(u=d[f](),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;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],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;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 d=o;d>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=0&&(u=f[h](this._params),u!==!0);h--)if(u instanceof Promise)return this._preserveStack(3,f,h,a,d),u;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(++d47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],g=_?_.length-1:-1;for(;g>=0&&(u=_[g](),u!==!0);g--)if(u instanceof Promise)return this._preserveStack(4,_,g,a,d),u;g<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s=t||(s=e[y])<32||s>127&&s>4:o>>8}return s}}function Sd(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 Ik(e,t=16){let[n,s,a]=e;return`rgb:${Sd(n,t)}/${Sd(s,t)}/${Sd(a,t)}`}var Uk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zr=131072,ty=10;function iy(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 ny=5e3,ry=0,Fk=class extends Pe{constructor(e,t,n,s,a,o,u,d,f=new jk){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=u,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new aw,this._utf8Decoder=new ow,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ot.clone(),this._eraseAttrDataInternal=Ot.clone(),this._onRequestBell=this._register(new pe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new pe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new pe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new pe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new pe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new pe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new pe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new pe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new pe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new pe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new pe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new pe),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 kf(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:_.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:_,data:g})}),this._parser.setDcsHandlerFallback((h,_,g)=>{_==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:_,payload:g})}),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(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ec.IND,()=>this.index()),this._parser.setExecuteHandler(Ec.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ec.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Yi(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Yi(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Yi(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Yi(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Yi(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Yi(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Yi(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Yi(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Yi(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Yi(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Yi(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Yi(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 Wt)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 Jv((h,_)=>this.requestStatusString(h,_)))}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"),ny))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ny} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,u=this._parseStack.paused;if(u){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>zr&&(o=this._parseStack.position+zr)}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.lengthzr)for(let h=o;h0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let y=this._parser.precedingJoinState;for(let b=t;bd){if(f){let D=g,X=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&g instanceof Da&&g.copyCellsFrom(D,X,0,B,!1);X=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(h&&(g.insertCells(this._activeBuffer.x,a-B,this._activeBuffer.getNullCell(_)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,_)),g.setCellFromCodepoint(this._activeBuffer.x++,s,a,_),a>0)for(;--a;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=y,this._activeBuffer.x0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>iy(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Jv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Yi(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 f=d;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,u=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:h,alt:_}=d,g=this._optionsService.rawOptions,y=(T,B)=>(u.triggerDataEvent(`${se.ESC}[${t?"":"?"}${T};${B}$y`),!0),b=T=>T?1:2,S=e.params[0];return t?S===2?y(S,4):S===4?y(S,b(u.modes.insertMode)):S===12?y(S,3):S===20?y(S,b(g.convertEol)):y(S,0):S===1?y(S,b(s.applicationCursorKeys)):S===3?y(S,g.windowOptions.setWinLines?f===80?2:f===132?1:0:0):S===6?y(S,b(s.origin)):S===7?y(S,b(s.wraparound)):S===8?y(S,3):S===9?y(S,b(a==="X10")):S===12?y(S,b(g.cursorBlink)):S===25?y(S,b(!u.isCursorHidden)):S===45?y(S,b(s.reverseWraparound)):S===66?y(S,b(s.applicationKeypad)):S===67?y(S,4):S===1e3?y(S,b(a==="VT200")):S===1002?y(S,b(a==="DRAG")):S===1003?y(S,b(a==="ANY")):S===1004?y(S,b(s.sendFocus)):S===1005?y(S,4):S===1006?y(S,b(o==="SGR")):S===1015?y(S,4):S===1016?y(S,b(o==="SGR_PIXELS")):S===1048?y(S,1):S===47||S===1047||S===1049?y(S,b(h===_)):S===2004?y(S,b(s.bracketedPasteMode)):S===2026?y(S,b(s.synchronizedOutput)):y(S,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Fa.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 u=e.getSubParams(t+o),d=0;do s[1]===5&&(a=1),s[o+d+1+a]=u[d];while(++d=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=Ot.fg,e.bg=Ot.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|=Ot.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ot.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|=Ot.fg&16777215,s.bg&=-67108864,s.bg|=Ot.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.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(`${se.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=Ot.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(!iy(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(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ty&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ty&&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(sy(o))if(a==="?")t.push({type:0,index:o});else{let u=ey(a);u&&t.push({type:1,index:o,color:u})}}}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=ey(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=Ot.clone(),this._eraseAttrDataInternal=Ot.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 dn;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(`${se.ESC}${u}${se.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)}},kf=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&&(ry=e,e=t,t=ry),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kf=Ct([ge(0,wi)],kf);function sy(e){return 0<=e&&e<256}var qk=5e7,ly=12,Wk=50,$k=class extends Pe{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 pe),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>qk)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 u=d=>performance.now()-n>=ly?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);a.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=ly)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Wk&&(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()}},Ef=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 d=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.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),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(u,o)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.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)))}};Ef=Ct([ge(0,wi)],Ef);var ay=!1,Yk=class extends Pe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new _l),this._onBinary=this._register(new pe),this.onBinary=this._onBinary.event,this._onData=this._register(new pe),this.onData=this._onData.event,this._onLineFeed=this._register(new pe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new pe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new pe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new pe),this._instantiationService=new gk,this.optionsService=this._register(new Ek(e)),this._instantiationService.setService(Ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(xf)),this._instantiationService.setService(wi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bf)),this._instantiationService.setService(Rb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Sf)),this._instantiationService.setService(Ss,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(wf)),this._instantiationService.setService(Db,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(_s)),this._instantiationService.setService(dw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Nk),this._instantiationService.setService(hw,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ef),this._instantiationService.setService(Nb,this._oscLinkService),this._inputHandler=this._register(new Fk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ui.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ui.forward(this._bufferService.onResize,this._onResize)),this._register(ui.forward(this.coreService.onData,this._onData)),this._register(ui.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 $k((t,n)=>this._inputHandler.parse(t,n))),this._register(ui.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new pe),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&&!ay&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ay=!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,cx),t=Math.max(t,ux),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(Qv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Qv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=gt(()=>{for(let t of e)t.dispose()})}}},Vk={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 Kk(e,t,n,s){var u;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=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.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=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=Vk[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)a.key=se.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(f);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),a.key=se.ESC+f,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=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var At=0,Gk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Oc,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Oc,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||(At=this._search(t),At===-1)||this._getKey(this._array[At])!==t)return!1;do if(this._array[At]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(At),!0;while(++Ata-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&&(At=this._search(e),!(At<0||At>=this._array.length)&&this._getKey(this._array[At])===e))do yield this._array[At];while(++At=this._array.length)&&this._getKey(this._array[At])===e))do t(this._array[At]);while(++At=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}},wd=0,oy=0,Xk=class extends Pe{constructor(){super(),this._decorations=new Gk(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new pe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new pe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(gt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Zk(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{wd=a.options.x??0,oy=wd+(a.options.width??1),e>=wd&&e=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)}},cy=20,zc=class extends Pe{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 Jk(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(Me(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(gt(()=>{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===cy+1&&(this._liveRegion.textContent+=$d.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),u=[],d=(o==null?void 0:o.translateToString(!0,void 0,void 0,u))||"",f=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,u)),h.setAttribute("aria-posinset",f),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 u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}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 d;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:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:f,offset:h})=>{let _=f instanceof Text?f.parentNode:f,g=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(_);if(!y)return console.warn("columns is null. Race condition?"),null;let b=h=this._terminal.cols&&(++g,b=0),{row:g,column:b}},o=a(t),u=a(n);if(!(!o||!u)){if(o.row>u.row||o.row===u.row&&o.column>=u.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(u.row-o.row)*this._terminal.cols-o.column+u.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;ys(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(Me(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Me(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Me(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Me(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(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,u]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):u.provideLinks(e.y,d=>{var h,_;if(this._isMouseOut)return;let f=d==null?void 0:d.map(g=>({link:g}));(h=this._activeProviderReplies)==null||h.set(o,f),n=this._checkLinkProviderResult(o,e,n),((_=this._activeProviderReplies)==null?void 0:_.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:u.link.range.end.x;for(let h=d;h<=f;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 u=0;uthis._linkAtPosition(d.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;uthis._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&e2(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,ys(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}}};Tf=Ct([ge(1,Uf),ge(2,lr),ge(3,wi),ge(4,Bb)],Tf);function e2(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 t2=class extends Yk{constructor(e={}){super(e),this._linkifier=this._register(new _l),this.browser=Qb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new _l),this._onCursorMove=this._register(new pe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new pe),this.onKey=this._onKey.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new pe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new pe),this.onBell=this._onBell.event,this._onFocus=this._register(new pe),this._onBlur=this._register(new pe),this._onA11yCharEmitter=this._register(new pe),this._onA11yTabEmitter=this._register(new pe),this._onWillOpen=this._register(new pe),this._setup(),this._decorationService=this._instantiationService.createInstance(Xk),this._instantiationService.setService(qa,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(WC),this._instantiationService.setService(Bb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Vd)),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(ui.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ui.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ui.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ui.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(gt(()=>{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=pt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${Ik(a)}${Xb.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=zt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(u=>u[o]=zt.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(zc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.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(se.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,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"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(Me(this.element,"copy",t=>{this.hasSelection()&&sw(t,this._selectionService)}));let e=t=>lw(t,this.textarea,this.coreService,this.optionsService);this._register(Me(this.textarea,"paste",e)),this._register(Me(this.element,"paste",e)),Jb?this._register(Me(this.element,"mousedown",t=>{t.button===2&&yv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Me(this.element,"contextmenu",t=>{yv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Gf&&this._register(Me(this.element,"auxclick",t=>{t.button===1&&Cb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Me(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Me(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Me(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Me(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Me(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Me(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Me(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(Me(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",Wd.get()),ix||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(FC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(sr,this._coreBrowserService),this._register(Me(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Me(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(mf,this._document,this._helperContainer),this._instantiationService.setService(qc,this._charSizeService),this._themeService=this._instantiationService.createInstance(yf),this._instantiationService.setService(yl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Bc),this._instantiationService.setService(Mb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(_f,this.rows,this.screenElement)),this._instantiationService.setService(lr,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(df,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(gf),this._instantiationService.setService(Uf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Tf,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(uf,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(vf,this.element,this.screenElement,s)),this._instantiationService.setService(pw,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(ui.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(hf,this.screenElement)),this._register(Me(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(zc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mc,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mc,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(pf,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,y,b;let u=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!u)return!1;let d,f;switch(o.overrideType||o.type){case"mousemove":f=32,o.buttons===void 0?(d=3,o.button!==void 0&&(d=o.button<3?o.button:3)):d=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":f=0,d=o.button<3?o.button:3;break;case"mousedown":f=1,d=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let S=o.deltaY;if(S===0||e.coreMouseService.consumeWheelEvent(o,(y=(g=(_=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:_.device)==null?void 0:g.cell)==null?void 0:y.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;f=S<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:f,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(Me(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(Me(t,"wheel",o=>{var u,d,f,h,_;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=(f=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:h.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(o,!0);let g=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var 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){wb(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=Kk(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===se.ETX||n.key===se.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)&&(i2(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 dn)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},uy=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 r2(t)}getNullCell(){return new dn}},s2=class extends Pe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new pe),this.onBufferChange=this._onBufferChange.event,this._normal=new uy(this._core.buffers.normal,"normal"),this._alternate=new uy(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)}},l2=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)}},a2=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}},o2=["cols","rows"],Tn=0,c2=class extends Pe{constructor(e){super(),this._core=this._register(new t2(e)),this._addonManager=this._register(new n2),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(o2.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 l2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new a2(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 s2(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 Wd.get()},set promptLabel(e){Wd.set(e)},get tooMuchOutput(){return $d.get()},set tooMuchOutput(e){$d.set(e)}}}_verifyIntegers(...e){for(Tn of e)if(Tn===1/0||isNaN(Tn)||Tn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Tn of e)if(Tn&&(Tn===1/0||isNaN(Tn)||Tn%1!==0||Tn<0))throw new Error("This API only accepts positive integers")}};/** +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Gf&&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=Iv(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=Kf(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,-_d),_d),t/=_d,t/Math.abs(t)+Math.round(t*(ck-1)))}shouldForceSelection(e){return Lc?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(),uk)}_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&&!(Lc&&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 u=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(o,e[0]),f=d,h=e[0]-d,_=0,g=0,y=0,b=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;f1&&(b+=X-1,f+=X-1);L>0&&d>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,L--):P>1&&(y+=P-1,d-=P-1),d--,L--}for(;D1&&(b+=P-1,f+=P-1),f++,D++}}f++;let S=d+h-_+y,T=Math.min(this._bufferService.cols,f-d+_+g-y-b);if(!(!t&&u.slice(d,f).trim()==="")){if(n&&S===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let X=this._bufferService.cols-D.start;S-=X,T+=X}}}if(s&&S+T===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(T+=D.length)}}return{start:S,length:T}}}_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=Iv(n,this._bufferService.cols)}};vf=At([ge(3,ki),ge(4,Ss),ge(5,Uf),ge(6,Ei),ge(7,lr),ge(8,sr)],vf);var Uv=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={}}},Fv=class{constructor(){this._color=new Uv,this._css=new Uv}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()}},$t=Object.freeze((()=>{let e=[xt.toColor("#2e3436"),xt.toColor("#cc0000"),xt.toColor("#4e9a06"),xt.toColor("#c4a000"),xt.toColor("#3465a4"),xt.toColor("#75507b"),xt.toColor("#06989a"),xt.toColor("#d3d7cf"),xt.toColor("#555753"),xt.toColor("#ef2929"),xt.toColor("#8ae234"),xt.toColor("#fce94f"),xt.toColor("#729fcf"),xt.toColor("#ad7fa8"),xt.toColor("#34e2e2"),xt.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:Pt.toCss(s,a,o),rgba:Pt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Pt.toCss(s,s,s),rgba:Pt.toRgba(s,s,s)})}return e})()),ps=xt.toColor("#ffffff"),Aa=xt.toColor("#000000"),qv=xt.toColor("#ffffff"),Wv=Aa,va={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},pk=ps,yf=class extends He{constructor(e){super(),this._optionsService=e,this._contrastCache=new Fv,this._halfContrastCache=new Fv,this._onChangeColors=this._register(new pe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ps,background:Aa,cursor:qv,cursorAccent:Wv,selectionForeground:void 0,selectionBackgroundTransparent:va,selectionBackgroundOpaque:gt.blend(Aa,va),selectionInactiveBackgroundTransparent:va,selectionInactiveBackgroundOpaque:gt.blend(Aa,va),scrollbarSliderBackground:gt.opacity(ps,.2),scrollbarSliderHoverBackground:gt.opacity(ps,.4),scrollbarSliderActiveBackground:gt.opacity(ps,.5),overviewRulerBorder:ps,ansi:$t.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=st(e.foreground,ps),t.background=st(e.background,Aa),t.cursor=gt.blend(t.background,st(e.cursor,qv)),t.cursorAccent=gt.blend(t.background,st(e.cursorAccent,Wv)),t.selectionBackgroundTransparent=st(e.selectionBackground,va),t.selectionBackgroundOpaque=gt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=gt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,jv):void 0,t.selectionForeground===jv&&(t.selectionForeground=void 0),gt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=gt.opacity(t.selectionBackgroundTransparent,.3)),gt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=gt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,gt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,gt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,gt.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,pk),t.ansi=$t.slice(),t.ansi[0]=st(e.black,$t[0]),t.ansi[1]=st(e.red,$t[1]),t.ansi[2]=st(e.green,$t[2]),t.ansi[3]=st(e.yellow,$t[3]),t.ansi[4]=st(e.blue,$t[4]),t.ansi[5]=st(e.magenta,$t[5]),t.ansi[6]=st(e.cyan,$t[6]),t.ansi[7]=st(e.white,$t[7]),t.ansi[8]=st(e.brightBlack,$t[8]),t.ansi[9]=st(e.brightRed,$t[9]),t.ansi[10]=st(e.brightGreen,$t[10]),t.ansi[11]=st(e.brightYellow,$t[11]),t.ansi[12]=st(e.brightBlue,$t[12]),t.ansi[13]=st(e.brightMagenta,$t[13]),t.ansi[14]=st(e.brightCyan,$t[14]),t.ansi[15]=st(e.brightWhite,$t[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-u.index),s=[];for(let o of n){let u=this._services.get(o.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(u)}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)}},_k={trace:0,debug:1,info:2,warn:3,error:4,off:5},vk="xterm.js: ",bf=class extends He{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=_k[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*je+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*je+0]=t|2097152|n[2]<<22):this._data[t*je+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*je+0]>>22}hasWidth(t){return this._data[t*je+0]&12582912}getFg(t){return this._data[t*je+1]}getBg(t){return this._data[t*je+2]}hasContent(t){return this._data[t*je+0]&4194303}getCodePoint(t){let n=this._data[t*je+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*je+0]&2097152}getString(t){let n=this._data[t*je+0];return n&2097152?this._combined[t]:n&2097151?Hr(n&2097151):""}isProtected(t){return this._data[t*je+2]&536870912}loadCell(t,n){return gc=t*je,n.content=this._data[gc+0],n.fg=this._data[gc+1],n.bg=this._data[gc+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*je+0]=n.content,this._data[t*je+1]=n.fg,this._data[t*je+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*je+0]=n|s<<22,this._data[t*je+1]=a.fg,this._data[t*je+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*je+0];a&2097152?this._combined[t]+=Hr(n):a&2097151?(this._combined[t]=Hr(a&2097151)+Hr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*je+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[d]}let o=Object.keys(this._extendedAttrs);for(let u=0;u=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*vd=0;--t)if(this._data[t*je+0]&4194303)return t+(this._data[t*je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*je+0]&4194303||this._data[t*je+2]&50331648)return t+(this._data[t*je+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let u=t._data;if(o)for(let f=a-1;f>=0;f--){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
Le?($e=be,be=null):$e=be.sibling;var Xe=K(H,be,W[Le],ne);if(Xe===null){be===null&&(be=$e);break}i&&be&&Xe.alternate===null&&r(H,be),O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe,be=$e}if(Le===W.length)return l(H,be),Ye&&Un(H,Le),Ce;if(be===null){for(;LeLe?($e=be,be=null):$e=be.sibling;var Br=K(H,be,Xe.value,ne);if(Br===null){be===null&&(be=$e);break}i&&be&&Br.alternate===null&&r(H,be),O=m(Br,O,Le),Ge===null?Ce=Br:Ge.sibling=Br,Ge=Br,be=$e}if(Xe.done)return l(H,be),Ye&&Un(H,Le),Ce;if(be===null){for(;!Xe.done;Le++,Xe=W.next())Xe=re(H,Xe.value,ne),Xe!==null&&(O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe);return Ye&&Un(H,Le),Ce}for(be=c(be);!Xe.done;Le++,Xe=W.next())Xe=Z(be,H,Le,Xe.value,ne),Xe!==null&&(i&&Xe.alternate!==null&&be.delete(Xe.key===null?Le:Xe.key),O=m(Xe,O,Le),Ge===null?Ce=Xe:Ge.sibling=Xe,Ge=Xe);return i&&be.forEach(function(L1){return r(H,L1)}),Ye&&Un(H,Le),Ce}function rt(H,O,W,ne){if(typeof W=="object"&&W!==null&&W.type===T&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case b:e:{for(var Ce=W.key;O!==null;){if(O.key===Ce){if(Ce=W.type,Ce===T){if(O.tag===7){l(H,O.sibling),ne=p(O,W.props.children),ne.return=H,H=ne;break e}}else if(O.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ue&&ns(Ce)===O.type){l(H,O.sibling),ne=p(O,W.props),Ul(ne,W),ne.return=H,H=ne;break e}l(H,O);break}else r(H,O);O=O.sibling}W.type===T?(ne=Qr(W.props.children,H.mode,ne,W.key),ne.return=H,H=ne):(ne=fo(W.type,W.key,W.props,null,H.mode,ne),Ul(ne,W),ne.return=H,H=ne)}return x(H);case S:e:{for(Ce=W.key;O!==null;){if(O.key===Ce)if(O.tag===4&&O.stateNode.containerInfo===W.containerInfo&&O.stateNode.implementation===W.implementation){l(H,O.sibling),ne=p(O,W.children||[]),ne.return=H,H=ne;break e}else{l(H,O);break}else r(H,O);O=O.sibling}ne=wu(W,H.mode,ne),ne.return=H,H=ne}return x(H);case ue:return W=ns(W),rt(H,O,W,ne)}if(A(W))return ve(H,O,W,ne);if(F(W)){if(Ce=F(W),typeof Ce!="function")throw Error(s(150));return W=Ce.call(W),Ee(H,O,W,ne)}if(typeof W.then=="function")return rt(H,O,bo(W),ne);if(W.$$typeof===P)return rt(H,O,go(H,W),ne);xo(H,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,O!==null&&O.tag===6?(l(H,O.sibling),ne=p(O,W),ne.return=H,H=ne):(l(H,O),ne=Su(W,H.mode,ne),ne.return=H,H=ne),x(H)):l(H,O)}return function(H,O,W,ne){try{Il=0;var Ce=rt(H,O,W,ne);return Ys=null,Ce}catch(be){if(be===$s||be===vo)throw be;var Ge=Fi(29,be,null,H.mode);return Ge.lanes=ne,Ge.return=H,Ge}finally{}}}var ss=bm(!0),xm=bm(!1),gr=!1;function Ou(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zu(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 _r(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function vr(i,r,l){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Qe&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=ho(i),rm(i,null,l),r}return uo(i,c,r,l),ho(i)}function Fl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}function ju(i,r){var l=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var p=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var x={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?p=m=x:m=m.next=x,l=l.next}while(l!==null);m===null?p=m=r:m=m.next=r}else p=m=r;l={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:m,shared:c.shared,callbacks:c.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var Hu=!1;function ql(){if(Hu){var i=Ws;if(i!==null)throw i}}function Wl(i,r,l,c){Hu=!1;var p=i.updateQueue;gr=!1;var m=p.firstBaseUpdate,x=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var N=C,$=N.next;N.next=null,x===null?m=$:x.next=$,x=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,C=ee.lastBaseUpdate,C!==x&&(C===null?ee.firstBaseUpdate=$:C.next=$,ee.lastBaseUpdate=N))}if(m!==null){var re=p.baseState;x=0,ee=$=N=null,C=m;do{var K=C.lane&-536870913,Z=K!==C.lane;if(Z?(We&K)===K:(c&K)===K){K!==0&&K===qs&&(Hu=!0),ee!==null&&(ee=ee.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var ve=i,Ee=C;K=r;var rt=l;switch(Ee.tag){case 1:if(ve=Ee.payload,typeof ve=="function"){re=ve.call(rt,re,K);break e}re=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ee.payload,K=typeof ve=="function"?ve.call(rt,re,K):ve,K==null)break e;re=g({},re,K);break e;case 2:gr=!0}}K=C.callback,K!==null&&(i.flags|=64,Z&&(i.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[K]:Z.push(K))}else Z={lane:K,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ee===null?($=ee=Z,N=re):ee=ee.next=Z,x|=K;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);ee===null&&(N=re),p.baseState=N,p.firstBaseUpdate=$,p.lastBaseUpdate=ee,m===null&&(p.shared.lanes=0),wr|=x,i.lanes=x,i.memoizedState=re}}function Sm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function wm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var x=k.T,C={};k.T=C,nh(i,!1,r,l);try{var N=p(),$=k.S;if($!==null&&$(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=w0(N,c);Vl(i,r,ee,Vi(i))}else Vl(i,r,c,Vi(i))}catch(re){Vl(i,r,{then:function(){},status:"rejected",reason:re},Vi())}finally{j.p=m,x!==null&&C.types!==null&&(x.types=C.types),k.T=x}}function D0(){}function th(i,r,l,c){if(i.tag!==5)throw Error(s(476));var p=tg(i).queue;eg(i,p,r,U,l===null?D0:function(){return ig(i),l(c)})}function tg(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:U},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$n,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function ig(i){var r=tg(i);r.next===null&&(r=i.alternate.memoizedState),Vl(i,r.next.queue,{},Vi())}function ih(){return ci(ua)}function ng(){return Nt().memoizedState}function rg(){return Nt().memoizedState}function R0(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Vi();i=_r(l);var c=vr(r,i,l);c!==null&&(Oi(c,r,l),Fl(c,r,l)),r={cache:Nu()},i.payload=r;return}r=r.return}}function N0(i,r,l){var c=Vi();l={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},No(i)?lg(r,l):(l=bu(i,r,l,c),l!==null&&(Oi(l,i,c),ag(l,r,c)))}function sg(i,r,l){var c=Vi();Vl(i,r,l,c)}function Vl(i,r,l,c){var p={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(No(i))lg(r,p);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var x=r.lastRenderedState,C=m(x,l);if(p.hasEagerState=!0,p.eagerState=C,Ui(C,x))return uo(i,r,p,0),at===null&&co(),!1}catch{}finally{}if(l=bu(i,r,p,c),l!==null)return Oi(l,i,c),ag(l,r,c),!0}return!1}function nh(i,r,l,c){if(c={lane:2,revertLane:Oh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},No(i)){if(r)throw Error(s(479))}else r=bu(i,l,c,2),r!==null&&Oi(r,i,2)}function No(i){var r=i.alternate;return i===Be||r!==null&&r===Be}function lg(i,r){Ks=Co=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function ag(i,r,l){if((l&4194048)!==0){var c=r.lanes;c&=i.pendingLanes,l|=c,r.lanes=l,Es(i,l)}}var Kl={readContext:ci,use:To,useCallback:Ct,useContext:Ct,useEffect:Ct,useImperativeHandle:Ct,useLayoutEffect:Ct,useInsertionEffect:Ct,useMemo:Ct,useReducer:Ct,useRef:Ct,useState:Ct,useDebugValue:Ct,useDeferredValue:Ct,useTransition:Ct,useSyncExternalStore:Ct,useId:Ct,useHostTransitionStatus:Ct,useFormState:Ct,useActionState:Ct,useOptimistic:Ct,useMemoCache:Ct,useCacheRefresh:Ct};Kl.useEffectEvent=Ct;var og={readContext:ci,use:To,useCallback:function(i,r){return xi().memoizedState=[i,r===void 0?null:r],i},useContext:ci,useEffect:$m,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,Do(4194308,4,Gm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return Do(4194308,4,i,r)},useInsertionEffect:function(i,r){Do(4,2,i,r)},useMemo:function(i,r){var l=xi();r=r===void 0?null:r;var c=i();if(ls){mi(!0);try{i()}finally{mi(!1)}}return l.memoizedState=[c,r],c},useReducer:function(i,r,l){var c=xi();if(l!==void 0){var p=l(r);if(ls){mi(!0);try{l(r)}finally{mi(!1)}}}else p=r;return c.memoizedState=c.baseState=p,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:p},c.queue=i,i=i.dispatch=N0.bind(null,Be,i),[c.memoizedState,i]},useRef:function(i){var r=xi();return i={current:i},r.memoizedState=i},useState:function(i){i=Xu(i);var r=i.queue,l=sg.bind(null,Be,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Ju,useDeferredValue:function(i,r){var l=xi();return eh(l,i,r)},useTransition:function(){var i=Xu(!1);return i=eg.bind(null,Be,i.queue,!0,!1),xi().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var c=Be,p=xi();if(Ye){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),at===null)throw Error(s(349));(We&127)!==0||Dm(c,r,l)}p.memoizedState=l;var m={value:l,getSnapshot:r};return p.queue=m,$m(Nm.bind(null,c,m,i),[i]),c.flags|=2048,Xs(9,{destroy:void 0},Rm.bind(null,c,m,l,r),null),l},useId:function(){var i=xi(),r=at.identifierPrefix;if(Ye){var l=kn,c=Cn;l=(c&~(1<<32-Je(c)-1)).toString(32)+l,r="_"+r+"R_"+l,l=ko++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof c.is=="string"?x.createElement("select",{is:c.is}):x.createElement("select"),c.multiple?m.multiple=!0:c.size&&(m.size=c.size);break;default:m=typeof c.is=="string"?x.createElement(p,{is:c.is}):x.createElement(p)}}m[Ut]=r,m[Ft]=c;e:for(x=r.child;x!==null;){if(x.tag===5||x.tag===6)m.appendChild(x.stateNode);else if(x.tag!==4&&x.tag!==27&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===r)break e;for(;x.sibling===null;){if(x.return===null||x.return===r)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}r.stateNode=m;e:switch(hi(m,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Vn(r)}}return mt(r),_h(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==c&&Vn(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(i=ae.current,Us(r)){if(i=r.stateNode,l=r.memoizedProps,c=null,p=oi,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}i[Ut]=r,i=!!(i.nodeValue===l||c!==null&&c.suppressHydrationWarning===!0||T_(i.nodeValue,l)),i||pr(r,!0)}else i=Zo(i).createTextNode(c),i[Ut]=r,r.stateNode=i}return mt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(c=Us(r),l!==null){if(i===null){if(!c)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Ut]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mt(r),i=!1}else l=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Wi(r),r):(Wi(r),null);if((r.flags&128)!==0)throw Error(s(558))}return mt(r),null;case 13:if(c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(p=Us(r),c!==null&&c.dehydrated!==null){if(i===null){if(!p)throw Error(s(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(s(317));p[Ut]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mt(r),p=!1}else p=Tu(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Wi(r),r):(Wi(r),null)}return Wi(r),(r.flags&128)!==0?(r.lanes=l,r):(l=c!==null,i=i!==null&&i.memoizedState!==null,l&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),m=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),m!==p&&(c.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),zo(r,r.updateQueue),mt(r),null);case 4:return xe(),i===null&&Ph(r.stateNode.containerInfo),mt(r),null;case 10:return qn(r.type),mt(r),null;case 19:if(Y(Rt),c=r.memoizedState,c===null)return mt(r),null;if(p=(r.flags&128)!==0,m=c.rendering,m===null)if(p)Xl(c,!1);else{if(kt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=wo(i),m!==null){for(r.flags|=128,Xl(c,!1),i=m.updateQueue,r.updateQueue=i,zo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)sm(l,i),l=l.sibling;return w(Rt,Rt.current&1|2),Ye&&Un(r,c.treeForkCount),r.child}i=i.sibling}c.tail!==null&&Ze()>Uo&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304)}else{if(!p)if(i=wo(m),i!==null){if(r.flags|=128,p=!0,i=i.updateQueue,r.updateQueue=i,zo(r,i),Xl(c,!0),c.tail===null&&c.tailMode==="hidden"&&!m.alternate&&!Ye)return mt(r),null}else 2*Ze()-c.renderingStartTime>Uo&&l!==536870912&&(r.flags|=128,p=!0,Xl(c,!1),r.lanes=4194304);c.isBackwards?(m.sibling=r.child,r.child=m):(i=c.last,i!==null?i.sibling=m:r.child=m,c.last=m)}return c.tail!==null?(i=c.tail,c.rendering=i,c.tail=i.sibling,c.renderingStartTime=Ze(),i.sibling=null,l=Rt.current,w(Rt,p?l&1|2:l&1),Ye&&Un(r,c.treeForkCount),i):(mt(r),null);case 22:case 23:return Wi(r),Iu(),c=r.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(l&536870912)!==0&&(r.flags&128)===0&&(mt(r),r.subtreeFlags&6&&(r.flags|=8192)):mt(r),l=r.updateQueue,l!==null&&zo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==l&&(r.flags|=2048),i!==null&&Y(is),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),qn(Bt),mt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function z0(i,r){switch(ku(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return qn(Bt),xe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return ct(r),null;case 31:if(r.memoizedState!==null){if(Wi(r),r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Wi(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Jr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return Y(Rt),null;case 4:return xe(),null;case 10:return qn(r.type),null;case 22:case 23:return Wi(r),Iu(),i!==null&&Y(is),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return qn(Bt),null;case 25:return null;default:return null}}function Mg(i,r){switch(ku(r),r.tag){case 3:qn(Bt),xe();break;case 26:case 27:case 5:ct(r);break;case 4:xe();break;case 31:r.memoizedState!==null&&Wi(r);break;case 13:Wi(r);break;case 19:Y(Rt);break;case 10:qn(r.type);break;case 22:case 23:Wi(r),Iu(),i!==null&&Y(is);break;case 24:qn(Bt)}}function Zl(i,r){try{var l=r.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var p=c.next;l=p;do{if((l.tag&i)===i){c=void 0;var m=l.create,x=l.inst;c=m(),x.destroy=c}l=l.next}while(l!==p)}}catch(C){tt(r,r.return,C)}}function xr(i,r,l){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var m=p.next;c=m;do{if((c.tag&i)===i){var x=c.inst,C=x.destroy;if(C!==void 0){x.destroy=void 0,p=r;var N=l,$=C;try{$()}catch(ee){tt(p,N,ee)}}}c=c.next}while(c!==m)}}catch(ee){tt(r,r.return,ee)}}function Bg(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{wm(r,l)}catch(c){tt(i,i.return,c)}}}function Lg(i,r,l){l.props=as(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(c){tt(i,r,c)}}function Ql(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var c=i.stateNode;break;case 30:c=i.stateNode;break;default:c=i.stateNode}typeof l=="function"?i.refCleanup=l(c):l.current=c}}catch(p){tt(i,r,p)}}function En(i,r){var l=i.ref,c=i.refCleanup;if(l!==null)if(typeof c=="function")try{c()}catch(p){tt(i,r,p)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){tt(i,r,p)}else l.current=null}function Og(i){var r=i.type,l=i.memoizedProps,c=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&c.focus();break e;case"img":l.src?c.src=l.src:l.srcSet&&(c.srcset=l.srcSet)}}catch(p){tt(i,i.return,p)}}function vh(i,r,l){try{var c=i.stateNode;r1(c,i.type,l,r),c[Ft]=r}catch(p){tt(i,i.return,p)}}function zg(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ar(i.type)||i.tag===4}function yh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||zg(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&&Ar(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 bh(i,r,l){var c=i.tag;if(c===5||c===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=Hn));else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(bh(i,r,l),i=i.sibling;i!==null;)bh(i,r,l),i=i.sibling}function jo(i,r,l){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(c!==4&&(c===27&&Ar(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(jo(i,r,l),i=i.sibling;i!==null;)jo(i,r,l),i=i.sibling}function jg(i){var r=i.stateNode,l=i.memoizedProps;try{for(var c=i.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);hi(r,c,l),r[Ut]=i,r[Ft]=l}catch(m){tt(i,i.return,m)}}var Kn=!1,zt=!1,xh=!1,Hg=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function j0(i,r){if(i=i.containerInfo,Fh=rc,i=Xp(i),pu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var p=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var x=0,C=-1,N=-1,$=0,ee=0,re=i,K=null;t:for(;;){for(var Z;re!==l||p!==0&&re.nodeType!==3||(C=x+p),re!==m||c!==0&&re.nodeType!==3||(N=x+c),re.nodeType===3&&(x+=re.nodeValue.length),(Z=re.firstChild)!==null;)K=re,re=Z;for(;;){if(re===i)break t;if(K===l&&++$===p&&(C=x),K===m&&++ee===c&&(N=x),(Z=re.nextSibling)!==null)break;re=K,K=re.parentNode}re=Z}l=C===-1||N===-1?null:{start:C,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(qh={focusedElem:i,selectionRange:l},rc=!1,Qt=r;Qt!==null;)if(r=Qt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Qt=i;else for(;Qt!==null;){switch(r=Qt,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"))),hi(m,c,l),m[Ut]=i,Zt(m),c=m;break e;case"link":var x=W_("link","href",p).get(c+(l.href||""));if(x){for(var C=0;Crt&&(x=rt,rt=Ee,Ee=x);var H=Kp(C,Ee),O=Kp(C,rt);if(H&&O&&(Z.rangeCount!==1||Z.anchorNode!==H.node||Z.anchorOffset!==H.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var W=re.createRange();W.setStart(H.node,H.offset),Z.removeAllRanges(),Ee>rt?(Z.addRange(W),Z.extend(O.node,O.offset)):(W.setEnd(O.node,O.offset),Z.addRange(W))}}}}for(re=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&re.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cl?32:l,k.T=null,l=Ah,Ah=null;var m=kr,x=Jn;if(Wt=0,tl=kr=null,Jn=0,(Qe&6)!==0)throw Error(s(331));var C=Qe;if(Qe|=4,Gg(m.current),Yg(m,m.current,x,l),Qe=C,ra(0,!1),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(Xt,m)}catch{}return!0}finally{j.p=p,k.T=c,f_(i,r)}}function m_(i,r,l){r=nn(l,r),r=ah(i.stateNode,r,2),i=vr(i,r,2),i!==null&&(or(i,2),Tn(i))}function tt(i,r,l){if(i.tag===3)m_(i,i,l);else for(;r!==null;){if(r.tag===3){m_(r,i,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Cr===null||!Cr.has(c))){i=nn(l,i),l=gg(2),c=vr(r,l,2),c!==null&&(_g(l,c,r,i),or(c,2),Tn(c));break}}r=r.return}}function Mh(i,r,l){var c=i.pingCache;if(c===null){c=i.pingCache=new I0;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(l)||(Ch=!0,p.add(l),i=$0.bind(null,i,r,l),r.then(i,i))}function $0(i,r,l){var c=i.pingCache;c!==null&&c.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,at===i&&(We&l)===l&&(kt===4||kt===3&&(We&62914560)===We&&300>Ze()-Io?(Qe&2)===0&&il(i,0):kh|=l,el===We&&(el=0)),Tn(i)}function g_(i,r){r===0&&(r=Xa()),i=Zr(i,r),i!==null&&(or(i,r),Tn(i))}function Y0(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),g_(i,l)}function V0(i,r){var l=0;switch(i.tag){case 31:case 13:var c=i.stateNode,p=i.memoizedState;p!==null&&(l=p.retryLane);break;case 19:c=i.stateNode;break;case 22:c=i.stateNode._retryCache;break;default:throw Error(s(314))}c!==null&&c.delete(r),g_(i,l)}function K0(i,r){return Dt(i,r)}var Vo=null,rl=null,Bh=!1,Ko=!1,Lh=!1,Tr=0;function Tn(i){i!==rl&&i.next===null&&(rl===null?Vo=rl=i:rl=rl.next=i),Ko=!0,Bh||(Bh=!0,X0())}function ra(i,r){if(!Lh&&Ko){Lh=!0;do for(var l=!1,c=Vo;c!==null;){if(i!==0){var p=c.pendingLanes;if(p===0)var m=0;else{var x=c.suspendedLanes,C=c.pingedLanes;m=(1<<31-Je(42|i)+1)-1,m&=p&~(x&~C),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,b_(c,m))}else m=We,m=ks(c,c===at?m:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(m&3)===0||Yr(c,m)||(l=!0,b_(c,m));c=c.next}while(l);Lh=!1}}function G0(){__()}function __(){Ko=Bh=!1;var i=0;Tr!==0&&l1()&&(i=Tr);for(var r=Ze(),l=null,c=Vo;c!==null;){var p=c.next,m=v_(c,r);m===0?(c.next=null,l===null?Vo=p:l.next=p,p===null&&(rl=l)):(l=c,(i!==0||(m&3)!==0)&&(Ko=!0)),c=p}Wt!==0&&Wt!==5||ra(i),Tr!==0&&(Tr=0)}function v_(i,r){for(var l=i.suspendedLanes,c=i.pingedLanes,p=i.expirationTimes,m=i.pendingLanes&-62914561;0C)break;var ee=N.transferSize,re=N.initiatorType;ee&&A_(re)&&(N=N.responseEnd,x+=ee*(N"u"?null:document;function I_(i,r,l){var c=sl;if(c&&typeof r=="string"&&r){var p=en(r);p='link[rel="'+i+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),P_.has(p)||(P_.add(p),i={rel:i,crossOrigin:l,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),hi(r,"link",i),Zt(r),c.head.appendChild(r)))}}function m1(i){er.D(i),I_("dns-prefetch",i,null)}function g1(i,r){er.C(i,r),I_("preconnect",i,r)}function _1(i,r,l){er.L(i,r,l);var c=sl;if(c&&i&&r){var p='link[rel="preload"][as="'+en(r)+'"]';r==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+en(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+en(l.imageSizes)+'"]')):p+='[href="'+en(i)+'"]';var m=p;switch(r){case"style":m=ll(i);break;case"script":m=al(i)}cn.has(m)||(i=g({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),cn.set(m,i),c.querySelector(p)!==null||r==="style"&&c.querySelector(oa(m))||r==="script"&&c.querySelector(ca(m))||(r=c.createElement("link"),hi(r,"link",i),Zt(r),c.head.appendChild(r)))}}function v1(i,r){er.m(i,r);var l=sl;if(l&&i){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+en(c)+'"][href="'+en(i)+'"]',m=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=al(i)}if(!cn.has(m)&&(i=g({rel:"modulepreload",href:i},r),cn.set(m,i),l.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ca(m)))return}c=l.createElement("link"),hi(c,"link",i),Zt(c),l.head.appendChild(c)}}}function y1(i,r,l){er.S(i,r,l);var c=sl;if(c&&i){var p=As(c).hoistableStyles,m=ll(i);r=r||"default";var x=p.get(m);if(!x){var C={loading:0,preload:null};if(x=c.querySelector(oa(m)))C.loading=5;else{i=g({rel:"stylesheet",href:i,"data-precedence":r},l),(l=cn.get(m))&&Xh(i,l);var N=x=c.createElement("link");Zt(N),hi(N,"link",i),N._p=new Promise(function($,ee){N.onload=$,N.onerror=ee}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Jo(x,r,c)}x={type:"stylesheet",instance:x,count:1,state:C},p.set(m,x)}}}function b1(i,r){er.X(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0},r),(r=cn.get(p))&&Zh(i,r),m=l.createElement("script"),Zt(m),hi(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function x1(i,r){er.M(i,r);var l=sl;if(l&&i){var c=As(l).hoistableScripts,p=al(i),m=c.get(p);m||(m=l.querySelector(ca(p)),m||(i=g({src:i,async:!0,type:"module"},r),(r=cn.get(p))&&Zh(i,r),m=l.createElement("script"),Zt(m),hi(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(p,m))}}function U_(i,r,l,c){var p=(p=ae.current)?Qo(p):null;if(!p)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=ll(l.href),l=As(p).hoistableStyles,c=l.get(r),c||(c={type:"style",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=ll(l.href);var m=As(p).hoistableStyles,x=m.get(i);if(x||(p=p.ownerDocument||p,x={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,x),(m=p.querySelector(oa(i)))&&!m._p&&(x.instance=m,x.state.loading=5),cn.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},cn.set(i,l),m||S1(p,i,l,x.state))),r&&c===null)throw Error(s(528,""));return x}if(r&&c!==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=al(l),l=As(p).hoistableScripts,c=l.get(r),c||(c={type:"script",instance:null,count:0,state:null},l.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function ll(i){return'href="'+en(i)+'"'}function oa(i){return'link[rel="stylesheet"]['+i+"]"}function F_(i){return g({},i,{"data-precedence":i.precedence,precedence:null})}function S1(i,r,l,c){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=i.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),hi(r,"link",l),Zt(r),i.head.appendChild(r))}function al(i){return'[src="'+en(i)+'"]'}function ca(i){return"script[async]"+i}function q_(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var c=i.querySelector('style[data-href~="'+en(l.href)+'"]');if(c)return r.instance=c,Zt(c),c;var p=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),Zt(c),hi(c,"style",p),Jo(c,l.precedence,i),r.instance=c;case"stylesheet":p=ll(l.href);var m=i.querySelector(oa(p));if(m)return r.state.loading|=4,r.instance=m,Zt(m),m;c=F_(l),(p=cn.get(p))&&Xh(c,p),m=(i.ownerDocument||i).createElement("link"),Zt(m);var x=m;return x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),hi(m,"link",c),r.state.loading|=4,Jo(m,l.precedence,i),r.instance=m;case"script":return m=al(l.src),(p=i.querySelector(ca(m)))?(r.instance=p,Zt(p),p):(c=l,(p=cn.get(m))&&(c=g({},l),Zh(c,p)),i=i.ownerDocument||i,p=i.createElement("script"),Zt(p),hi(p,"link",c),i.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Jo(c,l.precedence,i));return r.instance}function Jo(i,r,l){for(var c=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,m=p,x=0;x title"):null)}function w1(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 Y_(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function C1(i,r,l,c){if(l.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=ll(c.href),m=r.querySelector(oa(p));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=tc.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Zt(m);return}m=r.ownerDocument||r,c=F_(c),(p=cn.get(p))&&Xh(c,p),m=m.createElement("link"),Zt(m);var x=m;x._p=new Promise(function(C,N){x.onload=C,x.onerror=N}),hi(m,"link",c),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=tc.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var Qh=0;function k1(i,r){return i.stylesheets&&i.count===0&&nc(i,i.stylesheets),0Qh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function tc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nc(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ic=null;function nc(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ic=new Map,r.forEach(E1,i),ic=null,tc.call(i))}function E1(i,r){if(!(r.state.loading&4)){var l=ic.get(i);if(l)var c=l.get(null);else{l=new Map,ic.set(i,l);for(var p=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(),ad.exports=q1(),ad.exports}var $1=W1();const Y1=Uc($1);function V1({onLogin:e}){const[t,n]=B.useState(""),[s,a]=B.useState(null),[o,u]=B.useState(!1),d=async f=>{if(f.preventDefault(),!t.trim())return;u(!0),a(null);const h=await e(t);h&&a(h),u(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsxs("div",{className:"w-full max-w-sm",children:[v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),v.jsxs("form",{onSubmit:d,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:f=>n(f.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&&v.jsx("p",{className:"text-error text-xs",children:s}),v.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"})]})]}),v.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function K1({onSetup:e}){const[t,n]=B.useState(""),[s,a]=B.useState(""),[o,u]=B.useState(null),[d,f]=B.useState(!1),h=async _=>{if(_.preventDefault(),!t.trim()||t.length<4){u("Passphrase must be at least 4 characters");return}if(t!==s){u("Passphrases do not match");return}f(!0),u(null);const g=await e(t);g&&u(g),f(!1)};return v.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:v.jsx("div",{className:"w-full max-w-sm",children:v.jsxs("div",{className:"border-border rounded border p-6",children:[v.jsxs("div",{className:"mb-6 text-center",children:[v.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),v.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),v.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."}),v.jsxs("form",{onSubmit:h,className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),v.jsx("input",{type:"password",value:t,onChange:_=>n(_.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),v.jsx("input",{type:"password",value:s,onChange:_=>a(_.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&v.jsx("p",{className:"text-error text-xs",children:o}),v.jsx("button",{type:"submit",disabled:d||!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:d?"setting up...":"create passphrase"})]})]})})})}const gv="http://localhost:7777";function xb({token:e}){const[t,n]=B.useState(null),[s,a]=B.useState(!1),[o,u]=B.useState(!1),[d,f]=B.useState(null),h=(S,T)=>fetch(S,{...T,headers:{...T==null?void 0:T.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),_=()=>{h(`${gv}/api/wallet`).then(S=>S.json()).then(S=>n(S)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};B.useEffect(()=>{_()},[]);const g=async()=>{a(!0),f(null);try{const S=await h(`${gv}/api/wallet/create`,{method:"POST"}),T=await S.json();if(!S.ok)throw new Error(T.error||"Creation failed");_()}catch(S){f(S instanceof Error?S.message:"Failed to create wallet")}a(!1)},y=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),u(!0),setTimeout(()=>u(!1),2e3))},b=S=>`${S.slice(0,6)}...${S.slice(-4)}`;return v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&v.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),d&&v.jsx("p",{className:"text-error text-xs",children:d}),v.jsx("button",{onClick:g,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&&v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),v.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"})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:b(t.address)}),v.jsx("button",{onClick:y,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),v.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC"}),v.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"PLOT"}),v.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Network"}),v.jsx("span",{className:"text-foreground",children:"Base"})]})]}),v.jsxs("div",{className:"border-border border-t pt-3",children:[v.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),v.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),v.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 G1({token:e,onLogout:t}){const[n,s]=B.useState(""),[a,o]=B.useState(""),[u,d]=B.useState(null),[f,h]=B.useState(!1),[_,g]=B.useState(!1),[y,b]=B.useState(null),[S,T]=B.useState("AI Writer"),[L,D]=B.useState(""),[X,P]=B.useState(""),[J,I]=B.useState(!1),[M,Q]=B.useState(null),[ue,me]=B.useState(""),[z,te]=B.useState(null),[F,q]=B.useState(!1),[G,A]=B.useState(null),[k,j]=B.useState(null),U=B.useCallback((w,V)=>fetch(w,{...V,headers:{...V==null?void 0:V.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);B.useEffect(()=>{U("/api/settings/link-status").then(w=>w.json()).then(w=>b(w)).catch(()=>b({linked:!1}))},[]);const le=async()=>{if(!S.trim()){Q("Agent name is required");return}if(!L.trim()){Q("Description is required");return}I(!0),Q(null);try{const w=await U("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:S,description:L,...X.trim()&&{genre:X}})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Registration failed");b({linked:!0,agentId:V.agentId,owsWallet:V.owsWallet,txHash:V.txHash})}catch(w){Q(w instanceof Error?w.message:"Registration failed")}I(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){A("Enter a valid wallet address (0x...)");return}q(!0),A(null),te(null);try{const w=await U("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),V=await w.json();if(!w.ok)throw new Error(V.error||"Failed to generate binding code");te(V)}catch(w){A(w instanceof Error?w.message:"Failed to generate binding code")}q(!1)},R=async(w,V)=>{await navigator.clipboard.writeText(w),j(V),setTimeout(()=>j(null),2e3)},Y=async()=>{if(d(null),h(!1),!n||n.length<4){d("Passphrase must be at least 4 characters");return}if(n!==a){d("Passphrases do not match");return}g(!0);try{const w=await U("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!w.ok){const V=await w.json();throw new Error(V.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(w){d(w instanceof Error?w.message:"Reset failed")}g(!1)};return v.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),y!=null&&y.linked?v.jsxs("div",{className:"space-y-2",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),v.jsxs("span",{className:"text-muted text-xs",children:["Agent #",y.agentId]})]}),y.owsWallet&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",y.owsWallet.slice(0,6),"...",y.owsWallet.slice(-4)]}),y.owner&&v.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",y.owner.slice(0,6),"...",y.owner.slice(-4)]}),y.txHash&&v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),v.jsx("p",{className:"text-muted text-xs",children:v.jsx("a",{href:`https://plotlink.xyz/profile/${y.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),v.jsx("input",{value:S,onChange:w=>T(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),v.jsx("input",{value:L,onChange:w=>D(w.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"})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),v.jsx("input",{value:X,onChange:w=>P(w.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),M&&v.jsx("p",{className:"text-error text-xs",children:M}),v.jsx("button",{onClick:le,disabled:J||!S.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:J?"Registering...":"Register Agent Identity"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),y!=null&&y.owner?v.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",v.jsxs("span",{className:"font-mono",children:[y.owner.slice(0,6),"...",y.owner.slice(-4)]})]}):v.jsxs("div",{className:"space-y-3",children:[v.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."}),v.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[v.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),v.jsx("p",{children:'2. Click "Generate Binding Code"'}),v.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),v.jsx("input",{value:ue,onChange:w=>me(w.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"}),G&&v.jsx("p",{className:"text-error text-xs",children:G}),v.jsx("button",{onClick:E,disabled:F||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:F?"Generating...":"Generate Binding Code"}),z&&v.jsxs("div",{className:"space-y-3 mt-3",children:[v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.signature}),v.jsx("button",{onClick:()=>R(z.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:k==="signature"?"Copied!":"Copy"})]})]}),v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.owsWallet}),v.jsx("button",{onClick:()=>R(z.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:k==="wallet"?"Copied!":"Copy"})]})]}),z.agentId&&v.jsxs("div",{children:[v.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),v.jsxs("div",{className:"relative",children:[v.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:z.agentId}),v.jsx("button",{onClick:()=>R(String(z.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:k==="agentId"?"Copied!":"Copy"})]})]}),v.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),v.jsx(xb,{token:e}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("input",{type:"password",value:n,onChange:w=>s(w.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"}),v.jsx("input",{type:"password",value:a,onChange:w=>o(w.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"}),u&&v.jsx("p",{className:"text-error text-xs",children:u}),f&&v.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),v.jsx("button",{onClick:Y,disabled:_||!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:_?"updating...":"update passphrase"})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),v.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 X1="http://localhost:7777";function Z1({token:e}){const[t,n]=B.useState(null),s=(d,f)=>fetch(d,{...f,headers:{...f==null?void 0:f.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${X1}/api/dashboard`).then(d=>d.json()).then(n)};B.useEffect(()=>{a()},[]);const o=d=>`${d.slice(0,6)}...${d.slice(-4)}`,u=d=>{if(!d)return"Unknown date";const f=new Date(d);return isNaN(f.getTime())?"Unknown date":f.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?v.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[v.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),v.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),v.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[v.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),v.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Address"}),v.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"ETH Balance"}),v.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"USDC Balance"}),v.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),v.jsxs("div",{className:"space-y-1.5",children:[v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),v.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Royalties earned"}),v.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),v.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),v.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[v.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),v.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),v.jsxs("div",{className:"flex justify-between text-xs",children:[v.jsx("span",{className:"text-muted",children:"Stories published"}),v.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),v.jsxs("div",{className:"border-border rounded border p-4",children:[v.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?v.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):v.jsx("div",{className:"space-y-3",children:t.stories.published.map(d=>v.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[v.jsxs("div",{className:"flex items-start justify-between",children:[v.jsxs("div",{children:[d.genre&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:d.genre}),v.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:d.title}),v.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:d.storyName})]}),v.jsxs("div",{className:"flex items-center gap-2",children:[d.hasNotIndexed&&v.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),v.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[d.publishedFiles," published"]})]})]}),v.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.plotCount}),v.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:d.storylineId?`#${d.storylineId}`:"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),v.jsxs("div",{className:"rounded bg-background p-1.5",children:[v.jsx("div",{className:"text-foreground text-sm font-medium",children:d.totalGasCostEth??"—"}),v.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),v.jsx("div",{className:"mt-2 space-y-1",children:d.files.map(f=>v.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[v.jsxs("div",{className:"flex items-center gap-1.5",children:[v.jsx("span",{className:f.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:f.status==="published-not-indexed"?"⚠":"✓"}),v.jsx("span",{className:"text-muted font-mono",children:f.file})]}),f.txHash&&v.jsxs("a",{href:`https://basescan.org/tx/${f.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",f.txHash.slice(0,8),"..."]})]},f.file))}),v.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[v.jsx("span",{className:"text-muted",children:u(d.latestPublishedAt)}),d.storylineId&&v.jsx("a",{href:`https://plotlink.xyz/story/${d.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},d.id))})]}),t.stories.pendingFiles>0&&v.jsx("div",{className:"border-border rounded border p-4",children:v.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):v.jsx("div",{className:"flex h-full items-center justify-center",children:v.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Q1={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},J1={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function ew({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[u,d]=B.useState([]),[f,h]=B.useState([]),[_,g]=B.useState(new Set),[y,b]=B.useState(!1),S=B.useCallback(async()=>{try{const I=await e("/api/stories");if(I.ok){const M=await I.json();d(M.stories)}}catch{}},[e]),T=B.useCallback(async()=>{try{const I=await e("/api/stories/archived");if(I.ok){const M=await I.json();h(M.stories)}}catch{}},[e]),L=B.useCallback(async I=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I})})).ok&&(T(),S())}catch{}},[e,T,S]);B.useEffect(()=>{S();const I=setInterval(S,5e3);return()=>clearInterval(I)},[S]),B.useEffect(()=>{y&&T()},[y,T]),B.useEffect(()=>{t&&g(I=>new Set(I).add(t))},[t]);const D=I=>{var Q;const M=I.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return M.length>0?M[0].file:I.some(ue=>ue.file==="genesis.md")?"genesis.md":I.some(ue=>ue.file==="structure.md")?"structure.md":((Q=I[0])==null?void 0:Q.file)??null},X=I=>{g(M=>{const Q=new Set(M);return Q.has(I)?Q.delete(I):Q.add(I),Q})},P=I=>{if(X(I.name),!_.has(I.name)){const M=D(I.files);M&&s(I.name,M)}},J=I=>{const M=Q=>{if(Q==="structure.md")return 0;if(Q==="genesis.md")return 1;const ue=Q.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...I].sort((Q,ue)=>M(Q.file)-M(ue.file))};return y?v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),v.jsx("span",{className:"text-xs text-muted",children:f.length})]}),v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.jsxs("button",{onClick:()=>b(!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:[v.jsx("span",{children:"←"}),v.jsx("span",{children:"Back"})]})}),v.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?v.jsx("div",{className:"p-3 text-sm text-muted",children:v.jsx("p",{children:"No archived stories."})}):f.map(I=>v.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[v.jsx("span",{className:"text-sm font-medium truncate",title:I.name,children:I.title||I.name}),v.jsx("button",{onClick:()=>L(I.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},I.name))})]}):v.jsxs("div",{className:"h-full flex flex-col",children:[v.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),v.jsx("span",{className:"text-xs text-muted",children:u.length})]}),a&&v.jsx("div",{className:"px-3 py-2 border-b border-border",children:v.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:[v.jsx("span",{children:"+"}),v.jsx("span",{children:"New Story"})]})}),v.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(I=>v.jsx("div",{children:v.jsxs("button",{onClick:()=>s(I,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===I?"bg-surface":""}`,children:[v.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),v.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},I)),u.length===0&&o.length===0?v.jsxs("div",{className:"p-3 text-sm text-muted",children:[v.jsx("p",{children:"No stories yet."}),v.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):u.filter(I=>I.name!=="_example").map(I=>v.jsxs("div",{children:[v.jsxs("button",{onClick:()=>P(I),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[v.jsx("span",{className:"text-xs text-muted",children:_.has(I.name)?"▼":"▶"}),v.jsx("span",{className:"font-medium truncate",title:I.name,children:I.title||I.name}),I.contentType==="cartoon"&&v.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),v.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[I.publishedCount,"/",I.files.length]})]}),_.has(I.name)&&v.jsx("div",{className:"pl-4",children:J(I.files).map(M=>{const Q=t===I.name&&n===M.file;return v.jsxs("button",{onClick:()=>s(I.name,M.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${Q?"bg-surface font-medium":""}`,children:[v.jsx("span",{className:J1[M.status],children:Q1[M.status]}),v.jsx("span",{className:"truncate font-mono",children:M.file})]},M.file)})})]},I.name))]}),v.jsx("div",{className:"px-3 py-2 border-t border-border",children:v.jsx("button",{onClick:()=>b(!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:v.jsx("span",{children:"Archives"})})})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -57,22 +57,22 @@ Error generating stack: `+c.message+` * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Sb=Object.defineProperty,tw=Object.getOwnPropertyDescriptor,iw=(e,t)=>{for(var n in t)Sb(e,n,{get:t[n],enumerable:!0})},Ct=(e,t,n,s)=>{for(var a=s>1?void 0:s?tw(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(a=(s?u(t,n,a):u(a))||a);return s&&a&&Sb(t,n,a),a},ge=(e,t)=>(n,s)=>t(n,s,e),_v="Terminal input",Wd={get:()=>_v,set:e=>_v=e},vv="Too much output to announce, navigate to rows manually to read",$d={get:()=>vv,set:e=>vv=e};function nw(e){return e.replace(/\r?\n/g,"\r")}function rw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function lw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");wb(a,t,n,s)}}function wb(e,t,n,s){e=nw(e),e=rw(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Cb(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 yv(e,t,n,s,a){Cb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Hr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Fc(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 aw=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=u,s;let d=e.charCodeAt(o);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},ow=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,u,d,f=0,h=0;if(this.interim[0]){let y=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let S=0,T;for(;(T=this.interim[++S]&63)&&S<4;)b<<=6,b|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=B-S;for(;h=n)return 0;if(T=e[h++],(T&192)!==128){h--,y=!0;break}else this.interim[S++]=T,b<<=6,b|=T&63}y||(B===2?b<128?h--:t[s++]=b:B===3?b<2048||b>=55296&&b<=57343||b===65279||(t[s++]=b):b<65536||b>1114111||(t[s++]=b)),this.interim.fill(0)}let _=n-4,g=h;for(;g=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(f=(a&31)<<6|o&63,f<128){g--;continue}t[s++]=f}else if((a&240)===224){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(f=(a&15)<<12|(o&63)<<6|u&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[s++]=f}else if((a&248)===240){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=u,s;if(d=e[g++],(d&192)!==128){g--;continue}if(f=(a&7)<<18|(o&63)<<12|(u&63)<<6|d&63,f<65536||f>1114111)continue;t[s++]=f}}return s}},kb="",Ir=" ",Fa=class Eb{constructor(){this.fg=0,this.bg=0,this.extended=new Nc}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 Eb;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}},Nc=class Tb{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 Tb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dn=class Ab extends Fa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nc,this.combinedData=""}static fromCharData(t){let n=new Ab;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?Hr(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()]}},bv="di$target",Yd="di$dependencies",hd=new Map;function cw(e){return e[Yd]||[]}function ii(e){if(hd.has(e))return hd.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");uw(t,n,a)};return t._id=e,hd.set(e,t),t}function uw(e,t,n){t[bv]===t?t[Yd].push({id:e,index:n}):(t[Yd]=[{id:e,index:n}],t[bv]=t)}var wi=ii("BufferService"),Db=ii("CoreMouseService"),Ss=ii("CoreService"),hw=ii("CharsetService"),If=ii("InstantiationService"),Rb=ii("LogService"),Ci=ii("OptionsService"),Nb=ii("OscLinkService"),dw=ii("UnicodeService"),qa=ii("DecorationService"),Vd=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var _;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new dn,u=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;ga?a.activate(T,B,b):fw(T,B),hover:(T,B)=>{var D;return(D=a==null?void 0:a.hover)==null?void 0:D.call(a,T,B,b)},leave:(T,B)=>{var D;return(D=a==null?void 0:a.leave)==null?void 0:D.call(a,T,B,b)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(f=g,d=o.extended.urlId):(f=-1,d=-1)}}t(s)}};Vd=Ct([ge(0,wi),ge(1,Ci),ge(2,Nb)],Vd);function fw(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Sb=Object.defineProperty,tw=Object.getOwnPropertyDescriptor,iw=(e,t)=>{for(var n in t)Sb(e,n,{get:t[n],enumerable:!0})},At=(e,t,n,s)=>{for(var a=s>1?void 0:s?tw(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(a=(s?u(t,n,a):u(a))||a);return s&&a&&Sb(t,n,a),a},ge=(e,t)=>(n,s)=>t(n,s,e),_v="Terminal input",Wd={get:()=>_v,set:e=>_v=e},vv="Too much output to announce, navigate to rows manually to read",$d={get:()=>vv,set:e=>vv=e};function nw(e){return e.replace(/\r?\n/g,"\r")}function rw(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function lw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");wb(a,t,n,s)}}function wb(e,t,n,s){e=nw(e),e=rw(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Cb(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 yv(e,t,n,s,a){Cb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Hr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Fc(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 aw=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=u,s;let d=e.charCodeAt(o);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},ow=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,u,d,f=0,h=0;if(this.interim[0]){let y=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let S=0,T;for(;(T=this.interim[++S]&63)&&S<4;)b<<=6,b|=T;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=L-S;for(;h=n)return 0;if(T=e[h++],(T&192)!==128){h--,y=!0;break}else this.interim[S++]=T,b<<=6,b|=T&63}y||(L===2?b<128?h--:t[s++]=b:L===3?b<2048||b>=55296&&b<=57343||b===65279||(t[s++]=b):b<65536||b>1114111||(t[s++]=b)),this.interim.fill(0)}let _=n-4,g=h;for(;g=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(f=(a&31)<<6|o&63,f<128){g--;continue}t[s++]=f}else if((a&240)===224){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(f=(a&15)<<12|(o&63)<<6|u&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[s++]=f}else if((a&248)===240){if(g>=n)return this.interim[0]=a,s;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,s;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=u,s;if(d=e[g++],(d&192)!==128){g--;continue}if(f=(a&7)<<18|(o&63)<<12|(u&63)<<6|d&63,f<65536||f>1114111)continue;t[s++]=f}}return s}},kb="",Ir=" ",Fa=class Eb{constructor(){this.fg=0,this.bg=0,this.extended=new Nc}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 Eb;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}},Nc=class Tb{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 Tb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},pn=class Ab extends Fa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nc,this.combinedData=""}static fromCharData(t){let n=new Ab;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?Hr(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()]}},bv="di$target",Yd="di$dependencies",hd=new Map;function cw(e){return e[Yd]||[]}function li(e){if(hd.has(e))return hd.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");uw(t,n,a)};return t._id=e,hd.set(e,t),t}function uw(e,t,n){t[bv]===t?t[Yd].push({id:e,index:n}):(t[Yd]=[{id:e,index:n}],t[bv]=t)}var ki=li("BufferService"),Db=li("CoreMouseService"),Ss=li("CoreService"),hw=li("CharsetService"),If=li("InstantiationService"),Rb=li("LogService"),Ei=li("OptionsService"),Nb=li("OscLinkService"),dw=li("UnicodeService"),qa=li("DecorationService"),Vd=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var _;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new pn,u=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;ga?a.activate(T,L,b):fw(T,L),hover:(T,L)=>{var D;return(D=a==null?void 0:a.hover)==null?void 0:D.call(a,T,L,b)},leave:(T,L)=>{var D;return(D=a==null?void 0:a.leave)==null?void 0:D.call(a,T,L,b)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(f=g,d=o.extended.urlId):(f=-1,d=-1)}}t(s)}};Vd=At([ge(0,ki),ge(1,Ei),ge(2,Nb)],Vd);function fw(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 qc=ii("CharSizeService"),sr=ii("CoreBrowserService"),Uf=ii("MouseService"),lr=ii("RenderService"),pw=ii("SelectionService"),Mb=ii("CharacterJoinerService"),yl=ii("ThemeService"),Bb=ii("LinkProviderService"),mw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xv.isErrorNoTelemetry(e)?new xv(e.message+` +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 qc=li("CharSizeService"),sr=li("CoreBrowserService"),Uf=li("MouseService"),lr=li("RenderService"),pw=li("SelectionService"),Mb=li("CharacterJoinerService"),yl=li("ThemeService"),Bb=li("LinkProviderService"),mw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xv.isErrorNoTelemetry(e)?new xv(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)}},gw=new mw;function wc(e){_w(e)||gw.onUnexpectedError(e)}var Kd="Canceled";function _w(e){return e instanceof vw?!0:e instanceof Error&&e.name===Kd&&e.message===Kd}var vw=class extends Error{constructor(){super(Kd),this.name=this.message}};function yw(e){return new Error(`Illegal argument: ${e}`)}var xv=class Gd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gd)return t;let n=new Gd;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Xd=class Lb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Lb.prototype)}};function $i(e,t=0){return e[e.length-(1+t)]}var bw;(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})(bw||(bw={}));function xw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var Ob;(e=>{function t(J){return J&&typeof J=="object"&&typeof J[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(J){yield J}e.single=a;function o(J){return t(J)?J:a(J)}e.wrap=o;function u(J){return J||n}e.from=u;function*d(J){for(let I=J.length-1;I>=0;I--)yield J[I]}e.reverse=d;function f(J){return!J||J[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(J){return J[Symbol.iterator]().next().value}e.first=h;function _(J,I){let M=0;for(let Q of J)if(I(Q,M++))return!0;return!1}e.some=_;function g(J,I){for(let M of J)if(I(M))return M}e.find=g;function*y(J,I){for(let M of J)I(M)&&(yield M)}e.filter=y;function*b(J,I){let M=0;for(let Q of J)yield I(Q,M++)}e.map=b;function*S(J,I){let M=0;for(let Q of J)yield*I(Q,M++)}e.flatMap=S;function*T(...J){for(let I of J)yield*I}e.concat=T;function B(J,I,M){let Q=M;for(let ce of J)Q=I(Q,ce);return Q}e.reduce=B;function*D(J,I,M=J.length){for(I<0&&(I+=J.length),M<0?M+=J.length:M>J.length&&(M=J.length);I1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Sw(...e){return gt(()=>ys(e))}function gt(e){return{dispose:xw(()=>{e()})}}var zb=class jb{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{ys(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?jb.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)}};zb.DISABLE_DISPOSED_WARNING=!1;var Ur=zb,Pe=class{constructor(){this._store=new Ur,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)}};Pe.None=Object.freeze({dispose(){}});var _l=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}},rr=typeof window=="object"?window:globalThis,Zd=class Qd{constructor(t){this.element=t,this.next=Qd.Undefined,this.prev=Qd.Undefined}};Zd.Undefined=new Zd(void 0);var _t=Zd,Sv=class{constructor(){this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_t.Undefined}clear(){let e=this._first;for(;e!==_t.Undefined;){let t=e.next;e.prev=_t.Undefined,e.next=_t.Undefined,e=t}this._first=_t.Undefined,this._last=_t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new _t(e);if(this._first===_t.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!==_t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_t.Undefined&&e.next!==_t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_t.Undefined&&e.next===_t.Undefined?(this._first=_t.Undefined,this._last=_t.Undefined):e.next===_t.Undefined?(this._last=this._last.prev,this._last.next=_t.Undefined):e.prev===_t.Undefined&&(this._first=this._first.next,this._first.prev=_t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_t.Undefined;)yield e.element,e=e.next}},ww=globalThis.performance&&typeof globalThis.performance.now=="function",Cw=class Hb{static create(t){return new Hb(t)}constructor(t){this._now=ww&&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}},ui;(e=>{e.None=()=>Pe.None;function t($,F){return g($,()=>{},0,void 0,!0,void 0,F)}e.defer=t;function n($){return(F,Y=null,A)=>{let E=!1,j;return j=$(U=>{if(!E)return j?j.dispose():E=!0,F.call(Y,U)},null,A),E&&j.dispose(),j}}e.once=n;function s($,F,Y){return h((A,E=null,j)=>$(U=>A.call(E,F(U)),null,j),Y)}e.map=s;function a($,F,Y){return h((A,E=null,j)=>$(U=>{F(U),A.call(E,U)},null,j),Y)}e.forEach=a;function o($,F,Y){return h((A,E=null,j)=>$(U=>F(U)&&A.call(E,U),null,j),Y)}e.filter=o;function u($){return $}e.signal=u;function d(...$){return(F,Y=null,A)=>{let E=Sw(...$.map(j=>j(U=>F.call(Y,U))));return _(E,A)}}e.any=d;function f($,F,Y,A){let E=Y;return s($,j=>(E=F(E,j),E),A)}e.reduce=f;function h($,F){let Y,A={onWillAddFirstListener(){Y=$(E.fire,E)},onDidRemoveLastListener(){Y==null||Y.dispose()}},E=new pe(A);return F==null||F.add(E),E.event}function _($,F){return F instanceof Array?F.push($):F&&F.add($),$}function g($,F,Y=100,A=!1,E=!1,j,U){let le,k,R,K=0,w,V={leakWarningThreshold:j,onWillAddFirstListener(){le=$(ae=>{K++,k=F(k,ae),A&&!R&&(ue.fire(k),k=void 0),w=()=>{let ve=k;k=void 0,R=void 0,(!A||K>1)&&ue.fire(ve),K=0},typeof Y=="number"?(clearTimeout(R),R=setTimeout(w,Y)):R===void 0&&(R=0,queueMicrotask(w))})},onWillRemoveListener(){E&&K>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,le.dispose()}},ue=new pe(V);return U==null||U.add(ue),ue.event}e.debounce=g;function y($,F=0,Y){return e.debounce($,(A,E)=>A?(A.push(E),A):[E],F,void 0,!0,void 0,Y)}e.accumulate=y;function b($,F=(A,E)=>A===E,Y){let A=!0,E;return o($,j=>{let U=A||!F(j,E);return A=!1,E=j,U},Y)}e.latch=b;function S($,F,Y){return[e.filter($,F,Y),e.filter($,A=>!F(A),Y)]}e.split=S;function T($,F=!1,Y=[],A){let E=Y.slice(),j=$(k=>{E?E.push(k):le.fire(k)});A&&A.add(j);let U=()=>{E==null||E.forEach(k=>le.fire(k)),E=null},le=new pe({onWillAddFirstListener(){j||(j=$(k=>le.fire(k)),A&&A.add(j))},onDidAddFirstListener(){E&&(F?setTimeout(U):U())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return A&&A.add(le),le.event}e.buffer=T;function B($,F){return(Y,A,E)=>{let j=F(new X);return $(function(U){let le=j.evaluate(U);le!==D&&Y.call(A,le)},void 0,E)}}e.chain=B;let D=Symbol("HaltChainable");class X{constructor(){this.steps=[]}map(F){return this.steps.push(F),this}forEach(F){return this.steps.push(Y=>(F(Y),Y)),this}filter(F){return this.steps.push(Y=>F(Y)?Y:D),this}reduce(F,Y){let A=Y;return this.steps.push(E=>(A=F(A,E),A)),this}latch(F=(Y,A)=>Y===A){let Y=!0,A;return this.steps.push(E=>{let j=Y||!F(E,A);return Y=!1,A=E,j?E:D}),this}evaluate(F){for(let Y of this.steps)if(F=Y(F),F===D)break;return F}}function P($,F,Y=A=>A){let A=(...le)=>U.fire(Y(...le)),E=()=>$.on(F,A),j=()=>$.removeListener(F,A),U=new pe({onWillAddFirstListener:E,onDidRemoveLastListener:j});return U.event}e.fromNodeEventEmitter=P;function J($,F,Y=A=>A){let A=(...le)=>U.fire(Y(...le)),E=()=>$.addEventListener(F,A),j=()=>$.removeEventListener(F,A),U=new pe({onWillAddFirstListener:E,onDidRemoveLastListener:j});return U.event}e.fromDOMEventEmitter=J;function I($){return new Promise(F=>n($)(F))}e.toPromise=I;function M($){let F=new pe;return $.then(Y=>{F.fire(Y)},()=>{F.fire(void 0)}).finally(()=>{F.dispose()}),F.event}e.fromPromise=M;function Q($,F){return $(Y=>F.fire(Y))}e.forward=Q;function ce($,F,Y){return F(Y),$(A=>F(A))}e.runAndSubscribe=ce;class me{constructor(F,Y){this._observable=F,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{F.addObserver(this)},onDidRemoveLastListener:()=>{F.removeObserver(this)}};this.emitter=new pe(A),Y&&Y.add(this.emitter)}beginUpdate(F){this._counter++}handlePossibleChange(F){}handleChange(F,Y){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 z($,F){return new me($,F).emitter.event}e.fromObservable=z;function ie($){return(F,Y,A)=>{let E=0,j=!1,U={beginUpdate(){E++},endUpdate(){E--,E===0&&($.reportChanges(),j&&(j=!1,F.call(Y)))},handlePossibleChange(){},handleChange(){j=!0}};$.addObserver(U),$.reportChanges();let le={dispose(){$.removeObserver(U)}};return A instanceof Ur?A.add(le):Array.isArray(A)&&A.push(le),le}}e.fromObservableLight=ie})(ui||(ui={}));var Jd=class ef{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ef._idPool++}`,ef.all.add(this)}start(t){this._stopWatch=new Cw,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}}};Jd.all=new Set,Jd._idPool=0;var kw=Jd,Ew=-1,Pb=class Ib{constructor(t,n,s=(Ib._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{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)}},gw=new mw;function wc(e){_w(e)||gw.onUnexpectedError(e)}var Kd="Canceled";function _w(e){return e instanceof vw?!0:e instanceof Error&&e.name===Kd&&e.message===Kd}var vw=class extends Error{constructor(){super(Kd),this.name=this.message}};function yw(e){return new Error(`Illegal argument: ${e}`)}var xv=class Gd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gd)return t;let n=new Gd;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Xd=class Lb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Lb.prototype)}};function Ki(e,t=0){return e[e.length-(1+t)]}var bw;(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})(bw||(bw={}));function xw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var Ob;(e=>{function t(J){return J&&typeof J=="object"&&typeof J[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(J){yield J}e.single=a;function o(J){return t(J)?J:a(J)}e.wrap=o;function u(J){return J||n}e.from=u;function*d(J){for(let I=J.length-1;I>=0;I--)yield J[I]}e.reverse=d;function f(J){return!J||J[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(J){return J[Symbol.iterator]().next().value}e.first=h;function _(J,I){let M=0;for(let Q of J)if(I(Q,M++))return!0;return!1}e.some=_;function g(J,I){for(let M of J)if(I(M))return M}e.find=g;function*y(J,I){for(let M of J)I(M)&&(yield M)}e.filter=y;function*b(J,I){let M=0;for(let Q of J)yield I(Q,M++)}e.map=b;function*S(J,I){let M=0;for(let Q of J)yield*I(Q,M++)}e.flatMap=S;function*T(...J){for(let I of J)yield*I}e.concat=T;function L(J,I,M){let Q=M;for(let ue of J)Q=I(Q,ue);return Q}e.reduce=L;function*D(J,I,M=J.length){for(I<0&&(I+=J.length),M<0?M+=J.length:M>J.length&&(M=J.length);I1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Sw(...e){return yt(()=>ys(e))}function yt(e){return{dispose:xw(()=>{e()})}}var zb=class jb{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{ys(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?jb.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)}};zb.DISABLE_DISPOSED_WARNING=!1;var Ur=zb,He=class{constructor(){this._store=new Ur,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)}};He.None=Object.freeze({dispose(){}});var _l=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}},rr=typeof window=="object"?window:globalThis,Zd=class Qd{constructor(t){this.element=t,this.next=Qd.Undefined,this.prev=Qd.Undefined}};Zd.Undefined=new Zd(void 0);var bt=Zd,Sv=class{constructor(){this._first=bt.Undefined,this._last=bt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===bt.Undefined}clear(){let e=this._first;for(;e!==bt.Undefined;){let t=e.next;e.prev=bt.Undefined,e.next=bt.Undefined,e=t}this._first=bt.Undefined,this._last=bt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new bt(e);if(this._first===bt.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!==bt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==bt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==bt.Undefined&&e.next!==bt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===bt.Undefined&&e.next===bt.Undefined?(this._first=bt.Undefined,this._last=bt.Undefined):e.next===bt.Undefined?(this._last=this._last.prev,this._last.next=bt.Undefined):e.prev===bt.Undefined&&(this._first=this._first.next,this._first.prev=bt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==bt.Undefined;)yield e.element,e=e.next}},ww=globalThis.performance&&typeof globalThis.performance.now=="function",Cw=class Hb{static create(t){return new Hb(t)}constructor(t){this._now=ww&&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}},pi;(e=>{e.None=()=>He.None;function t(F,q){return g(F,()=>{},0,void 0,!0,void 0,q)}e.defer=t;function n(F){return(q,G=null,A)=>{let k=!1,j;return j=F(U=>{if(!k)return j?j.dispose():k=!0,q.call(G,U)},null,A),k&&j.dispose(),j}}e.once=n;function s(F,q,G){return h((A,k=null,j)=>F(U=>A.call(k,q(U)),null,j),G)}e.map=s;function a(F,q,G){return h((A,k=null,j)=>F(U=>{q(U),A.call(k,U)},null,j),G)}e.forEach=a;function o(F,q,G){return h((A,k=null,j)=>F(U=>q(U)&&A.call(k,U),null,j),G)}e.filter=o;function u(F){return F}e.signal=u;function d(...F){return(q,G=null,A)=>{let k=Sw(...F.map(j=>j(U=>q.call(G,U))));return _(k,A)}}e.any=d;function f(F,q,G,A){let k=G;return s(F,j=>(k=q(k,j),k),A)}e.reduce=f;function h(F,q){let G,A={onWillAddFirstListener(){G=F(k.fire,k)},onDidRemoveLastListener(){G==null||G.dispose()}},k=new pe(A);return q==null||q.add(k),k.event}function _(F,q){return q instanceof Array?q.push(F):q&&q.add(F),F}function g(F,q,G=100,A=!1,k=!1,j,U){let le,E,R,Y=0,w,V={leakWarningThreshold:j,onWillAddFirstListener(){le=F(ae=>{Y++,E=q(E,ae),A&&!R&&(he.fire(E),E=void 0),w=()=>{let _e=E;E=void 0,R=void 0,(!A||Y>1)&&he.fire(_e),Y=0},typeof G=="number"?(clearTimeout(R),R=setTimeout(w,G)):R===void 0&&(R=0,queueMicrotask(w))})},onWillRemoveListener(){k&&Y>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,le.dispose()}},he=new pe(V);return U==null||U.add(he),he.event}e.debounce=g;function y(F,q=0,G){return e.debounce(F,(A,k)=>A?(A.push(k),A):[k],q,void 0,!0,void 0,G)}e.accumulate=y;function b(F,q=(A,k)=>A===k,G){let A=!0,k;return o(F,j=>{let U=A||!q(j,k);return A=!1,k=j,U},G)}e.latch=b;function S(F,q,G){return[e.filter(F,q,G),e.filter(F,A=>!q(A),G)]}e.split=S;function T(F,q=!1,G=[],A){let k=G.slice(),j=F(E=>{k?k.push(E):le.fire(E)});A&&A.add(j);let U=()=>{k==null||k.forEach(E=>le.fire(E)),k=null},le=new pe({onWillAddFirstListener(){j||(j=F(E=>le.fire(E)),A&&A.add(j))},onDidAddFirstListener(){k&&(q?setTimeout(U):U())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return A&&A.add(le),le.event}e.buffer=T;function L(F,q){return(G,A,k)=>{let j=q(new X);return F(function(U){let le=j.evaluate(U);le!==D&&G.call(A,le)},void 0,k)}}e.chain=L;let D=Symbol("HaltChainable");class X{constructor(){this.steps=[]}map(q){return this.steps.push(q),this}forEach(q){return this.steps.push(G=>(q(G),G)),this}filter(q){return this.steps.push(G=>q(G)?G:D),this}reduce(q,G){let A=G;return this.steps.push(k=>(A=q(A,k),A)),this}latch(q=(G,A)=>G===A){let G=!0,A;return this.steps.push(k=>{let j=G||!q(k,A);return G=!1,A=k,j?k:D}),this}evaluate(q){for(let G of this.steps)if(q=G(q),q===D)break;return q}}function P(F,q,G=A=>A){let A=(...le)=>U.fire(G(...le)),k=()=>F.on(q,A),j=()=>F.removeListener(q,A),U=new pe({onWillAddFirstListener:k,onDidRemoveLastListener:j});return U.event}e.fromNodeEventEmitter=P;function J(F,q,G=A=>A){let A=(...le)=>U.fire(G(...le)),k=()=>F.addEventListener(q,A),j=()=>F.removeEventListener(q,A),U=new pe({onWillAddFirstListener:k,onDidRemoveLastListener:j});return U.event}e.fromDOMEventEmitter=J;function I(F){return new Promise(q=>n(F)(q))}e.toPromise=I;function M(F){let q=new pe;return F.then(G=>{q.fire(G)},()=>{q.fire(void 0)}).finally(()=>{q.dispose()}),q.event}e.fromPromise=M;function Q(F,q){return F(G=>q.fire(G))}e.forward=Q;function ue(F,q,G){return q(G),F(A=>q(A))}e.runAndSubscribe=ue;class me{constructor(q,G){this._observable=q,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{q.addObserver(this)},onDidRemoveLastListener:()=>{q.removeObserver(this)}};this.emitter=new pe(A),G&&G.add(this.emitter)}beginUpdate(q){this._counter++}handlePossibleChange(q){}handleChange(q,G){this._hasChanged=!0}endUpdate(q){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function z(F,q){return new me(F,q).emitter.event}e.fromObservable=z;function te(F){return(q,G,A)=>{let k=0,j=!1,U={beginUpdate(){k++},endUpdate(){k--,k===0&&(F.reportChanges(),j&&(j=!1,q.call(G)))},handlePossibleChange(){},handleChange(){j=!0}};F.addObserver(U),F.reportChanges();let le={dispose(){F.removeObserver(U)}};return A instanceof Ur?A.add(le):Array.isArray(A)&&A.push(le),le}}e.fromObservableLight=te})(pi||(pi={}));var Jd=class ef{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ef._idPool++}`,ef.all.add(this)}start(t){this._stopWatch=new Cw,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}}};Jd.all=new Set,Jd._idPool=0;var kw=Jd,Ew=-1,Pb=class Ib{constructor(t,n,s=(Ib._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 d,f,h,_,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new Rw(`${y}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((d=this._options)==null?void 0:d.onListenerError)||wc)(S),Pe.None}if(this._disposed)return Pe.None;n&&(t=t.bind(n));let a=new dd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=Aw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof dd?(this._deliveryQueue??(this._deliveryQueue=new Lw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=a,(g=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||g.call(_,this)),this._size++;let u=gt(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ur?s.add(u):Array.isArray(s)&&s.push(u),u}),this._event}_removeListener(t){var o,u,d,f;if((u=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||u.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,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*Mw<=n.length){let h=0;for(let _=0;_0}},Lw=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}},tf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new pe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new pe,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}};tf.INSTANCE=new tf;var Ff=tf;function Ow(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ff.INSTANCE.onDidChangeZoomLevel;function zw(e){return Ff.INSTANCE.getZoomFactor(e)}Ff.INSTANCE.onDidChangeFullscreen;var bl=typeof navigator=="object"?navigator.userAgent:"",nf=bl.indexOf("Firefox")>=0,jw=bl.indexOf("AppleWebKit")>=0,qf=bl.indexOf("Chrome")>=0,Hw=!qf&&bl.indexOf("Safari")>=0;bl.indexOf("Electron/")>=0;bl.indexOf("Android")>=0;var fd=!1;if(typeof rr.matchMedia=="function"){let e=rr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=rr.matchMedia("(display-mode: fullscreen)");fd=e.matches,Ow(rr,e,({matches:n})=>{fd&&t.matches||(fd=n)})}var ml="en",rf=!1,sf=!1,Cc=!1,Fb=!1,hc,kc=ml,wv=ml,Pw,yn,vs=globalThis,ci,vb;typeof vs.vscode<"u"&&typeof vs.vscode.process<"u"?ci=vs.vscode.process:typeof process<"u"&&typeof((vb=process==null?void 0:process.versions)==null?void 0:vb.node)=="string"&&(ci=process);var yb,Iw=typeof((yb=ci==null?void 0:ci.versions)==null?void 0:yb.electron)=="string",Uw=Iw&&(ci==null?void 0:ci.type)==="renderer",bb;if(typeof ci=="object"){rf=ci.platform==="win32",sf=ci.platform==="darwin",Cc=ci.platform==="linux",Cc&&ci.env.SNAP&&ci.env.SNAP_REVISION,ci.env.CI||ci.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hc=ml,kc=ml;let e=ci.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);hc=t.userLocale,wv=t.osLocale,kc=t.resolvedLanguage||ml,Pw=(bb=t.languagePack)==null?void 0:bb.translationsConfigFile}catch{}Fb=!0}else typeof navigator=="object"&&!Uw?(yn=navigator.userAgent,rf=yn.indexOf("Windows")>=0,sf=yn.indexOf("Macintosh")>=0,(yn.indexOf("Macintosh")>=0||yn.indexOf("iPad")>=0||yn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Cc=yn.indexOf("Linux")>=0,(yn==null?void 0:yn.indexOf("Mobi"))>=0,kc=globalThis._VSCODE_NLS_LANGUAGE||ml,hc=navigator.language.toLowerCase(),wv=hc):console.error("Unable to resolve platform.");var qb=rf,Nn=sf,Fw=Cc,Cv=Fb,Mn=yn,Lr=kc,qw;(e=>{function t(){return Lr}e.value=t;function n(){return Lr.length===2?Lr==="en":Lr.length>=3?Lr[0]==="e"&&Lr[1]==="n"&&Lr[2]==="-":!1}e.isDefaultVariant=n;function s(){return Lr==="en"}e.isDefault=s})(qw||(qw={}));var Ww=typeof vs.postMessage=="function"&&!vs.importScripts;(()=>{if(Ww){let e=[];vs.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}),vs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var $w=!!(Mn&&Mn.indexOf("Chrome")>=0);Mn&&Mn.indexOf("Firefox")>=0;!$w&&Mn&&Mn.indexOf("Safari")>=0;Mn&&Mn.indexOf("Edg/")>=0;Mn&&Mn.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Cv||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Cv||cl&&cl.clipboard&&cl.clipboard.readText;var Wf=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}},pd=new Wf,kv=new Wf,Ev=new Wf,Yw=new Array(230),Wb;(e=>{function t(d){return pd.keyCodeToStr(d)}e.toString=t;function n(d){return pd.strToKeyCode(d)}e.fromString=n;function s(d){return kv.keyCodeToStr(d)}e.toUserSettingsUS=s;function a(d){return Ev.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function o(d){return kv.strToKeyCode(d)||Ev.strToKeyCode(d)}e.fromUserSettings=o;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pd.keyCodeToStr(d)}e.toElectronAccelerator=u})(Wb||(Wb={}));var Vw=class $b{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 $b&&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 Kw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kw=class{constructor(e){if(e.length===0)throw yw("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 nC?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ui.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Yb})})(iC||(iC={}));var nC=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?Yb:(this._emitter||(this._emitter=new pe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$f=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 Xd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Xd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},rC=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 Xd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=gt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},sC;(e=>{async function t(s){let a,o=await Promise.all(s.map(u=>u.then(d=>d,d=>{a||(a=d)})));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(u){o(u)}})}e.withAsyncBody=n})(sC||(sC={}));var Rv=class cn{static fromArray(t){return new cn(n=>{n.emitMany(t)})}static fromPromise(t){return new cn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new cn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new cn(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 pe,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 cn(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return cn.map(this,t)}static filter(t,n){return new cn(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return cn.filter(this,t)}static coalesce(t){return cn.filter(t,n=>!!n)}coalesce(){return cn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return cn.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())}};Rv.EMPTY=Rv.fromArray([]);var{getWindow:Rn,getWindowId:lC,onDidRegisterWindow:aC}=(function(){let e=new Map,t={window:rr,disposables:new Ur};e.set(rr.vscodeWindowId,t);let n=new pe,s=new pe,a=new pe;function o(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Pe.None;let d=new Ur,f={window:u,disposables:d.add(new Ur)};return e.set(u.vscodeWindowId,f),d.add(gt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(Me(u,Gt.BEFORE_UNLOAD,()=>{a.fire(u)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:o,getWindow(u){var h;let d=u;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=u;return f!=null&&f.view?f.view.window:rr},getDocument(u){return Rn(u).document}}})(),oC=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 Me(e,t,n,s){return new oC(e,t,n,s)}var Nv=function(e,t,n,s){return Me(e,t,n,s)},Yf,cC=class extends rC{constructor(e){super(),this.defaultTarget=e&&Rn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Mv=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){wc(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 u=e.get(o)??[];for(t.set(o,u),e.set(o,[]),s.set(o,!0);u.length>0;)u.sort(Mv.sort),u.shift().execute();s.set(o,!1)};Yf=(o,u,d=0)=>{let f=lC(o),h=new Mv(u,d),_=e.get(f);return _||(_=[],e.set(f,_)),_.push(h),n.get(f)||(n.set(f,!0),o.requestAnimationFrame(()=>a(f))),h}})();function uC(e){let t=e.getBoundingClientRect(),n=Rn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Gt={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"},hC=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=Mi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Mi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Mi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Mi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Mi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Mi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Mi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Mi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Mi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Mi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Mi(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=Mi(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=Mi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Mi(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 Mi(e){return typeof e=="number"?`${e}px`:e}function Ma(e){return new hC(e)}var Vb=class{constructor(){this._hooks=new Ur,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(gt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Rn(e)}this._hooks.add(Me(o,Gt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Me(o,Gt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function dC(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(...u){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,u)}),this[o]}}var An;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(An||(An={}));var Ta=class fi extends Pe{constructor(){super(),this.dispatched=!1,this.targets=new Sv,this.ignoreTargets=new Sv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ui.runAndSubscribe(aC,({window:t,disposables:n})=>{n.add(Me(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Me(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Me(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:rr,disposables:this._store}))}static addTarget(t){if(!fi.isTouchDevice())return Pe.None;fi.INSTANCE||(fi.INSTANCE=new fi);let n=fi.INSTANCE.targets.push(t);return gt(n)}static ignoreTarget(t){if(!fi.isTouchDevice())return Pe.None;fi.INSTANCE||(fi.INSTANCE=new fi);let n=fi.INSTANCE.ignoreTargets.push(t);return gt(n)}static isTouchDevice(){return"ontouchstart"in rr||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=fi.HOLD_DELAY&&Math.abs(f.initialPageX-$i(f.rollingPageX))<30&&Math.abs(f.initialPageY-$i(f.rollingPageY))<30){let _=this.newGestureEvent(An.Contextmenu,f.initialTarget);_.pageX=$i(f.rollingPageX),_.pageY=$i(f.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=$i(f.rollingPageX),g=$i(f.rollingPageY),y=$i(f.rollingTimestamps)-f.rollingTimestamps[0],b=_-f.rollingPageX[0],S=g-f.rollingPageY[0],T=[...this.targets].filter(B=>f.initialTarget instanceof Node&&B.contains(f.initialTarget));this.inertia(t,T,s,Math.abs(b)/y,b>0?1:-1,_,Math.abs(S)/y,S>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(An.End,f.initialTarget)),delete this.activeTouches[d.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===An.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>fi.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===An.Change||t.type===An.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,u,d,f,h){this.handle=Yf(t,()=>{let _=Date.now(),g=_-s,y=0,b=0,S=!0;a+=fi.SCROLL_FRICTION*g,d+=fi.SCROLL_FRICTION*g,a>0&&(S=!1,y=o*a*g),d>0&&(S=!1,b=f*d*g);let T=this.newGestureEvent(An.Change);T.translationX=y,T.translationY=b,n.forEach(B=>B.dispatchEvent(T)),S||this.inertia(t,n,_,a,o,u+y,d,f,h+b)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(o.pageX),u.rollingPageY.push(o.pageY),u.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,Ct([dC],Ta,"isTouchDevice",1);var fC=Ta,Vf=class extends Pe{onclick(e,t){this._register(Me(e,Gt.CLICK,n=>t(new dc(Rn(e),n))))}onmousedown(e,t){this._register(Me(e,Gt.MOUSE_DOWN,n=>t(new dc(Rn(e),n))))}onmouseover(e,t){this._register(Me(e,Gt.MOUSE_OVER,n=>t(new dc(Rn(e),n))))}onmouseleave(e,t){this._register(Me(e,Gt.MOUSE_LEAVE,n=>t(new dc(Rn(e),n))))}onkeydown(e,t){this._register(Me(e,Gt.KEY_DOWN,n=>t(new Tv(n))))}onkeyup(e,t){this._register(Me(e,Gt.KEY_UP,n=>t(new Tv(n))))}oninput(e,t){this._register(Me(e,Gt.INPUT,t))}onblur(e,t){this._register(Me(e,Gt.BLUR,t))}onfocus(e,t){this._register(Me(e,Gt.FOCUS,t))}onchange(e,t){this._register(Me(e,Gt.CHANGE,t))}ignoreGesture(e){return fC.ignoreTarget(e)}},Bv=11,pC=class extends Vf{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 Vb),this._register(Nv(this.bgDomNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nv(this.domNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cC),this._pointerdownScheduleRepeatTimer=this._register(new $f)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Rn(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()}},mC=class lf{constructor(t,n,s,a,o,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,u=u|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),d+o>u&&(d=u-o),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=u,this.scrollTop=d}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 lf(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 lf(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,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=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:u,scrollHeightChanged:d,scrollTopChanged:f}}},gC=class extends Pe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new mC(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 Ov(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=Ov.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)))}},Lv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function md(e,t){let n=t-e;return function(s){return e+n*yC(s)}}function _C(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":"")))}},xC=140,Kb=class extends Vf{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 bC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vb),this._shouldRender=!0,this.domNode=Ma(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(Me(this.domNode.domNode,Gt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new pC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Ma(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(Me(this.slider.domNode,Gt.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=uC(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),u=Math.abs(o-n);if(qb&&u>xC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},Gb=class of{constructor(t,n,s,a,o,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new of(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 u=Math.max(0,s-t),d=Math.max(0,u-2*n),f=a>0&&a>s;if(!f)return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*d/a))),_=(d-h)/(a-s),g=o*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:_,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=of._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),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(a,u),1),h=Math.max(Math.min(o,d),1),_=Math.max(a,u),g=Math.max(o,d);_%f===0&&g%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};cf.INSTANCE=new cf;var EC=cf,TC=class extends Vf{constructor(e,t,n){super(),this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new pe),this.onWillScroll=this._onWillScroll.event,this._options=DC(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 wC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new SC(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=Ma(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ma(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ma(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 $f),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ys(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,Nn&&(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 Dv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ys(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Dv(n))};this._mouseWheelToDispose.push(Me(this._listenOnDomNode,Gt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=EC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+o===0?u=o=0:Math.abs(o)>=Math.abs(u)?u=0:o=0),this._options.flipAxes&&([o,u]=[u,o]);let d=!Nn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(o){let _=zv*o,g=f.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(h,g)}if(u){let _=zv*u,g=f.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.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(),CC)}},AC=class extends TC{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 DC(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,Nn&&(t.className+=" mac"),t}var uf=class extends Pe{constructor(e,t,n,s,a,o,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new gC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Yf(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new AC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),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(ui.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(gt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(gt(()=>this._styleElement.remove())),this._register(ui.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}};uf=Ct([ge(2,wi),ge(3,sr),ge(4,Db),ge(5,yl),ge(6,Ci),ge(7,lr)],uf);var hf=class extends Pe{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(gt(()=>{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()}};hf=Ct([ge(1,wi),ge(2,sr),ge(3,qa),ge(4,lr)],hf);var RC=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)}},En={full:0,left:0,center:0,right:0},Or={full:0,left:0,center:0,right:0},ga={full:0,left:0,center:0,right:0},Mc=class extends Pe{constructor(e,t,n,s,a,o,u,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new RC,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(gt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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);Or.full=this._canvas.width,Or.left=e,Or.center=t,Or.right=e,this._refreshDrawHeightConstants(),ga.full=1,ga.left=1,ga.center=1+Or.left,ga.right=1+Or.left+Or.center}_refreshDrawHeightConstants(){En.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);En.left=t,En.center=t,En.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*En.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(ga[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-En[e.position||"full"]/2),Or[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+En[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}))}};Mc=Ct([ge(2,wi),ge(3,qa),ge(4,lr),ge(5,Ci),ge(6,yl),ge(7,sr)],Mc);var se;(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=""))(se||(se={}));var Ec;(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=""))(Ec||(Ec={}));var Xb;(e=>e.ST=`${se.ESC}\\`)(Xb||(Xb={}));var df=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)}}};df=Ct([ge(2,wi),ge(3,Ci),ge(4,Ss),ge(5,lr)],df);var Xt=0,Zt=0,Qt=0,St=0,jv={css:"#00000000",rgba:0},zt;(e=>{function t(a,o,u,d){return d!==void 0?`#${us(a)}${us(o)}${us(u)}${us(d)}`:`#${us(a)}${us(o)}${us(u)}`}e.toCss=t;function n(a,o,u,d=255){return(a<<24|o<<16|u<<8|d)>>>0}e.toRgba=n;function s(a,o,u,d){return{css:e.toCss(a,o,u,d),rgba:e.toRgba(a,o,u,d)}}e.toColor=s})(zt||(zt={}));var pt;(e=>{function t(f,h){if(St=(h.rgba&255)/255,St===1)return{css:h.css,rgba:h.rgba};let _=h.rgba>>24&255,g=h.rgba>>16&255,y=h.rgba>>8&255,b=f.rgba>>24&255,S=f.rgba>>16&255,T=f.rgba>>8&255;Xt=b+Math.round((_-b)*St),Zt=S+Math.round((g-S)*St),Qt=T+Math.round((y-T)*St);let B=zt.toCss(Xt,Zt,Qt),D=zt.toRgba(Xt,Zt,Qt);return{css:B,rgba:D}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,h,_){let g=Tc.ensureContrastRatio(f.rgba,h.rgba,_);if(g)return zt.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(f){let h=(f.rgba|255)>>>0;return[Xt,Zt,Qt]=Tc.toChannels(h),{css:zt.toCss(Xt,Zt,Qt),rgba:h}}e.opaque=a;function o(f,h){return St=Math.round(h*255),[Xt,Zt,Qt]=Tc.toChannels(f.rgba),{css:zt.toCss(Xt,Zt,Qt,St),rgba:zt.toRgba(Xt,Zt,Qt,St)}}e.opacity=o;function u(f,h){return St=f.rgba&255,o(f,St*h/255)}e.multiplyOpacity=u;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(pt||(pt={}));var vt;(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 Xt=parseInt(a.slice(1,2).repeat(2),16),Zt=parseInt(a.slice(2,3).repeat(2),16),Qt=parseInt(a.slice(3,4).repeat(2),16),zt.toColor(Xt,Zt,Qt);case 5:return Xt=parseInt(a.slice(1,2).repeat(2),16),Zt=parseInt(a.slice(2,3).repeat(2),16),Qt=parseInt(a.slice(3,4).repeat(2),16),St=parseInt(a.slice(4,5).repeat(2),16),zt.toColor(Xt,Zt,Qt,St);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 Xt=parseInt(o[1]),Zt=parseInt(o[2]),Qt=parseInt(o[3]),St=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),zt.toColor(Xt,Zt,Qt,St);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),[Xt,Zt,Qt,St]=t.getImageData(0,0,1,1).data,St!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:zt.toRgba(Xt,Zt,Qt,St),css:a}}e.toColor=s})(vt||(vt={}));var bi;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let u=s/255,d=a/255,f=o/255,h=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+_*.7152+g*.0722}e.relativeLuminance2=n})(bi||(bi={}));var Tc;(e=>{function t(u,d){if(St=(d&255)/255,St===1)return d;let f=d>>24&255,h=d>>16&255,_=d>>8&255,g=u>>24&255,y=u>>16&255,b=u>>8&255;return Xt=g+Math.round((f-g)*St),Zt=y+Math.round((h-y)*St),Qt=b+Math.round((_-b)*St),zt.toRgba(Xt,Zt,Qt)}e.blend=t;function n(u,d,f){let h=bi.relativeLuminance(u>>8),_=bi.relativeLuminance(d>>8);if(tr(h,_)>8));if(S>8));return S>B?b:T}return b}let g=a(u,d,f),y=tr(h,bi.relativeLuminance(g>>8));if(y>8));return y>S?g:b}return g}}e.ensureContrastRatio=n;function s(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));for(;T0||b>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));return(y<<24|b<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(bi.relativeLuminance2(y,b,S),bi.relativeLuminance2(h,_,g));for(;T>>0}e.increaseLuminance=a;function o(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=o})(Tc||(Tc={}));function us(e){let t=e.toString(16);return t.length<2?"0"+t:t}function tr(e,t){return e1){let _=this._getJoinedRanges(s,u,o,t,a);for(let g=0;g<_.length;g++)n.push(_[g])}a=h,u=o,d=this._workCell.fg,f=this._workCell.bg}o+=this._workCell.getChars().length||Ir.length}if(this._bufferService.cols-a>1){let h=this._getJoinedRanges(s,u,o,t,a);for(let _=0;_=z,j=F,U=this._workCell;if(y.length>0&&F===y[0][0]&&E){let ye=y.shift(),Ne=this._isCellInSelection(ye[0],t);for(X=ye[0]+1;X=ye[1]),E?(A=!0,U=new NC(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),j=ye[1]-1,Y=U.getWidth()):z=ye[1]}let le=this._isCellInSelection(F,t),k=n&&F===o,R=$&&F>=h&&F<=_,K=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,ye=>{K=!0});let w=U.getChars()||Ir;if(w===" "&&(U.isUnderline()||U.isOverline())&&(w=" "),me=Y*d-f.get(w,U.isBold(),U.isItalic()),!T)T=this._document.createElement("span");else if(B&&(le&&ce||!le&&!ce&&U.bg===P)&&(le&&ce&&b.selectionForeground||U.fg===J)&&U.extended.ext===I&&R===M&&me===Q&&!k&&!A&&!K&&E){U.isInvisible()?D+=Ir:D+=w,B++;continue}else B&&(T.textContent=D),T=this._document.createElement("span"),B=0,D="";if(P=U.bg,J=U.fg,I=U.extended.ext,M=R,Q=me,ce=le,A&&o>=F&&o<=j&&(o=F),!this._coreService.isCursorHidden&&k&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ie.push("xterm-cursor-blink"),ie.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(U.isBold()&&ie.push("xterm-bold"),U.isItalic()&&ie.push("xterm-italic"),U.isDim()&&ie.push("xterm-dim"),U.isInvisible()?D=Ir:D=U.getChars()||Ir,U.isUnderline()&&(ie.push(`xterm-underline-${U.extended.underlineStyle}`),D===" "&&(D=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Fa.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let ye=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&ye<8&&(ye+=8),T.style.textDecorationColor=b.ansi[ye].css}U.isOverline()&&(ie.push("xterm-overline"),D===" "&&(D=" ")),U.isStrikethrough()&&ie.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let V=U.getFgColor(),ue=U.getFgColorMode(),ae=U.getBgColor(),ve=U.getBgColorMode(),Be=!!U.isInverse();if(Be){let ye=V;V=ae,ae=ye;let Ne=ue;ue=ve,ve=Ne}let Se,he,we=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,ye=>{ye.options.layer!=="top"&&we||(ye.backgroundColorRGB&&(ve=50331648,ae=ye.backgroundColorRGB.rgba>>8&16777215,Se=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ue=50331648,V=ye.foregroundColorRGB.rgba>>8&16777215,he=ye.foregroundColorRGB),we=ye.options.layer==="top")}),!we&&le&&(Se=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ae=Se.rgba>>8&16777215,ve=50331648,we=!0,b.selectionForeground&&(ue=50331648,V=b.selectionForeground.rgba>>8&16777215,he=b.selectionForeground)),we&&ie.push("xterm-decoration-top");let Ee;switch(ve){case 16777216:case 33554432:Ee=b.ansi[ae],ie.push(`xterm-bg-${ae}`);break;case 50331648:Ee=zt.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(T,`background-color:#${Hv((ae>>>0).toString(16),"0",6)}`);break;case 0:default:Be?(Ee=b.foreground,ie.push("xterm-bg-257")):Ee=b.background}switch(Se||U.isDim()&&(Se=pt.multiplyOpacity(Ee,.5)),ue){case 16777216:case 33554432:U.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(T,Ee,b.ansi[V],U,Se,void 0)||ie.push(`xterm-fg-${V}`);break;case 50331648:let ye=zt.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(T,Ee,ye,U,Se,he)||this._addStyle(T,`color:#${Hv(V.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(T,Ee,b.foreground,U,Se,he)||Be&&ie.push("xterm-fg-257")}ie.length&&(T.className=ie.join(" "),ie.length=0),!k&&!A&&!K&&E?B++:T.textContent=D,me!==this.defaultSpacing&&(T.style.letterSpacing=`${me}px`),g.push(T),F=j}return T&&B&&(T.textContent=D),g}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||LC(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!a&&!o&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=pt.ensureContrastRatio(a||t,o||n,f),u.setColor((a||t).rgba,(o||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.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]}};ff=Ct([ge(1,Mb),ge(2,Ci),ge(3,sr),ge(4,Ss),ge(5,qa),ge(6,yl)],ff);function Hv(e,t,n){for(;e.length0&&(this._flat[s]=u),u}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let u=0;t&&(u|=1),n&&(u|=2),o=this._measure(e,u),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}},jC=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,u=n[1]-a,d=Math.max(o,0),f=Math.min(u,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,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 HC(){return new jC}var gd="xterm-dom-renderer-owner-",on="xterm-rows",pc="xterm-fg-",Pv="xterm-bg-",_a="xterm-focus",mc="xterm-selection",PC=1,pf=class extends Pe{constructor(e,t,n,s,a,o,u,d,f,h,_,g,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=u,this._charSizeService=f,this._optionsService=h,this._bufferService=_,this._coreService=g,this._coreBrowserService=y,this._themeService=b,this._terminalClass=PC++,this._rowElements=[],this._selectionRenderModel=HC(),this.onRequestRedraw=this._register(new pe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(on),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(mc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(ff,document),this._element.classList.add(gd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(gt(()=>{this._element.classList.remove(gd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new zC(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} .${on} 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} .${on} { 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} .${on} .xterm-dim { color: ${pt.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} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${on}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${on} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${mc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,u]of e.ansi.entries())t+=`${this._terminalSelector} .${pc}${o} { color: ${u.css}; }${this._terminalSelector} .${pc}${o}.xterm-dim { color: ${pt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Pv}${o} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${pc}257 { color: ${pt.opaque(e.background).css}; }${this._terminalSelector} .${pc}257.xterm-dim { color: ${pt.multiplyOpacity(pt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Pv}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(_a),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(_a),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,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(o,f?t[0]:e[0],f?e[0]:t[0],u-o+1))}else{let f=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(o,f,h));let _=u-o-1;if(d.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==u){let g=a===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return o+u>this.dimensions.css.canvas.width&&(u=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=`${u}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,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,_=this._rowElements[f],g=n.lines.get(h);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,h,h===s,u,d,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gd}${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 u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,a-1),_=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let S=b+d.ydisp,T=this._rowElements[b],B=d.lines.get(S);if(!T||!B)break;T.replaceChildren(...this._rowFactory.createRow(B,S,S===f,g,y,h,_,this.dimensions.css.cell.width,this._widthCache,o?b===n?e:0:-1,o?(b===s?t:a)-1:-1))}}};pf=Ct([ge(7,If),ge(8,qc),ge(9,Ci),ge(10,wi),ge(11,Ss),ge(12,sr),ge(13,yl)],pf);var mf=class extends Pe{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new pe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new UC(this._optionsService))}catch{this._measureStrategy=this._register(new IC(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())}};mf=Ct([ge(2,Ci)],mf);var Zb=class extends Pe{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)}},IC=class extends Zb{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}},UC=class extends Zb{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}},FC=class extends Pe{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 qC(this._window)),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new pe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(ui.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Me(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Me(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}},qC=class extends Pe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new _l),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(gt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Me(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)}},WC=class extends Pe{constructor(){super(),this.linkProviders=[],this._register(gt(()=>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 Kf(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),u=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-u]}function $C(e,t,n,s,a,o,u,d,f){if(!o)return;let h=Kf(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?u/2:0))/u),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),s+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var gf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return $C(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=Kf(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])}}};gf=Ct([ge(0,lr),ge(1,qc)],gf);var YC=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=[]}},Qb={};iw(Qb,{getSafariVersion:()=>KC,isChromeOS:()=>ix,isFirefox:()=>Jb,isIpad:()=>GC,isIphone:()=>XC,isLegacyEdge:()=>VC,isLinux:()=>Gf,isMac:()=>Lc,isNode:()=>Wc,isSafari:()=>ex,isWindows:()=>tx});var Wc=typeof process<"u"&&"title"in process,Wa=Wc?"node":navigator.userAgent,$a=Wc?"node":navigator.platform,Jb=Wa.includes("Firefox"),VC=Wa.includes("Edge"),ex=/^((?!chrome|android).)*safari/i.test(Wa);function KC(){if(!ex)return 0;let e=Wa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Lc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($a),GC=$a==="iPad",XC=$a==="iPhone",tx=["Windows","Win16","Win32","WinCE"].includes($a),Gf=$a.indexOf("Linux")>=0,ix=/\bCrOS\b/.test(Wa),nx=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()}},ZC=class extends nx{_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())}}},QC=class extends nx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Oc=!Wc&&"requestIdleCallback"in window?QC:ZC,JC=class{constructor(){this._queue=new Oc}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_f=class extends Pe{constructor(e,t,n,s,a,o,u,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new _l),this._pausedResizeTask=new JC,this._observerDisposable=this._register(new _l),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 pe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new pe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new pe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new YC((h,_)=>this._renderRows(h,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ek(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(gt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.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=gt(()=>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()}};_f=Ct([ge(2,Ci),ge(3,qc),ge(4,Ss),ge(5,qa),ge(6,wi),ge(7,sr),ge(8,yl)],_f);var ek=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 tk(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return rk(a,o,e,t,n,s)+$c(o,t,n,s)+sk(a,o,e,t,n,s);let u;if(o===t)return u=a>e?"D":"C",ja(Math.abs(a-e),za(u,s));u=o>t?"D":"C";let d=Math.abs(o-t),f=nk(o>t?e:a,n)+(d-1)*n.cols+1+ik(o>t?a:e);return ja(f,za(u,s))}function ik(e,t){return e-1}function nk(e,t){return t.cols-e}function rk(e,t,n,s,a,o){return $c(t,s,a,o).length===0?"":ja(sx(e,t,e,t-bs(t,a),!1,a).length,za("D",o))}function $c(e,t,n,s){let a=e-bs(e,n),o=t-bs(t,n),u=Math.abs(a-o)-lk(e,t,n);return ja(u,za(rx(e,t),s))}function sk(e,t,n,s,a,o){let u;$c(t,s,a,o).length>0?u=s-bs(s,a):u=t;let d=s,f=ak(e,t,n,s,a,o);return ja(sx(e,u,n,d,f==="C",a).length,za(f,o))}function lk(e,t,n){var u;let s=0,a=e-bs(e,n),o=t-bs(t,n);for(let d=0;d=0&&e0?u=s-bs(s,a):u=t,e=n&&ut?"A":"B"}function sx(e,t,n,s,a,o){let u=e,d=t,f="";for(;(u!==n||d!==s)&&d>=0&&do.cols-1?(f+=o.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!a&&u<0&&(f+=o.buffer.translateBufferLineToString(d,!1,0,e+1),u=o.cols-1,e=u,d--);return f+o.buffer.translateBufferLineToString(d,!1,e,u)}function za(e,t){let n=t?"O":"[";return se.ESC+n+e}function ja(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 Iv(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 _d=50,ck=15,uk=50,hk=500,dk=" ",fk=new RegExp(dk,"g"),vf=class extends Pe{constructor(e,t,n,s,a,o,u,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=u,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new pe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new pe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new pe),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 ok(this._bufferService),this._activeSelectionMode=0,this._register(gt(()=>{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(fk," ")).join(tx?`\r +`))}},Dw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Rw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Nw=0,dd=class{constructor(e){this.value=e,this.id=Nw++}},Mw=2,Bw,pe=class{constructor(t){var n,s,a,o;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new Tw((t==null?void 0:t.onListenerError)??wc,((s=this._options)==null?void 0:s.leakWarningThreshold)??Ew):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new kw(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,n,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||s.call(n),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,n,s)=>{var d,f,h,_,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new Rw(`${y}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((d=this._options)==null?void 0:d.onListenerError)||wc)(S),He.None}if(this._disposed)return He.None;n&&(t=t.bind(n));let a=new dd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=Aw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof dd?(this._deliveryQueue??(this._deliveryQueue=new Lw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=a,(g=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||g.call(_,this)),this._size++;let u=yt(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ur?s.add(u):Array.isArray(s)&&s.push(u),u}),this._event}_removeListener(t){var o,u,d,f;if((u=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||u.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,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*Mw<=n.length){let h=0;for(let _=0;_0}},Lw=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}},tf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new pe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new pe,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}};tf.INSTANCE=new tf;var Ff=tf;function Ow(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ff.INSTANCE.onDidChangeZoomLevel;function zw(e){return Ff.INSTANCE.getZoomFactor(e)}Ff.INSTANCE.onDidChangeFullscreen;var bl=typeof navigator=="object"?navigator.userAgent:"",nf=bl.indexOf("Firefox")>=0,jw=bl.indexOf("AppleWebKit")>=0,qf=bl.indexOf("Chrome")>=0,Hw=!qf&&bl.indexOf("Safari")>=0;bl.indexOf("Electron/")>=0;bl.indexOf("Android")>=0;var fd=!1;if(typeof rr.matchMedia=="function"){let e=rr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=rr.matchMedia("(display-mode: fullscreen)");fd=e.matches,Ow(rr,e,({matches:n})=>{fd&&t.matches||(fd=n)})}var ml="en",rf=!1,sf=!1,Cc=!1,Fb=!1,hc,kc=ml,wv=ml,Pw,xn,vs=globalThis,fi,vb;typeof vs.vscode<"u"&&typeof vs.vscode.process<"u"?fi=vs.vscode.process:typeof process<"u"&&typeof((vb=process==null?void 0:process.versions)==null?void 0:vb.node)=="string"&&(fi=process);var yb,Iw=typeof((yb=fi==null?void 0:fi.versions)==null?void 0:yb.electron)=="string",Uw=Iw&&(fi==null?void 0:fi.type)==="renderer",bb;if(typeof fi=="object"){rf=fi.platform==="win32",sf=fi.platform==="darwin",Cc=fi.platform==="linux",Cc&&fi.env.SNAP&&fi.env.SNAP_REVISION,fi.env.CI||fi.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hc=ml,kc=ml;let e=fi.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);hc=t.userLocale,wv=t.osLocale,kc=t.resolvedLanguage||ml,Pw=(bb=t.languagePack)==null?void 0:bb.translationsConfigFile}catch{}Fb=!0}else typeof navigator=="object"&&!Uw?(xn=navigator.userAgent,rf=xn.indexOf("Windows")>=0,sf=xn.indexOf("Macintosh")>=0,(xn.indexOf("Macintosh")>=0||xn.indexOf("iPad")>=0||xn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Cc=xn.indexOf("Linux")>=0,(xn==null?void 0:xn.indexOf("Mobi"))>=0,kc=globalThis._VSCODE_NLS_LANGUAGE||ml,hc=navigator.language.toLowerCase(),wv=hc):console.error("Unable to resolve platform.");var qb=rf,Bn=sf,Fw=Cc,Cv=Fb,Ln=xn,Lr=kc,qw;(e=>{function t(){return Lr}e.value=t;function n(){return Lr.length===2?Lr==="en":Lr.length>=3?Lr[0]==="e"&&Lr[1]==="n"&&Lr[2]==="-":!1}e.isDefaultVariant=n;function s(){return Lr==="en"}e.isDefault=s})(qw||(qw={}));var Ww=typeof vs.postMessage=="function"&&!vs.importScripts;(()=>{if(Ww){let e=[];vs.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}),vs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var $w=!!(Ln&&Ln.indexOf("Chrome")>=0);Ln&&Ln.indexOf("Firefox")>=0;!$w&&Ln&&Ln.indexOf("Safari")>=0;Ln&&Ln.indexOf("Edg/")>=0;Ln&&Ln.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Cv||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Cv||cl&&cl.clipboard&&cl.clipboard.readText;var Wf=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}},pd=new Wf,kv=new Wf,Ev=new Wf,Yw=new Array(230),Wb;(e=>{function t(d){return pd.keyCodeToStr(d)}e.toString=t;function n(d){return pd.strToKeyCode(d)}e.fromString=n;function s(d){return kv.keyCodeToStr(d)}e.toUserSettingsUS=s;function a(d){return Ev.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function o(d){return kv.strToKeyCode(d)||Ev.strToKeyCode(d)}e.fromUserSettings=o;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pd.keyCodeToStr(d)}e.toElectronAccelerator=u})(Wb||(Wb={}));var Vw=class $b{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 $b&&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 Kw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kw=class{constructor(e){if(e.length===0)throw yw("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 nC?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:pi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Yb})})(iC||(iC={}));var nC=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?Yb:(this._emitter||(this._emitter=new pe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$f=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 Xd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Xd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},rC=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 Xd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=yt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},sC;(e=>{async function t(s){let a,o=await Promise.all(s.map(u=>u.then(d=>d,d=>{a||(a=d)})));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(u){o(u)}})}e.withAsyncBody=n})(sC||(sC={}));var Rv=class hn{static fromArray(t){return new hn(n=>{n.emitMany(t)})}static fromPromise(t){return new hn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new hn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new hn(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 pe,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 hn(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return hn.map(this,t)}static filter(t,n){return new hn(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return hn.filter(this,t)}static coalesce(t){return hn.filter(t,n=>!!n)}coalesce(){return hn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return hn.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())}};Rv.EMPTY=Rv.fromArray([]);var{getWindow:Mn,getWindowId:lC,onDidRegisterWindow:aC}=(function(){let e=new Map,t={window:rr,disposables:new Ur};e.set(rr.vscodeWindowId,t);let n=new pe,s=new pe,a=new pe;function o(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return He.None;let d=new Ur,f={window:u,disposables:d.add(new Ur)};return e.set(u.vscodeWindowId,f),d.add(yt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(Ae(u,Jt.BEFORE_UNLOAD,()=>{a.fire(u)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:o,getWindow(u){var h;let d=u;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=u;return f!=null&&f.view?f.view.window:rr},getDocument(u){return Mn(u).document}}})(),oC=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 Ae(e,t,n,s){return new oC(e,t,n,s)}var Nv=function(e,t,n,s){return Ae(e,t,n,s)},Yf,cC=class extends rC{constructor(e){super(),this.defaultTarget=e&&Mn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Mv=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){wc(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 u=e.get(o)??[];for(t.set(o,u),e.set(o,[]),s.set(o,!0);u.length>0;)u.sort(Mv.sort),u.shift().execute();s.set(o,!1)};Yf=(o,u,d=0)=>{let f=lC(o),h=new Mv(u,d),_=e.get(f);return _||(_=[],e.set(f,_)),_.push(h),n.get(f)||(n.set(f,!0),o.requestAnimationFrame(()=>a(f))),h}})();function uC(e){let t=e.getBoundingClientRect(),n=Mn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Jt={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"},hC=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=zi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=zi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=zi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=zi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=zi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=zi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=zi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=zi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=zi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=zi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=zi(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=zi(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=zi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=zi(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 zi(e){return typeof e=="number"?`${e}px`:e}function Ma(e){return new hC(e)}var Vb=class{constructor(){this._hooks=new Ur,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(yt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Mn(e)}this._hooks.add(Ae(o,Jt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ae(o,Jt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function dC(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(...u){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,u)}),this[o]}}var Rn;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Rn||(Rn={}));var Ta=class _i extends He{constructor(){super(),this.dispatched=!1,this.targets=new Sv,this.ignoreTargets=new Sv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(pi.runAndSubscribe(aC,({window:t,disposables:n})=>{n.add(Ae(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ae(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ae(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:rr,disposables:this._store}))}static addTarget(t){if(!_i.isTouchDevice())return He.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.targets.push(t);return yt(n)}static ignoreTarget(t){if(!_i.isTouchDevice())return He.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.ignoreTargets.push(t);return yt(n)}static isTouchDevice(){return"ontouchstart"in rr||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=_i.HOLD_DELAY&&Math.abs(f.initialPageX-Ki(f.rollingPageX))<30&&Math.abs(f.initialPageY-Ki(f.rollingPageY))<30){let _=this.newGestureEvent(Rn.Contextmenu,f.initialTarget);_.pageX=Ki(f.rollingPageX),_.pageY=Ki(f.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=Ki(f.rollingPageX),g=Ki(f.rollingPageY),y=Ki(f.rollingTimestamps)-f.rollingTimestamps[0],b=_-f.rollingPageX[0],S=g-f.rollingPageY[0],T=[...this.targets].filter(L=>f.initialTarget instanceof Node&&L.contains(f.initialTarget));this.inertia(t,T,s,Math.abs(b)/y,b>0?1:-1,_,Math.abs(S)/y,S>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(Rn.End,f.initialTarget)),delete this.activeTouches[d.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===Rn.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>_i.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Rn.Change||t.type===Rn.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,u,d,f,h){this.handle=Yf(t,()=>{let _=Date.now(),g=_-s,y=0,b=0,S=!0;a+=_i.SCROLL_FRICTION*g,d+=_i.SCROLL_FRICTION*g,a>0&&(S=!1,y=o*a*g),d>0&&(S=!1,b=f*d*g);let T=this.newGestureEvent(Rn.Change);T.translationX=y,T.translationY=b,n.forEach(L=>L.dispatchEvent(T)),S||this.inertia(t,n,_,a,o,u+y,d,f,h+b)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(o.pageX),u.rollingPageY.push(o.pageY),u.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,At([dC],Ta,"isTouchDevice",1);var fC=Ta,Vf=class extends He{onclick(e,t){this._register(Ae(e,Jt.CLICK,n=>t(new dc(Mn(e),n))))}onmousedown(e,t){this._register(Ae(e,Jt.MOUSE_DOWN,n=>t(new dc(Mn(e),n))))}onmouseover(e,t){this._register(Ae(e,Jt.MOUSE_OVER,n=>t(new dc(Mn(e),n))))}onmouseleave(e,t){this._register(Ae(e,Jt.MOUSE_LEAVE,n=>t(new dc(Mn(e),n))))}onkeydown(e,t){this._register(Ae(e,Jt.KEY_DOWN,n=>t(new Tv(n))))}onkeyup(e,t){this._register(Ae(e,Jt.KEY_UP,n=>t(new Tv(n))))}oninput(e,t){this._register(Ae(e,Jt.INPUT,t))}onblur(e,t){this._register(Ae(e,Jt.BLUR,t))}onfocus(e,t){this._register(Ae(e,Jt.FOCUS,t))}onchange(e,t){this._register(Ae(e,Jt.CHANGE,t))}ignoreGesture(e){return fC.ignoreTarget(e)}},Bv=11,pC=class extends Vf{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 Vb),this._register(Nv(this.bgDomNode,Jt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nv(this.domNode,Jt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cC),this._pointerdownScheduleRepeatTimer=this._register(new $f)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Mn(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()}},mC=class lf{constructor(t,n,s,a,o,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,u=u|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),d+o>u&&(d=u-o),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=u,this.scrollTop=d}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 lf(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 lf(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,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=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:u,scrollHeightChanged:d,scrollTopChanged:f}}},gC=class extends He{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new mC(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 Ov(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=Ov.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)))}},Lv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function md(e,t){let n=t-e;return function(s){return e+n*yC(s)}}function _C(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":"")))}},xC=140,Kb=class extends Vf{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 bC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vb),this._shouldRender=!0,this.domNode=Ma(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(Ae(this.domNode.domNode,Jt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new pC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Ma(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(Ae(this.slider.domNode,Jt.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=uC(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),u=Math.abs(o-n);if(qb&&u>xC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},Gb=class of{constructor(t,n,s,a,o,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new of(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 u=Math.max(0,s-t),d=Math.max(0,u-2*n),f=a>0&&a>s;if(!f)return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*d/a))),_=(d-h)/(a-s),g=o*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:_,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=of._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),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(a,u),1),h=Math.max(Math.min(o,d),1),_=Math.max(a,u),g=Math.max(o,d);_%f===0&&g%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};cf.INSTANCE=new cf;var EC=cf,TC=class extends Vf{constructor(e,t,n){super(),this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new pe),this.onWillScroll=this._onWillScroll.event,this._options=DC(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 wC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new SC(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=Ma(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ma(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ma(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 $f),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ys(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,Bn&&(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 Dv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ys(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Dv(n))};this._mouseWheelToDispose.push(Ae(this._listenOnDomNode,Jt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=EC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+o===0?u=o=0:Math.abs(o)>=Math.abs(u)?u=0:o=0),this._options.flipAxes&&([o,u]=[u,o]);let d=!Bn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(o){let _=zv*o,g=f.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(h,g)}if(u){let _=zv*u,g=f.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.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(),CC)}},AC=class extends TC{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 DC(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,Bn&&(t.className+=" mac"),t}var uf=class extends He{constructor(e,t,n,s,a,o,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new gC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Yf(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new AC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),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(pi.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(yt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(yt(()=>this._styleElement.remove())),this._register(pi.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}};uf=At([ge(2,ki),ge(3,sr),ge(4,Db),ge(5,yl),ge(6,Ei),ge(7,lr)],uf);var hf=class extends He{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(yt(()=>{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()}};hf=At([ge(1,ki),ge(2,sr),ge(3,qa),ge(4,lr)],hf);var RC=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)}},An={full:0,left:0,center:0,right:0},Or={full:0,left:0,center:0,right:0},ga={full:0,left:0,center:0,right:0},Mc=class extends He{constructor(e,t,n,s,a,o,u,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new RC,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(yt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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);Or.full=this._canvas.width,Or.left=e,Or.center=t,Or.right=e,this._refreshDrawHeightConstants(),ga.full=1,ga.left=1,ga.center=1+Or.left,ga.right=1+Or.left+Or.center}_refreshDrawHeightConstants(){An.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);An.left=t,An.center=t,An.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*An.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(ga[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-An[e.position||"full"]/2),Or[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+An[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}))}};Mc=At([ge(2,ki),ge(3,qa),ge(4,lr),ge(5,Ei),ge(6,yl),ge(7,sr)],Mc);var se;(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=""))(se||(se={}));var Ec;(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=""))(Ec||(Ec={}));var Xb;(e=>e.ST=`${se.ESC}\\`)(Xb||(Xb={}));var df=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)}}};df=At([ge(2,ki),ge(3,Ei),ge(4,Ss),ge(5,lr)],df);var ei=0,ti=0,ii=0,Et=0,jv={css:"#00000000",rgba:0},Pt;(e=>{function t(a,o,u,d){return d!==void 0?`#${us(a)}${us(o)}${us(u)}${us(d)}`:`#${us(a)}${us(o)}${us(u)}`}e.toCss=t;function n(a,o,u,d=255){return(a<<24|o<<16|u<<8|d)>>>0}e.toRgba=n;function s(a,o,u,d){return{css:e.toCss(a,o,u,d),rgba:e.toRgba(a,o,u,d)}}e.toColor=s})(Pt||(Pt={}));var gt;(e=>{function t(f,h){if(Et=(h.rgba&255)/255,Et===1)return{css:h.css,rgba:h.rgba};let _=h.rgba>>24&255,g=h.rgba>>16&255,y=h.rgba>>8&255,b=f.rgba>>24&255,S=f.rgba>>16&255,T=f.rgba>>8&255;ei=b+Math.round((_-b)*Et),ti=S+Math.round((g-S)*Et),ii=T+Math.round((y-T)*Et);let L=Pt.toCss(ei,ti,ii),D=Pt.toRgba(ei,ti,ii);return{css:L,rgba:D}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,h,_){let g=Tc.ensureContrastRatio(f.rgba,h.rgba,_);if(g)return Pt.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=s;function a(f){let h=(f.rgba|255)>>>0;return[ei,ti,ii]=Tc.toChannels(h),{css:Pt.toCss(ei,ti,ii),rgba:h}}e.opaque=a;function o(f,h){return Et=Math.round(h*255),[ei,ti,ii]=Tc.toChannels(f.rgba),{css:Pt.toCss(ei,ti,ii,Et),rgba:Pt.toRgba(ei,ti,ii,Et)}}e.opacity=o;function u(f,h){return Et=f.rgba&255,o(f,Et*h/255)}e.multiplyOpacity=u;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(gt||(gt={}));var xt;(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 ei=parseInt(a.slice(1,2).repeat(2),16),ti=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),Pt.toColor(ei,ti,ii);case 5:return ei=parseInt(a.slice(1,2).repeat(2),16),ti=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),Et=parseInt(a.slice(4,5).repeat(2),16),Pt.toColor(ei,ti,ii,Et);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 ei=parseInt(o[1]),ti=parseInt(o[2]),ii=parseInt(o[3]),Et=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Pt.toColor(ei,ti,ii,Et);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),[ei,ti,ii,Et]=t.getImageData(0,0,1,1).data,Et!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Pt.toRgba(ei,ti,ii,Et),css:a}}e.toColor=s})(xt||(xt={}));var Si;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let u=s/255,d=a/255,f=o/255,h=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+_*.7152+g*.0722}e.relativeLuminance2=n})(Si||(Si={}));var Tc;(e=>{function t(u,d){if(Et=(d&255)/255,Et===1)return d;let f=d>>24&255,h=d>>16&255,_=d>>8&255,g=u>>24&255,y=u>>16&255,b=u>>8&255;return ei=g+Math.round((f-g)*Et),ti=y+Math.round((h-y)*Et),ii=b+Math.round((_-b)*Et),Pt.toRgba(ei,ti,ii)}e.blend=t;function n(u,d,f){let h=Si.relativeLuminance(u>>8),_=Si.relativeLuminance(d>>8);if(tr(h,_)>8));if(S>8));return S>L?b:T}return b}let g=a(u,d,f),y=tr(h,Si.relativeLuminance(g>>8));if(y>8));return y>S?g:b}return g}}e.ensureContrastRatio=n;function s(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));for(;T0||b>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));return(y<<24|b<<16|S<<8|255)>>>0}e.reduceLuminance=s;function a(u,d,f){let h=u>>24&255,_=u>>16&255,g=u>>8&255,y=d>>24&255,b=d>>16&255,S=d>>8&255,T=tr(Si.relativeLuminance2(y,b,S),Si.relativeLuminance2(h,_,g));for(;T>>0}e.increaseLuminance=a;function o(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=o})(Tc||(Tc={}));function us(e){let t=e.toString(16);return t.length<2?"0"+t:t}function tr(e,t){return e1){let _=this._getJoinedRanges(s,u,o,t,a);for(let g=0;g<_.length;g++)n.push(_[g])}a=h,u=o,d=this._workCell.fg,f=this._workCell.bg}o+=this._workCell.getChars().length||Ir.length}if(this._bufferService.cols-a>1){let h=this._getJoinedRanges(s,u,o,t,a);for(let _=0;_=z,j=q,U=this._workCell;if(y.length>0&&q===y[0][0]&&k){let oe=y.shift(),Se=this._isCellInSelection(oe[0],t);for(X=oe[0]+1;X=oe[1]),k?(A=!0,U=new NC(this._workCell,e.translateToString(!0,oe[0],oe[1]),oe[1]-oe[0]),j=oe[1]-1,G=U.getWidth()):z=oe[1]}let le=this._isCellInSelection(q,t),E=n&&q===o,R=F&&q>=h&&q<=_,Y=!1;this._decorationService.forEachDecorationAtCell(q,t,void 0,oe=>{Y=!0});let w=U.getChars()||Ir;if(w===" "&&(U.isUnderline()||U.isOverline())&&(w=" "),me=G*d-f.get(w,U.isBold(),U.isItalic()),!T)T=this._document.createElement("span");else if(L&&(le&&ue||!le&&!ue&&U.bg===P)&&(le&&ue&&b.selectionForeground||U.fg===J)&&U.extended.ext===I&&R===M&&me===Q&&!E&&!A&&!Y&&k){U.isInvisible()?D+=Ir:D+=w,L++;continue}else L&&(T.textContent=D),T=this._document.createElement("span"),L=0,D="";if(P=U.bg,J=U.fg,I=U.extended.ext,M=R,Q=me,ue=le,A&&o>=q&&o<=j&&(o=q),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&te.push("xterm-cursor-blink"),te.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline");break}}if(U.isBold()&&te.push("xterm-bold"),U.isItalic()&&te.push("xterm-italic"),U.isDim()&&te.push("xterm-dim"),U.isInvisible()?D=Ir:D=U.getChars()||Ir,U.isUnderline()&&(te.push(`xterm-underline-${U.extended.underlineStyle}`),D===" "&&(D=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Fa.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let oe=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&oe<8&&(oe+=8),T.style.textDecorationColor=b.ansi[oe].css}U.isOverline()&&(te.push("xterm-overline"),D===" "&&(D=" ")),U.isStrikethrough()&&te.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let V=U.getFgColor(),he=U.getFgColorMode(),ae=U.getBgColor(),_e=U.getBgColorMode(),De=!!U.isInverse();if(De){let oe=V;V=ae,ae=oe;let Se=he;he=_e,_e=Se}let xe,Ke,ct=!1;this._decorationService.forEachDecorationAtCell(q,t,void 0,oe=>{oe.options.layer!=="top"&&ct||(oe.backgroundColorRGB&&(_e=50331648,ae=oe.backgroundColorRGB.rgba>>8&16777215,xe=oe.backgroundColorRGB),oe.foregroundColorRGB&&(he=50331648,V=oe.foregroundColorRGB.rgba>>8&16777215,Ke=oe.foregroundColorRGB),ct=oe.options.layer==="top")}),!ct&&le&&(xe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ae=xe.rgba>>8&16777215,_e=50331648,ct=!0,b.selectionForeground&&(he=50331648,V=b.selectionForeground.rgba>>8&16777215,Ke=b.selectionForeground)),ct&&te.push("xterm-decoration-top");let St;switch(_e){case 16777216:case 33554432:St=b.ansi[ae],te.push(`xterm-bg-${ae}`);break;case 50331648:St=Pt.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(T,`background-color:#${Hv((ae>>>0).toString(16),"0",6)}`);break;case 0:default:De?(St=b.foreground,te.push("xterm-bg-257")):St=b.background}switch(xe||U.isDim()&&(xe=gt.multiplyOpacity(St,.5)),he){case 16777216:case 33554432:U.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(T,St,b.ansi[V],U,xe,void 0)||te.push(`xterm-fg-${V}`);break;case 50331648:let oe=Pt.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(T,St,oe,U,xe,Ke)||this._addStyle(T,`color:#${Hv(V.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(T,St,b.foreground,U,xe,Ke)||De&&te.push("xterm-fg-257")}te.length&&(T.className=te.join(" "),te.length=0),!E&&!A&&!Y&&k?L++:T.textContent=D,me!==this.defaultSpacing&&(T.style.letterSpacing=`${me}px`),g.push(T),q=j}return T&&L&&(T.textContent=D),g}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||LC(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!a&&!o&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=gt.ensureContrastRatio(a||t,o||n,f),u.setColor((a||t).rgba,(o||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.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]}};ff=At([ge(1,Mb),ge(2,Ei),ge(3,sr),ge(4,Ss),ge(5,qa),ge(6,yl)],ff);function Hv(e,t,n){for(;e.length0&&(this._flat[s]=u),u}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let u=0;t&&(u|=1),n&&(u|=2),o=this._measure(e,u),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}},jC=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,u=n[1]-a,d=Math.max(o,0),f=Math.min(u,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,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 HC(){return new jC}var gd="xterm-dom-renderer-owner-",un="xterm-rows",pc="xterm-fg-",Pv="xterm-bg-",_a="xterm-focus",mc="xterm-selection",PC=1,pf=class extends He{constructor(e,t,n,s,a,o,u,d,f,h,_,g,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=u,this._charSizeService=f,this._optionsService=h,this._bufferService=_,this._coreService=g,this._coreBrowserService=y,this._themeService=b,this._terminalClass=PC++,this._rowElements=[],this._selectionRenderModel=HC(),this.onRequestRedraw=this._register(new pe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(un),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(mc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(ff,document),this._element.classList.add(gd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(yt(()=>{this._element.classList.remove(gd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new zC(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} .${un} 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} .${un} { 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} .${un} .xterm-dim { color: ${gt.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} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${un}.${_a} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${un} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${mc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,u]of e.ansi.entries())t+=`${this._terminalSelector} .${pc}${o} { color: ${u.css}; }${this._terminalSelector} .${pc}${o}.xterm-dim { color: ${gt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Pv}${o} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${pc}257 { color: ${gt.opaque(e.background).css}; }${this._terminalSelector} .${pc}257.xterm-dim { color: ${gt.multiplyOpacity(gt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Pv}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(_a),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(_a),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,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(o,f?t[0]:e[0],f?e[0]:t[0],u-o+1))}else{let f=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(o,f,h));let _=u-o-1;if(d.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==u){let g=a===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return o+u>this.dimensions.css.canvas.width&&(u=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=`${u}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,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,_=this._rowElements[f],g=n.lines.get(h);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,h,h===s,u,d,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gd}${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 u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,a-1),_=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let S=b+d.ydisp,T=this._rowElements[b],L=d.lines.get(S);if(!T||!L)break;T.replaceChildren(...this._rowFactory.createRow(L,S,S===f,g,y,h,_,this.dimensions.css.cell.width,this._widthCache,o?b===n?e:0:-1,o?(b===s?t:a)-1:-1))}}};pf=At([ge(7,If),ge(8,qc),ge(9,Ei),ge(10,ki),ge(11,Ss),ge(12,sr),ge(13,yl)],pf);var mf=class extends He{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new pe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new UC(this._optionsService))}catch{this._measureStrategy=this._register(new IC(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())}};mf=At([ge(2,Ei)],mf);var Zb=class extends He{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)}},IC=class extends Zb{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}},UC=class extends Zb{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}},FC=class extends He{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 qC(this._window)),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new pe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(pi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ae(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ae(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}},qC=class extends He{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new _l),this._onDprChange=this._register(new pe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(yt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ae(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)}},WC=class extends He{constructor(){super(),this.linkProviders=[],this._register(yt(()=>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 Kf(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),u=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-u]}function $C(e,t,n,s,a,o,u,d,f){if(!o)return;let h=Kf(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?u/2:0))/u),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),s+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var gf=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return $C(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=Kf(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])}}};gf=At([ge(0,lr),ge(1,qc)],gf);var YC=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=[]}},Qb={};iw(Qb,{getSafariVersion:()=>KC,isChromeOS:()=>ix,isFirefox:()=>Jb,isIpad:()=>GC,isIphone:()=>XC,isLegacyEdge:()=>VC,isLinux:()=>Gf,isMac:()=>Lc,isNode:()=>Wc,isSafari:()=>ex,isWindows:()=>tx});var Wc=typeof process<"u"&&"title"in process,Wa=Wc?"node":navigator.userAgent,$a=Wc?"node":navigator.platform,Jb=Wa.includes("Firefox"),VC=Wa.includes("Edge"),ex=/^((?!chrome|android).)*safari/i.test(Wa);function KC(){if(!ex)return 0;let e=Wa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Lc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($a),GC=$a==="iPad",XC=$a==="iPhone",tx=["Windows","Win16","Win32","WinCE"].includes($a),Gf=$a.indexOf("Linux")>=0,ix=/\bCrOS\b/.test(Wa),nx=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()}},ZC=class extends nx{_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())}}},QC=class extends nx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Oc=!Wc&&"requestIdleCallback"in window?QC:ZC,JC=class{constructor(){this._queue=new Oc}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_f=class extends He{constructor(e,t,n,s,a,o,u,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new _l),this._pausedResizeTask=new JC,this._observerDisposable=this._register(new _l),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 pe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new pe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new pe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new YC((h,_)=>this._renderRows(h,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ek(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(yt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.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=yt(()=>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()}};_f=At([ge(2,Ei),ge(3,qc),ge(4,Ss),ge(5,qa),ge(6,ki),ge(7,sr),ge(8,yl)],_f);var ek=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 tk(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return rk(a,o,e,t,n,s)+$c(o,t,n,s)+sk(a,o,e,t,n,s);let u;if(o===t)return u=a>e?"D":"C",ja(Math.abs(a-e),za(u,s));u=o>t?"D":"C";let d=Math.abs(o-t),f=nk(o>t?e:a,n)+(d-1)*n.cols+1+ik(o>t?a:e);return ja(f,za(u,s))}function ik(e,t){return e-1}function nk(e,t){return t.cols-e}function rk(e,t,n,s,a,o){return $c(t,s,a,o).length===0?"":ja(sx(e,t,e,t-bs(t,a),!1,a).length,za("D",o))}function $c(e,t,n,s){let a=e-bs(e,n),o=t-bs(t,n),u=Math.abs(a-o)-lk(e,t,n);return ja(u,za(rx(e,t),s))}function sk(e,t,n,s,a,o){let u;$c(t,s,a,o).length>0?u=s-bs(s,a):u=t;let d=s,f=ak(e,t,n,s,a,o);return ja(sx(e,u,n,d,f==="C",a).length,za(f,o))}function lk(e,t,n){var u;let s=0,a=e-bs(e,n),o=t-bs(t,n);for(let d=0;d=0&&e0?u=s-bs(s,a):u=t,e=n&&ut?"A":"B"}function sx(e,t,n,s,a,o){let u=e,d=t,f="";for(;(u!==n||d!==s)&&d>=0&&do.cols-1?(f+=o.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!a&&u<0&&(f+=o.buffer.translateBufferLineToString(d,!1,0,e+1),u=o.cols-1,e=u,d--);return f+o.buffer.translateBufferLineToString(d,!1,e,u)}function za(e,t){let n=t?"O":"[";return se.ESC+n+e}function ja(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 Iv(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 _d=50,ck=15,uk=50,hk=500,dk=" ",fk=new RegExp(dk,"g"),vf=class extends He{constructor(e,t,n,s,a,o,u,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=u,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new pn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new pe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new pe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new pe),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 ok(this._bufferService),this._activeSelectionMode=0,this._register(yt(()=>{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(fk," ")).join(tx?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Gf&&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=Iv(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=Kf(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,-_d),_d),t/=_d,t/Math.abs(t)+Math.round(t*(ck-1)))}shouldForceSelection(e){return Lc?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(),uk)}_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&&!(Lc&&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 u=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(o,e[0]),f=d,h=e[0]-d,_=0,g=0,y=0,b=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;f1&&(b+=X-1,f+=X-1);B>0&&d>0&&!this._isCharWordSeparator(o.loadCell(B-1,this._workCell));){o.loadCell(B-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,B--):P>1&&(y+=P-1,d-=P-1),d--,B--}for(;D1&&(b+=P-1,f+=P-1),f++,D++}}f++;let S=d+h-_+y,T=Math.min(this._bufferService.cols,f-d+_+g-y-b);if(!(!t&&u.slice(d,f).trim()==="")){if(n&&S===0&&o.getCodePoint(0)!==32){let B=a.lines.get(e[1]-1);if(B&&o.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let X=this._bufferService.cols-D.start;S-=X,T+=X}}}if(s&&S+T===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let B=a.lines.get(e[1]+1);if(B!=null&&B.isWrapped&&B.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(T+=D.length)}}return{start:S,length:T}}}_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=Iv(n,this._bufferService.cols)}};vf=Ct([ge(3,wi),ge(4,Ss),ge(5,Uf),ge(6,Ci),ge(7,lr),ge(8,sr)],vf);var Uv=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={}}},Fv=class{constructor(){this._color=new Uv,this._css=new Uv}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()}},Ut=Object.freeze((()=>{let e=[vt.toColor("#2e3436"),vt.toColor("#cc0000"),vt.toColor("#4e9a06"),vt.toColor("#c4a000"),vt.toColor("#3465a4"),vt.toColor("#75507b"),vt.toColor("#06989a"),vt.toColor("#d3d7cf"),vt.toColor("#555753"),vt.toColor("#ef2929"),vt.toColor("#8ae234"),vt.toColor("#fce94f"),vt.toColor("#729fcf"),vt.toColor("#ad7fa8"),vt.toColor("#34e2e2"),vt.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:zt.toCss(s,a,o),rgba:zt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:zt.toCss(s,s,s),rgba:zt.toRgba(s,s,s)})}return e})()),ps=vt.toColor("#ffffff"),Aa=vt.toColor("#000000"),qv=vt.toColor("#ffffff"),Wv=Aa,va={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},pk=ps,yf=class extends Pe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Fv,this._halfContrastCache=new Fv,this._onChangeColors=this._register(new pe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ps,background:Aa,cursor:qv,cursorAccent:Wv,selectionForeground:void 0,selectionBackgroundTransparent:va,selectionBackgroundOpaque:pt.blend(Aa,va),selectionInactiveBackgroundTransparent:va,selectionInactiveBackgroundOpaque:pt.blend(Aa,va),scrollbarSliderBackground:pt.opacity(ps,.2),scrollbarSliderHoverBackground:pt.opacity(ps,.4),scrollbarSliderActiveBackground:pt.opacity(ps,.5),overviewRulerBorder:ps,ansi:Ut.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=st(e.foreground,ps),t.background=st(e.background,Aa),t.cursor=pt.blend(t.background,st(e.cursor,qv)),t.cursorAccent=pt.blend(t.background,st(e.cursorAccent,Wv)),t.selectionBackgroundTransparent=st(e.selectionBackground,va),t.selectionBackgroundOpaque=pt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,jv):void 0,t.selectionForeground===jv&&(t.selectionForeground=void 0),pt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pt.opacity(t.selectionBackgroundTransparent,.3)),pt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,pt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,pt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,pt.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,pk),t.ansi=Ut.slice(),t.ansi[0]=st(e.black,Ut[0]),t.ansi[1]=st(e.red,Ut[1]),t.ansi[2]=st(e.green,Ut[2]),t.ansi[3]=st(e.yellow,Ut[3]),t.ansi[4]=st(e.blue,Ut[4]),t.ansi[5]=st(e.magenta,Ut[5]),t.ansi[6]=st(e.cyan,Ut[6]),t.ansi[7]=st(e.white,Ut[7]),t.ansi[8]=st(e.brightBlack,Ut[8]),t.ansi[9]=st(e.brightRed,Ut[9]),t.ansi[10]=st(e.brightGreen,Ut[10]),t.ansi[11]=st(e.brightYellow,Ut[11]),t.ansi[12]=st(e.brightBlue,Ut[12]),t.ansi[13]=st(e.brightMagenta,Ut[13]),t.ansi[14]=st(e.brightCyan,Ut[14]),t.ansi[15]=st(e.brightWhite,Ut[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-u.index),s=[];for(let o of n){let u=this._services.get(o.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(u)}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)}},_k={trace:0,debug:1,info:2,warn:3,error:4,off:5},vk="xterm.js: ",bf=class extends Pe{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=_k[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*He+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*He+0]=t|2097152|n[2]<<22):this._data[t*He+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*He+0]>>22}hasWidth(t){return this._data[t*He+0]&12582912}getFg(t){return this._data[t*He+1]}getBg(t){return this._data[t*He+2]}hasContent(t){return this._data[t*He+0]&4194303}getCodePoint(t){let n=this._data[t*He+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*He+0]&2097152}getString(t){let n=this._data[t*He+0];return n&2097152?this._combined[t]:n&2097151?Hr(n&2097151):""}isProtected(t){return this._data[t*He+2]&536870912}loadCell(t,n){return gc=t*He,n.content=this._data[gc+0],n.fg=this._data[gc+1],n.bg=this._data[gc+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*He+0]=n.content,this._data[t*He+1]=n.fg,this._data[t*He+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*He+0]=n|s<<22,this._data[t*He+1]=a.fg,this._data[t*He+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*He+0];a&2097152?this._combined[t]+=Hr(n):a&2097151?(this._combined[t]=Hr(a&2097151)+Hr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*He+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[d]}let o=Object.keys(this._extendedAttrs);for(let u=0;u=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*vd=0;--t)if(this._data[t*He+0]&4194303)return t+(this._data[t*He+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*He+0]&4194303||this._data[t*He+2]&50331648)return t+(this._data[t*He+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let u=t._data;if(o)for(let f=a-1;f>=0;f--){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 yk(e,t,n,s,a,o){let u=[];for(let d=0;d=d&&s0&&(B>g||_[B].getTrimmedLength()===0);B--)T++;T>0&&(u.push(d+_.length-T),u.push(T)),d+=_.length-1}return u}function bk(e,t){let n=[],s=0,a=t[s],o=0;for(let u=0;uHa(e,h,t)).reduce((f,h)=>f+h),o=0,u=0,d=0;for(;df&&(o-=f,u++);let h=e[u].getWidth(o-1)===2;h&&o--;let _=h?n-1:n;s.push(_),d+=_}return s}function Ha(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 ax=class ox{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ox._nextId++,this._onDispose=this.register(new pe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ys(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ax._nextId=1;var wk=ax,Wt={},ms=Wt.B;Wt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Wt.A={"#":"£"};Wt.B=void 0;Wt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Wt.C=Wt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Wt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Wt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Wt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Wt.E=Wt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Wt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Wt.H=Wt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Yv=4294967295,Vv=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=Ot.clone(),this.savedCharset=ms,this.markers=[],this._nullCell=dn.fromCharData([0,kb,1,0]),this._whitespaceCell=dn.fromCharData([0,Ir,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Oc,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $v(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 Nc),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 Nc),this._whitespaceCell}getBlankLine(e,t){return new Da(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&&eYv?Yv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ot);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 $v(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ot),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 Da(e,n)));else for(let u=this._rows;u>t;u--)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(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,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=yk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ot),n);if(s.length>0){let a=bk(this.lines,s);xk(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ot),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),f.unshift(d);if(!n){let P=this.ybase+this.y;if(P>=u&&P0&&(a.push({start:u+f.length+o,newLines:b}),o+=b.length),f.push(...b);let S=_.length-1,T=_[S];T===0&&(S--,T=_[S]);let B=f.length-g-1,D=h;for(;B>=0;){let P=Math.min(D,T);if(f[S]===void 0)break;if(f[S].copyCellsFrom(f[B],D-P,T-P,P,!0),T-=P,T===0&&(S--,T=_[S]),D-=P,D===0){B--;let J=Math.max(B,0);D=Ha(f,J,this._cols)}}for(let P=0;P0;)this.ybase===0?this.y0){let u=[],d=[];for(let T=0;T=0;T--)if(g&&g.start>h+y){for(let B=g.newLines.length-1;B>=0;B--)this.lines.set(T--,g.newLines[B]);T++,u.push({index:h+1,amount:g.newLines.length}),y+=g.newLines.length,g=a[++_]}else this.lines.set(T,d[h--]);let b=0;for(let T=u.length-1;T>=0;T--)u[T].index+=b,this.lines.onInsertEmitter.fire(u[T]),b+=u[T].amount;let S=Math.max(0,f+o-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}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)}},Ck=class extends Pe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new pe),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 Vv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Vv(!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)}},cx=2,ux=1,xf=class extends Pe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new pe),this.onResize=this._onResize.event,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,cx),this.rows=Math.max(e.rawOptions.rows||0,ux),this.buffers=this._register(new Ck(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 u=n.lines.isFull;o===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=o-a+1;n.lines.shiftElements(a+1,u-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))}};xf=Ct([ge(0,Ci)],xf);var ul={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:Lc,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},kk=["normal","bold","100","200","300","400","500","600","700","800","900"],Ek=class extends Pe{constructor(e){super(),this._onOptionChange=this._register(new pe),this.onOptionChange=this._onOptionChange.event;let t={...ul};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(gt(()=>{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 ul))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in ul))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=ul[e]),!Tk(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=kk.includes(t)?t:ul[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 Tk(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 Kv=Object.freeze({insertMode:!1}),Gv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Sf=class extends Pe{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 pe),this.onData=this._onData.event,this._onUserInput=this._register(new pe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new pe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new pe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ra(Kv),this.decPrivateModes=Ra(Gv)}reset(){this.modes=Ra(Kv),this.decPrivateModes=Ra(Gv)}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))}};Sf=Ct([ge(0,wi),ge(1,Rb),ge(2,Ci)],Sf);var Xv={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 yd(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 bd=String.fromCharCode,Zv={DEFAULT:e=>{let t=[yd(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${bd(t[0])}${bd(t[1])}${bd(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yd(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yd(e,!0)};${e.x};${e.y}${t}`}},wf=class extends Pe{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 pe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Xv))this.addProtocol(s,Xv[s]);for(let s of Object.keys(Zv))this.addEncoding(s,Zv[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)}};wf=Ct([ge(0,wi),ge(1,Ss),ge(2,Ci)],wf);var xd=[[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]],Ak=[[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]],Ft;function Dk(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=_s.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return _s.createPropertyValue(0,n,s)}},_s=class Ac{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new pe,this.onChange=this._onChange.event;let t=new Rk;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(u);let h=t.charCodeAt(o);56320<=h&&h<=57343?u=(u-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let d=this.charProperties(u,s),f=Ac.extractWidth(d);Ac.extractShouldJoin(d)&&(f-=Ac.extractWidth(s)),n+=f,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},Nk=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 Qv(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 ya=2147483647,Mk=256,hx=class Cf{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>Mk)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 Cf;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>ya?ya: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>ya?ya: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,ya):t}},ba=[],Bk=class{constructor(){this._state=0,this._active=ba,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=ba}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=ba,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ba,!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",Fc(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=ba,this._id=-1,this._state=0}}},Yi=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+=Fc(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}},xa=[],Lk=class{constructor(){this._handlers=Object.create(null),this._active=xa,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xa}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=xa,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||xa,!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",Fc(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=xa,this._ident=0}},Na=new hx;Na.addParam(0);var Jv=class{constructor(e){this._handler=e,this._data="",this._params=Na,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Na,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Fc(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=Na,this._data="",this._hitLimit=!1,n));return this._params=Na,this._data="",this._hitLimit=!1,t}},Ok=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;af),n=(d,f)=>t.slice(d,f),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in o)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,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(un,0,2,0),e.add(un,8,5,8),e.add(un,6,0,6),e.add(un,11,0,11),e.add(un,13,13,13),e})(),jk=class extends Pe{constructor(e=zk){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 hx,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(gt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Bk),this._dcsParser=this._register(new Lk),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,u;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 d=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(u=d[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(u=d[f](),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;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],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;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 d=o;d>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=t||(s=e[y])<32||s>126&&s=0&&(u=f[h](this._params),u!==!0);h--)if(u instanceof Promise)return this._preserveStack(3,f,h,a,d),u;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(++d47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],g=_?_.length-1:-1;for(;g>=0&&(u=_[g](),u!==!0);g--)if(u instanceof Promise)return this._preserveStack(4,_,g,a,d),u;g<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s=t||(s=e[y])<32||s>127&&s>4:o>>8}return s}}function Sd(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 Ik(e,t=16){let[n,s,a]=e;return`rgb:${Sd(n,t)}/${Sd(s,t)}/${Sd(a,t)}`}var Uk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zr=131072,ty=10;function iy(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 ny=5e3,ry=0,Fk=class extends Pe{constructor(e,t,n,s,a,o,u,d,f=new jk){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=u,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new aw,this._utf8Decoder=new ow,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ot.clone(),this._eraseAttrDataInternal=Ot.clone(),this._onRequestBell=this._register(new pe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new pe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new pe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new pe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new pe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new pe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new pe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new pe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new pe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new pe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new pe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new pe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new pe),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 kf(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:_.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:_,data:g})}),this._parser.setDcsHandlerFallback((h,_,g)=>{_==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:_,payload:g})}),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(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ec.IND,()=>this.index()),this._parser.setExecuteHandler(Ec.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ec.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Yi(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Yi(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Yi(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Yi(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Yi(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Yi(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Yi(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Yi(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Yi(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Yi(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Yi(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Yi(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 Wt)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 Jv((h,_)=>this.requestStatusString(h,_)))}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"),ny))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ny} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,u=this._parseStack.paused;if(u){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>zr&&(o=this._parseStack.position+zr)}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.lengthzr)for(let h=o;h0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let y=this._parser.precedingJoinState;for(let b=t;bd){if(f){let D=g,X=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&g instanceof Da&&g.copyCellsFrom(D,X,0,B,!1);X=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(h&&(g.insertCells(this._activeBuffer.x,a-B,this._activeBuffer.getNullCell(_)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,_)),g.setCellFromCodepoint(this._activeBuffer.x++,s,a,_),a>0)for(;--a;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=y,this._activeBuffer.x0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>iy(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Jv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Yi(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 f=d;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,u=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:h,alt:_}=d,g=this._optionsService.rawOptions,y=(T,B)=>(u.triggerDataEvent(`${se.ESC}[${t?"":"?"}${T};${B}$y`),!0),b=T=>T?1:2,S=e.params[0];return t?S===2?y(S,4):S===4?y(S,b(u.modes.insertMode)):S===12?y(S,3):S===20?y(S,b(g.convertEol)):y(S,0):S===1?y(S,b(s.applicationCursorKeys)):S===3?y(S,g.windowOptions.setWinLines?f===80?2:f===132?1:0:0):S===6?y(S,b(s.origin)):S===7?y(S,b(s.wraparound)):S===8?y(S,3):S===9?y(S,b(a==="X10")):S===12?y(S,b(g.cursorBlink)):S===25?y(S,b(!u.isCursorHidden)):S===45?y(S,b(s.reverseWraparound)):S===66?y(S,b(s.applicationKeypad)):S===67?y(S,4):S===1e3?y(S,b(a==="VT200")):S===1002?y(S,b(a==="DRAG")):S===1003?y(S,b(a==="ANY")):S===1004?y(S,b(s.sendFocus)):S===1005?y(S,4):S===1006?y(S,b(o==="SGR")):S===1015?y(S,4):S===1016?y(S,b(o==="SGR_PIXELS")):S===1048?y(S,1):S===47||S===1047||S===1049?y(S,b(h===_)):S===2004?y(S,b(s.bracketedPasteMode)):S===2026?y(S,b(s.synchronizedOutput)):y(S,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Fa.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 u=e.getSubParams(t+o),d=0;do s[1]===5&&(a=1),s[o+d+1+a]=u[d];while(++d=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=Ot.fg,e.bg=Ot.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|=Ot.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ot.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|=Ot.fg&16777215,s.bg&=-67108864,s.bg|=Ot.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.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(`${se.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=Ot.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(!iy(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(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ty&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ty&&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(sy(o))if(a==="?")t.push({type:0,index:o});else{let u=ey(a);u&&t.push({type:1,index:o,color:u})}}}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=ey(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=Ot.clone(),this._eraseAttrDataInternal=Ot.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 dn;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(`${se.ESC}${u}${se.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)}},kf=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&&(ry=e,e=t,t=ry),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kf=Ct([ge(0,wi)],kf);function sy(e){return 0<=e&&e<256}var qk=5e7,ly=12,Wk=50,$k=class extends Pe{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 pe),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>qk)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 u=d=>performance.now()-n>=ly?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);a.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=ly)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Wk&&(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()}},Ef=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 d=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.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),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(u,o)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.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)))}};Ef=Ct([ge(0,wi)],Ef);var ay=!1,Yk=class extends Pe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new _l),this._onBinary=this._register(new pe),this.onBinary=this._onBinary.event,this._onData=this._register(new pe),this.onData=this._onData.event,this._onLineFeed=this._register(new pe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new pe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new pe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new pe),this._instantiationService=new gk,this.optionsService=this._register(new Ek(e)),this._instantiationService.setService(Ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(xf)),this._instantiationService.setService(wi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bf)),this._instantiationService.setService(Rb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Sf)),this._instantiationService.setService(Ss,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(wf)),this._instantiationService.setService(Db,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(_s)),this._instantiationService.setService(dw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Nk),this._instantiationService.setService(hw,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ef),this._instantiationService.setService(Nb,this._oscLinkService),this._inputHandler=this._register(new Fk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ui.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ui.forward(this._bufferService.onResize,this._onResize)),this._register(ui.forward(this.coreService.onData,this._onData)),this._register(ui.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 $k((t,n)=>this._inputHandler.parse(t,n))),this._register(ui.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new pe),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&&!ay&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ay=!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,cx),t=Math.max(t,ux),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(Qv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Qv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=gt(()=>{for(let t of e)t.dispose()})}}},Vk={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 Kk(e,t,n,s){var u;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=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.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=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=Vk[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)a.key=se.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(f);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),a.key=se.ESC+f,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=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var At=0,Gk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Oc,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Oc,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||(At=this._search(t),At===-1)||this._getKey(this._array[At])!==t)return!1;do if(this._array[At]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(At),!0;while(++Ata-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&&(At=this._search(e),!(At<0||At>=this._array.length)&&this._getKey(this._array[At])===e))do yield this._array[At];while(++At=this._array.length)&&this._getKey(this._array[At])===e))do t(this._array[At]);while(++At=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}},wd=0,oy=0,Xk=class extends Pe{constructor(){super(),this._decorations=new Gk(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new pe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new pe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(gt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Zk(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{wd=a.options.x??0,oy=wd+(a.options.width??1),e>=wd&&e=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)}},cy=20,zc=class extends Pe{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 Jk(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(Me(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(gt(()=>{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===cy+1&&(this._liveRegion.textContent+=$d.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),u=[],d=(o==null?void 0:o.translateToString(!0,void 0,void 0,u))||"",f=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,u)),h.setAttribute("aria-posinset",f),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 u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}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 d;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:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:f,offset:h})=>{let _=f instanceof Text?f.parentNode:f,g=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(_);if(!y)return console.warn("columns is null. Race condition?"),null;let b=h=this._terminal.cols&&(++g,b=0),{row:g,column:b}},o=a(t),u=a(n);if(!(!o||!u)){if(o.row>u.row||o.row===u.row&&o.column>=u.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(u.row-o.row)*this._terminal.cols-o.column+u.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;ys(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(Me(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Me(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Me(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Me(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(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,u]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):u.provideLinks(e.y,d=>{var h,_;if(this._isMouseOut)return;let f=d==null?void 0:d.map(g=>({link:g}));(h=this._activeProviderReplies)==null||h.set(o,f),n=this._checkLinkProviderResult(o,e,n),((_=this._activeProviderReplies)==null?void 0:_.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:u.link.range.end.x;for(let h=d;h<=f;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 u=0;uthis._linkAtPosition(d.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;uthis._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&e2(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,ys(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}}};Tf=Ct([ge(1,Uf),ge(2,lr),ge(3,wi),ge(4,Bb)],Tf);function e2(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 t2=class extends Yk{constructor(e={}){super(e),this._linkifier=this._register(new _l),this.browser=Qb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new _l),this._onCursorMove=this._register(new pe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new pe),this.onKey=this._onKey.event,this._onRender=this._register(new pe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new pe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new pe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new pe),this.onBell=this._onBell.event,this._onFocus=this._register(new pe),this._onBlur=this._register(new pe),this._onA11yCharEmitter=this._register(new pe),this._onA11yTabEmitter=this._register(new pe),this._onWillOpen=this._register(new pe),this._setup(),this._decorationService=this._instantiationService.createInstance(Xk),this._instantiationService.setService(qa,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(WC),this._instantiationService.setService(Bb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Vd)),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(ui.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ui.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ui.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ui.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(gt(()=>{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=pt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${Ik(a)}${Xb.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=zt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(u=>u[o]=zt.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(zc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.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(se.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,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"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(Me(this.element,"copy",t=>{this.hasSelection()&&sw(t,this._selectionService)}));let e=t=>lw(t,this.textarea,this.coreService,this.optionsService);this._register(Me(this.textarea,"paste",e)),this._register(Me(this.element,"paste",e)),Jb?this._register(Me(this.element,"mousedown",t=>{t.button===2&&yv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Me(this.element,"contextmenu",t=>{yv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Gf&&this._register(Me(this.element,"auxclick",t=>{t.button===1&&Cb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Me(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Me(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Me(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Me(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Me(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Me(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Me(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(Me(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",Wd.get()),ix||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(FC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(sr,this._coreBrowserService),this._register(Me(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Me(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(mf,this._document,this._helperContainer),this._instantiationService.setService(qc,this._charSizeService),this._themeService=this._instantiationService.createInstance(yf),this._instantiationService.setService(yl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Bc),this._instantiationService.setService(Mb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(_f,this.rows,this.screenElement)),this._instantiationService.setService(lr,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(df,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(gf),this._instantiationService.setService(Uf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Tf,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(uf,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(vf,this.element,this.screenElement,s)),this._instantiationService.setService(pw,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(ui.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(hf,this.screenElement)),this._register(Me(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(zc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mc,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mc,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(pf,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,y,b;let u=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!u)return!1;let d,f;switch(o.overrideType||o.type){case"mousemove":f=32,o.buttons===void 0?(d=3,o.button!==void 0&&(d=o.button<3?o.button:3)):d=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":f=0,d=o.button<3?o.button:3;break;case"mousedown":f=1,d=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let S=o.deltaY;if(S===0||e.coreMouseService.consumeWheelEvent(o,(y=(g=(_=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:_.device)==null?void 0:g.cell)==null?void 0:y.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;f=S<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:f,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(Me(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(Me(t,"wheel",o=>{var u,d,f,h,_;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=(f=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:h.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(o,!0);let g=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var 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){wb(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=Kk(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===se.ETX||n.key===se.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)&&(i2(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 dn)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},uy=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 r2(t)}getNullCell(){return new dn}},s2=class extends Pe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new pe),this.onBufferChange=this._onBufferChange.event,this._normal=new uy(this._core.buffers.normal,"normal"),this._alternate=new uy(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)}},l2=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)}},a2=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}},o2=["cols","rows"],Tn=0,c2=class extends Pe{constructor(e){super(),this._core=this._register(new t2(e)),this._addonManager=this._register(new n2),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(o2.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 l2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new a2(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 s2(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 Wd.get()},set promptLabel(e){Wd.set(e)},get tooMuchOutput(){return $d.get()},set tooMuchOutput(e){$d.set(e)}}}_verifyIntegers(...e){for(Tn of e)if(Tn===1/0||isNaN(Tn)||Tn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Tn of e)if(Tn&&(Tn===1/0||isNaN(Tn)||Tn%1!==0||Tn<0))throw new Error("This API only accepts positive integers")}};/** +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Gf&&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=Iv(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=Kf(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,-_d),_d),t/=_d,t/Math.abs(t)+Math.round(t*(ck-1)))}shouldForceSelection(e){return Lc?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(),uk)}_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&&!(Lc&&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 u=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(o,e[0]),f=d,h=e[0]-d,_=0,g=0,y=0,b=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;f1&&(b+=X-1,f+=X-1);L>0&&d>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,L--):P>1&&(y+=P-1,d-=P-1),d--,L--}for(;D1&&(b+=P-1,f+=P-1),f++,D++}}f++;let S=d+h-_+y,T=Math.min(this._bufferService.cols,f-d+_+g-y-b);if(!(!t&&u.slice(d,f).trim()==="")){if(n&&S===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let X=this._bufferService.cols-D.start;S-=X,T+=X}}}if(s&&S+T===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(T+=D.length)}}return{start:S,length:T}}}_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=Iv(n,this._bufferService.cols)}};vf=At([ge(3,ki),ge(4,Ss),ge(5,Uf),ge(6,Ei),ge(7,lr),ge(8,sr)],vf);var Uv=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={}}},Fv=class{constructor(){this._color=new Uv,this._css=new Uv}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()}},$t=Object.freeze((()=>{let e=[xt.toColor("#2e3436"),xt.toColor("#cc0000"),xt.toColor("#4e9a06"),xt.toColor("#c4a000"),xt.toColor("#3465a4"),xt.toColor("#75507b"),xt.toColor("#06989a"),xt.toColor("#d3d7cf"),xt.toColor("#555753"),xt.toColor("#ef2929"),xt.toColor("#8ae234"),xt.toColor("#fce94f"),xt.toColor("#729fcf"),xt.toColor("#ad7fa8"),xt.toColor("#34e2e2"),xt.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:Pt.toCss(s,a,o),rgba:Pt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Pt.toCss(s,s,s),rgba:Pt.toRgba(s,s,s)})}return e})()),ps=xt.toColor("#ffffff"),Aa=xt.toColor("#000000"),qv=xt.toColor("#ffffff"),Wv=Aa,va={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},pk=ps,yf=class extends He{constructor(e){super(),this._optionsService=e,this._contrastCache=new Fv,this._halfContrastCache=new Fv,this._onChangeColors=this._register(new pe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ps,background:Aa,cursor:qv,cursorAccent:Wv,selectionForeground:void 0,selectionBackgroundTransparent:va,selectionBackgroundOpaque:gt.blend(Aa,va),selectionInactiveBackgroundTransparent:va,selectionInactiveBackgroundOpaque:gt.blend(Aa,va),scrollbarSliderBackground:gt.opacity(ps,.2),scrollbarSliderHoverBackground:gt.opacity(ps,.4),scrollbarSliderActiveBackground:gt.opacity(ps,.5),overviewRulerBorder:ps,ansi:$t.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=st(e.foreground,ps),t.background=st(e.background,Aa),t.cursor=gt.blend(t.background,st(e.cursor,qv)),t.cursorAccent=gt.blend(t.background,st(e.cursorAccent,Wv)),t.selectionBackgroundTransparent=st(e.selectionBackground,va),t.selectionBackgroundOpaque=gt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=gt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,jv):void 0,t.selectionForeground===jv&&(t.selectionForeground=void 0),gt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=gt.opacity(t.selectionBackgroundTransparent,.3)),gt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=gt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,gt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,gt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,gt.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,pk),t.ansi=$t.slice(),t.ansi[0]=st(e.black,$t[0]),t.ansi[1]=st(e.red,$t[1]),t.ansi[2]=st(e.green,$t[2]),t.ansi[3]=st(e.yellow,$t[3]),t.ansi[4]=st(e.blue,$t[4]),t.ansi[5]=st(e.magenta,$t[5]),t.ansi[6]=st(e.cyan,$t[6]),t.ansi[7]=st(e.white,$t[7]),t.ansi[8]=st(e.brightBlack,$t[8]),t.ansi[9]=st(e.brightRed,$t[9]),t.ansi[10]=st(e.brightGreen,$t[10]),t.ansi[11]=st(e.brightYellow,$t[11]),t.ansi[12]=st(e.brightBlue,$t[12]),t.ansi[13]=st(e.brightMagenta,$t[13]),t.ansi[14]=st(e.brightCyan,$t[14]),t.ansi[15]=st(e.brightWhite,$t[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-u.index),s=[];for(let o of n){let u=this._services.get(o.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(u)}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)}},_k={trace:0,debug:1,info:2,warn:3,error:4,off:5},vk="xterm.js: ",bf=class extends He{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=_k[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*je+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*je+0]=t|2097152|n[2]<<22):this._data[t*je+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*je+0]>>22}hasWidth(t){return this._data[t*je+0]&12582912}getFg(t){return this._data[t*je+1]}getBg(t){return this._data[t*je+2]}hasContent(t){return this._data[t*je+0]&4194303}getCodePoint(t){let n=this._data[t*je+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*je+0]&2097152}getString(t){let n=this._data[t*je+0];return n&2097152?this._combined[t]:n&2097151?Hr(n&2097151):""}isProtected(t){return this._data[t*je+2]&536870912}loadCell(t,n){return gc=t*je,n.content=this._data[gc+0],n.fg=this._data[gc+1],n.bg=this._data[gc+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*je+0]=n.content,this._data[t*je+1]=n.fg,this._data[t*je+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*je+0]=n|s<<22,this._data[t*je+1]=a.fg,this._data[t*je+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*je+0];a&2097152?this._combined[t]+=Hr(n):a&2097151?(this._combined[t]=Hr(a&2097151)+Hr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*je+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[d]}let o=Object.keys(this._extendedAttrs);for(let u=0;u=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*vd=0;--t)if(this._data[t*je+0]&4194303)return t+(this._data[t*je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*je+0]&4194303||this._data[t*je+2]&50331648)return t+(this._data[t*je+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let u=t._data;if(o)for(let f=a-1;f>=0;f--){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