From b9641f638ccb3cc1237e44ee0e42acb48fd8b4bd Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sat, 28 Mar 2026 23:26:25 +0200 Subject: [PATCH 01/12] fix: broadcast running status immediately when eval run starts Previously the UI showed "pending" for a long time after clicking Run because the first WebSocket event only arrived when the first eval item completed. Now we broadcast a progress event with 0/total right after run.start() so the UI transitions to "running" immediately. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/uipath/dev/services/eval_service.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/uipath/dev/services/eval_service.py b/src/uipath/dev/services/eval_service.py index 6668851..dc5ff87 100644 --- a/src/uipath/dev/services/eval_service.py +++ b/src/uipath/dev/services/eval_service.py @@ -352,6 +352,10 @@ async def _execute_eval_run(self, run: EvalRunState) -> None: """Execute eval run using uipath.eval.runtime.evaluate().""" run.start() + # Broadcast "running" status immediately so the UI transitions from "pending" + if self._on_eval_run_progress: + self._on_eval_run_progress(run.id, 0, run.progress_total, None) + try: eval_set_path = self._eval_set_paths.get(run.eval_set_id) if eval_set_path is None: From 458bf60f70de9d8e3e9a97bdca01972c7e7495ed Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sat, 28 Mar 2026 23:28:06 +0200 Subject: [PATCH 02/12] fix: stop adding empty criteria when attaching evaluators to eval sets Empty {} criteria caused "Evaluation criteria must be provided" errors for output-based evaluators like LLM judge that require expectedOutput. Criteria are populated when items are created, not when evaluators are attached to the set. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/uipath/dev/services/eval_service.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/uipath/dev/services/eval_service.py b/src/uipath/dev/services/eval_service.py index dc5ff87..6cb3f16 100644 --- a/src/uipath/dev/services/eval_service.py +++ b/src/uipath/dev/services/eval_service.py @@ -139,9 +139,6 @@ def update_eval_set_evaluators( for item in raw.get("evaluations", []): criterias = item.setdefault("evaluationCriterias", {}) - for ev_id in added: - if ev_id not in criterias: - criterias[ev_id] = {} for ev_id in removed: criterias.pop(ev_id, None) From 16ece57718f2c85e20c90cdb0a8a4c29fdad0284 Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sat, 28 Mar 2026 23:38:06 +0200 Subject: [PATCH 03/12] feat: add LLM model selection for evaluators and expose full evaluator schemas - Add /api/llm-models endpoint using agenthub.get_available_llm_models_async() - Enhance /api/evaluators to return full config and criteria schemas via generate_json_type() - Add model dropdown in create and edit evaluator views for LLM-type evaluators, with fallback to text input when models unavailable - Include model in evaluatorConfig when creating/updating evaluator JSON Co-Authored-By: Claude Opus 4.6 (1M context) --- .../server/frontend/src/api/eval-client.ts | 6 ++- .../evaluators/CreateEvaluatorView.tsx | 50 ++++++++++++++++++- .../components/evaluators/EvaluatorDetail.tsx | 49 +++++++++++++++++- .../server/frontend/src/store/useEvalStore.ts | 7 ++- .../dev/server/frontend/src/types/eval.ts | 6 +++ .../dev/server/frontend/tsconfig.tsbuildinfo | 2 +- src/uipath/dev/server/routes/evaluators.py | 33 +++++++++--- ...anel-CioL9l4m.js => ChatPanel-CrwXase9.js} | 2 +- .../{index-DXWSpgyM.js => index-CMiQYjGD.js} | 42 ++++++++-------- src/uipath/dev/server/static/index.html | 2 +- 10 files changed, 163 insertions(+), 36 deletions(-) rename src/uipath/dev/server/static/assets/{ChatPanel-CioL9l4m.js => ChatPanel-CrwXase9.js} (99%) rename src/uipath/dev/server/static/assets/{index-DXWSpgyM.js => index-CMiQYjGD.js} (66%) diff --git a/src/uipath/dev/server/frontend/src/api/eval-client.ts b/src/uipath/dev/server/frontend/src/api/eval-client.ts index eb6baa3..fa0fa41 100644 --- a/src/uipath/dev/server/frontend/src/api/eval-client.ts +++ b/src/uipath/dev/server/frontend/src/api/eval-client.ts @@ -1,4 +1,4 @@ -import type { EvaluatorInfo, LocalEvaluator, EvalSetSummary, EvalSetDetail, EvalItem, EvalRunSummary, EvalRunDetail } from "../types/eval"; +import type { EvaluatorInfo, LocalEvaluator, LlmModel, EvalSetSummary, EvalSetDetail, EvalItem, EvalRunSummary, EvalRunDetail } from "../types/eval"; const BASE = "/api"; @@ -24,6 +24,10 @@ export async function listEvaluators(): Promise { return fetchJson(`${BASE}/evaluators`); } +export async function listLlmModels(): Promise { + return fetchJson(`${BASE}/llm-models`); +} + export async function listEvalSets(): Promise { return fetchJson(`${BASE}/eval-sets`); } diff --git a/src/uipath/dev/server/frontend/src/components/evaluators/CreateEvaluatorView.tsx b/src/uipath/dev/server/frontend/src/components/evaluators/CreateEvaluatorView.tsx index 9a4c76c..f00fe96 100644 --- a/src/uipath/dev/server/frontend/src/components/evaluators/CreateEvaluatorView.tsx +++ b/src/uipath/dev/server/frontend/src/components/evaluators/CreateEvaluatorView.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import { useEvalStore } from "../../store/useEvalStore"; import { useHashRoute } from "../../hooks/useHashRoute"; -import { createLocalEvaluator } from "../../api/eval-client"; +import { createLocalEvaluator, listLlmModels } from "../../api/eval-client"; import { typesByCategory, typeDefaults, getTypeFields, categoryLabel } from "./EvaluatorDetail"; const allCategories = ["deterministic", "llm", "tool"] as const; @@ -12,6 +12,8 @@ interface Props { export default function CreateEvaluatorView({ category: initialCategory }: Props) { const addLocalEvaluator = useEvalStore((s) => s.addLocalEvaluator); + const llmModels = useEvalStore((s) => s.llmModels); + const setLlmModels = useEvalStore((s) => s.setLlmModels); const { navigate } = useHashRoute(); const isFixed = initialCategory !== "any"; @@ -22,11 +24,18 @@ export default function CreateEvaluatorView({ category: initialCategory }: Props const [typeId, setTypeId] = useState(types[0]?.id ?? ""); const [targetOutputKey, setTargetOutputKey] = useState("*"); const [prompt, setPrompt] = useState(""); + const [model, setModel] = useState(""); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); const [descriptionTouched, setDescriptionTouched] = useState(false); const [promptTouched, setPromptTouched] = useState(false); + useEffect(() => { + if (llmModels.length === 0) { + listLlmModels().then(setLlmModels).catch(() => {}); + } + }, []); + // Reset form when initial category prop changes useEffect(() => { const cat = isFixed ? initialCategory : "deterministic"; @@ -39,6 +48,7 @@ export default function CreateEvaluatorView({ category: initialCategory }: Props setTypeId(firstId); setTargetOutputKey("*"); setPrompt(defaults?.prompt ?? ""); + setModel(""); setError(null); setDescriptionTouched(false); setPromptTouched(false); @@ -64,6 +74,7 @@ export default function CreateEvaluatorView({ category: initialCategory }: Props }; const fields = getTypeFields(typeId); + const isLlm = category === "llm"; const handleSubmit = async () => { if (!name.trim()) { @@ -76,6 +87,7 @@ export default function CreateEvaluatorView({ category: initialCategory }: Props const config: Record = {}; if (fields.targetOutputKey) config.targetOutputKey = targetOutputKey; if (fields.prompt && prompt.trim()) config.prompt = prompt; + if (isLlm && model) config.model = model; const result = await createLocalEvaluator({ name: name.trim(), @@ -247,6 +259,42 @@ export default function CreateEvaluatorView({ category: initialCategory }: Props )} + {/* Model (LLM evaluators only) */} + {isLlm && ( +
+ + {llmModels.length > 0 ? ( + + ) : ( + setModel(e.target.value)} + placeholder="e.g. gpt-4.1-mini-2025-04-14" + className="w-full rounded-md px-3 py-2 text-xs" + style={inputStyle} + /> + )} +
+ )} + {/* Error */} {error && (

{error}

diff --git a/src/uipath/dev/server/frontend/src/components/evaluators/EvaluatorDetail.tsx b/src/uipath/dev/server/frontend/src/components/evaluators/EvaluatorDetail.tsx index d3cae15..b62ee43 100644 --- a/src/uipath/dev/server/frontend/src/components/evaluators/EvaluatorDetail.tsx +++ b/src/uipath/dev/server/frontend/src/components/evaluators/EvaluatorDetail.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useEvalStore } from "../../store/useEvalStore"; import { useHashRoute } from "../../hooks/useHashRoute"; -import { listLocalEvaluators, updateLocalEvaluator } from "../../api/eval-client"; +import { listLocalEvaluators, listLlmModels, updateLocalEvaluator } from "../../api/eval-client"; import type { EvaluatorInfo, LocalEvaluator } from "../../types/eval"; // --- Badge styles --- @@ -368,6 +368,8 @@ function EditEvaluatorForm({ }) { const category = categoryForTypeId(evaluator.evaluator_type_id); const types = typesByCategory[category] ?? []; + const llmModels = useEvalStore((s) => s.llmModels); + const setLlmModels = useEvalStore((s) => s.setLlmModels); const [description, setDescription] = useState(evaluator.description); const [typeId, setTypeId] = useState(evaluator.evaluator_type_id); @@ -377,21 +379,32 @@ function EditEvaluatorForm({ const [prompt, setPrompt] = useState( (evaluator.config?.prompt as string) ?? "", ); + const [model, setModel] = useState( + (evaluator.config?.model as string) ?? "", + ); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); const [success, setSuccess] = useState(false); + useEffect(() => { + if (category === "llm" && llmModels.length === 0) { + listLlmModels().then(setLlmModels).catch(() => {}); + } + }, [category]); + // Reset form when switching to a different evaluator useEffect(() => { setDescription(evaluator.description); setTypeId(evaluator.evaluator_type_id); setTargetOutputKey((evaluator.config?.targetOutputKey as string) ?? "*"); setPrompt((evaluator.config?.prompt as string) ?? ""); + setModel((evaluator.config?.model as string) ?? ""); setError(null); setSuccess(false); }, [evaluator.id]); const fields = getTypeFields(typeId); + const isLlm = category === "llm"; const handleSave = async () => { setSaving(true); @@ -401,6 +414,7 @@ function EditEvaluatorForm({ const config: Record = {}; if (fields.targetOutputKey) config.targetOutputKey = targetOutputKey; if (fields.prompt && prompt.trim()) config.prompt = prompt; + if (isLlm && model) config.model = model; const result = await updateLocalEvaluator(evaluator.id, { description: description.trim(), @@ -521,6 +535,39 @@ function EditEvaluatorForm({ /> )} + + {/* Model (LLM evaluators only) */} + {isLlm && ( +
+ + {llmModels.length > 0 ? ( + + ) : ( + setModel(e.target.value)} + placeholder="e.g. gpt-4.1-mini-2025-04-14" + className="w-full px-3 py-2 rounded-lg text-xs outline-none" + style={inputStyle} + /> + )} +
+ )} {/* Bottom pinned section */} diff --git a/src/uipath/dev/server/frontend/src/store/useEvalStore.ts b/src/uipath/dev/server/frontend/src/store/useEvalStore.ts index 55dbd78..4e58b0e 100644 --- a/src/uipath/dev/server/frontend/src/store/useEvalStore.ts +++ b/src/uipath/dev/server/frontend/src/store/useEvalStore.ts @@ -1,9 +1,10 @@ import { create } from "zustand"; -import type { EvaluatorInfo, LocalEvaluator, EvalSetSummary, EvalRunSummary, EvalItemResult } from "../types/eval"; +import type { EvaluatorInfo, LocalEvaluator, LlmModel, EvalSetSummary, EvalRunSummary, EvalItemResult } from "../types/eval"; interface EvalStore { evaluators: EvaluatorInfo[]; localEvaluators: LocalEvaluator[]; + llmModels: LlmModel[]; evalSets: Record; evalRuns: Record; /** Item results streamed via WebSocket, keyed by runId → itemName */ @@ -11,6 +12,7 @@ interface EvalStore { setEvaluators: (evaluators: EvaluatorInfo[]) => void; setLocalEvaluators: (evaluators: LocalEvaluator[]) => void; + setLlmModels: (models: LlmModel[]) => void; addLocalEvaluator: (evaluator: LocalEvaluator) => void; upsertLocalEvaluator: (evaluator: LocalEvaluator) => void; setEvalSets: (sets: EvalSetSummary[]) => void; @@ -26,6 +28,7 @@ interface EvalStore { export const useEvalStore = create((set) => ({ evaluators: [], localEvaluators: [], + llmModels: [], evalSets: {}, evalRuns: {}, streamingResults: {}, @@ -34,6 +37,8 @@ export const useEvalStore = create((set) => ({ setLocalEvaluators: (localEvaluators) => set({ localEvaluators }), + setLlmModels: (llmModels) => set({ llmModels }), + addLocalEvaluator: (evaluator) => set((state) => ({ localEvaluators: [...state.localEvaluators, evaluator] })), diff --git a/src/uipath/dev/server/frontend/src/types/eval.ts b/src/uipath/dev/server/frontend/src/types/eval.ts index 434b969..b70709b 100644 --- a/src/uipath/dev/server/frontend/src/types/eval.ts +++ b/src/uipath/dev/server/frontend/src/types/eval.ts @@ -5,6 +5,12 @@ export interface EvaluatorInfo { category: string; description: string; config_schema: Record; + criteria_schema: Record; +} + +export interface LlmModel { + model_name: string; + vendor: string | null; } export interface LocalEvaluator { diff --git a/src/uipath/dev/server/frontend/tsconfig.tsbuildinfo b/src/uipath/dev/server/frontend/tsconfig.tsbuildinfo index a37405d..a2b56fb 100644 --- a/src/uipath/dev/server/frontend/tsconfig.tsbuildinfo +++ b/src/uipath/dev/server/frontend/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/auth.ts","./src/api/cli-agent-client.ts","./src/api/cli-terminal-bridge.ts","./src/api/client.ts","./src/api/eval-client.ts","./src/api/explorer-client.ts","./src/api/statedb-client.ts","./src/api/websocket.ts","./src/components/chat/chatinput.tsx","./src/components/chat/chatinterrupt.tsx","./src/components/chat/chatmessage.tsx","./src/components/chat/chatpanel.tsx","./src/components/cli-agent/cliagentterminal.tsx","./src/components/debug/debugcontrols.tsx","./src/components/evals/createevalsetview.tsx","./src/components/evals/evalrunresults.tsx","./src/components/evals/evalsetdetail.tsx","./src/components/evals/evalssidebar.tsx","./src/components/evaluators/createevaluatorview.tsx","./src/components/evaluators/evaluatordetail.tsx","./src/components/evaluators/evaluatorssidebar.tsx","./src/components/explorer/explorercanvas.tsx","./src/components/explorer/explorercontent.tsx","./src/components/explorer/explorersidebar.tsx","./src/components/explorer/fileeditor.tsx","./src/components/explorer/statedbviewer.tsx","./src/components/graph/graphpanel.tsx","./src/components/graph/elklayout.ts","./src/components/graph/edges/elkedge.tsx","./src/components/graph/nodes/defaultnode.tsx","./src/components/graph/nodes/endnode.tsx","./src/components/graph/nodes/groupnode.tsx","./src/components/graph/nodes/modelnode.tsx","./src/components/graph/nodes/startnode.tsx","./src/components/graph/nodes/toolnode.tsx","./src/components/layout/activitybar.tsx","./src/components/layout/debugsidebar.tsx","./src/components/layout/sidepanel.tsx","./src/components/layout/sidebar.tsx","./src/components/layout/statusbar.tsx","./src/components/logs/logpanel.tsx","./src/components/runs/addtoevalmodal.tsx","./src/components/runs/newrunpanel.tsx","./src/components/runs/rundetailspanel.tsx","./src/components/runs/runeventspanel.tsx","./src/components/runs/runhistoryitem.tsx","./src/components/runs/setupview.tsx","./src/components/shared/datasection.tsx","./src/components/shared/jsonhighlight.tsx","./src/components/shared/reloadtoast.tsx","./src/components/shared/toastcontainer.tsx","./src/components/traces/spandetails.tsx","./src/components/traces/tracetree.tsx","./src/components/traces/waterfallview.tsx","./src/hooks/usehashroute.ts","./src/hooks/useismobile.ts","./src/store/useauthstore.ts","./src/store/usecliagentstore.ts","./src/store/useconfigstore.ts","./src/store/useevalstore.ts","./src/store/useexplorerstore.ts","./src/store/userunstore.ts","./src/store/usetheme.ts","./src/store/usetoaststore.ts","./src/store/usewebsocket.ts","./src/types/eval.ts","./src/types/explorer.ts","./src/types/graph.ts","./src/types/run.ts","./src/types/statedb.ts","./src/types/ws.ts"],"version":"5.7.3"} \ No newline at end of file +{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/auth.ts","./src/api/cli-agent-client.ts","./src/api/cli-terminal-bridge.ts","./src/api/client.ts","./src/api/eval-client.ts","./src/api/explorer-client.ts","./src/api/statedb-client.ts","./src/api/websocket.ts","./src/components/chat/chatinput.tsx","./src/components/chat/chatinterrupt.tsx","./src/components/chat/chatmessage.tsx","./src/components/chat/chatpanel.tsx","./src/components/cli-agent/cliagentterminal.tsx","./src/components/debug/debugcontrols.tsx","./src/components/evals/createevalsetview.tsx","./src/components/evals/evalrunresults.tsx","./src/components/evals/evalsetdetail.tsx","./src/components/evals/evalssidebar.tsx","./src/components/evaluators/createevaluatorview.tsx","./src/components/evaluators/evaluatordetail.tsx","./src/components/evaluators/evaluatorssidebar.tsx","./src/components/explorer/explorercanvas.tsx","./src/components/explorer/explorercontent.tsx","./src/components/explorer/explorersidebar.tsx","./src/components/explorer/fileeditor.tsx","./src/components/explorer/statedbviewer.tsx","./src/components/graph/graphpanel.tsx","./src/components/graph/elklayout.ts","./src/components/graph/edges/elkedge.tsx","./src/components/graph/nodes/defaultnode.tsx","./src/components/graph/nodes/endnode.tsx","./src/components/graph/nodes/groupnode.tsx","./src/components/graph/nodes/marchingborder.tsx","./src/components/graph/nodes/modelnode.tsx","./src/components/graph/nodes/startnode.tsx","./src/components/graph/nodes/toolnode.tsx","./src/components/layout/activitybar.tsx","./src/components/layout/debugsidebar.tsx","./src/components/layout/sidepanel.tsx","./src/components/layout/sidebar.tsx","./src/components/layout/statusbar.tsx","./src/components/logs/logpanel.tsx","./src/components/runs/addtoevalmodal.tsx","./src/components/runs/newrunpanel.tsx","./src/components/runs/rundetailspanel.tsx","./src/components/runs/runeventspanel.tsx","./src/components/runs/runhistoryitem.tsx","./src/components/runs/setupview.tsx","./src/components/shared/datasection.tsx","./src/components/shared/jsonhighlight.tsx","./src/components/shared/reloadtoast.tsx","./src/components/shared/toastcontainer.tsx","./src/components/traces/spandetails.tsx","./src/components/traces/tracetree.tsx","./src/components/traces/waterfallview.tsx","./src/hooks/usehashroute.ts","./src/hooks/useismobile.ts","./src/store/useauthstore.ts","./src/store/usecliagentstore.ts","./src/store/useconfigstore.ts","./src/store/useevalstore.ts","./src/store/useexplorerstore.ts","./src/store/userunstore.ts","./src/store/usetheme.ts","./src/store/usetoaststore.ts","./src/store/usewebsocket.ts","./src/types/eval.ts","./src/types/explorer.ts","./src/types/graph.ts","./src/types/run.ts","./src/types/statedb.ts","./src/types/ws.ts"],"version":"5.7.3"} \ No newline at end of file diff --git a/src/uipath/dev/server/routes/evaluators.py b/src/uipath/dev/server/routes/evaluators.py index c1a8fce..00b88d8 100644 --- a/src/uipath/dev/server/routes/evaluators.py +++ b/src/uipath/dev/server/routes/evaluators.py @@ -147,13 +147,11 @@ def _load_evaluators() -> list[dict[str, Any]]: ev_id = cls.get_evaluator_id() meta = _EVALUATOR_META.get(ev_id, {}) - config_schema: dict[str, Any] = {} - config_type = cls.model_fields.get("config_type") - if config_type and config_type.default is not None: - try: - config_schema = config_type.default.model_json_schema() - except Exception: - pass + json_type: dict[str, Any] = {} + try: + json_type = cls.generate_json_type() + except Exception: + pass result.append( { @@ -162,7 +160,10 @@ def _load_evaluators() -> list[dict[str, Any]]: "type": meta.get("type", _infer_type(cls.__name__)), "category": meta.get("category", "output"), "description": meta.get("description", ""), - "config_schema": config_schema, + "config_schema": json_type.get("evaluatorConfigSchema", {}), + "criteria_schema": json_type.get( + "evaluationCriteriaSchema", {} + ), } ) return result @@ -177,6 +178,22 @@ async def list_evaluators() -> list[dict[str, Any]]: return _load_evaluators() +@router.get("/llm-models") +async def list_llm_models() -> list[dict[str, Any]]: + """Return available LLM models from AgentHub.""" + try: + from uipath.platform import UiPath + + sdk = UiPath() + models = await sdk.agenthub.get_available_llm_models_async() + return [ + {"model_name": m.model_name, "vendor": m.vendor} for m in models + ] + except Exception: + logger.debug("Failed to fetch LLM models from AgentHub", exc_info=True) + return [] + + # ------------------------------------------------------------------ # Local evaluator files (evaluations/evaluators/*.json) # ------------------------------------------------------------------ diff --git a/src/uipath/dev/server/static/assets/ChatPanel-CioL9l4m.js b/src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js similarity index 99% rename from src/uipath/dev/server/static/assets/ChatPanel-CioL9l4m.js rename to src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js index 6c9de04..b71cc77 100644 --- a/src/uipath/dev/server/static/assets/ChatPanel-CioL9l4m.js +++ b/src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js @@ -1,4 +1,4 @@ -import{g as Br,j as I,a as pe}from"./vendor-react-VzyiTEsu.js";import{j as ga,H as ha,u as gn}from"./index-DXWSpgyM.js";import"./vendor-reactflow-B_2yZyR4.js";function ba(e,n){const t={};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const ya=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_a=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ea={};function Bt(e,n){return(Ea.jsx?_a:ya).test(e)}const xa=/[ \t\n\f\r]/g;function ka(e){return typeof e=="object"?e.type==="text"?zt(e.value):!1:zt(e)}function zt(e){return e.replace(xa,"")===""}class cn{constructor(n,t,r){this.normal=t,this.property=n,r&&(this.space=r)}}cn.prototype.normal={};cn.prototype.property={};cn.prototype.space=void 0;function zr(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new cn(t,r,n)}function ot(e){return e.toLowerCase()}class le{constructor(n,t){this.attribute=t,this.property=n}}le.prototype.attribute="";le.prototype.booleanish=!1;le.prototype.boolean=!1;le.prototype.commaOrSpaceSeparated=!1;le.prototype.commaSeparated=!1;le.prototype.defined=!1;le.prototype.mustUseProperty=!1;le.prototype.number=!1;le.prototype.overloadedBoolean=!1;le.prototype.property="";le.prototype.spaceSeparated=!1;le.prototype.space=void 0;let wa=0;const U=Le(),te=Le(),st=Le(),v=Le(),Q=Le(),qe=Le(),de=Le();function Le(){return 2**++wa}const lt=Object.freeze(Object.defineProperty({__proto__:null,boolean:U,booleanish:te,commaOrSpaceSeparated:de,commaSeparated:qe,number:v,overloadedBoolean:st,spaceSeparated:Q},Symbol.toStringTag,{value:"Module"})),$n=Object.keys(lt);class yt extends le{constructor(n,t,r,i){let o=-1;if(super(n,t),Ut(this,"space",i),typeof r=="number")for(;++o<$n.length;){const a=$n[o];Ut(this,$n[o],(r<[a])===lt[a])}}}yt.prototype.defined=!0;function Ut(e,n,t){t&&(e[n]=t)}function Ve(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const o=new yt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[ot(r)]=r,t[ot(o.attribute)]=r}return new cn(n,t,e.space)}const Ur=Ve({properties:{ariaActiveDescendant:null,ariaAtomic:te,ariaAutoComplete:null,ariaBusy:te,ariaChecked:te,ariaColCount:v,ariaColIndex:v,ariaColSpan:v,ariaControls:Q,ariaCurrent:null,ariaDescribedBy:Q,ariaDetails:null,ariaDisabled:te,ariaDropEffect:Q,ariaErrorMessage:null,ariaExpanded:te,ariaFlowTo:Q,ariaGrabbed:te,ariaHasPopup:null,ariaHidden:te,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Q,ariaLevel:v,ariaLive:null,ariaModal:te,ariaMultiLine:te,ariaMultiSelectable:te,ariaOrientation:null,ariaOwns:Q,ariaPlaceholder:null,ariaPosInSet:v,ariaPressed:te,ariaReadOnly:te,ariaRelevant:null,ariaRequired:te,ariaRoleDescription:Q,ariaRowCount:v,ariaRowIndex:v,ariaRowSpan:v,ariaSelected:te,ariaSetSize:v,ariaSort:null,ariaValueMax:v,ariaValueMin:v,ariaValueNow:v,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function $r(e,n){return n in e?e[n]:n}function Hr(e,n){return $r(e,n.toLowerCase())}const Sa=Ve({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:Q,accessKey:Q,action:null,allow:null,allowFullScreen:U,allowPaymentRequest:U,allowUserMedia:U,alt:null,as:null,async:U,autoCapitalize:null,autoComplete:Q,autoFocus:U,autoPlay:U,blocking:Q,capture:null,charSet:null,checked:U,cite:null,className:Q,cols:v,colSpan:null,content:null,contentEditable:te,controls:U,controlsList:Q,coords:v|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:U,defer:U,dir:null,dirName:null,disabled:U,download:st,draggable:te,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:U,formTarget:null,headers:Q,height:v,hidden:st,high:v,href:null,hrefLang:null,htmlFor:Q,httpEquiv:Q,id:null,imageSizes:null,imageSrcSet:null,inert:U,inputMode:null,integrity:null,is:null,isMap:U,itemId:null,itemProp:Q,itemRef:Q,itemScope:U,itemType:Q,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:U,low:v,manifest:null,max:null,maxLength:v,media:null,method:null,min:null,minLength:v,multiple:U,muted:U,name:null,nonce:null,noModule:U,noValidate:U,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:U,optimum:v,pattern:null,ping:Q,placeholder:null,playsInline:U,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:U,referrerPolicy:null,rel:Q,required:U,reversed:U,rows:v,rowSpan:v,sandbox:Q,scope:null,scoped:U,seamless:U,selected:U,shadowRootClonable:U,shadowRootDelegatesFocus:U,shadowRootMode:null,shape:null,size:v,sizes:null,slot:null,span:v,spellCheck:te,src:null,srcDoc:null,srcLang:null,srcSet:null,start:v,step:null,style:null,tabIndex:v,target:null,title:null,translate:null,type:null,typeMustMatch:U,useMap:null,value:te,width:v,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Q,axis:null,background:null,bgColor:null,border:v,borderColor:null,bottomMargin:v,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:U,declare:U,event:null,face:null,frame:null,frameBorder:null,hSpace:v,leftMargin:v,link:null,longDesc:null,lowSrc:null,marginHeight:v,marginWidth:v,noResize:U,noHref:U,noShade:U,noWrap:U,object:null,profile:null,prompt:null,rev:null,rightMargin:v,rules:null,scheme:null,scrolling:te,standby:null,summary:null,text:null,topMargin:v,valueType:null,version:null,vAlign:null,vLink:null,vSpace:v,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:U,disableRemotePlayback:U,prefix:null,property:null,results:v,security:null,unselectable:null},space:"html",transform:Hr}),Na=Ve({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:de,accentHeight:v,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:v,amplitude:v,arabicForm:null,ascent:v,attributeName:null,attributeType:null,azimuth:v,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:v,by:null,calcMode:null,capHeight:v,className:Q,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:v,diffuseConstant:v,direction:null,display:null,dur:null,divisor:v,dominantBaseline:null,download:U,dx:null,dy:null,edgeMode:null,editable:null,elevation:v,enableBackground:null,end:null,event:null,exponent:v,externalResourcesRequired:null,fill:null,fillOpacity:v,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:v,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:v,horizOriginX:v,horizOriginY:v,id:null,ideographic:v,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:v,k:v,k1:v,k2:v,k3:v,k4:v,kernelMatrix:de,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:v,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:v,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:v,overlineThickness:v,paintOrder:null,panose1:null,path:null,pathLength:v,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Q,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:v,pointsAtY:v,pointsAtZ:v,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:de,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:de,rev:de,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:de,requiredFeatures:de,requiredFonts:de,requiredFormats:de,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:v,specularExponent:v,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:v,strikethroughThickness:v,string:null,stroke:null,strokeDashArray:de,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:v,strokeOpacity:v,strokeWidth:null,style:null,surfaceScale:v,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:de,tabIndex:v,tableValues:null,target:null,targetX:v,targetY:v,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:de,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:v,underlineThickness:v,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:v,values:null,vAlphabetic:v,vMathematical:v,vectorEffect:null,vHanging:v,vIdeographic:v,version:null,vertAdvY:v,vertOriginX:v,vertOriginY:v,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:v,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$r}),Gr=Ve({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Kr=Ve({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Hr}),qr=Ve({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),va={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ta=/[A-Z]/g,$t=/-[a-z]/g,Aa=/^data[-\w.:]+$/i;function Ca(e,n){const t=ot(n);let r=n,i=le;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&Aa.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace($t,Oa);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!$t.test(o)){let a=o.replace(Ta,Ia);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=yt}return new i(r,n)}function Ia(e){return"-"+e.toLowerCase()}function Oa(e){return e.charAt(1).toUpperCase()}const Ra=zr([Ur,Sa,Gr,Kr,qr],"html"),_t=zr([Ur,Na,Gr,Kr,qr],"svg");function Ma(e){return e.join(" ").trim()}var ze={},Hn,Ht;function Da(){if(Ht)return Hn;Ht=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,t=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` +import{g as Br,j as I,a as pe}from"./vendor-react-VzyiTEsu.js";import{j as ga,H as ha,u as gn}from"./index-CMiQYjGD.js";import"./vendor-reactflow-B_2yZyR4.js";function ba(e,n){const t={};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const ya=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_a=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ea={};function Bt(e,n){return(Ea.jsx?_a:ya).test(e)}const xa=/[ \t\n\f\r]/g;function ka(e){return typeof e=="object"?e.type==="text"?zt(e.value):!1:zt(e)}function zt(e){return e.replace(xa,"")===""}class cn{constructor(n,t,r){this.normal=t,this.property=n,r&&(this.space=r)}}cn.prototype.normal={};cn.prototype.property={};cn.prototype.space=void 0;function zr(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new cn(t,r,n)}function ot(e){return e.toLowerCase()}class le{constructor(n,t){this.attribute=t,this.property=n}}le.prototype.attribute="";le.prototype.booleanish=!1;le.prototype.boolean=!1;le.prototype.commaOrSpaceSeparated=!1;le.prototype.commaSeparated=!1;le.prototype.defined=!1;le.prototype.mustUseProperty=!1;le.prototype.number=!1;le.prototype.overloadedBoolean=!1;le.prototype.property="";le.prototype.spaceSeparated=!1;le.prototype.space=void 0;let wa=0;const U=Le(),te=Le(),st=Le(),v=Le(),Q=Le(),qe=Le(),de=Le();function Le(){return 2**++wa}const lt=Object.freeze(Object.defineProperty({__proto__:null,boolean:U,booleanish:te,commaOrSpaceSeparated:de,commaSeparated:qe,number:v,overloadedBoolean:st,spaceSeparated:Q},Symbol.toStringTag,{value:"Module"})),$n=Object.keys(lt);class yt extends le{constructor(n,t,r,i){let o=-1;if(super(n,t),Ut(this,"space",i),typeof r=="number")for(;++o<$n.length;){const a=$n[o];Ut(this,$n[o],(r<[a])===lt[a])}}}yt.prototype.defined=!0;function Ut(e,n,t){t&&(e[n]=t)}function Ve(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const o=new yt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[ot(r)]=r,t[ot(o.attribute)]=r}return new cn(n,t,e.space)}const Ur=Ve({properties:{ariaActiveDescendant:null,ariaAtomic:te,ariaAutoComplete:null,ariaBusy:te,ariaChecked:te,ariaColCount:v,ariaColIndex:v,ariaColSpan:v,ariaControls:Q,ariaCurrent:null,ariaDescribedBy:Q,ariaDetails:null,ariaDisabled:te,ariaDropEffect:Q,ariaErrorMessage:null,ariaExpanded:te,ariaFlowTo:Q,ariaGrabbed:te,ariaHasPopup:null,ariaHidden:te,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Q,ariaLevel:v,ariaLive:null,ariaModal:te,ariaMultiLine:te,ariaMultiSelectable:te,ariaOrientation:null,ariaOwns:Q,ariaPlaceholder:null,ariaPosInSet:v,ariaPressed:te,ariaReadOnly:te,ariaRelevant:null,ariaRequired:te,ariaRoleDescription:Q,ariaRowCount:v,ariaRowIndex:v,ariaRowSpan:v,ariaSelected:te,ariaSetSize:v,ariaSort:null,ariaValueMax:v,ariaValueMin:v,ariaValueNow:v,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function $r(e,n){return n in e?e[n]:n}function Hr(e,n){return $r(e,n.toLowerCase())}const Sa=Ve({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:Q,accessKey:Q,action:null,allow:null,allowFullScreen:U,allowPaymentRequest:U,allowUserMedia:U,alt:null,as:null,async:U,autoCapitalize:null,autoComplete:Q,autoFocus:U,autoPlay:U,blocking:Q,capture:null,charSet:null,checked:U,cite:null,className:Q,cols:v,colSpan:null,content:null,contentEditable:te,controls:U,controlsList:Q,coords:v|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:U,defer:U,dir:null,dirName:null,disabled:U,download:st,draggable:te,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:U,formTarget:null,headers:Q,height:v,hidden:st,high:v,href:null,hrefLang:null,htmlFor:Q,httpEquiv:Q,id:null,imageSizes:null,imageSrcSet:null,inert:U,inputMode:null,integrity:null,is:null,isMap:U,itemId:null,itemProp:Q,itemRef:Q,itemScope:U,itemType:Q,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:U,low:v,manifest:null,max:null,maxLength:v,media:null,method:null,min:null,minLength:v,multiple:U,muted:U,name:null,nonce:null,noModule:U,noValidate:U,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:U,optimum:v,pattern:null,ping:Q,placeholder:null,playsInline:U,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:U,referrerPolicy:null,rel:Q,required:U,reversed:U,rows:v,rowSpan:v,sandbox:Q,scope:null,scoped:U,seamless:U,selected:U,shadowRootClonable:U,shadowRootDelegatesFocus:U,shadowRootMode:null,shape:null,size:v,sizes:null,slot:null,span:v,spellCheck:te,src:null,srcDoc:null,srcLang:null,srcSet:null,start:v,step:null,style:null,tabIndex:v,target:null,title:null,translate:null,type:null,typeMustMatch:U,useMap:null,value:te,width:v,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Q,axis:null,background:null,bgColor:null,border:v,borderColor:null,bottomMargin:v,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:U,declare:U,event:null,face:null,frame:null,frameBorder:null,hSpace:v,leftMargin:v,link:null,longDesc:null,lowSrc:null,marginHeight:v,marginWidth:v,noResize:U,noHref:U,noShade:U,noWrap:U,object:null,profile:null,prompt:null,rev:null,rightMargin:v,rules:null,scheme:null,scrolling:te,standby:null,summary:null,text:null,topMargin:v,valueType:null,version:null,vAlign:null,vLink:null,vSpace:v,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:U,disableRemotePlayback:U,prefix:null,property:null,results:v,security:null,unselectable:null},space:"html",transform:Hr}),Na=Ve({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:de,accentHeight:v,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:v,amplitude:v,arabicForm:null,ascent:v,attributeName:null,attributeType:null,azimuth:v,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:v,by:null,calcMode:null,capHeight:v,className:Q,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:v,diffuseConstant:v,direction:null,display:null,dur:null,divisor:v,dominantBaseline:null,download:U,dx:null,dy:null,edgeMode:null,editable:null,elevation:v,enableBackground:null,end:null,event:null,exponent:v,externalResourcesRequired:null,fill:null,fillOpacity:v,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:v,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:v,horizOriginX:v,horizOriginY:v,id:null,ideographic:v,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:v,k:v,k1:v,k2:v,k3:v,k4:v,kernelMatrix:de,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:v,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:v,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:v,overlineThickness:v,paintOrder:null,panose1:null,path:null,pathLength:v,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Q,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:v,pointsAtY:v,pointsAtZ:v,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:de,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:de,rev:de,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:de,requiredFeatures:de,requiredFonts:de,requiredFormats:de,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:v,specularExponent:v,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:v,strikethroughThickness:v,string:null,stroke:null,strokeDashArray:de,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:v,strokeOpacity:v,strokeWidth:null,style:null,surfaceScale:v,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:de,tabIndex:v,tableValues:null,target:null,targetX:v,targetY:v,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:de,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:v,underlineThickness:v,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:v,values:null,vAlphabetic:v,vMathematical:v,vectorEffect:null,vHanging:v,vIdeographic:v,version:null,vertAdvY:v,vertOriginX:v,vertOriginY:v,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:v,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$r}),Gr=Ve({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Kr=Ve({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Hr}),qr=Ve({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),va={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ta=/[A-Z]/g,$t=/-[a-z]/g,Aa=/^data[-\w.:]+$/i;function Ca(e,n){const t=ot(n);let r=n,i=le;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&Aa.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace($t,Oa);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!$t.test(o)){let a=o.replace(Ta,Ia);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=yt}return new i(r,n)}function Ia(e){return"-"+e.toLowerCase()}function Oa(e){return e.charAt(1).toUpperCase()}const Ra=zr([Ur,Sa,Gr,Kr,qr],"html"),_t=zr([Ur,Na,Gr,Kr,qr],"svg");function Ma(e){return e.join(" ").trim()}var ze={},Hn,Ht;function Da(){if(Ht)return Hn;Ht=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,t=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` `,c="/",u="*",d="",f="comment",p="declaration";function m(E,g){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];g=g||{};var x=1,k=1;function N(M){var A=M.match(n);A&&(x+=A.length);var z=M.lastIndexOf(l);k=~z?M.length-z:k+M.length}function T(){var M={line:x,column:k};return function(A){return A.position=new _(M),P(),A}}function _(M){this.start=M,this.end={line:x,column:k},this.source=g.source}_.prototype.content=E;function D(M){var A=new Error(g.source+":"+x+":"+k+": "+M);if(A.reason=M,A.filename=g.source,A.line=x,A.column=k,A.source=E,!g.silent)throw A}function L(M){var A=M.exec(E);if(A){var z=A[0];return N(z),E=E.slice(z.length),A}}function P(){L(t)}function w(M){var A;for(M=M||[];A=O();)A!==!1&&M.push(A);return M}function O(){var M=T();if(!(c!=E.charAt(0)||u!=E.charAt(1))){for(var A=2;d!=E.charAt(A)&&(u!=E.charAt(A)||c!=E.charAt(A+1));)++A;if(A+=2,d===E.charAt(A-1))return D("End of comment missing");var z=E.slice(2,A-2);return k+=2,N(z),E=E.slice(A),k+=2,M({type:f,comment:z})}}function R(){var M=T(),A=L(r);if(A){if(O(),!L(i))return D("property missing ':'");var z=L(o),Y=M({type:p,property:y(A[0].replace(e,d)),value:z?y(z[0].replace(e,d)):d});return L(a),Y}}function $(){var M=[];w(M);for(var A;A=R();)A!==!1&&(M.push(A),w(M));return M}return P(),$()}function y(E){return E?E.replace(s,d):d}return Hn=m,Hn}var Gt;function La(){if(Gt)return ze;Gt=1;var e=ze&&ze.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ze,"__esModule",{value:!0}),ze.default=t;const n=e(Da());function t(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,n.default)(r),s=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;s?i(c,u,l):u&&(o=o||{},o[c]=u)}),o}return ze}var je={},Kt;function Pa(){if(Kt)return je;Kt=1,Object.defineProperty(je,"__esModule",{value:!0}),je.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,t=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(c){return!c||t.test(c)||e.test(c)},a=function(c,u){return u.toUpperCase()},s=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),o(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,s):c=c.replace(r,s),c.replace(n,a))};return je.camelCase=l,je}var Qe,qt;function Fa(){if(qt)return Qe;qt=1;var e=Qe&&Qe.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},n=e(La()),t=Pa();function r(i,o){var a={};return!i||typeof i!="string"||(0,n.default)(i,function(s,l){s&&l&&(a[(0,t.camelCase)(s,o)]=l)}),a}return r.default=r,Qe=r,Qe}var Ba=Fa();const za=Br(Ba),Wr=Vr("end"),Et=Vr("start");function Vr(e){return n;function n(t){const r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ua(e){const n=Et(e),t=Wr(e);if(n&&t)return{start:n,end:t}}function rn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Wt(e.position):"start"in e||"end"in e?Wt(e):"line"in e||"column"in e?ct(e):""}function ct(e){return Vt(e&&e.line)+":"+Vt(e&&e.column)}function Wt(e){return ct(e&&e.start)+"-"+ct(e&&e.end)}function Vt(e){return e&&typeof e=="number"?e:1}class ie extends Error{constructor(n,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof n=="string"?i=n:!o.cause&&n&&(a=!0,i=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=rn(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ie.prototype.file="";ie.prototype.name="";ie.prototype.reason="";ie.prototype.message="";ie.prototype.stack="";ie.prototype.column=void 0;ie.prototype.line=void 0;ie.prototype.ancestors=void 0;ie.prototype.cause=void 0;ie.prototype.fatal=void 0;ie.prototype.place=void 0;ie.prototype.ruleId=void 0;ie.prototype.source=void 0;const xt={}.hasOwnProperty,$a=new Map,Ha=/[A-Z]/g,Ga=new Set(["table","tbody","thead","tfoot","tr"]),Ka=new Set(["td","th"]),Yr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qa(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=n.filePath||void 0;let r;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Ja(t,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Qa(t,n.jsx,n.jsxs)}const i={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:r,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?_t:Ra,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=Zr(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function Zr(e,n,t){if(n.type==="element")return Wa(e,n,t);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Va(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Za(e,n,t);if(n.type==="mdxjsEsm")return Ya(e,n);if(n.type==="root")return Xa(e,n,t);if(n.type==="text")return ja(e,n)}function Wa(e,n,t){const r=e.schema;let i=r;n.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=_t,e.schema=i),e.ancestors.push(n);const o=jr(e,n.tagName,!1),a=eo(e,n);let s=wt(e,n);return Ga.has(n.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!ka(l):!0})),Xr(e,a,o,n),kt(a,s),e.ancestors.pop(),e.schema=r,e.create(n,o,a,t)}function Va(e,n){if(n.data&&n.data.estree&&e.evaluater){const r=n.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}sn(e,n.position)}function Ya(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);sn(e,n.position)}function Za(e,n,t){const r=e.schema;let i=r;n.name==="svg"&&r.space==="html"&&(i=_t,e.schema=i),e.ancestors.push(n);const o=n.name===null?e.Fragment:jr(e,n.name,!0),a=no(e,n),s=wt(e,n);return Xr(e,a,o,n),kt(a,s),e.ancestors.pop(),e.schema=r,e.create(n,o,a,t)}function Xa(e,n,t){const r={};return kt(r,wt(e,n)),e.create(n,e.Fragment,r,t)}function ja(e,n){return n.value}function Xr(e,n,t,r){typeof t!="string"&&t!==e.Fragment&&e.passNode&&(n.node=r)}function kt(e,n){if(n.length>0){const t=n.length>1?n:n[0];t&&(e.children=t)}}function Qa(e,n,t){return r;function r(i,o,a,s){const c=Array.isArray(a.children)?t:n;return s?c(o,a,s):c(o,a)}}function Ja(e,n){return t;function t(r,i,o,a){const s=Array.isArray(o.children),l=Et(r);return n(i,o,a,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function eo(e,n){const t={};let r,i;for(i in n.properties)if(i!=="children"&&xt.call(n.properties,i)){const o=to(e,i,n.properties[i]);if(o){const[a,s]=o;e.tableCellAlignToStyle&&a==="align"&&typeof s=="string"&&Ka.has(n.tagName)?r=s:t[a]=s}}if(r){const o=t.style||(t.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return t}function no(e,n){const t={};for(const r of n.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const s=a.properties[0];s.type,Object.assign(t,e.evaluater.evaluateExpression(s.argument))}else sn(e,n.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,o=e.evaluater.evaluateExpression(s.expression)}else sn(e,n.position);else o=r.value===null?!0:r.value;t[i]=o}return t}function wt(e,n){const t=[];let r=-1;const i=e.passKeys?new Map:$a;for(;++ri?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)a=Array.from(r),a.unshift(n,t),e.splice(...a);else for(t&&e.splice(n,t);o0?(fe(e,e.length,0,n),e):n}const Xt={}.hasOwnProperty;function Jr(e){const n={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function be(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oe=Ae(/[A-Za-z]/),re=Ae(/[\dA-Za-z]/),po=Ae(/[#-'*+\--9=?A-Z^-~]/);function Tn(e){return e!==null&&(e<32||e===127)}const ut=Ae(/\d/),fo=Ae(/[\dA-Fa-f]/),mo=Ae(/[!-/:-@[-`{-~]/);function F(e){return e!==null&&e<-2}function X(e){return e!==null&&(e<0||e===32)}function G(e){return e===-2||e===-1||e===32}const Mn=Ae(new RegExp("\\p{P}|\\p{S}","u")),De=Ae(/\s/);function Ae(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ye(e){const n=[];let t=-1,r=0,i=0;for(;++t55295&&o<57344){const s=e.charCodeAt(t+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a="�"}else a=String.fromCharCode(o);a&&(n.push(e.slice(r,t),encodeURIComponent(a)),r=t+i+1,a=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function q(e,n,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(l){return G(l)?(e.enter(t),s(l)):n(l)}function s(l){return G(l)&&o++a))return;const D=n.events.length;let L=D,P,w;for(;L--;)if(n.events[L][0]==="exit"&&n.events[L][1].type==="chunkFlow"){if(P){w=n.events[L][1].end;break}P=!0}for(g(r),_=D;_k;){const T=t[N];n.containerState=T[1],T[0].exit.call(n,e)}t.length=k}function x(){i.write([null]),o=void 0,i=void 0,n.containerState._closeFlow=void 0}}function _o(e,n,t){return q(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function We(e){if(e===null||X(e)||De(e))return 1;if(Mn(e))return 2}function Dn(e,n,t){const r=[];let i=-1;for(;++i1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[t][1].start};Qt(d,-l),Qt(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[t][1].start},end:f},o={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[t][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[t][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=me(c,[["enter",e[r][1],n],["exit",e[r][1],n]])),c=me(c,[["enter",i,n],["enter",a,n],["exit",a,n],["enter",o,n]]),c=me(c,Dn(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),c=me(c,[["exit",o,n],["enter",s,n],["exit",s,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(u=2,c=me(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):u=0,fe(e,r-1,t-r+3,c),t=r+c.length-u-2;break}}for(t=-1;++t0&&G(_)?q(e,x,"linePrefix",o+1)(_):x(_)}function x(_){return _===null||F(_)?e.check(Jt,y,N)(_):(e.enter("codeFlowValue"),k(_))}function k(_){return _===null||F(_)?(e.exit("codeFlowValue"),x(_)):(e.consume(_),k)}function N(_){return e.exit("codeFenced"),n(_)}function T(_,D,L){let P=0;return w;function w(A){return _.enter("lineEnding"),_.consume(A),_.exit("lineEnding"),O}function O(A){return _.enter("codeFencedFence"),G(A)?q(_,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):R(A)}function R(A){return A===s?(_.enter("codeFencedFenceSequence"),$(A)):L(A)}function $(A){return A===s?(P++,_.consume(A),$):P>=a?(_.exit("codeFencedFenceSequence"),G(A)?q(_,M,"whitespace")(A):M(A)):L(A)}function M(A){return A===null||F(A)?(_.exit("codeFencedFence"),D(A)):L(A)}}}function Oo(e,n,t){const r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}const Kn={name:"codeIndented",tokenize:Mo},Ro={partial:!0,tokenize:Do};function Mo(e,n,t){const r=this;return i;function i(c){return e.enter("codeIndented"),q(e,o,"linePrefix",5)(c)}function o(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?a(c):t(c)}function a(c){return c===null?l(c):F(c)?e.attempt(Ro,a,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||F(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),n(c)}}function Do(e,n,t){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?t(a):F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):q(e,o,"linePrefix",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):F(a)?i(a):t(a)}}const Lo={name:"codeText",previous:Fo,resolve:Po,tokenize:Bo};function Po(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return nthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(n,t,r){const i=t||0;this.setCursor(Math.trunc(n));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Je(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Je(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Je(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n=4?n(a):e.interrupt(r.parser.constructs.flow,t,n)(a)}}function ai(e,n,t,r,i,o,a,s,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(g){return g===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(g),e.exit(o),f):g===null||g===32||g===41||Tn(g)?t(g):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),y(g))}function f(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(i),e.exit(r),n):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===62?(e.exit("chunkString"),e.exit(s),f(g)):g===null||g===60||F(g)?t(g):(e.consume(g),g===92?m:p)}function m(g){return g===60||g===62||g===92?(e.consume(g),p):p(g)}function y(g){return!u&&(g===null||g===41||X(g))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),n(g)):u999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?t(p):p===93?(e.exit(o),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):F(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||F(p)||s++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!G(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),s++,d):d(p)}}function si(e,n,t,r,i,o){let a;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),a=f===40?41:f,l):t(f)}function l(f){return f===a?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),n):(e.enter(o),c(f))}function c(f){return f===a?(e.exit(o),l(a)):f===null?t(f):F(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),q(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===a||f===null||F(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===a||f===92?(e.consume(f),u):u(f)}}function an(e,n){let t;return r;function r(i){return F(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):G(i)?q(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}const Wo={name:"definition",tokenize:Yo},Vo={partial:!0,tokenize:Zo};function Yo(e,n,t){const r=this;let i;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return oi.call(r,e,s,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=be(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):t(p)}function l(p){return X(p)?an(e,c)(p):c(p)}function c(p){return ai(e,u,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(Vo,d,d)(p)}function d(p){return G(p)?q(e,f,"whitespace")(p):f(p)}function f(p){return p===null||F(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function Zo(e,n,t){return r;function r(s){return X(s)?an(e,i)(s):t(s)}function i(s){return si(e,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function o(s){return G(s)?q(e,a,"whitespace")(s):a(s)}function a(s){return s===null||F(s)?n(s):t(s)}}const Xo={name:"hardBreakEscape",tokenize:jo};function jo(e,n,t){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return F(o)?(e.exit("hardBreakEscape"),n(o)):t(o)}}const Qo={name:"headingAtx",resolve:Jo,tokenize:es};function Jo(e,n){let t=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},o={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},fe(e,r,t-r+1,[["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n]])),e}function es(e,n,t){let r=0;return i;function i(u){return e.enter("atxHeading"),o(u)}function o(u){return e.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&r++<6?(e.consume(u),a):u===null||X(u)?(e.exit("atxHeadingSequence"),s(u)):t(u)}function s(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||F(u)?(e.exit("atxHeading"),n(u)):G(u)?q(e,s,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||X(u)?(e.exit("atxHeadingText"),s(u)):(e.consume(u),c)}}const ns=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],nr=["pre","script","style","textarea"],ts={concrete:!0,name:"htmlFlow",resolveTo:as,tokenize:os},rs={partial:!0,tokenize:ls},is={partial:!0,tokenize:ss};function as(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function os(e,n,t){const r=this;let i,o,a,s,l;return c;function c(b){return u(b)}function u(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),d}function d(b){return b===33?(e.consume(b),f):b===47?(e.consume(b),o=!0,y):b===63?(e.consume(b),i=3,r.interrupt?n:h):oe(b)?(e.consume(b),a=String.fromCharCode(b),E):t(b)}function f(b){return b===45?(e.consume(b),i=2,p):b===91?(e.consume(b),i=5,s=0,m):oe(b)?(e.consume(b),i=4,r.interrupt?n:h):t(b)}function p(b){return b===45?(e.consume(b),r.interrupt?n:h):t(b)}function m(b){const ce="CDATA[";return b===ce.charCodeAt(s++)?(e.consume(b),s===ce.length?r.interrupt?n:R:m):t(b)}function y(b){return oe(b)?(e.consume(b),a=String.fromCharCode(b),E):t(b)}function E(b){if(b===null||b===47||b===62||X(b)){const ce=b===47,ye=a.toLowerCase();return!ce&&!o&&nr.includes(ye)?(i=1,r.interrupt?n(b):R(b)):ns.includes(a.toLowerCase())?(i=6,ce?(e.consume(b),g):r.interrupt?n(b):R(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(b):o?x(b):k(b))}return b===45||re(b)?(e.consume(b),a+=String.fromCharCode(b),E):t(b)}function g(b){return b===62?(e.consume(b),r.interrupt?n:R):t(b)}function x(b){return G(b)?(e.consume(b),x):w(b)}function k(b){return b===47?(e.consume(b),w):b===58||b===95||oe(b)?(e.consume(b),N):G(b)?(e.consume(b),k):w(b)}function N(b){return b===45||b===46||b===58||b===95||re(b)?(e.consume(b),N):T(b)}function T(b){return b===61?(e.consume(b),_):G(b)?(e.consume(b),T):k(b)}function _(b){return b===null||b===60||b===61||b===62||b===96?t(b):b===34||b===39?(e.consume(b),l=b,D):G(b)?(e.consume(b),_):L(b)}function D(b){return b===l?(e.consume(b),l=null,P):b===null||F(b)?t(b):(e.consume(b),D)}function L(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||X(b)?T(b):(e.consume(b),L)}function P(b){return b===47||b===62||G(b)?k(b):t(b)}function w(b){return b===62?(e.consume(b),O):t(b)}function O(b){return b===null||F(b)?R(b):G(b)?(e.consume(b),O):t(b)}function R(b){return b===45&&i===2?(e.consume(b),z):b===60&&i===1?(e.consume(b),Y):b===62&&i===4?(e.consume(b),j):b===63&&i===3?(e.consume(b),h):b===93&&i===5?(e.consume(b),J):F(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(rs,ee,$)(b)):b===null||F(b)?(e.exit("htmlFlowData"),$(b)):(e.consume(b),R)}function $(b){return e.check(is,M,ee)(b)}function M(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),A}function A(b){return b===null||F(b)?$(b):(e.enter("htmlFlowData"),R(b))}function z(b){return b===45?(e.consume(b),h):R(b)}function Y(b){return b===47?(e.consume(b),a="",H):R(b)}function H(b){if(b===62){const ce=a.toLowerCase();return nr.includes(ce)?(e.consume(b),j):R(b)}return oe(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),H):R(b)}function J(b){return b===93?(e.consume(b),h):R(b)}function h(b){return b===62?(e.consume(b),j):b===45&&i===2?(e.consume(b),h):R(b)}function j(b){return b===null||F(b)?(e.exit("htmlFlowData"),ee(b)):(e.consume(b),j)}function ee(b){return e.exit("htmlFlow"),n(b)}}function ss(e,n,t){const r=this;return i;function i(a){return F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):t(a)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}function ls(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(un,n,t)}}const cs={name:"htmlText",tokenize:us};function us(e,n,t){const r=this;let i,o,a;return s;function s(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),l}function l(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),T):h===63?(e.consume(h),k):oe(h)?(e.consume(h),L):t(h)}function c(h){return h===45?(e.consume(h),u):h===91?(e.consume(h),o=0,m):oe(h)?(e.consume(h),x):t(h)}function u(h){return h===45?(e.consume(h),p):t(h)}function d(h){return h===null?t(h):h===45?(e.consume(h),f):F(h)?(a=d,Y(h)):(e.consume(h),d)}function f(h){return h===45?(e.consume(h),p):d(h)}function p(h){return h===62?z(h):h===45?f(h):d(h)}function m(h){const j="CDATA[";return h===j.charCodeAt(o++)?(e.consume(h),o===j.length?y:m):t(h)}function y(h){return h===null?t(h):h===93?(e.consume(h),E):F(h)?(a=y,Y(h)):(e.consume(h),y)}function E(h){return h===93?(e.consume(h),g):y(h)}function g(h){return h===62?z(h):h===93?(e.consume(h),g):y(h)}function x(h){return h===null||h===62?z(h):F(h)?(a=x,Y(h)):(e.consume(h),x)}function k(h){return h===null?t(h):h===63?(e.consume(h),N):F(h)?(a=k,Y(h)):(e.consume(h),k)}function N(h){return h===62?z(h):k(h)}function T(h){return oe(h)?(e.consume(h),_):t(h)}function _(h){return h===45||re(h)?(e.consume(h),_):D(h)}function D(h){return F(h)?(a=D,Y(h)):G(h)?(e.consume(h),D):z(h)}function L(h){return h===45||re(h)?(e.consume(h),L):h===47||h===62||X(h)?P(h):t(h)}function P(h){return h===47?(e.consume(h),z):h===58||h===95||oe(h)?(e.consume(h),w):F(h)?(a=P,Y(h)):G(h)?(e.consume(h),P):z(h)}function w(h){return h===45||h===46||h===58||h===95||re(h)?(e.consume(h),w):O(h)}function O(h){return h===61?(e.consume(h),R):F(h)?(a=O,Y(h)):G(h)?(e.consume(h),O):P(h)}function R(h){return h===null||h===60||h===61||h===62||h===96?t(h):h===34||h===39?(e.consume(h),i=h,$):F(h)?(a=R,Y(h)):G(h)?(e.consume(h),R):(e.consume(h),M)}function $(h){return h===i?(e.consume(h),i=void 0,A):h===null?t(h):F(h)?(a=$,Y(h)):(e.consume(h),$)}function M(h){return h===null||h===34||h===39||h===60||h===61||h===96?t(h):h===47||h===62||X(h)?P(h):(e.consume(h),M)}function A(h){return h===47||h===62||X(h)?P(h):t(h)}function z(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),n):t(h)}function Y(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),H}function H(h){return G(h)?q(e,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):J(h)}function J(h){return e.enter("htmlTextData"),a(h)}}const vt={name:"labelEnd",resolveAll:ms,resolveTo:gs,tokenize:hs},ds={tokenize:bs},ps={tokenize:ys},fs={tokenize:_s};function ms(e){let n=-1;const t=[];for(;++n=3&&(c===null||F(c))?(e.exit("thematicBreak"),n(c)):t(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),G(c)?q(e,s,"whitespace")(c):s(c))}}const se={continuation:{tokenize:Cs},exit:Os,name:"list",tokenize:As},vs={partial:!0,tokenize:Rs},Ts={partial:!0,tokenize:Is};function As(e,n,t){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ut(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(vn,t,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return t(p)}function l(p){return ut(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):t(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(un,r.interrupt?t:u,e.attempt(vs,f,d))}function u(p){return r.containerState.initialBlankLine=!0,o++,f(p)}function d(p){return G(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):t(p)}function f(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function Cs(e,n,t){const r=this;return r.containerState._closeFlow=void 0,e.check(un,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,q(e,n,"listItemIndent",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!G(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ts,n,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,q(e,e.attempt(se,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Is(e,n,t){const r=this;return q(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?n(o):t(o)}}function Os(e){e.exit(this.containerState.type)}function Rs(e,n,t){const r=this;return q(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!G(o)&&a&&a[1].type==="listItemPrefixWhitespace"?n(o):t(o)}}const tr={name:"setextUnderline",resolveTo:Ms,tokenize:Ds};function Ms(e,n){let t=e.length,r,i,o;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!o&&e[t][1].type==="definition"&&(o=t);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,n]),e.splice(o+1,0,["exit",e[r][1],n]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,n]),e}function Ds(e,n,t){const r=this;let i;return o;function o(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,a(c)):t(c)}function a(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===i?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),G(c)?q(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||F(c)?(e.exit("setextHeadingLine"),n(c)):t(c)}}const Ls={tokenize:Ps};function Ps(e){const n=this,t=e.attempt(un,r,e.attempt(this.parser.constructs.flowInitial,i,q(e,e.attempt(this.parser.constructs.flow,i,e.attempt($o,i)),"linePrefix")));return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,t}}const Fs={resolveAll:ci()},Bs=li("string"),zs=li("text");function li(e){return{resolveAll:ci(e==="text"?Us:void 0),tokenize:n};function n(t){const r=this,i=this.parser.constructs[e],o=t.attempt(i,a,s);return a;function a(u){return c(u)?o(u):s(u)}function s(u){if(u===null){t.consume(u);return}return t.enter("data"),t.consume(u),l}function l(u){return c(u)?(t.exit("data"),o(u)):(t.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f-1){const s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Js(e,n){let t=-1;const r=[];let i;for(;++t0){const he=B.tokenStack[B.tokenStack.length-1];(he[1]||ir).call(B,void 0,he[0])}for(C.position={start:Te(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Te(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},Z=-1;++Zi.map(i=>d[i]); -var tc=Object.defineProperty;var sc=(e,t,s)=>t in e?tc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Ut=(e,t,s)=>sc(e,typeof t!="symbol"?t+"":t,s);import{W as Zs,a as x,j as n,g as rc,b as ic,w as nc,F as oc,d as ac}from"./vendor-react-VzyiTEsu.js";import{M as lc,H as Lt,P as Tt,B as cc,u as ia,a as na,R as oa,b as aa,C as la,c as hc,d as ca}from"./vendor-reactflow-B_2yZyR4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function s(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=s(i);fetch(i.href,o)}})();const xn=e=>{let t;const s=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const p=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),s.forEach(g=>g(t,p))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>h,subscribe:c=>(s.add(c),()=>s.delete(c))},h=t=e(r,i,l);return l},dc=(e=>e?xn(e):xn),uc=e=>e;function fc(e,t=uc){const s=Zs.useSyncExternalStore(e.subscribe,Zs.useCallback(()=>t(e.getState()),[e,t]),Zs.useCallback(()=>t(e.getInitialState()),[e,t]));return Zs.useDebugValue(s),s}const yn=e=>{const t=dc(e),s=r=>fc(t,r);return Object.assign(s,t),s},Jt=(e=>e?yn(e):yn),de=Jt(e=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:t=>e(s=>{var o;let r=s.breakpoints;for(const a of t)(o=a.breakpoints)!=null&&o.length&&!r[a.id]&&(r={...r,[a.id]:Object.fromEntries(a.breakpoints.map(l=>[l,!0]))});const i={runs:Object.fromEntries(t.map(a=>[a.id,a]))};return r!==s.breakpoints&&(i.breakpoints=r),i}),upsertRun:t=>e(s=>{var i;const r={runs:{...s.runs,[t.id]:t}};if((i=t.breakpoints)!=null&&i.length&&!s.breakpoints[t.id]&&(r.breakpoints={...s.breakpoints,[t.id]:Object.fromEntries(t.breakpoints.map(o=>[o,!0]))}),(t.status==="completed"||t.status==="failed")&&s.activeNodes[t.id]){const{[t.id]:o,...a}=s.activeNodes;r.activeNodes=a}if(t.status!=="suspended"&&s.activeInterrupt[t.id]){const{[t.id]:o,...a}=s.activeInterrupt;r.activeInterrupt=a}return r}),selectRun:t=>e({selectedRunId:t}),addTrace:t=>e(s=>{const r=s.traces[t.run_id]??[],i=r.findIndex(a=>a.span_id===t.span_id),o=i>=0?r.map((a,l)=>l===i?t:a):[...r,t];return{traces:{...s.traces,[t.run_id]:o}}}),setTraces:(t,s)=>e(r=>({traces:{...r.traces,[t]:s}})),addLog:t=>e(s=>{const r=s.logs[t.run_id]??[];return{logs:{...s.logs,[t.run_id]:[...r,t]}}}),setLogs:(t,s)=>e(r=>({logs:{...r.logs,[t]:s}})),addChatEvent:(t,s)=>e(r=>{const i=r.chatMessages[t]??[],o=s.message;if(!o)return r;const a=o.messageId??o.message_id,l=o.role??"assistant",u=(o.contentParts??o.content_parts??[]).filter(y=>{const w=y.mimeType??y.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(y=>{const w=y.data;return(w==null?void 0:w.inline)??""}).join(` -`).trim(),d=(o.toolCalls??o.tool_calls??[]).map(y=>({name:y.name??"",has_result:!!y.result})),p={message_id:a,role:l,content:u,tool_calls:d.length>0?d:void 0},g=i.findIndex(y=>y.message_id===a);if(g>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((y,w)=>w===g?p:y)}};if(l==="user"){const y=i.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===u);if(y>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((w,k)=>k===y?p:w)}}}const m=[...i,p];return{chatMessages:{...r.chatMessages,[t]:m}}}),addLocalChatMessage:(t,s)=>e(r=>{const i=r.chatMessages[t]??[];return{chatMessages:{...r.chatMessages,[t]:[...i,s]}}}),setChatMessages:(t,s)=>e(r=>({chatMessages:{...r.chatMessages,[t]:s}})),setEntrypoints:t=>e({entrypoints:t}),breakpoints:{},toggleBreakpoint:(t,s)=>e(r=>{const i={...r.breakpoints[t]??{}};return i[s]?delete i[s]:i[s]=!0,{breakpoints:{...r.breakpoints,[t]:i}}}),clearBreakpoints:t=>e(s=>{const{[t]:r,...i}=s.breakpoints;return{breakpoints:i}}),activeNodes:{},setActiveNode:(t,s,r)=>e(i=>{const o=i.activeNodes[t]??{executing:{},prev:null};return{activeNodes:{...i.activeNodes,[t]:{executing:{...o.executing,[s]:r??null},prev:o.prev}}}}),removeActiveNode:(t,s)=>e(r=>{const i=r.activeNodes[t];if(!i)return r;const{[s]:o,...a}=i.executing;return{activeNodes:{...r.activeNodes,[t]:{executing:a,prev:s}}}}),resetRunGraphState:t=>e(s=>({stateEvents:{...s.stateEvents,[t]:[]},activeNodes:{...s.activeNodes,[t]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(t,s,r,i,o)=>e(a=>{const l=a.stateEvents[t]??[];return{stateEvents:{...a.stateEvents,[t]:[...l,{node_name:s,qualified_node_name:i,phase:o,timestamp:Date.now(),payload:r}]}}}),setStateEvents:(t,s)=>e(r=>({stateEvents:{...r.stateEvents,[t]:s}})),focusedSpan:null,setFocusedSpan:t=>e({focusedSpan:t}),activeInterrupt:{},setActiveInterrupt:(t,s)=>e(r=>({activeInterrupt:{...r.activeInterrupt,[t]:s}})),reloadPending:!1,setReloadPending:t=>e({reloadPending:t}),graphCache:{},setGraphCache:(t,s)=>e(r=>({graphCache:{...r.graphCache,[t]:s}}))})),Sr="/api";async function pc(e){const t=await fetch(`${Sr}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({environment:e})});if(!t.ok)throw new Error(`Login failed: ${t.status}`);return t.json()}async function Or(){const e=await fetch(`${Sr}/auth/status`);if(!e.ok)throw new Error(`Status check failed: ${e.status}`);return e.json()}async function _c(e){const t=await fetch(`${Sr}/auth/select-tenant`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tenant_name:e})});if(!t.ok)throw new Error(`Tenant selection failed: ${t.status}`);return t.json()}async function gc(){await fetch(`${Sr}/auth/logout`,{method:"POST"})}const ha="uipath-env",mc=["cloud","staging","alpha"];function vc(){const e=localStorage.getItem(ha);return mc.includes(e)?e:"cloud"}const da=Jt((e,t)=>({enabled:!0,status:"unauthenticated",environment:vc(),tenants:[],uipathUrl:null,pollTimer:null,expiryTimer:null,init:async()=>{try{const s=await fetch("/api/config");if(s.ok&&!(await s.json()).auth_enabled){e({enabled:!1});return}const r=await Or();e({status:r.status,tenants:r.tenants??[],uipathUrl:r.uipath_url??null}),r.status==="authenticated"&&t().startExpiryCheck()}catch(s){console.error("Auth init failed",s)}},setEnvironment:s=>{localStorage.setItem(ha,s),e({environment:s})},startLogin:async()=>{const{environment:s}=t();try{const r=await pc(s);e({status:"pending"}),window.open(r.auth_url,"_blank"),t().pollStatus()}catch(r){console.error("Login failed",r)}},pollStatus:()=>{const{pollTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{const i=await Or();i.status!=="pending"&&(t().stopPolling(),e({status:i.status,tenants:i.tenants??[],uipathUrl:i.uipath_url??null}),i.status==="authenticated"&&t().startExpiryCheck())}catch{}},2e3);e({pollTimer:r})},stopPolling:()=>{const{pollTimer:s}=t();s&&(clearInterval(s),e({pollTimer:null}))},startExpiryCheck:()=>{const{expiryTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{(await Or()).status==="expired"&&(t().stopExpiryCheck(),e({status:"expired"}))}catch{}},3e4);e({expiryTimer:r})},stopExpiryCheck:()=>{const{expiryTimer:s}=t();s&&(clearInterval(s),e({expiryTimer:null}))},selectTenant:async s=>{try{const r=await _c(s);e({status:"authenticated",uipathUrl:r.uipath_url,tenants:[]}),t().startExpiryCheck()}catch(r){console.error("Tenant selection failed",r)}},logout:async()=>{t().stopPolling(),t().stopExpiryCheck();try{await gc()}catch{}e({status:"unauthenticated",tenants:[],uipathUrl:null})}})),ua=Jt(e=>({projectName:null,projectVersion:null,projectAuthors:null,init:async()=>{try{const t=await fetch("/api/config");if(t.ok){const s=await t.json();e({projectName:s.project_name??null,projectVersion:s.project_version??null,projectAuthors:s.project_authors??null})}}catch{}}}));class xc{constructor(t){Ut(this,"ws",null);Ut(this,"url");Ut(this,"handlers",new Set);Ut(this,"reconnectTimer",null);Ut(this,"shouldReconnect",!0);Ut(this,"pendingMessages",[]);Ut(this,"activeSubscriptions",new Set);const s=window.location.protocol==="https:"?"wss:":"ws:";this.url=t??`${s}//${window.location.host}/ws`}connect(){var t;((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const s of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:s}}));for(const s of this.pendingMessages)this.sendRaw(s);this.pendingMessages=[]},this.ws.onmessage=s=>{let r;try{r=JSON.parse(s.data)}catch{console.warn("[ws] failed to parse message",s.data);return}this.handlers.forEach(i=>{try{i(r)}catch(o){console.error("[ws] handler error",o)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var s;(s=this.ws)==null||s.close()})}disconnect(){var t;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(t=this.ws)==null||t.close(),this.ws=null}onMessage(t){return this.handlers.add(t),()=>this.handlers.delete(t)}sendRaw(t){var s;((s=this.ws)==null?void 0:s.readyState)===WebSocket.OPEN&&this.ws.send(t)}send(t,s){var i;const r=JSON.stringify({type:t,payload:s});((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN?this.ws.send(r):this.pendingMessages.push(r)}subscribe(t){this.activeSubscriptions.add(t),this.send("subscribe",{run_id:t})}unsubscribe(t){this.activeSubscriptions.delete(t),this.send("unsubscribe",{run_id:t})}sendChatMessage(t,s){this.send("chat.message",{run_id:t,text:s})}sendInterruptResponse(t,s){this.send("chat.interrupt_response",{run_id:t,data:s})}debugStep(t){this.send("debug.step",{run_id:t})}debugContinue(t){this.send("debug.continue",{run_id:t})}debugStop(t){this.send("debug.stop",{run_id:t})}setBreakpoints(t,s){this.send("debug.set_breakpoints",{run_id:t,breakpoints:s})}sendCliAgentStart(t,s,r,i){this.send("cli_agent.start",{agent_id:t,session_id:s,cols:r,rows:i})}sendCliAgentInput(t,s){this.send("cli_agent.input",{session_id:t,data:s})}sendCliAgentResize(t,s,r){this.send("cli_agent.resize",{session_id:t,cols:s,rows:r})}sendCliAgentStop(t){this.send("cli_agent.stop",{session_id:t})}}const Zt="/api";async function Qt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function $i(){return Qt(`${Zt}/entrypoints`)}async function yc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/schema`)}async function bc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/mock-input`)}async function fa(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/graph`)}async function bn(e,t,s="run",r=[]){return Qt(`${Zt}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:e,input_data:t,mode:s,breakpoints:r})})}async function Sc(){return Qt(`${Zt}/runs`)}async function Ir(e){return Qt(`${Zt}/runs/${e}`)}async function wc(){return Qt(`${Zt}/reload`,{method:"POST"})}const Se=Jt(e=>({evaluators:[],localEvaluators:[],evalSets:{},evalRuns:{},streamingResults:{},setEvaluators:t=>e({evaluators:t}),setLocalEvaluators:t=>e({localEvaluators:t}),addLocalEvaluator:t=>e(s=>({localEvaluators:[...s.localEvaluators,t]})),upsertLocalEvaluator:t=>e(s=>({localEvaluators:s.localEvaluators.some(r=>r.id===t.id)?s.localEvaluators.map(r=>r.id===t.id?t:r):[...s.localEvaluators,t]})),setEvalSets:t=>e({evalSets:Object.fromEntries(t.map(s=>[s.id,s]))}),addEvalSet:t=>e(s=>({evalSets:{...s.evalSets,[t.id]:t}})),updateEvalSetEvaluators:(t,s)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,evaluator_ids:s}}}:r}),incrementEvalSetCount:(t,s=1)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,eval_count:i.eval_count+s}}}:r}),setEvalRuns:t=>e({evalRuns:Object.fromEntries(t.map(s=>[s.id,s]))}),upsertEvalRun:t=>e(s=>({evalRuns:{...s.evalRuns,[t.id]:t}})),updateEvalRunProgress:(t,s,r,i)=>e(o=>{const a=o.evalRuns[t];if(!a)return o;const l={...o.streamingResults};return i&&(l[t]={...l[t],[i.name]:i}),{evalRuns:{...o.evalRuns,[t]:{...a,progress_completed:s,progress_total:r,status:"running"}},streamingResults:l}}),completeEvalRun:(t,s,r)=>e(i=>{const o=i.evalRuns[t];if(!o)return i;const a={...i.streamingResults};return delete a[t],{evalRuns:{...i.evalRuns,[t]:{...o,status:"completed",overall_score:s,evaluator_scores:r,end_time:new Date().toISOString()}},streamingResults:a}})})),Ms=Jt(e=>({availableAgents:[],selectedAgentId:null,sessionId:null,status:"idle",exitCode:null,events:[],setAvailableAgents:t=>{e(s=>{const r={availableAgents:t};if(!s.selectedAgentId){const i=t.find(o=>o.installed);i&&(r.selectedAgentId=i.id)}return r})},setSelectedAgentId:t=>e({selectedAgentId:t}),setSessionId:t=>e({sessionId:t}),setStatus:t=>e({status:t}),setExitCode:t=>e({exitCode:t}),addEvent:t=>e(s=>({events:[...s.events,t]}))})),xe=Jt(e=>({children:{},expanded:{},selectedFile:null,openTabs:[],fileCache:{},dirty:{},buffers:{},loadingDirs:{},loadingFile:!1,agentChangedFiles:{},diffView:null,setChildren:(t,s)=>e(r=>({children:{...r.children,[t]:s}})),toggleExpanded:t=>e(s=>({expanded:{...s.expanded,[t]:!s.expanded[t]}})),setSelectedFile:t=>e({selectedFile:t}),openTab:t=>e(s=>({selectedFile:t,openTabs:s.openTabs.includes(t)?s.openTabs:[...s.openTabs,t]})),closeTab:t=>e(s=>{const r=s.openTabs.filter(c=>c!==t);let i=s.selectedFile;if(i===t){const c=s.openTabs.indexOf(t);i=r[Math.min(c,r.length-1)]??null}const{[t]:o,...a}=s.dirty,{[t]:l,...h}=s.buffers;return{openTabs:r,selectedFile:i,dirty:a,buffers:h}}),setFileContent:(t,s)=>e(r=>({fileCache:{...r.fileCache,[t]:s}})),updateBuffer:(t,s)=>e(r=>({buffers:{...r.buffers,[t]:s},dirty:{...r.dirty,[t]:!0}})),markClean:t=>e(s=>{const{[t]:r,...i}=s.dirty,{[t]:o,...a}=s.buffers;return{dirty:i,buffers:a}}),setLoadingDir:(t,s)=>e(r=>({loadingDirs:{...r.loadingDirs,[t]:s}})),setLoadingFile:t=>e({loadingFile:t}),markAgentChanged:t=>e(s=>({agentChangedFiles:{...s.agentChangedFiles,[t]:Date.now()}})),clearAgentChanged:t=>e(s=>{const{[t]:r,...i}=s.agentChangedFiles;return{agentChangedFiles:i}}),setDiffView:t=>e({diffView:t}),expandPath:t=>e(s=>{const r=t.split("/"),i={...s.expanded};for(let o=1;oe.current.onMessage(y=>{switch(y.type){case"run.updated":{const w=y.payload;t(w),(w.status==="running"||w.status==="completed"||w.status==="failed")&&Ms.getState().addEvent({type:"run_lifecycle",timestamp:Date.now(),runId:w.id,entrypoint:w.entrypoint,status:w.status});break}case"trace":s(y.payload);break;case"log":r(y.payload);break;case"chat":{const w=y.payload.run_id;i(w,y.payload);break}case"chat.interrupt":{const w=y.payload.run_id;o(w,y.payload);break}case"state":{const w=y.payload.run_id,k=y.payload.node_name,C=y.payload.qualified_node_name??null,A=y.payload.phase??null,O=y.payload.payload;k==="__start__"&&A==="started"&&h(w),A==="started"?a(w,k,C):A==="completed"&&l(w,k),c(w,k,O,C,A);break}case"reload":{y.payload.reloaded?$i().then(k=>{const C=de.getState();C.setEntrypoints(k.map(A=>A.name)),C.setReloadPending(!1)}).catch(k=>console.error("Failed to refresh entrypoints:",k)):de.getState().setReloadPending(!0);break}case"files.changed":{const w=y.payload.files,k=new Set(w),C=xe.getState(),A=w.filter(P=>P in C.children?!1:(P.split("/").pop()??"").includes("."));A.length>0&&Ms.getState().addEvent({type:"files_changed",timestamp:Date.now(),files:A});for(const P of C.openTabs)C.dirty[P]||!k.has(P)||pa(P).then(j=>{var L;const D=xe.getState();D.dirty[P]||((L=D.fileCache[P])==null?void 0:L.content)!==j.content&&D.setFileContent(P,j)}).catch(()=>{});const O=new Set;for(const P of w){const j=P.lastIndexOf("/"),D=j===-1?"":P.substring(0,j);D in C.children&&O.add(D)}for(const P of O)Ki(P).then(j=>xe.getState().setChildren(P,j)).catch(()=>{});break}case"eval_run.created":u(y.payload);break;case"eval_run.progress":{const{run_id:w,completed:k,total:C,item_result:A}=y.payload;d(w,k,C,A);break}case"eval_run.completed":{const{run_id:w,overall_score:k,evaluator_scores:C}=y.payload;p(w,k,C);break}case"cli_agent.output":{const{session_id:w,data:k}=y.payload,C=Ec(w);if(C){const A=Uint8Array.from(atob(k),O=>O.charCodeAt(0));C(A)}break}case"cli_agent.exit":{const{session_id:w,exit_code:k}=y.payload,C=Ms.getState();if(C.sessionId===w){C.setStatus("exited"),C.setExitCode(k);const A=C.availableAgents.find(O=>O.id===C.selectedAgentId);C.addEvent({type:"session",timestamp:Date.now(),agentName:(A==null?void 0:A.name)??"Unknown",action:"exited",exitCode:k})}break}case"mcp.tool_call":{const{tool:w,args:k}=y.payload;Ms.getState().addEvent({type:"mcp_tool_call",timestamp:Date.now(),tool:w,args:k});break}}}),[t,s,r,i,o,a,l,h,c,u,d,p]),e.current}function Mc(e){const t=e.replace(/^#\/?/,""),s={section:"debug",view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null,evalCreating:!1,evalSetId:null,evalRunId:null,evalRunItemName:null,evaluatorId:null,evaluatorCreateType:null,evaluatorFilter:null,explorerFile:null};if(!t||t==="new"||t==="debug"||t==="debug/new")return s;const r=t.match(/^(?:debug\/)?setup\/([^/]+)\/(run|chat)$/);if(r)return{...s,view:"setup",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const i=t.match(/^(?:debug\/)?runs\/([^/]+)(?:\/(traces|output))?$/);if(i)return{...s,view:"details",runId:i[1],tab:i[2]??"traces"};if(t==="evals/new")return{...s,section:"evals",evalCreating:!0};const o=t.match(/^evals\/runs\/([^/]+?)(?:\/([^/]+))?$/);if(o)return{...s,section:"evals",evalRunId:o[1],evalRunItemName:o[2]?decodeURIComponent(o[2]):null};const a=t.match(/^evals\/sets\/([^/]+)$/);if(a)return{...s,section:"evals",evalSetId:a[1]};if(t==="evals")return{...s,section:"evals"};const l=t.match(/^evaluators\/new(?:\/(deterministic|llm|tool))?$/);if(l)return{...s,section:"evaluators",evaluatorCreateType:l[1]??"any"};const h=t.match(/^evaluators\/category\/(deterministic|llm|tool)$/);if(h)return{...s,section:"evaluators",evaluatorFilter:h[1]};const c=t.match(/^evaluators\/([^/]+)$/);if(c)return{...s,section:"evaluators",evaluatorId:c[1]};if(t==="evaluators")return{...s,section:"evaluators"};if(t==="explorer/canvas")return{...s,section:"explorer",explorerFile:"__canvas__"};const u=t.match(/^explorer\/statedb\/(.+)$/);if(u)return{...s,section:"explorer",explorerFile:`__statedb__:${decodeURIComponent(u[1])}`};const d=t.match(/^explorer\/file\/(.+)$/);return d?{...s,section:"explorer",explorerFile:decodeURIComponent(d[1])}:t==="explorer"?{...s,section:"explorer"}:s}function Lc(){return window.location.hash}function Tc(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function et(){const e=x.useSyncExternalStore(Tc,Lc),t=Mc(e),s=x.useCallback(r=>{window.location.hash=r},[]);return{...t,navigate:s}}const Sn="(max-width: 767px)";function Rc(){const[e,t]=x.useState(()=>window.matchMedia(Sn).matches);return x.useEffect(()=>{const s=window.matchMedia(Sn),r=i=>t(i.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),e}const Bc=[{section:"debug",label:"Developer Console",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"8",y:"6",width:"8",height:"14",rx:"4"}),n.jsx("path",{d:"M6 10H4"}),n.jsx("path",{d:"M6 18H4"}),n.jsx("path",{d:"M18 10h2"}),n.jsx("path",{d:"M18 18h2"}),n.jsx("path",{d:"M8 14h8"}),n.jsx("path",{d:"M9 6l-1.5-2"}),n.jsx("path",{d:"M15 6l1.5-2"}),n.jsx("path",{d:"M6 14H4"}),n.jsx("path",{d:"M18 14h2"})]})},{section:"evals",label:"Evals",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.5L5 20a1 1 0 0 0 .9 1.4h12.2a1 1 0 0 0 .9-1.4L14 9.5V3"}),n.jsx("path",{d:"M8.5 14h7"})]})},{section:"evaluators",label:"Evaluators",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2l7 4v5c0 5.25-3.5 9.74-7 11-3.5-1.26-7-5.75-7-11V6l7-4z"}),n.jsx("path",{d:"M9 12l2 2 4-4"})]})},{section:"explorer",label:"Explorer",icon:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",children:n.jsx("path",{d:"M7.5 22.5H17.595C17.07 23.4 16.11 24 15 24H7.5C4.185 24 1.5 21.315 1.5 18V6C1.5 4.89 2.1 3.93 3 3.405V18C3 20.475 5.025 22.5 7.5 22.5ZM21 8.121V18C21 19.6545 19.6545 21 18 21H7.5C5.8455 21 4.5 19.6545 4.5 18V3C4.5 1.3455 5.8455 0 7.5 0H12.879C13.4715 0 14.0505 0.24 14.4705 0.6585L20.3415 6.5295C20.766 6.954 21 7.5195 21 8.121ZM13.5 6.75C13.5 7.164 13.8375 7.5 14.25 7.5H19.1895L13.5 1.8105V6.75ZM19.5 18V9H14.25C13.0095 9 12 7.9905 12 6.75V1.5H7.5C6.672 1.5 6 2.1735 6 3V18C6 18.8265 6.672 19.5 7.5 19.5H18C18.828 19.5 19.5 18.8265 19.5 18Z"})})}];function Dc({section:e,onSectionChange:t}){return n.jsx("div",{className:"w-12 flex flex-col items-center shrink-0 border-r",style:{background:"var(--activity-bar-bg)",borderColor:"var(--border)"},children:n.jsx("div",{className:"flex flex-col items-center gap-1 pt-2",children:Bc.map(s=>{const r=e===s.section;return n.jsxs("button",{onClick:()=>t(s.section),className:"w-10 h-10 flex items-center justify-center rounded cursor-pointer transition-colors relative",style:{color:r?"var(--text-primary)":"var(--text-muted)",background:r?"var(--bg-hover)":"transparent",border:"none"},title:s.label,onMouseEnter:i=>{r||(i.currentTarget.style.color="var(--text-secondary)")},onMouseLeave:i=>{r||(i.currentTarget.style.color="var(--text-muted)")},children:[r&&n.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r",style:{background:"var(--accent)"}}),s.icon]},s.section)})})})}const lt="/api";async function ct(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Pc(){return ct(`${lt}/evaluators`)}async function _a(){return ct(`${lt}/eval-sets`)}async function Ac(e){return ct(`${lt}/eval-sets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Oc(e,t){return ct(`${lt}/eval-sets/${encodeURIComponent(e)}/items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function Ic(e,t){await ct(`${lt}/eval-sets/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Wc(e){return ct(`${lt}/eval-sets/${encodeURIComponent(e)}`)}async function Hc(e){return ct(`${lt}/eval-sets/${encodeURIComponent(e)}/runs`,{method:"POST"})}async function $c(){return ct(`${lt}/eval-runs`)}async function wn(e){return ct(`${lt}/eval-runs/${encodeURIComponent(e)}`)}async function Vi(){return ct(`${lt}/local-evaluators`)}async function Fc(e){return ct(`${lt}/local-evaluators`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function zc(e,t){return ct(`${lt}/eval-sets/${encodeURIComponent(e)}/evaluators`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({evaluator_refs:t})})}async function Uc(e,t){return ct(`${lt}/local-evaluators/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}const Kc={"uipath-exact-match":e=>({expectedOutput:e}),"uipath-json-similarity":e=>({expectedOutput:e}),"uipath-contains":()=>({searchText:""}),"uipath-llm-judge-output-semantic-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-output-strict-json-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-trajectory-similarity":()=>({expectedAgentBehavior:""}),"uipath-llm-judge-trajectory-simulation":()=>({expectedAgentBehavior:""}),"uipath-tool-call-count":()=>({}),"uipath-tool-call-args":()=>({}),"uipath-tool-call-order":()=>({}),"uipath-tool-call-output":()=>({})};function Vc(e,t){if(!e)return{};const s=Kc[e.evaluator_type_id];return s?s(t):e.type==="tool"?{}:e.evaluator_type_id.includes("trajectory")?{expectedAgentBehavior:""}:{expectedOutput:t}}function ga(e){return e?e.type==="tool"?!0:e.evaluator_type_id.includes("tool-call"):!1}function qc(e){return e?ga(e)?{label:"tools",color:"var(--warning, #e5a00d)"}:e.evaluator_type_id.includes("trajectory")?{label:"quality",color:"var(--info, #3b82f6)"}:{label:"output",color:"var(--success, #22c55e)"}:{label:"output",color:"var(--success, #22c55e)"}}function Xc({run:e,onClose:t}){const s=Se(B=>B.evalSets),r=Se(B=>B.setEvalSets),i=Se(B=>B.incrementEvalSetCount),o=Se(B=>B.localEvaluators),a=Se(B=>B.setLocalEvaluators),[l,h]=x.useState(`run-${e.id.slice(0,8)}`),[c,u]=x.useState(new Set),[d,p]=x.useState({}),g=x.useRef(new Set),[m,y]=x.useState(!1),[w,k]=x.useState(null),[C,A]=x.useState(!1),O=Object.values(s),P=x.useMemo(()=>Object.fromEntries(o.map(B=>[B.id,B])),[o]),j=x.useMemo(()=>{const B=new Set;for(const I of c){const M=s[I];M&&M.evaluator_ids.forEach(R=>B.add(R))}return[...B]},[c,s]);x.useEffect(()=>{const B=e.output_data,I=g.current;p(M=>{const R={};for(const _ of j)if(I.has(_)&&M[_]!==void 0)R[_]=M[_];else{const f=P[_],v=Vc(f,B);R[_]=JSON.stringify(v,null,2)}return R})},[j,P,e.output_data]),x.useEffect(()=>{const B=I=>{I.key==="Escape"&&t()};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[t]),x.useEffect(()=>{O.length===0&&_a().then(r).catch(()=>{}),o.length===0&&Vi().then(a).catch(()=>{})},[]);const D=B=>{u(I=>{const M=new Set(I);return M.has(B)?M.delete(B):M.add(B),M})},L=async()=>{var I;if(!l.trim()||c.size===0)return;k(null),y(!0);const B={};for(const M of j){const R=d[M];if(R!==void 0)try{B[M]=JSON.parse(R)}catch{k(`Invalid JSON for evaluator "${((I=P[M])==null?void 0:I.name)??M}"`),y(!1);return}}try{for(const M of c){const R=s[M],_=new Set((R==null?void 0:R.evaluator_ids)??[]),f={};for(const[v,b]of Object.entries(B))_.has(v)&&(f[v]=b);await Oc(M,{name:l.trim(),inputs:e.input_data,expected_output:null,evaluation_criterias:f}),i(M)}A(!0),setTimeout(t,3e3)}catch(M){k(M.detail||M.message||"Failed to add item")}finally{y(!1)}};return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:B=>{B.target===B.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg p-6 shadow-xl max-h-[85vh] flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"Add to Eval Set"})]}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:B=>{B.currentTarget.style.color="var(--text-primary)"},onMouseLeave:B=>{B.currentTarget.style.color="var(--text-muted)"},"aria-label":"Close",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-4 pr-1",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Item Name"}),n.jsx("input",{type:"text",value:l,onChange:B=>h(B.target.value),className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Inputs"}),n.jsx("pre",{className:"rounded-md px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(e.input_data,null,2)})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Eval Sets"}),O.length===0?n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No eval sets found. Create one first."}):n.jsx("div",{className:"rounded-md border overflow-hidden max-h-40 overflow-y-auto",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:O.map(B=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:I=>{I.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:c.has(B.id),onChange:()=>D(B.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:B.name}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[B.eval_count," items"]})]},B.id))})]}),j.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluation Criteria"}),n.jsx("div",{className:"space-y-2",children:j.map(B=>{const I=P[B],M=ga(I),R=qc(I);return n.jsxs("div",{className:"rounded-md",style:{border:"1px solid var(--border)",background:"var(--bg-primary)",opacity:M?.6:1},children:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:M?"none":"1px solid var(--border)"},children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",style:{color:"var(--text-primary)"},children:(I==null?void 0:I.name)??B}),n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{color:R.color,background:`color-mix(in srgb, ${R.color} 12%, transparent)`},children:R.label})]}),M?n.jsx("div",{className:"px-3 pb-2",children:n.jsx("span",{className:"text-[10px] italic",style:{color:"var(--text-muted)"},children:"Default criteria — uses evaluator config"})}):n.jsx("div",{className:"px-3 pb-2 pt-1",children:n.jsx("textarea",{value:d[B]??"{}",onChange:_=>{g.current.add(B),p(f=>({...f,[B]:_.target.value}))},rows:8,className:"w-full rounded px-2 py-1.5 text-xs font-mono resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})})]},B)})})]})]}),n.jsxs("div",{className:"mt-4 space-y-3",children:[w&&n.jsx("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:w}),C&&n.jsxs("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--success)",background:"color-mix(in srgb, var(--success) 10%, var(--bg-secondary))"},children:["Added to ",c.size," eval set",c.size!==1?"s":"","."]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:t,className:"flex-1 py-2 rounded-md text-xs font-semibold cursor-pointer",style:{background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Cancel"}),n.jsx("button",{onClick:L,disabled:!l.trim()||c.size===0||m||C,className:"flex-1 py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:m?"Adding...":C?"Added":"Add Item"})]})]})]})})}const Yc={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function Gc({run:e,isSelected:t,onClick:s}){var d;const r=Yc[e.status]??"var(--text-muted)",i=((d=e.entrypoint.split("/").pop())==null?void 0:d.slice(0,16))??e.entrypoint,o=e.start_time?new Date(e.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",[a,l]=x.useState(!1),[h,c]=x.useState(!1),u=x.useRef(null);return x.useEffect(()=>{if(!a)return;const p=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[a]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"group relative w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:t?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:t?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:p=>{t||(p.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:p=>{t||(p.currentTarget.style.background="")},onClick:s,children:[n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:r}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs truncate",style:{color:t?"var(--text-primary)":"var(--text-secondary)"},children:i}),n.jsxs("div",{className:"text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[o,e.duration?` · ${e.duration}`:""]})]}),e.status==="completed"&&n.jsxs("div",{ref:u,className:"relative shrink-0",children:[n.jsx("button",{onClick:p=>{p.stopPropagation(),l(g=>!g)},className:"opacity-40 group-hover:opacity-100 focus:opacity-100 w-7 h-7 flex items-center justify-center rounded transition-opacity cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:p=>{p.currentTarget.style.color="var(--text-primary)",p.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:p=>{p.currentTarget.style.color="var(--text-muted)",p.currentTarget.style.background=""},"aria-label":"Actions",title:"Actions",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}),a&&n.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[140px] rounded-md shadow-lg py-1",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:n.jsx("button",{onClick:p=>{p.stopPropagation(),l(!1),c(!0)},className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},onMouseEnter:p=>{p.currentTarget.style.background="var(--bg-hover)",p.currentTarget.style.color="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.background="",p.currentTarget.style.color="var(--text-secondary)"},children:"Add to Eval Set"})})]})]}),h&&n.jsx(Xc,{run:e,onClose:()=>c(!1)})]})}function Cn({runs:e,selectedRunId:t,onSelectRun:s,onNewRun:r}){const i=[...e].sort((o,a)=>new Date(a.start_time??0).getTime()-new Date(o.start_time??0).getTime());return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:r,className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Run"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(o=>n.jsx(Gc,{run:o,isSelected:o.id===t,onClick:()=>s(o.id)},o.id)),i.length===0&&n.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]})]})}function ma(){const e=localStorage.getItem("uipath-dev-theme");return e==="light"||e==="dark"?e:"dark"}function va(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("uipath-dev-theme",e)}va(ma());const xa=Jt(e=>({theme:ma(),toggleTheme:()=>e(t=>{const s=t.theme==="dark"?"light":"dark";return va(s),{theme:s}})}));function kn(){const{theme:e,toggleTheme:t}=xa(),{enabled:s,status:r,environment:i,tenants:o,uipathUrl:a,setEnvironment:l,startLogin:h,selectTenant:c,logout:u}=da(),{projectName:d,projectVersion:p,projectAuthors:g}=ua(),[m,y]=x.useState(!1),[w,k]=x.useState(""),C=x.useRef(null),A=x.useRef(null);x.useEffect(()=>{if(!m)return;const f=v=>{C.current&&!C.current.contains(v.target)&&A.current&&!A.current.contains(v.target)&&y(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[m]);const O=r==="authenticated",P=r==="expired",j=r==="pending",D=r==="needs_tenant";let L="UiPath: Disconnected",B=null,I=!0;O?(L=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""}`,B="var(--success)",I=!1):P?(L=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""} (expired)`,B="var(--error)",I=!1):j?L="UiPath: Signing in…":D&&(L="UiPath: Select Tenant");const M=()=>{j||(P?h():y(f=>!f))},R="flex items-center gap-1 px-1.5 rounded transition-colors",_={onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="",f.currentTarget.style.color="var(--text-muted)"}};return n.jsxs("div",{className:"h-6 flex items-center justify-end gap-3 px-2 text-xs border-t shrink-0",style:{background:"var(--bg-secondary)",color:"var(--text-muted)",borderColor:"var(--border)",fontSize:"11px"},children:[s&&n.jsxs("div",{className:"relative flex items-center",children:[n.jsxs("div",{ref:A,className:`${R} cursor-pointer`,onClick:M,..._,title:O?a??"":P?"Token expired — click to re-authenticate":j?"Signing in…":D?"Select a tenant":"Click to sign in",children:[j?n.jsxs("svg",{className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),n.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})]}):B?n.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:B}}):I?n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}):null,n.jsx("span",{className:"truncate max-w-[200px]",children:L})]}),m&&n.jsx("div",{ref:C,className:"absolute bottom-full right-0 mb-1 rounded border shadow-lg p-1 min-w-[180px]",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},children:O||P?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>{a&&window.open(a,"_blank","noopener,noreferrer"),y(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Go to Platform"]}),n.jsxs("button",{onClick:()=>{u(),y(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]}):D?n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Tenant"}),n.jsxs("select",{value:w,onChange:f=>k(f.target.value),className:"w-full rounded px-1.5 py-1 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:[n.jsx("option",{value:"",children:"Select…"}),o.map(f=>n.jsx("option",{value:f,children:f},f))]}),n.jsx("button",{onClick:()=>{w&&(c(w),y(!1))},disabled:!w,className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--text-muted)"},children:"Confirm"})]}):n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Environment"}),n.jsxs("select",{value:i,onChange:f=>l(f.target.value),className:"w-full rounded px-1.5 py-0.5 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-muted)"},children:[n.jsx("option",{value:"cloud",children:"cloud"}),n.jsx("option",{value:"staging",children:"staging"}),n.jsx("option",{value:"alpha",children:"alpha"})]}),n.jsx("button",{onClick:()=>{h(),y(!1)},className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:f=>{f.currentTarget.style.color="var(--text-primary)",f.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:f=>{f.currentTarget.style.color="var(--text-muted)",f.currentTarget.style.borderColor="var(--border)"},children:"Sign In"})]})})]}),d&&n.jsxs("span",{className:R,children:["Project: ",d]}),p&&n.jsxs("span",{className:R,children:["Version: v",p]}),g&&n.jsxs("span",{className:R,children:["Author: ",g]}),n.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:`${R} cursor-pointer no-underline`,style:{color:"var(--text-muted)"},..._,title:"View on GitHub",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),n.jsx("span",{children:"uipath-dev-python"})]}),n.jsxs("div",{className:`${R} cursor-pointer`,onClick:t,..._,title:`Switch to ${e==="dark"?"light":"dark"} theme`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e==="dark"?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),n.jsx("span",{children:e==="dark"?"Dark":"Light"})]})]})}function Jc(){const{navigate:e}=et(),t=de(c=>c.entrypoints),[s,r]=x.useState(""),[i,o]=x.useState(!0),[a,l]=x.useState(null);x.useEffect(()=>{!s&&t.length>0&&r(t[0])},[t,s]),x.useEffect(()=>{s&&(o(!0),l(null),yc(s).then(c=>{var d;const u=(d=c.input)==null?void 0:d.properties;o(!!(u!=null&&u.messages))}).catch(c=>{const u=c.detail||{};l(u.error||u.message||`Failed to load entrypoint "${s}"`)}))},[s]);const h=c=>{s&&e(`#/setup/${encodeURIComponent(s)}/${c}`)};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),t.length>1&&n.jsxs("div",{className:"mb-8",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Entrypoint"}),n.jsx("select",{id:"entrypoint-select",value:s,onChange:c=>r(c.target.value),className:"w-full rounded-md px-3 py-2 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:t.map(c=>n.jsx("option",{value:c,children:c},c))})]}),a?n.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),n.jsx("div",{className:"overflow-auto max-h-48 p-3",children:n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(En,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:n.jsx(Zc,{}),color:"var(--success)",onClick:()=>h("run"),disabled:!s}),n.jsx(En,{title:"Conversational",description:i?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:n.jsx(Qc,{}),color:"var(--accent)",onClick:()=>h("chat"),disabled:!s||!i})]})]})})}function En({title:e,description:t,icon:s,color:r,onClick:i,disabled:o}){return n.jsxs("button",{onClick:i,disabled:o,className:"group flex flex-col items-center text-center p-6 rounded-md border transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{o||(a.currentTarget.style.borderColor=r,a.currentTarget.style.background=`color-mix(in srgb, ${r} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[n.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${r} 10%, var(--bg-primary))`,color:r},children:s}),n.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:e}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:t})]})}function Zc(){return n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function Qc(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),n.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),n.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),n.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),n.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),n.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),n.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const eh="modulepreload",th=function(e){return"/"+e},Nn={},ya=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){let a=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(s.map(c=>{if(c=th(c),c in Nn)return;Nn[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":eh,u||(p.as="script"),p.crossOrigin="",p.href=c,h&&p.setAttribute("nonce",h),document.head.appendChild(p),u)return new Promise((g,m)=>{p.addEventListener("load",g),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},sh=80,rh=32,ih=13;function jn(e){const t=(e==null?void 0:e.label)??"";return Math.max(sh,t.length*8+32)}function Mn(e,t){let s=rh;(t==="modelNode"||t==="toolNode")&&(s+=ih);const r=e==null?void 0:e.tool_names;return r&&r.length>0&&(s+=Math.min(r.length,3)*12+(r.length>3?12:0)+4),e!=null&&e.model_name&&(s+=14),s}let Wr=null;async function nh(){if(!Wr){const{default:e}=await ya(async()=>{const{default:t}=await import("./vendor-elk-BkmlSRbk.js").then(s=>s.e);return{default:t}},__vite__mapDeps([0,1]));Wr=new e}return Wr}const Ln={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},oh="[top=35,left=15,bottom=15,right=15]";function ah(e){const t=[],s=[];for(const r of e.nodes){const i=r.data,o={id:r.id,width:jn(i),height:Mn(i,r.type)};if(r.data.subgraph){const a=r.data.subgraph;delete o.width,delete o.height,o.layoutOptions={...Ln,"elk.padding":oh},o.children=a.nodes.map(l=>({id:`${r.id}/${l.id}`,width:jn(l.data),height:Mn(l.data,l.type)})),o.edges=a.edges.map(l=>({id:`${r.id}/${l.id}`,sources:[`${r.id}/${l.source}`],targets:[`${r.id}/${l.target}`]}))}t.push(o)}for(const r of e.edges)s.push({id:r.id,sources:[r.source],targets:[r.target]});return{id:"root",layoutOptions:Ln,children:t,edges:s}}const Os={type:lc.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function qi(e){return{stroke:"var(--node-border)",strokeWidth:1.5,...e?{strokeDasharray:"6 3"}:{}}}function Tn(e,t,s,r,i){var c;const o=(c=e.sections)==null?void 0:c[0],a=(i==null?void 0:i.x)??0,l=(i==null?void 0:i.y)??0;let h;if(o)h={sourcePoint:{x:o.startPoint.x+a,y:o.startPoint.y+l},targetPoint:{x:o.endPoint.x+a,y:o.endPoint.y+l},bendPoints:(o.bendPoints??[]).map(u=>({x:u.x+a,y:u.y+l}))};else{const u=t.get(e.sources[0]),d=t.get(e.targets[0]);u&&d&&(h={sourcePoint:{x:u.x+u.width/2,y:u.y+u.height},targetPoint:{x:d.x+d.width/2,y:d.y},bendPoints:[]})}return{id:e.id,source:e.sources[0],target:e.targets[0],type:"elk",data:h,style:qi(r),markerEnd:Os,...s?{label:s,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function ba(e){var h,c;const t=ah(e),r=await(await nh()).layout(t),i=new Map;for(const u of e.nodes)if(i.set(u.id,{type:u.type,data:u.data}),u.data.subgraph)for(const d of u.data.subgraph.nodes)i.set(`${u.id}/${d.id}`,{type:d.type,data:d.data});const o=[],a=[],l=new Map;for(const u of r.children??[]){const d=u.x??0,p=u.y??0;l.set(u.id,{x:d,y:p,width:u.width??0,height:u.height??0});for(const g of u.children??[])l.set(g.id,{x:d+(g.x??0),y:p+(g.y??0),width:g.width??0,height:g.height??0})}for(const u of r.children??[]){const d=i.get(u.id);if((((h=u.children)==null?void 0:h.length)??0)>0){o.push({id:u.id,type:"groupNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width,nodeHeight:u.height},position:{x:u.x??0,y:u.y??0},style:{width:u.width,height:u.height}});for(const y of u.children??[]){const w=i.get(y.id);o.push({id:y.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:y.width},position:{x:y.x??0,y:y.y??0},parentNode:u.id,extent:"parent"})}const g=u.x??0,m=u.y??0;for(const y of u.edges??[]){const w=e.nodes.find(C=>C.id===u.id),k=(c=w==null?void 0:w.data.subgraph)==null?void 0:c.edges.find(C=>`${u.id}/${C.id}`===y.id);a.push(Tn(y,l,k==null?void 0:k.label,k==null?void 0:k.conditional,{x:g,y:m}))}}else o.push({id:u.id,type:(d==null?void 0:d.type)??"defaultNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width},position:{x:u.x??0,y:u.y??0}})}for(const u of r.edges??[]){const d=e.edges.find(p=>p.id===u.id);a.push(Tn(u,l,d==null?void 0:d.label,d==null?void 0:d.conditional))}return{nodes:o,edges:a}}const lh={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Sa({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"Start",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),r,n.jsx(Lt,{type:"source",position:Tt.Bottom,style:lh})]})}const ch={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function wa({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"End",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:ch}),r]})}const Rn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ca({data:e}){const t=e.status,s=e.nodeWidth,r=e.model_name,i=e.label??"Model",o=e.hasBreakpoint,a=e.isPausedHere,l=e.isActiveNode,h=e.isExecutingNode,c=a?"var(--error)":h?"var(--success)":l?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",u=a?"var(--error)":h?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${c}`,boxShadow:a||l||h?`0 0 4px ${u}`:void 0,animation:a||l||h?`node-pulse-${a?"red":h?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r?`${i} -${r}`:i,children:[o&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Rn}),n.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),r&&n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:r,children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Rn})]})}const Bn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},hh=3;function ka({data:e}){const t=e.status,s=e.nodeWidth,r=e.tool_names,i=e.tool_count,o=e.label??"Tool",a=e.hasBreakpoint,l=e.isPausedHere,h=e.isActiveNode,c=e.isExecutingNode,u=l?"var(--error)":c?"var(--success)":h?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",d=l?"var(--error)":c?"var(--success)":"var(--accent)",p=(r==null?void 0:r.slice(0,hh))??[],g=(i??(r==null?void 0:r.length)??0)-p.length;return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${u}`,boxShadow:l||h||c?`0 0 4px ${d}`:void 0,animation:l||h||c?`node-pulse-${l?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r!=null&&r.length?`${o} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-elk-BkmlSRbk.js","assets/vendor-react-VzyiTEsu.js","assets/ChatPanel-CrwXase9.js","assets/vendor-reactflow-B_2yZyR4.js","assets/vendor-reactflow-B5DZHykP.css"])))=>i.map(i=>d[i]); +var sc=Object.defineProperty;var rc=(e,t,s)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Ut=(e,t,s)=>rc(e,typeof t!="symbol"?t+"":t,s);import{W as Zs,a as v,j as n,g as ic,b as nc,w as oc,F as ac,d as lc}from"./vendor-react-VzyiTEsu.js";import{M as cc,H as Lt,P as Tt,B as hc,u as ia,a as na,R as oa,b as aa,C as la,c as dc,d as ca}from"./vendor-reactflow-B_2yZyR4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function s(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=s(i);fetch(i.href,o)}})();const xn=e=>{let t;const s=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const _=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),s.forEach(g=>g(t,_))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>h,subscribe:c=>(s.add(c),()=>s.delete(c))},h=t=e(r,i,l);return l},uc=(e=>e?xn(e):xn),fc=e=>e;function pc(e,t=fc){const s=Zs.useSyncExternalStore(e.subscribe,Zs.useCallback(()=>t(e.getState()),[e,t]),Zs.useCallback(()=>t(e.getInitialState()),[e,t]));return Zs.useDebugValue(s),s}const yn=e=>{const t=uc(e),s=r=>pc(t,r);return Object.assign(s,t),s},Jt=(e=>e?yn(e):yn),de=Jt(e=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:t=>e(s=>{var o;let r=s.breakpoints;for(const a of t)(o=a.breakpoints)!=null&&o.length&&!r[a.id]&&(r={...r,[a.id]:Object.fromEntries(a.breakpoints.map(l=>[l,!0]))});const i={runs:Object.fromEntries(t.map(a=>[a.id,a]))};return r!==s.breakpoints&&(i.breakpoints=r),i}),upsertRun:t=>e(s=>{var i;const r={runs:{...s.runs,[t.id]:t}};if((i=t.breakpoints)!=null&&i.length&&!s.breakpoints[t.id]&&(r.breakpoints={...s.breakpoints,[t.id]:Object.fromEntries(t.breakpoints.map(o=>[o,!0]))}),(t.status==="completed"||t.status==="failed")&&s.activeNodes[t.id]){const{[t.id]:o,...a}=s.activeNodes;r.activeNodes=a}if(t.status!=="suspended"&&s.activeInterrupt[t.id]){const{[t.id]:o,...a}=s.activeInterrupt;r.activeInterrupt=a}return r}),selectRun:t=>e({selectedRunId:t}),addTrace:t=>e(s=>{const r=s.traces[t.run_id]??[],i=r.findIndex(a=>a.span_id===t.span_id),o=i>=0?r.map((a,l)=>l===i?t:a):[...r,t];return{traces:{...s.traces,[t.run_id]:o}}}),setTraces:(t,s)=>e(r=>({traces:{...r.traces,[t]:s}})),addLog:t=>e(s=>{const r=s.logs[t.run_id]??[];return{logs:{...s.logs,[t.run_id]:[...r,t]}}}),setLogs:(t,s)=>e(r=>({logs:{...r.logs,[t]:s}})),addChatEvent:(t,s)=>e(r=>{const i=r.chatMessages[t]??[],o=s.message;if(!o)return r;const a=o.messageId??o.message_id,l=o.role??"assistant",u=(o.contentParts??o.content_parts??[]).filter(x=>{const w=x.mimeType??x.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(x=>{const w=x.data;return(w==null?void 0:w.inline)??""}).join(` +`).trim(),d=(o.toolCalls??o.tool_calls??[]).map(x=>({name:x.name??"",has_result:!!x.result})),_={message_id:a,role:l,content:u,tool_calls:d.length>0?d:void 0},g=i.findIndex(x=>x.message_id===a);if(g>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((x,w)=>w===g?_:x)}};if(l==="user"){const x=i.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===u);if(x>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((w,E)=>E===x?_:w)}}}const m=[...i,_];return{chatMessages:{...r.chatMessages,[t]:m}}}),addLocalChatMessage:(t,s)=>e(r=>{const i=r.chatMessages[t]??[];return{chatMessages:{...r.chatMessages,[t]:[...i,s]}}}),setChatMessages:(t,s)=>e(r=>({chatMessages:{...r.chatMessages,[t]:s}})),setEntrypoints:t=>e({entrypoints:t}),breakpoints:{},toggleBreakpoint:(t,s)=>e(r=>{const i={...r.breakpoints[t]??{}};return i[s]?delete i[s]:i[s]=!0,{breakpoints:{...r.breakpoints,[t]:i}}}),clearBreakpoints:t=>e(s=>{const{[t]:r,...i}=s.breakpoints;return{breakpoints:i}}),activeNodes:{},setActiveNode:(t,s,r)=>e(i=>{const o=i.activeNodes[t]??{executing:{},prev:null};return{activeNodes:{...i.activeNodes,[t]:{executing:{...o.executing,[s]:r??null},prev:o.prev}}}}),removeActiveNode:(t,s)=>e(r=>{const i=r.activeNodes[t];if(!i)return r;const{[s]:o,...a}=i.executing;return{activeNodes:{...r.activeNodes,[t]:{executing:a,prev:s}}}}),resetRunGraphState:t=>e(s=>({stateEvents:{...s.stateEvents,[t]:[]},activeNodes:{...s.activeNodes,[t]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(t,s,r,i,o)=>e(a=>{const l=a.stateEvents[t]??[];return{stateEvents:{...a.stateEvents,[t]:[...l,{node_name:s,qualified_node_name:i,phase:o,timestamp:Date.now(),payload:r}]}}}),setStateEvents:(t,s)=>e(r=>({stateEvents:{...r.stateEvents,[t]:s}})),focusedSpan:null,setFocusedSpan:t=>e({focusedSpan:t}),activeInterrupt:{},setActiveInterrupt:(t,s)=>e(r=>({activeInterrupt:{...r.activeInterrupt,[t]:s}})),reloadPending:!1,setReloadPending:t=>e({reloadPending:t}),graphCache:{},setGraphCache:(t,s)=>e(r=>({graphCache:{...r.graphCache,[t]:s}}))})),Sr="/api";async function _c(e){const t=await fetch(`${Sr}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({environment:e})});if(!t.ok)throw new Error(`Login failed: ${t.status}`);return t.json()}async function Or(){const e=await fetch(`${Sr}/auth/status`);if(!e.ok)throw new Error(`Status check failed: ${e.status}`);return e.json()}async function gc(e){const t=await fetch(`${Sr}/auth/select-tenant`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tenant_name:e})});if(!t.ok)throw new Error(`Tenant selection failed: ${t.status}`);return t.json()}async function mc(){await fetch(`${Sr}/auth/logout`,{method:"POST"})}const ha="uipath-env",vc=["cloud","staging","alpha"];function xc(){const e=localStorage.getItem(ha);return vc.includes(e)?e:"cloud"}const da=Jt((e,t)=>({enabled:!0,status:"unauthenticated",environment:xc(),tenants:[],uipathUrl:null,pollTimer:null,expiryTimer:null,init:async()=>{try{const s=await fetch("/api/config");if(s.ok&&!(await s.json()).auth_enabled){e({enabled:!1});return}const r=await Or();e({status:r.status,tenants:r.tenants??[],uipathUrl:r.uipath_url??null}),r.status==="authenticated"&&t().startExpiryCheck()}catch(s){console.error("Auth init failed",s)}},setEnvironment:s=>{localStorage.setItem(ha,s),e({environment:s})},startLogin:async()=>{const{environment:s}=t();try{const r=await _c(s);e({status:"pending"}),window.open(r.auth_url,"_blank"),t().pollStatus()}catch(r){console.error("Login failed",r)}},pollStatus:()=>{const{pollTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{const i=await Or();i.status!=="pending"&&(t().stopPolling(),e({status:i.status,tenants:i.tenants??[],uipathUrl:i.uipath_url??null}),i.status==="authenticated"&&t().startExpiryCheck())}catch{}},2e3);e({pollTimer:r})},stopPolling:()=>{const{pollTimer:s}=t();s&&(clearInterval(s),e({pollTimer:null}))},startExpiryCheck:()=>{const{expiryTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{(await Or()).status==="expired"&&(t().stopExpiryCheck(),e({status:"expired"}))}catch{}},3e4);e({expiryTimer:r})},stopExpiryCheck:()=>{const{expiryTimer:s}=t();s&&(clearInterval(s),e({expiryTimer:null}))},selectTenant:async s=>{try{const r=await gc(s);e({status:"authenticated",uipathUrl:r.uipath_url,tenants:[]}),t().startExpiryCheck()}catch(r){console.error("Tenant selection failed",r)}},logout:async()=>{t().stopPolling(),t().stopExpiryCheck();try{await mc()}catch{}e({status:"unauthenticated",tenants:[],uipathUrl:null})}})),ua=Jt(e=>({projectName:null,projectVersion:null,projectAuthors:null,init:async()=>{try{const t=await fetch("/api/config");if(t.ok){const s=await t.json();e({projectName:s.project_name??null,projectVersion:s.project_version??null,projectAuthors:s.project_authors??null})}}catch{}}}));class yc{constructor(t){Ut(this,"ws",null);Ut(this,"url");Ut(this,"handlers",new Set);Ut(this,"reconnectTimer",null);Ut(this,"shouldReconnect",!0);Ut(this,"pendingMessages",[]);Ut(this,"activeSubscriptions",new Set);const s=window.location.protocol==="https:"?"wss:":"ws:";this.url=t??`${s}//${window.location.host}/ws`}connect(){var t;((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const s of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:s}}));for(const s of this.pendingMessages)this.sendRaw(s);this.pendingMessages=[]},this.ws.onmessage=s=>{let r;try{r=JSON.parse(s.data)}catch{console.warn("[ws] failed to parse message",s.data);return}this.handlers.forEach(i=>{try{i(r)}catch(o){console.error("[ws] handler error",o)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var s;(s=this.ws)==null||s.close()})}disconnect(){var t;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(t=this.ws)==null||t.close(),this.ws=null}onMessage(t){return this.handlers.add(t),()=>this.handlers.delete(t)}sendRaw(t){var s;((s=this.ws)==null?void 0:s.readyState)===WebSocket.OPEN&&this.ws.send(t)}send(t,s){var i;const r=JSON.stringify({type:t,payload:s});((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN?this.ws.send(r):this.pendingMessages.push(r)}subscribe(t){this.activeSubscriptions.add(t),this.send("subscribe",{run_id:t})}unsubscribe(t){this.activeSubscriptions.delete(t),this.send("unsubscribe",{run_id:t})}sendChatMessage(t,s){this.send("chat.message",{run_id:t,text:s})}sendInterruptResponse(t,s){this.send("chat.interrupt_response",{run_id:t,data:s})}debugStep(t){this.send("debug.step",{run_id:t})}debugContinue(t){this.send("debug.continue",{run_id:t})}debugStop(t){this.send("debug.stop",{run_id:t})}setBreakpoints(t,s){this.send("debug.set_breakpoints",{run_id:t,breakpoints:s})}sendCliAgentStart(t,s,r,i){this.send("cli_agent.start",{agent_id:t,session_id:s,cols:r,rows:i})}sendCliAgentInput(t,s){this.send("cli_agent.input",{session_id:t,data:s})}sendCliAgentResize(t,s,r){this.send("cli_agent.resize",{session_id:t,cols:s,rows:r})}sendCliAgentStop(t){this.send("cli_agent.stop",{session_id:t})}}const Zt="/api";async function Qt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function $i(){return Qt(`${Zt}/entrypoints`)}async function bc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/schema`)}async function Sc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/mock-input`)}async function fa(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/graph`)}async function bn(e,t,s="run",r=[]){return Qt(`${Zt}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:e,input_data:t,mode:s,breakpoints:r})})}async function wc(){return Qt(`${Zt}/runs`)}async function Ir(e){return Qt(`${Zt}/runs/${e}`)}async function Cc(){return Qt(`${Zt}/reload`,{method:"POST"})}const xe=Jt(e=>({evaluators:[],localEvaluators:[],llmModels:[],evalSets:{},evalRuns:{},streamingResults:{},setEvaluators:t=>e({evaluators:t}),setLocalEvaluators:t=>e({localEvaluators:t}),setLlmModels:t=>e({llmModels:t}),addLocalEvaluator:t=>e(s=>({localEvaluators:[...s.localEvaluators,t]})),upsertLocalEvaluator:t=>e(s=>({localEvaluators:s.localEvaluators.some(r=>r.id===t.id)?s.localEvaluators.map(r=>r.id===t.id?t:r):[...s.localEvaluators,t]})),setEvalSets:t=>e({evalSets:Object.fromEntries(t.map(s=>[s.id,s]))}),addEvalSet:t=>e(s=>({evalSets:{...s.evalSets,[t.id]:t}})),updateEvalSetEvaluators:(t,s)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,evaluator_ids:s}}}:r}),incrementEvalSetCount:(t,s=1)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,eval_count:i.eval_count+s}}}:r}),setEvalRuns:t=>e({evalRuns:Object.fromEntries(t.map(s=>[s.id,s]))}),upsertEvalRun:t=>e(s=>({evalRuns:{...s.evalRuns,[t.id]:t}})),updateEvalRunProgress:(t,s,r,i)=>e(o=>{const a=o.evalRuns[t];if(!a)return o;const l={...o.streamingResults};return i&&(l[t]={...l[t],[i.name]:i}),{evalRuns:{...o.evalRuns,[t]:{...a,progress_completed:s,progress_total:r,status:"running"}},streamingResults:l}}),completeEvalRun:(t,s,r)=>e(i=>{const o=i.evalRuns[t];if(!o)return i;const a={...i.streamingResults};return delete a[t],{evalRuns:{...i.evalRuns,[t]:{...o,status:"completed",overall_score:s,evaluator_scores:r,end_time:new Date().toISOString()}},streamingResults:a}})})),Ms=Jt(e=>({availableAgents:[],selectedAgentId:null,sessionId:null,status:"idle",exitCode:null,events:[],setAvailableAgents:t=>{e(s=>{const r={availableAgents:t};if(!s.selectedAgentId){const i=t.find(o=>o.installed);i&&(r.selectedAgentId=i.id)}return r})},setSelectedAgentId:t=>e({selectedAgentId:t}),setSessionId:t=>e({sessionId:t}),setStatus:t=>e({status:t}),setExitCode:t=>e({exitCode:t}),addEvent:t=>e(s=>({events:[...s.events,t]}))})),ye=Jt(e=>({children:{},expanded:{},selectedFile:null,openTabs:[],fileCache:{},dirty:{},buffers:{},loadingDirs:{},loadingFile:!1,agentChangedFiles:{},diffView:null,setChildren:(t,s)=>e(r=>({children:{...r.children,[t]:s}})),toggleExpanded:t=>e(s=>({expanded:{...s.expanded,[t]:!s.expanded[t]}})),setSelectedFile:t=>e({selectedFile:t}),openTab:t=>e(s=>({selectedFile:t,openTabs:s.openTabs.includes(t)?s.openTabs:[...s.openTabs,t]})),closeTab:t=>e(s=>{const r=s.openTabs.filter(c=>c!==t);let i=s.selectedFile;if(i===t){const c=s.openTabs.indexOf(t);i=r[Math.min(c,r.length-1)]??null}const{[t]:o,...a}=s.dirty,{[t]:l,...h}=s.buffers;return{openTabs:r,selectedFile:i,dirty:a,buffers:h}}),setFileContent:(t,s)=>e(r=>({fileCache:{...r.fileCache,[t]:s}})),updateBuffer:(t,s)=>e(r=>({buffers:{...r.buffers,[t]:s},dirty:{...r.dirty,[t]:!0}})),markClean:t=>e(s=>{const{[t]:r,...i}=s.dirty,{[t]:o,...a}=s.buffers;return{dirty:i,buffers:a}}),setLoadingDir:(t,s)=>e(r=>({loadingDirs:{...r.loadingDirs,[t]:s}})),setLoadingFile:t=>e({loadingFile:t}),markAgentChanged:t=>e(s=>({agentChangedFiles:{...s.agentChangedFiles,[t]:Date.now()}})),clearAgentChanged:t=>e(s=>{const{[t]:r,...i}=s.agentChangedFiles;return{agentChangedFiles:i}}),setDiffView:t=>e({diffView:t}),expandPath:t=>e(s=>{const r=t.split("/"),i={...s.expanded};for(let o=1;oe.current.onMessage(x=>{switch(x.type){case"run.updated":{const w=x.payload;t(w),(w.status==="running"||w.status==="completed"||w.status==="failed")&&Ms.getState().addEvent({type:"run_lifecycle",timestamp:Date.now(),runId:w.id,entrypoint:w.entrypoint,status:w.status});break}case"trace":s(x.payload);break;case"log":r(x.payload);break;case"chat":{const w=x.payload.run_id;i(w,x.payload);break}case"chat.interrupt":{const w=x.payload.run_id;o(w,x.payload);break}case"state":{const w=x.payload.run_id,E=x.payload.node_name,k=x.payload.qualified_node_name??null,P=x.payload.phase??null,A=x.payload.payload;E==="__start__"&&P==="started"&&h(w),P==="started"?a(w,E,k):P==="completed"&&l(w,E),c(w,E,A,k,P);break}case"reload":{x.payload.reloaded?$i().then(E=>{const k=de.getState();k.setEntrypoints(E.map(P=>P.name)),k.setReloadPending(!1)}).catch(E=>console.error("Failed to refresh entrypoints:",E)):de.getState().setReloadPending(!0);break}case"files.changed":{const w=x.payload.files,E=new Set(w),k=ye.getState(),P=w.filter(D=>D in k.children?!1:(D.split("/").pop()??"").includes("."));P.length>0&&Ms.getState().addEvent({type:"files_changed",timestamp:Date.now(),files:P});for(const D of k.openTabs)k.dirty[D]||!E.has(D)||pa(D).then(N=>{var B;const $=ye.getState();$.dirty[D]||((B=$.fileCache[D])==null?void 0:B.content)!==N.content&&$.setFileContent(D,N)}).catch(()=>{});const A=new Set;for(const D of w){const N=D.lastIndexOf("/"),$=N===-1?"":D.substring(0,N);$ in k.children&&A.add($)}for(const D of A)Ki(D).then(N=>ye.getState().setChildren(D,N)).catch(()=>{});break}case"eval_run.created":u(x.payload);break;case"eval_run.progress":{const{run_id:w,completed:E,total:k,item_result:P}=x.payload;d(w,E,k,P);break}case"eval_run.completed":{const{run_id:w,overall_score:E,evaluator_scores:k}=x.payload;_(w,E,k);break}case"cli_agent.output":{const{session_id:w,data:E}=x.payload,k=Nc(w);if(k){const P=Uint8Array.from(atob(E),A=>A.charCodeAt(0));k(P)}break}case"cli_agent.exit":{const{session_id:w,exit_code:E}=x.payload,k=Ms.getState();if(k.sessionId===w){k.setStatus("exited"),k.setExitCode(E);const P=k.availableAgents.find(A=>A.id===k.selectedAgentId);k.addEvent({type:"session",timestamp:Date.now(),agentName:(P==null?void 0:P.name)??"Unknown",action:"exited",exitCode:E})}break}case"mcp.tool_call":{const{tool:w,args:E}=x.payload;Ms.getState().addEvent({type:"mcp_tool_call",timestamp:Date.now(),tool:w,args:E});break}}}),[t,s,r,i,o,a,l,h,c,u,d,_]),e.current}function Lc(e){const t=e.replace(/^#\/?/,""),s={section:"debug",view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null,evalCreating:!1,evalSetId:null,evalRunId:null,evalRunItemName:null,evaluatorId:null,evaluatorCreateType:null,evaluatorFilter:null,explorerFile:null};if(!t||t==="new"||t==="debug"||t==="debug/new")return s;const r=t.match(/^(?:debug\/)?setup\/([^/]+)\/(run|chat)$/);if(r)return{...s,view:"setup",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const i=t.match(/^(?:debug\/)?runs\/([^/]+)(?:\/(traces|output))?$/);if(i)return{...s,view:"details",runId:i[1],tab:i[2]??"traces"};if(t==="evals/new")return{...s,section:"evals",evalCreating:!0};const o=t.match(/^evals\/runs\/([^/]+?)(?:\/([^/]+))?$/);if(o)return{...s,section:"evals",evalRunId:o[1],evalRunItemName:o[2]?decodeURIComponent(o[2]):null};const a=t.match(/^evals\/sets\/([^/]+)$/);if(a)return{...s,section:"evals",evalSetId:a[1]};if(t==="evals")return{...s,section:"evals"};const l=t.match(/^evaluators\/new(?:\/(deterministic|llm|tool))?$/);if(l)return{...s,section:"evaluators",evaluatorCreateType:l[1]??"any"};const h=t.match(/^evaluators\/category\/(deterministic|llm|tool)$/);if(h)return{...s,section:"evaluators",evaluatorFilter:h[1]};const c=t.match(/^evaluators\/([^/]+)$/);if(c)return{...s,section:"evaluators",evaluatorId:c[1]};if(t==="evaluators")return{...s,section:"evaluators"};if(t==="explorer/canvas")return{...s,section:"explorer",explorerFile:"__canvas__"};const u=t.match(/^explorer\/statedb\/(.+)$/);if(u)return{...s,section:"explorer",explorerFile:`__statedb__:${decodeURIComponent(u[1])}`};const d=t.match(/^explorer\/file\/(.+)$/);return d?{...s,section:"explorer",explorerFile:decodeURIComponent(d[1])}:t==="explorer"?{...s,section:"explorer"}:s}function Tc(){return window.location.hash}function Rc(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function et(){const e=v.useSyncExternalStore(Rc,Tc),t=Lc(e),s=v.useCallback(r=>{window.location.hash=r},[]);return{...t,navigate:s}}const Sn="(max-width: 767px)";function Bc(){const[e,t]=v.useState(()=>window.matchMedia(Sn).matches);return v.useEffect(()=>{const s=window.matchMedia(Sn),r=i=>t(i.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),e}const Dc=[{section:"debug",label:"Developer Console",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"8",y:"6",width:"8",height:"14",rx:"4"}),n.jsx("path",{d:"M6 10H4"}),n.jsx("path",{d:"M6 18H4"}),n.jsx("path",{d:"M18 10h2"}),n.jsx("path",{d:"M18 18h2"}),n.jsx("path",{d:"M8 14h8"}),n.jsx("path",{d:"M9 6l-1.5-2"}),n.jsx("path",{d:"M15 6l1.5-2"}),n.jsx("path",{d:"M6 14H4"}),n.jsx("path",{d:"M18 14h2"})]})},{section:"evals",label:"Evals",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.5L5 20a1 1 0 0 0 .9 1.4h12.2a1 1 0 0 0 .9-1.4L14 9.5V3"}),n.jsx("path",{d:"M8.5 14h7"})]})},{section:"evaluators",label:"Evaluators",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2l7 4v5c0 5.25-3.5 9.74-7 11-3.5-1.26-7-5.75-7-11V6l7-4z"}),n.jsx("path",{d:"M9 12l2 2 4-4"})]})},{section:"explorer",label:"Explorer",icon:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",children:n.jsx("path",{d:"M7.5 22.5H17.595C17.07 23.4 16.11 24 15 24H7.5C4.185 24 1.5 21.315 1.5 18V6C1.5 4.89 2.1 3.93 3 3.405V18C3 20.475 5.025 22.5 7.5 22.5ZM21 8.121V18C21 19.6545 19.6545 21 18 21H7.5C5.8455 21 4.5 19.6545 4.5 18V3C4.5 1.3455 5.8455 0 7.5 0H12.879C13.4715 0 14.0505 0.24 14.4705 0.6585L20.3415 6.5295C20.766 6.954 21 7.5195 21 8.121ZM13.5 6.75C13.5 7.164 13.8375 7.5 14.25 7.5H19.1895L13.5 1.8105V6.75ZM19.5 18V9H14.25C13.0095 9 12 7.9905 12 6.75V1.5H7.5C6.672 1.5 6 2.1735 6 3V18C6 18.8265 6.672 19.5 7.5 19.5H18C18.828 19.5 19.5 18.8265 19.5 18Z"})})}];function Pc({section:e,onSectionChange:t}){return n.jsx("div",{className:"w-12 flex flex-col items-center shrink-0 border-r",style:{background:"var(--activity-bar-bg)",borderColor:"var(--border)"},children:n.jsx("div",{className:"flex flex-col items-center gap-1 pt-2",children:Dc.map(s=>{const r=e===s.section;return n.jsxs("button",{onClick:()=>t(s.section),className:"w-10 h-10 flex items-center justify-center rounded cursor-pointer transition-colors relative",style:{color:r?"var(--text-primary)":"var(--text-muted)",background:r?"var(--bg-hover)":"transparent",border:"none"},title:s.label,onMouseEnter:i=>{r||(i.currentTarget.style.color="var(--text-secondary)")},onMouseLeave:i=>{r||(i.currentTarget.style.color="var(--text-muted)")},children:[r&&n.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r",style:{background:"var(--accent)"}}),s.icon]},s.section)})})})}const it="/api";async function nt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Ac(){return nt(`${it}/evaluators`)}async function _a(){return nt(`${it}/llm-models`)}async function ga(){return nt(`${it}/eval-sets`)}async function Oc(e){return nt(`${it}/eval-sets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Ic(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function Wc(e,t){await nt(`${it}/eval-sets/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Hc(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}`)}async function $c(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/runs`,{method:"POST"})}async function Fc(){return nt(`${it}/eval-runs`)}async function wn(e){return nt(`${it}/eval-runs/${encodeURIComponent(e)}`)}async function Vi(){return nt(`${it}/local-evaluators`)}async function zc(e){return nt(`${it}/local-evaluators`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Uc(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/evaluators`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({evaluator_refs:t})})}async function Kc(e,t){return nt(`${it}/local-evaluators/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}const Vc={"uipath-exact-match":e=>({expectedOutput:e}),"uipath-json-similarity":e=>({expectedOutput:e}),"uipath-contains":()=>({searchText:""}),"uipath-llm-judge-output-semantic-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-output-strict-json-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-trajectory-similarity":()=>({expectedAgentBehavior:""}),"uipath-llm-judge-trajectory-simulation":()=>({expectedAgentBehavior:""}),"uipath-tool-call-count":()=>({}),"uipath-tool-call-args":()=>({}),"uipath-tool-call-order":()=>({}),"uipath-tool-call-output":()=>({})};function qc(e,t){if(!e)return{};const s=Vc[e.evaluator_type_id];return s?s(t):e.type==="tool"?{}:e.evaluator_type_id.includes("trajectory")?{expectedAgentBehavior:""}:{expectedOutput:t}}function ma(e){return e?e.type==="tool"?!0:e.evaluator_type_id.includes("tool-call"):!1}function Xc(e){return e?ma(e)?{label:"tools",color:"var(--warning, #e5a00d)"}:e.evaluator_type_id.includes("trajectory")?{label:"quality",color:"var(--info, #3b82f6)"}:{label:"output",color:"var(--success, #22c55e)"}:{label:"output",color:"var(--success, #22c55e)"}}function Yc({run:e,onClose:t}){const s=xe(T=>T.evalSets),r=xe(T=>T.setEvalSets),i=xe(T=>T.incrementEvalSetCount),o=xe(T=>T.localEvaluators),a=xe(T=>T.setLocalEvaluators),[l,h]=v.useState(`run-${e.id.slice(0,8)}`),[c,u]=v.useState(new Set),[d,_]=v.useState({}),g=v.useRef(new Set),[m,x]=v.useState(!1),[w,E]=v.useState(null),[k,P]=v.useState(!1),A=Object.values(s),D=v.useMemo(()=>Object.fromEntries(o.map(T=>[T.id,T])),[o]),N=v.useMemo(()=>{const T=new Set;for(const O of c){const L=s[O];L&&L.evaluator_ids.forEach(R=>T.add(R))}return[...T]},[c,s]);v.useEffect(()=>{const T=e.output_data,O=g.current;_(L=>{const R={};for(const p of N)if(O.has(p)&&L[p]!==void 0)R[p]=L[p];else{const f=D[p],b=qc(f,T);R[p]=JSON.stringify(b,null,2)}return R})},[N,D,e.output_data]),v.useEffect(()=>{const T=O=>{O.key==="Escape"&&t()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[t]),v.useEffect(()=>{A.length===0&&ga().then(r).catch(()=>{}),o.length===0&&Vi().then(a).catch(()=>{})},[]);const $=T=>{u(O=>{const L=new Set(O);return L.has(T)?L.delete(T):L.add(T),L})},B=async()=>{var O;if(!l.trim()||c.size===0)return;E(null),x(!0);const T={};for(const L of N){const R=d[L];if(R!==void 0)try{T[L]=JSON.parse(R)}catch{E(`Invalid JSON for evaluator "${((O=D[L])==null?void 0:O.name)??L}"`),x(!1);return}}try{for(const L of c){const R=s[L],p=new Set((R==null?void 0:R.evaluator_ids)??[]),f={};for(const[b,y]of Object.entries(T))p.has(b)&&(f[b]=y);await Ic(L,{name:l.trim(),inputs:e.input_data,expected_output:null,evaluation_criterias:f}),i(L)}P(!0),setTimeout(t,3e3)}catch(L){E(L.detail||L.message||"Failed to add item")}finally{x(!1)}};return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:T=>{T.target===T.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg p-6 shadow-xl max-h-[85vh] flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"Add to Eval Set"})]}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:T=>{T.currentTarget.style.color="var(--text-primary)"},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-muted)"},"aria-label":"Close",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-4 pr-1",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Item Name"}),n.jsx("input",{type:"text",value:l,onChange:T=>h(T.target.value),className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Inputs"}),n.jsx("pre",{className:"rounded-md px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(e.input_data,null,2)})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Eval Sets"}),A.length===0?n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No eval sets found. Create one first."}):n.jsx("div",{className:"rounded-md border overflow-hidden max-h-40 overflow-y-auto",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:A.map(T=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:O=>{O.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:c.has(T.id),onChange:()=>$(T.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:T.name}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[T.eval_count," items"]})]},T.id))})]}),N.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluation Criteria"}),n.jsx("div",{className:"space-y-2",children:N.map(T=>{const O=D[T],L=ma(O),R=Xc(O);return n.jsxs("div",{className:"rounded-md",style:{border:"1px solid var(--border)",background:"var(--bg-primary)",opacity:L?.6:1},children:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:L?"none":"1px solid var(--border)"},children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",style:{color:"var(--text-primary)"},children:(O==null?void 0:O.name)??T}),n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{color:R.color,background:`color-mix(in srgb, ${R.color} 12%, transparent)`},children:R.label})]}),L?n.jsx("div",{className:"px-3 pb-2",children:n.jsx("span",{className:"text-[10px] italic",style:{color:"var(--text-muted)"},children:"Default criteria — uses evaluator config"})}):n.jsx("div",{className:"px-3 pb-2 pt-1",children:n.jsx("textarea",{value:d[T]??"{}",onChange:p=>{g.current.add(T),_(f=>({...f,[T]:p.target.value}))},rows:8,className:"w-full rounded px-2 py-1.5 text-xs font-mono resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})})]},T)})})]})]}),n.jsxs("div",{className:"mt-4 space-y-3",children:[w&&n.jsx("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:w}),k&&n.jsxs("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--success)",background:"color-mix(in srgb, var(--success) 10%, var(--bg-secondary))"},children:["Added to ",c.size," eval set",c.size!==1?"s":"","."]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:t,className:"flex-1 py-2 rounded-md text-xs font-semibold cursor-pointer",style:{background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Cancel"}),n.jsx("button",{onClick:B,disabled:!l.trim()||c.size===0||m||k,className:"flex-1 py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:m?"Adding...":k?"Added":"Add Item"})]})]})]})})}const Gc={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function Jc({run:e,isSelected:t,onClick:s}){var d;const r=Gc[e.status]??"var(--text-muted)",i=((d=e.entrypoint.split("/").pop())==null?void 0:d.slice(0,16))??e.entrypoint,o=e.start_time?new Date(e.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",[a,l]=v.useState(!1),[h,c]=v.useState(!1),u=v.useRef(null);return v.useEffect(()=>{if(!a)return;const _=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[a]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"group relative w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:t?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:t?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:_=>{t||(_.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:_=>{t||(_.currentTarget.style.background="")},onClick:s,children:[n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:r}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs truncate",style:{color:t?"var(--text-primary)":"var(--text-secondary)"},children:i}),n.jsxs("div",{className:"text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[o,e.duration?` · ${e.duration}`:""]})]}),e.status==="completed"&&n.jsxs("div",{ref:u,className:"relative shrink-0",children:[n.jsx("button",{onClick:_=>{_.stopPropagation(),l(g=>!g)},className:"opacity-40 group-hover:opacity-100 focus:opacity-100 w-7 h-7 flex items-center justify-center rounded transition-opacity cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:_=>{_.currentTarget.style.color="var(--text-primary)",_.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:_=>{_.currentTarget.style.color="var(--text-muted)",_.currentTarget.style.background=""},"aria-label":"Actions",title:"Actions",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}),a&&n.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[140px] rounded-md shadow-lg py-1",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:n.jsx("button",{onClick:_=>{_.stopPropagation(),l(!1),c(!0)},className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--bg-hover)",_.currentTarget.style.color="var(--text-primary)"},onMouseLeave:_=>{_.currentTarget.style.background="",_.currentTarget.style.color="var(--text-secondary)"},children:"Add to Eval Set"})})]})]}),h&&n.jsx(Yc,{run:e,onClose:()=>c(!1)})]})}function Cn({runs:e,selectedRunId:t,onSelectRun:s,onNewRun:r}){const i=[...e].sort((o,a)=>new Date(a.start_time??0).getTime()-new Date(o.start_time??0).getTime());return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:r,className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Run"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(o=>n.jsx(Jc,{run:o,isSelected:o.id===t,onClick:()=>s(o.id)},o.id)),i.length===0&&n.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]})]})}function va(){const e=localStorage.getItem("uipath-dev-theme");return e==="light"||e==="dark"?e:"dark"}function xa(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("uipath-dev-theme",e)}xa(va());const ya=Jt(e=>({theme:va(),toggleTheme:()=>e(t=>{const s=t.theme==="dark"?"light":"dark";return xa(s),{theme:s}})}));function kn(){const{theme:e,toggleTheme:t}=ya(),{enabled:s,status:r,environment:i,tenants:o,uipathUrl:a,setEnvironment:l,startLogin:h,selectTenant:c,logout:u}=da(),{projectName:d,projectVersion:_,projectAuthors:g}=ua(),[m,x]=v.useState(!1),[w,E]=v.useState(""),k=v.useRef(null),P=v.useRef(null);v.useEffect(()=>{if(!m)return;const f=b=>{k.current&&!k.current.contains(b.target)&&P.current&&!P.current.contains(b.target)&&x(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[m]);const A=r==="authenticated",D=r==="expired",N=r==="pending",$=r==="needs_tenant";let B="UiPath: Disconnected",T=null,O=!0;A?(B=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""}`,T="var(--success)",O=!1):D?(B=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""} (expired)`,T="var(--error)",O=!1):N?B="UiPath: Signing in…":$&&(B="UiPath: Select Tenant");const L=()=>{N||(D?h():x(f=>!f))},R="flex items-center gap-1 px-1.5 rounded transition-colors",p={onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="",f.currentTarget.style.color="var(--text-muted)"}};return n.jsxs("div",{className:"h-6 flex items-center justify-end gap-3 px-2 text-xs border-t shrink-0",style:{background:"var(--bg-secondary)",color:"var(--text-muted)",borderColor:"var(--border)",fontSize:"11px"},children:[s&&n.jsxs("div",{className:"relative flex items-center",children:[n.jsxs("div",{ref:P,className:`${R} cursor-pointer`,onClick:L,...p,title:A?a??"":D?"Token expired — click to re-authenticate":N?"Signing in…":$?"Select a tenant":"Click to sign in",children:[N?n.jsxs("svg",{className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),n.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})]}):T?n.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:T}}):O?n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}):null,n.jsx("span",{className:"truncate max-w-[200px]",children:B})]}),m&&n.jsx("div",{ref:k,className:"absolute bottom-full right-0 mb-1 rounded border shadow-lg p-1 min-w-[180px]",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},children:A||D?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>{a&&window.open(a,"_blank","noopener,noreferrer"),x(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Go to Platform"]}),n.jsxs("button",{onClick:()=>{u(),x(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]}):$?n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Tenant"}),n.jsxs("select",{value:w,onChange:f=>E(f.target.value),className:"w-full rounded px-1.5 py-1 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:[n.jsx("option",{value:"",children:"Select…"}),o.map(f=>n.jsx("option",{value:f,children:f},f))]}),n.jsx("button",{onClick:()=>{w&&(c(w),x(!1))},disabled:!w,className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--text-muted)"},children:"Confirm"})]}):n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Environment"}),n.jsxs("select",{value:i,onChange:f=>l(f.target.value),className:"w-full rounded px-1.5 py-0.5 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-muted)"},children:[n.jsx("option",{value:"cloud",children:"cloud"}),n.jsx("option",{value:"staging",children:"staging"}),n.jsx("option",{value:"alpha",children:"alpha"})]}),n.jsx("button",{onClick:()=>{h(),x(!1)},className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:f=>{f.currentTarget.style.color="var(--text-primary)",f.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:f=>{f.currentTarget.style.color="var(--text-muted)",f.currentTarget.style.borderColor="var(--border)"},children:"Sign In"})]})})]}),d&&n.jsxs("span",{className:R,children:["Project: ",d]}),_&&n.jsxs("span",{className:R,children:["Version: v",_]}),g&&n.jsxs("span",{className:R,children:["Author: ",g]}),n.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:`${R} cursor-pointer no-underline`,style:{color:"var(--text-muted)"},...p,title:"View on GitHub",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),n.jsx("span",{children:"uipath-dev-python"})]}),n.jsxs("div",{className:`${R} cursor-pointer`,onClick:t,...p,title:`Switch to ${e==="dark"?"light":"dark"} theme`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e==="dark"?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),n.jsx("span",{children:e==="dark"?"Dark":"Light"})]})]})}function Zc(){const{navigate:e}=et(),t=de(c=>c.entrypoints),[s,r]=v.useState(""),[i,o]=v.useState(!0),[a,l]=v.useState(null);v.useEffect(()=>{!s&&t.length>0&&r(t[0])},[t,s]),v.useEffect(()=>{s&&(o(!0),l(null),bc(s).then(c=>{var d;const u=(d=c.input)==null?void 0:d.properties;o(!!(u!=null&&u.messages))}).catch(c=>{const u=c.detail||{};l(u.error||u.message||`Failed to load entrypoint "${s}"`)}))},[s]);const h=c=>{s&&e(`#/setup/${encodeURIComponent(s)}/${c}`)};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),t.length>1&&n.jsxs("div",{className:"mb-8",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Entrypoint"}),n.jsx("select",{id:"entrypoint-select",value:s,onChange:c=>r(c.target.value),className:"w-full rounded-md px-3 py-2 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:t.map(c=>n.jsx("option",{value:c,children:c},c))})]}),a?n.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),n.jsx("div",{className:"overflow-auto max-h-48 p-3",children:n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(En,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:n.jsx(Qc,{}),color:"var(--success)",onClick:()=>h("run"),disabled:!s}),n.jsx(En,{title:"Conversational",description:i?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:n.jsx(eh,{}),color:"var(--accent)",onClick:()=>h("chat"),disabled:!s||!i})]})]})})}function En({title:e,description:t,icon:s,color:r,onClick:i,disabled:o}){return n.jsxs("button",{onClick:i,disabled:o,className:"group flex flex-col items-center text-center p-6 rounded-md border transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{o||(a.currentTarget.style.borderColor=r,a.currentTarget.style.background=`color-mix(in srgb, ${r} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[n.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${r} 10%, var(--bg-primary))`,color:r},children:s}),n.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:e}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:t})]})}function Qc(){return n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function eh(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),n.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),n.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),n.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),n.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),n.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),n.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const th="modulepreload",sh=function(e){return"/"+e},Nn={},ba=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){let a=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(s.map(c=>{if(c=sh(c),c in Nn)return;Nn[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const _=document.createElement("link");if(_.rel=u?"stylesheet":th,u||(_.as="script"),_.crossOrigin="",_.href=c,h&&_.setAttribute("nonce",h),document.head.appendChild(_),u)return new Promise((g,m)=>{_.addEventListener("load",g),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},rh=80,ih=32,nh=13;function jn(e){const t=(e==null?void 0:e.label)??"";return Math.max(rh,t.length*8+32)}function Mn(e,t){let s=ih;(t==="modelNode"||t==="toolNode")&&(s+=nh);const r=e==null?void 0:e.tool_names;return r&&r.length>0&&(s+=Math.min(r.length,3)*12+(r.length>3?12:0)+4),e!=null&&e.model_name&&(s+=14),s}let Wr=null;async function oh(){if(!Wr){const{default:e}=await ba(async()=>{const{default:t}=await import("./vendor-elk-BkmlSRbk.js").then(s=>s.e);return{default:t}},__vite__mapDeps([0,1]));Wr=new e}return Wr}const Ln={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},ah="[top=35,left=15,bottom=15,right=15]";function lh(e){const t=[],s=[];for(const r of e.nodes){const i=r.data,o={id:r.id,width:jn(i),height:Mn(i,r.type)};if(r.data.subgraph){const a=r.data.subgraph;delete o.width,delete o.height,o.layoutOptions={...Ln,"elk.padding":ah},o.children=a.nodes.map(l=>({id:`${r.id}/${l.id}`,width:jn(l.data),height:Mn(l.data,l.type)})),o.edges=a.edges.map(l=>({id:`${r.id}/${l.id}`,sources:[`${r.id}/${l.source}`],targets:[`${r.id}/${l.target}`]}))}t.push(o)}for(const r of e.edges)s.push({id:r.id,sources:[r.source],targets:[r.target]});return{id:"root",layoutOptions:Ln,children:t,edges:s}}const Os={type:cc.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function qi(e){return{stroke:"var(--node-border)",strokeWidth:1.5,...e?{strokeDasharray:"6 3"}:{}}}function Tn(e,t,s,r,i){var c;const o=(c=e.sections)==null?void 0:c[0],a=(i==null?void 0:i.x)??0,l=(i==null?void 0:i.y)??0;let h;if(o)h={sourcePoint:{x:o.startPoint.x+a,y:o.startPoint.y+l},targetPoint:{x:o.endPoint.x+a,y:o.endPoint.y+l},bendPoints:(o.bendPoints??[]).map(u=>({x:u.x+a,y:u.y+l}))};else{const u=t.get(e.sources[0]),d=t.get(e.targets[0]);u&&d&&(h={sourcePoint:{x:u.x+u.width/2,y:u.y+u.height},targetPoint:{x:d.x+d.width/2,y:d.y},bendPoints:[]})}return{id:e.id,source:e.sources[0],target:e.targets[0],type:"elk",data:h,style:qi(r),markerEnd:Os,...s?{label:s,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function Sa(e){var h,c;const t=lh(e),r=await(await oh()).layout(t),i=new Map;for(const u of e.nodes)if(i.set(u.id,{type:u.type,data:u.data}),u.data.subgraph)for(const d of u.data.subgraph.nodes)i.set(`${u.id}/${d.id}`,{type:d.type,data:d.data});const o=[],a=[],l=new Map;for(const u of r.children??[]){const d=u.x??0,_=u.y??0;l.set(u.id,{x:d,y:_,width:u.width??0,height:u.height??0});for(const g of u.children??[])l.set(g.id,{x:d+(g.x??0),y:_+(g.y??0),width:g.width??0,height:g.height??0})}for(const u of r.children??[]){const d=i.get(u.id);if((((h=u.children)==null?void 0:h.length)??0)>0){o.push({id:u.id,type:"groupNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width,nodeHeight:u.height},position:{x:u.x??0,y:u.y??0},style:{width:u.width,height:u.height}});for(const x of u.children??[]){const w=i.get(x.id);o.push({id:x.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:x.width},position:{x:x.x??0,y:x.y??0},parentNode:u.id,extent:"parent"})}const g=u.x??0,m=u.y??0;for(const x of u.edges??[]){const w=e.nodes.find(k=>k.id===u.id),E=(c=w==null?void 0:w.data.subgraph)==null?void 0:c.edges.find(k=>`${u.id}/${k.id}`===x.id);a.push(Tn(x,l,E==null?void 0:E.label,E==null?void 0:E.conditional,{x:g,y:m}))}}else o.push({id:u.id,type:(d==null?void 0:d.type)??"defaultNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width},position:{x:u.x??0,y:u.y??0}})}for(const u of r.edges??[]){const d=e.edges.find(_=>_.id===u.id);a.push(Tn(u,l,d==null?void 0:d.label,d==null?void 0:d.conditional))}return{nodes:o,edges:a}}const ch={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function wa({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"Start",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),r,n.jsx(Lt,{type:"source",position:Tt.Bottom,style:ch})]})}const hh={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ca({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"End",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:hh}),r]})}const Rn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function ka({data:e}){const t=e.status,s=e.nodeWidth,r=e.model_name,i=e.label??"Model",o=e.hasBreakpoint,a=e.isPausedHere,l=e.isActiveNode,h=e.isExecutingNode,c=a?"var(--error)":h?"var(--success)":l?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",u=a?"var(--error)":h?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${c}`,boxShadow:a||l||h?`0 0 4px ${u}`:void 0,animation:a||l||h?`node-pulse-${a?"red":h?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r?`${i} +${r}`:i,children:[o&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Rn}),n.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),r&&n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:r,children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Rn})]})}const Bn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},dh=3;function Ea({data:e}){const t=e.status,s=e.nodeWidth,r=e.tool_names,i=e.tool_count,o=e.label??"Tool",a=e.hasBreakpoint,l=e.isPausedHere,h=e.isActiveNode,c=e.isExecutingNode,u=l?"var(--error)":c?"var(--success)":h?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",d=l?"var(--error)":c?"var(--success)":"var(--accent)",_=(r==null?void 0:r.slice(0,dh))??[],g=(i??(r==null?void 0:r.length)??0)-_.length;return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${u}`,boxShadow:l||h||c?`0 0 4px ${d}`:void 0,animation:l||h||c?`node-pulse-${l?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r!=null&&r.length?`${o} ${r.join(` -`)}`:o,children:[a&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Bn}),n.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",i?` (${i})`:""]}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),p.length>0&&n.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[p.map(m=>n.jsx("div",{className:"truncate",children:m},m)),g>0&&n.jsxs("div",{style:{fontStyle:"italic"},children:["+",g," more"]})]}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Bn})]})}const Dn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ea({data:e}){const t=e.label??"",s=e.status,r=e.hasBreakpoint,i=e.isPausedHere,o=e.isActiveNode,a=e.isExecutingNode,l=i?"var(--error)":a?"var(--success)":o?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--bg-tertiary)",h=i?"var(--error)":a?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${i||o||a?"solid":"dashed"} ${l}`,borderRadius:8,boxShadow:i||o||a?`0 0 4px ${h}`:void 0,animation:i||o||a?`node-pulse-${i?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[r&&n.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Dn}),n.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${l}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:t}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Dn})]})}function Na({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom})]})}function dh(e,t=8){if(e.length<2)return"";if(e.length===2)return`M ${e[0].x} ${e[0].y} L ${e[1].x} ${e[1].y}`;let s=`M ${e[0].x} ${e[0].y}`;for(let i=1;if.breakpoints[t]),O=de(f=>f.toggleBreakpoint),P=de(f=>f.clearBreakpoints),j=de(f=>f.activeNodes[t]),D=de(f=>{var v;return(v=f.runs[t])==null?void 0:v.status}),L=x.useCallback((f,v)=>{if(v.type==="startNode"||v.type==="endNode")return;const b=v.type==="groupNode"?v.id:v.id.includes("/")?v.id.split("/").pop():v.id;O(t,b);const E=de.getState().breakpoints[t]??{};i==null||i(Object.keys(E))},[t,O,i]),B=A&&Object.keys(A).length>0,I=x.useCallback(()=>{if(B)P(t),i==null||i([]);else{const f=[];for(const b of o){if(b.type==="startNode"||b.type==="endNode"||b.parentNode)continue;const E=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id;f.push(E)}for(const b of f)A!=null&&A[b]||O(t,b);const v=de.getState().breakpoints[t]??{};i==null||i(Object.keys(v))}},[t,B,A,o,P,O,i]);x.useEffect(()=>{a(f=>f.map(v=>{var N;if(v.type==="startNode"||v.type==="endNode")return v;const b=v.type==="groupNode"?v.id:v.id.includes("/")?v.id.split("/").pop():v.id,E=!!(A&&A[b]);return E!==!!((N=v.data)!=null&&N.hasBreakpoint)?{...v,data:{...v.data,hasBreakpoint:E}}:v}))},[A,a]),x.useEffect(()=>{const f=s?new Set(s.split(",").map(v=>v.trim()).filter(Boolean)):null;a(v=>v.map(b=>{var T,$;if(b.type==="startNode"||b.type==="endNode")return b;const E=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id,N=(T=b.data)==null?void 0:T.label,z=f!=null&&(f.has(E)||N!=null&&f.has(N));return z!==!!(($=b.data)!=null&&$.isPausedHere)?{...b,data:{...b.data,isPausedHere:z}}:b}))},[s,y,a]);const M=de(f=>f.stateEvents[t]);x.useEffect(()=>{const f=!!s;let v=new Set;const b=new Set,E=new Set,N=new Set,z=new Map,T=new Map;if(M)for(const $ of M)$.phase==="started"?T.set($.node_name,$.qualified_node_name??null):$.phase==="completed"&&T.delete($.node_name);a($=>{var J;for(const re of $)re.type&&z.set(re.id,re.type);const V=re=>{var F;const ie=[];for(const te of $){const pe=te.type==="groupNode"?te.id:te.id.includes("/")?te.id.split("/").pop():te.id,_e=(F=te.data)==null?void 0:F.label;(pe===re||_e!=null&&_e===re)&&ie.push(te.id)}return ie};if(f&&s){const re=s.split(",").map(ie=>ie.trim()).filter(Boolean);for(const ie of re)V(ie).forEach(F=>v.add(F));if(r!=null&&r.length)for(const ie of r)V(ie).forEach(F=>E.add(F));j!=null&&j.prev&&V(j.prev).forEach(ie=>b.add(ie))}else if(T.size>0){const re=new Map;for(const ie of $){const F=(J=ie.data)==null?void 0:J.label;if(!F)continue;const te=ie.id.includes("/")?ie.id.split("/").pop():ie.id;for(const pe of[te,F]){let _e=re.get(pe);_e||(_e=new Set,re.set(pe,_e)),_e.add(ie.id)}}for(const[ie,F]of T){let te=!1;if(F){const pe=F.replace(/:/g,"/");for(const _e of $)_e.id===pe&&(v.add(_e.id),te=!0)}if(!te){const pe=re.get(ie);pe&&pe.forEach(_e=>v.add(_e))}}}return $}),c($=>{const V=b.size===0||$.some(J=>v.has(J.target)&&b.has(J.source));return $.map(J=>{var ie,F;let re;return f?re=v.has(J.target)&&(b.size===0||!V||b.has(J.source))||v.has(J.source)&&E.has(J.target):(re=v.has(J.source),!re&&z.get(J.target)==="endNode"&&v.has(J.target)&&(re=!0)),re?(f||N.add(J.target),{...J,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...J.data,highlighted:!0},animated:!0}):(ie=J.data)!=null&&ie.highlighted?{...J,style:qi((F=J.data)==null?void 0:F.conditional),markerEnd:Os,data:{...J.data,highlighted:!1},animated:!1}:J})}),a($=>$.map(V=>{var ie,F,te,pe;const J=!f&&v.has(V.id);if(V.type==="startNode"||V.type==="endNode"){const _e=N.has(V.id)||!f&&v.has(V.id);return _e!==!!((ie=V.data)!=null&&ie.isActiveNode)||J!==!!((F=V.data)!=null&&F.isExecutingNode)?{...V,data:{...V.data,isActiveNode:_e,isExecutingNode:J}}:V}const re=f?E.has(V.id):N.has(V.id);return re!==!!((te=V.data)!=null&&te.isActiveNode)||J!==!!((pe=V.data)!=null&&pe.isExecutingNode)?{...V,data:{...V.data,isActiveNode:re,isExecutingNode:J}}:V}))},[M,j,s,r,D,y,a,c]);const R=de(f=>f.graphCache[t]);x.useEffect(()=>{if(!R&&t!=="__setup__")return;const f=R?Promise.resolve(R):fa(e),v=++k.current;p(!0),m(!1),f.then(async b=>{if(k.current!==v)return;if(!b.nodes.length){m(!0);return}const{nodes:E,edges:N}=await ba(b);if(k.current!==v)return;const z=de.getState().breakpoints[t],T=z?E.map($=>{if($.type==="startNode"||$.type==="endNode")return $;const V=$.type==="groupNode"?$.id:$.id.includes("/")?$.id.split("/").pop():$.id;return z[V]?{...$,data:{...$.data,hasBreakpoint:!0}}:$}):E;a(T),c(N),w($=>$+1),setTimeout(()=>{var $;($=C.current)==null||$.fitView({padding:.1,duration:200})},100)}).catch(()=>{k.current===v&&m(!0)}).finally(()=>{k.current===v&&p(!1)})},[e,t,R,a,c]),x.useEffect(()=>{const f=setTimeout(()=>{var v;(v=C.current)==null||v.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(f)},[t]);const _=x.useRef(null);return x.useEffect(()=>{const f=_.current;if(!f)return;const v=new ResizeObserver(()=>{var b;(b=C.current)==null||b.fitView({padding:.1,duration:200})});return v.observe(f),()=>v.disconnect()},[d,g]),x.useEffect(()=>{a(f=>{var J,re,ie;const v=!!(M!=null&&M.length),b=D==="completed"||D==="failed",E=new Set,N=new Set(f.map(F=>F.id)),z=new Map;for(const F of f){const te=(J=F.data)==null?void 0:J.label;if(!te)continue;const pe=F.id.includes("/")?F.id.split("/").pop():F.id;for(const _e of[pe,te]){let qe=z.get(_e);qe||(qe=new Set,z.set(_e,qe)),qe.add(F.id)}}if(v)for(const F of M){let te=!1;if(F.qualified_node_name){const pe=F.qualified_node_name.replace(/:/g,"/");N.has(pe)&&(E.add(pe),te=!0)}if(!te){const pe=z.get(F.node_name);pe&&pe.forEach(_e=>E.add(_e))}}const T=new Set;for(const F of f)F.parentNode&&E.has(F.id)&&T.add(F.parentNode);let $;D==="failed"&&E.size===0&&($=(re=f.find(F=>!F.parentNode&&F.type!=="startNode"&&F.type!=="endNode"&&F.type!=="groupNode"))==null?void 0:re.id);let V;if(D==="completed"){const F=(ie=f.find(te=>!te.parentNode&&te.type!=="startNode"&&te.type!=="endNode"&&te.type!=="groupNode"))==null?void 0:ie.id;F&&!E.has(F)&&(V=F)}return f.map(F=>{var pe;let te;return F.id===$?te="failed":F.id===V||E.has(F.id)?te="completed":F.type==="startNode"?(!F.parentNode&&v||F.parentNode&&T.has(F.parentNode))&&(te="completed"):F.type==="endNode"?!F.parentNode&&b?te=D==="failed"?"failed":"completed":F.parentNode&&T.has(F.parentNode)&&(te="completed"):F.type==="groupNode"&&T.has(F.id)&&(te="completed"),te!==((pe=F.data)==null?void 0:pe.status)?{...F,data:{...F.data,status:te}}:F})})},[M,D,y,a]),d?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):g?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:_,className:"h-full graph-panel",children:[n.jsx("style",{children:` +`)}`:o,children:[a&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Bn}),n.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",i?` (${i})`:""]}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),_.length>0&&n.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[_.map(m=>n.jsx("div",{className:"truncate",children:m},m)),g>0&&n.jsxs("div",{style:{fontStyle:"italic"},children:["+",g," more"]})]}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Bn})]})}const Dn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Na({data:e}){const t=e.label??"",s=e.status,r=e.hasBreakpoint,i=e.isPausedHere,o=e.isActiveNode,a=e.isExecutingNode,l=i?"var(--error)":a?"var(--success)":o?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--bg-tertiary)",h=i?"var(--error)":a?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${i||o||a?"solid":"dashed"} ${l}`,borderRadius:8,boxShadow:i||o||a?`0 0 4px ${h}`:void 0,animation:i||o||a?`node-pulse-${i?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[r&&n.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Dn}),n.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${l}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:t}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Dn})]})}function ja({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom})]})}function uh(e,t=8){if(e.length<2)return"";if(e.length===2)return`M ${e[0].x} ${e[0].y} L ${e[1].x} ${e[1].y}`;let s=`M ${e[0].x} ${e[0].y}`;for(let i=1;if.breakpoints[t]),A=de(f=>f.toggleBreakpoint),D=de(f=>f.clearBreakpoints),N=de(f=>f.activeNodes[t]),$=de(f=>{var b;return(b=f.runs[t])==null?void 0:b.status}),B=v.useCallback((f,b)=>{if(b.type==="startNode"||b.type==="endNode")return;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id;A(t,y);const j=de.getState().breakpoints[t]??{};i==null||i(Object.keys(j))},[t,A,i]),T=P&&Object.keys(P).length>0,O=v.useCallback(()=>{if(T)D(t),i==null||i([]);else{const f=[];for(const y of o){if(y.type==="startNode"||y.type==="endNode"||y.parentNode)continue;const j=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id;f.push(j)}for(const y of f)P!=null&&P[y]||A(t,y);const b=de.getState().breakpoints[t]??{};i==null||i(Object.keys(b))}},[t,T,P,o,D,A,i]);v.useEffect(()=>{a(f=>f.map(b=>{var M;if(b.type==="startNode"||b.type==="endNode")return b;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id,j=!!(P&&P[y]);return j!==!!((M=b.data)!=null&&M.hasBreakpoint)?{...b,data:{...b.data,hasBreakpoint:j}}:b}))},[P,a]),v.useEffect(()=>{const f=s?new Set(s.split(",").map(b=>b.trim()).filter(Boolean)):null;a(b=>b.map(y=>{var C,H;if(y.type==="startNode"||y.type==="endNode")return y;const j=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id,M=(C=y.data)==null?void 0:C.label,z=f!=null&&(f.has(j)||M!=null&&f.has(M));return z!==!!((H=y.data)!=null&&H.isPausedHere)?{...y,data:{...y.data,isPausedHere:z}}:y}))},[s,x,a]);const L=de(f=>f.stateEvents[t]);v.useEffect(()=>{const f=!!s;let b=new Set;const y=new Set,j=new Set,M=new Set,z=new Map,C=new Map;if(L)for(const H of L)H.phase==="started"?C.set(H.node_name,H.qualified_node_name??null):H.phase==="completed"&&C.delete(H.node_name);a(H=>{var q;for(const ee of H)ee.type&&z.set(ee.id,ee.type);const U=ee=>{var F;const ie=[];for(const se of H){const pe=se.type==="groupNode"?se.id:se.id.includes("/")?se.id.split("/").pop():se.id,_e=(F=se.data)==null?void 0:F.label;(pe===ee||_e!=null&&_e===ee)&&ie.push(se.id)}return ie};if(f&&s){const ee=s.split(",").map(ie=>ie.trim()).filter(Boolean);for(const ie of ee)U(ie).forEach(F=>b.add(F));if(r!=null&&r.length)for(const ie of r)U(ie).forEach(F=>j.add(F));N!=null&&N.prev&&U(N.prev).forEach(ie=>y.add(ie))}else if(C.size>0){const ee=new Map;for(const ie of H){const F=(q=ie.data)==null?void 0:q.label;if(!F)continue;const se=ie.id.includes("/")?ie.id.split("/").pop():ie.id;for(const pe of[se,F]){let _e=ee.get(pe);_e||(_e=new Set,ee.set(pe,_e)),_e.add(ie.id)}}for(const[ie,F]of C){let se=!1;if(F){const pe=F.replace(/:/g,"/");for(const _e of H)_e.id===pe&&(b.add(_e.id),se=!0)}if(!se){const pe=ee.get(ie);pe&&pe.forEach(_e=>b.add(_e))}}}return H}),c(H=>{const U=y.size===0||H.some(q=>b.has(q.target)&&y.has(q.source));return H.map(q=>{var ie,F;let ee;return f?ee=b.has(q.target)&&(y.size===0||!U||y.has(q.source))||b.has(q.source)&&j.has(q.target):(ee=b.has(q.source),!ee&&z.get(q.target)==="endNode"&&b.has(q.target)&&(ee=!0)),ee?(f||M.add(q.target),{...q,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...q.data,highlighted:!0},animated:!0}):(ie=q.data)!=null&&ie.highlighted?{...q,style:qi((F=q.data)==null?void 0:F.conditional),markerEnd:Os,data:{...q.data,highlighted:!1},animated:!1}:q})}),a(H=>H.map(U=>{var ie,F,se,pe;const q=!f&&b.has(U.id);if(U.type==="startNode"||U.type==="endNode"){const _e=M.has(U.id)||!f&&b.has(U.id);return _e!==!!((ie=U.data)!=null&&ie.isActiveNode)||q!==!!((F=U.data)!=null&&F.isExecutingNode)?{...U,data:{...U.data,isActiveNode:_e,isExecutingNode:q}}:U}const ee=f?j.has(U.id):M.has(U.id);return ee!==!!((se=U.data)!=null&&se.isActiveNode)||q!==!!((pe=U.data)!=null&&pe.isExecutingNode)?{...U,data:{...U.data,isActiveNode:ee,isExecutingNode:q}}:U}))},[L,N,s,r,$,x,a,c]);const R=de(f=>f.graphCache[t]);v.useEffect(()=>{if(!R&&t!=="__setup__")return;const f=R?Promise.resolve(R):fa(e),b=++E.current;_(!0),m(!1),f.then(async y=>{if(E.current!==b)return;if(!y.nodes.length){m(!0);return}const{nodes:j,edges:M}=await Sa(y);if(E.current!==b)return;const z=de.getState().breakpoints[t],C=z?j.map(H=>{if(H.type==="startNode"||H.type==="endNode")return H;const U=H.type==="groupNode"?H.id:H.id.includes("/")?H.id.split("/").pop():H.id;return z[U]?{...H,data:{...H.data,hasBreakpoint:!0}}:H}):j;a(C),c(M),w(H=>H+1),setTimeout(()=>{var H;(H=k.current)==null||H.fitView({padding:.1,duration:200})},100)}).catch(()=>{E.current===b&&m(!0)}).finally(()=>{E.current===b&&_(!1)})},[e,t,R,a,c]),v.useEffect(()=>{const f=setTimeout(()=>{var b;(b=k.current)==null||b.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(f)},[t]);const p=v.useRef(null);return v.useEffect(()=>{const f=p.current;if(!f)return;const b=new ResizeObserver(()=>{var y;(y=k.current)==null||y.fitView({padding:.1,duration:200})});return b.observe(f),()=>b.disconnect()},[d,g]),v.useEffect(()=>{a(f=>{var q,ee,ie;const b=!!(L!=null&&L.length),y=$==="completed"||$==="failed",j=new Set,M=new Set(f.map(F=>F.id)),z=new Map;for(const F of f){const se=(q=F.data)==null?void 0:q.label;if(!se)continue;const pe=F.id.includes("/")?F.id.split("/").pop():F.id;for(const _e of[pe,se]){let qe=z.get(_e);qe||(qe=new Set,z.set(_e,qe)),qe.add(F.id)}}if(b)for(const F of L){let se=!1;if(F.qualified_node_name){const pe=F.qualified_node_name.replace(/:/g,"/");M.has(pe)&&(j.add(pe),se=!0)}if(!se){const pe=z.get(F.node_name);pe&&pe.forEach(_e=>j.add(_e))}}const C=new Set;for(const F of f)F.parentNode&&j.has(F.id)&&C.add(F.parentNode);let H;$==="failed"&&j.size===0&&(H=(ee=f.find(F=>!F.parentNode&&F.type!=="startNode"&&F.type!=="endNode"&&F.type!=="groupNode"))==null?void 0:ee.id);let U;if($==="completed"){const F=(ie=f.find(se=>!se.parentNode&&se.type!=="startNode"&&se.type!=="endNode"&&se.type!=="groupNode"))==null?void 0:ie.id;F&&!j.has(F)&&(U=F)}return f.map(F=>{var pe;let se;return F.id===H?se="failed":F.id===U||j.has(F.id)?se="completed":F.type==="startNode"?(!F.parentNode&&b||F.parentNode&&C.has(F.parentNode))&&(se="completed"):F.type==="endNode"?!F.parentNode&&y?se=$==="failed"?"failed":"completed":F.parentNode&&C.has(F.parentNode)&&(se="completed"):F.type==="groupNode"&&C.has(F.id)&&(se="completed"),se!==((pe=F.data)==null?void 0:pe.status)?{...F,data:{...F.data,status:se}}:F})})},[L,$,x,a]),d?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):g?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:p,className:"h-full graph-panel",children:[n.jsx("style",{children:` .graph-panel .react-flow__handle { opacity: 0 !important; width: 0 !important; @@ -37,8 +37,8 @@ ${r.join(` 0%, 100% { box-shadow: 0 0 4px var(--error); } 50% { box-shadow: 0 0 10px var(--error); } } - `}),n.jsxs(oa,{nodes:o,edges:h,onNodesChange:l,onEdgesChange:u,nodeTypes:uh,edgeTypes:fh,onInit:f=>{C.current=f},onNodeClick:L,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(hc,{position:"top-right",children:n.jsxs("button",{onClick:I,title:B?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:B?"var(--error)":"var(--text-muted)",border:`1px solid ${B?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[n.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:B?"var(--error)":"var(--node-border)"}}),B?"Clear all":"Break all"]})}),n.jsx(ca,{nodeColor:f=>{var b;if(f.type==="groupNode")return"var(--bg-tertiary)";const v=(b=f.data)==null?void 0:b.status;return v==="completed"?"var(--success)":v==="running"?"var(--warning)":v==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ts="__setup__";function ph({entrypoint:e,mode:t,ws:s,onRunCreated:r,isMobile:i}){const[o,a]=x.useState("{}"),[l,h]=x.useState({}),[c,u]=x.useState(!1),[d,p]=x.useState(!0),[g,m]=x.useState(null),[y,w]=x.useState(""),[k,C]=x.useState(!0),[A,O]=x.useState(()=>{const b=localStorage.getItem("setupTextareaHeight");return b?parseInt(b,10):140}),P=x.useRef(null),[j,D]=x.useState(()=>{const b=localStorage.getItem("setupPanelWidth");return b?parseInt(b,10):380}),L=t==="run";x.useEffect(()=>{p(!0),m(null),bc(e).then(b=>{h(b.mock_input),a(JSON.stringify(b.mock_input,null,2))}).catch(b=>{console.error("Failed to load mock input:",b);const E=b.detail||{};m(E.message||`Failed to load schema for "${e}"`),a("{}")}).finally(()=>p(!1))},[e]),x.useEffect(()=>{de.getState().clearBreakpoints(ts)},[]);const B=async()=>{let b;try{b=JSON.parse(o)}catch{alert("Invalid JSON input");return}u(!0);try{const E=de.getState().breakpoints[ts]??{},N=Object.keys(E),z=await bn(e,b,t,N);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),r(z.id)}catch(E){console.error("Failed to create run:",E)}finally{u(!1)}},I=async()=>{const b=y.trim();if(b){u(!0);try{const E=de.getState().breakpoints[ts]??{},N=Object.keys(E),z=await bn(e,l,"chat",N);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),de.getState().addLocalChatMessage(z.id,{message_id:`local-${Date.now()}`,role:"user",content:b}),s.sendChatMessage(z.id,b),r(z.id)}catch(E){console.error("Failed to create chat run:",E)}finally{u(!1)}}};x.useEffect(()=>{try{JSON.parse(o),C(!0)}catch{C(!1)}},[o]);const M=x.useCallback(b=>{b.preventDefault();const E="touches"in b?b.touches[0].clientY:b.clientY,N=A,z=$=>{const V="touches"in $?$.touches[0].clientY:$.clientY,J=Math.max(60,N+(E-V));O(J)},T=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",T),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",T),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(A))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",T),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",T)},[A]),R=x.useCallback(b=>{b.preventDefault();const E="touches"in b?b.touches[0].clientX:b.clientX,N=j,z=$=>{const V=P.current;if(!V)return;const J="touches"in $?$.touches[0].clientX:$.clientX,re=V.clientWidth-300,ie=Math.max(280,Math.min(re,N+(E-J)));D(ie)},T=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",T),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",T),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(j))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",T),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",T)},[j]),_=L?"Autonomous":"Conversational",f=L?"var(--success)":"var(--accent)",v=n.jsxs("div",{className:"shrink-0 flex flex-col",style:i?{background:"var(--bg-primary)"}:{width:j,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"px-4 text-xs font-semibold border-b flex items-center gap-2 h-10",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{style:{color:f},children:"●"}),_]}),n.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[n.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:L?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("polyline",{points:"12 6 12 12 16 14"})]}):n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),n.jsxs("div",{className:"text-center space-y-1.5",children:[n.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:L?"Ready to execute":"Ready to chat"}),n.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",L?n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"configure input below, then run"]}):n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"then send your first message"]})]})]})]}),L?n.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!i&&n.jsx("div",{onMouseDown:M,onTouchStart:M,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"px-4 py-3",children:[g?n.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:g}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:["Input",d&&n.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),n.jsx("textarea",{value:o,onChange:b=>a(b.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none mb-3",style:{height:i?120:A,background:"var(--bg-secondary)",border:`1px solid ${k?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),n.jsx("button",{onClick:B,disabled:c||d||!!g,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:f,color:f},onMouseEnter:b=>{c||(b.currentTarget.style.background=`color-mix(in srgb, ${f} 10%, transparent)`)},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:c?"Starting...":n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("input",{value:y,onChange:b=>w(b.target.value),onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),I())},disabled:c||d,placeholder:c?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),n.jsx("button",{onClick:I,disabled:c||d||!y.trim(),className:"text-xs font-semibold px-3 py-1.5 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!c&&y.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:b=>{!c&&y.trim()&&(b.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:"Send"})]})]});return i?n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:v})]}):n.jsxs("div",{ref:P,className:"flex h-full",children:[n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{onMouseDown:R,onTouchStart:R,className:"shrink-0 drag-handle-col"}),v]})}const _h={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function gh(e){const t=[],s=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let r=0,i;for(;(i=s.exec(e))!==null;){if(i.index>r&&t.push({type:"punctuation",text:e.slice(r,i.index)}),i[1]!==void 0){t.push({type:"key",text:i[1]});const o=e.indexOf(":",i.index+i[1].length);o!==-1&&(o>i.index+i[1].length&&t.push({type:"punctuation",text:e.slice(i.index+i[1].length,o)}),t.push({type:"punctuation",text:":"}),s.lastIndex=o+1)}else i[2]!==void 0?t.push({type:"string",text:i[2]}):i[3]!==void 0?t.push({type:"number",text:i[3]}):i[4]!==void 0?t.push({type:"boolean",text:i[4]}):i[5]!==void 0?t.push({type:"null",text:i[5]}):i[6]!==void 0&&t.push({type:"punctuation",text:i[6]});r=s.lastIndex}return rgh(e),[e]);return n.jsx("pre",{className:t,style:s,children:r.map((i,o)=>n.jsx("span",{style:{color:_h[i.type]},children:i.text},o))})}const mh={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},vh={color:"var(--text-muted)",label:"Unknown"};function xh(e){if(typeof e!="string")return null;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}return null}const Pn=200;function yh(e){if(typeof e=="string")return e;if(e==null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function bh({value:e}){const[t,s]=x.useState(!1),r=yh(e),i=x.useMemo(()=>xh(e),[e]),o=i!==null,a=i??r,l=a.length>Pn||a.includes(` -`),h=x.useCallback(()=>s(c=>!c),[]);return l?n.jsxs("div",{children:[t?o?n.jsx(gt,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):n.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):n.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,Pn),"..."]}),n.jsx("button",{onClick:h,className:"text-[11px] cursor-pointer ml-1 px-1",style:{color:"var(--info)"},children:t?"[less]":"[more]"})]}):o?n.jsx(gt,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function Sh({span:e}){const[t,s]=x.useState(!0),[r,i]=x.useState(!1),[o,a]=x.useState("table"),[l,h]=x.useState(!1),c=mh[e.status.toLowerCase()]??{...vh,label:e.status},u=x.useMemo(()=>JSON.stringify(e,null,2),[e]),d=x.useCallback(()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})},[u]),p=Object.entries(e.attributes),g=[{label:"Span",value:e.span_id},...e.trace_id?[{label:"Trace",value:e.trace_id}]:[],{label:"Run",value:e.run_id},...e.parent_span_id?[{label:"Parent",value:e.parent_span_id}]:[]];return n.jsxs("div",{className:"flex flex-col h-full text-xs leading-normal",children:[n.jsxs("div",{className:"px-2 border-b flex items-center gap-1 shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>a("table"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="table"?"var(--accent)":"var(--text-muted)",background:o==="table"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-muted)")},children:"Table"}),n.jsx("button",{onClick:()=>a("json"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="json"?"var(--accent)":"var(--text-muted)",background:o==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-muted)")},children:"JSON"}),n.jsxs("span",{className:"ml-auto shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${c.color} 15%, var(--bg-secondary))`,color:c.color},children:[n.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:c.color}}),c.label]})]}),n.jsx("div",{className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:o==="table"?n.jsxs(n.Fragment,{children:[p.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>s(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Attributes (",p.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:t?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),t&&p.map(([m,y],w)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:w%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m,children:m}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx(bh,{value:y})})]},m))]}),n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>i(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Identifiers (",g.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:r?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),r&&g.map((m,y)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:y%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m.label,children:m.label}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:m.value})})]},m.label))]}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:d,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:l?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:m=>{l||(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{m.currentTarget.style.color=l?"var(--success)":"var(--text-muted)"},children:l?"Copied!":"Copy"}),n.jsx(gt,{json:u,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]})}function wh(e){const t=[];function s(r,i){t.push({span:r.span,depth:i});for(const o of r.children)s(o,i+1)}for(const r of e)s(r,0);return t}function Ch({tree:e,selectedSpan:t,onSelect:s}){const r=x.useMemo(()=>wh(e),[e]),{globalStart:i,totalDuration:o}=x.useMemo(()=>{if(r.length===0)return{globalStart:0,totalDuration:1};let a=1/0,l=-1/0;for(const{span:h}of r){const c=new Date(h.timestamp).getTime();a=Math.min(a,c),l=Math.max(l,c+(h.duration_ms??0))}return{globalStart:a,totalDuration:Math.max(l-a,1)}},[r]);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(({span:a,depth:l})=>{var y;const h=new Date(a.timestamp).getTime()-i,c=a.duration_ms??0,u=h/o*100,d=Math.max(c/o*100,.3),p=Ma[a.status.toLowerCase()]??"var(--text-muted)",g=a.span_id===(t==null?void 0:t.span_id),m=(y=a.attributes)==null?void 0:y["openinference.span.kind"];return n.jsxs("button",{"data-span-id":a.span_id,onClick:()=>s(a),className:"w-full text-left text-xs leading-normal py-1 flex items-center transition-colors",style:{background:g?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:g?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{g||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{g||(w.currentTarget.style.background="")},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-1 overflow-hidden",style:{width:"35%",minWidth:"80px",paddingLeft:`${l*12+4}px`},children:[n.jsx("span",{className:"shrink-0 flex items-center justify-center w-3.5 h-3.5",children:n.jsx(La,{kind:m,statusColor:p})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate",children:a.span_name})]}),n.jsx("div",{className:"flex-1 relative h-[14px] mx-1 rounded-sm",style:{background:"var(--bg-secondary)"},children:n.jsx("div",{className:"absolute rounded-sm",style:{left:`${u}%`,width:`${d}%`,top:"2px",bottom:"2px",background:p,opacity:.8,minWidth:"2px"}})}),n.jsx("span",{className:"shrink-0 text-[10px] tabular-nums pr-2",style:{width:"52px",textAlign:"right",color:"var(--text-muted)"},children:Ta(a.duration_ms)})]},a.span_id)})})}const Ma={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function La({kind:e,statusColor:t}){const s=t,r=14,i={width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"LLM":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:s,stroke:"none"})});case"TOOL":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),n.jsx("circle",{cx:"6",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("circle",{cx:"10",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("path",{d:"M8 2v3"}),n.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return n.jsxs("svg",{...i,children:[n.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),n.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),n.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return n.jsxs("svg",{...i,children:[n.jsx("circle",{cx:"7",cy:"7",r:"4"}),n.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:t}})}}function kh(e){const t=new Map(e.map(a=>[a.span_id,a])),s=new Map;for(const a of e)if(a.parent_span_id){const l=s.get(a.parent_span_id)??[];l.push(a),s.set(a.parent_span_id,l)}const r=e.filter(a=>a.parent_span_id===null||!t.has(a.parent_span_id));function i(a){const l=(s.get(a.span_id)??[]).sort((h,c)=>h.timestamp.localeCompare(c.timestamp));return{span:a,children:l.map(i)}}return r.sort((a,l)=>a.timestamp.localeCompare(l.timestamp)).map(i).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function Ta(e){return e==null?"":e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`}function Ra(e){return e.map(t=>{const{span:s}=t;return t.children.length>0?{name:s.span_name,children:Ra(t.children)}:{name:s.span_name}})}function si({traces:e}){const[t,s]=x.useState(null),[r,i]=x.useState(new Set),[o,a]=x.useState(()=>{const L=localStorage.getItem("traceTreeSplitWidth");return L?parseFloat(L):50}),[l,h]=x.useState(!1),[c,u]=x.useState(!1),[d,p]=x.useState(()=>localStorage.getItem("traceViewMode")||"tree"),g=kh(e),m=x.useMemo(()=>JSON.stringify(Ra(g),null,2),[e]),y=x.useCallback(()=>{navigator.clipboard.writeText(m).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[m]),w=de(L=>L.focusedSpan),k=de(L=>L.setFocusedSpan),[C,A]=x.useState(null),O=x.useRef(null),P=x.useCallback(L=>{i(B=>{const I=new Set(B);return I.has(L)?I.delete(L):I.add(L),I})},[]),j=x.useRef(null);x.useEffect(()=>{const L=g.length>0?g[0].span.span_id:null,B=j.current;if(j.current=L,L&&L!==B)s(g[0].span);else if(t===null)g.length>0&&s(g[0].span);else{const I=e.find(M=>M.span_id===t.span_id);I&&I!==t&&s(I)}},[e]),x.useEffect(()=>{if(!w)return;const B=e.filter(I=>I.span_name===w.name).sort((I,M)=>I.timestamp.localeCompare(M.timestamp))[w.index];if(B){s(B),A(B.span_id);const I=new Map(e.map(M=>[M.span_id,M.parent_span_id]));i(M=>{const R=new Set(M);let _=B.parent_span_id;for(;_;)R.delete(_),_=I.get(_)??null;return R})}k(null)},[w,e,k]),x.useEffect(()=>{if(!C)return;const L=C;A(null),requestAnimationFrame(()=>{const B=O.current,I=B==null?void 0:B.querySelector(`[data-span-id="${L}"]`);B&&I&&I.scrollIntoView({block:"center",behavior:"smooth"})})},[C]),x.useEffect(()=>{if(!l)return;const L=I=>{const M=document.querySelector(".trace-tree-container");if(!M)return;const R=M.getBoundingClientRect(),_=(I.clientX-R.left)/R.width*100,f=Math.max(20,Math.min(80,_));a(f),localStorage.setItem("traceTreeSplitWidth",String(f))},B=()=>{h(!1)};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",B),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",B)}},[l]);const D=L=>{L.preventDefault(),h(!0)};return n.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:l?"col-resize":void 0},children:[n.jsxs("div",{className:"flex flex-col",style:{width:`${o}%`},children:[e.length>0&&n.jsxs("div",{className:"flex items-center gap-1 px-2 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>{p("tree"),localStorage.setItem("traceViewMode","tree")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="tree"?"var(--accent)":"var(--text-muted)",background:d==="tree"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:L=>{d!=="tree"&&(L.currentTarget.style.color="var(--text-primary)")},onMouseLeave:L=>{d!=="tree"&&(L.currentTarget.style.color="var(--text-muted)")},children:"Tree"}),n.jsx("button",{onClick:()=>{p("timeline"),localStorage.setItem("traceViewMode","timeline")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="timeline"?"var(--accent)":"var(--text-muted)",background:d==="timeline"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:L=>{d!=="timeline"&&(L.currentTarget.style.color="var(--text-primary)")},onMouseLeave:L=>{d!=="timeline"&&(L.currentTarget.style.color="var(--text-muted)")},children:"Timeline"}),n.jsx("button",{onClick:()=>{p("json"),localStorage.setItem("traceViewMode","json")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="json"?"var(--accent)":"var(--text-muted)",background:d==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:L=>{d!=="json"&&(L.currentTarget.style.color="var(--text-primary)")},onMouseLeave:L=>{d!=="json"&&(L.currentTarget.style.color="var(--text-muted)")},children:"JSON"})]}),n.jsx("div",{ref:O,className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:g.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):d==="tree"?g.map((L,B)=>n.jsx(Ba,{node:L,depth:0,selectedId:(t==null?void 0:t.span_id)??null,onSelect:s,isLast:B===g.length-1,collapsedIds:r,toggleExpanded:P},L.span.span_id)):d==="timeline"?n.jsx(Ch,{tree:g,selectedSpan:t,onSelect:s}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:y,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:c?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:L=>{c||(L.currentTarget.style.color="var(--text-primary)")},onMouseLeave:L=>{L.currentTarget.style.color=c?"var(--success)":"var(--text-muted)"},children:c?"Copied!":"Copy"}),n.jsx(gt,{json:m,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]}),n.jsx("div",{onMouseDown:D,className:"shrink-0 drag-handle-col",style:l?{background:"var(--accent)"}:void 0}),n.jsx("div",{className:"flex-1 overflow-hidden",children:t?n.jsx(Sh,{span:t}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function Ba({node:e,depth:t,selectedId:s,onSelect:r,isLast:i,collapsedIds:o,toggleExpanded:a}){var y;const{span:l}=e,h=!o.has(l.span_id),c=Ma[l.status.toLowerCase()]??"var(--text-muted)",u=Ta(l.duration_ms),d=l.span_id===s,p=e.children.length>0,g=t*20,m=(y=l.attributes)==null?void 0:y["openinference.span.kind"];return n.jsxs("div",{className:"relative",children:[t>0&&n.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${g-10}px`,width:"1px",height:i?"16px":"100%",background:"var(--border)"}}),n.jsxs("button",{"data-span-id":l.span_id,onClick:()=>r(l),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${g+4}px`,background:d?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:d?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:w=>{d||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{d||(w.currentTarget.style.background="")},children:[t>0&&n.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${g-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),p?n.jsx("span",{onClick:w=>{w.stopPropagation(),a(l.span_id)},className:"shrink-0 w-5 h-5 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("span",{className:"shrink-0 w-4"}),n.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:n.jsx(La,{kind:m,statusColor:c})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:l.span_name}),u&&n.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:u})]}),h&&e.children.map((w,k)=>n.jsx(Ba,{node:w,depth:t+1,selectedId:s,onSelect:r,isLast:k===e.children.length-1,collapsedIds:o,toggleExpanded:a},w.span.span_id))]})}const Eh={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},Nh={color:"var(--text-muted)",bg:"transparent"};function An({logs:e}){const t=x.useRef(null),s=x.useRef(null),[r,i]=x.useState(!1);x.useEffect(()=>{var a;(a=s.current)==null||a.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const a=t.current;a&&i(a.scrollTop>100)};return e.length===0?n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):n.jsxs("div",{className:"h-full relative",children:[n.jsxs("div",{ref:t,onScroll:o,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[e.map((a,l)=>{const h=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),c=a.level.toUpperCase(),u=c.slice(0,4),d=Eh[c]??Nh,p=l%2===0;return n.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:p?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:h}),n.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:d.color,background:d.bg},children:u}),n.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},l)}),n.jsx("div",{ref:s})]}),r&&n.jsx("button",{onClick:()=>{var a;return(a=t.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const jh={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},On={color:"var(--text-muted)",label:""};function er({events:e,runStatus:t}){const s=x.useRef(null),r=x.useRef(!0),[i,o]=x.useState(null),a=()=>{const l=s.current;l&&(r.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return x.useEffect(()=>{r.current&&s.current&&(s.current.scrollTop=s.current.scrollHeight)}),e.length===0?n.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t==="running"?"Waiting for events...":"No events yet"})}):n.jsx("div",{ref:s,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:e.map((l,h)=>{const c=new Date(l.timestamp).toLocaleTimeString(void 0,{hour12:!1}),u=l.payload&&Object.keys(l.payload).length>0,d=i===h,p=l.phase?jh[l.phase]??On:On;return n.jsxs("div",{children:[n.jsxs("div",{onClick:()=>{u&&o(d?null:h)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:h%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:u?"pointer":"default"},children:[n.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:c}),n.jsx("span",{className:"shrink-0",style:{color:p.color},children:"●"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:l.node_name}),p.label&&n.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:p.label}),u&&n.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:d?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),d&&u&&n.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:n.jsx(gt,{json:JSON.stringify(l.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},h)})})}function Ot({title:e,copyText:t,trailing:s,children:r}){const[i,o]=x.useState(!1),a=x.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[t]);return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:e}),s,t&&n.jsx("button",{onClick:a,className:`${s?"":"ml-auto "}text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-colors`,style:{color:i?"var(--success)":"var(--text-muted)",background:"var(--bg-tertiary)",border:"none"},onMouseEnter:l=>{i||(l.currentTarget.style.color="var(--text-primary)")},onMouseLeave:l=>{l.currentTarget.style.color=i?"var(--success)":"var(--text-muted)"},children:i?"Copied":"Copy"})]}),r]})}function In({runId:e,status:t,ws:s,breakpointNode:r}){const i=t==="suspended",o=a=>{const l=de.getState().breakpoints[e]??{};s.setBreakpoints(e,Object.keys(l)),a==="step"?s.debugStep(e):a==="continue"?s.debugContinue(e):s.debugStop(e)};return n.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),n.jsx(Hr,{label:"Step",onClick:()=>o("step"),disabled:!i,color:"var(--info)",active:i}),n.jsx(Hr,{label:"Continue",onClick:()=>o("continue"),disabled:!i,color:"var(--success)",active:i}),n.jsx(Hr,{label:"Stop",onClick:()=>o("stop"),disabled:!i,color:"var(--error)",active:i}),n.jsx("span",{className:"text-[11px] ml-auto truncate",style:{color:i?"var(--accent)":"var(--text-muted)"},children:i?r?`Paused at ${r}`:"Paused":t})]})}function Hr({label:e,onClick:t,disabled:s,color:r,active:i}){return n.jsx("button",{onClick:t,disabled:s,className:"px-3 py-1 h-7 text-[11px] font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:i?r:"var(--text-muted)",background:i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},onMouseEnter:o=>{s||(o.currentTarget.style.background=`color-mix(in srgb, ${r} 20%, transparent)`)},onMouseLeave:o=>{o.currentTarget.style.background=i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},children:e})}const Wn=x.lazy(()=>ya(()=>import("./ChatPanel-CioL9l4m.js"),__vite__mapDeps([2,1,3,4]))),Mh=[],Lh=[],Th=[],Rh=[];function Bh({run:e,ws:t,isMobile:s}){const r=e.mode==="chat",[i,o]=x.useState(280),[a,l]=x.useState(()=>{const _=localStorage.getItem("chatPanelWidth");return _?parseInt(_,10):380}),[h,c]=x.useState("primary"),[u,d]=x.useState(r?"primary":"traces"),p=x.useRef(null),g=x.useRef(null),m=x.useRef(!1),y=de(_=>_.traces[e.id]||Mh),w=de(_=>_.logs[e.id]||Lh),k=de(_=>_.chatMessages[e.id]||Th),C=de(_=>_.stateEvents[e.id]||Rh),A=de(_=>_.breakpoints[e.id]);x.useEffect(()=>{t.setBreakpoints(e.id,A?Object.keys(A):[])},[e.id]);const O=x.useCallback(_=>{t.setBreakpoints(e.id,_)},[e.id,t]),P=x.useCallback(_=>{_.preventDefault(),m.current=!0;const f="touches"in _?_.touches[0].clientY:_.clientY,v=i,b=N=>{if(!m.current)return;const z=p.current;if(!z)return;const T="touches"in N?N.touches[0].clientY:N.clientY,$=z.clientHeight-100,V=Math.max(80,Math.min($,v+(T-f)));o(V)},E=()=>{m.current=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",E),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",b),document.addEventListener("mouseup",E),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("touchend",E)},[i]),j=x.useCallback(_=>{_.preventDefault();const f="touches"in _?_.touches[0].clientX:_.clientX,v=a,b=N=>{const z=g.current;if(!z)return;const T="touches"in N?N.touches[0].clientX:N.clientX,$=z.clientWidth-300,V=Math.max(280,Math.min($,v+(f-T)));l(V)},E=()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",E),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",b),document.addEventListener("mouseup",E),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("touchend",E)},[a]),D=r?"Chat":"Events",L=r?"var(--accent)":"var(--success)",B=_=>_==="primary"?L:_==="events"?"var(--success)":"var(--accent)",I=de(_=>_.activeInterrupt[e.id]??null),M=e.status==="running"?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:r?"Thinking...":"Running..."}):r&&e.status==="suspended"&&I?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(s){const _=[{id:"traces",label:"Traces",count:y.length},{id:"primary",label:D},...r?[{id:"events",label:"Events",count:C.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{className:"flex flex-col h-full",children:[(e.mode==="debug"||e.status==="suspended"&&!I||A&&Object.keys(A).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:y,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:O})}),n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[_.map(f=>n.jsxs("button",{onClick:()=>d(f.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:u===f.id?B(f.id):"var(--text-muted)",background:u===f.id?`color-mix(in srgb, ${B(f.id)} 10%, transparent)`:"transparent"},children:[f.label,f.count!==void 0&&f.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:f.count})]},f.id)),M]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[u==="traces"&&n.jsx(si,{traces:y}),u==="primary"&&(r?n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:k,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:C,runStatus:e.status})),u==="events"&&n.jsx(er,{events:C,runStatus:e.status}),u==="io"&&n.jsx(Hn,{run:e}),u==="logs"&&n.jsx(An,{logs:w})]})]})}const R=[{id:"primary",label:D},...r?[{id:"events",label:"Events",count:C.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{ref:g,className:"flex h-full",children:[n.jsxs("div",{ref:p,className:"flex flex-col flex-1 min-w-0",children:[(e.mode==="debug"||e.status==="suspended"&&!I||A&&Object.keys(A).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0 overflow-hidden",style:{height:i},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:y,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:O})}),n.jsx("div",{onMouseDown:P,onTouchStart:P,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(si,{traces:y})})]}),n.jsx("div",{onMouseDown:j,onTouchStart:j,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[R.map(_=>n.jsxs("button",{onClick:()=>c(_.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:h===_.id?B(_.id):"var(--text-muted)",background:h===_.id?`color-mix(in srgb, ${B(_.id)} 10%, transparent)`:"transparent"},onMouseEnter:f=>{h!==_.id&&(f.currentTarget.style.color="var(--text-primary)")},onMouseLeave:f=>{h!==_.id&&(f.currentTarget.style.color="var(--text-muted)")},children:[_.label,_.count!==void 0&&_.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:_.count})]},_.id)),M]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[h==="primary"&&(r?n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:k,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:C,runStatus:e.status})),h==="events"&&n.jsx(er,{events:C,runStatus:e.status}),h==="io"&&n.jsx(Hn,{run:e}),h==="logs"&&n.jsx(An,{logs:w})]})]})]})}function Hn({run:e}){return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:JSON.stringify(e.input_data,null,2),children:n.jsx(gt,{json:JSON.stringify(e.input_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.output_data&&n.jsx(Ot,{title:"Output",copyText:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),children:n.jsx(gt,{json:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.error&&n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[n.jsxs("div",{className:"px-3 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[n.jsx("span",{children:"Error"}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.code}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.category})]}),n.jsxs("div",{className:"px-3 py-2 text-xs leading-normal",children:[n.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:e.error.title}),n.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:e.error.detail})]})]})]})}function $n(){const{reloadPending:e,setReloadPending:t,setEntrypoints:s}=de(),[r,i]=x.useState(!1);if(!e)return null;const o=async()=>{i(!0);try{await wc();const a=await $i();s(a.map(l=>l.name)),t(!1)}catch(a){console.error("Reload failed:",a)}finally{i(!1)}};return n.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2 rounded-lg shadow-lg",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[n.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Files changed"}),n.jsx("button",{onClick:o,disabled:r,className:"px-2.5 py-0.5 text-xs font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:r?.6:1},children:r?"Reloading...":"Reload"}),n.jsx("button",{onClick:()=>t(!1),"aria-label":"Dismiss reload prompt",className:"text-xs cursor-pointer px-0.5",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})}let Dh=0;const Fn=Jt(e=>({toasts:[],addToast:(t,s)=>{const r=String(++Dh);e(o=>({toasts:[...o.toasts,{id:r,type:t,message:s}]})),setTimeout(()=>{e(o=>({toasts:o.toasts.filter(a=>a.id!==r)}))},t==="error"?8e3:5e3)},removeToast:t=>{e(s=>({toasts:s.toasts.filter(r=>r.id!==t)}))}})),zn={success:{color:"var(--success)",bg:"color-mix(in srgb, var(--success) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--success) 30%, var(--border))"},error:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--error) 30%, var(--border))"},info:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--info) 30%, var(--border))"}};function Un(){const e=Fn(s=>s.toasts),t=Fn(s=>s.removeToast);return e.length===0?null:n.jsx("div",{className:"fixed bottom-8 right-4 z-[100] flex flex-col gap-2 pointer-events-none",children:e.map(s=>{const r=zn[s.type]??zn.info;return n.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-lg shadow-lg text-xs font-medium max-w-xs animate-[slideIn_0.2s_ease-out]",style:{background:r.bg,border:`1px solid ${r.border}`,color:r.color},children:[n.jsx("span",{className:"flex-1",children:s.message}),n.jsx("button",{onClick:()=>t(s.id),className:"shrink-0 w-5 h-5 flex items-center justify-center rounded cursor-pointer transition-opacity opacity-60 hover:opacity-100",style:{color:r.color,background:"transparent",border:"none"},"aria-label":"Dismiss",children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[n.jsx("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),n.jsx("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]})})]},s.id)})})}function Ph(e){return e===null?"-":`${Math.round(e*100)}%`}function Ah(e){if(e===null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}const Kn={pending:{color:"var(--text-muted)",label:"Pending"},running:{color:"var(--info)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"}};function Vn(){const e=Se(l=>l.evalSets),t=Se(l=>l.evalRuns),{evalSetId:s,evalRunId:r,navigate:i}=et(),o=Object.values(e),a=Object.values(t).sort((l,h)=>new Date(h.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("button",{onClick:()=>i("#/evals/new"),className:"w-[calc(100%-24px)] mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] text-center font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-secondary)",l.currentTarget.style.borderColor=""},children:"+ New Eval Set"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Eval Sets"}),o.map(l=>{const h=s===l.id;return n.jsxs("button",{onClick:()=>i(`#/evals/sets/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:c=>{h||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{h||(c.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"truncate font-medium",children:l.name}),n.jsxs("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:[l.eval_count," items · ",l.evaluator_ids.length," evaluator",l.evaluator_ids.length!==1?"s":""]})]},l.id)}),o.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval sets yet"}),n.jsx("div",{className:"px-3 pt-4 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),a.map(l=>{const h=r===l.id,c=Kn[l.status]??Kn.pending;return n.jsx("button",{onClick:()=>i(`#/evals/runs/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:u=>{h||(u.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:u=>{h||(u.currentTarget.style.background="transparent")},children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c.color}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"truncate font-medium",children:l.eval_set_name}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:l.start_time?new Date(l.start_time).toLocaleString():c.label})]}),n.jsx("span",{className:"font-mono shrink-0",style:{color:Ah(l.overall_score)},children:Ph(l.overall_score)})]})},l.id)}),a.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval runs yet"})]})}function qn(e,t=60){const s=typeof e=="string"?e:JSON.stringify(e);return!s||s==="null"?"-":s.length>t?s.slice(0,t)+"...":s}function Oh({evalSetId:e}){const[t,s]=x.useState(null),[r,i]=x.useState(!0),[o,a]=x.useState(null),[l,h]=x.useState(!1),[c,u]=x.useState("io"),d=Se(T=>T.evaluators),p=Se(T=>T.localEvaluators),g=Se(T=>T.updateEvalSetEvaluators),m=Se(T=>T.incrementEvalSetCount),y=Se(T=>T.upsertEvalRun),{navigate:w}=et(),[k,C]=x.useState(!1),[A,O]=x.useState(new Set),[P,j]=x.useState(!1),D=x.useRef(null),[L,B]=x.useState(()=>{const T=localStorage.getItem("evalSetSidebarWidth");return T?parseInt(T,10):320}),[I,M]=x.useState(!1),R=x.useRef(null);x.useEffect(()=>{localStorage.setItem("evalSetSidebarWidth",String(L))},[L]),x.useEffect(()=>{i(!0),a(null),Wc(e).then(T=>{s(T),T.items.length>0&&a(T.items[0].name)}).catch(console.error).finally(()=>i(!1))},[e]);const _=async()=>{h(!0);try{const T=await Hc(e);y(T),w(`#/evals/runs/${T.id}`)}catch(T){console.error(T)}finally{h(!1)}},f=async T=>{if(t)try{await Ic(e,T),s($=>{if(!$)return $;const V=$.items.filter(J=>J.name!==T);return{...$,items:V,eval_count:V.length}}),m(e,-1),o===T&&a(null)}catch($){console.error($)}},v=x.useCallback(()=>{t&&O(new Set(t.evaluator_ids)),C(!0)},[t]),b=T=>{O($=>{const V=new Set($);return V.has(T)?V.delete(T):V.add(T),V})},E=async()=>{if(t){j(!0);try{const T=await zc(e,Array.from(A));s(T),g(e,T.evaluator_ids),C(!1)}catch(T){console.error(T)}finally{j(!1)}}};x.useEffect(()=>{if(!k)return;const T=$=>{D.current&&!D.current.contains($.target)&&C(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[k]);const N=x.useCallback(T=>{T.preventDefault(),M(!0);const $="touches"in T?T.touches[0].clientX:T.clientX,V=L,J=ie=>{const F=R.current;if(!F)return;const te="touches"in ie?ie.touches[0].clientX:ie.clientX,pe=F.clientWidth-300,_e=Math.max(280,Math.min(pe,V+($-te)));B(_e)},re=()=>{M(!1),document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",re),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",re),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",J),document.addEventListener("mouseup",re),document.addEventListener("touchmove",J,{passive:!1}),document.addEventListener("touchend",re)},[L]);if(r)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!t)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval set not found"});const z=t.items.find(T=>T.name===o)??null;return n.jsxs("div",{ref:R,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:t.name}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[t.eval_count," items"]}),n.jsxs("div",{className:"flex gap-1 items-center ml-auto relative",children:[n.jsx("button",{onClick:v,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:T=>{T.currentTarget.style.color="var(--text-primary)",T.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-muted)",T.currentTarget.style.background="transparent"},title:"Edit evaluators","aria-label":"Edit evaluators",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),n.jsx("path",{d:"m15 5 4 4"})]})}),t.evaluator_ids.map(T=>{const $=d.find(V=>V.id===T);return n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:($==null?void 0:$.name)??T},T)}),k&&n.jsxs("div",{ref:D,className:"absolute top-full right-0 mt-1 z-50 rounded-md border shadow-lg",style:{background:"var(--bg-primary)",borderColor:"var(--border)",minWidth:220},children:[n.jsx("div",{className:"px-3 py-2 border-b text-[10px] uppercase tracking-wide font-semibold",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:"Evaluators"}),n.jsx("div",{className:"max-h-48 overflow-y-auto",children:p.length===0?n.jsx("div",{className:"px-3 py-3 text-xs",style:{color:"var(--text-muted)"},children:"No evaluators available"}):p.map(T=>n.jsxs("label",{className:"flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:$=>{$.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:$=>{$.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:A.has(T.id),onChange:()=>b(T.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:T.name})]},T.id))}),n.jsx("div",{className:"px-3 py-2 border-t flex justify-end",style:{borderColor:"var(--border)"},children:n.jsx("button",{onClick:E,disabled:P,className:"px-3 py-1 text-[11px] font-semibold rounded cursor-pointer transition-colors disabled:opacity-50",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},onMouseEnter:T=>{T.currentTarget.style.background="var(--accent-hover)"},onMouseLeave:T=>{T.currentTarget.style.background="var(--accent)"},children:P?"Saving...":"Update"})})]})]}),n.jsxs("button",{onClick:_,disabled:l,className:"ml-2 px-3 py-1 h-7 text-xs font-semibold rounded border flex items-center gap-1.5 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--success)",borderColor:"var(--success)",background:"transparent"},onMouseEnter:T=>{l||(T.currentTarget.style.background="color-mix(in srgb, var(--success) 10%, transparent)")},onMouseLeave:T=>{T.currentTarget.style.background="transparent"},title:"Run eval set","aria-label":"Run eval set",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),l?"Running...":"Run"]})]}),n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-56 shrink-0",children:"Name"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Input"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Behavior"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Output"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Simulation Instr."}),n.jsx("span",{className:"w-8 shrink-0"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.items.map(T=>{const $=T.name===o;return n.jsxs("button",{onClick:()=>a($?null:T.name),className:"group w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:$?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:$?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:V=>{$||(V.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:V=>{$||(V.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-56 shrink-0 truncate",style:{color:"var(--text-primary)"},children:T.name}),n.jsx("span",{className:"flex-1 min-w-0 truncate font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(T.inputs)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:T.expected_behavior||"-"}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(T.expected_output,40)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:T.simulation_instructions||"-"}),n.jsx("span",{role:"button",tabIndex:0,className:"w-8 shrink-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:V=>{V.stopPropagation(),f(T.name)},onKeyDown:V=>{V.key==="Enter"&&(V.stopPropagation(),f(T.name))},style:{color:"var(--text-muted)"},onMouseEnter:V=>{V.currentTarget.style.color="var(--error)"},onMouseLeave:V=>{V.currentTarget.style.color="var(--text-muted)"},title:"Delete item",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},T.name)}),t.items.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:"No items in this eval set"})]})]}),n.jsx("div",{onMouseDown:N,onTouchStart:N,className:`shrink-0 drag-handle-col${I?"":" transition-all"}`,style:{width:z?3:0,opacity:z?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${I?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:z?L:0,background:"var(--bg-primary)"},children:[n.jsx("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:L},children:["io","evaluators"].map(T=>{const $=c===T,V=T==="io"?"I/O":"Evaluators";return n.jsx("button",{onClick:()=>u(T),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded inline-flex items-center cursor-pointer transition-colors",style:{color:$?"var(--accent)":"var(--text-muted)",background:$?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},children:V},T)})}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:L},children:z?c==="io"?n.jsx(Ih,{item:z}):n.jsx(Wh,{item:z,evaluators:d}):null})]})]})}function Ih({item:e}){const t=JSON.stringify(e.inputs,null,2),s=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.expected_behavior&&n.jsx(Ot,{title:"Expected Behavior",copyText:e.expected_behavior,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.expected_behavior})}),s&&n.jsx(Ot,{title:"Expected Output",copyText:s,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.simulation_instructions&&n.jsx(Ot,{title:"Simulation Instructions",copyText:e.simulation_instructions,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.simulation_instructions})})]})}function Wh({item:e,evaluators:t}){return n.jsx("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:e.evaluator_ids.length>0?n.jsx(n.Fragment,{children:e.evaluator_ids.map(s=>{var o;const r=t.find(a=>a.id===s),i=(o=e.evaluation_criterias)==null?void 0:o[s];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:(r==null?void 0:r.name)??s}),n.jsx("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:i?"Custom criteria":"Default criteria"})]}),i&&n.jsx("pre",{className:"px-3 py-2 border-t text-[11px] font-mono overflow-x-auto max-h-32 whitespace-pre-wrap break-words",style:{borderColor:"var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(i,null,2)})]},s)})}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"No evaluators configured for this item"})})}function ms(e){return e==null?"-":`${Math.round(e*100)}%`}function At(e){if(e==null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}function Hh(e,t){if(!e)return"-";const s=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.round((r-s)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function Xn(e){return e.replace(/\s*Evaluator$/i,"")}const Yn={pending:{color:"var(--text-muted)",bg:"var(--bg-tertiary)",label:"Pending"},running:{color:"var(--info)",bg:"rgba(59,130,246,0.1)",label:"Running"},completed:{color:"var(--success)",bg:"rgba(34,197,94,0.1)",label:"Completed"},failed:{color:"var(--error)",bg:"rgba(239,68,68,0.1)",label:"Failed"}};function $h({evalRunId:e,itemName:t}){var _;const[s,r]=x.useState(null),[i,o]=x.useState(!0),{navigate:a}=et(),l=t??null,[h,c]=x.useState(220),u=x.useRef(null),d=x.useRef(!1),[p,g]=x.useState(()=>{const f=localStorage.getItem("evalSidebarWidth");return f?parseInt(f,10):320}),[m,y]=x.useState(!1),w=x.useRef(null);x.useEffect(()=>{localStorage.setItem("evalSidebarWidth",String(p))},[p]);const k=Se(f=>f.evalRuns[e]),C=Se(f=>f.evaluators),A=Se(f=>f.streamingResults[e]);x.useEffect(()=>{o(!0),wn(e).then(f=>{if(r(f),!t){const v=f.results.find(b=>b.status==="completed")??f.results[0];v&&a(`#/evals/runs/${e}/${encodeURIComponent(v.name)}`)}}).catch(console.error).finally(()=>o(!1))},[e]),x.useEffect(()=>{((k==null?void 0:k.status)==="completed"||(k==null?void 0:k.status)==="failed")&&wn(e).then(r).catch(console.error)},[k==null?void 0:k.status,e]),x.useEffect(()=>{if(t||!(s!=null&&s.results))return;const f=A?s.results.map(b=>A[b.name]??b):s.results,v=f.find(b=>b.status==="completed")??f[0];v&&a(`#/evals/runs/${e}/${encodeURIComponent(v.name)}`)},[s==null?void 0:s.results,A]);const O=x.useCallback(f=>{f.preventDefault(),d.current=!0;const v="touches"in f?f.touches[0].clientY:f.clientY,b=h,E=z=>{if(!d.current)return;const T=u.current;if(!T)return;const $="touches"in z?z.touches[0].clientY:z.clientY,V=T.clientHeight-100,J=Math.max(80,Math.min(V,b+($-v)));c(J)},N=()=>{d.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",E),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",E),document.addEventListener("mouseup",N),document.addEventListener("touchmove",E,{passive:!1}),document.addEventListener("touchend",N)},[h]),P=x.useCallback(f=>{f.preventDefault(),y(!0);const v="touches"in f?f.touches[0].clientX:f.clientX,b=p,E=z=>{const T=w.current;if(!T)return;const $="touches"in z?z.touches[0].clientX:z.clientX,V=T.clientWidth-300,J=Math.max(280,Math.min(V,b+(v-$)));g(J)},N=()=>{y(!1),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",E),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",E),document.addEventListener("mouseup",N),document.addEventListener("touchmove",E,{passive:!1}),document.addEventListener("touchend",N)},[p]);if(i)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!s)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval run not found"});const j=k??s,D=Yn[j.status]??Yn.pending,L=j.status==="running",B=Object.keys(j.evaluator_scores??{}).length>0?Object.keys(j.evaluator_scores):Object.keys(A?((_=Object.values(A).find(f=>Object.keys(f.scores).length>0))==null?void 0:_.scores)??{}:{}),I=A?s.results.map(f=>A[f.name]??f):s.results,M=I.find(f=>f.name===l)??null,R=((M==null?void 0:M.traces)??[]).map(f=>({...f,run_id:""}));return n.jsxs("div",{ref:w,className:"flex h-full",children:[n.jsxs("div",{ref:u,className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold truncate min-w-0",style:{color:"var(--text-primary)"},children:j.eval_set_name}),n.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold uppercase tracking-wide",style:{color:D.color,background:D.bg},children:D.label}),n.jsx("span",{className:"text-sm font-bold font-mono",style:{color:At(j.overall_score)},children:ms(j.overall_score)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:Hh(j.start_time,j.end_time)}),L&&n.jsxs("div",{className:"flex items-center gap-2 max-w-[160px]",children:[n.jsx("div",{className:"flex-1 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${j.progress_total>0?j.progress_completed/j.progress_total*100:0}%`,background:"var(--info)"}})}),n.jsxs("span",{className:"text-[11px] shrink-0",style:{color:"var(--text-muted)"},children:[j.progress_completed,"/",j.progress_total]})]}),B.length>0&&n.jsx("div",{className:"flex gap-3 ml-auto",children:B.map(f=>{const v=C.find(E=>E.id===f),b=j.evaluator_scores[f];return n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:Xn((v==null?void 0:v.name)??f)}),n.jsx("div",{className:"w-12 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${b*100}%`,background:At(b)}})}),n.jsx("span",{className:"text-[11px] font-mono",style:{color:At(b)},children:ms(b)})]},f)})})]}),n.jsxs("div",{className:"shrink-0 overflow-hidden flex flex-col",style:{height:h},children:[n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-5 shrink-0"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Score"}),B.map(f=>{const v=C.find(b=>b.id===f);return n.jsx("span",{className:"w-36 shrink-0 text-right truncate pl-2",title:(v==null?void 0:v.name)??f,children:Xn((v==null?void 0:v.name)??f)},f)}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Time"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[I.map(f=>{const v=f.status==="pending",b=f.status==="failed",E=f.name===l;return n.jsxs("button",{onClick:()=>{a(E?`#/evals/runs/${e}`:`#/evals/runs/${e}/${encodeURIComponent(f.name)}`)},className:"w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:E?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:E?"2px solid var(--accent)":"2px solid transparent",opacity:v?.5:1},onMouseEnter:N=>{E||(N.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:N=>{E||(N.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-5 shrink-0 flex justify-center",children:n.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:v?"var(--text-muted)":b?"var(--error)":f.overall_score>=.8?"var(--success)":f.overall_score>=.5?"var(--warning)":"var(--error)"}})}),n.jsx("span",{className:"flex-1 min-w-0 truncate",style:{color:"var(--text-primary)"},children:f.name}),n.jsx("span",{className:"w-14 shrink-0 text-right font-mono font-semibold",style:{color:At(v?null:f.overall_score)},children:v?"-":ms(f.overall_score)}),B.map(N=>n.jsx("span",{className:"w-36 shrink-0 text-right font-mono pl-2",style:{color:At(v?null:f.scores[N]??null)},children:v?"-":ms(f.scores[N]??null)},N)),n.jsx("span",{className:"w-14 shrink-0 text-right",style:{color:"var(--text-muted)"},children:f.duration_ms!==null?`${(f.duration_ms/1e3).toFixed(1)}s`:"-"})]},f.name)}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:L?"Waiting for results...":"No results"})]})]}),n.jsx("div",{onMouseDown:O,onTouchStart:O,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:M&&R.length>0?n.jsx(si,{traces:R}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:(M==null?void 0:M.status)==="pending"?"Pending...":"No traces available"})})]}),n.jsx("div",{onMouseDown:P,onTouchStart:P,className:`shrink-0 drag-handle-col${m?"":" transition-all"}`,style:{width:M?3:0,opacity:M?1:0}}),n.jsx(zh,{width:p,item:M,evaluators:C,isRunning:L,isDragging:m})]})}const Fh=[{id:"score",label:"Score"},{id:"io",label:"I/O"},{id:"logs",label:"Logs"}];function zh({width:e,item:t,evaluators:s,isRunning:r,isDragging:i}){const[o,a]=x.useState("score"),l=!!t;return n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${i?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:l?e:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:e},children:[Fh.map(h=>n.jsx("button",{onClick:()=>a(h.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:o===h.id?"var(--accent)":"var(--text-muted)",background:o===h.id?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},onMouseEnter:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-primary)")},onMouseLeave:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-muted)")},children:h.label},h.id)),r&&n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Running..."})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",style:{minWidth:e},children:t?t.status==="pending"?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Pending..."}):n.jsxs(n.Fragment,{children:[t.status==="failed"&&n.jsxs("div",{className:"mx-2 mt-2 px-3 py-2 rounded text-xs",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 4.5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"8",cy:"11",r:"0.75",fill:"currentColor"})]}),n.jsx("span",{children:"Evaluator error"})]}),t.error&&n.jsx("div",{className:"mt-1 pl-[22px] text-[11px] opacity-80 break-words",style:{color:"var(--text-secondary)"},children:t.error})]}),o==="score"?n.jsx(Uh,{item:t,evaluators:s}):o==="io"?n.jsx(Kh,{item:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Logs coming soon"})]}):null})]})}function Uh({item:e,evaluators:t}){const s=Object.keys(e.scores);return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Overall"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${e.overall_score*100}%`,background:At(e.overall_score)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(e.overall_score)},children:ms(e.overall_score)})]})]})}),e.status==="failed"&&s.length===0&&n.jsx("div",{className:"px-3 py-3 text-xs text-center",style:{color:"var(--text-muted)"},children:"All evaluators failed — no scores available"}),s.map(r=>{const i=t.find(l=>l.id===r),o=e.scores[r],a=e.justifications[r];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},title:(i==null?void 0:i.name)??r,children:(i==null?void 0:i.name)??r}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${o*100}%`,background:At(o)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(o)},children:ms(o)})]})]}),a&&n.jsx(qh,{text:a})]},r)})]})}function Kh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2),r=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),r&&n.jsx(Ot,{title:"Expected Output",copyText:r,children:n.jsx(gt,{json:r,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),n.jsx(Ot,{title:"Output",copyText:s,trailing:e.duration_ms!==null?n.jsxs("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:[(e.duration_ms/1e3).toFixed(2),"s"]}):void 0,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})})]})}function Vh(e){var i;const t=e.match(/expected="(.+?)"\s+actual="(.+?)"(.*)/s);if(!t)return null;const s={},r=((i=t[3])==null?void 0:i.trim())??"";if(r)for(const o of r.match(/(\w+)=([\S]+)/g)??[]){const a=o.indexOf("=");s[o.slice(0,a)]=o.slice(a+1)}return{expected:t[1],actual:t[2],meta:s}}function Gn(e){try{const t=e.replace(/'/g,'"').replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null"),s=JSON.parse(t);return JSON.stringify(s,null,2)}catch{return e}}function qh({text:e}){const t=Vh(e);if(!t)return n.jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:n.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--text-secondary)"},children:e})});const s=Gn(t.expected),r=Gn(t.actual),i=s===r;return n.jsxs("div",{className:"border-t",style:{borderColor:"var(--border)"},children:[n.jsxs("div",{className:"grid grid-cols-2 gap-0",children:[n.jsxs("div",{className:"px-3 py-2 border-r",style:{borderColor:"var(--border)"},children:[n.jsx("div",{className:"text-[10px] font-semibold mb-1",style:{color:"var(--text-muted)"},children:"Expected"}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:"var(--text-secondary)"},children:s})]}),n.jsxs("div",{className:"px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--text-muted)"},children:"Actual"}),n.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:i?"var(--success)":"var(--error)"}})]}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:i?"var(--success)":"var(--error)"},children:r})]})]}),Object.keys(t.meta).length>0&&n.jsx("div",{className:"px-3 py-1.5 border-t flex items-center gap-3",style:{borderColor:"var(--border)"},children:Object.entries(t.meta).map(([o,a])=>n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[n.jsx("span",{className:"font-medium",children:o.replace(/_/g," ")})," ",n.jsx("span",{className:"font-mono",children:a})]},o))})]})}const Jn={deterministic:"var(--success)",llm:"#a78bfa",tool:"var(--info)"};function Zn(){const e=Se(g=>g.localEvaluators),t=Se(g=>g.addEvalSet),{navigate:s}=et(),[r,i]=x.useState(""),[o,a]=x.useState(new Set),[l,h]=x.useState(null),[c,u]=x.useState(!1),d=g=>{a(m=>{const y=new Set(m);return y.has(g)?y.delete(g):y.add(g),y})},p=async()=>{if(r.trim()){h(null),u(!0);try{const g=await Ac({name:r.trim(),evaluator_refs:Array.from(o)});t(g),s(`#/evals/sets/${g.id}`)}catch(g){h(g.detail||g.message||"Failed to create eval set")}finally{u(!1)}}};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Eval Set"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluation set with a name and evaluators"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:r,onChange:g=>i(g.target.value),placeholder:"e.g. Basic QA Tests",className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},onKeyDown:g=>{g.key==="Enter"&&r.trim()&&p()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluators"}),e.length===0?n.jsxs("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:["No evaluators configured."," ",n.jsx("button",{onClick:()=>s("#/evaluators/new"),className:"underline cursor-pointer",style:{color:"var(--accent)",background:"none",border:"none",padding:0,font:"inherit"},children:"Create one first"})]}):n.jsx("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:e.map(g=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:m=>{m.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:o.has(g.id),onChange:()=>d(g.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:g.name}),n.jsx("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded",style:{background:`color-mix(in srgb, ${Jn[g.type]??"var(--text-muted)"} 15%, transparent)`,color:Jn[g.type]??"var(--text-muted)"},children:g.type})]},g.id))})]}),l&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:l}),n.jsx("button",{onClick:p,disabled:!r.trim()||c,className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:c?"Creating...":"Create Eval Set"})]})})}const Xh=[{type:"deterministic",label:"Deterministic",badgeColor:"var(--success)"},{type:"llm",label:"LLM Judge",badgeColor:"#a78bfa"},{type:"tool",label:"Tool-Based",badgeColor:"var(--info)"}];function Qn(){const e=Se(o=>o.localEvaluators),{evaluatorFilter:t,evaluatorCreateType:s,navigate:r}=et(),i=!t&&!s;return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>r("#/evaluators/new"),className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Evaluator"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Categories"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsxs("button",{onClick:()=>r("#/evaluators"),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:i?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)",borderLeft:i?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:o=>{i||(o.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:o=>{i||(o.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--text-muted)"}}),n.jsx("span",{className:"flex-1 truncate",children:"All"}),e.length>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.length})]}),Xh.map(o=>{const a=e.filter(h=>h.type===o.type).length,l=t===o.type;return n.jsxs("button",{onClick:()=>r(l?"#/evaluators":`#/evaluators/category/${o.type}`),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:l?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:l?"var(--text-primary)":"var(--text-secondary)",borderLeft:l?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:h=>{l||(h.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:h=>{l||(h.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:o.badgeColor}}),n.jsx("span",{className:"flex-1 truncate",children:o.label}),a>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a})]},o.type)})]})]})}const eo={deterministic:{label:"Deterministic",color:"var(--success)",bg:"rgba(34,197,94,0.1)"},llm:{label:"LLM Judge",color:"#a78bfa",bg:"rgba(167,139,250,0.1)"},tool:{label:"Tool-Based",color:"var(--info)",bg:"rgba(59,130,246,0.1)"}},ri={deterministic:"Deterministic",llm:"LLM Judge",tool:"Tool-Based"},Ps={deterministic:[{id:"uipath-exact-match",name:"Exact Match"},{id:"uipath-contains",name:"Contains"},{id:"uipath-json-similarity",name:"JSON Similarity"}],llm:[{id:"uipath-llm-judge-output-semantic-similarity",name:"LLM Judge Output"},{id:"uipath-llm-judge-output-strict-json-similarity",name:"LLM Judge Strict JSON"},{id:"uipath-llm-judge-trajectory-similarity",name:"LLM Judge Trajectory"},{id:"uipath-llm-judge-trajectory-simulation",name:"LLM Judge Trajectory Simulation"}],tool:[{id:"uipath-tool-call-order",name:"Tool Call Order"},{id:"uipath-tool-call-args",name:"Tool Call Args"},{id:"uipath-tool-call-count",name:"Tool Call Count"},{id:"uipath-tool-call-output",name:"Tool Call Output"}]};function Da(e){return e.includes("trajectory")?{targetOutputKey:!1,prompt:!0}:e.includes("llm-judge")?{targetOutputKey:!0,prompt:!0}:e.includes("tool-call-output")?{targetOutputKey:!0,prompt:!1}:e.includes("exact-match")||e.includes("contains")||e.includes("json-similarity")?{targetOutputKey:!0,prompt:!1}:{targetOutputKey:!1,prompt:!1}}const $r={"uipath-exact-match":{description:"Checks whether the agent output exactly matches the expected output.",prompt:""},"uipath-contains":{description:"Checks whether the agent output contains the expected substring.",prompt:""},"uipath-json-similarity":{description:"Compares JSON structures for semantic similarity, ignoring key ordering and whitespace.",prompt:""},"uipath-llm-judge-output-semantic-similarity":{description:"Uses an LLM to score semantic similarity between the agent's actual output and the expected output, accounting for synonyms, paraphrases, and equivalent expressions.",prompt:`As an expert evaluator, analyze the semantic similarity between the expected and actual outputs and determine a score from 0 to 100. Focus on comparing meaning and contextual equivalence of corresponding fields, accounting for alternative valid expressions, synonyms, and reasonable variations in language while maintaining high standards for accuracy and completeness. Provide your score with a brief justification. + `}),n.jsxs(oa,{nodes:o,edges:h,onNodesChange:l,onEdgesChange:u,nodeTypes:fh,edgeTypes:ph,onInit:f=>{k.current=f},onNodeClick:B,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(dc,{position:"top-right",children:n.jsxs("button",{onClick:O,title:T?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:T?"var(--error)":"var(--text-muted)",border:`1px solid ${T?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[n.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:T?"var(--error)":"var(--node-border)"}}),T?"Clear all":"Break all"]})}),n.jsx(ca,{nodeColor:f=>{var y;if(f.type==="groupNode")return"var(--bg-tertiary)";const b=(y=f.data)==null?void 0:y.status;return b==="completed"?"var(--success)":b==="running"?"var(--warning)":b==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ts="__setup__";function _h({entrypoint:e,mode:t,ws:s,onRunCreated:r,isMobile:i}){const[o,a]=v.useState("{}"),[l,h]=v.useState({}),[c,u]=v.useState(!1),[d,_]=v.useState(!0),[g,m]=v.useState(null),[x,w]=v.useState(""),[E,k]=v.useState(!0),[P,A]=v.useState(()=>{const y=localStorage.getItem("setupTextareaHeight");return y?parseInt(y,10):140}),D=v.useRef(null),[N,$]=v.useState(()=>{const y=localStorage.getItem("setupPanelWidth");return y?parseInt(y,10):380}),B=t==="run";v.useEffect(()=>{_(!0),m(null),Sc(e).then(y=>{h(y.mock_input),a(JSON.stringify(y.mock_input,null,2))}).catch(y=>{console.error("Failed to load mock input:",y);const j=y.detail||{};m(j.message||`Failed to load schema for "${e}"`),a("{}")}).finally(()=>_(!1))},[e]),v.useEffect(()=>{de.getState().clearBreakpoints(ts)},[]);const T=async()=>{let y;try{y=JSON.parse(o)}catch{alert("Invalid JSON input");return}u(!0);try{const j=de.getState().breakpoints[ts]??{},M=Object.keys(j),z=await bn(e,y,t,M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),r(z.id)}catch(j){console.error("Failed to create run:",j)}finally{u(!1)}},O=async()=>{const y=x.trim();if(y){u(!0);try{const j=de.getState().breakpoints[ts]??{},M=Object.keys(j),z=await bn(e,l,"chat",M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),de.getState().addLocalChatMessage(z.id,{message_id:`local-${Date.now()}`,role:"user",content:y}),s.sendChatMessage(z.id,y),r(z.id)}catch(j){console.error("Failed to create chat run:",j)}finally{u(!1)}}};v.useEffect(()=>{try{JSON.parse(o),k(!0)}catch{k(!1)}},[o]);const L=v.useCallback(y=>{y.preventDefault();const j="touches"in y?y.touches[0].clientY:y.clientY,M=P,z=H=>{const U="touches"in H?H.touches[0].clientY:H.clientY,q=Math.max(60,M+(j-U));A(q)},C=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(P))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",C),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",C)},[P]),R=v.useCallback(y=>{y.preventDefault();const j="touches"in y?y.touches[0].clientX:y.clientX,M=N,z=H=>{const U=D.current;if(!U)return;const q="touches"in H?H.touches[0].clientX:H.clientX,ee=U.clientWidth-300,ie=Math.max(280,Math.min(ee,M+(j-q)));$(ie)},C=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(N))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",C),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",C)},[N]),p=B?"Autonomous":"Conversational",f=B?"var(--success)":"var(--accent)",b=n.jsxs("div",{className:"shrink-0 flex flex-col",style:i?{background:"var(--bg-primary)"}:{width:N,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"px-4 text-xs font-semibold border-b flex items-center gap-2 h-10",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{style:{color:f},children:"●"}),p]}),n.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[n.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:B?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("polyline",{points:"12 6 12 12 16 14"})]}):n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),n.jsxs("div",{className:"text-center space-y-1.5",children:[n.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:B?"Ready to execute":"Ready to chat"}),n.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",B?n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"configure input below, then run"]}):n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"then send your first message"]})]})]})]}),B?n.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!i&&n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"px-4 py-3",children:[g?n.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:g}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:["Input",d&&n.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),n.jsx("textarea",{value:o,onChange:y=>a(y.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none mb-3",style:{height:i?120:P,background:"var(--bg-secondary)",border:`1px solid ${E?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),n.jsx("button",{onClick:T,disabled:c||d||!!g,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:f,color:f},onMouseEnter:y=>{c||(y.currentTarget.style.background=`color-mix(in srgb, ${f} 10%, transparent)`)},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:c?"Starting...":n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("input",{value:x,onChange:y=>w(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),O())},disabled:c||d,placeholder:c?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),n.jsx("button",{onClick:O,disabled:c||d||!x.trim(),className:"text-xs font-semibold px-3 py-1.5 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!c&&x.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:y=>{!c&&x.trim()&&(y.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:"Send"})]})]});return i?n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:b})]}):n.jsxs("div",{ref:D,className:"flex h-full",children:[n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{onMouseDown:R,onTouchStart:R,className:"shrink-0 drag-handle-col"}),b]})}const gh={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function mh(e){const t=[],s=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let r=0,i;for(;(i=s.exec(e))!==null;){if(i.index>r&&t.push({type:"punctuation",text:e.slice(r,i.index)}),i[1]!==void 0){t.push({type:"key",text:i[1]});const o=e.indexOf(":",i.index+i[1].length);o!==-1&&(o>i.index+i[1].length&&t.push({type:"punctuation",text:e.slice(i.index+i[1].length,o)}),t.push({type:"punctuation",text:":"}),s.lastIndex=o+1)}else i[2]!==void 0?t.push({type:"string",text:i[2]}):i[3]!==void 0?t.push({type:"number",text:i[3]}):i[4]!==void 0?t.push({type:"boolean",text:i[4]}):i[5]!==void 0?t.push({type:"null",text:i[5]}):i[6]!==void 0&&t.push({type:"punctuation",text:i[6]});r=s.lastIndex}return rmh(e),[e]);return n.jsx("pre",{className:t,style:s,children:r.map((i,o)=>n.jsx("span",{style:{color:gh[i.type]},children:i.text},o))})}const vh={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},xh={color:"var(--text-muted)",label:"Unknown"};function yh(e){if(typeof e!="string")return null;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}return null}const Pn=200;function bh(e){if(typeof e=="string")return e;if(e==null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Sh({value:e}){const[t,s]=v.useState(!1),r=bh(e),i=v.useMemo(()=>yh(e),[e]),o=i!==null,a=i??r,l=a.length>Pn||a.includes(` +`),h=v.useCallback(()=>s(c=>!c),[]);return l?n.jsxs("div",{children:[t?o?n.jsx(gt,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):n.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):n.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,Pn),"..."]}),n.jsx("button",{onClick:h,className:"text-[11px] cursor-pointer ml-1 px-1",style:{color:"var(--info)"},children:t?"[less]":"[more]"})]}):o?n.jsx(gt,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function wh({span:e}){const[t,s]=v.useState(!0),[r,i]=v.useState(!1),[o,a]=v.useState("table"),[l,h]=v.useState(!1),c=vh[e.status.toLowerCase()]??{...xh,label:e.status},u=v.useMemo(()=>JSON.stringify(e,null,2),[e]),d=v.useCallback(()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})},[u]),_=Object.entries(e.attributes),g=[{label:"Span",value:e.span_id},...e.trace_id?[{label:"Trace",value:e.trace_id}]:[],{label:"Run",value:e.run_id},...e.parent_span_id?[{label:"Parent",value:e.parent_span_id}]:[]];return n.jsxs("div",{className:"flex flex-col h-full text-xs leading-normal",children:[n.jsxs("div",{className:"px-2 border-b flex items-center gap-1 shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>a("table"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="table"?"var(--accent)":"var(--text-muted)",background:o==="table"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-muted)")},children:"Table"}),n.jsx("button",{onClick:()=>a("json"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="json"?"var(--accent)":"var(--text-muted)",background:o==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-muted)")},children:"JSON"}),n.jsxs("span",{className:"ml-auto shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${c.color} 15%, var(--bg-secondary))`,color:c.color},children:[n.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:c.color}}),c.label]})]}),n.jsx("div",{className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:o==="table"?n.jsxs(n.Fragment,{children:[_.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>s(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Attributes (",_.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:t?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),t&&_.map(([m,x],w)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:w%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m,children:m}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx(Sh,{value:x})})]},m))]}),n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>i(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Identifiers (",g.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:r?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),r&&g.map((m,x)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:x%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m.label,children:m.label}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:m.value})})]},m.label))]}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:d,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:l?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:m=>{l||(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{m.currentTarget.style.color=l?"var(--success)":"var(--text-muted)"},children:l?"Copied!":"Copy"}),n.jsx(gt,{json:u,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]})}function Ch(e){const t=[];function s(r,i){t.push({span:r.span,depth:i});for(const o of r.children)s(o,i+1)}for(const r of e)s(r,0);return t}function kh({tree:e,selectedSpan:t,onSelect:s}){const r=v.useMemo(()=>Ch(e),[e]),{globalStart:i,totalDuration:o}=v.useMemo(()=>{if(r.length===0)return{globalStart:0,totalDuration:1};let a=1/0,l=-1/0;for(const{span:h}of r){const c=new Date(h.timestamp).getTime();a=Math.min(a,c),l=Math.max(l,c+(h.duration_ms??0))}return{globalStart:a,totalDuration:Math.max(l-a,1)}},[r]);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(({span:a,depth:l})=>{var x;const h=new Date(a.timestamp).getTime()-i,c=a.duration_ms??0,u=h/o*100,d=Math.max(c/o*100,.3),_=La[a.status.toLowerCase()]??"var(--text-muted)",g=a.span_id===(t==null?void 0:t.span_id),m=(x=a.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("button",{"data-span-id":a.span_id,onClick:()=>s(a),className:"w-full text-left text-xs leading-normal py-1 flex items-center transition-colors",style:{background:g?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:g?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{g||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{g||(w.currentTarget.style.background="")},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-1 overflow-hidden",style:{width:"35%",minWidth:"80px",paddingLeft:`${l*12+4}px`},children:[n.jsx("span",{className:"shrink-0 flex items-center justify-center w-3.5 h-3.5",children:n.jsx(Ta,{kind:m,statusColor:_})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate",children:a.span_name})]}),n.jsx("div",{className:"flex-1 relative h-[14px] mx-1 rounded-sm",style:{background:"var(--bg-secondary)"},children:n.jsx("div",{className:"absolute rounded-sm",style:{left:`${u}%`,width:`${d}%`,top:"2px",bottom:"2px",background:_,opacity:.8,minWidth:"2px"}})}),n.jsx("span",{className:"shrink-0 text-[10px] tabular-nums pr-2",style:{width:"52px",textAlign:"right",color:"var(--text-muted)"},children:Ra(a.duration_ms)})]},a.span_id)})})}const La={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function Ta({kind:e,statusColor:t}){const s=t,r=14,i={width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"LLM":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:s,stroke:"none"})});case"TOOL":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),n.jsx("circle",{cx:"6",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("circle",{cx:"10",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("path",{d:"M8 2v3"}),n.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return n.jsxs("svg",{...i,children:[n.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),n.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),n.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return n.jsxs("svg",{...i,children:[n.jsx("circle",{cx:"7",cy:"7",r:"4"}),n.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:t}})}}function Eh(e){const t=new Map(e.map(a=>[a.span_id,a])),s=new Map;for(const a of e)if(a.parent_span_id){const l=s.get(a.parent_span_id)??[];l.push(a),s.set(a.parent_span_id,l)}const r=e.filter(a=>a.parent_span_id===null||!t.has(a.parent_span_id));function i(a){const l=(s.get(a.span_id)??[]).sort((h,c)=>h.timestamp.localeCompare(c.timestamp));return{span:a,children:l.map(i)}}return r.sort((a,l)=>a.timestamp.localeCompare(l.timestamp)).map(i).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function Ra(e){return e==null?"":e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`}function Ba(e){return e.map(t=>{const{span:s}=t;return t.children.length>0?{name:s.span_name,children:Ba(t.children)}:{name:s.span_name}})}function si({traces:e}){const[t,s]=v.useState(null),[r,i]=v.useState(new Set),[o,a]=v.useState(()=>{const B=localStorage.getItem("traceTreeSplitWidth");return B?parseFloat(B):50}),[l,h]=v.useState(!1),[c,u]=v.useState(!1),[d,_]=v.useState(()=>localStorage.getItem("traceViewMode")||"tree"),g=Eh(e),m=v.useMemo(()=>JSON.stringify(Ba(g),null,2),[e]),x=v.useCallback(()=>{navigator.clipboard.writeText(m).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[m]),w=de(B=>B.focusedSpan),E=de(B=>B.setFocusedSpan),[k,P]=v.useState(null),A=v.useRef(null),D=v.useCallback(B=>{i(T=>{const O=new Set(T);return O.has(B)?O.delete(B):O.add(B),O})},[]),N=v.useRef(null);v.useEffect(()=>{const B=g.length>0?g[0].span.span_id:null,T=N.current;if(N.current=B,B&&B!==T)s(g[0].span);else if(t===null)g.length>0&&s(g[0].span);else{const O=e.find(L=>L.span_id===t.span_id);O&&O!==t&&s(O)}},[e]),v.useEffect(()=>{if(!w)return;const T=e.filter(O=>O.span_name===w.name).sort((O,L)=>O.timestamp.localeCompare(L.timestamp))[w.index];if(T){s(T),P(T.span_id);const O=new Map(e.map(L=>[L.span_id,L.parent_span_id]));i(L=>{const R=new Set(L);let p=T.parent_span_id;for(;p;)R.delete(p),p=O.get(p)??null;return R})}E(null)},[w,e,E]),v.useEffect(()=>{if(!k)return;const B=k;P(null),requestAnimationFrame(()=>{const T=A.current,O=T==null?void 0:T.querySelector(`[data-span-id="${B}"]`);T&&O&&O.scrollIntoView({block:"center",behavior:"smooth"})})},[k]),v.useEffect(()=>{if(!l)return;const B=O=>{const L=document.querySelector(".trace-tree-container");if(!L)return;const R=L.getBoundingClientRect(),p=(O.clientX-R.left)/R.width*100,f=Math.max(20,Math.min(80,p));a(f),localStorage.setItem("traceTreeSplitWidth",String(f))},T=()=>{h(!1)};return window.addEventListener("mousemove",B),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",T)}},[l]);const $=B=>{B.preventDefault(),h(!0)};return n.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:l?"col-resize":void 0},children:[n.jsxs("div",{className:"flex flex-col",style:{width:`${o}%`},children:[e.length>0&&n.jsxs("div",{className:"flex items-center gap-1 px-2 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>{_("tree"),localStorage.setItem("traceViewMode","tree")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="tree"?"var(--accent)":"var(--text-muted)",background:d==="tree"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="tree"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="tree"&&(B.currentTarget.style.color="var(--text-muted)")},children:"Tree"}),n.jsx("button",{onClick:()=>{_("timeline"),localStorage.setItem("traceViewMode","timeline")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="timeline"?"var(--accent)":"var(--text-muted)",background:d==="timeline"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="timeline"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="timeline"&&(B.currentTarget.style.color="var(--text-muted)")},children:"Timeline"}),n.jsx("button",{onClick:()=>{_("json"),localStorage.setItem("traceViewMode","json")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="json"?"var(--accent)":"var(--text-muted)",background:d==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="json"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="json"&&(B.currentTarget.style.color="var(--text-muted)")},children:"JSON"})]}),n.jsx("div",{ref:A,className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:g.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):d==="tree"?g.map((B,T)=>n.jsx(Da,{node:B,depth:0,selectedId:(t==null?void 0:t.span_id)??null,onSelect:s,isLast:T===g.length-1,collapsedIds:r,toggleExpanded:D},B.span.span_id)):d==="timeline"?n.jsx(kh,{tree:g,selectedSpan:t,onSelect:s}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:x,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:c?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:B=>{c||(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{B.currentTarget.style.color=c?"var(--success)":"var(--text-muted)"},children:c?"Copied!":"Copy"}),n.jsx(gt,{json:m,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]}),n.jsx("div",{onMouseDown:$,className:"shrink-0 drag-handle-col",style:l?{background:"var(--accent)"}:void 0}),n.jsx("div",{className:"flex-1 overflow-hidden",children:t?n.jsx(wh,{span:t}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function Da({node:e,depth:t,selectedId:s,onSelect:r,isLast:i,collapsedIds:o,toggleExpanded:a}){var x;const{span:l}=e,h=!o.has(l.span_id),c=La[l.status.toLowerCase()]??"var(--text-muted)",u=Ra(l.duration_ms),d=l.span_id===s,_=e.children.length>0,g=t*20,m=(x=l.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("div",{className:"relative",children:[t>0&&n.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${g-10}px`,width:"1px",height:i?"16px":"100%",background:"var(--border)"}}),n.jsxs("button",{"data-span-id":l.span_id,onClick:()=>r(l),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${g+4}px`,background:d?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:d?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:w=>{d||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{d||(w.currentTarget.style.background="")},children:[t>0&&n.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${g-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),_?n.jsx("span",{onClick:w=>{w.stopPropagation(),a(l.span_id)},className:"shrink-0 w-5 h-5 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("span",{className:"shrink-0 w-4"}),n.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:n.jsx(Ta,{kind:m,statusColor:c})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:l.span_name}),u&&n.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:u})]}),h&&e.children.map((w,E)=>n.jsx(Da,{node:w,depth:t+1,selectedId:s,onSelect:r,isLast:E===e.children.length-1,collapsedIds:o,toggleExpanded:a},w.span.span_id))]})}const Nh={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},jh={color:"var(--text-muted)",bg:"transparent"};function An({logs:e}){const t=v.useRef(null),s=v.useRef(null),[r,i]=v.useState(!1);v.useEffect(()=>{var a;(a=s.current)==null||a.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const a=t.current;a&&i(a.scrollTop>100)};return e.length===0?n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):n.jsxs("div",{className:"h-full relative",children:[n.jsxs("div",{ref:t,onScroll:o,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[e.map((a,l)=>{const h=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),c=a.level.toUpperCase(),u=c.slice(0,4),d=Nh[c]??jh,_=l%2===0;return n.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:_?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:h}),n.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:d.color,background:d.bg},children:u}),n.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},l)}),n.jsx("div",{ref:s})]}),r&&n.jsx("button",{onClick:()=>{var a;return(a=t.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const Mh={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},On={color:"var(--text-muted)",label:""};function er({events:e,runStatus:t}){const s=v.useRef(null),r=v.useRef(!0),[i,o]=v.useState(null),a=()=>{const l=s.current;l&&(r.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return v.useEffect(()=>{r.current&&s.current&&(s.current.scrollTop=s.current.scrollHeight)}),e.length===0?n.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t==="running"?"Waiting for events...":"No events yet"})}):n.jsx("div",{ref:s,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:e.map((l,h)=>{const c=new Date(l.timestamp).toLocaleTimeString(void 0,{hour12:!1}),u=l.payload&&Object.keys(l.payload).length>0,d=i===h,_=l.phase?Mh[l.phase]??On:On;return n.jsxs("div",{children:[n.jsxs("div",{onClick:()=>{u&&o(d?null:h)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:h%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:u?"pointer":"default"},children:[n.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:c}),n.jsx("span",{className:"shrink-0",style:{color:_.color},children:"●"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:l.node_name}),_.label&&n.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:_.label}),u&&n.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:d?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),d&&u&&n.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:n.jsx(gt,{json:JSON.stringify(l.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},h)})})}function Ot({title:e,copyText:t,trailing:s,children:r}){const[i,o]=v.useState(!1),a=v.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[t]);return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:e}),s,t&&n.jsx("button",{onClick:a,className:`${s?"":"ml-auto "}text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-colors`,style:{color:i?"var(--success)":"var(--text-muted)",background:"var(--bg-tertiary)",border:"none"},onMouseEnter:l=>{i||(l.currentTarget.style.color="var(--text-primary)")},onMouseLeave:l=>{l.currentTarget.style.color=i?"var(--success)":"var(--text-muted)"},children:i?"Copied":"Copy"})]}),r]})}function In({runId:e,status:t,ws:s,breakpointNode:r}){const i=t==="suspended",o=a=>{const l=de.getState().breakpoints[e]??{};s.setBreakpoints(e,Object.keys(l)),a==="step"?s.debugStep(e):a==="continue"?s.debugContinue(e):s.debugStop(e)};return n.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),n.jsx(Hr,{label:"Step",onClick:()=>o("step"),disabled:!i,color:"var(--info)",active:i}),n.jsx(Hr,{label:"Continue",onClick:()=>o("continue"),disabled:!i,color:"var(--success)",active:i}),n.jsx(Hr,{label:"Stop",onClick:()=>o("stop"),disabled:!i,color:"var(--error)",active:i}),n.jsx("span",{className:"text-[11px] ml-auto truncate",style:{color:i?"var(--accent)":"var(--text-muted)"},children:i?r?`Paused at ${r}`:"Paused":t})]})}function Hr({label:e,onClick:t,disabled:s,color:r,active:i}){return n.jsx("button",{onClick:t,disabled:s,className:"px-3 py-1 h-7 text-[11px] font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:i?r:"var(--text-muted)",background:i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},onMouseEnter:o=>{s||(o.currentTarget.style.background=`color-mix(in srgb, ${r} 20%, transparent)`)},onMouseLeave:o=>{o.currentTarget.style.background=i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},children:e})}const Wn=v.lazy(()=>ba(()=>import("./ChatPanel-CrwXase9.js"),__vite__mapDeps([2,1,3,4]))),Lh=[],Th=[],Rh=[],Bh=[];function Dh({run:e,ws:t,isMobile:s}){const r=e.mode==="chat",[i,o]=v.useState(280),[a,l]=v.useState(()=>{const p=localStorage.getItem("chatPanelWidth");return p?parseInt(p,10):380}),[h,c]=v.useState("primary"),[u,d]=v.useState(r?"primary":"traces"),_=v.useRef(null),g=v.useRef(null),m=v.useRef(!1),x=de(p=>p.traces[e.id]||Lh),w=de(p=>p.logs[e.id]||Th),E=de(p=>p.chatMessages[e.id]||Rh),k=de(p=>p.stateEvents[e.id]||Bh),P=de(p=>p.breakpoints[e.id]);v.useEffect(()=>{t.setBreakpoints(e.id,P?Object.keys(P):[])},[e.id]);const A=v.useCallback(p=>{t.setBreakpoints(e.id,p)},[e.id,t]),D=v.useCallback(p=>{p.preventDefault(),m.current=!0;const f="touches"in p?p.touches[0].clientY:p.clientY,b=i,y=M=>{if(!m.current)return;const z=_.current;if(!z)return;const C="touches"in M?M.touches[0].clientY:M.clientY,H=z.clientHeight-100,U=Math.max(80,Math.min(H,b+(C-f)));o(U)},j=()=>{m.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[i]),N=v.useCallback(p=>{p.preventDefault();const f="touches"in p?p.touches[0].clientX:p.clientX,b=a,y=M=>{const z=g.current;if(!z)return;const C="touches"in M?M.touches[0].clientX:M.clientX,H=z.clientWidth-300,U=Math.max(280,Math.min(H,b+(f-C)));l(U)},j=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[a]),$=r?"Chat":"Events",B=r?"var(--accent)":"var(--success)",T=p=>p==="primary"?B:p==="events"?"var(--success)":"var(--accent)",O=de(p=>p.activeInterrupt[e.id]??null),L=e.status==="running"?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:r?"Thinking...":"Running..."}):r&&e.status==="suspended"&&O?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(s){const p=[{id:"traces",label:"Traces",count:x.length},{id:"primary",label:$},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{className:"flex flex-col h-full",children:[(e.mode==="debug"||e.status==="suspended"&&!O||P&&Object.keys(P).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:A})}),n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[p.map(f=>n.jsxs("button",{onClick:()=>d(f.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:u===f.id?T(f.id):"var(--text-muted)",background:u===f.id?`color-mix(in srgb, ${T(f.id)} 10%, transparent)`:"transparent"},children:[f.label,f.count!==void 0&&f.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:f.count})]},f.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[u==="traces"&&n.jsx(si,{traces:x}),u==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),u==="events"&&n.jsx(er,{events:k,runStatus:e.status}),u==="io"&&n.jsx(Hn,{run:e}),u==="logs"&&n.jsx(An,{logs:w})]})]})}const R=[{id:"primary",label:$},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{ref:g,className:"flex h-full",children:[n.jsxs("div",{ref:_,className:"flex flex-col flex-1 min-w-0",children:[(e.mode==="debug"||e.status==="suspended"&&!O||P&&Object.keys(P).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0 overflow-hidden",style:{height:i},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:A})}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(si,{traces:x})})]}),n.jsx("div",{onMouseDown:N,onTouchStart:N,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[R.map(p=>n.jsxs("button",{onClick:()=>c(p.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:h===p.id?T(p.id):"var(--text-muted)",background:h===p.id?`color-mix(in srgb, ${T(p.id)} 10%, transparent)`:"transparent"},onMouseEnter:f=>{h!==p.id&&(f.currentTarget.style.color="var(--text-primary)")},onMouseLeave:f=>{h!==p.id&&(f.currentTarget.style.color="var(--text-muted)")},children:[p.label,p.count!==void 0&&p.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:p.count})]},p.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[h==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),h==="events"&&n.jsx(er,{events:k,runStatus:e.status}),h==="io"&&n.jsx(Hn,{run:e}),h==="logs"&&n.jsx(An,{logs:w})]})]})]})}function Hn({run:e}){return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:JSON.stringify(e.input_data,null,2),children:n.jsx(gt,{json:JSON.stringify(e.input_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.output_data&&n.jsx(Ot,{title:"Output",copyText:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),children:n.jsx(gt,{json:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.error&&n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[n.jsxs("div",{className:"px-3 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[n.jsx("span",{children:"Error"}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.code}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.category})]}),n.jsxs("div",{className:"px-3 py-2 text-xs leading-normal",children:[n.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:e.error.title}),n.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:e.error.detail})]})]})]})}function $n(){const{reloadPending:e,setReloadPending:t,setEntrypoints:s}=de(),[r,i]=v.useState(!1);if(!e)return null;const o=async()=>{i(!0);try{await Cc();const a=await $i();s(a.map(l=>l.name)),t(!1)}catch(a){console.error("Reload failed:",a)}finally{i(!1)}};return n.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2 rounded-lg shadow-lg",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[n.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Files changed"}),n.jsx("button",{onClick:o,disabled:r,className:"px-2.5 py-0.5 text-xs font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:r?.6:1},children:r?"Reloading...":"Reload"}),n.jsx("button",{onClick:()=>t(!1),"aria-label":"Dismiss reload prompt",className:"text-xs cursor-pointer px-0.5",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})}let Ph=0;const Fn=Jt(e=>({toasts:[],addToast:(t,s)=>{const r=String(++Ph);e(o=>({toasts:[...o.toasts,{id:r,type:t,message:s}]})),setTimeout(()=>{e(o=>({toasts:o.toasts.filter(a=>a.id!==r)}))},t==="error"?8e3:5e3)},removeToast:t=>{e(s=>({toasts:s.toasts.filter(r=>r.id!==t)}))}})),zn={success:{color:"var(--success)",bg:"color-mix(in srgb, var(--success) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--success) 30%, var(--border))"},error:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--error) 30%, var(--border))"},info:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--info) 30%, var(--border))"}};function Un(){const e=Fn(s=>s.toasts),t=Fn(s=>s.removeToast);return e.length===0?null:n.jsx("div",{className:"fixed bottom-8 right-4 z-[100] flex flex-col gap-2 pointer-events-none",children:e.map(s=>{const r=zn[s.type]??zn.info;return n.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-lg shadow-lg text-xs font-medium max-w-xs animate-[slideIn_0.2s_ease-out]",style:{background:r.bg,border:`1px solid ${r.border}`,color:r.color},children:[n.jsx("span",{className:"flex-1",children:s.message}),n.jsx("button",{onClick:()=>t(s.id),className:"shrink-0 w-5 h-5 flex items-center justify-center rounded cursor-pointer transition-opacity opacity-60 hover:opacity-100",style:{color:r.color,background:"transparent",border:"none"},"aria-label":"Dismiss",children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[n.jsx("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),n.jsx("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]})})]},s.id)})})}function Ah(e){return e===null?"-":`${Math.round(e*100)}%`}function Oh(e){if(e===null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}const Kn={pending:{color:"var(--text-muted)",label:"Pending"},running:{color:"var(--info)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"}};function Vn(){const e=xe(l=>l.evalSets),t=xe(l=>l.evalRuns),{evalSetId:s,evalRunId:r,navigate:i}=et(),o=Object.values(e),a=Object.values(t).sort((l,h)=>new Date(h.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("button",{onClick:()=>i("#/evals/new"),className:"w-[calc(100%-24px)] mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] text-center font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-secondary)",l.currentTarget.style.borderColor=""},children:"+ New Eval Set"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Eval Sets"}),o.map(l=>{const h=s===l.id;return n.jsxs("button",{onClick:()=>i(`#/evals/sets/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:c=>{h||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{h||(c.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"truncate font-medium",children:l.name}),n.jsxs("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:[l.eval_count," items · ",l.evaluator_ids.length," evaluator",l.evaluator_ids.length!==1?"s":""]})]},l.id)}),o.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval sets yet"}),n.jsx("div",{className:"px-3 pt-4 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),a.map(l=>{const h=r===l.id,c=Kn[l.status]??Kn.pending;return n.jsx("button",{onClick:()=>i(`#/evals/runs/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:u=>{h||(u.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:u=>{h||(u.currentTarget.style.background="transparent")},children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c.color}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"truncate font-medium",children:l.eval_set_name}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:l.start_time?new Date(l.start_time).toLocaleString():c.label})]}),n.jsx("span",{className:"font-mono shrink-0",style:{color:Oh(l.overall_score)},children:Ah(l.overall_score)})]})},l.id)}),a.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval runs yet"})]})}function qn(e,t=60){const s=typeof e=="string"?e:JSON.stringify(e);return!s||s==="null"?"-":s.length>t?s.slice(0,t)+"...":s}function Ih({evalSetId:e}){const[t,s]=v.useState(null),[r,i]=v.useState(!0),[o,a]=v.useState(null),[l,h]=v.useState(!1),[c,u]=v.useState("io"),d=xe(C=>C.evaluators),_=xe(C=>C.localEvaluators),g=xe(C=>C.updateEvalSetEvaluators),m=xe(C=>C.incrementEvalSetCount),x=xe(C=>C.upsertEvalRun),{navigate:w}=et(),[E,k]=v.useState(!1),[P,A]=v.useState(new Set),[D,N]=v.useState(!1),$=v.useRef(null),[B,T]=v.useState(()=>{const C=localStorage.getItem("evalSetSidebarWidth");return C?parseInt(C,10):320}),[O,L]=v.useState(!1),R=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSetSidebarWidth",String(B))},[B]),v.useEffect(()=>{i(!0),a(null),Hc(e).then(C=>{s(C),C.items.length>0&&a(C.items[0].name)}).catch(console.error).finally(()=>i(!1))},[e]);const p=async()=>{h(!0);try{const C=await $c(e);x(C),w(`#/evals/runs/${C.id}`)}catch(C){console.error(C)}finally{h(!1)}},f=async C=>{if(t)try{await Wc(e,C),s(H=>{if(!H)return H;const U=H.items.filter(q=>q.name!==C);return{...H,items:U,eval_count:U.length}}),m(e,-1),o===C&&a(null)}catch(H){console.error(H)}},b=v.useCallback(()=>{t&&A(new Set(t.evaluator_ids)),k(!0)},[t]),y=C=>{A(H=>{const U=new Set(H);return U.has(C)?U.delete(C):U.add(C),U})},j=async()=>{if(t){N(!0);try{const C=await Uc(e,Array.from(P));s(C),g(e,C.evaluator_ids),k(!1)}catch(C){console.error(C)}finally{N(!1)}}};v.useEffect(()=>{if(!E)return;const C=H=>{$.current&&!$.current.contains(H.target)&&k(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[E]);const M=v.useCallback(C=>{C.preventDefault(),L(!0);const H="touches"in C?C.touches[0].clientX:C.clientX,U=B,q=ie=>{const F=R.current;if(!F)return;const se="touches"in ie?ie.touches[0].clientX:ie.clientX,pe=F.clientWidth-300,_e=Math.max(280,Math.min(pe,U+(H-se)));T(_e)},ee=()=>{L(!1),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ee),document.removeEventListener("touchmove",q),document.removeEventListener("touchend",ee),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",q),document.addEventListener("mouseup",ee),document.addEventListener("touchmove",q,{passive:!1}),document.addEventListener("touchend",ee)},[B]);if(r)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!t)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval set not found"});const z=t.items.find(C=>C.name===o)??null;return n.jsxs("div",{ref:R,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:t.name}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[t.eval_count," items"]}),n.jsxs("div",{className:"flex gap-1 items-center ml-auto relative",children:[n.jsx("button",{onClick:b,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-muted)",C.currentTarget.style.background="transparent"},title:"Edit evaluators","aria-label":"Edit evaluators",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),n.jsx("path",{d:"m15 5 4 4"})]})}),t.evaluator_ids.map(C=>{const H=d.find(U=>U.id===C);return n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:(H==null?void 0:H.name)??C},C)}),E&&n.jsxs("div",{ref:$,className:"absolute top-full right-0 mt-1 z-50 rounded-md border shadow-lg",style:{background:"var(--bg-primary)",borderColor:"var(--border)",minWidth:220},children:[n.jsx("div",{className:"px-3 py-2 border-b text-[10px] uppercase tracking-wide font-semibold",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:"Evaluators"}),n.jsx("div",{className:"max-h-48 overflow-y-auto",children:_.length===0?n.jsx("div",{className:"px-3 py-3 text-xs",style:{color:"var(--text-muted)"},children:"No evaluators available"}):_.map(C=>n.jsxs("label",{className:"flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:H=>{H.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:P.has(C.id),onChange:()=>y(C.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:C.name})]},C.id))}),n.jsx("div",{className:"px-3 py-2 border-t flex justify-end",style:{borderColor:"var(--border)"},children:n.jsx("button",{onClick:j,disabled:D,className:"px-3 py-1 text-[11px] font-semibold rounded cursor-pointer transition-colors disabled:opacity-50",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},onMouseEnter:C=>{C.currentTarget.style.background="var(--accent-hover)"},onMouseLeave:C=>{C.currentTarget.style.background="var(--accent)"},children:D?"Saving...":"Update"})})]})]}),n.jsxs("button",{onClick:p,disabled:l,className:"ml-2 px-3 py-1 h-7 text-xs font-semibold rounded border flex items-center gap-1.5 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--success)",borderColor:"var(--success)",background:"transparent"},onMouseEnter:C=>{l||(C.currentTarget.style.background="color-mix(in srgb, var(--success) 10%, transparent)")},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},title:"Run eval set","aria-label":"Run eval set",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),l?"Running...":"Run"]})]}),n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-56 shrink-0",children:"Name"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Input"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Behavior"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Output"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Simulation Instr."}),n.jsx("span",{className:"w-8 shrink-0"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.items.map(C=>{const H=C.name===o;return n.jsxs("button",{onClick:()=>a(H?null:C.name),className:"group w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:H?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:H?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:U=>{H||(U.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:U=>{H||(U.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-56 shrink-0 truncate",style:{color:"var(--text-primary)"},children:C.name}),n.jsx("span",{className:"flex-1 min-w-0 truncate font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(C.inputs)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.expected_behavior||"-"}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(C.expected_output,40)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.simulation_instructions||"-"}),n.jsx("span",{role:"button",tabIndex:0,className:"w-8 shrink-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:U=>{U.stopPropagation(),f(C.name)},onKeyDown:U=>{U.key==="Enter"&&(U.stopPropagation(),f(C.name))},style:{color:"var(--text-muted)"},onMouseEnter:U=>{U.currentTarget.style.color="var(--error)"},onMouseLeave:U=>{U.currentTarget.style.color="var(--text-muted)"},title:"Delete item",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},C.name)}),t.items.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:"No items in this eval set"})]})]}),n.jsx("div",{onMouseDown:M,onTouchStart:M,className:`shrink-0 drag-handle-col${O?"":" transition-all"}`,style:{width:z?3:0,opacity:z?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${O?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:z?B:0,background:"var(--bg-primary)"},children:[n.jsx("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:B},children:["io","evaluators"].map(C=>{const H=c===C,U=C==="io"?"I/O":"Evaluators";return n.jsx("button",{onClick:()=>u(C),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded inline-flex items-center cursor-pointer transition-colors",style:{color:H?"var(--accent)":"var(--text-muted)",background:H?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},children:U},C)})}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:B},children:z?c==="io"?n.jsx(Wh,{item:z}):n.jsx(Hh,{item:z,evaluators:d}):null})]})]})}function Wh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.expected_behavior&&n.jsx(Ot,{title:"Expected Behavior",copyText:e.expected_behavior,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.expected_behavior})}),s&&n.jsx(Ot,{title:"Expected Output",copyText:s,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.simulation_instructions&&n.jsx(Ot,{title:"Simulation Instructions",copyText:e.simulation_instructions,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.simulation_instructions})})]})}function Hh({item:e,evaluators:t}){return n.jsx("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:e.evaluator_ids.length>0?n.jsx(n.Fragment,{children:e.evaluator_ids.map(s=>{var o;const r=t.find(a=>a.id===s),i=(o=e.evaluation_criterias)==null?void 0:o[s];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:(r==null?void 0:r.name)??s}),n.jsx("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:i?"Custom criteria":"Default criteria"})]}),i&&n.jsx("pre",{className:"px-3 py-2 border-t text-[11px] font-mono overflow-x-auto max-h-32 whitespace-pre-wrap break-words",style:{borderColor:"var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(i,null,2)})]},s)})}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"No evaluators configured for this item"})})}function ms(e){return e==null?"-":`${Math.round(e*100)}%`}function At(e){if(e==null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}function $h(e,t){if(!e)return"-";const s=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.round((r-s)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function Xn(e){return e.replace(/\s*Evaluator$/i,"")}const Yn={pending:{color:"var(--text-muted)",bg:"var(--bg-tertiary)",label:"Pending"},running:{color:"var(--info)",bg:"rgba(59,130,246,0.1)",label:"Running"},completed:{color:"var(--success)",bg:"rgba(34,197,94,0.1)",label:"Completed"},failed:{color:"var(--error)",bg:"rgba(239,68,68,0.1)",label:"Failed"}};function Fh({evalRunId:e,itemName:t}){var p;const[s,r]=v.useState(null),[i,o]=v.useState(!0),{navigate:a}=et(),l=t??null,[h,c]=v.useState(220),u=v.useRef(null),d=v.useRef(!1),[_,g]=v.useState(()=>{const f=localStorage.getItem("evalSidebarWidth");return f?parseInt(f,10):320}),[m,x]=v.useState(!1),w=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSidebarWidth",String(_))},[_]);const E=xe(f=>f.evalRuns[e]),k=xe(f=>f.evaluators),P=xe(f=>f.streamingResults[e]);v.useEffect(()=>{o(!0),wn(e).then(f=>{if(r(f),!t){const b=f.results.find(y=>y.status==="completed")??f.results[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)}}).catch(console.error).finally(()=>o(!1))},[e]),v.useEffect(()=>{((E==null?void 0:E.status)==="completed"||(E==null?void 0:E.status)==="failed")&&wn(e).then(r).catch(console.error)},[E==null?void 0:E.status,e]),v.useEffect(()=>{if(t||!(s!=null&&s.results))return;const f=P?s.results.map(y=>P[y.name]??y):s.results,b=f.find(y=>y.status==="completed")??f[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)},[s==null?void 0:s.results,P]);const A=v.useCallback(f=>{f.preventDefault(),d.current=!0;const b="touches"in f?f.touches[0].clientY:f.clientY,y=h,j=z=>{if(!d.current)return;const C=u.current;if(!C)return;const H="touches"in z?z.touches[0].clientY:z.clientY,U=C.clientHeight-100,q=Math.max(80,Math.min(U,y+(H-b)));c(q)},M=()=>{d.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",j),document.addEventListener("mouseup",M),document.addEventListener("touchmove",j,{passive:!1}),document.addEventListener("touchend",M)},[h]),D=v.useCallback(f=>{f.preventDefault(),x(!0);const b="touches"in f?f.touches[0].clientX:f.clientX,y=_,j=z=>{const C=w.current;if(!C)return;const H="touches"in z?z.touches[0].clientX:z.clientX,U=C.clientWidth-300,q=Math.max(280,Math.min(U,y+(b-H)));g(q)},M=()=>{x(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",j),document.addEventListener("mouseup",M),document.addEventListener("touchmove",j,{passive:!1}),document.addEventListener("touchend",M)},[_]);if(i)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!s)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval run not found"});const N=E??s,$=Yn[N.status]??Yn.pending,B=N.status==="running",T=Object.keys(N.evaluator_scores??{}).length>0?Object.keys(N.evaluator_scores):Object.keys(P?((p=Object.values(P).find(f=>Object.keys(f.scores).length>0))==null?void 0:p.scores)??{}:{}),O=P?s.results.map(f=>P[f.name]??f):s.results,L=O.find(f=>f.name===l)??null,R=((L==null?void 0:L.traces)??[]).map(f=>({...f,run_id:""}));return n.jsxs("div",{ref:w,className:"flex h-full",children:[n.jsxs("div",{ref:u,className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold truncate min-w-0",style:{color:"var(--text-primary)"},children:N.eval_set_name}),n.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold uppercase tracking-wide",style:{color:$.color,background:$.bg},children:$.label}),n.jsx("span",{className:"text-sm font-bold font-mono",style:{color:At(N.overall_score)},children:ms(N.overall_score)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:$h(N.start_time,N.end_time)}),B&&n.jsxs("div",{className:"flex items-center gap-2 max-w-[160px]",children:[n.jsx("div",{className:"flex-1 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${N.progress_total>0?N.progress_completed/N.progress_total*100:0}%`,background:"var(--info)"}})}),n.jsxs("span",{className:"text-[11px] shrink-0",style:{color:"var(--text-muted)"},children:[N.progress_completed,"/",N.progress_total]})]}),T.length>0&&n.jsx("div",{className:"flex gap-3 ml-auto",children:T.map(f=>{const b=k.find(j=>j.id===f),y=N.evaluator_scores[f];return n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:Xn((b==null?void 0:b.name)??f)}),n.jsx("div",{className:"w-12 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${y*100}%`,background:At(y)}})}),n.jsx("span",{className:"text-[11px] font-mono",style:{color:At(y)},children:ms(y)})]},f)})})]}),n.jsxs("div",{className:"shrink-0 overflow-hidden flex flex-col",style:{height:h},children:[n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-5 shrink-0"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Score"}),T.map(f=>{const b=k.find(y=>y.id===f);return n.jsx("span",{className:"w-36 shrink-0 text-right truncate pl-2",title:(b==null?void 0:b.name)??f,children:Xn((b==null?void 0:b.name)??f)},f)}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Time"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[O.map(f=>{const b=f.status==="pending",y=f.status==="failed",j=f.name===l;return n.jsxs("button",{onClick:()=>{a(j?`#/evals/runs/${e}`:`#/evals/runs/${e}/${encodeURIComponent(f.name)}`)},className:"w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:j?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:j?"2px solid var(--accent)":"2px solid transparent",opacity:b?.5:1},onMouseEnter:M=>{j||(M.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:M=>{j||(M.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-5 shrink-0 flex justify-center",children:n.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:b?"var(--text-muted)":y?"var(--error)":f.overall_score>=.8?"var(--success)":f.overall_score>=.5?"var(--warning)":"var(--error)"}})}),n.jsx("span",{className:"flex-1 min-w-0 truncate",style:{color:"var(--text-primary)"},children:f.name}),n.jsx("span",{className:"w-14 shrink-0 text-right font-mono font-semibold",style:{color:At(b?null:f.overall_score)},children:b?"-":ms(f.overall_score)}),T.map(M=>n.jsx("span",{className:"w-36 shrink-0 text-right font-mono pl-2",style:{color:At(b?null:f.scores[M]??null)},children:b?"-":ms(f.scores[M]??null)},M)),n.jsx("span",{className:"w-14 shrink-0 text-right",style:{color:"var(--text-muted)"},children:f.duration_ms!==null?`${(f.duration_ms/1e3).toFixed(1)}s`:"-"})]},f.name)}),O.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:B?"Waiting for results...":"No results"})]})]}),n.jsx("div",{onMouseDown:A,onTouchStart:A,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:L&&R.length>0?n.jsx(si,{traces:R}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:(L==null?void 0:L.status)==="pending"?"Pending...":"No traces available"})})]}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:`shrink-0 drag-handle-col${m?"":" transition-all"}`,style:{width:L?3:0,opacity:L?1:0}}),n.jsx(Uh,{width:_,item:L,evaluators:k,isRunning:B,isDragging:m})]})}const zh=[{id:"score",label:"Score"},{id:"io",label:"I/O"},{id:"logs",label:"Logs"}];function Uh({width:e,item:t,evaluators:s,isRunning:r,isDragging:i}){const[o,a]=v.useState("score"),l=!!t;return n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${i?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:l?e:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:e},children:[zh.map(h=>n.jsx("button",{onClick:()=>a(h.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:o===h.id?"var(--accent)":"var(--text-muted)",background:o===h.id?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},onMouseEnter:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-primary)")},onMouseLeave:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-muted)")},children:h.label},h.id)),r&&n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Running..."})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",style:{minWidth:e},children:t?t.status==="pending"?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Pending..."}):n.jsxs(n.Fragment,{children:[t.status==="failed"&&n.jsxs("div",{className:"mx-2 mt-2 px-3 py-2 rounded text-xs",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 4.5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"8",cy:"11",r:"0.75",fill:"currentColor"})]}),n.jsx("span",{children:"Evaluator error"})]}),t.error&&n.jsx("div",{className:"mt-1 pl-[22px] text-[11px] opacity-80 break-words",style:{color:"var(--text-secondary)"},children:t.error})]}),o==="score"?n.jsx(Kh,{item:t,evaluators:s}):o==="io"?n.jsx(Vh,{item:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Logs coming soon"})]}):null})]})}function Kh({item:e,evaluators:t}){const s=Object.keys(e.scores);return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Overall"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${e.overall_score*100}%`,background:At(e.overall_score)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(e.overall_score)},children:ms(e.overall_score)})]})]})}),e.status==="failed"&&s.length===0&&n.jsx("div",{className:"px-3 py-3 text-xs text-center",style:{color:"var(--text-muted)"},children:"All evaluators failed — no scores available"}),s.map(r=>{const i=t.find(l=>l.id===r),o=e.scores[r],a=e.justifications[r];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},title:(i==null?void 0:i.name)??r,children:(i==null?void 0:i.name)??r}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${o*100}%`,background:At(o)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(o)},children:ms(o)})]})]}),a&&n.jsx(Xh,{text:a})]},r)})]})}function Vh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2),r=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),r&&n.jsx(Ot,{title:"Expected Output",copyText:r,children:n.jsx(gt,{json:r,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),n.jsx(Ot,{title:"Output",copyText:s,trailing:e.duration_ms!==null?n.jsxs("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:[(e.duration_ms/1e3).toFixed(2),"s"]}):void 0,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})})]})}function qh(e){var i;const t=e.match(/expected="(.+?)"\s+actual="(.+?)"(.*)/s);if(!t)return null;const s={},r=((i=t[3])==null?void 0:i.trim())??"";if(r)for(const o of r.match(/(\w+)=([\S]+)/g)??[]){const a=o.indexOf("=");s[o.slice(0,a)]=o.slice(a+1)}return{expected:t[1],actual:t[2],meta:s}}function Gn(e){try{const t=e.replace(/'/g,'"').replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null"),s=JSON.parse(t);return JSON.stringify(s,null,2)}catch{return e}}function Xh({text:e}){const t=qh(e);if(!t)return n.jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:n.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--text-secondary)"},children:e})});const s=Gn(t.expected),r=Gn(t.actual),i=s===r;return n.jsxs("div",{className:"border-t",style:{borderColor:"var(--border)"},children:[n.jsxs("div",{className:"grid grid-cols-2 gap-0",children:[n.jsxs("div",{className:"px-3 py-2 border-r",style:{borderColor:"var(--border)"},children:[n.jsx("div",{className:"text-[10px] font-semibold mb-1",style:{color:"var(--text-muted)"},children:"Expected"}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:"var(--text-secondary)"},children:s})]}),n.jsxs("div",{className:"px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--text-muted)"},children:"Actual"}),n.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:i?"var(--success)":"var(--error)"}})]}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:i?"var(--success)":"var(--error)"},children:r})]})]}),Object.keys(t.meta).length>0&&n.jsx("div",{className:"px-3 py-1.5 border-t flex items-center gap-3",style:{borderColor:"var(--border)"},children:Object.entries(t.meta).map(([o,a])=>n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[n.jsx("span",{className:"font-medium",children:o.replace(/_/g," ")})," ",n.jsx("span",{className:"font-mono",children:a})]},o))})]})}const Jn={deterministic:"var(--success)",llm:"#a78bfa",tool:"var(--info)"};function Zn(){const e=xe(g=>g.localEvaluators),t=xe(g=>g.addEvalSet),{navigate:s}=et(),[r,i]=v.useState(""),[o,a]=v.useState(new Set),[l,h]=v.useState(null),[c,u]=v.useState(!1),d=g=>{a(m=>{const x=new Set(m);return x.has(g)?x.delete(g):x.add(g),x})},_=async()=>{if(r.trim()){h(null),u(!0);try{const g=await Oc({name:r.trim(),evaluator_refs:Array.from(o)});t(g),s(`#/evals/sets/${g.id}`)}catch(g){h(g.detail||g.message||"Failed to create eval set")}finally{u(!1)}}};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Eval Set"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluation set with a name and evaluators"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:r,onChange:g=>i(g.target.value),placeholder:"e.g. Basic QA Tests",className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},onKeyDown:g=>{g.key==="Enter"&&r.trim()&&_()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluators"}),e.length===0?n.jsxs("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:["No evaluators configured."," ",n.jsx("button",{onClick:()=>s("#/evaluators/new"),className:"underline cursor-pointer",style:{color:"var(--accent)",background:"none",border:"none",padding:0,font:"inherit"},children:"Create one first"})]}):n.jsx("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:e.map(g=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:m=>{m.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:o.has(g.id),onChange:()=>d(g.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:g.name}),n.jsx("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded",style:{background:`color-mix(in srgb, ${Jn[g.type]??"var(--text-muted)"} 15%, transparent)`,color:Jn[g.type]??"var(--text-muted)"},children:g.type})]},g.id))})]}),l&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:l}),n.jsx("button",{onClick:_,disabled:!r.trim()||c,className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:c?"Creating...":"Create Eval Set"})]})})}const Yh=[{type:"deterministic",label:"Deterministic",badgeColor:"var(--success)"},{type:"llm",label:"LLM Judge",badgeColor:"#a78bfa"},{type:"tool",label:"Tool-Based",badgeColor:"var(--info)"}];function Qn(){const e=xe(o=>o.localEvaluators),{evaluatorFilter:t,evaluatorCreateType:s,navigate:r}=et(),i=!t&&!s;return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>r("#/evaluators/new"),className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Evaluator"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Categories"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsxs("button",{onClick:()=>r("#/evaluators"),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:i?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)",borderLeft:i?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:o=>{i||(o.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:o=>{i||(o.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--text-muted)"}}),n.jsx("span",{className:"flex-1 truncate",children:"All"}),e.length>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.length})]}),Yh.map(o=>{const a=e.filter(h=>h.type===o.type).length,l=t===o.type;return n.jsxs("button",{onClick:()=>r(l?"#/evaluators":`#/evaluators/category/${o.type}`),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:l?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:l?"var(--text-primary)":"var(--text-secondary)",borderLeft:l?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:h=>{l||(h.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:h=>{l||(h.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:o.badgeColor}}),n.jsx("span",{className:"flex-1 truncate",children:o.label}),a>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a})]},o.type)})]})]})}const eo={deterministic:{label:"Deterministic",color:"var(--success)",bg:"rgba(34,197,94,0.1)"},llm:{label:"LLM Judge",color:"#a78bfa",bg:"rgba(167,139,250,0.1)"},tool:{label:"Tool-Based",color:"var(--info)",bg:"rgba(59,130,246,0.1)"}},ri={deterministic:"Deterministic",llm:"LLM Judge",tool:"Tool-Based"},Ps={deterministic:[{id:"uipath-exact-match",name:"Exact Match"},{id:"uipath-contains",name:"Contains"},{id:"uipath-json-similarity",name:"JSON Similarity"}],llm:[{id:"uipath-llm-judge-output-semantic-similarity",name:"LLM Judge Output"},{id:"uipath-llm-judge-output-strict-json-similarity",name:"LLM Judge Strict JSON"},{id:"uipath-llm-judge-trajectory-similarity",name:"LLM Judge Trajectory"},{id:"uipath-llm-judge-trajectory-simulation",name:"LLM Judge Trajectory Simulation"}],tool:[{id:"uipath-tool-call-order",name:"Tool Call Order"},{id:"uipath-tool-call-args",name:"Tool Call Args"},{id:"uipath-tool-call-count",name:"Tool Call Count"},{id:"uipath-tool-call-output",name:"Tool Call Output"}]};function Pa(e){return e.includes("trajectory")?{targetOutputKey:!1,prompt:!0}:e.includes("llm-judge")?{targetOutputKey:!0,prompt:!0}:e.includes("tool-call-output")?{targetOutputKey:!0,prompt:!1}:e.includes("exact-match")||e.includes("contains")||e.includes("json-similarity")?{targetOutputKey:!0,prompt:!1}:{targetOutputKey:!1,prompt:!1}}const $r={"uipath-exact-match":{description:"Checks whether the agent output exactly matches the expected output.",prompt:""},"uipath-contains":{description:"Checks whether the agent output contains the expected substring.",prompt:""},"uipath-json-similarity":{description:"Compares JSON structures for semantic similarity, ignoring key ordering and whitespace.",prompt:""},"uipath-llm-judge-output-semantic-similarity":{description:"Uses an LLM to score semantic similarity between the agent's actual output and the expected output, accounting for synonyms, paraphrases, and equivalent expressions.",prompt:`As an expert evaluator, analyze the semantic similarity between the expected and actual outputs and determine a score from 0 to 100. Focus on comparing meaning and contextual equivalence of corresponding fields, accounting for alternative valid expressions, synonyms, and reasonable variations in language while maintaining high standards for accuracy and completeness. Provide your score with a brief justification. ---- ExpectedOutput: {{ExpectedOutput}} @@ -68,7 +68,7 @@ ExpectedAgentBehavior: {{ExpectedAgentBehavior}} ---- AgentRunHistory: -{{AgentRunHistory}}`},"uipath-tool-call-order":{description:"Validates that the agent called tools in the expected sequence.",prompt:""},"uipath-tool-call-args":{description:"Checks whether the agent called tools with the expected arguments.",prompt:""},"uipath-tool-call-count":{description:"Validates that the agent made the expected number of tool calls.",prompt:""},"uipath-tool-call-output":{description:"Validates the output returned by the agent's tool calls.",prompt:""}};function Yh(e){for(const[t,s]of Object.entries(Ps))if(s.some(r=>r.id===e))return t;return"deterministic"}function Gh({evaluatorId:e,evaluatorFilter:t}){const s=Se(C=>C.localEvaluators),r=Se(C=>C.setLocalEvaluators),i=Se(C=>C.upsertLocalEvaluator),o=Se(C=>C.evaluators),{navigate:a}=et(),l=e?s.find(C=>C.id===e)??null:null,h=!!l,c=t?s.filter(C=>C.type===t):s,[u,d]=x.useState(()=>{const C=localStorage.getItem("evaluatorSidebarWidth");return C?parseInt(C,10):320}),[p,g]=x.useState(!1),m=x.useRef(null);x.useEffect(()=>{localStorage.setItem("evaluatorSidebarWidth",String(u))},[u]),x.useEffect(()=>{Vi().then(r).catch(console.error)},[r]);const y=x.useCallback(C=>{C.preventDefault(),g(!0);const A="touches"in C?C.touches[0].clientX:C.clientX,O=u,P=D=>{const L=m.current;if(!L)return;const B="touches"in D?D.touches[0].clientX:D.clientX,I=L.clientWidth-300,M=Math.max(280,Math.min(I,O+(A-B)));d(M)},j=()=>{g(!1),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",P),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",P),document.addEventListener("mouseup",j),document.addEventListener("touchmove",P,{passive:!1}),document.addEventListener("touchend",j)},[u]),w=C=>{i(C)},k=()=>{a("#/evaluators")};return n.jsxs("div",{ref:m,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:"Evaluators"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c.length,t?` / ${s.length}`:""," configured"]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:c.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:s.length===0?"No evaluators configured yet.":"No evaluators in this category."}):n.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:c.map(C=>n.jsx(Jh,{evaluator:C,evaluators:o,selected:C.id===e,onClick:()=>a(C.id===e?"#/evaluators":`#/evaluators/${encodeURIComponent(C.id)}`)},C.id))})})]}),n.jsx("div",{onMouseDown:y,onTouchStart:y,className:`shrink-0 drag-handle-col${p?"":" transition-all"}`,style:{width:h?3:0,opacity:h?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${p?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:h?u:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:u},children:[n.jsx("span",{className:"px-2 py-0.5 h-7 text-xs font-semibold rounded inline-flex items-center",style:{color:"var(--accent)",background:"color-mix(in srgb, var(--accent) 10%, transparent)"},children:"Edit Evaluator"}),n.jsx("button",{onClick:k,"aria-label":"Close editor",className:"ml-auto w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:u},children:l&&n.jsx(Zh,{evaluator:l,onUpdated:w})})]})]})}function Jh({evaluator:e,evaluators:t,selected:s,onClick:r}){const i=eo[e.type]??eo.deterministic,o=t.find(l=>l.id===e.evaluator_type_id),a=e.evaluator_type_id.startsWith("file://");return n.jsxs("div",{className:"rounded-md p-4 flex flex-col cursor-pointer transition-colors",style:{border:s?"1px solid var(--accent)":"1px solid var(--border)",background:s?"color-mix(in srgb, var(--accent) 5%, var(--card-bg))":"var(--card-bg)"},onClick:r,onMouseEnter:l=>{s||(l.currentTarget.style.borderColor="var(--text-muted)")},onMouseLeave:l=>{s||(l.currentTarget.style.borderColor="var(--border)")},children:[n.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.name}),e.description&&n.jsx("div",{className:"text-xs leading-relaxed mt-2",style:{color:"var(--text-secondary)"},children:e.description}),n.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-auto pt-3",children:[n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:i.color,background:i.bg},children:["Category: ",i.label]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Type: ",a?"Custom":(o==null?void 0:o.name)??e.evaluator_type_id]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium font-mono",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Target: ",e.target_output_key||"*"]})]})]})}function Zh({evaluator:e,onUpdated:t}){var P,j;const s=Yh(e.evaluator_type_id),r=Ps[s]??[],[i,o]=x.useState(e.description),[a,l]=x.useState(e.evaluator_type_id),[h,c]=x.useState(((P=e.config)==null?void 0:P.targetOutputKey)??"*"),[u,d]=x.useState(((j=e.config)==null?void 0:j.prompt)??""),[p,g]=x.useState(!1),[m,y]=x.useState(null),[w,k]=x.useState(!1);x.useEffect(()=>{var D,L;o(e.description),l(e.evaluator_type_id),c(((D=e.config)==null?void 0:D.targetOutputKey)??"*"),d(((L=e.config)==null?void 0:L.prompt)??""),y(null),k(!1)},[e.id]);const C=Da(a),A=async()=>{g(!0),y(null),k(!1);try{const D={};C.targetOutputKey&&(D.targetOutputKey=h),C.prompt&&u.trim()&&(D.prompt=u);const L=await Uc(e.id,{description:i.trim(),evaluator_type_id:a,config:D});t(L),k(!0),setTimeout(()=>k(!1),2e3)}catch(D){const L=D==null?void 0:D.detail;y(L??"Failed to update evaluator")}finally{g(!1)}},O={background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)"};return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:e.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Category"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[s]??s})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:a,onChange:D=>l(D.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:O,children:r.map(D=>n.jsx("option",{value:D.id,children:D.name},D.id))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:i,onChange:D=>o(D.target.value),placeholder:"What does this evaluator check?",rows:4,className:"w-full px-3 py-2 rounded-lg text-xs leading-relaxed outline-none resize-y",style:O})]}),C.targetOutputKey&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:h,onChange:D=>c(D.target.value),placeholder:"*",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:O}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),C.prompt&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:u,onChange:D=>d(D.target.value),placeholder:"Evaluation prompt for the LLM judge...",rows:8,className:"w-full px-3 py-2 rounded-lg text-xs font-mono leading-relaxed outline-none resize-y",style:O})]})]}),n.jsxs("div",{className:"shrink-0 p-4 space-y-2",children:[m&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:m}),w&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(34,197,94,0.1)",color:"var(--success)"},children:"Saved successfully"}),n.jsx("button",{onClick:A,disabled:p,className:"w-full py-2.5 text-xs font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:"transparent",borderColor:"var(--accent)",color:"var(--accent)"},onMouseEnter:D=>{D.currentTarget.style.background="color-mix(in srgb, var(--accent) 15%, transparent)"},onMouseLeave:D=>{D.currentTarget.style.background="transparent"},children:p?"Saving...":"Save Changes"})]})]})}const Qh=["deterministic","llm","tool"];function ed({category:e}){var f;const t=Se(v=>v.addLocalEvaluator),{navigate:s}=et(),r=e!=="any",[i,o]=x.useState(r?e:"deterministic"),a=Ps[i]??[],[l,h]=x.useState(""),[c,u]=x.useState(""),[d,p]=x.useState(((f=a[0])==null?void 0:f.id)??""),[g,m]=x.useState("*"),[y,w]=x.useState(""),[k,C]=x.useState(!1),[A,O]=x.useState(null),[P,j]=x.useState(!1),[D,L]=x.useState(!1);x.useEffect(()=>{var z;const v=r?e:"deterministic";o(v);const E=((z=(Ps[v]??[])[0])==null?void 0:z.id)??"",N=$r[E];h(""),u((N==null?void 0:N.description)??""),p(E),m("*"),w((N==null?void 0:N.prompt)??""),O(null),j(!1),L(!1)},[e,r]);const B=v=>{var z;o(v);const E=((z=(Ps[v]??[])[0])==null?void 0:z.id)??"",N=$r[E];p(E),P||u((N==null?void 0:N.description)??""),D||w((N==null?void 0:N.prompt)??"")},I=v=>{p(v);const b=$r[v];b&&(P||u(b.description),D||w(b.prompt))},M=Da(d),R=async()=>{if(!l.trim()){O("Name is required");return}C(!0),O(null);try{const v={};M.targetOutputKey&&(v.targetOutputKey=g),M.prompt&&y.trim()&&(v.prompt=y);const b=await Fc({name:l.trim(),description:c.trim(),evaluator_type_id:d,config:v});t(b),s("#/evaluators")}catch(v){const b=v==null?void 0:v.detail;O(b??"Failed to create evaluator")}finally{C(!1)}},_={background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"};return n.jsx("div",{className:"h-full overflow-y-auto",children:n.jsx("div",{className:"flex items-center justify-center min-h-full py-8",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Evaluator"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluator to score agent outputs"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:l,onChange:v=>h(v.target.value),placeholder:"e.g. MyEvaluator",className:"w-full rounded-md px-3 py-2 text-xs",style:_,onKeyDown:v=>{v.key==="Enter"&&l.trim()&&R()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Category"}),r?n.jsx("div",{className:"px-3 py-2 rounded-md text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[i]??i}):n.jsx("select",{value:i,onChange:v=>B(v.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:_,children:Qh.map(v=>n.jsx("option",{value:v,children:ri[v]},v))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:d,onChange:v=>I(v.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:_,children:a.map(v=>n.jsx("option",{value:v.id,children:v.name},v.id))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:c,onChange:v=>{u(v.target.value),j(!0)},placeholder:"What does this evaluator check?",rows:3,className:"w-full rounded-md px-3 py-2 text-xs leading-relaxed resize-y",style:_})]}),M.targetOutputKey&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:g,onChange:v=>m(v.target.value),placeholder:"*",className:"w-full rounded-md px-3 py-2 text-xs",style:_}),n.jsx("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),M.prompt&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:y,onChange:v=>{w(v.target.value),L(!0)},placeholder:"Evaluation prompt for the LLM judge...",rows:6,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-y",style:_})]}),A&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:A}),n.jsx("button",{onClick:R,disabled:k||!l.trim(),className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:k?"Creating...":"Create Evaluator"})]})})})}const Cr="/api";async function kr(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Pa(){return kr(`${Cr}/statedb/status`)}async function td(){return kr(`${Cr}/statedb/tables`)}async function sd(e,t=100,s=0){return kr(`${Cr}/statedb/tables/${encodeURIComponent(e)}?limit=${t}&offset=${s}`)}async function rd(e,t){return kr(`${Cr}/statedb/query`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e,limit:t})})}function Aa({path:e,name:t,type:s,depth:r}){const i=xe(C=>C.children[e]),o=xe(C=>!!C.expanded[e]),a=xe(C=>!!C.loadingDirs[e]),l=xe(C=>!!C.dirty[e]),h=xe(C=>!!C.agentChangedFiles[e]),c=xe(C=>C.selectedFile),{setChildren:u,toggleExpanded:d,setLoadingDir:p,openTab:g}=xe(),{navigate:m}=et(),y=s==="directory",w=!y&&c===e,k=x.useCallback(()=>{y?(!i&&!a&&(p(e,!0),Ki(e).then(C=>u(e,C)).catch(console.error).finally(()=>p(e,!1))),d(e)):(g(e),m(`#/explorer/file/${encodeURIComponent(e)}`))},[y,i,a,e,u,d,p,g,m]);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:k,className:`w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors group${h?" agent-changed-file":""}`,style:{paddingLeft:`${12+r*16}px`,paddingRight:"8px",background:w?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:w?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:C=>{w||(C.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:C=>{w||(C.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"w-3 shrink-0 flex items-center justify-center",style:{color:"var(--text-muted)"},children:y&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5z"})})}),n.jsx("span",{className:"shrink-0",style:{color:y?"var(--accent)":"var(--text-muted)"},children:y?n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),n.jsx("span",{className:"truncate flex-1",children:t}),l&&n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"}}),a&&n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:"..."})]}),y&&o&&i&&i.map(C=>n.jsx(Aa,{path:C.path,name:C.name,type:C.type,depth:r+1},C.path))]})}const id="__statedb__:";function nd({onDbMissing:e}){const[t,s]=x.useState([]),[r,i]=x.useState(!0),[o,a]=x.useState(!1),l=xe(d=>d.selectedFile),{openTab:h}=xe(),{navigate:c}=et(),u=x.useCallback(()=>{a(!0),Pa().then(({exists:d})=>{if(!d){e();return}return td().then(s)}).catch(console.error).finally(()=>a(!1))},[e]);return x.useEffect(()=>{u()},[u]),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center",children:[n.jsxs("button",{onClick:()=>i(!r),className:"flex-1 text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),n.jsx("path",{d:"M21 12c0 1.66-4.03 3-9 3s-9-1.34-9-3"}),n.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"})]}),"State Database"]}),n.jsx("button",{onClick:d=>{d.stopPropagation(),u()},className:"shrink-0 flex items-center justify-center w-5 h-5 rounded cursor-pointer",style:{background:"none",border:"none",color:"var(--text-muted)",marginRight:"8px"},onMouseEnter:d=>{d.currentTarget.style.color="var(--text-primary)"},onMouseLeave:d=>{d.currentTarget.style.color="var(--text-muted)"},title:"Refresh tables",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:o?{animation:"spin 0.6s linear infinite"}:void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})})]}),r&&t.map(d=>{const p=`${id}${d.name}`,g=l===p;return n.jsxs("button",{onClick:()=>{h(p),c(`#/explorer/statedb/${encodeURIComponent(d.name)}`)},className:"w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors",style:{paddingLeft:"28px",paddingRight:"8px",background:g?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:g?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:m=>{g||(m.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:m=>{g||(m.currentTarget.style.background="transparent")},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)"},className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),n.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate flex-1",children:d.name}),n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:d.row_count})]},d.name)})]})}function to(){const e=xe(h=>h.children[""]),{setChildren:t}=xe(),[s,r]=x.useState(!1),[i,o]=x.useState(!0),{openTab:a}=xe(),{navigate:l}=et();return x.useEffect(()=>{e||Ki("").then(h=>t("",h)).catch(console.error)},[e,t]),x.useEffect(()=>{Pa().then(({exists:h})=>r(h)).catch(()=>r(!1))},[]),n.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[n.jsxs("button",{onClick:()=>{a("__canvas__"),l("#/explorer/canvas")},className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[n.jsx("circle",{cx:"5",cy:"1.5",r:"1.2"}),n.jsx("circle",{cx:"2",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.2"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"2",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"8",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"})]}),"Visualization"]}),s&&n.jsx(nd,{onDbMissing:()=>r(!1)}),n.jsxs("button",{onClick:()=>o(!i),className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"})}),"Files"]}),i&&(e?e.map(h=>n.jsx(Aa,{path:h.path,name:h.name,type:h.type,depth:0},h.path)):n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"Loading..."}))]})}async function od(){const e=await fetch("/api/cli-agent/available");return e.ok?e.json():[]}const ad={startNode:Sa,endNode:wa,modelNode:Ca,toolNode:ka,groupNode:Ea,defaultNode:Na},ld={elk:ja};function cd(){const e=de(j=>j.entrypoints),t=de(j=>j.runs),[s,r]=x.useState(null),[i,o,a]=ia([]),[l,h,c]=na([]),[u,d]=x.useState(!0),[p,g]=x.useState(!1),m=x.useRef(0),y=x.useRef(""),w=x.useRef(null),k=x.useRef(null),C=x.useRef(wr()).current,A=x.useMemo(()=>{if(!s)return null;let j=null;for(const D of Object.values(t))if(D.entrypoint===s){if(D.status==="running"||D.status==="pending")return D.id;(!j||D.start_time&&(!j.start_time||D.start_time>j.start_time))&&(j=D)}return(j==null?void 0:j.id)??null},[t,s]);x.useEffect(()=>{if(A)return C.subscribe(A),()=>{C.unsubscribe(A)}},[A,C]);const O=de(j=>A?j.stateEvents[A]:void 0),P=de(j=>{var D;return A?(D=j.runs[A])==null?void 0:D.status:void 0});return x.useEffect(()=>{e.length>0&&(!s||!e.includes(s))&&r(e[0])},[e,s]),x.useEffect(()=>{if(!s)return;const j=++m.current;!y.current&&d(!0),g(!1),fa(s).then(async L=>{if(m.current!==j)return;if(!L.nodes.length){g(!0);return}const B=JSON.stringify(L);if(B===y.current)return;y.current=B;const{nodes:I,edges:M}=await ba(L);m.current===j&&(o(I),h(M),setTimeout(()=>{var R;(R=w.current)==null||R.fitView({padding:.1,duration:200})},100))}).catch(()=>{m.current===j&&g(!0)}).finally(()=>{m.current===j&&d(!1)})},[s,e,o,h]),x.useEffect(()=>{if(!A)return;const j=new Map;if(O)for(const I of O)I.phase==="started"?j.set(I.node_name,I.qualified_node_name??null):I.phase==="completed"&&j.delete(I.node_name);let D=new Set;const L=new Set,B=new Map;o(I=>{var M;for(const R of I)R.type&&B.set(R.id,R.type);if(j.size>0){const R=new Map;for(const _ of I){const f=(M=_.data)==null?void 0:M.label;if(!f)continue;const v=_.id.includes("/")?_.id.split("/").pop():_.id;for(const b of[v,f]){let E=R.get(b);E||(E=new Set,R.set(b,E)),E.add(_.id)}}for(const[_,f]of j){let v=!1;if(f){const b=f.replace(/:/g,"/");for(const E of I)E.id===b&&(D.add(E.id),v=!0)}if(!v){const b=R.get(_);b&&b.forEach(E=>D.add(E))}}}return I}),h(I=>I.map(M=>{var _,f;let R=D.has(M.source);return!R&&B.get(M.target)==="endNode"&&D.has(M.target)&&(R=!0),R?(L.add(M.target),{...M,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...M.data,highlighted:!0},animated:!0}):(_=M.data)!=null&&_.highlighted?{...M,style:qi((f=M.data)==null?void 0:f.conditional),markerEnd:Os,data:{...M.data,highlighted:!1},animated:!1}:M})),o(I=>I.map(M=>{var f,v;const R=D.has(M.id),_=L.has(M.id)||D.has(M.id);return _!==!!((f=M.data)!=null&&f.isActiveNode)||R!==!!((v=M.data)!=null&&v.isExecutingNode)?{...M,data:{...M.data,isActiveNode:_,isExecutingNode:R}}:M}))},[A,O,o,h]),x.useEffect(()=>{A&&o(j=>{var _;const D=!!(O!=null&&O.length),L=P==="completed"||P==="failed",B=new Set,I=new Set(j.map(f=>f.id)),M=new Map;for(const f of j){const v=(_=f.data)==null?void 0:_.label;if(!v)continue;const b=f.id.includes("/")?f.id.split("/").pop():f.id;for(const E of[b,v]){let N=M.get(E);N||(N=new Set,M.set(E,N)),N.add(f.id)}}if(D)for(const f of O){let v=!1;if(f.qualified_node_name){const b=f.qualified_node_name.replace(/:/g,"/");I.has(b)&&(B.add(b),v=!0)}if(!v){const b=M.get(f.node_name);b&&b.forEach(E=>B.add(E))}}const R=new Set;for(const f of j)f.parentNode&&B.has(f.id)&&R.add(f.parentNode);return j.map(f=>{var b;let v;return B.has(f.id)?v="completed":f.type==="startNode"?(!f.parentNode&&D||f.parentNode&&R.has(f.parentNode))&&(v="completed"):f.type==="endNode"?!f.parentNode&&L?v=P==="failed"?"failed":"completed":f.parentNode&&R.has(f.parentNode)&&(v="completed"):f.type==="groupNode"&&R.has(f.id)&&(v="completed"),v!==((b=f.data)==null?void 0:b.status)?{...f,data:{...f.data,status:v}}:f})})},[A,O,P,o]),x.useEffect(()=>{const j=k.current;if(!j)return;const D=new ResizeObserver(()=>{var L;(L=w.current)==null||L.fitView({padding:.1,duration:200})});return D.observe(j),()=>D.disconnect()},[u,p]),u?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):p?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:k,className:"h-full explorer-canvas",children:[n.jsx("style",{children:` +{{AgentRunHistory}}`},"uipath-tool-call-order":{description:"Validates that the agent called tools in the expected sequence.",prompt:""},"uipath-tool-call-args":{description:"Checks whether the agent called tools with the expected arguments.",prompt:""},"uipath-tool-call-count":{description:"Validates that the agent made the expected number of tool calls.",prompt:""},"uipath-tool-call-output":{description:"Validates the output returned by the agent's tool calls.",prompt:""}};function Gh(e){for(const[t,s]of Object.entries(Ps))if(s.some(r=>r.id===e))return t;return"deterministic"}function Jh({evaluatorId:e,evaluatorFilter:t}){const s=xe(k=>k.localEvaluators),r=xe(k=>k.setLocalEvaluators),i=xe(k=>k.upsertLocalEvaluator),o=xe(k=>k.evaluators),{navigate:a}=et(),l=e?s.find(k=>k.id===e)??null:null,h=!!l,c=t?s.filter(k=>k.type===t):s,[u,d]=v.useState(()=>{const k=localStorage.getItem("evaluatorSidebarWidth");return k?parseInt(k,10):320}),[_,g]=v.useState(!1),m=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evaluatorSidebarWidth",String(u))},[u]),v.useEffect(()=>{Vi().then(r).catch(console.error)},[r]);const x=v.useCallback(k=>{k.preventDefault(),g(!0);const P="touches"in k?k.touches[0].clientX:k.clientX,A=u,D=$=>{const B=m.current;if(!B)return;const T="touches"in $?$.touches[0].clientX:$.clientX,O=B.clientWidth-300,L=Math.max(280,Math.min(O,A+(P-T)));d(L)},N=()=>{g(!1),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",D),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",D),document.addEventListener("mouseup",N),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("touchend",N)},[u]),w=k=>{i(k)},E=()=>{a("#/evaluators")};return n.jsxs("div",{ref:m,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:"Evaluators"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c.length,t?` / ${s.length}`:""," configured"]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:c.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:s.length===0?"No evaluators configured yet.":"No evaluators in this category."}):n.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:c.map(k=>n.jsx(Zh,{evaluator:k,evaluators:o,selected:k.id===e,onClick:()=>a(k.id===e?"#/evaluators":`#/evaluators/${encodeURIComponent(k.id)}`)},k.id))})})]}),n.jsx("div",{onMouseDown:x,onTouchStart:x,className:`shrink-0 drag-handle-col${_?"":" transition-all"}`,style:{width:h?3:0,opacity:h?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${_?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:h?u:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:u},children:[n.jsx("span",{className:"px-2 py-0.5 h-7 text-xs font-semibold rounded inline-flex items-center",style:{color:"var(--accent)",background:"color-mix(in srgb, var(--accent) 10%, transparent)"},children:"Edit Evaluator"}),n.jsx("button",{onClick:E,"aria-label":"Close editor",className:"ml-auto w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:k=>{k.currentTarget.style.color="var(--text-primary)"},onMouseLeave:k=>{k.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:u},children:l&&n.jsx(Qh,{evaluator:l,onUpdated:w})})]})]})}function Zh({evaluator:e,evaluators:t,selected:s,onClick:r}){const i=eo[e.type]??eo.deterministic,o=t.find(l=>l.id===e.evaluator_type_id),a=e.evaluator_type_id.startsWith("file://");return n.jsxs("div",{className:"rounded-md p-4 flex flex-col cursor-pointer transition-colors",style:{border:s?"1px solid var(--accent)":"1px solid var(--border)",background:s?"color-mix(in srgb, var(--accent) 5%, var(--card-bg))":"var(--card-bg)"},onClick:r,onMouseEnter:l=>{s||(l.currentTarget.style.borderColor="var(--text-muted)")},onMouseLeave:l=>{s||(l.currentTarget.style.borderColor="var(--border)")},children:[n.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.name}),e.description&&n.jsx("div",{className:"text-xs leading-relaxed mt-2",style:{color:"var(--text-secondary)"},children:e.description}),n.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-auto pt-3",children:[n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:i.color,background:i.bg},children:["Category: ",i.label]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Type: ",a?"Custom":(o==null?void 0:o.name)??e.evaluator_type_id]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium font-mono",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Target: ",e.target_output_key||"*"]})]})]})}function Qh({evaluator:e,onUpdated:t}){var O,L,R;const s=Gh(e.evaluator_type_id),r=Ps[s]??[],i=xe(p=>p.llmModels),o=xe(p=>p.setLlmModels),[a,l]=v.useState(e.description),[h,c]=v.useState(e.evaluator_type_id),[u,d]=v.useState(((O=e.config)==null?void 0:O.targetOutputKey)??"*"),[_,g]=v.useState(((L=e.config)==null?void 0:L.prompt)??""),[m,x]=v.useState(((R=e.config)==null?void 0:R.model)??""),[w,E]=v.useState(!1),[k,P]=v.useState(null),[A,D]=v.useState(!1);v.useEffect(()=>{s==="llm"&&i.length===0&&_a().then(o).catch(()=>{})},[s]),v.useEffect(()=>{var p,f,b;l(e.description),c(e.evaluator_type_id),d(((p=e.config)==null?void 0:p.targetOutputKey)??"*"),g(((f=e.config)==null?void 0:f.prompt)??""),x(((b=e.config)==null?void 0:b.model)??""),P(null),D(!1)},[e.id]);const N=Pa(h),$=s==="llm",B=async()=>{E(!0),P(null),D(!1);try{const p={};N.targetOutputKey&&(p.targetOutputKey=u),N.prompt&&_.trim()&&(p.prompt=_),$&&m&&(p.model=m);const f=await Kc(e.id,{description:a.trim(),evaluator_type_id:h,config:p});t(f),D(!0),setTimeout(()=>D(!1),2e3)}catch(p){const f=p==null?void 0:p.detail;P(f??"Failed to update evaluator")}finally{E(!1)}},T={background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)"};return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:e.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Category"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[s]??s})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:h,onChange:p=>c(p.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:r.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:a,onChange:p=>l(p.target.value),placeholder:"What does this evaluator check?",rows:4,className:"w-full px-3 py-2 rounded-lg text-xs leading-relaxed outline-none resize-y",style:T})]}),N.targetOutputKey&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:u,onChange:p=>d(p.target.value),placeholder:"*",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),N.prompt&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:_,onChange:p=>g(p.target.value),placeholder:"Evaluation prompt for the LLM judge...",rows:8,className:"w-full px-3 py-2 rounded-lg text-xs font-mono leading-relaxed outline-none resize-y",style:T})]}),$&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Model"}),i.length>0?n.jsxs("select",{value:m,onChange:p=>x(p.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:[n.jsx("option",{value:"",children:"Select a model"}),i.map(p=>n.jsxs("option",{value:p.model_name,children:[p.model_name,p.vendor?` (${p.vendor})`:""]},p.model_name))]}):n.jsx("input",{type:"text",value:m,onChange:p=>x(p.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T})]})]}),n.jsxs("div",{className:"shrink-0 p-4 space-y-2",children:[k&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:k}),A&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(34,197,94,0.1)",color:"var(--success)"},children:"Saved successfully"}),n.jsx("button",{onClick:B,disabled:w,className:"w-full py-2.5 text-xs font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:"transparent",borderColor:"var(--accent)",color:"var(--accent)"},onMouseEnter:p=>{p.currentTarget.style.background="color-mix(in srgb, var(--accent) 15%, transparent)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent"},children:w?"Saving...":"Save Changes"})]})]})}const ed=["deterministic","llm","tool"];function td({category:e}){var z;const t=xe(C=>C.addLocalEvaluator),s=xe(C=>C.llmModels),r=xe(C=>C.setLlmModels),{navigate:i}=et(),o=e!=="any",[a,l]=v.useState(o?e:"deterministic"),h=Ps[a]??[],[c,u]=v.useState(""),[d,_]=v.useState(""),[g,m]=v.useState(((z=h[0])==null?void 0:z.id)??""),[x,w]=v.useState("*"),[E,k]=v.useState(""),[P,A]=v.useState(""),[D,N]=v.useState(!1),[$,B]=v.useState(null),[T,O]=v.useState(!1),[L,R]=v.useState(!1);v.useEffect(()=>{s.length===0&&_a().then(r).catch(()=>{})},[]),v.useEffect(()=>{var ee;const C=o?e:"deterministic";l(C);const U=((ee=(Ps[C]??[])[0])==null?void 0:ee.id)??"",q=$r[U];u(""),_((q==null?void 0:q.description)??""),m(U),w("*"),k((q==null?void 0:q.prompt)??""),A(""),B(null),O(!1),R(!1)},[e,o]);const p=C=>{var ee;l(C);const U=((ee=(Ps[C]??[])[0])==null?void 0:ee.id)??"",q=$r[U];m(U),T||_((q==null?void 0:q.description)??""),L||k((q==null?void 0:q.prompt)??"")},f=C=>{m(C);const H=$r[C];H&&(T||_(H.description),L||k(H.prompt))},b=Pa(g),y=a==="llm",j=async()=>{if(!c.trim()){B("Name is required");return}N(!0),B(null);try{const C={};b.targetOutputKey&&(C.targetOutputKey=x),b.prompt&&E.trim()&&(C.prompt=E),y&&P&&(C.model=P);const H=await zc({name:c.trim(),description:d.trim(),evaluator_type_id:g,config:C});t(H),i("#/evaluators")}catch(C){const H=C==null?void 0:C.detail;B(H??"Failed to create evaluator")}finally{N(!1)}},M={background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"};return n.jsx("div",{className:"h-full overflow-y-auto",children:n.jsx("div",{className:"flex items-center justify-center min-h-full py-8",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Evaluator"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluator to score agent outputs"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:c,onChange:C=>u(C.target.value),placeholder:"e.g. MyEvaluator",className:"w-full rounded-md px-3 py-2 text-xs",style:M,onKeyDown:C=>{C.key==="Enter"&&c.trim()&&j()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Category"}),o?n.jsx("div",{className:"px-3 py-2 rounded-md text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[a]??a}):n.jsx("select",{value:a,onChange:C=>p(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:ed.map(C=>n.jsx("option",{value:C,children:ri[C]},C))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:g,onChange:C=>f(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:h.map(C=>n.jsx("option",{value:C.id,children:C.name},C.id))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:d,onChange:C=>{_(C.target.value),O(!0)},placeholder:"What does this evaluator check?",rows:3,className:"w-full rounded-md px-3 py-2 text-xs leading-relaxed resize-y",style:M})]}),b.targetOutputKey&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:x,onChange:C=>w(C.target.value),placeholder:"*",className:"w-full rounded-md px-3 py-2 text-xs",style:M}),n.jsx("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),b.prompt&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:E,onChange:C=>{k(C.target.value),R(!0)},placeholder:"Evaluation prompt for the LLM judge...",rows:6,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-y",style:M})]}),y&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Model"}),s.length>0?n.jsxs("select",{value:P,onChange:C=>A(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:[n.jsx("option",{value:"",children:"Select a model"}),s.map(C=>n.jsxs("option",{value:C.model_name,children:[C.model_name,C.vendor?` (${C.vendor})`:""]},C.model_name))]}):n.jsx("input",{type:"text",value:P,onChange:C=>A(C.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full rounded-md px-3 py-2 text-xs",style:M})]}),$&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:$}),n.jsx("button",{onClick:j,disabled:D||!c.trim(),className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:D?"Creating...":"Create Evaluator"})]})})})}const Cr="/api";async function kr(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Aa(){return kr(`${Cr}/statedb/status`)}async function sd(){return kr(`${Cr}/statedb/tables`)}async function rd(e,t=100,s=0){return kr(`${Cr}/statedb/tables/${encodeURIComponent(e)}?limit=${t}&offset=${s}`)}async function id(e,t){return kr(`${Cr}/statedb/query`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e,limit:t})})}function Oa({path:e,name:t,type:s,depth:r}){const i=ye(k=>k.children[e]),o=ye(k=>!!k.expanded[e]),a=ye(k=>!!k.loadingDirs[e]),l=ye(k=>!!k.dirty[e]),h=ye(k=>!!k.agentChangedFiles[e]),c=ye(k=>k.selectedFile),{setChildren:u,toggleExpanded:d,setLoadingDir:_,openTab:g}=ye(),{navigate:m}=et(),x=s==="directory",w=!x&&c===e,E=v.useCallback(()=>{x?(!i&&!a&&(_(e,!0),Ki(e).then(k=>u(e,k)).catch(console.error).finally(()=>_(e,!1))),d(e)):(g(e),m(`#/explorer/file/${encodeURIComponent(e)}`))},[x,i,a,e,u,d,_,g,m]);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:E,className:`w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors group${h?" agent-changed-file":""}`,style:{paddingLeft:`${12+r*16}px`,paddingRight:"8px",background:w?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:w?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:k=>{w||(k.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:k=>{w||(k.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"w-3 shrink-0 flex items-center justify-center",style:{color:"var(--text-muted)"},children:x&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5z"})})}),n.jsx("span",{className:"shrink-0",style:{color:x?"var(--accent)":"var(--text-muted)"},children:x?n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),n.jsx("span",{className:"truncate flex-1",children:t}),l&&n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"}}),a&&n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:"..."})]}),x&&o&&i&&i.map(k=>n.jsx(Oa,{path:k.path,name:k.name,type:k.type,depth:r+1},k.path))]})}const nd="__statedb__:";function od({onDbMissing:e}){const[t,s]=v.useState([]),[r,i]=v.useState(!0),[o,a]=v.useState(!1),l=ye(d=>d.selectedFile),{openTab:h}=ye(),{navigate:c}=et(),u=v.useCallback(()=>{a(!0),Aa().then(({exists:d})=>{if(!d){e();return}return sd().then(s)}).catch(console.error).finally(()=>a(!1))},[e]);return v.useEffect(()=>{u()},[u]),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center",children:[n.jsxs("button",{onClick:()=>i(!r),className:"flex-1 text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),n.jsx("path",{d:"M21 12c0 1.66-4.03 3-9 3s-9-1.34-9-3"}),n.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"})]}),"State Database"]}),n.jsx("button",{onClick:d=>{d.stopPropagation(),u()},className:"shrink-0 flex items-center justify-center w-5 h-5 rounded cursor-pointer",style:{background:"none",border:"none",color:"var(--text-muted)",marginRight:"8px"},onMouseEnter:d=>{d.currentTarget.style.color="var(--text-primary)"},onMouseLeave:d=>{d.currentTarget.style.color="var(--text-muted)"},title:"Refresh tables",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:o?{animation:"spin 0.6s linear infinite"}:void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})})]}),r&&t.map(d=>{const _=`${nd}${d.name}`,g=l===_;return n.jsxs("button",{onClick:()=>{h(_),c(`#/explorer/statedb/${encodeURIComponent(d.name)}`)},className:"w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors",style:{paddingLeft:"28px",paddingRight:"8px",background:g?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:g?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:m=>{g||(m.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:m=>{g||(m.currentTarget.style.background="transparent")},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)"},className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),n.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate flex-1",children:d.name}),n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:d.row_count})]},d.name)})]})}function to(){const e=ye(h=>h.children[""]),{setChildren:t}=ye(),[s,r]=v.useState(!1),[i,o]=v.useState(!0),{openTab:a}=ye(),{navigate:l}=et();return v.useEffect(()=>{e||Ki("").then(h=>t("",h)).catch(console.error)},[e,t]),v.useEffect(()=>{Aa().then(({exists:h})=>r(h)).catch(()=>r(!1))},[]),n.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[n.jsxs("button",{onClick:()=>{a("__canvas__"),l("#/explorer/canvas")},className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[n.jsx("circle",{cx:"5",cy:"1.5",r:"1.2"}),n.jsx("circle",{cx:"2",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.2"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"2",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"8",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"})]}),"Visualization"]}),s&&n.jsx(od,{onDbMissing:()=>r(!1)}),n.jsxs("button",{onClick:()=>o(!i),className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"})}),"Files"]}),i&&(e?e.map(h=>n.jsx(Oa,{path:h.path,name:h.name,type:h.type,depth:0},h.path)):n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"Loading..."}))]})}async function ad(){const e=await fetch("/api/cli-agent/available");return e.ok?e.json():[]}const ld={startNode:wa,endNode:Ca,modelNode:ka,toolNode:Ea,groupNode:Na,defaultNode:ja},cd={elk:Ma};function hd(){const e=de(N=>N.entrypoints),t=de(N=>N.runs),[s,r]=v.useState(null),[i,o,a]=ia([]),[l,h,c]=na([]),[u,d]=v.useState(!0),[_,g]=v.useState(!1),m=v.useRef(0),x=v.useRef(""),w=v.useRef(null),E=v.useRef(null),k=v.useRef(wr()).current,P=v.useMemo(()=>{if(!s)return null;let N=null;for(const $ of Object.values(t))if($.entrypoint===s){if($.status==="running"||$.status==="pending")return $.id;(!N||$.start_time&&(!N.start_time||$.start_time>N.start_time))&&(N=$)}return(N==null?void 0:N.id)??null},[t,s]);v.useEffect(()=>{if(P)return k.subscribe(P),()=>{k.unsubscribe(P)}},[P,k]);const A=de(N=>P?N.stateEvents[P]:void 0),D=de(N=>{var $;return P?($=N.runs[P])==null?void 0:$.status:void 0});return v.useEffect(()=>{e.length>0&&(!s||!e.includes(s))&&r(e[0])},[e,s]),v.useEffect(()=>{if(!s)return;const N=++m.current;!x.current&&d(!0),g(!1),fa(s).then(async B=>{if(m.current!==N)return;if(!B.nodes.length){g(!0);return}const T=JSON.stringify(B);if(T===x.current)return;x.current=T;const{nodes:O,edges:L}=await Sa(B);m.current===N&&(o(O),h(L),setTimeout(()=>{var R;(R=w.current)==null||R.fitView({padding:.1,duration:200})},100))}).catch(()=>{m.current===N&&g(!0)}).finally(()=>{m.current===N&&d(!1)})},[s,e,o,h]),v.useEffect(()=>{if(!P)return;const N=new Map;if(A)for(const O of A)O.phase==="started"?N.set(O.node_name,O.qualified_node_name??null):O.phase==="completed"&&N.delete(O.node_name);let $=new Set;const B=new Set,T=new Map;o(O=>{var L;for(const R of O)R.type&&T.set(R.id,R.type);if(N.size>0){const R=new Map;for(const p of O){const f=(L=p.data)==null?void 0:L.label;if(!f)continue;const b=p.id.includes("/")?p.id.split("/").pop():p.id;for(const y of[b,f]){let j=R.get(y);j||(j=new Set,R.set(y,j)),j.add(p.id)}}for(const[p,f]of N){let b=!1;if(f){const y=f.replace(/:/g,"/");for(const j of O)j.id===y&&($.add(j.id),b=!0)}if(!b){const y=R.get(p);y&&y.forEach(j=>$.add(j))}}}return O}),h(O=>O.map(L=>{var p,f;let R=$.has(L.source);return!R&&T.get(L.target)==="endNode"&&$.has(L.target)&&(R=!0),R?(B.add(L.target),{...L,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...L.data,highlighted:!0},animated:!0}):(p=L.data)!=null&&p.highlighted?{...L,style:qi((f=L.data)==null?void 0:f.conditional),markerEnd:Os,data:{...L.data,highlighted:!1},animated:!1}:L})),o(O=>O.map(L=>{var f,b;const R=$.has(L.id),p=B.has(L.id)||$.has(L.id);return p!==!!((f=L.data)!=null&&f.isActiveNode)||R!==!!((b=L.data)!=null&&b.isExecutingNode)?{...L,data:{...L.data,isActiveNode:p,isExecutingNode:R}}:L}))},[P,A,o,h]),v.useEffect(()=>{P&&o(N=>{var p;const $=!!(A!=null&&A.length),B=D==="completed"||D==="failed",T=new Set,O=new Set(N.map(f=>f.id)),L=new Map;for(const f of N){const b=(p=f.data)==null?void 0:p.label;if(!b)continue;const y=f.id.includes("/")?f.id.split("/").pop():f.id;for(const j of[y,b]){let M=L.get(j);M||(M=new Set,L.set(j,M)),M.add(f.id)}}if($)for(const f of A){let b=!1;if(f.qualified_node_name){const y=f.qualified_node_name.replace(/:/g,"/");O.has(y)&&(T.add(y),b=!0)}if(!b){const y=L.get(f.node_name);y&&y.forEach(j=>T.add(j))}}const R=new Set;for(const f of N)f.parentNode&&T.has(f.id)&&R.add(f.parentNode);return N.map(f=>{var y;let b;return T.has(f.id)?b="completed":f.type==="startNode"?(!f.parentNode&&$||f.parentNode&&R.has(f.parentNode))&&(b="completed"):f.type==="endNode"?!f.parentNode&&B?b=D==="failed"?"failed":"completed":f.parentNode&&R.has(f.parentNode)&&(b="completed"):f.type==="groupNode"&&R.has(f.id)&&(b="completed"),b!==((y=f.data)==null?void 0:y.status)?{...f,data:{...f.data,status:b}}:f})})},[P,A,D,o]),v.useEffect(()=>{const N=E.current;if(!N)return;const $=new ResizeObserver(()=>{var B;(B=w.current)==null||B.fitView({padding:.1,duration:200})});return $.observe(N),()=>$.disconnect()},[u,_]),u?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):_?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:E,className:"h-full explorer-canvas",children:[n.jsx("style",{children:` .explorer-canvas .react-flow__handle { opacity: 0 !important; width: 0 !important; @@ -89,9 +89,9 @@ AgentRunHistory: @keyframes explorer-edge-flow { to { stroke-dashoffset: -12; } } - `}),e.length>1&&n.jsx("div",{style:{position:"absolute",top:8,left:8,zIndex:10},children:n.jsx("select",{value:s??"",onChange:j=>r(j.target.value),style:{background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--node-border)",borderRadius:6,padding:"4px 8px",fontSize:12},children:e.map(j=>n.jsx("option",{value:j,children:j},j))})}),n.jsxs(oa,{nodes:i,edges:l,onNodesChange:a,onEdgesChange:c,nodeTypes:ad,edgeTypes:ld,onInit:j=>{w.current=j},fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(ca,{nodeColor:j=>{var L;if(j.type==="groupNode")return"var(--bg-tertiary)";const D=(L=j.data)==null?void 0:L.status;return D==="completed"?"var(--success)":D==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}var Fr,so;function hd(){if(so)return Fr;so=1;function e(S){return S instanceof Map?S.clear=S.delete=S.set=function(){throw new Error("map is read-only")}:S instanceof Set&&(S.add=S.clear=S.delete=function(){throw new Error("set is read-only")}),Object.freeze(S),Object.getOwnPropertyNames(S).forEach(W=>{const q=S[W],ae=typeof q;(ae==="object"||ae==="function")&&!Object.isFrozen(q)&&e(q)}),S}class t{constructor(W){W.data===void 0&&(W.data={}),this.data=W.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(S){return S.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(S,...W){const q=Object.create(null);for(const ae in S)q[ae]=S[ae];return W.forEach(function(ae){for(const Te in ae)q[Te]=ae[Te]}),q}const i="",o=S=>!!S.scope,a=(S,{prefix:W})=>{if(S.startsWith("language:"))return S.replace("language:","language-");if(S.includes(".")){const q=S.split(".");return[`${W}${q.shift()}`,...q.map((ae,Te)=>`${ae}${"_".repeat(Te+1)}`)].join(" ")}return`${W}${S}`};class l{constructor(W,q){this.buffer="",this.classPrefix=q.classPrefix,W.walk(this)}addText(W){this.buffer+=s(W)}openNode(W){if(!o(W))return;const q=a(W.scope,{prefix:this.classPrefix});this.span(q)}closeNode(W){o(W)&&(this.buffer+=i)}value(){return this.buffer}span(W){this.buffer+=``}}const h=(S={})=>{const W={children:[]};return Object.assign(W,S),W};class c{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(W){this.top.children.push(W)}openNode(W){const q=h({scope:W});this.add(q),this.stack.push(q)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(W){return this.constructor._walk(W,this.rootNode)}static _walk(W,q){return typeof q=="string"?W.addText(q):q.children&&(W.openNode(q),q.children.forEach(ae=>this._walk(W,ae)),W.closeNode(q)),W}static _collapse(W){typeof W!="string"&&W.children&&(W.children.every(q=>typeof q=="string")?W.children=[W.children.join("")]:W.children.forEach(q=>{c._collapse(q)}))}}class u extends c{constructor(W){super(),this.options=W}addText(W){W!==""&&this.add(W)}startScope(W){this.openNode(W)}endScope(){this.closeNode()}__addSublanguage(W,q){const ae=W.root;q&&(ae.scope=`language:${q}`),this.add(ae)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(S){return S?typeof S=="string"?S:S.source:null}function p(S){return y("(?=",S,")")}function g(S){return y("(?:",S,")*")}function m(S){return y("(?:",S,")?")}function y(...S){return S.map(q=>d(q)).join("")}function w(S){const W=S[S.length-1];return typeof W=="object"&&W.constructor===Object?(S.splice(S.length-1,1),W):{}}function k(...S){return"("+(w(S).capture?"":"?:")+S.map(ae=>d(ae)).join("|")+")"}function C(S){return new RegExp(S.toString()+"|").exec("").length-1}function A(S,W){const q=S&&S.exec(W);return q&&q.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function P(S,{joinWith:W}){let q=0;return S.map(ae=>{q+=1;const Te=q;let Re=d(ae),Q="";for(;Re.length>0;){const G=O.exec(Re);if(!G){Q+=Re;break}Q+=Re.substring(0,G.index),Re=Re.substring(G.index+G[0].length),G[0][0]==="\\"&&G[1]?Q+="\\"+String(Number(G[1])+Te):(Q+=G[0],G[0]==="("&&q++)}return Q}).map(ae=>`(${ae})`).join(W)}const j=/\b\B/,D="[a-zA-Z]\\w*",L="[a-zA-Z_]\\w*",B="\\b\\d+(\\.\\d+)?",I="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",M="\\b(0b[01]+)",R="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",_=(S={})=>{const W=/^#![ ]*\//;return S.binary&&(S.begin=y(W,/.*\b/,S.binary,/\b.*/)),r({scope:"meta",begin:W,end:/$/,relevance:0,"on:begin":(q,ae)=>{q.index!==0&&ae.ignoreMatch()}},S)},f={begin:"\\\\[\\s\\S]",relevance:0},v={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[f]},b={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[f]},E={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},N=function(S,W,q={}){const ae=r({scope:"comment",begin:S,end:W,contains:[]},q);ae.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Te=k("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ae.contains.push({begin:y(/[ ]+/,"(",Te,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ae},z=N("//","$"),T=N("/\\*","\\*/"),$=N("#","$"),V={scope:"number",begin:B,relevance:0},J={scope:"number",begin:I,relevance:0},re={scope:"number",begin:M,relevance:0},ie={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[f,{begin:/\[/,end:/\]/,relevance:0,contains:[f]}]},F={scope:"title",begin:D,relevance:0},te={scope:"title",begin:L,relevance:0},pe={begin:"\\.\\s*"+L,relevance:0};var qe=Object.freeze({__proto__:null,APOS_STRING_MODE:v,BACKSLASH_ESCAPE:f,BINARY_NUMBER_MODE:re,BINARY_NUMBER_RE:M,COMMENT:N,C_BLOCK_COMMENT_MODE:T,C_LINE_COMMENT_MODE:z,C_NUMBER_MODE:J,C_NUMBER_RE:I,END_SAME_AS_BEGIN:function(S){return Object.assign(S,{"on:begin":(W,q)=>{q.data._beginMatch=W[1]},"on:end":(W,q)=>{q.data._beginMatch!==W[1]&&q.ignoreMatch()}})},HASH_COMMENT_MODE:$,IDENT_RE:D,MATCH_NOTHING_RE:j,METHOD_GUARD:pe,NUMBER_MODE:V,NUMBER_RE:B,PHRASAL_WORDS_MODE:E,QUOTE_STRING_MODE:b,REGEXP_MODE:ie,RE_STARTERS_RE:R,SHEBANG:_,TITLE_MODE:F,UNDERSCORE_IDENT_RE:L,UNDERSCORE_TITLE_MODE:te});function St(S,W){S.input[S.index-1]==="."&&W.ignoreMatch()}function ht(S,W){S.className!==void 0&&(S.scope=S.className,delete S.className)}function ge(S,W){W&&S.beginKeywords&&(S.begin="\\b("+S.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",S.__beforeBegin=St,S.keywords=S.keywords||S.beginKeywords,delete S.beginKeywords,S.relevance===void 0&&(S.relevance=0))}function $t(S,W){Array.isArray(S.illegal)&&(S.illegal=k(...S.illegal))}function Z(S,W){if(S.match){if(S.begin||S.end)throw new Error("begin & end are not supported with match");S.begin=S.match,delete S.match}}function me(S,W){S.relevance===void 0&&(S.relevance=1)}const dt=(S,W)=>{if(!S.beforeMatch)return;if(S.starts)throw new Error("beforeMatch cannot be used with starts");const q=Object.assign({},S);Object.keys(S).forEach(ae=>{delete S[ae]}),S.keywords=q.keywords,S.begin=y(q.beforeMatch,p(q.begin)),S.starts={relevance:0,contains:[Object.assign(q,{endsParent:!0})]},S.relevance=0,delete q.beforeMatch},ve=["of","and","for","in","not","or","if","then","parent","list","value"],vt="keyword";function xt(S,W,q=vt){const ae=Object.create(null);return typeof S=="string"?Te(q,S.split(" ")):Array.isArray(S)?Te(q,S):Object.keys(S).forEach(function(Re){Object.assign(ae,xt(S[Re],W,Re))}),ae;function Te(Re,Q){W&&(Q=Q.map(G=>G.toLowerCase())),Q.forEach(function(G){const oe=G.split("|");ae[oe[0]]=[Re,it(oe[0],oe[1])]})}}function it(S,W){return W?Number(W):ut(S)?0:1}function ut(S){return ve.includes(S.toLowerCase())}const Ks={},Bt=S=>{console.error(S)},nn=(S,...W)=>{console.log(`WARN: ${S}`,...W)},ds=(S,W)=>{Ks[`${S}/${W}`]||(console.log(`Deprecated as of ${S}. ${W}`),Ks[`${S}/${W}`]=!0)},Vs=new Error;function on(S,W,{key:q}){let ae=0;const Te=S[q],Re={},Q={};for(let G=1;G<=W.length;G++)Q[G+ae]=Te[G],Re[G+ae]=!0,ae+=C(W[G-1]);S[q]=Q,S[q]._emit=Re,S[q]._multi=!0}function jl(S){if(Array.isArray(S.begin)){if(S.skip||S.excludeBegin||S.returnBegin)throw Bt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Vs;if(typeof S.beginScope!="object"||S.beginScope===null)throw Bt("beginScope must be object"),Vs;on(S,S.begin,{key:"beginScope"}),S.begin=P(S.begin,{joinWith:""})}}function Ml(S){if(Array.isArray(S.end)){if(S.skip||S.excludeEnd||S.returnEnd)throw Bt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Vs;if(typeof S.endScope!="object"||S.endScope===null)throw Bt("endScope must be object"),Vs;on(S,S.end,{key:"endScope"}),S.end=P(S.end,{joinWith:""})}}function Ll(S){S.scope&&typeof S.scope=="object"&&S.scope!==null&&(S.beginScope=S.scope,delete S.scope)}function Tl(S){Ll(S),typeof S.beginScope=="string"&&(S.beginScope={_wrap:S.beginScope}),typeof S.endScope=="string"&&(S.endScope={_wrap:S.endScope}),jl(S),Ml(S)}function Rl(S){function W(Q,G){return new RegExp(d(Q),"m"+(S.case_insensitive?"i":"")+(S.unicodeRegex?"u":"")+(G?"g":""))}class q{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(G,oe){oe.position=this.position++,this.matchIndexes[this.matchAt]=oe,this.regexes.push([oe,G]),this.matchAt+=C(G)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const G=this.regexes.map(oe=>oe[1]);this.matcherRe=W(P(G,{joinWith:"|"}),!0),this.lastIndex=0}exec(G){this.matcherRe.lastIndex=this.lastIndex;const oe=this.matcherRe.exec(G);if(!oe)return null;const $e=oe.findIndex((Ss,Tr)=>Tr>0&&Ss!==void 0),De=this.matchIndexes[$e];return oe.splice(0,$e),Object.assign(oe,De)}}class ae{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(G){if(this.multiRegexes[G])return this.multiRegexes[G];const oe=new q;return this.rules.slice(G).forEach(([$e,De])=>oe.addRule($e,De)),oe.compile(),this.multiRegexes[G]=oe,oe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(G,oe){this.rules.push([G,oe]),oe.type==="begin"&&this.count++}exec(G){const oe=this.getMatcher(this.regexIndex);oe.lastIndex=this.lastIndex;let $e=oe.exec(G);if(this.resumingScanAtSamePosition()&&!($e&&$e.index===this.lastIndex)){const De=this.getMatcher(0);De.lastIndex=this.lastIndex+1,$e=De.exec(G)}return $e&&(this.regexIndex+=$e.position+1,this.regexIndex===this.count&&this.considerAll()),$e}}function Te(Q){const G=new ae;return Q.contains.forEach(oe=>G.addRule(oe.begin,{rule:oe,type:"begin"})),Q.terminatorEnd&&G.addRule(Q.terminatorEnd,{type:"end"}),Q.illegal&&G.addRule(Q.illegal,{type:"illegal"}),G}function Re(Q,G){const oe=Q;if(Q.isCompiled)return oe;[ht,Z,Tl,dt].forEach(De=>De(Q,G)),S.compilerExtensions.forEach(De=>De(Q,G)),Q.__beforeBegin=null,[ge,$t,me].forEach(De=>De(Q,G)),Q.isCompiled=!0;let $e=null;return typeof Q.keywords=="object"&&Q.keywords.$pattern&&(Q.keywords=Object.assign({},Q.keywords),$e=Q.keywords.$pattern,delete Q.keywords.$pattern),$e=$e||/\w+/,Q.keywords&&(Q.keywords=xt(Q.keywords,S.case_insensitive)),oe.keywordPatternRe=W($e,!0),G&&(Q.begin||(Q.begin=/\B|\b/),oe.beginRe=W(oe.begin),!Q.end&&!Q.endsWithParent&&(Q.end=/\B|\b/),Q.end&&(oe.endRe=W(oe.end)),oe.terminatorEnd=d(oe.end)||"",Q.endsWithParent&&G.terminatorEnd&&(oe.terminatorEnd+=(Q.end?"|":"")+G.terminatorEnd)),Q.illegal&&(oe.illegalRe=W(Q.illegal)),Q.contains||(Q.contains=[]),Q.contains=[].concat(...Q.contains.map(function(De){return Bl(De==="self"?Q:De)})),Q.contains.forEach(function(De){Re(De,oe)}),Q.starts&&Re(Q.starts,G),oe.matcher=Te(oe),oe}if(S.compilerExtensions||(S.compilerExtensions=[]),S.contains&&S.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return S.classNameAliases=r(S.classNameAliases||{}),Re(S)}function an(S){return S?S.endsWithParent||an(S.starts):!1}function Bl(S){return S.variants&&!S.cachedVariants&&(S.cachedVariants=S.variants.map(function(W){return r(S,{variants:null},W)})),S.cachedVariants?S.cachedVariants:an(S)?r(S,{starts:S.starts?r(S.starts):null}):Object.isFrozen(S)?r(S):S}var Dl="11.11.1";class Pl extends Error{constructor(W,q){super(W),this.name="HTMLInjectionError",this.html=q}}const Lr=s,ln=r,cn=Symbol("nomatch"),Al=7,hn=function(S){const W=Object.create(null),q=Object.create(null),ae=[];let Te=!0;const Re="Could not find the language '{}', did you forget to load/include a language module?",Q={disableAutodetect:!0,name:"Plain text",contains:[]};let G={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function oe(U){return G.noHighlightRe.test(U)}function $e(U){let se=U.className+" ";se+=U.parentNode?U.parentNode.className:"";const fe=G.languageDetectRe.exec(se);if(fe){const we=Ft(fe[1]);return we||(nn(Re.replace("{}",fe[1])),nn("Falling back to no-highlight mode for this block.",U)),we?fe[1]:"no-highlight"}return se.split(/\s+/).find(we=>oe(we)||Ft(we))}function De(U,se,fe){let we="",Oe="";typeof se=="object"?(we=U,fe=se.ignoreIllegals,Oe=se.language):(ds("10.7.0","highlight(lang, code, ...args) has been deprecated."),ds("10.7.0",`Please use highlight(code, options) instead. -https://github.com/highlightjs/highlight.js/issues/2277`),Oe=U,we=se),fe===void 0&&(fe=!0);const yt={code:we,language:Oe};Xs("before:highlight",yt);const zt=yt.result?yt.result:Ss(yt.language,yt.code,fe);return zt.code=yt.code,Xs("after:highlight",zt),zt}function Ss(U,se,fe,we){const Oe=Object.create(null);function yt(X,ee){return X.keywords[ee]}function zt(){if(!le.keywords){Xe.addText(Ce);return}let X=0;le.keywordPatternRe.lastIndex=0;let ee=le.keywordPatternRe.exec(Ce),ce="";for(;ee;){ce+=Ce.substring(X,ee.index);const ye=Ct.case_insensitive?ee[0].toLowerCase():ee[0],Je=yt(le,ye);if(Je){const[Dt,Ql]=Je;if(Xe.addText(ce),ce="",Oe[ye]=(Oe[ye]||0)+1,Oe[ye]<=Al&&(Js+=Ql),Dt.startsWith("_"))ce+=ee[0];else{const ec=Ct.classNameAliases[Dt]||Dt;wt(ee[0],ec)}}else ce+=ee[0];X=le.keywordPatternRe.lastIndex,ee=le.keywordPatternRe.exec(Ce)}ce+=Ce.substring(X),Xe.addText(ce)}function Ys(){if(Ce==="")return;let X=null;if(typeof le.subLanguage=="string"){if(!W[le.subLanguage]){Xe.addText(Ce);return}X=Ss(le.subLanguage,Ce,!0,vn[le.subLanguage]),vn[le.subLanguage]=X._top}else X=Rr(Ce,le.subLanguage.length?le.subLanguage:null);le.relevance>0&&(Js+=X.relevance),Xe.__addSublanguage(X._emitter,X.language)}function nt(){le.subLanguage!=null?Ys():zt(),Ce=""}function wt(X,ee){X!==""&&(Xe.startScope(ee),Xe.addText(X),Xe.endScope())}function pn(X,ee){let ce=1;const ye=ee.length-1;for(;ce<=ye;){if(!X._emit[ce]){ce++;continue}const Je=Ct.classNameAliases[X[ce]]||X[ce],Dt=ee[ce];Je?wt(Dt,Je):(Ce=Dt,zt(),Ce=""),ce++}}function _n(X,ee){return X.scope&&typeof X.scope=="string"&&Xe.openNode(Ct.classNameAliases[X.scope]||X.scope),X.beginScope&&(X.beginScope._wrap?(wt(Ce,Ct.classNameAliases[X.beginScope._wrap]||X.beginScope._wrap),Ce=""):X.beginScope._multi&&(pn(X.beginScope,ee),Ce="")),le=Object.create(X,{parent:{value:le}}),le}function gn(X,ee,ce){let ye=A(X.endRe,ce);if(ye){if(X["on:end"]){const Je=new t(X);X["on:end"](ee,Je),Je.isMatchIgnored&&(ye=!1)}if(ye){for(;X.endsParent&&X.parent;)X=X.parent;return X}}if(X.endsWithParent)return gn(X.parent,ee,ce)}function Xl(X){return le.matcher.regexIndex===0?(Ce+=X[0],1):(Ar=!0,0)}function Yl(X){const ee=X[0],ce=X.rule,ye=new t(ce),Je=[ce.__beforeBegin,ce["on:begin"]];for(const Dt of Je)if(Dt&&(Dt(X,ye),ye.isMatchIgnored))return Xl(ee);return ce.skip?Ce+=ee:(ce.excludeBegin&&(Ce+=ee),nt(),!ce.returnBegin&&!ce.excludeBegin&&(Ce=ee)),_n(ce,X),ce.returnBegin?0:ee.length}function Gl(X){const ee=X[0],ce=se.substring(X.index),ye=gn(le,X,ce);if(!ye)return cn;const Je=le;le.endScope&&le.endScope._wrap?(nt(),wt(ee,le.endScope._wrap)):le.endScope&&le.endScope._multi?(nt(),pn(le.endScope,X)):Je.skip?Ce+=ee:(Je.returnEnd||Je.excludeEnd||(Ce+=ee),nt(),Je.excludeEnd&&(Ce=ee));do le.scope&&Xe.closeNode(),!le.skip&&!le.subLanguage&&(Js+=le.relevance),le=le.parent;while(le!==ye.parent);return ye.starts&&_n(ye.starts,X),Je.returnEnd?0:ee.length}function Jl(){const X=[];for(let ee=le;ee!==Ct;ee=ee.parent)ee.scope&&X.unshift(ee.scope);X.forEach(ee=>Xe.openNode(ee))}let Gs={};function mn(X,ee){const ce=ee&&ee[0];if(Ce+=X,ce==null)return nt(),0;if(Gs.type==="begin"&&ee.type==="end"&&Gs.index===ee.index&&ce===""){if(Ce+=se.slice(ee.index,ee.index+1),!Te){const ye=new Error(`0 width match regex (${U})`);throw ye.languageName=U,ye.badRule=Gs.rule,ye}return 1}if(Gs=ee,ee.type==="begin")return Yl(ee);if(ee.type==="illegal"&&!fe){const ye=new Error('Illegal lexeme "'+ce+'" for mode "'+(le.scope||"")+'"');throw ye.mode=le,ye}else if(ee.type==="end"){const ye=Gl(ee);if(ye!==cn)return ye}if(ee.type==="illegal"&&ce==="")return Ce+=` -`,1;if(Pr>1e5&&Pr>ee.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ce+=ce,ce.length}const Ct=Ft(U);if(!Ct)throw Bt(Re.replace("{}",U)),new Error('Unknown language: "'+U+'"');const Zl=Rl(Ct);let Dr="",le=we||Zl;const vn={},Xe=new G.__emitter(G);Jl();let Ce="",Js=0,es=0,Pr=0,Ar=!1;try{if(Ct.__emitTokens)Ct.__emitTokens(se,Xe);else{for(le.matcher.considerAll();;){Pr++,Ar?Ar=!1:le.matcher.considerAll(),le.matcher.lastIndex=es;const X=le.matcher.exec(se);if(!X)break;const ee=se.substring(es,X.index),ce=mn(ee,X);es=X.index+ce}mn(se.substring(es))}return Xe.finalize(),Dr=Xe.toHTML(),{language:U,value:Dr,relevance:Js,illegal:!1,_emitter:Xe,_top:le}}catch(X){if(X.message&&X.message.includes("Illegal"))return{language:U,value:Lr(se),illegal:!0,relevance:0,_illegalBy:{message:X.message,index:es,context:se.slice(es-100,es+100),mode:X.mode,resultSoFar:Dr},_emitter:Xe};if(Te)return{language:U,value:Lr(se),illegal:!1,relevance:0,errorRaised:X,_emitter:Xe,_top:le};throw X}}function Tr(U){const se={value:Lr(U),illegal:!1,relevance:0,_top:Q,_emitter:new G.__emitter(G)};return se._emitter.addText(U),se}function Rr(U,se){se=se||G.languages||Object.keys(W);const fe=Tr(U),we=se.filter(Ft).filter(fn).map(nt=>Ss(nt,U,!1));we.unshift(fe);const Oe=we.sort((nt,wt)=>{if(nt.relevance!==wt.relevance)return wt.relevance-nt.relevance;if(nt.language&&wt.language){if(Ft(nt.language).supersetOf===wt.language)return 1;if(Ft(wt.language).supersetOf===nt.language)return-1}return 0}),[yt,zt]=Oe,Ys=yt;return Ys.secondBest=zt,Ys}function Ol(U,se,fe){const we=se&&q[se]||fe;U.classList.add("hljs"),U.classList.add(`language-${we}`)}function Br(U){let se=null;const fe=$e(U);if(oe(fe))return;if(Xs("before:highlightElement",{el:U,language:fe}),U.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",U);return}if(U.children.length>0&&(G.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(U)),G.throwUnescapedHTML))throw new Pl("One of your code blocks includes unescaped HTML.",U.innerHTML);se=U;const we=se.textContent,Oe=fe?De(we,{language:fe,ignoreIllegals:!0}):Rr(we);U.innerHTML=Oe.value,U.dataset.highlighted="yes",Ol(U,fe,Oe.language),U.result={language:Oe.language,re:Oe.relevance,relevance:Oe.relevance},Oe.secondBest&&(U.secondBest={language:Oe.secondBest.language,relevance:Oe.secondBest.relevance}),Xs("after:highlightElement",{el:U,result:Oe,text:we})}function Il(U){G=ln(G,U)}const Wl=()=>{qs(),ds("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Hl(){qs(),ds("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let dn=!1;function qs(){function U(){qs()}if(document.readyState==="loading"){dn||window.addEventListener("DOMContentLoaded",U,!1),dn=!0;return}document.querySelectorAll(G.cssSelector).forEach(Br)}function $l(U,se){let fe=null;try{fe=se(S)}catch(we){if(Bt("Language definition for '{}' could not be registered.".replace("{}",U)),Te)Bt(we);else throw we;fe=Q}fe.name||(fe.name=U),W[U]=fe,fe.rawDefinition=se.bind(null,S),fe.aliases&&un(fe.aliases,{languageName:U})}function Fl(U){delete W[U];for(const se of Object.keys(q))q[se]===U&&delete q[se]}function zl(){return Object.keys(W)}function Ft(U){return U=(U||"").toLowerCase(),W[U]||W[q[U]]}function un(U,{languageName:se}){typeof U=="string"&&(U=[U]),U.forEach(fe=>{q[fe.toLowerCase()]=se})}function fn(U){const se=Ft(U);return se&&!se.disableAutodetect}function Ul(U){U["before:highlightBlock"]&&!U["before:highlightElement"]&&(U["before:highlightElement"]=se=>{U["before:highlightBlock"](Object.assign({block:se.el},se))}),U["after:highlightBlock"]&&!U["after:highlightElement"]&&(U["after:highlightElement"]=se=>{U["after:highlightBlock"](Object.assign({block:se.el},se))})}function Kl(U){Ul(U),ae.push(U)}function Vl(U){const se=ae.indexOf(U);se!==-1&&ae.splice(se,1)}function Xs(U,se){const fe=U;ae.forEach(function(we){we[fe]&&we[fe](se)})}function ql(U){return ds("10.7.0","highlightBlock will be removed entirely in v12.0"),ds("10.7.0","Please use highlightElement now."),Br(U)}Object.assign(S,{highlight:De,highlightAuto:Rr,highlightAll:qs,highlightElement:Br,highlightBlock:ql,configure:Il,initHighlighting:Wl,initHighlightingOnLoad:Hl,registerLanguage:$l,unregisterLanguage:Fl,listLanguages:zl,getLanguage:Ft,registerAliases:un,autoDetection:fn,inherit:ln,addPlugin:Kl,removePlugin:Vl}),S.debugMode=function(){Te=!1},S.safeMode=function(){Te=!0},S.versionString=Dl,S.regex={concat:y,lookahead:p,either:k,optional:m,anyNumberOfTimes:g};for(const U in qe)typeof qe[U]=="object"&&e(qe[U]);return Object.assign(S,qe),S},us=hn({});return us.newInstance=()=>hn({}),Fr=us,us.HighlightJS=us,us.default=us,Fr}var dd=hd();const Oa=rc(dd);function ud(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,s,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}Oa.registerLanguage("json",ud);const fs=100;function ps(e){return e!==null&&typeof e=="object"}function fd(e){if(Array.isArray(e))return`Array(${e.length})`;const t=Object.keys(e);return t.length<=3?`{${t.join(", ")}}`:`{${t.slice(0,3).join(", ")}, …} (${t.length} keys)`}function pd({value:e,onClose:t}){const s=x.useRef(null),r=x.useMemo(()=>JSON.stringify(e,null,2),[e]),i=x.useMemo(()=>Oa.highlight(r,{language:"json"}).value,[r]);return x.useEffect(()=>{const o=a=>{a.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),ic.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:o=>{o.target===o.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg shadow-xl flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",maxHeight:"80vh"},children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Array.isArray(e)?`Array (${e.length} items)`:`Object (${Object.keys(e).length} keys)`}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-auto chat-markdown",children:n.jsx("pre",{className:"m-0 p-4",style:{background:"transparent"},children:n.jsx("code",{ref:s,className:"hljs language-json text-[13px] leading-relaxed",style:{background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-all"},dangerouslySetInnerHTML:{__html:i}})})})]})}),document.body)}function _d({value:e}){const[t,s]=x.useState(!1),r=fd(e);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>s(!0),className:"text-left text-[12px] cursor-pointer flex items-center gap-1 max-w-[300px]",style:{background:"none",border:"none",padding:0,color:"var(--accent)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate",style:{color:"var(--text-secondary)"},children:r})]}),t&&n.jsx(pd,{value:e,onClose:()=>s(!1)})]})}function gd({table:e}){return n.jsx(md,{table:e})}function md({table:e}){const[t,s]=x.useState([]),[r,i]=x.useState([]),[o,a]=x.useState(0),[l,h]=x.useState(0),[c,u]=x.useState(!0),[d,p]=x.useState(null),[g,m]=x.useState(""),[y,w]=x.useState(!1),k=x.useCallback(L=>{u(!0),p(null),w(!1),sd(e,fs,L).then(B=>{s(B.columns),i(B.rows),a(B.total),h(L)}).catch(B=>p(B.detail||B.message)).finally(()=>u(!1))},[e]);x.useEffect(()=>{k(0),m("")},[e,k]);const C=x.useCallback(()=>{g.trim()&&(u(!0),p(null),w(!0),rd(g).then(L=>{s(L.columns),i(L.rows),a(L.row_count),h(0)}).catch(L=>p(L.detail||L.message)).finally(()=>u(!1)))},[g]),A=L=>{L.key==="Enter"&&(L.ctrlKey||L.metaKey)&&(L.preventDefault(),C())},O=!y&&l>0,P=!y&&l+fsm(L.target.value),onKeyDown:A,placeholder:`SELECT * FROM [${e}] WHERE ...`,className:"flex-1 text-[13px] px-3 py-1.5 rounded",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)",outline:"none"}}),n.jsx("button",{onClick:C,disabled:!g.trim(),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:g.trim()?"var(--accent)":"var(--bg-hover)",color:g.trim()?"#fff":"var(--text-muted)",border:"none"},children:"Run"}),y&&n.jsx("button",{onClick:()=>k(0),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Reset"})]}),d&&n.jsx("div",{className:"px-4 py-2 text-[12px] shrink-0",style:{background:"rgba(239,68,68,0.1)",color:"#ef4444"},children:d}),n.jsx("div",{className:"flex-1 overflow-auto",children:c?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"Loading..."}):r.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"No rows"}):n.jsxs("table",{className:"w-full text-[12px]",style:{borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(L=>n.jsxs("th",{className:"text-left px-3 py-2 whitespace-nowrap sticky top-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)",color:"var(--text-primary)",fontWeight:600},children:[L.name,n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)",fontSize:"10px"},children:L.type})]},L.name))})}),n.jsx("tbody",{children:r.map((L,B)=>n.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},onMouseEnter:I=>{I.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:L.map((I,M)=>n.jsx("td",{className:"px-3 py-1.5",style:{color:I==null?"var(--text-muted)":"var(--text-secondary)",maxWidth:ps(I)?void 0:"300px",overflow:ps(I)?void 0:"hidden",textOverflow:ps(I)?void 0:"ellipsis",whiteSpace:ps(I)?void 0:"nowrap",verticalAlign:"top"},title:I!=null&&!ps(I)?String(I):void 0,children:I==null?n.jsx("span",{style:{fontStyle:"italic"},children:"NULL"}):ps(I)?n.jsx(_d,{value:I}):String(I)},M))},B))})]})}),(O||P)&&!c&&n.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 shrink-0 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>k(l-fs),disabled:!O,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:O?"var(--text-secondary)":"var(--text-muted)",opacity:O?1:.5},children:"Previous"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:["Page ",j," of ",D]}),n.jsx("button",{onClick:()=>k(l+fs),disabled:!P,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:P?"var(--text-secondary)":"var(--text-muted)",opacity:P?1:.5},children:"Next"})]})]})}const lr="__canvas__",ns="__statedb__:";function ro(e){return e===lr?"#/explorer/canvas":e.startsWith(ns)?`#/explorer/statedb/${encodeURIComponent(e.slice(ns.length))}`:`#/explorer/file/${encodeURIComponent(e)}`}const io=e=>{e.editor.defineTheme("uipath-dark",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"64748b",fontStyle:"italic"},{token:"keyword",foreground:"c084fc"},{token:"string",foreground:"86efac"},{token:"number",foreground:"fcd34d"},{token:"type",foreground:"7dd3fc"}],colors:{"editor.background":"#0f172a","editor.foreground":"#cbd5e1","editor.lineHighlightBackground":"#1e293b","editor.selectionBackground":"#334155","editor.inactiveSelectionBackground":"#263348","editorLineNumber.foreground":"#64748b","editorLineNumber.activeForeground":"#94a3b8","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#334155","editorIndentGuide.activeBackground":"#64748b","editorWidget.background":"#1e293b","editorWidget.border":"#334155","editorSuggestWidget.background":"#1e293b","editorSuggestWidget.border":"#334155","editorSuggestWidget.selectedBackground":"#263348","editorHoverWidget.background":"#1e293b","editorHoverWidget.border":"#334155","scrollbarSlider.background":"#33415580","scrollbarSlider.hoverBackground":"#33415599","scrollbarSlider.activeBackground":"#334155cc"}}),e.editor.defineTheme("uipath-light",{base:"vs",inherit:!0,rules:[{token:"comment",foreground:"94a3b8",fontStyle:"italic"},{token:"keyword",foreground:"7c3aed"},{token:"string",foreground:"16a34a"},{token:"number",foreground:"d97706"},{token:"type",foreground:"0284c7"}],colors:{"editor.background":"#f8fafc","editor.foreground":"#0f172a","editor.lineHighlightBackground":"#f1f5f9","editor.selectionBackground":"#e2e8f0","editor.inactiveSelectionBackground":"#f1f5f9","editorLineNumber.foreground":"#94a3b8","editorLineNumber.activeForeground":"#475569","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#e2e8f0","editorIndentGuide.activeBackground":"#94a3b8","editorWidget.background":"#ffffff","editorWidget.border":"#e2e8f0","editorSuggestWidget.background":"#ffffff","editorSuggestWidget.border":"#e2e8f0","editorSuggestWidget.selectedBackground":"#f1f5f9","editorHoverWidget.background":"#ffffff","editorHoverWidget.border":"#e2e8f0","scrollbarSlider.background":"#d1d5db80","scrollbarSlider.hoverBackground":"#d1d5db99","scrollbarSlider.activeBackground":"#d1d5dbcc"}})};function no(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vd(e){const t=e.replace(/\\/g,"/").split("/");return t[t.length-1]||e}function xd(){const e=xe(_=>_.openTabs),s=xe(_=>_.selectedFile),r=xe(_=>s?_.fileCache[s]:void 0),i=xe(_=>s?!!_.dirty[s]:!1),o=xe(_=>s?_.buffers[s]:void 0),a=xe(_=>_.loadingFile),l=xe(_=>_.dirty),h=xe(_=>_.diffView),c=xe(_=>s?!!_.agentChangedFiles[s]:!1),{setFileContent:u,updateBuffer:d,markClean:p,setLoadingFile:g,openTab:m,closeTab:y,setDiffView:w}=xe(),{navigate:k}=et(),C=xa(_=>_.theme),A=x.useRef(null),{explorerFile:O}=et();x.useEffect(()=>{O&&m(O)},[O,m]),x.useEffect(()=>{!s||s===lr||s.startsWith(ns)||xe.getState().fileCache[s]||(g(!0),pa(s).then(_=>u(s,_)).catch(console.error).finally(()=>g(!1)))},[s,u,g]);const P=x.useCallback(()=>{if(!s)return;const _=xe.getState().fileCache[s],v=xe.getState().buffers[s]??(_==null?void 0:_.content);v!=null&&Nc(s,v).then(()=>{p(s),u(s,{..._,content:v})}).catch(console.error)},[s,p,u]);x.useEffect(()=>{const _=f=>{(f.ctrlKey||f.metaKey)&&f.key==="s"&&(f.preventDefault(),P())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[P]);const j=_=>{A.current=_},D=x.useCallback(_=>{_!==void 0&&s&&d(s,_)},[s,d]),L=x.useCallback(_=>{m(_),k(ro(_))},[m,k]),B=x.useCallback((_,f)=>{_.stopPropagation();const v=xe.getState(),b=v.openTabs.filter(E=>E!==f);if(y(f),v.selectedFile===f){const E=v.openTabs.indexOf(f),N=b[Math.min(E,b.length-1)];k(N?ro(N):"#/explorer")}},[y,k]),I=x.useCallback((_,f)=>{_.button===1&&B(_,f)},[B]),M=e.length>0&&n.jsx("div",{className:"h-10 flex items-end overflow-x-auto shrink-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},children:e.map(_=>{const f=_===s,v=!!l[_];return n.jsxs("button",{onClick:()=>L(_),onMouseDown:b=>I(b,_),className:"h-full flex items-center gap-1.5 px-3 text-[12px] shrink-0 cursor-pointer transition-colors relative",style:{background:f?"var(--bg-primary)":"transparent",color:f?"var(--text-primary)":"var(--text-secondary)",border:"none",borderBottom:f?"2px solid var(--accent)":"2px solid transparent",maxWidth:"180px"},onMouseEnter:b=>{f||(b.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:b=>{f||(b.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"truncate",children:_===lr?"Visualization":_.startsWith(ns)?`db:${_.slice(ns.length)}`:vd(_)}),v?n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"},title:"Unsaved changes"}):n.jsx("span",{className:"w-4 h-4 flex items-center justify-center rounded shrink-0 transition-colors",style:{color:"var(--text-muted)"},onClick:b=>B(b,_),onMouseEnter:b=>{b.currentTarget.style.background="var(--bg-hover)",b.currentTarget.style.color="var(--text-primary)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent",b.currentTarget.style.color="var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:n.jsx("path",{d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.708.708L7.293 8l-3.647 3.646.708.708L8 8.707z"})})})]},_)})});if(s===lr)return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(cd,{})})]});if(s!=null&&s.startsWith(ns)){const _=s.slice(ns.length);return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(gd,{table:_})})]})}if(!s)return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a file to view"})]});if(a&&!r)return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Loading file..."})})]});if(!r&&!a)return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Failed to load file"})})]});if(!r)return null;if(r.binary)return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsx("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)})}),n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),n.jsx("span",{className:"text-sm",children:"Binary file — preview not available"})]})]});const R=h&&h.path===s;return n.jsxs("div",{className:"flex flex-col h-full",children:[M,n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[r.language&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--bg-hover)",color:"var(--text-muted)"},children:r.language}),n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)}),c&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium",style:{background:"color-mix(in srgb, var(--info) 20%, transparent)",color:"var(--info)"},children:"Agent modified"}),n.jsx("div",{className:"flex-1"}),i&&n.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--accent)"},children:"Modified"}),n.jsx("button",{onClick:P,className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:i?"var(--accent)":"var(--bg-hover)",color:i?"white":"var(--text-muted)",border:"none"},children:"Save"})]}),R&&n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--info) 10%, var(--bg-secondary))"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--info)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),n.jsx("span",{style:{color:"var(--info)"},children:"Agent modified this file"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>w(null),className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Dismiss"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:R?n.jsx(nc,{original:h.original,modified:h.modified,language:h.language??"plaintext",theme:C==="dark"?"uipath-dark":"uipath-light",beforeMount:io,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,automaticLayout:!0,renderSideBySide:!0}},`diff-${s}`):n.jsx(oc,{language:r.language??"plaintext",theme:C==="dark"?"uipath-dark":"uipath-light",value:o??r.content??"",onChange:D,beforeMount:io,onMount:j,options:{minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2,renderWhitespace:"selection"}},s)})]})}/** + `}),e.length>1&&n.jsx("div",{style:{position:"absolute",top:8,left:8,zIndex:10},children:n.jsx("select",{value:s??"",onChange:N=>r(N.target.value),style:{background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--node-border)",borderRadius:6,padding:"4px 8px",fontSize:12},children:e.map(N=>n.jsx("option",{value:N,children:N},N))})}),n.jsxs(oa,{nodes:i,edges:l,onNodesChange:a,onEdgesChange:c,nodeTypes:ld,edgeTypes:cd,onInit:N=>{w.current=N},fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(ca,{nodeColor:N=>{var B;if(N.type==="groupNode")return"var(--bg-tertiary)";const $=(B=N.data)==null?void 0:B.status;return $==="completed"?"var(--success)":$==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}var Fr,so;function dd(){if(so)return Fr;so=1;function e(S){return S instanceof Map?S.clear=S.delete=S.set=function(){throw new Error("map is read-only")}:S instanceof Set&&(S.add=S.clear=S.delete=function(){throw new Error("set is read-only")}),Object.freeze(S),Object.getOwnPropertyNames(S).forEach(I=>{const X=S[I],ae=typeof X;(ae==="object"||ae==="function")&&!Object.isFrozen(X)&&e(X)}),S}class t{constructor(I){I.data===void 0&&(I.data={}),this.data=I.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(S){return S.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(S,...I){const X=Object.create(null);for(const ae in S)X[ae]=S[ae];return I.forEach(function(ae){for(const Te in ae)X[Te]=ae[Te]}),X}const i="",o=S=>!!S.scope,a=(S,{prefix:I})=>{if(S.startsWith("language:"))return S.replace("language:","language-");if(S.includes(".")){const X=S.split(".");return[`${I}${X.shift()}`,...X.map((ae,Te)=>`${ae}${"_".repeat(Te+1)}`)].join(" ")}return`${I}${S}`};class l{constructor(I,X){this.buffer="",this.classPrefix=X.classPrefix,I.walk(this)}addText(I){this.buffer+=s(I)}openNode(I){if(!o(I))return;const X=a(I.scope,{prefix:this.classPrefix});this.span(X)}closeNode(I){o(I)&&(this.buffer+=i)}value(){return this.buffer}span(I){this.buffer+=``}}const h=(S={})=>{const I={children:[]};return Object.assign(I,S),I};class c{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(I){this.top.children.push(I)}openNode(I){const X=h({scope:I});this.add(X),this.stack.push(X)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(I){return this.constructor._walk(I,this.rootNode)}static _walk(I,X){return typeof X=="string"?I.addText(X):X.children&&(I.openNode(X),X.children.forEach(ae=>this._walk(I,ae)),I.closeNode(X)),I}static _collapse(I){typeof I!="string"&&I.children&&(I.children.every(X=>typeof X=="string")?I.children=[I.children.join("")]:I.children.forEach(X=>{c._collapse(X)}))}}class u extends c{constructor(I){super(),this.options=I}addText(I){I!==""&&this.add(I)}startScope(I){this.openNode(I)}endScope(){this.closeNode()}__addSublanguage(I,X){const ae=I.root;X&&(ae.scope=`language:${X}`),this.add(ae)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(S){return S?typeof S=="string"?S:S.source:null}function _(S){return x("(?=",S,")")}function g(S){return x("(?:",S,")*")}function m(S){return x("(?:",S,")?")}function x(...S){return S.map(X=>d(X)).join("")}function w(S){const I=S[S.length-1];return typeof I=="object"&&I.constructor===Object?(S.splice(S.length-1,1),I):{}}function E(...S){return"("+(w(S).capture?"":"?:")+S.map(ae=>d(ae)).join("|")+")"}function k(S){return new RegExp(S.toString()+"|").exec("").length-1}function P(S,I){const X=S&&S.exec(I);return X&&X.index===0}const A=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function D(S,{joinWith:I}){let X=0;return S.map(ae=>{X+=1;const Te=X;let Re=d(ae),Q="";for(;Re.length>0;){const J=A.exec(Re);if(!J){Q+=Re;break}Q+=Re.substring(0,J.index),Re=Re.substring(J.index+J[0].length),J[0][0]==="\\"&&J[1]?Q+="\\"+String(Number(J[1])+Te):(Q+=J[0],J[0]==="("&&X++)}return Q}).map(ae=>`(${ae})`).join(I)}const N=/\b\B/,$="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",O="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",L="\\b(0b[01]+)",R="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",p=(S={})=>{const I=/^#![ ]*\//;return S.binary&&(S.begin=x(I,/.*\b/,S.binary,/\b.*/)),r({scope:"meta",begin:I,end:/$/,relevance:0,"on:begin":(X,ae)=>{X.index!==0&&ae.ignoreMatch()}},S)},f={begin:"\\\\[\\s\\S]",relevance:0},b={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[f]},y={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[f]},j={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},M=function(S,I,X={}){const ae=r({scope:"comment",begin:S,end:I,contains:[]},X);ae.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Te=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ae.contains.push({begin:x(/[ ]+/,"(",Te,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ae},z=M("//","$"),C=M("/\\*","\\*/"),H=M("#","$"),U={scope:"number",begin:T,relevance:0},q={scope:"number",begin:O,relevance:0},ee={scope:"number",begin:L,relevance:0},ie={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[f,{begin:/\[/,end:/\]/,relevance:0,contains:[f]}]},F={scope:"title",begin:$,relevance:0},se={scope:"title",begin:B,relevance:0},pe={begin:"\\.\\s*"+B,relevance:0};var qe=Object.freeze({__proto__:null,APOS_STRING_MODE:b,BACKSLASH_ESCAPE:f,BINARY_NUMBER_MODE:ee,BINARY_NUMBER_RE:L,COMMENT:M,C_BLOCK_COMMENT_MODE:C,C_LINE_COMMENT_MODE:z,C_NUMBER_MODE:q,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(S){return Object.assign(S,{"on:begin":(I,X)=>{X.data._beginMatch=I[1]},"on:end":(I,X)=>{X.data._beginMatch!==I[1]&&X.ignoreMatch()}})},HASH_COMMENT_MODE:H,IDENT_RE:$,MATCH_NOTHING_RE:N,METHOD_GUARD:pe,NUMBER_MODE:U,NUMBER_RE:T,PHRASAL_WORDS_MODE:j,QUOTE_STRING_MODE:y,REGEXP_MODE:ie,RE_STARTERS_RE:R,SHEBANG:p,TITLE_MODE:F,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:se});function St(S,I){S.input[S.index-1]==="."&&I.ignoreMatch()}function ht(S,I){S.className!==void 0&&(S.scope=S.className,delete S.className)}function ge(S,I){I&&S.beginKeywords&&(S.begin="\\b("+S.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",S.__beforeBegin=St,S.keywords=S.keywords||S.beginKeywords,delete S.beginKeywords,S.relevance===void 0&&(S.relevance=0))}function $t(S,I){Array.isArray(S.illegal)&&(S.illegal=E(...S.illegal))}function Z(S,I){if(S.match){if(S.begin||S.end)throw new Error("begin & end are not supported with match");S.begin=S.match,delete S.match}}function me(S,I){S.relevance===void 0&&(S.relevance=1)}const dt=(S,I)=>{if(!S.beforeMatch)return;if(S.starts)throw new Error("beforeMatch cannot be used with starts");const X=Object.assign({},S);Object.keys(S).forEach(ae=>{delete S[ae]}),S.keywords=X.keywords,S.begin=x(X.beforeMatch,_(X.begin)),S.starts={relevance:0,contains:[Object.assign(X,{endsParent:!0})]},S.relevance=0,delete X.beforeMatch},ve=["of","and","for","in","not","or","if","then","parent","list","value"],vt="keyword";function xt(S,I,X=vt){const ae=Object.create(null);return typeof S=="string"?Te(X,S.split(" ")):Array.isArray(S)?Te(X,S):Object.keys(S).forEach(function(Re){Object.assign(ae,xt(S[Re],I,Re))}),ae;function Te(Re,Q){I&&(Q=Q.map(J=>J.toLowerCase())),Q.forEach(function(J){const oe=J.split("|");ae[oe[0]]=[Re,ot(oe[0],oe[1])]})}}function ot(S,I){return I?Number(I):ut(S)?0:1}function ut(S){return ve.includes(S.toLowerCase())}const Ks={},Bt=S=>{console.error(S)},nn=(S,...I)=>{console.log(`WARN: ${S}`,...I)},ds=(S,I)=>{Ks[`${S}/${I}`]||(console.log(`Deprecated as of ${S}. ${I}`),Ks[`${S}/${I}`]=!0)},Vs=new Error;function on(S,I,{key:X}){let ae=0;const Te=S[X],Re={},Q={};for(let J=1;J<=I.length;J++)Q[J+ae]=Te[J],Re[J+ae]=!0,ae+=k(I[J-1]);S[X]=Q,S[X]._emit=Re,S[X]._multi=!0}function Ml(S){if(Array.isArray(S.begin)){if(S.skip||S.excludeBegin||S.returnBegin)throw Bt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Vs;if(typeof S.beginScope!="object"||S.beginScope===null)throw Bt("beginScope must be object"),Vs;on(S,S.begin,{key:"beginScope"}),S.begin=D(S.begin,{joinWith:""})}}function Ll(S){if(Array.isArray(S.end)){if(S.skip||S.excludeEnd||S.returnEnd)throw Bt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Vs;if(typeof S.endScope!="object"||S.endScope===null)throw Bt("endScope must be object"),Vs;on(S,S.end,{key:"endScope"}),S.end=D(S.end,{joinWith:""})}}function Tl(S){S.scope&&typeof S.scope=="object"&&S.scope!==null&&(S.beginScope=S.scope,delete S.scope)}function Rl(S){Tl(S),typeof S.beginScope=="string"&&(S.beginScope={_wrap:S.beginScope}),typeof S.endScope=="string"&&(S.endScope={_wrap:S.endScope}),Ml(S),Ll(S)}function Bl(S){function I(Q,J){return new RegExp(d(Q),"m"+(S.case_insensitive?"i":"")+(S.unicodeRegex?"u":"")+(J?"g":""))}class X{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(J,oe){oe.position=this.position++,this.matchIndexes[this.matchAt]=oe,this.regexes.push([oe,J]),this.matchAt+=k(J)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const J=this.regexes.map(oe=>oe[1]);this.matcherRe=I(D(J,{joinWith:"|"}),!0),this.lastIndex=0}exec(J){this.matcherRe.lastIndex=this.lastIndex;const oe=this.matcherRe.exec(J);if(!oe)return null;const $e=oe.findIndex((Ss,Tr)=>Tr>0&&Ss!==void 0),De=this.matchIndexes[$e];return oe.splice(0,$e),Object.assign(oe,De)}}class ae{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(J){if(this.multiRegexes[J])return this.multiRegexes[J];const oe=new X;return this.rules.slice(J).forEach(([$e,De])=>oe.addRule($e,De)),oe.compile(),this.multiRegexes[J]=oe,oe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(J,oe){this.rules.push([J,oe]),oe.type==="begin"&&this.count++}exec(J){const oe=this.getMatcher(this.regexIndex);oe.lastIndex=this.lastIndex;let $e=oe.exec(J);if(this.resumingScanAtSamePosition()&&!($e&&$e.index===this.lastIndex)){const De=this.getMatcher(0);De.lastIndex=this.lastIndex+1,$e=De.exec(J)}return $e&&(this.regexIndex+=$e.position+1,this.regexIndex===this.count&&this.considerAll()),$e}}function Te(Q){const J=new ae;return Q.contains.forEach(oe=>J.addRule(oe.begin,{rule:oe,type:"begin"})),Q.terminatorEnd&&J.addRule(Q.terminatorEnd,{type:"end"}),Q.illegal&&J.addRule(Q.illegal,{type:"illegal"}),J}function Re(Q,J){const oe=Q;if(Q.isCompiled)return oe;[ht,Z,Rl,dt].forEach(De=>De(Q,J)),S.compilerExtensions.forEach(De=>De(Q,J)),Q.__beforeBegin=null,[ge,$t,me].forEach(De=>De(Q,J)),Q.isCompiled=!0;let $e=null;return typeof Q.keywords=="object"&&Q.keywords.$pattern&&(Q.keywords=Object.assign({},Q.keywords),$e=Q.keywords.$pattern,delete Q.keywords.$pattern),$e=$e||/\w+/,Q.keywords&&(Q.keywords=xt(Q.keywords,S.case_insensitive)),oe.keywordPatternRe=I($e,!0),J&&(Q.begin||(Q.begin=/\B|\b/),oe.beginRe=I(oe.begin),!Q.end&&!Q.endsWithParent&&(Q.end=/\B|\b/),Q.end&&(oe.endRe=I(oe.end)),oe.terminatorEnd=d(oe.end)||"",Q.endsWithParent&&J.terminatorEnd&&(oe.terminatorEnd+=(Q.end?"|":"")+J.terminatorEnd)),Q.illegal&&(oe.illegalRe=I(Q.illegal)),Q.contains||(Q.contains=[]),Q.contains=[].concat(...Q.contains.map(function(De){return Dl(De==="self"?Q:De)})),Q.contains.forEach(function(De){Re(De,oe)}),Q.starts&&Re(Q.starts,J),oe.matcher=Te(oe),oe}if(S.compilerExtensions||(S.compilerExtensions=[]),S.contains&&S.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return S.classNameAliases=r(S.classNameAliases||{}),Re(S)}function an(S){return S?S.endsWithParent||an(S.starts):!1}function Dl(S){return S.variants&&!S.cachedVariants&&(S.cachedVariants=S.variants.map(function(I){return r(S,{variants:null},I)})),S.cachedVariants?S.cachedVariants:an(S)?r(S,{starts:S.starts?r(S.starts):null}):Object.isFrozen(S)?r(S):S}var Pl="11.11.1";class Al extends Error{constructor(I,X){super(I),this.name="HTMLInjectionError",this.html=X}}const Lr=s,ln=r,cn=Symbol("nomatch"),Ol=7,hn=function(S){const I=Object.create(null),X=Object.create(null),ae=[];let Te=!0;const Re="Could not find the language '{}', did you forget to load/include a language module?",Q={disableAutodetect:!0,name:"Plain text",contains:[]};let J={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function oe(K){return J.noHighlightRe.test(K)}function $e(K){let re=K.className+" ";re+=K.parentNode?K.parentNode.className:"";const fe=J.languageDetectRe.exec(re);if(fe){const we=Ft(fe[1]);return we||(nn(Re.replace("{}",fe[1])),nn("Falling back to no-highlight mode for this block.",K)),we?fe[1]:"no-highlight"}return re.split(/\s+/).find(we=>oe(we)||Ft(we))}function De(K,re,fe){let we="",Oe="";typeof re=="object"?(we=K,fe=re.ignoreIllegals,Oe=re.language):(ds("10.7.0","highlight(lang, code, ...args) has been deprecated."),ds("10.7.0",`Please use highlight(code, options) instead. +https://github.com/highlightjs/highlight.js/issues/2277`),Oe=K,we=re),fe===void 0&&(fe=!0);const yt={code:we,language:Oe};Xs("before:highlight",yt);const zt=yt.result?yt.result:Ss(yt.language,yt.code,fe);return zt.code=yt.code,Xs("after:highlight",zt),zt}function Ss(K,re,fe,we){const Oe=Object.create(null);function yt(Y,te){return Y.keywords[te]}function zt(){if(!le.keywords){Xe.addText(Ce);return}let Y=0;le.keywordPatternRe.lastIndex=0;let te=le.keywordPatternRe.exec(Ce),ce="";for(;te;){ce+=Ce.substring(Y,te.index);const be=Ct.case_insensitive?te[0].toLowerCase():te[0],Je=yt(le,be);if(Je){const[Dt,ec]=Je;if(Xe.addText(ce),ce="",Oe[be]=(Oe[be]||0)+1,Oe[be]<=Ol&&(Js+=ec),Dt.startsWith("_"))ce+=te[0];else{const tc=Ct.classNameAliases[Dt]||Dt;wt(te[0],tc)}}else ce+=te[0];Y=le.keywordPatternRe.lastIndex,te=le.keywordPatternRe.exec(Ce)}ce+=Ce.substring(Y),Xe.addText(ce)}function Ys(){if(Ce==="")return;let Y=null;if(typeof le.subLanguage=="string"){if(!I[le.subLanguage]){Xe.addText(Ce);return}Y=Ss(le.subLanguage,Ce,!0,vn[le.subLanguage]),vn[le.subLanguage]=Y._top}else Y=Rr(Ce,le.subLanguage.length?le.subLanguage:null);le.relevance>0&&(Js+=Y.relevance),Xe.__addSublanguage(Y._emitter,Y.language)}function at(){le.subLanguage!=null?Ys():zt(),Ce=""}function wt(Y,te){Y!==""&&(Xe.startScope(te),Xe.addText(Y),Xe.endScope())}function pn(Y,te){let ce=1;const be=te.length-1;for(;ce<=be;){if(!Y._emit[ce]){ce++;continue}const Je=Ct.classNameAliases[Y[ce]]||Y[ce],Dt=te[ce];Je?wt(Dt,Je):(Ce=Dt,zt(),Ce=""),ce++}}function _n(Y,te){return Y.scope&&typeof Y.scope=="string"&&Xe.openNode(Ct.classNameAliases[Y.scope]||Y.scope),Y.beginScope&&(Y.beginScope._wrap?(wt(Ce,Ct.classNameAliases[Y.beginScope._wrap]||Y.beginScope._wrap),Ce=""):Y.beginScope._multi&&(pn(Y.beginScope,te),Ce="")),le=Object.create(Y,{parent:{value:le}}),le}function gn(Y,te,ce){let be=P(Y.endRe,ce);if(be){if(Y["on:end"]){const Je=new t(Y);Y["on:end"](te,Je),Je.isMatchIgnored&&(be=!1)}if(be){for(;Y.endsParent&&Y.parent;)Y=Y.parent;return Y}}if(Y.endsWithParent)return gn(Y.parent,te,ce)}function Yl(Y){return le.matcher.regexIndex===0?(Ce+=Y[0],1):(Ar=!0,0)}function Gl(Y){const te=Y[0],ce=Y.rule,be=new t(ce),Je=[ce.__beforeBegin,ce["on:begin"]];for(const Dt of Je)if(Dt&&(Dt(Y,be),be.isMatchIgnored))return Yl(te);return ce.skip?Ce+=te:(ce.excludeBegin&&(Ce+=te),at(),!ce.returnBegin&&!ce.excludeBegin&&(Ce=te)),_n(ce,Y),ce.returnBegin?0:te.length}function Jl(Y){const te=Y[0],ce=re.substring(Y.index),be=gn(le,Y,ce);if(!be)return cn;const Je=le;le.endScope&&le.endScope._wrap?(at(),wt(te,le.endScope._wrap)):le.endScope&&le.endScope._multi?(at(),pn(le.endScope,Y)):Je.skip?Ce+=te:(Je.returnEnd||Je.excludeEnd||(Ce+=te),at(),Je.excludeEnd&&(Ce=te));do le.scope&&Xe.closeNode(),!le.skip&&!le.subLanguage&&(Js+=le.relevance),le=le.parent;while(le!==be.parent);return be.starts&&_n(be.starts,Y),Je.returnEnd?0:te.length}function Zl(){const Y=[];for(let te=le;te!==Ct;te=te.parent)te.scope&&Y.unshift(te.scope);Y.forEach(te=>Xe.openNode(te))}let Gs={};function mn(Y,te){const ce=te&&te[0];if(Ce+=Y,ce==null)return at(),0;if(Gs.type==="begin"&&te.type==="end"&&Gs.index===te.index&&ce===""){if(Ce+=re.slice(te.index,te.index+1),!Te){const be=new Error(`0 width match regex (${K})`);throw be.languageName=K,be.badRule=Gs.rule,be}return 1}if(Gs=te,te.type==="begin")return Gl(te);if(te.type==="illegal"&&!fe){const be=new Error('Illegal lexeme "'+ce+'" for mode "'+(le.scope||"")+'"');throw be.mode=le,be}else if(te.type==="end"){const be=Jl(te);if(be!==cn)return be}if(te.type==="illegal"&&ce==="")return Ce+=` +`,1;if(Pr>1e5&&Pr>te.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ce+=ce,ce.length}const Ct=Ft(K);if(!Ct)throw Bt(Re.replace("{}",K)),new Error('Unknown language: "'+K+'"');const Ql=Bl(Ct);let Dr="",le=we||Ql;const vn={},Xe=new J.__emitter(J);Zl();let Ce="",Js=0,es=0,Pr=0,Ar=!1;try{if(Ct.__emitTokens)Ct.__emitTokens(re,Xe);else{for(le.matcher.considerAll();;){Pr++,Ar?Ar=!1:le.matcher.considerAll(),le.matcher.lastIndex=es;const Y=le.matcher.exec(re);if(!Y)break;const te=re.substring(es,Y.index),ce=mn(te,Y);es=Y.index+ce}mn(re.substring(es))}return Xe.finalize(),Dr=Xe.toHTML(),{language:K,value:Dr,relevance:Js,illegal:!1,_emitter:Xe,_top:le}}catch(Y){if(Y.message&&Y.message.includes("Illegal"))return{language:K,value:Lr(re),illegal:!0,relevance:0,_illegalBy:{message:Y.message,index:es,context:re.slice(es-100,es+100),mode:Y.mode,resultSoFar:Dr},_emitter:Xe};if(Te)return{language:K,value:Lr(re),illegal:!1,relevance:0,errorRaised:Y,_emitter:Xe,_top:le};throw Y}}function Tr(K){const re={value:Lr(K),illegal:!1,relevance:0,_top:Q,_emitter:new J.__emitter(J)};return re._emitter.addText(K),re}function Rr(K,re){re=re||J.languages||Object.keys(I);const fe=Tr(K),we=re.filter(Ft).filter(fn).map(at=>Ss(at,K,!1));we.unshift(fe);const Oe=we.sort((at,wt)=>{if(at.relevance!==wt.relevance)return wt.relevance-at.relevance;if(at.language&&wt.language){if(Ft(at.language).supersetOf===wt.language)return 1;if(Ft(wt.language).supersetOf===at.language)return-1}return 0}),[yt,zt]=Oe,Ys=yt;return Ys.secondBest=zt,Ys}function Il(K,re,fe){const we=re&&X[re]||fe;K.classList.add("hljs"),K.classList.add(`language-${we}`)}function Br(K){let re=null;const fe=$e(K);if(oe(fe))return;if(Xs("before:highlightElement",{el:K,language:fe}),K.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",K);return}if(K.children.length>0&&(J.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(K)),J.throwUnescapedHTML))throw new Al("One of your code blocks includes unescaped HTML.",K.innerHTML);re=K;const we=re.textContent,Oe=fe?De(we,{language:fe,ignoreIllegals:!0}):Rr(we);K.innerHTML=Oe.value,K.dataset.highlighted="yes",Il(K,fe,Oe.language),K.result={language:Oe.language,re:Oe.relevance,relevance:Oe.relevance},Oe.secondBest&&(K.secondBest={language:Oe.secondBest.language,relevance:Oe.secondBest.relevance}),Xs("after:highlightElement",{el:K,result:Oe,text:we})}function Wl(K){J=ln(J,K)}const Hl=()=>{qs(),ds("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $l(){qs(),ds("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let dn=!1;function qs(){function K(){qs()}if(document.readyState==="loading"){dn||window.addEventListener("DOMContentLoaded",K,!1),dn=!0;return}document.querySelectorAll(J.cssSelector).forEach(Br)}function Fl(K,re){let fe=null;try{fe=re(S)}catch(we){if(Bt("Language definition for '{}' could not be registered.".replace("{}",K)),Te)Bt(we);else throw we;fe=Q}fe.name||(fe.name=K),I[K]=fe,fe.rawDefinition=re.bind(null,S),fe.aliases&&un(fe.aliases,{languageName:K})}function zl(K){delete I[K];for(const re of Object.keys(X))X[re]===K&&delete X[re]}function Ul(){return Object.keys(I)}function Ft(K){return K=(K||"").toLowerCase(),I[K]||I[X[K]]}function un(K,{languageName:re}){typeof K=="string"&&(K=[K]),K.forEach(fe=>{X[fe.toLowerCase()]=re})}function fn(K){const re=Ft(K);return re&&!re.disableAutodetect}function Kl(K){K["before:highlightBlock"]&&!K["before:highlightElement"]&&(K["before:highlightElement"]=re=>{K["before:highlightBlock"](Object.assign({block:re.el},re))}),K["after:highlightBlock"]&&!K["after:highlightElement"]&&(K["after:highlightElement"]=re=>{K["after:highlightBlock"](Object.assign({block:re.el},re))})}function Vl(K){Kl(K),ae.push(K)}function ql(K){const re=ae.indexOf(K);re!==-1&&ae.splice(re,1)}function Xs(K,re){const fe=K;ae.forEach(function(we){we[fe]&&we[fe](re)})}function Xl(K){return ds("10.7.0","highlightBlock will be removed entirely in v12.0"),ds("10.7.0","Please use highlightElement now."),Br(K)}Object.assign(S,{highlight:De,highlightAuto:Rr,highlightAll:qs,highlightElement:Br,highlightBlock:Xl,configure:Wl,initHighlighting:Hl,initHighlightingOnLoad:$l,registerLanguage:Fl,unregisterLanguage:zl,listLanguages:Ul,getLanguage:Ft,registerAliases:un,autoDetection:fn,inherit:ln,addPlugin:Vl,removePlugin:ql}),S.debugMode=function(){Te=!1},S.safeMode=function(){Te=!0},S.versionString=Pl,S.regex={concat:x,lookahead:_,either:E,optional:m,anyNumberOfTimes:g};for(const K in qe)typeof qe[K]=="object"&&e(qe[K]);return Object.assign(S,qe),S},us=hn({});return us.newInstance=()=>hn({}),Fr=us,us.HighlightJS=us,us.default=us,Fr}var ud=dd();const Ia=ic(ud);function fd(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,s,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}Ia.registerLanguage("json",fd);const fs=100;function ps(e){return e!==null&&typeof e=="object"}function pd(e){if(Array.isArray(e))return`Array(${e.length})`;const t=Object.keys(e);return t.length<=3?`{${t.join(", ")}}`:`{${t.slice(0,3).join(", ")}, …} (${t.length} keys)`}function _d({value:e,onClose:t}){const s=v.useRef(null),r=v.useMemo(()=>JSON.stringify(e,null,2),[e]),i=v.useMemo(()=>Ia.highlight(r,{language:"json"}).value,[r]);return v.useEffect(()=>{const o=a=>{a.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),nc.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:o=>{o.target===o.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg shadow-xl flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",maxHeight:"80vh"},children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Array.isArray(e)?`Array (${e.length} items)`:`Object (${Object.keys(e).length} keys)`}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-auto chat-markdown",children:n.jsx("pre",{className:"m-0 p-4",style:{background:"transparent"},children:n.jsx("code",{ref:s,className:"hljs language-json text-[13px] leading-relaxed",style:{background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-all"},dangerouslySetInnerHTML:{__html:i}})})})]})}),document.body)}function gd({value:e}){const[t,s]=v.useState(!1),r=pd(e);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>s(!0),className:"text-left text-[12px] cursor-pointer flex items-center gap-1 max-w-[300px]",style:{background:"none",border:"none",padding:0,color:"var(--accent)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate",style:{color:"var(--text-secondary)"},children:r})]}),t&&n.jsx(_d,{value:e,onClose:()=>s(!1)})]})}function md({table:e}){return n.jsx(vd,{table:e})}function vd({table:e}){const[t,s]=v.useState([]),[r,i]=v.useState([]),[o,a]=v.useState(0),[l,h]=v.useState(0),[c,u]=v.useState(!0),[d,_]=v.useState(null),[g,m]=v.useState(""),[x,w]=v.useState(!1),E=v.useCallback(B=>{u(!0),_(null),w(!1),rd(e,fs,B).then(T=>{s(T.columns),i(T.rows),a(T.total),h(B)}).catch(T=>_(T.detail||T.message)).finally(()=>u(!1))},[e]);v.useEffect(()=>{E(0),m("")},[e,E]);const k=v.useCallback(()=>{g.trim()&&(u(!0),_(null),w(!0),id(g).then(B=>{s(B.columns),i(B.rows),a(B.row_count),h(0)}).catch(B=>_(B.detail||B.message)).finally(()=>u(!1)))},[g]),P=B=>{B.key==="Enter"&&(B.ctrlKey||B.metaKey)&&(B.preventDefault(),k())},A=!x&&l>0,D=!x&&l+fsm(B.target.value),onKeyDown:P,placeholder:`SELECT * FROM [${e}] WHERE ...`,className:"flex-1 text-[13px] px-3 py-1.5 rounded",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)",outline:"none"}}),n.jsx("button",{onClick:k,disabled:!g.trim(),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:g.trim()?"var(--accent)":"var(--bg-hover)",color:g.trim()?"#fff":"var(--text-muted)",border:"none"},children:"Run"}),x&&n.jsx("button",{onClick:()=>E(0),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Reset"})]}),d&&n.jsx("div",{className:"px-4 py-2 text-[12px] shrink-0",style:{background:"rgba(239,68,68,0.1)",color:"#ef4444"},children:d}),n.jsx("div",{className:"flex-1 overflow-auto",children:c?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"Loading..."}):r.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"No rows"}):n.jsxs("table",{className:"w-full text-[12px]",style:{borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(B=>n.jsxs("th",{className:"text-left px-3 py-2 whitespace-nowrap sticky top-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)",color:"var(--text-primary)",fontWeight:600},children:[B.name,n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)",fontSize:"10px"},children:B.type})]},B.name))})}),n.jsx("tbody",{children:r.map((B,T)=>n.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},onMouseEnter:O=>{O.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:B.map((O,L)=>n.jsx("td",{className:"px-3 py-1.5",style:{color:O==null?"var(--text-muted)":"var(--text-secondary)",maxWidth:ps(O)?void 0:"300px",overflow:ps(O)?void 0:"hidden",textOverflow:ps(O)?void 0:"ellipsis",whiteSpace:ps(O)?void 0:"nowrap",verticalAlign:"top"},title:O!=null&&!ps(O)?String(O):void 0,children:O==null?n.jsx("span",{style:{fontStyle:"italic"},children:"NULL"}):ps(O)?n.jsx(gd,{value:O}):String(O)},L))},T))})]})}),(A||D)&&!c&&n.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 shrink-0 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>E(l-fs),disabled:!A,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:A?"var(--text-secondary)":"var(--text-muted)",opacity:A?1:.5},children:"Previous"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:["Page ",N," of ",$]}),n.jsx("button",{onClick:()=>E(l+fs),disabled:!D,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:D?"var(--text-secondary)":"var(--text-muted)",opacity:D?1:.5},children:"Next"})]})]})}const lr="__canvas__",ns="__statedb__:";function ro(e){return e===lr?"#/explorer/canvas":e.startsWith(ns)?`#/explorer/statedb/${encodeURIComponent(e.slice(ns.length))}`:`#/explorer/file/${encodeURIComponent(e)}`}const io=e=>{e.editor.defineTheme("uipath-dark",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"64748b",fontStyle:"italic"},{token:"keyword",foreground:"c084fc"},{token:"string",foreground:"86efac"},{token:"number",foreground:"fcd34d"},{token:"type",foreground:"7dd3fc"}],colors:{"editor.background":"#0f172a","editor.foreground":"#cbd5e1","editor.lineHighlightBackground":"#1e293b","editor.selectionBackground":"#334155","editor.inactiveSelectionBackground":"#263348","editorLineNumber.foreground":"#64748b","editorLineNumber.activeForeground":"#94a3b8","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#334155","editorIndentGuide.activeBackground":"#64748b","editorWidget.background":"#1e293b","editorWidget.border":"#334155","editorSuggestWidget.background":"#1e293b","editorSuggestWidget.border":"#334155","editorSuggestWidget.selectedBackground":"#263348","editorHoverWidget.background":"#1e293b","editorHoverWidget.border":"#334155","scrollbarSlider.background":"#33415580","scrollbarSlider.hoverBackground":"#33415599","scrollbarSlider.activeBackground":"#334155cc"}}),e.editor.defineTheme("uipath-light",{base:"vs",inherit:!0,rules:[{token:"comment",foreground:"94a3b8",fontStyle:"italic"},{token:"keyword",foreground:"7c3aed"},{token:"string",foreground:"16a34a"},{token:"number",foreground:"d97706"},{token:"type",foreground:"0284c7"}],colors:{"editor.background":"#f8fafc","editor.foreground":"#0f172a","editor.lineHighlightBackground":"#f1f5f9","editor.selectionBackground":"#e2e8f0","editor.inactiveSelectionBackground":"#f1f5f9","editorLineNumber.foreground":"#94a3b8","editorLineNumber.activeForeground":"#475569","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#e2e8f0","editorIndentGuide.activeBackground":"#94a3b8","editorWidget.background":"#ffffff","editorWidget.border":"#e2e8f0","editorSuggestWidget.background":"#ffffff","editorSuggestWidget.border":"#e2e8f0","editorSuggestWidget.selectedBackground":"#f1f5f9","editorHoverWidget.background":"#ffffff","editorHoverWidget.border":"#e2e8f0","scrollbarSlider.background":"#d1d5db80","scrollbarSlider.hoverBackground":"#d1d5db99","scrollbarSlider.activeBackground":"#d1d5dbcc"}})};function no(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function xd(e){const t=e.replace(/\\/g,"/").split("/");return t[t.length-1]||e}function yd(){const e=ye(p=>p.openTabs),s=ye(p=>p.selectedFile),r=ye(p=>s?p.fileCache[s]:void 0),i=ye(p=>s?!!p.dirty[s]:!1),o=ye(p=>s?p.buffers[s]:void 0),a=ye(p=>p.loadingFile),l=ye(p=>p.dirty),h=ye(p=>p.diffView),c=ye(p=>s?!!p.agentChangedFiles[s]:!1),{setFileContent:u,updateBuffer:d,markClean:_,setLoadingFile:g,openTab:m,closeTab:x,setDiffView:w}=ye(),{navigate:E}=et(),k=ya(p=>p.theme),P=v.useRef(null),{explorerFile:A}=et();v.useEffect(()=>{A&&m(A)},[A,m]),v.useEffect(()=>{!s||s===lr||s.startsWith(ns)||ye.getState().fileCache[s]||(g(!0),pa(s).then(p=>u(s,p)).catch(console.error).finally(()=>g(!1)))},[s,u,g]);const D=v.useCallback(()=>{if(!s)return;const p=ye.getState().fileCache[s],b=ye.getState().buffers[s]??(p==null?void 0:p.content);b!=null&&jc(s,b).then(()=>{_(s),u(s,{...p,content:b})}).catch(console.error)},[s,_,u]);v.useEffect(()=>{const p=f=>{(f.ctrlKey||f.metaKey)&&f.key==="s"&&(f.preventDefault(),D())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[D]);const N=p=>{P.current=p},$=v.useCallback(p=>{p!==void 0&&s&&d(s,p)},[s,d]),B=v.useCallback(p=>{m(p),E(ro(p))},[m,E]),T=v.useCallback((p,f)=>{p.stopPropagation();const b=ye.getState(),y=b.openTabs.filter(j=>j!==f);if(x(f),b.selectedFile===f){const j=b.openTabs.indexOf(f),M=y[Math.min(j,y.length-1)];E(M?ro(M):"#/explorer")}},[x,E]),O=v.useCallback((p,f)=>{p.button===1&&T(p,f)},[T]),L=e.length>0&&n.jsx("div",{className:"h-10 flex items-end overflow-x-auto shrink-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},children:e.map(p=>{const f=p===s,b=!!l[p];return n.jsxs("button",{onClick:()=>B(p),onMouseDown:y=>O(y,p),className:"h-full flex items-center gap-1.5 px-3 text-[12px] shrink-0 cursor-pointer transition-colors relative",style:{background:f?"var(--bg-primary)":"transparent",color:f?"var(--text-primary)":"var(--text-secondary)",border:"none",borderBottom:f?"2px solid var(--accent)":"2px solid transparent",maxWidth:"180px"},onMouseEnter:y=>{f||(y.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:y=>{f||(y.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"truncate",children:p===lr?"Visualization":p.startsWith(ns)?`db:${p.slice(ns.length)}`:xd(p)}),b?n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"},title:"Unsaved changes"}):n.jsx("span",{className:"w-4 h-4 flex items-center justify-center rounded shrink-0 transition-colors",style:{color:"var(--text-muted)"},onClick:y=>T(y,p),onMouseEnter:y=>{y.currentTarget.style.background="var(--bg-hover)",y.currentTarget.style.color="var(--text-primary)"},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color="var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:n.jsx("path",{d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.708.708L7.293 8l-3.647 3.646.708.708L8 8.707z"})})})]},p)})});if(s===lr)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(hd,{})})]});if(s!=null&&s.startsWith(ns)){const p=s.slice(ns.length);return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(md,{table:p})})]})}if(!s)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a file to view"})]});if(a&&!r)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Loading file..."})})]});if(!r&&!a)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Failed to load file"})})]});if(!r)return null;if(r.binary)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)})}),n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),n.jsx("span",{className:"text-sm",children:"Binary file — preview not available"})]})]});const R=h&&h.path===s;return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[r.language&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--bg-hover)",color:"var(--text-muted)"},children:r.language}),n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)}),c&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium",style:{background:"color-mix(in srgb, var(--info) 20%, transparent)",color:"var(--info)"},children:"Agent modified"}),n.jsx("div",{className:"flex-1"}),i&&n.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--accent)"},children:"Modified"}),n.jsx("button",{onClick:D,className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:i?"var(--accent)":"var(--bg-hover)",color:i?"white":"var(--text-muted)",border:"none"},children:"Save"})]}),R&&n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--info) 10%, var(--bg-secondary))"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--info)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),n.jsx("span",{style:{color:"var(--info)"},children:"Agent modified this file"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>w(null),className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Dismiss"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:R?n.jsx(oc,{original:h.original,modified:h.modified,language:h.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",beforeMount:io,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,automaticLayout:!0,renderSideBySide:!0}},`diff-${s}`):n.jsx(ac,{language:r.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",value:o??r.content??"",onChange:$,beforeMount:io,onMount:N,options:{minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2,renderWhitespace:"selection"}},s)})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -102,21 +102,21 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Oe=U,we=se),fe===void * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Ia=Object.defineProperty,yd=Object.getOwnPropertyDescriptor,bd=(e,t)=>{for(var s in t)Ia(e,s,{get:t[s],enumerable:!0})},Le=(e,t,s,r)=>{for(var i=r>1?void 0:r?yd(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(t,s,i):a(i))||i);return r&&i&&Ia(t,s,i),i},Y=(e,t)=>(s,r)=>t(s,r,e),oo="Terminal input",ii={get:()=>oo,set:e=>oo=e},ao="Too much output to announce, navigate to rows manually to read",ni={get:()=>ao,set:e=>ao=e};function Sd(e){return e.replace(/\r?\n/g,"\r")}function wd(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Cd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function kd(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");Wa(i,t,s,r)}}function Wa(e,t,s,r){e=Sd(e),e=wd(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Ha(e,t,s){let r=s.getBoundingClientRect(),i=e.clientX-r.left-10,o=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function lo(e,t,s,r,i){Ha(e,t,s),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Xt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Er(e,t=0,s=e.length){let r="";for(let i=t;i65535?(o-=65536,r+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):r+=String.fromCharCode(o)}return r}var Ed=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i=0;if(this._interim){let o=e.charCodeAt(i++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=i;o=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[r++]=(a-55296)*1024+l-56320+65536:(t[r++]=a,t[r++]=l);continue}a!==65279&&(t[r++]=a)}return r}},Nd=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i,o,a,l,h=0,c=0;if(this.interim[0]){let p=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let m=0,y;for(;(y=this.interim[++m]&63)&&m<4;)g<<=6,g|=y;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=w-m;for(;c=s)return 0;if(y=e[c++],(y&192)!==128){c--,p=!0;break}else this.interim[m++]=y,g<<=6,g|=y&63}p||(w===2?g<128?c--:t[r++]=g:w===3?g<2048||g>=55296&&g<=57343||g===65279||(t[r++]=g):g<65536||g>1114111||(t[r++]=g)),this.interim.fill(0)}let u=s-4,d=c;for(;d=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(i&31)<<6|o&63,h<128){d--;continue}t[r++]=h}else if((i&240)===224){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(i&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[r++]=h}else if((i&248)===240){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,r;if(l=e[d++],(l&192)!==128){d--;continue}if(h=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[r++]=h}}return r}},$a="",Yt=" ",$s=class Fa{constructor(){this.fg=0,this.bg=0,this.extended=new gr}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 Fa;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}},gr=class za{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 za(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mt=class Ua extends $s{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gr,this.combinedData=""}static fromCharData(t){let s=new Ua;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xt(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},co="di$target",oi="di$dependencies",zr=new Map;function jd(e){return e[oi]||[]}function Ve(e){if(zr.has(e))return zr.get(e);let t=function(s,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Md(t,s,i)};return t._id=e,zr.set(e,t),t}function Md(e,t,s){t[co]===t?t[oi].push({id:e,index:s}):(t[oi]=[{id:e,index:s}],t[co]=t)}var tt=Ve("BufferService"),Ka=Ve("CoreMouseService"),hs=Ve("CoreService"),Ld=Ve("CharsetService"),Xi=Ve("InstantiationService"),Va=Ve("LogService"),st=Ve("OptionsService"),qa=Ve("OscLinkService"),Td=Ve("UnicodeService"),Fs=Ve("DecorationService"),ai=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,o=new mt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;di?i.activate(y,w,g):Rd(y,w),hover:(y,w)=>{var k;return(k=i==null?void 0:i.hover)==null?void 0:k.call(i,y,w,g)},leave:(y,w)=>{var k;return(k=i==null?void 0:i.leave)==null?void 0:k.call(i,y,w,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};ai=Le([Y(0,tt),Y(1,st),Y(2,qa)],ai);function Rd(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Wa=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Sd=(e,t)=>{for(var s in t)Wa(e,s,{get:t[s],enumerable:!0})},Le=(e,t,s,r)=>{for(var i=r>1?void 0:r?bd(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(t,s,i):a(i))||i);return r&&i&&Wa(t,s,i),i},G=(e,t)=>(s,r)=>t(s,r,e),oo="Terminal input",ii={get:()=>oo,set:e=>oo=e},ao="Too much output to announce, navigate to rows manually to read",ni={get:()=>ao,set:e=>ao=e};function wd(e){return e.replace(/\r?\n/g,"\r")}function Cd(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function kd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ed(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");Ha(i,t,s,r)}}function Ha(e,t,s,r){e=wd(e),e=Cd(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function $a(e,t,s){let r=s.getBoundingClientRect(),i=e.clientX-r.left-10,o=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function lo(e,t,s,r,i){$a(e,t,s),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Xt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Er(e,t=0,s=e.length){let r="";for(let i=t;i65535?(o-=65536,r+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):r+=String.fromCharCode(o)}return r}var Nd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i=0;if(this._interim){let o=e.charCodeAt(i++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=i;o=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[r++]=(a-55296)*1024+l-56320+65536:(t[r++]=a,t[r++]=l);continue}a!==65279&&(t[r++]=a)}return r}},jd=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i,o,a,l,h=0,c=0;if(this.interim[0]){let _=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let m=0,x;for(;(x=this.interim[++m]&63)&&m<4;)g<<=6,g|=x;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=w-m;for(;c=s)return 0;if(x=e[c++],(x&192)!==128){c--,_=!0;break}else this.interim[m++]=x,g<<=6,g|=x&63}_||(w===2?g<128?c--:t[r++]=g:w===3?g<2048||g>=55296&&g<=57343||g===65279||(t[r++]=g):g<65536||g>1114111||(t[r++]=g)),this.interim.fill(0)}let u=s-4,d=c;for(;d=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(i&31)<<6|o&63,h<128){d--;continue}t[r++]=h}else if((i&240)===224){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(i&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[r++]=h}else if((i&248)===240){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,r;if(l=e[d++],(l&192)!==128){d--;continue}if(h=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[r++]=h}}return r}},Fa="",Yt=" ",$s=class za{constructor(){this.fg=0,this.bg=0,this.extended=new gr}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 za;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}},gr=class Ua{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Ua(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mt=class Ka extends $s{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gr,this.combinedData=""}static fromCharData(t){let s=new Ka;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xt(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},co="di$target",oi="di$dependencies",zr=new Map;function Md(e){return e[oi]||[]}function Ve(e){if(zr.has(e))return zr.get(e);let t=function(s,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ld(t,s,i)};return t._id=e,zr.set(e,t),t}function Ld(e,t,s){t[co]===t?t[oi].push({id:e,index:s}):(t[oi]=[{id:e,index:s}],t[co]=t)}var tt=Ve("BufferService"),Va=Ve("CoreMouseService"),hs=Ve("CoreService"),Td=Ve("CharsetService"),Xi=Ve("InstantiationService"),qa=Ve("LogService"),st=Ve("OptionsService"),Xa=Ve("OscLinkService"),Rd=Ve("UnicodeService"),Fs=Ve("DecorationService"),ai=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,o=new mt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;di?i.activate(x,w,g):Bd(x,w),hover:(x,w)=>{var E;return(E=i==null?void 0:i.hover)==null?void 0:E.call(i,x,w,g)},leave:(x,w)=>{var E;return(E=i==null?void 0:i.leave)==null?void 0:E.call(i,x,w,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};ai=Le([G(0,tt),G(1,st),G(2,Xa)],ai);function Bd(e,t){if(confirm(`Do you want to navigate to ${t}? -WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nr=Ve("CharSizeService"),Wt=Ve("CoreBrowserService"),Yi=Ve("MouseService"),Ht=Ve("RenderService"),Bd=Ve("SelectionService"),Xa=Ve("CharacterJoinerService"),ys=Ve("ThemeService"),Ya=Ve("LinkProviderService"),Dd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ho.isErrorNoTelemetry(e)?new ho(e.message+` +WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nr=Ve("CharSizeService"),Wt=Ve("CoreBrowserService"),Yi=Ve("MouseService"),Ht=Ve("RenderService"),Dd=Ve("SelectionService"),Ya=Ve("CharacterJoinerService"),ys=Ve("ThemeService"),Ga=Ve("LinkProviderService"),Pd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ho.isErrorNoTelemetry(e)?new ho(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)}},Pd=new Dd;function cr(e){Ad(e)||Pd.onUnexpectedError(e)}var li="Canceled";function Ad(e){return e instanceof Od?!0:e instanceof Error&&e.name===li&&e.message===li}var Od=class extends Error{constructor(){super(li),this.name=this.message}};function Id(e){return new Error(`Illegal argument: ${e}`)}var ho=class ci extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ci)return t;let s=new ci;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hi=class Ga extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ga.prototype)}};function ot(e,t=0){return e[e.length-(1+t)]}var Wd;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function r(o){return o>0}e.isGreaterThan=r;function i(o){return o===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Wd||(Wd={}));function Hd(e,t){let s=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}var Ja;(e=>{function t(O){return O&&typeof O=="object"&&typeof O[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*i(O){yield O}e.single=i;function o(O){return t(O)?O:i(O)}e.wrap=o;function a(O){return O||s}e.from=a;function*l(O){for(let P=O.length-1;P>=0;P--)yield O[P]}e.reverse=l;function h(O){return!O||O[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(O){return O[Symbol.iterator]().next().value}e.first=c;function u(O,P){let j=0;for(let D of O)if(P(D,j++))return!0;return!1}e.some=u;function d(O,P){for(let j of O)if(P(j))return j}e.find=d;function*p(O,P){for(let j of O)P(j)&&(yield j)}e.filter=p;function*g(O,P){let j=0;for(let D of O)yield P(D,j++)}e.map=g;function*m(O,P){let j=0;for(let D of O)yield*P(D,j++)}e.flatMap=m;function*y(...O){for(let P of O)yield*P}e.concat=y;function w(O,P,j){let D=j;for(let L of O)D=P(D,L);return D}e.reduce=w;function*k(O,P,j=O.length){for(P<0&&(P+=O.length),j<0?j+=O.length:j>O.length&&(j=O.length);P1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function $d(...e){return Ee(()=>ls(e))}function Ee(e){return{dispose:Hd(()=>{e()})}}var Za=class Qa{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{ls(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?Qa.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)}};Za.DISABLE_DISPOSED_WARNING=!1;var Gt=Za,ue=class{constructor(){this._store=new Gt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ue.None=Object.freeze({dispose(){}});var xs=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}},It=typeof window=="object"?window:globalThis,di=class ui{constructor(t){this.element=t,this.next=ui.Undefined,this.prev=ui.Undefined}};di.Undefined=new di(void 0);var Ne=di,uo=class{constructor(){this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ne.Undefined}clear(){let e=this._first;for(;e!==Ne.Undefined;){let t=e.next;e.prev=Ne.Undefined,e.next=Ne.Undefined,e=t}this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Ne(e);if(this._first===Ne.Undefined)this._first=s,this._last=s;else if(t){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Ne.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ne.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ne.Undefined&&e.next!==Ne.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ne.Undefined&&e.next===Ne.Undefined?(this._first=Ne.Undefined,this._last=Ne.Undefined):e.next===Ne.Undefined?(this._last=this._last.prev,this._last.next=Ne.Undefined):e.prev===Ne.Undefined&&(this._first=this._first.next,this._first.prev=Ne.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ne.Undefined;)yield e.element,e=e.next}},Fd=globalThis.performance&&typeof globalThis.performance.now=="function",zd=class el{static create(t){return new el(t)}constructor(t){this._now=Fd&&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}},Ge;(e=>{e.None=()=>ue.None;function t(R,_){return d(R,()=>{},0,void 0,!0,void 0,_)}e.defer=t;function s(R){return(_,f=null,v)=>{let b=!1,E;return E=R(N=>{if(!b)return E?E.dispose():b=!0,_.call(f,N)},null,v),b&&E.dispose(),E}}e.once=s;function r(R,_,f){return c((v,b=null,E)=>R(N=>v.call(b,_(N)),null,E),f)}e.map=r;function i(R,_,f){return c((v,b=null,E)=>R(N=>{_(N),v.call(b,N)},null,E),f)}e.forEach=i;function o(R,_,f){return c((v,b=null,E)=>R(N=>_(N)&&v.call(b,N),null,E),f)}e.filter=o;function a(R){return R}e.signal=a;function l(...R){return(_,f=null,v)=>{let b=$d(...R.map(E=>E(N=>_.call(f,N))));return u(b,v)}}e.any=l;function h(R,_,f,v){let b=f;return r(R,E=>(b=_(b,E),b),v)}e.reduce=h;function c(R,_){let f,v={onWillAddFirstListener(){f=R(b.fire,b)},onDidRemoveLastListener(){f==null||f.dispose()}},b=new K(v);return _==null||_.add(b),b.event}function u(R,_){return _ instanceof Array?_.push(R):_&&_.add(R),R}function d(R,_,f=100,v=!1,b=!1,E,N){let z,T,$,V=0,J,re={leakWarningThreshold:E,onWillAddFirstListener(){z=R(F=>{V++,T=_(T,F),v&&!$&&(ie.fire(T),T=void 0),J=()=>{let te=T;T=void 0,$=void 0,(!v||V>1)&&ie.fire(te),V=0},typeof f=="number"?(clearTimeout($),$=setTimeout(J,f)):$===void 0&&($=0,queueMicrotask(J))})},onWillRemoveListener(){b&&V>0&&(J==null||J())},onDidRemoveLastListener(){J=void 0,z.dispose()}},ie=new K(re);return N==null||N.add(ie),ie.event}e.debounce=d;function p(R,_=0,f){return e.debounce(R,(v,b)=>v?(v.push(b),v):[b],_,void 0,!0,void 0,f)}e.accumulate=p;function g(R,_=(v,b)=>v===b,f){let v=!0,b;return o(R,E=>{let N=v||!_(E,b);return v=!1,b=E,N},f)}e.latch=g;function m(R,_,f){return[e.filter(R,_,f),e.filter(R,v=>!_(v),f)]}e.split=m;function y(R,_=!1,f=[],v){let b=f.slice(),E=R(T=>{b?b.push(T):z.fire(T)});v&&v.add(E);let N=()=>{b==null||b.forEach(T=>z.fire(T)),b=null},z=new K({onWillAddFirstListener(){E||(E=R(T=>z.fire(T)),v&&v.add(E))},onDidAddFirstListener(){b&&(_?setTimeout(N):N())},onDidRemoveLastListener(){E&&E.dispose(),E=null}});return v&&v.add(z),z.event}e.buffer=y;function w(R,_){return(f,v,b)=>{let E=_(new C);return R(function(N){let z=E.evaluate(N);z!==k&&f.call(v,z)},void 0,b)}}e.chain=w;let k=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(_){return this.steps.push(_),this}forEach(_){return this.steps.push(f=>(_(f),f)),this}filter(_){return this.steps.push(f=>_(f)?f:k),this}reduce(_,f){let v=f;return this.steps.push(b=>(v=_(v,b),v)),this}latch(_=(f,v)=>f===v){let f=!0,v;return this.steps.push(b=>{let E=f||!_(b,v);return f=!1,v=b,E?b:k}),this}evaluate(_){for(let f of this.steps)if(_=f(_),_===k)break;return _}}function A(R,_,f=v=>v){let v=(...z)=>N.fire(f(...z)),b=()=>R.on(_,v),E=()=>R.removeListener(_,v),N=new K({onWillAddFirstListener:b,onDidRemoveLastListener:E});return N.event}e.fromNodeEventEmitter=A;function O(R,_,f=v=>v){let v=(...z)=>N.fire(f(...z)),b=()=>R.addEventListener(_,v),E=()=>R.removeEventListener(_,v),N=new K({onWillAddFirstListener:b,onDidRemoveLastListener:E});return N.event}e.fromDOMEventEmitter=O;function P(R){return new Promise(_=>s(R)(_))}e.toPromise=P;function j(R){let _=new K;return R.then(f=>{_.fire(f)},()=>{_.fire(void 0)}).finally(()=>{_.dispose()}),_.event}e.fromPromise=j;function D(R,_){return R(f=>_.fire(f))}e.forward=D;function L(R,_,f){return _(f),R(v=>_(v))}e.runAndSubscribe=L;class B{constructor(_,f){this._observable=_,this._counter=0,this._hasChanged=!1;let v={onWillAddFirstListener:()=>{_.addObserver(this)},onDidRemoveLastListener:()=>{_.removeObserver(this)}};this.emitter=new K(v),f&&f.add(this.emitter)}beginUpdate(_){this._counter++}handlePossibleChange(_){}handleChange(_,f){this._hasChanged=!0}endUpdate(_){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function I(R,_){return new B(R,_).emitter.event}e.fromObservable=I;function M(R){return(_,f,v)=>{let b=0,E=!1,N={beginUpdate(){b++},endUpdate(){b--,b===0&&(R.reportChanges(),E&&(E=!1,_.call(f)))},handlePossibleChange(){},handleChange(){E=!0}};R.addObserver(N),R.reportChanges();let z={dispose(){R.removeObserver(N)}};return v instanceof Gt?v.add(z):Array.isArray(v)&&v.push(z),z}}e.fromObservableLight=M})(Ge||(Ge={}));var fi=class pi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${pi._idPool++}`,pi.all.add(this)}start(t){this._stopWatch=new zd,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}}};fi.all=new Set,fi._idPool=0;var Ud=fi,Kd=-1,tl=class sl{constructor(t,s,r=(sl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let r=this.threshold;if(r<=0||s{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,i]of this._stacks)(!t||s{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)}},Ad=new Pd;function cr(e){Od(e)||Ad.onUnexpectedError(e)}var li="Canceled";function Od(e){return e instanceof Id?!0:e instanceof Error&&e.name===li&&e.message===li}var Id=class extends Error{constructor(){super(li),this.name=this.message}};function Wd(e){return new Error(`Illegal argument: ${e}`)}var ho=class ci extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ci)return t;let s=new ci;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hi=class Ja extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ja.prototype)}};function lt(e,t=0){return e[e.length-(1+t)]}var Hd;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function r(o){return o>0}e.isGreaterThan=r;function i(o){return o===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Hd||(Hd={}));function $d(e,t){let s=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}var Za;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*i(A){yield A}e.single=i;function o(A){return t(A)?A:i(A)}e.wrap=o;function a(A){return A||s}e.from=a;function*l(A){for(let D=A.length-1;D>=0;D--)yield A[D]}e.reverse=l;function h(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(A){return A[Symbol.iterator]().next().value}e.first=c;function u(A,D){let N=0;for(let $ of A)if(D($,N++))return!0;return!1}e.some=u;function d(A,D){for(let N of A)if(D(N))return N}e.find=d;function*_(A,D){for(let N of A)D(N)&&(yield N)}e.filter=_;function*g(A,D){let N=0;for(let $ of A)yield D($,N++)}e.map=g;function*m(A,D){let N=0;for(let $ of A)yield*D($,N++)}e.flatMap=m;function*x(...A){for(let D of A)yield*D}e.concat=x;function w(A,D,N){let $=N;for(let B of A)$=D($,B);return $}e.reduce=w;function*E(A,D,N=A.length){for(D<0&&(D+=A.length),N<0?N+=A.length:N>A.length&&(N=A.length);D1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Fd(...e){return Ee(()=>ls(e))}function Ee(e){return{dispose:$d(()=>{e()})}}var Qa=class el{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{ls(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?el.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)}};Qa.DISABLE_DISPOSED_WARNING=!1;var Gt=Qa,ue=class{constructor(){this._store=new Gt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ue.None=Object.freeze({dispose(){}});var xs=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}},It=typeof window=="object"?window:globalThis,di=class ui{constructor(t){this.element=t,this.next=ui.Undefined,this.prev=ui.Undefined}};di.Undefined=new di(void 0);var Ne=di,uo=class{constructor(){this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ne.Undefined}clear(){let e=this._first;for(;e!==Ne.Undefined;){let t=e.next;e.prev=Ne.Undefined,e.next=Ne.Undefined,e=t}this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Ne(e);if(this._first===Ne.Undefined)this._first=s,this._last=s;else if(t){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Ne.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ne.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ne.Undefined&&e.next!==Ne.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ne.Undefined&&e.next===Ne.Undefined?(this._first=Ne.Undefined,this._last=Ne.Undefined):e.next===Ne.Undefined?(this._last=this._last.prev,this._last.next=Ne.Undefined):e.prev===Ne.Undefined&&(this._first=this._first.next,this._first.prev=Ne.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ne.Undefined;)yield e.element,e=e.next}},zd=globalThis.performance&&typeof globalThis.performance.now=="function",Ud=class tl{static create(t){return new tl(t)}constructor(t){this._now=zd&&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}},Ge;(e=>{e.None=()=>ue.None;function t(R,p){return d(R,()=>{},0,void 0,!0,void 0,p)}e.defer=t;function s(R){return(p,f=null,b)=>{let y=!1,j;return j=R(M=>{if(!y)return j?j.dispose():y=!0,p.call(f,M)},null,b),y&&j.dispose(),j}}e.once=s;function r(R,p,f){return c((b,y=null,j)=>R(M=>b.call(y,p(M)),null,j),f)}e.map=r;function i(R,p,f){return c((b,y=null,j)=>R(M=>{p(M),b.call(y,M)},null,j),f)}e.forEach=i;function o(R,p,f){return c((b,y=null,j)=>R(M=>p(M)&&b.call(y,M),null,j),f)}e.filter=o;function a(R){return R}e.signal=a;function l(...R){return(p,f=null,b)=>{let y=Fd(...R.map(j=>j(M=>p.call(f,M))));return u(y,b)}}e.any=l;function h(R,p,f,b){let y=f;return r(R,j=>(y=p(y,j),y),b)}e.reduce=h;function c(R,p){let f,b={onWillAddFirstListener(){f=R(y.fire,y)},onDidRemoveLastListener(){f==null||f.dispose()}},y=new V(b);return p==null||p.add(y),y.event}function u(R,p){return p instanceof Array?p.push(R):p&&p.add(R),R}function d(R,p,f=100,b=!1,y=!1,j,M){let z,C,H,U=0,q,ee={leakWarningThreshold:j,onWillAddFirstListener(){z=R(F=>{U++,C=p(C,F),b&&!H&&(ie.fire(C),C=void 0),q=()=>{let se=C;C=void 0,H=void 0,(!b||U>1)&&ie.fire(se),U=0},typeof f=="number"?(clearTimeout(H),H=setTimeout(q,f)):H===void 0&&(H=0,queueMicrotask(q))})},onWillRemoveListener(){y&&U>0&&(q==null||q())},onDidRemoveLastListener(){q=void 0,z.dispose()}},ie=new V(ee);return M==null||M.add(ie),ie.event}e.debounce=d;function _(R,p=0,f){return e.debounce(R,(b,y)=>b?(b.push(y),b):[y],p,void 0,!0,void 0,f)}e.accumulate=_;function g(R,p=(b,y)=>b===y,f){let b=!0,y;return o(R,j=>{let M=b||!p(j,y);return b=!1,y=j,M},f)}e.latch=g;function m(R,p,f){return[e.filter(R,p,f),e.filter(R,b=>!p(b),f)]}e.split=m;function x(R,p=!1,f=[],b){let y=f.slice(),j=R(C=>{y?y.push(C):z.fire(C)});b&&b.add(j);let M=()=>{y==null||y.forEach(C=>z.fire(C)),y=null},z=new V({onWillAddFirstListener(){j||(j=R(C=>z.fire(C)),b&&b.add(j))},onDidAddFirstListener(){y&&(p?setTimeout(M):M())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return b&&b.add(z),z.event}e.buffer=x;function w(R,p){return(f,b,y)=>{let j=p(new k);return R(function(M){let z=j.evaluate(M);z!==E&&f.call(b,z)},void 0,y)}}e.chain=w;let E=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(p){return this.steps.push(p),this}forEach(p){return this.steps.push(f=>(p(f),f)),this}filter(p){return this.steps.push(f=>p(f)?f:E),this}reduce(p,f){let b=f;return this.steps.push(y=>(b=p(b,y),b)),this}latch(p=(f,b)=>f===b){let f=!0,b;return this.steps.push(y=>{let j=f||!p(y,b);return f=!1,b=y,j?y:E}),this}evaluate(p){for(let f of this.steps)if(p=f(p),p===E)break;return p}}function P(R,p,f=b=>b){let b=(...z)=>M.fire(f(...z)),y=()=>R.on(p,b),j=()=>R.removeListener(p,b),M=new V({onWillAddFirstListener:y,onDidRemoveLastListener:j});return M.event}e.fromNodeEventEmitter=P;function A(R,p,f=b=>b){let b=(...z)=>M.fire(f(...z)),y=()=>R.addEventListener(p,b),j=()=>R.removeEventListener(p,b),M=new V({onWillAddFirstListener:y,onDidRemoveLastListener:j});return M.event}e.fromDOMEventEmitter=A;function D(R){return new Promise(p=>s(R)(p))}e.toPromise=D;function N(R){let p=new V;return R.then(f=>{p.fire(f)},()=>{p.fire(void 0)}).finally(()=>{p.dispose()}),p.event}e.fromPromise=N;function $(R,p){return R(f=>p.fire(f))}e.forward=$;function B(R,p,f){return p(f),R(b=>p(b))}e.runAndSubscribe=B;class T{constructor(p,f){this._observable=p,this._counter=0,this._hasChanged=!1;let b={onWillAddFirstListener:()=>{p.addObserver(this)},onDidRemoveLastListener:()=>{p.removeObserver(this)}};this.emitter=new V(b),f&&f.add(this.emitter)}beginUpdate(p){this._counter++}handlePossibleChange(p){}handleChange(p,f){this._hasChanged=!0}endUpdate(p){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function O(R,p){return new T(R,p).emitter.event}e.fromObservable=O;function L(R){return(p,f,b)=>{let y=0,j=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(R.reportChanges(),j&&(j=!1,p.call(f)))},handlePossibleChange(){},handleChange(){j=!0}};R.addObserver(M),R.reportChanges();let z={dispose(){R.removeObserver(M)}};return b instanceof Gt?b.add(z):Array.isArray(b)&&b.push(z),z}}e.fromObservableLight=L})(Ge||(Ge={}));var fi=class pi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${pi._idPool++}`,pi.all.add(this)}start(t){this._stopWatch=new Ud,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}}};fi.all=new Set,fi._idPool=0;var Kd=fi,Vd=-1,sl=class rl{constructor(t,s,r=(rl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let r=this.threshold;if(r<=0||s{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,i]of this._stacks)(!t||s{var a,l,h,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new Yd(`${d}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(((a=this._options)==null?void 0:a.onListenerError)||cr)(g),ue.None}if(this._disposed)return ue.None;t&&(e=e.bind(t));let r=new Ur(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ur?(this._deliveryQueue??(this._deliveryQueue=new Qd),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let o=Ee(()=>{i==null||i(),this._removeListener(r)});return s instanceof Gt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var i,o,a,l;if((o=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||o.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||l.call(a,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);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--,t[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Jd<=t.length){let h=0;for(let c=0;c0}},Qd=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_i=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new K,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new K,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};_i.INSTANCE=new _i;var Gi=_i;function eu(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Gi.INSTANCE.onDidChangeZoomLevel;function tu(e){return Gi.INSTANCE.getZoomFactor(e)}Gi.INSTANCE.onDidChangeFullscreen;var bs=typeof navigator=="object"?navigator.userAgent:"",gi=bs.indexOf("Firefox")>=0,su=bs.indexOf("AppleWebKit")>=0,Ji=bs.indexOf("Chrome")>=0,ru=!Ji&&bs.indexOf("Safari")>=0;bs.indexOf("Electron/")>=0;bs.indexOf("Android")>=0;var Kr=!1;if(typeof It.matchMedia=="function"){let e=It.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=It.matchMedia("(display-mode: fullscreen)");Kr=e.matches,eu(It,e,({matches:s})=>{Kr&&t.matches||(Kr=s)})}var vs="en",mi=!1,vi=!1,hr=!1,il=!1,tr,dr=vs,fo=vs,iu,bt,as=globalThis,Ye,ta;typeof as.vscode<"u"&&typeof as.vscode.process<"u"?Ye=as.vscode.process:typeof process<"u"&&typeof((ta=process==null?void 0:process.versions)==null?void 0:ta.node)=="string"&&(Ye=process);var sa,nu=typeof((sa=Ye==null?void 0:Ye.versions)==null?void 0:sa.electron)=="string",ou=nu&&(Ye==null?void 0:Ye.type)==="renderer",ra;if(typeof Ye=="object"){mi=Ye.platform==="win32",vi=Ye.platform==="darwin",hr=Ye.platform==="linux",hr&&Ye.env.SNAP&&Ye.env.SNAP_REVISION,Ye.env.CI||Ye.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tr=vs,dr=vs;let e=Ye.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);tr=t.userLocale,fo=t.osLocale,dr=t.resolvedLanguage||vs,iu=(ra=t.languagePack)==null?void 0:ra.translationsConfigFile}catch{}il=!0}else typeof navigator=="object"&&!ou?(bt=navigator.userAgent,mi=bt.indexOf("Windows")>=0,vi=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,hr=bt.indexOf("Linux")>=0,(bt==null?void 0:bt.indexOf("Mobi"))>=0,dr=globalThis._VSCODE_NLS_LANGUAGE||vs,tr=navigator.language.toLowerCase(),fo=tr):console.error("Unable to resolve platform.");var nl=mi,Mt=vi,au=hr,po=il,Rt=bt,Kt=dr,lu;(e=>{function t(){return Kt}e.value=t;function s(){return Kt.length===2?Kt==="en":Kt.length>=3?Kt[0]==="e"&&Kt[1]==="n"&&Kt[2]==="-":!1}e.isDefaultVariant=s;function r(){return Kt==="en"}e.isDefault=r})(lu||(lu={}));var cu=typeof as.postMessage=="function"&&!as.importScripts;(()=>{if(cu){let e=[];as.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r{let r=++t;e.push({id:r,callback:s}),as.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var hu=!!(Rt&&Rt.indexOf("Chrome")>=0);Rt&&Rt.indexOf("Firefox")>=0;!hu&&Rt&&Rt.indexOf("Safari")>=0;Rt&&Rt.indexOf("Edg/")>=0;Rt&&Rt.indexOf("Android")>=0;var _s=typeof navigator=="object"?navigator:{};po||document.queryCommandSupported&&document.queryCommandSupported("copy")||_s&&_s.clipboard&&_s.clipboard.writeText,po||_s&&_s.clipboard&&_s.clipboard.readText;var Zi=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}},Vr=new Zi,_o=new Zi,go=new Zi,du=new Array(230),ol;(e=>{function t(l){return Vr.keyCodeToStr(l)}e.toString=t;function s(l){return Vr.strToKeyCode(l)}e.fromString=s;function r(l){return _o.keyCodeToStr(l)}e.toUserSettingsUS=r;function i(l){return go.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function o(l){return _o.strToKeyCode(l)||go.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Vr.keyCodeToStr(l)}e.toElectronAccelerator=a})(ol||(ol={}));var uu=class al{constructor(t,s,r,i,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=i,this.keyCode=o}equals(t){return t instanceof al&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${s}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new fu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},fu=class{constructor(e){if(e.length===0)throw Id("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof Su?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ge.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ll})})(bu||(bu={}));var Su=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?ll:(this._emitter||(this._emitter=new K),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Qi=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 hi("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hi("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},wu=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,s=globalThis){if(this.isDisposed)throw new hi("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Ee(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Cu;(e=>{async function t(r){let i,o=await Promise.all(r.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}e.settled=t;function s(r){return new Promise(async(i,o)=>{try{await r(i,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Cu||(Cu={}));var yo=class pt{static fromArray(t){return new pt(s=>{s.emitMany(t)})}static fromPromise(t){return new pt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new pt(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new pt(async s=>{await Promise.all(t.map(async r=>{for await(let i of r)s.emitOne(i)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new K,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new pt(async r=>{for await(let i of t)r.emitOne(s(i))})}map(t){return pt.map(this,t)}static filter(t,s){return new pt(async r=>{for await(let i of t)s(i)&&r.emitOne(i)})}filter(t){return pt.filter(this,t)}static coalesce(t){return pt.filter(t,s=>!!s)}coalesce(){return pt.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return pt.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())}};yo.EMPTY=yo.fromArray([]);var{getWindow:jt,getWindowId:ku,onDidRegisterWindow:Eu}=(function(){let e=new Map,t={window:It,disposables:new Gt};e.set(It.vscodeWindowId,t);let s=new K,r=new K,i=new K;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ue.None;let l=new Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(Ee(()=>{e.delete(a.vscodeWindowId),r.fire(a)})),l.add(ne(a,Fe.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:It},getDocument(a){return jt(a).document}}})(),Nu=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!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 ne(e,t,s,r){return new Nu(e,t,s,r)}var bo=function(e,t,s,r){return ne(e,t,s,r)},en,ju=class extends wu{constructor(e){super(),this.defaultTarget=e&&jt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},So=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){cr(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,i=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),r.set(o,!0);a.length>0;)a.sort(So.sort),a.shift().execute();r.set(o,!1)};en=(o,a,l=0)=>{let h=ku(o),c=new So(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>i(h))),c}})();function Mu(e){let t=e.getBoundingClientRect(),s=jt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Fe={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"},Lu=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=rt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=rt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=rt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=rt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=rt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=rt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=rt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=rt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=rt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=rt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=rt(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=rt(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=rt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=rt(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 rt(e){return typeof e=="number"?`${e}px`:e}function As(e){return new Lu(e)}var cl=class{constructor(){this._hooks=new Gt,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let o=e;try{e.setPointerCapture(t),this._hooks.add(Ee(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=jt(e)}this._hooks.add(ne(o,Fe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ne(o,Fe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Tu(e,t,s){let r=null,i=null;if(typeof s.value=="function"?(r="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${t}`;s[r]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var Nt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Nt||(Nt={}));var Ls=class Ze extends ue{constructor(){super(),this.dispatched=!1,this.targets=new uo,this.ignoreTargets=new uo,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ge.runAndSubscribe(Eu,({window:t,disposables:s})=>{s.add(ne(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(ne(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(ne(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:It,disposables:this._store}))}static addTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.targets.push(t);return Ee(s)}static ignoreTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.ignoreTargets.push(t);return Ee(s)}static isTouchDevice(){return"ontouchstart"in It||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r=Ze.HOLD_DELAY&&Math.abs(h.initialPageX-ot(h.rollingPageX))<30&&Math.abs(h.initialPageY-ot(h.rollingPageY))<30){let u=this.newGestureEvent(Nt.Contextmenu,h.initialTarget);u.pageX=ot(h.rollingPageX),u.pageY=ot(h.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=ot(h.rollingPageX),d=ot(h.rollingPageY),p=ot(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],m=d-h.rollingPageY[0],y=[...this.targets].filter(w=>h.initialTarget instanceof Node&&w.contains(h.initialTarget));this.inertia(t,y,r,Math.abs(g)/p,g>0?1:-1,u,Math.abs(m)/p,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Nt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===Nt.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Ze.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Nt.Change||t.type===Nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,o=t.initialTarget;for(;o&&o!==r;)i++,o=o.parentElement;s.push([i,r])}s.sort((r,i)=>r[0]-i[0]);for(let[r,i]of s)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,i,o,a,l,h,c){this.handle=en(t,()=>{let u=Date.now(),d=u-r,p=0,g=0,m=!0;i+=Ze.SCROLL_FRICTION*d,l+=Ze.SCROLL_FRICTION*d,i>0&&(m=!1,p=o*i*d),l>0&&(m=!1,g=h*l*d);let y=this.newGestureEvent(Nt.Change);y.translationX=p,y.translationY=g,s.forEach(w=>w.dispatchEvent(y)),m||this.inertia(t,s,u,i,o,a+p,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let r=0,i=t.changedTouches.length;r3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ls.SCROLL_FRICTION=-.005,Ls.HOLD_DELAY=700,Ls.CLEAR_TAP_COUNT_TIME=400,Le([Tu],Ls,"isTouchDevice",1);var Ru=Ls,tn=class extends ue{onclick(e,t){this._register(ne(e,Fe.CLICK,s=>t(new sr(jt(e),s))))}onmousedown(e,t){this._register(ne(e,Fe.MOUSE_DOWN,s=>t(new sr(jt(e),s))))}onmouseover(e,t){this._register(ne(e,Fe.MOUSE_OVER,s=>t(new sr(jt(e),s))))}onmouseleave(e,t){this._register(ne(e,Fe.MOUSE_LEAVE,s=>t(new sr(jt(e),s))))}onkeydown(e,t){this._register(ne(e,Fe.KEY_DOWN,s=>t(new mo(s))))}onkeyup(e,t){this._register(ne(e,Fe.KEY_UP,s=>t(new mo(s))))}oninput(e,t){this._register(ne(e,Fe.INPUT,t))}onblur(e,t){this._register(ne(e,Fe.BLUR,t))}onfocus(e,t){this._register(ne(e,Fe.FOCUS,t))}onchange(e,t){this._register(ne(e,Fe.CHANGE,t))}ignoreGesture(e){return Ru.ignoreTarget(e)}},wo=11,Bu=class extends tn{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=wo+"px",this.domNode.style.height=wo+"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 cl),this._register(bo(this.bgDomNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bo(this.domNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ju),this._pointerdownScheduleRepeatTimer=this._register(new Qi)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,jt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Du=class xi{constructor(t,s,r,i,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>r&&(i=r-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=r,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}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,s){return new xi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new xi(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,s){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:r,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Pu=class extends ue{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Du(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 r;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new ko(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=ko.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Co=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function qr(e,t){let s=t-e;return function(r){return e+s*Iu(r)}}function Au(e,t,s){return function(r){return r2.5*r){let i,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":"")))}},Hu=140,hl=class extends tn{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 Wu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new cl),this._shouldRender=!0,this.domNode=As(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(ne(this.domNode.domNode,Fe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Bu(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=As(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ne(this.slider.domNode,Fe.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let i=Mu(this.domNode.domNode);t=e.pageX-i.left,s=e.pageY-i.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(nl&&a>Hu){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{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()}},dl=class bi{constructor(t,s,r,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bi(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,i,o){let a=Math.max(0,r-t),l=Math.max(0,a-2*s),h=i>0&&i>r;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*l/i))),u=(l-c)/(i-r),d=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=bi._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let i=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(i,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(i,a),d=Math.max(o,l);u%h===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Si.INSTANCE=new Si;var Ku=Si,Vu=class extends tn{constructor(e,t,s){super(),this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new K),this.onWillScroll=this._onWillScroll.event,this._options=Xu(t),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Fu(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $u(this._scrollable,this._options,r)),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=As(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=As(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=As(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Qi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ls(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,Mt&&(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 xo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ls(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new xo(s))};this._mouseWheelToDispose.push(ne(this._listenOnDomNode,Fe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Ku.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!Mt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Eo*o,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(a){let u=Eo*a,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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,s=e.scrollLeft>0,r=s?" left":"",i=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${r}`)}}_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(),zu)}},qu=class extends Vu{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Xu(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,Mt&&(t.className+=" mac"),t}var wi=class extends ue{constructor(e,t,s,r,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Pu({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>en(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new qu(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ge.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ee(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ee(()=>this._styleElement.remove())),this._register(Ge.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(c=>this._handleScroll(c)))}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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};wi=Le([Y(2,tt),Y(3,Wt),Y(4,Ka),Y(5,ys),Y(6,st),Y(7,Ht)],wi);var Ci=class extends ue{constructor(e,t,s,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=i,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(Ee(()=>{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 r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*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()}};Ci=Le([Y(1,tt),Y(2,Wt),Y(3,Fs),Y(4,Ht)],Ci);var Yu=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},kt={full:0,left:0,center:0,right:0},Vt={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},mr=class extends ue{constructor(e,t,s,r,i,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Yu,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(Ee(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Vt.full=this._canvas.width,Vt.left=e,Vt.center=t,Vt.right=e,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Vt.left,ws.right=1+Vt.left+Vt.center}_refreshDrawHeightConstants(){kt.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);kt.left=t,kt.center=t,kt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.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(ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kt[e.position||"full"]/2),Vt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kt[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}))}};mr=Le([Y(2,tt),Y(3,Fs),Y(4,Ht),Y(5,st),Y(6,ys),Y(7,Wt)],mr);var H;(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=""))(H||(H={}));var ur;(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="Ÿ"))(ur||(ur={}));var ul;(e=>e.ST=`${H.ESC}\\`)(ul||(ul={}));var ki=class{constructor(e,t,s,r,i,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=i,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};ki=Le([Y(2,tt),Y(3,st),Y(4,hs),Y(5,Ht)],ki);var ze=0,Ue=0,Ke=0,Me=0,No={css:"#00000000",rgba:0},Ae;(e=>{function t(i,o,a,l){return l!==void 0?`#${ss(i)}${ss(o)}${ss(a)}${ss(l)}`:`#${ss(i)}${ss(o)}${ss(a)}`}e.toCss=t;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function r(i,o,a,l){return{css:e.toCss(i,o,a,l),rgba:e.toRgba(i,o,a,l)}}e.toColor=r})(Ae||(Ae={}));var ke;(e=>{function t(h,c){if(Me=(c.rgba&255)/255,Me===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,p=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,y=h.rgba>>8&255;ze=g+Math.round((u-g)*Me),Ue=m+Math.round((d-m)*Me),Ke=y+Math.round((p-y)*Me);let w=Ae.toCss(ze,Ue,Ke),k=Ae.toRgba(ze,Ue,Ke);return{css:w,rgba:k}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function r(h,c,u){let d=fr.ensureContrastRatio(h.rgba,c.rgba,u);if(d)return Ae.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(h){let c=(h.rgba|255)>>>0;return[ze,Ue,Ke]=fr.toChannels(c),{css:Ae.toCss(ze,Ue,Ke),rgba:c}}e.opaque=i;function o(h,c){return Me=Math.round(c*255),[ze,Ue,Ke]=fr.toChannels(h.rgba),{css:Ae.toCss(ze,Ue,Ke,Me),rgba:Ae.toRgba(ze,Ue,Ke,Me)}}e.opacity=o;function a(h,c){return Me=h.rgba&255,o(h,Me*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ke||(ke={}));var je;(e=>{let t,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Ae.toColor(ze,Ue,Ke);case 5:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Me=parseInt(i.slice(4,5).repeat(2),16),Ae.toColor(ze,Ue,Ke,Me);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.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 ze=parseInt(o[1]),Ue=parseInt(o[2]),Ke=parseInt(o[3]),Me=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ae.toColor(ze,Ue,Ke,Me);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ue,Ke,Me]=t.getImageData(0,0,1,1).data,Me!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(ze,Ue,Ke,Me),css:i}}e.toColor=r})(je||(je={}));var Qe;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,i,o){let a=r/255,l=i/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=s})(Qe||(Qe={}));var fr;(e=>{function t(a,l){if(Me=(l&255)/255,Me===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,d=a>>24&255,p=a>>16&255,g=a>>8&255;return ze=d+Math.round((h-d)*Me),Ue=p+Math.round((c-p)*Me),Ke=g+Math.round((u-g)*Me),Ae.toRgba(ze,Ue,Ke)}e.blend=t;function s(a,l,h){let c=Qe.relativeLuminance(a>>8),u=Qe.relativeLuminance(l>>8);if(Pt(c,u)>8));if(m>8));return m>w?g:y}return g}let d=i(a,l,h),p=Pt(c,Qe.relativeLuminance(d>>8));if(p>8));return p>m?d:g}return d}}e.ensureContrastRatio=s;function r(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,p=l>>24&255,g=l>>16&255,m=l>>8&255,y=Pt(Qe.relativeLuminance2(p,g,m),Qe.relativeLuminance2(c,u,d));for(;y0||g>0||m>0);)p-=Math.max(0,Math.ceil(p*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),y=Pt(Qe.relativeLuminance2(p,g,m),Qe.relativeLuminance2(c,u,d));return(p<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,p=l>>24&255,g=l>>16&255,m=l>>8&255,y=Pt(Qe.relativeLuminance2(p,g,m),Qe.relativeLuminance2(c,u,d));for(;y>>0}e.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(fr||(fr={}));function ss(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e1){let u=this._getJoinedRanges(r,a,o,t,i);for(let d=0;d1){let c=this._getJoinedRanges(r,a,o,t,i);for(let u=0;u=I,E=_,N=this._workCell;if(p.length>0&&_===p[0][0]&&b){let ge=p.shift(),$t=this._isCellInSelection(ge[0],t);for(C=ge[0]+1;C=ge[1]),b?(v=!0,N=new Gu(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),E=ge[1]-1,f=N.getWidth()):I=ge[1]}let z=this._isCellInSelection(_,t),T=s&&_===o,$=R&&_>=c&&_<=u,V=!1;this._decorationService.forEachDecorationAtCell(_,t,void 0,ge=>{V=!0});let J=N.getChars()||Yt;if(J===" "&&(N.isUnderline()||N.isOverline())&&(J=" "),B=f*l-h.get(J,N.isBold(),N.isItalic()),!y)y=this._document.createElement("span");else if(w&&(z&&L||!z&&!L&&N.bg===A)&&(z&&L&&g.selectionForeground||N.fg===O)&&N.extended.ext===P&&$===j&&B===D&&!T&&!v&&!V&&b){N.isInvisible()?k+=Yt:k+=J,w++;continue}else w&&(y.textContent=k),y=this._document.createElement("span"),w=0,k="";if(A=N.bg,O=N.fg,P=N.extended.ext,j=$,D=B,L=z,v&&o>=_&&o<=E&&(o=_),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(M.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&M.push("xterm-cursor-blink"),M.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":M.push("xterm-cursor-outline");break;case"block":M.push("xterm-cursor-block");break;case"bar":M.push("xterm-cursor-bar");break;case"underline":M.push("xterm-cursor-underline");break}}if(N.isBold()&&M.push("xterm-bold"),N.isItalic()&&M.push("xterm-italic"),N.isDim()&&M.push("xterm-dim"),N.isInvisible()?k=Yt:k=N.getChars()||Yt,N.isUnderline()&&(M.push(`xterm-underline-${N.extended.underlineStyle}`),k===" "&&(k=" "),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())y.style.textDecorationColor=`rgb(${$s.toColorRGB(N.getUnderlineColor()).join(",")})`;else{let ge=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&ge<8&&(ge+=8),y.style.textDecorationColor=g.ansi[ge].css}N.isOverline()&&(M.push("xterm-overline"),k===" "&&(k=" ")),N.isStrikethrough()&&M.push("xterm-strikethrough"),$&&(y.style.textDecoration="underline");let re=N.getFgColor(),ie=N.getFgColorMode(),F=N.getBgColor(),te=N.getBgColorMode(),pe=!!N.isInverse();if(pe){let ge=re;re=F,F=ge;let $t=ie;ie=te,te=$t}let _e,qe,St=!1;this._decorationService.forEachDecorationAtCell(_,t,void 0,ge=>{ge.options.layer!=="top"&&St||(ge.backgroundColorRGB&&(te=50331648,F=ge.backgroundColorRGB.rgba>>8&16777215,_e=ge.backgroundColorRGB),ge.foregroundColorRGB&&(ie=50331648,re=ge.foregroundColorRGB.rgba>>8&16777215,qe=ge.foregroundColorRGB),St=ge.options.layer==="top")}),!St&&z&&(_e=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,F=_e.rgba>>8&16777215,te=50331648,St=!0,g.selectionForeground&&(ie=50331648,re=g.selectionForeground.rgba>>8&16777215,qe=g.selectionForeground)),St&&M.push("xterm-decoration-top");let ht;switch(te){case 16777216:case 33554432:ht=g.ansi[F],M.push(`xterm-bg-${F}`);break;case 50331648:ht=Ae.toColor(F>>16,F>>8&255,F&255),this._addStyle(y,`background-color:#${jo((F>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(ht=g.foreground,M.push("xterm-bg-257")):ht=g.background}switch(_e||N.isDim()&&(_e=ke.multiplyOpacity(ht,.5)),ie){case 16777216:case 33554432:N.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(y,ht,g.ansi[re],N,_e,void 0)||M.push(`xterm-fg-${re}`);break;case 50331648:let ge=Ae.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(y,ht,ge,N,_e,qe)||this._addStyle(y,`color:#${jo(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(y,ht,g.foreground,N,_e,qe)||pe&&M.push("xterm-fg-257")}M.length&&(y.className=M.join(" "),M.length=0),!T&&!v&&!V&&b?w++:y.textContent=k,B!==this.defaultSpacing&&(y.style.letterSpacing=`${B}px`),d.push(y),_=E}return y&&w&&(y.textContent=k),d}_applyMinimumContrast(e,t,s,r,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Qu(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!i&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ke.ensureContrastRatio(i||t,o||s,h),a.setColor((i||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t=s[0]&&e=s[0]}};Ei=Le([Y(1,Xa),Y(2,st),Y(3,Wt),Y(4,hs),Y(5,Fs),Y(6,ys)],Ei);function jo(e,t,s){for(;e.length0&&(this._flat[r]=a),a}let i=e;t&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(i,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},sf=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let i=e.buffers.active.ydisp,o=t[1]-i,a=s[1]-i,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function rf(){return new sf}var Xr="xterm-dom-renderer-owner-",ft="xterm-rows",ir="xterm-fg-",Mo="xterm-bg-",Cs="xterm-focus",nr="xterm-selection",nf=1,Ni=class extends ue{constructor(e,t,s,r,i,o,a,l,h,c,u,d,p,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=p,this._themeService=g,this._terminalClass=nf++,this._rowElements=[],this._selectionRenderModel=rf(),this.onRequestRedraw=this._register(new K).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ft),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(nr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=ef(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ei,document),this._element.classList.add(Xr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ee(()=>{this._element.classList.remove(Xr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new tf(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ft} 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} .${ft} { 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} .${ft} .xterm-dim { color: ${ke.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${nr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${nr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${nr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${ir}${o} { color: ${a.css}; }${this._terminalSelector} .${ir}${o}.xterm-dim { color: ${ke.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Mo}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${ir}257 { color: ${ke.opaque(e.background).css}; }${this._terminalSelector} .${ir}257.xterm-dim { color: ${ke.multiplyOpacity(ke.opaque(e.background),.5).css}; }${this._terminalSelector} .${Mo}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 s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let d=i===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,d))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,r=1){let i=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}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 s=this._bufferService.buffer,r=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],d=s.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Xr}${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,s,r,i,o){s<0&&(e=0),r<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=r;++g){let m=g+l.ydisp,y=this._rowElements[g],w=l.lines.get(m);if(!y||!w)break;y.replaceChildren(...this._rowFactory.createRow(w,m,m===h,d,p,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===r?t:i)-1:-1))}}};Ni=Le([Y(7,Xi),Y(8,Nr),Y(9,st),Y(10,tt),Y(11,hs),Y(12,Wt),Y(13,ys)],Ni);var ji=class extends ue{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new K),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new af(this._optionsService))}catch{this._measureStrategy=this._register(new of(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())}};ji=Le([Y(2,st)],ji);var fl=class extends ue{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)}},of=class extends fl{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},af=class extends fl{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}},lf=class extends ue{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new cf(this._window)),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new K),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ge.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ne(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}},cf=class extends ue{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new xs),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ee(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ne(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)}},hf=class extends ue{constructor(){super(),this.linkProviders=[],this._register(Ee(()=>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 sn(e,t,s){let r=s.getBoundingClientRect(),i=e.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-o,t.clientY-r.top-a]}function df(e,t,s,r,i,o,a,l,h){if(!o)return;let c=sn(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),r+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var Mi=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,i){return df(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let s=sn(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Mi=Le([Y(0,Ht),Y(1,Nr)],Mi);var uf=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,s){this._rowCount=s,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=[]}},pl={};bd(pl,{getSafariVersion:()=>pf,isChromeOS:()=>vl,isFirefox:()=>_l,isIpad:()=>_f,isIphone:()=>gf,isLegacyEdge:()=>ff,isLinux:()=>rn,isMac:()=>xr,isNode:()=>jr,isSafari:()=>gl,isWindows:()=>ml});var jr=typeof process<"u"&&"title"in process,zs=jr?"node":navigator.userAgent,Us=jr?"node":navigator.platform,_l=zs.includes("Firefox"),ff=zs.includes("Edge"),gl=/^((?!chrome|android).)*safari/i.test(zs);function pf(){if(!gl)return 0;let e=zs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var xr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Us),_f=Us==="iPad",gf=Us==="iPhone",ml=["Windows","Win16","Win32","WinCE"].includes(Us),rn=Us.indexOf("Linux")>=0,vl=/\bCrOS\b/.test(zs),xl=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},mf=class extends xl{_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())}}},vf=class extends xl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},yr=!jr&&"requestIdleCallback"in window?vf:mf,xf=class{constructor(){this._queue=new yr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Li=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new xs),this._pausedResizeTask=new xf,this._observerDisposable=this._register(new xs),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 K),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new K),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new K),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uf((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new yf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ee(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.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(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ee(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(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 s;return(s=this._renderer.value)==null?void 0:s.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,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Li=Le([Y(2,st),Y(3,Nr),Y(4,hs),Y(5,Fs),Y(6,tt),Y(7,Wt),Y(8,ys)],Li);var yf=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 bf(e,t,s,r){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Cf(i,o,e,t,s,r)+Mr(o,t,s,r)+kf(i,o,e,t,s,r);let a;if(o===t)return a=i>e?"D":"C",Ws(Math.abs(i-e),Is(a,r));a=o>t?"D":"C";let l=Math.abs(o-t),h=wf(o>t?e:i,s)+(l-1)*s.cols+1+Sf(o>t?i:e);return Ws(h,Is(a,r))}function Sf(e,t){return e-1}function wf(e,t){return t.cols-e}function Cf(e,t,s,r,i,o){return Mr(t,r,i,o).length===0?"":Ws(bl(e,t,e,t-cs(t,i),!1,i).length,Is("D",o))}function Mr(e,t,s,r){let i=e-cs(e,s),o=t-cs(t,s),a=Math.abs(i-o)-Ef(e,t,s);return Ws(a,Is(yl(e,t),r))}function kf(e,t,s,r,i,o){let a;Mr(t,r,i,o).length>0?a=r-cs(r,i):a=t;let l=r,h=Nf(e,t,s,r,i,o);return Ws(bl(e,a,s,l,h==="C",i).length,Is(h,o))}function Ef(e,t,s){var a;let r=0,i=e-cs(e,s),o=t-cs(t,s);for(let l=0;l=0&&e0?a=r-cs(r,i):a=t,e=s&&at?"A":"B"}function bl(e,t,s,r,i,o){let a=e,l=t,h="";for(;(a!==s||l!==r)&&l>=0&&lo.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!i&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function Is(e,t){let s=t?"O":"[";return H.ESC+s+e}function Ws(e,t){e=Math.floor(e);let s="";for(let r=0;rthis._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 Lo(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 Yr=50,Mf=15,Lf=50,Tf=500,Rf=" ",Bf=new RegExp(Rf,"g"),Ti=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new K),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new K),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new jf(this._bufferService),this._activeSelectionMode=0,this._register(Ee(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]i.replace(Bf," ")).join(ml?`\r +`))}},Yd=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Gd=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Jd=0,Ur=class{constructor(e){this.value=e,this.id=Jd++}},Zd=2,Qd,V=class{constructor(e){var t,s,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new qd((e==null?void 0:e.onListenerError)??cr,((s=this._options)==null?void 0:s.leakWarningThreshold)??Vd):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Kd(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var a,l,h,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new Gd(`${d}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((a=this._options)==null?void 0:a.onListenerError)||cr)(g),ue.None}if(this._disposed)return ue.None;t&&(e=e.bind(t));let r=new Ur(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Xd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ur?(this._deliveryQueue??(this._deliveryQueue=new eu),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let o=Ee(()=>{i==null||i(),this._removeListener(r)});return s instanceof Gt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var i,o,a,l;if((o=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||o.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||l.call(a,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);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--,t[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Zd<=t.length){let h=0;for(let c=0;c0}},eu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_i=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new V,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new V,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};_i.INSTANCE=new _i;var Gi=_i;function tu(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Gi.INSTANCE.onDidChangeZoomLevel;function su(e){return Gi.INSTANCE.getZoomFactor(e)}Gi.INSTANCE.onDidChangeFullscreen;var bs=typeof navigator=="object"?navigator.userAgent:"",gi=bs.indexOf("Firefox")>=0,ru=bs.indexOf("AppleWebKit")>=0,Ji=bs.indexOf("Chrome")>=0,iu=!Ji&&bs.indexOf("Safari")>=0;bs.indexOf("Electron/")>=0;bs.indexOf("Android")>=0;var Kr=!1;if(typeof It.matchMedia=="function"){let e=It.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=It.matchMedia("(display-mode: fullscreen)");Kr=e.matches,tu(It,e,({matches:s})=>{Kr&&t.matches||(Kr=s)})}var vs="en",mi=!1,vi=!1,hr=!1,nl=!1,tr,dr=vs,fo=vs,nu,bt,as=globalThis,Ye,ta;typeof as.vscode<"u"&&typeof as.vscode.process<"u"?Ye=as.vscode.process:typeof process<"u"&&typeof((ta=process==null?void 0:process.versions)==null?void 0:ta.node)=="string"&&(Ye=process);var sa,ou=typeof((sa=Ye==null?void 0:Ye.versions)==null?void 0:sa.electron)=="string",au=ou&&(Ye==null?void 0:Ye.type)==="renderer",ra;if(typeof Ye=="object"){mi=Ye.platform==="win32",vi=Ye.platform==="darwin",hr=Ye.platform==="linux",hr&&Ye.env.SNAP&&Ye.env.SNAP_REVISION,Ye.env.CI||Ye.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tr=vs,dr=vs;let e=Ye.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);tr=t.userLocale,fo=t.osLocale,dr=t.resolvedLanguage||vs,nu=(ra=t.languagePack)==null?void 0:ra.translationsConfigFile}catch{}nl=!0}else typeof navigator=="object"&&!au?(bt=navigator.userAgent,mi=bt.indexOf("Windows")>=0,vi=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,hr=bt.indexOf("Linux")>=0,(bt==null?void 0:bt.indexOf("Mobi"))>=0,dr=globalThis._VSCODE_NLS_LANGUAGE||vs,tr=navigator.language.toLowerCase(),fo=tr):console.error("Unable to resolve platform.");var ol=mi,Mt=vi,lu=hr,po=nl,Rt=bt,Kt=dr,cu;(e=>{function t(){return Kt}e.value=t;function s(){return Kt.length===2?Kt==="en":Kt.length>=3?Kt[0]==="e"&&Kt[1]==="n"&&Kt[2]==="-":!1}e.isDefaultVariant=s;function r(){return Kt==="en"}e.isDefault=r})(cu||(cu={}));var hu=typeof as.postMessage=="function"&&!as.importScripts;(()=>{if(hu){let e=[];as.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r{let r=++t;e.push({id:r,callback:s}),as.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var du=!!(Rt&&Rt.indexOf("Chrome")>=0);Rt&&Rt.indexOf("Firefox")>=0;!du&&Rt&&Rt.indexOf("Safari")>=0;Rt&&Rt.indexOf("Edg/")>=0;Rt&&Rt.indexOf("Android")>=0;var _s=typeof navigator=="object"?navigator:{};po||document.queryCommandSupported&&document.queryCommandSupported("copy")||_s&&_s.clipboard&&_s.clipboard.writeText,po||_s&&_s.clipboard&&_s.clipboard.readText;var Zi=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}},Vr=new Zi,_o=new Zi,go=new Zi,uu=new Array(230),al;(e=>{function t(l){return Vr.keyCodeToStr(l)}e.toString=t;function s(l){return Vr.strToKeyCode(l)}e.fromString=s;function r(l){return _o.keyCodeToStr(l)}e.toUserSettingsUS=r;function i(l){return go.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function o(l){return _o.strToKeyCode(l)||go.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Vr.keyCodeToStr(l)}e.toElectronAccelerator=a})(al||(al={}));var fu=class ll{constructor(t,s,r,i,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=i,this.keyCode=o}equals(t){return t instanceof ll&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${s}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new pu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},pu=class{constructor(e){if(e.length===0)throw Wd("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof wu?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ge.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:cl})})(Su||(Su={}));var wu=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?cl:(this._emitter||(this._emitter=new V),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Qi=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 hi("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hi("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Cu=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,s=globalThis){if(this.isDisposed)throw new hi("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Ee(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ku;(e=>{async function t(r){let i,o=await Promise.all(r.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}e.settled=t;function s(r){return new Promise(async(i,o)=>{try{await r(i,o)}catch(a){o(a)}})}e.withAsyncBody=s})(ku||(ku={}));var yo=class pt{static fromArray(t){return new pt(s=>{s.emitMany(t)})}static fromPromise(t){return new pt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new pt(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new pt(async s=>{await Promise.all(t.map(async r=>{for await(let i of r)s.emitOne(i)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new V,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new pt(async r=>{for await(let i of t)r.emitOne(s(i))})}map(t){return pt.map(this,t)}static filter(t,s){return new pt(async r=>{for await(let i of t)s(i)&&r.emitOne(i)})}filter(t){return pt.filter(this,t)}static coalesce(t){return pt.filter(t,s=>!!s)}coalesce(){return pt.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return pt.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())}};yo.EMPTY=yo.fromArray([]);var{getWindow:jt,getWindowId:Eu,onDidRegisterWindow:Nu}=(function(){let e=new Map,t={window:It,disposables:new Gt};e.set(It.vscodeWindowId,t);let s=new V,r=new V,i=new V;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ue.None;let l=new Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(Ee(()=>{e.delete(a.vscodeWindowId),r.fire(a)})),l.add(ne(a,Fe.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:It},getDocument(a){return jt(a).document}}})(),ju=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!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 ne(e,t,s,r){return new ju(e,t,s,r)}var bo=function(e,t,s,r){return ne(e,t,s,r)},en,Mu=class extends Cu{constructor(e){super(),this.defaultTarget=e&&jt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},So=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){cr(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,i=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),r.set(o,!0);a.length>0;)a.sort(So.sort),a.shift().execute();r.set(o,!1)};en=(o,a,l=0)=>{let h=Eu(o),c=new So(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>i(h))),c}})();function Lu(e){let t=e.getBoundingClientRect(),s=jt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Fe={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"},Tu=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=rt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=rt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=rt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=rt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=rt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=rt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=rt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=rt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=rt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=rt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=rt(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=rt(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=rt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=rt(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 rt(e){return typeof e=="number"?`${e}px`:e}function As(e){return new Tu(e)}var hl=class{constructor(){this._hooks=new Gt,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let o=e;try{e.setPointerCapture(t),this._hooks.add(Ee(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=jt(e)}this._hooks.add(ne(o,Fe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ne(o,Fe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Ru(e,t,s){let r=null,i=null;if(typeof s.value=="function"?(r="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${t}`;s[r]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var Nt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Nt||(Nt={}));var Ls=class Ze extends ue{constructor(){super(),this.dispatched=!1,this.targets=new uo,this.ignoreTargets=new uo,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ge.runAndSubscribe(Nu,({window:t,disposables:s})=>{s.add(ne(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(ne(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(ne(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:It,disposables:this._store}))}static addTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.targets.push(t);return Ee(s)}static ignoreTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.ignoreTargets.push(t);return Ee(s)}static isTouchDevice(){return"ontouchstart"in It||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r=Ze.HOLD_DELAY&&Math.abs(h.initialPageX-lt(h.rollingPageX))<30&&Math.abs(h.initialPageY-lt(h.rollingPageY))<30){let u=this.newGestureEvent(Nt.Contextmenu,h.initialTarget);u.pageX=lt(h.rollingPageX),u.pageY=lt(h.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=lt(h.rollingPageX),d=lt(h.rollingPageY),_=lt(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],m=d-h.rollingPageY[0],x=[...this.targets].filter(w=>h.initialTarget instanceof Node&&w.contains(h.initialTarget));this.inertia(t,x,r,Math.abs(g)/_,g>0?1:-1,u,Math.abs(m)/_,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Nt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===Nt.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Ze.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Nt.Change||t.type===Nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,o=t.initialTarget;for(;o&&o!==r;)i++,o=o.parentElement;s.push([i,r])}s.sort((r,i)=>r[0]-i[0]);for(let[r,i]of s)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,i,o,a,l,h,c){this.handle=en(t,()=>{let u=Date.now(),d=u-r,_=0,g=0,m=!0;i+=Ze.SCROLL_FRICTION*d,l+=Ze.SCROLL_FRICTION*d,i>0&&(m=!1,_=o*i*d),l>0&&(m=!1,g=h*l*d);let x=this.newGestureEvent(Nt.Change);x.translationX=_,x.translationY=g,s.forEach(w=>w.dispatchEvent(x)),m||this.inertia(t,s,u,i,o,a+_,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let r=0,i=t.changedTouches.length;r3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ls.SCROLL_FRICTION=-.005,Ls.HOLD_DELAY=700,Ls.CLEAR_TAP_COUNT_TIME=400,Le([Ru],Ls,"isTouchDevice",1);var Bu=Ls,tn=class extends ue{onclick(e,t){this._register(ne(e,Fe.CLICK,s=>t(new sr(jt(e),s))))}onmousedown(e,t){this._register(ne(e,Fe.MOUSE_DOWN,s=>t(new sr(jt(e),s))))}onmouseover(e,t){this._register(ne(e,Fe.MOUSE_OVER,s=>t(new sr(jt(e),s))))}onmouseleave(e,t){this._register(ne(e,Fe.MOUSE_LEAVE,s=>t(new sr(jt(e),s))))}onkeydown(e,t){this._register(ne(e,Fe.KEY_DOWN,s=>t(new mo(s))))}onkeyup(e,t){this._register(ne(e,Fe.KEY_UP,s=>t(new mo(s))))}oninput(e,t){this._register(ne(e,Fe.INPUT,t))}onblur(e,t){this._register(ne(e,Fe.BLUR,t))}onfocus(e,t){this._register(ne(e,Fe.FOCUS,t))}onchange(e,t){this._register(ne(e,Fe.CHANGE,t))}ignoreGesture(e){return Bu.ignoreTarget(e)}},wo=11,Du=class extends tn{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=wo+"px",this.domNode.style.height=wo+"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 hl),this._register(bo(this.bgDomNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bo(this.domNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Mu),this._pointerdownScheduleRepeatTimer=this._register(new Qi)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,jt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Pu=class xi{constructor(t,s,r,i,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>r&&(i=r-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=r,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}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,s){return new xi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new xi(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,s){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:r,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Au=class extends ue{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Pu(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 r;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new ko(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=ko.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Co=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function qr(e,t){let s=t-e;return function(r){return e+s*Wu(r)}}function Ou(e,t,s){return function(r){return r2.5*r){let i,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":"")))}},$u=140,dl=class extends tn{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 Hu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new hl),this._shouldRender=!0,this.domNode=As(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(ne(this.domNode.domNode,Fe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Du(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=As(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ne(this.slider.domNode,Fe.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let i=Lu(this.domNode.domNode);t=e.pageX-i.left,s=e.pageY-i.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(ol&&a>$u){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{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()}},ul=class bi{constructor(t,s,r,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bi(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,i,o){let a=Math.max(0,r-t),l=Math.max(0,a-2*s),h=i>0&&i>r;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*l/i))),u=(l-c)/(i-r),d=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=bi._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let i=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(i,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(i,a),d=Math.max(o,l);u%h===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Si.INSTANCE=new Si;var Vu=Si,qu=class extends tn{constructor(e,t,s){super(),this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new V),this.onWillScroll=this._onWillScroll.event,this._options=Yu(t),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new zu(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Fu(this._scrollable,this._options,r)),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=As(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=As(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=As(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Qi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ls(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,Mt&&(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 xo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ls(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new xo(s))};this._mouseWheelToDispose.push(ne(this._listenOnDomNode,Fe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Vu.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!Mt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Eo*o,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(a){let u=Eo*a,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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,s=e.scrollLeft>0,r=s?" left":"",i=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${r}`)}}_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(),Uu)}},Xu=class extends qu{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Yu(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,Mt&&(t.className+=" mac"),t}var wi=class extends ue{constructor(e,t,s,r,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new V),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Au({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>en(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Xu(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ge.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ee(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ee(()=>this._styleElement.remove())),this._register(Ge.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(c=>this._handleScroll(c)))}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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};wi=Le([G(2,tt),G(3,Wt),G(4,Va),G(5,ys),G(6,st),G(7,Ht)],wi);var Ci=class extends ue{constructor(e,t,s,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=i,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(Ee(()=>{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 r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*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()}};Ci=Le([G(1,tt),G(2,Wt),G(3,Fs),G(4,Ht)],Ci);var Gu=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},kt={full:0,left:0,center:0,right:0},Vt={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},mr=class extends ue{constructor(e,t,s,r,i,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Gu,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(Ee(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Vt.full=this._canvas.width,Vt.left=e,Vt.center=t,Vt.right=e,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Vt.left,ws.right=1+Vt.left+Vt.center}_refreshDrawHeightConstants(){kt.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);kt.left=t,kt.center=t,kt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.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(ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kt[e.position||"full"]/2),Vt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kt[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}))}};mr=Le([G(2,tt),G(3,Fs),G(4,Ht),G(5,st),G(6,ys),G(7,Wt)],mr);var W;(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=""))(W||(W={}));var ur;(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="Ÿ"))(ur||(ur={}));var fl;(e=>e.ST=`${W.ESC}\\`)(fl||(fl={}));var ki=class{constructor(e,t,s,r,i,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=i,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};ki=Le([G(2,tt),G(3,st),G(4,hs),G(5,Ht)],ki);var ze=0,Ue=0,Ke=0,Me=0,No={css:"#00000000",rgba:0},Ae;(e=>{function t(i,o,a,l){return l!==void 0?`#${ss(i)}${ss(o)}${ss(a)}${ss(l)}`:`#${ss(i)}${ss(o)}${ss(a)}`}e.toCss=t;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function r(i,o,a,l){return{css:e.toCss(i,o,a,l),rgba:e.toRgba(i,o,a,l)}}e.toColor=r})(Ae||(Ae={}));var ke;(e=>{function t(h,c){if(Me=(c.rgba&255)/255,Me===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,_=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,x=h.rgba>>8&255;ze=g+Math.round((u-g)*Me),Ue=m+Math.round((d-m)*Me),Ke=x+Math.round((_-x)*Me);let w=Ae.toCss(ze,Ue,Ke),E=Ae.toRgba(ze,Ue,Ke);return{css:w,rgba:E}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function r(h,c,u){let d=fr.ensureContrastRatio(h.rgba,c.rgba,u);if(d)return Ae.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(h){let c=(h.rgba|255)>>>0;return[ze,Ue,Ke]=fr.toChannels(c),{css:Ae.toCss(ze,Ue,Ke),rgba:c}}e.opaque=i;function o(h,c){return Me=Math.round(c*255),[ze,Ue,Ke]=fr.toChannels(h.rgba),{css:Ae.toCss(ze,Ue,Ke,Me),rgba:Ae.toRgba(ze,Ue,Ke,Me)}}e.opacity=o;function a(h,c){return Me=h.rgba&255,o(h,Me*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ke||(ke={}));var je;(e=>{let t,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Ae.toColor(ze,Ue,Ke);case 5:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Me=parseInt(i.slice(4,5).repeat(2),16),Ae.toColor(ze,Ue,Ke,Me);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.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 ze=parseInt(o[1]),Ue=parseInt(o[2]),Ke=parseInt(o[3]),Me=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ae.toColor(ze,Ue,Ke,Me);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ue,Ke,Me]=t.getImageData(0,0,1,1).data,Me!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(ze,Ue,Ke,Me),css:i}}e.toColor=r})(je||(je={}));var Qe;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,i,o){let a=r/255,l=i/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=s})(Qe||(Qe={}));var fr;(e=>{function t(a,l){if(Me=(l&255)/255,Me===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,d=a>>24&255,_=a>>16&255,g=a>>8&255;return ze=d+Math.round((h-d)*Me),Ue=_+Math.round((c-_)*Me),Ke=g+Math.round((u-g)*Me),Ae.toRgba(ze,Ue,Ke)}e.blend=t;function s(a,l,h){let c=Qe.relativeLuminance(a>>8),u=Qe.relativeLuminance(l>>8);if(Pt(c,u)>8));if(m>8));return m>w?g:x}return g}let d=i(a,l,h),_=Pt(c,Qe.relativeLuminance(d>>8));if(_>8));return _>m?d:g}return d}}e.ensureContrastRatio=s;function r(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x0||g>0||m>0);)_-=Math.max(0,Math.ceil(_*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));return(_<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x>>0}e.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(fr||(fr={}));function ss(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e1){let u=this._getJoinedRanges(r,a,o,t,i);for(let d=0;d1){let c=this._getJoinedRanges(r,a,o,t,i);for(let u=0;u=O,j=p,M=this._workCell;if(_.length>0&&p===_[0][0]&&y){let ge=_.shift(),$t=this._isCellInSelection(ge[0],t);for(k=ge[0]+1;k=ge[1]),y?(b=!0,M=new Ju(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),j=ge[1]-1,f=M.getWidth()):O=ge[1]}let z=this._isCellInSelection(p,t),C=s&&p===o,H=R&&p>=c&&p<=u,U=!1;this._decorationService.forEachDecorationAtCell(p,t,void 0,ge=>{U=!0});let q=M.getChars()||Yt;if(q===" "&&(M.isUnderline()||M.isOverline())&&(q=" "),T=f*l-h.get(q,M.isBold(),M.isItalic()),!x)x=this._document.createElement("span");else if(w&&(z&&B||!z&&!B&&M.bg===P)&&(z&&B&&g.selectionForeground||M.fg===A)&&M.extended.ext===D&&H===N&&T===$&&!C&&!b&&!U&&y){M.isInvisible()?E+=Yt:E+=q,w++;continue}else w&&(x.textContent=E),x=this._document.createElement("span"),w=0,E="";if(P=M.bg,A=M.fg,D=M.extended.ext,N=H,$=T,B=z,b&&o>=p&&o<=j&&(o=p),!this._coreService.isCursorHidden&&C&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&L.push("xterm-cursor-blink"),L.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(M.isBold()&&L.push("xterm-bold"),M.isItalic()&&L.push("xterm-italic"),M.isDim()&&L.push("xterm-dim"),M.isInvisible()?E=Yt:E=M.getChars()||Yt,M.isUnderline()&&(L.push(`xterm-underline-${M.extended.underlineStyle}`),E===" "&&(E=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${$s.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let ge=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&ge<8&&(ge+=8),x.style.textDecorationColor=g.ansi[ge].css}M.isOverline()&&(L.push("xterm-overline"),E===" "&&(E=" ")),M.isStrikethrough()&&L.push("xterm-strikethrough"),H&&(x.style.textDecoration="underline");let ee=M.getFgColor(),ie=M.getFgColorMode(),F=M.getBgColor(),se=M.getBgColorMode(),pe=!!M.isInverse();if(pe){let ge=ee;ee=F,F=ge;let $t=ie;ie=se,se=$t}let _e,qe,St=!1;this._decorationService.forEachDecorationAtCell(p,t,void 0,ge=>{ge.options.layer!=="top"&&St||(ge.backgroundColorRGB&&(se=50331648,F=ge.backgroundColorRGB.rgba>>8&16777215,_e=ge.backgroundColorRGB),ge.foregroundColorRGB&&(ie=50331648,ee=ge.foregroundColorRGB.rgba>>8&16777215,qe=ge.foregroundColorRGB),St=ge.options.layer==="top")}),!St&&z&&(_e=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,F=_e.rgba>>8&16777215,se=50331648,St=!0,g.selectionForeground&&(ie=50331648,ee=g.selectionForeground.rgba>>8&16777215,qe=g.selectionForeground)),St&&L.push("xterm-decoration-top");let ht;switch(se){case 16777216:case 33554432:ht=g.ansi[F],L.push(`xterm-bg-${F}`);break;case 50331648:ht=Ae.toColor(F>>16,F>>8&255,F&255),this._addStyle(x,`background-color:#${jo((F>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(ht=g.foreground,L.push("xterm-bg-257")):ht=g.background}switch(_e||M.isDim()&&(_e=ke.multiplyOpacity(ht,.5)),ie){case 16777216:case 33554432:M.isBold()&&ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ee+=8),this._applyMinimumContrast(x,ht,g.ansi[ee],M,_e,void 0)||L.push(`xterm-fg-${ee}`);break;case 50331648:let ge=Ae.toColor(ee>>16&255,ee>>8&255,ee&255);this._applyMinimumContrast(x,ht,ge,M,_e,qe)||this._addStyle(x,`color:#${jo(ee.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,ht,g.foreground,M,_e,qe)||pe&&L.push("xterm-fg-257")}L.length&&(x.className=L.join(" "),L.length=0),!C&&!b&&!U&&y?w++:x.textContent=E,T!==this.defaultSpacing&&(x.style.letterSpacing=`${T}px`),d.push(x),p=j}return x&&w&&(x.textContent=E),d}_applyMinimumContrast(e,t,s,r,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||ef(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!i&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ke.ensureContrastRatio(i||t,o||s,h),a.setColor((i||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t=s[0]&&e=s[0]}};Ei=Le([G(1,Ya),G(2,st),G(3,Wt),G(4,hs),G(5,Fs),G(6,ys)],Ei);function jo(e,t,s){for(;e.length0&&(this._flat[r]=a),a}let i=e;t&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(i,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},rf=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let i=e.buffers.active.ydisp,o=t[1]-i,a=s[1]-i,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function nf(){return new rf}var Xr="xterm-dom-renderer-owner-",ft="xterm-rows",ir="xterm-fg-",Mo="xterm-bg-",Cs="xterm-focus",nr="xterm-selection",of=1,Ni=class extends ue{constructor(e,t,s,r,i,o,a,l,h,c,u,d,_,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=_,this._themeService=g,this._terminalClass=of++,this._rowElements=[],this._selectionRenderModel=nf(),this.onRequestRedraw=this._register(new V).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ft),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(nr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=tf(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ei,document),this._element.classList.add(Xr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ee(()=>{this._element.classList.remove(Xr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new sf(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ft} 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} .${ft} { 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} .${ft} .xterm-dim { color: ${ke.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${nr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${nr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${nr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${ir}${o} { color: ${a.css}; }${this._terminalSelector} .${ir}${o}.xterm-dim { color: ${ke.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Mo}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${ir}257 { color: ${ke.opaque(e.background).css}; }${this._terminalSelector} .${ir}257.xterm-dim { color: ${ke.multiplyOpacity(ke.opaque(e.background),.5).css}; }${this._terminalSelector} .${Mo}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 s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let d=i===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,d))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,r=1){let i=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}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 s=this._bufferService.buffer,r=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],d=s.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Xr}${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,s,r,i,o){s<0&&(e=0),r<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=r;++g){let m=g+l.ydisp,x=this._rowElements[g],w=l.lines.get(m);if(!x||!w)break;x.replaceChildren(...this._rowFactory.createRow(w,m,m===h,d,_,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===r?t:i)-1:-1))}}};Ni=Le([G(7,Xi),G(8,Nr),G(9,st),G(10,tt),G(11,hs),G(12,Wt),G(13,ys)],Ni);var ji=class extends ue{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new V),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new lf(this._optionsService))}catch{this._measureStrategy=this._register(new af(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())}};ji=Le([G(2,st)],ji);var pl=class extends ue{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)}},af=class extends pl{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},lf=class extends pl{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}},cf=class extends ue{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hf(this._window)),this._onDprChange=this._register(new V),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new V),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ge.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ne(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}},hf=class extends ue{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new xs),this._onDprChange=this._register(new V),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ee(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ne(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)}},df=class extends ue{constructor(){super(),this.linkProviders=[],this._register(Ee(()=>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 sn(e,t,s){let r=s.getBoundingClientRect(),i=e.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-o,t.clientY-r.top-a]}function uf(e,t,s,r,i,o,a,l,h){if(!o)return;let c=sn(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),r+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var Mi=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,i){return uf(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let s=sn(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Mi=Le([G(0,Ht),G(1,Nr)],Mi);var ff=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,s){this._rowCount=s,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=[]}},_l={};Sd(_l,{getSafariVersion:()=>_f,isChromeOS:()=>xl,isFirefox:()=>gl,isIpad:()=>gf,isIphone:()=>mf,isLegacyEdge:()=>pf,isLinux:()=>rn,isMac:()=>xr,isNode:()=>jr,isSafari:()=>ml,isWindows:()=>vl});var jr=typeof process<"u"&&"title"in process,zs=jr?"node":navigator.userAgent,Us=jr?"node":navigator.platform,gl=zs.includes("Firefox"),pf=zs.includes("Edge"),ml=/^((?!chrome|android).)*safari/i.test(zs);function _f(){if(!ml)return 0;let e=zs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var xr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Us),gf=Us==="iPad",mf=Us==="iPhone",vl=["Windows","Win16","Win32","WinCE"].includes(Us),rn=Us.indexOf("Linux")>=0,xl=/\bCrOS\b/.test(zs),yl=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},vf=class extends yl{_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())}}},xf=class extends yl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},yr=!jr&&"requestIdleCallback"in window?xf:vf,yf=class{constructor(){this._queue=new yr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Li=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new xs),this._pausedResizeTask=new yf,this._observerDisposable=this._register(new xs),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 V),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new V),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new V),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new V),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ff((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new bf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ee(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.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(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ee(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(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 s;return(s=this._renderer.value)==null?void 0:s.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,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Li=Le([G(2,st),G(3,Nr),G(4,hs),G(5,Fs),G(6,tt),G(7,Wt),G(8,ys)],Li);var bf=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 Sf(e,t,s,r){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return kf(i,o,e,t,s,r)+Mr(o,t,s,r)+Ef(i,o,e,t,s,r);let a;if(o===t)return a=i>e?"D":"C",Ws(Math.abs(i-e),Is(a,r));a=o>t?"D":"C";let l=Math.abs(o-t),h=Cf(o>t?e:i,s)+(l-1)*s.cols+1+wf(o>t?i:e);return Ws(h,Is(a,r))}function wf(e,t){return e-1}function Cf(e,t){return t.cols-e}function kf(e,t,s,r,i,o){return Mr(t,r,i,o).length===0?"":Ws(Sl(e,t,e,t-cs(t,i),!1,i).length,Is("D",o))}function Mr(e,t,s,r){let i=e-cs(e,s),o=t-cs(t,s),a=Math.abs(i-o)-Nf(e,t,s);return Ws(a,Is(bl(e,t),r))}function Ef(e,t,s,r,i,o){let a;Mr(t,r,i,o).length>0?a=r-cs(r,i):a=t;let l=r,h=jf(e,t,s,r,i,o);return Ws(Sl(e,a,s,l,h==="C",i).length,Is(h,o))}function Nf(e,t,s){var a;let r=0,i=e-cs(e,s),o=t-cs(t,s);for(let l=0;l=0&&e0?a=r-cs(r,i):a=t,e=s&&at?"A":"B"}function Sl(e,t,s,r,i,o){let a=e,l=t,h="";for(;(a!==s||l!==r)&&l>=0&&lo.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!i&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function Is(e,t){let s=t?"O":"[";return W.ESC+s+e}function Ws(e,t){e=Math.floor(e);let s="";for(let r=0;rthis._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 Lo(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 Yr=50,Lf=15,Tf=50,Rf=500,Bf=" ",Df=new RegExp(Bf,"g"),Ti=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new V),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new V),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new V),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new V),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Mf(this._bufferService),this._activeSelectionMode=0,this._register(Ee(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]i.replace(Df," ")).join(vl?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),rn&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var i,o;let s=(o=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Lo(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=sn(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Yr),Yr),t/=Yr,t/Math.abs(t)+Math.round(t*(Mf-1)))}shouldForceSelection(e){return xr?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(),Lf)}_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&&!(xr&&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 s=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 s=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&t!==r&&(s+=i-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(e[1]);if(!o)return;let a=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,d=0,p=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h1&&(g+=C-1,h+=C-1);w>0&&l>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):A>1&&(p+=A-1,l-=A-1),l--,w--}for(;k1&&(g+=A-1,h+=A-1),h++,k++}}h++;let m=l+c-u+p,y=Math.min(this._bufferService.cols,h-l+u+d-p-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let C=this._bufferService.cols-k.start;m-=C,y+=C}}}if(r&&m+y===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(y+=k.length)}}return{start:m,length:y}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=Lo(s,this._bufferService.cols)}};Ti=Le([Y(3,tt),Y(4,hs),Y(5,Yi),Y(6,st),Y(7,Ht),Y(8,Wt)],Ti);var To=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ro=class{constructor(){this._color=new To,this._css=new To}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ie=Object.freeze((()=>{let e=[je.toColor("#2e3436"),je.toColor("#cc0000"),je.toColor("#4e9a06"),je.toColor("#c4a000"),je.toColor("#3465a4"),je.toColor("#75507b"),je.toColor("#06989a"),je.toColor("#d3d7cf"),je.toColor("#555753"),je.toColor("#ef2929"),je.toColor("#8ae234"),je.toColor("#fce94f"),je.toColor("#729fcf"),je.toColor("#ad7fa8"),je.toColor("#34e2e2"),je.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],i=t[s/6%6|0],o=t[s%6];e.push({css:Ae.toCss(r,i,o),rgba:Ae.toRgba(r,i,o)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:Ae.toCss(r,r,r),rgba:Ae.toRgba(r,r,r)})}return e})()),rs=je.toColor("#ffffff"),Ts=je.toColor("#000000"),Bo=je.toColor("#ffffff"),Do=Ts,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Df=rs,Ri=class extends ue{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ro,this._halfContrastCache=new Ro,this._onChangeColors=this._register(new K),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rs,background:Ts,cursor:Bo,cursorAccent:Do,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:ke.blend(Ts,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:ke.blend(Ts,ks),scrollbarSliderBackground:ke.opacity(rs,.2),scrollbarSliderHoverBackground:ke.opacity(rs,.4),scrollbarSliderActiveBackground:ke.opacity(rs,.5),overviewRulerBorder:rs,ansi:Ie.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=be(e.foreground,rs),t.background=be(e.background,Ts),t.cursor=ke.blend(t.background,be(e.cursor,Bo)),t.cursorAccent=ke.blend(t.background,be(e.cursorAccent,Do)),t.selectionBackgroundTransparent=be(e.selectionBackground,ks),t.selectionBackgroundOpaque=ke.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=be(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ke.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?be(e.selectionForeground,No):void 0,t.selectionForeground===No&&(t.selectionForeground=void 0),ke.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ke.opacity(t.selectionBackgroundTransparent,.3)),ke.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ke.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=be(e.scrollbarSliderBackground,ke.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=be(e.scrollbarSliderHoverBackground,ke.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=be(e.scrollbarSliderActiveBackground,ke.opacity(t.foreground,.5)),t.overviewRulerBorder=be(e.overviewRulerBorder,Df),t.ansi=Ie.slice(),t.ansi[0]=be(e.black,Ie[0]),t.ansi[1]=be(e.red,Ie[1]),t.ansi[2]=be(e.green,Ie[2]),t.ansi[3]=be(e.yellow,Ie[3]),t.ansi[4]=be(e.blue,Ie[4]),t.ansi[5]=be(e.magenta,Ie[5]),t.ansi[6]=be(e.cyan,Ie[6]),t.ansi[7]=be(e.white,Ie[7]),t.ansi[8]=be(e.brightBlack,Ie[8]),t.ansi[9]=be(e.brightRed,Ie[9]),t.ansi[10]=be(e.brightGreen,Ie[10]),t.ansi[11]=be(e.brightYellow,Ie[11]),t.ansi[12]=be(e.brightBlue,Ie[12]),t.ansi[13]=be(e.brightMagenta,Ie[13]),t.ansi[14]=be(e.brightCyan,Ie[14]),t.ansi[15]=be(e.brightWhite,Ie[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;ro.index-a.index),r=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);r.push(a)}let i=s.length>0?s[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Of={trace:0,debug:1,info:2,warn:3,error:4,off:5},If="xterm.js: ",Bi=class extends ue{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=Of[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=t-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*he+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*he+0]=t|2097152|s[2]<<22):this._data[t*he+0]=s[1].charCodeAt(0)|s[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 s=this._data[t*he+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*he+0]&2097152}getString(t){let s=this._data[t*he+0];return s&2097152?this._combined[t]:s&2097151?Xt(s&2097151):""}isProtected(t){return this._data[t*he+2]&536870912}loadCell(t,s){return or=t*he,s.content=this._data[or+0],s.fg=this._data[or+1],s.bg=this._data[or+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*he+0]=s.content,this._data[t*he+1]=s.fg,this._data[t*he+2]=s.bg}setCellFromCodepoint(t,s,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*he+0]=s|r<<22,this._data[t*he+1]=i.fg,this._data[t*he+2]=i.bg}addCodepointToCell(t,s,r){let i=this._data[t*he+0];i&2097152?this._combined[t]+=Xt(s):i&2097151?(this._combined[t]=Xt(i&2097151)+Xt(s),i&=-2097152,i|=2097152):i=s|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*he+0]=i}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s=0;--o)this.setCell(t+s+o,this.loadCell(t+o,i));for(let o=0;othis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*Gr=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,s,r,i,o){let a=t._data;if(o)for(let h=i-1;h>=0;h--){for(let c=0;c=s&&(this._combined[c-s+r]=t._combined[c])}}translateToString(t,s,r,i){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s>22||1}return i&&i.push(s),o}};function Wf(e,t,s,r,i,o){let a=[];for(let l=0;l=l&&r0&&(w>d||u[w].getTrimmedLength()===0);w--)y++;y>0&&(a.push(l+u.length-y),a.push(y)),l+=u.length-1}return a}function Hf(e,t){let s=[],r=0,i=t[r],o=0;for(let a=0;aHs(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;lh&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;r.push(u),l+=u}return r}function Hs(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?s-1:s}var wl=class Cl{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Cl._nextId++,this._onDispose=this.register(new K),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ls(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};wl._nextId=1;var zf=wl,He={},is=He.B;He[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:"≥","{":"π","|":"≠","}":"£","~":"·"};He.A={"#":"£"};He.B=void 0;He[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};He.C=He[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};He.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};He.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};He.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};He.E=He[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};He.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};He.H=He[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ao=4294967295,Oo=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Pe.clone(),this.savedCharset=is,this.markers=[],this._nullCell=mt.fromCharData([0,$a,1,0]),this._whitespaceCell=mt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new yr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Po(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 gr),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 gr),this._whitespaceCell}getBlankLine(e,t){return new Rs(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&&eAo?Ao:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Pe);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 Po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Pe),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),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 Rs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}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 s=this._optionsService.rawOptions.reflowCursorLine,r=Wf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Pe),s);if(r.length>0){let i=Hf(this.lines,r);$f(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(Pe),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let A=this.ybase+this.y;if(A>=a&&A0&&(i.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=u.length-1,y=u[m];y===0&&(m--,y=u[m]);let w=h.length-d-1,k=c;for(;w>=0;){let A=Math.min(k,y);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[w],k-A,y-A,A,!0),y-=A,y===0&&(m--,y=u[m]),k-=A,k===0){w--;let O=Math.max(w,0);k=Hs(h,O,this._cols)}}for(let A=0;A0;)this.ybase===0?this.y0){let a=[],l=[];for(let y=0;y=0;y--)if(d&&d.start>c+p){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(y--,d.newLines[w]);y++,a.push({index:c+1,amount:d.newLines.length}),p+=d.newLines.length,d=i[++u]}else this.lines.set(y,l[c--]);let g=0;for(let y=a.length-1;y>=0;y--)a[y].index+=g,this.lines.onInsertEmitter.fire(a[y]),g+=a[y].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,r){let i=this.lines.get(e);return i?i.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+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-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Uf=class extends ue{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new K),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 Oo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Oo(!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)}},kl=2,El=1,Di=class extends ue{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,kl),this.rows=Math.max(e.rawOptions.rows||0,El),this.buffers=this._register(new Uf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(o+1,0,r.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Di=Le([Y(0,st)],Di);var gs={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:xr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Kf=["normal","bold","100","200","300","400","500","600","700","800","900"],Vf=class extends ue{constructor(e){super(),this._onOptionChange=this._register(new K),this.onOptionChange=this._onOptionChange.event;let t={...gs};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=gs[e]),!qf(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=gs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Kf.includes(t)?t:gs[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 qf(e){return e==="block"||e==="underline"||e==="bar"}function Bs(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&Bs(e[r],t-1);return s}var Io=Object.freeze({insertMode:!1}),Wo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Pi=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new K),this.onData=this._onData.event,this._onUserInput=this._register(new K),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new K),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}reset(){this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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))}};Pi=Le([Y(0,tt),Y(1,Va),Y(2,st)],Pi);var Ho={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 Jr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Zr=String.fromCharCode,$o={DEFAULT:e=>{let t=[Jr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Zr(t[0])}${Zr(t[1])}${Zr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.x};${e.y}${t}`}},Ai=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new K),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Ho))this.addProtocol(r,Ho[r]);for(let r of Object.keys($o))this.addEncoding(r,$o[r]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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,s){if(s){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)}};Ai=Le([Y(0,tt),Y(1,hs),Y(2,st)],Ai);var Qr=[[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]],Xf=[[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]],We;function Yf(e,t){let s=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let i=os.extractWidth(t);i===0?r=!1:i>s&&(s=i)}return os.createPropertyValue(0,s,r)}},os=class pr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new K,this.onChange=this._onChange.event;let t=new Gf;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,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?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 s=0,r=0,i=t.length;for(let o=0;o=i)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,r),h=pr.extractWidth(l);pr.extractShouldJoin(l)&&(h-=pr.extractWidth(r)),s+=h,r=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Jf=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 Fo(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Es=2147483647,Zf=256,Nl=class Oi{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Zf)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Oi;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r>8,i=this._subParamsIdx[s]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>Es?Es: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>Es?Es:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s>8,i=this._subParamsIdx[s]&255;i-r>0&&(t[s]=this._subParams.slice(r,i))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[s-1];r[s-1]=~i?Math.min(i*10+t,Es):t}},Ns=[],Qf=class{constructor(){this._state=0,this._active=Ns,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=Ns}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=Ns,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ns,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Ns,this._id=-1,this._state=0}}},at=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},js=[],ep=class{constructor(){this._handlers=Object.create(null),this._active=js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=js,this._ident=0}},Ds=new Nl;Ds.addParam(0);var zo=class{constructor(e){this._handler=e,this._data="",this._params=Ds,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ds,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._params=Ds,this._data="",this._hitLimit=!1,s));return this._params=Ds,this._data="",this._hitLimit=!1,t}},tp=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let i=0;ih),s=(l,h)=>t.slice(l,h),r=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(r,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_t,0,2,0),e.add(_t,8,5,8),e.add(_t,6,0,6),e.add(_t,11,0,11),e.add(_t,13,13,13),e})(),rp=class extends ue{constructor(e=sp){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 Nl,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Qf),this._dcsParser=this._register(new ep),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 i=0;io||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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,s,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,s){let r=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===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 l=o;l>4){case 2:for(let p=l+1;;++p){if(p>=t||(r=e[p])<32||r>126&&r<_t){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<_t){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<_t){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<_t){this._printHandler(e,l,p),l=p-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,i,l),a;c<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(a=u[d](),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(4,u,d,i,l),a;d<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let p=l+1;;++p)if(p>=t||(r=e[p])===24||r===26||r===27||r>127&&r<_t){this._dcsParser.put(e,l,p),l=p-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let p=l+1;;p++)if(p>=t||(r=e[p])<32||r>127&&r<_t){this._oscParser.put(e,l,p),l=p-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},ip=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,np=/^[\da-f]+$/;function Uo(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=ip.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),np.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(t.slice(s*i,s*i+s),16);r[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return r}}function ei(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function op(e,t=16){let[s,r,i]=e;return`rgb:${ei(s,t)}/${ei(r,t)}/${ei(i,t)}`}var ap={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,Ko=10;function Vo(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 qo=5e3,Xo=0,lp=class extends ue{constructor(e,t,s,r,i,o,a,l,h=new rp){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Ed,this._utf8Decoder=new Nd,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone(),this._onRequestBell=this._register(new K),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new K),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new K),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new K),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new K),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new K),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new K),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new K),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new K),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 Ii(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(H.BEL,()=>this.bell()),this._parser.setExecuteHandler(H.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(H.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(H.BS,()=>this.backspace()),this._parser.setExecuteHandler(H.HT,()=>this.tab()),this._parser.setExecuteHandler(H.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(H.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ur.IND,()=>this.index()),this._parser.setExecuteHandler(ur.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ur.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new at(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new at(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new at(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new at(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new at(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new at(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new at(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new at(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new at(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new at(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new at(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new at(c=>this.restoreCursorColor(c))),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 c in He)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new zo((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),qo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.lengthqt)for(let c=o;c0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let p=this._parser.precedingJoinState;for(let g=t;gl){if(h){let k=d,C=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&d instanceof Rs&&d.copyCellsFrom(k,C,0,w,!1);C=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(l-1)===2&&d.setCellFromCodepoint(l-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=p,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>Vo(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new zo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new at(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,s,r=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&r.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 h=l;for(let c=1;c0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(H.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(H.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(H.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(H.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(H.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(y[y.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",y[y.SET=1]="SET",y[y.RESET=2]="RESET",y[y.PERMANENTLY_SET=3]="PERMANENTLY_SET",y[y.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,d=this._optionsService.rawOptions,p=(y,w)=>(a.triggerDataEvent(`${H.ESC}[${t?"":"?"}${y};${w}$y`),!0),g=y=>y?1:2,m=e.params[0];return t?m===2?p(m,4):m===4?p(m,g(a.modes.insertMode)):m===12?p(m,3):m===20?p(m,g(d.convertEol)):p(m,0):m===1?p(m,g(r.applicationCursorKeys)):m===3?p(m,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?p(m,g(r.origin)):m===7?p(m,g(r.wraparound)):m===8?p(m,3):m===9?p(m,g(i==="X10")):m===12?p(m,g(d.cursorBlink)):m===25?p(m,g(!a.isCursorHidden)):m===45?p(m,g(r.reverseWraparound)):m===66?p(m,g(r.applicationKeypad)):m===67?p(m,4):m===1e3?p(m,g(i==="VT200")):m===1002?p(m,g(i==="DRAG")):m===1003?p(m,g(i==="ANY")):m===1004?p(m,g(r.sendFocus)):m===1005?p(m,4):m===1006?p(m,g(o==="SGR")):m===1015?p(m,4):m===1016?p(m,g(o==="SGR_PIXELS")):m===1048?p(m,1):m===47||m===1047||m===1049?p(m,g(c===u)):m===2004?p(m,g(r.bracketedPasteMode)):m===2026?p(m,g(r.synchronizedOutput)):p(m,0)}_updateAttrColor(e,t,s,r,i){return t===2?(e|=50331648,e&=-16777216,e|=$s.fromColorRGB([s,r,i])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],i=0,o=0;do{if(r[o+i]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do r[1]===5&&(i=1),r[o+l+1+i]=a[l];while(++l=2||r[1]===2&&o+i>=5)break;r[1]&&(i=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Pe.fg,e.bg=Pe.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,s,r=this._curAttrData;for(let i=0;i=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=Pe.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=Pe.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(e,i,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=Pe.fg&16777215,r.bg&=-67108864,r.bg|=Pe.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${H.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${H.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${H.ESC}[?${t};${s}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=Pe.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Vo(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(`${H.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ko&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ko&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),i=s.shift();if(/^\d+$/.exec(r)){let o=parseInt(r);if(Yo(o))if(i==="?")t.push({type:0,index:o});else{let a=Uo(i);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(r=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,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 s=e.split(";");for(let r=0;r=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=Uo(s[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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=[],s=e.split(";");for(let r=0;r=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=Pe.clone(),this._eraseAttrDataInternal=Pe.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 mt;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(`${H.ESC}${a}${H.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ii=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&&(Xo=e,e=t,t=Xo),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ii=Le([Y(0,tt)],Ii);function Yo(e){return 0<=e&&e<256}var cp=5e7,Go=12,hp=50,dp=class extends ue{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 K),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>cp)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let a=l=>performance.now()-s>=Go?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Go)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>hp&&(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()}},Wi=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 l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}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 s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wi=Le([Y(0,tt)],Wi);var Jo=!1,up=class extends ue{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new xs),this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onData=this._register(new K),this.onData=this._onData.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new K),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new K),this._instantiationService=new Af,this.optionsService=this._register(new Vf(e)),this._instantiationService.setService(st,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Di)),this._instantiationService.setService(tt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Bi)),this._instantiationService.setService(Va,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Pi)),this._instantiationService.setService(hs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ai)),this._instantiationService.setService(Ka,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(os)),this._instantiationService.setService(Td,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Jf),this._instantiationService.setService(Ld,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wi),this._instantiationService.setService(qa,this._oscLinkService),this._inputHandler=this._register(new lp(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ge.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ge.forward(this._bufferService.onResize,this._onResize)),this._register(Ge.forward(this.coreService.onData,this._onData)),this._register(Ge.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 dp((t,s)=>this._inputHandler.parse(t,s))),this._register(Ge.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new K),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&&!Jo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Jo=!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,kl),t=Math.max(t,El),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(Fo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Fo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ee(()=>{for(let t of e)t.dispose()})}}},fp={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 pp(e,t,s,r){var a;let i={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?i.key=H.ESC+"OA":i.key=H.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=H.ESC+"OD":i.key=H.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=H.ESC+"OC":i.key=H.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=H.ESC+"OB":i.key=H.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":H.DEL,e.altKey&&(i.key=H.ESC+i.key);break;case 9:if(e.shiftKey){i.key=H.ESC+"[Z";break}i.key=H.HT,i.cancel=!0;break;case 13:i.key=e.altKey?H.ESC+H.CR:H.CR,i.cancel=!0;break;case 27:i.key=H.ESC,e.altKey&&(i.key=H.ESC+H.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;o?i.key=H.ESC+"[1;"+(o+1)+"D":t?i.key=H.ESC+"OD":i.key=H.ESC+"[D";break;case 39:if(e.metaKey)break;o?i.key=H.ESC+"[1;"+(o+1)+"C":t?i.key=H.ESC+"OC":i.key=H.ESC+"[C";break;case 38:if(e.metaKey)break;o?i.key=H.ESC+"[1;"+(o+1)+"A":t?i.key=H.ESC+"OA":i.key=H.ESC+"[A";break;case 40:if(e.metaKey)break;o?i.key=H.ESC+"[1;"+(o+1)+"B":t?i.key=H.ESC+"OB":i.key=H.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=H.ESC+"[2~");break;case 46:o?i.key=H.ESC+"[3;"+(o+1)+"~":i.key=H.ESC+"[3~";break;case 36:o?i.key=H.ESC+"[1;"+(o+1)+"H":t?i.key=H.ESC+"OH":i.key=H.ESC+"[H";break;case 35:o?i.key=H.ESC+"[1;"+(o+1)+"F":t?i.key=H.ESC+"OF":i.key=H.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=H.ESC+"[5;"+(o+1)+"~":i.key=H.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=H.ESC+"[6;"+(o+1)+"~":i.key=H.ESC+"[6~";break;case 112:o?i.key=H.ESC+"[1;"+(o+1)+"P":i.key=H.ESC+"OP";break;case 113:o?i.key=H.ESC+"[1;"+(o+1)+"Q":i.key=H.ESC+"OQ";break;case 114:o?i.key=H.ESC+"[1;"+(o+1)+"R":i.key=H.ESC+"OR";break;case 115:o?i.key=H.ESC+"[1;"+(o+1)+"S":i.key=H.ESC+"OS";break;case 116:o?i.key=H.ESC+"[15;"+(o+1)+"~":i.key=H.ESC+"[15~";break;case 117:o?i.key=H.ESC+"[17;"+(o+1)+"~":i.key=H.ESC+"[17~";break;case 118:o?i.key=H.ESC+"[18;"+(o+1)+"~":i.key=H.ESC+"[18~";break;case 119:o?i.key=H.ESC+"[19;"+(o+1)+"~":i.key=H.ESC+"[19~";break;case 120:o?i.key=H.ESC+"[20;"+(o+1)+"~":i.key=H.ESC+"[20~";break;case 121:o?i.key=H.ESC+"[21;"+(o+1)+"~":i.key=H.ESC+"[21~";break;case 122:o?i.key=H.ESC+"[23;"+(o+1)+"~":i.key=H.ESC+"[23~";break;case 123:o?i.key=H.ESC+"[24;"+(o+1)+"~":i.key=H.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=H.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=H.DEL:e.keyCode===219?i.key=H.ESC:e.keyCode===220?i.key=H.FS:e.keyCode===221&&(i.key=H.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let l=(a=fp[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)i.key=H.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),i.key=H.ESC+c}else if(e.keyCode===32)i.key=H.ESC+(e.ctrlKey?H.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),i.key=H.ESC+h,i.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=H.US),e.key==="@"&&(i.key=H.NUL));break}return i}var Be=0,_p=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new yr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new yr,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((i,o)=>this._getKey(i)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[i]=e[t],t++):r[i]=this._array[s++];this._array=r,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||(Be=this._search(t),Be===-1)||this._getKey(this._array[Be])!==t)return!1;do if(this._array[Be]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Be),!0;while(++Bei-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Be=this._search(e),!(Be<0||Be>=this._array.length)&&this._getKey(this._array[Be])===e))do yield this._array[Be];while(++Be=this._array.length)&&this._getKey(this._array[Be])===e))do t(this._array[Be]);while(++Be=t;){let r=t+s>>1,i=this._getKey(this._array[r]);if(i>e)s=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ti=0,Zo=0,gp=class extends ue{constructor(){super(),this._decorations=new _p(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new K),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new K),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new mp(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,i=0;for(let o of this._decorations.getKeyIterator(t))r=o.options.x??0,i=r+(o.options.width??1),e>=r&&e{ti=i.options.x??0,Zo=ti+(i.options.width??1),e>=ti&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,o=this._debounceThresholdMS-i;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)}},Qo=20,br=class extends ue{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new xp(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(` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),rn&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var i,o;let s=(o=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Lo(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=sn(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Yr),Yr),t/=Yr,t/Math.abs(t)+Math.round(t*(Lf-1)))}shouldForceSelection(e){return xr?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(),Tf)}_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&&!(xr&&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 s=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 s=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&t!==r&&(s+=i-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(e[1]);if(!o)return;let a=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,d=0,_=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h1&&(g+=k-1,h+=k-1);w>0&&l>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):P>1&&(_+=P-1,l-=P-1),l--,w--}for(;E1&&(g+=P-1,h+=P-1),h++,E++}}h++;let m=l+c-u+_,x=Math.min(this._bufferService.cols,h-l+u+d-_-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let k=this._bufferService.cols-E.start;m-=k,x+=k}}}if(r&&m+x===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(x+=E.length)}}return{start:m,length:x}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=Lo(s,this._bufferService.cols)}};Ti=Le([G(3,tt),G(4,hs),G(5,Yi),G(6,st),G(7,Ht),G(8,Wt)],Ti);var To=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ro=class{constructor(){this._color=new To,this._css=new To}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ie=Object.freeze((()=>{let e=[je.toColor("#2e3436"),je.toColor("#cc0000"),je.toColor("#4e9a06"),je.toColor("#c4a000"),je.toColor("#3465a4"),je.toColor("#75507b"),je.toColor("#06989a"),je.toColor("#d3d7cf"),je.toColor("#555753"),je.toColor("#ef2929"),je.toColor("#8ae234"),je.toColor("#fce94f"),je.toColor("#729fcf"),je.toColor("#ad7fa8"),je.toColor("#34e2e2"),je.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],i=t[s/6%6|0],o=t[s%6];e.push({css:Ae.toCss(r,i,o),rgba:Ae.toRgba(r,i,o)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:Ae.toCss(r,r,r),rgba:Ae.toRgba(r,r,r)})}return e})()),rs=je.toColor("#ffffff"),Ts=je.toColor("#000000"),Bo=je.toColor("#ffffff"),Do=Ts,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pf=rs,Ri=class extends ue{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ro,this._halfContrastCache=new Ro,this._onChangeColors=this._register(new V),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rs,background:Ts,cursor:Bo,cursorAccent:Do,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:ke.blend(Ts,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:ke.blend(Ts,ks),scrollbarSliderBackground:ke.opacity(rs,.2),scrollbarSliderHoverBackground:ke.opacity(rs,.4),scrollbarSliderActiveBackground:ke.opacity(rs,.5),overviewRulerBorder:rs,ansi:Ie.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=Se(e.foreground,rs),t.background=Se(e.background,Ts),t.cursor=ke.blend(t.background,Se(e.cursor,Bo)),t.cursorAccent=ke.blend(t.background,Se(e.cursorAccent,Do)),t.selectionBackgroundTransparent=Se(e.selectionBackground,ks),t.selectionBackgroundOpaque=ke.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Se(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ke.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Se(e.selectionForeground,No):void 0,t.selectionForeground===No&&(t.selectionForeground=void 0),ke.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ke.opacity(t.selectionBackgroundTransparent,.3)),ke.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ke.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Se(e.scrollbarSliderBackground,ke.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Se(e.scrollbarSliderHoverBackground,ke.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Se(e.scrollbarSliderActiveBackground,ke.opacity(t.foreground,.5)),t.overviewRulerBorder=Se(e.overviewRulerBorder,Pf),t.ansi=Ie.slice(),t.ansi[0]=Se(e.black,Ie[0]),t.ansi[1]=Se(e.red,Ie[1]),t.ansi[2]=Se(e.green,Ie[2]),t.ansi[3]=Se(e.yellow,Ie[3]),t.ansi[4]=Se(e.blue,Ie[4]),t.ansi[5]=Se(e.magenta,Ie[5]),t.ansi[6]=Se(e.cyan,Ie[6]),t.ansi[7]=Se(e.white,Ie[7]),t.ansi[8]=Se(e.brightBlack,Ie[8]),t.ansi[9]=Se(e.brightRed,Ie[9]),t.ansi[10]=Se(e.brightGreen,Ie[10]),t.ansi[11]=Se(e.brightYellow,Ie[11]),t.ansi[12]=Se(e.brightBlue,Ie[12]),t.ansi[13]=Se(e.brightMagenta,Ie[13]),t.ansi[14]=Se(e.brightCyan,Ie[14]),t.ansi[15]=Se(e.brightWhite,Ie[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;ro.index-a.index),r=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);r.push(a)}let i=s.length>0?s[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},If={trace:0,debug:1,info:2,warn:3,error:4,off:5},Wf="xterm.js: ",Bi=class extends ue{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=If[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=t-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*he+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*he+0]=t|2097152|s[2]<<22):this._data[t*he+0]=s[1].charCodeAt(0)|s[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 s=this._data[t*he+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*he+0]&2097152}getString(t){let s=this._data[t*he+0];return s&2097152?this._combined[t]:s&2097151?Xt(s&2097151):""}isProtected(t){return this._data[t*he+2]&536870912}loadCell(t,s){return or=t*he,s.content=this._data[or+0],s.fg=this._data[or+1],s.bg=this._data[or+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*he+0]=s.content,this._data[t*he+1]=s.fg,this._data[t*he+2]=s.bg}setCellFromCodepoint(t,s,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*he+0]=s|r<<22,this._data[t*he+1]=i.fg,this._data[t*he+2]=i.bg}addCodepointToCell(t,s,r){let i=this._data[t*he+0];i&2097152?this._combined[t]+=Xt(s):i&2097151?(this._combined[t]=Xt(i&2097151)+Xt(s),i&=-2097152,i|=2097152):i=s|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*he+0]=i}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s=0;--o)this.setCell(t+s+o,this.loadCell(t+o,i));for(let o=0;othis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*Gr=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,s,r,i,o){let a=t._data;if(o)for(let h=i-1;h>=0;h--){for(let c=0;c=s&&(this._combined[c-s+r]=t._combined[c])}}translateToString(t,s,r,i){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s>22||1}return i&&i.push(s),o}};function Hf(e,t,s,r,i,o){let a=[];for(let l=0;l=l&&r0&&(w>d||u[w].getTrimmedLength()===0);w--)x++;x>0&&(a.push(l+u.length-x),a.push(x)),l+=u.length-1}return a}function $f(e,t){let s=[],r=0,i=t[r],o=0;for(let a=0;aHs(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;lh&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;r.push(u),l+=u}return r}function Hs(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?s-1:s}var Cl=class kl{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=kl._nextId++,this._onDispose=this.register(new V),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ls(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Cl._nextId=1;var Uf=Cl,He={},is=He.B;He[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:"≥","{":"π","|":"≠","}":"£","~":"·"};He.A={"#":"£"};He.B=void 0;He[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};He.C=He[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};He.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};He.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};He.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};He.E=He[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};He.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};He.H=He[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ao=4294967295,Oo=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Pe.clone(),this.savedCharset=is,this.markers=[],this._nullCell=mt.fromCharData([0,Fa,1,0]),this._whitespaceCell=mt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new yr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Po(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 gr),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 gr),this._whitespaceCell}getBlankLine(e,t){return new Rs(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&&eAo?Ao:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Pe);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 Po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Pe),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),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 Rs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}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 s=this._optionsService.rawOptions.reflowCursorLine,r=Hf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Pe),s);if(r.length>0){let i=$f(this.lines,r);Ff(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(Pe),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let P=this.ybase+this.y;if(P>=a&&P0&&(i.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=u.length-1,x=u[m];x===0&&(m--,x=u[m]);let w=h.length-d-1,E=c;for(;w>=0;){let P=Math.min(E,x);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[w],E-P,x-P,P,!0),x-=P,x===0&&(m--,x=u[m]),E-=P,E===0){w--;let A=Math.max(w,0);E=Hs(h,A,this._cols)}}for(let P=0;P0;)this.ybase===0?this.y0){let a=[],l=[];for(let x=0;x=0;x--)if(d&&d.start>c+_){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(x--,d.newLines[w]);x++,a.push({index:c+1,amount:d.newLines.length}),_+=d.newLines.length,d=i[++u]}else this.lines.set(x,l[c--]);let g=0;for(let x=a.length-1;x>=0;x--)a[x].index+=g,this.lines.onInsertEmitter.fire(a[x]),g+=a[x].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,r){let i=this.lines.get(e);return i?i.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+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-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Kf=class extends ue{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new V),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 Oo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Oo(!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)}},El=2,Nl=1,Di=class extends ue{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new V),this.onResize=this._onResize.event,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,El),this.rows=Math.max(e.rawOptions.rows||0,Nl),this.buffers=this._register(new Kf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(o+1,0,r.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Di=Le([G(0,st)],Di);var gs={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:xr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Vf=["normal","bold","100","200","300","400","500","600","700","800","900"],qf=class extends ue{constructor(e){super(),this._onOptionChange=this._register(new V),this.onOptionChange=this._onOptionChange.event;let t={...gs};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=gs[e]),!Xf(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=gs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Vf.includes(t)?t:gs[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 Xf(e){return e==="block"||e==="underline"||e==="bar"}function Bs(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&Bs(e[r],t-1);return s}var Io=Object.freeze({insertMode:!1}),Wo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Pi=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new V),this.onData=this._onData.event,this._onUserInput=this._register(new V),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new V),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new V),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}reset(){this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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))}};Pi=Le([G(0,tt),G(1,qa),G(2,st)],Pi);var Ho={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 Jr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Zr=String.fromCharCode,$o={DEFAULT:e=>{let t=[Jr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Zr(t[0])}${Zr(t[1])}${Zr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.x};${e.y}${t}`}},Ai=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new V),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Ho))this.addProtocol(r,Ho[r]);for(let r of Object.keys($o))this.addEncoding(r,$o[r]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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,s){if(s){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)}};Ai=Le([G(0,tt),G(1,hs),G(2,st)],Ai);var Qr=[[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]],Yf=[[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]],We;function Gf(e,t){let s=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let i=os.extractWidth(t);i===0?r=!1:i>s&&(s=i)}return os.createPropertyValue(0,s,r)}},os=class pr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new V,this.onChange=this._onChange.event;let t=new Jf;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,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?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 s=0,r=0,i=t.length;for(let o=0;o=i)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,r),h=pr.extractWidth(l);pr.extractShouldJoin(l)&&(h-=pr.extractWidth(r)),s+=h,r=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Zf=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 Fo(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Es=2147483647,Qf=256,jl=class Oi{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Qf)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Oi;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r>8,i=this._subParamsIdx[s]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>Es?Es: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>Es?Es:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s>8,i=this._subParamsIdx[s]&255;i-r>0&&(t[s]=this._subParams.slice(r,i))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[s-1];r[s-1]=~i?Math.min(i*10+t,Es):t}},Ns=[],ep=class{constructor(){this._state=0,this._active=Ns,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=Ns}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=Ns,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ns,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Ns,this._id=-1,this._state=0}}},ct=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},js=[],tp=class{constructor(){this._handlers=Object.create(null),this._active=js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=js,this._ident=0}},Ds=new jl;Ds.addParam(0);var zo=class{constructor(e){this._handler=e,this._data="",this._params=Ds,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ds,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._params=Ds,this._data="",this._hitLimit=!1,s));return this._params=Ds,this._data="",this._hitLimit=!1,t}},sp=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let i=0;ih),s=(l,h)=>t.slice(l,h),r=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(r,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_t,0,2,0),e.add(_t,8,5,8),e.add(_t,6,0,6),e.add(_t,11,0,11),e.add(_t,13,13,13),e})(),ip=class extends ue{constructor(e=rp){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 jl,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ep),this._dcsParser=this._register(new tp),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 i=0;io||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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,s,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,s){let r=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===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 l=o;l>4){case 2:for(let _=l+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,i,l),a;c<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(a=u[d](),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(4,u,d,i,l),a;d<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<_t){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<_t){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},np=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,op=/^[\da-f]+$/;function Uo(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=np.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),op.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(t.slice(s*i,s*i+s),16);r[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return r}}function ei(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function ap(e,t=16){let[s,r,i]=e;return`rgb:${ei(s,t)}/${ei(r,t)}/${ei(i,t)}`}var lp={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,Ko=10;function Vo(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 qo=5e3,Xo=0,cp=class extends ue{constructor(e,t,s,r,i,o,a,l,h=new ip){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Nd,this._utf8Decoder=new jd,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone(),this._onRequestBell=this._register(new V),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new V),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new V),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new V),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new V),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new V),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new V),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new V),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new V),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new V),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new V),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new V),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 Ii(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(W.BEL,()=>this.bell()),this._parser.setExecuteHandler(W.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(W.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(W.BS,()=>this.backspace()),this._parser.setExecuteHandler(W.HT,()=>this.tab()),this._parser.setExecuteHandler(W.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(W.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ur.IND,()=>this.index()),this._parser.setExecuteHandler(ur.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ur.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ct(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new ct(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new ct(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new ct(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new ct(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new ct(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new ct(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new ct(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new ct(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new ct(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new ct(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new ct(c=>this.restoreCursorColor(c))),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 c in He)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new zo((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),qo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.lengthqt)for(let c=o;c0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let g=t;gl){if(h){let E=d,k=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&d instanceof Rs&&d.copyCellsFrom(E,k,0,w,!1);k=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(l-1)===2&&d.setCellFromCodepoint(l-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>Vo(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new zo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ct(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,s,r=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&r.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 h=l;for(let c=1;c0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(W.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(W.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(W.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(W.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(W.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,d=this._optionsService.rawOptions,_=(x,w)=>(a.triggerDataEvent(`${W.ESC}[${t?"":"?"}${x};${w}$y`),!0),g=x=>x?1:2,m=e.params[0];return t?m===2?_(m,4):m===4?_(m,g(a.modes.insertMode)):m===12?_(m,3):m===20?_(m,g(d.convertEol)):_(m,0):m===1?_(m,g(r.applicationCursorKeys)):m===3?_(m,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?_(m,g(r.origin)):m===7?_(m,g(r.wraparound)):m===8?_(m,3):m===9?_(m,g(i==="X10")):m===12?_(m,g(d.cursorBlink)):m===25?_(m,g(!a.isCursorHidden)):m===45?_(m,g(r.reverseWraparound)):m===66?_(m,g(r.applicationKeypad)):m===67?_(m,4):m===1e3?_(m,g(i==="VT200")):m===1002?_(m,g(i==="DRAG")):m===1003?_(m,g(i==="ANY")):m===1004?_(m,g(r.sendFocus)):m===1005?_(m,4):m===1006?_(m,g(o==="SGR")):m===1015?_(m,4):m===1016?_(m,g(o==="SGR_PIXELS")):m===1048?_(m,1):m===47||m===1047||m===1049?_(m,g(c===u)):m===2004?_(m,g(r.bracketedPasteMode)):m===2026?_(m,g(r.synchronizedOutput)):_(m,0)}_updateAttrColor(e,t,s,r,i){return t===2?(e|=50331648,e&=-16777216,e|=$s.fromColorRGB([s,r,i])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],i=0,o=0;do{if(r[o+i]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do r[1]===5&&(i=1),r[o+l+1+i]=a[l];while(++l=2||r[1]===2&&o+i>=5)break;r[1]&&(i=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Pe.fg,e.bg=Pe.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,s,r=this._curAttrData;for(let i=0;i=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=Pe.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=Pe.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(e,i,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=Pe.fg&16777215,r.bg&=-67108864,r.bg|=Pe.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${W.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.ESC}[?${t};${s}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=Pe.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Vo(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(`${W.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ko&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ko&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),i=s.shift();if(/^\d+$/.exec(r)){let o=parseInt(r);if(Yo(o))if(i==="?")t.push({type:0,index:o});else{let a=Uo(i);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(r=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,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 s=e.split(";");for(let r=0;r=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=Uo(s[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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=[],s=e.split(";");for(let r=0;r=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=Pe.clone(),this._eraseAttrDataInternal=Pe.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 mt;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(`${W.ESC}${a}${W.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ii=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&&(Xo=e,e=t,t=Xo),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ii=Le([G(0,tt)],Ii);function Yo(e){return 0<=e&&e<256}var hp=5e7,Go=12,dp=50,up=class extends ue{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 V),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>hp)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let a=l=>performance.now()-s>=Go?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Go)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dp&&(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()}},Wi=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 l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}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 s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wi=Le([G(0,tt)],Wi);var Jo=!1,fp=class extends ue{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new xs),this._onBinary=this._register(new V),this.onBinary=this._onBinary.event,this._onData=this._register(new V),this.onData=this._onData.event,this._onLineFeed=this._register(new V),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new V),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new V),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new V),this._instantiationService=new Of,this.optionsService=this._register(new qf(e)),this._instantiationService.setService(st,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Di)),this._instantiationService.setService(tt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Bi)),this._instantiationService.setService(qa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Pi)),this._instantiationService.setService(hs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ai)),this._instantiationService.setService(Va,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(os)),this._instantiationService.setService(Rd,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Zf),this._instantiationService.setService(Td,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wi),this._instantiationService.setService(Xa,this._oscLinkService),this._inputHandler=this._register(new cp(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ge.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ge.forward(this._bufferService.onResize,this._onResize)),this._register(Ge.forward(this.coreService.onData,this._onData)),this._register(Ge.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 up((t,s)=>this._inputHandler.parse(t,s))),this._register(Ge.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new V),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&&!Jo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Jo=!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,El),t=Math.max(t,Nl),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(Fo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Fo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ee(()=>{for(let t of e)t.dispose()})}}},pp={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 _p(e,t,s,r){var a;let i={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?i.key=W.ESC+"OA":i.key=W.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=W.ESC+"OD":i.key=W.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=W.ESC+"OC":i.key=W.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=W.ESC+"OB":i.key=W.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":W.DEL,e.altKey&&(i.key=W.ESC+i.key);break;case 9:if(e.shiftKey){i.key=W.ESC+"[Z";break}i.key=W.HT,i.cancel=!0;break;case 13:i.key=e.altKey?W.ESC+W.CR:W.CR,i.cancel=!0;break;case 27:i.key=W.ESC,e.altKey&&(i.key=W.ESC+W.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"D":t?i.key=W.ESC+"OD":i.key=W.ESC+"[D";break;case 39:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"C":t?i.key=W.ESC+"OC":i.key=W.ESC+"[C";break;case 38:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"A":t?i.key=W.ESC+"OA":i.key=W.ESC+"[A";break;case 40:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"B":t?i.key=W.ESC+"OB":i.key=W.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=W.ESC+"[2~");break;case 46:o?i.key=W.ESC+"[3;"+(o+1)+"~":i.key=W.ESC+"[3~";break;case 36:o?i.key=W.ESC+"[1;"+(o+1)+"H":t?i.key=W.ESC+"OH":i.key=W.ESC+"[H";break;case 35:o?i.key=W.ESC+"[1;"+(o+1)+"F":t?i.key=W.ESC+"OF":i.key=W.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=W.ESC+"[5;"+(o+1)+"~":i.key=W.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=W.ESC+"[6;"+(o+1)+"~":i.key=W.ESC+"[6~";break;case 112:o?i.key=W.ESC+"[1;"+(o+1)+"P":i.key=W.ESC+"OP";break;case 113:o?i.key=W.ESC+"[1;"+(o+1)+"Q":i.key=W.ESC+"OQ";break;case 114:o?i.key=W.ESC+"[1;"+(o+1)+"R":i.key=W.ESC+"OR";break;case 115:o?i.key=W.ESC+"[1;"+(o+1)+"S":i.key=W.ESC+"OS";break;case 116:o?i.key=W.ESC+"[15;"+(o+1)+"~":i.key=W.ESC+"[15~";break;case 117:o?i.key=W.ESC+"[17;"+(o+1)+"~":i.key=W.ESC+"[17~";break;case 118:o?i.key=W.ESC+"[18;"+(o+1)+"~":i.key=W.ESC+"[18~";break;case 119:o?i.key=W.ESC+"[19;"+(o+1)+"~":i.key=W.ESC+"[19~";break;case 120:o?i.key=W.ESC+"[20;"+(o+1)+"~":i.key=W.ESC+"[20~";break;case 121:o?i.key=W.ESC+"[21;"+(o+1)+"~":i.key=W.ESC+"[21~";break;case 122:o?i.key=W.ESC+"[23;"+(o+1)+"~":i.key=W.ESC+"[23~";break;case 123:o?i.key=W.ESC+"[24;"+(o+1)+"~":i.key=W.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=W.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=W.DEL:e.keyCode===219?i.key=W.ESC:e.keyCode===220?i.key=W.FS:e.keyCode===221&&(i.key=W.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let l=(a=pp[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)i.key=W.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),i.key=W.ESC+c}else if(e.keyCode===32)i.key=W.ESC+(e.ctrlKey?W.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),i.key=W.ESC+h,i.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=W.US),e.key==="@"&&(i.key=W.NUL));break}return i}var Be=0,gp=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new yr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new yr,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((i,o)=>this._getKey(i)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[i]=e[t],t++):r[i]=this._array[s++];this._array=r,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||(Be=this._search(t),Be===-1)||this._getKey(this._array[Be])!==t)return!1;do if(this._array[Be]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Be),!0;while(++Bei-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Be=this._search(e),!(Be<0||Be>=this._array.length)&&this._getKey(this._array[Be])===e))do yield this._array[Be];while(++Be=this._array.length)&&this._getKey(this._array[Be])===e))do t(this._array[Be]);while(++Be=t;){let r=t+s>>1,i=this._getKey(this._array[r]);if(i>e)s=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ti=0,Zo=0,mp=class extends ue{constructor(){super(),this._decorations=new gp(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new V),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new V),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new vp(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,i=0;for(let o of this._decorations.getKeyIterator(t))r=o.options.x??0,i=r+(o.options.width??1),e>=r&&e{ti=i.options.x??0,Zo=ti+(i.options.width??1),e>=ti&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,o=this._debounceThresholdMS-i;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)}},Qo=20,br=class extends ue{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yp(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(ne(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ee(()=>{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===Qo+1&&(this._liveRegion.textContent+=ni.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let i=e;i<=t;i++){let o=s.lines.get(s.ydisp+i),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||e.relatedTarget!==r)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 l;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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let i=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let p=this._rowColumns.get(u);if(!p)return console.warn("columns is null. Race condition?"),null;let g=c=this._terminal.cols&&(++d,g=0),{row:d,column:g}},o=i(t),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.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;ls(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(ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ne(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 s=e.composedPath();for(let r=0;r{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;re?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){i.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),i=!1;for(let a=0;athis._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;athis._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&yp(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,ls(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 s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.pointerCursor},set:s=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.underline},set:s=>{var r,i,o;(r=this._currentLink)!=null&&r.state&&((o=(i=this._currentLink)==null?void 0:i.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return s<=i&&i<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,i){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:i}}};Hi=Le([Y(1,Yi),Y(2,Ht),Y(3,tt),Y(4,Ya)],Hi);function yp(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 bp=class extends up{constructor(e={}){super(e),this._linkifier=this._register(new xs),this.browser=pl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xs),this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new K),this.onKey=this._onKey.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new K),this.onBell=this._onBell.event,this._onFocus=this._register(new K),this._onBlur=this._register(new K),this._onA11yCharEmitter=this._register(new K),this._onA11yTabEmitter=this._register(new K),this._onWillOpen=this._register(new K),this._setup(),this._decorationService=this._instantiationService.createInstance(gp),this._instantiationService.setService(Fs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(hf),this._instantiationService.setService(Ya,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ai)),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(Ge.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ge.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ge.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ge.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ee(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let i=ke.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${H.ESC}]${r};${op(i)}${ul.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ae.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ae.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(br,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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(H.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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ne(this.element,"copy",t=>{this.hasSelection()&&Cd(t,this._selectionService)}));let e=t=>kd(t,this.textarea,this.coreService,this.optionsService);this._register(ne(this.textarea,"paste",e)),this._register(ne(this.element,"paste",e)),_l?this._register(ne(this.element,"mousedown",t=>{t.button===2&&lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ne(this.element,"contextmenu",t=>{lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),rn&&this._register(ne(this.element,"auxclick",t=>{t.button===1&&Ha(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(ne(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 s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ii.get()),vl||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(lf,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(ne(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ji,this._document,this._helperContainer),this._instantiationService.setService(Nr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ri),this._instantiationService.setService(ys,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vr),this._instantiationService.setService(Xa,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Li,this.rows,this.screenElement)),this._instantiationService.setService(Ht,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(ki,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mi),this._instantiationService.setService(Yi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hi,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(wi,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(Ti,this.element,this.screenElement,r)),this._instantiationService.setService(Bd,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(Ge.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ci,this.screenElement)),this._register(ne(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(br,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ni,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,d,p,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(p=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:p.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(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?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ne(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(ne(t,"wheel",o=>{var a,l,h,c,u;if(!r.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,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let d=H.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.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){Wa(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,s){this._selectionService.setSelection(e,t,s)}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 s;(s=this._selectionService)==null||s.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 s=pp(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===H.ETX||s.key===H.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Sp(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 s;(s=this._charSizeService)==null||s.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 s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},ea=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 Cp(t)}getNullCell(){return new mt}},kp=class extends ue{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new K),this.onBufferChange=this._onBufferChange.event,this._normal=new ea(this._core.buffers.normal,"normal"),this._alternate=new ea(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)}},Ep=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.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)}},Np=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}},jp=["cols","rows"],Et=0,Mp=class extends ue{constructor(e){super(),this._core=this._register(new bp(e)),this._addonManager=this._register(new wp),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(jp.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 Ep(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Np(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 kp(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qo+1&&(this._liveRegion.textContent+=ni.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let i=e;i<=t;i++){let o=s.lines.get(s.ydisp+i),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||e.relatedTarget!==r)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 l;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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let i=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let g=c<_.length?_[c]:_.slice(-1)[0]+1;return g>=this._terminal.cols&&(++d,g=0),{row:d,column:g}},o=i(t),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.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;ls(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(ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ne(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 s=e.composedPath();for(let r=0;r{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;re?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){i.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),i=!1;for(let a=0;athis._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;athis._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&bp(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,ls(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 s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.pointerCursor},set:s=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.underline},set:s=>{var r,i,o;(r=this._currentLink)!=null&&r.state&&((o=(i=this._currentLink)==null?void 0:i.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return s<=i&&i<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,i){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:i}}};Hi=Le([G(1,Yi),G(2,Ht),G(3,tt),G(4,Ga)],Hi);function bp(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 Sp=class extends fp{constructor(e={}){super(e),this._linkifier=this._register(new xs),this.browser=_l,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xs),this._onCursorMove=this._register(new V),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new V),this.onKey=this._onKey.event,this._onRender=this._register(new V),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new V),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new V),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new V),this.onBell=this._onBell.event,this._onFocus=this._register(new V),this._onBlur=this._register(new V),this._onA11yCharEmitter=this._register(new V),this._onA11yTabEmitter=this._register(new V),this._onWillOpen=this._register(new V),this._setup(),this._decorationService=this._instantiationService.createInstance(mp),this._instantiationService.setService(Fs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(df),this._instantiationService.setService(Ga,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ai)),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(Ge.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ge.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ge.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ge.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ee(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let i=ke.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${W.ESC}]${r};${ap(i)}${fl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ae.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ae.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(br,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.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(W.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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ne(this.element,"copy",t=>{this.hasSelection()&&kd(t,this._selectionService)}));let e=t=>Ed(t,this.textarea,this.coreService,this.optionsService);this._register(ne(this.textarea,"paste",e)),this._register(ne(this.element,"paste",e)),gl?this._register(ne(this.element,"mousedown",t=>{t.button===2&&lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ne(this.element,"contextmenu",t=>{lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),rn&&this._register(ne(this.element,"auxclick",t=>{t.button===1&&$a(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(ne(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 s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ii.get()),xl||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(cf,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(ne(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ji,this._document,this._helperContainer),this._instantiationService.setService(Nr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ri),this._instantiationService.setService(ys,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vr),this._instantiationService.setService(Ya,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Li,this.rows,this.screenElement)),this._instantiationService.setService(Ht,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(ki,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mi),this._instantiationService.setService(Yi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hi,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(wi,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(Ti,this.element,this.screenElement,r)),this._instantiationService.setService(Dd,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(Ge.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ci,this.screenElement)),this._register(ne(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(br,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ni,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,d,_,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(_=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(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?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ne(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(ne(t,"wheel",o=>{var a,l,h,c,u;if(!r.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,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let d=W.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.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){Ha(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,s){this._selectionService.setSelection(e,t,s)}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 s;(s=this._selectionService)==null||s.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 s=_p(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===W.ETX||s.key===W.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(wp(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 s;(s=this._charSizeService)==null||s.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 s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},ea=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 kp(t)}getNullCell(){return new mt}},Ep=class extends ue{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new V),this.onBufferChange=this._onBufferChange.event,this._normal=new ea(this._core.buffers.normal,"normal"),this._alternate=new ea(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)}},Np=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.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)}},jp=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}},Mp=["cols","rows"],Et=0,Lp=class extends ue{constructor(e){super(),this._core=this._register(new Sp(e)),this._addonManager=this._register(new Cp),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(Mp.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 Np(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jp(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 Ep(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 ii.get()},set promptLabel(e){ii.set(e)},get tooMuchOutput(){return ni.get()},set tooMuchOutput(e){ni.set(e)}}}_verifyIntegers(...e){for(Et of e)if(Et===1/0||isNaN(Et)||Et%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Et of e)if(Et&&(Et===1/0||isNaN(Et)||Et%1!==0||Et<0))throw new Error("This API only accepts positive integers")}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT @@ -128,5 +128,5 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Lp=2,Tp=1,Rp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=r-l,u=i-h-t;return{cols:Math.max(Lp,Math.floor(u/e.css.cell.width)),rows:Math.max(Tp,Math.floor(c/e.css.cell.height))}}};function Bp({sessionId:e}){const t=x.useRef(null),s=x.useRef(null),r=x.useRef(null),i=x.useRef(wr()).current;return x.useEffect(()=>{if(!t.current)return;const o=new Mp({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#7dd3fc",selectionBackground:"#334155"}}),a=new Rp;o.loadAddon(a),o.open(t.current),a.fit(),s.current=o,r.current=a,Cc(e,c=>o.write(c));const l=navigator.platform.startsWith("Mac");o.attachCustomKeyEventHandler(c=>{const u=l?c.metaKey:c.ctrlKey;if(u&&c.key==="c"||c.ctrlKey&&c.shiftKey&&c.key==="C"){const d=o.getSelection();return d?(navigator.clipboard.writeText(d),!1):!l}return u&&c.key==="v"||c.ctrlKey&&c.shiftKey&&c.key==="V"?(navigator.clipboard.readText().then(d=>{d&&i.sendCliAgentInput(e,d)}),!1):!0}),o.onData(c=>{i.sendCliAgentInput(e,c)});const h=new ResizeObserver(()=>{a.fit(),i.sendCliAgentResize(e,o.cols,o.rows)});return h.observe(t.current),i.sendCliAgentResize(e,o.cols,o.rows),()=>{kc(e),h.disconnect(),o.dispose(),s.current=null,r.current=null}},[e,i]),n.jsx("div",{ref:t,className:"flex-1 min-h-0",style:{padding:"4px"}})}function Dp(){return crypto.randomUUID()}function Pp(){const e=x.useRef(wr()).current,t=x.useRef(null),s=x.useRef(!1),[r,i]=x.useState(250),[o,a]=x.useState(280),[l,h]=x.useState(!1),c=xe(_=>_.openTabs),{explorerFile:u}=et(),{availableAgents:d,selectedAgentId:p,sessionId:g,status:m,exitCode:y,events:w,setAvailableAgents:k,setSelectedAgentId:C,setSessionId:A,setStatus:O,setExitCode:P,addEvent:j}=Ms();x.useEffect(()=>{od().then(_=>k(_))},[k]);const D=d.filter(_=>_.installed),L=()=>{var v;if(!p)return;const _=Dp(),f=((v=D.find(b=>b.id===p))==null?void 0:v.name)??p;A(_),O("running"),P(null),h(!1),e.sendCliAgentStart(p,_,120,40),j({type:"session",timestamp:Date.now(),agentName:f,action:"started"})},B=()=>{var _;if(g){const f=((_=D.find(v=>v.id===p))==null?void 0:_.name)??p??"Unknown";e.sendCliAgentStop(g),j({type:"session",timestamp:Date.now(),agentName:f,action:"stopped"}),O("idle"),A(null)}},I=x.useCallback(_=>{_.preventDefault(),s.current=!0;const f="touches"in _?_.touches[0].clientY:_.clientY,v=r,b=N=>{if(!s.current)return;const z=t.current;if(!z)return;const T="touches"in N?N.touches[0].clientY:N.clientY,$=z.clientHeight-100,V=Math.max(100,Math.min($,v-(T-f)));i(V)},E=()=>{s.current=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",E),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",b),document.addEventListener("mouseup",E),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("touchend",E)},[r]),M=x.useCallback(_=>{_.preventDefault();const f="touches"in _?_.touches[0].clientX:_.clientX,v=o,b=N=>{const z="touches"in N?N.touches[0].clientX:N.clientX,T=Math.max(180,Math.min(500,v-(z-f)));a(T)},E=()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",E),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",b),document.addEventListener("mouseup",E),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("touchend",E)},[o]),R=c.length>0||!!u;return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{ref:t,className:"flex flex-col flex-1 min-w-0",children:[n.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:R?n.jsx(xd,{}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a file to view"})}),!l&&n.jsx("div",{onMouseDown:I,onTouchStart:I,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"shrink-0 flex flex-col overflow-hidden",style:{height:l?32:r,borderTop:"1px solid var(--border)",background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3",style:{height:32,borderBottom:l?"none":"1px solid var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("button",{onClick:()=>h(!l),className:"shrink-0 flex items-center justify-center",style:{width:18,height:18,border:"none",background:"none",color:"var(--text-muted)",cursor:"pointer"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:l?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M6 9l6 6 6-6"})})}),n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold shrink-0",style:{color:"var(--text-muted)"},children:"Terminal"}),n.jsxs("select",{value:p??"",onChange:_=>C(_.target.value),disabled:m==="running",style:{fontSize:11,padding:"2px 4px",borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-primary)",color:"var(--text-primary)",cursor:m==="running"?"not-allowed":"pointer",opacity:m==="running"?.6:1,maxWidth:160},children:[D.length===0&&n.jsx("option",{value:"",children:"No agents found"}),D.map(_=>n.jsx("option",{value:_.id,children:_.name},_.id))]}),m==="idle"||m==="exited"?n.jsx("button",{onClick:L,disabled:!p||D.length===0,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:p?"var(--accent)":"var(--bg-primary)",color:p?"#fff":"var(--text-muted)",cursor:p?"pointer":"not-allowed",fontWeight:500},children:m==="exited"?"Restart":"Start"}):n.jsx("button",{onClick:B,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:"#ef4444",color:"#fff",cursor:"pointer",fontWeight:500},children:"Stop"}),n.jsx("span",{className:"ml-auto",style:{width:6,height:6,borderRadius:"50%",background:m==="running"?"#4ade80":m==="exited"?"#ef4444":"var(--text-muted)"}})]}),!l&&n.jsx("div",{className:"flex-1 min-h-0",children:g&&m==="running"?n.jsx(Bp,{sessionId:g}):n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:D.length===0?"No CLI agents detected. Install Claude Code, Codex, or GitHub Copilot CLI.":m==="exited"?`Process exited${y!==null?` (code ${y})`:""}. Click Restart.`:"Select an agent and click Start."})})})]})]}),n.jsx("div",{onMouseDown:M,onTouchStart:M,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:o,background:"var(--bg-primary)",borderLeft:"1px solid var(--border)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center px-3 h-10 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold",style:{color:"var(--text-muted)"},children:"Events"}),n.jsx("span",{className:"ml-1 text-[11px]",style:{color:"var(--text-muted)"},children:w.length>0&&w.length})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:w.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:"No events yet"})}):n.jsx("div",{className:"py-1",children:w.map((_,f)=>n.jsx(Ap,{event:_},f))})})]})]})}function ar({dot:e,label:t,detail:s,time:r,children:i}){const[o,a]=x.useState(!1),l=!!i;return n.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)",cursor:l?"pointer":void 0},onClick:l?()=>a(!o):void 0,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"shrink-0",style:{width:6,height:6,borderRadius:"50%",background:e}}),n.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--text-primary)"},children:t}),s&&n.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:s}),n.jsx("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--text-muted)"},children:r})]}),o&&i]})}function Ap({event:e}){const t=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(e.type==="mcp_tool_call"){const i=Object.keys(e.args).length>0;return n.jsx(ar,{dot:"#a78bfa",label:e.tool,time:t,children:i&&n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:Object.entries(e.args).map(([o,a])=>n.jsxs("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:[o,"=",JSON.stringify(a)]},o))})})}if(e.type==="run_lifecycle"){const i=e.status==="running"?"#facc15":e.status==="completed"?"#4ade80":e.status==="failed"?"#ef4444":"var(--text-muted)";return n.jsx(ar,{dot:i,label:e.entrypoint,detail:e.status,time:t})}if(e.type==="files_changed"){const i=`${e.files.length} file${e.files.length!==1?"s":""} changed`;return n.jsx(ar,{dot:"#60a5fa",label:i,time:t,children:n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:e.files.map(o=>n.jsx("div",{className:"text-xs truncate",style:{color:"var(--text-primary)"},children:o},o))})})}const s=e.action==="started"?"#4ade80":e.action==="exited"?"#ef4444":"var(--text-muted)",r=e.action+(e.action==="exited"&&e.exitCode!==void 0?` (${e.exitCode})`:"");return n.jsx(ar,{dot:s,label:e.agentName,detail:r,time:t})}function Op(){const e=jc(),t=Rc(),[s,r]=x.useState(!1),[i,o]=x.useState(248),[a,l]=x.useState(!1),{runs:h,selectedRunId:c,setRuns:u,upsertRun:d,selectRun:p,setTraces:g,setLogs:m,setChatMessages:y,setEntrypoints:w,setStateEvents:k,setGraphCache:C,setActiveNode:A,removeActiveNode:O}=de(),{section:P,view:j,runId:D,setupEntrypoint:L,setupMode:B,evalCreating:I,evalSetId:M,evalRunId:R,evalRunItemName:_,evaluatorCreateType:f,evaluatorId:v,evaluatorFilter:b,navigate:E}=et(),{setEvalSets:N,setEvaluators:z,setLocalEvaluators:T,setEvalRuns:$}=Se();x.useEffect(()=>{P==="debug"&&j==="details"&&D&&D!==c&&p(D)},[P,j,D,c,p]);const V=da(Z=>Z.init),J=ua(Z=>Z.init);x.useEffect(()=>{Sc().then(u).catch(console.error),$i().then(Z=>w(Z.map(me=>me.name))).catch(console.error),V(),J()},[u,w,V,J]),x.useEffect(()=>{P==="evals"&&(_a().then(Z=>N(Z)).catch(console.error),$c().then(Z=>$(Z)).catch(console.error)),(P==="evals"||P==="evaluators")&&(Pc().then(Z=>z(Z)).catch(console.error),Vi().then(Z=>T(Z)).catch(console.error))},[P,N,z,T,$]);const re=Se(Z=>Z.evalSets),ie=Se(Z=>Z.evalRuns);x.useEffect(()=>{if(P!=="evals"||I||M||R)return;const Z=Object.values(ie).sort((dt,ve)=>new Date(ve.start_time??0).getTime()-new Date(dt.start_time??0).getTime());if(Z.length>0){E(`#/evals/runs/${Z[0].id}`);return}const me=Object.values(re);me.length>0&&E(`#/evals/sets/${me[0].id}`)},[P,I,M,R,ie,re,E]),x.useEffect(()=>{const Z=me=>{me.key==="Escape"&&s&&r(!1)};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[s]);const F=c?h[c]:null,te=x.useCallback((Z,me)=>{d(me),g(Z,me.traces),m(Z,me.logs);const dt=me.messages.map(ve=>{const vt=ve.contentParts??ve.content_parts??[],xt=ve.toolCalls??ve.tool_calls??[];return{message_id:ve.messageId??ve.message_id,role:ve.role??"assistant",content:vt.filter(it=>{const ut=it.mimeType??it.mime_type??"";return ut.startsWith("text/")||ut==="application/json"}).map(it=>{const ut=it.data;return(ut==null?void 0:ut.inline)??""}).join(` -`).trim()??"",tool_calls:xt.length>0?xt.map(it=>({name:it.name??"",has_result:!!it.result})):void 0}});if(y(Z,dt),me.graph&&me.graph.nodes.length>0&&C(Z,me.graph),me.states&&me.states.length>0&&(k(Z,me.states.map(ve=>({node_name:ve.node_name,qualified_node_name:ve.qualified_node_name,phase:ve.phase,timestamp:new Date(ve.timestamp).getTime(),payload:ve.payload}))),me.status!=="completed"&&me.status!=="failed"))for(const ve of me.states)ve.phase==="started"?A(Z,ve.node_name,ve.qualified_node_name):ve.phase==="completed"&&O(Z,ve.node_name)},[d,g,m,y,k,C,A,O]);x.useEffect(()=>{if(!c)return;e.subscribe(c),Ir(c).then(me=>te(c,me)).catch(console.error);const Z=setTimeout(()=>{const me=de.getState().runs[c];me&&(me.status==="pending"||me.status==="running")&&Ir(c).then(dt=>te(c,dt)).catch(console.error)},2e3);return()=>{clearTimeout(Z),e.unsubscribe(c)}},[c,e,te]);const pe=x.useRef(null);x.useEffect(()=>{var dt,ve;if(!c)return;const Z=F==null?void 0:F.status,me=pe.current;if(pe.current=Z??null,Z&&(Z==="completed"||Z==="failed")&&me!==Z){const vt=de.getState(),xt=((dt=vt.traces[c])==null?void 0:dt.length)??0,it=((ve=vt.logs[c])==null?void 0:ve.length)??0,ut=(F==null?void 0:F.trace_count)??0,Ks=(F==null?void 0:F.log_count)??0;(xtte(c,Bt)).catch(console.error)}},[c,F==null?void 0:F.status,te]);const _e=Z=>{E(`#/debug/runs/${Z}/traces`),p(Z),r(!1)},qe=Z=>{E(`#/debug/runs/${Z}/traces`),p(Z),r(!1)},St=()=>{E("#/debug/new"),r(!1)},ht=Z=>{Z==="debug"?E("#/debug/new"):Z==="evals"?E("#/evals"):Z==="evaluators"?E("#/evaluators"):Z==="explorer"&&E("#/explorer")},ge=x.useCallback(Z=>{Z.preventDefault(),l(!0);const me="touches"in Z?Z.touches[0].clientX:Z.clientX,dt=i,ve=xt=>{const it="touches"in xt?xt.touches[0].clientX:xt.clientX,ut=Math.max(200,Math.min(480,dt+(it-me)));o(ut)},vt=()=>{l(!1),document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",vt),document.removeEventListener("touchmove",ve),document.removeEventListener("touchend",vt),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",ve),document.addEventListener("mouseup",vt),document.addEventListener("touchmove",ve,{passive:!1}),document.addEventListener("touchend",vt)},[i]),$t=()=>P==="explorer"?n.jsx(Pp,{}):P==="evals"?I?n.jsx(Zn,{}):R?n.jsx($h,{evalRunId:R,itemName:_}):M?n.jsx(Oh,{evalSetId:M}):n.jsx(Zn,{}):P==="evaluators"?f?n.jsx(ed,{category:f}):n.jsx(Gh,{evaluatorId:v,evaluatorFilter:b}):j==="new"?n.jsx(Jc,{}):j==="setup"&&L&&B?n.jsx(ph,{entrypoint:L,mode:B,ws:e,onRunCreated:_e,isMobile:t}):F?n.jsx(Bh,{run:F,ws:e,isMobile:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"});return t?n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden relative",children:[!s&&n.jsx("button",{onClick:()=>r(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),n.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),n.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>r(!1)}),n.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[n.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[n.jsxs("button",{onClick:()=>{E("#/debug/new"),r(!1)},className:"flex items-center gap-2 cursor-pointer",style:{background:"none",border:"none"},children:[n.jsx("img",{src:"/favicon.ico",width:"14",height:"14",alt:"UiPath"}),n.jsx("span",{className:"text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Developer Console"})]}),n.jsx("button",{onClick:()=>r(!1),className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),P==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),P==="evals"&&n.jsx(Vn,{}),P==="evaluators"&&n.jsx(Qn,{}),P==="explorer"&&n.jsx(to,{})]})]}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]}):n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsxs("aside",{className:"shrink-0 flex flex-col",style:{width:i,background:"var(--sidebar-bg)"},children:[n.jsxs("div",{className:"flex h-10 border-b shrink-0",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>E("#/debug/new"),className:"w-12 shrink-0 flex items-center justify-center cursor-pointer transition-colors border-r",style:{background:"var(--activity-bar-bg)",border:"none",borderRight:"1px solid var(--border)"},onMouseEnter:Z=>{Z.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:Z=>{Z.currentTarget.style.background="var(--activity-bar-bg)"},children:n.jsx("img",{src:"/favicon.ico",width:"20",height:"20",alt:"UiPath"})}),n.jsx("div",{className:"flex-1 flex items-center px-3",style:{background:"var(--sidebar-bg)"},children:n.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:P==="debug"?"Developer Console":P==="evals"?"Evaluations":P==="evaluators"?"Evaluators":"Explorer"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx(Dc,{section:P,onSectionChange:ht}),n.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[P==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),P==="evals"&&n.jsx(Vn,{}),P==="evaluators"&&n.jsx(Qn,{}),P==="explorer"&&n.jsx(to,{})]})]})]}),n.jsx("div",{onMouseDown:ge,onTouchStart:ge,className:"shrink-0 drag-handle-col",style:a?{background:"var(--accent)"}:void 0}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]})}ac.createRoot(document.getElementById("root")).render(n.jsx(x.StrictMode,{children:n.jsx(Op,{})}));export{Oa as H,ud as j,de as u}; + */var Tp=2,Rp=1,Bp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=r-l,u=i-h-t;return{cols:Math.max(Tp,Math.floor(u/e.css.cell.width)),rows:Math.max(Rp,Math.floor(c/e.css.cell.height))}}};function Dp({sessionId:e}){const t=v.useRef(null),s=v.useRef(null),r=v.useRef(null),i=v.useRef(wr()).current;return v.useEffect(()=>{if(!t.current)return;const o=new Lp({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#7dd3fc",selectionBackground:"#334155"}}),a=new Bp;o.loadAddon(a),o.open(t.current),a.fit(),s.current=o,r.current=a,kc(e,c=>o.write(c));const l=navigator.platform.startsWith("Mac");o.attachCustomKeyEventHandler(c=>{const u=l?c.metaKey:c.ctrlKey;if(u&&c.key==="c"||c.ctrlKey&&c.shiftKey&&c.key==="C"){const d=o.getSelection();return d?(navigator.clipboard.writeText(d),!1):!l}return u&&c.key==="v"||c.ctrlKey&&c.shiftKey&&c.key==="V"?(navigator.clipboard.readText().then(d=>{d&&i.sendCliAgentInput(e,d)}),!1):!0}),o.onData(c=>{i.sendCliAgentInput(e,c)});const h=new ResizeObserver(()=>{a.fit(),i.sendCliAgentResize(e,o.cols,o.rows)});return h.observe(t.current),i.sendCliAgentResize(e,o.cols,o.rows),()=>{Ec(e),h.disconnect(),o.dispose(),s.current=null,r.current=null}},[e,i]),n.jsx("div",{ref:t,className:"flex-1 min-h-0",style:{padding:"4px"}})}function Pp(){return crypto.randomUUID()}function Ap(){const e=v.useRef(wr()).current,t=v.useRef(null),s=v.useRef(!1),[r,i]=v.useState(250),[o,a]=v.useState(280),[l,h]=v.useState(!1),c=ye(p=>p.openTabs),{explorerFile:u}=et(),{availableAgents:d,selectedAgentId:_,sessionId:g,status:m,exitCode:x,events:w,setAvailableAgents:E,setSelectedAgentId:k,setSessionId:P,setStatus:A,setExitCode:D,addEvent:N}=Ms();v.useEffect(()=>{ad().then(p=>E(p))},[E]);const $=d.filter(p=>p.installed),B=()=>{var b;if(!_)return;const p=Pp(),f=((b=$.find(y=>y.id===_))==null?void 0:b.name)??_;P(p),A("running"),D(null),h(!1),e.sendCliAgentStart(_,p,120,40),N({type:"session",timestamp:Date.now(),agentName:f,action:"started"})},T=()=>{var p;if(g){const f=((p=$.find(b=>b.id===_))==null?void 0:p.name)??_??"Unknown";e.sendCliAgentStop(g),N({type:"session",timestamp:Date.now(),agentName:f,action:"stopped"}),A("idle"),P(null)}},O=v.useCallback(p=>{p.preventDefault(),s.current=!0;const f="touches"in p?p.touches[0].clientY:p.clientY,b=r,y=M=>{if(!s.current)return;const z=t.current;if(!z)return;const C="touches"in M?M.touches[0].clientY:M.clientY,H=z.clientHeight-100,U=Math.max(100,Math.min(H,b-(C-f)));i(U)},j=()=>{s.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[r]),L=v.useCallback(p=>{p.preventDefault();const f="touches"in p?p.touches[0].clientX:p.clientX,b=o,y=M=>{const z="touches"in M?M.touches[0].clientX:M.clientX,C=Math.max(180,Math.min(500,b-(z-f)));a(C)},j=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[o]),R=c.length>0||!!u;return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{ref:t,className:"flex flex-col flex-1 min-w-0",children:[n.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:R?n.jsx(yd,{}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a file to view"})}),!l&&n.jsx("div",{onMouseDown:O,onTouchStart:O,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"shrink-0 flex flex-col overflow-hidden",style:{height:l?32:r,borderTop:"1px solid var(--border)",background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3",style:{height:32,borderBottom:l?"none":"1px solid var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("button",{onClick:()=>h(!l),className:"shrink-0 flex items-center justify-center",style:{width:18,height:18,border:"none",background:"none",color:"var(--text-muted)",cursor:"pointer"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:l?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M6 9l6 6 6-6"})})}),n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold shrink-0",style:{color:"var(--text-muted)"},children:"Terminal"}),n.jsxs("select",{value:_??"",onChange:p=>k(p.target.value),disabled:m==="running",style:{fontSize:11,padding:"2px 4px",borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-primary)",color:"var(--text-primary)",cursor:m==="running"?"not-allowed":"pointer",opacity:m==="running"?.6:1,maxWidth:160},children:[$.length===0&&n.jsx("option",{value:"",children:"No agents found"}),$.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))]}),m==="idle"||m==="exited"?n.jsx("button",{onClick:B,disabled:!_||$.length===0,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:_?"var(--accent)":"var(--bg-primary)",color:_?"#fff":"var(--text-muted)",cursor:_?"pointer":"not-allowed",fontWeight:500},children:m==="exited"?"Restart":"Start"}):n.jsx("button",{onClick:T,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:"#ef4444",color:"#fff",cursor:"pointer",fontWeight:500},children:"Stop"}),n.jsx("span",{className:"ml-auto",style:{width:6,height:6,borderRadius:"50%",background:m==="running"?"#4ade80":m==="exited"?"#ef4444":"var(--text-muted)"}})]}),!l&&n.jsx("div",{className:"flex-1 min-h-0",children:g&&m==="running"?n.jsx(Dp,{sessionId:g}):n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:$.length===0?"No CLI agents detected. Install Claude Code, Codex, or GitHub Copilot CLI.":m==="exited"?`Process exited${x!==null?` (code ${x})`:""}. Click Restart.`:"Select an agent and click Start."})})})]})]}),n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:o,background:"var(--bg-primary)",borderLeft:"1px solid var(--border)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center px-3 h-10 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold",style:{color:"var(--text-muted)"},children:"Events"}),n.jsx("span",{className:"ml-1 text-[11px]",style:{color:"var(--text-muted)"},children:w.length>0&&w.length})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:w.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:"No events yet"})}):n.jsx("div",{className:"py-1",children:w.map((p,f)=>n.jsx(Op,{event:p},f))})})]})]})}function ar({dot:e,label:t,detail:s,time:r,children:i}){const[o,a]=v.useState(!1),l=!!i;return n.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)",cursor:l?"pointer":void 0},onClick:l?()=>a(!o):void 0,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"shrink-0",style:{width:6,height:6,borderRadius:"50%",background:e}}),n.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--text-primary)"},children:t}),s&&n.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:s}),n.jsx("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--text-muted)"},children:r})]}),o&&i]})}function Op({event:e}){const t=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(e.type==="mcp_tool_call"){const i=Object.keys(e.args).length>0;return n.jsx(ar,{dot:"#a78bfa",label:e.tool,time:t,children:i&&n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:Object.entries(e.args).map(([o,a])=>n.jsxs("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:[o,"=",JSON.stringify(a)]},o))})})}if(e.type==="run_lifecycle"){const i=e.status==="running"?"#facc15":e.status==="completed"?"#4ade80":e.status==="failed"?"#ef4444":"var(--text-muted)";return n.jsx(ar,{dot:i,label:e.entrypoint,detail:e.status,time:t})}if(e.type==="files_changed"){const i=`${e.files.length} file${e.files.length!==1?"s":""} changed`;return n.jsx(ar,{dot:"#60a5fa",label:i,time:t,children:n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:e.files.map(o=>n.jsx("div",{className:"text-xs truncate",style:{color:"var(--text-primary)"},children:o},o))})})}const s=e.action==="started"?"#4ade80":e.action==="exited"?"#ef4444":"var(--text-muted)",r=e.action+(e.action==="exited"&&e.exitCode!==void 0?` (${e.exitCode})`:"");return n.jsx(ar,{dot:s,label:e.agentName,detail:r,time:t})}function Ip(){const e=Mc(),t=Bc(),[s,r]=v.useState(!1),[i,o]=v.useState(248),[a,l]=v.useState(!1),{runs:h,selectedRunId:c,setRuns:u,upsertRun:d,selectRun:_,setTraces:g,setLogs:m,setChatMessages:x,setEntrypoints:w,setStateEvents:E,setGraphCache:k,setActiveNode:P,removeActiveNode:A}=de(),{section:D,view:N,runId:$,setupEntrypoint:B,setupMode:T,evalCreating:O,evalSetId:L,evalRunId:R,evalRunItemName:p,evaluatorCreateType:f,evaluatorId:b,evaluatorFilter:y,navigate:j}=et(),{setEvalSets:M,setEvaluators:z,setLocalEvaluators:C,setEvalRuns:H}=xe();v.useEffect(()=>{D==="debug"&&N==="details"&&$&&$!==c&&_($)},[D,N,$,c,_]);const U=da(Z=>Z.init),q=ua(Z=>Z.init);v.useEffect(()=>{wc().then(u).catch(console.error),$i().then(Z=>w(Z.map(me=>me.name))).catch(console.error),U(),q()},[u,w,U,q]),v.useEffect(()=>{D==="evals"&&(ga().then(Z=>M(Z)).catch(console.error),Fc().then(Z=>H(Z)).catch(console.error)),(D==="evals"||D==="evaluators")&&(Ac().then(Z=>z(Z)).catch(console.error),Vi().then(Z=>C(Z)).catch(console.error))},[D,M,z,C,H]);const ee=xe(Z=>Z.evalSets),ie=xe(Z=>Z.evalRuns);v.useEffect(()=>{if(D!=="evals"||O||L||R)return;const Z=Object.values(ie).sort((dt,ve)=>new Date(ve.start_time??0).getTime()-new Date(dt.start_time??0).getTime());if(Z.length>0){j(`#/evals/runs/${Z[0].id}`);return}const me=Object.values(ee);me.length>0&&j(`#/evals/sets/${me[0].id}`)},[D,O,L,R,ie,ee,j]),v.useEffect(()=>{const Z=me=>{me.key==="Escape"&&s&&r(!1)};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[s]);const F=c?h[c]:null,se=v.useCallback((Z,me)=>{d(me),g(Z,me.traces),m(Z,me.logs);const dt=me.messages.map(ve=>{const vt=ve.contentParts??ve.content_parts??[],xt=ve.toolCalls??ve.tool_calls??[];return{message_id:ve.messageId??ve.message_id,role:ve.role??"assistant",content:vt.filter(ot=>{const ut=ot.mimeType??ot.mime_type??"";return ut.startsWith("text/")||ut==="application/json"}).map(ot=>{const ut=ot.data;return(ut==null?void 0:ut.inline)??""}).join(` +`).trim()??"",tool_calls:xt.length>0?xt.map(ot=>({name:ot.name??"",has_result:!!ot.result})):void 0}});if(x(Z,dt),me.graph&&me.graph.nodes.length>0&&k(Z,me.graph),me.states&&me.states.length>0&&(E(Z,me.states.map(ve=>({node_name:ve.node_name,qualified_node_name:ve.qualified_node_name,phase:ve.phase,timestamp:new Date(ve.timestamp).getTime(),payload:ve.payload}))),me.status!=="completed"&&me.status!=="failed"))for(const ve of me.states)ve.phase==="started"?P(Z,ve.node_name,ve.qualified_node_name):ve.phase==="completed"&&A(Z,ve.node_name)},[d,g,m,x,E,k,P,A]);v.useEffect(()=>{if(!c)return;e.subscribe(c),Ir(c).then(me=>se(c,me)).catch(console.error);const Z=setTimeout(()=>{const me=de.getState().runs[c];me&&(me.status==="pending"||me.status==="running")&&Ir(c).then(dt=>se(c,dt)).catch(console.error)},2e3);return()=>{clearTimeout(Z),e.unsubscribe(c)}},[c,e,se]);const pe=v.useRef(null);v.useEffect(()=>{var dt,ve;if(!c)return;const Z=F==null?void 0:F.status,me=pe.current;if(pe.current=Z??null,Z&&(Z==="completed"||Z==="failed")&&me!==Z){const vt=de.getState(),xt=((dt=vt.traces[c])==null?void 0:dt.length)??0,ot=((ve=vt.logs[c])==null?void 0:ve.length)??0,ut=(F==null?void 0:F.trace_count)??0,Ks=(F==null?void 0:F.log_count)??0;(xtse(c,Bt)).catch(console.error)}},[c,F==null?void 0:F.status,se]);const _e=Z=>{j(`#/debug/runs/${Z}/traces`),_(Z),r(!1)},qe=Z=>{j(`#/debug/runs/${Z}/traces`),_(Z),r(!1)},St=()=>{j("#/debug/new"),r(!1)},ht=Z=>{Z==="debug"?j("#/debug/new"):Z==="evals"?j("#/evals"):Z==="evaluators"?j("#/evaluators"):Z==="explorer"&&j("#/explorer")},ge=v.useCallback(Z=>{Z.preventDefault(),l(!0);const me="touches"in Z?Z.touches[0].clientX:Z.clientX,dt=i,ve=xt=>{const ot="touches"in xt?xt.touches[0].clientX:xt.clientX,ut=Math.max(200,Math.min(480,dt+(ot-me)));o(ut)},vt=()=>{l(!1),document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",vt),document.removeEventListener("touchmove",ve),document.removeEventListener("touchend",vt),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",ve),document.addEventListener("mouseup",vt),document.addEventListener("touchmove",ve,{passive:!1}),document.addEventListener("touchend",vt)},[i]),$t=()=>D==="explorer"?n.jsx(Ap,{}):D==="evals"?O?n.jsx(Zn,{}):R?n.jsx(Fh,{evalRunId:R,itemName:p}):L?n.jsx(Ih,{evalSetId:L}):n.jsx(Zn,{}):D==="evaluators"?f?n.jsx(td,{category:f}):n.jsx(Jh,{evaluatorId:b,evaluatorFilter:y}):N==="new"?n.jsx(Zc,{}):N==="setup"&&B&&T?n.jsx(_h,{entrypoint:B,mode:T,ws:e,onRunCreated:_e,isMobile:t}):F?n.jsx(Dh,{run:F,ws:e,isMobile:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"});return t?n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden relative",children:[!s&&n.jsx("button",{onClick:()=>r(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),n.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),n.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>r(!1)}),n.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[n.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[n.jsxs("button",{onClick:()=>{j("#/debug/new"),r(!1)},className:"flex items-center gap-2 cursor-pointer",style:{background:"none",border:"none"},children:[n.jsx("img",{src:"/favicon.ico",width:"14",height:"14",alt:"UiPath"}),n.jsx("span",{className:"text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Developer Console"})]}),n.jsx("button",{onClick:()=>r(!1),className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(Vn,{}),D==="evaluators"&&n.jsx(Qn,{}),D==="explorer"&&n.jsx(to,{})]})]}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]}):n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsxs("aside",{className:"shrink-0 flex flex-col",style:{width:i,background:"var(--sidebar-bg)"},children:[n.jsxs("div",{className:"flex h-10 border-b shrink-0",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>j("#/debug/new"),className:"w-12 shrink-0 flex items-center justify-center cursor-pointer transition-colors border-r",style:{background:"var(--activity-bar-bg)",border:"none",borderRight:"1px solid var(--border)"},onMouseEnter:Z=>{Z.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:Z=>{Z.currentTarget.style.background="var(--activity-bar-bg)"},children:n.jsx("img",{src:"/favicon.ico",width:"20",height:"20",alt:"UiPath"})}),n.jsx("div",{className:"flex-1 flex items-center px-3",style:{background:"var(--sidebar-bg)"},children:n.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:D==="debug"?"Developer Console":D==="evals"?"Evaluations":D==="evaluators"?"Evaluators":"Explorer"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx(Pc,{section:D,onSectionChange:ht}),n.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[D==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(Vn,{}),D==="evaluators"&&n.jsx(Qn,{}),D==="explorer"&&n.jsx(to,{})]})]})]}),n.jsx("div",{onMouseDown:ge,onTouchStart:ge,className:"shrink-0 drag-handle-col",style:a?{background:"var(--accent)"}:void 0}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]})}lc.createRoot(document.getElementById("root")).render(n.jsx(v.StrictMode,{children:n.jsx(Ip,{})}));export{Ia as H,fd as j,de as u}; diff --git a/src/uipath/dev/server/static/index.html b/src/uipath/dev/server/static/index.html index f5a773a..25f520a 100644 --- a/src/uipath/dev/server/static/index.html +++ b/src/uipath/dev/server/static/index.html @@ -5,7 +5,7 @@ UiPath Developer Console - + From 51476ff70196b9c80e4c10f8e7175e0abef8675f Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sat, 28 Mar 2026 23:44:47 +0200 Subject: [PATCH 04/12] feat: add Models popover in status bar to browse available LLM models Add a "Models" button in the status bar (next to connection status) that expands a popover listing available LLM models from AgentHub. Fetches on first click, shows model name and vendor in a minimal scrollable list. Co-Authored-By: Claude Opus 4.6 (1M context) --- img.png | Bin 0 -> 42850 bytes .../components/graph/nodes/MarchingBorder.tsx | 13 +++ .../src/components/layout/StatusBar.tsx | 95 +++++++++++++++++- ...anel-CrwXase9.js => ChatPanel-CvZbTGws.js} | 2 +- .../server/static/assets/index-2G7e_dtD.css | 32 ++++++ .../server/static/assets/index-6FxzQyx2.css | 32 ------ .../{index-CMiQYjGD.js => index-DDJ_NWFS.js} | 44 ++++---- src/uipath/dev/server/static/index.html | 4 +- 8 files changed, 162 insertions(+), 60 deletions(-) create mode 100644 img.png create mode 100644 src/uipath/dev/server/frontend/src/components/graph/nodes/MarchingBorder.tsx rename src/uipath/dev/server/static/assets/{ChatPanel-CrwXase9.js => ChatPanel-CvZbTGws.js} (99%) create mode 100644 src/uipath/dev/server/static/assets/index-2G7e_dtD.css delete mode 100644 src/uipath/dev/server/static/assets/index-6FxzQyx2.css rename src/uipath/dev/server/static/assets/{index-CMiQYjGD.js => index-DDJ_NWFS.js} (63%) diff --git a/img.png b/img.png new file mode 100644 index 0000000000000000000000000000000000000000..1e3597cda4863338e8112bc6290f2b0ad9d2ddfc GIT binary patch literal 42850 zcmeFZcU+TMyEYn72SEjuL3Ah?8(2X_X#p~h<1k3GQlvzsNlBsCB+LjhiV_t8>7ybj zE%XEe1VKQIfPxSq2_duyAqf#eAR)>3pw7GBefIhN&UwGRzf*qS{!1RSvYxf>wbp%K z_jTPXx6V3PZ&LX|1q1?Zvia?o^B~X~A_%nBas79||C~^^4+DYXK{mgfycp#<%jm^x z4?H#$OALRpu6n!0v@_v~7t3_^wd&E}AE$Ph#p7PSY<)Fak%r!=`NvB|9hmYCojtpD z7tG7z@5CiJ|Azd9r{n1ZO3i+M;gzYpU8|frFfiazi@7L5@S6fjD?8%WdO)4ZY6HTB zVqP&qo&na5+69cFMam<;+5r49irF)&2m&2ZQ8WOap8ojX5C0q6prv^($TU=1f|8EY zSZ~J#=AbJYz`kgUjx%zX5>>)siDd^fT7Qp{zIv>QaHPVp((_da!?(EnVAjP3sd%kB zi0Hi9-hUmP17<24=2_eiszxgEtRq`%Ma`c~Mb%*vA@^j9v(>rna)2`K+@@Ugp_JJ2bGCuEtL&n<0Z6!6`bkh}GW8!B{m#-iz#T zxAF}{(4Exy4J~z-uGXp4Rl<|#%Q|#7Ry!rKkj0r<_Jh!7JzCzE1c}p8R8K*tYjl-`=iy_w!f@9JW}Tj8FlakFHM$3yTnD+ z*&AHZeYCc*J75S5-K6PB+Tt0mpBTJ``3fs(yUxQr zWfH>~pLuTi&CX&e4sp|@5WaLE2+qhlMBZWG*v5HfP1wf$V%%1XBY@dw!N887ZA%)? zRUtx6=fakjY2m1t$qcQ2_=9-K+^hp%ST=VZ@(@9P&YxRo5H^uWY zR-1C&@XhZ0(4_#PJ6uGf48c%5ZRqm-7os-7w6T6`2S3Z)5VMCf5N{XQ9Ajni zp`8EH22uz|{vl{uN1vR`cmvVuX?CN^?`jU?l8|=dQcO@BhfpmG=%Mb}h?Mcpm@b^< zM1d;Q))PTNv~r6l^vlLg*-I?_tK;|WS}dcVVmyv*LKgX+tXEDpOqx$U8z)S(4gWJp zab#Ltj(|MscrebcX%mLIhWbVI-AwYMXaXrmI2-F-EP2Fv%I2J{k6ykOWs0E_ zmHo5%33vN5E~m5Ut77nqhKx8h0XmlHov;dI!TsN(t!77%E69UqZs zoeEdD5(TVT;Lv-l-aeTw`(MR{ri@&jjzsVqZ>CK37)I=M>pB}hj} z8f+ilObH!{V#XH9$`Q!z-^H_(iJ*-|-=hwu{%9`U`QlggBia0J2gQlR3qnztmRfG( z55^dJW1gkn3QM1rHWNI#%;>S1BQ0P07&D*hZ{`ePLhQ?aK(T)p3nN?WXNY{nz~c&! zj|RxY#XrzCkF4yItk|G`~JXV>6AM6SpfTuG%vKz4$TYJU;z1 z&d%OFXC3*4>)DkGSy8e9RK9SHaqF}TSv+-jZY<5QZ3@gkq(&^8bCrJ%7IHcwTeaNI zee!&2_0FlpM^R+s#wwc#WE(N4#(xj2*_J| z%N?qgp}QLeou@$~;&CpDwfrd~Asdq39qHvqVLv`0azPZV^sa3WkJ)9hvNFqj)xEO5 z|0!9v$345&Cy?{&$E9;C>w^tO9qj62gMSzyXWg7N(RN^li1^`c>b-XumeAO32M+Y`WhSF$!_}3h zSF{v()`|uwn3*6(*2DeL&cbM|`{KKJ_VwP5v3U4eB3PN&f-X>X)O2X4gl?lboC+5H zHqXhJ;*9h8g};}Mkmsc%%d*~^M$~b>EP~?ViRpNeZIj8UGZ_AG7(38~q!(theqn#C z5AlWP5-bg#HX$l8??;xxU(omZIO;FIZy+|?$e(dDQxc2cF4vV={mI#;gYUnok&>2C zR~egP)X7^o7sopoti=nT_1nX}%kjttBb)76E1hg3mD}_4-@^&}^!pv_$6q~&c*QO| z%Uq1Q%Nf~Uw4i&J;?6R)r4fS;DOfyO>pm(wxACf3wep0J)>VMdOCbFGGN|>*J(a`J1Jcs9+O~KTPEuc2)(mwrqCg=sdT5g5 z8}8P?exkgcdyJzGLL`-(yZ&~@l1#y+y;*4YwliGJ%w;-A^e7LYrD46{m-Az_Brh&? zOqC*n8Aju^%9+Ux&m=uJLP(9?Wc}Ohefr!YdNd{H>5G*p`_8c^{7|?j8+{+?m+vtAppArkVe0ubCe*W4bjowq`bb3|9P%tAsjgTuX8izWIh=v3c zhY0VW^ciEw)YwXAI2S>Em;rUnL}x5aAE1Rx&_Y3$PV%#6WF2f#>Dk-hs_@>!Yp$GW zS;qqhuBAsQX68Rkf74^J>*I)tQ5W5Fc}MjvjO0>aUqcgPd%g1c_wL)Af(u)ZgtKy5Xj9>OR=&CQ@ z@;2qXy7r2g5zov~x2zy^q z5tngnyg3M5M6!Tv%RZ{b$EtO@*4}+)wI=G_dcc_!#Sxxl9XD2g*}4ZSbAcV-k#D!l zFpPIBoRaUL`?Ml0zZ8EK^DCopaZiNtxt@d@HTLx}zdZQs97GWF!*;>j`yyOfruD{p z>_gR?TGp&?^$W?jysf{l>9fJWb@Qg4*vJoUHZBh7>k?jjaJlPd_4(x;40JJf+$Qja zy&z(peSAO{@51^vZulgoi~5XKci?+(-j&0LNqs5`iC6l#Z3wCD%NGS<7-uu5YtLkk zo#AoKsg)XcyFQ!lpC$jy$iQ{C2WKEfzl4;JN2K>$FxP#<-sd+kU)LAaozh;&r*Vck zR5ORdy9e*?jaLGa3DE2VS%syQ+T~bKwxmgaw9jh`3eRlRaIot0)L&&OB+2o%IM)_5KY}P`IbY?x zd4{^u?9j3f1X|Qo$k45hk3}14FHe>M$t;A`o~rN5c@iJHblz07$iB+)MR!JWnjBku zaf6fEF|0-JA?_S~x`dS`nh|CrJvQO27J`u&3_?wi}(HL%P{k^sH*SDx8kXn2Dsy8b;18)cQ# z9Cff!Frs<2xPW%K30vK6d#kMUMS zOm+dBz>vp)`KaecLkDuG1S8EIy1=J0UwRk;9SgdrW!YqA@tS#7HS5)e`~7QFqRL6NNHEN*p*W+a3R228A`GRMx^o%KbQdg1p>URL#rA6}Jf*nUz+PW)_GQl9w zk9+@%iLI)tQ`VR*c^1prbJa%po2k7`z~c1RUp--6I(1vHvSl$Vo^oDE%~AvNd4a-O z>NiZ>4Ykx#1xtLEGM*MGfUcOElurFQ;9i+!xtiAf^IvD&fnF1MFI3vet@cL_uld4y|cy&8Bb;;>X@@Cpm=Wa)V%@sV|lPv zggR<}F=o-S*+l`=a-g{0+k%|H&>KC!$_iE(D17M;NIgKMwkq0`b@YSsEi!4fe4_~glV6@(w@f&g8NNdkxxx;Uq_`1U@yBS0 zPJCT6{eB2=q7Qx@2?MVnVnQW2)KO0pp=55b%)9`hKf3tc)Cq1>OWAO9>ZAgQzWZC- z3jKBUgfB6+*XtHrUqc zl9%(}H2Z{2<@v z7us@H5q4P9DjVKEIT@e%UM0F8v|XunnzPSTuai4ySPvOip$EUdgBu#qEOk~U-X|hc z0W>x`?{$Kky^ek@R{=DrKYDB}urFd&iSKtez->_32(2WRa1Fu)RM&P*Tbp$9i0X@` zPJY5Tk=|bAPNJ$11>+q}3MS6J?uh+s*ZgBJT)P(gQ-Mxf-vu-&7;Q^C$|O`q#VA9CO&J`KkGar^#qOSCtngS%#jsSOPY9U0LvX^5ma%&# zu~H}fg2J73sy9+AwkLHwr6}^oQjkLCVuT=fbcx7_cPqYN@@HXWs6-L*g5PKTupbTr z@p9uSn}Kt|GaJ>ti~aEYnDQl)VceDsvf5>4ZP2=kp!JCT35`6D2|E`H^9@ymv9k>p zqsG5i4ihfmKk>r*)8ks~B`=nF$ZF|=uo00NG097J%<#c@A2?7%M*q{sSxY~?-Ikn` z_1z$^?$X@M+PB`4-?pMSKMrj|EyrhXxRFN3*|ncMrdm{wCdn<%{ea4b)FoTp<_vj4 zU$E1b5TPaf;hpH=awmpSWZF7+&=r&Q#EmCgo?Z7-R!}A`#7>-#65zt0 zH;Jbptc7XH)$!%XR)A+}6-3cq4WYyUw=)%(af}0CnTT{CuHQv{?zSN|MMEqiXS?2t zeE?!*K!-^MHYwJ7lyS*hhWZy9-H$!iq8UY;XgLbK?yPp-V6ny;p726iB0AVHX#kMj0@$6gUs z5L3I7I!DJN6T5A40WJrdc$aCPj*i-`4Iw@kRWe6x(iH&5YNC))b-{$hI>w%Wun2}8 z8*#c;8mjO{^^xa)@Pyr{PouZy-mwm{(hksNyf+ha$HX;i_KLFwZ@asyObi;eRduYi z9At>C$B~#HFqo+GgRBx(NUfY?(%LoNn_%q-Ph|G|F;}Cil)uTZP7eruTzF`26K4;!u%F?WIvPD--o8k(P>vs`=p#zk$qA+>*_68jnil z&Ur7|WQXur{|Y(@3Eseg5@&9SvZZ9Ke8NJS>7JLagUN#}m~=rXCw zqfuKQw-puQ4);pu)miW7^Ys-LS!`&o5`6?htoC}S$Wv2=ZOAC;eCX(*il^Us18lNi z0XIkey=X*@TFh@BS=r@|fg9!INR3Y7gPOo8VB&Vq91MF=ikj^#YJFNXf+ydAs6FZy z+kmVvW;v$s>4{B7@)6!CNB50>mjv)GCvd{7u#lj&HK1k1k4e=r)ha zno}WiRUU<9C)61^K(x9ILmH&F zW%V&}F^i6>P3QrfEr8p8Qzp*t_G=5pE?pDsTS$T>n0S)3RV}|q5-hvPcOmGB<@;fl zfXJ)*U%=QNgoI6Kvbs{q%23FBfax+l5a>8p%PI6#K>7Aw@KwAr@lg2Oy9+FRN3wPb zRC?a@bAR<}IJt>6i}?WrDhzE4NO9@bC^7Ro5qXE5THy>N1eY|Q&)`F>O?vif8i7F9 zOQ!A&(9ga0*{5jGR7`GF1_E1Y@jr!zXV1mDr-jdL;#T8{)qr+iWXLKYJty>17!d6r z+prA;T6ppA5N9a?-0{r;Z9gAi(T{}4WkcAT7sw5d4k0gc zjO84xZ8~81Rp?%0xQ53dv3i-4b@f`!<+?CgNbS2JONUxMw3Q00BP{nXnCAM-Lta%| zKMU;?f2IwIhjJ%ogppWf<0+``e64 z^u^rXp3fc|i8kx)6%kVoL0eH7)J>o(Wd9`krB?Xquc%%E88ybs`!=N?Tt{C@2{LGj zIE7r?GU;&TE~PZQ*$YzUrnicZm9qZ1bFvbB8UF*}2K#`5Np<(}7UPpO(TwI2H?hJC zC$s(|Gy}p5m^*?aJiZ+}Ze0k9mz?5JAKHGKd$xj!Of^7VoLF1jAIB>03oSLDsGG@M84I1~P`F<0;R+z4T=^@!Bq;K36wG_MfIw=S z{|1Mm>x+L@L25uPH-7t;R5pR;u5A9#=6e5p6#g4p{{M>-w0&94dMm`Y z3UTvalr?}!iDv-}Lk>W^%!Yh4^@!GYFaLu(1*xWHvPJI)p6@OE7R9*L>56z$7 z-ddI;(M!vFJ~V6VqQ@ptQ<0H+G^VnqgZ&^l&Nyc%>!IkSK5Ih#8zGna7ioEhlIaET zN~OO7WA<;6zGMaV^Cvwqvgv8gDMPv{723EZTvF)9nxobzWOzv8#TY}iD0G*PeYSXKjN2E9@sB>&aeQMh z=59U5*Yv(NfUvHdP&7FBdL8}NU9GE}amTh^M?_*E7^~Z(n|(Nc9X(L9=WtyvL%=B3 zJ(V}|Qo1V#8hyYbj0oSoav>xLScrl3#L~YuqtqI;d$3EFKCX;9h?I(a6+~j|{3OkM zGcDbiv1_Ih$qazRHm}UJ&y6Xi3i*JbjDs2}*YzgsCdWVo^i4>Yt-ukik8GX`mGi zL=%-8QsZOiQ!50h!01H?z_EZxKq`7zzVMsSMQ|5&Skx<7WnNl9YuyLW$^$+NvjIjF z@1dgREI)oWwrMq8+Xz$v0o{EM@abPr;=lIb6!Gb`VQZ>BRvi;DHGukDPX+q=MzS5v zgSL9Aqg-c39~ZSc=3&gVvEpZ_i6Xx?mKS-WJY?ZG2xP~;IiOvcbsf`QBwc(9_8#RWWgq?BNRX`mrg{MPTdnUZe9F>K!AMo zT@vI0X@&8Rxb!t$%KjA!--exF!M}0OelCKWHlYGe!_|9=`%Jt{Vqfz+Tjhvu5h# z-2lcER*LNU3;^m??q|`br76~AWtl`bu8tQ@20X5g%@G?+|DQq`p4Y1Z&c1{QunDh( zQ}ym+S){>6Lq#|vZ_%qKT*8?gkVno882AnIh`MDB;lquk_CV$26BWXMpG3aGl%j$1`~B{@LGcr!mh79qqR`u zb3>S>pZD3}sx3yRTD?Rr$&kmn@ZqZ#ZiKumk2ZY1ud{&|Oe?&Kc5((biLOiiKcf%% zcl3SFYj1cN|58||iQ2%b4J~!wQAFB#BKl$E&LLzo8tWEuV05w0zGYp!(q-*`#!>8e zn(D>eNz!&y>gKGqbh{Q?Mc(Iz!{5I-RH}(mh-dVv)|VvE{$7E|7PzPUnO3Qj3NiRO zW!*=_r|!f~#5ZJ=z3H~Js5kcOBx1RK;}2NVZ~e|CuY8%cRt80^ol0WX#L zMb0QO^R~bzH2pYQb#YbgP;s^lIFHV6RdZATy?Z|Ow-5f6mA+G%SX#Q8=K)C_Y_d2X ztpth>K)7^oL9^4P|EW;%KNDX5U;NIq&c8vJo7Kv$MuFJZR4}e@MC0eJDMBQa@JBXk zCH04w#4IE_w$(y|5<683IRHG6~pd($^IWi&)}LSVFa9PrCFIKtQTRwmNAXfHtU) z5SKzsk1!Uy=048nCj^3xai##|$$P||e`j=cycQ^xZP;z$N)V1fSg(H{VhrPuNuj-D z81rym!Utbhv=TuXpTVgrihQWw8OJ>zMO2~VkT*-XoyGbFIWfC(qMF2Vpi-(o#kwb{ zA5Tb;zvRx1O&77@L3PmRxP$I_1M=Z)=eDO3;}2_qj0f1*)@Fd-_@O%*mBW0`h|$-U z2wu#6!doe4r-o->EtQiUo1mMToaMqv)TcQk*2fKm*7|__;@PqTk1)EPak9y|Pq^O1 zR6P9VxKdWUTN*(_H}<)er|~Ez3ebNCD6H4&?ADGFp_MZ%%6Mh;Z)P$eo9U6cB7cDz zeY|f}H%CW)!;LjN9m;yAuGu!kWM-C<)jchuuf@ELk>FdW+_F<6ayRMwb`n=O7c!dx zOW)K36!BWXJN5!Z;Ii6JxvQ*}%JWp|Wd#unn^%VC#rLGk7oDd?QJl}bgn7qy%9D6f z^kEANCLgF!9+`dAPo3WVCO1Czb4QH~Z*d`MsKFB`Z5_xRHo@ERt*A7@aQKnK>Huc~ z1<=mJH3$gGIMQ6bUuxWXU(*-21?z4(77LGYuG4a%_^>l3|L}FEhGj>zbnEOk*d1M9 zc0msWs=xvm>d#Z-Z`BNwHk3hf=OIK~ewLN0g{WLzPzm^(NrjZYBMqN*=tEYklocKDf-&B*%)gTJZ+2&=`d}NkI9ME`@dVv-9o|Dz zd_wCj{bE$CaZVHqV2``H8h}dX4ZZmrlJtHTz3Y(lgRxoP(GS=;F=^803p#WSMP9dI zD-srErd_<)v=aTji{VYpk{HkY5A#ctsIgyGfcFa6%$I1hoMjJyNt}9r9SEi%o}r?F zrLO`ZdLrr?2S?EVT^JX&PrR44rqiVDAm2%$as)B2X43Yn#;-X0R;0$BlF0%5K@)PA zJ6F_}%$lX;CzT!e(?K+}5vTKKThL)G6yAMtpQ!T?X*! zDqkd>mFbMtXt5~?Cq1@8dEftUOrXmuQueaQPXKBz`$`&qx`a)GtOkfjK!9*N;a579 z^0UFIEvRWg;Bg=VvEkAHy)x@m$NZU(8vqV&K(w#e+I}qg8;{qV`UTh(gEu^HcH9E{ z57N^)p;Q^VZyl&5;!^1A0D~R9hF1y7t1`Gm7gh>n0UG}%b^q5uKZ#W%VpXs* z9+-uXls_#0!s(H*T2{#!OlvDi;k&vw8O)nxv?ycFsj<;jB+5g((c+{&zB;120e4p5 zNuA4Xk>vb`%jl(fVHhKTcN4Gg#X&OZWiZFi;ieBq43Z>@fjM2&Y-)d(ja-azc%Tyf*^AF-G08+d!8R44M* zAZ9!}rySPOW6Rp|Y|D38QhOzrr_c{-&}y?wM@66FxKT}7oVDG#6)VK)*yWQdM2f_3 z@4xH3C|<%KusD55gEh!zHSFQCd>iP(4kzC+40JO}lr)j`K2+L>_ZiW*p@~{jz@fMv zY6_K9dFo^UEgfuvHrzm@8IR`to07>=47(Gyi#BcXRz;+eB`Hm50M4 z$_3rArMiZ>5w#-z1_zrKk7wXvcCCkJBeHfy-UU;N8QDFL;VhgqclzwL-#H2Tj87d} z@)uzvv-eWd^8^G2$7Ut3jOmw*f#V&;m3ZA946knnt?hFq3J|=>I%^^a0+jm+fI2H@lFvjX)@NZaOqVsMj^bk`MX2#pOEAyxW@F zMh_=kz%8NGbE}0`ob)@@KYOGKEBh7`15Y#RRwT!zH1iak6Z!|kI5N)AcK)traD1AIsy@@$?wBkIphNeTt_E+u@ow|USmKv$; z4c<{UZlGlwtn)xL5oGsDdLH+<#y)qvovp9BIndqlfw)$$f)PR*e?ri`)g{ievVDW> zi44q^VPJf8-xgfw;)(r(5GSL~6sC2qtVie(r^Dlr!`_DZbhIq2)V^`-Vb4C|`q(r% zN0UqY>XyPine6MAablt%_E4FhJUCVK`M~%gUF)G{xN8-f?e0izr;gSbYKA*>{%YZr z+WT~w*t=@~_VEDEP99s}`OW;EN_4uCJ7OzcRzWF)*@wOLzGmXK&3?~t430rS270W# zY>M*WrH0X*>NC|Uyh(L=G23X)S^L7?+}1bl#so{Bbh(A(L`g1}Be)R}`gv(@U1s-V z16*StG<4#}V+uIQ;+a9S-e(a$Gv~5`G&=0rQBBf&gFAPG+T@BQyE04bQY_Jq-jX7> zsVeh}UY|I~%kaRA%ve~>prIC)7xIaq}L^>l%Gm zr>35@lpdGv1vjS`++edzkxQWmkkQj-l4?{1AMX%ssFBau$a5VFAA_Zrvl^atUdR1j ztaB+lTi){~2M#6c?k%1t#jT`CYS=6K{QepkiQ@F!x+g5IhQN>R?GRob=GPw^^O=?u zl#F1`O>GU%75AKMgcaqF#W5PftO71vME};FdgHQKVJmw5gdU>a=P*PAl}*L+9y%}G3$Pi! z_#9c~fjgb80v=AAUhY~5E%L}zKIKo=sHIf~xfhHZ^ylZQt-Sr{I+*9}dimEPUC}#P zkJ)Sv`)%|aJMRXsABT%Bcn;s3Ts^SRsbVxaS2}mz+=13NPo0I9&{WWwWo@O02XMGr z{Yjx3i=22`bEq02`D9 zJ|sA~968UlyJkPa`aEA_#IU|WpS_o0?<~%n;iZ;X`?=Psjl~r7jZZDw z^j;FU?{OMx_79{xCZcKV{WRWn+L(ALic)9ju9-eto&8O^0xIOC$^2`seytZ&0=nvi z;^m}|CS_{yXD-`^rk7Ee)M-fJolg^{O-{0=6jZ zs=0%7<2+HD@t4pfGXH6uU3iaw+(?z=G`j+h$#at!!#O&dlg-mX(8EuUo0W0M`*u_F zqFh(Z%dGokoJ4TuOkk{^dxx-`a%auN3~&JfnTGjOWJ6;hI$`8w{gM|`(jfz*yqdk} z9e1C_>G*Q}ahxHSGjDD)ZMmEe4+I%a5fkaca!1Jt*Sb>O`v`E)@FRCkxA4~s_E<8z z!@BVhhA|LpKl3NG-Rr~!>Z0WEG(Su-&2jRONB}MNkWpcwRLjE)LOb61Nj^?7=VuV% z6i&V_M5f){#BQL>gg*RG?PpQobLh>qj$aqs*`jWjZJnW#@U7Wx&VwB4kg*_|_x45u z^jI26^?Qo#@Ud9rf(JI@{#V{JV$Z0<2~BDueQk85mC4bdvfjAgsBcahj2JH$DIZI{ zIa~E}v<+j-oWOAg+@fL#_zD^<=3+c%wM0JH{8vIdJrhgL_@cy(;xQp!|7iC<;<>?4}|wn+=D>JhSJQr6XSYi)^udzd_Q&Z?L=|t$XLV);h%aJ z=Fwxp&0Ngu4?7{o*iXi{IQ5$PL!2LVV< z2R}KnO*SYUUoScL!>%Dn$;#F7mwJB_@*mBFI!fv7KzgnUAVfe_`dT!L z;%~!^WUl2QyLM*@yl}GseF~Iq`}_^a|5w)9{z) zL{`H#>l%`szhyZb!|_S4S~n@tj?vrZ@Np<|ZT=J18lLK~V1DH<4+2Z}x7i|tB1*s+ z(eK2WX|qvtJJb{iIF2&i@tfDUpdczEF&)A7@Gw0DRlZf0l~C@qIoly+o5WcCnSUlz zy0>w_m6`X;04_3I|76*%_X|XB$hi6UuOxeMxWl^bxy3WYo`&l`o1!0@nh(~fO;NHI z2jM|)G6`5$r~}1??q3G>DBr8jbpYFmxs;i3e?=`q;QQXD@oOV_zH$u;Uc4JpIQ;mk z4eZ2ND8me9D-M`6ui-Gw^|^~Ri~L2`%NQs1BV+S}Lj;;8LxvcRiLA4)Ml!9It#~=( zK}|d%(Y`)em^(jAFfd6Uo=kr=UeLtsGaelFdOnOzi>D3g?>FL!8q~5EBbcJH2H)~^ z&-9O&`;_)62`Vqs413xR@Jk{{MQVio| zrE{LHNX(gh#(bU@GnnDbjs2+eO;Nc8TxdMPvnzPgb=r9SMOsZpJKjzG5AO%>;vSi( z&qmY>6L#j=!P#qMfT@2K2JrJ8a;!*hc^A8>-FmyZF=4c-m=^mr-rDBJq}%NSAgOuN z-p^|t&r^N#qyAu|FV6P`A4T?l4$+j@c{0nyyFEu9Qfs^tn{U(5$IIudnlIO?b{}<1 z6-?!HpmmfI4ds1C^+uK-x2&i2V6h{$PE!=?m(tsVIcL6mu+E z$~N?qgGDeu+EUyJuNUF;KSlyu`;0rr11cT0gNDaACl}G$c;rA}tbz#vEwXHCR2vgH z$)op?@qJ$GcDB(>wS&$upW^Gm%Xvjj{-oXRh3{7jMqeI3$ipp5%&Q&4Jm;x@<_We@ zE2Xk{k8d&yPz)_d@_%Z1{|!Rj-t+-A^QU9X^5qJgp6dm{t9_UzG#7H1(K0kZFvu$% zYzU{oQ#TMNe@cthadbCQf37ieF28Nbz2>wu$C6$2R5_yDvhwq?t=@z!1tGGxs62%1 zr#hE>czi(=^(3|i(%c|Hp4z(kz%%2z#c3VQ9hr;mlab;*&UgoKX)t}vehN{qVi?Gt@o8TckS7YY0C0{Es^{jdu^K|YPfTV*RYtdU-M9?0)dtuHB^Op zJMgUO5J9$}l3MsY-+70o4P$=hmTwrr$J5E=PK0Eq0SWln%0Qp0`M!!fxYOu8*CC68 zHjgAYo%_W1{@IFAexfe6v%Ly^j0?p7x~_qP>No2m=`r~eyvrs0t<|El!H3Fz#M)n< z8S3w#i(R9KB6>w#HRJqntRdNWTix^>GLcWhr=E=p8?bVT&>b5u>`b9OFoI^>GA(eX z#Pm4YN^%OMgzb^Hh9V{fmttUkVvC_jCnmhPsMt%RQ*-vnw}PSHTDs9cI_hr|d9~!) z|8iNKwA6E|xl}mFrN(D}s6|^3wf28O1=VNZ7K2KJUu zTD+Tu-#N1(L0Ti8Q|-yyzY5^>OAd0k&(gJ;-RC5O;oH> z8w$}G2Z2?js&yMP1OrrOT6x<8fd~qy`*(!5U=Wa)Exo55qN1G7V z=;i&wQOTLs86iUk*bBmyx3wt*vGwJ-CF}YJ~nLeF*9@h zD|M#$RGeTZQ0lst&P(tWzg!XVUhT=d@~ShhxknoUxfSS1Xji99zj|CN4?`33(9k`= z5zhR{9+##YD^VcuO*3VGX0!_*rMYJPR7?3(V`*;U&lsbcrNW0(tG#zQrwOFq$8J&4=Ao?iP(kxHk6AhD+kSnNW19U}<~3 z&--9~iT-%0(K1fn(!byzeMopSJ}7%kMEML{jV$!|^;fYh^WnTbflrg@Q=6BvjA9ws z9>4Kf5}!mN(3G0kJ0t0Ll(weOdG&sFhl7TVwyj+A}_W>EXk!qUgBUXXx5obMFpMzqr%FTl&rI%>jBu zL3ALpe+RZ2{^iJLEe^=L^TvHr1>q@LWZVH=4V+U(F&B6FL}apdHUSdJjThahUUOy~K^oI#(*G^KgCpVuC4va61B6xn+XqR6uh zlUttL>s-=!J%0(E%SkS<&#j8-aO;(vYVjd_EBPx@07#71jB3i^tH9e9i5K-+U8$^}^LZu+#s_8jydD;16>@#;UmqN%=8(l>o|>(rR`_Mhi)Ai-ScsJeXYXeR2%%0C`% zNZ7k)vy-l(rjc9d(LTq)-$JkIf;1O3GS*Mi1$JUWF{#9PfY8h=zKo3#jx;gvd)^k! z@QP=OXL#b-+QIMizSJ@go^EOXem(IBAfE$rlYyc^;ZH4zw^pl(;={L~j;>QQu=`R@ zRGJ*0yni$5>gq2*0QE9!-R*!IBI>K+2#B+5^qR_A_eWpu>$+$vXkPenwDp(OQlyrK z^~6Vt3Yz~9yy~YiISacIL6O`2(|pdhCAk4J`t|P_Z3PF(@j!*GzlSBNS9V@yH6Ei?$cibvx|2ph6nyeNPoz&y%Ge>QaAQ9q5BrL=^p(p@F}Xs zpJlwFTJCnLp|-#srs%bMv^8wyRc}^jzStw=6i^t~@;+??!D_VOM1h;_8{ys~#)<}2 zn1v4;x<@ko9%unoY@n1pccKtqU;EVU)SK|V6&u#Nd+R`CzeuFYKLgSoNLy|IU&?ip z4`U^ADf8k4ERTTVJ=Nn$zF%SO2iis<;GYKnM3j9Ryp!N&cPlX;ynaDOS=h#oG{69PcoAJP}KFDU1lB=xf2%rpfU@BxWmv1_1MXzJ^ zPmK*3y=h+EO~==|U;J$i4~_Fc7|5pkr!LFyPXTWJ`lN{NJ>w)8{3@+oFT zyLO23=PL|V$xkQFX?tQfza)X+MjOyfkk4(OaqrnVGesVc? z*e`1X)-?!g{~gm4e8e!%(sd(|88a6YI`$-xX5F3GpWM*QvAWI3m%}u<*y;13V-rT* znHlt>%{f1}G|BBk<+*$sS#=7kx_iM)Dv{dIZ&sSH}=k1*^ao7=mL+edz9!5$f)|J*Ww(d~f- zL`B*)R+!@)!0w5Rb}3Gc1(#&~^}!Nx@NvI^Gjyl;X0 z&(E+CC$b+ck&MfN)#K(5oV@Ve<>l%KS+E4S&g8Kp84ZghZ+1ywCrKeqQb85==BVs{ zQ1{+(O)X)&s2vnBR!}JsD@s#TIz&W7P$?FA5djq;v`7;YP=vURQlv?jCL$1u5C|oJ zNDBf|14(E?2rWbiB#@BgF5K>K``vQx{hfQx`JM02tgNi8nR#dCdCT)mUG^kPnH_Pw zoP!{0_+IT_p9$Z@fC0Z!H`~x#rd)X8l%zNK5bk|-2=Jc{2A4GYYiEg)J+&d6W*M4Z z>X4qFz{oVy2)|!)rA(+8&oZR|;nN0YEUI%SM`JCSbInV)4$df}sDH}er}4^ zI~*rsaxEcE8I%Uk2`Im?y#j^dO(snCVnyTWXGc~l{GGaZeg6&9JDKl{8@qaP&?eQ;bLz%(qNYZY0DB0|d=`vKso;~}Q1pj!rprjn9V0y-0i&g z`+>`*l>SIJxzmLBx&Z(I0$54j-4wWdN%&vj_rDO{VnjULhoHFX&uO?_z`zdv2H2QG z9<>Af<8TS!%|8Fe?ND(KVEMI!4+Z+nGA5Zk1Y@wqU9b|kLvPF9NW9du4hrwyMpBxx zjVA%u&jPfyb@1L}x@ms7Gf80{J{;(S{AC&8d;iA&&SD!`lYoX6j>4-MA@gS3V7CVW zGVTV3&fnk~dTiYb7=84=1MvU<;A2cTQvsx;wv3v1us*jYD*nLYHzG7wNt0h|ZLhfj z6}uZQh5z3p`Twi!Sgc#~gLU(~2{=m|zE}J|;dcY_x>XMyzJ-=~W^-gTqh;tl*?o+x zcazLIz0zz z{AGn3f-QdO3~$)*;1^GS!-jW&qXyi!;hxBU#|^00zfmfJIsJqLLMz4d5t*uTb|X8? z=*ad}a0}sfjvews|Vqslt!TRk)B6Cmf!Sotw1JlQ%Z zhEi;*JPE8dy974LD}LBnK`9{>c^HQj2#E=lLAQ&3nn9!&CA#sfHDv6XZ;3uC@7DW; zvNy?l`AB$FvB_0tId(QNHs(d;8+}uJD}9~?lXiQ!xE2F%0Q7d9$)!5orZXGM`H!+i zw{?yldlznL`_bkj74ktf@Pg{;+od|PE8Hqv4k_Z*B(WO_wKF_u3Xgo*;bIZtYUL|g zqQF)6#ntpLQ0ltjbKd?po)|*KoPu{;j-|VpjQpJUE7g>st5k1$X8PKHvDjLhX>kWl zr*~KHrrwVzaCk%aO3qL^;ceNh&`90S^c{)N2V)5o4bQL1rZbOQgGnqs^Ej>YQZ>%_ zo66o*DOUSyWc99iQUmPnqY_=-|=)x={Tu&t%UFWArsyv5>H#c`%fY zmzdFKkI;`bA0K`w*j^&16Hw+ELm$AWT{IYJ^_1O8vgM$I?u2R3Jw__3dpchgzwWq+ zF$vGUl`0GJ5i(>YgOW(Yq(cmK+0d zw98hq`IK{u)GURbOS@UQr#2hcS&kyT^EfSvlulDfXu8k!jb>qSwihs#L86q|{z)f4 zYsH8!J|`Ul6eZQY#bdoJOX%bNN2z}O#>~SonS@g%Hs_#-3DPHP++`wCFs8RdK=DYvl&vudDlA$*{YC9!^7Rb6pQogB{pGf6m%t4! zi4Qj#w1(DL=ET2{J9NjkJsu6*p$u5TR`#pX;JmGgWt-gG(vD|I7Zyl(^k`i?;k~rWs;+Mn{?o>C&Ca5r zHg9zub2)Ctm2KoK_bUlRRn=B(3(jb>+qC$PlB(dOQiWWzF{U%g25mMQGFA4)FRNL` zJB(qT;ttr?X;HD z!pef~lM9v`^-I;MLu;7B^^a9>bmv*)ZSZgmG89iEP~tFV$w@%Ba0YxWYp+AT zA}mcJaF5-_C!^WNZo`vcQ~MHYB1i*vvX4@u z8JBC#cYUp|M{Y6_3aV$`ugj0#Vx0rpVrnz}g?O|RySw5o;klMGNxC6*=S{rlW4oNd zq6@4D_SY2T&bw_JestEeZm*T~4gGf@v?BNbo6=ZAFsJMNEUxqI6~tPxB~sazAz z6OKr(9FM28My4i!wN(K*2~IRD%0Y_S+WN$>O_knS!u4#ZXjMAR&3tj~jgLet!E0QK zRj{LiSCP2xLFtCdIvP{Sl3 zoOc9J3OA5)U+tn~dJhAeL->Ek=CHoG{r}ru{%b$s==k*H+H#N*fscDa>jYouOb##@ z{1qYlpj)SV73{(H%2f582LdzX*vVC;pMbx}dO`Lz5KV*yt$oC@k@2yBt`ZRC0}cpK zWCsUuAH&GC%sQ8L`j9$Sq2~P@BsM+?H7_v<2uuOD)tLZjIc%>-gtvW(PzAgwkY>r~ zDF=KvKDS|V4J5)@_j%^~KuLK)vylF^d1O1Ip*azL5MH3V`~%ruCWZ>)(=sO$&Oc1# zbX50L^9b|rWZZ4tB(?hc{MmO|#5a@Qa%I}-{O)*vTFvCQV<;M=f@r-<>oN`4j5~pV z<=?w&m|z79(wAJhV$a$`Iqwz#HWh`~Y4~E)CkKAKb3qY?xq7fM^7-}!z>O5;aeI8y zsA(EC8k0@U?TsTEJsN8(M@w;4E31WRN@n~eLl}D^bn;uCye$9oDz|fpr!^{%;d9j6 z6Pgt+oa&H!UL@3nwrMt0WYV1TS0u5Ud?e zV`}B|7QA4!kjYk7h6hoNd6|(M@Q~R~5NTd+wyx>c`0mc<>54vrxXEku)A>_@@le1R%yi78N@1o|^mTYcrFBJd9$S-{>Q#cSzJ00JQ++skw67gs*dOAPZe z@g>R3l+i?oO8Af9fJ{}1QaP=Y>#PnSu&V=%6hN_fxmOlOAH{I8n|rsCgDx0p73Fh! zW#%0KV}U?N`fj#uS^tBj-5ycJSL?j(`{6l0E4${`UGhr$s1M&ced%3gFsE~J#>y<| zb_5Ub;@en>GV|&c?$$GqGu-=(Ku!vomDm$u_t-Ekj`r(m`+q+T$NA*}SJp;W4xNAoyjGQk5^Im;DV(?SXBaTJqY?U=YqLQY%xvJwBHHZck`&;*HiU25 zB)?08_KR`6;m95j&(XiV!`>sKKk9zr{0$$q*Ms^0qe8=d;b|)tjDhG{C?b%TJ=tpa zE5iAR5a#w~s{fT2S8(p|Mp517a7fqMRIX@ZG{hg{KY^@$ge&(2mbDF!XqpS|?fYu| ziiNA@`9q!a-q;UY0DOp&6?GeOr%3wGO;0=k;&Z{7?V%Q{;plPO_*sK{q5xd+qLcRm zgyRkG7wBXI;AiOdp9w{CBttpoCDl>DHygrtVx(}NvAepNO{*o(kZW5H}&Ci_tPXFr*WmF zP9X~KXFre7#%VV5O-gDlCfzT$4;(71LhvOHkion59(r^Fi`&u!WMiCN0FphmT@)4i z<)N?N!8fx%WnU9RXC9%N8+t(F>MN)^X1t^?GnxR>A^GOcBo3-ryVW;AKMKY}C3?1! zKNXvk;^ytq~>2 zh;_XfZen_wF#LinT5=A@x8 z^e$DUA-!!O+!6<=@aveFa3ft6-a16ZMb*lSIFyf++jl{fxy_Fn z7FujY;fIw~`btfgoACa<$Zd=uVR$CdILAi=C<5*oEJ9`6S z3_Hq7Q*DO8#yZ<9_0bB?iuZWf6AkL1;17$>N&{C4nWF?*eDyI=l)VHZswnV%IjH0A zj4L>D`o7|JEIh&4?;7a{D+>CS)S!EP|E0H$BsS>hEwS$6x8oLvQQ4)k1=TS8eOHqY zd&PgiI+k^aCzmxyIA$RQZ`Emqx)dY(3CS~;mxZU4yz%B1$;wECEF~|U+s+~&x*}`k zA7?QJ@}`h-rS)jYfSawT4Fp5tUQ}E2I$l9{Dn#L4f6+Vx(efN5uDUp(GtdY%Ji0bFK7;k)< zlUNw%qr$O6C^hCXHi@%&rsa}M>))BZ8zjLB+U8S!Dy_&M)}?Mq%q$B06940iwfMBP zzv7WB(2&+OGB!{4OpMYM)OKjSRJe)cw-SYD2h&@mZCLXbmIKi!rIZ%Fx5+VOJLTZu ze54w4f!BIezrdl*@yOfdf<6%7X$}l_N6$68y{z(VU`{A#A}zgw;rrXT80ot#$*+~S%g~h zL%CVY30|*Vn~zkdzVRws6^k`<(;@14$<7QAKHnM^WC`>}Ju`j#I|-@;s=#l)=05MR^sxpN%WBPlVlc#6{44z2Y_CYECN$ZsQhvwW z)|_tUM=*xGEyz`cIiunow^6D(d^s2x_n6gB|1dr!)i10KwEu8Js5=0ekB{U zFcxa)m)3jPG`0V#YG*ghx}!DKtMg}=k{o*h6~G;75v013YMoab6jaU-BbiZNnr13M zQ)62H9Z@j>@+;)~UafD6LdX|uf^QWZ8XFx9hc-15GJA8%q@M1sqOmVu85zmwyE9Gh$b`%_@ znTIv6GV(zckCUQ-G2KyyA{M@BbhY1;^o_B6oblj&sg13G)nlD&!)cCo&CgxbU9C9u z`Q*2Z>uA&x@BMJ*r;fX)^ZM-eP5S3|;0#OGTZ=C?_|;xlu~!aVX@x<)7Y0+KF(#?; zYZipq%zipCi0UTlN?OFt^NfjSPr+E<4ReK^`KJl6&HYY6CS@2bGrAGS1l??|-9fjq^$6dHdqLHp=47V+uMxTSHo)_oL$EzwJaA_Rh(y zXo+|9aKGFO4YrySaKfGB?v9JDMz@FJ3dY3m%;-~f|9Yn^v)q6cCLNjOU6tr8RR|Od z;anfUFh>^rUjR8$-FD40Kz$te$7<<*JJD(ENy5#rA%Tm~kJ~G4j0B_pj`8bsfFySy(6>^eeAxpJ@R z-yQhmrg_Y64{Br3>xCludm#~P3%m9eY1TK}V@JlN|5!qPxuPxqMK8>JoPytCc{nW7JRi+B42s%qIJu6}c-|A#hbRFs9D?$jjL*P*q+> zQW-k-ZYg8cjgin5U&2$G3!_C5oUDd@3U3c?yP@~54ICXsyL|FEl=w+F37M=`^{M%Y zsQa;j`DAivd$VH!Y`ETh)Wf-jLzB?e`w*Z7py8A{tr{F|3s zVbhtW8Nv_L6@MUJ%^GvG<@aB8)5)>RI?j0_l=^eIGzFjWF)03swMH!IUd-K_n2Y&# ztBscqzK_vjhB=T`v8xB#6N+|a)3hP^>ZhV-Gp>a@nIp<+%mTl(tXe0rQh14@ST{p@ z7_xtQIo_nQC<4hm#z*!G_e>K8e80;To^`Ef2M3+$M(NZms;W{LSZ zX-ASyiV8I^s$zO`C&V~2^gViI7xytWOa zq=eU@)$*kb{9EqZRM-M(s1kMqol6#1YH>L+ z7$<>x>TE%+L>RMO2SM{?l+~T%AIVgusM!$vfOPO8ET07NEtD@ym&QimXX`pGvLQ|u z``-R1?6IKZwwlPRt0<7&TZ+`agCoo$KGtzoJRDg{CIjk)?8{Uo5L z=u=u1STuAAPb#VqQ)Yxv-0$GRa{fm;RlhM3qqt2(<8Xx>fgm zSw*)be#~Xab4T&Vx6AsLnkfjWqiw!y)nJ^)M+USd z?yfcjSyUK<=n>H-y4ZRdE?&&0;m`#G-w;C`Cn9(w%m!80QM-1GVTeM1}colJwpV zR*x;b0KU*h)t_c7bdhEbQY)@X7>bUTaxC1!pFkrW9+vxSt}dQorw^PmID|iE172NC zlrd67=S`)W62fx-GX!HcS=%PBAbW38?6WoNzBFFH1|W9c7WV%Jq?5b3Dvy6v{{U1 z;thS-ar=-^6*z`Q^r!6a#Ln}g#88V|?JA#5GFuOiuf;N6&$yBls1uL7cW1omJk#xR zj%0KdKJ9mgI}S|;Yg844DoHyWkoepk_}!VXe5RR-pYDCFTl2(C)e_P~$Wz*u{c!rz zBK1xeC?P;kPu0jfT(*n~#hlJwzHQw+1AX`Wk7d%ouApL2Pl)lvBvzx2C~(W;b38<* zQsBwFl#e`kw-+gl=6TkfHWWR-5knq{HvxP2c5SOQT09$`cLD4ViBIp)X&bcBQlIT3gfq=XVKsA z4!I74Y`dA-xx&-duh>4>tM{fjy0(0uq@4*I9e>%G6Hd!S#CF?w*x3Yys{zPa9ELwp z41Cqi%mTAjAI6#Z7sh!fQck}`M8S*`KI1i=9{+*Pls2JzGzE3IZ?HidKA@&34Q_rb z!rcNBi|L<_i~8uR;x|jX<$TO>caaVpebHQ5In-GqY>}}>Dktl-@7QN}_)-(Fdjt$v za=*VFPnUhG?#qFo_iB6;f?jJXF7NioGh4B{p}yWOTn~BY+3#Urto2zY?DU5nt%+(o ze&DQQ;4-c{YPF7a!a-5peIwlJTk2mJ9^<13k#YNBNWK@Yn42N^)%+2fhtdr7k_xJ0#d(n z`lElWwEv|c+LwZ=_INvZ4;h#3s&4S0ALLF88VdBMGbZJn#FUCh$hP11DVrrLFd-&P zRcS3}ttwXgHOA=KSa5od#;DQBwz_gN6f(C%wCds|vjC z4wb2R2YrkBck*7TJFu(ezP;D^S!BpzU}B>NtQfYRLbiLS zXP$Ju=d#PAPObwfylK8pjlX51uk3#sAH90{=M!o^UGkgeaq zbQ62zP7Wo0W-89G5#b6JagJ^|J+W?yHI{G|yjNsE+l1vFr=p{+dO%okhP{ITj)n zM3c79m*5AAErsUa>fccUc7Nh1hTFluY_Wph>U#&5EI?cMk<1-v^Dj4nyjC9K2ZPSkXcZf;>#vnxFt$=Hrr8FDq z&)@I_bdkUN@bgFf-HV{YvHJM9)&8RgPYQ8IwXxPOR|Krg+=&mym$QV25N!e&*V}IC zdAU=_EFc7Az%8=AwxT!}5qGl>1Wyx(E&I|I05-W1wvnm#5 z+T5J*349@AC|l_TEXQo_lz#59td7;GgW3ETMHtP?yJa<@pTufUscKSr-2BoZZ&GLS z-Q4Vn>A)y>JTqjs{b!AGx2qx!PFyZwqF4MJ9OGwjkC0 z>p|A5;)BxEaloj!ovY0Bus`g;A841g?PPkdrpI%n$;v$;aG>R(#WFwqM|UHw-YUdPQBVRxKZcWDprG39{)2&MhA5i$-@jji5XA4No{KSg98yw)SaV^T zvAh0a- z;X^Vcjh2mA6NH#-^F4Pq0yMvZSNL8%n%E7eZO%p;^PMT;=Qpp;pk z)kMX(jx#I)n)n->NgL4Qaod!*ymRahOnl?yC3?z0FKD)t4j4|Z!7l0D?C z8cVYLK~!WKH4MJ(cgNDVo^+5RzQx&|oQ?e9LMT5sWpxgTTrh2t4*+{m$g{kPBn{AD zQy)jF2K1Q3AUv=)JW1ex>Q=IZ<%mCWwMm%Ppxr5znikc^GIw~#wD=zjGGuFEMa*h| zCGtDOp{&@r%>X~^%CV)zQbQDLLkNs!W(>pg6$|;I%Z__6ktJ~aUpEP}*CSvS~gM?c*AOCl6-s4fO$EhHg zSWABg9R!$BJ&8JX-W6uPVG#i?;LlBe_;qUgf6;ED|K9^*{y#(&PNw%S6t?}&IsB@e zo0tRAqWTryYqP%tn}2h&PRM^_`??PCtI~#M|7UTw$Omlr)vG`9faD<)qF+w?ZpE=v zwv#7ztpZr&X=Udfx8VhvWd+Nh5m(abDjvC7g!YsC75*x98-lX1@auyjtLyQ!Fbg8!iyDZWk~ufL5V#1JU_SH0q6ZYaK^T?Ee6ZH8u z)p%yZqDnTROSILyU@mi6@2?>cj*E9exM49>L3*&0TB2q+m)k&OMvSJkG@*H|gOdgB zR(jWrS#+Qj4ow|?J8t)=!So$BGASA-agi{2l56ay&DNllferZeO#p^6-2PTp16%F!uO zS?0Vfj&(W-mG0P@8ML2GHX_LuhKv!HImh94BVlE+Y^el2FRd7KyWEmax-ieLJV;r= zdJwPGdJy0S5cB;Wv~ng6kJm1EkIn3CHVD@(zB%N>Nx0hu%2v8V24_^pdMdCs|7~C& z3bt752V6S?iqgy%uswoIPK;hfxk1xE)WjL%ANQ3>4Wcz}T+c@q4M%uZbqjp< z)>`ge7;G#3T+|+WinNaqCI8Aa3A6(`S4PQ!Ab<^-XD5d{F0h(8)ZlGR+3m7iKfrWDOMe7-1SP9U%XJ#_6n|!><_RYezU=M@R?N4z@^CBl1ei2 zBHsvm4J-<7iA~(kkZBJ5`Ouu3U2AJ8jz(Lp{k34)am*~frhqPLfw+V0ChTzvC~0YJ z9~{2Qs0V|?=HKW0B<0sSq?w)B@s5~rvp`Q?n&VJL5HLua&z906fe)9#uR=sTAZPu8{Ypa*SKpN)X=%mf|fgn z%nbjV{7TdqJ)?b7Be(=)((E_jH?z=n4j;mOzm5EJ<7seKY%j7Xlj%T~XAD?ECGbBk zhj-fI&}1d-_Zz3-HbnF{Bsuw_-F0(@J+=Uf%!61=#pBW6F~#Z%1b5H0C*0j-H&c!! z5Ogg{I(v#cmysVzz-#8@TTNG-tCH=U)pcT_f~N`ES$6x|cwUaAI8NK*58RCinI-QJ z!d98f4QEf;a3)kwGo;09q02fSgv&N6_s*Ycc0HEu(xY}NNFMJ~0E}&oe5Ku{7lhP) zbZ~MszDz6)c`NnZu|_3n?<|-!>nRp|sjl$?K!JctdQd_tL7=hC>F~M<$!eQJlOakL zSEjvpL0F(JcH{HA=&Pq?RQjzepbJvDkQXVXTrc|vV5?IWHK!jyGh=%VKcy zP@|@!DG=urFUXsV;O9?8;n888Ph9)^Vrj%PBCov8O&6ZWre(@*axh3c*}RJQwuH18<6LS?29gWV>`$%Cm7oMCs1+n&`8ve5DnRLwDH4gWT_7jk-lQ zIM&Y5N=P6kZz|Tmy}~)AO>MDLNoRq0r$c|qn|v~8?J;z4sWOsORb0Y3ClNGmDS?+| z=@bheUY-m!NLZxajpkQfWlm}#xYVZ12EDWafc=Q-S368c6L=puDm z6q(W;s4uF^ylglqFRFSGW;$4i(E183W^2rE22Nhjz{#~Jf=7jmRTCvS)QJ;%YO)dg7bc|GLrKZCRO88U^iz0eHn4R zBmHVF_$y)>^U4L*gLsL*NiyE&@foI_+fa#vJw~^$otMEOxORu*s7ap}yrr5y@tuYZ zV7KOPA0}miP2F|KdR{pHg?CiW#{VFS$m8E4OQLaB8}I4rU%IR>ik{#;LhbtUZZ1n0 zuJS`N{Mhdaa&&b5TGhZ?A-tPs%-U74OEoE55>%&k1`pHK`b~zjhp;H9lCdOOIvuVn9fy*}; zjl5IS7%0}eeAUaO8OR7?LhgS_y42#-IM^AR4XBK>n zN6a^tbF;q@+8+{Pq3?=qtm%Nz*DoCbfR98Hs13a2t4vp*&w&cP>8}rh%U!{XZVTV# z?o`6RG+tS$TsEGX6=zyua&0sOnq4?85r5^PvUw@d+8ziSF&lq-E2r8l?)x-Ub}z^q z`Z3z#!YkaX5dE8C6Xwfo-i?Ovl7lUn`toB1$7GL5q7H}@PG*$4JS05C@#hdPsZMAf zyZ9RQN?1}S3c<;zBNdn|q~~8VXF536+|^ZMZ)i9Ue=Z-5b81YzqFu+4DMd5%mmX*GRnASA1dQ1}HE z=e488)u~(jS4WpnuPIt3!rse-B6d1C?CDiVMJ2uEk{BkNylt6!FTV%zmTL7lL|n{2 zkQnA@_yEg}3B9)jtnJ$x8{^K2aJ@eV+AwvrYcGLBL^%(xvtkPJvMTgwEkbI*&kERq# z-5qy=Uyz)mB+@^-IXhp|->}}LQFT~oMmVAeZ&T9r<*AKxl^0H?jFjK@v<9dgBJ?o- zs{AT$O7)NH_VG^>Uyme_-itp>F3hbp%YlpEnrSte2VoH&gs0X)SS^3P;dARdVVv?Q z-$CF63*-934$IzM%5bqS3`6SltFQie#Pt?LR1B@;+nTwwd+2b+3^_lgZRT|gbSwL~LU&BKY6w0$N89j`9dNtq-$yo1no@km*q1q^Z>rG$zu?C1l&Qc%)8tLQ%eJj*3;Ws${+CHjA zr5s@V4RNdF2x$+o;8%s9m=fl5U#+Yk;`FV{lbg_{Mry3?b2HLVvkqkm#(+FAGC&h* zC*@j7=_U8P27q^&VhrODv$ITFwL@h@){}dj_I;*Rd}IMCy&O_vldBLEbWO*Uh`U@T z!E9UB*;*j4m*;L&N>cMVkQW{rX)F5NOR|Jc>CANt99NqB;&i4urR?5y#ulCFTfinr;2fg;?)l|rnBqVPv^)?zM`N$q7_Wzb20#YYVhV zf_bIgjcLmGZiMG;cdC-T%@fZvhe&%LCpwU|(A9T2`Q)%}u9T)8R1)m=dtJb6LW3~M zoKU`3Qs7JW&pjHB6Pw!{HTJVZhrG1=`VusjK8Z**{g72PO^x@m9;;8%+V66RTXa>- z)xaXaVBk?32t17UG!Y{+zZ`so%70&of*uq(Z!l<|;Ia(w?DPM-P)dYaO1I6UAzuL? z+rm(hZnnSIWvlg|kj5(uqCOTli{Tm07UD;&v%q3 z60e@veT9RBP7zC8b+F(c#Xp-B+GK~p%+k6&d!av@scd~3a>t~nGx#LcNzy7;MT8m# zi-$pTAx$&ap>w8(QRuZfc6x8vdr6jaQa2*kOAJ^}R@4~HF04-tzjbGbmUR+tMEucv z=0{dSUk2RE-|f-35Hc}FFPFntW+RhVhIAShc?kETtQn+a99Ac|C&{VO@%(qG<*Da)7Nc^izy-FZbSGTbZKDinAWssNRSj!}7i)kG0Q=Y3 znqAoU^BC1>xu%i~@~U35v$n-#F7hIU)J!;{P?w-x>|6}k;4Mt3bz%Q_j3&kqA^Wry zi(frTI>gd_Vly($@BVqlL2AaRA9MgJ*rsn=X!1x0h;*@Z*f-SI{+SqCt=~Vdl%5sM z!s>RM>D3J=-;mhze3JmO@|rs}J$ZIqRS>#im+Ue&7%KITGS9$i@A{gdpMy0r={2O{ zNq71)S+3}X84dAv?MItEjJ-P#&hy9rz5609Gmf;Q+?KuIAfkNmHhWL&kU(3=_idva zwrf4c(H`!+|4%e#oeA^5g#ge$Jm3%5E#xF$oHK6ilkcx&A2_C_jK5q04zQaGdOKIX zuY4Y}JOU&IQGwloKJH(9?kj(yhLi&Nz}X5Y@xEC9JhE<`7Ohm%#8K>5^AS74mcpg2 z^Q$$ArISFDdB9dRx2N8N!`o^6KPn^>cCjZgKy1ln~TK$=}+ZLb$2;N0knHk zqen$gdi^RcOZOF=hmk6%u9>gf#owP3xO(+B)>_Z}wc8=Y=iFehfnk2!(*Y5AH2LVg z1qOme@+&`rorakDJgg-(b59P--C>Um;rHQ0#80O~1bCmBr2!#M75sS8@urv~q|srLdcF6dOuPQQfZuba zU<(-`^29)XZ((!9 z8f)^ZZu_F2Mb4V4vksc~epgLe`LSupc=eFq3M?WbihH#4wtsn_hWmJ6v{I{L&#Dv$ zcYIo4Fz)!rHnmuc%f@orb$+7P4bw)RzPe6HJD$f&+&S~trt69#(<{`S>FAkd@@iZ; z1>Ihvd&pp*ceW=B8c7J^2A;JwBJPg}m5_|Jdvzy@FobmsS63VbNW9a_IbCe+urI;4 zax9Fx<8QSGekaCvlZ zn%n~z3=$>6_#Zk@7h|-Fp4@;gMVE$tq*HsTxIw$T*0otF8+EUyeKNyTOvW?S>vbuv zFC0ZYNK+6Yj*%A>9rE6CP>fsDK*eF~YUH-$35{0 z#2*O5WD|qM;K{NVdb4F8d{IL8Zga3Qju>%cauR!aC~2yNhHb|lvoJc=z@;Ti%v=YPgFR32-tU)Op4Pm=;F+{OX6P^| zFD9LynH+z4mL7|)O(ky21|!uP>^A8(_mznq1PU;Ig;D+M`b5ue_C9w&>t%@Ur3!k{ zPt6>yxgKP|ytf(BHRSU8fO&_@Ih~8H&diC2K91-V@4=K;2U~^?2T4&hbnxcR%{wT$oBnO{Q^eFe{&Dr8u*n)Sz{z zlT@}~%Mxhp<#qHOSayNbW~lY3mZu`>r-m(Jpf?b!M>?&9UM;+f;XJ+T9OO+%yol^Z z7>LYgtD0BK8(52pq%*^XFmQigEqA-?vo|^w0Z_Z%(ipIJ$K?`y4yntS4IiJ?RmiE>YHNw-yi^Lld zx0@VP(BxhB_Wg!yra-Zhf?!9j*vA3nY|$0y~0RXboDS=L#|eK21sb=I~`|8?a}%_mW|Og?BE)#x!WW z7})SWh7=Z@(^+7jbP+t^_fj>%J%oJ9&F(3J?YG;b7|@0LB_GniY5tw5?dwgXDEXrs zpDbP4Iy&_q03z7lh5lqC!vh9caWd*_ez{S6>pvTu=Me~k6iz4uVg?)PVA}ocwExiO`&$zv3d}o- z{lyA2lpp;+srvz>M5W)~9rP%)s~ukC!(8&j15`g#pD#{#l7z<1STUk^&+-T^?^ z;}e!{QUMVe9q#h}Um*wbUz@MJF7or=ltsxP8sU6P{GHqj{W--olSANj*5=UP3M?jQ z@H3lZqZw0C^kmmzm4xASjmO|ftMip*nbt;|sxH^*##L!Ags&?MJ;s(DlM=lR;53x) zI<2(mOnF$$--CP>7_gQk;Bd$d#v$~HU*ed6oJ*wg8Q{wMuz&3=kOdsjwPDulAJYld zAI<_U1mA7>o!VX8wobgwzxnfNx)*E+mSi`?$HQr$eK7rF!StE>}N;*{=P_oLaO?K@-_$sqRL=V@pQli`2PATPe z3RsIi8dCME^_y~JFddR&X>SgBl=p!E-O@iA@qU8u=UOOyhtK#Sxk%D8QsOW8Rd&i( z6iv-L$d9%{^L}n*H6Po?IJbEo!`=uS3H(QY#AvX%^Sp&wr0AIG;5;^hRq3lcR8l7V26jM~vhmYH)&GRLPlP2_I5z*$O{R4!;5swP$w<1%R?x z=fOV>oUUVoIq|wS5tnM(H5AqzV9kJVHU0@hw zJEoVZOcP)kmZ~?^%;P=i22~CXK;_9t`q~d~f+Xv6fDLo=hKUx=?*HgRRrw;#V!?8RtHT?(_rAMfps@RYd1BN&YlbVx z>9S~xK-x#f@BdtH{7&Amo;&^B-6PwZ%0puriodIT|Nk!i`^M)V?k1M+(LT;k?|Kr*X=SrF1sr`NMZTkDD_TO1w84p-J`6~vuP3U{AZ~6Zp_kWeE>jDQY_I=;U z(fF=935x8FG}{_TB6@667GmxpdhtM5)OI=F6G&P_LW?%9{L54umfdwg>2?K|0d zv$-d}Q@)`0#eVaRcXnofcK?&Tt{PR@j59KY2 zx(}@M*6jS<|6AGTlf-Kad5&U`4ZUJ!s^8m}+}XX^zGg%9^J}cPvj5gQd9;Ne-+q>B zhhD`lhFAYRrdGe*|8K+ZcN_TU+)Ga*f;&x zhw^FvWn**~SWfpZQ#}2jQRRF4#Jay8<$G?Q|GQE7`+UWs+jn2Tt6tOp$2&YeV%qeIN*OzZyJt*JiCnpWP&U%UMGP4;uXzYhLoH2B`P=^HS%;#14^PXQi(azhNc44B3p z__p5Z`R&uyUDfQLe*TMf)&_=5hutsz(~n~$iti_Wy`Q;v%XXelJ&S!ci+)?`oZkES z<$vHY6f6Gmt4=*NZH>Lr)Bh5a@A&U~cdC@}%J=5%VBlq+eZT$1f0pff|902=KfCtN zkYNKkWvc%F%dYQ~ukDiuHej~7-m?d9iyq*j8mX4Je7k?CIp}a;AFz|)BLOa`_c z8icl|soY8O0-p3*3_Oqzc#J}M39y=au#?!6hyPXoF7*MOu%NJ_KD*k2&*?xDXleQe q1(2OO9H7P#cN5T}QDLIOgt0+nm+j3pe?aFMGI+ZBxvX + + + ); +} diff --git a/src/uipath/dev/server/frontend/src/components/layout/StatusBar.tsx b/src/uipath/dev/server/frontend/src/components/layout/StatusBar.tsx index 5f34e0f..177ec2c 100644 --- a/src/uipath/dev/server/frontend/src/components/layout/StatusBar.tsx +++ b/src/uipath/dev/server/frontend/src/components/layout/StatusBar.tsx @@ -1,31 +1,57 @@ import { useState, useRef, useEffect } from "react"; import { useAuthStore } from "../../store/useAuthStore"; import { useConfigStore } from "../../store/useConfigStore"; +import { useEvalStore } from "../../store/useEvalStore"; import { useTheme } from "../../store/useTheme"; +import { listLlmModels } from "../../api/eval-client"; export default function StatusBar() { const { theme, toggleTheme } = useTheme(); const { enabled, status, environment, tenants, uipathUrl, setEnvironment, startLogin, selectTenant, logout } = useAuthStore(); const { projectName, projectVersion, projectAuthors } = useConfigStore(); + const llmModels = useEvalStore((s) => s.llmModels); + const setLlmModels = useEvalStore((s) => s.setLlmModels); const [popoverOpen, setPopoverOpen] = useState(false); + const [modelsOpen, setModelsOpen] = useState(false); + const [modelsLoading, setModelsLoading] = useState(false); const [selectedTenant, setSelectedTenant] = useState(""); const popoverRef = useRef(null); const triggerRef = useRef(null); + const modelsPopoverRef = useRef(null); + const modelsTriggerRef = useRef(null); - // Close popover on outside click + // Close popovers on outside click useEffect(() => { - if (!popoverOpen) return; + if (!popoverOpen && !modelsOpen) return; const handleClick = (e: MouseEvent) => { if ( + popoverOpen && popoverRef.current && !popoverRef.current.contains(e.target as Node) && triggerRef.current && !triggerRef.current.contains(e.target as Node) ) { setPopoverOpen(false); } + if ( + modelsOpen && + modelsPopoverRef.current && !modelsPopoverRef.current.contains(e.target as Node) && + modelsTriggerRef.current && !modelsTriggerRef.current.contains(e.target as Node) + ) { + setModelsOpen(false); + } }; document.addEventListener("mousedown", handleClick); return () => document.removeEventListener("mousedown", handleClick); - }, [popoverOpen]); + }, [popoverOpen, modelsOpen]); + + const handleModelsClick = () => { + if (!modelsOpen && llmModels.length === 0) { + setModelsLoading(true); + listLlmModels() + .then(setLlmModels) + .finally(() => setModelsLoading(false)); + } + setModelsOpen((v) => !v); + }; const isAuthenticated = status === "authenticated"; const isExpired = status === "expired"; @@ -198,6 +224,69 @@ export default function StatusBar() { )} + {/* Models */} +
+
+ + + + + + + + + Models{llmModels.length > 0 ? ` (${llmModels.length})` : ""} +
+ {modelsOpen && ( +
+
+ LLM Models +
+
+ {modelsLoading && llmModels.length === 0 && ( +
+ Loading... +
+ )} + {!modelsLoading && llmModels.length === 0 && ( +
+ No models available +
+ )} + {llmModels.map((m) => ( +
+ + {m.model_name} + + {m.vendor && ( + + {m.vendor} + + )} +
+ ))} +
+
+ )} +
+ {/* Project name */} {projectName && ( Project: {projectName} diff --git a/src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js b/src/uipath/dev/server/static/assets/ChatPanel-CvZbTGws.js similarity index 99% rename from src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js rename to src/uipath/dev/server/static/assets/ChatPanel-CvZbTGws.js index b71cc77..5d8e294 100644 --- a/src/uipath/dev/server/static/assets/ChatPanel-CrwXase9.js +++ b/src/uipath/dev/server/static/assets/ChatPanel-CvZbTGws.js @@ -1,4 +1,4 @@ -import{g as Br,j as I,a as pe}from"./vendor-react-VzyiTEsu.js";import{j as ga,H as ha,u as gn}from"./index-CMiQYjGD.js";import"./vendor-reactflow-B_2yZyR4.js";function ba(e,n){const t={};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const ya=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_a=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ea={};function Bt(e,n){return(Ea.jsx?_a:ya).test(e)}const xa=/[ \t\n\f\r]/g;function ka(e){return typeof e=="object"?e.type==="text"?zt(e.value):!1:zt(e)}function zt(e){return e.replace(xa,"")===""}class cn{constructor(n,t,r){this.normal=t,this.property=n,r&&(this.space=r)}}cn.prototype.normal={};cn.prototype.property={};cn.prototype.space=void 0;function zr(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new cn(t,r,n)}function ot(e){return e.toLowerCase()}class le{constructor(n,t){this.attribute=t,this.property=n}}le.prototype.attribute="";le.prototype.booleanish=!1;le.prototype.boolean=!1;le.prototype.commaOrSpaceSeparated=!1;le.prototype.commaSeparated=!1;le.prototype.defined=!1;le.prototype.mustUseProperty=!1;le.prototype.number=!1;le.prototype.overloadedBoolean=!1;le.prototype.property="";le.prototype.spaceSeparated=!1;le.prototype.space=void 0;let wa=0;const U=Le(),te=Le(),st=Le(),v=Le(),Q=Le(),qe=Le(),de=Le();function Le(){return 2**++wa}const lt=Object.freeze(Object.defineProperty({__proto__:null,boolean:U,booleanish:te,commaOrSpaceSeparated:de,commaSeparated:qe,number:v,overloadedBoolean:st,spaceSeparated:Q},Symbol.toStringTag,{value:"Module"})),$n=Object.keys(lt);class yt extends le{constructor(n,t,r,i){let o=-1;if(super(n,t),Ut(this,"space",i),typeof r=="number")for(;++o<$n.length;){const a=$n[o];Ut(this,$n[o],(r<[a])===lt[a])}}}yt.prototype.defined=!0;function Ut(e,n,t){t&&(e[n]=t)}function Ve(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const o=new yt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[ot(r)]=r,t[ot(o.attribute)]=r}return new cn(n,t,e.space)}const Ur=Ve({properties:{ariaActiveDescendant:null,ariaAtomic:te,ariaAutoComplete:null,ariaBusy:te,ariaChecked:te,ariaColCount:v,ariaColIndex:v,ariaColSpan:v,ariaControls:Q,ariaCurrent:null,ariaDescribedBy:Q,ariaDetails:null,ariaDisabled:te,ariaDropEffect:Q,ariaErrorMessage:null,ariaExpanded:te,ariaFlowTo:Q,ariaGrabbed:te,ariaHasPopup:null,ariaHidden:te,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Q,ariaLevel:v,ariaLive:null,ariaModal:te,ariaMultiLine:te,ariaMultiSelectable:te,ariaOrientation:null,ariaOwns:Q,ariaPlaceholder:null,ariaPosInSet:v,ariaPressed:te,ariaReadOnly:te,ariaRelevant:null,ariaRequired:te,ariaRoleDescription:Q,ariaRowCount:v,ariaRowIndex:v,ariaRowSpan:v,ariaSelected:te,ariaSetSize:v,ariaSort:null,ariaValueMax:v,ariaValueMin:v,ariaValueNow:v,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function $r(e,n){return n in e?e[n]:n}function Hr(e,n){return $r(e,n.toLowerCase())}const Sa=Ve({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:Q,accessKey:Q,action:null,allow:null,allowFullScreen:U,allowPaymentRequest:U,allowUserMedia:U,alt:null,as:null,async:U,autoCapitalize:null,autoComplete:Q,autoFocus:U,autoPlay:U,blocking:Q,capture:null,charSet:null,checked:U,cite:null,className:Q,cols:v,colSpan:null,content:null,contentEditable:te,controls:U,controlsList:Q,coords:v|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:U,defer:U,dir:null,dirName:null,disabled:U,download:st,draggable:te,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:U,formTarget:null,headers:Q,height:v,hidden:st,high:v,href:null,hrefLang:null,htmlFor:Q,httpEquiv:Q,id:null,imageSizes:null,imageSrcSet:null,inert:U,inputMode:null,integrity:null,is:null,isMap:U,itemId:null,itemProp:Q,itemRef:Q,itemScope:U,itemType:Q,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:U,low:v,manifest:null,max:null,maxLength:v,media:null,method:null,min:null,minLength:v,multiple:U,muted:U,name:null,nonce:null,noModule:U,noValidate:U,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:U,optimum:v,pattern:null,ping:Q,placeholder:null,playsInline:U,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:U,referrerPolicy:null,rel:Q,required:U,reversed:U,rows:v,rowSpan:v,sandbox:Q,scope:null,scoped:U,seamless:U,selected:U,shadowRootClonable:U,shadowRootDelegatesFocus:U,shadowRootMode:null,shape:null,size:v,sizes:null,slot:null,span:v,spellCheck:te,src:null,srcDoc:null,srcLang:null,srcSet:null,start:v,step:null,style:null,tabIndex:v,target:null,title:null,translate:null,type:null,typeMustMatch:U,useMap:null,value:te,width:v,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Q,axis:null,background:null,bgColor:null,border:v,borderColor:null,bottomMargin:v,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:U,declare:U,event:null,face:null,frame:null,frameBorder:null,hSpace:v,leftMargin:v,link:null,longDesc:null,lowSrc:null,marginHeight:v,marginWidth:v,noResize:U,noHref:U,noShade:U,noWrap:U,object:null,profile:null,prompt:null,rev:null,rightMargin:v,rules:null,scheme:null,scrolling:te,standby:null,summary:null,text:null,topMargin:v,valueType:null,version:null,vAlign:null,vLink:null,vSpace:v,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:U,disableRemotePlayback:U,prefix:null,property:null,results:v,security:null,unselectable:null},space:"html",transform:Hr}),Na=Ve({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:de,accentHeight:v,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:v,amplitude:v,arabicForm:null,ascent:v,attributeName:null,attributeType:null,azimuth:v,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:v,by:null,calcMode:null,capHeight:v,className:Q,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:v,diffuseConstant:v,direction:null,display:null,dur:null,divisor:v,dominantBaseline:null,download:U,dx:null,dy:null,edgeMode:null,editable:null,elevation:v,enableBackground:null,end:null,event:null,exponent:v,externalResourcesRequired:null,fill:null,fillOpacity:v,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:v,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:v,horizOriginX:v,horizOriginY:v,id:null,ideographic:v,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:v,k:v,k1:v,k2:v,k3:v,k4:v,kernelMatrix:de,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:v,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:v,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:v,overlineThickness:v,paintOrder:null,panose1:null,path:null,pathLength:v,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Q,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:v,pointsAtY:v,pointsAtZ:v,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:de,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:de,rev:de,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:de,requiredFeatures:de,requiredFonts:de,requiredFormats:de,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:v,specularExponent:v,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:v,strikethroughThickness:v,string:null,stroke:null,strokeDashArray:de,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:v,strokeOpacity:v,strokeWidth:null,style:null,surfaceScale:v,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:de,tabIndex:v,tableValues:null,target:null,targetX:v,targetY:v,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:de,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:v,underlineThickness:v,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:v,values:null,vAlphabetic:v,vMathematical:v,vectorEffect:null,vHanging:v,vIdeographic:v,version:null,vertAdvY:v,vertOriginX:v,vertOriginY:v,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:v,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$r}),Gr=Ve({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Kr=Ve({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Hr}),qr=Ve({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),va={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ta=/[A-Z]/g,$t=/-[a-z]/g,Aa=/^data[-\w.:]+$/i;function Ca(e,n){const t=ot(n);let r=n,i=le;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&Aa.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace($t,Oa);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!$t.test(o)){let a=o.replace(Ta,Ia);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=yt}return new i(r,n)}function Ia(e){return"-"+e.toLowerCase()}function Oa(e){return e.charAt(1).toUpperCase()}const Ra=zr([Ur,Sa,Gr,Kr,qr],"html"),_t=zr([Ur,Na,Gr,Kr,qr],"svg");function Ma(e){return e.join(" ").trim()}var ze={},Hn,Ht;function Da(){if(Ht)return Hn;Ht=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,t=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` +import{g as Br,j as I,a as pe}from"./vendor-react-VzyiTEsu.js";import{j as ga,H as ha,u as gn}from"./index-DDJ_NWFS.js";import"./vendor-reactflow-B_2yZyR4.js";function ba(e,n){const t={};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const ya=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_a=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ea={};function Bt(e,n){return(Ea.jsx?_a:ya).test(e)}const xa=/[ \t\n\f\r]/g;function ka(e){return typeof e=="object"?e.type==="text"?zt(e.value):!1:zt(e)}function zt(e){return e.replace(xa,"")===""}class cn{constructor(n,t,r){this.normal=t,this.property=n,r&&(this.space=r)}}cn.prototype.normal={};cn.prototype.property={};cn.prototype.space=void 0;function zr(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new cn(t,r,n)}function ot(e){return e.toLowerCase()}class le{constructor(n,t){this.attribute=t,this.property=n}}le.prototype.attribute="";le.prototype.booleanish=!1;le.prototype.boolean=!1;le.prototype.commaOrSpaceSeparated=!1;le.prototype.commaSeparated=!1;le.prototype.defined=!1;le.prototype.mustUseProperty=!1;le.prototype.number=!1;le.prototype.overloadedBoolean=!1;le.prototype.property="";le.prototype.spaceSeparated=!1;le.prototype.space=void 0;let wa=0;const U=Le(),te=Le(),st=Le(),v=Le(),Q=Le(),qe=Le(),de=Le();function Le(){return 2**++wa}const lt=Object.freeze(Object.defineProperty({__proto__:null,boolean:U,booleanish:te,commaOrSpaceSeparated:de,commaSeparated:qe,number:v,overloadedBoolean:st,spaceSeparated:Q},Symbol.toStringTag,{value:"Module"})),$n=Object.keys(lt);class yt extends le{constructor(n,t,r,i){let o=-1;if(super(n,t),Ut(this,"space",i),typeof r=="number")for(;++o<$n.length;){const a=$n[o];Ut(this,$n[o],(r<[a])===lt[a])}}}yt.prototype.defined=!0;function Ut(e,n,t){t&&(e[n]=t)}function Ve(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const o=new yt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[ot(r)]=r,t[ot(o.attribute)]=r}return new cn(n,t,e.space)}const Ur=Ve({properties:{ariaActiveDescendant:null,ariaAtomic:te,ariaAutoComplete:null,ariaBusy:te,ariaChecked:te,ariaColCount:v,ariaColIndex:v,ariaColSpan:v,ariaControls:Q,ariaCurrent:null,ariaDescribedBy:Q,ariaDetails:null,ariaDisabled:te,ariaDropEffect:Q,ariaErrorMessage:null,ariaExpanded:te,ariaFlowTo:Q,ariaGrabbed:te,ariaHasPopup:null,ariaHidden:te,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Q,ariaLevel:v,ariaLive:null,ariaModal:te,ariaMultiLine:te,ariaMultiSelectable:te,ariaOrientation:null,ariaOwns:Q,ariaPlaceholder:null,ariaPosInSet:v,ariaPressed:te,ariaReadOnly:te,ariaRelevant:null,ariaRequired:te,ariaRoleDescription:Q,ariaRowCount:v,ariaRowIndex:v,ariaRowSpan:v,ariaSelected:te,ariaSetSize:v,ariaSort:null,ariaValueMax:v,ariaValueMin:v,ariaValueNow:v,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function $r(e,n){return n in e?e[n]:n}function Hr(e,n){return $r(e,n.toLowerCase())}const Sa=Ve({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:Q,accessKey:Q,action:null,allow:null,allowFullScreen:U,allowPaymentRequest:U,allowUserMedia:U,alt:null,as:null,async:U,autoCapitalize:null,autoComplete:Q,autoFocus:U,autoPlay:U,blocking:Q,capture:null,charSet:null,checked:U,cite:null,className:Q,cols:v,colSpan:null,content:null,contentEditable:te,controls:U,controlsList:Q,coords:v|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:U,defer:U,dir:null,dirName:null,disabled:U,download:st,draggable:te,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:U,formTarget:null,headers:Q,height:v,hidden:st,high:v,href:null,hrefLang:null,htmlFor:Q,httpEquiv:Q,id:null,imageSizes:null,imageSrcSet:null,inert:U,inputMode:null,integrity:null,is:null,isMap:U,itemId:null,itemProp:Q,itemRef:Q,itemScope:U,itemType:Q,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:U,low:v,manifest:null,max:null,maxLength:v,media:null,method:null,min:null,minLength:v,multiple:U,muted:U,name:null,nonce:null,noModule:U,noValidate:U,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:U,optimum:v,pattern:null,ping:Q,placeholder:null,playsInline:U,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:U,referrerPolicy:null,rel:Q,required:U,reversed:U,rows:v,rowSpan:v,sandbox:Q,scope:null,scoped:U,seamless:U,selected:U,shadowRootClonable:U,shadowRootDelegatesFocus:U,shadowRootMode:null,shape:null,size:v,sizes:null,slot:null,span:v,spellCheck:te,src:null,srcDoc:null,srcLang:null,srcSet:null,start:v,step:null,style:null,tabIndex:v,target:null,title:null,translate:null,type:null,typeMustMatch:U,useMap:null,value:te,width:v,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Q,axis:null,background:null,bgColor:null,border:v,borderColor:null,bottomMargin:v,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:U,declare:U,event:null,face:null,frame:null,frameBorder:null,hSpace:v,leftMargin:v,link:null,longDesc:null,lowSrc:null,marginHeight:v,marginWidth:v,noResize:U,noHref:U,noShade:U,noWrap:U,object:null,profile:null,prompt:null,rev:null,rightMargin:v,rules:null,scheme:null,scrolling:te,standby:null,summary:null,text:null,topMargin:v,valueType:null,version:null,vAlign:null,vLink:null,vSpace:v,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:U,disableRemotePlayback:U,prefix:null,property:null,results:v,security:null,unselectable:null},space:"html",transform:Hr}),Na=Ve({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:de,accentHeight:v,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:v,amplitude:v,arabicForm:null,ascent:v,attributeName:null,attributeType:null,azimuth:v,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:v,by:null,calcMode:null,capHeight:v,className:Q,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:v,diffuseConstant:v,direction:null,display:null,dur:null,divisor:v,dominantBaseline:null,download:U,dx:null,dy:null,edgeMode:null,editable:null,elevation:v,enableBackground:null,end:null,event:null,exponent:v,externalResourcesRequired:null,fill:null,fillOpacity:v,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:v,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:v,horizOriginX:v,horizOriginY:v,id:null,ideographic:v,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:v,k:v,k1:v,k2:v,k3:v,k4:v,kernelMatrix:de,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:v,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:v,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:v,overlineThickness:v,paintOrder:null,panose1:null,path:null,pathLength:v,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Q,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:v,pointsAtY:v,pointsAtZ:v,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:de,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:de,rev:de,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:de,requiredFeatures:de,requiredFonts:de,requiredFormats:de,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:v,specularExponent:v,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:v,strikethroughThickness:v,string:null,stroke:null,strokeDashArray:de,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:v,strokeOpacity:v,strokeWidth:null,style:null,surfaceScale:v,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:de,tabIndex:v,tableValues:null,target:null,targetX:v,targetY:v,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:de,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:v,underlineThickness:v,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:v,values:null,vAlphabetic:v,vMathematical:v,vectorEffect:null,vHanging:v,vIdeographic:v,version:null,vertAdvY:v,vertOriginX:v,vertOriginY:v,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:v,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$r}),Gr=Ve({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Kr=Ve({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Hr}),qr=Ve({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),va={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ta=/[A-Z]/g,$t=/-[a-z]/g,Aa=/^data[-\w.:]+$/i;function Ca(e,n){const t=ot(n);let r=n,i=le;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&Aa.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace($t,Oa);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!$t.test(o)){let a=o.replace(Ta,Ia);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=yt}return new i(r,n)}function Ia(e){return"-"+e.toLowerCase()}function Oa(e){return e.charAt(1).toUpperCase()}const Ra=zr([Ur,Sa,Gr,Kr,qr],"html"),_t=zr([Ur,Na,Gr,Kr,qr],"svg");function Ma(e){return e.join(" ").trim()}var ze={},Hn,Ht;function Da(){if(Ht)return Hn;Ht=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,t=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` `,c="/",u="*",d="",f="comment",p="declaration";function m(E,g){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];g=g||{};var x=1,k=1;function N(M){var A=M.match(n);A&&(x+=A.length);var z=M.lastIndexOf(l);k=~z?M.length-z:k+M.length}function T(){var M={line:x,column:k};return function(A){return A.position=new _(M),P(),A}}function _(M){this.start=M,this.end={line:x,column:k},this.source=g.source}_.prototype.content=E;function D(M){var A=new Error(g.source+":"+x+":"+k+": "+M);if(A.reason=M,A.filename=g.source,A.line=x,A.column=k,A.source=E,!g.silent)throw A}function L(M){var A=M.exec(E);if(A){var z=A[0];return N(z),E=E.slice(z.length),A}}function P(){L(t)}function w(M){var A;for(M=M||[];A=O();)A!==!1&&M.push(A);return M}function O(){var M=T();if(!(c!=E.charAt(0)||u!=E.charAt(1))){for(var A=2;d!=E.charAt(A)&&(u!=E.charAt(A)||c!=E.charAt(A+1));)++A;if(A+=2,d===E.charAt(A-1))return D("End of comment missing");var z=E.slice(2,A-2);return k+=2,N(z),E=E.slice(A),k+=2,M({type:f,comment:z})}}function R(){var M=T(),A=L(r);if(A){if(O(),!L(i))return D("property missing ':'");var z=L(o),Y=M({type:p,property:y(A[0].replace(e,d)),value:z?y(z[0].replace(e,d)):d});return L(a),Y}}function $(){var M=[];w(M);for(var A;A=R();)A!==!1&&(M.push(A),w(M));return M}return P(),$()}function y(E){return E?E.replace(s,d):d}return Hn=m,Hn}var Gt;function La(){if(Gt)return ze;Gt=1;var e=ze&&ze.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ze,"__esModule",{value:!0}),ze.default=t;const n=e(Da());function t(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,n.default)(r),s=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;s?i(c,u,l):u&&(o=o||{},o[c]=u)}),o}return ze}var je={},Kt;function Pa(){if(Kt)return je;Kt=1,Object.defineProperty(je,"__esModule",{value:!0}),je.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,t=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(c){return!c||t.test(c)||e.test(c)},a=function(c,u){return u.toUpperCase()},s=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),o(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,s):c=c.replace(r,s),c.replace(n,a))};return je.camelCase=l,je}var Qe,qt;function Fa(){if(qt)return Qe;qt=1;var e=Qe&&Qe.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},n=e(La()),t=Pa();function r(i,o){var a={};return!i||typeof i!="string"||(0,n.default)(i,function(s,l){s&&l&&(a[(0,t.camelCase)(s,o)]=l)}),a}return r.default=r,Qe=r,Qe}var Ba=Fa();const za=Br(Ba),Wr=Vr("end"),Et=Vr("start");function Vr(e){return n;function n(t){const r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ua(e){const n=Et(e),t=Wr(e);if(n&&t)return{start:n,end:t}}function rn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Wt(e.position):"start"in e||"end"in e?Wt(e):"line"in e||"column"in e?ct(e):""}function ct(e){return Vt(e&&e.line)+":"+Vt(e&&e.column)}function Wt(e){return ct(e&&e.start)+"-"+ct(e&&e.end)}function Vt(e){return e&&typeof e=="number"?e:1}class ie extends Error{constructor(n,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof n=="string"?i=n:!o.cause&&n&&(a=!0,i=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=rn(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ie.prototype.file="";ie.prototype.name="";ie.prototype.reason="";ie.prototype.message="";ie.prototype.stack="";ie.prototype.column=void 0;ie.prototype.line=void 0;ie.prototype.ancestors=void 0;ie.prototype.cause=void 0;ie.prototype.fatal=void 0;ie.prototype.place=void 0;ie.prototype.ruleId=void 0;ie.prototype.source=void 0;const xt={}.hasOwnProperty,$a=new Map,Ha=/[A-Z]/g,Ga=new Set(["table","tbody","thead","tfoot","tr"]),Ka=new Set(["td","th"]),Yr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qa(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=n.filePath||void 0;let r;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Ja(t,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Qa(t,n.jsx,n.jsxs)}const i={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:r,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?_t:Ra,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=Zr(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function Zr(e,n,t){if(n.type==="element")return Wa(e,n,t);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Va(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Za(e,n,t);if(n.type==="mdxjsEsm")return Ya(e,n);if(n.type==="root")return Xa(e,n,t);if(n.type==="text")return ja(e,n)}function Wa(e,n,t){const r=e.schema;let i=r;n.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=_t,e.schema=i),e.ancestors.push(n);const o=jr(e,n.tagName,!1),a=eo(e,n);let s=wt(e,n);return Ga.has(n.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!ka(l):!0})),Xr(e,a,o,n),kt(a,s),e.ancestors.pop(),e.schema=r,e.create(n,o,a,t)}function Va(e,n){if(n.data&&n.data.estree&&e.evaluater){const r=n.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}sn(e,n.position)}function Ya(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);sn(e,n.position)}function Za(e,n,t){const r=e.schema;let i=r;n.name==="svg"&&r.space==="html"&&(i=_t,e.schema=i),e.ancestors.push(n);const o=n.name===null?e.Fragment:jr(e,n.name,!0),a=no(e,n),s=wt(e,n);return Xr(e,a,o,n),kt(a,s),e.ancestors.pop(),e.schema=r,e.create(n,o,a,t)}function Xa(e,n,t){const r={};return kt(r,wt(e,n)),e.create(n,e.Fragment,r,t)}function ja(e,n){return n.value}function Xr(e,n,t,r){typeof t!="string"&&t!==e.Fragment&&e.passNode&&(n.node=r)}function kt(e,n){if(n.length>0){const t=n.length>1?n:n[0];t&&(e.children=t)}}function Qa(e,n,t){return r;function r(i,o,a,s){const c=Array.isArray(a.children)?t:n;return s?c(o,a,s):c(o,a)}}function Ja(e,n){return t;function t(r,i,o,a){const s=Array.isArray(o.children),l=Et(r);return n(i,o,a,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function eo(e,n){const t={};let r,i;for(i in n.properties)if(i!=="children"&&xt.call(n.properties,i)){const o=to(e,i,n.properties[i]);if(o){const[a,s]=o;e.tableCellAlignToStyle&&a==="align"&&typeof s=="string"&&Ka.has(n.tagName)?r=s:t[a]=s}}if(r){const o=t.style||(t.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return t}function no(e,n){const t={};for(const r of n.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const s=a.properties[0];s.type,Object.assign(t,e.evaluater.evaluateExpression(s.argument))}else sn(e,n.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,o=e.evaluater.evaluateExpression(s.expression)}else sn(e,n.position);else o=r.value===null?!0:r.value;t[i]=o}return t}function wt(e,n){const t=[];let r=-1;const i=e.passKeys?new Map:$a;for(;++ri?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)a=Array.from(r),a.unshift(n,t),e.splice(...a);else for(t&&e.splice(n,t);o0?(fe(e,e.length,0,n),e):n}const Xt={}.hasOwnProperty;function Jr(e){const n={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function be(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oe=Ae(/[A-Za-z]/),re=Ae(/[\dA-Za-z]/),po=Ae(/[#-'*+\--9=?A-Z^-~]/);function Tn(e){return e!==null&&(e<32||e===127)}const ut=Ae(/\d/),fo=Ae(/[\dA-Fa-f]/),mo=Ae(/[!-/:-@[-`{-~]/);function F(e){return e!==null&&e<-2}function X(e){return e!==null&&(e<0||e===32)}function G(e){return e===-2||e===-1||e===32}const Mn=Ae(new RegExp("\\p{P}|\\p{S}","u")),De=Ae(/\s/);function Ae(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ye(e){const n=[];let t=-1,r=0,i=0;for(;++t55295&&o<57344){const s=e.charCodeAt(t+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a="�"}else a=String.fromCharCode(o);a&&(n.push(e.slice(r,t),encodeURIComponent(a)),r=t+i+1,a=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function q(e,n,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(l){return G(l)?(e.enter(t),s(l)):n(l)}function s(l){return G(l)&&o++a))return;const D=n.events.length;let L=D,P,w;for(;L--;)if(n.events[L][0]==="exit"&&n.events[L][1].type==="chunkFlow"){if(P){w=n.events[L][1].end;break}P=!0}for(g(r),_=D;_k;){const T=t[N];n.containerState=T[1],T[0].exit.call(n,e)}t.length=k}function x(){i.write([null]),o=void 0,i=void 0,n.containerState._closeFlow=void 0}}function _o(e,n,t){return q(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function We(e){if(e===null||X(e)||De(e))return 1;if(Mn(e))return 2}function Dn(e,n,t){const r=[];let i=-1;for(;++i1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[t][1].start};Qt(d,-l),Qt(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[t][1].start},end:f},o={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[t][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[t][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=me(c,[["enter",e[r][1],n],["exit",e[r][1],n]])),c=me(c,[["enter",i,n],["enter",a,n],["exit",a,n],["enter",o,n]]),c=me(c,Dn(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),c=me(c,[["exit",o,n],["enter",s,n],["exit",s,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(u=2,c=me(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):u=0,fe(e,r-1,t-r+3,c),t=r+c.length-u-2;break}}for(t=-1;++t0&&G(_)?q(e,x,"linePrefix",o+1)(_):x(_)}function x(_){return _===null||F(_)?e.check(Jt,y,N)(_):(e.enter("codeFlowValue"),k(_))}function k(_){return _===null||F(_)?(e.exit("codeFlowValue"),x(_)):(e.consume(_),k)}function N(_){return e.exit("codeFenced"),n(_)}function T(_,D,L){let P=0;return w;function w(A){return _.enter("lineEnding"),_.consume(A),_.exit("lineEnding"),O}function O(A){return _.enter("codeFencedFence"),G(A)?q(_,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):R(A)}function R(A){return A===s?(_.enter("codeFencedFenceSequence"),$(A)):L(A)}function $(A){return A===s?(P++,_.consume(A),$):P>=a?(_.exit("codeFencedFenceSequence"),G(A)?q(_,M,"whitespace")(A):M(A)):L(A)}function M(A){return A===null||F(A)?(_.exit("codeFencedFence"),D(A)):L(A)}}}function Oo(e,n,t){const r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}const Kn={name:"codeIndented",tokenize:Mo},Ro={partial:!0,tokenize:Do};function Mo(e,n,t){const r=this;return i;function i(c){return e.enter("codeIndented"),q(e,o,"linePrefix",5)(c)}function o(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?a(c):t(c)}function a(c){return c===null?l(c):F(c)?e.attempt(Ro,a,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||F(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),n(c)}}function Do(e,n,t){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?t(a):F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):q(e,o,"linePrefix",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):F(a)?i(a):t(a)}}const Lo={name:"codeText",previous:Fo,resolve:Po,tokenize:Bo};function Po(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return nthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(n,t,r){const i=t||0;this.setCursor(Math.trunc(n));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Je(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Je(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Je(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n=4?n(a):e.interrupt(r.parser.constructs.flow,t,n)(a)}}function ai(e,n,t,r,i,o,a,s,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(g){return g===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(g),e.exit(o),f):g===null||g===32||g===41||Tn(g)?t(g):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),y(g))}function f(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(i),e.exit(r),n):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===62?(e.exit("chunkString"),e.exit(s),f(g)):g===null||g===60||F(g)?t(g):(e.consume(g),g===92?m:p)}function m(g){return g===60||g===62||g===92?(e.consume(g),p):p(g)}function y(g){return!u&&(g===null||g===41||X(g))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),n(g)):u999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?t(p):p===93?(e.exit(o),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):F(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||F(p)||s++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!G(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),s++,d):d(p)}}function si(e,n,t,r,i,o){let a;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),a=f===40?41:f,l):t(f)}function l(f){return f===a?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),n):(e.enter(o),c(f))}function c(f){return f===a?(e.exit(o),l(a)):f===null?t(f):F(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),q(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===a||f===null||F(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===a||f===92?(e.consume(f),u):u(f)}}function an(e,n){let t;return r;function r(i){return F(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):G(i)?q(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}const Wo={name:"definition",tokenize:Yo},Vo={partial:!0,tokenize:Zo};function Yo(e,n,t){const r=this;let i;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return oi.call(r,e,s,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=be(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):t(p)}function l(p){return X(p)?an(e,c)(p):c(p)}function c(p){return ai(e,u,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(Vo,d,d)(p)}function d(p){return G(p)?q(e,f,"whitespace")(p):f(p)}function f(p){return p===null||F(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function Zo(e,n,t){return r;function r(s){return X(s)?an(e,i)(s):t(s)}function i(s){return si(e,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function o(s){return G(s)?q(e,a,"whitespace")(s):a(s)}function a(s){return s===null||F(s)?n(s):t(s)}}const Xo={name:"hardBreakEscape",tokenize:jo};function jo(e,n,t){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return F(o)?(e.exit("hardBreakEscape"),n(o)):t(o)}}const Qo={name:"headingAtx",resolve:Jo,tokenize:es};function Jo(e,n){let t=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},o={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},fe(e,r,t-r+1,[["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n]])),e}function es(e,n,t){let r=0;return i;function i(u){return e.enter("atxHeading"),o(u)}function o(u){return e.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&r++<6?(e.consume(u),a):u===null||X(u)?(e.exit("atxHeadingSequence"),s(u)):t(u)}function s(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||F(u)?(e.exit("atxHeading"),n(u)):G(u)?q(e,s,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||X(u)?(e.exit("atxHeadingText"),s(u)):(e.consume(u),c)}}const ns=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],nr=["pre","script","style","textarea"],ts={concrete:!0,name:"htmlFlow",resolveTo:as,tokenize:os},rs={partial:!0,tokenize:ls},is={partial:!0,tokenize:ss};function as(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function os(e,n,t){const r=this;let i,o,a,s,l;return c;function c(b){return u(b)}function u(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),d}function d(b){return b===33?(e.consume(b),f):b===47?(e.consume(b),o=!0,y):b===63?(e.consume(b),i=3,r.interrupt?n:h):oe(b)?(e.consume(b),a=String.fromCharCode(b),E):t(b)}function f(b){return b===45?(e.consume(b),i=2,p):b===91?(e.consume(b),i=5,s=0,m):oe(b)?(e.consume(b),i=4,r.interrupt?n:h):t(b)}function p(b){return b===45?(e.consume(b),r.interrupt?n:h):t(b)}function m(b){const ce="CDATA[";return b===ce.charCodeAt(s++)?(e.consume(b),s===ce.length?r.interrupt?n:R:m):t(b)}function y(b){return oe(b)?(e.consume(b),a=String.fromCharCode(b),E):t(b)}function E(b){if(b===null||b===47||b===62||X(b)){const ce=b===47,ye=a.toLowerCase();return!ce&&!o&&nr.includes(ye)?(i=1,r.interrupt?n(b):R(b)):ns.includes(a.toLowerCase())?(i=6,ce?(e.consume(b),g):r.interrupt?n(b):R(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(b):o?x(b):k(b))}return b===45||re(b)?(e.consume(b),a+=String.fromCharCode(b),E):t(b)}function g(b){return b===62?(e.consume(b),r.interrupt?n:R):t(b)}function x(b){return G(b)?(e.consume(b),x):w(b)}function k(b){return b===47?(e.consume(b),w):b===58||b===95||oe(b)?(e.consume(b),N):G(b)?(e.consume(b),k):w(b)}function N(b){return b===45||b===46||b===58||b===95||re(b)?(e.consume(b),N):T(b)}function T(b){return b===61?(e.consume(b),_):G(b)?(e.consume(b),T):k(b)}function _(b){return b===null||b===60||b===61||b===62||b===96?t(b):b===34||b===39?(e.consume(b),l=b,D):G(b)?(e.consume(b),_):L(b)}function D(b){return b===l?(e.consume(b),l=null,P):b===null||F(b)?t(b):(e.consume(b),D)}function L(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||X(b)?T(b):(e.consume(b),L)}function P(b){return b===47||b===62||G(b)?k(b):t(b)}function w(b){return b===62?(e.consume(b),O):t(b)}function O(b){return b===null||F(b)?R(b):G(b)?(e.consume(b),O):t(b)}function R(b){return b===45&&i===2?(e.consume(b),z):b===60&&i===1?(e.consume(b),Y):b===62&&i===4?(e.consume(b),j):b===63&&i===3?(e.consume(b),h):b===93&&i===5?(e.consume(b),J):F(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(rs,ee,$)(b)):b===null||F(b)?(e.exit("htmlFlowData"),$(b)):(e.consume(b),R)}function $(b){return e.check(is,M,ee)(b)}function M(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),A}function A(b){return b===null||F(b)?$(b):(e.enter("htmlFlowData"),R(b))}function z(b){return b===45?(e.consume(b),h):R(b)}function Y(b){return b===47?(e.consume(b),a="",H):R(b)}function H(b){if(b===62){const ce=a.toLowerCase();return nr.includes(ce)?(e.consume(b),j):R(b)}return oe(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),H):R(b)}function J(b){return b===93?(e.consume(b),h):R(b)}function h(b){return b===62?(e.consume(b),j):b===45&&i===2?(e.consume(b),h):R(b)}function j(b){return b===null||F(b)?(e.exit("htmlFlowData"),ee(b)):(e.consume(b),j)}function ee(b){return e.exit("htmlFlow"),n(b)}}function ss(e,n,t){const r=this;return i;function i(a){return F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):t(a)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}function ls(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(un,n,t)}}const cs={name:"htmlText",tokenize:us};function us(e,n,t){const r=this;let i,o,a;return s;function s(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),l}function l(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),T):h===63?(e.consume(h),k):oe(h)?(e.consume(h),L):t(h)}function c(h){return h===45?(e.consume(h),u):h===91?(e.consume(h),o=0,m):oe(h)?(e.consume(h),x):t(h)}function u(h){return h===45?(e.consume(h),p):t(h)}function d(h){return h===null?t(h):h===45?(e.consume(h),f):F(h)?(a=d,Y(h)):(e.consume(h),d)}function f(h){return h===45?(e.consume(h),p):d(h)}function p(h){return h===62?z(h):h===45?f(h):d(h)}function m(h){const j="CDATA[";return h===j.charCodeAt(o++)?(e.consume(h),o===j.length?y:m):t(h)}function y(h){return h===null?t(h):h===93?(e.consume(h),E):F(h)?(a=y,Y(h)):(e.consume(h),y)}function E(h){return h===93?(e.consume(h),g):y(h)}function g(h){return h===62?z(h):h===93?(e.consume(h),g):y(h)}function x(h){return h===null||h===62?z(h):F(h)?(a=x,Y(h)):(e.consume(h),x)}function k(h){return h===null?t(h):h===63?(e.consume(h),N):F(h)?(a=k,Y(h)):(e.consume(h),k)}function N(h){return h===62?z(h):k(h)}function T(h){return oe(h)?(e.consume(h),_):t(h)}function _(h){return h===45||re(h)?(e.consume(h),_):D(h)}function D(h){return F(h)?(a=D,Y(h)):G(h)?(e.consume(h),D):z(h)}function L(h){return h===45||re(h)?(e.consume(h),L):h===47||h===62||X(h)?P(h):t(h)}function P(h){return h===47?(e.consume(h),z):h===58||h===95||oe(h)?(e.consume(h),w):F(h)?(a=P,Y(h)):G(h)?(e.consume(h),P):z(h)}function w(h){return h===45||h===46||h===58||h===95||re(h)?(e.consume(h),w):O(h)}function O(h){return h===61?(e.consume(h),R):F(h)?(a=O,Y(h)):G(h)?(e.consume(h),O):P(h)}function R(h){return h===null||h===60||h===61||h===62||h===96?t(h):h===34||h===39?(e.consume(h),i=h,$):F(h)?(a=R,Y(h)):G(h)?(e.consume(h),R):(e.consume(h),M)}function $(h){return h===i?(e.consume(h),i=void 0,A):h===null?t(h):F(h)?(a=$,Y(h)):(e.consume(h),$)}function M(h){return h===null||h===34||h===39||h===60||h===61||h===96?t(h):h===47||h===62||X(h)?P(h):(e.consume(h),M)}function A(h){return h===47||h===62||X(h)?P(h):t(h)}function z(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),n):t(h)}function Y(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),H}function H(h){return G(h)?q(e,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):J(h)}function J(h){return e.enter("htmlTextData"),a(h)}}const vt={name:"labelEnd",resolveAll:ms,resolveTo:gs,tokenize:hs},ds={tokenize:bs},ps={tokenize:ys},fs={tokenize:_s};function ms(e){let n=-1;const t=[];for(;++n=3&&(c===null||F(c))?(e.exit("thematicBreak"),n(c)):t(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),G(c)?q(e,s,"whitespace")(c):s(c))}}const se={continuation:{tokenize:Cs},exit:Os,name:"list",tokenize:As},vs={partial:!0,tokenize:Rs},Ts={partial:!0,tokenize:Is};function As(e,n,t){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ut(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(vn,t,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return t(p)}function l(p){return ut(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):t(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(un,r.interrupt?t:u,e.attempt(vs,f,d))}function u(p){return r.containerState.initialBlankLine=!0,o++,f(p)}function d(p){return G(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):t(p)}function f(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function Cs(e,n,t){const r=this;return r.containerState._closeFlow=void 0,e.check(un,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,q(e,n,"listItemIndent",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!G(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ts,n,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,q(e,e.attempt(se,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Is(e,n,t){const r=this;return q(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?n(o):t(o)}}function Os(e){e.exit(this.containerState.type)}function Rs(e,n,t){const r=this;return q(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!G(o)&&a&&a[1].type==="listItemPrefixWhitespace"?n(o):t(o)}}const tr={name:"setextUnderline",resolveTo:Ms,tokenize:Ds};function Ms(e,n){let t=e.length,r,i,o;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!o&&e[t][1].type==="definition"&&(o=t);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,n]),e.splice(o+1,0,["exit",e[r][1],n]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,n]),e}function Ds(e,n,t){const r=this;let i;return o;function o(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,a(c)):t(c)}function a(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===i?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),G(c)?q(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||F(c)?(e.exit("setextHeadingLine"),n(c)):t(c)}}const Ls={tokenize:Ps};function Ps(e){const n=this,t=e.attempt(un,r,e.attempt(this.parser.constructs.flowInitial,i,q(e,e.attempt(this.parser.constructs.flow,i,e.attempt($o,i)),"linePrefix")));return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,t}}const Fs={resolveAll:ci()},Bs=li("string"),zs=li("text");function li(e){return{resolveAll:ci(e==="text"?Us:void 0),tokenize:n};function n(t){const r=this,i=this.parser.constructs[e],o=t.attempt(i,a,s);return a;function a(u){return c(u)?o(u):s(u)}function s(u){if(u===null){t.consume(u);return}return t.enter("data"),t.consume(u),l}function l(u){return c(u)?(t.exit("data"),o(u)):(t.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f-1){const s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Js(e,n){let t=-1;const r=[];let i;for(;++t0){const he=B.tokenStack[B.tokenStack.length-1];(he[1]||ir).call(B,void 0,he[0])}for(C.position={start:Te(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Te(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},Z=-1;++Zdiv{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-duration:initial;--tw-ease:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--container-xs:20rem;--container-xl:36rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-normal:0em;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-normal:1.5;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-y-0{inset-block:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-1{top:calc(var(--spacing) * 1)}.top-1\.5{top:calc(var(--spacing) * 1.5)}.top-2{top:calc(var(--spacing) * 2)}.top-4{top:calc(var(--spacing) * 4)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-1{right:calc(var(--spacing) * 1)}.right-3{right:calc(var(--spacing) * 3)}.right-4{right:calc(var(--spacing) * 4)}.bottom-1\.5{bottom:calc(var(--spacing) * 1.5)}.bottom-8{bottom:calc(var(--spacing) * 8)}.bottom-full{bottom:100%}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.mx-1{margin-inline:calc(var(--spacing) * 1)}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-2{margin-block:calc(var(--spacing) * 2)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-auto{margin-top:auto}.mr-0\.5{margin-right:calc(var(--spacing) * .5)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-32{height:calc(var(--spacing) * 32)}.h-\[14px\]{height:14px}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:calc(var(--spacing) * 32)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-\[85vh\]{max-height:85vh}.max-h-\[320px\]{max-height:320px}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-full{min-height:100%}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-24{width:calc(var(--spacing) * 24)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-\[200px\]{width:200px}.w-\[calc\(100\%-24px\)\]{width:calc(100% - 24px)}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[300px\]{max-width:300px}.max-w-prose{max-width:65ch}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[140px\]{min-width:140px}.min-w-\[180px\]{min-width:180px}.min-w-\[220px\]{min-width:220px}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-\[slideIn_0\.2s_ease-out\]{animation:.2s ease-out slideIn}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.appearance-auto{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing) * 0)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-\[var\(--border\)\]{border-color:var(--border)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--sidebar-bg\)\]{background-color:var(--sidebar-bg)}.bg-transparent{background-color:#0000}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-\[3px\]{padding-block:3px}.py-\[5px\]{padding-block:5px}.pt-0{padding-top:calc(var(--spacing) * 0)}.pt-1{padding-top:calc(var(--spacing) * 1)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-px{padding-top:1px}.pr-0{padding-right:calc(var(--spacing) * 0)}.pr-1{padding-right:calc(var(--spacing) * 1)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-\[22px\]{padding-left:22px}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.leading-none{--tw-leading:1;line-height:1}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-normal{--tw-tracking:var(--tracking-normal);letter-spacing:var(--tracking-normal)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--text-muted\)\]{color:var(--text-muted)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.no-underline{text-decoration-line:none}.underline{text-decoration-line:underline}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-0{opacity:0}.opacity-40{opacity:.4}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-80{opacity:.8}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}@media(hover:hover){.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\:text-\[var\(--text-muted\)\]::placeholder{color:var(--text-muted)}@media(hover:hover){.hover\:bg-\[var\(--bg-hover\)\]:hover{background-color:var(--bg-hover)}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-100:hover{opacity:1}.hover\:brightness-125:hover{--tw-brightness:brightness(125%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}}.focus\:opacity-100:focus{opacity:1}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}pre code.hljs{padding:1em;display:block;overflow-x:auto}code.hljs{padding:3px 5px}.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-variable,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id{color:#79c0ff}.hljs-regexp,.hljs-string,.hljs-meta .hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-comment,.hljs-code,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-tag,.hljs-selector-pseudo{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}:root,[data-theme=dark]{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--bg-hover:#263348;--bg-elevated:#253041;--text-primary:#cbd5e1;--text-secondary:#94a3b8;--text-muted:#64748b;--border:#334155;--accent:#fa4616;--accent-hover:#e03d12;--accent-light:#ff6a3d;--success:#22c55e;--warning:#eab308;--error:#ef4444;--info:#3b82f6;--sidebar-bg:#0e1526;--activity-bar-bg:#0a1020;--card-bg:#1e293b;--input-bg:#0f172a;--code-bg:#0f172a;--tab-active:#fa4616;--tab-text:#94a3b8;--tab-text-active:#fa4616;--node-bg:#1e293b;--node-border:#475569;--scrollbar-thumb:#334155;color-scheme:dark}[data-theme=light]{--bg-primary:#f8fafc;--bg-secondary:#fff;--bg-tertiary:#cbd5e1;--bg-hover:#f1f5f9;--bg-elevated:#fff;--text-primary:#0f172a;--text-secondary:#475569;--text-muted:#94a3b8;--border:#e2e8f0;--accent:#fa4616;--accent-hover:#e03d12;--accent-light:#ff6a3d;--success:#22c55e;--warning:#ca8a04;--error:#ef4444;--info:#2563eb;--sidebar-bg:#fff;--activity-bar-bg:#f1f5f9;--card-bg:#fff;--input-bg:#f8fafc;--code-bg:#e8ecf1;--tab-active:#fa4616;--tab-text:#64748b;--tab-text-active:#fa4616;--node-bg:#fff;--node-border:#cbd5e1;--scrollbar-thumb:#d1d5db;color-scheme:light}body{background:var(--bg-primary);color:var(--text-primary);margin:0;font-family:Inter,system-ui,-apple-system,sans-serif;transition:background-color .2s,color .2s}#root{height:100dvh;display:flex}:focus-visible{outline:2px solid var(--accent);outline-offset:1px}button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--accent)}@supports (color:color-mix(in lab,red,red)){button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 60%,transparent)}}button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline-offset:0px;border-radius:3px}.drag-handle-row{cursor:row-resize;background:var(--border);height:3px;transition:background .15s;position:relative}.drag-handle-row:before{content:"";position:absolute;top:-5px;right:0;bottom:-5px;left:0}.drag-handle-row:hover,.drag-handle-row:active{background:var(--accent)}.drag-handle-col{cursor:col-resize;background:var(--border);width:3px;transition:background .15s;position:relative}.drag-handle-col:before{content:"";position:absolute;top:0;right:-5px;bottom:0;left:-5px}.drag-handle-col:hover,.drag-handle-col:active{background:var(--accent)}@keyframes skeleton-pulse{0%,to{opacity:.4}50%{opacity:.7}}.skeleton{background:var(--bg-tertiary);border-radius:4px;animation:1.5s ease-in-out infinite skeleton-pulse}.react-flow__node{font-size:12px}.react-flow__node-default{background:var(--node-bg)!important;color:var(--text-primary)!important;border-color:var(--node-border)!important}.react-flow__background{background:var(--bg-primary)!important}.react-flow__controls button{background:var(--bg-secondary)!important;color:var(--text-primary)!important;border-color:var(--border)!important}.react-flow__controls button:hover{background:var(--bg-hover)!important}.react-flow__controls button svg{fill:var(--text-primary)!important}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb);border-radius:3px}select{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}select option{background:var(--bg-secondary);color:var(--text-primary)}.chat-markdown p{margin:.25em 0}.chat-markdown p:first-child{margin-top:0}.chat-markdown p:last-child{margin-bottom:0}.chat-markdown code{background:var(--code-bg);border:1px solid var(--border);border-radius:3px;padding:.1em .35em;font-size:.85em}.chat-markdown pre{background:var(--code-bg);border:1px solid var(--border);border-radius:6px;margin:.5em 0;padding:.75em;overflow-x:auto}.chat-markdown pre code{background:0 0;border:none;padding:0;font-size:.85em}.chat-markdown ul,.chat-markdown ol{margin:.25em 0;padding-left:1.5em}.chat-markdown li{margin:.1em 0}.chat-markdown h1,.chat-markdown h2,.chat-markdown h3{margin:.5em 0 .25em;font-weight:600}.chat-markdown h1{font-size:1.2em}.chat-markdown h2{font-size:1.1em}.chat-markdown h3{font-size:1em}.chat-markdown blockquote{border-left:3px solid var(--border);color:var(--text-secondary);margin:.25em 0;padding-left:.75em}.chat-markdown strong{font-weight:600}.chat-markdown a{color:var(--accent);text-decoration:underline}.chat-markdown table{border-collapse:collapse;width:100%;margin:.5em 0}.chat-markdown th,.chat-markdown td{border:1px solid var(--border);text-align:left;padding:.3em .6em}.chat-markdown th{background:var(--code-bg);font-weight:600}.chat-markdown tr:nth-child(2n){background:var(--code-bg)}.chat-markdown .hljs{background:0 0}[data-theme=light] .chat-markdown .hljs{color:#24292e}[data-theme=light] .chat-markdown .hljs-doctag,[data-theme=light] .chat-markdown .hljs-keyword,[data-theme=light] .chat-markdown .hljs-meta .hljs-keyword,[data-theme=light] .chat-markdown .hljs-template-tag,[data-theme=light] .chat-markdown .hljs-template-variable,[data-theme=light] .chat-markdown .hljs-type,[data-theme=light] .chat-markdown .hljs-variable.language_{color:#d73a49}[data-theme=light] .chat-markdown .hljs-title,[data-theme=light] .chat-markdown .hljs-title.class_,[data-theme=light] .chat-markdown .hljs-title.class_.inherited__,[data-theme=light] .chat-markdown .hljs-title.function_{color:#6f42c1}[data-theme=light] .chat-markdown .hljs-attr,[data-theme=light] .chat-markdown .hljs-attribute,[data-theme=light] .chat-markdown .hljs-literal,[data-theme=light] .chat-markdown .hljs-meta,[data-theme=light] .chat-markdown .hljs-number,[data-theme=light] .chat-markdown .hljs-operator,[data-theme=light] .chat-markdown .hljs-variable,[data-theme=light] .chat-markdown .hljs-selector-attr,[data-theme=light] .chat-markdown .hljs-selector-class,[data-theme=light] .chat-markdown .hljs-selector-id{color:#005cc5}[data-theme=light] .chat-markdown .hljs-regexp,[data-theme=light] .chat-markdown .hljs-string,[data-theme=light] .chat-markdown .hljs-meta .hljs-string{color:#032f62}[data-theme=light] .chat-markdown .hljs-built_in,[data-theme=light] .chat-markdown .hljs-symbol{color:#e36209}[data-theme=light] .chat-markdown .hljs-comment,[data-theme=light] .chat-markdown .hljs-code,[data-theme=light] .chat-markdown .hljs-formula{color:#6a737d}[data-theme=light] .chat-markdown .hljs-name,[data-theme=light] .chat-markdown .hljs-quote,[data-theme=light] .chat-markdown .hljs-selector-tag,[data-theme=light] .chat-markdown .hljs-selector-pseudo{color:#22863a}[data-theme=light] .chat-markdown .hljs-subst{color:#24292e}[data-theme=light] .chat-markdown .hljs-section{color:#005cc5}[data-theme=light] .chat-markdown .hljs-bullet{color:#735c0f}[data-theme=light] .chat-markdown .hljs-addition{color:#22863a;background-color:#f0fff4}[data-theme=light] .chat-markdown .hljs-deletion{color:#b31d28;background-color:#ffeef0}@keyframes agent-changed-pulse{0%,to{box-shadow:inset 0 0 0 50px color-mix(in srgb,var(--success) 20%,transparent)}50%{box-shadow:none}}.agent-changed-file{animation:2s ease-in-out 3 agent-changed-pulse}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/src/uipath/dev/server/static/assets/index-6FxzQyx2.css b/src/uipath/dev/server/static/assets/index-6FxzQyx2.css deleted file mode 100644 index 58fc4d3..0000000 --- a/src/uipath/dev/server/static/assets/index-6FxzQyx2.css +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2014 The xterm.js authors. All rights reserved. - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * https://github.com/chjj/term.js - * @license MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - * The original design remains. The terminal itself - * has been extended to include xterm CSI codes, among - * other features. - */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-duration:initial;--tw-ease:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--container-xs:20rem;--container-xl:36rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-normal:0em;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-normal:1.5;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-y-0{inset-block:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-1{top:calc(var(--spacing) * 1)}.top-1\.5{top:calc(var(--spacing) * 1.5)}.top-2{top:calc(var(--spacing) * 2)}.top-4{top:calc(var(--spacing) * 4)}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-1{right:calc(var(--spacing) * 1)}.right-3{right:calc(var(--spacing) * 3)}.right-4{right:calc(var(--spacing) * 4)}.bottom-1\.5{bottom:calc(var(--spacing) * 1.5)}.bottom-8{bottom:calc(var(--spacing) * 8)}.bottom-full{bottom:100%}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.mx-1{margin-inline:calc(var(--spacing) * 1)}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-2{margin-block:calc(var(--spacing) * 2)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-auto{margin-top:auto}.mr-0\.5{margin-right:calc(var(--spacing) * .5)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-32{height:calc(var(--spacing) * 32)}.h-\[14px\]{height:14px}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:calc(var(--spacing) * 32)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-\[85vh\]{max-height:85vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-full{min-height:100%}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-24{width:calc(var(--spacing) * 24)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-\[200px\]{width:200px}.w-\[calc\(100\%-24px\)\]{width:calc(100% - 24px)}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[300px\]{max-width:300px}.max-w-prose{max-width:65ch}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[140px\]{min-width:140px}.min-w-\[180px\]{min-width:180px}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-\[slideIn_0\.2s_ease-out\]{animation:.2s ease-out slideIn}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.appearance-auto{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing) * 0)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-\[var\(--border\)\]{border-color:var(--border)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--sidebar-bg\)\]{background-color:var(--sidebar-bg)}.bg-transparent{background-color:#0000}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-\[3px\]{padding-block:3px}.py-\[5px\]{padding-block:5px}.pt-0{padding-top:calc(var(--spacing) * 0)}.pt-1{padding-top:calc(var(--spacing) * 1)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-px{padding-top:1px}.pr-0{padding-right:calc(var(--spacing) * 0)}.pr-1{padding-right:calc(var(--spacing) * 1)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-\[22px\]{padding-left:22px}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.leading-none{--tw-leading:1;line-height:1}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-normal{--tw-tracking:var(--tracking-normal);letter-spacing:var(--tracking-normal)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--text-muted\)\]{color:var(--text-muted)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.no-underline{text-decoration-line:none}.underline{text-decoration-line:underline}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-0{opacity:0}.opacity-40{opacity:.4}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-80{opacity:.8}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}@media(hover:hover){.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\:text-\[var\(--text-muted\)\]::placeholder{color:var(--text-muted)}@media(hover:hover){.hover\:bg-\[var\(--bg-hover\)\]:hover{background-color:var(--bg-hover)}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-100:hover{opacity:1}.hover\:brightness-125:hover{--tw-brightness:brightness(125%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}}.focus\:opacity-100:focus{opacity:1}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}pre code.hljs{padding:1em;display:block;overflow-x:auto}code.hljs{padding:3px 5px}.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-variable,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id{color:#79c0ff}.hljs-regexp,.hljs-string,.hljs-meta .hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-comment,.hljs-code,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-tag,.hljs-selector-pseudo{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}:root,[data-theme=dark]{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--bg-hover:#263348;--bg-elevated:#253041;--text-primary:#cbd5e1;--text-secondary:#94a3b8;--text-muted:#64748b;--border:#334155;--accent:#fa4616;--accent-hover:#e03d12;--accent-light:#ff6a3d;--success:#22c55e;--warning:#eab308;--error:#ef4444;--info:#3b82f6;--sidebar-bg:#0e1526;--activity-bar-bg:#0a1020;--card-bg:#1e293b;--input-bg:#0f172a;--code-bg:#0f172a;--tab-active:#fa4616;--tab-text:#94a3b8;--tab-text-active:#fa4616;--node-bg:#1e293b;--node-border:#475569;--scrollbar-thumb:#334155;color-scheme:dark}[data-theme=light]{--bg-primary:#f8fafc;--bg-secondary:#fff;--bg-tertiary:#cbd5e1;--bg-hover:#f1f5f9;--bg-elevated:#fff;--text-primary:#0f172a;--text-secondary:#475569;--text-muted:#94a3b8;--border:#e2e8f0;--accent:#fa4616;--accent-hover:#e03d12;--accent-light:#ff6a3d;--success:#22c55e;--warning:#ca8a04;--error:#ef4444;--info:#2563eb;--sidebar-bg:#fff;--activity-bar-bg:#f1f5f9;--card-bg:#fff;--input-bg:#f8fafc;--code-bg:#e8ecf1;--tab-active:#fa4616;--tab-text:#64748b;--tab-text-active:#fa4616;--node-bg:#fff;--node-border:#cbd5e1;--scrollbar-thumb:#d1d5db;color-scheme:light}body{background:var(--bg-primary);color:var(--text-primary);margin:0;font-family:Inter,system-ui,-apple-system,sans-serif;transition:background-color .2s,color .2s}#root{height:100dvh;display:flex}:focus-visible{outline:2px solid var(--accent);outline-offset:1px}button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--accent)}@supports (color:color-mix(in lab,red,red)){button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 60%,transparent)}}button:focus-visible,[role=button]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline-offset:0px;border-radius:3px}.drag-handle-row{cursor:row-resize;background:var(--border);height:3px;transition:background .15s;position:relative}.drag-handle-row:before{content:"";position:absolute;top:-5px;right:0;bottom:-5px;left:0}.drag-handle-row:hover,.drag-handle-row:active{background:var(--accent)}.drag-handle-col{cursor:col-resize;background:var(--border);width:3px;transition:background .15s;position:relative}.drag-handle-col:before{content:"";position:absolute;top:0;right:-5px;bottom:0;left:-5px}.drag-handle-col:hover,.drag-handle-col:active{background:var(--accent)}@keyframes skeleton-pulse{0%,to{opacity:.4}50%{opacity:.7}}.skeleton{background:var(--bg-tertiary);border-radius:4px;animation:1.5s ease-in-out infinite skeleton-pulse}.react-flow__node{font-size:12px}.react-flow__node-default{background:var(--node-bg)!important;color:var(--text-primary)!important;border-color:var(--node-border)!important}.react-flow__background{background:var(--bg-primary)!important}.react-flow__controls button{background:var(--bg-secondary)!important;color:var(--text-primary)!important;border-color:var(--border)!important}.react-flow__controls button:hover{background:var(--bg-hover)!important}.react-flow__controls button svg{fill:var(--text-primary)!important}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb);border-radius:3px}select{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}select option{background:var(--bg-secondary);color:var(--text-primary)}.chat-markdown p{margin:.25em 0}.chat-markdown p:first-child{margin-top:0}.chat-markdown p:last-child{margin-bottom:0}.chat-markdown code{background:var(--code-bg);border:1px solid var(--border);border-radius:3px;padding:.1em .35em;font-size:.85em}.chat-markdown pre{background:var(--code-bg);border:1px solid var(--border);border-radius:6px;margin:.5em 0;padding:.75em;overflow-x:auto}.chat-markdown pre code{background:0 0;border:none;padding:0;font-size:.85em}.chat-markdown ul,.chat-markdown ol{margin:.25em 0;padding-left:1.5em}.chat-markdown li{margin:.1em 0}.chat-markdown h1,.chat-markdown h2,.chat-markdown h3{margin:.5em 0 .25em;font-weight:600}.chat-markdown h1{font-size:1.2em}.chat-markdown h2{font-size:1.1em}.chat-markdown h3{font-size:1em}.chat-markdown blockquote{border-left:3px solid var(--border);color:var(--text-secondary);margin:.25em 0;padding-left:.75em}.chat-markdown strong{font-weight:600}.chat-markdown a{color:var(--accent);text-decoration:underline}.chat-markdown table{border-collapse:collapse;width:100%;margin:.5em 0}.chat-markdown th,.chat-markdown td{border:1px solid var(--border);text-align:left;padding:.3em .6em}.chat-markdown th{background:var(--code-bg);font-weight:600}.chat-markdown tr:nth-child(2n){background:var(--code-bg)}.chat-markdown .hljs{background:0 0}[data-theme=light] .chat-markdown .hljs{color:#24292e}[data-theme=light] .chat-markdown .hljs-doctag,[data-theme=light] .chat-markdown .hljs-keyword,[data-theme=light] .chat-markdown .hljs-meta .hljs-keyword,[data-theme=light] .chat-markdown .hljs-template-tag,[data-theme=light] .chat-markdown .hljs-template-variable,[data-theme=light] .chat-markdown .hljs-type,[data-theme=light] .chat-markdown .hljs-variable.language_{color:#d73a49}[data-theme=light] .chat-markdown .hljs-title,[data-theme=light] .chat-markdown .hljs-title.class_,[data-theme=light] .chat-markdown .hljs-title.class_.inherited__,[data-theme=light] .chat-markdown .hljs-title.function_{color:#6f42c1}[data-theme=light] .chat-markdown .hljs-attr,[data-theme=light] .chat-markdown .hljs-attribute,[data-theme=light] .chat-markdown .hljs-literal,[data-theme=light] .chat-markdown .hljs-meta,[data-theme=light] .chat-markdown .hljs-number,[data-theme=light] .chat-markdown .hljs-operator,[data-theme=light] .chat-markdown .hljs-variable,[data-theme=light] .chat-markdown .hljs-selector-attr,[data-theme=light] .chat-markdown .hljs-selector-class,[data-theme=light] .chat-markdown .hljs-selector-id{color:#005cc5}[data-theme=light] .chat-markdown .hljs-regexp,[data-theme=light] .chat-markdown .hljs-string,[data-theme=light] .chat-markdown .hljs-meta .hljs-string{color:#032f62}[data-theme=light] .chat-markdown .hljs-built_in,[data-theme=light] .chat-markdown .hljs-symbol{color:#e36209}[data-theme=light] .chat-markdown .hljs-comment,[data-theme=light] .chat-markdown .hljs-code,[data-theme=light] .chat-markdown .hljs-formula{color:#6a737d}[data-theme=light] .chat-markdown .hljs-name,[data-theme=light] .chat-markdown .hljs-quote,[data-theme=light] .chat-markdown .hljs-selector-tag,[data-theme=light] .chat-markdown .hljs-selector-pseudo{color:#22863a}[data-theme=light] .chat-markdown .hljs-subst{color:#24292e}[data-theme=light] .chat-markdown .hljs-section{color:#005cc5}[data-theme=light] .chat-markdown .hljs-bullet{color:#735c0f}[data-theme=light] .chat-markdown .hljs-addition{color:#22863a;background-color:#f0fff4}[data-theme=light] .chat-markdown .hljs-deletion{color:#b31d28;background-color:#ffeef0}@keyframes agent-changed-pulse{0%,to{box-shadow:inset 0 0 0 50px color-mix(in srgb,var(--success) 20%,transparent)}50%{box-shadow:none}}.agent-changed-file{animation:2s ease-in-out 3 agent-changed-pulse}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/src/uipath/dev/server/static/assets/index-CMiQYjGD.js b/src/uipath/dev/server/static/assets/index-DDJ_NWFS.js similarity index 63% rename from src/uipath/dev/server/static/assets/index-CMiQYjGD.js rename to src/uipath/dev/server/static/assets/index-DDJ_NWFS.js index 8f1210c..c1722e1 100644 --- a/src/uipath/dev/server/static/assets/index-CMiQYjGD.js +++ b/src/uipath/dev/server/static/assets/index-DDJ_NWFS.js @@ -1,10 +1,10 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-elk-BkmlSRbk.js","assets/vendor-react-VzyiTEsu.js","assets/ChatPanel-CrwXase9.js","assets/vendor-reactflow-B_2yZyR4.js","assets/vendor-reactflow-B5DZHykP.css"])))=>i.map(i=>d[i]); -var sc=Object.defineProperty;var rc=(e,t,s)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Ut=(e,t,s)=>rc(e,typeof t!="symbol"?t+"":t,s);import{W as Zs,a as v,j as n,g as ic,b as nc,w as oc,F as ac,d as lc}from"./vendor-react-VzyiTEsu.js";import{M as cc,H as Lt,P as Tt,B as hc,u as ia,a as na,R as oa,b as aa,C as la,c as dc,d as ca}from"./vendor-reactflow-B_2yZyR4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function s(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=s(i);fetch(i.href,o)}})();const xn=e=>{let t;const s=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const _=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),s.forEach(g=>g(t,_))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>h,subscribe:c=>(s.add(c),()=>s.delete(c))},h=t=e(r,i,l);return l},uc=(e=>e?xn(e):xn),fc=e=>e;function pc(e,t=fc){const s=Zs.useSyncExternalStore(e.subscribe,Zs.useCallback(()=>t(e.getState()),[e,t]),Zs.useCallback(()=>t(e.getInitialState()),[e,t]));return Zs.useDebugValue(s),s}const yn=e=>{const t=uc(e),s=r=>pc(t,r);return Object.assign(s,t),s},Jt=(e=>e?yn(e):yn),de=Jt(e=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:t=>e(s=>{var o;let r=s.breakpoints;for(const a of t)(o=a.breakpoints)!=null&&o.length&&!r[a.id]&&(r={...r,[a.id]:Object.fromEntries(a.breakpoints.map(l=>[l,!0]))});const i={runs:Object.fromEntries(t.map(a=>[a.id,a]))};return r!==s.breakpoints&&(i.breakpoints=r),i}),upsertRun:t=>e(s=>{var i;const r={runs:{...s.runs,[t.id]:t}};if((i=t.breakpoints)!=null&&i.length&&!s.breakpoints[t.id]&&(r.breakpoints={...s.breakpoints,[t.id]:Object.fromEntries(t.breakpoints.map(o=>[o,!0]))}),(t.status==="completed"||t.status==="failed")&&s.activeNodes[t.id]){const{[t.id]:o,...a}=s.activeNodes;r.activeNodes=a}if(t.status!=="suspended"&&s.activeInterrupt[t.id]){const{[t.id]:o,...a}=s.activeInterrupt;r.activeInterrupt=a}return r}),selectRun:t=>e({selectedRunId:t}),addTrace:t=>e(s=>{const r=s.traces[t.run_id]??[],i=r.findIndex(a=>a.span_id===t.span_id),o=i>=0?r.map((a,l)=>l===i?t:a):[...r,t];return{traces:{...s.traces,[t.run_id]:o}}}),setTraces:(t,s)=>e(r=>({traces:{...r.traces,[t]:s}})),addLog:t=>e(s=>{const r=s.logs[t.run_id]??[];return{logs:{...s.logs,[t.run_id]:[...r,t]}}}),setLogs:(t,s)=>e(r=>({logs:{...r.logs,[t]:s}})),addChatEvent:(t,s)=>e(r=>{const i=r.chatMessages[t]??[],o=s.message;if(!o)return r;const a=o.messageId??o.message_id,l=o.role??"assistant",u=(o.contentParts??o.content_parts??[]).filter(x=>{const w=x.mimeType??x.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(x=>{const w=x.data;return(w==null?void 0:w.inline)??""}).join(` -`).trim(),d=(o.toolCalls??o.tool_calls??[]).map(x=>({name:x.name??"",has_result:!!x.result})),_={message_id:a,role:l,content:u,tool_calls:d.length>0?d:void 0},g=i.findIndex(x=>x.message_id===a);if(g>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((x,w)=>w===g?_:x)}};if(l==="user"){const x=i.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===u);if(x>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((w,E)=>E===x?_:w)}}}const m=[...i,_];return{chatMessages:{...r.chatMessages,[t]:m}}}),addLocalChatMessage:(t,s)=>e(r=>{const i=r.chatMessages[t]??[];return{chatMessages:{...r.chatMessages,[t]:[...i,s]}}}),setChatMessages:(t,s)=>e(r=>({chatMessages:{...r.chatMessages,[t]:s}})),setEntrypoints:t=>e({entrypoints:t}),breakpoints:{},toggleBreakpoint:(t,s)=>e(r=>{const i={...r.breakpoints[t]??{}};return i[s]?delete i[s]:i[s]=!0,{breakpoints:{...r.breakpoints,[t]:i}}}),clearBreakpoints:t=>e(s=>{const{[t]:r,...i}=s.breakpoints;return{breakpoints:i}}),activeNodes:{},setActiveNode:(t,s,r)=>e(i=>{const o=i.activeNodes[t]??{executing:{},prev:null};return{activeNodes:{...i.activeNodes,[t]:{executing:{...o.executing,[s]:r??null},prev:o.prev}}}}),removeActiveNode:(t,s)=>e(r=>{const i=r.activeNodes[t];if(!i)return r;const{[s]:o,...a}=i.executing;return{activeNodes:{...r.activeNodes,[t]:{executing:a,prev:s}}}}),resetRunGraphState:t=>e(s=>({stateEvents:{...s.stateEvents,[t]:[]},activeNodes:{...s.activeNodes,[t]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(t,s,r,i,o)=>e(a=>{const l=a.stateEvents[t]??[];return{stateEvents:{...a.stateEvents,[t]:[...l,{node_name:s,qualified_node_name:i,phase:o,timestamp:Date.now(),payload:r}]}}}),setStateEvents:(t,s)=>e(r=>({stateEvents:{...r.stateEvents,[t]:s}})),focusedSpan:null,setFocusedSpan:t=>e({focusedSpan:t}),activeInterrupt:{},setActiveInterrupt:(t,s)=>e(r=>({activeInterrupt:{...r.activeInterrupt,[t]:s}})),reloadPending:!1,setReloadPending:t=>e({reloadPending:t}),graphCache:{},setGraphCache:(t,s)=>e(r=>({graphCache:{...r.graphCache,[t]:s}}))})),Sr="/api";async function _c(e){const t=await fetch(`${Sr}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({environment:e})});if(!t.ok)throw new Error(`Login failed: ${t.status}`);return t.json()}async function Or(){const e=await fetch(`${Sr}/auth/status`);if(!e.ok)throw new Error(`Status check failed: ${e.status}`);return e.json()}async function gc(e){const t=await fetch(`${Sr}/auth/select-tenant`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tenant_name:e})});if(!t.ok)throw new Error(`Tenant selection failed: ${t.status}`);return t.json()}async function mc(){await fetch(`${Sr}/auth/logout`,{method:"POST"})}const ha="uipath-env",vc=["cloud","staging","alpha"];function xc(){const e=localStorage.getItem(ha);return vc.includes(e)?e:"cloud"}const da=Jt((e,t)=>({enabled:!0,status:"unauthenticated",environment:xc(),tenants:[],uipathUrl:null,pollTimer:null,expiryTimer:null,init:async()=>{try{const s=await fetch("/api/config");if(s.ok&&!(await s.json()).auth_enabled){e({enabled:!1});return}const r=await Or();e({status:r.status,tenants:r.tenants??[],uipathUrl:r.uipath_url??null}),r.status==="authenticated"&&t().startExpiryCheck()}catch(s){console.error("Auth init failed",s)}},setEnvironment:s=>{localStorage.setItem(ha,s),e({environment:s})},startLogin:async()=>{const{environment:s}=t();try{const r=await _c(s);e({status:"pending"}),window.open(r.auth_url,"_blank"),t().pollStatus()}catch(r){console.error("Login failed",r)}},pollStatus:()=>{const{pollTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{const i=await Or();i.status!=="pending"&&(t().stopPolling(),e({status:i.status,tenants:i.tenants??[],uipathUrl:i.uipath_url??null}),i.status==="authenticated"&&t().startExpiryCheck())}catch{}},2e3);e({pollTimer:r})},stopPolling:()=>{const{pollTimer:s}=t();s&&(clearInterval(s),e({pollTimer:null}))},startExpiryCheck:()=>{const{expiryTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{(await Or()).status==="expired"&&(t().stopExpiryCheck(),e({status:"expired"}))}catch{}},3e4);e({expiryTimer:r})},stopExpiryCheck:()=>{const{expiryTimer:s}=t();s&&(clearInterval(s),e({expiryTimer:null}))},selectTenant:async s=>{try{const r=await gc(s);e({status:"authenticated",uipathUrl:r.uipath_url,tenants:[]}),t().startExpiryCheck()}catch(r){console.error("Tenant selection failed",r)}},logout:async()=>{t().stopPolling(),t().stopExpiryCheck();try{await mc()}catch{}e({status:"unauthenticated",tenants:[],uipathUrl:null})}})),ua=Jt(e=>({projectName:null,projectVersion:null,projectAuthors:null,init:async()=>{try{const t=await fetch("/api/config");if(t.ok){const s=await t.json();e({projectName:s.project_name??null,projectVersion:s.project_version??null,projectAuthors:s.project_authors??null})}}catch{}}}));class yc{constructor(t){Ut(this,"ws",null);Ut(this,"url");Ut(this,"handlers",new Set);Ut(this,"reconnectTimer",null);Ut(this,"shouldReconnect",!0);Ut(this,"pendingMessages",[]);Ut(this,"activeSubscriptions",new Set);const s=window.location.protocol==="https:"?"wss:":"ws:";this.url=t??`${s}//${window.location.host}/ws`}connect(){var t;((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const s of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:s}}));for(const s of this.pendingMessages)this.sendRaw(s);this.pendingMessages=[]},this.ws.onmessage=s=>{let r;try{r=JSON.parse(s.data)}catch{console.warn("[ws] failed to parse message",s.data);return}this.handlers.forEach(i=>{try{i(r)}catch(o){console.error("[ws] handler error",o)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var s;(s=this.ws)==null||s.close()})}disconnect(){var t;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(t=this.ws)==null||t.close(),this.ws=null}onMessage(t){return this.handlers.add(t),()=>this.handlers.delete(t)}sendRaw(t){var s;((s=this.ws)==null?void 0:s.readyState)===WebSocket.OPEN&&this.ws.send(t)}send(t,s){var i;const r=JSON.stringify({type:t,payload:s});((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN?this.ws.send(r):this.pendingMessages.push(r)}subscribe(t){this.activeSubscriptions.add(t),this.send("subscribe",{run_id:t})}unsubscribe(t){this.activeSubscriptions.delete(t),this.send("unsubscribe",{run_id:t})}sendChatMessage(t,s){this.send("chat.message",{run_id:t,text:s})}sendInterruptResponse(t,s){this.send("chat.interrupt_response",{run_id:t,data:s})}debugStep(t){this.send("debug.step",{run_id:t})}debugContinue(t){this.send("debug.continue",{run_id:t})}debugStop(t){this.send("debug.stop",{run_id:t})}setBreakpoints(t,s){this.send("debug.set_breakpoints",{run_id:t,breakpoints:s})}sendCliAgentStart(t,s,r,i){this.send("cli_agent.start",{agent_id:t,session_id:s,cols:r,rows:i})}sendCliAgentInput(t,s){this.send("cli_agent.input",{session_id:t,data:s})}sendCliAgentResize(t,s,r){this.send("cli_agent.resize",{session_id:t,cols:s,rows:r})}sendCliAgentStop(t){this.send("cli_agent.stop",{session_id:t})}}const Zt="/api";async function Qt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function $i(){return Qt(`${Zt}/entrypoints`)}async function bc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/schema`)}async function Sc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/mock-input`)}async function fa(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/graph`)}async function bn(e,t,s="run",r=[]){return Qt(`${Zt}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:e,input_data:t,mode:s,breakpoints:r})})}async function wc(){return Qt(`${Zt}/runs`)}async function Ir(e){return Qt(`${Zt}/runs/${e}`)}async function Cc(){return Qt(`${Zt}/reload`,{method:"POST"})}const xe=Jt(e=>({evaluators:[],localEvaluators:[],llmModels:[],evalSets:{},evalRuns:{},streamingResults:{},setEvaluators:t=>e({evaluators:t}),setLocalEvaluators:t=>e({localEvaluators:t}),setLlmModels:t=>e({llmModels:t}),addLocalEvaluator:t=>e(s=>({localEvaluators:[...s.localEvaluators,t]})),upsertLocalEvaluator:t=>e(s=>({localEvaluators:s.localEvaluators.some(r=>r.id===t.id)?s.localEvaluators.map(r=>r.id===t.id?t:r):[...s.localEvaluators,t]})),setEvalSets:t=>e({evalSets:Object.fromEntries(t.map(s=>[s.id,s]))}),addEvalSet:t=>e(s=>({evalSets:{...s.evalSets,[t.id]:t}})),updateEvalSetEvaluators:(t,s)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,evaluator_ids:s}}}:r}),incrementEvalSetCount:(t,s=1)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,eval_count:i.eval_count+s}}}:r}),setEvalRuns:t=>e({evalRuns:Object.fromEntries(t.map(s=>[s.id,s]))}),upsertEvalRun:t=>e(s=>({evalRuns:{...s.evalRuns,[t.id]:t}})),updateEvalRunProgress:(t,s,r,i)=>e(o=>{const a=o.evalRuns[t];if(!a)return o;const l={...o.streamingResults};return i&&(l[t]={...l[t],[i.name]:i}),{evalRuns:{...o.evalRuns,[t]:{...a,progress_completed:s,progress_total:r,status:"running"}},streamingResults:l}}),completeEvalRun:(t,s,r)=>e(i=>{const o=i.evalRuns[t];if(!o)return i;const a={...i.streamingResults};return delete a[t],{evalRuns:{...i.evalRuns,[t]:{...o,status:"completed",overall_score:s,evaluator_scores:r,end_time:new Date().toISOString()}},streamingResults:a}})})),Ms=Jt(e=>({availableAgents:[],selectedAgentId:null,sessionId:null,status:"idle",exitCode:null,events:[],setAvailableAgents:t=>{e(s=>{const r={availableAgents:t};if(!s.selectedAgentId){const i=t.find(o=>o.installed);i&&(r.selectedAgentId=i.id)}return r})},setSelectedAgentId:t=>e({selectedAgentId:t}),setSessionId:t=>e({sessionId:t}),setStatus:t=>e({status:t}),setExitCode:t=>e({exitCode:t}),addEvent:t=>e(s=>({events:[...s.events,t]}))})),ye=Jt(e=>({children:{},expanded:{},selectedFile:null,openTabs:[],fileCache:{},dirty:{},buffers:{},loadingDirs:{},loadingFile:!1,agentChangedFiles:{},diffView:null,setChildren:(t,s)=>e(r=>({children:{...r.children,[t]:s}})),toggleExpanded:t=>e(s=>({expanded:{...s.expanded,[t]:!s.expanded[t]}})),setSelectedFile:t=>e({selectedFile:t}),openTab:t=>e(s=>({selectedFile:t,openTabs:s.openTabs.includes(t)?s.openTabs:[...s.openTabs,t]})),closeTab:t=>e(s=>{const r=s.openTabs.filter(c=>c!==t);let i=s.selectedFile;if(i===t){const c=s.openTabs.indexOf(t);i=r[Math.min(c,r.length-1)]??null}const{[t]:o,...a}=s.dirty,{[t]:l,...h}=s.buffers;return{openTabs:r,selectedFile:i,dirty:a,buffers:h}}),setFileContent:(t,s)=>e(r=>({fileCache:{...r.fileCache,[t]:s}})),updateBuffer:(t,s)=>e(r=>({buffers:{...r.buffers,[t]:s},dirty:{...r.dirty,[t]:!0}})),markClean:t=>e(s=>{const{[t]:r,...i}=s.dirty,{[t]:o,...a}=s.buffers;return{dirty:i,buffers:a}}),setLoadingDir:(t,s)=>e(r=>({loadingDirs:{...r.loadingDirs,[t]:s}})),setLoadingFile:t=>e({loadingFile:t}),markAgentChanged:t=>e(s=>({agentChangedFiles:{...s.agentChangedFiles,[t]:Date.now()}})),clearAgentChanged:t=>e(s=>{const{[t]:r,...i}=s.agentChangedFiles;return{agentChangedFiles:i}}),setDiffView:t=>e({diffView:t}),expandPath:t=>e(s=>{const r=t.split("/"),i={...s.expanded};for(let o=1;oe.current.onMessage(x=>{switch(x.type){case"run.updated":{const w=x.payload;t(w),(w.status==="running"||w.status==="completed"||w.status==="failed")&&Ms.getState().addEvent({type:"run_lifecycle",timestamp:Date.now(),runId:w.id,entrypoint:w.entrypoint,status:w.status});break}case"trace":s(x.payload);break;case"log":r(x.payload);break;case"chat":{const w=x.payload.run_id;i(w,x.payload);break}case"chat.interrupt":{const w=x.payload.run_id;o(w,x.payload);break}case"state":{const w=x.payload.run_id,E=x.payload.node_name,k=x.payload.qualified_node_name??null,P=x.payload.phase??null,A=x.payload.payload;E==="__start__"&&P==="started"&&h(w),P==="started"?a(w,E,k):P==="completed"&&l(w,E),c(w,E,A,k,P);break}case"reload":{x.payload.reloaded?$i().then(E=>{const k=de.getState();k.setEntrypoints(E.map(P=>P.name)),k.setReloadPending(!1)}).catch(E=>console.error("Failed to refresh entrypoints:",E)):de.getState().setReloadPending(!0);break}case"files.changed":{const w=x.payload.files,E=new Set(w),k=ye.getState(),P=w.filter(D=>D in k.children?!1:(D.split("/").pop()??"").includes("."));P.length>0&&Ms.getState().addEvent({type:"files_changed",timestamp:Date.now(),files:P});for(const D of k.openTabs)k.dirty[D]||!E.has(D)||pa(D).then(N=>{var B;const $=ye.getState();$.dirty[D]||((B=$.fileCache[D])==null?void 0:B.content)!==N.content&&$.setFileContent(D,N)}).catch(()=>{});const A=new Set;for(const D of w){const N=D.lastIndexOf("/"),$=N===-1?"":D.substring(0,N);$ in k.children&&A.add($)}for(const D of A)Ki(D).then(N=>ye.getState().setChildren(D,N)).catch(()=>{});break}case"eval_run.created":u(x.payload);break;case"eval_run.progress":{const{run_id:w,completed:E,total:k,item_result:P}=x.payload;d(w,E,k,P);break}case"eval_run.completed":{const{run_id:w,overall_score:E,evaluator_scores:k}=x.payload;_(w,E,k);break}case"cli_agent.output":{const{session_id:w,data:E}=x.payload,k=Nc(w);if(k){const P=Uint8Array.from(atob(E),A=>A.charCodeAt(0));k(P)}break}case"cli_agent.exit":{const{session_id:w,exit_code:E}=x.payload,k=Ms.getState();if(k.sessionId===w){k.setStatus("exited"),k.setExitCode(E);const P=k.availableAgents.find(A=>A.id===k.selectedAgentId);k.addEvent({type:"session",timestamp:Date.now(),agentName:(P==null?void 0:P.name)??"Unknown",action:"exited",exitCode:E})}break}case"mcp.tool_call":{const{tool:w,args:E}=x.payload;Ms.getState().addEvent({type:"mcp_tool_call",timestamp:Date.now(),tool:w,args:E});break}}}),[t,s,r,i,o,a,l,h,c,u,d,_]),e.current}function Lc(e){const t=e.replace(/^#\/?/,""),s={section:"debug",view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null,evalCreating:!1,evalSetId:null,evalRunId:null,evalRunItemName:null,evaluatorId:null,evaluatorCreateType:null,evaluatorFilter:null,explorerFile:null};if(!t||t==="new"||t==="debug"||t==="debug/new")return s;const r=t.match(/^(?:debug\/)?setup\/([^/]+)\/(run|chat)$/);if(r)return{...s,view:"setup",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const i=t.match(/^(?:debug\/)?runs\/([^/]+)(?:\/(traces|output))?$/);if(i)return{...s,view:"details",runId:i[1],tab:i[2]??"traces"};if(t==="evals/new")return{...s,section:"evals",evalCreating:!0};const o=t.match(/^evals\/runs\/([^/]+?)(?:\/([^/]+))?$/);if(o)return{...s,section:"evals",evalRunId:o[1],evalRunItemName:o[2]?decodeURIComponent(o[2]):null};const a=t.match(/^evals\/sets\/([^/]+)$/);if(a)return{...s,section:"evals",evalSetId:a[1]};if(t==="evals")return{...s,section:"evals"};const l=t.match(/^evaluators\/new(?:\/(deterministic|llm|tool))?$/);if(l)return{...s,section:"evaluators",evaluatorCreateType:l[1]??"any"};const h=t.match(/^evaluators\/category\/(deterministic|llm|tool)$/);if(h)return{...s,section:"evaluators",evaluatorFilter:h[1]};const c=t.match(/^evaluators\/([^/]+)$/);if(c)return{...s,section:"evaluators",evaluatorId:c[1]};if(t==="evaluators")return{...s,section:"evaluators"};if(t==="explorer/canvas")return{...s,section:"explorer",explorerFile:"__canvas__"};const u=t.match(/^explorer\/statedb\/(.+)$/);if(u)return{...s,section:"explorer",explorerFile:`__statedb__:${decodeURIComponent(u[1])}`};const d=t.match(/^explorer\/file\/(.+)$/);return d?{...s,section:"explorer",explorerFile:decodeURIComponent(d[1])}:t==="explorer"?{...s,section:"explorer"}:s}function Tc(){return window.location.hash}function Rc(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function et(){const e=v.useSyncExternalStore(Rc,Tc),t=Lc(e),s=v.useCallback(r=>{window.location.hash=r},[]);return{...t,navigate:s}}const Sn="(max-width: 767px)";function Bc(){const[e,t]=v.useState(()=>window.matchMedia(Sn).matches);return v.useEffect(()=>{const s=window.matchMedia(Sn),r=i=>t(i.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),e}const Dc=[{section:"debug",label:"Developer Console",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"8",y:"6",width:"8",height:"14",rx:"4"}),n.jsx("path",{d:"M6 10H4"}),n.jsx("path",{d:"M6 18H4"}),n.jsx("path",{d:"M18 10h2"}),n.jsx("path",{d:"M18 18h2"}),n.jsx("path",{d:"M8 14h8"}),n.jsx("path",{d:"M9 6l-1.5-2"}),n.jsx("path",{d:"M15 6l1.5-2"}),n.jsx("path",{d:"M6 14H4"}),n.jsx("path",{d:"M18 14h2"})]})},{section:"evals",label:"Evals",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.5L5 20a1 1 0 0 0 .9 1.4h12.2a1 1 0 0 0 .9-1.4L14 9.5V3"}),n.jsx("path",{d:"M8.5 14h7"})]})},{section:"evaluators",label:"Evaluators",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2l7 4v5c0 5.25-3.5 9.74-7 11-3.5-1.26-7-5.75-7-11V6l7-4z"}),n.jsx("path",{d:"M9 12l2 2 4-4"})]})},{section:"explorer",label:"Explorer",icon:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",children:n.jsx("path",{d:"M7.5 22.5H17.595C17.07 23.4 16.11 24 15 24H7.5C4.185 24 1.5 21.315 1.5 18V6C1.5 4.89 2.1 3.93 3 3.405V18C3 20.475 5.025 22.5 7.5 22.5ZM21 8.121V18C21 19.6545 19.6545 21 18 21H7.5C5.8455 21 4.5 19.6545 4.5 18V3C4.5 1.3455 5.8455 0 7.5 0H12.879C13.4715 0 14.0505 0.24 14.4705 0.6585L20.3415 6.5295C20.766 6.954 21 7.5195 21 8.121ZM13.5 6.75C13.5 7.164 13.8375 7.5 14.25 7.5H19.1895L13.5 1.8105V6.75ZM19.5 18V9H14.25C13.0095 9 12 7.9905 12 6.75V1.5H7.5C6.672 1.5 6 2.1735 6 3V18C6 18.8265 6.672 19.5 7.5 19.5H18C18.828 19.5 19.5 18.8265 19.5 18Z"})})}];function Pc({section:e,onSectionChange:t}){return n.jsx("div",{className:"w-12 flex flex-col items-center shrink-0 border-r",style:{background:"var(--activity-bar-bg)",borderColor:"var(--border)"},children:n.jsx("div",{className:"flex flex-col items-center gap-1 pt-2",children:Dc.map(s=>{const r=e===s.section;return n.jsxs("button",{onClick:()=>t(s.section),className:"w-10 h-10 flex items-center justify-center rounded cursor-pointer transition-colors relative",style:{color:r?"var(--text-primary)":"var(--text-muted)",background:r?"var(--bg-hover)":"transparent",border:"none"},title:s.label,onMouseEnter:i=>{r||(i.currentTarget.style.color="var(--text-secondary)")},onMouseLeave:i=>{r||(i.currentTarget.style.color="var(--text-muted)")},children:[r&&n.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r",style:{background:"var(--accent)"}}),s.icon]},s.section)})})})}const it="/api";async function nt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Ac(){return nt(`${it}/evaluators`)}async function _a(){return nt(`${it}/llm-models`)}async function ga(){return nt(`${it}/eval-sets`)}async function Oc(e){return nt(`${it}/eval-sets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Ic(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function Wc(e,t){await nt(`${it}/eval-sets/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Hc(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}`)}async function $c(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/runs`,{method:"POST"})}async function Fc(){return nt(`${it}/eval-runs`)}async function wn(e){return nt(`${it}/eval-runs/${encodeURIComponent(e)}`)}async function Vi(){return nt(`${it}/local-evaluators`)}async function zc(e){return nt(`${it}/local-evaluators`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Uc(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/evaluators`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({evaluator_refs:t})})}async function Kc(e,t){return nt(`${it}/local-evaluators/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}const Vc={"uipath-exact-match":e=>({expectedOutput:e}),"uipath-json-similarity":e=>({expectedOutput:e}),"uipath-contains":()=>({searchText:""}),"uipath-llm-judge-output-semantic-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-output-strict-json-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-trajectory-similarity":()=>({expectedAgentBehavior:""}),"uipath-llm-judge-trajectory-simulation":()=>({expectedAgentBehavior:""}),"uipath-tool-call-count":()=>({}),"uipath-tool-call-args":()=>({}),"uipath-tool-call-order":()=>({}),"uipath-tool-call-output":()=>({})};function qc(e,t){if(!e)return{};const s=Vc[e.evaluator_type_id];return s?s(t):e.type==="tool"?{}:e.evaluator_type_id.includes("trajectory")?{expectedAgentBehavior:""}:{expectedOutput:t}}function ma(e){return e?e.type==="tool"?!0:e.evaluator_type_id.includes("tool-call"):!1}function Xc(e){return e?ma(e)?{label:"tools",color:"var(--warning, #e5a00d)"}:e.evaluator_type_id.includes("trajectory")?{label:"quality",color:"var(--info, #3b82f6)"}:{label:"output",color:"var(--success, #22c55e)"}:{label:"output",color:"var(--success, #22c55e)"}}function Yc({run:e,onClose:t}){const s=xe(T=>T.evalSets),r=xe(T=>T.setEvalSets),i=xe(T=>T.incrementEvalSetCount),o=xe(T=>T.localEvaluators),a=xe(T=>T.setLocalEvaluators),[l,h]=v.useState(`run-${e.id.slice(0,8)}`),[c,u]=v.useState(new Set),[d,_]=v.useState({}),g=v.useRef(new Set),[m,x]=v.useState(!1),[w,E]=v.useState(null),[k,P]=v.useState(!1),A=Object.values(s),D=v.useMemo(()=>Object.fromEntries(o.map(T=>[T.id,T])),[o]),N=v.useMemo(()=>{const T=new Set;for(const O of c){const L=s[O];L&&L.evaluator_ids.forEach(R=>T.add(R))}return[...T]},[c,s]);v.useEffect(()=>{const T=e.output_data,O=g.current;_(L=>{const R={};for(const p of N)if(O.has(p)&&L[p]!==void 0)R[p]=L[p];else{const f=D[p],b=qc(f,T);R[p]=JSON.stringify(b,null,2)}return R})},[N,D,e.output_data]),v.useEffect(()=>{const T=O=>{O.key==="Escape"&&t()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[t]),v.useEffect(()=>{A.length===0&&ga().then(r).catch(()=>{}),o.length===0&&Vi().then(a).catch(()=>{})},[]);const $=T=>{u(O=>{const L=new Set(O);return L.has(T)?L.delete(T):L.add(T),L})},B=async()=>{var O;if(!l.trim()||c.size===0)return;E(null),x(!0);const T={};for(const L of N){const R=d[L];if(R!==void 0)try{T[L]=JSON.parse(R)}catch{E(`Invalid JSON for evaluator "${((O=D[L])==null?void 0:O.name)??L}"`),x(!1);return}}try{for(const L of c){const R=s[L],p=new Set((R==null?void 0:R.evaluator_ids)??[]),f={};for(const[b,y]of Object.entries(T))p.has(b)&&(f[b]=y);await Ic(L,{name:l.trim(),inputs:e.input_data,expected_output:null,evaluation_criterias:f}),i(L)}P(!0),setTimeout(t,3e3)}catch(L){E(L.detail||L.message||"Failed to add item")}finally{x(!1)}};return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:T=>{T.target===T.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg p-6 shadow-xl max-h-[85vh] flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"Add to Eval Set"})]}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:T=>{T.currentTarget.style.color="var(--text-primary)"},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-muted)"},"aria-label":"Close",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-4 pr-1",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Item Name"}),n.jsx("input",{type:"text",value:l,onChange:T=>h(T.target.value),className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Inputs"}),n.jsx("pre",{className:"rounded-md px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(e.input_data,null,2)})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Eval Sets"}),A.length===0?n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No eval sets found. Create one first."}):n.jsx("div",{className:"rounded-md border overflow-hidden max-h-40 overflow-y-auto",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:A.map(T=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:O=>{O.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:c.has(T.id),onChange:()=>$(T.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:T.name}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[T.eval_count," items"]})]},T.id))})]}),N.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluation Criteria"}),n.jsx("div",{className:"space-y-2",children:N.map(T=>{const O=D[T],L=ma(O),R=Xc(O);return n.jsxs("div",{className:"rounded-md",style:{border:"1px solid var(--border)",background:"var(--bg-primary)",opacity:L?.6:1},children:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:L?"none":"1px solid var(--border)"},children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",style:{color:"var(--text-primary)"},children:(O==null?void 0:O.name)??T}),n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{color:R.color,background:`color-mix(in srgb, ${R.color} 12%, transparent)`},children:R.label})]}),L?n.jsx("div",{className:"px-3 pb-2",children:n.jsx("span",{className:"text-[10px] italic",style:{color:"var(--text-muted)"},children:"Default criteria — uses evaluator config"})}):n.jsx("div",{className:"px-3 pb-2 pt-1",children:n.jsx("textarea",{value:d[T]??"{}",onChange:p=>{g.current.add(T),_(f=>({...f,[T]:p.target.value}))},rows:8,className:"w-full rounded px-2 py-1.5 text-xs font-mono resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})})]},T)})})]})]}),n.jsxs("div",{className:"mt-4 space-y-3",children:[w&&n.jsx("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:w}),k&&n.jsxs("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--success)",background:"color-mix(in srgb, var(--success) 10%, var(--bg-secondary))"},children:["Added to ",c.size," eval set",c.size!==1?"s":"","."]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:t,className:"flex-1 py-2 rounded-md text-xs font-semibold cursor-pointer",style:{background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Cancel"}),n.jsx("button",{onClick:B,disabled:!l.trim()||c.size===0||m||k,className:"flex-1 py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:m?"Adding...":k?"Added":"Add Item"})]})]})]})})}const Gc={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function Jc({run:e,isSelected:t,onClick:s}){var d;const r=Gc[e.status]??"var(--text-muted)",i=((d=e.entrypoint.split("/").pop())==null?void 0:d.slice(0,16))??e.entrypoint,o=e.start_time?new Date(e.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",[a,l]=v.useState(!1),[h,c]=v.useState(!1),u=v.useRef(null);return v.useEffect(()=>{if(!a)return;const _=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[a]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"group relative w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:t?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:t?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:_=>{t||(_.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:_=>{t||(_.currentTarget.style.background="")},onClick:s,children:[n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:r}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs truncate",style:{color:t?"var(--text-primary)":"var(--text-secondary)"},children:i}),n.jsxs("div",{className:"text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[o,e.duration?` · ${e.duration}`:""]})]}),e.status==="completed"&&n.jsxs("div",{ref:u,className:"relative shrink-0",children:[n.jsx("button",{onClick:_=>{_.stopPropagation(),l(g=>!g)},className:"opacity-40 group-hover:opacity-100 focus:opacity-100 w-7 h-7 flex items-center justify-center rounded transition-opacity cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:_=>{_.currentTarget.style.color="var(--text-primary)",_.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:_=>{_.currentTarget.style.color="var(--text-muted)",_.currentTarget.style.background=""},"aria-label":"Actions",title:"Actions",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}),a&&n.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[140px] rounded-md shadow-lg py-1",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:n.jsx("button",{onClick:_=>{_.stopPropagation(),l(!1),c(!0)},className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--bg-hover)",_.currentTarget.style.color="var(--text-primary)"},onMouseLeave:_=>{_.currentTarget.style.background="",_.currentTarget.style.color="var(--text-secondary)"},children:"Add to Eval Set"})})]})]}),h&&n.jsx(Yc,{run:e,onClose:()=>c(!1)})]})}function Cn({runs:e,selectedRunId:t,onSelectRun:s,onNewRun:r}){const i=[...e].sort((o,a)=>new Date(a.start_time??0).getTime()-new Date(o.start_time??0).getTime());return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:r,className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Run"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(o=>n.jsx(Jc,{run:o,isSelected:o.id===t,onClick:()=>s(o.id)},o.id)),i.length===0&&n.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]})]})}function va(){const e=localStorage.getItem("uipath-dev-theme");return e==="light"||e==="dark"?e:"dark"}function xa(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("uipath-dev-theme",e)}xa(va());const ya=Jt(e=>({theme:va(),toggleTheme:()=>e(t=>{const s=t.theme==="dark"?"light":"dark";return xa(s),{theme:s}})}));function kn(){const{theme:e,toggleTheme:t}=ya(),{enabled:s,status:r,environment:i,tenants:o,uipathUrl:a,setEnvironment:l,startLogin:h,selectTenant:c,logout:u}=da(),{projectName:d,projectVersion:_,projectAuthors:g}=ua(),[m,x]=v.useState(!1),[w,E]=v.useState(""),k=v.useRef(null),P=v.useRef(null);v.useEffect(()=>{if(!m)return;const f=b=>{k.current&&!k.current.contains(b.target)&&P.current&&!P.current.contains(b.target)&&x(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[m]);const A=r==="authenticated",D=r==="expired",N=r==="pending",$=r==="needs_tenant";let B="UiPath: Disconnected",T=null,O=!0;A?(B=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""}`,T="var(--success)",O=!1):D?(B=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""} (expired)`,T="var(--error)",O=!1):N?B="UiPath: Signing in…":$&&(B="UiPath: Select Tenant");const L=()=>{N||(D?h():x(f=>!f))},R="flex items-center gap-1 px-1.5 rounded transition-colors",p={onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="",f.currentTarget.style.color="var(--text-muted)"}};return n.jsxs("div",{className:"h-6 flex items-center justify-end gap-3 px-2 text-xs border-t shrink-0",style:{background:"var(--bg-secondary)",color:"var(--text-muted)",borderColor:"var(--border)",fontSize:"11px"},children:[s&&n.jsxs("div",{className:"relative flex items-center",children:[n.jsxs("div",{ref:P,className:`${R} cursor-pointer`,onClick:L,...p,title:A?a??"":D?"Token expired — click to re-authenticate":N?"Signing in…":$?"Select a tenant":"Click to sign in",children:[N?n.jsxs("svg",{className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),n.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})]}):T?n.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:T}}):O?n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}):null,n.jsx("span",{className:"truncate max-w-[200px]",children:B})]}),m&&n.jsx("div",{ref:k,className:"absolute bottom-full right-0 mb-1 rounded border shadow-lg p-1 min-w-[180px]",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},children:A||D?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>{a&&window.open(a,"_blank","noopener,noreferrer"),x(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Go to Platform"]}),n.jsxs("button",{onClick:()=>{u(),x(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-hover)",f.currentTarget.style.color="var(--text-primary)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent",f.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]}):$?n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Tenant"}),n.jsxs("select",{value:w,onChange:f=>E(f.target.value),className:"w-full rounded px-1.5 py-1 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:[n.jsx("option",{value:"",children:"Select…"}),o.map(f=>n.jsx("option",{value:f,children:f},f))]}),n.jsx("button",{onClick:()=>{w&&(c(w),x(!1))},disabled:!w,className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--text-muted)"},children:"Confirm"})]}):n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Environment"}),n.jsxs("select",{value:i,onChange:f=>l(f.target.value),className:"w-full rounded px-1.5 py-0.5 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-muted)"},children:[n.jsx("option",{value:"cloud",children:"cloud"}),n.jsx("option",{value:"staging",children:"staging"}),n.jsx("option",{value:"alpha",children:"alpha"})]}),n.jsx("button",{onClick:()=>{h(),x(!1)},className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:f=>{f.currentTarget.style.color="var(--text-primary)",f.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:f=>{f.currentTarget.style.color="var(--text-muted)",f.currentTarget.style.borderColor="var(--border)"},children:"Sign In"})]})})]}),d&&n.jsxs("span",{className:R,children:["Project: ",d]}),_&&n.jsxs("span",{className:R,children:["Version: v",_]}),g&&n.jsxs("span",{className:R,children:["Author: ",g]}),n.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:`${R} cursor-pointer no-underline`,style:{color:"var(--text-muted)"},...p,title:"View on GitHub",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),n.jsx("span",{children:"uipath-dev-python"})]}),n.jsxs("div",{className:`${R} cursor-pointer`,onClick:t,...p,title:`Switch to ${e==="dark"?"light":"dark"} theme`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e==="dark"?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),n.jsx("span",{children:e==="dark"?"Dark":"Light"})]})]})}function Zc(){const{navigate:e}=et(),t=de(c=>c.entrypoints),[s,r]=v.useState(""),[i,o]=v.useState(!0),[a,l]=v.useState(null);v.useEffect(()=>{!s&&t.length>0&&r(t[0])},[t,s]),v.useEffect(()=>{s&&(o(!0),l(null),bc(s).then(c=>{var d;const u=(d=c.input)==null?void 0:d.properties;o(!!(u!=null&&u.messages))}).catch(c=>{const u=c.detail||{};l(u.error||u.message||`Failed to load entrypoint "${s}"`)}))},[s]);const h=c=>{s&&e(`#/setup/${encodeURIComponent(s)}/${c}`)};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),t.length>1&&n.jsxs("div",{className:"mb-8",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Entrypoint"}),n.jsx("select",{id:"entrypoint-select",value:s,onChange:c=>r(c.target.value),className:"w-full rounded-md px-3 py-2 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:t.map(c=>n.jsx("option",{value:c,children:c},c))})]}),a?n.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),n.jsx("div",{className:"overflow-auto max-h-48 p-3",children:n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(En,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:n.jsx(Qc,{}),color:"var(--success)",onClick:()=>h("run"),disabled:!s}),n.jsx(En,{title:"Conversational",description:i?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:n.jsx(eh,{}),color:"var(--accent)",onClick:()=>h("chat"),disabled:!s||!i})]})]})})}function En({title:e,description:t,icon:s,color:r,onClick:i,disabled:o}){return n.jsxs("button",{onClick:i,disabled:o,className:"group flex flex-col items-center text-center p-6 rounded-md border transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{o||(a.currentTarget.style.borderColor=r,a.currentTarget.style.background=`color-mix(in srgb, ${r} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[n.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${r} 10%, var(--bg-primary))`,color:r},children:s}),n.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:e}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:t})]})}function Qc(){return n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function eh(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),n.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),n.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),n.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),n.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),n.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),n.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const th="modulepreload",sh=function(e){return"/"+e},Nn={},ba=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){let a=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(s.map(c=>{if(c=sh(c),c in Nn)return;Nn[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const _=document.createElement("link");if(_.rel=u?"stylesheet":th,u||(_.as="script"),_.crossOrigin="",_.href=c,h&&_.setAttribute("nonce",h),document.head.appendChild(_),u)return new Promise((g,m)=>{_.addEventListener("load",g),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},rh=80,ih=32,nh=13;function jn(e){const t=(e==null?void 0:e.label)??"";return Math.max(rh,t.length*8+32)}function Mn(e,t){let s=ih;(t==="modelNode"||t==="toolNode")&&(s+=nh);const r=e==null?void 0:e.tool_names;return r&&r.length>0&&(s+=Math.min(r.length,3)*12+(r.length>3?12:0)+4),e!=null&&e.model_name&&(s+=14),s}let Wr=null;async function oh(){if(!Wr){const{default:e}=await ba(async()=>{const{default:t}=await import("./vendor-elk-BkmlSRbk.js").then(s=>s.e);return{default:t}},__vite__mapDeps([0,1]));Wr=new e}return Wr}const Ln={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},ah="[top=35,left=15,bottom=15,right=15]";function lh(e){const t=[],s=[];for(const r of e.nodes){const i=r.data,o={id:r.id,width:jn(i),height:Mn(i,r.type)};if(r.data.subgraph){const a=r.data.subgraph;delete o.width,delete o.height,o.layoutOptions={...Ln,"elk.padding":ah},o.children=a.nodes.map(l=>({id:`${r.id}/${l.id}`,width:jn(l.data),height:Mn(l.data,l.type)})),o.edges=a.edges.map(l=>({id:`${r.id}/${l.id}`,sources:[`${r.id}/${l.source}`],targets:[`${r.id}/${l.target}`]}))}t.push(o)}for(const r of e.edges)s.push({id:r.id,sources:[r.source],targets:[r.target]});return{id:"root",layoutOptions:Ln,children:t,edges:s}}const Os={type:cc.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function qi(e){return{stroke:"var(--node-border)",strokeWidth:1.5,...e?{strokeDasharray:"6 3"}:{}}}function Tn(e,t,s,r,i){var c;const o=(c=e.sections)==null?void 0:c[0],a=(i==null?void 0:i.x)??0,l=(i==null?void 0:i.y)??0;let h;if(o)h={sourcePoint:{x:o.startPoint.x+a,y:o.startPoint.y+l},targetPoint:{x:o.endPoint.x+a,y:o.endPoint.y+l},bendPoints:(o.bendPoints??[]).map(u=>({x:u.x+a,y:u.y+l}))};else{const u=t.get(e.sources[0]),d=t.get(e.targets[0]);u&&d&&(h={sourcePoint:{x:u.x+u.width/2,y:u.y+u.height},targetPoint:{x:d.x+d.width/2,y:d.y},bendPoints:[]})}return{id:e.id,source:e.sources[0],target:e.targets[0],type:"elk",data:h,style:qi(r),markerEnd:Os,...s?{label:s,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function Sa(e){var h,c;const t=lh(e),r=await(await oh()).layout(t),i=new Map;for(const u of e.nodes)if(i.set(u.id,{type:u.type,data:u.data}),u.data.subgraph)for(const d of u.data.subgraph.nodes)i.set(`${u.id}/${d.id}`,{type:d.type,data:d.data});const o=[],a=[],l=new Map;for(const u of r.children??[]){const d=u.x??0,_=u.y??0;l.set(u.id,{x:d,y:_,width:u.width??0,height:u.height??0});for(const g of u.children??[])l.set(g.id,{x:d+(g.x??0),y:_+(g.y??0),width:g.width??0,height:g.height??0})}for(const u of r.children??[]){const d=i.get(u.id);if((((h=u.children)==null?void 0:h.length)??0)>0){o.push({id:u.id,type:"groupNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width,nodeHeight:u.height},position:{x:u.x??0,y:u.y??0},style:{width:u.width,height:u.height}});for(const x of u.children??[]){const w=i.get(x.id);o.push({id:x.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:x.width},position:{x:x.x??0,y:x.y??0},parentNode:u.id,extent:"parent"})}const g=u.x??0,m=u.y??0;for(const x of u.edges??[]){const w=e.nodes.find(k=>k.id===u.id),E=(c=w==null?void 0:w.data.subgraph)==null?void 0:c.edges.find(k=>`${u.id}/${k.id}`===x.id);a.push(Tn(x,l,E==null?void 0:E.label,E==null?void 0:E.conditional,{x:g,y:m}))}}else o.push({id:u.id,type:(d==null?void 0:d.type)??"defaultNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width},position:{x:u.x??0,y:u.y??0}})}for(const u of r.edges??[]){const d=e.edges.find(_=>_.id===u.id);a.push(Tn(u,l,d==null?void 0:d.label,d==null?void 0:d.conditional))}return{nodes:o,edges:a}}const ch={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function wa({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"Start",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),r,n.jsx(Lt,{type:"source",position:Tt.Bottom,style:ch})]})}const hh={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ca({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"End",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:hh}),r]})}const Rn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function ka({data:e}){const t=e.status,s=e.nodeWidth,r=e.model_name,i=e.label??"Model",o=e.hasBreakpoint,a=e.isPausedHere,l=e.isActiveNode,h=e.isExecutingNode,c=a?"var(--error)":h?"var(--success)":l?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",u=a?"var(--error)":h?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${c}`,boxShadow:a||l||h?`0 0 4px ${u}`:void 0,animation:a||l||h?`node-pulse-${a?"red":h?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r?`${i} -${r}`:i,children:[o&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Rn}),n.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),r&&n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:r,children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Rn})]})}const Bn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},dh=3;function Ea({data:e}){const t=e.status,s=e.nodeWidth,r=e.tool_names,i=e.tool_count,o=e.label??"Tool",a=e.hasBreakpoint,l=e.isPausedHere,h=e.isActiveNode,c=e.isExecutingNode,u=l?"var(--error)":c?"var(--success)":h?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",d=l?"var(--error)":c?"var(--success)":"var(--accent)",_=(r==null?void 0:r.slice(0,dh))??[],g=(i??(r==null?void 0:r.length)??0)-_.length;return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${u}`,boxShadow:l||h||c?`0 0 4px ${d}`:void 0,animation:l||h||c?`node-pulse-${l?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r!=null&&r.length?`${o} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-elk-BkmlSRbk.js","assets/vendor-react-VzyiTEsu.js","assets/ChatPanel-CvZbTGws.js","assets/vendor-reactflow-B_2yZyR4.js","assets/vendor-reactflow-B5DZHykP.css"])))=>i.map(i=>d[i]); +var sc=Object.defineProperty;var rc=(e,t,s)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Ut=(e,t,s)=>rc(e,typeof t!="symbol"?t+"":t,s);import{W as Zs,a as v,j as n,g as ic,b as nc,w as oc,F as ac,d as lc}from"./vendor-react-VzyiTEsu.js";import{M as cc,H as Lt,P as Tt,B as hc,u as na,a as oa,R as aa,b as la,C as ca,c as dc,d as ha}from"./vendor-reactflow-B_2yZyR4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function s(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=s(i);fetch(i.href,o)}})();const yn=e=>{let t;const s=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const _=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),s.forEach(g=>g(t,_))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>h,subscribe:c=>(s.add(c),()=>s.delete(c))},h=t=e(r,i,l);return l},uc=(e=>e?yn(e):yn),fc=e=>e;function pc(e,t=fc){const s=Zs.useSyncExternalStore(e.subscribe,Zs.useCallback(()=>t(e.getState()),[e,t]),Zs.useCallback(()=>t(e.getInitialState()),[e,t]));return Zs.useDebugValue(s),s}const bn=e=>{const t=uc(e),s=r=>pc(t,r);return Object.assign(s,t),s},Jt=(e=>e?bn(e):bn),de=Jt(e=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:t=>e(s=>{var o;let r=s.breakpoints;for(const a of t)(o=a.breakpoints)!=null&&o.length&&!r[a.id]&&(r={...r,[a.id]:Object.fromEntries(a.breakpoints.map(l=>[l,!0]))});const i={runs:Object.fromEntries(t.map(a=>[a.id,a]))};return r!==s.breakpoints&&(i.breakpoints=r),i}),upsertRun:t=>e(s=>{var i;const r={runs:{...s.runs,[t.id]:t}};if((i=t.breakpoints)!=null&&i.length&&!s.breakpoints[t.id]&&(r.breakpoints={...s.breakpoints,[t.id]:Object.fromEntries(t.breakpoints.map(o=>[o,!0]))}),(t.status==="completed"||t.status==="failed")&&s.activeNodes[t.id]){const{[t.id]:o,...a}=s.activeNodes;r.activeNodes=a}if(t.status!=="suspended"&&s.activeInterrupt[t.id]){const{[t.id]:o,...a}=s.activeInterrupt;r.activeInterrupt=a}return r}),selectRun:t=>e({selectedRunId:t}),addTrace:t=>e(s=>{const r=s.traces[t.run_id]??[],i=r.findIndex(a=>a.span_id===t.span_id),o=i>=0?r.map((a,l)=>l===i?t:a):[...r,t];return{traces:{...s.traces,[t.run_id]:o}}}),setTraces:(t,s)=>e(r=>({traces:{...r.traces,[t]:s}})),addLog:t=>e(s=>{const r=s.logs[t.run_id]??[];return{logs:{...s.logs,[t.run_id]:[...r,t]}}}),setLogs:(t,s)=>e(r=>({logs:{...r.logs,[t]:s}})),addChatEvent:(t,s)=>e(r=>{const i=r.chatMessages[t]??[],o=s.message;if(!o)return r;const a=o.messageId??o.message_id,l=o.role??"assistant",u=(o.contentParts??o.content_parts??[]).filter(x=>{const w=x.mimeType??x.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(x=>{const w=x.data;return(w==null?void 0:w.inline)??""}).join(` +`).trim(),d=(o.toolCalls??o.tool_calls??[]).map(x=>({name:x.name??"",has_result:!!x.result})),_={message_id:a,role:l,content:u,tool_calls:d.length>0?d:void 0},g=i.findIndex(x=>x.message_id===a);if(g>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((x,w)=>w===g?_:x)}};if(l==="user"){const x=i.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===u);if(x>=0)return{chatMessages:{...r.chatMessages,[t]:i.map((w,E)=>E===x?_:w)}}}const m=[...i,_];return{chatMessages:{...r.chatMessages,[t]:m}}}),addLocalChatMessage:(t,s)=>e(r=>{const i=r.chatMessages[t]??[];return{chatMessages:{...r.chatMessages,[t]:[...i,s]}}}),setChatMessages:(t,s)=>e(r=>({chatMessages:{...r.chatMessages,[t]:s}})),setEntrypoints:t=>e({entrypoints:t}),breakpoints:{},toggleBreakpoint:(t,s)=>e(r=>{const i={...r.breakpoints[t]??{}};return i[s]?delete i[s]:i[s]=!0,{breakpoints:{...r.breakpoints,[t]:i}}}),clearBreakpoints:t=>e(s=>{const{[t]:r,...i}=s.breakpoints;return{breakpoints:i}}),activeNodes:{},setActiveNode:(t,s,r)=>e(i=>{const o=i.activeNodes[t]??{executing:{},prev:null};return{activeNodes:{...i.activeNodes,[t]:{executing:{...o.executing,[s]:r??null},prev:o.prev}}}}),removeActiveNode:(t,s)=>e(r=>{const i=r.activeNodes[t];if(!i)return r;const{[s]:o,...a}=i.executing;return{activeNodes:{...r.activeNodes,[t]:{executing:a,prev:s}}}}),resetRunGraphState:t=>e(s=>({stateEvents:{...s.stateEvents,[t]:[]},activeNodes:{...s.activeNodes,[t]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(t,s,r,i,o)=>e(a=>{const l=a.stateEvents[t]??[];return{stateEvents:{...a.stateEvents,[t]:[...l,{node_name:s,qualified_node_name:i,phase:o,timestamp:Date.now(),payload:r}]}}}),setStateEvents:(t,s)=>e(r=>({stateEvents:{...r.stateEvents,[t]:s}})),focusedSpan:null,setFocusedSpan:t=>e({focusedSpan:t}),activeInterrupt:{},setActiveInterrupt:(t,s)=>e(r=>({activeInterrupt:{...r.activeInterrupt,[t]:s}})),reloadPending:!1,setReloadPending:t=>e({reloadPending:t}),graphCache:{},setGraphCache:(t,s)=>e(r=>({graphCache:{...r.graphCache,[t]:s}}))})),Sr="/api";async function _c(e){const t=await fetch(`${Sr}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({environment:e})});if(!t.ok)throw new Error(`Login failed: ${t.status}`);return t.json()}async function Or(){const e=await fetch(`${Sr}/auth/status`);if(!e.ok)throw new Error(`Status check failed: ${e.status}`);return e.json()}async function gc(e){const t=await fetch(`${Sr}/auth/select-tenant`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tenant_name:e})});if(!t.ok)throw new Error(`Tenant selection failed: ${t.status}`);return t.json()}async function mc(){await fetch(`${Sr}/auth/logout`,{method:"POST"})}const da="uipath-env",vc=["cloud","staging","alpha"];function xc(){const e=localStorage.getItem(da);return vc.includes(e)?e:"cloud"}const ua=Jt((e,t)=>({enabled:!0,status:"unauthenticated",environment:xc(),tenants:[],uipathUrl:null,pollTimer:null,expiryTimer:null,init:async()=>{try{const s=await fetch("/api/config");if(s.ok&&!(await s.json()).auth_enabled){e({enabled:!1});return}const r=await Or();e({status:r.status,tenants:r.tenants??[],uipathUrl:r.uipath_url??null}),r.status==="authenticated"&&t().startExpiryCheck()}catch(s){console.error("Auth init failed",s)}},setEnvironment:s=>{localStorage.setItem(da,s),e({environment:s})},startLogin:async()=>{const{environment:s}=t();try{const r=await _c(s);e({status:"pending"}),window.open(r.auth_url,"_blank"),t().pollStatus()}catch(r){console.error("Login failed",r)}},pollStatus:()=>{const{pollTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{const i=await Or();i.status!=="pending"&&(t().stopPolling(),e({status:i.status,tenants:i.tenants??[],uipathUrl:i.uipath_url??null}),i.status==="authenticated"&&t().startExpiryCheck())}catch{}},2e3);e({pollTimer:r})},stopPolling:()=>{const{pollTimer:s}=t();s&&(clearInterval(s),e({pollTimer:null}))},startExpiryCheck:()=>{const{expiryTimer:s}=t();if(s)return;const r=setInterval(async()=>{try{(await Or()).status==="expired"&&(t().stopExpiryCheck(),e({status:"expired"}))}catch{}},3e4);e({expiryTimer:r})},stopExpiryCheck:()=>{const{expiryTimer:s}=t();s&&(clearInterval(s),e({expiryTimer:null}))},selectTenant:async s=>{try{const r=await gc(s);e({status:"authenticated",uipathUrl:r.uipath_url,tenants:[]}),t().startExpiryCheck()}catch(r){console.error("Tenant selection failed",r)}},logout:async()=>{t().stopPolling(),t().stopExpiryCheck();try{await mc()}catch{}e({status:"unauthenticated",tenants:[],uipathUrl:null})}})),fa=Jt(e=>({projectName:null,projectVersion:null,projectAuthors:null,init:async()=>{try{const t=await fetch("/api/config");if(t.ok){const s=await t.json();e({projectName:s.project_name??null,projectVersion:s.project_version??null,projectAuthors:s.project_authors??null})}}catch{}}}));class yc{constructor(t){Ut(this,"ws",null);Ut(this,"url");Ut(this,"handlers",new Set);Ut(this,"reconnectTimer",null);Ut(this,"shouldReconnect",!0);Ut(this,"pendingMessages",[]);Ut(this,"activeSubscriptions",new Set);const s=window.location.protocol==="https:"?"wss:":"ws:";this.url=t??`${s}//${window.location.host}/ws`}connect(){var t;((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const s of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:s}}));for(const s of this.pendingMessages)this.sendRaw(s);this.pendingMessages=[]},this.ws.onmessage=s=>{let r;try{r=JSON.parse(s.data)}catch{console.warn("[ws] failed to parse message",s.data);return}this.handlers.forEach(i=>{try{i(r)}catch(o){console.error("[ws] handler error",o)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var s;(s=this.ws)==null||s.close()})}disconnect(){var t;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(t=this.ws)==null||t.close(),this.ws=null}onMessage(t){return this.handlers.add(t),()=>this.handlers.delete(t)}sendRaw(t){var s;((s=this.ws)==null?void 0:s.readyState)===WebSocket.OPEN&&this.ws.send(t)}send(t,s){var i;const r=JSON.stringify({type:t,payload:s});((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN?this.ws.send(r):this.pendingMessages.push(r)}subscribe(t){this.activeSubscriptions.add(t),this.send("subscribe",{run_id:t})}unsubscribe(t){this.activeSubscriptions.delete(t),this.send("unsubscribe",{run_id:t})}sendChatMessage(t,s){this.send("chat.message",{run_id:t,text:s})}sendInterruptResponse(t,s){this.send("chat.interrupt_response",{run_id:t,data:s})}debugStep(t){this.send("debug.step",{run_id:t})}debugContinue(t){this.send("debug.continue",{run_id:t})}debugStop(t){this.send("debug.stop",{run_id:t})}setBreakpoints(t,s){this.send("debug.set_breakpoints",{run_id:t,breakpoints:s})}sendCliAgentStart(t,s,r,i){this.send("cli_agent.start",{agent_id:t,session_id:s,cols:r,rows:i})}sendCliAgentInput(t,s){this.send("cli_agent.input",{session_id:t,data:s})}sendCliAgentResize(t,s,r){this.send("cli_agent.resize",{session_id:t,cols:s,rows:r})}sendCliAgentStop(t){this.send("cli_agent.stop",{session_id:t})}}const Zt="/api";async function Qt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function $i(){return Qt(`${Zt}/entrypoints`)}async function bc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/schema`)}async function Sc(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/mock-input`)}async function pa(e){return Qt(`${Zt}/entrypoints/${encodeURIComponent(e)}/graph`)}async function Sn(e,t,s="run",r=[]){return Qt(`${Zt}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:e,input_data:t,mode:s,breakpoints:r})})}async function wc(){return Qt(`${Zt}/runs`)}async function Ir(e){return Qt(`${Zt}/runs/${e}`)}async function Cc(){return Qt(`${Zt}/reload`,{method:"POST"})}const me=Jt(e=>({evaluators:[],localEvaluators:[],llmModels:[],evalSets:{},evalRuns:{},streamingResults:{},setEvaluators:t=>e({evaluators:t}),setLocalEvaluators:t=>e({localEvaluators:t}),setLlmModels:t=>e({llmModels:t}),addLocalEvaluator:t=>e(s=>({localEvaluators:[...s.localEvaluators,t]})),upsertLocalEvaluator:t=>e(s=>({localEvaluators:s.localEvaluators.some(r=>r.id===t.id)?s.localEvaluators.map(r=>r.id===t.id?t:r):[...s.localEvaluators,t]})),setEvalSets:t=>e({evalSets:Object.fromEntries(t.map(s=>[s.id,s]))}),addEvalSet:t=>e(s=>({evalSets:{...s.evalSets,[t.id]:t}})),updateEvalSetEvaluators:(t,s)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,evaluator_ids:s}}}:r}),incrementEvalSetCount:(t,s=1)=>e(r=>{const i=r.evalSets[t];return i?{evalSets:{...r.evalSets,[t]:{...i,eval_count:i.eval_count+s}}}:r}),setEvalRuns:t=>e({evalRuns:Object.fromEntries(t.map(s=>[s.id,s]))}),upsertEvalRun:t=>e(s=>({evalRuns:{...s.evalRuns,[t.id]:t}})),updateEvalRunProgress:(t,s,r,i)=>e(o=>{const a=o.evalRuns[t];if(!a)return o;const l={...o.streamingResults};return i&&(l[t]={...l[t],[i.name]:i}),{evalRuns:{...o.evalRuns,[t]:{...a,progress_completed:s,progress_total:r,status:"running"}},streamingResults:l}}),completeEvalRun:(t,s,r)=>e(i=>{const o=i.evalRuns[t];if(!o)return i;const a={...i.streamingResults};return delete a[t],{evalRuns:{...i.evalRuns,[t]:{...o,status:"completed",overall_score:s,evaluator_scores:r,end_time:new Date().toISOString()}},streamingResults:a}})})),Ms=Jt(e=>({availableAgents:[],selectedAgentId:null,sessionId:null,status:"idle",exitCode:null,events:[],setAvailableAgents:t=>{e(s=>{const r={availableAgents:t};if(!s.selectedAgentId){const i=t.find(o=>o.installed);i&&(r.selectedAgentId=i.id)}return r})},setSelectedAgentId:t=>e({selectedAgentId:t}),setSessionId:t=>e({sessionId:t}),setStatus:t=>e({status:t}),setExitCode:t=>e({exitCode:t}),addEvent:t=>e(s=>({events:[...s.events,t]}))})),ye=Jt(e=>({children:{},expanded:{},selectedFile:null,openTabs:[],fileCache:{},dirty:{},buffers:{},loadingDirs:{},loadingFile:!1,agentChangedFiles:{},diffView:null,setChildren:(t,s)=>e(r=>({children:{...r.children,[t]:s}})),toggleExpanded:t=>e(s=>({expanded:{...s.expanded,[t]:!s.expanded[t]}})),setSelectedFile:t=>e({selectedFile:t}),openTab:t=>e(s=>({selectedFile:t,openTabs:s.openTabs.includes(t)?s.openTabs:[...s.openTabs,t]})),closeTab:t=>e(s=>{const r=s.openTabs.filter(c=>c!==t);let i=s.selectedFile;if(i===t){const c=s.openTabs.indexOf(t);i=r[Math.min(c,r.length-1)]??null}const{[t]:o,...a}=s.dirty,{[t]:l,...h}=s.buffers;return{openTabs:r,selectedFile:i,dirty:a,buffers:h}}),setFileContent:(t,s)=>e(r=>({fileCache:{...r.fileCache,[t]:s}})),updateBuffer:(t,s)=>e(r=>({buffers:{...r.buffers,[t]:s},dirty:{...r.dirty,[t]:!0}})),markClean:t=>e(s=>{const{[t]:r,...i}=s.dirty,{[t]:o,...a}=s.buffers;return{dirty:i,buffers:a}}),setLoadingDir:(t,s)=>e(r=>({loadingDirs:{...r.loadingDirs,[t]:s}})),setLoadingFile:t=>e({loadingFile:t}),markAgentChanged:t=>e(s=>({agentChangedFiles:{...s.agentChangedFiles,[t]:Date.now()}})),clearAgentChanged:t=>e(s=>{const{[t]:r,...i}=s.agentChangedFiles;return{agentChangedFiles:i}}),setDiffView:t=>e({diffView:t}),expandPath:t=>e(s=>{const r=t.split("/"),i={...s.expanded};for(let o=1;oe.current.onMessage(x=>{switch(x.type){case"run.updated":{const w=x.payload;t(w),(w.status==="running"||w.status==="completed"||w.status==="failed")&&Ms.getState().addEvent({type:"run_lifecycle",timestamp:Date.now(),runId:w.id,entrypoint:w.entrypoint,status:w.status});break}case"trace":s(x.payload);break;case"log":r(x.payload);break;case"chat":{const w=x.payload.run_id;i(w,x.payload);break}case"chat.interrupt":{const w=x.payload.run_id;o(w,x.payload);break}case"state":{const w=x.payload.run_id,E=x.payload.node_name,k=x.payload.qualified_node_name??null,P=x.payload.phase??null,O=x.payload.payload;E==="__start__"&&P==="started"&&h(w),P==="started"?a(w,E,k):P==="completed"&&l(w,E),c(w,E,O,k,P);break}case"reload":{x.payload.reloaded?$i().then(E=>{const k=de.getState();k.setEntrypoints(E.map(P=>P.name)),k.setReloadPending(!1)}).catch(E=>console.error("Failed to refresh entrypoints:",E)):de.getState().setReloadPending(!0);break}case"files.changed":{const w=x.payload.files,E=new Set(w),k=ye.getState(),P=w.filter(D=>D in k.children?!1:(D.split("/").pop()??"").includes("."));P.length>0&&Ms.getState().addEvent({type:"files_changed",timestamp:Date.now(),files:P});for(const D of k.openTabs)k.dirty[D]||!E.has(D)||_a(D).then(j=>{var R;const F=ye.getState();F.dirty[D]||((R=F.fileCache[D])==null?void 0:R.content)!==j.content&&F.setFileContent(D,j)}).catch(()=>{});const O=new Set;for(const D of w){const j=D.lastIndexOf("/"),F=j===-1?"":D.substring(0,j);F in k.children&&O.add(F)}for(const D of O)Ki(D).then(j=>ye.getState().setChildren(D,j)).catch(()=>{});break}case"eval_run.created":u(x.payload);break;case"eval_run.progress":{const{run_id:w,completed:E,total:k,item_result:P}=x.payload;d(w,E,k,P);break}case"eval_run.completed":{const{run_id:w,overall_score:E,evaluator_scores:k}=x.payload;_(w,E,k);break}case"cli_agent.output":{const{session_id:w,data:E}=x.payload,k=Nc(w);if(k){const P=Uint8Array.from(atob(E),O=>O.charCodeAt(0));k(P)}break}case"cli_agent.exit":{const{session_id:w,exit_code:E}=x.payload,k=Ms.getState();if(k.sessionId===w){k.setStatus("exited"),k.setExitCode(E);const P=k.availableAgents.find(O=>O.id===k.selectedAgentId);k.addEvent({type:"session",timestamp:Date.now(),agentName:(P==null?void 0:P.name)??"Unknown",action:"exited",exitCode:E})}break}case"mcp.tool_call":{const{tool:w,args:E}=x.payload;Ms.getState().addEvent({type:"mcp_tool_call",timestamp:Date.now(),tool:w,args:E});break}}}),[t,s,r,i,o,a,l,h,c,u,d,_]),e.current}function Lc(e){const t=e.replace(/^#\/?/,""),s={section:"debug",view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null,evalCreating:!1,evalSetId:null,evalRunId:null,evalRunItemName:null,evaluatorId:null,evaluatorCreateType:null,evaluatorFilter:null,explorerFile:null};if(!t||t==="new"||t==="debug"||t==="debug/new")return s;const r=t.match(/^(?:debug\/)?setup\/([^/]+)\/(run|chat)$/);if(r)return{...s,view:"setup",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const i=t.match(/^(?:debug\/)?runs\/([^/]+)(?:\/(traces|output))?$/);if(i)return{...s,view:"details",runId:i[1],tab:i[2]??"traces"};if(t==="evals/new")return{...s,section:"evals",evalCreating:!0};const o=t.match(/^evals\/runs\/([^/]+?)(?:\/([^/]+))?$/);if(o)return{...s,section:"evals",evalRunId:o[1],evalRunItemName:o[2]?decodeURIComponent(o[2]):null};const a=t.match(/^evals\/sets\/([^/]+)$/);if(a)return{...s,section:"evals",evalSetId:a[1]};if(t==="evals")return{...s,section:"evals"};const l=t.match(/^evaluators\/new(?:\/(deterministic|llm|tool))?$/);if(l)return{...s,section:"evaluators",evaluatorCreateType:l[1]??"any"};const h=t.match(/^evaluators\/category\/(deterministic|llm|tool)$/);if(h)return{...s,section:"evaluators",evaluatorFilter:h[1]};const c=t.match(/^evaluators\/([^/]+)$/);if(c)return{...s,section:"evaluators",evaluatorId:c[1]};if(t==="evaluators")return{...s,section:"evaluators"};if(t==="explorer/canvas")return{...s,section:"explorer",explorerFile:"__canvas__"};const u=t.match(/^explorer\/statedb\/(.+)$/);if(u)return{...s,section:"explorer",explorerFile:`__statedb__:${decodeURIComponent(u[1])}`};const d=t.match(/^explorer\/file\/(.+)$/);return d?{...s,section:"explorer",explorerFile:decodeURIComponent(d[1])}:t==="explorer"?{...s,section:"explorer"}:s}function Tc(){return window.location.hash}function Rc(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function et(){const e=v.useSyncExternalStore(Rc,Tc),t=Lc(e),s=v.useCallback(r=>{window.location.hash=r},[]);return{...t,navigate:s}}const wn="(max-width: 767px)";function Bc(){const[e,t]=v.useState(()=>window.matchMedia(wn).matches);return v.useEffect(()=>{const s=window.matchMedia(wn),r=i=>t(i.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),e}const Dc=[{section:"debug",label:"Developer Console",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"8",y:"6",width:"8",height:"14",rx:"4"}),n.jsx("path",{d:"M6 10H4"}),n.jsx("path",{d:"M6 18H4"}),n.jsx("path",{d:"M18 10h2"}),n.jsx("path",{d:"M18 18h2"}),n.jsx("path",{d:"M8 14h8"}),n.jsx("path",{d:"M9 6l-1.5-2"}),n.jsx("path",{d:"M15 6l1.5-2"}),n.jsx("path",{d:"M6 14H4"}),n.jsx("path",{d:"M18 14h2"})]})},{section:"evals",label:"Evals",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.5L5 20a1 1 0 0 0 .9 1.4h12.2a1 1 0 0 0 .9-1.4L14 9.5V3"}),n.jsx("path",{d:"M8.5 14h7"})]})},{section:"evaluators",label:"Evaluators",icon:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2l7 4v5c0 5.25-3.5 9.74-7 11-3.5-1.26-7-5.75-7-11V6l7-4z"}),n.jsx("path",{d:"M9 12l2 2 4-4"})]})},{section:"explorer",label:"Explorer",icon:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",children:n.jsx("path",{d:"M7.5 22.5H17.595C17.07 23.4 16.11 24 15 24H7.5C4.185 24 1.5 21.315 1.5 18V6C1.5 4.89 2.1 3.93 3 3.405V18C3 20.475 5.025 22.5 7.5 22.5ZM21 8.121V18C21 19.6545 19.6545 21 18 21H7.5C5.8455 21 4.5 19.6545 4.5 18V3C4.5 1.3455 5.8455 0 7.5 0H12.879C13.4715 0 14.0505 0.24 14.4705 0.6585L20.3415 6.5295C20.766 6.954 21 7.5195 21 8.121ZM13.5 6.75C13.5 7.164 13.8375 7.5 14.25 7.5H19.1895L13.5 1.8105V6.75ZM19.5 18V9H14.25C13.0095 9 12 7.9905 12 6.75V1.5H7.5C6.672 1.5 6 2.1735 6 3V18C6 18.8265 6.672 19.5 7.5 19.5H18C18.828 19.5 19.5 18.8265 19.5 18Z"})})}];function Pc({section:e,onSectionChange:t}){return n.jsx("div",{className:"w-12 flex flex-col items-center shrink-0 border-r",style:{background:"var(--activity-bar-bg)",borderColor:"var(--border)"},children:n.jsx("div",{className:"flex flex-col items-center gap-1 pt-2",children:Dc.map(s=>{const r=e===s.section;return n.jsxs("button",{onClick:()=>t(s.section),className:"w-10 h-10 flex items-center justify-center rounded cursor-pointer transition-colors relative",style:{color:r?"var(--text-primary)":"var(--text-muted)",background:r?"var(--bg-hover)":"transparent",border:"none"},title:s.label,onMouseEnter:i=>{r||(i.currentTarget.style.color="var(--text-secondary)")},onMouseLeave:i=>{r||(i.currentTarget.style.color="var(--text-muted)")},children:[r&&n.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r",style:{background:"var(--accent)"}}),s.icon]},s.section)})})})}const it="/api";async function nt(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Ac(){return nt(`${it}/evaluators`)}async function Vi(){return nt(`${it}/llm-models`)}async function ga(){return nt(`${it}/eval-sets`)}async function Oc(e){return nt(`${it}/eval-sets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Ic(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/items`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function Wc(e,t){await nt(`${it}/eval-sets/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Hc(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}`)}async function $c(e){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/runs`,{method:"POST"})}async function Fc(){return nt(`${it}/eval-runs`)}async function Cn(e){return nt(`${it}/eval-runs/${encodeURIComponent(e)}`)}async function qi(){return nt(`${it}/local-evaluators`)}async function zc(e){return nt(`${it}/local-evaluators`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Uc(e,t){return nt(`${it}/eval-sets/${encodeURIComponent(e)}/evaluators`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({evaluator_refs:t})})}async function Kc(e,t){return nt(`${it}/local-evaluators/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}const Vc={"uipath-exact-match":e=>({expectedOutput:e}),"uipath-json-similarity":e=>({expectedOutput:e}),"uipath-contains":()=>({searchText:""}),"uipath-llm-judge-output-semantic-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-output-strict-json-similarity":e=>({expectedOutput:e}),"uipath-llm-judge-trajectory-similarity":()=>({expectedAgentBehavior:""}),"uipath-llm-judge-trajectory-simulation":()=>({expectedAgentBehavior:""}),"uipath-tool-call-count":()=>({}),"uipath-tool-call-args":()=>({}),"uipath-tool-call-order":()=>({}),"uipath-tool-call-output":()=>({})};function qc(e,t){if(!e)return{};const s=Vc[e.evaluator_type_id];return s?s(t):e.type==="tool"?{}:e.evaluator_type_id.includes("trajectory")?{expectedAgentBehavior:""}:{expectedOutput:t}}function ma(e){return e?e.type==="tool"?!0:e.evaluator_type_id.includes("tool-call"):!1}function Xc(e){return e?ma(e)?{label:"tools",color:"var(--warning, #e5a00d)"}:e.evaluator_type_id.includes("trajectory")?{label:"quality",color:"var(--info, #3b82f6)"}:{label:"output",color:"var(--success, #22c55e)"}:{label:"output",color:"var(--success, #22c55e)"}}function Yc({run:e,onClose:t}){const s=me(T=>T.evalSets),r=me(T=>T.setEvalSets),i=me(T=>T.incrementEvalSetCount),o=me(T=>T.localEvaluators),a=me(T=>T.setLocalEvaluators),[l,h]=v.useState(`run-${e.id.slice(0,8)}`),[c,u]=v.useState(new Set),[d,_]=v.useState({}),g=v.useRef(new Set),[m,x]=v.useState(!1),[w,E]=v.useState(null),[k,P]=v.useState(!1),O=Object.values(s),D=v.useMemo(()=>Object.fromEntries(o.map(T=>[T.id,T])),[o]),j=v.useMemo(()=>{const T=new Set;for(const I of c){const L=s[I];L&&L.evaluator_ids.forEach(B=>T.add(B))}return[...T]},[c,s]);v.useEffect(()=>{const T=e.output_data,I=g.current;_(L=>{const B={};for(const f of j)if(I.has(f)&&L[f]!==void 0)B[f]=L[f];else{const p=D[f],b=qc(p,T);B[f]=JSON.stringify(b,null,2)}return B})},[j,D,e.output_data]),v.useEffect(()=>{const T=I=>{I.key==="Escape"&&t()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[t]),v.useEffect(()=>{O.length===0&&ga().then(r).catch(()=>{}),o.length===0&&qi().then(a).catch(()=>{})},[]);const F=T=>{u(I=>{const L=new Set(I);return L.has(T)?L.delete(T):L.add(T),L})},R=async()=>{var I;if(!l.trim()||c.size===0)return;E(null),x(!0);const T={};for(const L of j){const B=d[L];if(B!==void 0)try{T[L]=JSON.parse(B)}catch{E(`Invalid JSON for evaluator "${((I=D[L])==null?void 0:I.name)??L}"`),x(!1);return}}try{for(const L of c){const B=s[L],f=new Set((B==null?void 0:B.evaluator_ids)??[]),p={};for(const[b,y]of Object.entries(T))f.has(b)&&(p[b]=y);await Ic(L,{name:l.trim(),inputs:e.input_data,expected_output:null,evaluation_criterias:p}),i(L)}P(!0),setTimeout(t,3e3)}catch(L){E(L.detail||L.message||"Failed to add item")}finally{x(!1)}};return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:T=>{T.target===T.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg p-6 shadow-xl max-h-[85vh] flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"Add to Eval Set"})]}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:T=>{T.currentTarget.style.color="var(--text-primary)"},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-muted)"},"aria-label":"Close",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-4 pr-1",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Item Name"}),n.jsx("input",{type:"text",value:l,onChange:T=>h(T.target.value),className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Inputs"}),n.jsx("pre",{className:"rounded-md px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(e.input_data,null,2)})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Eval Sets"}),O.length===0?n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No eval sets found. Create one first."}):n.jsx("div",{className:"rounded-md border overflow-hidden max-h-40 overflow-y-auto",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:O.map(T=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:I=>{I.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:c.has(T.id),onChange:()=>F(T.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:T.name}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[T.eval_count," items"]})]},T.id))})]}),j.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluation Criteria"}),n.jsx("div",{className:"space-y-2",children:j.map(T=>{const I=D[T],L=ma(I),B=Xc(I);return n.jsxs("div",{className:"rounded-md",style:{border:"1px solid var(--border)",background:"var(--bg-primary)",opacity:L?.6:1},children:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:L?"none":"1px solid var(--border)"},children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",style:{color:"var(--text-primary)"},children:(I==null?void 0:I.name)??T}),n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{color:B.color,background:`color-mix(in srgb, ${B.color} 12%, transparent)`},children:B.label})]}),L?n.jsx("div",{className:"px-3 pb-2",children:n.jsx("span",{className:"text-[10px] italic",style:{color:"var(--text-muted)"},children:"Default criteria — uses evaluator config"})}):n.jsx("div",{className:"px-3 pb-2 pt-1",children:n.jsx("textarea",{value:d[T]??"{}",onChange:f=>{g.current.add(T),_(p=>({...p,[T]:f.target.value}))},rows:8,className:"w-full rounded px-2 py-1.5 text-xs font-mono resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"}})})]},T)})})]})]}),n.jsxs("div",{className:"mt-4 space-y-3",children:[w&&n.jsx("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:w}),k&&n.jsxs("p",{className:"text-xs px-3 py-2 rounded",style:{color:"var(--success)",background:"color-mix(in srgb, var(--success) 10%, var(--bg-secondary))"},children:["Added to ",c.size," eval set",c.size!==1?"s":"","."]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:t,className:"flex-1 py-2 rounded-md text-xs font-semibold cursor-pointer",style:{background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Cancel"}),n.jsx("button",{onClick:R,disabled:!l.trim()||c.size===0||m||k,className:"flex-1 py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:m?"Adding...":k?"Added":"Add Item"})]})]})]})})}const Gc={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function Jc({run:e,isSelected:t,onClick:s}){var d;const r=Gc[e.status]??"var(--text-muted)",i=((d=e.entrypoint.split("/").pop())==null?void 0:d.slice(0,16))??e.entrypoint,o=e.start_time?new Date(e.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",[a,l]=v.useState(!1),[h,c]=v.useState(!1),u=v.useRef(null);return v.useEffect(()=>{if(!a)return;const _=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[a]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"group relative w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:t?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:t?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:_=>{t||(_.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:_=>{t||(_.currentTarget.style.background="")},onClick:s,children:[n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:r}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs truncate",style:{color:t?"var(--text-primary)":"var(--text-secondary)"},children:i}),n.jsxs("div",{className:"text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[o,e.duration?` · ${e.duration}`:""]})]}),e.status==="completed"&&n.jsxs("div",{ref:u,className:"relative shrink-0",children:[n.jsx("button",{onClick:_=>{_.stopPropagation(),l(g=>!g)},className:"opacity-40 group-hover:opacity-100 focus:opacity-100 w-7 h-7 flex items-center justify-center rounded transition-opacity cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:_=>{_.currentTarget.style.color="var(--text-primary)",_.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:_=>{_.currentTarget.style.color="var(--text-muted)",_.currentTarget.style.background=""},"aria-label":"Actions",title:"Actions",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}),a&&n.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[140px] rounded-md shadow-lg py-1",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:n.jsx("button",{onClick:_=>{_.stopPropagation(),l(!1),c(!0)},className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{color:"var(--text-secondary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--bg-hover)",_.currentTarget.style.color="var(--text-primary)"},onMouseLeave:_=>{_.currentTarget.style.background="",_.currentTarget.style.color="var(--text-secondary)"},children:"Add to Eval Set"})})]})]}),h&&n.jsx(Yc,{run:e,onClose:()=>c(!1)})]})}function kn({runs:e,selectedRunId:t,onSelectRun:s,onNewRun:r}){const i=[...e].sort((o,a)=>new Date(a.start_time??0).getTime()-new Date(o.start_time??0).getTime());return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:r,className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Run"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(o=>n.jsx(Jc,{run:o,isSelected:o.id===t,onClick:()=>s(o.id)},o.id)),i.length===0&&n.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]})]})}function va(){const e=localStorage.getItem("uipath-dev-theme");return e==="light"||e==="dark"?e:"dark"}function xa(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("uipath-dev-theme",e)}xa(va());const ya=Jt(e=>({theme:va(),toggleTheme:()=>e(t=>{const s=t.theme==="dark"?"light":"dark";return xa(s),{theme:s}})}));function En(){const{theme:e,toggleTheme:t}=ya(),{enabled:s,status:r,environment:i,tenants:o,uipathUrl:a,setEnvironment:l,startLogin:h,selectTenant:c,logout:u}=ua(),{projectName:d,projectVersion:_,projectAuthors:g}=fa(),m=me(A=>A.llmModels),x=me(A=>A.setLlmModels),[w,E]=v.useState(!1),[k,P]=v.useState(!1),[O,D]=v.useState(!1),[j,F]=v.useState(""),R=v.useRef(null),T=v.useRef(null),I=v.useRef(null),L=v.useRef(null);v.useEffect(()=>{if(!w&&!k)return;const A=Z=>{w&&R.current&&!R.current.contains(Z.target)&&T.current&&!T.current.contains(Z.target)&&E(!1),k&&I.current&&!I.current.contains(Z.target)&&L.current&&!L.current.contains(Z.target)&&P(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[w,k]);const B=()=>{!k&&m.length===0&&(D(!0),Vi().then(x).finally(()=>D(!1))),P(A=>!A)},f=r==="authenticated",p=r==="expired",b=r==="pending",y=r==="needs_tenant";let N="UiPath: Disconnected",M=null,U=!0;f?(N=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""}`,M="var(--success)",U=!1):p?(N=`UiPath: ${a?a.replace(/^https?:\/\/[^/]+\//,""):""} (expired)`,M="var(--error)",U=!1):b?N="UiPath: Signing in…":y&&(N="UiPath: Select Tenant");const C=()=>{b||(p?h():E(A=>!A))},W="flex items-center gap-1 px-1.5 rounded transition-colors",z={onMouseEnter:A=>{A.currentTarget.style.background="var(--bg-hover)",A.currentTarget.style.color="var(--text-primary)"},onMouseLeave:A=>{A.currentTarget.style.background="",A.currentTarget.style.color="var(--text-muted)"}};return n.jsxs("div",{className:"h-6 flex items-center justify-end gap-3 px-2 text-xs border-t shrink-0",style:{background:"var(--bg-secondary)",color:"var(--text-muted)",borderColor:"var(--border)",fontSize:"11px"},children:[s&&n.jsxs("div",{className:"relative flex items-center",children:[n.jsxs("div",{ref:T,className:`${W} cursor-pointer`,onClick:C,...z,title:f?a??"":p?"Token expired — click to re-authenticate":b?"Signing in…":y?"Select a tenant":"Click to sign in",children:[b?n.jsxs("svg",{className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),n.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})]}):M?n.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:M}}):U?n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}):null,n.jsx("span",{className:"truncate max-w-[200px]",children:N})]}),w&&n.jsx("div",{ref:R,className:"absolute bottom-full right-0 mb-1 rounded border shadow-lg p-1 min-w-[180px]",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},children:f||p?n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>{a&&window.open(a,"_blank","noopener,noreferrer"),E(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:A=>{A.currentTarget.style.background="var(--bg-hover)",A.currentTarget.style.color="var(--text-primary)"},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Go to Platform"]}),n.jsxs("button",{onClick:()=>{u(),E(!1)},className:"w-full flex items-center gap-2 px-2 py-2 text-[11px] rounded cursor-pointer transition-colors text-left",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:A=>{A.currentTarget.style.background="var(--bg-hover)",A.currentTarget.style.color="var(--text-primary)"},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.currentTarget.style.color="var(--text-muted)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]}):y?n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Tenant"}),n.jsxs("select",{value:j,onChange:A=>F(A.target.value),className:"w-full rounded px-1.5 py-1 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:[n.jsx("option",{value:"",children:"Select…"}),o.map(A=>n.jsx("option",{value:A,children:A},A))]}),n.jsx("button",{onClick:()=>{j&&(c(j),E(!1))},disabled:!j,className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--text-muted)"},children:"Confirm"})]}):n.jsxs("div",{className:"p-1",children:[n.jsx("label",{className:"block text-[10px] font-medium mb-1",style:{color:"var(--text-muted)"},children:"Environment"}),n.jsxs("select",{value:i,onChange:A=>l(A.target.value),className:"w-full rounded px-1.5 py-0.5 text-[10px] mb-1.5 appearance-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-muted)"},children:[n.jsx("option",{value:"cloud",children:"cloud"}),n.jsx("option",{value:"staging",children:"staging"}),n.jsx("option",{value:"alpha",children:"alpha"})]}),n.jsx("button",{onClick:()=>{h(),E(!1)},className:"w-full px-2 py-1 text-[10px] font-medium rounded border border-[var(--border)] bg-transparent cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:A=>{A.currentTarget.style.color="var(--text-primary)",A.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:A=>{A.currentTarget.style.color="var(--text-muted)",A.currentTarget.style.borderColor="var(--border)"},children:"Sign In"})]})})]}),n.jsxs("div",{className:"relative flex items-center",children:[n.jsxs("div",{ref:L,className:`${W} cursor-pointer`,onClick:B,...z,title:"Available LLM models",children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),n.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1"}),n.jsx("path",{d:"M9 1v3"}),n.jsx("path",{d:"M15 1v3"}),n.jsx("path",{d:"M9 20v3"}),n.jsx("path",{d:"M15 20v3"}),n.jsx("path",{d:"M20 9h3"}),n.jsx("path",{d:"M20 14h3"}),n.jsx("path",{d:"M1 9h3"}),n.jsx("path",{d:"M1 14h3"})]}),n.jsxs("span",{children:["Models",m.length>0?` (${m.length})`:""]})]}),k&&n.jsxs("div",{ref:I,className:"absolute bottom-full left-0 mb-1 rounded border shadow-lg min-w-[220px] max-h-[320px] flex flex-col",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("div",{className:"px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wide border-b shrink-0",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:"LLM Models"}),n.jsxs("div",{className:"overflow-y-auto flex-1",children:[O&&m.length===0&&n.jsx("div",{className:"px-2 py-3 text-[11px] text-center",style:{color:"var(--text-muted)"},children:"Loading..."}),!O&&m.length===0&&n.jsx("div",{className:"px-2 py-3 text-[11px] text-center",style:{color:"var(--text-muted)"},children:"No models available"}),m.map(A=>n.jsxs("div",{className:"px-2 py-1.5 text-[11px] flex items-center gap-2 border-b",style:{borderColor:"var(--border)"},children:[n.jsx("span",{className:"font-mono truncate flex-1",style:{color:"var(--text-primary)"},title:A.model_name,children:A.model_name}),A.vendor&&n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:A.vendor})]},A.model_name))]})]})]}),d&&n.jsxs("span",{className:W,children:["Project: ",d]}),_&&n.jsxs("span",{className:W,children:["Version: v",_]}),g&&n.jsxs("span",{className:W,children:["Author: ",g]}),n.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:`${W} cursor-pointer no-underline`,style:{color:"var(--text-muted)"},...z,title:"View on GitHub",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),n.jsx("span",{children:"uipath-dev-python"})]}),n.jsxs("div",{className:`${W} cursor-pointer`,onClick:t,...z,title:`Switch to ${e==="dark"?"light":"dark"} theme`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e==="dark"?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),n.jsx("span",{children:e==="dark"?"Dark":"Light"})]})]})}function Zc(){const{navigate:e}=et(),t=de(c=>c.entrypoints),[s,r]=v.useState(""),[i,o]=v.useState(!0),[a,l]=v.useState(null);v.useEffect(()=>{!s&&t.length>0&&r(t[0])},[t,s]),v.useEffect(()=>{s&&(o(!0),l(null),bc(s).then(c=>{var d;const u=(d=c.input)==null?void 0:d.properties;o(!!(u!=null&&u.messages))}).catch(c=>{const u=c.detail||{};l(u.error||u.message||`Failed to load entrypoint "${s}"`)}))},[s]);const h=c=>{s&&e(`#/setup/${encodeURIComponent(s)}/${c}`)};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:t.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),t.length>1&&n.jsxs("div",{className:"mb-8",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Entrypoint"}),n.jsx("select",{id:"entrypoint-select",value:s,onChange:c=>r(c.target.value),className:"w-full rounded-md px-3 py-2 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:t.map(c=>n.jsx("option",{value:c,children:c},c))})]}),a?n.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:n.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),n.jsx("div",{className:"overflow-auto max-h-48 p-3",children:n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(Nn,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:n.jsx(Qc,{}),color:"var(--success)",onClick:()=>h("run"),disabled:!s}),n.jsx(Nn,{title:"Conversational",description:i?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:n.jsx(eh,{}),color:"var(--accent)",onClick:()=>h("chat"),disabled:!s||!i})]})]})})}function Nn({title:e,description:t,icon:s,color:r,onClick:i,disabled:o}){return n.jsxs("button",{onClick:i,disabled:o,className:"group flex flex-col items-center text-center p-6 rounded-md border transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{o||(a.currentTarget.style.borderColor=r,a.currentTarget.style.background=`color-mix(in srgb, ${r} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[n.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${r} 10%, var(--bg-primary))`,color:r},children:s}),n.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:e}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:t})]})}function Qc(){return n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function eh(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),n.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),n.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),n.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),n.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),n.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),n.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const th="modulepreload",sh=function(e){return"/"+e},jn={},ba=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){let a=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(s.map(c=>{if(c=sh(c),c in jn)return;jn[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const _=document.createElement("link");if(_.rel=u?"stylesheet":th,u||(_.as="script"),_.crossOrigin="",_.href=c,h&&_.setAttribute("nonce",h),document.head.appendChild(_),u)return new Promise((g,m)=>{_.addEventListener("load",g),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},rh=80,ih=32,nh=13;function Mn(e){const t=(e==null?void 0:e.label)??"";return Math.max(rh,t.length*8+32)}function Ln(e,t){let s=ih;(t==="modelNode"||t==="toolNode")&&(s+=nh);const r=e==null?void 0:e.tool_names;return r&&r.length>0&&(s+=Math.min(r.length,3)*12+(r.length>3?12:0)+4),e!=null&&e.model_name&&(s+=14),s}let Wr=null;async function oh(){if(!Wr){const{default:e}=await ba(async()=>{const{default:t}=await import("./vendor-elk-BkmlSRbk.js").then(s=>s.e);return{default:t}},__vite__mapDeps([0,1]));Wr=new e}return Wr}const Tn={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},ah="[top=35,left=15,bottom=15,right=15]";function lh(e){const t=[],s=[];for(const r of e.nodes){const i=r.data,o={id:r.id,width:Mn(i),height:Ln(i,r.type)};if(r.data.subgraph){const a=r.data.subgraph;delete o.width,delete o.height,o.layoutOptions={...Tn,"elk.padding":ah},o.children=a.nodes.map(l=>({id:`${r.id}/${l.id}`,width:Mn(l.data),height:Ln(l.data,l.type)})),o.edges=a.edges.map(l=>({id:`${r.id}/${l.id}`,sources:[`${r.id}/${l.source}`],targets:[`${r.id}/${l.target}`]}))}t.push(o)}for(const r of e.edges)s.push({id:r.id,sources:[r.source],targets:[r.target]});return{id:"root",layoutOptions:Tn,children:t,edges:s}}const Os={type:cc.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function Xi(e){return{stroke:"var(--node-border)",strokeWidth:1.5,...e?{strokeDasharray:"6 3"}:{}}}function Rn(e,t,s,r,i){var c;const o=(c=e.sections)==null?void 0:c[0],a=(i==null?void 0:i.x)??0,l=(i==null?void 0:i.y)??0;let h;if(o)h={sourcePoint:{x:o.startPoint.x+a,y:o.startPoint.y+l},targetPoint:{x:o.endPoint.x+a,y:o.endPoint.y+l},bendPoints:(o.bendPoints??[]).map(u=>({x:u.x+a,y:u.y+l}))};else{const u=t.get(e.sources[0]),d=t.get(e.targets[0]);u&&d&&(h={sourcePoint:{x:u.x+u.width/2,y:u.y+u.height},targetPoint:{x:d.x+d.width/2,y:d.y},bendPoints:[]})}return{id:e.id,source:e.sources[0],target:e.targets[0],type:"elk",data:h,style:Xi(r),markerEnd:Os,...s?{label:s,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function Sa(e){var h,c;const t=lh(e),r=await(await oh()).layout(t),i=new Map;for(const u of e.nodes)if(i.set(u.id,{type:u.type,data:u.data}),u.data.subgraph)for(const d of u.data.subgraph.nodes)i.set(`${u.id}/${d.id}`,{type:d.type,data:d.data});const o=[],a=[],l=new Map;for(const u of r.children??[]){const d=u.x??0,_=u.y??0;l.set(u.id,{x:d,y:_,width:u.width??0,height:u.height??0});for(const g of u.children??[])l.set(g.id,{x:d+(g.x??0),y:_+(g.y??0),width:g.width??0,height:g.height??0})}for(const u of r.children??[]){const d=i.get(u.id);if((((h=u.children)==null?void 0:h.length)??0)>0){o.push({id:u.id,type:"groupNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width,nodeHeight:u.height},position:{x:u.x??0,y:u.y??0},style:{width:u.width,height:u.height}});for(const x of u.children??[]){const w=i.get(x.id);o.push({id:x.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:x.width},position:{x:x.x??0,y:x.y??0},parentNode:u.id,extent:"parent"})}const g=u.x??0,m=u.y??0;for(const x of u.edges??[]){const w=e.nodes.find(k=>k.id===u.id),E=(c=w==null?void 0:w.data.subgraph)==null?void 0:c.edges.find(k=>`${u.id}/${k.id}`===x.id);a.push(Rn(x,l,E==null?void 0:E.label,E==null?void 0:E.conditional,{x:g,y:m}))}}else o.push({id:u.id,type:(d==null?void 0:d.type)??"defaultNode",data:{...(d==null?void 0:d.data)??{},nodeWidth:u.width},position:{x:u.x??0,y:u.y??0}})}for(const u of r.edges??[]){const d=e.edges.find(_=>_.id===u.id);a.push(Rn(u,l,d==null?void 0:d.label,d==null?void 0:d.conditional))}return{nodes:o,edges:a}}const ch={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function wa({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"Start",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),r,n.jsx(Lt,{type:"source",position:Tt.Bottom,style:ch})]})}const hh={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ca({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"End",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:hh}),r]})}const Bn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function ka({data:e}){const t=e.status,s=e.nodeWidth,r=e.model_name,i=e.label??"Model",o=e.hasBreakpoint,a=e.isPausedHere,l=e.isActiveNode,h=e.isExecutingNode,c=a?"var(--error)":h?"var(--success)":l?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",u=a?"var(--error)":h?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${c}`,boxShadow:a||l||h?`0 0 4px ${u}`:void 0,animation:a||l||h?`node-pulse-${a?"red":h?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r?`${i} +${r}`:i,children:[o&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Bn}),n.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),r&&n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:r,children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Bn})]})}const Dn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},dh=3;function Ea({data:e}){const t=e.status,s=e.nodeWidth,r=e.tool_names,i=e.tool_count,o=e.label??"Tool",a=e.hasBreakpoint,l=e.isPausedHere,h=e.isActiveNode,c=e.isExecutingNode,u=l?"var(--error)":c?"var(--success)":h?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",d=l?"var(--error)":c?"var(--success)":"var(--accent)",_=(r==null?void 0:r.slice(0,dh))??[],g=(i??(r==null?void 0:r.length)??0)-_.length;return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${u}`,boxShadow:l||h||c?`0 0 4px ${d}`:void 0,animation:l||h||c?`node-pulse-${l?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r!=null&&r.length?`${o} ${r.join(` -`)}`:o,children:[a&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Bn}),n.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",i?` (${i})`:""]}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),_.length>0&&n.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[_.map(m=>n.jsx("div",{className:"truncate",children:m},m)),g>0&&n.jsxs("div",{style:{fontStyle:"italic"},children:["+",g," more"]})]}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Bn})]})}const Dn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Na({data:e}){const t=e.label??"",s=e.status,r=e.hasBreakpoint,i=e.isPausedHere,o=e.isActiveNode,a=e.isExecutingNode,l=i?"var(--error)":a?"var(--success)":o?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--bg-tertiary)",h=i?"var(--error)":a?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${i||o||a?"solid":"dashed"} ${l}`,borderRadius:8,boxShadow:i||o||a?`0 0 4px ${h}`:void 0,animation:i||o||a?`node-pulse-${i?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[r&&n.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Dn}),n.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${l}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:t}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Dn})]})}function ja({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom})]})}function uh(e,t=8){if(e.length<2)return"";if(e.length===2)return`M ${e[0].x} ${e[0].y} L ${e[1].x} ${e[1].y}`;let s=`M ${e[0].x} ${e[0].y}`;for(let i=1;if.breakpoints[t]),A=de(f=>f.toggleBreakpoint),D=de(f=>f.clearBreakpoints),N=de(f=>f.activeNodes[t]),$=de(f=>{var b;return(b=f.runs[t])==null?void 0:b.status}),B=v.useCallback((f,b)=>{if(b.type==="startNode"||b.type==="endNode")return;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id;A(t,y);const j=de.getState().breakpoints[t]??{};i==null||i(Object.keys(j))},[t,A,i]),T=P&&Object.keys(P).length>0,O=v.useCallback(()=>{if(T)D(t),i==null||i([]);else{const f=[];for(const y of o){if(y.type==="startNode"||y.type==="endNode"||y.parentNode)continue;const j=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id;f.push(j)}for(const y of f)P!=null&&P[y]||A(t,y);const b=de.getState().breakpoints[t]??{};i==null||i(Object.keys(b))}},[t,T,P,o,D,A,i]);v.useEffect(()=>{a(f=>f.map(b=>{var M;if(b.type==="startNode"||b.type==="endNode")return b;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id,j=!!(P&&P[y]);return j!==!!((M=b.data)!=null&&M.hasBreakpoint)?{...b,data:{...b.data,hasBreakpoint:j}}:b}))},[P,a]),v.useEffect(()=>{const f=s?new Set(s.split(",").map(b=>b.trim()).filter(Boolean)):null;a(b=>b.map(y=>{var C,H;if(y.type==="startNode"||y.type==="endNode")return y;const j=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id,M=(C=y.data)==null?void 0:C.label,z=f!=null&&(f.has(j)||M!=null&&f.has(M));return z!==!!((H=y.data)!=null&&H.isPausedHere)?{...y,data:{...y.data,isPausedHere:z}}:y}))},[s,x,a]);const L=de(f=>f.stateEvents[t]);v.useEffect(()=>{const f=!!s;let b=new Set;const y=new Set,j=new Set,M=new Set,z=new Map,C=new Map;if(L)for(const H of L)H.phase==="started"?C.set(H.node_name,H.qualified_node_name??null):H.phase==="completed"&&C.delete(H.node_name);a(H=>{var q;for(const ee of H)ee.type&&z.set(ee.id,ee.type);const U=ee=>{var F;const ie=[];for(const se of H){const pe=se.type==="groupNode"?se.id:se.id.includes("/")?se.id.split("/").pop():se.id,_e=(F=se.data)==null?void 0:F.label;(pe===ee||_e!=null&&_e===ee)&&ie.push(se.id)}return ie};if(f&&s){const ee=s.split(",").map(ie=>ie.trim()).filter(Boolean);for(const ie of ee)U(ie).forEach(F=>b.add(F));if(r!=null&&r.length)for(const ie of r)U(ie).forEach(F=>j.add(F));N!=null&&N.prev&&U(N.prev).forEach(ie=>y.add(ie))}else if(C.size>0){const ee=new Map;for(const ie of H){const F=(q=ie.data)==null?void 0:q.label;if(!F)continue;const se=ie.id.includes("/")?ie.id.split("/").pop():ie.id;for(const pe of[se,F]){let _e=ee.get(pe);_e||(_e=new Set,ee.set(pe,_e)),_e.add(ie.id)}}for(const[ie,F]of C){let se=!1;if(F){const pe=F.replace(/:/g,"/");for(const _e of H)_e.id===pe&&(b.add(_e.id),se=!0)}if(!se){const pe=ee.get(ie);pe&&pe.forEach(_e=>b.add(_e))}}}return H}),c(H=>{const U=y.size===0||H.some(q=>b.has(q.target)&&y.has(q.source));return H.map(q=>{var ie,F;let ee;return f?ee=b.has(q.target)&&(y.size===0||!U||y.has(q.source))||b.has(q.source)&&j.has(q.target):(ee=b.has(q.source),!ee&&z.get(q.target)==="endNode"&&b.has(q.target)&&(ee=!0)),ee?(f||M.add(q.target),{...q,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...q.data,highlighted:!0},animated:!0}):(ie=q.data)!=null&&ie.highlighted?{...q,style:qi((F=q.data)==null?void 0:F.conditional),markerEnd:Os,data:{...q.data,highlighted:!1},animated:!1}:q})}),a(H=>H.map(U=>{var ie,F,se,pe;const q=!f&&b.has(U.id);if(U.type==="startNode"||U.type==="endNode"){const _e=M.has(U.id)||!f&&b.has(U.id);return _e!==!!((ie=U.data)!=null&&ie.isActiveNode)||q!==!!((F=U.data)!=null&&F.isExecutingNode)?{...U,data:{...U.data,isActiveNode:_e,isExecutingNode:q}}:U}const ee=f?j.has(U.id):M.has(U.id);return ee!==!!((se=U.data)!=null&&se.isActiveNode)||q!==!!((pe=U.data)!=null&&pe.isExecutingNode)?{...U,data:{...U.data,isActiveNode:ee,isExecutingNode:q}}:U}))},[L,N,s,r,$,x,a,c]);const R=de(f=>f.graphCache[t]);v.useEffect(()=>{if(!R&&t!=="__setup__")return;const f=R?Promise.resolve(R):fa(e),b=++E.current;_(!0),m(!1),f.then(async y=>{if(E.current!==b)return;if(!y.nodes.length){m(!0);return}const{nodes:j,edges:M}=await Sa(y);if(E.current!==b)return;const z=de.getState().breakpoints[t],C=z?j.map(H=>{if(H.type==="startNode"||H.type==="endNode")return H;const U=H.type==="groupNode"?H.id:H.id.includes("/")?H.id.split("/").pop():H.id;return z[U]?{...H,data:{...H.data,hasBreakpoint:!0}}:H}):j;a(C),c(M),w(H=>H+1),setTimeout(()=>{var H;(H=k.current)==null||H.fitView({padding:.1,duration:200})},100)}).catch(()=>{E.current===b&&m(!0)}).finally(()=>{E.current===b&&_(!1)})},[e,t,R,a,c]),v.useEffect(()=>{const f=setTimeout(()=>{var b;(b=k.current)==null||b.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(f)},[t]);const p=v.useRef(null);return v.useEffect(()=>{const f=p.current;if(!f)return;const b=new ResizeObserver(()=>{var y;(y=k.current)==null||y.fitView({padding:.1,duration:200})});return b.observe(f),()=>b.disconnect()},[d,g]),v.useEffect(()=>{a(f=>{var q,ee,ie;const b=!!(L!=null&&L.length),y=$==="completed"||$==="failed",j=new Set,M=new Set(f.map(F=>F.id)),z=new Map;for(const F of f){const se=(q=F.data)==null?void 0:q.label;if(!se)continue;const pe=F.id.includes("/")?F.id.split("/").pop():F.id;for(const _e of[pe,se]){let qe=z.get(_e);qe||(qe=new Set,z.set(_e,qe)),qe.add(F.id)}}if(b)for(const F of L){let se=!1;if(F.qualified_node_name){const pe=F.qualified_node_name.replace(/:/g,"/");M.has(pe)&&(j.add(pe),se=!0)}if(!se){const pe=z.get(F.node_name);pe&&pe.forEach(_e=>j.add(_e))}}const C=new Set;for(const F of f)F.parentNode&&j.has(F.id)&&C.add(F.parentNode);let H;$==="failed"&&j.size===0&&(H=(ee=f.find(F=>!F.parentNode&&F.type!=="startNode"&&F.type!=="endNode"&&F.type!=="groupNode"))==null?void 0:ee.id);let U;if($==="completed"){const F=(ie=f.find(se=>!se.parentNode&&se.type!=="startNode"&&se.type!=="endNode"&&se.type!=="groupNode"))==null?void 0:ie.id;F&&!j.has(F)&&(U=F)}return f.map(F=>{var pe;let se;return F.id===H?se="failed":F.id===U||j.has(F.id)?se="completed":F.type==="startNode"?(!F.parentNode&&b||F.parentNode&&C.has(F.parentNode))&&(se="completed"):F.type==="endNode"?!F.parentNode&&y?se=$==="failed"?"failed":"completed":F.parentNode&&C.has(F.parentNode)&&(se="completed"):F.type==="groupNode"&&C.has(F.id)&&(se="completed"),se!==((pe=F.data)==null?void 0:pe.status)?{...F,data:{...F.data,status:se}}:F})})},[L,$,x,a]),d?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):g?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:p,className:"h-full graph-panel",children:[n.jsx("style",{children:` +`)}`:o,children:[a&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Dn}),n.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",i?` (${i})`:""]}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),_.length>0&&n.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[_.map(m=>n.jsx("div",{className:"truncate",children:m},m)),g>0&&n.jsxs("div",{style:{fontStyle:"italic"},children:["+",g," more"]})]}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Dn})]})}const Pn={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Na({data:e}){const t=e.label??"",s=e.status,r=e.hasBreakpoint,i=e.isPausedHere,o=e.isActiveNode,a=e.isExecutingNode,l=i?"var(--error)":a?"var(--success)":o?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--bg-tertiary)",h=i?"var(--error)":a?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${i||o||a?"solid":"dashed"} ${l}`,borderRadius:8,boxShadow:i||o||a?`0 0 4px ${h}`:void 0,animation:i||o||a?`node-pulse-${i?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[r&&n.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),n.jsx(Lt,{type:"target",position:Tt.Top,style:Pn}),n.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${l}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:t}),n.jsx(Lt,{type:"source",position:Tt.Bottom,style:Pn})]})}function ja({data:e}){const t=e.status,s=e.nodeWidth,r=e.label??"",i=e.hasBreakpoint,o=e.isPausedHere,a=e.isActiveNode,l=e.isExecutingNode,h=o?"var(--error)":l?"var(--success)":a?"var(--accent)":t==="completed"?"var(--success)":t==="running"?"var(--warning)":t==="failed"?"var(--error)":"var(--node-border)",c=o?"var(--error)":l?"var(--success)":"var(--accent)";return n.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:s,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${h}`,boxShadow:o||a||l?`0 0 4px ${c}`:void 0,animation:o||a||l?`node-pulse-${o?"red":l?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:r,children:[i&&n.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),n.jsx(Lt,{type:"target",position:Tt.Top}),n.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:r}),n.jsx(Lt,{type:"source",position:Tt.Bottom})]})}function uh(e,t=8){if(e.length<2)return"";if(e.length===2)return`M ${e[0].x} ${e[0].y} L ${e[1].x} ${e[1].y}`;let s=`M ${e[0].x} ${e[0].y}`;for(let i=1;ip.breakpoints[t]),O=de(p=>p.toggleBreakpoint),D=de(p=>p.clearBreakpoints),j=de(p=>p.activeNodes[t]),F=de(p=>{var b;return(b=p.runs[t])==null?void 0:b.status}),R=v.useCallback((p,b)=>{if(b.type==="startNode"||b.type==="endNode")return;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id;O(t,y);const N=de.getState().breakpoints[t]??{};i==null||i(Object.keys(N))},[t,O,i]),T=P&&Object.keys(P).length>0,I=v.useCallback(()=>{if(T)D(t),i==null||i([]);else{const p=[];for(const y of o){if(y.type==="startNode"||y.type==="endNode"||y.parentNode)continue;const N=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id;p.push(N)}for(const y of p)P!=null&&P[y]||O(t,y);const b=de.getState().breakpoints[t]??{};i==null||i(Object.keys(b))}},[t,T,P,o,D,O,i]);v.useEffect(()=>{a(p=>p.map(b=>{var M;if(b.type==="startNode"||b.type==="endNode")return b;const y=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id,N=!!(P&&P[y]);return N!==!!((M=b.data)!=null&&M.hasBreakpoint)?{...b,data:{...b.data,hasBreakpoint:N}}:b}))},[P,a]),v.useEffect(()=>{const p=s?new Set(s.split(",").map(b=>b.trim()).filter(Boolean)):null;a(b=>b.map(y=>{var C,W;if(y.type==="startNode"||y.type==="endNode")return y;const N=y.type==="groupNode"?y.id:y.id.includes("/")?y.id.split("/").pop():y.id,M=(C=y.data)==null?void 0:C.label,U=p!=null&&(p.has(N)||M!=null&&p.has(M));return U!==!!((W=y.data)!=null&&W.isPausedHere)?{...y,data:{...y.data,isPausedHere:U}}:y}))},[s,x,a]);const L=de(p=>p.stateEvents[t]);v.useEffect(()=>{const p=!!s;let b=new Set;const y=new Set,N=new Set,M=new Set,U=new Map,C=new Map;if(L)for(const W of L)W.phase==="started"?C.set(W.node_name,W.qualified_node_name??null):W.phase==="completed"&&C.delete(W.node_name);a(W=>{var A;for(const Z of W)Z.type&&U.set(Z.id,Z.type);const z=Z=>{var K;const ie=[];for(const se of W){const pe=se.type==="groupNode"?se.id:se.id.includes("/")?se.id.split("/").pop():se.id,_e=(K=se.data)==null?void 0:K.label;(pe===Z||_e!=null&&_e===Z)&&ie.push(se.id)}return ie};if(p&&s){const Z=s.split(",").map(ie=>ie.trim()).filter(Boolean);for(const ie of Z)z(ie).forEach(K=>b.add(K));if(r!=null&&r.length)for(const ie of r)z(ie).forEach(K=>N.add(K));j!=null&&j.prev&&z(j.prev).forEach(ie=>y.add(ie))}else if(C.size>0){const Z=new Map;for(const ie of W){const K=(A=ie.data)==null?void 0:A.label;if(!K)continue;const se=ie.id.includes("/")?ie.id.split("/").pop():ie.id;for(const pe of[se,K]){let _e=Z.get(pe);_e||(_e=new Set,Z.set(pe,_e)),_e.add(ie.id)}}for(const[ie,K]of C){let se=!1;if(K){const pe=K.replace(/:/g,"/");for(const _e of W)_e.id===pe&&(b.add(_e.id),se=!0)}if(!se){const pe=Z.get(ie);pe&&pe.forEach(_e=>b.add(_e))}}}return W}),c(W=>{const z=y.size===0||W.some(A=>b.has(A.target)&&y.has(A.source));return W.map(A=>{var ie,K;let Z;return p?Z=b.has(A.target)&&(y.size===0||!z||y.has(A.source))||b.has(A.source)&&N.has(A.target):(Z=b.has(A.source),!Z&&U.get(A.target)==="endNode"&&b.has(A.target)&&(Z=!0)),Z?(p||M.add(A.target),{...A,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...A.data,highlighted:!0},animated:!0}):(ie=A.data)!=null&&ie.highlighted?{...A,style:Xi((K=A.data)==null?void 0:K.conditional),markerEnd:Os,data:{...A.data,highlighted:!1},animated:!1}:A})}),a(W=>W.map(z=>{var ie,K,se,pe;const A=!p&&b.has(z.id);if(z.type==="startNode"||z.type==="endNode"){const _e=M.has(z.id)||!p&&b.has(z.id);return _e!==!!((ie=z.data)!=null&&ie.isActiveNode)||A!==!!((K=z.data)!=null&&K.isExecutingNode)?{...z,data:{...z.data,isActiveNode:_e,isExecutingNode:A}}:z}const Z=p?N.has(z.id):M.has(z.id);return Z!==!!((se=z.data)!=null&&se.isActiveNode)||A!==!!((pe=z.data)!=null&&pe.isExecutingNode)?{...z,data:{...z.data,isActiveNode:Z,isExecutingNode:A}}:z}))},[L,j,s,r,F,x,a,c]);const B=de(p=>p.graphCache[t]);v.useEffect(()=>{if(!B&&t!=="__setup__")return;const p=B?Promise.resolve(B):pa(e),b=++E.current;_(!0),m(!1),p.then(async y=>{if(E.current!==b)return;if(!y.nodes.length){m(!0);return}const{nodes:N,edges:M}=await Sa(y);if(E.current!==b)return;const U=de.getState().breakpoints[t],C=U?N.map(W=>{if(W.type==="startNode"||W.type==="endNode")return W;const z=W.type==="groupNode"?W.id:W.id.includes("/")?W.id.split("/").pop():W.id;return U[z]?{...W,data:{...W.data,hasBreakpoint:!0}}:W}):N;a(C),c(M),w(W=>W+1),setTimeout(()=>{var W;(W=k.current)==null||W.fitView({padding:.1,duration:200})},100)}).catch(()=>{E.current===b&&m(!0)}).finally(()=>{E.current===b&&_(!1)})},[e,t,B,a,c]),v.useEffect(()=>{const p=setTimeout(()=>{var b;(b=k.current)==null||b.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(p)},[t]);const f=v.useRef(null);return v.useEffect(()=>{const p=f.current;if(!p)return;const b=new ResizeObserver(()=>{var y;(y=k.current)==null||y.fitView({padding:.1,duration:200})});return b.observe(p),()=>b.disconnect()},[d,g]),v.useEffect(()=>{a(p=>{var A,Z,ie;const b=!!(L!=null&&L.length),y=F==="completed"||F==="failed",N=new Set,M=new Set(p.map(K=>K.id)),U=new Map;for(const K of p){const se=(A=K.data)==null?void 0:A.label;if(!se)continue;const pe=K.id.includes("/")?K.id.split("/").pop():K.id;for(const _e of[pe,se]){let qe=U.get(_e);qe||(qe=new Set,U.set(_e,qe)),qe.add(K.id)}}if(b)for(const K of L){let se=!1;if(K.qualified_node_name){const pe=K.qualified_node_name.replace(/:/g,"/");M.has(pe)&&(N.add(pe),se=!0)}if(!se){const pe=U.get(K.node_name);pe&&pe.forEach(_e=>N.add(_e))}}const C=new Set;for(const K of p)K.parentNode&&N.has(K.id)&&C.add(K.parentNode);let W;F==="failed"&&N.size===0&&(W=(Z=p.find(K=>!K.parentNode&&K.type!=="startNode"&&K.type!=="endNode"&&K.type!=="groupNode"))==null?void 0:Z.id);let z;if(F==="completed"){const K=(ie=p.find(se=>!se.parentNode&&se.type!=="startNode"&&se.type!=="endNode"&&se.type!=="groupNode"))==null?void 0:ie.id;K&&!N.has(K)&&(z=K)}return p.map(K=>{var pe;let se;return K.id===W?se="failed":K.id===z||N.has(K.id)?se="completed":K.type==="startNode"?(!K.parentNode&&b||K.parentNode&&C.has(K.parentNode))&&(se="completed"):K.type==="endNode"?!K.parentNode&&y?se=F==="failed"?"failed":"completed":K.parentNode&&C.has(K.parentNode)&&(se="completed"):K.type==="groupNode"&&C.has(K.id)&&(se="completed"),se!==((pe=K.data)==null?void 0:pe.status)?{...K,data:{...K.data,status:se}}:K})})},[L,F,x,a]),d?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):g?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:f,className:"h-full graph-panel",children:[n.jsx("style",{children:` .graph-panel .react-flow__handle { opacity: 0 !important; width: 0 !important; @@ -37,8 +37,8 @@ ${r.join(` 0%, 100% { box-shadow: 0 0 4px var(--error); } 50% { box-shadow: 0 0 10px var(--error); } } - `}),n.jsxs(oa,{nodes:o,edges:h,onNodesChange:l,onEdgesChange:u,nodeTypes:fh,edgeTypes:ph,onInit:f=>{k.current=f},onNodeClick:B,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(dc,{position:"top-right",children:n.jsxs("button",{onClick:O,title:T?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:T?"var(--error)":"var(--text-muted)",border:`1px solid ${T?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[n.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:T?"var(--error)":"var(--node-border)"}}),T?"Clear all":"Break all"]})}),n.jsx(ca,{nodeColor:f=>{var y;if(f.type==="groupNode")return"var(--bg-tertiary)";const b=(y=f.data)==null?void 0:y.status;return b==="completed"?"var(--success)":b==="running"?"var(--warning)":b==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ts="__setup__";function _h({entrypoint:e,mode:t,ws:s,onRunCreated:r,isMobile:i}){const[o,a]=v.useState("{}"),[l,h]=v.useState({}),[c,u]=v.useState(!1),[d,_]=v.useState(!0),[g,m]=v.useState(null),[x,w]=v.useState(""),[E,k]=v.useState(!0),[P,A]=v.useState(()=>{const y=localStorage.getItem("setupTextareaHeight");return y?parseInt(y,10):140}),D=v.useRef(null),[N,$]=v.useState(()=>{const y=localStorage.getItem("setupPanelWidth");return y?parseInt(y,10):380}),B=t==="run";v.useEffect(()=>{_(!0),m(null),Sc(e).then(y=>{h(y.mock_input),a(JSON.stringify(y.mock_input,null,2))}).catch(y=>{console.error("Failed to load mock input:",y);const j=y.detail||{};m(j.message||`Failed to load schema for "${e}"`),a("{}")}).finally(()=>_(!1))},[e]),v.useEffect(()=>{de.getState().clearBreakpoints(ts)},[]);const T=async()=>{let y;try{y=JSON.parse(o)}catch{alert("Invalid JSON input");return}u(!0);try{const j=de.getState().breakpoints[ts]??{},M=Object.keys(j),z=await bn(e,y,t,M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),r(z.id)}catch(j){console.error("Failed to create run:",j)}finally{u(!1)}},O=async()=>{const y=x.trim();if(y){u(!0);try{const j=de.getState().breakpoints[ts]??{},M=Object.keys(j),z=await bn(e,l,"chat",M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(z),de.getState().addLocalChatMessage(z.id,{message_id:`local-${Date.now()}`,role:"user",content:y}),s.sendChatMessage(z.id,y),r(z.id)}catch(j){console.error("Failed to create chat run:",j)}finally{u(!1)}}};v.useEffect(()=>{try{JSON.parse(o),k(!0)}catch{k(!1)}},[o]);const L=v.useCallback(y=>{y.preventDefault();const j="touches"in y?y.touches[0].clientY:y.clientY,M=P,z=H=>{const U="touches"in H?H.touches[0].clientY:H.clientY,q=Math.max(60,M+(j-U));A(q)},C=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(P))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",C),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",C)},[P]),R=v.useCallback(y=>{y.preventDefault();const j="touches"in y?y.touches[0].clientX:y.clientX,M=N,z=H=>{const U=D.current;if(!U)return;const q="touches"in H?H.touches[0].clientX:H.clientX,ee=U.clientWidth-300,ie=Math.max(280,Math.min(ee,M+(j-q)));$(ie)},C=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",z),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(N))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",z),document.addEventListener("mouseup",C),document.addEventListener("touchmove",z,{passive:!1}),document.addEventListener("touchend",C)},[N]),p=B?"Autonomous":"Conversational",f=B?"var(--success)":"var(--accent)",b=n.jsxs("div",{className:"shrink-0 flex flex-col",style:i?{background:"var(--bg-primary)"}:{width:N,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"px-4 text-xs font-semibold border-b flex items-center gap-2 h-10",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{style:{color:f},children:"●"}),p]}),n.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[n.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:B?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("polyline",{points:"12 6 12 12 16 14"})]}):n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),n.jsxs("div",{className:"text-center space-y-1.5",children:[n.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:B?"Ready to execute":"Ready to chat"}),n.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",B?n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"configure input below, then run"]}):n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"then send your first message"]})]})]})]}),B?n.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!i&&n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"px-4 py-3",children:[g?n.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:g}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:["Input",d&&n.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),n.jsx("textarea",{value:o,onChange:y=>a(y.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none mb-3",style:{height:i?120:P,background:"var(--bg-secondary)",border:`1px solid ${E?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),n.jsx("button",{onClick:T,disabled:c||d||!!g,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:f,color:f},onMouseEnter:y=>{c||(y.currentTarget.style.background=`color-mix(in srgb, ${f} 10%, transparent)`)},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:c?"Starting...":n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("input",{value:x,onChange:y=>w(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),O())},disabled:c||d,placeholder:c?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),n.jsx("button",{onClick:O,disabled:c||d||!x.trim(),className:"text-xs font-semibold px-3 py-1.5 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!c&&x.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:y=>{!c&&x.trim()&&(y.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:"Send"})]})]});return i?n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:b})]}):n.jsxs("div",{ref:D,className:"flex h-full",children:[n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{onMouseDown:R,onTouchStart:R,className:"shrink-0 drag-handle-col"}),b]})}const gh={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function mh(e){const t=[],s=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let r=0,i;for(;(i=s.exec(e))!==null;){if(i.index>r&&t.push({type:"punctuation",text:e.slice(r,i.index)}),i[1]!==void 0){t.push({type:"key",text:i[1]});const o=e.indexOf(":",i.index+i[1].length);o!==-1&&(o>i.index+i[1].length&&t.push({type:"punctuation",text:e.slice(i.index+i[1].length,o)}),t.push({type:"punctuation",text:":"}),s.lastIndex=o+1)}else i[2]!==void 0?t.push({type:"string",text:i[2]}):i[3]!==void 0?t.push({type:"number",text:i[3]}):i[4]!==void 0?t.push({type:"boolean",text:i[4]}):i[5]!==void 0?t.push({type:"null",text:i[5]}):i[6]!==void 0&&t.push({type:"punctuation",text:i[6]});r=s.lastIndex}return rmh(e),[e]);return n.jsx("pre",{className:t,style:s,children:r.map((i,o)=>n.jsx("span",{style:{color:gh[i.type]},children:i.text},o))})}const vh={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},xh={color:"var(--text-muted)",label:"Unknown"};function yh(e){if(typeof e!="string")return null;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}return null}const Pn=200;function bh(e){if(typeof e=="string")return e;if(e==null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Sh({value:e}){const[t,s]=v.useState(!1),r=bh(e),i=v.useMemo(()=>yh(e),[e]),o=i!==null,a=i??r,l=a.length>Pn||a.includes(` -`),h=v.useCallback(()=>s(c=>!c),[]);return l?n.jsxs("div",{children:[t?o?n.jsx(gt,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):n.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):n.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,Pn),"..."]}),n.jsx("button",{onClick:h,className:"text-[11px] cursor-pointer ml-1 px-1",style:{color:"var(--info)"},children:t?"[less]":"[more]"})]}):o?n.jsx(gt,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function wh({span:e}){const[t,s]=v.useState(!0),[r,i]=v.useState(!1),[o,a]=v.useState("table"),[l,h]=v.useState(!1),c=vh[e.status.toLowerCase()]??{...xh,label:e.status},u=v.useMemo(()=>JSON.stringify(e,null,2),[e]),d=v.useCallback(()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})},[u]),_=Object.entries(e.attributes),g=[{label:"Span",value:e.span_id},...e.trace_id?[{label:"Trace",value:e.trace_id}]:[],{label:"Run",value:e.run_id},...e.parent_span_id?[{label:"Parent",value:e.parent_span_id}]:[]];return n.jsxs("div",{className:"flex flex-col h-full text-xs leading-normal",children:[n.jsxs("div",{className:"px-2 border-b flex items-center gap-1 shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>a("table"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="table"?"var(--accent)":"var(--text-muted)",background:o==="table"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-muted)")},children:"Table"}),n.jsx("button",{onClick:()=>a("json"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="json"?"var(--accent)":"var(--text-muted)",background:o==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-muted)")},children:"JSON"}),n.jsxs("span",{className:"ml-auto shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${c.color} 15%, var(--bg-secondary))`,color:c.color},children:[n.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:c.color}}),c.label]})]}),n.jsx("div",{className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:o==="table"?n.jsxs(n.Fragment,{children:[_.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>s(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Attributes (",_.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:t?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),t&&_.map(([m,x],w)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:w%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m,children:m}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx(Sh,{value:x})})]},m))]}),n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>i(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Identifiers (",g.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:r?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),r&&g.map((m,x)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:x%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m.label,children:m.label}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:m.value})})]},m.label))]}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:d,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:l?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:m=>{l||(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{m.currentTarget.style.color=l?"var(--success)":"var(--text-muted)"},children:l?"Copied!":"Copy"}),n.jsx(gt,{json:u,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]})}function Ch(e){const t=[];function s(r,i){t.push({span:r.span,depth:i});for(const o of r.children)s(o,i+1)}for(const r of e)s(r,0);return t}function kh({tree:e,selectedSpan:t,onSelect:s}){const r=v.useMemo(()=>Ch(e),[e]),{globalStart:i,totalDuration:o}=v.useMemo(()=>{if(r.length===0)return{globalStart:0,totalDuration:1};let a=1/0,l=-1/0;for(const{span:h}of r){const c=new Date(h.timestamp).getTime();a=Math.min(a,c),l=Math.max(l,c+(h.duration_ms??0))}return{globalStart:a,totalDuration:Math.max(l-a,1)}},[r]);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(({span:a,depth:l})=>{var x;const h=new Date(a.timestamp).getTime()-i,c=a.duration_ms??0,u=h/o*100,d=Math.max(c/o*100,.3),_=La[a.status.toLowerCase()]??"var(--text-muted)",g=a.span_id===(t==null?void 0:t.span_id),m=(x=a.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("button",{"data-span-id":a.span_id,onClick:()=>s(a),className:"w-full text-left text-xs leading-normal py-1 flex items-center transition-colors",style:{background:g?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:g?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{g||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{g||(w.currentTarget.style.background="")},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-1 overflow-hidden",style:{width:"35%",minWidth:"80px",paddingLeft:`${l*12+4}px`},children:[n.jsx("span",{className:"shrink-0 flex items-center justify-center w-3.5 h-3.5",children:n.jsx(Ta,{kind:m,statusColor:_})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate",children:a.span_name})]}),n.jsx("div",{className:"flex-1 relative h-[14px] mx-1 rounded-sm",style:{background:"var(--bg-secondary)"},children:n.jsx("div",{className:"absolute rounded-sm",style:{left:`${u}%`,width:`${d}%`,top:"2px",bottom:"2px",background:_,opacity:.8,minWidth:"2px"}})}),n.jsx("span",{className:"shrink-0 text-[10px] tabular-nums pr-2",style:{width:"52px",textAlign:"right",color:"var(--text-muted)"},children:Ra(a.duration_ms)})]},a.span_id)})})}const La={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function Ta({kind:e,statusColor:t}){const s=t,r=14,i={width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"LLM":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:s,stroke:"none"})});case"TOOL":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),n.jsx("circle",{cx:"6",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("circle",{cx:"10",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("path",{d:"M8 2v3"}),n.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return n.jsxs("svg",{...i,children:[n.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),n.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),n.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return n.jsxs("svg",{...i,children:[n.jsx("circle",{cx:"7",cy:"7",r:"4"}),n.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:t}})}}function Eh(e){const t=new Map(e.map(a=>[a.span_id,a])),s=new Map;for(const a of e)if(a.parent_span_id){const l=s.get(a.parent_span_id)??[];l.push(a),s.set(a.parent_span_id,l)}const r=e.filter(a=>a.parent_span_id===null||!t.has(a.parent_span_id));function i(a){const l=(s.get(a.span_id)??[]).sort((h,c)=>h.timestamp.localeCompare(c.timestamp));return{span:a,children:l.map(i)}}return r.sort((a,l)=>a.timestamp.localeCompare(l.timestamp)).map(i).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function Ra(e){return e==null?"":e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`}function Ba(e){return e.map(t=>{const{span:s}=t;return t.children.length>0?{name:s.span_name,children:Ba(t.children)}:{name:s.span_name}})}function si({traces:e}){const[t,s]=v.useState(null),[r,i]=v.useState(new Set),[o,a]=v.useState(()=>{const B=localStorage.getItem("traceTreeSplitWidth");return B?parseFloat(B):50}),[l,h]=v.useState(!1),[c,u]=v.useState(!1),[d,_]=v.useState(()=>localStorage.getItem("traceViewMode")||"tree"),g=Eh(e),m=v.useMemo(()=>JSON.stringify(Ba(g),null,2),[e]),x=v.useCallback(()=>{navigator.clipboard.writeText(m).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[m]),w=de(B=>B.focusedSpan),E=de(B=>B.setFocusedSpan),[k,P]=v.useState(null),A=v.useRef(null),D=v.useCallback(B=>{i(T=>{const O=new Set(T);return O.has(B)?O.delete(B):O.add(B),O})},[]),N=v.useRef(null);v.useEffect(()=>{const B=g.length>0?g[0].span.span_id:null,T=N.current;if(N.current=B,B&&B!==T)s(g[0].span);else if(t===null)g.length>0&&s(g[0].span);else{const O=e.find(L=>L.span_id===t.span_id);O&&O!==t&&s(O)}},[e]),v.useEffect(()=>{if(!w)return;const T=e.filter(O=>O.span_name===w.name).sort((O,L)=>O.timestamp.localeCompare(L.timestamp))[w.index];if(T){s(T),P(T.span_id);const O=new Map(e.map(L=>[L.span_id,L.parent_span_id]));i(L=>{const R=new Set(L);let p=T.parent_span_id;for(;p;)R.delete(p),p=O.get(p)??null;return R})}E(null)},[w,e,E]),v.useEffect(()=>{if(!k)return;const B=k;P(null),requestAnimationFrame(()=>{const T=A.current,O=T==null?void 0:T.querySelector(`[data-span-id="${B}"]`);T&&O&&O.scrollIntoView({block:"center",behavior:"smooth"})})},[k]),v.useEffect(()=>{if(!l)return;const B=O=>{const L=document.querySelector(".trace-tree-container");if(!L)return;const R=L.getBoundingClientRect(),p=(O.clientX-R.left)/R.width*100,f=Math.max(20,Math.min(80,p));a(f),localStorage.setItem("traceTreeSplitWidth",String(f))},T=()=>{h(!1)};return window.addEventListener("mousemove",B),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",T)}},[l]);const $=B=>{B.preventDefault(),h(!0)};return n.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:l?"col-resize":void 0},children:[n.jsxs("div",{className:"flex flex-col",style:{width:`${o}%`},children:[e.length>0&&n.jsxs("div",{className:"flex items-center gap-1 px-2 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>{_("tree"),localStorage.setItem("traceViewMode","tree")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="tree"?"var(--accent)":"var(--text-muted)",background:d==="tree"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="tree"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="tree"&&(B.currentTarget.style.color="var(--text-muted)")},children:"Tree"}),n.jsx("button",{onClick:()=>{_("timeline"),localStorage.setItem("traceViewMode","timeline")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="timeline"?"var(--accent)":"var(--text-muted)",background:d==="timeline"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="timeline"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="timeline"&&(B.currentTarget.style.color="var(--text-muted)")},children:"Timeline"}),n.jsx("button",{onClick:()=>{_("json"),localStorage.setItem("traceViewMode","json")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="json"?"var(--accent)":"var(--text-muted)",background:d==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:B=>{d!=="json"&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{d!=="json"&&(B.currentTarget.style.color="var(--text-muted)")},children:"JSON"})]}),n.jsx("div",{ref:A,className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:g.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):d==="tree"?g.map((B,T)=>n.jsx(Da,{node:B,depth:0,selectedId:(t==null?void 0:t.span_id)??null,onSelect:s,isLast:T===g.length-1,collapsedIds:r,toggleExpanded:D},B.span.span_id)):d==="timeline"?n.jsx(kh,{tree:g,selectedSpan:t,onSelect:s}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:x,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:c?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:B=>{c||(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{B.currentTarget.style.color=c?"var(--success)":"var(--text-muted)"},children:c?"Copied!":"Copy"}),n.jsx(gt,{json:m,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]}),n.jsx("div",{onMouseDown:$,className:"shrink-0 drag-handle-col",style:l?{background:"var(--accent)"}:void 0}),n.jsx("div",{className:"flex-1 overflow-hidden",children:t?n.jsx(wh,{span:t}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function Da({node:e,depth:t,selectedId:s,onSelect:r,isLast:i,collapsedIds:o,toggleExpanded:a}){var x;const{span:l}=e,h=!o.has(l.span_id),c=La[l.status.toLowerCase()]??"var(--text-muted)",u=Ra(l.duration_ms),d=l.span_id===s,_=e.children.length>0,g=t*20,m=(x=l.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("div",{className:"relative",children:[t>0&&n.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${g-10}px`,width:"1px",height:i?"16px":"100%",background:"var(--border)"}}),n.jsxs("button",{"data-span-id":l.span_id,onClick:()=>r(l),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${g+4}px`,background:d?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:d?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:w=>{d||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{d||(w.currentTarget.style.background="")},children:[t>0&&n.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${g-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),_?n.jsx("span",{onClick:w=>{w.stopPropagation(),a(l.span_id)},className:"shrink-0 w-5 h-5 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("span",{className:"shrink-0 w-4"}),n.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:n.jsx(Ta,{kind:m,statusColor:c})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:l.span_name}),u&&n.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:u})]}),h&&e.children.map((w,E)=>n.jsx(Da,{node:w,depth:t+1,selectedId:s,onSelect:r,isLast:E===e.children.length-1,collapsedIds:o,toggleExpanded:a},w.span.span_id))]})}const Nh={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},jh={color:"var(--text-muted)",bg:"transparent"};function An({logs:e}){const t=v.useRef(null),s=v.useRef(null),[r,i]=v.useState(!1);v.useEffect(()=>{var a;(a=s.current)==null||a.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const a=t.current;a&&i(a.scrollTop>100)};return e.length===0?n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):n.jsxs("div",{className:"h-full relative",children:[n.jsxs("div",{ref:t,onScroll:o,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[e.map((a,l)=>{const h=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),c=a.level.toUpperCase(),u=c.slice(0,4),d=Nh[c]??jh,_=l%2===0;return n.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:_?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:h}),n.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:d.color,background:d.bg},children:u}),n.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},l)}),n.jsx("div",{ref:s})]}),r&&n.jsx("button",{onClick:()=>{var a;return(a=t.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const Mh={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},On={color:"var(--text-muted)",label:""};function er({events:e,runStatus:t}){const s=v.useRef(null),r=v.useRef(!0),[i,o]=v.useState(null),a=()=>{const l=s.current;l&&(r.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return v.useEffect(()=>{r.current&&s.current&&(s.current.scrollTop=s.current.scrollHeight)}),e.length===0?n.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t==="running"?"Waiting for events...":"No events yet"})}):n.jsx("div",{ref:s,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:e.map((l,h)=>{const c=new Date(l.timestamp).toLocaleTimeString(void 0,{hour12:!1}),u=l.payload&&Object.keys(l.payload).length>0,d=i===h,_=l.phase?Mh[l.phase]??On:On;return n.jsxs("div",{children:[n.jsxs("div",{onClick:()=>{u&&o(d?null:h)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:h%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:u?"pointer":"default"},children:[n.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:c}),n.jsx("span",{className:"shrink-0",style:{color:_.color},children:"●"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:l.node_name}),_.label&&n.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:_.label}),u&&n.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:d?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),d&&u&&n.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:n.jsx(gt,{json:JSON.stringify(l.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},h)})})}function Ot({title:e,copyText:t,trailing:s,children:r}){const[i,o]=v.useState(!1),a=v.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[t]);return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:e}),s,t&&n.jsx("button",{onClick:a,className:`${s?"":"ml-auto "}text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-colors`,style:{color:i?"var(--success)":"var(--text-muted)",background:"var(--bg-tertiary)",border:"none"},onMouseEnter:l=>{i||(l.currentTarget.style.color="var(--text-primary)")},onMouseLeave:l=>{l.currentTarget.style.color=i?"var(--success)":"var(--text-muted)"},children:i?"Copied":"Copy"})]}),r]})}function In({runId:e,status:t,ws:s,breakpointNode:r}){const i=t==="suspended",o=a=>{const l=de.getState().breakpoints[e]??{};s.setBreakpoints(e,Object.keys(l)),a==="step"?s.debugStep(e):a==="continue"?s.debugContinue(e):s.debugStop(e)};return n.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),n.jsx(Hr,{label:"Step",onClick:()=>o("step"),disabled:!i,color:"var(--info)",active:i}),n.jsx(Hr,{label:"Continue",onClick:()=>o("continue"),disabled:!i,color:"var(--success)",active:i}),n.jsx(Hr,{label:"Stop",onClick:()=>o("stop"),disabled:!i,color:"var(--error)",active:i}),n.jsx("span",{className:"text-[11px] ml-auto truncate",style:{color:i?"var(--accent)":"var(--text-muted)"},children:i?r?`Paused at ${r}`:"Paused":t})]})}function Hr({label:e,onClick:t,disabled:s,color:r,active:i}){return n.jsx("button",{onClick:t,disabled:s,className:"px-3 py-1 h-7 text-[11px] font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:i?r:"var(--text-muted)",background:i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},onMouseEnter:o=>{s||(o.currentTarget.style.background=`color-mix(in srgb, ${r} 20%, transparent)`)},onMouseLeave:o=>{o.currentTarget.style.background=i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},children:e})}const Wn=v.lazy(()=>ba(()=>import("./ChatPanel-CrwXase9.js"),__vite__mapDeps([2,1,3,4]))),Lh=[],Th=[],Rh=[],Bh=[];function Dh({run:e,ws:t,isMobile:s}){const r=e.mode==="chat",[i,o]=v.useState(280),[a,l]=v.useState(()=>{const p=localStorage.getItem("chatPanelWidth");return p?parseInt(p,10):380}),[h,c]=v.useState("primary"),[u,d]=v.useState(r?"primary":"traces"),_=v.useRef(null),g=v.useRef(null),m=v.useRef(!1),x=de(p=>p.traces[e.id]||Lh),w=de(p=>p.logs[e.id]||Th),E=de(p=>p.chatMessages[e.id]||Rh),k=de(p=>p.stateEvents[e.id]||Bh),P=de(p=>p.breakpoints[e.id]);v.useEffect(()=>{t.setBreakpoints(e.id,P?Object.keys(P):[])},[e.id]);const A=v.useCallback(p=>{t.setBreakpoints(e.id,p)},[e.id,t]),D=v.useCallback(p=>{p.preventDefault(),m.current=!0;const f="touches"in p?p.touches[0].clientY:p.clientY,b=i,y=M=>{if(!m.current)return;const z=_.current;if(!z)return;const C="touches"in M?M.touches[0].clientY:M.clientY,H=z.clientHeight-100,U=Math.max(80,Math.min(H,b+(C-f)));o(U)},j=()=>{m.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[i]),N=v.useCallback(p=>{p.preventDefault();const f="touches"in p?p.touches[0].clientX:p.clientX,b=a,y=M=>{const z=g.current;if(!z)return;const C="touches"in M?M.touches[0].clientX:M.clientX,H=z.clientWidth-300,U=Math.max(280,Math.min(H,b+(f-C)));l(U)},j=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[a]),$=r?"Chat":"Events",B=r?"var(--accent)":"var(--success)",T=p=>p==="primary"?B:p==="events"?"var(--success)":"var(--accent)",O=de(p=>p.activeInterrupt[e.id]??null),L=e.status==="running"?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:r?"Thinking...":"Running..."}):r&&e.status==="suspended"&&O?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(s){const p=[{id:"traces",label:"Traces",count:x.length},{id:"primary",label:$},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{className:"flex flex-col h-full",children:[(e.mode==="debug"||e.status==="suspended"&&!O||P&&Object.keys(P).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:A})}),n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[p.map(f=>n.jsxs("button",{onClick:()=>d(f.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:u===f.id?T(f.id):"var(--text-muted)",background:u===f.id?`color-mix(in srgb, ${T(f.id)} 10%, transparent)`:"transparent"},children:[f.label,f.count!==void 0&&f.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:f.count})]},f.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[u==="traces"&&n.jsx(si,{traces:x}),u==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),u==="events"&&n.jsx(er,{events:k,runStatus:e.status}),u==="io"&&n.jsx(Hn,{run:e}),u==="logs"&&n.jsx(An,{logs:w})]})]})}const R=[{id:"primary",label:$},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{ref:g,className:"flex h-full",children:[n.jsxs("div",{ref:_,className:"flex flex-col flex-1 min-w-0",children:[(e.mode==="debug"||e.status==="suspended"&&!O||P&&Object.keys(P).length>0)&&n.jsx(In,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0 overflow-hidden",style:{height:i},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:A})}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(si,{traces:x})})]}),n.jsx("div",{onMouseDown:N,onTouchStart:N,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[R.map(p=>n.jsxs("button",{onClick:()=>c(p.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:h===p.id?T(p.id):"var(--text-muted)",background:h===p.id?`color-mix(in srgb, ${T(p.id)} 10%, transparent)`:"transparent"},onMouseEnter:f=>{h!==p.id&&(f.currentTarget.style.color="var(--text-primary)")},onMouseLeave:f=>{h!==p.id&&(f.currentTarget.style.color="var(--text-muted)")},children:[p.label,p.count!==void 0&&p.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:p.count})]},p.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[h==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Wn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),h==="events"&&n.jsx(er,{events:k,runStatus:e.status}),h==="io"&&n.jsx(Hn,{run:e}),h==="logs"&&n.jsx(An,{logs:w})]})]})]})}function Hn({run:e}){return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:JSON.stringify(e.input_data,null,2),children:n.jsx(gt,{json:JSON.stringify(e.input_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.output_data&&n.jsx(Ot,{title:"Output",copyText:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),children:n.jsx(gt,{json:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.error&&n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[n.jsxs("div",{className:"px-3 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[n.jsx("span",{children:"Error"}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.code}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.category})]}),n.jsxs("div",{className:"px-3 py-2 text-xs leading-normal",children:[n.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:e.error.title}),n.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:e.error.detail})]})]})]})}function $n(){const{reloadPending:e,setReloadPending:t,setEntrypoints:s}=de(),[r,i]=v.useState(!1);if(!e)return null;const o=async()=>{i(!0);try{await Cc();const a=await $i();s(a.map(l=>l.name)),t(!1)}catch(a){console.error("Reload failed:",a)}finally{i(!1)}};return n.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2 rounded-lg shadow-lg",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[n.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Files changed"}),n.jsx("button",{onClick:o,disabled:r,className:"px-2.5 py-0.5 text-xs font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:r?.6:1},children:r?"Reloading...":"Reload"}),n.jsx("button",{onClick:()=>t(!1),"aria-label":"Dismiss reload prompt",className:"text-xs cursor-pointer px-0.5",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})}let Ph=0;const Fn=Jt(e=>({toasts:[],addToast:(t,s)=>{const r=String(++Ph);e(o=>({toasts:[...o.toasts,{id:r,type:t,message:s}]})),setTimeout(()=>{e(o=>({toasts:o.toasts.filter(a=>a.id!==r)}))},t==="error"?8e3:5e3)},removeToast:t=>{e(s=>({toasts:s.toasts.filter(r=>r.id!==t)}))}})),zn={success:{color:"var(--success)",bg:"color-mix(in srgb, var(--success) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--success) 30%, var(--border))"},error:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--error) 30%, var(--border))"},info:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--info) 30%, var(--border))"}};function Un(){const e=Fn(s=>s.toasts),t=Fn(s=>s.removeToast);return e.length===0?null:n.jsx("div",{className:"fixed bottom-8 right-4 z-[100] flex flex-col gap-2 pointer-events-none",children:e.map(s=>{const r=zn[s.type]??zn.info;return n.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-lg shadow-lg text-xs font-medium max-w-xs animate-[slideIn_0.2s_ease-out]",style:{background:r.bg,border:`1px solid ${r.border}`,color:r.color},children:[n.jsx("span",{className:"flex-1",children:s.message}),n.jsx("button",{onClick:()=>t(s.id),className:"shrink-0 w-5 h-5 flex items-center justify-center rounded cursor-pointer transition-opacity opacity-60 hover:opacity-100",style:{color:r.color,background:"transparent",border:"none"},"aria-label":"Dismiss",children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[n.jsx("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),n.jsx("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]})})]},s.id)})})}function Ah(e){return e===null?"-":`${Math.round(e*100)}%`}function Oh(e){if(e===null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}const Kn={pending:{color:"var(--text-muted)",label:"Pending"},running:{color:"var(--info)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"}};function Vn(){const e=xe(l=>l.evalSets),t=xe(l=>l.evalRuns),{evalSetId:s,evalRunId:r,navigate:i}=et(),o=Object.values(e),a=Object.values(t).sort((l,h)=>new Date(h.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("button",{onClick:()=>i("#/evals/new"),className:"w-[calc(100%-24px)] mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] text-center font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-secondary)",l.currentTarget.style.borderColor=""},children:"+ New Eval Set"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Eval Sets"}),o.map(l=>{const h=s===l.id;return n.jsxs("button",{onClick:()=>i(`#/evals/sets/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:c=>{h||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{h||(c.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"truncate font-medium",children:l.name}),n.jsxs("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:[l.eval_count," items · ",l.evaluator_ids.length," evaluator",l.evaluator_ids.length!==1?"s":""]})]},l.id)}),o.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval sets yet"}),n.jsx("div",{className:"px-3 pt-4 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),a.map(l=>{const h=r===l.id,c=Kn[l.status]??Kn.pending;return n.jsx("button",{onClick:()=>i(`#/evals/runs/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:u=>{h||(u.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:u=>{h||(u.currentTarget.style.background="transparent")},children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c.color}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"truncate font-medium",children:l.eval_set_name}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:l.start_time?new Date(l.start_time).toLocaleString():c.label})]}),n.jsx("span",{className:"font-mono shrink-0",style:{color:Oh(l.overall_score)},children:Ah(l.overall_score)})]})},l.id)}),a.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval runs yet"})]})}function qn(e,t=60){const s=typeof e=="string"?e:JSON.stringify(e);return!s||s==="null"?"-":s.length>t?s.slice(0,t)+"...":s}function Ih({evalSetId:e}){const[t,s]=v.useState(null),[r,i]=v.useState(!0),[o,a]=v.useState(null),[l,h]=v.useState(!1),[c,u]=v.useState("io"),d=xe(C=>C.evaluators),_=xe(C=>C.localEvaluators),g=xe(C=>C.updateEvalSetEvaluators),m=xe(C=>C.incrementEvalSetCount),x=xe(C=>C.upsertEvalRun),{navigate:w}=et(),[E,k]=v.useState(!1),[P,A]=v.useState(new Set),[D,N]=v.useState(!1),$=v.useRef(null),[B,T]=v.useState(()=>{const C=localStorage.getItem("evalSetSidebarWidth");return C?parseInt(C,10):320}),[O,L]=v.useState(!1),R=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSetSidebarWidth",String(B))},[B]),v.useEffect(()=>{i(!0),a(null),Hc(e).then(C=>{s(C),C.items.length>0&&a(C.items[0].name)}).catch(console.error).finally(()=>i(!1))},[e]);const p=async()=>{h(!0);try{const C=await $c(e);x(C),w(`#/evals/runs/${C.id}`)}catch(C){console.error(C)}finally{h(!1)}},f=async C=>{if(t)try{await Wc(e,C),s(H=>{if(!H)return H;const U=H.items.filter(q=>q.name!==C);return{...H,items:U,eval_count:U.length}}),m(e,-1),o===C&&a(null)}catch(H){console.error(H)}},b=v.useCallback(()=>{t&&A(new Set(t.evaluator_ids)),k(!0)},[t]),y=C=>{A(H=>{const U=new Set(H);return U.has(C)?U.delete(C):U.add(C),U})},j=async()=>{if(t){N(!0);try{const C=await Uc(e,Array.from(P));s(C),g(e,C.evaluator_ids),k(!1)}catch(C){console.error(C)}finally{N(!1)}}};v.useEffect(()=>{if(!E)return;const C=H=>{$.current&&!$.current.contains(H.target)&&k(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[E]);const M=v.useCallback(C=>{C.preventDefault(),L(!0);const H="touches"in C?C.touches[0].clientX:C.clientX,U=B,q=ie=>{const F=R.current;if(!F)return;const se="touches"in ie?ie.touches[0].clientX:ie.clientX,pe=F.clientWidth-300,_e=Math.max(280,Math.min(pe,U+(H-se)));T(_e)},ee=()=>{L(!1),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ee),document.removeEventListener("touchmove",q),document.removeEventListener("touchend",ee),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",q),document.addEventListener("mouseup",ee),document.addEventListener("touchmove",q,{passive:!1}),document.addEventListener("touchend",ee)},[B]);if(r)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!t)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval set not found"});const z=t.items.find(C=>C.name===o)??null;return n.jsxs("div",{ref:R,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:t.name}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[t.eval_count," items"]}),n.jsxs("div",{className:"flex gap-1 items-center ml-auto relative",children:[n.jsx("button",{onClick:b,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-muted)",C.currentTarget.style.background="transparent"},title:"Edit evaluators","aria-label":"Edit evaluators",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),n.jsx("path",{d:"m15 5 4 4"})]})}),t.evaluator_ids.map(C=>{const H=d.find(U=>U.id===C);return n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:(H==null?void 0:H.name)??C},C)}),E&&n.jsxs("div",{ref:$,className:"absolute top-full right-0 mt-1 z-50 rounded-md border shadow-lg",style:{background:"var(--bg-primary)",borderColor:"var(--border)",minWidth:220},children:[n.jsx("div",{className:"px-3 py-2 border-b text-[10px] uppercase tracking-wide font-semibold",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:"Evaluators"}),n.jsx("div",{className:"max-h-48 overflow-y-auto",children:_.length===0?n.jsx("div",{className:"px-3 py-3 text-xs",style:{color:"var(--text-muted)"},children:"No evaluators available"}):_.map(C=>n.jsxs("label",{className:"flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:H=>{H.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:P.has(C.id),onChange:()=>y(C.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:C.name})]},C.id))}),n.jsx("div",{className:"px-3 py-2 border-t flex justify-end",style:{borderColor:"var(--border)"},children:n.jsx("button",{onClick:j,disabled:D,className:"px-3 py-1 text-[11px] font-semibold rounded cursor-pointer transition-colors disabled:opacity-50",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},onMouseEnter:C=>{C.currentTarget.style.background="var(--accent-hover)"},onMouseLeave:C=>{C.currentTarget.style.background="var(--accent)"},children:D?"Saving...":"Update"})})]})]}),n.jsxs("button",{onClick:p,disabled:l,className:"ml-2 px-3 py-1 h-7 text-xs font-semibold rounded border flex items-center gap-1.5 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--success)",borderColor:"var(--success)",background:"transparent"},onMouseEnter:C=>{l||(C.currentTarget.style.background="color-mix(in srgb, var(--success) 10%, transparent)")},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},title:"Run eval set","aria-label":"Run eval set",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),l?"Running...":"Run"]})]}),n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-56 shrink-0",children:"Name"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Input"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Behavior"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Output"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Simulation Instr."}),n.jsx("span",{className:"w-8 shrink-0"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.items.map(C=>{const H=C.name===o;return n.jsxs("button",{onClick:()=>a(H?null:C.name),className:"group w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:H?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:H?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:U=>{H||(U.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:U=>{H||(U.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-56 shrink-0 truncate",style:{color:"var(--text-primary)"},children:C.name}),n.jsx("span",{className:"flex-1 min-w-0 truncate font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(C.inputs)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.expected_behavior||"-"}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:qn(C.expected_output,40)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.simulation_instructions||"-"}),n.jsx("span",{role:"button",tabIndex:0,className:"w-8 shrink-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:U=>{U.stopPropagation(),f(C.name)},onKeyDown:U=>{U.key==="Enter"&&(U.stopPropagation(),f(C.name))},style:{color:"var(--text-muted)"},onMouseEnter:U=>{U.currentTarget.style.color="var(--error)"},onMouseLeave:U=>{U.currentTarget.style.color="var(--text-muted)"},title:"Delete item",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},C.name)}),t.items.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:"No items in this eval set"})]})]}),n.jsx("div",{onMouseDown:M,onTouchStart:M,className:`shrink-0 drag-handle-col${O?"":" transition-all"}`,style:{width:z?3:0,opacity:z?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${O?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:z?B:0,background:"var(--bg-primary)"},children:[n.jsx("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:B},children:["io","evaluators"].map(C=>{const H=c===C,U=C==="io"?"I/O":"Evaluators";return n.jsx("button",{onClick:()=>u(C),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded inline-flex items-center cursor-pointer transition-colors",style:{color:H?"var(--accent)":"var(--text-muted)",background:H?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},children:U},C)})}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:B},children:z?c==="io"?n.jsx(Wh,{item:z}):n.jsx(Hh,{item:z,evaluators:d}):null})]})]})}function Wh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.expected_behavior&&n.jsx(Ot,{title:"Expected Behavior",copyText:e.expected_behavior,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.expected_behavior})}),s&&n.jsx(Ot,{title:"Expected Output",copyText:s,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.simulation_instructions&&n.jsx(Ot,{title:"Simulation Instructions",copyText:e.simulation_instructions,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.simulation_instructions})})]})}function Hh({item:e,evaluators:t}){return n.jsx("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:e.evaluator_ids.length>0?n.jsx(n.Fragment,{children:e.evaluator_ids.map(s=>{var o;const r=t.find(a=>a.id===s),i=(o=e.evaluation_criterias)==null?void 0:o[s];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:(r==null?void 0:r.name)??s}),n.jsx("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:i?"Custom criteria":"Default criteria"})]}),i&&n.jsx("pre",{className:"px-3 py-2 border-t text-[11px] font-mono overflow-x-auto max-h-32 whitespace-pre-wrap break-words",style:{borderColor:"var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(i,null,2)})]},s)})}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"No evaluators configured for this item"})})}function ms(e){return e==null?"-":`${Math.round(e*100)}%`}function At(e){if(e==null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}function $h(e,t){if(!e)return"-";const s=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.round((r-s)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function Xn(e){return e.replace(/\s*Evaluator$/i,"")}const Yn={pending:{color:"var(--text-muted)",bg:"var(--bg-tertiary)",label:"Pending"},running:{color:"var(--info)",bg:"rgba(59,130,246,0.1)",label:"Running"},completed:{color:"var(--success)",bg:"rgba(34,197,94,0.1)",label:"Completed"},failed:{color:"var(--error)",bg:"rgba(239,68,68,0.1)",label:"Failed"}};function Fh({evalRunId:e,itemName:t}){var p;const[s,r]=v.useState(null),[i,o]=v.useState(!0),{navigate:a}=et(),l=t??null,[h,c]=v.useState(220),u=v.useRef(null),d=v.useRef(!1),[_,g]=v.useState(()=>{const f=localStorage.getItem("evalSidebarWidth");return f?parseInt(f,10):320}),[m,x]=v.useState(!1),w=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSidebarWidth",String(_))},[_]);const E=xe(f=>f.evalRuns[e]),k=xe(f=>f.evaluators),P=xe(f=>f.streamingResults[e]);v.useEffect(()=>{o(!0),wn(e).then(f=>{if(r(f),!t){const b=f.results.find(y=>y.status==="completed")??f.results[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)}}).catch(console.error).finally(()=>o(!1))},[e]),v.useEffect(()=>{((E==null?void 0:E.status)==="completed"||(E==null?void 0:E.status)==="failed")&&wn(e).then(r).catch(console.error)},[E==null?void 0:E.status,e]),v.useEffect(()=>{if(t||!(s!=null&&s.results))return;const f=P?s.results.map(y=>P[y.name]??y):s.results,b=f.find(y=>y.status==="completed")??f[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)},[s==null?void 0:s.results,P]);const A=v.useCallback(f=>{f.preventDefault(),d.current=!0;const b="touches"in f?f.touches[0].clientY:f.clientY,y=h,j=z=>{if(!d.current)return;const C=u.current;if(!C)return;const H="touches"in z?z.touches[0].clientY:z.clientY,U=C.clientHeight-100,q=Math.max(80,Math.min(U,y+(H-b)));c(q)},M=()=>{d.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",j),document.addEventListener("mouseup",M),document.addEventListener("touchmove",j,{passive:!1}),document.addEventListener("touchend",M)},[h]),D=v.useCallback(f=>{f.preventDefault(),x(!0);const b="touches"in f?f.touches[0].clientX:f.clientX,y=_,j=z=>{const C=w.current;if(!C)return;const H="touches"in z?z.touches[0].clientX:z.clientX,U=C.clientWidth-300,q=Math.max(280,Math.min(U,y+(b-H)));g(q)},M=()=>{x(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",j),document.addEventListener("mouseup",M),document.addEventListener("touchmove",j,{passive:!1}),document.addEventListener("touchend",M)},[_]);if(i)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!s)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval run not found"});const N=E??s,$=Yn[N.status]??Yn.pending,B=N.status==="running",T=Object.keys(N.evaluator_scores??{}).length>0?Object.keys(N.evaluator_scores):Object.keys(P?((p=Object.values(P).find(f=>Object.keys(f.scores).length>0))==null?void 0:p.scores)??{}:{}),O=P?s.results.map(f=>P[f.name]??f):s.results,L=O.find(f=>f.name===l)??null,R=((L==null?void 0:L.traces)??[]).map(f=>({...f,run_id:""}));return n.jsxs("div",{ref:w,className:"flex h-full",children:[n.jsxs("div",{ref:u,className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold truncate min-w-0",style:{color:"var(--text-primary)"},children:N.eval_set_name}),n.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold uppercase tracking-wide",style:{color:$.color,background:$.bg},children:$.label}),n.jsx("span",{className:"text-sm font-bold font-mono",style:{color:At(N.overall_score)},children:ms(N.overall_score)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:$h(N.start_time,N.end_time)}),B&&n.jsxs("div",{className:"flex items-center gap-2 max-w-[160px]",children:[n.jsx("div",{className:"flex-1 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${N.progress_total>0?N.progress_completed/N.progress_total*100:0}%`,background:"var(--info)"}})}),n.jsxs("span",{className:"text-[11px] shrink-0",style:{color:"var(--text-muted)"},children:[N.progress_completed,"/",N.progress_total]})]}),T.length>0&&n.jsx("div",{className:"flex gap-3 ml-auto",children:T.map(f=>{const b=k.find(j=>j.id===f),y=N.evaluator_scores[f];return n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:Xn((b==null?void 0:b.name)??f)}),n.jsx("div",{className:"w-12 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${y*100}%`,background:At(y)}})}),n.jsx("span",{className:"text-[11px] font-mono",style:{color:At(y)},children:ms(y)})]},f)})})]}),n.jsxs("div",{className:"shrink-0 overflow-hidden flex flex-col",style:{height:h},children:[n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-5 shrink-0"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Score"}),T.map(f=>{const b=k.find(y=>y.id===f);return n.jsx("span",{className:"w-36 shrink-0 text-right truncate pl-2",title:(b==null?void 0:b.name)??f,children:Xn((b==null?void 0:b.name)??f)},f)}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Time"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[O.map(f=>{const b=f.status==="pending",y=f.status==="failed",j=f.name===l;return n.jsxs("button",{onClick:()=>{a(j?`#/evals/runs/${e}`:`#/evals/runs/${e}/${encodeURIComponent(f.name)}`)},className:"w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:j?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:j?"2px solid var(--accent)":"2px solid transparent",opacity:b?.5:1},onMouseEnter:M=>{j||(M.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:M=>{j||(M.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-5 shrink-0 flex justify-center",children:n.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:b?"var(--text-muted)":y?"var(--error)":f.overall_score>=.8?"var(--success)":f.overall_score>=.5?"var(--warning)":"var(--error)"}})}),n.jsx("span",{className:"flex-1 min-w-0 truncate",style:{color:"var(--text-primary)"},children:f.name}),n.jsx("span",{className:"w-14 shrink-0 text-right font-mono font-semibold",style:{color:At(b?null:f.overall_score)},children:b?"-":ms(f.overall_score)}),T.map(M=>n.jsx("span",{className:"w-36 shrink-0 text-right font-mono pl-2",style:{color:At(b?null:f.scores[M]??null)},children:b?"-":ms(f.scores[M]??null)},M)),n.jsx("span",{className:"w-14 shrink-0 text-right",style:{color:"var(--text-muted)"},children:f.duration_ms!==null?`${(f.duration_ms/1e3).toFixed(1)}s`:"-"})]},f.name)}),O.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:B?"Waiting for results...":"No results"})]})]}),n.jsx("div",{onMouseDown:A,onTouchStart:A,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:L&&R.length>0?n.jsx(si,{traces:R}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:(L==null?void 0:L.status)==="pending"?"Pending...":"No traces available"})})]}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:`shrink-0 drag-handle-col${m?"":" transition-all"}`,style:{width:L?3:0,opacity:L?1:0}}),n.jsx(Uh,{width:_,item:L,evaluators:k,isRunning:B,isDragging:m})]})}const zh=[{id:"score",label:"Score"},{id:"io",label:"I/O"},{id:"logs",label:"Logs"}];function Uh({width:e,item:t,evaluators:s,isRunning:r,isDragging:i}){const[o,a]=v.useState("score"),l=!!t;return n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${i?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:l?e:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:e},children:[zh.map(h=>n.jsx("button",{onClick:()=>a(h.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:o===h.id?"var(--accent)":"var(--text-muted)",background:o===h.id?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},onMouseEnter:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-primary)")},onMouseLeave:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-muted)")},children:h.label},h.id)),r&&n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Running..."})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",style:{minWidth:e},children:t?t.status==="pending"?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Pending..."}):n.jsxs(n.Fragment,{children:[t.status==="failed"&&n.jsxs("div",{className:"mx-2 mt-2 px-3 py-2 rounded text-xs",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 4.5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"8",cy:"11",r:"0.75",fill:"currentColor"})]}),n.jsx("span",{children:"Evaluator error"})]}),t.error&&n.jsx("div",{className:"mt-1 pl-[22px] text-[11px] opacity-80 break-words",style:{color:"var(--text-secondary)"},children:t.error})]}),o==="score"?n.jsx(Kh,{item:t,evaluators:s}):o==="io"?n.jsx(Vh,{item:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Logs coming soon"})]}):null})]})}function Kh({item:e,evaluators:t}){const s=Object.keys(e.scores);return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Overall"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${e.overall_score*100}%`,background:At(e.overall_score)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(e.overall_score)},children:ms(e.overall_score)})]})]})}),e.status==="failed"&&s.length===0&&n.jsx("div",{className:"px-3 py-3 text-xs text-center",style:{color:"var(--text-muted)"},children:"All evaluators failed — no scores available"}),s.map(r=>{const i=t.find(l=>l.id===r),o=e.scores[r],a=e.justifications[r];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},title:(i==null?void 0:i.name)??r,children:(i==null?void 0:i.name)??r}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${o*100}%`,background:At(o)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(o)},children:ms(o)})]})]}),a&&n.jsx(Xh,{text:a})]},r)})]})}function Vh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2),r=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),r&&n.jsx(Ot,{title:"Expected Output",copyText:r,children:n.jsx(gt,{json:r,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),n.jsx(Ot,{title:"Output",copyText:s,trailing:e.duration_ms!==null?n.jsxs("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:[(e.duration_ms/1e3).toFixed(2),"s"]}):void 0,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})})]})}function qh(e){var i;const t=e.match(/expected="(.+?)"\s+actual="(.+?)"(.*)/s);if(!t)return null;const s={},r=((i=t[3])==null?void 0:i.trim())??"";if(r)for(const o of r.match(/(\w+)=([\S]+)/g)??[]){const a=o.indexOf("=");s[o.slice(0,a)]=o.slice(a+1)}return{expected:t[1],actual:t[2],meta:s}}function Gn(e){try{const t=e.replace(/'/g,'"').replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null"),s=JSON.parse(t);return JSON.stringify(s,null,2)}catch{return e}}function Xh({text:e}){const t=qh(e);if(!t)return n.jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:n.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--text-secondary)"},children:e})});const s=Gn(t.expected),r=Gn(t.actual),i=s===r;return n.jsxs("div",{className:"border-t",style:{borderColor:"var(--border)"},children:[n.jsxs("div",{className:"grid grid-cols-2 gap-0",children:[n.jsxs("div",{className:"px-3 py-2 border-r",style:{borderColor:"var(--border)"},children:[n.jsx("div",{className:"text-[10px] font-semibold mb-1",style:{color:"var(--text-muted)"},children:"Expected"}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:"var(--text-secondary)"},children:s})]}),n.jsxs("div",{className:"px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--text-muted)"},children:"Actual"}),n.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:i?"var(--success)":"var(--error)"}})]}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:i?"var(--success)":"var(--error)"},children:r})]})]}),Object.keys(t.meta).length>0&&n.jsx("div",{className:"px-3 py-1.5 border-t flex items-center gap-3",style:{borderColor:"var(--border)"},children:Object.entries(t.meta).map(([o,a])=>n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[n.jsx("span",{className:"font-medium",children:o.replace(/_/g," ")})," ",n.jsx("span",{className:"font-mono",children:a})]},o))})]})}const Jn={deterministic:"var(--success)",llm:"#a78bfa",tool:"var(--info)"};function Zn(){const e=xe(g=>g.localEvaluators),t=xe(g=>g.addEvalSet),{navigate:s}=et(),[r,i]=v.useState(""),[o,a]=v.useState(new Set),[l,h]=v.useState(null),[c,u]=v.useState(!1),d=g=>{a(m=>{const x=new Set(m);return x.has(g)?x.delete(g):x.add(g),x})},_=async()=>{if(r.trim()){h(null),u(!0);try{const g=await Oc({name:r.trim(),evaluator_refs:Array.from(o)});t(g),s(`#/evals/sets/${g.id}`)}catch(g){h(g.detail||g.message||"Failed to create eval set")}finally{u(!1)}}};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Eval Set"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluation set with a name and evaluators"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:r,onChange:g=>i(g.target.value),placeholder:"e.g. Basic QA Tests",className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},onKeyDown:g=>{g.key==="Enter"&&r.trim()&&_()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluators"}),e.length===0?n.jsxs("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:["No evaluators configured."," ",n.jsx("button",{onClick:()=>s("#/evaluators/new"),className:"underline cursor-pointer",style:{color:"var(--accent)",background:"none",border:"none",padding:0,font:"inherit"},children:"Create one first"})]}):n.jsx("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:e.map(g=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:m=>{m.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:o.has(g.id),onChange:()=>d(g.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:g.name}),n.jsx("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded",style:{background:`color-mix(in srgb, ${Jn[g.type]??"var(--text-muted)"} 15%, transparent)`,color:Jn[g.type]??"var(--text-muted)"},children:g.type})]},g.id))})]}),l&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:l}),n.jsx("button",{onClick:_,disabled:!r.trim()||c,className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:c?"Creating...":"Create Eval Set"})]})})}const Yh=[{type:"deterministic",label:"Deterministic",badgeColor:"var(--success)"},{type:"llm",label:"LLM Judge",badgeColor:"#a78bfa"},{type:"tool",label:"Tool-Based",badgeColor:"var(--info)"}];function Qn(){const e=xe(o=>o.localEvaluators),{evaluatorFilter:t,evaluatorCreateType:s,navigate:r}=et(),i=!t&&!s;return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>r("#/evaluators/new"),className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Evaluator"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Categories"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsxs("button",{onClick:()=>r("#/evaluators"),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:i?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)",borderLeft:i?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:o=>{i||(o.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:o=>{i||(o.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--text-muted)"}}),n.jsx("span",{className:"flex-1 truncate",children:"All"}),e.length>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.length})]}),Yh.map(o=>{const a=e.filter(h=>h.type===o.type).length,l=t===o.type;return n.jsxs("button",{onClick:()=>r(l?"#/evaluators":`#/evaluators/category/${o.type}`),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:l?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:l?"var(--text-primary)":"var(--text-secondary)",borderLeft:l?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:h=>{l||(h.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:h=>{l||(h.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:o.badgeColor}}),n.jsx("span",{className:"flex-1 truncate",children:o.label}),a>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a})]},o.type)})]})]})}const eo={deterministic:{label:"Deterministic",color:"var(--success)",bg:"rgba(34,197,94,0.1)"},llm:{label:"LLM Judge",color:"#a78bfa",bg:"rgba(167,139,250,0.1)"},tool:{label:"Tool-Based",color:"var(--info)",bg:"rgba(59,130,246,0.1)"}},ri={deterministic:"Deterministic",llm:"LLM Judge",tool:"Tool-Based"},Ps={deterministic:[{id:"uipath-exact-match",name:"Exact Match"},{id:"uipath-contains",name:"Contains"},{id:"uipath-json-similarity",name:"JSON Similarity"}],llm:[{id:"uipath-llm-judge-output-semantic-similarity",name:"LLM Judge Output"},{id:"uipath-llm-judge-output-strict-json-similarity",name:"LLM Judge Strict JSON"},{id:"uipath-llm-judge-trajectory-similarity",name:"LLM Judge Trajectory"},{id:"uipath-llm-judge-trajectory-simulation",name:"LLM Judge Trajectory Simulation"}],tool:[{id:"uipath-tool-call-order",name:"Tool Call Order"},{id:"uipath-tool-call-args",name:"Tool Call Args"},{id:"uipath-tool-call-count",name:"Tool Call Count"},{id:"uipath-tool-call-output",name:"Tool Call Output"}]};function Pa(e){return e.includes("trajectory")?{targetOutputKey:!1,prompt:!0}:e.includes("llm-judge")?{targetOutputKey:!0,prompt:!0}:e.includes("tool-call-output")?{targetOutputKey:!0,prompt:!1}:e.includes("exact-match")||e.includes("contains")||e.includes("json-similarity")?{targetOutputKey:!0,prompt:!1}:{targetOutputKey:!1,prompt:!1}}const $r={"uipath-exact-match":{description:"Checks whether the agent output exactly matches the expected output.",prompt:""},"uipath-contains":{description:"Checks whether the agent output contains the expected substring.",prompt:""},"uipath-json-similarity":{description:"Compares JSON structures for semantic similarity, ignoring key ordering and whitespace.",prompt:""},"uipath-llm-judge-output-semantic-similarity":{description:"Uses an LLM to score semantic similarity between the agent's actual output and the expected output, accounting for synonyms, paraphrases, and equivalent expressions.",prompt:`As an expert evaluator, analyze the semantic similarity between the expected and actual outputs and determine a score from 0 to 100. Focus on comparing meaning and contextual equivalence of corresponding fields, accounting for alternative valid expressions, synonyms, and reasonable variations in language while maintaining high standards for accuracy and completeness. Provide your score with a brief justification. + `}),n.jsxs(aa,{nodes:o,edges:h,onNodesChange:l,onEdgesChange:u,nodeTypes:fh,edgeTypes:ph,onInit:p=>{k.current=p},onNodeClick:R,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(la,{color:"var(--bg-tertiary)",gap:16}),n.jsx(ca,{showInteractive:!1}),n.jsx(dc,{position:"top-right",children:n.jsxs("button",{onClick:I,title:T?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:T?"var(--error)":"var(--text-muted)",border:`1px solid ${T?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[n.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:T?"var(--error)":"var(--node-border)"}}),T?"Clear all":"Break all"]})}),n.jsx(ha,{nodeColor:p=>{var y;if(p.type==="groupNode")return"var(--bg-tertiary)";const b=(y=p.data)==null?void 0:y.status;return b==="completed"?"var(--success)":b==="running"?"var(--warning)":b==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ts="__setup__";function _h({entrypoint:e,mode:t,ws:s,onRunCreated:r,isMobile:i}){const[o,a]=v.useState("{}"),[l,h]=v.useState({}),[c,u]=v.useState(!1),[d,_]=v.useState(!0),[g,m]=v.useState(null),[x,w]=v.useState(""),[E,k]=v.useState(!0),[P,O]=v.useState(()=>{const y=localStorage.getItem("setupTextareaHeight");return y?parseInt(y,10):140}),D=v.useRef(null),[j,F]=v.useState(()=>{const y=localStorage.getItem("setupPanelWidth");return y?parseInt(y,10):380}),R=t==="run";v.useEffect(()=>{_(!0),m(null),Sc(e).then(y=>{h(y.mock_input),a(JSON.stringify(y.mock_input,null,2))}).catch(y=>{console.error("Failed to load mock input:",y);const N=y.detail||{};m(N.message||`Failed to load schema for "${e}"`),a("{}")}).finally(()=>_(!1))},[e]),v.useEffect(()=>{de.getState().clearBreakpoints(ts)},[]);const T=async()=>{let y;try{y=JSON.parse(o)}catch{alert("Invalid JSON input");return}u(!0);try{const N=de.getState().breakpoints[ts]??{},M=Object.keys(N),U=await Sn(e,y,t,M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(U),r(U.id)}catch(N){console.error("Failed to create run:",N)}finally{u(!1)}},I=async()=>{const y=x.trim();if(y){u(!0);try{const N=de.getState().breakpoints[ts]??{},M=Object.keys(N),U=await Sn(e,l,"chat",M);de.getState().clearBreakpoints(ts),de.getState().upsertRun(U),de.getState().addLocalChatMessage(U.id,{message_id:`local-${Date.now()}`,role:"user",content:y}),s.sendChatMessage(U.id,y),r(U.id)}catch(N){console.error("Failed to create chat run:",N)}finally{u(!1)}}};v.useEffect(()=>{try{JSON.parse(o),k(!0)}catch{k(!1)}},[o]);const L=v.useCallback(y=>{y.preventDefault();const N="touches"in y?y.touches[0].clientY:y.clientY,M=P,U=W=>{const z="touches"in W?W.touches[0].clientY:W.clientY,A=Math.max(60,M+(N-z));O(A)},C=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(P))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",U),document.addEventListener("mouseup",C),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",C)},[P]),B=v.useCallback(y=>{y.preventDefault();const N="touches"in y?y.touches[0].clientX:y.clientX,M=j,U=W=>{const z=D.current;if(!z)return;const A="touches"in W?W.touches[0].clientX:W.clientX,Z=z.clientWidth-300,ie=Math.max(280,Math.min(Z,M+(N-A)));F(ie)},C=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",C),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(j))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",U),document.addEventListener("mouseup",C),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",C)},[j]),f=R?"Autonomous":"Conversational",p=R?"var(--success)":"var(--accent)",b=n.jsxs("div",{className:"shrink-0 flex flex-col",style:i?{background:"var(--bg-primary)"}:{width:j,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"px-4 text-xs font-semibold border-b flex items-center gap-2 h-10",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{style:{color:p},children:"●"}),f]}),n.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[n.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:R?n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("polyline",{points:"12 6 12 12 16 14"})]}):n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),n.jsxs("div",{className:"text-center space-y-1.5",children:[n.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:R?"Ready to execute":"Ready to chat"}),n.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",R?n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"configure input below, then run"]}):n.jsxs(n.Fragment,{children:[",",n.jsx("br",{}),"then send your first message"]})]})]})]}),R?n.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!i&&n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"px-4 py-3",children:[g?n.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:g}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:["Input",d&&n.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),n.jsx("textarea",{value:o,onChange:y=>a(y.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none mb-3",style:{height:i?120:P,background:"var(--bg-secondary)",border:`1px solid ${E?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),n.jsx("button",{onClick:T,disabled:c||d||!!g,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:p,color:p},onMouseEnter:y=>{c||(y.currentTarget.style.background=`color-mix(in srgb, ${p} 10%, transparent)`)},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:c?"Starting...":n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("input",{value:x,onChange:y=>w(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),I())},disabled:c||d,placeholder:c?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),n.jsx("button",{onClick:I,disabled:c||d||!x.trim(),className:"text-xs font-semibold px-3 py-1.5 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!c&&x.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:y=>{!c&&x.trim()&&(y.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:"Send"})]})]});return i?n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:b})]}):n.jsxs("div",{ref:D,className:"flex h-full",children:[n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(_r,{entrypoint:e,traces:[],runId:ts})}),n.jsx("div",{onMouseDown:B,onTouchStart:B,className:"shrink-0 drag-handle-col"}),b]})}const gh={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function mh(e){const t=[],s=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let r=0,i;for(;(i=s.exec(e))!==null;){if(i.index>r&&t.push({type:"punctuation",text:e.slice(r,i.index)}),i[1]!==void 0){t.push({type:"key",text:i[1]});const o=e.indexOf(":",i.index+i[1].length);o!==-1&&(o>i.index+i[1].length&&t.push({type:"punctuation",text:e.slice(i.index+i[1].length,o)}),t.push({type:"punctuation",text:":"}),s.lastIndex=o+1)}else i[2]!==void 0?t.push({type:"string",text:i[2]}):i[3]!==void 0?t.push({type:"number",text:i[3]}):i[4]!==void 0?t.push({type:"boolean",text:i[4]}):i[5]!==void 0?t.push({type:"null",text:i[5]}):i[6]!==void 0&&t.push({type:"punctuation",text:i[6]});r=s.lastIndex}return rmh(e),[e]);return n.jsx("pre",{className:t,style:s,children:r.map((i,o)=>n.jsx("span",{style:{color:gh[i.type]},children:i.text},o))})}const vh={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},xh={color:"var(--text-muted)",label:"Unknown"};function yh(e){if(typeof e!="string")return null;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}return null}const An=200;function bh(e){if(typeof e=="string")return e;if(e==null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Sh({value:e}){const[t,s]=v.useState(!1),r=bh(e),i=v.useMemo(()=>yh(e),[e]),o=i!==null,a=i??r,l=a.length>An||a.includes(` +`),h=v.useCallback(()=>s(c=>!c),[]);return l?n.jsxs("div",{children:[t?o?n.jsx(gt,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):n.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):n.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,An),"..."]}),n.jsx("button",{onClick:h,className:"text-[11px] cursor-pointer ml-1 px-1",style:{color:"var(--info)"},children:t?"[less]":"[more]"})]}):o?n.jsx(gt,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function wh({span:e}){const[t,s]=v.useState(!0),[r,i]=v.useState(!1),[o,a]=v.useState("table"),[l,h]=v.useState(!1),c=vh[e.status.toLowerCase()]??{...xh,label:e.status},u=v.useMemo(()=>JSON.stringify(e,null,2),[e]),d=v.useCallback(()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})},[u]),_=Object.entries(e.attributes),g=[{label:"Span",value:e.span_id},...e.trace_id?[{label:"Trace",value:e.trace_id}]:[],{label:"Run",value:e.run_id},...e.parent_span_id?[{label:"Parent",value:e.parent_span_id}]:[]];return n.jsxs("div",{className:"flex flex-col h-full text-xs leading-normal",children:[n.jsxs("div",{className:"px-2 border-b flex items-center gap-1 shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>a("table"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="table"?"var(--accent)":"var(--text-muted)",background:o==="table"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="table"&&(m.currentTarget.style.color="var(--text-muted)")},children:"Table"}),n.jsx("button",{onClick:()=>a("json"),className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:o==="json"?"var(--accent)":"var(--text-muted)",background:o==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{o!=="json"&&(m.currentTarget.style.color="var(--text-muted)")},children:"JSON"}),n.jsxs("span",{className:"ml-auto shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${c.color} 15%, var(--bg-secondary))`,color:c.color},children:[n.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:c.color}}),c.label]})]}),n.jsx("div",{className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:o==="table"?n.jsxs(n.Fragment,{children:[_.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>s(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Attributes (",_.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:t?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),t&&_.map(([m,x],w)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:w%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m,children:m}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx(Sh,{value:x})})]},m))]}),n.jsxs("div",{className:"px-2 py-1 text-[11px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--success)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>i(m=>!m),children:[n.jsxs("span",{className:"flex-1",children:["Identifiers (",g.length,")"]}),n.jsx("span",{style:{color:"var(--text-muted)",transform:r?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),r&&g.map((m,x)=>n.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:x%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:m.label,children:m.label}),n.jsx("span",{className:"flex-1 min-w-0",children:n.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:m.value})})]},m.label))]}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:d,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:l?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:m=>{l||(m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{m.currentTarget.style.color=l?"var(--success)":"var(--text-muted)"},children:l?"Copied!":"Copy"}),n.jsx(gt,{json:u,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]})}function Ch(e){const t=[];function s(r,i){t.push({span:r.span,depth:i});for(const o of r.children)s(o,i+1)}for(const r of e)s(r,0);return t}function kh({tree:e,selectedSpan:t,onSelect:s}){const r=v.useMemo(()=>Ch(e),[e]),{globalStart:i,totalDuration:o}=v.useMemo(()=>{if(r.length===0)return{globalStart:0,totalDuration:1};let a=1/0,l=-1/0;for(const{span:h}of r){const c=new Date(h.timestamp).getTime();a=Math.min(a,c),l=Math.max(l,c+(h.duration_ms??0))}return{globalStart:a,totalDuration:Math.max(l-a,1)}},[r]);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(({span:a,depth:l})=>{var x;const h=new Date(a.timestamp).getTime()-i,c=a.duration_ms??0,u=h/o*100,d=Math.max(c/o*100,.3),_=La[a.status.toLowerCase()]??"var(--text-muted)",g=a.span_id===(t==null?void 0:t.span_id),m=(x=a.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("button",{"data-span-id":a.span_id,onClick:()=>s(a),className:"w-full text-left text-xs leading-normal py-1 flex items-center transition-colors",style:{background:g?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:g?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{g||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{g||(w.currentTarget.style.background="")},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-1 overflow-hidden",style:{width:"35%",minWidth:"80px",paddingLeft:`${l*12+4}px`},children:[n.jsx("span",{className:"shrink-0 flex items-center justify-center w-3.5 h-3.5",children:n.jsx(Ta,{kind:m,statusColor:_})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate",children:a.span_name})]}),n.jsx("div",{className:"flex-1 relative h-[14px] mx-1 rounded-sm",style:{background:"var(--bg-secondary)"},children:n.jsx("div",{className:"absolute rounded-sm",style:{left:`${u}%`,width:`${d}%`,top:"2px",bottom:"2px",background:_,opacity:.8,minWidth:"2px"}})}),n.jsx("span",{className:"shrink-0 text-[10px] tabular-nums pr-2",style:{width:"52px",textAlign:"right",color:"var(--text-muted)"},children:Ra(a.duration_ms)})]},a.span_id)})})}const La={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function Ta({kind:e,statusColor:t}){const s=t,r=14,i={width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:s,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"LLM":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:s,stroke:"none"})});case"TOOL":return n.jsx("svg",{...i,children:n.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),n.jsx("circle",{cx:"6",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("circle",{cx:"10",cy:"9",r:"1",fill:s,stroke:"none"}),n.jsx("path",{d:"M8 2v3"}),n.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return n.jsxs("svg",{...i,children:[n.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),n.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),n.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return n.jsxs("svg",{...i,children:[n.jsx("circle",{cx:"7",cy:"7",r:"4"}),n.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return n.jsxs("svg",{...i,children:[n.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),n.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return n.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:t}})}}function Eh(e){const t=new Map(e.map(a=>[a.span_id,a])),s=new Map;for(const a of e)if(a.parent_span_id){const l=s.get(a.parent_span_id)??[];l.push(a),s.set(a.parent_span_id,l)}const r=e.filter(a=>a.parent_span_id===null||!t.has(a.parent_span_id));function i(a){const l=(s.get(a.span_id)??[]).sort((h,c)=>h.timestamp.localeCompare(c.timestamp));return{span:a,children:l.map(i)}}return r.sort((a,l)=>a.timestamp.localeCompare(l.timestamp)).map(i).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function Ra(e){return e==null?"":e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`}function Ba(e){return e.map(t=>{const{span:s}=t;return t.children.length>0?{name:s.span_name,children:Ba(t.children)}:{name:s.span_name}})}function si({traces:e}){const[t,s]=v.useState(null),[r,i]=v.useState(new Set),[o,a]=v.useState(()=>{const R=localStorage.getItem("traceTreeSplitWidth");return R?parseFloat(R):50}),[l,h]=v.useState(!1),[c,u]=v.useState(!1),[d,_]=v.useState(()=>localStorage.getItem("traceViewMode")||"tree"),g=Eh(e),m=v.useMemo(()=>JSON.stringify(Ba(g),null,2),[e]),x=v.useCallback(()=>{navigator.clipboard.writeText(m).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[m]),w=de(R=>R.focusedSpan),E=de(R=>R.setFocusedSpan),[k,P]=v.useState(null),O=v.useRef(null),D=v.useCallback(R=>{i(T=>{const I=new Set(T);return I.has(R)?I.delete(R):I.add(R),I})},[]),j=v.useRef(null);v.useEffect(()=>{const R=g.length>0?g[0].span.span_id:null,T=j.current;if(j.current=R,R&&R!==T)s(g[0].span);else if(t===null)g.length>0&&s(g[0].span);else{const I=e.find(L=>L.span_id===t.span_id);I&&I!==t&&s(I)}},[e]),v.useEffect(()=>{if(!w)return;const T=e.filter(I=>I.span_name===w.name).sort((I,L)=>I.timestamp.localeCompare(L.timestamp))[w.index];if(T){s(T),P(T.span_id);const I=new Map(e.map(L=>[L.span_id,L.parent_span_id]));i(L=>{const B=new Set(L);let f=T.parent_span_id;for(;f;)B.delete(f),f=I.get(f)??null;return B})}E(null)},[w,e,E]),v.useEffect(()=>{if(!k)return;const R=k;P(null),requestAnimationFrame(()=>{const T=O.current,I=T==null?void 0:T.querySelector(`[data-span-id="${R}"]`);T&&I&&I.scrollIntoView({block:"center",behavior:"smooth"})})},[k]),v.useEffect(()=>{if(!l)return;const R=I=>{const L=document.querySelector(".trace-tree-container");if(!L)return;const B=L.getBoundingClientRect(),f=(I.clientX-B.left)/B.width*100,p=Math.max(20,Math.min(80,f));a(p),localStorage.setItem("traceTreeSplitWidth",String(p))},T=()=>{h(!1)};return window.addEventListener("mousemove",R),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)}},[l]);const F=R=>{R.preventDefault(),h(!0)};return n.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:l?"col-resize":void 0},children:[n.jsxs("div",{className:"flex flex-col",style:{width:`${o}%`},children:[e.length>0&&n.jsxs("div",{className:"flex items-center gap-1 px-2 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",height:"32px"},children:[n.jsx("button",{onClick:()=>{_("tree"),localStorage.setItem("traceViewMode","tree")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="tree"?"var(--accent)":"var(--text-muted)",background:d==="tree"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:R=>{d!=="tree"&&(R.currentTarget.style.color="var(--text-primary)")},onMouseLeave:R=>{d!=="tree"&&(R.currentTarget.style.color="var(--text-muted)")},children:"Tree"}),n.jsx("button",{onClick:()=>{_("timeline"),localStorage.setItem("traceViewMode","timeline")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="timeline"?"var(--accent)":"var(--text-muted)",background:d==="timeline"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:R=>{d!=="timeline"&&(R.currentTarget.style.color="var(--text-primary)")},onMouseLeave:R=>{d!=="timeline"&&(R.currentTarget.style.color="var(--text-muted)")},children:"Timeline"}),n.jsx("button",{onClick:()=>{_("json"),localStorage.setItem("traceViewMode","json")},className:"px-2.5 h-6 text-[11px] font-semibold rounded transition-colors cursor-pointer inline-flex items-center",style:{color:d==="json"?"var(--accent)":"var(--text-muted)",background:d==="json"?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent"},onMouseEnter:R=>{d!=="json"&&(R.currentTarget.style.color="var(--text-primary)")},onMouseLeave:R=>{d!=="json"&&(R.currentTarget.style.color="var(--text-muted)")},children:"JSON"})]}),n.jsx("div",{ref:O,className:"overflow-y-auto flex-1 p-0.5 pr-0 pt-0 mr-0.5 mt-0.5",children:g.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):d==="tree"?g.map((R,T)=>n.jsx(Da,{node:R,depth:0,selectedId:(t==null?void 0:t.span_id)??null,onSelect:s,isLast:T===g.length-1,collapsedIds:r,toggleExpanded:D},R.span.span_id)):d==="timeline"?n.jsx(kh,{tree:g,selectedSpan:t,onSelect:s}):n.jsxs("div",{className:"relative",children:[n.jsx("button",{onClick:x,className:"absolute top-1 right-1 z-10 text-[11px] cursor-pointer px-2 py-1 rounded transition-colors",style:{color:c?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:R=>{c||(R.currentTarget.style.color="var(--text-primary)")},onMouseLeave:R=>{R.currentTarget.style.color=c?"var(--success)":"var(--text-muted)"},children:c?"Copied!":"Copy"}),n.jsx(gt,{json:m,className:"font-mono text-[11px] whitespace-pre-wrap p-2",style:{}})]})})]}),n.jsx("div",{onMouseDown:F,className:"shrink-0 drag-handle-col",style:l?{background:"var(--accent)"}:void 0}),n.jsx("div",{className:"flex-1 overflow-hidden",children:t?n.jsx(wh,{span:t}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function Da({node:e,depth:t,selectedId:s,onSelect:r,isLast:i,collapsedIds:o,toggleExpanded:a}){var x;const{span:l}=e,h=!o.has(l.span_id),c=La[l.status.toLowerCase()]??"var(--text-muted)",u=Ra(l.duration_ms),d=l.span_id===s,_=e.children.length>0,g=t*20,m=(x=l.attributes)==null?void 0:x["openinference.span.kind"];return n.jsxs("div",{className:"relative",children:[t>0&&n.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${g-10}px`,width:"1px",height:i?"16px":"100%",background:"var(--border)"}}),n.jsxs("button",{"data-span-id":l.span_id,onClick:()=>r(l),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${g+4}px`,background:d?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":void 0,borderLeft:d?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:w=>{d||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{d||(w.currentTarget.style.background="")},children:[t>0&&n.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${g-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),_?n.jsx("span",{onClick:w=>{w.stopPropagation(),a(l.span_id)},className:"shrink-0 w-5 h-5 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("span",{className:"shrink-0 w-4"}),n.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:n.jsx(Ta,{kind:m,statusColor:c})}),n.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:l.span_name}),u&&n.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:u})]}),h&&e.children.map((w,E)=>n.jsx(Da,{node:w,depth:t+1,selectedId:s,onSelect:r,isLast:E===e.children.length-1,collapsedIds:o,toggleExpanded:a},w.span.span_id))]})}const Nh={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},jh={color:"var(--text-muted)",bg:"transparent"};function On({logs:e}){const t=v.useRef(null),s=v.useRef(null),[r,i]=v.useState(!1);v.useEffect(()=>{var a;(a=s.current)==null||a.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const a=t.current;a&&i(a.scrollTop>100)};return e.length===0?n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):n.jsxs("div",{className:"h-full relative",children:[n.jsxs("div",{ref:t,onScroll:o,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[e.map((a,l)=>{const h=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),c=a.level.toUpperCase(),u=c.slice(0,4),d=Nh[c]??jh,_=l%2===0;return n.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:_?"var(--bg-primary)":"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:h}),n.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:d.color,background:d.bg},children:u}),n.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},l)}),n.jsx("div",{ref:s})]}),r&&n.jsx("button",{onClick:()=>{var a;return(a=t.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const Mh={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},In={color:"var(--text-muted)",label:""};function er({events:e,runStatus:t}){const s=v.useRef(null),r=v.useRef(!0),[i,o]=v.useState(null),a=()=>{const l=s.current;l&&(r.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return v.useEffect(()=>{r.current&&s.current&&(s.current.scrollTop=s.current.scrollHeight)}),e.length===0?n.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:n.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t==="running"?"Waiting for events...":"No events yet"})}):n.jsx("div",{ref:s,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:e.map((l,h)=>{const c=new Date(l.timestamp).toLocaleTimeString(void 0,{hour12:!1}),u=l.payload&&Object.keys(l.payload).length>0,d=i===h,_=l.phase?Mh[l.phase]??In:In;return n.jsxs("div",{children:[n.jsxs("div",{onClick:()=>{u&&o(d?null:h)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:h%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:u?"pointer":"default"},children:[n.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:c}),n.jsx("span",{className:"shrink-0",style:{color:_.color},children:"●"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:l.node_name}),_.label&&n.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:_.label}),u&&n.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:d?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),d&&u&&n.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:n.jsx(gt,{json:JSON.stringify(l.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},h)})})}function Ot({title:e,copyText:t,trailing:s,children:r}){const[i,o]=v.useState(!1),a=v.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[t]);return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:e}),s,t&&n.jsx("button",{onClick:a,className:`${s?"":"ml-auto "}text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-colors`,style:{color:i?"var(--success)":"var(--text-muted)",background:"var(--bg-tertiary)",border:"none"},onMouseEnter:l=>{i||(l.currentTarget.style.color="var(--text-primary)")},onMouseLeave:l=>{l.currentTarget.style.color=i?"var(--success)":"var(--text-muted)"},children:i?"Copied":"Copy"})]}),r]})}function Wn({runId:e,status:t,ws:s,breakpointNode:r}){const i=t==="suspended",o=a=>{const l=de.getState().breakpoints[e]??{};s.setBreakpoints(e,Object.keys(l)),a==="step"?s.debugStep(e):a==="continue"?s.debugContinue(e):s.debugStop(e)};return n.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),n.jsx(Hr,{label:"Step",onClick:()=>o("step"),disabled:!i,color:"var(--info)",active:i}),n.jsx(Hr,{label:"Continue",onClick:()=>o("continue"),disabled:!i,color:"var(--success)",active:i}),n.jsx(Hr,{label:"Stop",onClick:()=>o("stop"),disabled:!i,color:"var(--error)",active:i}),n.jsx("span",{className:"text-[11px] ml-auto truncate",style:{color:i?"var(--accent)":"var(--text-muted)"},children:i?r?`Paused at ${r}`:"Paused":t})]})}function Hr({label:e,onClick:t,disabled:s,color:r,active:i}){return n.jsx("button",{onClick:t,disabled:s,className:"px-3 py-1 h-7 text-[11px] font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:i?r:"var(--text-muted)",background:i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},onMouseEnter:o=>{s||(o.currentTarget.style.background=`color-mix(in srgb, ${r} 20%, transparent)`)},onMouseLeave:o=>{o.currentTarget.style.background=i?`color-mix(in srgb, ${r} 10%, transparent)`:"transparent"},children:e})}const Hn=v.lazy(()=>ba(()=>import("./ChatPanel-CvZbTGws.js"),__vite__mapDeps([2,1,3,4]))),Lh=[],Th=[],Rh=[],Bh=[];function Dh({run:e,ws:t,isMobile:s}){const r=e.mode==="chat",[i,o]=v.useState(280),[a,l]=v.useState(()=>{const f=localStorage.getItem("chatPanelWidth");return f?parseInt(f,10):380}),[h,c]=v.useState("primary"),[u,d]=v.useState(r?"primary":"traces"),_=v.useRef(null),g=v.useRef(null),m=v.useRef(!1),x=de(f=>f.traces[e.id]||Lh),w=de(f=>f.logs[e.id]||Th),E=de(f=>f.chatMessages[e.id]||Rh),k=de(f=>f.stateEvents[e.id]||Bh),P=de(f=>f.breakpoints[e.id]);v.useEffect(()=>{t.setBreakpoints(e.id,P?Object.keys(P):[])},[e.id]);const O=v.useCallback(f=>{t.setBreakpoints(e.id,f)},[e.id,t]),D=v.useCallback(f=>{f.preventDefault(),m.current=!0;const p="touches"in f?f.touches[0].clientY:f.clientY,b=i,y=M=>{if(!m.current)return;const U=_.current;if(!U)return;const C="touches"in M?M.touches[0].clientY:M.clientY,W=U.clientHeight-100,z=Math.max(80,Math.min(W,b+(C-p)));o(z)},N=()=>{m.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",N),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",N)},[i]),j=v.useCallback(f=>{f.preventDefault();const p="touches"in f?f.touches[0].clientX:f.clientX,b=a,y=M=>{const U=g.current;if(!U)return;const C="touches"in M?M.touches[0].clientX:M.clientX,W=U.clientWidth-300,z=Math.max(280,Math.min(W,b+(p-C)));l(z)},N=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a))};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",N),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",N)},[a]),F=r?"Chat":"Events",R=r?"var(--accent)":"var(--success)",T=f=>f==="primary"?R:f==="events"?"var(--success)":"var(--accent)",I=de(f=>f.activeInterrupt[e.id]??null),L=e.status==="running"?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:r?"Thinking...":"Running..."}):r&&e.status==="suspended"&&I?n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(s){const f=[{id:"traces",label:"Traces",count:x.length},{id:"primary",label:F},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{className:"flex flex-col h-full",children:[(e.mode==="debug"||e.status==="suspended"&&!I||P&&Object.keys(P).length>0)&&n.jsx(Wn,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:O})}),n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[f.map(p=>n.jsxs("button",{onClick:()=>d(p.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:u===p.id?T(p.id):"var(--text-muted)",background:u===p.id?`color-mix(in srgb, ${T(p.id)} 10%, transparent)`:"transparent"},children:[p.label,p.count!==void 0&&p.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:p.count})]},p.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[u==="traces"&&n.jsx(si,{traces:x}),u==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Hn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),u==="events"&&n.jsx(er,{events:k,runStatus:e.status}),u==="io"&&n.jsx($n,{run:e}),u==="logs"&&n.jsx(On,{logs:w})]})]})}const B=[{id:"primary",label:F},...r?[{id:"events",label:"Events",count:k.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:w.length}];return n.jsxs("div",{ref:g,className:"flex h-full",children:[n.jsxs("div",{ref:_,className:"flex flex-col flex-1 min-w-0",children:[(e.mode==="debug"||e.status==="suspended"&&!I||P&&Object.keys(P).length>0)&&n.jsx(Wn,{runId:e.id,status:e.status,ws:t,breakpointNode:e.breakpoint_node}),n.jsx("div",{className:"shrink-0 overflow-hidden",style:{height:i},children:n.jsx(_r,{entrypoint:e.entrypoint,traces:x,runId:e.id,breakpointNode:e.breakpoint_node,breakpointNextNodes:e.breakpoint_next_nodes,onBreakpointChange:O})}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(si,{traces:x})})]}),n.jsx("div",{onMouseDown:j,onTouchStart:j,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[B.map(f=>n.jsxs("button",{onClick:()=>c(f.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:h===f.id?T(f.id):"var(--text-muted)",background:h===f.id?`color-mix(in srgb, ${T(f.id)} 10%, transparent)`:"transparent"},onMouseEnter:p=>{h!==f.id&&(p.currentTarget.style.color="var(--text-primary)")},onMouseLeave:p=>{h!==f.id&&(p.currentTarget.style.color="var(--text-muted)")},children:[f.label,f.count!==void 0&&f.count>0&&n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:f.count})]},f.id)),L]}),n.jsxs("div",{className:"flex-1 overflow-hidden",children:[h==="primary"&&(r?n.jsx(v.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:n.jsx(Hn,{messages:E,runId:e.id,runStatus:e.status,ws:t})}):n.jsx(er,{events:k,runStatus:e.status})),h==="events"&&n.jsx(er,{events:k,runStatus:e.status}),h==="io"&&n.jsx($n,{run:e}),h==="logs"&&n.jsx(On,{logs:w})]})]})]})}function $n({run:e}){return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:JSON.stringify(e.input_data,null,2),children:n.jsx(gt,{json:JSON.stringify(e.input_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.output_data&&n.jsx(Ot,{title:"Output",copyText:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),children:n.jsx(gt,{json:typeof e.output_data=="string"?e.output_data:JSON.stringify(e.output_data,null,2),className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.error&&n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[n.jsxs("div",{className:"px-3 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[n.jsx("span",{children:"Error"}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.code}),n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:e.error.category})]}),n.jsxs("div",{className:"px-3 py-2 text-xs leading-normal",children:[n.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:e.error.title}),n.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:e.error.detail})]})]})]})}function Fn(){const{reloadPending:e,setReloadPending:t,setEntrypoints:s}=de(),[r,i]=v.useState(!1);if(!e)return null;const o=async()=>{i(!0);try{await Cc();const a=await $i();s(a.map(l=>l.name)),t(!1)}catch(a){console.error("Reload failed:",a)}finally{i(!1)}};return n.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2 rounded-lg shadow-lg",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[n.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Files changed"}),n.jsx("button",{onClick:o,disabled:r,className:"px-2.5 py-0.5 text-xs font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:r?.6:1},children:r?"Reloading...":"Reload"}),n.jsx("button",{onClick:()=>t(!1),"aria-label":"Dismiss reload prompt",className:"text-xs cursor-pointer px-0.5",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})}let Ph=0;const zn=Jt(e=>({toasts:[],addToast:(t,s)=>{const r=String(++Ph);e(o=>({toasts:[...o.toasts,{id:r,type:t,message:s}]})),setTimeout(()=>{e(o=>({toasts:o.toasts.filter(a=>a.id!==r)}))},t==="error"?8e3:5e3)},removeToast:t=>{e(s=>({toasts:s.toasts.filter(r=>r.id!==t)}))}})),Un={success:{color:"var(--success)",bg:"color-mix(in srgb, var(--success) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--success) 30%, var(--border))"},error:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--error) 30%, var(--border))"},info:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 10%, var(--bg-elevated))",border:"color-mix(in srgb, var(--info) 30%, var(--border))"}};function Kn(){const e=zn(s=>s.toasts),t=zn(s=>s.removeToast);return e.length===0?null:n.jsx("div",{className:"fixed bottom-8 right-4 z-[100] flex flex-col gap-2 pointer-events-none",children:e.map(s=>{const r=Un[s.type]??Un.info;return n.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-lg shadow-lg text-xs font-medium max-w-xs animate-[slideIn_0.2s_ease-out]",style:{background:r.bg,border:`1px solid ${r.border}`,color:r.color},children:[n.jsx("span",{className:"flex-1",children:s.message}),n.jsx("button",{onClick:()=>t(s.id),className:"shrink-0 w-5 h-5 flex items-center justify-center rounded cursor-pointer transition-opacity opacity-60 hover:opacity-100",style:{color:r.color,background:"transparent",border:"none"},"aria-label":"Dismiss",children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[n.jsx("line",{x1:"1",y1:"1",x2:"9",y2:"9"}),n.jsx("line",{x1:"9",y1:"1",x2:"1",y2:"9"})]})})]},s.id)})})}function Ah(e){return e===null?"-":`${Math.round(e*100)}%`}function Oh(e){if(e===null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}const Vn={pending:{color:"var(--text-muted)",label:"Pending"},running:{color:"var(--info)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"}};function qn(){const e=me(l=>l.evalSets),t=me(l=>l.evalRuns),{evalSetId:s,evalRunId:r,navigate:i}=et(),o=Object.values(e),a=Object.values(t).sort((l,h)=>new Date(h.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("button",{onClick:()=>i("#/evals/new"),className:"w-[calc(100%-24px)] mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] text-center font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-secondary)",l.currentTarget.style.borderColor=""},children:"+ New Eval Set"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Eval Sets"}),o.map(l=>{const h=s===l.id;return n.jsxs("button",{onClick:()=>i(`#/evals/sets/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:c=>{h||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{h||(c.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"truncate font-medium",children:l.name}),n.jsxs("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:[l.eval_count," items · ",l.evaluator_ids.length," evaluator",l.evaluator_ids.length!==1?"s":""]})]},l.id)}),o.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval sets yet"}),n.jsx("div",{className:"px-3 pt-4 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),a.map(l=>{const h=r===l.id,c=Vn[l.status]??Vn.pending;return n.jsx("button",{onClick:()=>i(`#/evals/runs/${l.id}`),className:"w-full text-left px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{background:h?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:h?"var(--text-primary)":"var(--text-secondary)",borderLeft:h?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:u=>{h||(u.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:u=>{h||(u.currentTarget.style.background="transparent")},children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c.color}}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"truncate font-medium",children:l.eval_set_name}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:l.start_time?new Date(l.start_time).toLocaleString():c.label})]}),n.jsx("span",{className:"font-mono shrink-0",style:{color:Oh(l.overall_score)},children:Ah(l.overall_score)})]})},l.id)}),a.length===0&&n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"No eval runs yet"})]})}function Xn(e,t=60){const s=typeof e=="string"?e:JSON.stringify(e);return!s||s==="null"?"-":s.length>t?s.slice(0,t)+"...":s}function Ih({evalSetId:e}){const[t,s]=v.useState(null),[r,i]=v.useState(!0),[o,a]=v.useState(null),[l,h]=v.useState(!1),[c,u]=v.useState("io"),d=me(C=>C.evaluators),_=me(C=>C.localEvaluators),g=me(C=>C.updateEvalSetEvaluators),m=me(C=>C.incrementEvalSetCount),x=me(C=>C.upsertEvalRun),{navigate:w}=et(),[E,k]=v.useState(!1),[P,O]=v.useState(new Set),[D,j]=v.useState(!1),F=v.useRef(null),[R,T]=v.useState(()=>{const C=localStorage.getItem("evalSetSidebarWidth");return C?parseInt(C,10):320}),[I,L]=v.useState(!1),B=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSetSidebarWidth",String(R))},[R]),v.useEffect(()=>{i(!0),a(null),Hc(e).then(C=>{s(C),C.items.length>0&&a(C.items[0].name)}).catch(console.error).finally(()=>i(!1))},[e]);const f=async()=>{h(!0);try{const C=await $c(e);x(C),w(`#/evals/runs/${C.id}`)}catch(C){console.error(C)}finally{h(!1)}},p=async C=>{if(t)try{await Wc(e,C),s(W=>{if(!W)return W;const z=W.items.filter(A=>A.name!==C);return{...W,items:z,eval_count:z.length}}),m(e,-1),o===C&&a(null)}catch(W){console.error(W)}},b=v.useCallback(()=>{t&&O(new Set(t.evaluator_ids)),k(!0)},[t]),y=C=>{O(W=>{const z=new Set(W);return z.has(C)?z.delete(C):z.add(C),z})},N=async()=>{if(t){j(!0);try{const C=await Uc(e,Array.from(P));s(C),g(e,C.evaluator_ids),k(!1)}catch(C){console.error(C)}finally{j(!1)}}};v.useEffect(()=>{if(!E)return;const C=W=>{F.current&&!F.current.contains(W.target)&&k(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[E]);const M=v.useCallback(C=>{C.preventDefault(),L(!0);const W="touches"in C?C.touches[0].clientX:C.clientX,z=R,A=ie=>{const K=B.current;if(!K)return;const se="touches"in ie?ie.touches[0].clientX:ie.clientX,pe=K.clientWidth-300,_e=Math.max(280,Math.min(pe,z+(W-se)));T(_e)},Z=()=>{L(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",A),document.removeEventListener("touchend",Z),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",A),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",A,{passive:!1}),document.addEventListener("touchend",Z)},[R]);if(r)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!t)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval set not found"});const U=t.items.find(C=>C.name===o)??null;return n.jsxs("div",{ref:B,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:t.name}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[t.eval_count," items"]}),n.jsxs("div",{className:"flex gap-1 items-center ml-auto relative",children:[n.jsx("button",{onClick:b,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-muted)",C.currentTarget.style.background="transparent"},title:"Edit evaluators","aria-label":"Edit evaluators",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),n.jsx("path",{d:"m15 5 4 4"})]})}),t.evaluator_ids.map(C=>{const W=d.find(z=>z.id===C);return n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:(W==null?void 0:W.name)??C},C)}),E&&n.jsxs("div",{ref:F,className:"absolute top-full right-0 mt-1 z-50 rounded-md border shadow-lg",style:{background:"var(--bg-primary)",borderColor:"var(--border)",minWidth:220},children:[n.jsx("div",{className:"px-3 py-2 border-b text-[10px] uppercase tracking-wide font-semibold",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:"Evaluators"}),n.jsx("div",{className:"max-h-48 overflow-y-auto",children:_.length===0?n.jsx("div",{className:"px-3 py-3 text-xs",style:{color:"var(--text-muted)"},children:"No evaluators available"}):_.map(C=>n.jsxs("label",{className:"flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:W=>{W.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:P.has(C.id),onChange:()=>y(C.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:C.name})]},C.id))}),n.jsx("div",{className:"px-3 py-2 border-t flex justify-end",style:{borderColor:"var(--border)"},children:n.jsx("button",{onClick:N,disabled:D,className:"px-3 py-1 text-[11px] font-semibold rounded cursor-pointer transition-colors disabled:opacity-50",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},onMouseEnter:C=>{C.currentTarget.style.background="var(--accent-hover)"},onMouseLeave:C=>{C.currentTarget.style.background="var(--accent)"},children:D?"Saving...":"Update"})})]})]}),n.jsxs("button",{onClick:f,disabled:l,className:"ml-2 px-3 py-1 h-7 text-xs font-semibold rounded border flex items-center gap-1.5 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--success)",borderColor:"var(--success)",background:"transparent"},onMouseEnter:C=>{l||(C.currentTarget.style.background="color-mix(in srgb, var(--success) 10%, transparent)")},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},title:"Run eval set","aria-label":"Run eval set",children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:n.jsx("polygon",{points:"5,3 19,12 5,21"})}),l?"Running...":"Run"]})]}),n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-56 shrink-0",children:"Name"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Input"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Behavior"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Expected Output"}),n.jsx("span",{className:"w-32 shrink-0 pl-2",children:"Simulation Instr."}),n.jsx("span",{className:"w-8 shrink-0"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.items.map(C=>{const W=C.name===o;return n.jsxs("button",{onClick:()=>a(W?null:C.name),className:"group w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:W?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:W?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:z=>{W||(z.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:z=>{W||(z.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-56 shrink-0 truncate",style:{color:"var(--text-primary)"},children:C.name}),n.jsx("span",{className:"flex-1 min-w-0 truncate font-mono text-[11px]",style:{color:"var(--text-muted)"},children:Xn(C.inputs)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.expected_behavior||"-"}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:Xn(C.expected_output,40)}),n.jsx("span",{className:"w-32 shrink-0 truncate pl-2 text-[11px]",style:{color:"var(--text-muted)"},children:C.simulation_instructions||"-"}),n.jsx("span",{role:"button",tabIndex:0,className:"w-8 shrink-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:z=>{z.stopPropagation(),p(C.name)},onKeyDown:z=>{z.key==="Enter"&&(z.stopPropagation(),p(C.name))},style:{color:"var(--text-muted)"},onMouseEnter:z=>{z.currentTarget.style.color="var(--error)"},onMouseLeave:z=>{z.currentTarget.style.color="var(--text-muted)"},title:"Delete item",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},C.name)}),t.items.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:"No items in this eval set"})]})]}),n.jsx("div",{onMouseDown:M,onTouchStart:M,className:`shrink-0 drag-handle-col${I?"":" transition-all"}`,style:{width:U?3:0,opacity:U?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${I?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:U?R:0,background:"var(--bg-primary)"},children:[n.jsx("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:R},children:["io","evaluators"].map(C=>{const W=c===C,z=C==="io"?"I/O":"Evaluators";return n.jsx("button",{onClick:()=>u(C),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded inline-flex items-center cursor-pointer transition-colors",style:{color:W?"var(--accent)":"var(--text-muted)",background:W?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},children:z},C)})}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:R},children:U?c==="io"?n.jsx(Wh,{item:U}):n.jsx(Hh,{item:U,evaluators:d}):null})]})]})}function Wh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.expected_behavior&&n.jsx(Ot,{title:"Expected Behavior",copyText:e.expected_behavior,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.expected_behavior})}),s&&n.jsx(Ot,{title:"Expected Output",copyText:s,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),e.simulation_instructions&&n.jsx(Ot,{title:"Simulation Instructions",copyText:e.simulation_instructions,children:n.jsx("div",{className:"px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:e.simulation_instructions})})]})}function Hh({item:e,evaluators:t}){return n.jsx("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:e.evaluator_ids.length>0?n.jsx(n.Fragment,{children:e.evaluator_ids.map(s=>{var o;const r=t.find(a=>a.id===s),i=(o=e.evaluation_criterias)==null?void 0:o[s];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:(r==null?void 0:r.name)??s}),n.jsx("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:i?"Custom criteria":"Default criteria"})]}),i&&n.jsx("pre",{className:"px-3 py-2 border-t text-[11px] font-mono overflow-x-auto max-h-32 whitespace-pre-wrap break-words",style:{borderColor:"var(--border)",color:"var(--text-secondary)"},children:JSON.stringify(i,null,2)})]},s)})}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"No evaluators configured for this item"})})}function ms(e){return e==null?"-":`${Math.round(e*100)}%`}function At(e){if(e==null)return"var(--text-muted)";const t=e*100;return t>=80?"var(--success)":t>=50?"var(--warning)":"var(--error)"}function $h(e,t){if(!e)return"-";const s=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.round((r-s)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function Yn(e){return e.replace(/\s*Evaluator$/i,"")}const Gn={pending:{color:"var(--text-muted)",bg:"var(--bg-tertiary)",label:"Pending"},running:{color:"var(--info)",bg:"rgba(59,130,246,0.1)",label:"Running"},completed:{color:"var(--success)",bg:"rgba(34,197,94,0.1)",label:"Completed"},failed:{color:"var(--error)",bg:"rgba(239,68,68,0.1)",label:"Failed"}};function Fh({evalRunId:e,itemName:t}){var f;const[s,r]=v.useState(null),[i,o]=v.useState(!0),{navigate:a}=et(),l=t??null,[h,c]=v.useState(220),u=v.useRef(null),d=v.useRef(!1),[_,g]=v.useState(()=>{const p=localStorage.getItem("evalSidebarWidth");return p?parseInt(p,10):320}),[m,x]=v.useState(!1),w=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evalSidebarWidth",String(_))},[_]);const E=me(p=>p.evalRuns[e]),k=me(p=>p.evaluators),P=me(p=>p.streamingResults[e]);v.useEffect(()=>{o(!0),Cn(e).then(p=>{if(r(p),!t){const b=p.results.find(y=>y.status==="completed")??p.results[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)}}).catch(console.error).finally(()=>o(!1))},[e]),v.useEffect(()=>{((E==null?void 0:E.status)==="completed"||(E==null?void 0:E.status)==="failed")&&Cn(e).then(r).catch(console.error)},[E==null?void 0:E.status,e]),v.useEffect(()=>{if(t||!(s!=null&&s.results))return;const p=P?s.results.map(y=>P[y.name]??y):s.results,b=p.find(y=>y.status==="completed")??p[0];b&&a(`#/evals/runs/${e}/${encodeURIComponent(b.name)}`)},[s==null?void 0:s.results,P]);const O=v.useCallback(p=>{p.preventDefault(),d.current=!0;const b="touches"in p?p.touches[0].clientY:p.clientY,y=h,N=U=>{if(!d.current)return;const C=u.current;if(!C)return;const W="touches"in U?U.touches[0].clientY:U.clientY,z=C.clientHeight-100,A=Math.max(80,Math.min(z,y+(W-b)));c(A)},M=()=>{d.current=!1,document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",N),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",N),document.addEventListener("mouseup",M),document.addEventListener("touchmove",N,{passive:!1}),document.addEventListener("touchend",M)},[h]),D=v.useCallback(p=>{p.preventDefault(),x(!0);const b="touches"in p?p.touches[0].clientX:p.clientX,y=_,N=U=>{const C=w.current;if(!C)return;const W="touches"in U?U.touches[0].clientX:U.clientX,z=C.clientWidth-300,A=Math.max(280,Math.min(z,y+(b-W)));g(A)},M=()=>{x(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",M),document.removeEventListener("touchmove",N),document.removeEventListener("touchend",M),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",N),document.addEventListener("mouseup",M),document.addEventListener("touchmove",N,{passive:!1}),document.addEventListener("touchend",M)},[_]);if(i)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-sm",children:"Loading..."});if(!s)return n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Eval run not found"});const j=E??s,F=Gn[j.status]??Gn.pending,R=j.status==="running",T=Object.keys(j.evaluator_scores??{}).length>0?Object.keys(j.evaluator_scores):Object.keys(P?((f=Object.values(P).find(p=>Object.keys(p.scores).length>0))==null?void 0:f.scores)??{}:{}),I=P?s.results.map(p=>P[p.name]??p):s.results,L=I.find(p=>p.name===l)??null,B=((L==null?void 0:L.traces)??[]).map(p=>({...p,run_id:""}));return n.jsxs("div",{ref:w,className:"flex h-full",children:[n.jsxs("div",{ref:u,className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold truncate min-w-0",style:{color:"var(--text-primary)"},children:j.eval_set_name}),n.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold uppercase tracking-wide",style:{color:F.color,background:F.bg},children:F.label}),n.jsx("span",{className:"text-sm font-bold font-mono",style:{color:At(j.overall_score)},children:ms(j.overall_score)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:$h(j.start_time,j.end_time)}),R&&n.jsxs("div",{className:"flex items-center gap-2 max-w-[160px]",children:[n.jsx("div",{className:"flex-1 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${j.progress_total>0?j.progress_completed/j.progress_total*100:0}%`,background:"var(--info)"}})}),n.jsxs("span",{className:"text-[11px] shrink-0",style:{color:"var(--text-muted)"},children:[j.progress_completed,"/",j.progress_total]})]}),T.length>0&&n.jsx("div",{className:"flex gap-3 ml-auto",children:T.map(p=>{const b=k.find(N=>N.id===p),y=j.evaluator_scores[p];return n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:Yn((b==null?void 0:b.name)??p)}),n.jsx("div",{className:"w-12 h-2 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${y*100}%`,background:At(y)}})}),n.jsx("span",{className:"text-[11px] font-mono",style:{color:At(y)},children:ms(y)})]},p)})})]}),n.jsxs("div",{className:"shrink-0 overflow-hidden flex flex-col",style:{height:h},children:[n.jsxs("div",{className:"flex items-center px-3 h-7 text-[11px] font-semibold shrink-0 border-b",style:{color:"var(--text-muted)",background:"var(--bg-secondary)",borderColor:"var(--border)"},children:[n.jsx("span",{className:"w-5 shrink-0"}),n.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Score"}),T.map(p=>{const b=k.find(y=>y.id===p);return n.jsx("span",{className:"w-36 shrink-0 text-right truncate pl-2",title:(b==null?void 0:b.name)??p,children:Yn((b==null?void 0:b.name)??p)},p)}),n.jsx("span",{className:"w-14 shrink-0 text-right",children:"Time"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[I.map(p=>{const b=p.status==="pending",y=p.status==="failed",N=p.name===l;return n.jsxs("button",{onClick:()=>{a(N?`#/evals/runs/${e}`:`#/evals/runs/${e}/${encodeURIComponent(p.name)}`)},className:"w-full text-left px-3 py-1.5 flex items-center text-xs border-b transition-colors cursor-pointer",style:{borderColor:"var(--border)",background:N?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:N?"2px solid var(--accent)":"2px solid transparent",opacity:b?.5:1},onMouseEnter:M=>{N||(M.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:M=>{N||(M.currentTarget.style.background="")},children:[n.jsx("span",{className:"w-5 shrink-0 flex justify-center",children:n.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:b?"var(--text-muted)":y?"var(--error)":p.overall_score>=.8?"var(--success)":p.overall_score>=.5?"var(--warning)":"var(--error)"}})}),n.jsx("span",{className:"flex-1 min-w-0 truncate",style:{color:"var(--text-primary)"},children:p.name}),n.jsx("span",{className:"w-14 shrink-0 text-right font-mono font-semibold",style:{color:At(b?null:p.overall_score)},children:b?"-":ms(p.overall_score)}),T.map(M=>n.jsx("span",{className:"w-36 shrink-0 text-right font-mono pl-2",style:{color:At(b?null:p.scores[M]??null)},children:b?"-":ms(p.scores[M]??null)},M)),n.jsx("span",{className:"w-14 shrink-0 text-right",style:{color:"var(--text-muted)"},children:p.duration_ms!==null?`${(p.duration_ms/1e3).toFixed(1)}s`:"-"})]},p.name)}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-[var(--text-muted)] text-xs",children:R?"Waiting for results...":"No results"})]})]}),n.jsx("div",{onMouseDown:O,onTouchStart:O,className:"shrink-0 drag-handle-row"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:L&&B.length>0?n.jsx(si,{traces:B}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:(L==null?void 0:L.status)==="pending"?"Pending...":"No traces available"})})]}),n.jsx("div",{onMouseDown:D,onTouchStart:D,className:`shrink-0 drag-handle-col${m?"":" transition-all"}`,style:{width:L?3:0,opacity:L?1:0}}),n.jsx(Uh,{width:_,item:L,evaluators:k,isRunning:R,isDragging:m})]})}const zh=[{id:"score",label:"Score"},{id:"io",label:"I/O"},{id:"logs",label:"Logs"}];function Uh({width:e,item:t,evaluators:s,isRunning:r,isDragging:i}){const[o,a]=v.useState("score"),l=!!t;return n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${i?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:l?e:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:e},children:[zh.map(h=>n.jsx("button",{onClick:()=>a(h.id),className:"px-2.5 py-1 h-7 text-xs font-semibold rounded transition-colors cursor-pointer",style:{color:o===h.id?"var(--accent)":"var(--text-muted)",background:o===h.id?"color-mix(in srgb, var(--accent) 10%, transparent)":"transparent",border:"none"},onMouseEnter:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-primary)")},onMouseLeave:c=>{o!==h.id&&(c.currentTarget.style.color="var(--text-muted)")},children:h.label},h.id)),r&&n.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Running..."})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",style:{minWidth:e},children:t?t.status==="pending"?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Pending..."}):n.jsxs(n.Fragment,{children:[t.status==="failed"&&n.jsxs("div",{className:"mx-2 mt-2 px-3 py-2 rounded text-xs",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 4.5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"8",cy:"11",r:"0.75",fill:"currentColor"})]}),n.jsx("span",{children:"Evaluator error"})]}),t.error&&n.jsx("div",{className:"mt-1 pl-[22px] text-[11px] opacity-80 break-words",style:{color:"var(--text-secondary)"},children:t.error})]}),o==="score"?n.jsx(Kh,{item:t,evaluators:s}):o==="io"?n.jsx(Vh,{item:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:"Logs coming soon"})]}):null})]})}function Kh({item:e,evaluators:t}){const s=Object.keys(e.scores);return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Overall"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${e.overall_score*100}%`,background:At(e.overall_score)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(e.overall_score)},children:ms(e.overall_score)})]})]})}),e.status==="failed"&&s.length===0&&n.jsx("div",{className:"px-3 py-3 text-xs text-center",style:{color:"var(--text-muted)"},children:"All evaluators failed — no scores available"}),s.map(r=>{const i=t.find(l=>l.id===r),o=e.scores[r],a=e.justifications[r];return n.jsxs("div",{className:"overflow-hidden",style:{border:"1px solid var(--border)"},children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"truncate text-[11px] font-semibold",style:{color:"var(--text-primary)"},title:(i==null?void 0:i.name)??r,children:(i==null?void 0:i.name)??r}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("div",{className:"w-24 h-2.5 rounded-full overflow-hidden",style:{background:"var(--bg-tertiary)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${o*100}%`,background:At(o)}})}),n.jsx("span",{className:"text-xs font-mono font-bold shrink-0 w-10 text-right",style:{color:At(o)},children:ms(o)})]})]}),a&&n.jsx(Xh,{text:a})]},r)})]})}function Vh({item:e}){const t=JSON.stringify(e.inputs,null,2),s=typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2),r=e.expected_output!=null?typeof e.expected_output=="string"?e.expected_output:JSON.stringify(e.expected_output,null,2):null;return n.jsxs("div",{className:"p-2 overflow-y-auto h-full space-y-1.5",children:[n.jsx(Ot,{title:"Input",copyText:t,children:n.jsx(gt,{json:t,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),r&&n.jsx(Ot,{title:"Expected Output",copyText:r,children:n.jsx(gt,{json:r,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})}),n.jsx(Ot,{title:"Output",copyText:s,trailing:e.duration_ms!==null?n.jsxs("span",{className:"ml-auto text-[10px]",style:{color:"var(--text-muted)"},children:[(e.duration_ms/1e3).toFixed(2),"s"]}):void 0,children:n.jsx(gt,{json:s,className:"px-3 py-2 text-xs font-mono whitespace-pre-wrap break-words"})})]})}function qh(e){var i;const t=e.match(/expected="(.+?)"\s+actual="(.+?)"(.*)/s);if(!t)return null;const s={},r=((i=t[3])==null?void 0:i.trim())??"";if(r)for(const o of r.match(/(\w+)=([\S]+)/g)??[]){const a=o.indexOf("=");s[o.slice(0,a)]=o.slice(a+1)}return{expected:t[1],actual:t[2],meta:s}}function Jn(e){try{const t=e.replace(/'/g,'"').replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null"),s=JSON.parse(t);return JSON.stringify(s,null,2)}catch{return e}}function Xh({text:e}){const t=qh(e);if(!t)return n.jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:n.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--text-secondary)"},children:e})});const s=Jn(t.expected),r=Jn(t.actual),i=s===r;return n.jsxs("div",{className:"border-t",style:{borderColor:"var(--border)"},children:[n.jsxs("div",{className:"grid grid-cols-2 gap-0",children:[n.jsxs("div",{className:"px-3 py-2 border-r",style:{borderColor:"var(--border)"},children:[n.jsx("div",{className:"text-[10px] font-semibold mb-1",style:{color:"var(--text-muted)"},children:"Expected"}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:"var(--text-secondary)"},children:s})]}),n.jsxs("div",{className:"px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--text-muted)"},children:"Actual"}),n.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:i?"var(--success)":"var(--error)"}})]}),n.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words",style:{color:i?"var(--success)":"var(--error)"},children:r})]})]}),Object.keys(t.meta).length>0&&n.jsx("div",{className:"px-3 py-1.5 border-t flex items-center gap-3",style:{borderColor:"var(--border)"},children:Object.entries(t.meta).map(([o,a])=>n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:[n.jsx("span",{className:"font-medium",children:o.replace(/_/g," ")})," ",n.jsx("span",{className:"font-mono",children:a})]},o))})]})}const Zn={deterministic:"var(--success)",llm:"#a78bfa",tool:"var(--info)"};function Qn(){const e=me(g=>g.localEvaluators),t=me(g=>g.addEvalSet),{navigate:s}=et(),[r,i]=v.useState(""),[o,a]=v.useState(new Set),[l,h]=v.useState(null),[c,u]=v.useState(!1),d=g=>{a(m=>{const x=new Set(m);return x.has(g)?x.delete(g):x.add(g),x})},_=async()=>{if(r.trim()){h(null),u(!0);try{const g=await Oc({name:r.trim(),evaluator_refs:Array.from(o)});t(g),s(`#/evals/sets/${g.id}`)}catch(g){h(g.detail||g.message||"Failed to create eval set")}finally{u(!1)}}};return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Eval Set"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluation set with a name and evaluators"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:r,onChange:g=>i(g.target.value),placeholder:"e.g. Basic QA Tests",className:"w-full rounded-md px-3 py-2 text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},onKeyDown:g=>{g.key==="Enter"&&r.trim()&&_()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Evaluators"}),e.length===0?n.jsxs("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:["No evaluators configured."," ",n.jsx("button",{onClick:()=>s("#/evaluators/new"),className:"underline cursor-pointer",style:{color:"var(--accent)",background:"none",border:"none",padding:0,font:"inherit"},children:"Create one first"})]}):n.jsx("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:e.map(g=>n.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--border)"},onMouseEnter:m=>{m.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:[n.jsx("input",{type:"checkbox",checked:o.has(g.id),onChange:()=>d(g.id),className:"accent-[var(--accent)]"}),n.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:g.name}),n.jsx("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded",style:{background:`color-mix(in srgb, ${Zn[g.type]??"var(--text-muted)"} 15%, transparent)`,color:Zn[g.type]??"var(--text-muted)"},children:g.type})]},g.id))})]}),l&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:l}),n.jsx("button",{onClick:_,disabled:!r.trim()||c,className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:c?"Creating...":"Create Eval Set"})]})})}const Yh=[{type:"deterministic",label:"Deterministic",badgeColor:"var(--success)"},{type:"llm",label:"LLM Judge",badgeColor:"#a78bfa"},{type:"tool",label:"Tool-Based",badgeColor:"var(--info)"}];function eo(){const e=me(o=>o.localEvaluators),{evaluatorFilter:t,evaluatorCreateType:s,navigate:r}=et(),i=!t&&!s;return n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>r("#/evaluators/new"),className:"mx-3 mt-2.5 mb-1 px-3 py-1.5 text-[11px] font-medium rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-secondary)"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)",o.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-secondary)",o.currentTarget.style.borderColor=""},children:"+ New Evaluator"}),n.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Categories"}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsxs("button",{onClick:()=>r("#/evaluators"),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:i?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)",borderLeft:i?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:o=>{i||(o.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:o=>{i||(o.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--text-muted)"}}),n.jsx("span",{className:"flex-1 truncate",children:"All"}),e.length>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.length})]}),Yh.map(o=>{const a=e.filter(h=>h.type===o.type).length,l=t===o.type;return n.jsxs("button",{onClick:()=>r(l?"#/evaluators":`#/evaluators/category/${o.type}`),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 cursor-pointer transition-colors",style:{background:l?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:l?"var(--text-primary)":"var(--text-secondary)",borderLeft:l?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:h=>{l||(h.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:h=>{l||(h.currentTarget.style.background="transparent")},children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:o.badgeColor}}),n.jsx("span",{className:"flex-1 truncate",children:o.label}),a>0&&n.jsx("span",{className:"text-[10px] px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a})]},o.type)})]})]})}const to={deterministic:{label:"Deterministic",color:"var(--success)",bg:"rgba(34,197,94,0.1)"},llm:{label:"LLM Judge",color:"#a78bfa",bg:"rgba(167,139,250,0.1)"},tool:{label:"Tool-Based",color:"var(--info)",bg:"rgba(59,130,246,0.1)"}},ri={deterministic:"Deterministic",llm:"LLM Judge",tool:"Tool-Based"},Ps={deterministic:[{id:"uipath-exact-match",name:"Exact Match"},{id:"uipath-contains",name:"Contains"},{id:"uipath-json-similarity",name:"JSON Similarity"}],llm:[{id:"uipath-llm-judge-output-semantic-similarity",name:"LLM Judge Output"},{id:"uipath-llm-judge-output-strict-json-similarity",name:"LLM Judge Strict JSON"},{id:"uipath-llm-judge-trajectory-similarity",name:"LLM Judge Trajectory"},{id:"uipath-llm-judge-trajectory-simulation",name:"LLM Judge Trajectory Simulation"}],tool:[{id:"uipath-tool-call-order",name:"Tool Call Order"},{id:"uipath-tool-call-args",name:"Tool Call Args"},{id:"uipath-tool-call-count",name:"Tool Call Count"},{id:"uipath-tool-call-output",name:"Tool Call Output"}]};function Pa(e){return e.includes("trajectory")?{targetOutputKey:!1,prompt:!0}:e.includes("llm-judge")?{targetOutputKey:!0,prompt:!0}:e.includes("tool-call-output")?{targetOutputKey:!0,prompt:!1}:e.includes("exact-match")||e.includes("contains")||e.includes("json-similarity")?{targetOutputKey:!0,prompt:!1}:{targetOutputKey:!1,prompt:!1}}const $r={"uipath-exact-match":{description:"Checks whether the agent output exactly matches the expected output.",prompt:""},"uipath-contains":{description:"Checks whether the agent output contains the expected substring.",prompt:""},"uipath-json-similarity":{description:"Compares JSON structures for semantic similarity, ignoring key ordering and whitespace.",prompt:""},"uipath-llm-judge-output-semantic-similarity":{description:"Uses an LLM to score semantic similarity between the agent's actual output and the expected output, accounting for synonyms, paraphrases, and equivalent expressions.",prompt:`As an expert evaluator, analyze the semantic similarity between the expected and actual outputs and determine a score from 0 to 100. Focus on comparing meaning and contextual equivalence of corresponding fields, accounting for alternative valid expressions, synonyms, and reasonable variations in language while maintaining high standards for accuracy and completeness. Provide your score with a brief justification. ---- ExpectedOutput: {{ExpectedOutput}} @@ -68,7 +68,7 @@ ExpectedAgentBehavior: {{ExpectedAgentBehavior}} ---- AgentRunHistory: -{{AgentRunHistory}}`},"uipath-tool-call-order":{description:"Validates that the agent called tools in the expected sequence.",prompt:""},"uipath-tool-call-args":{description:"Checks whether the agent called tools with the expected arguments.",prompt:""},"uipath-tool-call-count":{description:"Validates that the agent made the expected number of tool calls.",prompt:""},"uipath-tool-call-output":{description:"Validates the output returned by the agent's tool calls.",prompt:""}};function Gh(e){for(const[t,s]of Object.entries(Ps))if(s.some(r=>r.id===e))return t;return"deterministic"}function Jh({evaluatorId:e,evaluatorFilter:t}){const s=xe(k=>k.localEvaluators),r=xe(k=>k.setLocalEvaluators),i=xe(k=>k.upsertLocalEvaluator),o=xe(k=>k.evaluators),{navigate:a}=et(),l=e?s.find(k=>k.id===e)??null:null,h=!!l,c=t?s.filter(k=>k.type===t):s,[u,d]=v.useState(()=>{const k=localStorage.getItem("evaluatorSidebarWidth");return k?parseInt(k,10):320}),[_,g]=v.useState(!1),m=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evaluatorSidebarWidth",String(u))},[u]),v.useEffect(()=>{Vi().then(r).catch(console.error)},[r]);const x=v.useCallback(k=>{k.preventDefault(),g(!0);const P="touches"in k?k.touches[0].clientX:k.clientX,A=u,D=$=>{const B=m.current;if(!B)return;const T="touches"in $?$.touches[0].clientX:$.clientX,O=B.clientWidth-300,L=Math.max(280,Math.min(O,A+(P-T)));d(L)},N=()=>{g(!1),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",D),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",D),document.addEventListener("mouseup",N),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("touchend",N)},[u]),w=k=>{i(k)},E=()=>{a("#/evaluators")};return n.jsxs("div",{ref:m,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:"Evaluators"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c.length,t?` / ${s.length}`:""," configured"]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:c.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:s.length===0?"No evaluators configured yet.":"No evaluators in this category."}):n.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:c.map(k=>n.jsx(Zh,{evaluator:k,evaluators:o,selected:k.id===e,onClick:()=>a(k.id===e?"#/evaluators":`#/evaluators/${encodeURIComponent(k.id)}`)},k.id))})})]}),n.jsx("div",{onMouseDown:x,onTouchStart:x,className:`shrink-0 drag-handle-col${_?"":" transition-all"}`,style:{width:h?3:0,opacity:h?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${_?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:h?u:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:u},children:[n.jsx("span",{className:"px-2 py-0.5 h-7 text-xs font-semibold rounded inline-flex items-center",style:{color:"var(--accent)",background:"color-mix(in srgb, var(--accent) 10%, transparent)"},children:"Edit Evaluator"}),n.jsx("button",{onClick:E,"aria-label":"Close editor",className:"ml-auto w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:k=>{k.currentTarget.style.color="var(--text-primary)"},onMouseLeave:k=>{k.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:u},children:l&&n.jsx(Qh,{evaluator:l,onUpdated:w})})]})]})}function Zh({evaluator:e,evaluators:t,selected:s,onClick:r}){const i=eo[e.type]??eo.deterministic,o=t.find(l=>l.id===e.evaluator_type_id),a=e.evaluator_type_id.startsWith("file://");return n.jsxs("div",{className:"rounded-md p-4 flex flex-col cursor-pointer transition-colors",style:{border:s?"1px solid var(--accent)":"1px solid var(--border)",background:s?"color-mix(in srgb, var(--accent) 5%, var(--card-bg))":"var(--card-bg)"},onClick:r,onMouseEnter:l=>{s||(l.currentTarget.style.borderColor="var(--text-muted)")},onMouseLeave:l=>{s||(l.currentTarget.style.borderColor="var(--border)")},children:[n.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.name}),e.description&&n.jsx("div",{className:"text-xs leading-relaxed mt-2",style:{color:"var(--text-secondary)"},children:e.description}),n.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-auto pt-3",children:[n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:i.color,background:i.bg},children:["Category: ",i.label]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Type: ",a?"Custom":(o==null?void 0:o.name)??e.evaluator_type_id]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium font-mono",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Target: ",e.target_output_key||"*"]})]})]})}function Qh({evaluator:e,onUpdated:t}){var O,L,R;const s=Gh(e.evaluator_type_id),r=Ps[s]??[],i=xe(p=>p.llmModels),o=xe(p=>p.setLlmModels),[a,l]=v.useState(e.description),[h,c]=v.useState(e.evaluator_type_id),[u,d]=v.useState(((O=e.config)==null?void 0:O.targetOutputKey)??"*"),[_,g]=v.useState(((L=e.config)==null?void 0:L.prompt)??""),[m,x]=v.useState(((R=e.config)==null?void 0:R.model)??""),[w,E]=v.useState(!1),[k,P]=v.useState(null),[A,D]=v.useState(!1);v.useEffect(()=>{s==="llm"&&i.length===0&&_a().then(o).catch(()=>{})},[s]),v.useEffect(()=>{var p,f,b;l(e.description),c(e.evaluator_type_id),d(((p=e.config)==null?void 0:p.targetOutputKey)??"*"),g(((f=e.config)==null?void 0:f.prompt)??""),x(((b=e.config)==null?void 0:b.model)??""),P(null),D(!1)},[e.id]);const N=Pa(h),$=s==="llm",B=async()=>{E(!0),P(null),D(!1);try{const p={};N.targetOutputKey&&(p.targetOutputKey=u),N.prompt&&_.trim()&&(p.prompt=_),$&&m&&(p.model=m);const f=await Kc(e.id,{description:a.trim(),evaluator_type_id:h,config:p});t(f),D(!0),setTimeout(()=>D(!1),2e3)}catch(p){const f=p==null?void 0:p.detail;P(f??"Failed to update evaluator")}finally{E(!1)}},T={background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)"};return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:e.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Category"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[s]??s})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:h,onChange:p=>c(p.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:r.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:a,onChange:p=>l(p.target.value),placeholder:"What does this evaluator check?",rows:4,className:"w-full px-3 py-2 rounded-lg text-xs leading-relaxed outline-none resize-y",style:T})]}),N.targetOutputKey&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:u,onChange:p=>d(p.target.value),placeholder:"*",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),N.prompt&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:_,onChange:p=>g(p.target.value),placeholder:"Evaluation prompt for the LLM judge...",rows:8,className:"w-full px-3 py-2 rounded-lg text-xs font-mono leading-relaxed outline-none resize-y",style:T})]}),$&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Model"}),i.length>0?n.jsxs("select",{value:m,onChange:p=>x(p.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:[n.jsx("option",{value:"",children:"Select a model"}),i.map(p=>n.jsxs("option",{value:p.model_name,children:[p.model_name,p.vendor?` (${p.vendor})`:""]},p.model_name))]}):n.jsx("input",{type:"text",value:m,onChange:p=>x(p.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T})]})]}),n.jsxs("div",{className:"shrink-0 p-4 space-y-2",children:[k&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:k}),A&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(34,197,94,0.1)",color:"var(--success)"},children:"Saved successfully"}),n.jsx("button",{onClick:B,disabled:w,className:"w-full py-2.5 text-xs font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:"transparent",borderColor:"var(--accent)",color:"var(--accent)"},onMouseEnter:p=>{p.currentTarget.style.background="color-mix(in srgb, var(--accent) 15%, transparent)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent"},children:w?"Saving...":"Save Changes"})]})]})}const ed=["deterministic","llm","tool"];function td({category:e}){var z;const t=xe(C=>C.addLocalEvaluator),s=xe(C=>C.llmModels),r=xe(C=>C.setLlmModels),{navigate:i}=et(),o=e!=="any",[a,l]=v.useState(o?e:"deterministic"),h=Ps[a]??[],[c,u]=v.useState(""),[d,_]=v.useState(""),[g,m]=v.useState(((z=h[0])==null?void 0:z.id)??""),[x,w]=v.useState("*"),[E,k]=v.useState(""),[P,A]=v.useState(""),[D,N]=v.useState(!1),[$,B]=v.useState(null),[T,O]=v.useState(!1),[L,R]=v.useState(!1);v.useEffect(()=>{s.length===0&&_a().then(r).catch(()=>{})},[]),v.useEffect(()=>{var ee;const C=o?e:"deterministic";l(C);const U=((ee=(Ps[C]??[])[0])==null?void 0:ee.id)??"",q=$r[U];u(""),_((q==null?void 0:q.description)??""),m(U),w("*"),k((q==null?void 0:q.prompt)??""),A(""),B(null),O(!1),R(!1)},[e,o]);const p=C=>{var ee;l(C);const U=((ee=(Ps[C]??[])[0])==null?void 0:ee.id)??"",q=$r[U];m(U),T||_((q==null?void 0:q.description)??""),L||k((q==null?void 0:q.prompt)??"")},f=C=>{m(C);const H=$r[C];H&&(T||_(H.description),L||k(H.prompt))},b=Pa(g),y=a==="llm",j=async()=>{if(!c.trim()){B("Name is required");return}N(!0),B(null);try{const C={};b.targetOutputKey&&(C.targetOutputKey=x),b.prompt&&E.trim()&&(C.prompt=E),y&&P&&(C.model=P);const H=await zc({name:c.trim(),description:d.trim(),evaluator_type_id:g,config:C});t(H),i("#/evaluators")}catch(C){const H=C==null?void 0:C.detail;B(H??"Failed to create evaluator")}finally{N(!1)}},M={background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"};return n.jsx("div",{className:"h-full overflow-y-auto",children:n.jsx("div",{className:"flex items-center justify-center min-h-full py-8",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Evaluator"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluator to score agent outputs"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:c,onChange:C=>u(C.target.value),placeholder:"e.g. MyEvaluator",className:"w-full rounded-md px-3 py-2 text-xs",style:M,onKeyDown:C=>{C.key==="Enter"&&c.trim()&&j()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Category"}),o?n.jsx("div",{className:"px-3 py-2 rounded-md text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[a]??a}):n.jsx("select",{value:a,onChange:C=>p(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:ed.map(C=>n.jsx("option",{value:C,children:ri[C]},C))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:g,onChange:C=>f(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:h.map(C=>n.jsx("option",{value:C.id,children:C.name},C.id))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:d,onChange:C=>{_(C.target.value),O(!0)},placeholder:"What does this evaluator check?",rows:3,className:"w-full rounded-md px-3 py-2 text-xs leading-relaxed resize-y",style:M})]}),b.targetOutputKey&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:x,onChange:C=>w(C.target.value),placeholder:"*",className:"w-full rounded-md px-3 py-2 text-xs",style:M}),n.jsx("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),b.prompt&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:E,onChange:C=>{k(C.target.value),R(!0)},placeholder:"Evaluation prompt for the LLM judge...",rows:6,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-y",style:M})]}),y&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Model"}),s.length>0?n.jsxs("select",{value:P,onChange:C=>A(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:[n.jsx("option",{value:"",children:"Select a model"}),s.map(C=>n.jsxs("option",{value:C.model_name,children:[C.model_name,C.vendor?` (${C.vendor})`:""]},C.model_name))]}):n.jsx("input",{type:"text",value:P,onChange:C=>A(C.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full rounded-md px-3 py-2 text-xs",style:M})]}),$&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:$}),n.jsx("button",{onClick:j,disabled:D||!c.trim(),className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:D?"Creating...":"Create Evaluator"})]})})})}const Cr="/api";async function kr(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Aa(){return kr(`${Cr}/statedb/status`)}async function sd(){return kr(`${Cr}/statedb/tables`)}async function rd(e,t=100,s=0){return kr(`${Cr}/statedb/tables/${encodeURIComponent(e)}?limit=${t}&offset=${s}`)}async function id(e,t){return kr(`${Cr}/statedb/query`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e,limit:t})})}function Oa({path:e,name:t,type:s,depth:r}){const i=ye(k=>k.children[e]),o=ye(k=>!!k.expanded[e]),a=ye(k=>!!k.loadingDirs[e]),l=ye(k=>!!k.dirty[e]),h=ye(k=>!!k.agentChangedFiles[e]),c=ye(k=>k.selectedFile),{setChildren:u,toggleExpanded:d,setLoadingDir:_,openTab:g}=ye(),{navigate:m}=et(),x=s==="directory",w=!x&&c===e,E=v.useCallback(()=>{x?(!i&&!a&&(_(e,!0),Ki(e).then(k=>u(e,k)).catch(console.error).finally(()=>_(e,!1))),d(e)):(g(e),m(`#/explorer/file/${encodeURIComponent(e)}`))},[x,i,a,e,u,d,_,g,m]);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:E,className:`w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors group${h?" agent-changed-file":""}`,style:{paddingLeft:`${12+r*16}px`,paddingRight:"8px",background:w?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:w?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:k=>{w||(k.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:k=>{w||(k.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"w-3 shrink-0 flex items-center justify-center",style:{color:"var(--text-muted)"},children:x&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5z"})})}),n.jsx("span",{className:"shrink-0",style:{color:x?"var(--accent)":"var(--text-muted)"},children:x?n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),n.jsx("span",{className:"truncate flex-1",children:t}),l&&n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"}}),a&&n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:"..."})]}),x&&o&&i&&i.map(k=>n.jsx(Oa,{path:k.path,name:k.name,type:k.type,depth:r+1},k.path))]})}const nd="__statedb__:";function od({onDbMissing:e}){const[t,s]=v.useState([]),[r,i]=v.useState(!0),[o,a]=v.useState(!1),l=ye(d=>d.selectedFile),{openTab:h}=ye(),{navigate:c}=et(),u=v.useCallback(()=>{a(!0),Aa().then(({exists:d})=>{if(!d){e();return}return sd().then(s)}).catch(console.error).finally(()=>a(!1))},[e]);return v.useEffect(()=>{u()},[u]),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center",children:[n.jsxs("button",{onClick:()=>i(!r),className:"flex-1 text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),n.jsx("path",{d:"M21 12c0 1.66-4.03 3-9 3s-9-1.34-9-3"}),n.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"})]}),"State Database"]}),n.jsx("button",{onClick:d=>{d.stopPropagation(),u()},className:"shrink-0 flex items-center justify-center w-5 h-5 rounded cursor-pointer",style:{background:"none",border:"none",color:"var(--text-muted)",marginRight:"8px"},onMouseEnter:d=>{d.currentTarget.style.color="var(--text-primary)"},onMouseLeave:d=>{d.currentTarget.style.color="var(--text-muted)"},title:"Refresh tables",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:o?{animation:"spin 0.6s linear infinite"}:void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})})]}),r&&t.map(d=>{const _=`${nd}${d.name}`,g=l===_;return n.jsxs("button",{onClick:()=>{h(_),c(`#/explorer/statedb/${encodeURIComponent(d.name)}`)},className:"w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors",style:{paddingLeft:"28px",paddingRight:"8px",background:g?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:g?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:m=>{g||(m.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:m=>{g||(m.currentTarget.style.background="transparent")},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)"},className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),n.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate flex-1",children:d.name}),n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:d.row_count})]},d.name)})]})}function to(){const e=ye(h=>h.children[""]),{setChildren:t}=ye(),[s,r]=v.useState(!1),[i,o]=v.useState(!0),{openTab:a}=ye(),{navigate:l}=et();return v.useEffect(()=>{e||Ki("").then(h=>t("",h)).catch(console.error)},[e,t]),v.useEffect(()=>{Aa().then(({exists:h})=>r(h)).catch(()=>r(!1))},[]),n.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[n.jsxs("button",{onClick:()=>{a("__canvas__"),l("#/explorer/canvas")},className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[n.jsx("circle",{cx:"5",cy:"1.5",r:"1.2"}),n.jsx("circle",{cx:"2",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.2"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"2",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"8",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"})]}),"Visualization"]}),s&&n.jsx(od,{onDbMissing:()=>r(!1)}),n.jsxs("button",{onClick:()=>o(!i),className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"})}),"Files"]}),i&&(e?e.map(h=>n.jsx(Oa,{path:h.path,name:h.name,type:h.type,depth:0},h.path)):n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"Loading..."}))]})}async function ad(){const e=await fetch("/api/cli-agent/available");return e.ok?e.json():[]}const ld={startNode:wa,endNode:Ca,modelNode:ka,toolNode:Ea,groupNode:Na,defaultNode:ja},cd={elk:Ma};function hd(){const e=de(N=>N.entrypoints),t=de(N=>N.runs),[s,r]=v.useState(null),[i,o,a]=ia([]),[l,h,c]=na([]),[u,d]=v.useState(!0),[_,g]=v.useState(!1),m=v.useRef(0),x=v.useRef(""),w=v.useRef(null),E=v.useRef(null),k=v.useRef(wr()).current,P=v.useMemo(()=>{if(!s)return null;let N=null;for(const $ of Object.values(t))if($.entrypoint===s){if($.status==="running"||$.status==="pending")return $.id;(!N||$.start_time&&(!N.start_time||$.start_time>N.start_time))&&(N=$)}return(N==null?void 0:N.id)??null},[t,s]);v.useEffect(()=>{if(P)return k.subscribe(P),()=>{k.unsubscribe(P)}},[P,k]);const A=de(N=>P?N.stateEvents[P]:void 0),D=de(N=>{var $;return P?($=N.runs[P])==null?void 0:$.status:void 0});return v.useEffect(()=>{e.length>0&&(!s||!e.includes(s))&&r(e[0])},[e,s]),v.useEffect(()=>{if(!s)return;const N=++m.current;!x.current&&d(!0),g(!1),fa(s).then(async B=>{if(m.current!==N)return;if(!B.nodes.length){g(!0);return}const T=JSON.stringify(B);if(T===x.current)return;x.current=T;const{nodes:O,edges:L}=await Sa(B);m.current===N&&(o(O),h(L),setTimeout(()=>{var R;(R=w.current)==null||R.fitView({padding:.1,duration:200})},100))}).catch(()=>{m.current===N&&g(!0)}).finally(()=>{m.current===N&&d(!1)})},[s,e,o,h]),v.useEffect(()=>{if(!P)return;const N=new Map;if(A)for(const O of A)O.phase==="started"?N.set(O.node_name,O.qualified_node_name??null):O.phase==="completed"&&N.delete(O.node_name);let $=new Set;const B=new Set,T=new Map;o(O=>{var L;for(const R of O)R.type&&T.set(R.id,R.type);if(N.size>0){const R=new Map;for(const p of O){const f=(L=p.data)==null?void 0:L.label;if(!f)continue;const b=p.id.includes("/")?p.id.split("/").pop():p.id;for(const y of[b,f]){let j=R.get(y);j||(j=new Set,R.set(y,j)),j.add(p.id)}}for(const[p,f]of N){let b=!1;if(f){const y=f.replace(/:/g,"/");for(const j of O)j.id===y&&($.add(j.id),b=!0)}if(!b){const y=R.get(p);y&&y.forEach(j=>$.add(j))}}}return O}),h(O=>O.map(L=>{var p,f;let R=$.has(L.source);return!R&&T.get(L.target)==="endNode"&&$.has(L.target)&&(R=!0),R?(B.add(L.target),{...L,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...L.data,highlighted:!0},animated:!0}):(p=L.data)!=null&&p.highlighted?{...L,style:qi((f=L.data)==null?void 0:f.conditional),markerEnd:Os,data:{...L.data,highlighted:!1},animated:!1}:L})),o(O=>O.map(L=>{var f,b;const R=$.has(L.id),p=B.has(L.id)||$.has(L.id);return p!==!!((f=L.data)!=null&&f.isActiveNode)||R!==!!((b=L.data)!=null&&b.isExecutingNode)?{...L,data:{...L.data,isActiveNode:p,isExecutingNode:R}}:L}))},[P,A,o,h]),v.useEffect(()=>{P&&o(N=>{var p;const $=!!(A!=null&&A.length),B=D==="completed"||D==="failed",T=new Set,O=new Set(N.map(f=>f.id)),L=new Map;for(const f of N){const b=(p=f.data)==null?void 0:p.label;if(!b)continue;const y=f.id.includes("/")?f.id.split("/").pop():f.id;for(const j of[y,b]){let M=L.get(j);M||(M=new Set,L.set(j,M)),M.add(f.id)}}if($)for(const f of A){let b=!1;if(f.qualified_node_name){const y=f.qualified_node_name.replace(/:/g,"/");O.has(y)&&(T.add(y),b=!0)}if(!b){const y=L.get(f.node_name);y&&y.forEach(j=>T.add(j))}}const R=new Set;for(const f of N)f.parentNode&&T.has(f.id)&&R.add(f.parentNode);return N.map(f=>{var y;let b;return T.has(f.id)?b="completed":f.type==="startNode"?(!f.parentNode&&$||f.parentNode&&R.has(f.parentNode))&&(b="completed"):f.type==="endNode"?!f.parentNode&&B?b=D==="failed"?"failed":"completed":f.parentNode&&R.has(f.parentNode)&&(b="completed"):f.type==="groupNode"&&R.has(f.id)&&(b="completed"),b!==((y=f.data)==null?void 0:y.status)?{...f,data:{...f.data,status:b}}:f})})},[P,A,D,o]),v.useEffect(()=>{const N=E.current;if(!N)return;const $=new ResizeObserver(()=>{var B;(B=w.current)==null||B.fitView({padding:.1,duration:200})});return $.observe(N),()=>$.disconnect()},[u,_]),u?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):_?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:E,className:"h-full explorer-canvas",children:[n.jsx("style",{children:` +{{AgentRunHistory}}`},"uipath-tool-call-order":{description:"Validates that the agent called tools in the expected sequence.",prompt:""},"uipath-tool-call-args":{description:"Checks whether the agent called tools with the expected arguments.",prompt:""},"uipath-tool-call-count":{description:"Validates that the agent made the expected number of tool calls.",prompt:""},"uipath-tool-call-output":{description:"Validates the output returned by the agent's tool calls.",prompt:""}};function Gh(e){for(const[t,s]of Object.entries(Ps))if(s.some(r=>r.id===e))return t;return"deterministic"}function Jh({evaluatorId:e,evaluatorFilter:t}){const s=me(k=>k.localEvaluators),r=me(k=>k.setLocalEvaluators),i=me(k=>k.upsertLocalEvaluator),o=me(k=>k.evaluators),{navigate:a}=et(),l=e?s.find(k=>k.id===e)??null:null,h=!!l,c=t?s.filter(k=>k.type===t):s,[u,d]=v.useState(()=>{const k=localStorage.getItem("evaluatorSidebarWidth");return k?parseInt(k,10):320}),[_,g]=v.useState(!1),m=v.useRef(null);v.useEffect(()=>{localStorage.setItem("evaluatorSidebarWidth",String(u))},[u]),v.useEffect(()=>{qi().then(r).catch(console.error)},[r]);const x=v.useCallback(k=>{k.preventDefault(),g(!0);const P="touches"in k?k.touches[0].clientX:k.clientX,O=u,D=F=>{const R=m.current;if(!R)return;const T="touches"in F?F.touches[0].clientX:F.clientX,I=R.clientWidth-300,L=Math.max(280,Math.min(I,O+(P-T)));d(L)},j=()=>{g(!1),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",D),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",D),document.addEventListener("mouseup",j),document.addEventListener("touchmove",D,{passive:!1}),document.addEventListener("touchend",j)},[u]),w=k=>{i(k)},E=()=>{a("#/evaluators")};return n.jsxs("div",{ref:m,className:"flex h-full",children:[n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsxs("div",{className:"px-4 h-10 border-b shrink-0 flex items-center gap-4",style:{borderColor:"var(--border)"},children:[n.jsx("h1",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:"Evaluators"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c.length,t?` / ${s.length}`:""," configured"]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:c.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)] text-xs",children:s.length===0?"No evaluators configured yet.":"No evaluators in this category."}):n.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:c.map(k=>n.jsx(Zh,{evaluator:k,evaluators:o,selected:k.id===e,onClick:()=>a(k.id===e?"#/evaluators":`#/evaluators/${encodeURIComponent(k.id)}`)},k.id))})})]}),n.jsx("div",{onMouseDown:x,onTouchStart:x,className:`shrink-0 drag-handle-col${_?"":" transition-all"}`,style:{width:h?3:0,opacity:h?1:0}}),n.jsxs("div",{className:`shrink-0 flex flex-col overflow-hidden${_?"":" transition-[width] duration-200 ease-in-out"}`,style:{width:h?u:0,background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)",minWidth:u},children:[n.jsx("span",{className:"px-2 py-0.5 h-7 text-xs font-semibold rounded inline-flex items-center",style:{color:"var(--accent)",background:"color-mix(in srgb, var(--accent) 10%, transparent)"},children:"Edit Evaluator"}),n.jsx("button",{onClick:E,"aria-label":"Close editor",className:"ml-auto w-7 h-7 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:k=>{k.currentTarget.style.color="var(--text-primary)"},onMouseLeave:k=>{k.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",style:{minWidth:u},children:l&&n.jsx(Qh,{evaluator:l,onUpdated:w})})]})]})}function Zh({evaluator:e,evaluators:t,selected:s,onClick:r}){const i=to[e.type]??to.deterministic,o=t.find(l=>l.id===e.evaluator_type_id),a=e.evaluator_type_id.startsWith("file://");return n.jsxs("div",{className:"rounded-md p-4 flex flex-col cursor-pointer transition-colors",style:{border:s?"1px solid var(--accent)":"1px solid var(--border)",background:s?"color-mix(in srgb, var(--accent) 5%, var(--card-bg))":"var(--card-bg)"},onClick:r,onMouseEnter:l=>{s||(l.currentTarget.style.borderColor="var(--text-muted)")},onMouseLeave:l=>{s||(l.currentTarget.style.borderColor="var(--border)")},children:[n.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:e.name}),e.description&&n.jsx("div",{className:"text-xs leading-relaxed mt-2",style:{color:"var(--text-secondary)"},children:e.description}),n.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-auto pt-3",children:[n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:i.color,background:i.bg},children:["Category: ",i.label]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Type: ",a?"Custom":(o==null?void 0:o.name)??e.evaluator_type_id]}),n.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium font-mono",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:["Target: ",e.target_output_key||"*"]})]})]})}function Qh({evaluator:e,onUpdated:t}){var I,L,B;const s=Gh(e.evaluator_type_id),r=Ps[s]??[],i=me(f=>f.llmModels),o=me(f=>f.setLlmModels),[a,l]=v.useState(e.description),[h,c]=v.useState(e.evaluator_type_id),[u,d]=v.useState(((I=e.config)==null?void 0:I.targetOutputKey)??"*"),[_,g]=v.useState(((L=e.config)==null?void 0:L.prompt)??""),[m,x]=v.useState(((B=e.config)==null?void 0:B.model)??""),[w,E]=v.useState(!1),[k,P]=v.useState(null),[O,D]=v.useState(!1);v.useEffect(()=>{s==="llm"&&i.length===0&&Vi().then(o).catch(()=>{})},[s]),v.useEffect(()=>{var f,p,b;l(e.description),c(e.evaluator_type_id),d(((f=e.config)==null?void 0:f.targetOutputKey)??"*"),g(((p=e.config)==null?void 0:p.prompt)??""),x(((b=e.config)==null?void 0:b.model)??""),P(null),D(!1)},[e.id]);const j=Pa(h),F=s==="llm",R=async()=>{E(!0),P(null),D(!1);try{const f={};j.targetOutputKey&&(f.targetOutputKey=u),j.prompt&&_.trim()&&(f.prompt=_),F&&m&&(f.model=m);const p=await Kc(e.id,{description:a.trim(),evaluator_type_id:h,config:f});t(p),D(!0),setTimeout(()=>D(!1),2e3)}catch(f){const p=f==null?void 0:f.detail;P(p??"Failed to update evaluator")}finally{E(!1)}},T={background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)"};return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:e.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Category"}),n.jsx("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[s]??s})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:h,onChange:f=>c(f.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:r.map(f=>n.jsx("option",{value:f.id,children:f.name},f.id))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:a,onChange:f=>l(f.target.value),placeholder:"What does this evaluator check?",rows:4,className:"w-full px-3 py-2 rounded-lg text-xs leading-relaxed outline-none resize-y",style:T})]}),j.targetOutputKey&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:u,onChange:f=>d(f.target.value),placeholder:"*",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),j.prompt&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:_,onChange:f=>g(f.target.value),placeholder:"Evaluation prompt for the LLM judge...",rows:8,className:"w-full px-3 py-2 rounded-lg text-xs font-mono leading-relaxed outline-none resize-y",style:T})]}),F&&n.jsxs("div",{children:[n.jsx("label",{className:"text-[11px] font-medium block mb-1",style:{color:"var(--text-muted)"},children:"Model"}),i.length>0?n.jsxs("select",{value:m,onChange:f=>x(f.target.value),className:"w-full px-3 py-2 rounded-lg text-xs outline-none cursor-pointer",style:T,children:[n.jsx("option",{value:"",children:"Select a model"}),i.map(f=>n.jsxs("option",{value:f.model_name,children:[f.model_name,f.vendor?` (${f.vendor})`:""]},f.model_name))]}):n.jsx("input",{type:"text",value:m,onChange:f=>x(f.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full px-3 py-2 rounded-lg text-xs outline-none",style:T})]})]}),n.jsxs("div",{className:"shrink-0 p-4 space-y-2",children:[k&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(239,68,68,0.1)",color:"var(--error)"},children:k}),O&&n.jsx("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(34,197,94,0.1)",color:"var(--success)"},children:"Saved successfully"}),n.jsx("button",{onClick:R,disabled:w,className:"w-full py-2.5 text-xs font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:"transparent",borderColor:"var(--accent)",color:"var(--accent)"},onMouseEnter:f=>{f.currentTarget.style.background="color-mix(in srgb, var(--accent) 15%, transparent)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:w?"Saving...":"Save Changes"})]})]})}const ed=["deterministic","llm","tool"];function td({category:e}){var U;const t=me(C=>C.addLocalEvaluator),s=me(C=>C.llmModels),r=me(C=>C.setLlmModels),{navigate:i}=et(),o=e!=="any",[a,l]=v.useState(o?e:"deterministic"),h=Ps[a]??[],[c,u]=v.useState(""),[d,_]=v.useState(""),[g,m]=v.useState(((U=h[0])==null?void 0:U.id)??""),[x,w]=v.useState("*"),[E,k]=v.useState(""),[P,O]=v.useState(""),[D,j]=v.useState(!1),[F,R]=v.useState(null),[T,I]=v.useState(!1),[L,B]=v.useState(!1);v.useEffect(()=>{s.length===0&&Vi().then(r).catch(()=>{})},[]),v.useEffect(()=>{var Z;const C=o?e:"deterministic";l(C);const z=((Z=(Ps[C]??[])[0])==null?void 0:Z.id)??"",A=$r[z];u(""),_((A==null?void 0:A.description)??""),m(z),w("*"),k((A==null?void 0:A.prompt)??""),O(""),R(null),I(!1),B(!1)},[e,o]);const f=C=>{var Z;l(C);const z=((Z=(Ps[C]??[])[0])==null?void 0:Z.id)??"",A=$r[z];m(z),T||_((A==null?void 0:A.description)??""),L||k((A==null?void 0:A.prompt)??"")},p=C=>{m(C);const W=$r[C];W&&(T||_(W.description),L||k(W.prompt))},b=Pa(g),y=a==="llm",N=async()=>{if(!c.trim()){R("Name is required");return}j(!0),R(null);try{const C={};b.targetOutputKey&&(C.targetOutputKey=x),b.prompt&&E.trim()&&(C.prompt=E),y&&P&&(C.model=P);const W=await zc({name:c.trim(),description:d.trim(),evaluator_type_id:g,config:C});t(W),i("#/evaluators")}catch(C){const W=C==null?void 0:C.detail;R(W??"Failed to create evaluator")}finally{j(!1)}},M={background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"};return n.jsx("div",{className:"h-full overflow-y-auto",children:n.jsx("div",{className:"flex items-center justify-center min-h-full py-8",children:n.jsxs("div",{className:"w-full max-w-xl px-6",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--accent)"}}),n.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-muted)"},children:"New Evaluator"})]}),n.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Create an evaluator to score agent outputs"})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Name"}),n.jsx("input",{type:"text",value:c,onChange:C=>u(C.target.value),placeholder:"e.g. MyEvaluator",className:"w-full rounded-md px-3 py-2 text-xs",style:M,onKeyDown:C=>{C.key==="Enter"&&c.trim()&&N()}})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Category"}),o?n.jsx("div",{className:"px-3 py-2 rounded-md text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:ri[a]??a}):n.jsx("select",{value:a,onChange:C=>f(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:ed.map(C=>n.jsx("option",{value:C,children:ri[C]},C))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Type"}),n.jsx("select",{value:g,onChange:C=>p(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:h.map(C=>n.jsx("option",{value:C.id,children:C.name},C.id))})]}),n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Description"}),n.jsx("textarea",{value:d,onChange:C=>{_(C.target.value),I(!0)},placeholder:"What does this evaluator check?",rows:3,className:"w-full rounded-md px-3 py-2 text-xs leading-relaxed resize-y",style:M})]}),b.targetOutputKey&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Target Output Key"}),n.jsx("input",{type:"text",value:x,onChange:C=>w(C.target.value),placeholder:"*",className:"w-full rounded-md px-3 py-2 text-xs",style:M}),n.jsx("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Use * for entire output or a specific key name"})]}),b.prompt&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Prompt"}),n.jsx("textarea",{value:E,onChange:C=>{k(C.target.value),B(!0)},placeholder:"Evaluation prompt for the LLM judge...",rows:6,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-y",style:M})]}),y&&n.jsxs("div",{className:"mb-6",children:[n.jsx("label",{className:"block text-[11px] font-medium mb-1.5",style:{color:"var(--text-muted)"},children:"Model"}),s.length>0?n.jsxs("select",{value:P,onChange:C=>O(C.target.value),className:"w-full rounded-md px-3 py-2 text-xs cursor-pointer appearance-auto",style:M,children:[n.jsx("option",{value:"",children:"Select a model"}),s.map(C=>n.jsxs("option",{value:C.model_name,children:[C.model_name,C.vendor?` (${C.vendor})`:""]},C.model_name))]}):n.jsx("input",{type:"text",value:P,onChange:C=>O(C.target.value),placeholder:"e.g. gpt-4.1-mini-2025-04-14",className:"w-full rounded-md px-3 py-2 text-xs",style:M})]}),F&&n.jsx("p",{className:"text-xs mb-4 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:F}),n.jsx("button",{onClick:N,disabled:D||!c.trim(),className:"w-full py-2 rounded-md text-[13px] font-semibold transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"var(--bg-primary)",border:"none"},children:D?"Creating...":"Create Evaluator"})]})})})}const Cr="/api";async function kr(e,t){const s=await fetch(e,t);if(!s.ok){let r;try{r=(await s.json()).detail||s.statusText}catch{r=s.statusText}const i=new Error(`HTTP ${s.status}`);throw i.detail=r,i.status=s.status,i}return s.json()}async function Aa(){return kr(`${Cr}/statedb/status`)}async function sd(){return kr(`${Cr}/statedb/tables`)}async function rd(e,t=100,s=0){return kr(`${Cr}/statedb/tables/${encodeURIComponent(e)}?limit=${t}&offset=${s}`)}async function id(e,t){return kr(`${Cr}/statedb/query`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e,limit:t})})}function Oa({path:e,name:t,type:s,depth:r}){const i=ye(k=>k.children[e]),o=ye(k=>!!k.expanded[e]),a=ye(k=>!!k.loadingDirs[e]),l=ye(k=>!!k.dirty[e]),h=ye(k=>!!k.agentChangedFiles[e]),c=ye(k=>k.selectedFile),{setChildren:u,toggleExpanded:d,setLoadingDir:_,openTab:g}=ye(),{navigate:m}=et(),x=s==="directory",w=!x&&c===e,E=v.useCallback(()=>{x?(!i&&!a&&(_(e,!0),Ki(e).then(k=>u(e,k)).catch(console.error).finally(()=>_(e,!1))),d(e)):(g(e),m(`#/explorer/file/${encodeURIComponent(e)}`))},[x,i,a,e,u,d,_,g,m]);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:E,className:`w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors group${h?" agent-changed-file":""}`,style:{paddingLeft:`${12+r*16}px`,paddingRight:"8px",background:w?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:w?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:k=>{w||(k.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:k=>{w||(k.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"w-3 shrink-0 flex items-center justify-center",style:{color:"var(--text-muted)"},children:x&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M3 1.5L7 5L3 8.5z"})})}),n.jsx("span",{className:"shrink-0",style:{color:x?"var(--accent)":"var(--text-muted)"},children:x?n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),n.jsx("span",{className:"truncate flex-1",children:t}),l&&n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"}}),a&&n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:"..."})]}),x&&o&&i&&i.map(k=>n.jsx(Oa,{path:k.path,name:k.name,type:k.type,depth:r+1},k.path))]})}const nd="__statedb__:";function od({onDbMissing:e}){const[t,s]=v.useState([]),[r,i]=v.useState(!0),[o,a]=v.useState(!1),l=ye(d=>d.selectedFile),{openTab:h}=ye(),{navigate:c}=et(),u=v.useCallback(()=>{a(!0),Aa().then(({exists:d})=>{if(!d){e();return}return sd().then(s)}).catch(console.error).finally(()=>a(!1))},[e]);return v.useEffect(()=>{u()},[u]),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center",children:[n.jsxs("button",{onClick:()=>i(!r),className:"flex-1 text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),n.jsx("path",{d:"M21 12c0 1.66-4.03 3-9 3s-9-1.34-9-3"}),n.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"})]}),"State Database"]}),n.jsx("button",{onClick:d=>{d.stopPropagation(),u()},className:"shrink-0 flex items-center justify-center w-5 h-5 rounded cursor-pointer",style:{background:"none",border:"none",color:"var(--text-muted)",marginRight:"8px"},onMouseEnter:d=>{d.currentTarget.style.color="var(--text-primary)"},onMouseLeave:d=>{d.currentTarget.style.color="var(--text-muted)"},title:"Refresh tables",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:o?{animation:"spin 0.6s linear infinite"}:void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})})]}),r&&t.map(d=>{const _=`${nd}${d.name}`,g=l===_;return n.jsxs("button",{onClick:()=>{h(_),c(`#/explorer/statedb/${encodeURIComponent(d.name)}`)},className:"w-full text-left flex items-center gap-1 py-[3px] text-[13px] cursor-pointer transition-colors",style:{paddingLeft:"28px",paddingRight:"8px",background:g?"color-mix(in srgb, var(--accent) 15%, var(--bg-primary))":"transparent",color:g?"var(--text-primary)":"var(--text-secondary)",border:"none"},onMouseEnter:m=>{g||(m.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:m=>{g||(m.currentTarget.style.background="transparent")},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)"},className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),n.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate flex-1",children:d.name}),n.jsx("span",{className:"text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:d.row_count})]},d.name)})]})}function so(){const e=ye(h=>h.children[""]),{setChildren:t}=ye(),[s,r]=v.useState(!1),[i,o]=v.useState(!0),{openTab:a}=ye(),{navigate:l}=et();return v.useEffect(()=>{e||Ki("").then(h=>t("",h)).catch(console.error)},[e,t]),v.useEffect(()=>{Aa().then(({exists:h})=>r(h)).catch(()=>r(!1))},[]),n.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[n.jsxs("button",{onClick:()=>{a("__canvas__"),l("#/explorer/canvas")},className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[n.jsx("circle",{cx:"5",cy:"1.5",r:"1.2"}),n.jsx("circle",{cx:"2",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.2"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"2",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"}),n.jsx("line",{x1:"5",y1:"2.7",x2:"8",y2:"6.8",stroke:"currentColor",strokeWidth:"0.8"})]}),"Visualization"]}),s&&n.jsx(od,{onDbMissing:()=>r(!1)}),n.jsxs("button",{onClick:()=>o(!i),className:"w-full text-left flex items-center gap-1 py-[5px] text-[11px] uppercase tracking-wider font-semibold cursor-pointer",style:{paddingLeft:"12px",paddingRight:"8px",background:"none",border:"none",color:"var(--text-muted)"},children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"})}),"Files"]}),i&&(e?e.map(h=>n.jsx(Oa,{path:h.path,name:h.name,type:h.type,depth:0},h.path)):n.jsx("p",{className:"text-[11px] px-3 py-2",style:{color:"var(--text-muted)"},children:"Loading..."}))]})}async function ad(){const e=await fetch("/api/cli-agent/available");return e.ok?e.json():[]}const ld={startNode:wa,endNode:Ca,modelNode:ka,toolNode:Ea,groupNode:Na,defaultNode:ja},cd={elk:Ma};function hd(){const e=de(j=>j.entrypoints),t=de(j=>j.runs),[s,r]=v.useState(null),[i,o,a]=na([]),[l,h,c]=oa([]),[u,d]=v.useState(!0),[_,g]=v.useState(!1),m=v.useRef(0),x=v.useRef(""),w=v.useRef(null),E=v.useRef(null),k=v.useRef(wr()).current,P=v.useMemo(()=>{if(!s)return null;let j=null;for(const F of Object.values(t))if(F.entrypoint===s){if(F.status==="running"||F.status==="pending")return F.id;(!j||F.start_time&&(!j.start_time||F.start_time>j.start_time))&&(j=F)}return(j==null?void 0:j.id)??null},[t,s]);v.useEffect(()=>{if(P)return k.subscribe(P),()=>{k.unsubscribe(P)}},[P,k]);const O=de(j=>P?j.stateEvents[P]:void 0),D=de(j=>{var F;return P?(F=j.runs[P])==null?void 0:F.status:void 0});return v.useEffect(()=>{e.length>0&&(!s||!e.includes(s))&&r(e[0])},[e,s]),v.useEffect(()=>{if(!s)return;const j=++m.current;!x.current&&d(!0),g(!1),pa(s).then(async R=>{if(m.current!==j)return;if(!R.nodes.length){g(!0);return}const T=JSON.stringify(R);if(T===x.current)return;x.current=T;const{nodes:I,edges:L}=await Sa(R);m.current===j&&(o(I),h(L),setTimeout(()=>{var B;(B=w.current)==null||B.fitView({padding:.1,duration:200})},100))}).catch(()=>{m.current===j&&g(!0)}).finally(()=>{m.current===j&&d(!1)})},[s,e,o,h]),v.useEffect(()=>{if(!P)return;const j=new Map;if(O)for(const I of O)I.phase==="started"?j.set(I.node_name,I.qualified_node_name??null):I.phase==="completed"&&j.delete(I.node_name);let F=new Set;const R=new Set,T=new Map;o(I=>{var L;for(const B of I)B.type&&T.set(B.id,B.type);if(j.size>0){const B=new Map;for(const f of I){const p=(L=f.data)==null?void 0:L.label;if(!p)continue;const b=f.id.includes("/")?f.id.split("/").pop():f.id;for(const y of[b,p]){let N=B.get(y);N||(N=new Set,B.set(y,N)),N.add(f.id)}}for(const[f,p]of j){let b=!1;if(p){const y=p.replace(/:/g,"/");for(const N of I)N.id===y&&(F.add(N.id),b=!0)}if(!b){const y=B.get(f);y&&y.forEach(N=>F.add(N))}}}return I}),h(I=>I.map(L=>{var f,p;let B=F.has(L.source);return!B&&T.get(L.target)==="endNode"&&F.has(L.target)&&(B=!0),B?(R.add(L.target),{...L,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...Os,color:"var(--accent)"},data:{...L.data,highlighted:!0},animated:!0}):(f=L.data)!=null&&f.highlighted?{...L,style:Xi((p=L.data)==null?void 0:p.conditional),markerEnd:Os,data:{...L.data,highlighted:!1},animated:!1}:L})),o(I=>I.map(L=>{var p,b;const B=F.has(L.id),f=R.has(L.id)||F.has(L.id);return f!==!!((p=L.data)!=null&&p.isActiveNode)||B!==!!((b=L.data)!=null&&b.isExecutingNode)?{...L,data:{...L.data,isActiveNode:f,isExecutingNode:B}}:L}))},[P,O,o,h]),v.useEffect(()=>{P&&o(j=>{var f;const F=!!(O!=null&&O.length),R=D==="completed"||D==="failed",T=new Set,I=new Set(j.map(p=>p.id)),L=new Map;for(const p of j){const b=(f=p.data)==null?void 0:f.label;if(!b)continue;const y=p.id.includes("/")?p.id.split("/").pop():p.id;for(const N of[y,b]){let M=L.get(N);M||(M=new Set,L.set(N,M)),M.add(p.id)}}if(F)for(const p of O){let b=!1;if(p.qualified_node_name){const y=p.qualified_node_name.replace(/:/g,"/");I.has(y)&&(T.add(y),b=!0)}if(!b){const y=L.get(p.node_name);y&&y.forEach(N=>T.add(N))}}const B=new Set;for(const p of j)p.parentNode&&T.has(p.id)&&B.add(p.parentNode);return j.map(p=>{var y;let b;return T.has(p.id)?b="completed":p.type==="startNode"?(!p.parentNode&&F||p.parentNode&&B.has(p.parentNode))&&(b="completed"):p.type==="endNode"?!p.parentNode&&R?b=D==="failed"?"failed":"completed":p.parentNode&&B.has(p.parentNode)&&(b="completed"):p.type==="groupNode"&&B.has(p.id)&&(b="completed"),b!==((y=p.data)==null?void 0:y.status)?{...p,data:{...p.data,status:b}}:p})})},[P,O,D,o]),v.useEffect(()=>{const j=E.current;if(!j)return;const F=new ResizeObserver(()=>{var R;(R=w.current)==null||R.fitView({padding:.1,duration:200})});return F.observe(j),()=>F.disconnect()},[u,_]),u?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):_?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),n.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),n.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),n.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):n.jsxs("div",{ref:E,className:"h-full explorer-canvas",children:[n.jsx("style",{children:` .explorer-canvas .react-flow__handle { opacity: 0 !important; width: 0 !important; @@ -89,9 +89,9 @@ AgentRunHistory: @keyframes explorer-edge-flow { to { stroke-dashoffset: -12; } } - `}),e.length>1&&n.jsx("div",{style:{position:"absolute",top:8,left:8,zIndex:10},children:n.jsx("select",{value:s??"",onChange:N=>r(N.target.value),style:{background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--node-border)",borderRadius:6,padding:"4px 8px",fontSize:12},children:e.map(N=>n.jsx("option",{value:N,children:N},N))})}),n.jsxs(oa,{nodes:i,edges:l,onNodesChange:a,onEdgesChange:c,nodeTypes:ld,edgeTypes:cd,onInit:N=>{w.current=N},fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(aa,{color:"var(--bg-tertiary)",gap:16}),n.jsx(la,{showInteractive:!1}),n.jsx(ca,{nodeColor:N=>{var B;if(N.type==="groupNode")return"var(--bg-tertiary)";const $=(B=N.data)==null?void 0:B.status;return $==="completed"?"var(--success)":$==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}var Fr,so;function dd(){if(so)return Fr;so=1;function e(S){return S instanceof Map?S.clear=S.delete=S.set=function(){throw new Error("map is read-only")}:S instanceof Set&&(S.add=S.clear=S.delete=function(){throw new Error("set is read-only")}),Object.freeze(S),Object.getOwnPropertyNames(S).forEach(I=>{const X=S[I],ae=typeof X;(ae==="object"||ae==="function")&&!Object.isFrozen(X)&&e(X)}),S}class t{constructor(I){I.data===void 0&&(I.data={}),this.data=I.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(S){return S.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(S,...I){const X=Object.create(null);for(const ae in S)X[ae]=S[ae];return I.forEach(function(ae){for(const Te in ae)X[Te]=ae[Te]}),X}const i="
",o=S=>!!S.scope,a=(S,{prefix:I})=>{if(S.startsWith("language:"))return S.replace("language:","language-");if(S.includes(".")){const X=S.split(".");return[`${I}${X.shift()}`,...X.map((ae,Te)=>`${ae}${"_".repeat(Te+1)}`)].join(" ")}return`${I}${S}`};class l{constructor(I,X){this.buffer="",this.classPrefix=X.classPrefix,I.walk(this)}addText(I){this.buffer+=s(I)}openNode(I){if(!o(I))return;const X=a(I.scope,{prefix:this.classPrefix});this.span(X)}closeNode(I){o(I)&&(this.buffer+=i)}value(){return this.buffer}span(I){this.buffer+=``}}const h=(S={})=>{const I={children:[]};return Object.assign(I,S),I};class c{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(I){this.top.children.push(I)}openNode(I){const X=h({scope:I});this.add(X),this.stack.push(X)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(I){return this.constructor._walk(I,this.rootNode)}static _walk(I,X){return typeof X=="string"?I.addText(X):X.children&&(I.openNode(X),X.children.forEach(ae=>this._walk(I,ae)),I.closeNode(X)),I}static _collapse(I){typeof I!="string"&&I.children&&(I.children.every(X=>typeof X=="string")?I.children=[I.children.join("")]:I.children.forEach(X=>{c._collapse(X)}))}}class u extends c{constructor(I){super(),this.options=I}addText(I){I!==""&&this.add(I)}startScope(I){this.openNode(I)}endScope(){this.closeNode()}__addSublanguage(I,X){const ae=I.root;X&&(ae.scope=`language:${X}`),this.add(ae)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(S){return S?typeof S=="string"?S:S.source:null}function _(S){return x("(?=",S,")")}function g(S){return x("(?:",S,")*")}function m(S){return x("(?:",S,")?")}function x(...S){return S.map(X=>d(X)).join("")}function w(S){const I=S[S.length-1];return typeof I=="object"&&I.constructor===Object?(S.splice(S.length-1,1),I):{}}function E(...S){return"("+(w(S).capture?"":"?:")+S.map(ae=>d(ae)).join("|")+")"}function k(S){return new RegExp(S.toString()+"|").exec("").length-1}function P(S,I){const X=S&&S.exec(I);return X&&X.index===0}const A=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function D(S,{joinWith:I}){let X=0;return S.map(ae=>{X+=1;const Te=X;let Re=d(ae),Q="";for(;Re.length>0;){const J=A.exec(Re);if(!J){Q+=Re;break}Q+=Re.substring(0,J.index),Re=Re.substring(J.index+J[0].length),J[0][0]==="\\"&&J[1]?Q+="\\"+String(Number(J[1])+Te):(Q+=J[0],J[0]==="("&&X++)}return Q}).map(ae=>`(${ae})`).join(I)}const N=/\b\B/,$="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",O="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",L="\\b(0b[01]+)",R="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",p=(S={})=>{const I=/^#![ ]*\//;return S.binary&&(S.begin=x(I,/.*\b/,S.binary,/\b.*/)),r({scope:"meta",begin:I,end:/$/,relevance:0,"on:begin":(X,ae)=>{X.index!==0&&ae.ignoreMatch()}},S)},f={begin:"\\\\[\\s\\S]",relevance:0},b={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[f]},y={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[f]},j={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},M=function(S,I,X={}){const ae=r({scope:"comment",begin:S,end:I,contains:[]},X);ae.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Te=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ae.contains.push({begin:x(/[ ]+/,"(",Te,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ae},z=M("//","$"),C=M("/\\*","\\*/"),H=M("#","$"),U={scope:"number",begin:T,relevance:0},q={scope:"number",begin:O,relevance:0},ee={scope:"number",begin:L,relevance:0},ie={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[f,{begin:/\[/,end:/\]/,relevance:0,contains:[f]}]},F={scope:"title",begin:$,relevance:0},se={scope:"title",begin:B,relevance:0},pe={begin:"\\.\\s*"+B,relevance:0};var qe=Object.freeze({__proto__:null,APOS_STRING_MODE:b,BACKSLASH_ESCAPE:f,BINARY_NUMBER_MODE:ee,BINARY_NUMBER_RE:L,COMMENT:M,C_BLOCK_COMMENT_MODE:C,C_LINE_COMMENT_MODE:z,C_NUMBER_MODE:q,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(S){return Object.assign(S,{"on:begin":(I,X)=>{X.data._beginMatch=I[1]},"on:end":(I,X)=>{X.data._beginMatch!==I[1]&&X.ignoreMatch()}})},HASH_COMMENT_MODE:H,IDENT_RE:$,MATCH_NOTHING_RE:N,METHOD_GUARD:pe,NUMBER_MODE:U,NUMBER_RE:T,PHRASAL_WORDS_MODE:j,QUOTE_STRING_MODE:y,REGEXP_MODE:ie,RE_STARTERS_RE:R,SHEBANG:p,TITLE_MODE:F,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:se});function St(S,I){S.input[S.index-1]==="."&&I.ignoreMatch()}function ht(S,I){S.className!==void 0&&(S.scope=S.className,delete S.className)}function ge(S,I){I&&S.beginKeywords&&(S.begin="\\b("+S.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",S.__beforeBegin=St,S.keywords=S.keywords||S.beginKeywords,delete S.beginKeywords,S.relevance===void 0&&(S.relevance=0))}function $t(S,I){Array.isArray(S.illegal)&&(S.illegal=E(...S.illegal))}function Z(S,I){if(S.match){if(S.begin||S.end)throw new Error("begin & end are not supported with match");S.begin=S.match,delete S.match}}function me(S,I){S.relevance===void 0&&(S.relevance=1)}const dt=(S,I)=>{if(!S.beforeMatch)return;if(S.starts)throw new Error("beforeMatch cannot be used with starts");const X=Object.assign({},S);Object.keys(S).forEach(ae=>{delete S[ae]}),S.keywords=X.keywords,S.begin=x(X.beforeMatch,_(X.begin)),S.starts={relevance:0,contains:[Object.assign(X,{endsParent:!0})]},S.relevance=0,delete X.beforeMatch},ve=["of","and","for","in","not","or","if","then","parent","list","value"],vt="keyword";function xt(S,I,X=vt){const ae=Object.create(null);return typeof S=="string"?Te(X,S.split(" ")):Array.isArray(S)?Te(X,S):Object.keys(S).forEach(function(Re){Object.assign(ae,xt(S[Re],I,Re))}),ae;function Te(Re,Q){I&&(Q=Q.map(J=>J.toLowerCase())),Q.forEach(function(J){const oe=J.split("|");ae[oe[0]]=[Re,ot(oe[0],oe[1])]})}}function ot(S,I){return I?Number(I):ut(S)?0:1}function ut(S){return ve.includes(S.toLowerCase())}const Ks={},Bt=S=>{console.error(S)},nn=(S,...I)=>{console.log(`WARN: ${S}`,...I)},ds=(S,I)=>{Ks[`${S}/${I}`]||(console.log(`Deprecated as of ${S}. ${I}`),Ks[`${S}/${I}`]=!0)},Vs=new Error;function on(S,I,{key:X}){let ae=0;const Te=S[X],Re={},Q={};for(let J=1;J<=I.length;J++)Q[J+ae]=Te[J],Re[J+ae]=!0,ae+=k(I[J-1]);S[X]=Q,S[X]._emit=Re,S[X]._multi=!0}function Ml(S){if(Array.isArray(S.begin)){if(S.skip||S.excludeBegin||S.returnBegin)throw Bt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Vs;if(typeof S.beginScope!="object"||S.beginScope===null)throw Bt("beginScope must be object"),Vs;on(S,S.begin,{key:"beginScope"}),S.begin=D(S.begin,{joinWith:""})}}function Ll(S){if(Array.isArray(S.end)){if(S.skip||S.excludeEnd||S.returnEnd)throw Bt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Vs;if(typeof S.endScope!="object"||S.endScope===null)throw Bt("endScope must be object"),Vs;on(S,S.end,{key:"endScope"}),S.end=D(S.end,{joinWith:""})}}function Tl(S){S.scope&&typeof S.scope=="object"&&S.scope!==null&&(S.beginScope=S.scope,delete S.scope)}function Rl(S){Tl(S),typeof S.beginScope=="string"&&(S.beginScope={_wrap:S.beginScope}),typeof S.endScope=="string"&&(S.endScope={_wrap:S.endScope}),Ml(S),Ll(S)}function Bl(S){function I(Q,J){return new RegExp(d(Q),"m"+(S.case_insensitive?"i":"")+(S.unicodeRegex?"u":"")+(J?"g":""))}class X{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(J,oe){oe.position=this.position++,this.matchIndexes[this.matchAt]=oe,this.regexes.push([oe,J]),this.matchAt+=k(J)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const J=this.regexes.map(oe=>oe[1]);this.matcherRe=I(D(J,{joinWith:"|"}),!0),this.lastIndex=0}exec(J){this.matcherRe.lastIndex=this.lastIndex;const oe=this.matcherRe.exec(J);if(!oe)return null;const $e=oe.findIndex((Ss,Tr)=>Tr>0&&Ss!==void 0),De=this.matchIndexes[$e];return oe.splice(0,$e),Object.assign(oe,De)}}class ae{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(J){if(this.multiRegexes[J])return this.multiRegexes[J];const oe=new X;return this.rules.slice(J).forEach(([$e,De])=>oe.addRule($e,De)),oe.compile(),this.multiRegexes[J]=oe,oe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(J,oe){this.rules.push([J,oe]),oe.type==="begin"&&this.count++}exec(J){const oe=this.getMatcher(this.regexIndex);oe.lastIndex=this.lastIndex;let $e=oe.exec(J);if(this.resumingScanAtSamePosition()&&!($e&&$e.index===this.lastIndex)){const De=this.getMatcher(0);De.lastIndex=this.lastIndex+1,$e=De.exec(J)}return $e&&(this.regexIndex+=$e.position+1,this.regexIndex===this.count&&this.considerAll()),$e}}function Te(Q){const J=new ae;return Q.contains.forEach(oe=>J.addRule(oe.begin,{rule:oe,type:"begin"})),Q.terminatorEnd&&J.addRule(Q.terminatorEnd,{type:"end"}),Q.illegal&&J.addRule(Q.illegal,{type:"illegal"}),J}function Re(Q,J){const oe=Q;if(Q.isCompiled)return oe;[ht,Z,Rl,dt].forEach(De=>De(Q,J)),S.compilerExtensions.forEach(De=>De(Q,J)),Q.__beforeBegin=null,[ge,$t,me].forEach(De=>De(Q,J)),Q.isCompiled=!0;let $e=null;return typeof Q.keywords=="object"&&Q.keywords.$pattern&&(Q.keywords=Object.assign({},Q.keywords),$e=Q.keywords.$pattern,delete Q.keywords.$pattern),$e=$e||/\w+/,Q.keywords&&(Q.keywords=xt(Q.keywords,S.case_insensitive)),oe.keywordPatternRe=I($e,!0),J&&(Q.begin||(Q.begin=/\B|\b/),oe.beginRe=I(oe.begin),!Q.end&&!Q.endsWithParent&&(Q.end=/\B|\b/),Q.end&&(oe.endRe=I(oe.end)),oe.terminatorEnd=d(oe.end)||"",Q.endsWithParent&&J.terminatorEnd&&(oe.terminatorEnd+=(Q.end?"|":"")+J.terminatorEnd)),Q.illegal&&(oe.illegalRe=I(Q.illegal)),Q.contains||(Q.contains=[]),Q.contains=[].concat(...Q.contains.map(function(De){return Dl(De==="self"?Q:De)})),Q.contains.forEach(function(De){Re(De,oe)}),Q.starts&&Re(Q.starts,J),oe.matcher=Te(oe),oe}if(S.compilerExtensions||(S.compilerExtensions=[]),S.contains&&S.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return S.classNameAliases=r(S.classNameAliases||{}),Re(S)}function an(S){return S?S.endsWithParent||an(S.starts):!1}function Dl(S){return S.variants&&!S.cachedVariants&&(S.cachedVariants=S.variants.map(function(I){return r(S,{variants:null},I)})),S.cachedVariants?S.cachedVariants:an(S)?r(S,{starts:S.starts?r(S.starts):null}):Object.isFrozen(S)?r(S):S}var Pl="11.11.1";class Al extends Error{constructor(I,X){super(I),this.name="HTMLInjectionError",this.html=X}}const Lr=s,ln=r,cn=Symbol("nomatch"),Ol=7,hn=function(S){const I=Object.create(null),X=Object.create(null),ae=[];let Te=!0;const Re="Could not find the language '{}', did you forget to load/include a language module?",Q={disableAutodetect:!0,name:"Plain text",contains:[]};let J={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function oe(K){return J.noHighlightRe.test(K)}function $e(K){let re=K.className+" ";re+=K.parentNode?K.parentNode.className:"";const fe=J.languageDetectRe.exec(re);if(fe){const we=Ft(fe[1]);return we||(nn(Re.replace("{}",fe[1])),nn("Falling back to no-highlight mode for this block.",K)),we?fe[1]:"no-highlight"}return re.split(/\s+/).find(we=>oe(we)||Ft(we))}function De(K,re,fe){let we="",Oe="";typeof re=="object"?(we=K,fe=re.ignoreIllegals,Oe=re.language):(ds("10.7.0","highlight(lang, code, ...args) has been deprecated."),ds("10.7.0",`Please use highlight(code, options) instead. -https://github.com/highlightjs/highlight.js/issues/2277`),Oe=K,we=re),fe===void 0&&(fe=!0);const yt={code:we,language:Oe};Xs("before:highlight",yt);const zt=yt.result?yt.result:Ss(yt.language,yt.code,fe);return zt.code=yt.code,Xs("after:highlight",zt),zt}function Ss(K,re,fe,we){const Oe=Object.create(null);function yt(Y,te){return Y.keywords[te]}function zt(){if(!le.keywords){Xe.addText(Ce);return}let Y=0;le.keywordPatternRe.lastIndex=0;let te=le.keywordPatternRe.exec(Ce),ce="";for(;te;){ce+=Ce.substring(Y,te.index);const be=Ct.case_insensitive?te[0].toLowerCase():te[0],Je=yt(le,be);if(Je){const[Dt,ec]=Je;if(Xe.addText(ce),ce="",Oe[be]=(Oe[be]||0)+1,Oe[be]<=Ol&&(Js+=ec),Dt.startsWith("_"))ce+=te[0];else{const tc=Ct.classNameAliases[Dt]||Dt;wt(te[0],tc)}}else ce+=te[0];Y=le.keywordPatternRe.lastIndex,te=le.keywordPatternRe.exec(Ce)}ce+=Ce.substring(Y),Xe.addText(ce)}function Ys(){if(Ce==="")return;let Y=null;if(typeof le.subLanguage=="string"){if(!I[le.subLanguage]){Xe.addText(Ce);return}Y=Ss(le.subLanguage,Ce,!0,vn[le.subLanguage]),vn[le.subLanguage]=Y._top}else Y=Rr(Ce,le.subLanguage.length?le.subLanguage:null);le.relevance>0&&(Js+=Y.relevance),Xe.__addSublanguage(Y._emitter,Y.language)}function at(){le.subLanguage!=null?Ys():zt(),Ce=""}function wt(Y,te){Y!==""&&(Xe.startScope(te),Xe.addText(Y),Xe.endScope())}function pn(Y,te){let ce=1;const be=te.length-1;for(;ce<=be;){if(!Y._emit[ce]){ce++;continue}const Je=Ct.classNameAliases[Y[ce]]||Y[ce],Dt=te[ce];Je?wt(Dt,Je):(Ce=Dt,zt(),Ce=""),ce++}}function _n(Y,te){return Y.scope&&typeof Y.scope=="string"&&Xe.openNode(Ct.classNameAliases[Y.scope]||Y.scope),Y.beginScope&&(Y.beginScope._wrap?(wt(Ce,Ct.classNameAliases[Y.beginScope._wrap]||Y.beginScope._wrap),Ce=""):Y.beginScope._multi&&(pn(Y.beginScope,te),Ce="")),le=Object.create(Y,{parent:{value:le}}),le}function gn(Y,te,ce){let be=P(Y.endRe,ce);if(be){if(Y["on:end"]){const Je=new t(Y);Y["on:end"](te,Je),Je.isMatchIgnored&&(be=!1)}if(be){for(;Y.endsParent&&Y.parent;)Y=Y.parent;return Y}}if(Y.endsWithParent)return gn(Y.parent,te,ce)}function Yl(Y){return le.matcher.regexIndex===0?(Ce+=Y[0],1):(Ar=!0,0)}function Gl(Y){const te=Y[0],ce=Y.rule,be=new t(ce),Je=[ce.__beforeBegin,ce["on:begin"]];for(const Dt of Je)if(Dt&&(Dt(Y,be),be.isMatchIgnored))return Yl(te);return ce.skip?Ce+=te:(ce.excludeBegin&&(Ce+=te),at(),!ce.returnBegin&&!ce.excludeBegin&&(Ce=te)),_n(ce,Y),ce.returnBegin?0:te.length}function Jl(Y){const te=Y[0],ce=re.substring(Y.index),be=gn(le,Y,ce);if(!be)return cn;const Je=le;le.endScope&&le.endScope._wrap?(at(),wt(te,le.endScope._wrap)):le.endScope&&le.endScope._multi?(at(),pn(le.endScope,Y)):Je.skip?Ce+=te:(Je.returnEnd||Je.excludeEnd||(Ce+=te),at(),Je.excludeEnd&&(Ce=te));do le.scope&&Xe.closeNode(),!le.skip&&!le.subLanguage&&(Js+=le.relevance),le=le.parent;while(le!==be.parent);return be.starts&&_n(be.starts,Y),Je.returnEnd?0:te.length}function Zl(){const Y=[];for(let te=le;te!==Ct;te=te.parent)te.scope&&Y.unshift(te.scope);Y.forEach(te=>Xe.openNode(te))}let Gs={};function mn(Y,te){const ce=te&&te[0];if(Ce+=Y,ce==null)return at(),0;if(Gs.type==="begin"&&te.type==="end"&&Gs.index===te.index&&ce===""){if(Ce+=re.slice(te.index,te.index+1),!Te){const be=new Error(`0 width match regex (${K})`);throw be.languageName=K,be.badRule=Gs.rule,be}return 1}if(Gs=te,te.type==="begin")return Gl(te);if(te.type==="illegal"&&!fe){const be=new Error('Illegal lexeme "'+ce+'" for mode "'+(le.scope||"")+'"');throw be.mode=le,be}else if(te.type==="end"){const be=Jl(te);if(be!==cn)return be}if(te.type==="illegal"&&ce==="")return Ce+=` -`,1;if(Pr>1e5&&Pr>te.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ce+=ce,ce.length}const Ct=Ft(K);if(!Ct)throw Bt(Re.replace("{}",K)),new Error('Unknown language: "'+K+'"');const Ql=Bl(Ct);let Dr="",le=we||Ql;const vn={},Xe=new J.__emitter(J);Zl();let Ce="",Js=0,es=0,Pr=0,Ar=!1;try{if(Ct.__emitTokens)Ct.__emitTokens(re,Xe);else{for(le.matcher.considerAll();;){Pr++,Ar?Ar=!1:le.matcher.considerAll(),le.matcher.lastIndex=es;const Y=le.matcher.exec(re);if(!Y)break;const te=re.substring(es,Y.index),ce=mn(te,Y);es=Y.index+ce}mn(re.substring(es))}return Xe.finalize(),Dr=Xe.toHTML(),{language:K,value:Dr,relevance:Js,illegal:!1,_emitter:Xe,_top:le}}catch(Y){if(Y.message&&Y.message.includes("Illegal"))return{language:K,value:Lr(re),illegal:!0,relevance:0,_illegalBy:{message:Y.message,index:es,context:re.slice(es-100,es+100),mode:Y.mode,resultSoFar:Dr},_emitter:Xe};if(Te)return{language:K,value:Lr(re),illegal:!1,relevance:0,errorRaised:Y,_emitter:Xe,_top:le};throw Y}}function Tr(K){const re={value:Lr(K),illegal:!1,relevance:0,_top:Q,_emitter:new J.__emitter(J)};return re._emitter.addText(K),re}function Rr(K,re){re=re||J.languages||Object.keys(I);const fe=Tr(K),we=re.filter(Ft).filter(fn).map(at=>Ss(at,K,!1));we.unshift(fe);const Oe=we.sort((at,wt)=>{if(at.relevance!==wt.relevance)return wt.relevance-at.relevance;if(at.language&&wt.language){if(Ft(at.language).supersetOf===wt.language)return 1;if(Ft(wt.language).supersetOf===at.language)return-1}return 0}),[yt,zt]=Oe,Ys=yt;return Ys.secondBest=zt,Ys}function Il(K,re,fe){const we=re&&X[re]||fe;K.classList.add("hljs"),K.classList.add(`language-${we}`)}function Br(K){let re=null;const fe=$e(K);if(oe(fe))return;if(Xs("before:highlightElement",{el:K,language:fe}),K.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",K);return}if(K.children.length>0&&(J.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(K)),J.throwUnescapedHTML))throw new Al("One of your code blocks includes unescaped HTML.",K.innerHTML);re=K;const we=re.textContent,Oe=fe?De(we,{language:fe,ignoreIllegals:!0}):Rr(we);K.innerHTML=Oe.value,K.dataset.highlighted="yes",Il(K,fe,Oe.language),K.result={language:Oe.language,re:Oe.relevance,relevance:Oe.relevance},Oe.secondBest&&(K.secondBest={language:Oe.secondBest.language,relevance:Oe.secondBest.relevance}),Xs("after:highlightElement",{el:K,result:Oe,text:we})}function Wl(K){J=ln(J,K)}const Hl=()=>{qs(),ds("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $l(){qs(),ds("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let dn=!1;function qs(){function K(){qs()}if(document.readyState==="loading"){dn||window.addEventListener("DOMContentLoaded",K,!1),dn=!0;return}document.querySelectorAll(J.cssSelector).forEach(Br)}function Fl(K,re){let fe=null;try{fe=re(S)}catch(we){if(Bt("Language definition for '{}' could not be registered.".replace("{}",K)),Te)Bt(we);else throw we;fe=Q}fe.name||(fe.name=K),I[K]=fe,fe.rawDefinition=re.bind(null,S),fe.aliases&&un(fe.aliases,{languageName:K})}function zl(K){delete I[K];for(const re of Object.keys(X))X[re]===K&&delete X[re]}function Ul(){return Object.keys(I)}function Ft(K){return K=(K||"").toLowerCase(),I[K]||I[X[K]]}function un(K,{languageName:re}){typeof K=="string"&&(K=[K]),K.forEach(fe=>{X[fe.toLowerCase()]=re})}function fn(K){const re=Ft(K);return re&&!re.disableAutodetect}function Kl(K){K["before:highlightBlock"]&&!K["before:highlightElement"]&&(K["before:highlightElement"]=re=>{K["before:highlightBlock"](Object.assign({block:re.el},re))}),K["after:highlightBlock"]&&!K["after:highlightElement"]&&(K["after:highlightElement"]=re=>{K["after:highlightBlock"](Object.assign({block:re.el},re))})}function Vl(K){Kl(K),ae.push(K)}function ql(K){const re=ae.indexOf(K);re!==-1&&ae.splice(re,1)}function Xs(K,re){const fe=K;ae.forEach(function(we){we[fe]&&we[fe](re)})}function Xl(K){return ds("10.7.0","highlightBlock will be removed entirely in v12.0"),ds("10.7.0","Please use highlightElement now."),Br(K)}Object.assign(S,{highlight:De,highlightAuto:Rr,highlightAll:qs,highlightElement:Br,highlightBlock:Xl,configure:Wl,initHighlighting:Hl,initHighlightingOnLoad:$l,registerLanguage:Fl,unregisterLanguage:zl,listLanguages:Ul,getLanguage:Ft,registerAliases:un,autoDetection:fn,inherit:ln,addPlugin:Vl,removePlugin:ql}),S.debugMode=function(){Te=!1},S.safeMode=function(){Te=!0},S.versionString=Pl,S.regex={concat:x,lookahead:_,either:E,optional:m,anyNumberOfTimes:g};for(const K in qe)typeof qe[K]=="object"&&e(qe[K]);return Object.assign(S,qe),S},us=hn({});return us.newInstance=()=>hn({}),Fr=us,us.HighlightJS=us,us.default=us,Fr}var ud=dd();const Ia=ic(ud);function fd(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,s,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}Ia.registerLanguage("json",fd);const fs=100;function ps(e){return e!==null&&typeof e=="object"}function pd(e){if(Array.isArray(e))return`Array(${e.length})`;const t=Object.keys(e);return t.length<=3?`{${t.join(", ")}}`:`{${t.slice(0,3).join(", ")}, …} (${t.length} keys)`}function _d({value:e,onClose:t}){const s=v.useRef(null),r=v.useMemo(()=>JSON.stringify(e,null,2),[e]),i=v.useMemo(()=>Ia.highlight(r,{language:"json"}).value,[r]);return v.useEffect(()=>{const o=a=>{a.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),nc.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:o=>{o.target===o.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg shadow-xl flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",maxHeight:"80vh"},children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Array.isArray(e)?`Array (${e.length} items)`:`Object (${Object.keys(e).length} keys)`}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-auto chat-markdown",children:n.jsx("pre",{className:"m-0 p-4",style:{background:"transparent"},children:n.jsx("code",{ref:s,className:"hljs language-json text-[13px] leading-relaxed",style:{background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-all"},dangerouslySetInnerHTML:{__html:i}})})})]})}),document.body)}function gd({value:e}){const[t,s]=v.useState(!1),r=pd(e);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>s(!0),className:"text-left text-[12px] cursor-pointer flex items-center gap-1 max-w-[300px]",style:{background:"none",border:"none",padding:0,color:"var(--accent)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate",style:{color:"var(--text-secondary)"},children:r})]}),t&&n.jsx(_d,{value:e,onClose:()=>s(!1)})]})}function md({table:e}){return n.jsx(vd,{table:e})}function vd({table:e}){const[t,s]=v.useState([]),[r,i]=v.useState([]),[o,a]=v.useState(0),[l,h]=v.useState(0),[c,u]=v.useState(!0),[d,_]=v.useState(null),[g,m]=v.useState(""),[x,w]=v.useState(!1),E=v.useCallback(B=>{u(!0),_(null),w(!1),rd(e,fs,B).then(T=>{s(T.columns),i(T.rows),a(T.total),h(B)}).catch(T=>_(T.detail||T.message)).finally(()=>u(!1))},[e]);v.useEffect(()=>{E(0),m("")},[e,E]);const k=v.useCallback(()=>{g.trim()&&(u(!0),_(null),w(!0),id(g).then(B=>{s(B.columns),i(B.rows),a(B.row_count),h(0)}).catch(B=>_(B.detail||B.message)).finally(()=>u(!1)))},[g]),P=B=>{B.key==="Enter"&&(B.ctrlKey||B.metaKey)&&(B.preventDefault(),k())},A=!x&&l>0,D=!x&&l+fsm(B.target.value),onKeyDown:P,placeholder:`SELECT * FROM [${e}] WHERE ...`,className:"flex-1 text-[13px] px-3 py-1.5 rounded",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)",outline:"none"}}),n.jsx("button",{onClick:k,disabled:!g.trim(),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:g.trim()?"var(--accent)":"var(--bg-hover)",color:g.trim()?"#fff":"var(--text-muted)",border:"none"},children:"Run"}),x&&n.jsx("button",{onClick:()=>E(0),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Reset"})]}),d&&n.jsx("div",{className:"px-4 py-2 text-[12px] shrink-0",style:{background:"rgba(239,68,68,0.1)",color:"#ef4444"},children:d}),n.jsx("div",{className:"flex-1 overflow-auto",children:c?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"Loading..."}):r.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"No rows"}):n.jsxs("table",{className:"w-full text-[12px]",style:{borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(B=>n.jsxs("th",{className:"text-left px-3 py-2 whitespace-nowrap sticky top-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)",color:"var(--text-primary)",fontWeight:600},children:[B.name,n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)",fontSize:"10px"},children:B.type})]},B.name))})}),n.jsx("tbody",{children:r.map((B,T)=>n.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},onMouseEnter:O=>{O.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:B.map((O,L)=>n.jsx("td",{className:"px-3 py-1.5",style:{color:O==null?"var(--text-muted)":"var(--text-secondary)",maxWidth:ps(O)?void 0:"300px",overflow:ps(O)?void 0:"hidden",textOverflow:ps(O)?void 0:"ellipsis",whiteSpace:ps(O)?void 0:"nowrap",verticalAlign:"top"},title:O!=null&&!ps(O)?String(O):void 0,children:O==null?n.jsx("span",{style:{fontStyle:"italic"},children:"NULL"}):ps(O)?n.jsx(gd,{value:O}):String(O)},L))},T))})]})}),(A||D)&&!c&&n.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 shrink-0 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>E(l-fs),disabled:!A,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:A?"var(--text-secondary)":"var(--text-muted)",opacity:A?1:.5},children:"Previous"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:["Page ",N," of ",$]}),n.jsx("button",{onClick:()=>E(l+fs),disabled:!D,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:D?"var(--text-secondary)":"var(--text-muted)",opacity:D?1:.5},children:"Next"})]})]})}const lr="__canvas__",ns="__statedb__:";function ro(e){return e===lr?"#/explorer/canvas":e.startsWith(ns)?`#/explorer/statedb/${encodeURIComponent(e.slice(ns.length))}`:`#/explorer/file/${encodeURIComponent(e)}`}const io=e=>{e.editor.defineTheme("uipath-dark",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"64748b",fontStyle:"italic"},{token:"keyword",foreground:"c084fc"},{token:"string",foreground:"86efac"},{token:"number",foreground:"fcd34d"},{token:"type",foreground:"7dd3fc"}],colors:{"editor.background":"#0f172a","editor.foreground":"#cbd5e1","editor.lineHighlightBackground":"#1e293b","editor.selectionBackground":"#334155","editor.inactiveSelectionBackground":"#263348","editorLineNumber.foreground":"#64748b","editorLineNumber.activeForeground":"#94a3b8","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#334155","editorIndentGuide.activeBackground":"#64748b","editorWidget.background":"#1e293b","editorWidget.border":"#334155","editorSuggestWidget.background":"#1e293b","editorSuggestWidget.border":"#334155","editorSuggestWidget.selectedBackground":"#263348","editorHoverWidget.background":"#1e293b","editorHoverWidget.border":"#334155","scrollbarSlider.background":"#33415580","scrollbarSlider.hoverBackground":"#33415599","scrollbarSlider.activeBackground":"#334155cc"}}),e.editor.defineTheme("uipath-light",{base:"vs",inherit:!0,rules:[{token:"comment",foreground:"94a3b8",fontStyle:"italic"},{token:"keyword",foreground:"7c3aed"},{token:"string",foreground:"16a34a"},{token:"number",foreground:"d97706"},{token:"type",foreground:"0284c7"}],colors:{"editor.background":"#f8fafc","editor.foreground":"#0f172a","editor.lineHighlightBackground":"#f1f5f9","editor.selectionBackground":"#e2e8f0","editor.inactiveSelectionBackground":"#f1f5f9","editorLineNumber.foreground":"#94a3b8","editorLineNumber.activeForeground":"#475569","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#e2e8f0","editorIndentGuide.activeBackground":"#94a3b8","editorWidget.background":"#ffffff","editorWidget.border":"#e2e8f0","editorSuggestWidget.background":"#ffffff","editorSuggestWidget.border":"#e2e8f0","editorSuggestWidget.selectedBackground":"#f1f5f9","editorHoverWidget.background":"#ffffff","editorHoverWidget.border":"#e2e8f0","scrollbarSlider.background":"#d1d5db80","scrollbarSlider.hoverBackground":"#d1d5db99","scrollbarSlider.activeBackground":"#d1d5dbcc"}})};function no(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function xd(e){const t=e.replace(/\\/g,"/").split("/");return t[t.length-1]||e}function yd(){const e=ye(p=>p.openTabs),s=ye(p=>p.selectedFile),r=ye(p=>s?p.fileCache[s]:void 0),i=ye(p=>s?!!p.dirty[s]:!1),o=ye(p=>s?p.buffers[s]:void 0),a=ye(p=>p.loadingFile),l=ye(p=>p.dirty),h=ye(p=>p.diffView),c=ye(p=>s?!!p.agentChangedFiles[s]:!1),{setFileContent:u,updateBuffer:d,markClean:_,setLoadingFile:g,openTab:m,closeTab:x,setDiffView:w}=ye(),{navigate:E}=et(),k=ya(p=>p.theme),P=v.useRef(null),{explorerFile:A}=et();v.useEffect(()=>{A&&m(A)},[A,m]),v.useEffect(()=>{!s||s===lr||s.startsWith(ns)||ye.getState().fileCache[s]||(g(!0),pa(s).then(p=>u(s,p)).catch(console.error).finally(()=>g(!1)))},[s,u,g]);const D=v.useCallback(()=>{if(!s)return;const p=ye.getState().fileCache[s],b=ye.getState().buffers[s]??(p==null?void 0:p.content);b!=null&&jc(s,b).then(()=>{_(s),u(s,{...p,content:b})}).catch(console.error)},[s,_,u]);v.useEffect(()=>{const p=f=>{(f.ctrlKey||f.metaKey)&&f.key==="s"&&(f.preventDefault(),D())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[D]);const N=p=>{P.current=p},$=v.useCallback(p=>{p!==void 0&&s&&d(s,p)},[s,d]),B=v.useCallback(p=>{m(p),E(ro(p))},[m,E]),T=v.useCallback((p,f)=>{p.stopPropagation();const b=ye.getState(),y=b.openTabs.filter(j=>j!==f);if(x(f),b.selectedFile===f){const j=b.openTabs.indexOf(f),M=y[Math.min(j,y.length-1)];E(M?ro(M):"#/explorer")}},[x,E]),O=v.useCallback((p,f)=>{p.button===1&&T(p,f)},[T]),L=e.length>0&&n.jsx("div",{className:"h-10 flex items-end overflow-x-auto shrink-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},children:e.map(p=>{const f=p===s,b=!!l[p];return n.jsxs("button",{onClick:()=>B(p),onMouseDown:y=>O(y,p),className:"h-full flex items-center gap-1.5 px-3 text-[12px] shrink-0 cursor-pointer transition-colors relative",style:{background:f?"var(--bg-primary)":"transparent",color:f?"var(--text-primary)":"var(--text-secondary)",border:"none",borderBottom:f?"2px solid var(--accent)":"2px solid transparent",maxWidth:"180px"},onMouseEnter:y=>{f||(y.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:y=>{f||(y.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"truncate",children:p===lr?"Visualization":p.startsWith(ns)?`db:${p.slice(ns.length)}`:xd(p)}),b?n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"},title:"Unsaved changes"}):n.jsx("span",{className:"w-4 h-4 flex items-center justify-center rounded shrink-0 transition-colors",style:{color:"var(--text-muted)"},onClick:y=>T(y,p),onMouseEnter:y=>{y.currentTarget.style.background="var(--bg-hover)",y.currentTarget.style.color="var(--text-primary)"},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color="var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:n.jsx("path",{d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.708.708L7.293 8l-3.647 3.646.708.708L8 8.707z"})})})]},p)})});if(s===lr)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(hd,{})})]});if(s!=null&&s.startsWith(ns)){const p=s.slice(ns.length);return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(md,{table:p})})]})}if(!s)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a file to view"})]});if(a&&!r)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Loading file..."})})]});if(!r&&!a)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Failed to load file"})})]});if(!r)return null;if(r.binary)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)})}),n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),n.jsx("span",{className:"text-sm",children:"Binary file — preview not available"})]})]});const R=h&&h.path===s;return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[r.language&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--bg-hover)",color:"var(--text-muted)"},children:r.language}),n.jsx("span",{style:{color:"var(--text-muted)"},children:no(r.size)}),c&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium",style:{background:"color-mix(in srgb, var(--info) 20%, transparent)",color:"var(--info)"},children:"Agent modified"}),n.jsx("div",{className:"flex-1"}),i&&n.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--accent)"},children:"Modified"}),n.jsx("button",{onClick:D,className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:i?"var(--accent)":"var(--bg-hover)",color:i?"white":"var(--text-muted)",border:"none"},children:"Save"})]}),R&&n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--info) 10%, var(--bg-secondary))"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--info)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),n.jsx("span",{style:{color:"var(--info)"},children:"Agent modified this file"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>w(null),className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Dismiss"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:R?n.jsx(oc,{original:h.original,modified:h.modified,language:h.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",beforeMount:io,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,automaticLayout:!0,renderSideBySide:!0}},`diff-${s}`):n.jsx(ac,{language:r.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",value:o??r.content??"",onChange:$,beforeMount:io,onMount:N,options:{minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2,renderWhitespace:"selection"}},s)})]})}/** + `}),e.length>1&&n.jsx("div",{style:{position:"absolute",top:8,left:8,zIndex:10},children:n.jsx("select",{value:s??"",onChange:j=>r(j.target.value),style:{background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--node-border)",borderRadius:6,padding:"4px 8px",fontSize:12},children:e.map(j=>n.jsx("option",{value:j,children:j},j))})}),n.jsxs(aa,{nodes:i,edges:l,onNodesChange:a,onEdgesChange:c,nodeTypes:ld,edgeTypes:cd,onInit:j=>{w.current=j},fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[n.jsx(la,{color:"var(--bg-tertiary)",gap:16}),n.jsx(ca,{showInteractive:!1}),n.jsx(ha,{nodeColor:j=>{var R;if(j.type==="groupNode")return"var(--bg-tertiary)";const F=(R=j.data)==null?void 0:R.status;return F==="completed"?"var(--success)":F==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}var Fr,ro;function dd(){if(ro)return Fr;ro=1;function e(S){return S instanceof Map?S.clear=S.delete=S.set=function(){throw new Error("map is read-only")}:S instanceof Set&&(S.add=S.clear=S.delete=function(){throw new Error("set is read-only")}),Object.freeze(S),Object.getOwnPropertyNames(S).forEach(H=>{const X=S[H],ae=typeof X;(ae==="object"||ae==="function")&&!Object.isFrozen(X)&&e(X)}),S}class t{constructor(H){H.data===void 0&&(H.data={}),this.data=H.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(S){return S.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(S,...H){const X=Object.create(null);for(const ae in S)X[ae]=S[ae];return H.forEach(function(ae){for(const Te in ae)X[Te]=ae[Te]}),X}const i="",o=S=>!!S.scope,a=(S,{prefix:H})=>{if(S.startsWith("language:"))return S.replace("language:","language-");if(S.includes(".")){const X=S.split(".");return[`${H}${X.shift()}`,...X.map((ae,Te)=>`${ae}${"_".repeat(Te+1)}`)].join(" ")}return`${H}${S}`};class l{constructor(H,X){this.buffer="",this.classPrefix=X.classPrefix,H.walk(this)}addText(H){this.buffer+=s(H)}openNode(H){if(!o(H))return;const X=a(H.scope,{prefix:this.classPrefix});this.span(X)}closeNode(H){o(H)&&(this.buffer+=i)}value(){return this.buffer}span(H){this.buffer+=``}}const h=(S={})=>{const H={children:[]};return Object.assign(H,S),H};class c{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(H){this.top.children.push(H)}openNode(H){const X=h({scope:H});this.add(X),this.stack.push(X)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(H){return this.constructor._walk(H,this.rootNode)}static _walk(H,X){return typeof X=="string"?H.addText(X):X.children&&(H.openNode(X),X.children.forEach(ae=>this._walk(H,ae)),H.closeNode(X)),H}static _collapse(H){typeof H!="string"&&H.children&&(H.children.every(X=>typeof X=="string")?H.children=[H.children.join("")]:H.children.forEach(X=>{c._collapse(X)}))}}class u extends c{constructor(H){super(),this.options=H}addText(H){H!==""&&this.add(H)}startScope(H){this.openNode(H)}endScope(){this.closeNode()}__addSublanguage(H,X){const ae=H.root;X&&(ae.scope=`language:${X}`),this.add(ae)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(S){return S?typeof S=="string"?S:S.source:null}function _(S){return x("(?=",S,")")}function g(S){return x("(?:",S,")*")}function m(S){return x("(?:",S,")?")}function x(...S){return S.map(X=>d(X)).join("")}function w(S){const H=S[S.length-1];return typeof H=="object"&&H.constructor===Object?(S.splice(S.length-1,1),H):{}}function E(...S){return"("+(w(S).capture?"":"?:")+S.map(ae=>d(ae)).join("|")+")"}function k(S){return new RegExp(S.toString()+"|").exec("").length-1}function P(S,H){const X=S&&S.exec(H);return X&&X.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function D(S,{joinWith:H}){let X=0;return S.map(ae=>{X+=1;const Te=X;let Re=d(ae),ee="";for(;Re.length>0;){const J=O.exec(Re);if(!J){ee+=Re;break}ee+=Re.substring(0,J.index),Re=Re.substring(J.index+J[0].length),J[0][0]==="\\"&&J[1]?ee+="\\"+String(Number(J[1])+Te):(ee+=J[0],J[0]==="("&&X++)}return ee}).map(ae=>`(${ae})`).join(H)}const j=/\b\B/,F="[a-zA-Z]\\w*",R="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",I="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",L="\\b(0b[01]+)",B="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",f=(S={})=>{const H=/^#![ ]*\//;return S.binary&&(S.begin=x(H,/.*\b/,S.binary,/\b.*/)),r({scope:"meta",begin:H,end:/$/,relevance:0,"on:begin":(X,ae)=>{X.index!==0&&ae.ignoreMatch()}},S)},p={begin:"\\\\[\\s\\S]",relevance:0},b={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[p]},y={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[p]},N={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},M=function(S,H,X={}){const ae=r({scope:"comment",begin:S,end:H,contains:[]},X);ae.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Te=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ae.contains.push({begin:x(/[ ]+/,"(",Te,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ae},U=M("//","$"),C=M("/\\*","\\*/"),W=M("#","$"),z={scope:"number",begin:T,relevance:0},A={scope:"number",begin:I,relevance:0},Z={scope:"number",begin:L,relevance:0},ie={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[p,{begin:/\[/,end:/\]/,relevance:0,contains:[p]}]},K={scope:"title",begin:F,relevance:0},se={scope:"title",begin:R,relevance:0},pe={begin:"\\.\\s*"+R,relevance:0};var qe=Object.freeze({__proto__:null,APOS_STRING_MODE:b,BACKSLASH_ESCAPE:p,BINARY_NUMBER_MODE:Z,BINARY_NUMBER_RE:L,COMMENT:M,C_BLOCK_COMMENT_MODE:C,C_LINE_COMMENT_MODE:U,C_NUMBER_MODE:A,C_NUMBER_RE:I,END_SAME_AS_BEGIN:function(S){return Object.assign(S,{"on:begin":(H,X)=>{X.data._beginMatch=H[1]},"on:end":(H,X)=>{X.data._beginMatch!==H[1]&&X.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:F,MATCH_NOTHING_RE:j,METHOD_GUARD:pe,NUMBER_MODE:z,NUMBER_RE:T,PHRASAL_WORDS_MODE:N,QUOTE_STRING_MODE:y,REGEXP_MODE:ie,RE_STARTERS_RE:B,SHEBANG:f,TITLE_MODE:K,UNDERSCORE_IDENT_RE:R,UNDERSCORE_TITLE_MODE:se});function St(S,H){S.input[S.index-1]==="."&&H.ignoreMatch()}function ht(S,H){S.className!==void 0&&(S.scope=S.className,delete S.className)}function ge(S,H){H&&S.beginKeywords&&(S.begin="\\b("+S.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",S.__beforeBegin=St,S.keywords=S.keywords||S.beginKeywords,delete S.beginKeywords,S.relevance===void 0&&(S.relevance=0))}function $t(S,H){Array.isArray(S.illegal)&&(S.illegal=E(...S.illegal))}function Q(S,H){if(S.match){if(S.begin||S.end)throw new Error("begin & end are not supported with match");S.begin=S.match,delete S.match}}function ve(S,H){S.relevance===void 0&&(S.relevance=1)}const dt=(S,H)=>{if(!S.beforeMatch)return;if(S.starts)throw new Error("beforeMatch cannot be used with starts");const X=Object.assign({},S);Object.keys(S).forEach(ae=>{delete S[ae]}),S.keywords=X.keywords,S.begin=x(X.beforeMatch,_(X.begin)),S.starts={relevance:0,contains:[Object.assign(X,{endsParent:!0})]},S.relevance=0,delete X.beforeMatch},xe=["of","and","for","in","not","or","if","then","parent","list","value"],vt="keyword";function xt(S,H,X=vt){const ae=Object.create(null);return typeof S=="string"?Te(X,S.split(" ")):Array.isArray(S)?Te(X,S):Object.keys(S).forEach(function(Re){Object.assign(ae,xt(S[Re],H,Re))}),ae;function Te(Re,ee){H&&(ee=ee.map(J=>J.toLowerCase())),ee.forEach(function(J){const oe=J.split("|");ae[oe[0]]=[Re,ot(oe[0],oe[1])]})}}function ot(S,H){return H?Number(H):ut(S)?0:1}function ut(S){return xe.includes(S.toLowerCase())}const Ks={},Bt=S=>{console.error(S)},on=(S,...H)=>{console.log(`WARN: ${S}`,...H)},ds=(S,H)=>{Ks[`${S}/${H}`]||(console.log(`Deprecated as of ${S}. ${H}`),Ks[`${S}/${H}`]=!0)},Vs=new Error;function an(S,H,{key:X}){let ae=0;const Te=S[X],Re={},ee={};for(let J=1;J<=H.length;J++)ee[J+ae]=Te[J],Re[J+ae]=!0,ae+=k(H[J-1]);S[X]=ee,S[X]._emit=Re,S[X]._multi=!0}function Ml(S){if(Array.isArray(S.begin)){if(S.skip||S.excludeBegin||S.returnBegin)throw Bt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Vs;if(typeof S.beginScope!="object"||S.beginScope===null)throw Bt("beginScope must be object"),Vs;an(S,S.begin,{key:"beginScope"}),S.begin=D(S.begin,{joinWith:""})}}function Ll(S){if(Array.isArray(S.end)){if(S.skip||S.excludeEnd||S.returnEnd)throw Bt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Vs;if(typeof S.endScope!="object"||S.endScope===null)throw Bt("endScope must be object"),Vs;an(S,S.end,{key:"endScope"}),S.end=D(S.end,{joinWith:""})}}function Tl(S){S.scope&&typeof S.scope=="object"&&S.scope!==null&&(S.beginScope=S.scope,delete S.scope)}function Rl(S){Tl(S),typeof S.beginScope=="string"&&(S.beginScope={_wrap:S.beginScope}),typeof S.endScope=="string"&&(S.endScope={_wrap:S.endScope}),Ml(S),Ll(S)}function Bl(S){function H(ee,J){return new RegExp(d(ee),"m"+(S.case_insensitive?"i":"")+(S.unicodeRegex?"u":"")+(J?"g":""))}class X{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(J,oe){oe.position=this.position++,this.matchIndexes[this.matchAt]=oe,this.regexes.push([oe,J]),this.matchAt+=k(J)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const J=this.regexes.map(oe=>oe[1]);this.matcherRe=H(D(J,{joinWith:"|"}),!0),this.lastIndex=0}exec(J){this.matcherRe.lastIndex=this.lastIndex;const oe=this.matcherRe.exec(J);if(!oe)return null;const $e=oe.findIndex((Ss,Tr)=>Tr>0&&Ss!==void 0),De=this.matchIndexes[$e];return oe.splice(0,$e),Object.assign(oe,De)}}class ae{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(J){if(this.multiRegexes[J])return this.multiRegexes[J];const oe=new X;return this.rules.slice(J).forEach(([$e,De])=>oe.addRule($e,De)),oe.compile(),this.multiRegexes[J]=oe,oe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(J,oe){this.rules.push([J,oe]),oe.type==="begin"&&this.count++}exec(J){const oe=this.getMatcher(this.regexIndex);oe.lastIndex=this.lastIndex;let $e=oe.exec(J);if(this.resumingScanAtSamePosition()&&!($e&&$e.index===this.lastIndex)){const De=this.getMatcher(0);De.lastIndex=this.lastIndex+1,$e=De.exec(J)}return $e&&(this.regexIndex+=$e.position+1,this.regexIndex===this.count&&this.considerAll()),$e}}function Te(ee){const J=new ae;return ee.contains.forEach(oe=>J.addRule(oe.begin,{rule:oe,type:"begin"})),ee.terminatorEnd&&J.addRule(ee.terminatorEnd,{type:"end"}),ee.illegal&&J.addRule(ee.illegal,{type:"illegal"}),J}function Re(ee,J){const oe=ee;if(ee.isCompiled)return oe;[ht,Q,Rl,dt].forEach(De=>De(ee,J)),S.compilerExtensions.forEach(De=>De(ee,J)),ee.__beforeBegin=null,[ge,$t,ve].forEach(De=>De(ee,J)),ee.isCompiled=!0;let $e=null;return typeof ee.keywords=="object"&&ee.keywords.$pattern&&(ee.keywords=Object.assign({},ee.keywords),$e=ee.keywords.$pattern,delete ee.keywords.$pattern),$e=$e||/\w+/,ee.keywords&&(ee.keywords=xt(ee.keywords,S.case_insensitive)),oe.keywordPatternRe=H($e,!0),J&&(ee.begin||(ee.begin=/\B|\b/),oe.beginRe=H(oe.begin),!ee.end&&!ee.endsWithParent&&(ee.end=/\B|\b/),ee.end&&(oe.endRe=H(oe.end)),oe.terminatorEnd=d(oe.end)||"",ee.endsWithParent&&J.terminatorEnd&&(oe.terminatorEnd+=(ee.end?"|":"")+J.terminatorEnd)),ee.illegal&&(oe.illegalRe=H(ee.illegal)),ee.contains||(ee.contains=[]),ee.contains=[].concat(...ee.contains.map(function(De){return Dl(De==="self"?ee:De)})),ee.contains.forEach(function(De){Re(De,oe)}),ee.starts&&Re(ee.starts,J),oe.matcher=Te(oe),oe}if(S.compilerExtensions||(S.compilerExtensions=[]),S.contains&&S.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return S.classNameAliases=r(S.classNameAliases||{}),Re(S)}function ln(S){return S?S.endsWithParent||ln(S.starts):!1}function Dl(S){return S.variants&&!S.cachedVariants&&(S.cachedVariants=S.variants.map(function(H){return r(S,{variants:null},H)})),S.cachedVariants?S.cachedVariants:ln(S)?r(S,{starts:S.starts?r(S.starts):null}):Object.isFrozen(S)?r(S):S}var Pl="11.11.1";class Al extends Error{constructor(H,X){super(H),this.name="HTMLInjectionError",this.html=X}}const Lr=s,cn=r,hn=Symbol("nomatch"),Ol=7,dn=function(S){const H=Object.create(null),X=Object.create(null),ae=[];let Te=!0;const Re="Could not find the language '{}', did you forget to load/include a language module?",ee={disableAutodetect:!0,name:"Plain text",contains:[]};let J={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function oe(V){return J.noHighlightRe.test(V)}function $e(V){let re=V.className+" ";re+=V.parentNode?V.parentNode.className:"";const fe=J.languageDetectRe.exec(re);if(fe){const we=Ft(fe[1]);return we||(on(Re.replace("{}",fe[1])),on("Falling back to no-highlight mode for this block.",V)),we?fe[1]:"no-highlight"}return re.split(/\s+/).find(we=>oe(we)||Ft(we))}function De(V,re,fe){let we="",Oe="";typeof re=="object"?(we=V,fe=re.ignoreIllegals,Oe=re.language):(ds("10.7.0","highlight(lang, code, ...args) has been deprecated."),ds("10.7.0",`Please use highlight(code, options) instead. +https://github.com/highlightjs/highlight.js/issues/2277`),Oe=V,we=re),fe===void 0&&(fe=!0);const yt={code:we,language:Oe};Xs("before:highlight",yt);const zt=yt.result?yt.result:Ss(yt.language,yt.code,fe);return zt.code=yt.code,Xs("after:highlight",zt),zt}function Ss(V,re,fe,we){const Oe=Object.create(null);function yt(Y,te){return Y.keywords[te]}function zt(){if(!le.keywords){Xe.addText(Ce);return}let Y=0;le.keywordPatternRe.lastIndex=0;let te=le.keywordPatternRe.exec(Ce),ce="";for(;te;){ce+=Ce.substring(Y,te.index);const be=Ct.case_insensitive?te[0].toLowerCase():te[0],Je=yt(le,be);if(Je){const[Dt,ec]=Je;if(Xe.addText(ce),ce="",Oe[be]=(Oe[be]||0)+1,Oe[be]<=Ol&&(Js+=ec),Dt.startsWith("_"))ce+=te[0];else{const tc=Ct.classNameAliases[Dt]||Dt;wt(te[0],tc)}}else ce+=te[0];Y=le.keywordPatternRe.lastIndex,te=le.keywordPatternRe.exec(Ce)}ce+=Ce.substring(Y),Xe.addText(ce)}function Ys(){if(Ce==="")return;let Y=null;if(typeof le.subLanguage=="string"){if(!H[le.subLanguage]){Xe.addText(Ce);return}Y=Ss(le.subLanguage,Ce,!0,xn[le.subLanguage]),xn[le.subLanguage]=Y._top}else Y=Rr(Ce,le.subLanguage.length?le.subLanguage:null);le.relevance>0&&(Js+=Y.relevance),Xe.__addSublanguage(Y._emitter,Y.language)}function at(){le.subLanguage!=null?Ys():zt(),Ce=""}function wt(Y,te){Y!==""&&(Xe.startScope(te),Xe.addText(Y),Xe.endScope())}function _n(Y,te){let ce=1;const be=te.length-1;for(;ce<=be;){if(!Y._emit[ce]){ce++;continue}const Je=Ct.classNameAliases[Y[ce]]||Y[ce],Dt=te[ce];Je?wt(Dt,Je):(Ce=Dt,zt(),Ce=""),ce++}}function gn(Y,te){return Y.scope&&typeof Y.scope=="string"&&Xe.openNode(Ct.classNameAliases[Y.scope]||Y.scope),Y.beginScope&&(Y.beginScope._wrap?(wt(Ce,Ct.classNameAliases[Y.beginScope._wrap]||Y.beginScope._wrap),Ce=""):Y.beginScope._multi&&(_n(Y.beginScope,te),Ce="")),le=Object.create(Y,{parent:{value:le}}),le}function mn(Y,te,ce){let be=P(Y.endRe,ce);if(be){if(Y["on:end"]){const Je=new t(Y);Y["on:end"](te,Je),Je.isMatchIgnored&&(be=!1)}if(be){for(;Y.endsParent&&Y.parent;)Y=Y.parent;return Y}}if(Y.endsWithParent)return mn(Y.parent,te,ce)}function Yl(Y){return le.matcher.regexIndex===0?(Ce+=Y[0],1):(Ar=!0,0)}function Gl(Y){const te=Y[0],ce=Y.rule,be=new t(ce),Je=[ce.__beforeBegin,ce["on:begin"]];for(const Dt of Je)if(Dt&&(Dt(Y,be),be.isMatchIgnored))return Yl(te);return ce.skip?Ce+=te:(ce.excludeBegin&&(Ce+=te),at(),!ce.returnBegin&&!ce.excludeBegin&&(Ce=te)),gn(ce,Y),ce.returnBegin?0:te.length}function Jl(Y){const te=Y[0],ce=re.substring(Y.index),be=mn(le,Y,ce);if(!be)return hn;const Je=le;le.endScope&&le.endScope._wrap?(at(),wt(te,le.endScope._wrap)):le.endScope&&le.endScope._multi?(at(),_n(le.endScope,Y)):Je.skip?Ce+=te:(Je.returnEnd||Je.excludeEnd||(Ce+=te),at(),Je.excludeEnd&&(Ce=te));do le.scope&&Xe.closeNode(),!le.skip&&!le.subLanguage&&(Js+=le.relevance),le=le.parent;while(le!==be.parent);return be.starts&&gn(be.starts,Y),Je.returnEnd?0:te.length}function Zl(){const Y=[];for(let te=le;te!==Ct;te=te.parent)te.scope&&Y.unshift(te.scope);Y.forEach(te=>Xe.openNode(te))}let Gs={};function vn(Y,te){const ce=te&&te[0];if(Ce+=Y,ce==null)return at(),0;if(Gs.type==="begin"&&te.type==="end"&&Gs.index===te.index&&ce===""){if(Ce+=re.slice(te.index,te.index+1),!Te){const be=new Error(`0 width match regex (${V})`);throw be.languageName=V,be.badRule=Gs.rule,be}return 1}if(Gs=te,te.type==="begin")return Gl(te);if(te.type==="illegal"&&!fe){const be=new Error('Illegal lexeme "'+ce+'" for mode "'+(le.scope||"")+'"');throw be.mode=le,be}else if(te.type==="end"){const be=Jl(te);if(be!==hn)return be}if(te.type==="illegal"&&ce==="")return Ce+=` +`,1;if(Pr>1e5&&Pr>te.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ce+=ce,ce.length}const Ct=Ft(V);if(!Ct)throw Bt(Re.replace("{}",V)),new Error('Unknown language: "'+V+'"');const Ql=Bl(Ct);let Dr="",le=we||Ql;const xn={},Xe=new J.__emitter(J);Zl();let Ce="",Js=0,es=0,Pr=0,Ar=!1;try{if(Ct.__emitTokens)Ct.__emitTokens(re,Xe);else{for(le.matcher.considerAll();;){Pr++,Ar?Ar=!1:le.matcher.considerAll(),le.matcher.lastIndex=es;const Y=le.matcher.exec(re);if(!Y)break;const te=re.substring(es,Y.index),ce=vn(te,Y);es=Y.index+ce}vn(re.substring(es))}return Xe.finalize(),Dr=Xe.toHTML(),{language:V,value:Dr,relevance:Js,illegal:!1,_emitter:Xe,_top:le}}catch(Y){if(Y.message&&Y.message.includes("Illegal"))return{language:V,value:Lr(re),illegal:!0,relevance:0,_illegalBy:{message:Y.message,index:es,context:re.slice(es-100,es+100),mode:Y.mode,resultSoFar:Dr},_emitter:Xe};if(Te)return{language:V,value:Lr(re),illegal:!1,relevance:0,errorRaised:Y,_emitter:Xe,_top:le};throw Y}}function Tr(V){const re={value:Lr(V),illegal:!1,relevance:0,_top:ee,_emitter:new J.__emitter(J)};return re._emitter.addText(V),re}function Rr(V,re){re=re||J.languages||Object.keys(H);const fe=Tr(V),we=re.filter(Ft).filter(pn).map(at=>Ss(at,V,!1));we.unshift(fe);const Oe=we.sort((at,wt)=>{if(at.relevance!==wt.relevance)return wt.relevance-at.relevance;if(at.language&&wt.language){if(Ft(at.language).supersetOf===wt.language)return 1;if(Ft(wt.language).supersetOf===at.language)return-1}return 0}),[yt,zt]=Oe,Ys=yt;return Ys.secondBest=zt,Ys}function Il(V,re,fe){const we=re&&X[re]||fe;V.classList.add("hljs"),V.classList.add(`language-${we}`)}function Br(V){let re=null;const fe=$e(V);if(oe(fe))return;if(Xs("before:highlightElement",{el:V,language:fe}),V.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",V);return}if(V.children.length>0&&(J.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(V)),J.throwUnescapedHTML))throw new Al("One of your code blocks includes unescaped HTML.",V.innerHTML);re=V;const we=re.textContent,Oe=fe?De(we,{language:fe,ignoreIllegals:!0}):Rr(we);V.innerHTML=Oe.value,V.dataset.highlighted="yes",Il(V,fe,Oe.language),V.result={language:Oe.language,re:Oe.relevance,relevance:Oe.relevance},Oe.secondBest&&(V.secondBest={language:Oe.secondBest.language,relevance:Oe.secondBest.relevance}),Xs("after:highlightElement",{el:V,result:Oe,text:we})}function Wl(V){J=cn(J,V)}const Hl=()=>{qs(),ds("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $l(){qs(),ds("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let un=!1;function qs(){function V(){qs()}if(document.readyState==="loading"){un||window.addEventListener("DOMContentLoaded",V,!1),un=!0;return}document.querySelectorAll(J.cssSelector).forEach(Br)}function Fl(V,re){let fe=null;try{fe=re(S)}catch(we){if(Bt("Language definition for '{}' could not be registered.".replace("{}",V)),Te)Bt(we);else throw we;fe=ee}fe.name||(fe.name=V),H[V]=fe,fe.rawDefinition=re.bind(null,S),fe.aliases&&fn(fe.aliases,{languageName:V})}function zl(V){delete H[V];for(const re of Object.keys(X))X[re]===V&&delete X[re]}function Ul(){return Object.keys(H)}function Ft(V){return V=(V||"").toLowerCase(),H[V]||H[X[V]]}function fn(V,{languageName:re}){typeof V=="string"&&(V=[V]),V.forEach(fe=>{X[fe.toLowerCase()]=re})}function pn(V){const re=Ft(V);return re&&!re.disableAutodetect}function Kl(V){V["before:highlightBlock"]&&!V["before:highlightElement"]&&(V["before:highlightElement"]=re=>{V["before:highlightBlock"](Object.assign({block:re.el},re))}),V["after:highlightBlock"]&&!V["after:highlightElement"]&&(V["after:highlightElement"]=re=>{V["after:highlightBlock"](Object.assign({block:re.el},re))})}function Vl(V){Kl(V),ae.push(V)}function ql(V){const re=ae.indexOf(V);re!==-1&&ae.splice(re,1)}function Xs(V,re){const fe=V;ae.forEach(function(we){we[fe]&&we[fe](re)})}function Xl(V){return ds("10.7.0","highlightBlock will be removed entirely in v12.0"),ds("10.7.0","Please use highlightElement now."),Br(V)}Object.assign(S,{highlight:De,highlightAuto:Rr,highlightAll:qs,highlightElement:Br,highlightBlock:Xl,configure:Wl,initHighlighting:Hl,initHighlightingOnLoad:$l,registerLanguage:Fl,unregisterLanguage:zl,listLanguages:Ul,getLanguage:Ft,registerAliases:fn,autoDetection:pn,inherit:cn,addPlugin:Vl,removePlugin:ql}),S.debugMode=function(){Te=!1},S.safeMode=function(){Te=!0},S.versionString=Pl,S.regex={concat:x,lookahead:_,either:E,optional:m,anyNumberOfTimes:g};for(const V in qe)typeof qe[V]=="object"&&e(qe[V]);return Object.assign(S,qe),S},us=dn({});return us.newInstance=()=>dn({}),Fr=us,us.HighlightJS=us,us.default=us,Fr}var ud=dd();const Ia=ic(ud);function fd(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,s,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}Ia.registerLanguage("json",fd);const fs=100;function ps(e){return e!==null&&typeof e=="object"}function pd(e){if(Array.isArray(e))return`Array(${e.length})`;const t=Object.keys(e);return t.length<=3?`{${t.join(", ")}}`:`{${t.slice(0,3).join(", ")}, …} (${t.length} keys)`}function _d({value:e,onClose:t}){const s=v.useRef(null),r=v.useMemo(()=>JSON.stringify(e,null,2),[e]),i=v.useMemo(()=>Ia.highlight(r,{language:"json"}).value,[r]);return v.useEffect(()=>{const o=a=>{a.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),nc.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:o=>{o.target===o.currentTarget&&t()},children:n.jsxs("div",{className:"w-full max-w-2xl rounded-lg shadow-xl flex flex-col",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",maxHeight:"80vh"},children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Array.isArray(e)?`Array (${e.length} items)`:`Object (${Object.keys(e).length} keys)`}),n.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded cursor-pointer",style:{color:"var(--text-muted)",background:"transparent",border:"none"},onMouseEnter:o=>{o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.color="var(--text-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsx("div",{className:"flex-1 overflow-auto chat-markdown",children:n.jsx("pre",{className:"m-0 p-4",style:{background:"transparent"},children:n.jsx("code",{ref:s,className:"hljs language-json text-[13px] leading-relaxed",style:{background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-all"},dangerouslySetInnerHTML:{__html:i}})})})]})}),document.body)}function gd({value:e}){const[t,s]=v.useState(!1),r=pd(e);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:()=>s(!0),className:"text-left text-[12px] cursor-pointer flex items-center gap-1 max-w-[300px]",style:{background:"none",border:"none",padding:0,color:"var(--accent)"},children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),n.jsx("span",{className:"truncate",style:{color:"var(--text-secondary)"},children:r})]}),t&&n.jsx(_d,{value:e,onClose:()=>s(!1)})]})}function md({table:e}){return n.jsx(vd,{table:e})}function vd({table:e}){const[t,s]=v.useState([]),[r,i]=v.useState([]),[o,a]=v.useState(0),[l,h]=v.useState(0),[c,u]=v.useState(!0),[d,_]=v.useState(null),[g,m]=v.useState(""),[x,w]=v.useState(!1),E=v.useCallback(R=>{u(!0),_(null),w(!1),rd(e,fs,R).then(T=>{s(T.columns),i(T.rows),a(T.total),h(R)}).catch(T=>_(T.detail||T.message)).finally(()=>u(!1))},[e]);v.useEffect(()=>{E(0),m("")},[e,E]);const k=v.useCallback(()=>{g.trim()&&(u(!0),_(null),w(!0),id(g).then(R=>{s(R.columns),i(R.rows),a(R.row_count),h(0)}).catch(R=>_(R.detail||R.message)).finally(()=>u(!1)))},[g]),P=R=>{R.key==="Enter"&&(R.ctrlKey||R.metaKey)&&(R.preventDefault(),k())},O=!x&&l>0,D=!x&&l+fsm(R.target.value),onKeyDown:P,placeholder:`SELECT * FROM [${e}] WHERE ...`,className:"flex-1 text-[13px] px-3 py-1.5 rounded",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",color:"var(--text-primary)",outline:"none"}}),n.jsx("button",{onClick:k,disabled:!g.trim(),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:g.trim()?"var(--accent)":"var(--bg-hover)",color:g.trim()?"#fff":"var(--text-muted)",border:"none"},children:"Run"}),x&&n.jsx("button",{onClick:()=>E(0),className:"text-[12px] px-3 py-1.5 rounded cursor-pointer shrink-0",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Reset"})]}),d&&n.jsx("div",{className:"px-4 py-2 text-[12px] shrink-0",style:{background:"rgba(239,68,68,0.1)",color:"#ef4444"},children:d}),n.jsx("div",{className:"flex-1 overflow-auto",children:c?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"Loading..."}):r.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",style:{color:"var(--text-muted)"},children:"No rows"}):n.jsxs("table",{className:"w-full text-[12px]",style:{borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(R=>n.jsxs("th",{className:"text-left px-3 py-2 whitespace-nowrap sticky top-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)",color:"var(--text-primary)",fontWeight:600},children:[R.name,n.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)",fontSize:"10px"},children:R.type})]},R.name))})}),n.jsx("tbody",{children:r.map((R,T)=>n.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},onMouseEnter:I=>{I.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:R.map((I,L)=>n.jsx("td",{className:"px-3 py-1.5",style:{color:I==null?"var(--text-muted)":"var(--text-secondary)",maxWidth:ps(I)?void 0:"300px",overflow:ps(I)?void 0:"hidden",textOverflow:ps(I)?void 0:"ellipsis",whiteSpace:ps(I)?void 0:"nowrap",verticalAlign:"top"},title:I!=null&&!ps(I)?String(I):void 0,children:I==null?n.jsx("span",{style:{fontStyle:"italic"},children:"NULL"}):ps(I)?n.jsx(gd,{value:I}):String(I)},L))},T))})]})}),(O||D)&&!c&&n.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 shrink-0 border-t",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>E(l-fs),disabled:!O,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:O?"var(--text-secondary)":"var(--text-muted)",opacity:O?1:.5},children:"Previous"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:["Page ",j," of ",F]}),n.jsx("button",{onClick:()=>E(l+fs),disabled:!D,className:"text-[12px] px-3 py-1 rounded cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:D?"var(--text-secondary)":"var(--text-muted)",opacity:D?1:.5},children:"Next"})]})]})}const lr="__canvas__",ns="__statedb__:";function io(e){return e===lr?"#/explorer/canvas":e.startsWith(ns)?`#/explorer/statedb/${encodeURIComponent(e.slice(ns.length))}`:`#/explorer/file/${encodeURIComponent(e)}`}const no=e=>{e.editor.defineTheme("uipath-dark",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"64748b",fontStyle:"italic"},{token:"keyword",foreground:"c084fc"},{token:"string",foreground:"86efac"},{token:"number",foreground:"fcd34d"},{token:"type",foreground:"7dd3fc"}],colors:{"editor.background":"#0f172a","editor.foreground":"#cbd5e1","editor.lineHighlightBackground":"#1e293b","editor.selectionBackground":"#334155","editor.inactiveSelectionBackground":"#263348","editorLineNumber.foreground":"#64748b","editorLineNumber.activeForeground":"#94a3b8","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#334155","editorIndentGuide.activeBackground":"#64748b","editorWidget.background":"#1e293b","editorWidget.border":"#334155","editorSuggestWidget.background":"#1e293b","editorSuggestWidget.border":"#334155","editorSuggestWidget.selectedBackground":"#263348","editorHoverWidget.background":"#1e293b","editorHoverWidget.border":"#334155","scrollbarSlider.background":"#33415580","scrollbarSlider.hoverBackground":"#33415599","scrollbarSlider.activeBackground":"#334155cc"}}),e.editor.defineTheme("uipath-light",{base:"vs",inherit:!0,rules:[{token:"comment",foreground:"94a3b8",fontStyle:"italic"},{token:"keyword",foreground:"7c3aed"},{token:"string",foreground:"16a34a"},{token:"number",foreground:"d97706"},{token:"type",foreground:"0284c7"}],colors:{"editor.background":"#f8fafc","editor.foreground":"#0f172a","editor.lineHighlightBackground":"#f1f5f9","editor.selectionBackground":"#e2e8f0","editor.inactiveSelectionBackground":"#f1f5f9","editorLineNumber.foreground":"#94a3b8","editorLineNumber.activeForeground":"#475569","editorCursor.foreground":"#fa4616","editorIndentGuide.background":"#e2e8f0","editorIndentGuide.activeBackground":"#94a3b8","editorWidget.background":"#ffffff","editorWidget.border":"#e2e8f0","editorSuggestWidget.background":"#ffffff","editorSuggestWidget.border":"#e2e8f0","editorSuggestWidget.selectedBackground":"#f1f5f9","editorHoverWidget.background":"#ffffff","editorHoverWidget.border":"#e2e8f0","scrollbarSlider.background":"#d1d5db80","scrollbarSlider.hoverBackground":"#d1d5db99","scrollbarSlider.activeBackground":"#d1d5dbcc"}})};function oo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function xd(e){const t=e.replace(/\\/g,"/").split("/");return t[t.length-1]||e}function yd(){const e=ye(f=>f.openTabs),s=ye(f=>f.selectedFile),r=ye(f=>s?f.fileCache[s]:void 0),i=ye(f=>s?!!f.dirty[s]:!1),o=ye(f=>s?f.buffers[s]:void 0),a=ye(f=>f.loadingFile),l=ye(f=>f.dirty),h=ye(f=>f.diffView),c=ye(f=>s?!!f.agentChangedFiles[s]:!1),{setFileContent:u,updateBuffer:d,markClean:_,setLoadingFile:g,openTab:m,closeTab:x,setDiffView:w}=ye(),{navigate:E}=et(),k=ya(f=>f.theme),P=v.useRef(null),{explorerFile:O}=et();v.useEffect(()=>{O&&m(O)},[O,m]),v.useEffect(()=>{!s||s===lr||s.startsWith(ns)||ye.getState().fileCache[s]||(g(!0),_a(s).then(f=>u(s,f)).catch(console.error).finally(()=>g(!1)))},[s,u,g]);const D=v.useCallback(()=>{if(!s)return;const f=ye.getState().fileCache[s],b=ye.getState().buffers[s]??(f==null?void 0:f.content);b!=null&&jc(s,b).then(()=>{_(s),u(s,{...f,content:b})}).catch(console.error)},[s,_,u]);v.useEffect(()=>{const f=p=>{(p.ctrlKey||p.metaKey)&&p.key==="s"&&(p.preventDefault(),D())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[D]);const j=f=>{P.current=f},F=v.useCallback(f=>{f!==void 0&&s&&d(s,f)},[s,d]),R=v.useCallback(f=>{m(f),E(io(f))},[m,E]),T=v.useCallback((f,p)=>{f.stopPropagation();const b=ye.getState(),y=b.openTabs.filter(N=>N!==p);if(x(p),b.selectedFile===p){const N=b.openTabs.indexOf(p),M=y[Math.min(N,y.length-1)];E(M?io(M):"#/explorer")}},[x,E]),I=v.useCallback((f,p)=>{f.button===1&&T(f,p)},[T]),L=e.length>0&&n.jsx("div",{className:"h-10 flex items-end overflow-x-auto shrink-0",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},children:e.map(f=>{const p=f===s,b=!!l[f];return n.jsxs("button",{onClick:()=>R(f),onMouseDown:y=>I(y,f),className:"h-full flex items-center gap-1.5 px-3 text-[12px] shrink-0 cursor-pointer transition-colors relative",style:{background:p?"var(--bg-primary)":"transparent",color:p?"var(--text-primary)":"var(--text-secondary)",border:"none",borderBottom:p?"2px solid var(--accent)":"2px solid transparent",maxWidth:"180px"},onMouseEnter:y=>{p||(y.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:y=>{p||(y.currentTarget.style.background="transparent")},children:[n.jsx("span",{className:"truncate",children:f===lr?"Visualization":f.startsWith(ns)?`db:${f.slice(ns.length)}`:xd(f)}),b?n.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:"var(--accent)"},title:"Unsaved changes"}):n.jsx("span",{className:"w-4 h-4 flex items-center justify-center rounded shrink-0 transition-colors",style:{color:"var(--text-muted)"},onClick:y=>T(y,f),onMouseEnter:y=>{y.currentTarget.style.background="var(--bg-hover)",y.currentTarget.style.color="var(--text-primary)"},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color="var(--text-muted)"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:n.jsx("path",{d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.708.708L7.293 8l-3.647 3.646.708.708L8 8.707z"})})})]},f)})});if(s===lr)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(hd,{})})]});if(s!=null&&s.startsWith(ns)){const f=s.slice(ns.length);return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(md,{table:f})})]})}if(!s)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a file to view"})]});if(a&&!r)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Loading file..."})})]});if(!r&&!a)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:n.jsx("div",{className:"text-sm",children:"Failed to load file"})})]});if(!r)return null;if(r.binary)return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsx("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:n.jsx("span",{style:{color:"var(--text-muted)"},children:oo(r.size)})}),n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",style:{color:"var(--text-muted)"},children:[n.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),n.jsx("span",{className:"text-sm",children:"Binary file — preview not available"})]})]});const B=h&&h.path===s;return n.jsxs("div",{className:"flex flex-col h-full",children:[L,n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[r.language&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--bg-hover)",color:"var(--text-muted)"},children:r.language}),n.jsx("span",{style:{color:"var(--text-muted)"},children:oo(r.size)}),c&&n.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium",style:{background:"color-mix(in srgb, var(--info) 20%, transparent)",color:"var(--info)"},children:"Agent modified"}),n.jsx("div",{className:"flex-1"}),i&&n.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--accent)"},children:"Modified"}),n.jsx("button",{onClick:D,className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:i?"var(--accent)":"var(--bg-hover)",color:i?"white":"var(--text-muted)",border:"none"},children:"Save"})]}),B&&n.jsxs("div",{className:"h-8 flex items-center px-3 gap-2 text-xs shrink-0 border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--info) 10%, var(--bg-secondary))"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--info)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),n.jsx("span",{style:{color:"var(--info)"},children:"Agent modified this file"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>w(null),className:"px-2 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors",style:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none"},children:"Dismiss"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:B?n.jsx(oc,{original:h.original,modified:h.modified,language:h.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",beforeMount:no,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,automaticLayout:!0,renderSideBySide:!0}},`diff-${s}`):n.jsx(ac,{language:r.language??"plaintext",theme:k==="dark"?"uipath-dark":"uipath-light",value:o??r.content??"",onChange:F,beforeMount:no,onMount:j,options:{minimap:{enabled:!1},fontSize:13,lineNumbersMinChars:4,scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2,renderWhitespace:"selection"}},s)})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -102,21 +102,21 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Oe=K,we=re),fe===void * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Wa=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Sd=(e,t)=>{for(var s in t)Wa(e,s,{get:t[s],enumerable:!0})},Le=(e,t,s,r)=>{for(var i=r>1?void 0:r?bd(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(t,s,i):a(i))||i);return r&&i&&Wa(t,s,i),i},G=(e,t)=>(s,r)=>t(s,r,e),oo="Terminal input",ii={get:()=>oo,set:e=>oo=e},ao="Too much output to announce, navigate to rows manually to read",ni={get:()=>ao,set:e=>ao=e};function wd(e){return e.replace(/\r?\n/g,"\r")}function Cd(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function kd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ed(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");Ha(i,t,s,r)}}function Ha(e,t,s,r){e=wd(e),e=Cd(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function $a(e,t,s){let r=s.getBoundingClientRect(),i=e.clientX-r.left-10,o=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function lo(e,t,s,r,i){$a(e,t,s),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Xt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Er(e,t=0,s=e.length){let r="";for(let i=t;i65535?(o-=65536,r+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):r+=String.fromCharCode(o)}return r}var Nd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i=0;if(this._interim){let o=e.charCodeAt(i++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=i;o=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[r++]=(a-55296)*1024+l-56320+65536:(t[r++]=a,t[r++]=l);continue}a!==65279&&(t[r++]=a)}return r}},jd=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i,o,a,l,h=0,c=0;if(this.interim[0]){let _=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let m=0,x;for(;(x=this.interim[++m]&63)&&m<4;)g<<=6,g|=x;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=w-m;for(;c=s)return 0;if(x=e[c++],(x&192)!==128){c--,_=!0;break}else this.interim[m++]=x,g<<=6,g|=x&63}_||(w===2?g<128?c--:t[r++]=g:w===3?g<2048||g>=55296&&g<=57343||g===65279||(t[r++]=g):g<65536||g>1114111||(t[r++]=g)),this.interim.fill(0)}let u=s-4,d=c;for(;d=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(i&31)<<6|o&63,h<128){d--;continue}t[r++]=h}else if((i&240)===224){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(i&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[r++]=h}else if((i&248)===240){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,r;if(l=e[d++],(l&192)!==128){d--;continue}if(h=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[r++]=h}}return r}},Fa="",Yt=" ",$s=class za{constructor(){this.fg=0,this.bg=0,this.extended=new gr}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 za;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}},gr=class Ua{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Ua(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mt=class Ka extends $s{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gr,this.combinedData=""}static fromCharData(t){let s=new Ka;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xt(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},co="di$target",oi="di$dependencies",zr=new Map;function Md(e){return e[oi]||[]}function Ve(e){if(zr.has(e))return zr.get(e);let t=function(s,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ld(t,s,i)};return t._id=e,zr.set(e,t),t}function Ld(e,t,s){t[co]===t?t[oi].push({id:e,index:s}):(t[oi]=[{id:e,index:s}],t[co]=t)}var tt=Ve("BufferService"),Va=Ve("CoreMouseService"),hs=Ve("CoreService"),Td=Ve("CharsetService"),Xi=Ve("InstantiationService"),qa=Ve("LogService"),st=Ve("OptionsService"),Xa=Ve("OscLinkService"),Rd=Ve("UnicodeService"),Fs=Ve("DecorationService"),ai=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,o=new mt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;di?i.activate(x,w,g):Bd(x,w),hover:(x,w)=>{var E;return(E=i==null?void 0:i.hover)==null?void 0:E.call(i,x,w,g)},leave:(x,w)=>{var E;return(E=i==null?void 0:i.leave)==null?void 0:E.call(i,x,w,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};ai=Le([G(0,tt),G(1,st),G(2,Xa)],ai);function Bd(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Wa=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Sd=(e,t)=>{for(var s in t)Wa(e,s,{get:t[s],enumerable:!0})},Le=(e,t,s,r)=>{for(var i=r>1?void 0:r?bd(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(t,s,i):a(i))||i);return r&&i&&Wa(t,s,i),i},G=(e,t)=>(s,r)=>t(s,r,e),ao="Terminal input",ii={get:()=>ao,set:e=>ao=e},lo="Too much output to announce, navigate to rows manually to read",ni={get:()=>lo,set:e=>lo=e};function wd(e){return e.replace(/\r?\n/g,"\r")}function Cd(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function kd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ed(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");Ha(i,t,s,r)}}function Ha(e,t,s,r){e=wd(e),e=Cd(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function $a(e,t,s){let r=s.getBoundingClientRect(),i=e.clientX-r.left-10,o=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function co(e,t,s,r,i){$a(e,t,s),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Xt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Er(e,t=0,s=e.length){let r="";for(let i=t;i65535?(o-=65536,r+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):r+=String.fromCharCode(o)}return r}var Nd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i=0;if(this._interim){let o=e.charCodeAt(i++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=i;o=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[r++]=(a-55296)*1024+l-56320+65536:(t[r++]=a,t[r++]=l);continue}a!==65279&&(t[r++]=a)}return r}},jd=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,i,o,a,l,h=0,c=0;if(this.interim[0]){let _=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let m=0,x;for(;(x=this.interim[++m]&63)&&m<4;)g<<=6,g|=x;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=w-m;for(;c=s)return 0;if(x=e[c++],(x&192)!==128){c--,_=!0;break}else this.interim[m++]=x,g<<=6,g|=x&63}_||(w===2?g<128?c--:t[r++]=g:w===3?g<2048||g>=55296&&g<=57343||g===65279||(t[r++]=g):g<65536||g>1114111||(t[r++]=g)),this.interim.fill(0)}let u=s-4,d=c;for(;d=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(i&31)<<6|o&63,h<128){d--;continue}t[r++]=h}else if((i&240)===224){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(i&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[r++]=h}else if((i&248)===240){if(d>=s)return this.interim[0]=i,r;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,r;if(a=e[d++],(a&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,r;if(l=e[d++],(l&192)!==128){d--;continue}if(h=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[r++]=h}}return r}},Fa="",Yt=" ",$s=class za{constructor(){this.fg=0,this.bg=0,this.extended=new gr}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 za;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}},gr=class Ua{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Ua(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mt=class Ka extends $s{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gr,this.combinedData=""}static fromCharData(t){let s=new Ka;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xt(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ho="di$target",oi="di$dependencies",zr=new Map;function Md(e){return e[oi]||[]}function Ve(e){if(zr.has(e))return zr.get(e);let t=function(s,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ld(t,s,i)};return t._id=e,zr.set(e,t),t}function Ld(e,t,s){t[ho]===t?t[oi].push({id:e,index:s}):(t[oi]=[{id:e,index:s}],t[ho]=t)}var tt=Ve("BufferService"),Va=Ve("CoreMouseService"),hs=Ve("CoreService"),Td=Ve("CharsetService"),Yi=Ve("InstantiationService"),qa=Ve("LogService"),st=Ve("OptionsService"),Xa=Ve("OscLinkService"),Rd=Ve("UnicodeService"),Fs=Ve("DecorationService"),ai=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,o=new mt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;di?i.activate(x,w,g):Bd(x,w),hover:(x,w)=>{var E;return(E=i==null?void 0:i.hover)==null?void 0:E.call(i,x,w,g)},leave:(x,w)=>{var E;return(E=i==null?void 0:i.leave)==null?void 0:E.call(i,x,w,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};ai=Le([G(0,tt),G(1,st),G(2,Xa)],ai);function Bd(e,t){if(confirm(`Do you want to navigate to ${t}? -WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nr=Ve("CharSizeService"),Wt=Ve("CoreBrowserService"),Yi=Ve("MouseService"),Ht=Ve("RenderService"),Dd=Ve("SelectionService"),Ya=Ve("CharacterJoinerService"),ys=Ve("ThemeService"),Ga=Ve("LinkProviderService"),Pd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ho.isErrorNoTelemetry(e)?new ho(e.message+` +WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nr=Ve("CharSizeService"),Wt=Ve("CoreBrowserService"),Gi=Ve("MouseService"),Ht=Ve("RenderService"),Dd=Ve("SelectionService"),Ya=Ve("CharacterJoinerService"),ys=Ve("ThemeService"),Ga=Ve("LinkProviderService"),Pd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?uo.isErrorNoTelemetry(e)?new uo(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)}},Ad=new Pd;function cr(e){Od(e)||Ad.onUnexpectedError(e)}var li="Canceled";function Od(e){return e instanceof Id?!0:e instanceof Error&&e.name===li&&e.message===li}var Id=class extends Error{constructor(){super(li),this.name=this.message}};function Wd(e){return new Error(`Illegal argument: ${e}`)}var ho=class ci extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ci)return t;let s=new ci;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hi=class Ja extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ja.prototype)}};function lt(e,t=0){return e[e.length-(1+t)]}var Hd;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function r(o){return o>0}e.isGreaterThan=r;function i(o){return o===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Hd||(Hd={}));function $d(e,t){let s=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}var Za;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*i(A){yield A}e.single=i;function o(A){return t(A)?A:i(A)}e.wrap=o;function a(A){return A||s}e.from=a;function*l(A){for(let D=A.length-1;D>=0;D--)yield A[D]}e.reverse=l;function h(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(A){return A[Symbol.iterator]().next().value}e.first=c;function u(A,D){let N=0;for(let $ of A)if(D($,N++))return!0;return!1}e.some=u;function d(A,D){for(let N of A)if(D(N))return N}e.find=d;function*_(A,D){for(let N of A)D(N)&&(yield N)}e.filter=_;function*g(A,D){let N=0;for(let $ of A)yield D($,N++)}e.map=g;function*m(A,D){let N=0;for(let $ of A)yield*D($,N++)}e.flatMap=m;function*x(...A){for(let D of A)yield*D}e.concat=x;function w(A,D,N){let $=N;for(let B of A)$=D($,B);return $}e.reduce=w;function*E(A,D,N=A.length){for(D<0&&(D+=A.length),N<0?N+=A.length:N>A.length&&(N=A.length);D1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Fd(...e){return Ee(()=>ls(e))}function Ee(e){return{dispose:$d(()=>{e()})}}var Qa=class el{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{ls(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?el.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)}};Qa.DISABLE_DISPOSED_WARNING=!1;var Gt=Qa,ue=class{constructor(){this._store=new Gt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ue.None=Object.freeze({dispose(){}});var xs=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}},It=typeof window=="object"?window:globalThis,di=class ui{constructor(t){this.element=t,this.next=ui.Undefined,this.prev=ui.Undefined}};di.Undefined=new di(void 0);var Ne=di,uo=class{constructor(){this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ne.Undefined}clear(){let e=this._first;for(;e!==Ne.Undefined;){let t=e.next;e.prev=Ne.Undefined,e.next=Ne.Undefined,e=t}this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Ne(e);if(this._first===Ne.Undefined)this._first=s,this._last=s;else if(t){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Ne.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ne.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ne.Undefined&&e.next!==Ne.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ne.Undefined&&e.next===Ne.Undefined?(this._first=Ne.Undefined,this._last=Ne.Undefined):e.next===Ne.Undefined?(this._last=this._last.prev,this._last.next=Ne.Undefined):e.prev===Ne.Undefined&&(this._first=this._first.next,this._first.prev=Ne.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ne.Undefined;)yield e.element,e=e.next}},zd=globalThis.performance&&typeof globalThis.performance.now=="function",Ud=class tl{static create(t){return new tl(t)}constructor(t){this._now=zd&&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}},Ge;(e=>{e.None=()=>ue.None;function t(R,p){return d(R,()=>{},0,void 0,!0,void 0,p)}e.defer=t;function s(R){return(p,f=null,b)=>{let y=!1,j;return j=R(M=>{if(!y)return j?j.dispose():y=!0,p.call(f,M)},null,b),y&&j.dispose(),j}}e.once=s;function r(R,p,f){return c((b,y=null,j)=>R(M=>b.call(y,p(M)),null,j),f)}e.map=r;function i(R,p,f){return c((b,y=null,j)=>R(M=>{p(M),b.call(y,M)},null,j),f)}e.forEach=i;function o(R,p,f){return c((b,y=null,j)=>R(M=>p(M)&&b.call(y,M),null,j),f)}e.filter=o;function a(R){return R}e.signal=a;function l(...R){return(p,f=null,b)=>{let y=Fd(...R.map(j=>j(M=>p.call(f,M))));return u(y,b)}}e.any=l;function h(R,p,f,b){let y=f;return r(R,j=>(y=p(y,j),y),b)}e.reduce=h;function c(R,p){let f,b={onWillAddFirstListener(){f=R(y.fire,y)},onDidRemoveLastListener(){f==null||f.dispose()}},y=new V(b);return p==null||p.add(y),y.event}function u(R,p){return p instanceof Array?p.push(R):p&&p.add(R),R}function d(R,p,f=100,b=!1,y=!1,j,M){let z,C,H,U=0,q,ee={leakWarningThreshold:j,onWillAddFirstListener(){z=R(F=>{U++,C=p(C,F),b&&!H&&(ie.fire(C),C=void 0),q=()=>{let se=C;C=void 0,H=void 0,(!b||U>1)&&ie.fire(se),U=0},typeof f=="number"?(clearTimeout(H),H=setTimeout(q,f)):H===void 0&&(H=0,queueMicrotask(q))})},onWillRemoveListener(){y&&U>0&&(q==null||q())},onDidRemoveLastListener(){q=void 0,z.dispose()}},ie=new V(ee);return M==null||M.add(ie),ie.event}e.debounce=d;function _(R,p=0,f){return e.debounce(R,(b,y)=>b?(b.push(y),b):[y],p,void 0,!0,void 0,f)}e.accumulate=_;function g(R,p=(b,y)=>b===y,f){let b=!0,y;return o(R,j=>{let M=b||!p(j,y);return b=!1,y=j,M},f)}e.latch=g;function m(R,p,f){return[e.filter(R,p,f),e.filter(R,b=>!p(b),f)]}e.split=m;function x(R,p=!1,f=[],b){let y=f.slice(),j=R(C=>{y?y.push(C):z.fire(C)});b&&b.add(j);let M=()=>{y==null||y.forEach(C=>z.fire(C)),y=null},z=new V({onWillAddFirstListener(){j||(j=R(C=>z.fire(C)),b&&b.add(j))},onDidAddFirstListener(){y&&(p?setTimeout(M):M())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return b&&b.add(z),z.event}e.buffer=x;function w(R,p){return(f,b,y)=>{let j=p(new k);return R(function(M){let z=j.evaluate(M);z!==E&&f.call(b,z)},void 0,y)}}e.chain=w;let E=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(p){return this.steps.push(p),this}forEach(p){return this.steps.push(f=>(p(f),f)),this}filter(p){return this.steps.push(f=>p(f)?f:E),this}reduce(p,f){let b=f;return this.steps.push(y=>(b=p(b,y),b)),this}latch(p=(f,b)=>f===b){let f=!0,b;return this.steps.push(y=>{let j=f||!p(y,b);return f=!1,b=y,j?y:E}),this}evaluate(p){for(let f of this.steps)if(p=f(p),p===E)break;return p}}function P(R,p,f=b=>b){let b=(...z)=>M.fire(f(...z)),y=()=>R.on(p,b),j=()=>R.removeListener(p,b),M=new V({onWillAddFirstListener:y,onDidRemoveLastListener:j});return M.event}e.fromNodeEventEmitter=P;function A(R,p,f=b=>b){let b=(...z)=>M.fire(f(...z)),y=()=>R.addEventListener(p,b),j=()=>R.removeEventListener(p,b),M=new V({onWillAddFirstListener:y,onDidRemoveLastListener:j});return M.event}e.fromDOMEventEmitter=A;function D(R){return new Promise(p=>s(R)(p))}e.toPromise=D;function N(R){let p=new V;return R.then(f=>{p.fire(f)},()=>{p.fire(void 0)}).finally(()=>{p.dispose()}),p.event}e.fromPromise=N;function $(R,p){return R(f=>p.fire(f))}e.forward=$;function B(R,p,f){return p(f),R(b=>p(b))}e.runAndSubscribe=B;class T{constructor(p,f){this._observable=p,this._counter=0,this._hasChanged=!1;let b={onWillAddFirstListener:()=>{p.addObserver(this)},onDidRemoveLastListener:()=>{p.removeObserver(this)}};this.emitter=new V(b),f&&f.add(this.emitter)}beginUpdate(p){this._counter++}handlePossibleChange(p){}handleChange(p,f){this._hasChanged=!0}endUpdate(p){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function O(R,p){return new T(R,p).emitter.event}e.fromObservable=O;function L(R){return(p,f,b)=>{let y=0,j=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(R.reportChanges(),j&&(j=!1,p.call(f)))},handlePossibleChange(){},handleChange(){j=!0}};R.addObserver(M),R.reportChanges();let z={dispose(){R.removeObserver(M)}};return b instanceof Gt?b.add(z):Array.isArray(b)&&b.push(z),z}}e.fromObservableLight=L})(Ge||(Ge={}));var fi=class pi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${pi._idPool++}`,pi.all.add(this)}start(t){this._stopWatch=new Ud,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}}};fi.all=new Set,fi._idPool=0;var Kd=fi,Vd=-1,sl=class rl{constructor(t,s,r=(rl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let r=this.threshold;if(r<=0||s{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,i]of this._stacks)(!t||s{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)}},Ad=new Pd;function cr(e){Od(e)||Ad.onUnexpectedError(e)}var li="Canceled";function Od(e){return e instanceof Id?!0:e instanceof Error&&e.name===li&&e.message===li}var Id=class extends Error{constructor(){super(li),this.name=this.message}};function Wd(e){return new Error(`Illegal argument: ${e}`)}var uo=class ci extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ci)return t;let s=new ci;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hi=class Ja extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ja.prototype)}};function lt(e,t=0){return e[e.length-(1+t)]}var Hd;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function r(o){return o>0}e.isGreaterThan=r;function i(o){return o===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Hd||(Hd={}));function $d(e,t){let s=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}var Za;(e=>{function t(O){return O&&typeof O=="object"&&typeof O[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*i(O){yield O}e.single=i;function o(O){return t(O)?O:i(O)}e.wrap=o;function a(O){return O||s}e.from=a;function*l(O){for(let D=O.length-1;D>=0;D--)yield O[D]}e.reverse=l;function h(O){return!O||O[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(O){return O[Symbol.iterator]().next().value}e.first=c;function u(O,D){let j=0;for(let F of O)if(D(F,j++))return!0;return!1}e.some=u;function d(O,D){for(let j of O)if(D(j))return j}e.find=d;function*_(O,D){for(let j of O)D(j)&&(yield j)}e.filter=_;function*g(O,D){let j=0;for(let F of O)yield D(F,j++)}e.map=g;function*m(O,D){let j=0;for(let F of O)yield*D(F,j++)}e.flatMap=m;function*x(...O){for(let D of O)yield*D}e.concat=x;function w(O,D,j){let F=j;for(let R of O)F=D(F,R);return F}e.reduce=w;function*E(O,D,j=O.length){for(D<0&&(D+=O.length),j<0?j+=O.length:j>O.length&&(j=O.length);D1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Fd(...e){return Ee(()=>ls(e))}function Ee(e){return{dispose:$d(()=>{e()})}}var Qa=class el{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{ls(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?el.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)}};Qa.DISABLE_DISPOSED_WARNING=!1;var Gt=Qa,ue=class{constructor(){this._store=new Gt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ue.None=Object.freeze({dispose(){}});var xs=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}},It=typeof window=="object"?window:globalThis,di=class ui{constructor(t){this.element=t,this.next=ui.Undefined,this.prev=ui.Undefined}};di.Undefined=new di(void 0);var Ne=di,fo=class{constructor(){this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ne.Undefined}clear(){let e=this._first;for(;e!==Ne.Undefined;){let t=e.next;e.prev=Ne.Undefined,e.next=Ne.Undefined,e=t}this._first=Ne.Undefined,this._last=Ne.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Ne(e);if(this._first===Ne.Undefined)this._first=s,this._last=s;else if(t){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Ne.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ne.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ne.Undefined&&e.next!==Ne.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ne.Undefined&&e.next===Ne.Undefined?(this._first=Ne.Undefined,this._last=Ne.Undefined):e.next===Ne.Undefined?(this._last=this._last.prev,this._last.next=Ne.Undefined):e.prev===Ne.Undefined&&(this._first=this._first.next,this._first.prev=Ne.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ne.Undefined;)yield e.element,e=e.next}},zd=globalThis.performance&&typeof globalThis.performance.now=="function",Ud=class tl{static create(t){return new tl(t)}constructor(t){this._now=zd&&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}},Ge;(e=>{e.None=()=>ue.None;function t(B,f){return d(B,()=>{},0,void 0,!0,void 0,f)}e.defer=t;function s(B){return(f,p=null,b)=>{let y=!1,N;return N=B(M=>{if(!y)return N?N.dispose():y=!0,f.call(p,M)},null,b),y&&N.dispose(),N}}e.once=s;function r(B,f,p){return c((b,y=null,N)=>B(M=>b.call(y,f(M)),null,N),p)}e.map=r;function i(B,f,p){return c((b,y=null,N)=>B(M=>{f(M),b.call(y,M)},null,N),p)}e.forEach=i;function o(B,f,p){return c((b,y=null,N)=>B(M=>f(M)&&b.call(y,M),null,N),p)}e.filter=o;function a(B){return B}e.signal=a;function l(...B){return(f,p=null,b)=>{let y=Fd(...B.map(N=>N(M=>f.call(p,M))));return u(y,b)}}e.any=l;function h(B,f,p,b){let y=p;return r(B,N=>(y=f(y,N),y),b)}e.reduce=h;function c(B,f){let p,b={onWillAddFirstListener(){p=B(y.fire,y)},onDidRemoveLastListener(){p==null||p.dispose()}},y=new q(b);return f==null||f.add(y),y.event}function u(B,f){return f instanceof Array?f.push(B):f&&f.add(B),B}function d(B,f,p=100,b=!1,y=!1,N,M){let U,C,W,z=0,A,Z={leakWarningThreshold:N,onWillAddFirstListener(){U=B(K=>{z++,C=f(C,K),b&&!W&&(ie.fire(C),C=void 0),A=()=>{let se=C;C=void 0,W=void 0,(!b||z>1)&&ie.fire(se),z=0},typeof p=="number"?(clearTimeout(W),W=setTimeout(A,p)):W===void 0&&(W=0,queueMicrotask(A))})},onWillRemoveListener(){y&&z>0&&(A==null||A())},onDidRemoveLastListener(){A=void 0,U.dispose()}},ie=new q(Z);return M==null||M.add(ie),ie.event}e.debounce=d;function _(B,f=0,p){return e.debounce(B,(b,y)=>b?(b.push(y),b):[y],f,void 0,!0,void 0,p)}e.accumulate=_;function g(B,f=(b,y)=>b===y,p){let b=!0,y;return o(B,N=>{let M=b||!f(N,y);return b=!1,y=N,M},p)}e.latch=g;function m(B,f,p){return[e.filter(B,f,p),e.filter(B,b=>!f(b),p)]}e.split=m;function x(B,f=!1,p=[],b){let y=p.slice(),N=B(C=>{y?y.push(C):U.fire(C)});b&&b.add(N);let M=()=>{y==null||y.forEach(C=>U.fire(C)),y=null},U=new q({onWillAddFirstListener(){N||(N=B(C=>U.fire(C)),b&&b.add(N))},onDidAddFirstListener(){y&&(f?setTimeout(M):M())},onDidRemoveLastListener(){N&&N.dispose(),N=null}});return b&&b.add(U),U.event}e.buffer=x;function w(B,f){return(p,b,y)=>{let N=f(new k);return B(function(M){let U=N.evaluate(M);U!==E&&p.call(b,U)},void 0,y)}}e.chain=w;let E=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(f){return this.steps.push(f),this}forEach(f){return this.steps.push(p=>(f(p),p)),this}filter(f){return this.steps.push(p=>f(p)?p:E),this}reduce(f,p){let b=p;return this.steps.push(y=>(b=f(b,y),b)),this}latch(f=(p,b)=>p===b){let p=!0,b;return this.steps.push(y=>{let N=p||!f(y,b);return p=!1,b=y,N?y:E}),this}evaluate(f){for(let p of this.steps)if(f=p(f),f===E)break;return f}}function P(B,f,p=b=>b){let b=(...U)=>M.fire(p(...U)),y=()=>B.on(f,b),N=()=>B.removeListener(f,b),M=new q({onWillAddFirstListener:y,onDidRemoveLastListener:N});return M.event}e.fromNodeEventEmitter=P;function O(B,f,p=b=>b){let b=(...U)=>M.fire(p(...U)),y=()=>B.addEventListener(f,b),N=()=>B.removeEventListener(f,b),M=new q({onWillAddFirstListener:y,onDidRemoveLastListener:N});return M.event}e.fromDOMEventEmitter=O;function D(B){return new Promise(f=>s(B)(f))}e.toPromise=D;function j(B){let f=new q;return B.then(p=>{f.fire(p)},()=>{f.fire(void 0)}).finally(()=>{f.dispose()}),f.event}e.fromPromise=j;function F(B,f){return B(p=>f.fire(p))}e.forward=F;function R(B,f,p){return f(p),B(b=>f(b))}e.runAndSubscribe=R;class T{constructor(f,p){this._observable=f,this._counter=0,this._hasChanged=!1;let b={onWillAddFirstListener:()=>{f.addObserver(this)},onDidRemoveLastListener:()=>{f.removeObserver(this)}};this.emitter=new q(b),p&&p.add(this.emitter)}beginUpdate(f){this._counter++}handlePossibleChange(f){}handleChange(f,p){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 I(B,f){return new T(B,f).emitter.event}e.fromObservable=I;function L(B){return(f,p,b)=>{let y=0,N=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(B.reportChanges(),N&&(N=!1,f.call(p)))},handlePossibleChange(){},handleChange(){N=!0}};B.addObserver(M),B.reportChanges();let U={dispose(){B.removeObserver(M)}};return b instanceof Gt?b.add(U):Array.isArray(b)&&b.push(U),U}}e.fromObservableLight=L})(Ge||(Ge={}));var fi=class pi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${pi._idPool++}`,pi.all.add(this)}start(t){this._stopWatch=new Ud,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}}};fi.all=new Set,fi._idPool=0;var Kd=fi,Vd=-1,sl=class rl{constructor(t,s,r=(rl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let r=this.threshold;if(r<=0||s{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,i]of this._stacks)(!t||s{var a,l,h,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new Gd(`${d}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((a=this._options)==null?void 0:a.onListenerError)||cr)(g),ue.None}if(this._disposed)return ue.None;t&&(e=e.bind(t));let r=new Ur(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Xd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ur?(this._deliveryQueue??(this._deliveryQueue=new eu),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let o=Ee(()=>{i==null||i(),this._removeListener(r)});return s instanceof Gt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var i,o,a,l;if((o=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||o.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||l.call(a,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);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--,t[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Zd<=t.length){let h=0;for(let c=0;c0}},eu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_i=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new V,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new V,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};_i.INSTANCE=new _i;var Gi=_i;function tu(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Gi.INSTANCE.onDidChangeZoomLevel;function su(e){return Gi.INSTANCE.getZoomFactor(e)}Gi.INSTANCE.onDidChangeFullscreen;var bs=typeof navigator=="object"?navigator.userAgent:"",gi=bs.indexOf("Firefox")>=0,ru=bs.indexOf("AppleWebKit")>=0,Ji=bs.indexOf("Chrome")>=0,iu=!Ji&&bs.indexOf("Safari")>=0;bs.indexOf("Electron/")>=0;bs.indexOf("Android")>=0;var Kr=!1;if(typeof It.matchMedia=="function"){let e=It.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=It.matchMedia("(display-mode: fullscreen)");Kr=e.matches,tu(It,e,({matches:s})=>{Kr&&t.matches||(Kr=s)})}var vs="en",mi=!1,vi=!1,hr=!1,nl=!1,tr,dr=vs,fo=vs,nu,bt,as=globalThis,Ye,ta;typeof as.vscode<"u"&&typeof as.vscode.process<"u"?Ye=as.vscode.process:typeof process<"u"&&typeof((ta=process==null?void 0:process.versions)==null?void 0:ta.node)=="string"&&(Ye=process);var sa,ou=typeof((sa=Ye==null?void 0:Ye.versions)==null?void 0:sa.electron)=="string",au=ou&&(Ye==null?void 0:Ye.type)==="renderer",ra;if(typeof Ye=="object"){mi=Ye.platform==="win32",vi=Ye.platform==="darwin",hr=Ye.platform==="linux",hr&&Ye.env.SNAP&&Ye.env.SNAP_REVISION,Ye.env.CI||Ye.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tr=vs,dr=vs;let e=Ye.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);tr=t.userLocale,fo=t.osLocale,dr=t.resolvedLanguage||vs,nu=(ra=t.languagePack)==null?void 0:ra.translationsConfigFile}catch{}nl=!0}else typeof navigator=="object"&&!au?(bt=navigator.userAgent,mi=bt.indexOf("Windows")>=0,vi=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,hr=bt.indexOf("Linux")>=0,(bt==null?void 0:bt.indexOf("Mobi"))>=0,dr=globalThis._VSCODE_NLS_LANGUAGE||vs,tr=navigator.language.toLowerCase(),fo=tr):console.error("Unable to resolve platform.");var ol=mi,Mt=vi,lu=hr,po=nl,Rt=bt,Kt=dr,cu;(e=>{function t(){return Kt}e.value=t;function s(){return Kt.length===2?Kt==="en":Kt.length>=3?Kt[0]==="e"&&Kt[1]==="n"&&Kt[2]==="-":!1}e.isDefaultVariant=s;function r(){return Kt==="en"}e.isDefault=r})(cu||(cu={}));var hu=typeof as.postMessage=="function"&&!as.importScripts;(()=>{if(hu){let e=[];as.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r{let r=++t;e.push({id:r,callback:s}),as.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var du=!!(Rt&&Rt.indexOf("Chrome")>=0);Rt&&Rt.indexOf("Firefox")>=0;!du&&Rt&&Rt.indexOf("Safari")>=0;Rt&&Rt.indexOf("Edg/")>=0;Rt&&Rt.indexOf("Android")>=0;var _s=typeof navigator=="object"?navigator:{};po||document.queryCommandSupported&&document.queryCommandSupported("copy")||_s&&_s.clipboard&&_s.clipboard.writeText,po||_s&&_s.clipboard&&_s.clipboard.readText;var Zi=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}},Vr=new Zi,_o=new Zi,go=new Zi,uu=new Array(230),al;(e=>{function t(l){return Vr.keyCodeToStr(l)}e.toString=t;function s(l){return Vr.strToKeyCode(l)}e.fromString=s;function r(l){return _o.keyCodeToStr(l)}e.toUserSettingsUS=r;function i(l){return go.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function o(l){return _o.strToKeyCode(l)||go.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Vr.keyCodeToStr(l)}e.toElectronAccelerator=a})(al||(al={}));var fu=class ll{constructor(t,s,r,i,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=i,this.keyCode=o}equals(t){return t instanceof ll&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${s}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new pu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},pu=class{constructor(e){if(e.length===0)throw Wd("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof wu?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ge.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:cl})})(Su||(Su={}));var wu=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?cl:(this._emitter||(this._emitter=new V),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Qi=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 hi("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hi("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Cu=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,s=globalThis){if(this.isDisposed)throw new hi("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Ee(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ku;(e=>{async function t(r){let i,o=await Promise.all(r.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}e.settled=t;function s(r){return new Promise(async(i,o)=>{try{await r(i,o)}catch(a){o(a)}})}e.withAsyncBody=s})(ku||(ku={}));var yo=class pt{static fromArray(t){return new pt(s=>{s.emitMany(t)})}static fromPromise(t){return new pt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new pt(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new pt(async s=>{await Promise.all(t.map(async r=>{for await(let i of r)s.emitOne(i)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new V,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new pt(async r=>{for await(let i of t)r.emitOne(s(i))})}map(t){return pt.map(this,t)}static filter(t,s){return new pt(async r=>{for await(let i of t)s(i)&&r.emitOne(i)})}filter(t){return pt.filter(this,t)}static coalesce(t){return pt.filter(t,s=>!!s)}coalesce(){return pt.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return pt.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())}};yo.EMPTY=yo.fromArray([]);var{getWindow:jt,getWindowId:Eu,onDidRegisterWindow:Nu}=(function(){let e=new Map,t={window:It,disposables:new Gt};e.set(It.vscodeWindowId,t);let s=new V,r=new V,i=new V;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ue.None;let l=new Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(Ee(()=>{e.delete(a.vscodeWindowId),r.fire(a)})),l.add(ne(a,Fe.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:It},getDocument(a){return jt(a).document}}})(),ju=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!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 ne(e,t,s,r){return new ju(e,t,s,r)}var bo=function(e,t,s,r){return ne(e,t,s,r)},en,Mu=class extends Cu{constructor(e){super(),this.defaultTarget=e&&jt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},So=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){cr(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,i=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),r.set(o,!0);a.length>0;)a.sort(So.sort),a.shift().execute();r.set(o,!1)};en=(o,a,l=0)=>{let h=Eu(o),c=new So(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>i(h))),c}})();function Lu(e){let t=e.getBoundingClientRect(),s=jt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Fe={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"},Tu=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=rt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=rt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=rt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=rt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=rt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=rt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=rt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=rt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=rt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=rt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=rt(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=rt(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=rt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=rt(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 rt(e){return typeof e=="number"?`${e}px`:e}function As(e){return new Tu(e)}var hl=class{constructor(){this._hooks=new Gt,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let o=e;try{e.setPointerCapture(t),this._hooks.add(Ee(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=jt(e)}this._hooks.add(ne(o,Fe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ne(o,Fe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Ru(e,t,s){let r=null,i=null;if(typeof s.value=="function"?(r="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${t}`;s[r]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var Nt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Nt||(Nt={}));var Ls=class Ze extends ue{constructor(){super(),this.dispatched=!1,this.targets=new uo,this.ignoreTargets=new uo,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ge.runAndSubscribe(Nu,({window:t,disposables:s})=>{s.add(ne(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(ne(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(ne(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:It,disposables:this._store}))}static addTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.targets.push(t);return Ee(s)}static ignoreTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.ignoreTargets.push(t);return Ee(s)}static isTouchDevice(){return"ontouchstart"in It||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r=Ze.HOLD_DELAY&&Math.abs(h.initialPageX-lt(h.rollingPageX))<30&&Math.abs(h.initialPageY-lt(h.rollingPageY))<30){let u=this.newGestureEvent(Nt.Contextmenu,h.initialTarget);u.pageX=lt(h.rollingPageX),u.pageY=lt(h.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=lt(h.rollingPageX),d=lt(h.rollingPageY),_=lt(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],m=d-h.rollingPageY[0],x=[...this.targets].filter(w=>h.initialTarget instanceof Node&&w.contains(h.initialTarget));this.inertia(t,x,r,Math.abs(g)/_,g>0?1:-1,u,Math.abs(m)/_,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Nt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===Nt.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Ze.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Nt.Change||t.type===Nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,o=t.initialTarget;for(;o&&o!==r;)i++,o=o.parentElement;s.push([i,r])}s.sort((r,i)=>r[0]-i[0]);for(let[r,i]of s)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,i,o,a,l,h,c){this.handle=en(t,()=>{let u=Date.now(),d=u-r,_=0,g=0,m=!0;i+=Ze.SCROLL_FRICTION*d,l+=Ze.SCROLL_FRICTION*d,i>0&&(m=!1,_=o*i*d),l>0&&(m=!1,g=h*l*d);let x=this.newGestureEvent(Nt.Change);x.translationX=_,x.translationY=g,s.forEach(w=>w.dispatchEvent(x)),m||this.inertia(t,s,u,i,o,a+_,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let r=0,i=t.changedTouches.length;r3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ls.SCROLL_FRICTION=-.005,Ls.HOLD_DELAY=700,Ls.CLEAR_TAP_COUNT_TIME=400,Le([Ru],Ls,"isTouchDevice",1);var Bu=Ls,tn=class extends ue{onclick(e,t){this._register(ne(e,Fe.CLICK,s=>t(new sr(jt(e),s))))}onmousedown(e,t){this._register(ne(e,Fe.MOUSE_DOWN,s=>t(new sr(jt(e),s))))}onmouseover(e,t){this._register(ne(e,Fe.MOUSE_OVER,s=>t(new sr(jt(e),s))))}onmouseleave(e,t){this._register(ne(e,Fe.MOUSE_LEAVE,s=>t(new sr(jt(e),s))))}onkeydown(e,t){this._register(ne(e,Fe.KEY_DOWN,s=>t(new mo(s))))}onkeyup(e,t){this._register(ne(e,Fe.KEY_UP,s=>t(new mo(s))))}oninput(e,t){this._register(ne(e,Fe.INPUT,t))}onblur(e,t){this._register(ne(e,Fe.BLUR,t))}onfocus(e,t){this._register(ne(e,Fe.FOCUS,t))}onchange(e,t){this._register(ne(e,Fe.CHANGE,t))}ignoreGesture(e){return Bu.ignoreTarget(e)}},wo=11,Du=class extends tn{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=wo+"px",this.domNode.style.height=wo+"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 hl),this._register(bo(this.bgDomNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bo(this.domNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Mu),this._pointerdownScheduleRepeatTimer=this._register(new Qi)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,jt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Pu=class xi{constructor(t,s,r,i,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>r&&(i=r-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=r,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}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,s){return new xi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new xi(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,s){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:r,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Au=class extends ue{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Pu(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 r;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new ko(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=ko.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Co=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function qr(e,t){let s=t-e;return function(r){return e+s*Wu(r)}}function Ou(e,t,s){return function(r){return r2.5*r){let i,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":"")))}},$u=140,dl=class extends tn{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 Hu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new hl),this._shouldRender=!0,this.domNode=As(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(ne(this.domNode.domNode,Fe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Du(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=As(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ne(this.slider.domNode,Fe.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let i=Lu(this.domNode.domNode);t=e.pageX-i.left,s=e.pageY-i.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(ol&&a>$u){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{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()}},ul=class bi{constructor(t,s,r,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bi(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,i,o){let a=Math.max(0,r-t),l=Math.max(0,a-2*s),h=i>0&&i>r;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*l/i))),u=(l-c)/(i-r),d=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=bi._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let i=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(i,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(i,a),d=Math.max(o,l);u%h===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Si.INSTANCE=new Si;var Vu=Si,qu=class extends tn{constructor(e,t,s){super(),this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new V),this.onWillScroll=this._onWillScroll.event,this._options=Yu(t),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new zu(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Fu(this._scrollable,this._options,r)),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=As(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=As(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=As(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Qi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ls(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,Mt&&(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 xo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ls(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new xo(s))};this._mouseWheelToDispose.push(ne(this._listenOnDomNode,Fe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Vu.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!Mt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Eo*o,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(a){let u=Eo*a,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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,s=e.scrollLeft>0,r=s?" left":"",i=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${r}`)}}_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(),Uu)}},Xu=class extends qu{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Yu(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,Mt&&(t.className+=" mac"),t}var wi=class extends ue{constructor(e,t,s,r,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new V),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Au({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>en(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Xu(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ge.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ee(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ee(()=>this._styleElement.remove())),this._register(Ge.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(c=>this._handleScroll(c)))}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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};wi=Le([G(2,tt),G(3,Wt),G(4,Va),G(5,ys),G(6,st),G(7,Ht)],wi);var Ci=class extends ue{constructor(e,t,s,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=i,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(Ee(()=>{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 r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*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()}};Ci=Le([G(1,tt),G(2,Wt),G(3,Fs),G(4,Ht)],Ci);var Gu=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},kt={full:0,left:0,center:0,right:0},Vt={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},mr=class extends ue{constructor(e,t,s,r,i,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Gu,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(Ee(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Vt.full=this._canvas.width,Vt.left=e,Vt.center=t,Vt.right=e,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Vt.left,ws.right=1+Vt.left+Vt.center}_refreshDrawHeightConstants(){kt.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);kt.left=t,kt.center=t,kt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.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(ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kt[e.position||"full"]/2),Vt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kt[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}))}};mr=Le([G(2,tt),G(3,Fs),G(4,Ht),G(5,st),G(6,ys),G(7,Wt)],mr);var W;(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=""))(W||(W={}));var ur;(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="Ÿ"))(ur||(ur={}));var fl;(e=>e.ST=`${W.ESC}\\`)(fl||(fl={}));var ki=class{constructor(e,t,s,r,i,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=i,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};ki=Le([G(2,tt),G(3,st),G(4,hs),G(5,Ht)],ki);var ze=0,Ue=0,Ke=0,Me=0,No={css:"#00000000",rgba:0},Ae;(e=>{function t(i,o,a,l){return l!==void 0?`#${ss(i)}${ss(o)}${ss(a)}${ss(l)}`:`#${ss(i)}${ss(o)}${ss(a)}`}e.toCss=t;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function r(i,o,a,l){return{css:e.toCss(i,o,a,l),rgba:e.toRgba(i,o,a,l)}}e.toColor=r})(Ae||(Ae={}));var ke;(e=>{function t(h,c){if(Me=(c.rgba&255)/255,Me===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,_=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,x=h.rgba>>8&255;ze=g+Math.round((u-g)*Me),Ue=m+Math.round((d-m)*Me),Ke=x+Math.round((_-x)*Me);let w=Ae.toCss(ze,Ue,Ke),E=Ae.toRgba(ze,Ue,Ke);return{css:w,rgba:E}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function r(h,c,u){let d=fr.ensureContrastRatio(h.rgba,c.rgba,u);if(d)return Ae.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(h){let c=(h.rgba|255)>>>0;return[ze,Ue,Ke]=fr.toChannels(c),{css:Ae.toCss(ze,Ue,Ke),rgba:c}}e.opaque=i;function o(h,c){return Me=Math.round(c*255),[ze,Ue,Ke]=fr.toChannels(h.rgba),{css:Ae.toCss(ze,Ue,Ke,Me),rgba:Ae.toRgba(ze,Ue,Ke,Me)}}e.opacity=o;function a(h,c){return Me=h.rgba&255,o(h,Me*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ke||(ke={}));var je;(e=>{let t,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Ae.toColor(ze,Ue,Ke);case 5:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Me=parseInt(i.slice(4,5).repeat(2),16),Ae.toColor(ze,Ue,Ke,Me);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.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 ze=parseInt(o[1]),Ue=parseInt(o[2]),Ke=parseInt(o[3]),Me=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ae.toColor(ze,Ue,Ke,Me);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ue,Ke,Me]=t.getImageData(0,0,1,1).data,Me!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(ze,Ue,Ke,Me),css:i}}e.toColor=r})(je||(je={}));var Qe;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,i,o){let a=r/255,l=i/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=s})(Qe||(Qe={}));var fr;(e=>{function t(a,l){if(Me=(l&255)/255,Me===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,d=a>>24&255,_=a>>16&255,g=a>>8&255;return ze=d+Math.round((h-d)*Me),Ue=_+Math.round((c-_)*Me),Ke=g+Math.round((u-g)*Me),Ae.toRgba(ze,Ue,Ke)}e.blend=t;function s(a,l,h){let c=Qe.relativeLuminance(a>>8),u=Qe.relativeLuminance(l>>8);if(Pt(c,u)>8));if(m>8));return m>w?g:x}return g}let d=i(a,l,h),_=Pt(c,Qe.relativeLuminance(d>>8));if(_>8));return _>m?d:g}return d}}e.ensureContrastRatio=s;function r(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x0||g>0||m>0);)_-=Math.max(0,Math.ceil(_*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));return(_<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x>>0}e.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(fr||(fr={}));function ss(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e1){let u=this._getJoinedRanges(r,a,o,t,i);for(let d=0;d1){let c=this._getJoinedRanges(r,a,o,t,i);for(let u=0;u=O,j=p,M=this._workCell;if(_.length>0&&p===_[0][0]&&y){let ge=_.shift(),$t=this._isCellInSelection(ge[0],t);for(k=ge[0]+1;k=ge[1]),y?(b=!0,M=new Ju(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),j=ge[1]-1,f=M.getWidth()):O=ge[1]}let z=this._isCellInSelection(p,t),C=s&&p===o,H=R&&p>=c&&p<=u,U=!1;this._decorationService.forEachDecorationAtCell(p,t,void 0,ge=>{U=!0});let q=M.getChars()||Yt;if(q===" "&&(M.isUnderline()||M.isOverline())&&(q=" "),T=f*l-h.get(q,M.isBold(),M.isItalic()),!x)x=this._document.createElement("span");else if(w&&(z&&B||!z&&!B&&M.bg===P)&&(z&&B&&g.selectionForeground||M.fg===A)&&M.extended.ext===D&&H===N&&T===$&&!C&&!b&&!U&&y){M.isInvisible()?E+=Yt:E+=q,w++;continue}else w&&(x.textContent=E),x=this._document.createElement("span"),w=0,E="";if(P=M.bg,A=M.fg,D=M.extended.ext,N=H,$=T,B=z,b&&o>=p&&o<=j&&(o=p),!this._coreService.isCursorHidden&&C&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&L.push("xterm-cursor-blink"),L.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(M.isBold()&&L.push("xterm-bold"),M.isItalic()&&L.push("xterm-italic"),M.isDim()&&L.push("xterm-dim"),M.isInvisible()?E=Yt:E=M.getChars()||Yt,M.isUnderline()&&(L.push(`xterm-underline-${M.extended.underlineStyle}`),E===" "&&(E=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${$s.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let ge=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&ge<8&&(ge+=8),x.style.textDecorationColor=g.ansi[ge].css}M.isOverline()&&(L.push("xterm-overline"),E===" "&&(E=" ")),M.isStrikethrough()&&L.push("xterm-strikethrough"),H&&(x.style.textDecoration="underline");let ee=M.getFgColor(),ie=M.getFgColorMode(),F=M.getBgColor(),se=M.getBgColorMode(),pe=!!M.isInverse();if(pe){let ge=ee;ee=F,F=ge;let $t=ie;ie=se,se=$t}let _e,qe,St=!1;this._decorationService.forEachDecorationAtCell(p,t,void 0,ge=>{ge.options.layer!=="top"&&St||(ge.backgroundColorRGB&&(se=50331648,F=ge.backgroundColorRGB.rgba>>8&16777215,_e=ge.backgroundColorRGB),ge.foregroundColorRGB&&(ie=50331648,ee=ge.foregroundColorRGB.rgba>>8&16777215,qe=ge.foregroundColorRGB),St=ge.options.layer==="top")}),!St&&z&&(_e=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,F=_e.rgba>>8&16777215,se=50331648,St=!0,g.selectionForeground&&(ie=50331648,ee=g.selectionForeground.rgba>>8&16777215,qe=g.selectionForeground)),St&&L.push("xterm-decoration-top");let ht;switch(se){case 16777216:case 33554432:ht=g.ansi[F],L.push(`xterm-bg-${F}`);break;case 50331648:ht=Ae.toColor(F>>16,F>>8&255,F&255),this._addStyle(x,`background-color:#${jo((F>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(ht=g.foreground,L.push("xterm-bg-257")):ht=g.background}switch(_e||M.isDim()&&(_e=ke.multiplyOpacity(ht,.5)),ie){case 16777216:case 33554432:M.isBold()&&ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ee+=8),this._applyMinimumContrast(x,ht,g.ansi[ee],M,_e,void 0)||L.push(`xterm-fg-${ee}`);break;case 50331648:let ge=Ae.toColor(ee>>16&255,ee>>8&255,ee&255);this._applyMinimumContrast(x,ht,ge,M,_e,qe)||this._addStyle(x,`color:#${jo(ee.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,ht,g.foreground,M,_e,qe)||pe&&L.push("xterm-fg-257")}L.length&&(x.className=L.join(" "),L.length=0),!C&&!b&&!U&&y?w++:x.textContent=E,T!==this.defaultSpacing&&(x.style.letterSpacing=`${T}px`),d.push(x),p=j}return x&&w&&(x.textContent=E),d}_applyMinimumContrast(e,t,s,r,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||ef(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!i&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ke.ensureContrastRatio(i||t,o||s,h),a.setColor((i||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t=s[0]&&e=s[0]}};Ei=Le([G(1,Ya),G(2,st),G(3,Wt),G(4,hs),G(5,Fs),G(6,ys)],Ei);function jo(e,t,s){for(;e.length0&&(this._flat[r]=a),a}let i=e;t&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(i,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},rf=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let i=e.buffers.active.ydisp,o=t[1]-i,a=s[1]-i,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function nf(){return new rf}var Xr="xterm-dom-renderer-owner-",ft="xterm-rows",ir="xterm-fg-",Mo="xterm-bg-",Cs="xterm-focus",nr="xterm-selection",of=1,Ni=class extends ue{constructor(e,t,s,r,i,o,a,l,h,c,u,d,_,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=_,this._themeService=g,this._terminalClass=of++,this._rowElements=[],this._selectionRenderModel=nf(),this.onRequestRedraw=this._register(new V).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ft),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(nr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=tf(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ei,document),this._element.classList.add(Xr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ee(()=>{this._element.classList.remove(Xr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new sf(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ft} 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} .${ft} { 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} .${ft} .xterm-dim { color: ${ke.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${nr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${nr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${nr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${ir}${o} { color: ${a.css}; }${this._terminalSelector} .${ir}${o}.xterm-dim { color: ${ke.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Mo}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${ir}257 { color: ${ke.opaque(e.background).css}; }${this._terminalSelector} .${ir}257.xterm-dim { color: ${ke.multiplyOpacity(ke.opaque(e.background),.5).css}; }${this._terminalSelector} .${Mo}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 s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let d=i===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,d))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,r=1){let i=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}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 s=this._bufferService.buffer,r=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],d=s.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Xr}${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,s,r,i,o){s<0&&(e=0),r<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=r;++g){let m=g+l.ydisp,x=this._rowElements[g],w=l.lines.get(m);if(!x||!w)break;x.replaceChildren(...this._rowFactory.createRow(w,m,m===h,d,_,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===r?t:i)-1:-1))}}};Ni=Le([G(7,Xi),G(8,Nr),G(9,st),G(10,tt),G(11,hs),G(12,Wt),G(13,ys)],Ni);var ji=class extends ue{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new V),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new lf(this._optionsService))}catch{this._measureStrategy=this._register(new af(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())}};ji=Le([G(2,st)],ji);var pl=class extends ue{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)}},af=class extends pl{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},lf=class extends pl{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}},cf=class extends ue{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hf(this._window)),this._onDprChange=this._register(new V),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new V),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ge.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ne(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}},hf=class extends ue{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new xs),this._onDprChange=this._register(new V),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ee(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ne(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)}},df=class extends ue{constructor(){super(),this.linkProviders=[],this._register(Ee(()=>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 sn(e,t,s){let r=s.getBoundingClientRect(),i=e.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-o,t.clientY-r.top-a]}function uf(e,t,s,r,i,o,a,l,h){if(!o)return;let c=sn(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),r+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var Mi=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,i){return uf(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let s=sn(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Mi=Le([G(0,Ht),G(1,Nr)],Mi);var ff=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,s){this._rowCount=s,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=[]}},_l={};Sd(_l,{getSafariVersion:()=>_f,isChromeOS:()=>xl,isFirefox:()=>gl,isIpad:()=>gf,isIphone:()=>mf,isLegacyEdge:()=>pf,isLinux:()=>rn,isMac:()=>xr,isNode:()=>jr,isSafari:()=>ml,isWindows:()=>vl});var jr=typeof process<"u"&&"title"in process,zs=jr?"node":navigator.userAgent,Us=jr?"node":navigator.platform,gl=zs.includes("Firefox"),pf=zs.includes("Edge"),ml=/^((?!chrome|android).)*safari/i.test(zs);function _f(){if(!ml)return 0;let e=zs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var xr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Us),gf=Us==="iPad",mf=Us==="iPhone",vl=["Windows","Win16","Win32","WinCE"].includes(Us),rn=Us.indexOf("Linux")>=0,xl=/\bCrOS\b/.test(zs),yl=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},vf=class extends yl{_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())}}},xf=class extends yl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},yr=!jr&&"requestIdleCallback"in window?xf:vf,yf=class{constructor(){this._queue=new yr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Li=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new xs),this._pausedResizeTask=new yf,this._observerDisposable=this._register(new xs),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 V),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new V),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new V),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new V),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ff((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new bf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ee(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.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(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ee(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(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 s;return(s=this._renderer.value)==null?void 0:s.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,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Li=Le([G(2,st),G(3,Nr),G(4,hs),G(5,Fs),G(6,tt),G(7,Wt),G(8,ys)],Li);var bf=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 Sf(e,t,s,r){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return kf(i,o,e,t,s,r)+Mr(o,t,s,r)+Ef(i,o,e,t,s,r);let a;if(o===t)return a=i>e?"D":"C",Ws(Math.abs(i-e),Is(a,r));a=o>t?"D":"C";let l=Math.abs(o-t),h=Cf(o>t?e:i,s)+(l-1)*s.cols+1+wf(o>t?i:e);return Ws(h,Is(a,r))}function wf(e,t){return e-1}function Cf(e,t){return t.cols-e}function kf(e,t,s,r,i,o){return Mr(t,r,i,o).length===0?"":Ws(Sl(e,t,e,t-cs(t,i),!1,i).length,Is("D",o))}function Mr(e,t,s,r){let i=e-cs(e,s),o=t-cs(t,s),a=Math.abs(i-o)-Nf(e,t,s);return Ws(a,Is(bl(e,t),r))}function Ef(e,t,s,r,i,o){let a;Mr(t,r,i,o).length>0?a=r-cs(r,i):a=t;let l=r,h=jf(e,t,s,r,i,o);return Ws(Sl(e,a,s,l,h==="C",i).length,Is(h,o))}function Nf(e,t,s){var a;let r=0,i=e-cs(e,s),o=t-cs(t,s);for(let l=0;l=0&&e0?a=r-cs(r,i):a=t,e=s&&at?"A":"B"}function Sl(e,t,s,r,i,o){let a=e,l=t,h="";for(;(a!==s||l!==r)&&l>=0&&lo.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!i&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function Is(e,t){let s=t?"O":"[";return W.ESC+s+e}function Ws(e,t){e=Math.floor(e);let s="";for(let r=0;rthis._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 Lo(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 Yr=50,Lf=15,Tf=50,Rf=500,Bf=" ",Df=new RegExp(Bf,"g"),Ti=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new V),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new V),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new V),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new V),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Mf(this._bufferService),this._activeSelectionMode=0,this._register(Ee(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]i.replace(Df," ")).join(vl?`\r +`))}},Yd=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Gd=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Jd=0,Ur=class{constructor(e){this.value=e,this.id=Jd++}},Zd=2,Qd,q=class{constructor(e){var t,s,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new qd((e==null?void 0:e.onListenerError)??cr,((s=this._options)==null?void 0:s.leakWarningThreshold)??Vd):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Kd(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var a,l,h,c,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new Gd(`${d}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((a=this._options)==null?void 0:a.onListenerError)||cr)(g),ue.None}if(this._disposed)return ue.None;t&&(e=e.bind(t));let r=new Ur(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Xd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ur?(this._deliveryQueue??(this._deliveryQueue=new eu),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(u=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||u.call(c,this)),this._size++;let o=Ee(()=>{i==null||i(),this._removeListener(r)});return s instanceof Gt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var i,o,a,l;if((o=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||o.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||l.call(a,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);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--,t[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Zd<=t.length){let h=0;for(let c=0;c0}},eu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_i=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};_i.INSTANCE=new _i;var Ji=_i;function tu(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Ji.INSTANCE.onDidChangeZoomLevel;function su(e){return Ji.INSTANCE.getZoomFactor(e)}Ji.INSTANCE.onDidChangeFullscreen;var bs=typeof navigator=="object"?navigator.userAgent:"",gi=bs.indexOf("Firefox")>=0,ru=bs.indexOf("AppleWebKit")>=0,Zi=bs.indexOf("Chrome")>=0,iu=!Zi&&bs.indexOf("Safari")>=0;bs.indexOf("Electron/")>=0;bs.indexOf("Android")>=0;var Kr=!1;if(typeof It.matchMedia=="function"){let e=It.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=It.matchMedia("(display-mode: fullscreen)");Kr=e.matches,tu(It,e,({matches:s})=>{Kr&&t.matches||(Kr=s)})}var vs="en",mi=!1,vi=!1,hr=!1,nl=!1,tr,dr=vs,po=vs,nu,bt,as=globalThis,Ye,sa;typeof as.vscode<"u"&&typeof as.vscode.process<"u"?Ye=as.vscode.process:typeof process<"u"&&typeof((sa=process==null?void 0:process.versions)==null?void 0:sa.node)=="string"&&(Ye=process);var ra,ou=typeof((ra=Ye==null?void 0:Ye.versions)==null?void 0:ra.electron)=="string",au=ou&&(Ye==null?void 0:Ye.type)==="renderer",ia;if(typeof Ye=="object"){mi=Ye.platform==="win32",vi=Ye.platform==="darwin",hr=Ye.platform==="linux",hr&&Ye.env.SNAP&&Ye.env.SNAP_REVISION,Ye.env.CI||Ye.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tr=vs,dr=vs;let e=Ye.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);tr=t.userLocale,po=t.osLocale,dr=t.resolvedLanguage||vs,nu=(ia=t.languagePack)==null?void 0:ia.translationsConfigFile}catch{}nl=!0}else typeof navigator=="object"&&!au?(bt=navigator.userAgent,mi=bt.indexOf("Windows")>=0,vi=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,hr=bt.indexOf("Linux")>=0,(bt==null?void 0:bt.indexOf("Mobi"))>=0,dr=globalThis._VSCODE_NLS_LANGUAGE||vs,tr=navigator.language.toLowerCase(),po=tr):console.error("Unable to resolve platform.");var ol=mi,Mt=vi,lu=hr,_o=nl,Rt=bt,Kt=dr,cu;(e=>{function t(){return Kt}e.value=t;function s(){return Kt.length===2?Kt==="en":Kt.length>=3?Kt[0]==="e"&&Kt[1]==="n"&&Kt[2]==="-":!1}e.isDefaultVariant=s;function r(){return Kt==="en"}e.isDefault=r})(cu||(cu={}));var hu=typeof as.postMessage=="function"&&!as.importScripts;(()=>{if(hu){let e=[];as.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r{let r=++t;e.push({id:r,callback:s}),as.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var du=!!(Rt&&Rt.indexOf("Chrome")>=0);Rt&&Rt.indexOf("Firefox")>=0;!du&&Rt&&Rt.indexOf("Safari")>=0;Rt&&Rt.indexOf("Edg/")>=0;Rt&&Rt.indexOf("Android")>=0;var _s=typeof navigator=="object"?navigator:{};_o||document.queryCommandSupported&&document.queryCommandSupported("copy")||_s&&_s.clipboard&&_s.clipboard.writeText,_o||_s&&_s.clipboard&&_s.clipboard.readText;var Qi=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}},Vr=new Qi,go=new Qi,mo=new Qi,uu=new Array(230),al;(e=>{function t(l){return Vr.keyCodeToStr(l)}e.toString=t;function s(l){return Vr.strToKeyCode(l)}e.fromString=s;function r(l){return go.keyCodeToStr(l)}e.toUserSettingsUS=r;function i(l){return mo.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function o(l){return go.strToKeyCode(l)||mo.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Vr.keyCodeToStr(l)}e.toElectronAccelerator=a})(al||(al={}));var fu=class ll{constructor(t,s,r,i,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=i,this.keyCode=o}equals(t){return t instanceof ll&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${s}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new pu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},pu=class{constructor(e){if(e.length===0)throw Wd("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t{function t(s){return s===e.None||s===e.Cancelled||s instanceof wu?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ge.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:cl})})(Su||(Su={}));var wu=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?cl:(this._emitter||(this._emitter=new q),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},en=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 hi("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hi("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Cu=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,s=globalThis){if(this.isDisposed)throw new hi("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Ee(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ku;(e=>{async function t(r){let i,o=await Promise.all(r.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}e.settled=t;function s(r){return new Promise(async(i,o)=>{try{await r(i,o)}catch(a){o(a)}})}e.withAsyncBody=s})(ku||(ku={}));var bo=class pt{static fromArray(t){return new pt(s=>{s.emitMany(t)})}static fromPromise(t){return new pt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new pt(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new pt(async s=>{await Promise.all(t.map(async r=>{for await(let i of r)s.emitOne(i)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new q,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new pt(async r=>{for await(let i of t)r.emitOne(s(i))})}map(t){return pt.map(this,t)}static filter(t,s){return new pt(async r=>{for await(let i of t)s(i)&&r.emitOne(i)})}filter(t){return pt.filter(this,t)}static coalesce(t){return pt.filter(t,s=>!!s)}coalesce(){return pt.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return pt.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())}};bo.EMPTY=bo.fromArray([]);var{getWindow:jt,getWindowId:Eu,onDidRegisterWindow:Nu}=(function(){let e=new Map,t={window:It,disposables:new Gt};e.set(It.vscodeWindowId,t);let s=new q,r=new q,i=new q;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ue.None;let l=new Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(Ee(()=>{e.delete(a.vscodeWindowId),r.fire(a)})),l.add(ne(a,Fe.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:It},getDocument(a){return jt(a).document}}})(),ju=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!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 ne(e,t,s,r){return new ju(e,t,s,r)}var So=function(e,t,s,r){return ne(e,t,s,r)},tn,Mu=class extends Cu{constructor(e){super(),this.defaultTarget=e&&jt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},wo=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){cr(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,i=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),r.set(o,!0);a.length>0;)a.sort(wo.sort),a.shift().execute();r.set(o,!1)};tn=(o,a,l=0)=>{let h=Eu(o),c=new wo(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>i(h))),c}})();function Lu(e){let t=e.getBoundingClientRect(),s=jt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Fe={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"},Tu=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=rt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=rt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=rt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=rt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=rt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=rt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=rt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=rt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=rt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=rt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=rt(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=rt(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=rt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=rt(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 rt(e){return typeof e=="number"?`${e}px`:e}function As(e){return new Tu(e)}var hl=class{constructor(){this._hooks=new Gt,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let o=e;try{e.setPointerCapture(t),this._hooks.add(Ee(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=jt(e)}this._hooks.add(ne(o,Fe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ne(o,Fe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Ru(e,t,s){let r=null,i=null;if(typeof s.value=="function"?(r="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${t}`;s[r]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var Nt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Nt||(Nt={}));var Ls=class Ze extends ue{constructor(){super(),this.dispatched=!1,this.targets=new fo,this.ignoreTargets=new fo,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ge.runAndSubscribe(Nu,({window:t,disposables:s})=>{s.add(ne(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(ne(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(ne(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:It,disposables:this._store}))}static addTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.targets.push(t);return Ee(s)}static ignoreTarget(t){if(!Ze.isTouchDevice())return ue.None;Ze.INSTANCE||(Ze.INSTANCE=new Ze);let s=Ze.INSTANCE.ignoreTargets.push(t);return Ee(s)}static isTouchDevice(){return"ontouchstart"in It||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,i=t.targetTouches.length;r=Ze.HOLD_DELAY&&Math.abs(h.initialPageX-lt(h.rollingPageX))<30&&Math.abs(h.initialPageY-lt(h.rollingPageY))<30){let u=this.newGestureEvent(Nt.Contextmenu,h.initialTarget);u.pageX=lt(h.rollingPageX),u.pageY=lt(h.rollingPageY),this.dispatchEvent(u)}else if(i===1){let u=lt(h.rollingPageX),d=lt(h.rollingPageY),_=lt(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],m=d-h.rollingPageY[0],x=[...this.targets].filter(w=>h.initialTarget instanceof Node&&w.contains(h.initialTarget));this.inertia(t,x,r,Math.abs(g)/_,g>0?1:-1,u,Math.abs(m)/_,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Nt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===Nt.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Ze.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Nt.Change||t.type===Nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let i=0,o=t.initialTarget;for(;o&&o!==r;)i++,o=o.parentElement;s.push([i,r])}s.sort((r,i)=>r[0]-i[0]);for(let[r,i]of s)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,i,o,a,l,h,c){this.handle=tn(t,()=>{let u=Date.now(),d=u-r,_=0,g=0,m=!0;i+=Ze.SCROLL_FRICTION*d,l+=Ze.SCROLL_FRICTION*d,i>0&&(m=!1,_=o*i*d),l>0&&(m=!1,g=h*l*d);let x=this.newGestureEvent(Nt.Change);x.translationX=_,x.translationY=g,s.forEach(w=>w.dispatchEvent(x)),m||this.inertia(t,s,u,i,o,a+_,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let r=0,i=t.changedTouches.length;r3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ls.SCROLL_FRICTION=-.005,Ls.HOLD_DELAY=700,Ls.CLEAR_TAP_COUNT_TIME=400,Le([Ru],Ls,"isTouchDevice",1);var Bu=Ls,sn=class extends ue{onclick(e,t){this._register(ne(e,Fe.CLICK,s=>t(new sr(jt(e),s))))}onmousedown(e,t){this._register(ne(e,Fe.MOUSE_DOWN,s=>t(new sr(jt(e),s))))}onmouseover(e,t){this._register(ne(e,Fe.MOUSE_OVER,s=>t(new sr(jt(e),s))))}onmouseleave(e,t){this._register(ne(e,Fe.MOUSE_LEAVE,s=>t(new sr(jt(e),s))))}onkeydown(e,t){this._register(ne(e,Fe.KEY_DOWN,s=>t(new vo(s))))}onkeyup(e,t){this._register(ne(e,Fe.KEY_UP,s=>t(new vo(s))))}oninput(e,t){this._register(ne(e,Fe.INPUT,t))}onblur(e,t){this._register(ne(e,Fe.BLUR,t))}onfocus(e,t){this._register(ne(e,Fe.FOCUS,t))}onchange(e,t){this._register(ne(e,Fe.CHANGE,t))}ignoreGesture(e){return Bu.ignoreTarget(e)}},Co=11,Du=class extends sn{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=Co+"px",this.domNode.style.height=Co+"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 hl),this._register(So(this.bgDomNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(So(this.domNode,Fe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Mu),this._pointerdownScheduleRepeatTimer=this._register(new en)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,jt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Pu=class xi{constructor(t,s,r,i,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>r&&(i=r-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=r,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}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,s){return new xi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new xi(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,s){let r=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:r,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Au=class extends ue{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Pu(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 r;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new Eo(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Eo.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},ko=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function qr(e,t){let s=t-e;return function(r){return e+s*Wu(r)}}function Ou(e,t,s){return function(r){return r2.5*r){let i,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":"")))}},$u=140,dl=class extends sn{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 Hu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new hl),this._shouldRender=!0,this.domNode=As(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(ne(this.domNode.domNode,Fe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Du(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=As(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ne(this.slider.domNode,Fe.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let i=Lu(this.domNode.domNode);t=e.pageX-i.left,s=e.pageY-i.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(ol&&a>$u){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{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()}},ul=class bi{constructor(t,s,r,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bi(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,i,o){let a=Math.max(0,r-t),l=Math.max(0,a-2*s),h=i>0&&i>r;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(r*l/i))),u=(l-c)/(i-r),d=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=bi._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let i=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(i,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(i,a),d=Math.max(o,l);u%h===0&&d%c===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Si.INSTANCE=new Si;var Vu=Si,qu=class extends sn{constructor(e,t,s){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=Yu(t),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new zu(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Fu(this._scrollable,this._options,r)),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=As(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=As(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=As(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new en),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ls(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,Mt&&(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 yo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ls(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new yo(s))};this._mouseWheelToDispose.push(ne(this._listenOnDomNode,Fe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=Vu.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!Mt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=No*o,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,d)}if(a){let u=No*a,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,d)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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,s=e.scrollLeft>0,r=s?" left":"",i=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${r}`)}}_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(),Uu)}},Xu=class extends qu{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Yu(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,Mt&&(t.className+=" mac"),t}var wi=class extends ue{constructor(e,t,s,r,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Au({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>tn(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Xu(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ge.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ee(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ee(()=>this._styleElement.remove())),this._register(Ge.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(c=>this._handleScroll(c)))}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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};wi=Le([G(2,tt),G(3,Wt),G(4,Va),G(5,ys),G(6,st),G(7,Ht)],wi);var Ci=class extends ue{constructor(e,t,s,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=i,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(Ee(()=>{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 r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*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()}};Ci=Le([G(1,tt),G(2,Wt),G(3,Fs),G(4,Ht)],Ci);var Gu=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},kt={full:0,left:0,center:0,right:0},Vt={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},mr=class extends ue{constructor(e,t,s,r,i,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Gu,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(Ee(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Vt.full=this._canvas.width,Vt.left=e,Vt.center=t,Vt.right=e,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Vt.left,ws.right=1+Vt.left+Vt.center}_refreshDrawHeightConstants(){kt.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);kt.left=t,kt.center=t,kt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kt.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(ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kt[e.position||"full"]/2),Vt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kt[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}))}};mr=Le([G(2,tt),G(3,Fs),G(4,Ht),G(5,st),G(6,ys),G(7,Wt)],mr);var $;(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=""))($||($={}));var ur;(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="Ÿ"))(ur||(ur={}));var fl;(e=>e.ST=`${$.ESC}\\`)(fl||(fl={}));var ki=class{constructor(e,t,s,r,i,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=i,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.lengththis.updateCompositionElements(!0),0)}}};ki=Le([G(2,tt),G(3,st),G(4,hs),G(5,Ht)],ki);var ze=0,Ue=0,Ke=0,Me=0,jo={css:"#00000000",rgba:0},Ae;(e=>{function t(i,o,a,l){return l!==void 0?`#${ss(i)}${ss(o)}${ss(a)}${ss(l)}`:`#${ss(i)}${ss(o)}${ss(a)}`}e.toCss=t;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function r(i,o,a,l){return{css:e.toCss(i,o,a,l),rgba:e.toRgba(i,o,a,l)}}e.toColor=r})(Ae||(Ae={}));var ke;(e=>{function t(h,c){if(Me=(c.rgba&255)/255,Me===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,d=c.rgba>>16&255,_=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,x=h.rgba>>8&255;ze=g+Math.round((u-g)*Me),Ue=m+Math.round((d-m)*Me),Ke=x+Math.round((_-x)*Me);let w=Ae.toCss(ze,Ue,Ke),E=Ae.toRgba(ze,Ue,Ke);return{css:w,rgba:E}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function r(h,c,u){let d=fr.ensureContrastRatio(h.rgba,c.rgba,u);if(d)return Ae.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function i(h){let c=(h.rgba|255)>>>0;return[ze,Ue,Ke]=fr.toChannels(c),{css:Ae.toCss(ze,Ue,Ke),rgba:c}}e.opaque=i;function o(h,c){return Me=Math.round(c*255),[ze,Ue,Ke]=fr.toChannels(h.rgba),{css:Ae.toCss(ze,Ue,Ke,Me),rgba:Ae.toRgba(ze,Ue,Ke,Me)}}e.opacity=o;function a(h,c){return Me=h.rgba&255,o(h,Me*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ke||(ke={}));var je;(e=>{let t,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Ae.toColor(ze,Ue,Ke);case 5:return ze=parseInt(i.slice(1,2).repeat(2),16),Ue=parseInt(i.slice(2,3).repeat(2),16),Ke=parseInt(i.slice(3,4).repeat(2),16),Me=parseInt(i.slice(4,5).repeat(2),16),Ae.toColor(ze,Ue,Ke,Me);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.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 ze=parseInt(o[1]),Ue=parseInt(o[2]),Ke=parseInt(o[3]),Me=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ae.toColor(ze,Ue,Ke,Me);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ue,Ke,Me]=t.getImageData(0,0,1,1).data,Me!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(ze,Ue,Ke,Me),css:i}}e.toColor=r})(je||(je={}));var Qe;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,i,o){let a=r/255,l=i/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+d*.0722}e.relativeLuminance2=s})(Qe||(Qe={}));var fr;(e=>{function t(a,l){if(Me=(l&255)/255,Me===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,d=a>>24&255,_=a>>16&255,g=a>>8&255;return ze=d+Math.round((h-d)*Me),Ue=_+Math.round((c-_)*Me),Ke=g+Math.round((u-g)*Me),Ae.toRgba(ze,Ue,Ke)}e.blend=t;function s(a,l,h){let c=Qe.relativeLuminance(a>>8),u=Qe.relativeLuminance(l>>8);if(Pt(c,u)>8));if(m>8));return m>w?g:x}return g}let d=i(a,l,h),_=Pt(c,Qe.relativeLuminance(d>>8));if(_>8));return _>m?d:g}return d}}e.ensureContrastRatio=s;function r(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x0||g>0||m>0);)_-=Math.max(0,Math.ceil(_*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));return(_<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=r;function i(a,l,h){let c=a>>24&255,u=a>>16&255,d=a>>8&255,_=l>>24&255,g=l>>16&255,m=l>>8&255,x=Pt(Qe.relativeLuminance2(_,g,m),Qe.relativeLuminance2(c,u,d));for(;x>>0}e.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(fr||(fr={}));function ss(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e1){let u=this._getJoinedRanges(r,a,o,t,i);for(let d=0;d1){let c=this._getJoinedRanges(r,a,o,t,i);for(let u=0;u=I,N=f,M=this._workCell;if(_.length>0&&f===_[0][0]&&y){let ge=_.shift(),$t=this._isCellInSelection(ge[0],t);for(k=ge[0]+1;k=ge[1]),y?(b=!0,M=new Ju(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),N=ge[1]-1,p=M.getWidth()):I=ge[1]}let U=this._isCellInSelection(f,t),C=s&&f===o,W=B&&f>=c&&f<=u,z=!1;this._decorationService.forEachDecorationAtCell(f,t,void 0,ge=>{z=!0});let A=M.getChars()||Yt;if(A===" "&&(M.isUnderline()||M.isOverline())&&(A=" "),T=p*l-h.get(A,M.isBold(),M.isItalic()),!x)x=this._document.createElement("span");else if(w&&(U&&R||!U&&!R&&M.bg===P)&&(U&&R&&g.selectionForeground||M.fg===O)&&M.extended.ext===D&&W===j&&T===F&&!C&&!b&&!z&&y){M.isInvisible()?E+=Yt:E+=A,w++;continue}else w&&(x.textContent=E),x=this._document.createElement("span"),w=0,E="";if(P=M.bg,O=M.fg,D=M.extended.ext,j=W,F=T,R=U,b&&o>=f&&o<=N&&(o=f),!this._coreService.isCursorHidden&&C&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&L.push("xterm-cursor-blink"),L.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(M.isBold()&&L.push("xterm-bold"),M.isItalic()&&L.push("xterm-italic"),M.isDim()&&L.push("xterm-dim"),M.isInvisible()?E=Yt:E=M.getChars()||Yt,M.isUnderline()&&(L.push(`xterm-underline-${M.extended.underlineStyle}`),E===" "&&(E=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${$s.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let ge=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&ge<8&&(ge+=8),x.style.textDecorationColor=g.ansi[ge].css}M.isOverline()&&(L.push("xterm-overline"),E===" "&&(E=" ")),M.isStrikethrough()&&L.push("xterm-strikethrough"),W&&(x.style.textDecoration="underline");let Z=M.getFgColor(),ie=M.getFgColorMode(),K=M.getBgColor(),se=M.getBgColorMode(),pe=!!M.isInverse();if(pe){let ge=Z;Z=K,K=ge;let $t=ie;ie=se,se=$t}let _e,qe,St=!1;this._decorationService.forEachDecorationAtCell(f,t,void 0,ge=>{ge.options.layer!=="top"&&St||(ge.backgroundColorRGB&&(se=50331648,K=ge.backgroundColorRGB.rgba>>8&16777215,_e=ge.backgroundColorRGB),ge.foregroundColorRGB&&(ie=50331648,Z=ge.foregroundColorRGB.rgba>>8&16777215,qe=ge.foregroundColorRGB),St=ge.options.layer==="top")}),!St&&U&&(_e=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,K=_e.rgba>>8&16777215,se=50331648,St=!0,g.selectionForeground&&(ie=50331648,Z=g.selectionForeground.rgba>>8&16777215,qe=g.selectionForeground)),St&&L.push("xterm-decoration-top");let ht;switch(se){case 16777216:case 33554432:ht=g.ansi[K],L.push(`xterm-bg-${K}`);break;case 50331648:ht=Ae.toColor(K>>16,K>>8&255,K&255),this._addStyle(x,`background-color:#${Mo((K>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(ht=g.foreground,L.push("xterm-bg-257")):ht=g.background}switch(_e||M.isDim()&&(_e=ke.multiplyOpacity(ht,.5)),ie){case 16777216:case 33554432:M.isBold()&&Z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Z+=8),this._applyMinimumContrast(x,ht,g.ansi[Z],M,_e,void 0)||L.push(`xterm-fg-${Z}`);break;case 50331648:let ge=Ae.toColor(Z>>16&255,Z>>8&255,Z&255);this._applyMinimumContrast(x,ht,ge,M,_e,qe)||this._addStyle(x,`color:#${Mo(Z.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,ht,g.foreground,M,_e,qe)||pe&&L.push("xterm-fg-257")}L.length&&(x.className=L.join(" "),L.length=0),!C&&!b&&!z&&y?w++:x.textContent=E,T!==this.defaultSpacing&&(x.style.letterSpacing=`${T}px`),d.push(x),f=N}return x&&w&&(x.textContent=E),d}_applyMinimumContrast(e,t,s,r,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||ef(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!i&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ke.ensureContrastRatio(i||t,o||s,h),a.setColor((i||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t=s[0]&&e=s[0]}};Ei=Le([G(1,Ya),G(2,st),G(3,Wt),G(4,hs),G(5,Fs),G(6,ys)],Ei);function Mo(e,t,s){for(;e.length0&&(this._flat[r]=a),a}let i=e;t&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(i,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},rf=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let i=e.buffers.active.ydisp,o=t[1]-i,a=s[1]-i,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s=this.startCol&&t=this.startCol):!1}};function nf(){return new rf}var Xr="xterm-dom-renderer-owner-",ft="xterm-rows",ir="xterm-fg-",Lo="xterm-bg-",Cs="xterm-focus",nr="xterm-selection",of=1,Ni=class extends ue{constructor(e,t,s,r,i,o,a,l,h,c,u,d,_,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=d,this._coreBrowserService=_,this._themeService=g,this._terminalClass=of++,this._rowElements=[],this._selectionRenderModel=nf(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ft),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(nr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=tf(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ei,document),this._element.classList.add(Xr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ee(()=>{this._element.classList.remove(Xr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new sf(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ft} 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} .${ft} { 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} .${ft} .xterm-dim { color: ${ke.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${nr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${nr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${nr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${ir}${o} { color: ${a.css}; }${this._terminalSelector} .${ir}${o}.xterm-dim { color: ${ke.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Lo}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${ir}257 { color: ${ke.opaque(e.background).css}; }${this._terminalSelector} .${ir}257.xterm-dim { color: ${ke.multiplyOpacity(ke.opaque(e.background),.5).css}; }${this._terminalSelector} .${Lo}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 s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let d=i===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,d))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,r=1){let i=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}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 s=this._bufferService.buffer,r=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],d=s.lines.get(c);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,c,c===r,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Xr}${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,s,r,i,o){s<0&&(e=0),r<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=r;++g){let m=g+l.ydisp,x=this._rowElements[g],w=l.lines.get(m);if(!x||!w)break;x.replaceChildren(...this._rowFactory.createRow(w,m,m===h,d,_,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===r?t:i)-1:-1))}}};Ni=Le([G(7,Yi),G(8,Nr),G(9,st),G(10,tt),G(11,hs),G(12,Wt),G(13,ys)],Ni);var ji=class extends ue{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new lf(this._optionsService))}catch{this._measureStrategy=this._register(new af(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())}};ji=Le([G(2,st)],ji);var pl=class extends ue{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)}},af=class extends pl{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},lf=class extends pl{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}},cf=class extends ue{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hf(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ge.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ne(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}},hf=class extends ue{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new xs),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ee(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ne(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)}},df=class extends ue{constructor(){super(),this.linkProviders=[],this._register(Ee(()=>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 rn(e,t,s){let r=s.getBoundingClientRect(),i=e.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-o,t.clientY-r.top-a]}function uf(e,t,s,r,i,o,a,l,h){if(!o)return;let c=rn(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),r+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var Mi=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,i){return uf(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let s=rn(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Mi=Le([G(0,Ht),G(1,Nr)],Mi);var ff=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,s){this._rowCount=s,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=[]}},_l={};Sd(_l,{getSafariVersion:()=>_f,isChromeOS:()=>xl,isFirefox:()=>gl,isIpad:()=>gf,isIphone:()=>mf,isLegacyEdge:()=>pf,isLinux:()=>nn,isMac:()=>xr,isNode:()=>jr,isSafari:()=>ml,isWindows:()=>vl});var jr=typeof process<"u"&&"title"in process,zs=jr?"node":navigator.userAgent,Us=jr?"node":navigator.platform,gl=zs.includes("Firefox"),pf=zs.includes("Edge"),ml=/^((?!chrome|android).)*safari/i.test(zs);function _f(){if(!ml)return 0;let e=zs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var xr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Us),gf=Us==="iPad",mf=Us==="iPhone",vl=["Windows","Win16","Win32","WinCE"].includes(Us),nn=Us.indexOf("Linux")>=0,xl=/\bCrOS\b/.test(zs),yl=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},vf=class extends yl{_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())}}},xf=class extends yl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},yr=!jr&&"requestIdleCallback"in window?xf:vf,yf=class{constructor(){this._queue=new yr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Li=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new xs),this._pausedResizeTask=new yf,this._observerDisposable=this._register(new xs),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 q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ff((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new bf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ee(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.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(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ee(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(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 s;return(s=this._renderer.value)==null?void 0:s.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,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Li=Le([G(2,st),G(3,Nr),G(4,hs),G(5,Fs),G(6,tt),G(7,Wt),G(8,ys)],Li);var bf=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 Sf(e,t,s,r){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return kf(i,o,e,t,s,r)+Mr(o,t,s,r)+Ef(i,o,e,t,s,r);let a;if(o===t)return a=i>e?"D":"C",Ws(Math.abs(i-e),Is(a,r));a=o>t?"D":"C";let l=Math.abs(o-t),h=Cf(o>t?e:i,s)+(l-1)*s.cols+1+wf(o>t?i:e);return Ws(h,Is(a,r))}function wf(e,t){return e-1}function Cf(e,t){return t.cols-e}function kf(e,t,s,r,i,o){return Mr(t,r,i,o).length===0?"":Ws(Sl(e,t,e,t-cs(t,i),!1,i).length,Is("D",o))}function Mr(e,t,s,r){let i=e-cs(e,s),o=t-cs(t,s),a=Math.abs(i-o)-Nf(e,t,s);return Ws(a,Is(bl(e,t),r))}function Ef(e,t,s,r,i,o){let a;Mr(t,r,i,o).length>0?a=r-cs(r,i):a=t;let l=r,h=jf(e,t,s,r,i,o);return Ws(Sl(e,a,s,l,h==="C",i).length,Is(h,o))}function Nf(e,t,s){var a;let r=0,i=e-cs(e,s),o=t-cs(t,s);for(let l=0;l=0&&e0?a=r-cs(r,i):a=t,e=s&&at?"A":"B"}function Sl(e,t,s,r,i,o){let a=e,l=t,h="";for(;(a!==s||l!==r)&&l>=0&&lo.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!i&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function Is(e,t){let s=t?"O":"[";return $.ESC+s+e}function Ws(e,t){e=Math.floor(e);let s="";for(let r=0;rthis._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 To(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 Yr=50,Lf=15,Tf=50,Rf=500,Bf=" ",Df=new RegExp(Bf,"g"),Ti=class extends ue{constructor(e,t,s,r,i,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Mf(this._bufferService),this._activeSelectionMode=0,this._register(Ee(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]i.replace(Df," ")).join(vl?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),rn&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var i,o;let s=(o=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Lo(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=sn(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Yr),Yr),t/=Yr,t/Math.abs(t)+Math.round(t*(Lf-1)))}shouldForceSelection(e){return xr?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(),Tf)}_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&&!(xr&&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 s=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 s=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&t!==r&&(s+=i-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(e[1]);if(!o)return;let a=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,d=0,_=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h1&&(g+=k-1,h+=k-1);w>0&&l>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):P>1&&(_+=P-1,l-=P-1),l--,w--}for(;E1&&(g+=P-1,h+=P-1),h++,E++}}h++;let m=l+c-u+_,x=Math.min(this._bufferService.cols,h-l+u+d-_-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let k=this._bufferService.cols-E.start;m-=k,x+=k}}}if(r&&m+x===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(x+=E.length)}}return{start:m,length:x}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=Lo(s,this._bufferService.cols)}};Ti=Le([G(3,tt),G(4,hs),G(5,Yi),G(6,st),G(7,Ht),G(8,Wt)],Ti);var To=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ro=class{constructor(){this._color=new To,this._css=new To}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ie=Object.freeze((()=>{let e=[je.toColor("#2e3436"),je.toColor("#cc0000"),je.toColor("#4e9a06"),je.toColor("#c4a000"),je.toColor("#3465a4"),je.toColor("#75507b"),je.toColor("#06989a"),je.toColor("#d3d7cf"),je.toColor("#555753"),je.toColor("#ef2929"),je.toColor("#8ae234"),je.toColor("#fce94f"),je.toColor("#729fcf"),je.toColor("#ad7fa8"),je.toColor("#34e2e2"),je.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],i=t[s/6%6|0],o=t[s%6];e.push({css:Ae.toCss(r,i,o),rgba:Ae.toRgba(r,i,o)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:Ae.toCss(r,r,r),rgba:Ae.toRgba(r,r,r)})}return e})()),rs=je.toColor("#ffffff"),Ts=je.toColor("#000000"),Bo=je.toColor("#ffffff"),Do=Ts,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pf=rs,Ri=class extends ue{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ro,this._halfContrastCache=new Ro,this._onChangeColors=this._register(new V),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rs,background:Ts,cursor:Bo,cursorAccent:Do,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:ke.blend(Ts,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:ke.blend(Ts,ks),scrollbarSliderBackground:ke.opacity(rs,.2),scrollbarSliderHoverBackground:ke.opacity(rs,.4),scrollbarSliderActiveBackground:ke.opacity(rs,.5),overviewRulerBorder:rs,ansi:Ie.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=Se(e.foreground,rs),t.background=Se(e.background,Ts),t.cursor=ke.blend(t.background,Se(e.cursor,Bo)),t.cursorAccent=ke.blend(t.background,Se(e.cursorAccent,Do)),t.selectionBackgroundTransparent=Se(e.selectionBackground,ks),t.selectionBackgroundOpaque=ke.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Se(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ke.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Se(e.selectionForeground,No):void 0,t.selectionForeground===No&&(t.selectionForeground=void 0),ke.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ke.opacity(t.selectionBackgroundTransparent,.3)),ke.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ke.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Se(e.scrollbarSliderBackground,ke.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Se(e.scrollbarSliderHoverBackground,ke.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Se(e.scrollbarSliderActiveBackground,ke.opacity(t.foreground,.5)),t.overviewRulerBorder=Se(e.overviewRulerBorder,Pf),t.ansi=Ie.slice(),t.ansi[0]=Se(e.black,Ie[0]),t.ansi[1]=Se(e.red,Ie[1]),t.ansi[2]=Se(e.green,Ie[2]),t.ansi[3]=Se(e.yellow,Ie[3]),t.ansi[4]=Se(e.blue,Ie[4]),t.ansi[5]=Se(e.magenta,Ie[5]),t.ansi[6]=Se(e.cyan,Ie[6]),t.ansi[7]=Se(e.white,Ie[7]),t.ansi[8]=Se(e.brightBlack,Ie[8]),t.ansi[9]=Se(e.brightRed,Ie[9]),t.ansi[10]=Se(e.brightGreen,Ie[10]),t.ansi[11]=Se(e.brightYellow,Ie[11]),t.ansi[12]=Se(e.brightBlue,Ie[12]),t.ansi[13]=Se(e.brightMagenta,Ie[13]),t.ansi[14]=Se(e.brightCyan,Ie[14]),t.ansi[15]=Se(e.brightWhite,Ie[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;ro.index-a.index),r=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);r.push(a)}let i=s.length>0?s[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},If={trace:0,debug:1,info:2,warn:3,error:4,off:5},Wf="xterm.js: ",Bi=class extends ue{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=If[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=t-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*he+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*he+0]=t|2097152|s[2]<<22):this._data[t*he+0]=s[1].charCodeAt(0)|s[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 s=this._data[t*he+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*he+0]&2097152}getString(t){let s=this._data[t*he+0];return s&2097152?this._combined[t]:s&2097151?Xt(s&2097151):""}isProtected(t){return this._data[t*he+2]&536870912}loadCell(t,s){return or=t*he,s.content=this._data[or+0],s.fg=this._data[or+1],s.bg=this._data[or+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*he+0]=s.content,this._data[t*he+1]=s.fg,this._data[t*he+2]=s.bg}setCellFromCodepoint(t,s,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*he+0]=s|r<<22,this._data[t*he+1]=i.fg,this._data[t*he+2]=i.bg}addCodepointToCell(t,s,r){let i=this._data[t*he+0];i&2097152?this._combined[t]+=Xt(s):i&2097151?(this._combined[t]=Xt(i&2097151)+Xt(s),i&=-2097152,i|=2097152):i=s|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*he+0]=i}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s=0;--o)this.setCell(t+s+o,this.loadCell(t+o,i));for(let o=0;othis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*Gr=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,s,r,i,o){let a=t._data;if(o)for(let h=i-1;h>=0;h--){for(let c=0;c=s&&(this._combined[c-s+r]=t._combined[c])}}translateToString(t,s,r,i){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s>22||1}return i&&i.push(s),o}};function Hf(e,t,s,r,i,o){let a=[];for(let l=0;l=l&&r0&&(w>d||u[w].getTrimmedLength()===0);w--)x++;x>0&&(a.push(l+u.length-x),a.push(x)),l+=u.length-1}return a}function $f(e,t){let s=[],r=0,i=t[r],o=0;for(let a=0;aHs(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;lh&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;r.push(u),l+=u}return r}function Hs(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?s-1:s}var Cl=class kl{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=kl._nextId++,this._onDispose=this.register(new V),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ls(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Cl._nextId=1;var Uf=Cl,He={},is=He.B;He[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:"≥","{":"π","|":"≠","}":"£","~":"·"};He.A={"#":"£"};He.B=void 0;He[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};He.C=He[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};He.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};He.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};He.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};He.E=He[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};He.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};He.H=He[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ao=4294967295,Oo=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Pe.clone(),this.savedCharset=is,this.markers=[],this._nullCell=mt.fromCharData([0,Fa,1,0]),this._whitespaceCell=mt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new yr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Po(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 gr),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 gr),this._whitespaceCell}getBlankLine(e,t){return new Rs(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&&eAo?Ao:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Pe);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 Po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Pe),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),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 Rs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}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 s=this._optionsService.rawOptions.reflowCursorLine,r=Hf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Pe),s);if(r.length>0){let i=$f(this.lines,r);Ff(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(Pe),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let P=this.ybase+this.y;if(P>=a&&P0&&(i.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=u.length-1,x=u[m];x===0&&(m--,x=u[m]);let w=h.length-d-1,E=c;for(;w>=0;){let P=Math.min(E,x);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[w],E-P,x-P,P,!0),x-=P,x===0&&(m--,x=u[m]),E-=P,E===0){w--;let A=Math.max(w,0);E=Hs(h,A,this._cols)}}for(let P=0;P0;)this.ybase===0?this.y0){let a=[],l=[];for(let x=0;x=0;x--)if(d&&d.start>c+_){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(x--,d.newLines[w]);x++,a.push({index:c+1,amount:d.newLines.length}),_+=d.newLines.length,d=i[++u]}else this.lines.set(x,l[c--]);let g=0;for(let x=a.length-1;x>=0;x--)a[x].index+=g,this.lines.onInsertEmitter.fire(a[x]),g+=a[x].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,r){let i=this.lines.get(e);return i?i.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+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-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Kf=class extends ue{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new V),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 Oo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Oo(!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)}},El=2,Nl=1,Di=class extends ue{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new V),this.onResize=this._onResize.event,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,El),this.rows=Math.max(e.rawOptions.rows||0,Nl),this.buffers=this._register(new Kf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(o+1,0,r.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Di=Le([G(0,st)],Di);var gs={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:xr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Vf=["normal","bold","100","200","300","400","500","600","700","800","900"],qf=class extends ue{constructor(e){super(),this._onOptionChange=this._register(new V),this.onOptionChange=this._onOptionChange.event;let t={...gs};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=gs[e]),!Xf(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=gs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Vf.includes(t)?t:gs[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 Xf(e){return e==="block"||e==="underline"||e==="bar"}function Bs(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&Bs(e[r],t-1);return s}var Io=Object.freeze({insertMode:!1}),Wo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Pi=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new V),this.onData=this._onData.event,this._onUserInput=this._register(new V),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new V),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new V),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}reset(){this.modes=Bs(Io),this.decPrivateModes=Bs(Wo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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))}};Pi=Le([G(0,tt),G(1,qa),G(2,st)],Pi);var Ho={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 Jr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Zr=String.fromCharCode,$o={DEFAULT:e=>{let t=[Jr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Zr(t[0])}${Zr(t[1])}${Zr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.x};${e.y}${t}`}},Ai=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new V),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Ho))this.addProtocol(r,Ho[r]);for(let r of Object.keys($o))this.addEncoding(r,$o[r]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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,s){if(s){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)}};Ai=Le([G(0,tt),G(1,hs),G(2,st)],Ai);var Qr=[[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]],Yf=[[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]],We;function Gf(e,t){let s=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let i=os.extractWidth(t);i===0?r=!1:i>s&&(s=i)}return os.createPropertyValue(0,s,r)}},os=class pr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new V,this.onChange=this._onChange.event;let t=new Jf;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,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?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 s=0,r=0,i=t.length;for(let o=0;o=i)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,r),h=pr.extractWidth(l);pr.extractShouldJoin(l)&&(h-=pr.extractWidth(r)),s+=h,r=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Zf=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 Fo(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Es=2147483647,Qf=256,jl=class Oi{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Qf)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Oi;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r>8,i=this._subParamsIdx[s]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>Es?Es: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>Es?Es:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s>8,i=this._subParamsIdx[s]&255;i-r>0&&(t[s]=this._subParams.slice(r,i))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[s-1];r[s-1]=~i?Math.min(i*10+t,Es):t}},Ns=[],ep=class{constructor(){this._state=0,this._active=Ns,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=Ns}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=Ns,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ns,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Ns,this._id=-1,this._state=0}}},ct=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},js=[],tp=class{constructor(){this._handlers=Object.create(null),this._active=js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=js,this._ident=0}},Ds=new jl;Ds.addParam(0);var zo=class{constructor(e){this._handler=e,this._data="",this._params=Ds,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ds,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._params=Ds,this._data="",this._hitLimit=!1,s));return this._params=Ds,this._data="",this._hitLimit=!1,t}},sp=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let i=0;ih),s=(l,h)=>t.slice(l,h),r=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(r,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_t,0,2,0),e.add(_t,8,5,8),e.add(_t,6,0,6),e.add(_t,11,0,11),e.add(_t,13,13,13),e})(),ip=class extends ue{constructor(e=rp){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 jl,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ep),this._dcsParser=this._register(new tp),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 i=0;io||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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,s,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,s){let r=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===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 l=o;l>4){case 2:for(let _=l+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,i,l),a;c<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(a=u[d](),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(4,u,d,i,l),a;d<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<_t){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<_t){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},np=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,op=/^[\da-f]+$/;function Uo(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=np.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),op.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(t.slice(s*i,s*i+s),16);r[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return r}}function ei(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function ap(e,t=16){let[s,r,i]=e;return`rgb:${ei(s,t)}/${ei(r,t)}/${ei(i,t)}`}var lp={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,Ko=10;function Vo(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 qo=5e3,Xo=0,cp=class extends ue{constructor(e,t,s,r,i,o,a,l,h=new ip){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Nd,this._utf8Decoder=new jd,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone(),this._onRequestBell=this._register(new V),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new V),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new V),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new V),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new V),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new V),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new V),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new V),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new V),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new V),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new V),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new V),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new V),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 Ii(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(W.BEL,()=>this.bell()),this._parser.setExecuteHandler(W.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(W.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(W.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(W.BS,()=>this.backspace()),this._parser.setExecuteHandler(W.HT,()=>this.tab()),this._parser.setExecuteHandler(W.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(W.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ur.IND,()=>this.index()),this._parser.setExecuteHandler(ur.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ur.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ct(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new ct(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new ct(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new ct(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new ct(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new ct(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new ct(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new ct(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new ct(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new ct(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new ct(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new ct(c=>this.restoreCursorColor(c))),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 c in He)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new zo((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),qo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.lengthqt)for(let c=o;c0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let g=t;gl){if(h){let E=d,k=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&d instanceof Rs&&d.copyCellsFrom(E,k,0,w,!1);k=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(l-1)===2&&d.setCellFromCodepoint(l-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>Vo(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new zo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ct(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,s,r=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&r.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 h=l;for(let c=1;c0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(W.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(W.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(W.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(W.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(W.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,d=this._optionsService.rawOptions,_=(x,w)=>(a.triggerDataEvent(`${W.ESC}[${t?"":"?"}${x};${w}$y`),!0),g=x=>x?1:2,m=e.params[0];return t?m===2?_(m,4):m===4?_(m,g(a.modes.insertMode)):m===12?_(m,3):m===20?_(m,g(d.convertEol)):_(m,0):m===1?_(m,g(r.applicationCursorKeys)):m===3?_(m,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?_(m,g(r.origin)):m===7?_(m,g(r.wraparound)):m===8?_(m,3):m===9?_(m,g(i==="X10")):m===12?_(m,g(d.cursorBlink)):m===25?_(m,g(!a.isCursorHidden)):m===45?_(m,g(r.reverseWraparound)):m===66?_(m,g(r.applicationKeypad)):m===67?_(m,4):m===1e3?_(m,g(i==="VT200")):m===1002?_(m,g(i==="DRAG")):m===1003?_(m,g(i==="ANY")):m===1004?_(m,g(r.sendFocus)):m===1005?_(m,4):m===1006?_(m,g(o==="SGR")):m===1015?_(m,4):m===1016?_(m,g(o==="SGR_PIXELS")):m===1048?_(m,1):m===47||m===1047||m===1049?_(m,g(c===u)):m===2004?_(m,g(r.bracketedPasteMode)):m===2026?_(m,g(r.synchronizedOutput)):_(m,0)}_updateAttrColor(e,t,s,r,i){return t===2?(e|=50331648,e&=-16777216,e|=$s.fromColorRGB([s,r,i])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],i=0,o=0;do{if(r[o+i]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do r[1]===5&&(i=1),r[o+l+1+i]=a[l];while(++l=2||r[1]===2&&o+i>=5)break;r[1]&&(i=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Pe.fg,e.bg=Pe.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,s,r=this._curAttrData;for(let i=0;i=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=Pe.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=Pe.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(e,i,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=Pe.fg&16777215,r.bg&=-67108864,r.bg|=Pe.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${W.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${W.ESC}[?${t};${s}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=Pe.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Vo(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(`${W.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ko&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ko&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),i=s.shift();if(/^\d+$/.exec(r)){let o=parseInt(r);if(Yo(o))if(i==="?")t.push({type:0,index:o});else{let a=Uo(i);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(r=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,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 s=e.split(";");for(let r=0;r=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=Uo(s[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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=[],s=e.split(";");for(let r=0;r=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=Pe.clone(),this._eraseAttrDataInternal=Pe.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 mt;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(`${W.ESC}${a}${W.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ii=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&&(Xo=e,e=t,t=Xo),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ii=Le([G(0,tt)],Ii);function Yo(e){return 0<=e&&e<256}var hp=5e7,Go=12,dp=50,up=class extends ue{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 V),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>hp)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let a=l=>performance.now()-s>=Go?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Go)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dp&&(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()}},Wi=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 l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}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 s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wi=Le([G(0,tt)],Wi);var Jo=!1,fp=class extends ue{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new xs),this._onBinary=this._register(new V),this.onBinary=this._onBinary.event,this._onData=this._register(new V),this.onData=this._onData.event,this._onLineFeed=this._register(new V),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new V),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new V),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new V),this._instantiationService=new Of,this.optionsService=this._register(new qf(e)),this._instantiationService.setService(st,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Di)),this._instantiationService.setService(tt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Bi)),this._instantiationService.setService(qa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Pi)),this._instantiationService.setService(hs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ai)),this._instantiationService.setService(Va,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(os)),this._instantiationService.setService(Rd,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Zf),this._instantiationService.setService(Td,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wi),this._instantiationService.setService(Xa,this._oscLinkService),this._inputHandler=this._register(new cp(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ge.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ge.forward(this._bufferService.onResize,this._onResize)),this._register(Ge.forward(this.coreService.onData,this._onData)),this._register(Ge.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 up((t,s)=>this._inputHandler.parse(t,s))),this._register(Ge.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new V),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&&!Jo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Jo=!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,El),t=Math.max(t,Nl),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(Fo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Fo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ee(()=>{for(let t of e)t.dispose()})}}},pp={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 _p(e,t,s,r){var a;let i={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?i.key=W.ESC+"OA":i.key=W.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=W.ESC+"OD":i.key=W.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=W.ESC+"OC":i.key=W.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=W.ESC+"OB":i.key=W.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":W.DEL,e.altKey&&(i.key=W.ESC+i.key);break;case 9:if(e.shiftKey){i.key=W.ESC+"[Z";break}i.key=W.HT,i.cancel=!0;break;case 13:i.key=e.altKey?W.ESC+W.CR:W.CR,i.cancel=!0;break;case 27:i.key=W.ESC,e.altKey&&(i.key=W.ESC+W.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"D":t?i.key=W.ESC+"OD":i.key=W.ESC+"[D";break;case 39:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"C":t?i.key=W.ESC+"OC":i.key=W.ESC+"[C";break;case 38:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"A":t?i.key=W.ESC+"OA":i.key=W.ESC+"[A";break;case 40:if(e.metaKey)break;o?i.key=W.ESC+"[1;"+(o+1)+"B":t?i.key=W.ESC+"OB":i.key=W.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=W.ESC+"[2~");break;case 46:o?i.key=W.ESC+"[3;"+(o+1)+"~":i.key=W.ESC+"[3~";break;case 36:o?i.key=W.ESC+"[1;"+(o+1)+"H":t?i.key=W.ESC+"OH":i.key=W.ESC+"[H";break;case 35:o?i.key=W.ESC+"[1;"+(o+1)+"F":t?i.key=W.ESC+"OF":i.key=W.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=W.ESC+"[5;"+(o+1)+"~":i.key=W.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=W.ESC+"[6;"+(o+1)+"~":i.key=W.ESC+"[6~";break;case 112:o?i.key=W.ESC+"[1;"+(o+1)+"P":i.key=W.ESC+"OP";break;case 113:o?i.key=W.ESC+"[1;"+(o+1)+"Q":i.key=W.ESC+"OQ";break;case 114:o?i.key=W.ESC+"[1;"+(o+1)+"R":i.key=W.ESC+"OR";break;case 115:o?i.key=W.ESC+"[1;"+(o+1)+"S":i.key=W.ESC+"OS";break;case 116:o?i.key=W.ESC+"[15;"+(o+1)+"~":i.key=W.ESC+"[15~";break;case 117:o?i.key=W.ESC+"[17;"+(o+1)+"~":i.key=W.ESC+"[17~";break;case 118:o?i.key=W.ESC+"[18;"+(o+1)+"~":i.key=W.ESC+"[18~";break;case 119:o?i.key=W.ESC+"[19;"+(o+1)+"~":i.key=W.ESC+"[19~";break;case 120:o?i.key=W.ESC+"[20;"+(o+1)+"~":i.key=W.ESC+"[20~";break;case 121:o?i.key=W.ESC+"[21;"+(o+1)+"~":i.key=W.ESC+"[21~";break;case 122:o?i.key=W.ESC+"[23;"+(o+1)+"~":i.key=W.ESC+"[23~";break;case 123:o?i.key=W.ESC+"[24;"+(o+1)+"~":i.key=W.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=W.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=W.DEL:e.keyCode===219?i.key=W.ESC:e.keyCode===220?i.key=W.FS:e.keyCode===221&&(i.key=W.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let l=(a=pp[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)i.key=W.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),i.key=W.ESC+c}else if(e.keyCode===32)i.key=W.ESC+(e.ctrlKey?W.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),i.key=W.ESC+h,i.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=W.US),e.key==="@"&&(i.key=W.NUL));break}return i}var Be=0,gp=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new yr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new yr,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((i,o)=>this._getKey(i)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[i]=e[t],t++):r[i]=this._array[s++];this._array=r,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||(Be=this._search(t),Be===-1)||this._getKey(this._array[Be])!==t)return!1;do if(this._array[Be]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Be),!0;while(++Bei-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Be=this._search(e),!(Be<0||Be>=this._array.length)&&this._getKey(this._array[Be])===e))do yield this._array[Be];while(++Be=this._array.length)&&this._getKey(this._array[Be])===e))do t(this._array[Be]);while(++Be=t;){let r=t+s>>1,i=this._getKey(this._array[r]);if(i>e)s=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ti=0,Zo=0,mp=class extends ue{constructor(){super(),this._decorations=new gp(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new V),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new V),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new vp(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,i=0;for(let o of this._decorations.getKeyIterator(t))r=o.options.x??0,i=r+(o.options.width??1),e>=r&&e{ti=i.options.x??0,Zo=ti+(i.options.width??1),e>=ti&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,o=this._debounceThresholdMS-i;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)}},Qo=20,br=class extends ue{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yp(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(ne(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ee(()=>{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===Qo+1&&(this._liveRegion.textContent+=ni.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let i=e;i<=t;i++){let o=s.lines.get(s.ydisp+i),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||e.relatedTarget!==r)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 l;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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let i=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let g=c<_.length?_[c]:_.slice(-1)[0]+1;return g>=this._terminal.cols&&(++d,g=0),{row:d,column:g}},o=i(t),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.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;ls(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(ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ne(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 s=e.composedPath();for(let r=0;r{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;re?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){i.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),i=!1;for(let a=0;athis._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;athis._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&bp(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,ls(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 s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.pointerCursor},set:s=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.underline},set:s=>{var r,i,o;(r=this._currentLink)!=null&&r.state&&((o=(i=this._currentLink)==null?void 0:i.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return s<=i&&i<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,i){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:i}}};Hi=Le([G(1,Yi),G(2,Ht),G(3,tt),G(4,Ga)],Hi);function bp(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 Sp=class extends fp{constructor(e={}){super(e),this._linkifier=this._register(new xs),this.browser=_l,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xs),this._onCursorMove=this._register(new V),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new V),this.onKey=this._onKey.event,this._onRender=this._register(new V),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new V),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new V),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new V),this.onBell=this._onBell.event,this._onFocus=this._register(new V),this._onBlur=this._register(new V),this._onA11yCharEmitter=this._register(new V),this._onA11yTabEmitter=this._register(new V),this._onWillOpen=this._register(new V),this._setup(),this._decorationService=this._instantiationService.createInstance(mp),this._instantiationService.setService(Fs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(df),this._instantiationService.setService(Ga,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ai)),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(Ge.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ge.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ge.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ge.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ee(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let i=ke.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${W.ESC}]${r};${ap(i)}${fl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ae.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ae.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(br,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.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(W.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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ne(this.element,"copy",t=>{this.hasSelection()&&kd(t,this._selectionService)}));let e=t=>Ed(t,this.textarea,this.coreService,this.optionsService);this._register(ne(this.textarea,"paste",e)),this._register(ne(this.element,"paste",e)),gl?this._register(ne(this.element,"mousedown",t=>{t.button===2&&lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ne(this.element,"contextmenu",t=>{lo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),rn&&this._register(ne(this.element,"auxclick",t=>{t.button===1&&$a(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(ne(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 s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ii.get()),xl||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(cf,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(ne(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ji,this._document,this._helperContainer),this._instantiationService.setService(Nr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ri),this._instantiationService.setService(ys,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vr),this._instantiationService.setService(Ya,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Li,this.rows,this.screenElement)),this._instantiationService.setService(Ht,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(ki,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mi),this._instantiationService.setService(Yi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hi,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(wi,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(Ti,this.element,this.screenElement,r)),this._instantiationService.setService(Dd,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(Ge.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ci,this.screenElement)),this._register(ne(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(br,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ni,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,d,_,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(_=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(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?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ne(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(ne(t,"wheel",o=>{var a,l,h,c,u;if(!r.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,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let d=W.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.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){Ha(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,s){this._selectionService.setSelection(e,t,s)}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 s;(s=this._selectionService)==null||s.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 s=_p(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===W.ETX||s.key===W.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(wp(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 s;(s=this._charSizeService)==null||s.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 s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},ea=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 kp(t)}getNullCell(){return new mt}},Ep=class extends ue{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new V),this.onBufferChange=this._onBufferChange.event,this._normal=new ea(this._core.buffers.normal,"normal"),this._alternate=new ea(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)}},Np=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.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)}},jp=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}},Mp=["cols","rows"],Et=0,Lp=class extends ue{constructor(e){super(),this._core=this._register(new Sp(e)),this._addonManager=this._register(new Cp),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(Mp.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 Np(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jp(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 Ep(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),nn&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var i,o;let s=(o=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=To(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=rn(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Yr),Yr),t/=Yr,t/Math.abs(t)+Math.round(t*(Lf-1)))}shouldForceSelection(e){return xr?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(),Tf)}_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&&!(xr&&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 s=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 s=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&t!==r&&(s+=i-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(e[1]);if(!o)return;let a=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,d=0,_=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h1&&(g+=k-1,h+=k-1);w>0&&l>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,w--):P>1&&(_+=P-1,l-=P-1),l--,w--}for(;E1&&(g+=P-1,h+=P-1),h++,E++}}h++;let m=l+c-u+_,x=Math.min(this._bufferService.cols,h-l+u+d-_-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let k=this._bufferService.cols-E.start;m-=k,x+=k}}}if(r&&m+x===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(x+=E.length)}}return{start:m,length:x}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=To(s,this._bufferService.cols)}};Ti=Le([G(3,tt),G(4,hs),G(5,Gi),G(6,st),G(7,Ht),G(8,Wt)],Ti);var Ro=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Bo=class{constructor(){this._color=new Ro,this._css=new Ro}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ie=Object.freeze((()=>{let e=[je.toColor("#2e3436"),je.toColor("#cc0000"),je.toColor("#4e9a06"),je.toColor("#c4a000"),je.toColor("#3465a4"),je.toColor("#75507b"),je.toColor("#06989a"),je.toColor("#d3d7cf"),je.toColor("#555753"),je.toColor("#ef2929"),je.toColor("#8ae234"),je.toColor("#fce94f"),je.toColor("#729fcf"),je.toColor("#ad7fa8"),je.toColor("#34e2e2"),je.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],i=t[s/6%6|0],o=t[s%6];e.push({css:Ae.toCss(r,i,o),rgba:Ae.toRgba(r,i,o)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:Ae.toCss(r,r,r),rgba:Ae.toRgba(r,r,r)})}return e})()),rs=je.toColor("#ffffff"),Ts=je.toColor("#000000"),Do=je.toColor("#ffffff"),Po=Ts,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pf=rs,Ri=class extends ue{constructor(e){super(),this._optionsService=e,this._contrastCache=new Bo,this._halfContrastCache=new Bo,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rs,background:Ts,cursor:Do,cursorAccent:Po,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:ke.blend(Ts,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:ke.blend(Ts,ks),scrollbarSliderBackground:ke.opacity(rs,.2),scrollbarSliderHoverBackground:ke.opacity(rs,.4),scrollbarSliderActiveBackground:ke.opacity(rs,.5),overviewRulerBorder:rs,ansi:Ie.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=Se(e.foreground,rs),t.background=Se(e.background,Ts),t.cursor=ke.blend(t.background,Se(e.cursor,Do)),t.cursorAccent=ke.blend(t.background,Se(e.cursorAccent,Po)),t.selectionBackgroundTransparent=Se(e.selectionBackground,ks),t.selectionBackgroundOpaque=ke.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Se(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ke.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Se(e.selectionForeground,jo):void 0,t.selectionForeground===jo&&(t.selectionForeground=void 0),ke.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ke.opacity(t.selectionBackgroundTransparent,.3)),ke.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ke.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Se(e.scrollbarSliderBackground,ke.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Se(e.scrollbarSliderHoverBackground,ke.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Se(e.scrollbarSliderActiveBackground,ke.opacity(t.foreground,.5)),t.overviewRulerBorder=Se(e.overviewRulerBorder,Pf),t.ansi=Ie.slice(),t.ansi[0]=Se(e.black,Ie[0]),t.ansi[1]=Se(e.red,Ie[1]),t.ansi[2]=Se(e.green,Ie[2]),t.ansi[3]=Se(e.yellow,Ie[3]),t.ansi[4]=Se(e.blue,Ie[4]),t.ansi[5]=Se(e.magenta,Ie[5]),t.ansi[6]=Se(e.cyan,Ie[6]),t.ansi[7]=Se(e.white,Ie[7]),t.ansi[8]=Se(e.brightBlack,Ie[8]),t.ansi[9]=Se(e.brightRed,Ie[9]),t.ansi[10]=Se(e.brightGreen,Ie[10]),t.ansi[11]=Se(e.brightYellow,Ie[11]),t.ansi[12]=Se(e.brightBlue,Ie[12]),t.ansi[13]=Se(e.brightMagenta,Ie[13]),t.ansi[14]=Se(e.brightCyan,Ie[14]),t.ansi[15]=Se(e.brightWhite,Ie[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;ro.index-a.index),r=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);r.push(a)}let i=s.length>0?s[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},If={trace:0,debug:1,info:2,warn:3,error:4,off:5},Wf="xterm.js: ",Bi=class extends ue{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=If[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=t-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*he+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*he+0]=t|2097152|s[2]<<22):this._data[t*he+0]=s[1].charCodeAt(0)|s[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 s=this._data[t*he+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*he+0]&2097152}getString(t){let s=this._data[t*he+0];return s&2097152?this._combined[t]:s&2097151?Xt(s&2097151):""}isProtected(t){return this._data[t*he+2]&536870912}loadCell(t,s){return or=t*he,s.content=this._data[or+0],s.fg=this._data[or+1],s.bg=this._data[or+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*he+0]=s.content,this._data[t*he+1]=s.fg,this._data[t*he+2]=s.bg}setCellFromCodepoint(t,s,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*he+0]=s|r<<22,this._data[t*he+1]=i.fg,this._data[t*he+2]=i.bg}addCodepointToCell(t,s,r){let i=this._data[t*he+0];i&2097152?this._combined[t]+=Xt(s):i&2097151?(this._combined[t]=Xt(i&2097151)+Xt(s),i&=-2097152,i|=2097152):i=s|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*he+0]=i}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s=0;--o)this.setCell(t+s+o,this.loadCell(t+o,i));for(let o=0;othis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*Gr=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,s,r,i,o){let a=t._data;if(o)for(let h=i-1;h>=0;h--){for(let c=0;c=s&&(this._combined[c-s+r]=t._combined[c])}}translateToString(t,s,r,i){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s>22||1}return i&&i.push(s),o}};function Hf(e,t,s,r,i,o){let a=[];for(let l=0;l=l&&r0&&(w>d||u[w].getTrimmedLength()===0);w--)x++;x>0&&(a.push(l+u.length-x),a.push(x)),l+=u.length-1}return a}function $f(e,t){let s=[],r=0,i=t[r],o=0;for(let a=0;aHs(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;lh&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;r.push(u),l+=u}return r}function Hs(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?s-1:s}var Cl=class kl{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=kl._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ls(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Cl._nextId=1;var Uf=Cl,He={},is=He.B;He[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:"≥","{":"π","|":"≠","}":"£","~":"·"};He.A={"#":"£"};He.B=void 0;He[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};He.C=He[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};He.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};He.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};He.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};He.E=He[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};He.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};He.H=He[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};He["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Oo=4294967295,Io=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Pe.clone(),this.savedCharset=is,this.markers=[],this._nullCell=mt.fromCharData([0,Fa,1,0]),this._whitespaceCell=mt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new yr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ao(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 gr),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 gr),this._whitespaceCell}getBlankLine(e,t){return new Rs(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&&eOo?Oo:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Pe);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 Ao(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Pe),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),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 Rs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}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 s=this._optionsService.rawOptions.reflowCursorLine,r=Hf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Pe),s);if(r.length>0){let i=$f(this.lines,r);Ff(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(Pe),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let P=this.ybase+this.y;if(P>=a&&P0&&(i.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=u.length-1,x=u[m];x===0&&(m--,x=u[m]);let w=h.length-d-1,E=c;for(;w>=0;){let P=Math.min(E,x);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[w],E-P,x-P,P,!0),x-=P,x===0&&(m--,x=u[m]),E-=P,E===0){w--;let O=Math.max(w,0);E=Hs(h,O,this._cols)}}for(let P=0;P0;)this.ybase===0?this.y0){let a=[],l=[];for(let x=0;x=0;x--)if(d&&d.start>c+_){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(x--,d.newLines[w]);x++,a.push({index:c+1,amount:d.newLines.length}),_+=d.newLines.length,d=i[++u]}else this.lines.set(x,l[c--]);let g=0;for(let x=a.length-1;x>=0;x--)a[x].index+=g,this.lines.onInsertEmitter.fire(a[x]),g+=a[x].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,r){let i=this.lines.get(e);return i?i.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+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-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.lines.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Kf=class extends ue{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new q),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 Io(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Io(!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)}},El=2,Nl=1,Di=class extends ue{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,El),this.rows=Math.max(e.rawOptions.rows||0,Nl),this.buffers=this._register(new Kf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(o+1,0,r.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Di=Le([G(0,st)],Di);var gs={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:xr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Vf=["normal","bold","100","200","300","400","500","600","700","800","900"],qf=class extends ue{constructor(e){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let t={...gs};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in gs))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=gs[e]),!Xf(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=gs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Vf.includes(t)?t:gs[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 Xf(e){return e==="block"||e==="underline"||e==="bar"}function Bs(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&Bs(e[r],t-1);return s}var Wo=Object.freeze({insertMode:!1}),Ho=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Pi=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Bs(Wo),this.decPrivateModes=Bs(Ho)}reset(){this.modes=Bs(Wo),this.decPrivateModes=Bs(Ho)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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))}};Pi=Le([G(0,tt),G(1,qa),G(2,st)],Pi);var $o={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 Jr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Zr=String.fromCharCode,Fo={DEFAULT:e=>{let t=[Jr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Zr(t[0])}${Zr(t[1])}${Zr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jr(e,!0)};${e.x};${e.y}${t}`}},Ai=class extends ue{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new q),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys($o))this.addProtocol(r,$o[r]);for(let r of Object.keys(Fo))this.addEncoding(r,Fo[r]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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,s){if(s){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)}};Ai=Le([G(0,tt),G(1,hs),G(2,st)],Ai);var Qr=[[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]],Yf=[[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]],We;function Gf(e,t){let s=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let i=os.extractWidth(t);i===0?r=!1:i>s&&(s=i)}return os.createPropertyValue(0,s,r)}},os=class pr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new q,this.onChange=this._onChange.event;let t=new Jf;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,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?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 s=0,r=0,i=t.length;for(let o=0;o=i)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,r),h=pr.extractWidth(l);pr.extractShouldJoin(l)&&(h-=pr.extractWidth(r)),s+=h,r=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Zf=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 zo(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Es=2147483647,Qf=256,jl=class Oi{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Qf)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Oi;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r>8,i=this._subParamsIdx[s]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>Es?Es: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>Es?Es:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s>8,i=this._subParamsIdx[s]&255;i-r>0&&(t[s]=this._subParams.slice(r,i))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[s-1];r[s-1]=~i?Math.min(i*10+t,Es):t}},Ns=[],ep=class{constructor(){this._state=0,this._active=Ns,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=Ns}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=Ns,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ns,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Ns,this._id=-1,this._state=0}}},ct=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},js=[],tp=class{constructor(){this._handlers=Object.create(null),this._active=js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Er(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=js,this._ident=0}},Ds=new jl;Ds.addParam(0);var Uo=class{constructor(e){this._handler=e,this._data="",this._params=Ds,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ds,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Er(e,t,s),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(s=>(this._params=Ds,this._data="",this._hitLimit=!1,s));return this._params=Ds,this._data="",this._hitLimit=!1,t}},sp=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let i=0;ih),s=(l,h)=>t.slice(l,h),r=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(r,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_t,0,2,0),e.add(_t,8,5,8),e.add(_t,6,0,6),e.add(_t,11,0,11),e.add(_t,13,13,13),e})(),ip=class extends ue{constructor(e=rp){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 jl,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ep),this._dcsParser=this._register(new tp),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 i=0;io||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,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,s,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,s){let r=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===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 l=o;l>4){case 2:for(let _=l+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<_t){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,i,l),a;c<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(a=u[d](),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(4,u,d,i,l),a;d<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<_t){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<_t){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,i,l),a;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},np=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,op=/^[\da-f]+$/;function Ko(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=np.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),op.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(t.slice(s*i,s*i+s),16);r[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return r}}function ei(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function ap(e,t=16){let[s,r,i]=e;return`rgb:${ei(s,t)}/${ei(r,t)}/${ei(i,t)}`}var lp={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,Vo=10;function qo(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 Xo=5e3,Yo=0,cp=class extends ue{constructor(e,t,s,r,i,o,a,l,h=new ip){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Nd,this._utf8Decoder=new jd,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 Ii(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:d})}),this._parser.setDcsHandlerFallback((c,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:d})}),this._parser.setPrintHandler((c,u,d)=>this.print(c,u,d)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ur.IND,()=>this.index()),this._parser.setExecuteHandler(ur.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ur.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ct(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new ct(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new ct(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new ct(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new ct(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new ct(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new ct(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new ct(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new ct(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new ct(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new ct(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new ct(c=>this.restoreCursorColor(c))),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 c in He)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Uo((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Xo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Xo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.lengthqt)for(let c=o;c0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let g=t;gl){if(h){let E=d,k=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&d instanceof Rs&&d.copyCellsFrom(E,k,0,w,!1);k=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(d.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(u)),d.getWidth(l-1)===2&&d.setCellFromCodepoint(l-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>qo(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Uo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ct(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,s,r=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&r.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 h=l;for(let c=1;c0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent($.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent($.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent($.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent($.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent($.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,d=this._optionsService.rawOptions,_=(x,w)=>(a.triggerDataEvent(`${$.ESC}[${t?"":"?"}${x};${w}$y`),!0),g=x=>x?1:2,m=e.params[0];return t?m===2?_(m,4):m===4?_(m,g(a.modes.insertMode)):m===12?_(m,3):m===20?_(m,g(d.convertEol)):_(m,0):m===1?_(m,g(r.applicationCursorKeys)):m===3?_(m,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?_(m,g(r.origin)):m===7?_(m,g(r.wraparound)):m===8?_(m,3):m===9?_(m,g(i==="X10")):m===12?_(m,g(d.cursorBlink)):m===25?_(m,g(!a.isCursorHidden)):m===45?_(m,g(r.reverseWraparound)):m===66?_(m,g(r.applicationKeypad)):m===67?_(m,4):m===1e3?_(m,g(i==="VT200")):m===1002?_(m,g(i==="DRAG")):m===1003?_(m,g(i==="ANY")):m===1004?_(m,g(r.sendFocus)):m===1005?_(m,4):m===1006?_(m,g(o==="SGR")):m===1015?_(m,4):m===1016?_(m,g(o==="SGR_PIXELS")):m===1048?_(m,1):m===47||m===1047||m===1049?_(m,g(c===u)):m===2004?_(m,g(r.bracketedPasteMode)):m===2026?_(m,g(r.synchronizedOutput)):_(m,0)}_updateAttrColor(e,t,s,r,i){return t===2?(e|=50331648,e&=-16777216,e|=$s.fromColorRGB([s,r,i])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],i=0,o=0;do{if(r[o+i]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do r[1]===5&&(i=1),r[o+l+1+i]=a[l];while(++l=2||r[1]===2&&o+i>=5)break;r[1]&&(i=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Pe.fg,e.bg=Pe.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,s,r=this._curAttrData;for(let i=0;i=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=Pe.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=Pe.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(e,i,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=Pe.fg&16777215,r.bg&=-67108864,r.bg|=Pe.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${t};${s}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=Pe.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!qo(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(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Vo&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Vo&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),i=s.shift();if(/^\d+$/.exec(r)){let o=parseInt(r);if(Go(o))if(i==="?")t.push({type:0,index:o});else{let a=Ko(i);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(r=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,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 s=e.split(";");for(let r=0;r=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=Ko(s[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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=[],s=e.split(";");for(let r=0;r=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=Pe.clone(),this._eraseAttrDataInternal=Pe.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 mt;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(`${$.ESC}${a}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ii=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&&(Yo=e,e=t,t=Yo),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ii=Le([G(0,tt)],Ii);function Go(e){return 0<=e&&e<256}var hp=5e7,Jo=12,dp=50,up=class extends ue{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 q),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>hp)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let a=l=>performance.now()-s>=Jo?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Jo)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dp&&(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()}},Wi=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 l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}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 s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Wi=Le([G(0,tt)],Wi);var Zo=!1,fp=class extends ue{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new xs),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new Of,this.optionsService=this._register(new qf(e)),this._instantiationService.setService(st,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Di)),this._instantiationService.setService(tt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Bi)),this._instantiationService.setService(qa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Pi)),this._instantiationService.setService(hs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ai)),this._instantiationService.setService(Va,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(os)),this._instantiationService.setService(Rd,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Zf),this._instantiationService.setService(Td,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wi),this._instantiationService.setService(Xa,this._oscLinkService),this._inputHandler=this._register(new cp(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ge.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ge.forward(this._bufferService.onResize,this._onResize)),this._register(Ge.forward(this.coreService.onData,this._onData)),this._register(Ge.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 up((t,s)=>this._inputHandler.parse(t,s))),this._register(Ge.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),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&&!Zo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Zo=!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,El),t=Math.max(t,Nl),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(zo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(zo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ee(()=>{for(let t of e)t.dispose()})}}},pp={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 _p(e,t,s,r){var a;let i={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?i.key=$.ESC+"OA":i.key=$.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=$.ESC+"OD":i.key=$.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=$.ESC+"OC":i.key=$.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=$.ESC+"OB":i.key=$.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+"[Z";break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;o?i.key=$.ESC+"[1;"+(o+1)+"D":t?i.key=$.ESC+"OD":i.key=$.ESC+"[D";break;case 39:if(e.metaKey)break;o?i.key=$.ESC+"[1;"+(o+1)+"C":t?i.key=$.ESC+"OC":i.key=$.ESC+"[C";break;case 38:if(e.metaKey)break;o?i.key=$.ESC+"[1;"+(o+1)+"A":t?i.key=$.ESC+"OA":i.key=$.ESC+"[A";break;case 40:if(e.metaKey)break;o?i.key=$.ESC+"[1;"+(o+1)+"B":t?i.key=$.ESC+"OB":i.key=$.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+"[2~");break;case 46:o?i.key=$.ESC+"[3;"+(o+1)+"~":i.key=$.ESC+"[3~";break;case 36:o?i.key=$.ESC+"[1;"+(o+1)+"H":t?i.key=$.ESC+"OH":i.key=$.ESC+"[H";break;case 35:o?i.key=$.ESC+"[1;"+(o+1)+"F":t?i.key=$.ESC+"OF":i.key=$.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+"[5;"+(o+1)+"~":i.key=$.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+"[6;"+(o+1)+"~":i.key=$.ESC+"[6~";break;case 112:o?i.key=$.ESC+"[1;"+(o+1)+"P":i.key=$.ESC+"OP";break;case 113:o?i.key=$.ESC+"[1;"+(o+1)+"Q":i.key=$.ESC+"OQ";break;case 114:o?i.key=$.ESC+"[1;"+(o+1)+"R":i.key=$.ESC+"OR";break;case 115:o?i.key=$.ESC+"[1;"+(o+1)+"S":i.key=$.ESC+"OS";break;case 116:o?i.key=$.ESC+"[15;"+(o+1)+"~":i.key=$.ESC+"[15~";break;case 117:o?i.key=$.ESC+"[17;"+(o+1)+"~":i.key=$.ESC+"[17~";break;case 118:o?i.key=$.ESC+"[18;"+(o+1)+"~":i.key=$.ESC+"[18~";break;case 119:o?i.key=$.ESC+"[19;"+(o+1)+"~":i.key=$.ESC+"[19~";break;case 120:o?i.key=$.ESC+"[20;"+(o+1)+"~":i.key=$.ESC+"[20~";break;case 121:o?i.key=$.ESC+"[21;"+(o+1)+"~":i.key=$.ESC+"[21~";break;case 122:o?i.key=$.ESC+"[23;"+(o+1)+"~":i.key=$.ESC+"[23~";break;case 123:o?i.key=$.ESC+"[24;"+(o+1)+"~":i.key=$.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let l=(a=pp[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)i.key=$.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),i.key=$.ESC+c}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),i.key=$.ESC+h,i.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=$.US),e.key==="@"&&(i.key=$.NUL));break}return i}var Be=0,gp=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new yr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new yr,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((i,o)=>this._getKey(i)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[i]=e[t],t++):r[i]=this._array[s++];this._array=r,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||(Be=this._search(t),Be===-1)||this._getKey(this._array[Be])!==t)return!1;do if(this._array[Be]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Be),!0;while(++Bei-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Be=this._search(e),!(Be<0||Be>=this._array.length)&&this._getKey(this._array[Be])===e))do yield this._array[Be];while(++Be=this._array.length)&&this._getKey(this._array[Be])===e))do t(this._array[Be]);while(++Be=t;){let r=t+s>>1,i=this._getKey(this._array[r]);if(i>e)s=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ti=0,Qo=0,mp=class extends ue{constructor(){super(),this._decorations=new gp(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new vp(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,i=0;for(let o of this._decorations.getKeyIterator(t))r=o.options.x??0,i=r+(o.options.width??1),e>=r&&e{ti=i.options.x??0,Qo=ti+(i.options.width??1),e>=ti&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,o=this._debounceThresholdMS-i;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)}},ea=20,br=class extends ue{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yp(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(ne(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ee(()=>{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===ea+1&&(this._liveRegion.textContent+=ni.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let i=e;i<=t;i++){let o=s.lines.get(s.ydisp+i),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",r),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||e.relatedTarget!==r)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 l;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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let i=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let g=c<_.length?_[c]:_.slice(-1)[0]+1;return g>=this._terminal.cols&&(++d,g=0),{row:d,column:g}},o=i(t),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.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;ls(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(ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ne(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 s=e.composedPath();for(let r=0;r{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(d=>({link:d}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;re?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){i.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),i=!1;for(let a=0;athis._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;athis._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&bp(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,ls(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 s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.pointerCursor},set:s=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,r;return(r=(s=this._currentLink)==null?void 0:s.state)==null?void 0:r.decorations.underline},set:s=>{var r,i,o;(r=this._currentLink)!=null&&r.state&&((o=(i=this._currentLink)==null?void 0:i.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,s){var r;(r=this._currentLink)!=null&&r.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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return s<=i&&i<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,i){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:i}}};Hi=Le([G(1,Gi),G(2,Ht),G(3,tt),G(4,Ga)],Hi);function bp(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 Sp=class extends fp{constructor(e={}){super(e),this._linkifier=this._register(new xs),this.browser=_l,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xs),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(mp),this._instantiationService.setService(Fs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(df),this._instantiationService.setService(Ga,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ai)),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(Ge.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ge.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ge.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ge.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ee(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let i=ke.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${$.ESC}]${r};${ap(i)}${fl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ae.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ae.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(br,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ne(this.element,"copy",t=>{this.hasSelection()&&kd(t,this._selectionService)}));let e=t=>Ed(t,this.textarea,this.coreService,this.optionsService);this._register(ne(this.textarea,"paste",e)),this._register(ne(this.element,"paste",e)),gl?this._register(ne(this.element,"mousedown",t=>{t.button===2&&co(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ne(this.element,"contextmenu",t=>{co(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nn&&this._register(ne(this.element,"auxclick",t=>{t.button===1&&$a(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(ne(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 s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ii.get()),xl||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(cf,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(ne(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ji,this._document,this._helperContainer),this._instantiationService.setService(Nr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ri),this._instantiationService.setService(ys,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vr),this._instantiationService.setService(Ya,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Li,this.rows,this.screenElement)),this._instantiationService.setService(Ht,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(ki,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mi),this._instantiationService.setService(Gi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hi,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(wi,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(Ti,this.element,this.screenElement,r)),this._instantiationService.setService(Dd,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(Ge.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Ci,this.screenElement)),this._register(ne(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(br,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(mr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ni,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,d,_,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(_=(d=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(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?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ne(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(ne(t,"wheel",o=>{var a,l,h,c,u;if(!r.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,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let d=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.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){Ha(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,s){this._selectionService.setSelection(e,t,s)}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 s;(s=this._selectionService)==null||s.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 s=_p(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===$.ETX||s.key===$.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(wp(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 s;(s=this._charSizeService)==null||s.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 s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},ta=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 kp(t)}getNullCell(){return new mt}},Ep=class extends ue{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new ta(this._core.buffers.normal,"normal"),this._alternate=new ta(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)}},Np=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.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)}},jp=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}},Mp=["cols","rows"],Et=0,Lp=class extends ue{constructor(e){super(),this._core=this._register(new Sp(e)),this._addonManager=this._register(new Cp),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(Mp.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 Np(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jp(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 Ep(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 ii.get()},set promptLabel(e){ii.set(e)},get tooMuchOutput(){return ni.get()},set tooMuchOutput(e){ni.set(e)}}}_verifyIntegers(...e){for(Et of e)if(Et===1/0||isNaN(Et)||Et%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Et of e)if(Et&&(Et===1/0||isNaN(Et)||Et%1!==0||Et<0))throw new Error("This API only accepts positive integers")}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT @@ -128,5 +128,5 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Tp=2,Rp=1,Bp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=r-l,u=i-h-t;return{cols:Math.max(Tp,Math.floor(u/e.css.cell.width)),rows:Math.max(Rp,Math.floor(c/e.css.cell.height))}}};function Dp({sessionId:e}){const t=v.useRef(null),s=v.useRef(null),r=v.useRef(null),i=v.useRef(wr()).current;return v.useEffect(()=>{if(!t.current)return;const o=new Lp({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#7dd3fc",selectionBackground:"#334155"}}),a=new Bp;o.loadAddon(a),o.open(t.current),a.fit(),s.current=o,r.current=a,kc(e,c=>o.write(c));const l=navigator.platform.startsWith("Mac");o.attachCustomKeyEventHandler(c=>{const u=l?c.metaKey:c.ctrlKey;if(u&&c.key==="c"||c.ctrlKey&&c.shiftKey&&c.key==="C"){const d=o.getSelection();return d?(navigator.clipboard.writeText(d),!1):!l}return u&&c.key==="v"||c.ctrlKey&&c.shiftKey&&c.key==="V"?(navigator.clipboard.readText().then(d=>{d&&i.sendCliAgentInput(e,d)}),!1):!0}),o.onData(c=>{i.sendCliAgentInput(e,c)});const h=new ResizeObserver(()=>{a.fit(),i.sendCliAgentResize(e,o.cols,o.rows)});return h.observe(t.current),i.sendCliAgentResize(e,o.cols,o.rows),()=>{Ec(e),h.disconnect(),o.dispose(),s.current=null,r.current=null}},[e,i]),n.jsx("div",{ref:t,className:"flex-1 min-h-0",style:{padding:"4px"}})}function Pp(){return crypto.randomUUID()}function Ap(){const e=v.useRef(wr()).current,t=v.useRef(null),s=v.useRef(!1),[r,i]=v.useState(250),[o,a]=v.useState(280),[l,h]=v.useState(!1),c=ye(p=>p.openTabs),{explorerFile:u}=et(),{availableAgents:d,selectedAgentId:_,sessionId:g,status:m,exitCode:x,events:w,setAvailableAgents:E,setSelectedAgentId:k,setSessionId:P,setStatus:A,setExitCode:D,addEvent:N}=Ms();v.useEffect(()=>{ad().then(p=>E(p))},[E]);const $=d.filter(p=>p.installed),B=()=>{var b;if(!_)return;const p=Pp(),f=((b=$.find(y=>y.id===_))==null?void 0:b.name)??_;P(p),A("running"),D(null),h(!1),e.sendCliAgentStart(_,p,120,40),N({type:"session",timestamp:Date.now(),agentName:f,action:"started"})},T=()=>{var p;if(g){const f=((p=$.find(b=>b.id===_))==null?void 0:p.name)??_??"Unknown";e.sendCliAgentStop(g),N({type:"session",timestamp:Date.now(),agentName:f,action:"stopped"}),A("idle"),P(null)}},O=v.useCallback(p=>{p.preventDefault(),s.current=!0;const f="touches"in p?p.touches[0].clientY:p.clientY,b=r,y=M=>{if(!s.current)return;const z=t.current;if(!z)return;const C="touches"in M?M.touches[0].clientY:M.clientY,H=z.clientHeight-100,U=Math.max(100,Math.min(H,b-(C-f)));i(U)},j=()=>{s.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[r]),L=v.useCallback(p=>{p.preventDefault();const f="touches"in p?p.touches[0].clientX:p.clientX,b=o,y=M=>{const z="touches"in M?M.touches[0].clientX:M.clientX,C=Math.max(180,Math.min(500,b-(z-f)));a(C)},j=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",j),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j)},[o]),R=c.length>0||!!u;return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{ref:t,className:"flex flex-col flex-1 min-w-0",children:[n.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:R?n.jsx(yd,{}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a file to view"})}),!l&&n.jsx("div",{onMouseDown:O,onTouchStart:O,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"shrink-0 flex flex-col overflow-hidden",style:{height:l?32:r,borderTop:"1px solid var(--border)",background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3",style:{height:32,borderBottom:l?"none":"1px solid var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("button",{onClick:()=>h(!l),className:"shrink-0 flex items-center justify-center",style:{width:18,height:18,border:"none",background:"none",color:"var(--text-muted)",cursor:"pointer"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:l?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M6 9l6 6 6-6"})})}),n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold shrink-0",style:{color:"var(--text-muted)"},children:"Terminal"}),n.jsxs("select",{value:_??"",onChange:p=>k(p.target.value),disabled:m==="running",style:{fontSize:11,padding:"2px 4px",borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-primary)",color:"var(--text-primary)",cursor:m==="running"?"not-allowed":"pointer",opacity:m==="running"?.6:1,maxWidth:160},children:[$.length===0&&n.jsx("option",{value:"",children:"No agents found"}),$.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))]}),m==="idle"||m==="exited"?n.jsx("button",{onClick:B,disabled:!_||$.length===0,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:_?"var(--accent)":"var(--bg-primary)",color:_?"#fff":"var(--text-muted)",cursor:_?"pointer":"not-allowed",fontWeight:500},children:m==="exited"?"Restart":"Start"}):n.jsx("button",{onClick:T,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:"#ef4444",color:"#fff",cursor:"pointer",fontWeight:500},children:"Stop"}),n.jsx("span",{className:"ml-auto",style:{width:6,height:6,borderRadius:"50%",background:m==="running"?"#4ade80":m==="exited"?"#ef4444":"var(--text-muted)"}})]}),!l&&n.jsx("div",{className:"flex-1 min-h-0",children:g&&m==="running"?n.jsx(Dp,{sessionId:g}):n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:$.length===0?"No CLI agents detected. Install Claude Code, Codex, or GitHub Copilot CLI.":m==="exited"?`Process exited${x!==null?` (code ${x})`:""}. Click Restart.`:"Select an agent and click Start."})})})]})]}),n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:o,background:"var(--bg-primary)",borderLeft:"1px solid var(--border)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center px-3 h-10 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold",style:{color:"var(--text-muted)"},children:"Events"}),n.jsx("span",{className:"ml-1 text-[11px]",style:{color:"var(--text-muted)"},children:w.length>0&&w.length})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:w.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:"No events yet"})}):n.jsx("div",{className:"py-1",children:w.map((p,f)=>n.jsx(Op,{event:p},f))})})]})]})}function ar({dot:e,label:t,detail:s,time:r,children:i}){const[o,a]=v.useState(!1),l=!!i;return n.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)",cursor:l?"pointer":void 0},onClick:l?()=>a(!o):void 0,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"shrink-0",style:{width:6,height:6,borderRadius:"50%",background:e}}),n.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--text-primary)"},children:t}),s&&n.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:s}),n.jsx("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--text-muted)"},children:r})]}),o&&i]})}function Op({event:e}){const t=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(e.type==="mcp_tool_call"){const i=Object.keys(e.args).length>0;return n.jsx(ar,{dot:"#a78bfa",label:e.tool,time:t,children:i&&n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:Object.entries(e.args).map(([o,a])=>n.jsxs("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:[o,"=",JSON.stringify(a)]},o))})})}if(e.type==="run_lifecycle"){const i=e.status==="running"?"#facc15":e.status==="completed"?"#4ade80":e.status==="failed"?"#ef4444":"var(--text-muted)";return n.jsx(ar,{dot:i,label:e.entrypoint,detail:e.status,time:t})}if(e.type==="files_changed"){const i=`${e.files.length} file${e.files.length!==1?"s":""} changed`;return n.jsx(ar,{dot:"#60a5fa",label:i,time:t,children:n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:e.files.map(o=>n.jsx("div",{className:"text-xs truncate",style:{color:"var(--text-primary)"},children:o},o))})})}const s=e.action==="started"?"#4ade80":e.action==="exited"?"#ef4444":"var(--text-muted)",r=e.action+(e.action==="exited"&&e.exitCode!==void 0?` (${e.exitCode})`:"");return n.jsx(ar,{dot:s,label:e.agentName,detail:r,time:t})}function Ip(){const e=Mc(),t=Bc(),[s,r]=v.useState(!1),[i,o]=v.useState(248),[a,l]=v.useState(!1),{runs:h,selectedRunId:c,setRuns:u,upsertRun:d,selectRun:_,setTraces:g,setLogs:m,setChatMessages:x,setEntrypoints:w,setStateEvents:E,setGraphCache:k,setActiveNode:P,removeActiveNode:A}=de(),{section:D,view:N,runId:$,setupEntrypoint:B,setupMode:T,evalCreating:O,evalSetId:L,evalRunId:R,evalRunItemName:p,evaluatorCreateType:f,evaluatorId:b,evaluatorFilter:y,navigate:j}=et(),{setEvalSets:M,setEvaluators:z,setLocalEvaluators:C,setEvalRuns:H}=xe();v.useEffect(()=>{D==="debug"&&N==="details"&&$&&$!==c&&_($)},[D,N,$,c,_]);const U=da(Z=>Z.init),q=ua(Z=>Z.init);v.useEffect(()=>{wc().then(u).catch(console.error),$i().then(Z=>w(Z.map(me=>me.name))).catch(console.error),U(),q()},[u,w,U,q]),v.useEffect(()=>{D==="evals"&&(ga().then(Z=>M(Z)).catch(console.error),Fc().then(Z=>H(Z)).catch(console.error)),(D==="evals"||D==="evaluators")&&(Ac().then(Z=>z(Z)).catch(console.error),Vi().then(Z=>C(Z)).catch(console.error))},[D,M,z,C,H]);const ee=xe(Z=>Z.evalSets),ie=xe(Z=>Z.evalRuns);v.useEffect(()=>{if(D!=="evals"||O||L||R)return;const Z=Object.values(ie).sort((dt,ve)=>new Date(ve.start_time??0).getTime()-new Date(dt.start_time??0).getTime());if(Z.length>0){j(`#/evals/runs/${Z[0].id}`);return}const me=Object.values(ee);me.length>0&&j(`#/evals/sets/${me[0].id}`)},[D,O,L,R,ie,ee,j]),v.useEffect(()=>{const Z=me=>{me.key==="Escape"&&s&&r(!1)};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[s]);const F=c?h[c]:null,se=v.useCallback((Z,me)=>{d(me),g(Z,me.traces),m(Z,me.logs);const dt=me.messages.map(ve=>{const vt=ve.contentParts??ve.content_parts??[],xt=ve.toolCalls??ve.tool_calls??[];return{message_id:ve.messageId??ve.message_id,role:ve.role??"assistant",content:vt.filter(ot=>{const ut=ot.mimeType??ot.mime_type??"";return ut.startsWith("text/")||ut==="application/json"}).map(ot=>{const ut=ot.data;return(ut==null?void 0:ut.inline)??""}).join(` -`).trim()??"",tool_calls:xt.length>0?xt.map(ot=>({name:ot.name??"",has_result:!!ot.result})):void 0}});if(x(Z,dt),me.graph&&me.graph.nodes.length>0&&k(Z,me.graph),me.states&&me.states.length>0&&(E(Z,me.states.map(ve=>({node_name:ve.node_name,qualified_node_name:ve.qualified_node_name,phase:ve.phase,timestamp:new Date(ve.timestamp).getTime(),payload:ve.payload}))),me.status!=="completed"&&me.status!=="failed"))for(const ve of me.states)ve.phase==="started"?P(Z,ve.node_name,ve.qualified_node_name):ve.phase==="completed"&&A(Z,ve.node_name)},[d,g,m,x,E,k,P,A]);v.useEffect(()=>{if(!c)return;e.subscribe(c),Ir(c).then(me=>se(c,me)).catch(console.error);const Z=setTimeout(()=>{const me=de.getState().runs[c];me&&(me.status==="pending"||me.status==="running")&&Ir(c).then(dt=>se(c,dt)).catch(console.error)},2e3);return()=>{clearTimeout(Z),e.unsubscribe(c)}},[c,e,se]);const pe=v.useRef(null);v.useEffect(()=>{var dt,ve;if(!c)return;const Z=F==null?void 0:F.status,me=pe.current;if(pe.current=Z??null,Z&&(Z==="completed"||Z==="failed")&&me!==Z){const vt=de.getState(),xt=((dt=vt.traces[c])==null?void 0:dt.length)??0,ot=((ve=vt.logs[c])==null?void 0:ve.length)??0,ut=(F==null?void 0:F.trace_count)??0,Ks=(F==null?void 0:F.log_count)??0;(xtse(c,Bt)).catch(console.error)}},[c,F==null?void 0:F.status,se]);const _e=Z=>{j(`#/debug/runs/${Z}/traces`),_(Z),r(!1)},qe=Z=>{j(`#/debug/runs/${Z}/traces`),_(Z),r(!1)},St=()=>{j("#/debug/new"),r(!1)},ht=Z=>{Z==="debug"?j("#/debug/new"):Z==="evals"?j("#/evals"):Z==="evaluators"?j("#/evaluators"):Z==="explorer"&&j("#/explorer")},ge=v.useCallback(Z=>{Z.preventDefault(),l(!0);const me="touches"in Z?Z.touches[0].clientX:Z.clientX,dt=i,ve=xt=>{const ot="touches"in xt?xt.touches[0].clientX:xt.clientX,ut=Math.max(200,Math.min(480,dt+(ot-me)));o(ut)},vt=()=>{l(!1),document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",vt),document.removeEventListener("touchmove",ve),document.removeEventListener("touchend",vt),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",ve),document.addEventListener("mouseup",vt),document.addEventListener("touchmove",ve,{passive:!1}),document.addEventListener("touchend",vt)},[i]),$t=()=>D==="explorer"?n.jsx(Ap,{}):D==="evals"?O?n.jsx(Zn,{}):R?n.jsx(Fh,{evalRunId:R,itemName:p}):L?n.jsx(Ih,{evalSetId:L}):n.jsx(Zn,{}):D==="evaluators"?f?n.jsx(td,{category:f}):n.jsx(Jh,{evaluatorId:b,evaluatorFilter:y}):N==="new"?n.jsx(Zc,{}):N==="setup"&&B&&T?n.jsx(_h,{entrypoint:B,mode:T,ws:e,onRunCreated:_e,isMobile:t}):F?n.jsx(Dh,{run:F,ws:e,isMobile:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"});return t?n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden relative",children:[!s&&n.jsx("button",{onClick:()=>r(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),n.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),n.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>r(!1)}),n.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[n.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[n.jsxs("button",{onClick:()=>{j("#/debug/new"),r(!1)},className:"flex items-center gap-2 cursor-pointer",style:{background:"none",border:"none"},children:[n.jsx("img",{src:"/favicon.ico",width:"14",height:"14",alt:"UiPath"}),n.jsx("span",{className:"text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Developer Console"})]}),n.jsx("button",{onClick:()=>r(!1),className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(Vn,{}),D==="evaluators"&&n.jsx(Qn,{}),D==="explorer"&&n.jsx(to,{})]})]}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]}):n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsxs("aside",{className:"shrink-0 flex flex-col",style:{width:i,background:"var(--sidebar-bg)"},children:[n.jsxs("div",{className:"flex h-10 border-b shrink-0",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>j("#/debug/new"),className:"w-12 shrink-0 flex items-center justify-center cursor-pointer transition-colors border-r",style:{background:"var(--activity-bar-bg)",border:"none",borderRight:"1px solid var(--border)"},onMouseEnter:Z=>{Z.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:Z=>{Z.currentTarget.style.background="var(--activity-bar-bg)"},children:n.jsx("img",{src:"/favicon.ico",width:"20",height:"20",alt:"UiPath"})}),n.jsx("div",{className:"flex-1 flex items-center px-3",style:{background:"var(--sidebar-bg)"},children:n.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:D==="debug"?"Developer Console":D==="evals"?"Evaluations":D==="evaluators"?"Evaluators":"Explorer"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx(Pc,{section:D,onSectionChange:ht}),n.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[D==="debug"&&n.jsx(Cn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(Vn,{}),D==="evaluators"&&n.jsx(Qn,{}),D==="explorer"&&n.jsx(to,{})]})]})]}),n.jsx("div",{onMouseDown:ge,onTouchStart:ge,className:"shrink-0 drag-handle-col",style:a?{background:"var(--accent)"}:void 0}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(kn,{}),n.jsx($n,{}),n.jsx(Un,{})]})}lc.createRoot(document.getElementById("root")).render(n.jsx(v.StrictMode,{children:n.jsx(Ip,{})}));export{Ia as H,fd as j,de as u}; + */var Tp=2,Rp=1,Bp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=r-l,u=i-h-t;return{cols:Math.max(Tp,Math.floor(u/e.css.cell.width)),rows:Math.max(Rp,Math.floor(c/e.css.cell.height))}}};function Dp({sessionId:e}){const t=v.useRef(null),s=v.useRef(null),r=v.useRef(null),i=v.useRef(wr()).current;return v.useEffect(()=>{if(!t.current)return;const o=new Lp({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#7dd3fc",selectionBackground:"#334155"}}),a=new Bp;o.loadAddon(a),o.open(t.current),a.fit(),s.current=o,r.current=a,kc(e,c=>o.write(c));const l=navigator.platform.startsWith("Mac");o.attachCustomKeyEventHandler(c=>{const u=l?c.metaKey:c.ctrlKey;if(u&&c.key==="c"||c.ctrlKey&&c.shiftKey&&c.key==="C"){const d=o.getSelection();return d?(navigator.clipboard.writeText(d),!1):!l}return u&&c.key==="v"||c.ctrlKey&&c.shiftKey&&c.key==="V"?(navigator.clipboard.readText().then(d=>{d&&i.sendCliAgentInput(e,d)}),!1):!0}),o.onData(c=>{i.sendCliAgentInput(e,c)});const h=new ResizeObserver(()=>{a.fit(),i.sendCliAgentResize(e,o.cols,o.rows)});return h.observe(t.current),i.sendCliAgentResize(e,o.cols,o.rows),()=>{Ec(e),h.disconnect(),o.dispose(),s.current=null,r.current=null}},[e,i]),n.jsx("div",{ref:t,className:"flex-1 min-h-0",style:{padding:"4px"}})}function Pp(){return crypto.randomUUID()}function Ap(){const e=v.useRef(wr()).current,t=v.useRef(null),s=v.useRef(!1),[r,i]=v.useState(250),[o,a]=v.useState(280),[l,h]=v.useState(!1),c=ye(f=>f.openTabs),{explorerFile:u}=et(),{availableAgents:d,selectedAgentId:_,sessionId:g,status:m,exitCode:x,events:w,setAvailableAgents:E,setSelectedAgentId:k,setSessionId:P,setStatus:O,setExitCode:D,addEvent:j}=Ms();v.useEffect(()=>{ad().then(f=>E(f))},[E]);const F=d.filter(f=>f.installed),R=()=>{var b;if(!_)return;const f=Pp(),p=((b=F.find(y=>y.id===_))==null?void 0:b.name)??_;P(f),O("running"),D(null),h(!1),e.sendCliAgentStart(_,f,120,40),j({type:"session",timestamp:Date.now(),agentName:p,action:"started"})},T=()=>{var f;if(g){const p=((f=F.find(b=>b.id===_))==null?void 0:f.name)??_??"Unknown";e.sendCliAgentStop(g),j({type:"session",timestamp:Date.now(),agentName:p,action:"stopped"}),O("idle"),P(null)}},I=v.useCallback(f=>{f.preventDefault(),s.current=!0;const p="touches"in f?f.touches[0].clientY:f.clientY,b=r,y=M=>{if(!s.current)return;const U=t.current;if(!U)return;const C="touches"in M?M.touches[0].clientY:M.clientY,W=U.clientHeight-100,z=Math.max(100,Math.min(W,b-(C-p)));i(z)},N=()=>{s.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",N),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",N)},[r]),L=v.useCallback(f=>{f.preventDefault();const p="touches"in f?f.touches[0].clientX:f.clientX,b=o,y=M=>{const U="touches"in M?M.touches[0].clientX:M.clientX,C=Math.max(180,Math.min(500,b-(U-p)));a(C)},N=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",N),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",N),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",N)},[o]),B=c.length>0||!!u;return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{ref:t,className:"flex flex-col flex-1 min-w-0",children:[n.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:B?n.jsx(yd,{}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a file to view"})}),!l&&n.jsx("div",{onMouseDown:I,onTouchStart:I,className:"shrink-0 drag-handle-row"}),n.jsxs("div",{className:"shrink-0 flex flex-col overflow-hidden",style:{height:l?32:r,borderTop:"1px solid var(--border)",background:"var(--bg-primary)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3",style:{height:32,borderBottom:l?"none":"1px solid var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("button",{onClick:()=>h(!l),className:"shrink-0 flex items-center justify-center",style:{width:18,height:18,border:"none",background:"none",color:"var(--text-muted)",cursor:"pointer"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:l?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.15s"},children:n.jsx("path",{d:"M6 9l6 6 6-6"})})}),n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold shrink-0",style:{color:"var(--text-muted)"},children:"Terminal"}),n.jsxs("select",{value:_??"",onChange:f=>k(f.target.value),disabled:m==="running",style:{fontSize:11,padding:"2px 4px",borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-primary)",color:"var(--text-primary)",cursor:m==="running"?"not-allowed":"pointer",opacity:m==="running"?.6:1,maxWidth:160},children:[F.length===0&&n.jsx("option",{value:"",children:"No agents found"}),F.map(f=>n.jsx("option",{value:f.id,children:f.name},f.id))]}),m==="idle"||m==="exited"?n.jsx("button",{onClick:R,disabled:!_||F.length===0,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:_?"var(--accent)":"var(--bg-primary)",color:_?"#fff":"var(--text-muted)",cursor:_?"pointer":"not-allowed",fontWeight:500},children:m==="exited"?"Restart":"Start"}):n.jsx("button",{onClick:T,style:{fontSize:10,padding:"2px 8px",borderRadius:4,border:"none",background:"#ef4444",color:"#fff",cursor:"pointer",fontWeight:500},children:"Stop"}),n.jsx("span",{className:"ml-auto",style:{width:6,height:6,borderRadius:"50%",background:m==="running"?"#4ade80":m==="exited"?"#ef4444":"var(--text-muted)"}})]}),!l&&n.jsx("div",{className:"flex-1 min-h-0",children:g&&m==="running"?n.jsx(Dp,{sessionId:g}):n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:F.length===0?"No CLI agents detected. Install Claude Code, Codex, or GitHub Copilot CLI.":m==="exited"?`Process exited${x!==null?` (code ${x})`:""}. Click Restart.`:"Select an agent and click Start."})})})]})]}),n.jsx("div",{onMouseDown:L,onTouchStart:L,className:"shrink-0 drag-handle-col"}),n.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:o,background:"var(--bg-primary)",borderLeft:"1px solid var(--border)"},children:[n.jsxs("div",{className:"shrink-0 flex items-center px-3 h-10 border-b",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[n.jsx("span",{className:"text-[11px] uppercase tracking-wider font-semibold",style:{color:"var(--text-muted)"},children:"Events"}),n.jsx("span",{className:"ml-1 text-[11px]",style:{color:"var(--text-muted)"},children:w.length>0&&w.length})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:w.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:n.jsx("p",{className:"text-xs",children:"No events yet"})}):n.jsx("div",{className:"py-1",children:w.map((f,p)=>n.jsx(Op,{event:f},p))})})]})]})}function ar({dot:e,label:t,detail:s,time:r,children:i}){const[o,a]=v.useState(!1),l=!!i;return n.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)",cursor:l?"pointer":void 0},onClick:l?()=>a(!o):void 0,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"shrink-0",style:{width:6,height:6,borderRadius:"50%",background:e}}),n.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--text-primary)"},children:t}),s&&n.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:s}),n.jsx("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--text-muted)"},children:r})]}),o&&i]})}function Op({event:e}){const t=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(e.type==="mcp_tool_call"){const i=Object.keys(e.args).length>0;return n.jsx(ar,{dot:"#a78bfa",label:e.tool,time:t,children:i&&n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:Object.entries(e.args).map(([o,a])=>n.jsxs("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:[o,"=",JSON.stringify(a)]},o))})})}if(e.type==="run_lifecycle"){const i=e.status==="running"?"#facc15":e.status==="completed"?"#4ade80":e.status==="failed"?"#ef4444":"var(--text-muted)";return n.jsx(ar,{dot:i,label:e.entrypoint,detail:e.status,time:t})}if(e.type==="files_changed"){const i=`${e.files.length} file${e.files.length!==1?"s":""} changed`;return n.jsx(ar,{dot:"#60a5fa",label:i,time:t,children:n.jsx("div",{className:"mt-1",style:{marginLeft:14},children:e.files.map(o=>n.jsx("div",{className:"text-xs truncate",style:{color:"var(--text-primary)"},children:o},o))})})}const s=e.action==="started"?"#4ade80":e.action==="exited"?"#ef4444":"var(--text-muted)",r=e.action+(e.action==="exited"&&e.exitCode!==void 0?` (${e.exitCode})`:"");return n.jsx(ar,{dot:s,label:e.agentName,detail:r,time:t})}function Ip(){const e=Mc(),t=Bc(),[s,r]=v.useState(!1),[i,o]=v.useState(248),[a,l]=v.useState(!1),{runs:h,selectedRunId:c,setRuns:u,upsertRun:d,selectRun:_,setTraces:g,setLogs:m,setChatMessages:x,setEntrypoints:w,setStateEvents:E,setGraphCache:k,setActiveNode:P,removeActiveNode:O}=de(),{section:D,view:j,runId:F,setupEntrypoint:R,setupMode:T,evalCreating:I,evalSetId:L,evalRunId:B,evalRunItemName:f,evaluatorCreateType:p,evaluatorId:b,evaluatorFilter:y,navigate:N}=et(),{setEvalSets:M,setEvaluators:U,setLocalEvaluators:C,setEvalRuns:W}=me();v.useEffect(()=>{D==="debug"&&j==="details"&&F&&F!==c&&_(F)},[D,j,F,c,_]);const z=ua(Q=>Q.init),A=fa(Q=>Q.init);v.useEffect(()=>{wc().then(u).catch(console.error),$i().then(Q=>w(Q.map(ve=>ve.name))).catch(console.error),z(),A()},[u,w,z,A]),v.useEffect(()=>{D==="evals"&&(ga().then(Q=>M(Q)).catch(console.error),Fc().then(Q=>W(Q)).catch(console.error)),(D==="evals"||D==="evaluators")&&(Ac().then(Q=>U(Q)).catch(console.error),qi().then(Q=>C(Q)).catch(console.error))},[D,M,U,C,W]);const Z=me(Q=>Q.evalSets),ie=me(Q=>Q.evalRuns);v.useEffect(()=>{if(D!=="evals"||I||L||B)return;const Q=Object.values(ie).sort((dt,xe)=>new Date(xe.start_time??0).getTime()-new Date(dt.start_time??0).getTime());if(Q.length>0){N(`#/evals/runs/${Q[0].id}`);return}const ve=Object.values(Z);ve.length>0&&N(`#/evals/sets/${ve[0].id}`)},[D,I,L,B,ie,Z,N]),v.useEffect(()=>{const Q=ve=>{ve.key==="Escape"&&s&&r(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[s]);const K=c?h[c]:null,se=v.useCallback((Q,ve)=>{d(ve),g(Q,ve.traces),m(Q,ve.logs);const dt=ve.messages.map(xe=>{const vt=xe.contentParts??xe.content_parts??[],xt=xe.toolCalls??xe.tool_calls??[];return{message_id:xe.messageId??xe.message_id,role:xe.role??"assistant",content:vt.filter(ot=>{const ut=ot.mimeType??ot.mime_type??"";return ut.startsWith("text/")||ut==="application/json"}).map(ot=>{const ut=ot.data;return(ut==null?void 0:ut.inline)??""}).join(` +`).trim()??"",tool_calls:xt.length>0?xt.map(ot=>({name:ot.name??"",has_result:!!ot.result})):void 0}});if(x(Q,dt),ve.graph&&ve.graph.nodes.length>0&&k(Q,ve.graph),ve.states&&ve.states.length>0&&(E(Q,ve.states.map(xe=>({node_name:xe.node_name,qualified_node_name:xe.qualified_node_name,phase:xe.phase,timestamp:new Date(xe.timestamp).getTime(),payload:xe.payload}))),ve.status!=="completed"&&ve.status!=="failed"))for(const xe of ve.states)xe.phase==="started"?P(Q,xe.node_name,xe.qualified_node_name):xe.phase==="completed"&&O(Q,xe.node_name)},[d,g,m,x,E,k,P,O]);v.useEffect(()=>{if(!c)return;e.subscribe(c),Ir(c).then(ve=>se(c,ve)).catch(console.error);const Q=setTimeout(()=>{const ve=de.getState().runs[c];ve&&(ve.status==="pending"||ve.status==="running")&&Ir(c).then(dt=>se(c,dt)).catch(console.error)},2e3);return()=>{clearTimeout(Q),e.unsubscribe(c)}},[c,e,se]);const pe=v.useRef(null);v.useEffect(()=>{var dt,xe;if(!c)return;const Q=K==null?void 0:K.status,ve=pe.current;if(pe.current=Q??null,Q&&(Q==="completed"||Q==="failed")&&ve!==Q){const vt=de.getState(),xt=((dt=vt.traces[c])==null?void 0:dt.length)??0,ot=((xe=vt.logs[c])==null?void 0:xe.length)??0,ut=(K==null?void 0:K.trace_count)??0,Ks=(K==null?void 0:K.log_count)??0;(xtse(c,Bt)).catch(console.error)}},[c,K==null?void 0:K.status,se]);const _e=Q=>{N(`#/debug/runs/${Q}/traces`),_(Q),r(!1)},qe=Q=>{N(`#/debug/runs/${Q}/traces`),_(Q),r(!1)},St=()=>{N("#/debug/new"),r(!1)},ht=Q=>{Q==="debug"?N("#/debug/new"):Q==="evals"?N("#/evals"):Q==="evaluators"?N("#/evaluators"):Q==="explorer"&&N("#/explorer")},ge=v.useCallback(Q=>{Q.preventDefault(),l(!0);const ve="touches"in Q?Q.touches[0].clientX:Q.clientX,dt=i,xe=xt=>{const ot="touches"in xt?xt.touches[0].clientX:xt.clientX,ut=Math.max(200,Math.min(480,dt+(ot-ve)));o(ut)},vt=()=>{l(!1),document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",vt),document.removeEventListener("touchmove",xe),document.removeEventListener("touchend",vt),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",xe),document.addEventListener("mouseup",vt),document.addEventListener("touchmove",xe,{passive:!1}),document.addEventListener("touchend",vt)},[i]),$t=()=>D==="explorer"?n.jsx(Ap,{}):D==="evals"?I?n.jsx(Qn,{}):B?n.jsx(Fh,{evalRunId:B,itemName:f}):L?n.jsx(Ih,{evalSetId:L}):n.jsx(Qn,{}):D==="evaluators"?p?n.jsx(td,{category:p}):n.jsx(Jh,{evaluatorId:b,evaluatorFilter:y}):j==="new"?n.jsx(Zc,{}):j==="setup"&&R&&T?n.jsx(_h,{entrypoint:R,mode:T,ws:e,onRunCreated:_e,isMobile:t}):K?n.jsx(Dh,{run:K,ws:e,isMobile:t}):n.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"});return t?n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden relative",children:[!s&&n.jsx("button",{onClick:()=>r(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),n.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),n.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>r(!1)}),n.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[n.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[n.jsxs("button",{onClick:()=>{N("#/debug/new"),r(!1)},className:"flex items-center gap-2 cursor-pointer",style:{background:"none",border:"none"},children:[n.jsx("img",{src:"/favicon.ico",width:"14",height:"14",alt:"UiPath"}),n.jsx("span",{className:"text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Developer Console"})]}),n.jsx("button",{onClick:()=>r(!1),className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)",background:"transparent",border:"none"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D==="debug"&&n.jsx(kn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(qn,{}),D==="evaluators"&&n.jsx(eo,{}),D==="explorer"&&n.jsx(so,{})]})]}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(En,{}),n.jsx(Fn,{}),n.jsx(Kn,{})]}):n.jsxs("div",{className:"flex flex-col h-screen w-screen",children:[n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsxs("aside",{className:"shrink-0 flex flex-col",style:{width:i,background:"var(--sidebar-bg)"},children:[n.jsxs("div",{className:"flex h-10 border-b shrink-0",style:{borderColor:"var(--border)"},children:[n.jsx("button",{onClick:()=>N("#/debug/new"),className:"w-12 shrink-0 flex items-center justify-center cursor-pointer transition-colors border-r",style:{background:"var(--activity-bar-bg)",border:"none",borderRight:"1px solid var(--border)"},onMouseEnter:Q=>{Q.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:Q=>{Q.currentTarget.style.background="var(--activity-bar-bg)"},children:n.jsx("img",{src:"/favicon.ico",width:"20",height:"20",alt:"UiPath"})}),n.jsx("div",{className:"flex-1 flex items-center px-3",style:{background:"var(--sidebar-bg)"},children:n.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:D==="debug"?"Developer Console":D==="evals"?"Evaluations":D==="evaluators"?"Evaluators":"Explorer"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx(Pc,{section:D,onSectionChange:ht}),n.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[D==="debug"&&n.jsx(kn,{runs:Object.values(h),selectedRunId:c,onSelectRun:qe,onNewRun:St}),D==="evals"&&n.jsx(qn,{}),D==="evaluators"&&n.jsx(eo,{}),D==="explorer"&&n.jsx(so,{})]})]})]}),n.jsx("div",{onMouseDown:ge,onTouchStart:ge,className:"shrink-0 drag-handle-col",style:a?{background:"var(--accent)"}:void 0}),n.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$t()})]}),n.jsx(En,{}),n.jsx(Fn,{}),n.jsx(Kn,{})]})}lc.createRoot(document.getElementById("root")).render(n.jsx(v.StrictMode,{children:n.jsx(Ip,{})}));export{Ia as H,fd as j,de as u}; diff --git a/src/uipath/dev/server/static/index.html b/src/uipath/dev/server/static/index.html index 25f520a..54923d0 100644 --- a/src/uipath/dev/server/static/index.html +++ b/src/uipath/dev/server/static/index.html @@ -5,11 +5,11 @@ UiPath Developer Console - + - +
From 4419061883819f8421635314eb08bc0a665c6bd2 Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sat, 28 Mar 2026 23:52:08 +0200 Subject: [PATCH 05/12] feat: add eval MCP tools for listing and running evaluation sets Add five new MCP tools: - list_eval_sets: discover available evaluation sets - get_eval_set: get full eval set detail with items - run_eval_set: execute an eval set with streamed progress - list_eval_runs: list all eval run summaries - get_eval_run: get full eval run detail with per-item results Co-Authored-By: Claude Opus 4.6 (1M context) --- src/uipath/dev/mcp/__init__.py | 122 +++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/src/uipath/dev/mcp/__init__.py b/src/uipath/dev/mcp/__init__.py index 46d23fd..ffbeb35 100644 --- a/src/uipath/dev/mcp/__init__.py +++ b/src/uipath/dev/mcp/__init__.py @@ -191,6 +191,128 @@ async def get_run_status(run_id: str) -> dict[str, Any]: return resp.json() +@mcp.tool() +async def list_eval_sets() -> list[dict[str, Any]]: + """List all evaluation sets. + + Returns the available eval sets with their IDs, names, item counts, + and attached evaluator IDs. Use the returned IDs with run_eval_set. + """ + await _report_tool_call("list_eval_sets") + async with httpx.AsyncClient() as client: + resp = await client.get(_api_url("/eval-sets"), timeout=10) + resp.raise_for_status() + return resp.json() + + +@mcp.tool() +async def get_eval_set(eval_set_id: str) -> dict[str, Any]: + """Get full details of an evaluation set including all items. + + Args: + eval_set_id: ID of the eval set (from list_eval_sets). + + Returns the eval set with all items, their inputs, expected outputs, + and evaluation criteria. + """ + await _report_tool_call("get_eval_set", {"eval_set_id": eval_set_id}) + async with httpx.AsyncClient() as client: + resp = await client.get( + _api_url(f"/eval-sets/{eval_set_id}"), timeout=10 + ) + resp.raise_for_status() + return resp.json() + + +@mcp.tool() +async def run_eval_set( + eval_set_id: str, + ctx: Context, # type: ignore[type-arg] +) -> dict[str, Any]: + """Run an evaluation set against the agent. + + Args: + eval_set_id: ID of the eval set (from list_eval_sets). + + Starts the eval run and streams progress as each item completes. + Returns the full run result with per-item scores and overall score. + """ + await _report_tool_call("run_eval_set", {"eval_set_id": eval_set_id}) + async with httpx.AsyncClient() as client: + resp = await client.post( + _api_url(f"/eval-sets/{eval_set_id}/runs"), timeout=30 + ) + resp.raise_for_status() + run: dict[str, Any] = resp.json() + run_id = run["id"] + + await ctx.log("info", f"Eval run {run_id} created — streaming progress...") + + terminal_statuses = {"completed", "failed"} + + async with websockets.connect(_ws_url()) as ws: + async for raw in ws: + msg = json.loads(raw) + msg_type = msg.get("type", "") + payload = msg.get("payload", {}) + + if msg_type == "eval_run.progress" and payload.get("run_id") == run_id: + completed = payload.get("completed", 0) + total = payload.get("total", 0) + item = payload.get("item_result") + if item: + name = item.get("name", "") + status = item.get("status", "") + score = item.get("overall_score") + score_str = f" — score: {score:.0%}" if score is not None else "" + await ctx.log("info", f" [{completed}/{total}] {name}: {status}{score_str}") + await ctx.report_progress(progress=completed, total=total) + + elif msg_type == "eval_run.completed" and payload.get("run_id") == run_id: + overall = payload.get("overall_score") + if overall is not None: + await ctx.log("info", f"Eval run completed — overall score: {overall:.0%}") + break + + # Fetch final run detail + async with httpx.AsyncClient() as client: + resp = await client.get(_api_url(f"/eval-runs/{run_id}"), timeout=10) + resp.raise_for_status() + return resp.json() + + +@mcp.tool() +async def list_eval_runs() -> list[dict[str, Any]]: + """List all evaluation runs. + + Returns summaries of all eval runs with their status, scores, + and progress. Use run IDs with get_eval_run for full details. + """ + await _report_tool_call("list_eval_runs") + async with httpx.AsyncClient() as client: + resp = await client.get(_api_url("/eval-runs"), timeout=10) + resp.raise_for_status() + return resp.json() + + +@mcp.tool() +async def get_eval_run(eval_run_id: str) -> dict[str, Any]: + """Get full details of an evaluation run including per-item results. + + Args: + eval_run_id: ID of the eval run. + + Returns the run with all item results, scores, justifications, and traces. + """ + await _report_tool_call("get_eval_run", {"eval_run_id": eval_run_id}) + async with httpx.AsyncClient() as client: + resp = await client.get( + _api_url(f"/eval-runs/{eval_run_id}"), timeout=10 + ) + resp.raise_for_status() + return resp.json() + + def main() -> None: """Entry point for the uipath-dev-mcp CLI command.""" mcp.run(transport="stdio") From 45552e4072f1e7d6495b990d03f75293a3e9e57c Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Sun, 29 Mar 2026 00:00:08 +0200 Subject: [PATCH 06/12] feat: per-item evaluator management in eval set detail Add ability to toggle evaluators on/off per eval item and edit their criteria directly from the Evaluators sidebar tab. - Add PATCH /api/eval-sets/{id}/items/{name}/evaluators endpoint - Add update_eval_item_criterias service method - Replace read-only ItemEvaluatorsView with interactive version: enabled evaluators show with Edit/Remove controls, available evaluators show as "Add" buttons with dashed borders - Criteria saved as null uses evaluator defaults, or custom JSON Co-Authored-By: Claude Opus 4.6 (1M context) --- .../server/frontend/src/api/eval-client.ts | 15 ++ .../src/components/evals/EvalSetDetail.tsx | 247 +++++++++++++++--- src/uipath/dev/server/routes/evals.py | 21 ++ ...anel-CvZbTGws.js => ChatPanel-DDbjilLG.js} | 2 +- .../server/static/assets/index-2G7e_dtD.css | 32 --- .../server/static/assets/index-BpYfe5M1.css | 32 +++ .../{index-DDJ_NWFS.js => index-Cmg1nBHj.js} | 42 +-- src/uipath/dev/server/static/index.html | 4 +- src/uipath/dev/services/eval_service.py | 25 ++ 9 files changed, 324 insertions(+), 96 deletions(-) rename src/uipath/dev/server/static/assets/{ChatPanel-CvZbTGws.js => ChatPanel-DDbjilLG.js} (99%) delete mode 100644 src/uipath/dev/server/static/assets/index-2G7e_dtD.css create mode 100644 src/uipath/dev/server/static/assets/index-BpYfe5M1.css rename src/uipath/dev/server/static/assets/{index-DDJ_NWFS.js => index-Cmg1nBHj.js} (71%) diff --git a/src/uipath/dev/server/frontend/src/api/eval-client.ts b/src/uipath/dev/server/frontend/src/api/eval-client.ts index fa0fa41..c9c8e8a 100644 --- a/src/uipath/dev/server/frontend/src/api/eval-client.ts +++ b/src/uipath/dev/server/frontend/src/api/eval-client.ts @@ -59,6 +59,21 @@ export async function addEvalItem( }); } +export async function updateEvalItemEvaluators( + evalSetId: string, + itemName: string, + evaluationCriterias: Record, +): Promise { + return fetchJson( + `${BASE}/eval-sets/${encodeURIComponent(evalSetId)}/items/${encodeURIComponent(itemName)}/evaluators`, + { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ evaluation_criterias: evaluationCriterias }), + }, + ); +} + export async function deleteEvalItem( evalSetId: string, itemName: string, diff --git a/src/uipath/dev/server/frontend/src/components/evals/EvalSetDetail.tsx b/src/uipath/dev/server/frontend/src/components/evals/EvalSetDetail.tsx index 2d322be..472da99 100644 --- a/src/uipath/dev/server/frontend/src/components/evals/EvalSetDetail.tsx +++ b/src/uipath/dev/server/frontend/src/components/evals/EvalSetDetail.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useRef, useState } from "react"; -import { getEvalSet, startEvalRun, updateEvalSetEvaluators, deleteEvalItem } from "../../api/eval-client"; +import { getEvalSet, startEvalRun, updateEvalSetEvaluators, updateEvalItemEvaluators, deleteEvalItem } from "../../api/eval-client"; import { useEvalStore } from "../../store/useEvalStore"; import { useHashRoute } from "../../hooks/useHashRoute"; import type { EvalSetDetail as EvalSetDetailType, EvalItem } from "../../types/eval"; @@ -419,7 +419,21 @@ export default function EvalSetDetail({ evalSetId }: Props) { sidebarTab === "io" ? ( ) : ( - + { + setDetail((prev) => { + if (!prev) return prev; + return { + ...prev, + items: prev.items.map((it) => it.name === updated.name ? updated : it), + }; + }); + }} + /> ) ) : null} @@ -471,48 +485,201 @@ function ItemIOView({ item }: { item: EvalItem }) { ); } -function ItemEvaluatorsView({ item, evaluators }: { item: EvalItem; evaluators: { id: string; name: string }[] }) { +function ItemEvaluatorsView({ + item, + evalSetId, + evaluators, + localEvaluators, + onItemUpdated, +}: { + item: EvalItem; + evalSetId: string; + evaluators: { id: string; name: string }[]; + localEvaluators: { id: string; name: string; type: string }[]; + onItemUpdated: (updated: EvalItem) => void; +}) { + const criterias = item.evaluation_criterias ?? {}; + const [editingId, setEditingId] = useState(null); + const [editJson, setEditJson] = useState(""); + const [saving, setSaving] = useState(false); + const [error, setError] = useState(null); + + // Reset editing state when item changes + useEffect(() => { + setEditingId(null); + setError(null); + }, [item.name]); + + const saveCriterias = async (newCriterias: Record) => { + setSaving(true); + setError(null); + try { + const updated = await updateEvalItemEvaluators(evalSetId, item.name, newCriterias); + onItemUpdated(updated); + } catch (err: unknown) { + const detail = (err as { detail?: string })?.detail; + setError(detail ?? "Failed to update"); + } finally { + setSaving(false); + } + }; + + const handleToggle = (evId: string) => { + const next = { ...criterias }; + if (evId in next) { + delete next[evId]; + } else { + next[evId] = null as unknown as Record; + } + saveCriterias(next); + }; + + const handleStartEdit = (evId: string) => { + const val = criterias[evId]; + setEditJson(val != null ? JSON.stringify(val, null, 2) : ""); + setEditingId(evId); + setError(null); + }; + + const handleSaveEdit = (evId: string) => { + const trimmed = editJson.trim(); + let parsed: unknown = null; + if (trimmed) { + try { + parsed = JSON.parse(trimmed); + } catch { + setError("Invalid JSON"); + return; + } + } + const next = { ...criterias, [evId]: parsed as Record }; + saveCriterias(next).then(() => setEditingId(null)); + }; + + const enabled = Object.keys(criterias); + const available = localEvaluators.filter((ev) => !(ev.id in criterias)); + return ( -
- {item.evaluator_ids.length > 0 ? ( - <> - {item.evaluator_ids.map((evId) => { - const ev = evaluators.find((e) => e.id === evId); - const criteria = item.evaluation_criterias?.[evId]; - return ( -
+
+
+ {error && ( +
+ {error} +
+ )} + + {enabled.length > 0 && ( + <> + {enabled.map((evId) => { + const ev = evaluators.find((e) => e.id === evId) ?? localEvaluators.find((e) => e.id === evId); + const val = criterias[evId]; + const isEditing = editingId === evId; + return (
- - {ev?.name ?? evId} - - - {criteria ? "Custom criteria" : "Default criteria"} - -
- {criteria && ( -
-                    {JSON.stringify(criteria, null, 2)}
-                  
- )} -
- ); - })} - - ) : ( -
- No evaluators configured for this item -
- )} + + {ev?.name ?? evId} + + + + + +
+ {isEditing ? ( +
+