From 2d3c570429e966a79a1875dacea326c3f44ba76c Mon Sep 17 00:00:00 2001 From: zhengchuyi Date: Mon, 17 Aug 2026 15:14:49 +0800 Subject: [PATCH] feat: auto resume sandbox snapshots for admins --- frontend/src/adk/sandbox.ts | 18 +- frontend/src/ui/MyAgents.tsx | 10 +- .../ui/new-chat-modes/NewChatAgentPicker.tsx | 10 +- frontend/tests/myAgents.test.mjs | 10 +- frontend/tests/sandboxThreadsClient.test.mjs | 31 ++ tests/cli/test_frontend_sandbox.py | 96 ++++- veadk/cli/frontend_sandbox.py | 123 ++++-- ...4r.js => MarkdownPromptEditor-UWDOV-0M.js} | 2 +- .../{index-DiN_KGp4.js => index-DoYN33I0.js} | 376 +++++++++--------- veadk/webui/index.html | 2 +- 10 files changed, 453 insertions(+), 225 deletions(-) rename veadk/webui/assets/{MarkdownPromptEditor-Cfdarq4r.js => MarkdownPromptEditor-UWDOV-0M.js} (99%) rename veadk/webui/assets/{index-DiN_KGp4.js => index-DoYN33I0.js} (80%) diff --git a/frontend/src/adk/sandbox.ts b/frontend/src/adk/sandbox.ts index 5d019f2d6..e2c1554d2 100644 --- a/frontend/src/adk/sandbox.ts +++ b/frontend/src/adk/sandbox.ts @@ -223,6 +223,10 @@ export interface SandboxRequestOptions { onUsage?: (update: SandboxTokenUsageUpdate) => void; } +export interface SandboxListOptions extends SandboxRequestOptions { + autoResumeSnapshots?: boolean; +} + export interface SandboxStartOptions extends SandboxRequestOptions { displayName?: string; persistent?: boolean; @@ -284,11 +288,11 @@ export interface SandboxReply { } export interface AgentKitSandboxClient { - listSessions(options?: SandboxRequestOptions): Promise; + listSessions(options?: SandboxListOptions): Promise; startSession(options?: SandboxStartOptions): Promise; listAgentSessions( kind: SandboxAgentKind, - options?: SandboxRequestOptions, + options?: SandboxListOptions, ): Promise; startAgentSession( kind: SandboxAgentKind, @@ -611,6 +615,12 @@ function parseSnapshot( }; } +function sandboxListUrl(base: string, options?: SandboxListOptions): string { + if (!options?.autoResumeSnapshots) return base; + const params = new URLSearchParams({ autoResumeSnapshots: "true" }); + return `${base}?${params.toString()}`; +} + const DEFAULT_PERMISSIONS: SandboxPermissions = { approvalPolicy: "on-request", approvalsReviewer: "user", @@ -1013,7 +1023,7 @@ async function sandboxJson( export const sandboxClient: AgentKitSandboxClient = { async listSessions(options = {}) { const response = await studioFetch( - SANDBOX_API, + sandboxListUrl(SANDBOX_API, options), { method: "GET", headers: sandboxHeaders(), @@ -1059,7 +1069,7 @@ export const sandboxClient: AgentKitSandboxClient = { async listAgentSessions(kind, options = {}) { const response = await studioFetch( - `/web/${kind}/sessions`, + sandboxListUrl(`/web/${kind}/sessions`, options), { method: "GET", headers: sandboxHeaders(), diff --git a/frontend/src/ui/MyAgents.tsx b/frontend/src/ui/MyAgents.tsx index 310e51419..d31df48ac 100644 --- a/frontend/src/ui/MyAgents.tsx +++ b/frontend/src/ui/MyAgents.tsx @@ -540,8 +540,14 @@ export function MyAgents({ setSandboxAgents([]); try { const sessions = type === "codex" - ? await sandboxClient.listSessions({ signal: controller.signal }) - : await sandboxClient.listAgentSessions(type, { signal: controller.signal }); + ? await sandboxClient.listSessions({ + signal: controller.signal, + autoResumeSnapshots: true, + }) + : await sandboxClient.listAgentSessions(type, { + signal: controller.signal, + autoResumeSnapshots: true, + }); if (sandboxRequestRef.current !== requestId) return; setSandboxAgents(sessions.map(sandboxToAgent)); } catch (cause) { diff --git a/frontend/src/ui/new-chat-modes/NewChatAgentPicker.tsx b/frontend/src/ui/new-chat-modes/NewChatAgentPicker.tsx index 683716a4a..a531bb835 100644 --- a/frontend/src/ui/new-chat-modes/NewChatAgentPicker.tsx +++ b/frontend/src/ui/new-chat-modes/NewChatAgentPicker.tsx @@ -187,8 +187,14 @@ export function NewChatAgentPicker({ setSandboxSessions([]); try { const sessions = type === "codex" - ? await sandboxClient.listSessions({ signal: controller.signal }) - : await sandboxClient.listAgentSessions(type, { signal: controller.signal }); + ? await sandboxClient.listSessions({ + signal: controller.signal, + autoResumeSnapshots: true, + }) + : await sandboxClient.listAgentSessions(type, { + signal: controller.signal, + autoResumeSnapshots: true, + }); if (requestIdRef.current !== requestId) return; setSandboxSessions(sessions); setLoadedSandboxType(type); diff --git a/frontend/tests/myAgents.test.mjs b/frontend/tests/myAgents.test.mjs index d9385a954..d743c5ea8 100644 --- a/frontend/tests/myAgents.test.mjs +++ b/frontend/tests/myAgents.test.mjs @@ -89,8 +89,14 @@ test("renders only account-backed Runtime and Sandbox agents", () => { pageSource, /codex-code-review|codex-test-coverage|openclaw-research|hermes-data-analysis/, ); - assert.match(pageSource, /sandboxClient\.listSessions\(\{ signal: controller\.signal \}\)/); - assert.match(pageSource, /sandboxClient\.listAgentSessions\(type, \{ signal: controller\.signal \}\)/); + assert.match( + pageSource, + /sandboxClient\.listSessions\(\{[\s\S]*?signal: controller\.signal,[\s\S]*?autoResumeSnapshots: true,[\s\S]*?\}\)/, + ); + assert.match( + pageSource, + /sandboxClient\.listAgentSessions\(type, \{[\s\S]*?signal: controller\.signal,[\s\S]*?autoResumeSnapshots: true,[\s\S]*?\}\)/, + ); assert.match(pageSource, /sessions\.map\(sandboxToAgent\)/); }); diff --git a/frontend/tests/sandboxThreadsClient.test.mjs b/frontend/tests/sandboxThreadsClient.test.mjs index b63cc393b..61bcaba4b 100644 --- a/frontend/tests/sandboxThreadsClient.test.mjs +++ b/frontend/tests/sandboxThreadsClient.test.mjs @@ -317,3 +317,34 @@ test("sends persistence explicitly for default and temporary agents", async (t) }, ]); }); + +test("requests snapshot auto-resume when listing sandbox agents", async (t) => { + const previousFetch = globalThis.fetch; + t.after(() => { + globalThis.fetch = previousFetch; + }); + const requests = []; + globalThis.fetch = async (url, init) => { + requests.push({ url, method: init.method }); + return new Response(JSON.stringify({ sessions: [] }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + }; + + await sandboxClient.listSessions({ autoResumeSnapshots: true }); + await sandboxClient.listAgentSessions("openclaw", { + autoResumeSnapshots: true, + }); + + assert.deepEqual(requests, [ + { + url: "/web/sandbox/sessions?autoResumeSnapshots=true", + method: "GET", + }, + { + url: "/web/openclaw/sessions?autoResumeSnapshots=true", + method: "GET", + }, + ]); +}); diff --git a/tests/cli/test_frontend_sandbox.py b/tests/cli/test_frontend_sandbox.py index 0a47ea732..868720de6 100644 --- a/tests/cli/test_frontend_sandbox.py +++ b/tests/cli/test_frontend_sandbox.py @@ -722,7 +722,7 @@ def test_managed_agent_snapshot_is_listed_resumed_and_deleted() -> None: headers={"X-Test-User": "alice"}, ) admin_list = client.get( - "/web/openclaw/sessions", + "/web/openclaw/sessions?autoResumeSnapshots=false", headers={"X-Test-User": "admin", "X-Test-Role": "admin"}, ) denied = client.post( @@ -752,6 +752,52 @@ def test_managed_agent_snapshot_is_listed_resumed_and_deleted() -> None: assert [item.snapshot_id for item in gateway.deleted_snapshots] == ["snapshot-bob"] +def test_managed_agent_admin_listing_auto_resumes_current_kind_snapshots() -> None: + gateway = _FakeGateway() + gateway.snapshots["snapshot-openclaw"] = SandboxCloudSnapshot( + tool_id="tool-openclaw-snapshot", + snapshot_id="snapshot-openclaw", + session_id="expired-openclaw", + user_session_id="user-openclaw", + region="cn-beijing", + status="Ready", + reason="Expired", + created_at="2026-08-06T09:00:00Z", + display_name="OpenClaw Agent", + created_by="alice", + ) + gateway.snapshots["snapshot-hermes"] = SandboxCloudSnapshot( + tool_id="tool-hermes-snapshot", + snapshot_id="snapshot-hermes", + session_id="expired-hermes", + user_session_id="user-hermes", + region="cn-beijing", + status="Ready", + reason="Expired", + created_at="2026-08-06T09:01:00Z", + display_name="Hermes Agent", + created_by="alice", + ) + + with TestClient(_agent_app(gateway)) as client: + ordinary = client.get( + "/web/openclaw/sessions", + headers={"X-Test-User": "alice"}, + ) + admin = client.get( + "/web/openclaw/sessions", + headers={"X-Test-User": "admin", "X-Test-Role": "admin"}, + ) + + assert ordinary.status_code == 200 + assert "snapshots" not in ordinary.json() + assert "resumed-snapshot-openclaw" in { + item["sessionId"] for item in admin.json()["sessions"] + } + assert "snapshots" not in admin.json() + assert "resumed-snapshot-hermes" not in gateway.sessions + + def test_managed_agent_routes_enforce_username_scope() -> None: gateway = _FakeGateway() with TestClient(_agent_app(gateway)) as client: @@ -1816,7 +1862,7 @@ def test_sandbox_snapshot_is_wakeable_for_admin_only() -> None: headers={"X-Test-User": "alice"}, ) admin_list = client.get( - "/web/sandbox/sessions", + "/web/sandbox/sessions?autoResumeSnapshots=false", headers={"X-Test-User": "admin", "X-Test-Role": "admin"}, ) resumed = client.post( @@ -1843,6 +1889,52 @@ def test_sandbox_snapshot_is_wakeable_for_admin_only() -> None: assert deleted.json() == {"deleted": True} +def test_sandbox_admin_listing_auto_resumes_snapshots() -> None: + gateway = _FakeGateway() + gateway.snapshots["snapshot-alice"] = SandboxCloudSnapshot( + tool_id="tool-studio-snapshot", + snapshot_id="snapshot-alice", + session_id="expired-alice", + user_session_id="user-alice", + region="cn-beijing", + status="Ready", + reason="Expired", + created_at="2026-08-06T09:00:00Z", + display_name="Alice Codex", + created_by="alice", + ) + gateway.snapshots["snapshot-failed"] = SandboxCloudSnapshot( + tool_id="tool-studio-snapshot", + snapshot_id="snapshot-failed", + session_id="failed-session", + user_session_id="user-failed", + region="cn-beijing", + status="Failed", + reason="Create failed", + created_at="2026-08-06T10:00:00Z", + display_name="Failed Codex", + created_by="alice", + ) + + with TestClient(_app(gateway)) as client: + ordinary = client.get( + "/web/sandbox/sessions", + headers={"X-Test-User": "alice"}, + ) + admin = client.get( + "/web/sandbox/sessions", + headers={"X-Test-User": "admin", "X-Test-Role": "admin"}, + ) + + assert ordinary.status_code == 200 + assert "snapshots" not in ordinary.json() + assert "resumed-snapshot-alice" in { + item["sessionId"] for item in admin.json()["sessions"] + } + assert "snapshots" not in admin.json() + assert "resumed-snapshot-failed" not in gateway.sessions + + def test_sandbox_list_scope_follows_user_role() -> None: gateway = _FakeGateway() with TestClient(_app(gateway)) as client: diff --git a/veadk/cli/frontend_sandbox.py b/veadk/cli/frontend_sandbox.py index 9512a9519..cac95147e 100644 --- a/veadk/cli/frontend_sandbox.py +++ b/veadk/cli/frontend_sandbox.py @@ -27,7 +27,7 @@ import secrets import time import uuid -from collections.abc import AsyncIterator, Callable +from collections.abc import AsyncIterator, Awaitable, Callable from dataclasses import dataclass, field, replace from typing import Annotated, Any, Protocol @@ -107,6 +107,7 @@ _SESSION_NOT_FOUND_CODE = "InvalidResource.NotFound" _ACTIVE_SESSION_STATUSES = {"creating", "pending", "running", "ready", "starting"} _RESTORABLE_SNAPSHOT_STATUSES = {"completed", "ready", "success", "succeeded"} +_AUTO_RESUME_SNAPSHOT_CONCURRENCY = 3 _RESUME_SESSION_ATTEMPTS = 36 _RESUME_SESSION_INTERVAL_SECONDS = 5 _SENSITIVE_PATTERN = re.compile( @@ -655,6 +656,42 @@ def _restorable_snapshots( return restorable +def _request_auto_resume_snapshots(request: Request, *, default: bool = False) -> bool: + raw_value = request.query_params.get("autoResumeSnapshots") + if raw_value is None: + return default + return raw_value.strip().lower() in { + "1", + "true", + "yes", + "on", + } + + +async def _auto_resume_snapshot_batch( + snapshots: list[SandboxCloudSnapshot], + resume: Callable[[SandboxCloudSnapshot], Awaitable[SandboxCloudSession]], +) -> None: + if not snapshots: + return + semaphore = asyncio.Semaphore(_AUTO_RESUME_SNAPSHOT_CONCURRENCY) + + async def _resume(snapshot: SandboxCloudSnapshot) -> None: + async with semaphore: + try: + await resume(snapshot) + except Exception as error: + logger.warning( + "Failed to auto-resume Sandbox snapshot snapshot_id=%s " + "session_id=%s error_type=%s", + snapshot.snapshot_id, + snapshot.session_id, + type(error).__name__, + ) + + await asyncio.gather(*(_resume(snapshot) for snapshot in snapshots)) + + def _session_for_tools( session: SandboxCloudSession, tools: SandboxToolPair, @@ -1534,13 +1571,37 @@ async def list_snapshots( return await self._gateway.list_snapshots(tools.persistent) async def list_resources( - self, owner_id: str, *, is_admin: bool = False + self, + owner_id: str, + *, + is_admin: bool = False, + auto_resume_snapshots: bool = False, ) -> tuple[list[SandboxCloudSession], list[SandboxCloudSnapshot]]: sessions, snapshots = await asyncio.gather( self.list_sessions(owner_id, is_admin=is_admin), self.list_snapshots(owner_id, is_admin=is_admin), ) - return sessions, _restorable_snapshots(sessions, snapshots) + restorable = _restorable_snapshots(sessions, snapshots) + if auto_resume_snapshots and is_admin and restorable: + await _auto_resume_snapshot_batch( + restorable, + self._resume_snapshot, + ) + return await self.list_sessions(owner_id, is_admin=is_admin), [] + return sessions, restorable + + async def _resume_snapshot( + self, snapshot: SandboxCloudSnapshot + ) -> SandboxCloudSession: + session = await self._gateway.resume_snapshot(snapshot) + return _session_for_tools( + replace( + session, + display_name=session.display_name or snapshot.display_name, + created_by=session.created_by or snapshot.created_by, + ), + self._tools(), + ) async def resume_snapshot( self, @@ -1556,15 +1617,7 @@ async def resume_snapshot( ) if snapshot is None: raise SandboxSessionNotFoundError("智能体快照不存在或不属于当前用户。") - session = await self._gateway.resume_snapshot(snapshot) - return _session_for_tools( - replace( - session, - display_name=session.display_name or snapshot.display_name, - created_by=session.created_by or snapshot.created_by, - ), - self._tools(), - ) + return await self._resume_snapshot(snapshot) async def delete_snapshot( self, @@ -2423,13 +2476,37 @@ async def list_snapshots( return await self._gateway.list_snapshots(tools.persistent) async def list_resources( - self, owner_id: str, *, is_admin: bool = False + self, + owner_id: str, + *, + is_admin: bool = False, + auto_resume_snapshots: bool = False, ) -> tuple[list[SandboxCloudSession], list[SandboxCloudSnapshot]]: sessions, snapshots = await asyncio.gather( self.list_sessions(owner_id, is_admin=is_admin), self.list_snapshots(owner_id, is_admin=is_admin), ) - return sessions, _restorable_snapshots(sessions, snapshots) + restorable = _restorable_snapshots(sessions, snapshots) + if auto_resume_snapshots and is_admin and restorable: + await _auto_resume_snapshot_batch( + restorable, + self._resume_snapshot, + ) + return await self.list_sessions(owner_id, is_admin=is_admin), [] + return sessions, restorable + + async def _resume_snapshot( + self, snapshot: SandboxCloudSnapshot + ) -> SandboxCloudSession: + session = await self._gateway.resume_snapshot(snapshot) + return _session_for_tools( + replace( + session, + display_name=session.display_name or snapshot.display_name, + created_by=session.created_by or snapshot.created_by, + ), + self._tools(), + ) async def resume_snapshot( self, @@ -2445,15 +2522,7 @@ async def resume_snapshot( ) if snapshot is None: raise SandboxSessionNotFoundError("智能体快照不存在或不属于当前用户。") - session = await self._gateway.resume_snapshot(snapshot) - return _session_for_tools( - replace( - session, - display_name=session.display_name or snapshot.display_name, - created_by=session.created_by or snapshot.created_by, - ), - self._tools(), - ) + return await self._resume_snapshot(snapshot) async def delete_snapshot( self, @@ -2713,6 +2782,10 @@ async def _list_sandbox_agent_sessions( sessions, snapshots = await _service(kind).list_resources( owner_resolver(request), is_admin=_is_admin(request), + auto_resume_snapshots=_request_auto_resume_snapshots( + request, + default=True, + ), ) except SandboxError as error: raise _http_error(error) from error @@ -3238,6 +3311,10 @@ async def _list_sandbox_sessions(request: Request) -> dict[str, object]: sessions, snapshots = await service.list_resources( owner_resolver(request), is_admin=_is_admin(request), + auto_resume_snapshots=_request_auto_resume_snapshots( + request, + default=True, + ), ) except SandboxError as error: raise _http_error(error) from error diff --git a/veadk/webui/assets/MarkdownPromptEditor-Cfdarq4r.js b/veadk/webui/assets/MarkdownPromptEditor-UWDOV-0M.js similarity index 99% rename from veadk/webui/assets/MarkdownPromptEditor-Cfdarq4r.js rename to veadk/webui/assets/MarkdownPromptEditor-UWDOV-0M.js index dc190d81f..4840032a5 100644 --- a/veadk/webui/assets/MarkdownPromptEditor-Cfdarq4r.js +++ b/veadk/webui/assets/MarkdownPromptEditor-UWDOV-0M.js @@ -1,4 +1,4 @@ -var T0=Object.defineProperty;var E0=(n,e,t)=>e in n?T0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e,t)=>E0(n,typeof e!="symbol"?e+"":e,t);import{a0 as I,a7 as Rn,U as F,A as k0,d as Kt,o as at,ac as jo,P as N0,c as M0,a6 as hc,ab as Fh,$ as Uo,s as Rh,q as $0,S as L0,aa as O0,R as A0,F as I0,D as P0,r as Hh,u as D0,C as F0,l as R0,a9 as Vh,a8 as Fu,h as H0,I as V0,j as B0,t as Bh,v as zh,g as z0,T as J0,B as Ru,E as K0,x as W0,y as aa,_ as j0,ad as U0,Q as Z0,f as T,w as Hu,m as Vu,V as Qe,Z as nn,a4 as Di,a2 as $l,a1 as q0,n as Bu,W as jt,Y as hs,z as gc,X as Wn,a5 as En,a3 as Pt,p as So,G as G0,L as Y0,J as X0,K as Q0,H as e5,O as t5,M as n5,N as r5,e as o5,i as i5,k as s5,b as l5,a as a5}from"./index-DiN_KGp4.js";var c5=Object.defineProperty,u5=(n,e)=>c5(n,"name",{value:e,configurable:!0});function Jh(n){const e=I.useRef({value:n,previous:n});return I.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}u5(Jh,"usePrevious");var f5=Object.defineProperty,d5=(n,e)=>f5(n,"name",{value:e,configurable:!0});function ca(n,[e,t]){return Math.min(t,Math.max(e,n))}d5(ca,"clamp");var h5=Object.defineProperty,be=(n,e)=>h5(n,"name",{value:e,configurable:!0}),g5=[" ","Enter","ArrowUp","ArrowDown"],p5=[" ","Enter"],oo="Select",[Us,pc,m5]=$0(oo),[vr,gv]=Hh(oo,[m5,Rh]),mc=Rh(),[_5,Hn]=vr(oo),[x5,y5]=vr(oo);function Kh(n){const{__scopeSelect:e,children:t,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:a,dir:c,name:u,autoComplete:f,disabled:d,required:g,form:h,internal_do_not_use_render:_}=n,m=mc(e),[p,y]=I.useState(null),[C,x]=I.useState(null),[w,k]=I.useState(!1),b=Vh(c),[v,E]=Fu({prop:r,defaultProp:o??!1,onChange:i,caller:oo}),[M,L]=Fu({prop:s,defaultProp:l,onChange:a,caller:oo}),H=I.useRef(null),R=I.useRef(M);I.useEffect(()=>{const Te=h?p==null?void 0:p.ownerDocument.getElementById(h):p==null?void 0:p.form;if(Te instanceof HTMLFormElement){const Se=be(()=>L(R.current),"reset");return Te.addEventListener("reset",Se),()=>Te.removeEventListener("reset",Se)}},[h,p,L]);const V=p?!!h||!!p.closest("form"):!0,[Z,G]=I.useState(new Set),z=Fh(),re=Array.from(Z).map(Te=>Te.props.value).join(";"),ee=I.useCallback(Te=>{G(Se=>new Set(Se).add(Te))},[]),ne=I.useCallback(Te=>{G(Se=>{const Ke=new Set(Se);return Ke.delete(Te),Ke})},[]),ae={required:g,trigger:p,onTriggerChange:y,valueNode:C,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:z,value:M,onValueChange:L,open:v,onOpenChange:E,dir:b,triggerPointerDownPosRef:H,disabled:d,name:u,autoComplete:f,form:h,nativeOptions:Z,nativeSelectKey:re,isFormControl:V};return F.jsx(H0,{...m,children:F.jsx(_5,{scope:e,...ae,children:F.jsx(Us.Provider,{scope:e,children:F.jsx(x5,{scope:e,onNativeOptionAdd:ee,onNativeOptionRemove:ne,children:jh(_)?_(ae):t})})})})}be(Kh,"SelectProvider");var C5=be(n=>{const{__scopeSelect:e,children:t,...r}=n;return F.jsx(Kh,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:o})=>F.jsxs(F.Fragment,{children:[t,o?F.jsx(W5,{__scopeSelect:e}):null]})})},"Select"),v5="SelectTrigger",b5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,disabled:o=!1,...i}=e,s=mc(r),l=Hn(v5,r),a=l.disabled||o,c=Rn(t,l.onTriggerChange),u=pc(r),f=I.useRef("touch"),[d,g,h]=_c(m=>{const p=u().filter(x=>!x.disabled),y=p.find(x=>x.value===l.value),C=xc(p,m,y);C!==void 0&&l.onValueChange(C.value)}),_=be(m=>{a||(l.onOpenChange(!0),h()),m&&(l.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})},"handleOpen");return F.jsx(k0,{asChild:!0,...s,children:F.jsx(Kt.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yi(l.value)?"":void 0,...i,ref:c,onClick:at(i.onClick,m=>{m.currentTarget.focus(),f.current!=="mouse"&&_(m)}),onPointerDown:at(i.onPointerDown,m=>{f.current=m.pointerType;const p=m.target;p.hasPointerCapture(m.pointerId)&&p.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(_(m),m.preventDefault())}),onKeyDown:at(i.onKeyDown,m=>{const p=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&g(m.key),!(p&&m.key===" ")&&g5.includes(m.key)&&(_(),m.preventDefault())})})})},"SelectTrigger")),S5="SelectValue",w5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,children:s,placeholder:l="",...a}=e,c=Hn(S5,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,d=Rn(t,c.onValueNodeChange);jo(()=>{u(f)},[u,f]);const g=yi(c.value);return F.jsx(Kt.span,{...a,asChild:g?!1:a.asChild,ref:d,style:{pointerEvents:"none"},children:F.jsx(I.Fragment,{children:g?l:s},g?"placeholder":"value")})},"SelectValue")),T5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,...i}=e;return F.jsx(Kt.span,{"aria-hidden":!0,...i,ref:t,children:o||"▼"})},"SelectIcon")),E5="SelectPortal",[k5,N5]=vr(E5,{forceMount:void 0}),M5=be(n=>{const{__scopeSelect:e,forceMount:t,...r}=n;return F.jsx(k5,{scope:n.__scopeSelect,forceMount:t,children:F.jsx(N0,{asChild:!0,...r})})},"SelectPortal"),sr="SelectContent",$5=I.forwardRef(be(function(e,t){const r=N5(sr,e.__scopeSelect),{forceMount:o=r.forceMount,...i}=e,s=Hn(sr,e.__scopeSelect),[l,a]=I.useState();return jo(()=>{a(new DocumentFragment)},[]),F.jsx(M0,{present:o||s.open,children:({present:c})=>c?F.jsx(A5,{...i,ref:t}):F.jsx(L5,{...i,fragment:l})})},"SelectContent")),L5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,fragment:i}=e;return i?Uo.createPortal(F.jsx(Wh,{scope:r,children:F.jsx(Us.Slot,{scope:r,children:F.jsx("div",{ref:t,children:o})})}),i):null},"SelectContentFragment")),Ft=10,[Wh,Zs]=vr(sr),O5=D0("SelectContent.RemoveScroll"),A5=I.forwardRef(be(function(e,t){const{__scopeSelect:r}=e,{position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p,...y}=e,C=Hn(sr,r),[x,w]=I.useState(null),[k,b]=I.useState(null),v=Rn(t,w),[E,M]=I.useState(null),[L,H]=I.useState(null),R=pc(r),[V,Z]=I.useState(!1),G=I.useRef(!1);I.useEffect(()=>{if(x)return L0(x)},[x]),O0();const z=I.useCallback(W=>{const[ce,...Ie]=R().map(xe=>xe.ref.current),[ue]=Ie.slice(-1),de=document.activeElement;for(const xe of W)if(xe===de||(xe==null||xe.scrollIntoView({block:"nearest"}),xe===ce&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe==null||xe.focus(),document.activeElement!==de))return},[R,k]),re=I.useCallback(()=>z([E,x]),[z,E,x]);I.useEffect(()=>{V&&re()},[V,re]);const{onOpenChange:ee,triggerPointerDownPosRef:ne}=C;I.useEffect(()=>{if(x){let W={x:0,y:0};const ce=be(ue=>{var de,xe;W={x:Math.abs(Math.round(ue.pageX)-(((de=ne.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((xe=ne.current)==null?void 0:xe.y)??0))}},"handlePointerMove"),Ie=be(ue=>{W.x<=10&&W.y<=10?ue.preventDefault():ue.composedPath().includes(x)||ee(!1),document.removeEventListener("pointermove",ce),ne.current=null},"handlePointerUp");return ne.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[x,ee,ne]),I.useEffect(()=>{const W=be(()=>ee(!1),"close");return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[ee]);const[ae,Te]=_c(W=>{const ce=R().filter(de=>!de.disabled),Ie=ce.find(de=>de.ref.current===document.activeElement),ue=xc(ce,W,Ie);ue&&setTimeout(()=>{var de;return(de=ue.ref.current)==null?void 0:de.focus()})}),Se=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&(M(W),ue&&(G.current=!0))},[C.value]),Ke=I.useCallback(()=>x==null?void 0:x.focus(),[x]),Ye=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&H(W)},[C.value]),ie=o==="popper"?zu:I5,_e=ie===zu?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p}:{};return F.jsx(Wh,{scope:r,content:x,viewport:k,onViewportChange:b,itemRefCallback:Se,selectedItem:E,onItemLeave:Ke,itemTextRefCallback:Ye,focusSelectedItem:re,selectedItemText:L,position:o,isPositioned:V,searchRef:ae,children:F.jsx(A0,{as:O5,allowPinchZoom:!0,children:F.jsx(I0,{asChild:!0,trapped:C.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:at(i,W=>{var ce;(ce=C.trigger)==null||ce.focus({preventScroll:!0}),W.preventDefault()}),children:F.jsx(P0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:F.jsx(ie,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:W=>W.preventDefault(),...y,..._e,onPlaced:()=>Z(!0),ref:v,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:at(y.onKeyDown,W=>{const ce=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!ce&&W.key.length===1&&Te(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=R().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const de=W.target,xe=ue.indexOf(de);ue=ue.slice(xe+1)}setTimeout(()=>z(ue)),W.preventDefault()}})})})})})})},"SelectContentImpl")),I5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,onPlaced:o,...i}=e,s=Hn(sr,r),l=Zs(sr,r),[a,c]=I.useState(null),[u,f]=I.useState(null),d=Rn(t,f),g=pc(r),h=I.useRef(!1),_=I.useRef(!0),{viewport:m,selectedItem:p,selectedItemText:y,focusSelectedItem:C}=l,x=I.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&m&&p&&y){const v=s.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=L.left-E.left,xe=M.left-de,en=v.left-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.left=Pr+"px"}else{const de=E.right-L.right,xe=window.innerWidth-M.right-de,en=window.innerWidth-v.right-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.right=Pr+"px"}const H=g(),R=window.innerHeight-Ft*2,V=m.scrollHeight,Z=window.getComputedStyle(u),G=parseInt(Z.borderTopWidth,10),z=parseInt(Z.paddingTop,10),re=parseInt(Z.borderBottomWidth,10),ee=parseInt(Z.paddingBottom,10),ne=G+z+V+ee+re,ae=Math.min(p.offsetHeight*5,ne),Te=window.getComputedStyle(m),Se=parseInt(Te.paddingTop,10),Ke=parseInt(Te.paddingBottom,10),Ye=v.top+v.height/2-Ft,ie=R-Ye,_e=p.offsetHeight/2,W=p.offsetTop+_e,ce=G+z+W,Ie=ne-ce;if(ce<=Ye){const de=H.length>0&&p===H[H.length-1].ref.current;a.style.bottom="0px";const xe=u.clientHeight-m.offsetTop-m.offsetHeight,en=Math.max(ie,_e+(de?Ke:0)+xe+re),tn=ce+en;a.style.height=tn+"px"}else{const de=H.length>0&&p===H[0].ref.current;a.style.top="0px";const en=Math.max(Ye,G+m.offsetTop+(de?Se:0)+_e)+Ie;a.style.height=en+"px",m.scrollTop=ce-Ye+m.offsetTop}a.style.margin=`${Ft}px 0`,a.style.minHeight=ae+"px",a.style.maxHeight=R+"px",o==null||o(),requestAnimationFrame(()=>h.current=!0)}},[g,s.trigger,s.valueNode,a,u,m,p,y,s.dir,o]);jo(()=>x(),[x]);const[w,k]=I.useState();jo(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const b=I.useCallback(v=>{v&&_.current===!0&&(x(),C==null||C(),_.current=!1)},[x,C]);return F.jsx(P5,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:b,children:F.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:F.jsx(Kt.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),zu=I.forwardRef(be(function(e,t){const{__scopeSelect:r,align:o="start",collisionPadding:i=Ft,...s}=e,l=mc(r);return F.jsx(F0,{...l,...s,ref:t,align:o,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[P5,D5]=vr(sr,{}),Ju="SelectViewport",F5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,nonce:o,...i}=e,s=Zs(Ju,r),l=D5(Ju,r),a=Rn(t,s.onViewportChange),c=I.useRef(0);return F.jsxs(F.Fragment,{children:[F.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),F.jsx(Us.Slot,{scope:r,children:F.jsx(Kt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.onScroll,u=>{const f=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&d){const h=Math.abs(c.current-f.scrollTop);if(h>0){const _=window.innerHeight-Ft*2,m=parseFloat(d.style.minHeight),p=parseFloat(d.style.height),y=Math.max(m,p);if(y<_){const C=y+h,x=Math.min(_,C),w=C-x;d.style.height=x+"px",d.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,d.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})},"SelectViewport")),R5="SelectGroup",[pv,mv]=vr(R5),ua="SelectItem",[H5,V5]=vr(ua),B5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,value:o,disabled:i=!1,textValue:s,...l}=e,a=Hn(ua,r),c=Zs(ua,r),u=a.value===o,[f,d]=I.useState(s??""),[g,h]=I.useState(!1),_=hc(x=>{var w;return(w=c.itemRefCallback)==null?void 0:w.call(c,x,o,i)}),m=Rn(t,_),p=Fh(),y=I.useRef("touch"),C=be(()=>{i||(a.onValueChange(o),a.onOpenChange(!1))},"handleSelect");return F.jsx(H5,{scope:r,value:o,disabled:i,textId:p,isSelected:u,onItemTextChange:I.useCallback(x=>{d(w=>w||((x==null?void 0:x.textContent)??"").trim())},[]),children:F.jsx(Us.ItemSlot,{scope:r,value:o,disabled:i,textValue:f,children:F.jsx(Kt.div,{role:"option","aria-labelledby":p,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:m,onFocus:at(l.onFocus,()=>h(!0)),onBlur:at(l.onBlur,()=>h(!1)),onClick:at(l.onClick,()=>{y.current!=="mouse"&&C()}),onPointerUp:at(l.onPointerUp,()=>{y.current==="mouse"&&C()}),onPointerDown:at(l.onPointerDown,x=>{y.current=x.pointerType}),onPointerMove:at(l.onPointerMove,x=>{var w;y.current=x.pointerType,i?(w=c.onItemLeave)==null||w.call(c):y.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(l.onPointerLeave,x=>{var w;x.currentTarget===document.activeElement&&((w=c.onItemLeave)==null||w.call(c))}),onKeyDown:at(l.onKeyDown,x=>{var k;i||x.target!==x.currentTarget||((k=c.searchRef)==null?void 0:k.current)!==""&&x.key===" "||(p5.includes(x.key)&&C(),x.key===" "&&x.preventDefault())})})})})},"SelectItem")),Fi="SelectItemText",z5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,...s}=e,l=Hn(Fi,r),a=Zs(Fi,r),c=V5(Fi,r),u=y5(Fi,r),[f,d]=I.useState(null),g=hc(C=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,C,c.value,c.disabled)}),h=Rn(t,d,c.onItemTextChange,g),_=f==null?void 0:f.textContent,m=I.useMemo(()=>F.jsx("option",{value:c.value,disabled:c.disabled,children:_},c.value),[c.disabled,c.value,_]),{onNativeOptionAdd:p,onNativeOptionRemove:y}=u;return jo(()=>(p(m),()=>y(m)),[p,y,m]),F.jsxs(F.Fragment,{children:[F.jsx(Kt.span,{id:c.textId,...s,ref:h}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!yi(l.value)?Uo.createPortal(s.children,l.valueNode):null]})},"SelectItemText")),J5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,...o}=e;return F.jsx(Kt.div,{"aria-hidden":!0,...o,ref:t})},"SelectSeparator")),K5="SelectBubbleInput",W5=I.forwardRef(be(function({__scopeSelect:e,...t},r){const o=Hn(K5,e),{value:i,onValueChange:s,required:l,disabled:a,name:c,autoComplete:u,form:f}=o,{nativeOptions:d,nativeSelectKey:g}=o,h=I.useRef(null),_=Rn(r,h),m=i??"",p=Jh(m),y=Array.from(d).some(C=>(C.props.value??"")==="");return I.useEffect(()=>{const C=h.current;if(!C)return;const x=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(x,"value").set;if(p!==m&&k){const b=new Event("change",{bubbles:!0});k.call(C,m),C.dispatchEvent(b)}},[p,m]),F.jsxs(Kt.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:c,autoComplete:u,disabled:a,form:f,onChange:C=>s(C.target.value),...t,style:{...R0,...t.style},ref:_,defaultValue:m,children:[yi(i)&&!y?F.jsx("option",{value:""}):null,Array.from(d)]},g)},"SelectBubbleInput"));function jh(n){return typeof n=="function"}be(jh,"isFunction");function yi(n){return n===""||n===void 0}be(yi,"shouldShowPlaceholder");function _c(n){const e=hc(n),t=I.useRef(""),r=I.useRef(0),o=I.useCallback(s=>{const l=t.current+s;e(l),be(function a(c){t.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>a(""),1e3))},"updateSearch")(l)},[e]),i=I.useCallback(()=>{t.current="",window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[t,o,i]}be(_c,"useTypeaheadSearch");function xc(n,e,t){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let s=Uh(n,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==t));const a=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return a!==t?a:void 0}be(xc,"findNextItem");function Uh(n,e){return n.map((t,r)=>n[(e+r)%n.length])}be(Uh,"wrapArray");var j5=Object.defineProperty,qs=(n,e)=>j5(n,"name",{value:e,configurable:!0}),Zh="Toolbar",[U5,_v]=Hh(Zh,[Bh,zh]),qh=Bh(),Gh=zh(),[Z5,q5]=U5(Zh),G5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,orientation:o="horizontal",dir:i,loop:s=!0,...l}=e,a=qh(r),c=Vh(i);return F.jsx(Z5,{scope:r,orientation:o,dir:c,children:F.jsx(z0,{asChild:!0,...a,orientation:o,dir:c,loop:s,children:F.jsx(Kt.div,{role:"toolbar","aria-orientation":o,dir:c,...l,ref:t})})})},"Toolbar")),Yh=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=qh(r);return F.jsx(V0,{asChild:!0,...i,focusable:!e.disabled,children:F.jsx(Kt.button,{type:"button",...o,ref:t})})},"ToolbarButton")),Y5="ToolbarToggleGroup",X5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=q5(Y5,r),s=Gh(r);return F.jsx(J0,{"data-orientation":i.orientation,dir:i.dir,...s,...o,ref:t,rovingFocus:!1})},"ToolbarToggleGroup")),Q5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=Gh(r),s={__scopeToolbar:e.__scopeToolbar};return F.jsx(Yh,{asChild:!0,...s,children:F.jsx(B0,{...i,...o,ref:t})})},"ToolbarToggleItem")),e2=G5,t2=Yh,yc=X5,n2=Q5;const r2={}.hasOwnProperty;function Xh(n,e){let t=-1,r;if(e.extensions)for(;++te in n?T0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e,t)=>E0(n,typeof e!="symbol"?e+"":e,t);import{a0 as I,a7 as Rn,U as F,A as k0,d as Kt,o as at,ac as jo,P as N0,c as M0,a6 as hc,ab as Fh,$ as Uo,s as Rh,q as $0,S as L0,aa as O0,R as A0,F as I0,D as P0,r as Hh,u as D0,C as F0,l as R0,a9 as Vh,a8 as Fu,h as H0,I as V0,j as B0,t as Bh,v as zh,g as z0,T as J0,B as Ru,E as K0,x as W0,y as aa,_ as j0,ad as U0,Q as Z0,f as T,w as Hu,m as Vu,V as Qe,Z as nn,a4 as Di,a2 as $l,a1 as q0,n as Bu,W as jt,Y as hs,z as gc,X as Wn,a5 as En,a3 as Pt,p as So,G as G0,L as Y0,J as X0,K as Q0,H as e5,O as t5,M as n5,N as r5,e as o5,i as i5,k as s5,b as l5,a as a5}from"./index-DoYN33I0.js";var c5=Object.defineProperty,u5=(n,e)=>c5(n,"name",{value:e,configurable:!0});function Jh(n){const e=I.useRef({value:n,previous:n});return I.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}u5(Jh,"usePrevious");var f5=Object.defineProperty,d5=(n,e)=>f5(n,"name",{value:e,configurable:!0});function ca(n,[e,t]){return Math.min(t,Math.max(e,n))}d5(ca,"clamp");var h5=Object.defineProperty,be=(n,e)=>h5(n,"name",{value:e,configurable:!0}),g5=[" ","Enter","ArrowUp","ArrowDown"],p5=[" ","Enter"],oo="Select",[Us,pc,m5]=$0(oo),[vr,gv]=Hh(oo,[m5,Rh]),mc=Rh(),[_5,Hn]=vr(oo),[x5,y5]=vr(oo);function Kh(n){const{__scopeSelect:e,children:t,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:a,dir:c,name:u,autoComplete:f,disabled:d,required:g,form:h,internal_do_not_use_render:_}=n,m=mc(e),[p,y]=I.useState(null),[C,x]=I.useState(null),[w,k]=I.useState(!1),b=Vh(c),[v,E]=Fu({prop:r,defaultProp:o??!1,onChange:i,caller:oo}),[M,L]=Fu({prop:s,defaultProp:l,onChange:a,caller:oo}),H=I.useRef(null),R=I.useRef(M);I.useEffect(()=>{const Te=h?p==null?void 0:p.ownerDocument.getElementById(h):p==null?void 0:p.form;if(Te instanceof HTMLFormElement){const Se=be(()=>L(R.current),"reset");return Te.addEventListener("reset",Se),()=>Te.removeEventListener("reset",Se)}},[h,p,L]);const V=p?!!h||!!p.closest("form"):!0,[Z,G]=I.useState(new Set),z=Fh(),re=Array.from(Z).map(Te=>Te.props.value).join(";"),ee=I.useCallback(Te=>{G(Se=>new Set(Se).add(Te))},[]),ne=I.useCallback(Te=>{G(Se=>{const Ke=new Set(Se);return Ke.delete(Te),Ke})},[]),ae={required:g,trigger:p,onTriggerChange:y,valueNode:C,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:z,value:M,onValueChange:L,open:v,onOpenChange:E,dir:b,triggerPointerDownPosRef:H,disabled:d,name:u,autoComplete:f,form:h,nativeOptions:Z,nativeSelectKey:re,isFormControl:V};return F.jsx(H0,{...m,children:F.jsx(_5,{scope:e,...ae,children:F.jsx(Us.Provider,{scope:e,children:F.jsx(x5,{scope:e,onNativeOptionAdd:ee,onNativeOptionRemove:ne,children:jh(_)?_(ae):t})})})})}be(Kh,"SelectProvider");var C5=be(n=>{const{__scopeSelect:e,children:t,...r}=n;return F.jsx(Kh,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:o})=>F.jsxs(F.Fragment,{children:[t,o?F.jsx(W5,{__scopeSelect:e}):null]})})},"Select"),v5="SelectTrigger",b5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,disabled:o=!1,...i}=e,s=mc(r),l=Hn(v5,r),a=l.disabled||o,c=Rn(t,l.onTriggerChange),u=pc(r),f=I.useRef("touch"),[d,g,h]=_c(m=>{const p=u().filter(x=>!x.disabled),y=p.find(x=>x.value===l.value),C=xc(p,m,y);C!==void 0&&l.onValueChange(C.value)}),_=be(m=>{a||(l.onOpenChange(!0),h()),m&&(l.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})},"handleOpen");return F.jsx(k0,{asChild:!0,...s,children:F.jsx(Kt.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yi(l.value)?"":void 0,...i,ref:c,onClick:at(i.onClick,m=>{m.currentTarget.focus(),f.current!=="mouse"&&_(m)}),onPointerDown:at(i.onPointerDown,m=>{f.current=m.pointerType;const p=m.target;p.hasPointerCapture(m.pointerId)&&p.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(_(m),m.preventDefault())}),onKeyDown:at(i.onKeyDown,m=>{const p=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&g(m.key),!(p&&m.key===" ")&&g5.includes(m.key)&&(_(),m.preventDefault())})})})},"SelectTrigger")),S5="SelectValue",w5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,children:s,placeholder:l="",...a}=e,c=Hn(S5,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,d=Rn(t,c.onValueNodeChange);jo(()=>{u(f)},[u,f]);const g=yi(c.value);return F.jsx(Kt.span,{...a,asChild:g?!1:a.asChild,ref:d,style:{pointerEvents:"none"},children:F.jsx(I.Fragment,{children:g?l:s},g?"placeholder":"value")})},"SelectValue")),T5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,...i}=e;return F.jsx(Kt.span,{"aria-hidden":!0,...i,ref:t,children:o||"▼"})},"SelectIcon")),E5="SelectPortal",[k5,N5]=vr(E5,{forceMount:void 0}),M5=be(n=>{const{__scopeSelect:e,forceMount:t,...r}=n;return F.jsx(k5,{scope:n.__scopeSelect,forceMount:t,children:F.jsx(N0,{asChild:!0,...r})})},"SelectPortal"),sr="SelectContent",$5=I.forwardRef(be(function(e,t){const r=N5(sr,e.__scopeSelect),{forceMount:o=r.forceMount,...i}=e,s=Hn(sr,e.__scopeSelect),[l,a]=I.useState();return jo(()=>{a(new DocumentFragment)},[]),F.jsx(M0,{present:o||s.open,children:({present:c})=>c?F.jsx(A5,{...i,ref:t}):F.jsx(L5,{...i,fragment:l})})},"SelectContent")),L5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,fragment:i}=e;return i?Uo.createPortal(F.jsx(Wh,{scope:r,children:F.jsx(Us.Slot,{scope:r,children:F.jsx("div",{ref:t,children:o})})}),i):null},"SelectContentFragment")),Ft=10,[Wh,Zs]=vr(sr),O5=D0("SelectContent.RemoveScroll"),A5=I.forwardRef(be(function(e,t){const{__scopeSelect:r}=e,{position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p,...y}=e,C=Hn(sr,r),[x,w]=I.useState(null),[k,b]=I.useState(null),v=Rn(t,w),[E,M]=I.useState(null),[L,H]=I.useState(null),R=pc(r),[V,Z]=I.useState(!1),G=I.useRef(!1);I.useEffect(()=>{if(x)return L0(x)},[x]),O0();const z=I.useCallback(W=>{const[ce,...Ie]=R().map(xe=>xe.ref.current),[ue]=Ie.slice(-1),de=document.activeElement;for(const xe of W)if(xe===de||(xe==null||xe.scrollIntoView({block:"nearest"}),xe===ce&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe==null||xe.focus(),document.activeElement!==de))return},[R,k]),re=I.useCallback(()=>z([E,x]),[z,E,x]);I.useEffect(()=>{V&&re()},[V,re]);const{onOpenChange:ee,triggerPointerDownPosRef:ne}=C;I.useEffect(()=>{if(x){let W={x:0,y:0};const ce=be(ue=>{var de,xe;W={x:Math.abs(Math.round(ue.pageX)-(((de=ne.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((xe=ne.current)==null?void 0:xe.y)??0))}},"handlePointerMove"),Ie=be(ue=>{W.x<=10&&W.y<=10?ue.preventDefault():ue.composedPath().includes(x)||ee(!1),document.removeEventListener("pointermove",ce),ne.current=null},"handlePointerUp");return ne.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[x,ee,ne]),I.useEffect(()=>{const W=be(()=>ee(!1),"close");return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[ee]);const[ae,Te]=_c(W=>{const ce=R().filter(de=>!de.disabled),Ie=ce.find(de=>de.ref.current===document.activeElement),ue=xc(ce,W,Ie);ue&&setTimeout(()=>{var de;return(de=ue.ref.current)==null?void 0:de.focus()})}),Se=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&(M(W),ue&&(G.current=!0))},[C.value]),Ke=I.useCallback(()=>x==null?void 0:x.focus(),[x]),Ye=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&H(W)},[C.value]),ie=o==="popper"?zu:I5,_e=ie===zu?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p}:{};return F.jsx(Wh,{scope:r,content:x,viewport:k,onViewportChange:b,itemRefCallback:Se,selectedItem:E,onItemLeave:Ke,itemTextRefCallback:Ye,focusSelectedItem:re,selectedItemText:L,position:o,isPositioned:V,searchRef:ae,children:F.jsx(A0,{as:O5,allowPinchZoom:!0,children:F.jsx(I0,{asChild:!0,trapped:C.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:at(i,W=>{var ce;(ce=C.trigger)==null||ce.focus({preventScroll:!0}),W.preventDefault()}),children:F.jsx(P0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:F.jsx(ie,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:W=>W.preventDefault(),...y,..._e,onPlaced:()=>Z(!0),ref:v,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:at(y.onKeyDown,W=>{const ce=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!ce&&W.key.length===1&&Te(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=R().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const de=W.target,xe=ue.indexOf(de);ue=ue.slice(xe+1)}setTimeout(()=>z(ue)),W.preventDefault()}})})})})})})},"SelectContentImpl")),I5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,onPlaced:o,...i}=e,s=Hn(sr,r),l=Zs(sr,r),[a,c]=I.useState(null),[u,f]=I.useState(null),d=Rn(t,f),g=pc(r),h=I.useRef(!1),_=I.useRef(!0),{viewport:m,selectedItem:p,selectedItemText:y,focusSelectedItem:C}=l,x=I.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&m&&p&&y){const v=s.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=L.left-E.left,xe=M.left-de,en=v.left-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.left=Pr+"px"}else{const de=E.right-L.right,xe=window.innerWidth-M.right-de,en=window.innerWidth-v.right-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.right=Pr+"px"}const H=g(),R=window.innerHeight-Ft*2,V=m.scrollHeight,Z=window.getComputedStyle(u),G=parseInt(Z.borderTopWidth,10),z=parseInt(Z.paddingTop,10),re=parseInt(Z.borderBottomWidth,10),ee=parseInt(Z.paddingBottom,10),ne=G+z+V+ee+re,ae=Math.min(p.offsetHeight*5,ne),Te=window.getComputedStyle(m),Se=parseInt(Te.paddingTop,10),Ke=parseInt(Te.paddingBottom,10),Ye=v.top+v.height/2-Ft,ie=R-Ye,_e=p.offsetHeight/2,W=p.offsetTop+_e,ce=G+z+W,Ie=ne-ce;if(ce<=Ye){const de=H.length>0&&p===H[H.length-1].ref.current;a.style.bottom="0px";const xe=u.clientHeight-m.offsetTop-m.offsetHeight,en=Math.max(ie,_e+(de?Ke:0)+xe+re),tn=ce+en;a.style.height=tn+"px"}else{const de=H.length>0&&p===H[0].ref.current;a.style.top="0px";const en=Math.max(Ye,G+m.offsetTop+(de?Se:0)+_e)+Ie;a.style.height=en+"px",m.scrollTop=ce-Ye+m.offsetTop}a.style.margin=`${Ft}px 0`,a.style.minHeight=ae+"px",a.style.maxHeight=R+"px",o==null||o(),requestAnimationFrame(()=>h.current=!0)}},[g,s.trigger,s.valueNode,a,u,m,p,y,s.dir,o]);jo(()=>x(),[x]);const[w,k]=I.useState();jo(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const b=I.useCallback(v=>{v&&_.current===!0&&(x(),C==null||C(),_.current=!1)},[x,C]);return F.jsx(P5,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:b,children:F.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:F.jsx(Kt.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),zu=I.forwardRef(be(function(e,t){const{__scopeSelect:r,align:o="start",collisionPadding:i=Ft,...s}=e,l=mc(r);return F.jsx(F0,{...l,...s,ref:t,align:o,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[P5,D5]=vr(sr,{}),Ju="SelectViewport",F5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,nonce:o,...i}=e,s=Zs(Ju,r),l=D5(Ju,r),a=Rn(t,s.onViewportChange),c=I.useRef(0);return F.jsxs(F.Fragment,{children:[F.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),F.jsx(Us.Slot,{scope:r,children:F.jsx(Kt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.onScroll,u=>{const f=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&d){const h=Math.abs(c.current-f.scrollTop);if(h>0){const _=window.innerHeight-Ft*2,m=parseFloat(d.style.minHeight),p=parseFloat(d.style.height),y=Math.max(m,p);if(y<_){const C=y+h,x=Math.min(_,C),w=C-x;d.style.height=x+"px",d.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,d.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})},"SelectViewport")),R5="SelectGroup",[pv,mv]=vr(R5),ua="SelectItem",[H5,V5]=vr(ua),B5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,value:o,disabled:i=!1,textValue:s,...l}=e,a=Hn(ua,r),c=Zs(ua,r),u=a.value===o,[f,d]=I.useState(s??""),[g,h]=I.useState(!1),_=hc(x=>{var w;return(w=c.itemRefCallback)==null?void 0:w.call(c,x,o,i)}),m=Rn(t,_),p=Fh(),y=I.useRef("touch"),C=be(()=>{i||(a.onValueChange(o),a.onOpenChange(!1))},"handleSelect");return F.jsx(H5,{scope:r,value:o,disabled:i,textId:p,isSelected:u,onItemTextChange:I.useCallback(x=>{d(w=>w||((x==null?void 0:x.textContent)??"").trim())},[]),children:F.jsx(Us.ItemSlot,{scope:r,value:o,disabled:i,textValue:f,children:F.jsx(Kt.div,{role:"option","aria-labelledby":p,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:m,onFocus:at(l.onFocus,()=>h(!0)),onBlur:at(l.onBlur,()=>h(!1)),onClick:at(l.onClick,()=>{y.current!=="mouse"&&C()}),onPointerUp:at(l.onPointerUp,()=>{y.current==="mouse"&&C()}),onPointerDown:at(l.onPointerDown,x=>{y.current=x.pointerType}),onPointerMove:at(l.onPointerMove,x=>{var w;y.current=x.pointerType,i?(w=c.onItemLeave)==null||w.call(c):y.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(l.onPointerLeave,x=>{var w;x.currentTarget===document.activeElement&&((w=c.onItemLeave)==null||w.call(c))}),onKeyDown:at(l.onKeyDown,x=>{var k;i||x.target!==x.currentTarget||((k=c.searchRef)==null?void 0:k.current)!==""&&x.key===" "||(p5.includes(x.key)&&C(),x.key===" "&&x.preventDefault())})})})})},"SelectItem")),Fi="SelectItemText",z5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,...s}=e,l=Hn(Fi,r),a=Zs(Fi,r),c=V5(Fi,r),u=y5(Fi,r),[f,d]=I.useState(null),g=hc(C=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,C,c.value,c.disabled)}),h=Rn(t,d,c.onItemTextChange,g),_=f==null?void 0:f.textContent,m=I.useMemo(()=>F.jsx("option",{value:c.value,disabled:c.disabled,children:_},c.value),[c.disabled,c.value,_]),{onNativeOptionAdd:p,onNativeOptionRemove:y}=u;return jo(()=>(p(m),()=>y(m)),[p,y,m]),F.jsxs(F.Fragment,{children:[F.jsx(Kt.span,{id:c.textId,...s,ref:h}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!yi(l.value)?Uo.createPortal(s.children,l.valueNode):null]})},"SelectItemText")),J5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,...o}=e;return F.jsx(Kt.div,{"aria-hidden":!0,...o,ref:t})},"SelectSeparator")),K5="SelectBubbleInput",W5=I.forwardRef(be(function({__scopeSelect:e,...t},r){const o=Hn(K5,e),{value:i,onValueChange:s,required:l,disabled:a,name:c,autoComplete:u,form:f}=o,{nativeOptions:d,nativeSelectKey:g}=o,h=I.useRef(null),_=Rn(r,h),m=i??"",p=Jh(m),y=Array.from(d).some(C=>(C.props.value??"")==="");return I.useEffect(()=>{const C=h.current;if(!C)return;const x=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(x,"value").set;if(p!==m&&k){const b=new Event("change",{bubbles:!0});k.call(C,m),C.dispatchEvent(b)}},[p,m]),F.jsxs(Kt.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:c,autoComplete:u,disabled:a,form:f,onChange:C=>s(C.target.value),...t,style:{...R0,...t.style},ref:_,defaultValue:m,children:[yi(i)&&!y?F.jsx("option",{value:""}):null,Array.from(d)]},g)},"SelectBubbleInput"));function jh(n){return typeof n=="function"}be(jh,"isFunction");function yi(n){return n===""||n===void 0}be(yi,"shouldShowPlaceholder");function _c(n){const e=hc(n),t=I.useRef(""),r=I.useRef(0),o=I.useCallback(s=>{const l=t.current+s;e(l),be(function a(c){t.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>a(""),1e3))},"updateSearch")(l)},[e]),i=I.useCallback(()=>{t.current="",window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[t,o,i]}be(_c,"useTypeaheadSearch");function xc(n,e,t){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let s=Uh(n,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==t));const a=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return a!==t?a:void 0}be(xc,"findNextItem");function Uh(n,e){return n.map((t,r)=>n[(e+r)%n.length])}be(Uh,"wrapArray");var j5=Object.defineProperty,qs=(n,e)=>j5(n,"name",{value:e,configurable:!0}),Zh="Toolbar",[U5,_v]=Hh(Zh,[Bh,zh]),qh=Bh(),Gh=zh(),[Z5,q5]=U5(Zh),G5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,orientation:o="horizontal",dir:i,loop:s=!0,...l}=e,a=qh(r),c=Vh(i);return F.jsx(Z5,{scope:r,orientation:o,dir:c,children:F.jsx(z0,{asChild:!0,...a,orientation:o,dir:c,loop:s,children:F.jsx(Kt.div,{role:"toolbar","aria-orientation":o,dir:c,...l,ref:t})})})},"Toolbar")),Yh=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=qh(r);return F.jsx(V0,{asChild:!0,...i,focusable:!e.disabled,children:F.jsx(Kt.button,{type:"button",...o,ref:t})})},"ToolbarButton")),Y5="ToolbarToggleGroup",X5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=q5(Y5,r),s=Gh(r);return F.jsx(J0,{"data-orientation":i.orientation,dir:i.dir,...s,...o,ref:t,rovingFocus:!1})},"ToolbarToggleGroup")),Q5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=Gh(r),s={__scopeToolbar:e.__scopeToolbar};return F.jsx(Yh,{asChild:!0,...s,children:F.jsx(B0,{...i,...o,ref:t})})},"ToolbarToggleItem")),e2=G5,t2=Yh,yc=X5,n2=Q5;const r2={}.hasOwnProperty;function Xh(n,e){let t=-1,r;if(e.extensions)for(;++ti.map(i=>d[i]); -var $ge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Qge=(e,t,n)=>t in e?$ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Or=(e,t,n)=>Qge(e,typeof t!="symbol"?t+"":t,n),o6=(e,t,n)=>t.has(e)||a6("Cannot "+n);var Fs=(e,t,n)=>(o6(e,t,"read from private field"),n?n.call(e):t.get(e)),l6=(e,t,n)=>t.has(e)?a6("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),BN=(e,t,n,i)=>(o6(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);function Bge(e,t){for(var n=0;ni[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var tf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function N0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var EY={exports:{}},FT={};/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPromptEditor-UWDOV-0M.js","assets/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]); +var Qge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Bge=(e,t,n)=>t in e?Qge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Or=(e,t,n)=>Bge(e,typeof t!="symbol"?t+"":t,n),o6=(e,t,n)=>t.has(e)||a6("Cannot "+n);var Fs=(e,t,n)=>(o6(e,t,"read from private field"),n?n.call(e):t.get(e)),l6=(e,t,n)=>t.has(e)?a6("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),BN=(e,t,n,i)=>(o6(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);function Uge(e,t){for(var n=0;ni[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var tf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function N0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kY={exports:{}},FT={};/** * @license React * react-jsx-runtime.production.js * @@ -7,7 +7,7 @@ var $ge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Qge=(e,t,n)=>t * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Uge=Symbol.for("react.transitional.element"),zge=Symbol.for("react.fragment");function kY(e,t,n){var i=null;if(n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),"key"in t){n={};for(var r in t)r!=="key"&&(n[r]=t[r])}else n=t;return t=n.ref,{$$typeof:Uge,type:e,key:i,ref:t!==void 0?t:null,props:n}}FT.Fragment=zge;FT.jsx=kY;FT.jsxs=kY;EY.exports=FT;var l=EY.exports,TY={exports:{}},un={};/** + */var zge=Symbol.for("react.transitional.element"),Fge=Symbol.for("react.fragment");function TY(e,t,n){var i=null;if(n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),"key"in t){n={};for(var r in t)r!=="key"&&(n[r]=t[r])}else n=t;return t=n.ref,{$$typeof:zge,type:e,key:i,ref:t!==void 0?t:null,props:n}}FT.Fragment=Fge;FT.jsx=TY;FT.jsxs=TY;kY.exports=FT;var l=kY.exports,_Y={exports:{}},un={};/** * @license React * react.production.js * @@ -15,7 +15,7 @@ var $ge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Qge=(e,t,n)=>t * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var e5=Symbol.for("react.transitional.element"),Fge=Symbol.for("react.portal"),Vge=Symbol.for("react.fragment"),Xge=Symbol.for("react.strict_mode"),qge=Symbol.for("react.profiler"),Hge=Symbol.for("react.consumer"),Yge=Symbol.for("react.context"),Gge=Symbol.for("react.forward_ref"),Wge=Symbol.for("react.suspense"),Zge=Symbol.for("react.memo"),_Y=Symbol.for("react.lazy"),Kge=Symbol.for("react.activity"),c6=Symbol.iterator;function Jge(e){return e===null||typeof e!="object"?null:(e=c6&&e[c6]||e["@@iterator"],typeof e=="function"?e:null)}var AY={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},NY=Object.assign,CY={};function C0(e,t,n){this.props=e,this.context=t,this.refs=CY,this.updater=n||AY}C0.prototype.isReactComponent={};C0.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};C0.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function jY(){}jY.prototype=C0.prototype;function t5(e,t,n){this.props=e,this.context=t,this.refs=CY,this.updater=n||AY}var n5=t5.prototype=new jY;n5.constructor=t5;NY(n5,C0.prototype);n5.isPureReactComponent=!0;var u6=Array.isArray;function QR(){}var Wi={H:null,A:null,T:null,S:null},RY=Object.prototype.hasOwnProperty;function i5(e,t,n){var i=n.ref;return{$$typeof:e5,type:e,key:t,ref:i!==void 0?i:null,props:n}}function e0e(e,t){return i5(e.type,t,e.props)}function r5(e){return typeof e=="object"&&e!==null&&e.$$typeof===e5}function t0e(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var d6=/\/+/g;function UN(e,t){return typeof e=="object"&&e!==null&&e.key!=null?t0e(""+e.key):t.toString(36)}function n0e(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(QR,QR):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function wm(e,t,n,i,r){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(s){case"bigint":case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case e5:case Fge:a=!0;break;case _Y:return a=e._init,wm(a(e._payload),t,n,i,r)}}if(a)return r=r(e),a=i===""?"."+UN(e,0):i,u6(r)?(n="",a!=null&&(n=a.replace(d6,"$&/")+"/"),wm(r,t,n,"",function(u){return u})):r!=null&&(r5(r)&&(r=e0e(r,n+(r.key==null||e&&e.key===r.key?"":(""+r.key).replace(d6,"$&/")+"/")+a)),t.push(r)),1;a=0;var o=i===""?".":i+":";if(u6(e))for(var c=0;c{throw TypeError(e)};var Qge=(e,t,n)=>t * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(e){function t(j,$){var U=j.length;j.push($);e:for(;0>>1,I=j[B];if(0>>1;Br(D,U))Hr(re,D)?(j[B]=re,j[H]=U,B=H):(j[B]=D,j[q]=U,B=q);else if(Hr(re,U))j[B]=re,j[H]=U,B=H;else break e}}return $}function r(j,$){var U=j.sortIndex-$.sortIndex;return U!==0?U:j.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var c=[],u=[],d=1,f=null,h=3,p=!1,g=!1,b=!1,y=!1,O=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;function w(j){for(var $=n(u);$!==null;){if($.callback===null)i(u);else if($.startTime<=j)i(u),$.sortIndex=$.expirationTime,t(c,$);else break;$=n(u)}}function E(j){if(b=!1,w(j),!g)if(n(c)!==null)g=!0,S||(S=!0,M());else{var $=n(u);$!==null&&Q(E,$.startTime-j)}}var S=!1,k=-1,T=5,A=-1;function N(){return y?!0:!(e.unstable_now()-Aj&&N());){var B=f.callback;if(typeof B=="function"){f.callback=null,h=f.priorityLevel;var I=B(f.expirationTime<=j);if(j=e.unstable_now(),typeof I=="function"){f.callback=I,w(j),$=!0;break t}f===n(c)&&i(c),w(j)}else i(c);f=n(c)}if(f!==null)$=!0;else{var X=n(u);X!==null&&Q(E,X.startTime-j),$=!1}}break e}finally{f=null,h=U,p=!1}$=void 0}}finally{$?M():S=!1}}}var M;if(typeof x=="function")M=function(){x(C)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,P=L.port2;L.port1.onmessage=C,M=function(){P.postMessage(null)}}else M=function(){O(C,0)};function Q(j,$){k=O(function(){j(e.unstable_now())},$)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125B?(j.sortIndex=U,t(u,j),n(c)===null&&j===n(u)&&(b?(v(k),k=-1):b=!0,Q(E,U-B))):(j.sortIndex=I,t(c,j),g||p||(g=!0,S||(S=!0,M()))),j},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(j){var $=h;return function(){var U=h;h=$;try{return j.apply(this,arguments)}finally{h=U}}}})(MY);PY.exports=MY;var s0e=PY.exports,LY={exports:{}},wa={};/** + */(function(e){function t(j,$){var U=j.length;j.push($);e:for(;0>>1,I=j[B];if(0>>1;Br(D,U))Hr(re,D)?(j[B]=re,j[H]=U,B=H):(j[B]=D,j[q]=U,B=q);else if(Hr(re,U))j[B]=re,j[H]=U,B=H;else break e}}return $}function r(j,$){var U=j.sortIndex-$.sortIndex;return U!==0?U:j.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var c=[],u=[],d=1,f=null,h=3,p=!1,g=!1,b=!1,y=!1,O=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;function w(j){for(var $=n(u);$!==null;){if($.callback===null)i(u);else if($.startTime<=j)i(u),$.sortIndex=$.expirationTime,t(c,$);else break;$=n(u)}}function E(j){if(b=!1,w(j),!g)if(n(c)!==null)g=!0,S||(S=!0,M());else{var $=n(u);$!==null&&Q(E,$.startTime-j)}}var S=!1,k=-1,T=5,A=-1;function N(){return y?!0:!(e.unstable_now()-Aj&&N());){var B=f.callback;if(typeof B=="function"){f.callback=null,h=f.priorityLevel;var I=B(f.expirationTime<=j);if(j=e.unstable_now(),typeof I=="function"){f.callback=I,w(j),$=!0;break t}f===n(c)&&i(c),w(j)}else i(c);f=n(c)}if(f!==null)$=!0;else{var X=n(u);X!==null&&Q(E,X.startTime-j),$=!1}}break e}finally{f=null,h=U,p=!1}$=void 0}}finally{$?M():S=!1}}}var M;if(typeof x=="function")M=function(){x(C)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,P=L.port2;L.port1.onmessage=C,M=function(){P.postMessage(null)}}else M=function(){O(C,0)};function Q(j,$){k=O(function(){j(e.unstable_now())},$)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125B?(j.sortIndex=U,t(u,j),n(c)===null&&j===n(u)&&(b?(v(k),k=-1):b=!0,Q(E,U-B))):(j.sortIndex=I,t(c,j),g||p||(g=!0,S||(S=!0,M()))),j},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(j){var $=h;return function(){var U=h;h=$;try{return j.apply(this,arguments)}finally{h=U}}}})(LY);MY.exports=LY;var a0e=MY.exports,DY={exports:{}},wa={};/** * @license React * react-dom.production.js * @@ -31,7 +31,7 @@ var $ge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Qge=(e,t,n)=>t * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var a0e=m;function DY(e){var t="https://react.dev/errors/"+e;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($Y)}catch(e){console.error(e)}}$Y(),LY.exports=wa;var zi=LY.exports;/** + */var o0e=m;function $Y(e){var t="https://react.dev/errors/"+e;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(QY)}catch(e){console.error(e)}}QY(),DY.exports=wa;var zi=DY.exports;/** * @license React * react-dom-client.production.js * @@ -39,15 +39,15 @@ var $ge=Object.defineProperty;var a6=e=>{throw TypeError(e)};var Qge=(e,t,n)=>t * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var rs=s0e,QY=m,c0e=zi;function ze(e){var t="https://react.dev/errors/"+e;if(1Dm||(e.current=XR[Dm],XR[Dm]=null,Dm--)}function Ui(e,t){Dm++,XR[Dm]=e.current,e.current=t}var Mc=Xc(null),My=Xc(null),df=Xc(null),NE=Xc(null);function CE(e,t){switch(Ui(df,t),Ui(My,e),Ui(Mc,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xB(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xB(t),e=dZ(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ys(Mc),Ui(Mc,e)}function Bg(){ys(Mc),ys(My),ys(df)}function qR(e){e.memoizedState!==null&&Ui(NE,e);var t=Mc.current,n=dZ(t,e.type);t!==n&&(Ui(My,e),Ui(Mc,n))}function jE(e){My.current===e&&(ys(Mc),ys(My)),NE.current===e&&(ys(NE),qy._currentValue=Gh)}var zN,m6;function xh(e){if(zN===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);zN=t&&t[1]||"",m6=-1Dm||(e.current=XR[Dm],XR[Dm]=null,Dm--)}function Ui(e,t){Dm++,XR[Dm]=e.current,e.current=t}var Mc=Xc(null),My=Xc(null),df=Xc(null),NE=Xc(null);function CE(e,t){switch(Ui(df,t),Ui(My,e),Ui(Mc,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xB(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xB(t),e=fZ(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ys(Mc),Ui(Mc,e)}function Bg(){ys(Mc),ys(My),ys(df)}function qR(e){e.memoizedState!==null&&Ui(NE,e);var t=Mc.current,n=fZ(t,e.type);t!==n&&(Ui(My,e),Ui(Mc,n))}function jE(e){My.current===e&&(ys(Mc),ys(My)),NE.current===e&&(ys(NE),qy._currentValue=Gh)}var zN,m6;function xh(e){if(zN===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);zN=t&&t[1]||"",m6=-1)":-1r||c[i]!==u[r]){var d=` -`+c[i].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=i&&0<=r);break}}}finally{FN=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?xh(n):""}function p0e(e,t){switch(e.tag){case 26:case 27:case 5:return xh(e.type);case 16:return xh("Lazy");case 13:return e.child!==t&&t!==null?xh("Suspense Fallback"):xh("Suspense");case 19:return xh("SuspenseList");case 0:case 15:return VN(e.type,!1);case 11:return VN(e.type.render,!1);case 1:return VN(e.type,!0);case 31:return xh("Activity");default:return""}}function g6(e){try{var t="",n=null;do t+=p0e(e,n),n=e,e=e.return;while(e);return t}catch(i){return` +`+c[i].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=i&&0<=r);break}}}finally{FN=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?xh(n):""}function m0e(e,t){switch(e.tag){case 26:case 27:case 5:return xh(e.type);case 16:return xh("Lazy");case 13:return e.child!==t&&t!==null?xh("Suspense Fallback"):xh("Suspense");case 19:return xh("SuspenseList");case 0:case 15:return VN(e.type,!1);case 11:return VN(e.type.render,!1);case 1:return VN(e.type,!0);case 31:return xh("Activity");default:return""}}function g6(e){try{var t="",n=null;do t+=m0e(e,n),n=e,e=e.return;while(e);return t}catch(i){return` Error generating stack: `+i.message+` -`+i.stack}}var HR=Object.prototype.hasOwnProperty,o5=rs.unstable_scheduleCallback,XN=rs.unstable_cancelCallback,m0e=rs.unstable_shouldYield,g0e=rs.unstable_requestPaint,go=rs.unstable_now,b0e=rs.unstable_getCurrentPriorityLevel,qY=rs.unstable_ImmediatePriority,HY=rs.unstable_UserBlockingPriority,RE=rs.unstable_NormalPriority,O0e=rs.unstable_LowPriority,YY=rs.unstable_IdlePriority,y0e=rs.log,x0e=rs.unstable_setDisableYieldValue,a1=null,bo=null;function nf(e){if(typeof y0e=="function"&&x0e(e),bo&&typeof bo.setStrictMode=="function")try{bo.setStrictMode(a1,e)}catch{}}var Oo=Math.clz32?Math.clz32:S0e,v0e=Math.log,w0e=Math.LN2;function S0e(e){return e>>>=0,e===0?32:31-(v0e(e)/w0e|0)|0}var Dv=256,$v=262144,Qv=4194304;function vh(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qT(e,t,n){var i=e.pendingLanes;if(i===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes;e=e.warmLanes;var o=i&134217727;return o!==0?(i=o&~s,i!==0?r=vh(i):(a&=o,a!==0?r=vh(a):n||(n=o&~e,n!==0&&(r=vh(n))))):(o=i&~s,o!==0?r=vh(o):a!==0?r=vh(a):n||(n=i&~e,n!==0&&(r=vh(n)))),r===0?0:t!==0&&t!==r&&!(t&s)&&(s=r&-r,n=t&-t,s>=n||s===32&&(n&4194048)!==0)?t:r}function o1(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function E0e(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function GY(){var e=Qv;return Qv<<=1,!(Qv&62914560)&&(Qv=4194304),e}function qN(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function l1(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function k0e(e,t,n,i,r,s){var a=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,c=e.expirationTimes,u=e.hiddenUpdates;for(n=a&~n;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var j0e=/[\n"\\]/g;function zo(e){return e.replace(j0e,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function WR(e,t,n,i,r,s,a,o){e.name="",a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"?e.type=a:e.removeAttribute("type"),t!=null?a==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Do(t)):e.value!==""+Do(t)&&(e.value=""+Do(t)):a!=="submit"&&a!=="reset"||e.removeAttribute("value"),t!=null?ZR(e,a,Do(t)):n!=null?ZR(e,a,Do(n)):i!=null&&e.removeAttribute("value"),r==null&&s!=null&&(e.defaultChecked=!!s),r!=null&&(e.checked=r&&typeof r!="function"&&typeof r!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?e.name=""+Do(o):e.removeAttribute("name")}function rG(e,t,n,i,r,s,a,o){if(s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.type=s),t!=null||n!=null){if(!(s!=="submit"&&s!=="reset"||t!=null)){GR(e);return}n=n!=null?""+Do(n):"",t=t!=null?""+Do(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i=i??r,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"&&(e.name=a),GR(e)}function ZR(e,t,n){t==="number"&&IE(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function hg(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),JR=!1;if(Gu)try{var $b={};Object.defineProperty($b,"passive",{get:function(){JR=!0}}),window.addEventListener("test",$b,$b),window.removeEventListener("test",$b,$b)}catch{JR=!1}var rf=null,h5=null,wS=null;function cG(){if(wS)return wS;var e,t=h5,n=t.length,i,r="value"in rf?rf.value:rf.textContent,s=r.length;for(e=0;e=FO),_6=" ",A6=!1;function dG(e,t){switch(e){case"keyup":return sbe.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fG(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bm=!1;function obe(e,t){switch(e){case"compositionend":return fG(t);case"keypress":return t.which!==32?null:(A6=!0,_6);case"textInput":return e=t.data,e===_6&&A6?null:e;default:return null}}function lbe(e,t){if(Bm)return e==="compositionend"||!m5&&dG(e,t)?(e=cG(),wS=h5=rf=null,Bm=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=I6(n)}}function gG(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gG(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function bG(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=IE(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=IE(e.document)}return t}function g5(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var gbe=Gu&&"documentMode"in document&&11>=document.documentMode,Um=null,eI=null,XO=null,tI=!1;function M6(e,t,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;tI||Um==null||Um!==IE(i)||(i=Um,"selectionStart"in i&&g5(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),XO&&$y(XO,i)||(XO=i,i=ZE(eI,"onSelect"),0>=a,r-=a,kc=1<<32-Oo(t)+r|n<T?(A=k,k=null):A=k.sibling;var N=h(O,k,x[T],w);if(N===null){k===null&&(k=A);break}e&&k&&N.alternate===null&&t(O,k),v=s(N,v,T),S===null?E=N:S.sibling=N,S=N,k=A}if(T===x.length)return n(O,k),Xn&&Tu(O,T),E;if(k===null){for(;TT?(A=k,k=null):A=k.sibling;var C=h(O,k,N.value,w);if(C===null){k===null&&(k=A);break}e&&k&&C.alternate===null&&t(O,k),v=s(C,v,T),S===null?E=C:S.sibling=C,S=C,k=A}if(N.done)return n(O,k),Xn&&Tu(O,T),E;if(k===null){for(;!N.done;T++,N=x.next())N=f(O,N.value,w),N!==null&&(v=s(N,v,T),S===null?E=N:S.sibling=N,S=N);return Xn&&Tu(O,T),E}for(k=i(k);!N.done;T++,N=x.next())N=p(k,O,T,N.value,w),N!==null&&(e&&N.alternate!==null&&k.delete(N.key===null?T:N.key),v=s(N,v,T),S===null?E=N:S.sibling=N,S=N);return e&&k.forEach(function(M){return t(O,M)}),Xn&&Tu(O,T),E}function y(O,v,x,w){if(typeof x=="object"&&x!==null&&x.type===Lm&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Lv:e:{for(var E=x.key;v!==null;){if(v.key===E){if(E=x.type,E===Lm){if(v.tag===7){n(O,v.sibling),w=r(v,x.props.children),w.return=O,O=w;break e}}else if(v.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===zd&&wh(E)===v.type){n(O,v.sibling),w=r(v,x.props),Bb(w,x),w.return=O,O=w;break e}n(O,v);break}else t(O,v);v=v.sibling}x.type===Lm?(w=Wh(x.props.children,O.mode,w,x.key),w.return=O,O=w):(w=ES(x.type,x.key,x.props,null,O.mode,w),Bb(w,x),w.return=O,O=w)}return a(O);case OO:e:{for(E=x.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){n(O,v.sibling),w=r(v,x.children||[]),w.return=O,O=w;break e}else{n(O,v);break}else t(O,v);v=v.sibling}w=t2(x,O.mode,w),w.return=O,O=w}return a(O);case zd:return x=wh(x),y(O,v,x,w)}if(yO(x))return g(O,v,x,w);if(Db(x)){if(E=Db(x),typeof E!="function")throw Error(ze(150));return x=E.call(x),b(O,v,x,w)}if(typeof x.then=="function")return y(O,v,Fv(x),w);if(x.$$typeof===ju)return y(O,v,zv(O,x),w);Vv(O,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,v!==null&&v.tag===6?(n(O,v.sibling),w=r(v,x),w.return=O,O=w):(n(O,v),w=e2(x,O.mode,w),w.return=O,O=w),a(O)):n(O,v)}return function(O,v,x,w){try{Uy=0;var E=y(O,v,x,w);return gg=null,E}catch(k){if(k===M0||k===KT)throw k;var S=uo(29,k,null,O.mode);return S.lanes=w,S.return=O,S}finally{}}}var hp=RG(!0),IG=RG(!1),Fd=!1;function k5(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lI(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function hf(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function pf(e,t,n){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,ai&2){var r=i.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=ME(e),EG(e,null,n),t}return ZT(e,i,t,n),ME(e)}function HO(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,ZY(e,n)}}function i2(e,t){var n=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var r=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};s===null?r=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?r=s=t:s=s.next=t}else r=s=t;n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,callbacks:i.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var cI=!1;function YO(){if(cI){var e=mg;if(e!==null)throw e}}function GO(e,t,n,i){cI=!1;var r=e.updateQueue;Fd=!1;var s=r.firstBaseUpdate,a=r.lastBaseUpdate,o=r.shared.pending;if(o!==null){r.shared.pending=null;var c=o,u=c.next;c.next=null,a===null?s=u:a.next=u,a=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==a&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(s!==null){var f=r.baseState;a=0,d=u=c=null,o=s;do{var h=o.lane&-536870913,p=h!==o.lane;if(p?(Un&h)===h:(i&h)===h){h!==0&&h===Fg&&(cI=!0),d!==null&&(d=d.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var g=e,b=o;h=t;var y=n;switch(b.tag){case 1:if(g=b.payload,typeof g=="function"){f=g.call(y,f,h);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,h=typeof g=="function"?g.call(y,f,h):g,h==null)break e;f=Ki({},f,h);break e;case 2:Fd=!0}}h=o.callback,h!==null&&(e.flags|=64,p&&(e.flags|=8192),p=r.callbacks,p===null?r.callbacks=[h]:p.push(h))}else p={lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=p,c=f):d=d.next=p,a|=h;if(o=o.next,o===null){if(o=r.shared.pending,o===null)break;p=o,o=p.next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}while(!0);d===null&&(c=f),r.baseState=c,r.firstBaseUpdate=u,r.lastBaseUpdate=d,s===null&&(r.shared.lanes=0),Cf|=a,e.lanes=a,e.memoizedState=f}}function PG(e,t){if(typeof e!="function")throw Error(ze(191,e));e.call(t)}function MG(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;es?s:8;var a=Zt.T,o={};Zt.T=o,$5(e,!1,t,n);try{var c=r(),u=Zt.S;if(u!==null&&u(o,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=kbe(c,i);WO(e,t,d,yo(e))}else WO(e,t,i,yo(e))}catch(f){WO(e,t,{then:function(){},status:"rejected",reason:f},yo())}finally{ci.p=s,a!==null&&o.types!==null&&(a.types=o.types),Zt.T=a}}function jbe(){}function pI(e,t,n,i){if(e.tag!==5)throw Error(ze(476));var r=aW(e).queue;sW(e,r,t,Gh,n===null?jbe:function(){return oW(e),n(i)})}function aW(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Gh,baseState:Gh,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zu,lastRenderedState:Gh},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zu,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function oW(e){var t=aW(e);t.next===null&&(t=e.alternate.memoizedState),WO(e,t.next.queue,{},yo())}function D5(){return js(qy)}function lW(){return Ir().memoizedState}function cW(){return Ir().memoizedState}function Rbe(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=yo();e=hf(n);var i=pf(t,e,n);i!==null&&(Ua(i,t,n),HO(i,t,n)),t={cache:w5()},e.payload=t;return}t=t.return}}function Ibe(e,t,n){var i=yo();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},n_(e)?dW(t,n):(n=O5(e,t,n,i),n!==null&&(Ua(n,e,i),fW(n,t,i)))}function uW(e,t,n){var i=yo();WO(e,t,n,i)}function WO(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(n_(e))dW(t,r);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,o=s(a,n);if(r.hasEagerState=!0,r.eagerState=o,So(o,a))return ZT(e,t,r,0),Mi===null&&WT(),!1}catch{}finally{}if(n=O5(e,t,r,i),n!==null)return Ua(n,e,i),fW(n,t,i),!0}return!1}function $5(e,t,n,i){if(i={lane:2,revertLane:H5(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},n_(e)){if(t)throw Error(ze(479))}else t=O5(e,n,i,2),t!==null&&Ua(t,e,2)}function n_(e){var t=e.alternate;return e===hn||t!==null&&t===hn}function dW(e,t){bg=UE=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fW(e,t,n){if(n&4194048){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,ZY(e,n)}}var Fy={readContext:js,use:e_,useCallback:yr,useContext:yr,useEffect:yr,useImperativeHandle:yr,useLayoutEffect:yr,useInsertionEffect:yr,useMemo:yr,useReducer:yr,useRef:yr,useState:yr,useDebugValue:yr,useDeferredValue:yr,useTransition:yr,useSyncExternalStore:yr,useId:yr,useHostTransitionStatus:yr,useFormState:yr,useActionState:yr,useOptimistic:yr,useMemoCache:yr,useCacheRefresh:yr};Fy.useEffectEvent=yr;var hW={readContext:js,use:e_,useCallback:function(e,t){return ua().memoizedState=[e,t===void 0?null:t],e},useContext:js,useEffect:W6,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,_S(4194308,4,eW.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _S(4194308,4,e,t)},useInsertionEffect:function(e,t){_S(4,2,e,t)},useMemo:function(e,t){var n=ua();t=t===void 0?null:t;var i=e();if(pp){nf(!0);try{e()}finally{nf(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=ua();if(n!==void 0){var r=n(t);if(pp){nf(!0);try{n(t)}finally{nf(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=Ibe.bind(null,hn,e),[i.memoizedState,e]},useRef:function(e){var t=ua();return e={current:e},t.memoizedState=e},useState:function(e){e=fI(e);var t=e.queue,n=uW.bind(null,hn,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:M5,useDeferredValue:function(e,t){var n=ua();return L5(n,e,t)},useTransition:function(){var e=fI(!1);return e=sW.bind(null,hn,e.queue,!0,!1),ua().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var i=hn,r=ua();if(Xn){if(n===void 0)throw Error(ze(407));n=n()}else{if(n=t(),Mi===null)throw Error(ze(349));Un&127||BG(i,t,n)}r.memoizedState=n;var s={value:n,getSnapshot:t};return r.queue=s,W6(zG.bind(null,i,s,e),[e]),i.flags|=2048,Xg(9,{destroy:void 0},UG.bind(null,i,s,n,t),null),n},useId:function(){var e=ua(),t=Mi.identifierPrefix;if(Xn){var n=Tc,i=kc;n=(i&~(1<<32-Oo(i)-1)).toString(32)+n,t="_"+t+"R_"+n,n=zE++,0<\/script>",s=s.removeChild(s.firstChild);break;case"select":s=typeof i.is=="string"?a.createElement("select",{is:i.is}):a.createElement("select"),i.multiple?s.multiple=!0:i.size&&(s.size=i.size);break;default:s=typeof i.is=="string"?a.createElement(r,{is:i.is}):a.createElement(r)}}s[As]=t,s[Xa]=i;e:for(a=t.child;a!==null;){if(a.tag===5||a.tag===6)s.appendChild(a.stateNode);else if(a.tag!==4&&a.tag!==27&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break e;for(;a.sibling===null;){if(a.return===null||a.return===t)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}t.stateNode=s;e:switch(Rs(s,r,i),r){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&du(t)}}return Yi(t),d2(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&du(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(ze(166));if(e=df.current,em(t)){if(e=t.stateNode,n=t.memoizedProps,i=null,r=Ns,r!==null)switch(r.tag){case 27:case 5:i=r.memoizedProps}e[As]=t,e=!!(e.nodeValue===n||i!==null&&i.suppressHydrationWarning===!0||uZ(e.nodeValue,n)),e||Af(t,!0)}else e=KE(e).createTextNode(i),e[As]=t,t.stateNode=e}return Yi(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=em(t),n!==null){if(e===null){if(!i)throw Error(ze(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ze(557));e[As]=t}else dp(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yi(t),e=!1}else n=n2(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(co(t),t):(co(t),null);if(t.flags&128)throw Error(ze(558))}return Yi(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(r=em(t),i!==null&&i.dehydrated!==null){if(e===null){if(!r)throw Error(ze(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(ze(317));r[As]=t}else dp(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yi(t),r=!1}else r=n2(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return t.flags&256?(co(t),t):(co(t),null)}return co(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,r=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(r=i.alternate.memoizedState.cachePool.pool),s=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(s=i.memoizedState.cachePool.pool),s!==r&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Xv(t,t.updateQueue),Yi(t),null);case 4:return Bg(),e===null&&Y5(t.stateNode.containerInfo),Yi(t),null;case 10:return $u(t.type),Yi(t),null;case 19:if(ys(Cr),i=t.memoizedState,i===null)return Yi(t),null;if(r=(t.flags&128)!==0,s=i.rendering,s===null)if(r)Ub(i,!1);else{if(vr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=BE(e),s!==null){for(t.flags|=128,Ub(i,!1),e=s.updateQueue,t.updateQueue=e,Xv(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)kG(n,e),n=n.sibling;return Ui(Cr,Cr.current&1|2),Xn&&Tu(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&go()>qE&&(t.flags|=128,r=!0,Ub(i,!1),t.lanes=4194304)}else{if(!r)if(e=BE(s),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,Xv(t,e),Ub(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!Xn)return Yi(t),null}else 2*go()-i.renderingStartTime>qE&&n!==536870912&&(t.flags|=128,r=!0,Ub(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(e=i.last,e!==null?e.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=go(),e.sibling=null,n=Cr.current,Ui(Cr,r?n&1|2:n&1),Xn&&Tu(t,i.treeForkCount),e):(Yi(t),null);case 22:case 23:return co(t),T5(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Yi(t),t.subtreeFlags&6&&(t.flags|=8192)):Yi(t),n=t.updateQueue,n!==null&&Xv(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&ys(Zh),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$u(Fr),Yi(t),null;case 25:return null;case 30:return null}throw Error(ze(156,t.tag))}function $be(e,t){switch(v5(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $u(Fr),Bg(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return jE(t),null;case 31:if(t.memoizedState!==null){if(co(t),t.alternate===null)throw Error(ze(340));dp()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(co(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ze(340));dp()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ys(Cr),null;case 4:return Bg(),null;case 10:return $u(t.type),null;case 22:case 23:return co(t),T5(),e!==null&&ys(Zh),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return $u(Fr),null;case 25:return null;default:return null}}function kW(e,t){switch(v5(t),t.tag){case 3:$u(Fr),Bg();break;case 26:case 27:case 5:jE(t);break;case 4:Bg();break;case 31:t.memoizedState!==null&&co(t);break;case 13:co(t);break;case 19:ys(Cr);break;case 10:$u(t.type);break;case 22:case 23:co(t),T5(),e!==null&&ys(Zh);break;case 24:$u(Fr)}}function h1(e,t){try{var n=t.updateQueue,i=n!==null?n.lastEffect:null;if(i!==null){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var s=n.create,a=n.inst;i=s(),a.destroy=i}n=n.next}while(n!==r)}}catch(o){xi(t,t.return,o)}}function Nf(e,t,n){try{var i=t.updateQueue,r=i!==null?i.lastEffect:null;if(r!==null){var s=r.next;i=s;do{if((i.tag&e)===e){var a=i.inst,o=a.destroy;if(o!==void 0){a.destroy=void 0,r=t;var c=n,u=o;try{u()}catch(d){xi(r,c,d)}}}i=i.next}while(i!==s)}}catch(d){xi(t,t.return,d)}}function TW(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{MG(t,n)}catch(i){xi(e,e.return,i)}}}function _W(e,t,n){n.props=mp(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(i){xi(e,t,i)}}function ZO(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof n=="function"?e.refCleanup=n(i):n.current=i}}catch(r){xi(e,t,r)}}function _c(e,t){var n=e.ref,i=e.refCleanup;if(n!==null)if(typeof i=="function")try{i()}catch(r){xi(e,t,r)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(r){xi(e,t,r)}else n.current=null}function AW(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(r){xi(e,e.return,r)}}function f2(e,t,n){try{var i=e.stateNode;aOe(i,e.type,n,t),i[Xa]=t}catch(r){xi(e,e.return,r)}}function NW(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zf(e.type)||e.tag===4}function h2(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||NW(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zf(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function yI(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ru));else if(i!==4&&(i===27&&Zf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(yI(e,t,n),e=e.sibling;e!==null;)yI(e,t,n),e=e.sibling}function XE(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(i!==4&&(i===27&&Zf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(XE(e,t,n),e=e.sibling;e!==null;)XE(e,t,n),e=e.sibling}function CW(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Rs(t,i,n),t[As]=e,t[Xa]=n}catch(s){xi(e,e.return,s)}}var Au=!1,zr=!1,p2=!1,cB=typeof WeakSet=="function"?WeakSet:Set,us=null;function Qbe(e,t){if(e=e.containerInfo,TI=nk,e=bG(e),g5(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var p;f!==n||r!==0&&f.nodeType!==3||(o=a+r),f!==s||i!==0&&f.nodeType!==3||(c=a+i),f.nodeType===3&&(a+=f.nodeValue.length),(p=f.firstChild)!==null;)h=f,f=p;for(;;){if(f===e)break t;if(h===n&&++u===r&&(o=a),h===s&&++d===i&&(c=a),(p=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=p}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(_I={focusedElem:e,selectionRange:n},nk=!1,us=t;us!==null;)if(t=us,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,us=e;else for(;us!==null;){switch(t=us,s=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n title"))),Rs(s,i,n),s[As]=e,hs(s),i=s;break e;case"link":var a=NB("link","href",r).get(i+(n.href||""));if(a){for(var o=0;oy&&(a=y,y=b,b=a);var O=P6(o,b),v=P6(o,y);if(O&&v&&(p.rangeCount!==1||p.anchorNode!==O.node||p.anchorOffset!==O.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var x=f.createRange();x.setStart(O.node,O.offset),p.removeAllRanges(),b>y?(p.addRange(x),p.extend(v.node,v.offset)):(x.setEnd(v.node,v.offset),p.addRange(x))}}}}for(f=[],p=o;p=p.parentNode;)p.nodeType===1&&f.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;on?32:n,Zt.T=null,n=wI,wI=null;var s=gf,a=Qu;if(is=0,Hg=gf=null,Qu=0,ai&6)throw Error(ze(331));var o=ai;if(ai|=4,UW(s.current),$W(s,s.current,a,n),ai=o,p1(0,!1),bo&&typeof bo.onPostCommitFiberRoot=="function")try{bo.onPostCommitFiberRoot(a1,s)}catch{}return!0}finally{ci.p=r,Zt.T=i,nZ(e,t)}}function hB(e,t,n){t=Fo(n,t),t=gI(e.stateNode,t,2),e=pf(e,t,2),e!==null&&(l1(e,2),qc(e))}function xi(e,t,n){if(e.tag===3)hB(e,e,n);else for(;t!==null;){if(t.tag===3){hB(t,e,n);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(mf===null||!mf.has(i))){e=Fo(n,e),n=OW(2),i=pf(t,n,2),i!==null&&(yW(n,i,t,e),l1(i,2),qc(i));break}}t=t.return}}function g2(e,t,n){var i=e.pingCache;if(i===null){i=e.pingCache=new zbe;var r=new Set;i.set(t,r)}else r=i.get(t),r===void 0&&(r=new Set,i.set(t,r));r.has(n)||(V5=!0,r.add(n),e=Hbe.bind(null,e,t,n),t.then(e,e))}function Hbe(e,t,n){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Mi===e&&(Un&n)===n&&(vr===4||vr===3&&(Un&62914560)===Un&&300>go()-i_?!(ai&2)&&Yg(e,0):X5|=n,qg===Un&&(qg=0)),qc(e)}function rZ(e,t){t===0&&(t=GY()),e=Pp(e,t),e!==null&&(l1(e,t),qc(e))}function Ybe(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),rZ(e,n)}function Gbe(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,r=e.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(ze(314))}i!==null&&i.delete(t),rZ(e,n)}function Wbe(e,t){return o5(e,t)}var GE=null,Em=null,EI=!1,WE=!1,b2=!1,of=0;function qc(e){e!==Em&&e.next===null&&(Em===null?GE=Em=e:Em=Em.next=e),WE=!0,EI||(EI=!0,Kbe())}function p1(e,t){if(!b2&&WE){b2=!0;do for(var n=!1,i=GE;i!==null;){if(e!==0){var r=i.pendingLanes;if(r===0)var s=0;else{var a=i.suspendedLanes,o=i.pingedLanes;s=(1<<31-Oo(42|e)+1)-1,s&=r&~(a&~o),s=s&201326741?s&201326741|1:s?s|2:0}s!==0&&(n=!0,pB(i,s))}else s=Un,s=qT(i,i===Mi?s:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),!(s&3)||o1(i,s)||(n=!0,pB(i,s));i=i.next}while(n);b2=!1}}function Zbe(){sZ()}function sZ(){WE=EI=!1;var e=0;of!==0&&lOe()&&(e=of);for(var t=go(),n=null,i=GE;i!==null;){var r=i.next,s=aZ(i,t);s===0?(i.next=null,n===null?GE=r:n.next=r,r===null&&(Em=n)):(n=i,(e!==0||s&3)&&(WE=!0)),i=r}is!==0&&is!==5||p1(e),of!==0&&(of=0)}function aZ(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,s=e.pendingLanes&-62914561;0o)break;var d=c.transferSize,f=c.initiatorType;d&&yB(f)&&(c=c.responseEnd,a+=d*(c"u"?null:document;function mZ(e,t,n){var i=D0;if(i&&typeof t=="string"&&t){var r=zo(t);r='link[rel="'+e+'"][href="'+r+'"]',typeof n=="string"&&(r+='[crossorigin="'+n+'"]'),TB.has(r)||(TB.add(r),e={rel:e,crossOrigin:n,href:t},i.querySelector(r)===null&&(t=i.createElement("link"),Rs(t,"link",e),hs(t),i.head.appendChild(t)))}}function bOe(e){fd.D(e),mZ("dns-prefetch",e,null)}function OOe(e,t){fd.C(e,t),mZ("preconnect",e,t)}function yOe(e,t,n){fd.L(e,t,n);var i=D0;if(i&&e&&t){var r='link[rel="preload"][as="'+zo(t)+'"]';t==="image"&&n&&n.imageSrcSet?(r+='[imagesrcset="'+zo(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(r+='[imagesizes="'+zo(n.imageSizes)+'"]')):r+='[href="'+zo(e)+'"]';var s=r;switch(t){case"style":s=Gg(e);break;case"script":s=$0(e)}rl.has(s)||(e=Ki({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),rl.set(s,e),i.querySelector(r)!==null||t==="style"&&i.querySelector(m1(s))||t==="script"&&i.querySelector(g1(s))||(t=i.createElement("link"),Rs(t,"link",e),hs(t),i.head.appendChild(t)))}}function xOe(e,t){fd.m(e,t);var n=D0;if(n&&e){var i=t&&typeof t.as=="string"?t.as:"script",r='link[rel="modulepreload"][as="'+zo(i)+'"][href="'+zo(e)+'"]',s=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":s=$0(e)}if(!rl.has(s)&&(e=Ki({rel:"modulepreload",href:e},t),rl.set(s,e),n.querySelector(r)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(g1(s)))return}i=n.createElement("link"),Rs(i,"link",e),hs(i),n.head.appendChild(i)}}}function vOe(e,t,n){fd.S(e,t,n);var i=D0;if(i&&e){var r=fg(i).hoistableStyles,s=Gg(e);t=t||"default";var a=r.get(s);if(!a){var o={loading:0,preload:null};if(a=i.querySelector(m1(s)))o.loading=5;else{e=Ki({rel:"stylesheet",href:e,"data-precedence":t},n),(n=rl.get(s))&&G5(e,n);var c=a=i.createElement("link");hs(c),Rs(c,"link",e),c._p=new Promise(function(u,d){c.onload=u,c.onerror=d}),c.addEventListener("load",function(){o.loading|=1}),c.addEventListener("error",function(){o.loading|=2}),o.loading|=4,jS(a,t,i)}a={type:"stylesheet",instance:a,count:1,state:o},r.set(s,a)}}}function wOe(e,t){fd.X(e,t);var n=D0;if(n&&e){var i=fg(n).hoistableScripts,r=$0(e),s=i.get(r);s||(s=n.querySelector(g1(r)),s||(e=Ki({src:e,async:!0},t),(t=rl.get(r))&&W5(e,t),s=n.createElement("script"),hs(s),Rs(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}}function SOe(e,t){fd.M(e,t);var n=D0;if(n&&e){var i=fg(n).hoistableScripts,r=$0(e),s=i.get(r);s||(s=n.querySelector(g1(r)),s||(e=Ki({src:e,async:!0,type:"module"},t),(t=rl.get(r))&&W5(e,t),s=n.createElement("script"),hs(s),Rs(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}}function _B(e,t,n,i){var r=(r=df.current)?JE(r):null;if(!r)throw Error(ze(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Gg(n.href),n=fg(r).hoistableStyles,i=n.get(t),i||(i={type:"style",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Gg(n.href);var s=fg(r).hoistableStyles,a=s.get(e);if(a||(r=r.ownerDocument||r,a={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},s.set(e,a),(s=r.querySelector(m1(e)))&&!s._p&&(a.instance=s,a.state.loading=5),rl.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},rl.set(e,n),s||EOe(r,e,n,a.state))),t&&i===null)throw Error(ze(528,""));return a}if(t&&i!==null)throw Error(ze(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=$0(n),n=fg(r).hoistableScripts,i=n.get(t),i||(i={type:"script",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(ze(444,e))}}function Gg(e){return'href="'+zo(e)+'"'}function m1(e){return'link[rel="stylesheet"]['+e+"]"}function gZ(e){return Ki({},e,{"data-precedence":e.precedence,precedence:null})}function EOe(e,t,n,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Rs(t,"link",n),hs(t),e.head.appendChild(t))}function $0(e){return'[src="'+zo(e)+'"]'}function g1(e){return"script[async]"+e}function AB(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+zo(n.href)+'"]');if(i)return t.instance=i,hs(i),i;var r=Ki({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),hs(i),Rs(i,"style",r),jS(i,n.precedence,e),t.instance=i;case"stylesheet":r=Gg(n.href);var s=e.querySelector(m1(r));if(s)return t.state.loading|=4,t.instance=s,hs(s),s;i=gZ(n),(r=rl.get(r))&&G5(i,r),s=(e.ownerDocument||e).createElement("link"),hs(s);var a=s;return a._p=new Promise(function(o,c){a.onload=o,a.onerror=c}),Rs(s,"link",i),t.state.loading|=4,jS(s,n.precedence,e),t.instance=s;case"script":return s=$0(n.src),(r=e.querySelector(g1(s)))?(t.instance=r,hs(r),r):(i=n,(r=rl.get(s))&&(i=Ki({},n),W5(i,r)),e=e.ownerDocument||e,r=e.createElement("script"),hs(r),Rs(r,"link",i),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(ze(443,t.type))}else t.type==="stylesheet"&&!(t.state.loading&4)&&(i=t.instance,t.state.loading|=4,jS(i,n.precedence,e));return t.instance}function jS(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,s=r,a=0;a title"):null)}function kOe(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function bZ(e){return!(e.type==="stylesheet"&&!(e.state.loading&3))}function TOe(e,t,n,i){if(n.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&!(n.state.loading&4)){if(n.instance===null){var r=Gg(i.href),s=t.querySelector(m1(r));if(s){t=s._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ek.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=s,hs(s);return}s=t.ownerDocument||t,i=gZ(i),(r=rl.get(r))&&G5(i,r),s=s.createElement("link"),hs(s);var a=s;a._p=new Promise(function(o,c){a.onload=o,a.onerror=c}),Rs(s,"link",i),n.instance=s}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ek.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var S2=0;function _Oe(e,t){return e.stylesheets&&e.count===0&&IS(e,e.stylesheets),0S2?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}function ek(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)IS(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var tk=null;function IS(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,tk=new Map,t.forEach(AOe,e),tk=null,ek.call(e))}function AOe(e,t){if(!(t.state.loading&4)){var n=tk.get(e);if(n)var i=n.get(null);else{n=new Map,tk.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kZ)}catch(e){console.error(e)}}kZ(),IY.exports=VT;var LOe=IY.exports;const DOe=N0(LOe),tD=m.createContext({});function l_(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const c_=m.createContext(null),Gy=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class $Oe extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const i=this.props.sizeRef.current;i.height=n.offsetHeight||0,i.width=n.offsetWidth||0,i.top=n.offsetTop,i.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function QOe({children:e,isPresent:t}){const n=m.useId(),i=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=m.useContext(Gy);return m.useInsertionEffect(()=>{const{width:a,height:o,top:c,left:u}=r.current;if(t||!i.current||!a||!o)return;i.current.dataset.motionPopId=n;const d=document.createElement("style");return s&&(d.nonce=s),document.head.appendChild(d),d.sheet&&d.sheet.insertRule(` +`+i.stack}}var HR=Object.prototype.hasOwnProperty,o5=rs.unstable_scheduleCallback,XN=rs.unstable_cancelCallback,g0e=rs.unstable_shouldYield,b0e=rs.unstable_requestPaint,go=rs.unstable_now,O0e=rs.unstable_getCurrentPriorityLevel,HY=rs.unstable_ImmediatePriority,YY=rs.unstable_UserBlockingPriority,RE=rs.unstable_NormalPriority,y0e=rs.unstable_LowPriority,GY=rs.unstable_IdlePriority,x0e=rs.log,v0e=rs.unstable_setDisableYieldValue,a1=null,bo=null;function nf(e){if(typeof x0e=="function"&&v0e(e),bo&&typeof bo.setStrictMode=="function")try{bo.setStrictMode(a1,e)}catch{}}var Oo=Math.clz32?Math.clz32:E0e,w0e=Math.log,S0e=Math.LN2;function E0e(e){return e>>>=0,e===0?32:31-(w0e(e)/S0e|0)|0}var Dv=256,$v=262144,Qv=4194304;function vh(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qT(e,t,n){var i=e.pendingLanes;if(i===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes;e=e.warmLanes;var o=i&134217727;return o!==0?(i=o&~s,i!==0?r=vh(i):(a&=o,a!==0?r=vh(a):n||(n=o&~e,n!==0&&(r=vh(n))))):(o=i&~s,o!==0?r=vh(o):a!==0?r=vh(a):n||(n=i&~e,n!==0&&(r=vh(n)))),r===0?0:t!==0&&t!==r&&!(t&s)&&(s=r&-r,n=t&-t,s>=n||s===32&&(n&4194048)!==0)?t:r}function o1(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function k0e(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function WY(){var e=Qv;return Qv<<=1,!(Qv&62914560)&&(Qv=4194304),e}function qN(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function l1(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function T0e(e,t,n,i,r,s){var a=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,c=e.expirationTimes,u=e.hiddenUpdates;for(n=a&~n;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var R0e=/[\n"\\]/g;function zo(e){return e.replace(R0e,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function WR(e,t,n,i,r,s,a,o){e.name="",a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"?e.type=a:e.removeAttribute("type"),t!=null?a==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Do(t)):e.value!==""+Do(t)&&(e.value=""+Do(t)):a!=="submit"&&a!=="reset"||e.removeAttribute("value"),t!=null?ZR(e,a,Do(t)):n!=null?ZR(e,a,Do(n)):i!=null&&e.removeAttribute("value"),r==null&&s!=null&&(e.defaultChecked=!!s),r!=null&&(e.checked=r&&typeof r!="function"&&typeof r!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?e.name=""+Do(o):e.removeAttribute("name")}function sG(e,t,n,i,r,s,a,o){if(s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.type=s),t!=null||n!=null){if(!(s!=="submit"&&s!=="reset"||t!=null)){GR(e);return}n=n!=null?""+Do(n):"",t=t!=null?""+Do(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i=i??r,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"&&(e.name=a),GR(e)}function ZR(e,t,n){t==="number"&&IE(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function hg(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),JR=!1;if(Gu)try{var $b={};Object.defineProperty($b,"passive",{get:function(){JR=!0}}),window.addEventListener("test",$b,$b),window.removeEventListener("test",$b,$b)}catch{JR=!1}var rf=null,h5=null,wS=null;function uG(){if(wS)return wS;var e,t=h5,n=t.length,i,r="value"in rf?rf.value:rf.textContent,s=r.length;for(e=0;e=FO),_6=" ",A6=!1;function fG(e,t){switch(e){case"keyup":return abe.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hG(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bm=!1;function lbe(e,t){switch(e){case"compositionend":return hG(t);case"keypress":return t.which!==32?null:(A6=!0,_6);case"textInput":return e=t.data,e===_6&&A6?null:e;default:return null}}function cbe(e,t){if(Bm)return e==="compositionend"||!m5&&fG(e,t)?(e=uG(),wS=h5=rf=null,Bm=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=I6(n)}}function bG(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?bG(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function OG(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=IE(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=IE(e.document)}return t}function g5(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var bbe=Gu&&"documentMode"in document&&11>=document.documentMode,Um=null,eI=null,XO=null,tI=!1;function M6(e,t,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;tI||Um==null||Um!==IE(i)||(i=Um,"selectionStart"in i&&g5(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),XO&&$y(XO,i)||(XO=i,i=ZE(eI,"onSelect"),0>=a,r-=a,kc=1<<32-Oo(t)+r|n<T?(A=k,k=null):A=k.sibling;var N=h(O,k,x[T],w);if(N===null){k===null&&(k=A);break}e&&k&&N.alternate===null&&t(O,k),v=s(N,v,T),S===null?E=N:S.sibling=N,S=N,k=A}if(T===x.length)return n(O,k),Xn&&Tu(O,T),E;if(k===null){for(;TT?(A=k,k=null):A=k.sibling;var C=h(O,k,N.value,w);if(C===null){k===null&&(k=A);break}e&&k&&C.alternate===null&&t(O,k),v=s(C,v,T),S===null?E=C:S.sibling=C,S=C,k=A}if(N.done)return n(O,k),Xn&&Tu(O,T),E;if(k===null){for(;!N.done;T++,N=x.next())N=f(O,N.value,w),N!==null&&(v=s(N,v,T),S===null?E=N:S.sibling=N,S=N);return Xn&&Tu(O,T),E}for(k=i(k);!N.done;T++,N=x.next())N=p(k,O,T,N.value,w),N!==null&&(e&&N.alternate!==null&&k.delete(N.key===null?T:N.key),v=s(N,v,T),S===null?E=N:S.sibling=N,S=N);return e&&k.forEach(function(M){return t(O,M)}),Xn&&Tu(O,T),E}function y(O,v,x,w){if(typeof x=="object"&&x!==null&&x.type===Lm&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Lv:e:{for(var E=x.key;v!==null;){if(v.key===E){if(E=x.type,E===Lm){if(v.tag===7){n(O,v.sibling),w=r(v,x.props.children),w.return=O,O=w;break e}}else if(v.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===zd&&wh(E)===v.type){n(O,v.sibling),w=r(v,x.props),Bb(w,x),w.return=O,O=w;break e}n(O,v);break}else t(O,v);v=v.sibling}x.type===Lm?(w=Wh(x.props.children,O.mode,w,x.key),w.return=O,O=w):(w=ES(x.type,x.key,x.props,null,O.mode,w),Bb(w,x),w.return=O,O=w)}return a(O);case OO:e:{for(E=x.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){n(O,v.sibling),w=r(v,x.children||[]),w.return=O,O=w;break e}else{n(O,v);break}else t(O,v);v=v.sibling}w=t2(x,O.mode,w),w.return=O,O=w}return a(O);case zd:return x=wh(x),y(O,v,x,w)}if(yO(x))return g(O,v,x,w);if(Db(x)){if(E=Db(x),typeof E!="function")throw Error(ze(150));return x=E.call(x),b(O,v,x,w)}if(typeof x.then=="function")return y(O,v,Fv(x),w);if(x.$$typeof===ju)return y(O,v,zv(O,x),w);Vv(O,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,v!==null&&v.tag===6?(n(O,v.sibling),w=r(v,x),w.return=O,O=w):(n(O,v),w=e2(x,O.mode,w),w.return=O,O=w),a(O)):n(O,v)}return function(O,v,x,w){try{Uy=0;var E=y(O,v,x,w);return gg=null,E}catch(k){if(k===M0||k===KT)throw k;var S=uo(29,k,null,O.mode);return S.lanes=w,S.return=O,S}finally{}}}var hp=IG(!0),PG=IG(!1),Fd=!1;function k5(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lI(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function hf(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function pf(e,t,n){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,ai&2){var r=i.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=ME(e),kG(e,null,n),t}return ZT(e,i,t,n),ME(e)}function HO(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,KY(e,n)}}function i2(e,t){var n=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var r=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};s===null?r=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?r=s=t:s=s.next=t}else r=s=t;n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,callbacks:i.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var cI=!1;function YO(){if(cI){var e=mg;if(e!==null)throw e}}function GO(e,t,n,i){cI=!1;var r=e.updateQueue;Fd=!1;var s=r.firstBaseUpdate,a=r.lastBaseUpdate,o=r.shared.pending;if(o!==null){r.shared.pending=null;var c=o,u=c.next;c.next=null,a===null?s=u:a.next=u,a=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==a&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(s!==null){var f=r.baseState;a=0,d=u=c=null,o=s;do{var h=o.lane&-536870913,p=h!==o.lane;if(p?(Un&h)===h:(i&h)===h){h!==0&&h===Fg&&(cI=!0),d!==null&&(d=d.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var g=e,b=o;h=t;var y=n;switch(b.tag){case 1:if(g=b.payload,typeof g=="function"){f=g.call(y,f,h);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,h=typeof g=="function"?g.call(y,f,h):g,h==null)break e;f=Ki({},f,h);break e;case 2:Fd=!0}}h=o.callback,h!==null&&(e.flags|=64,p&&(e.flags|=8192),p=r.callbacks,p===null?r.callbacks=[h]:p.push(h))}else p={lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=p,c=f):d=d.next=p,a|=h;if(o=o.next,o===null){if(o=r.shared.pending,o===null)break;p=o,o=p.next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}while(!0);d===null&&(c=f),r.baseState=c,r.firstBaseUpdate=u,r.lastBaseUpdate=d,s===null&&(r.shared.lanes=0),Cf|=a,e.lanes=a,e.memoizedState=f}}function MG(e,t){if(typeof e!="function")throw Error(ze(191,e));e.call(t)}function LG(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;es?s:8;var a=Zt.T,o={};Zt.T=o,$5(e,!1,t,n);try{var c=r(),u=Zt.S;if(u!==null&&u(o,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=Tbe(c,i);WO(e,t,d,yo(e))}else WO(e,t,i,yo(e))}catch(f){WO(e,t,{then:function(){},status:"rejected",reason:f},yo())}finally{ci.p=s,a!==null&&o.types!==null&&(a.types=o.types),Zt.T=a}}function Rbe(){}function pI(e,t,n,i){if(e.tag!==5)throw Error(ze(476));var r=oW(e).queue;aW(e,r,t,Gh,n===null?Rbe:function(){return lW(e),n(i)})}function oW(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Gh,baseState:Gh,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zu,lastRenderedState:Gh},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zu,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function lW(e){var t=oW(e);t.next===null&&(t=e.alternate.memoizedState),WO(e,t.next.queue,{},yo())}function D5(){return js(qy)}function cW(){return Ir().memoizedState}function uW(){return Ir().memoizedState}function Ibe(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=yo();e=hf(n);var i=pf(t,e,n);i!==null&&(Ua(i,t,n),HO(i,t,n)),t={cache:w5()},e.payload=t;return}t=t.return}}function Pbe(e,t,n){var i=yo();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},n_(e)?fW(t,n):(n=O5(e,t,n,i),n!==null&&(Ua(n,e,i),hW(n,t,i)))}function dW(e,t,n){var i=yo();WO(e,t,n,i)}function WO(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(n_(e))fW(t,r);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,o=s(a,n);if(r.hasEagerState=!0,r.eagerState=o,So(o,a))return ZT(e,t,r,0),Mi===null&&WT(),!1}catch{}finally{}if(n=O5(e,t,r,i),n!==null)return Ua(n,e,i),hW(n,t,i),!0}return!1}function $5(e,t,n,i){if(i={lane:2,revertLane:H5(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},n_(e)){if(t)throw Error(ze(479))}else t=O5(e,n,i,2),t!==null&&Ua(t,e,2)}function n_(e){var t=e.alternate;return e===hn||t!==null&&t===hn}function fW(e,t){bg=UE=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hW(e,t,n){if(n&4194048){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,KY(e,n)}}var Fy={readContext:js,use:e_,useCallback:yr,useContext:yr,useEffect:yr,useImperativeHandle:yr,useLayoutEffect:yr,useInsertionEffect:yr,useMemo:yr,useReducer:yr,useRef:yr,useState:yr,useDebugValue:yr,useDeferredValue:yr,useTransition:yr,useSyncExternalStore:yr,useId:yr,useHostTransitionStatus:yr,useFormState:yr,useActionState:yr,useOptimistic:yr,useMemoCache:yr,useCacheRefresh:yr};Fy.useEffectEvent=yr;var pW={readContext:js,use:e_,useCallback:function(e,t){return ua().memoizedState=[e,t===void 0?null:t],e},useContext:js,useEffect:W6,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,_S(4194308,4,tW.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _S(4194308,4,e,t)},useInsertionEffect:function(e,t){_S(4,2,e,t)},useMemo:function(e,t){var n=ua();t=t===void 0?null:t;var i=e();if(pp){nf(!0);try{e()}finally{nf(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=ua();if(n!==void 0){var r=n(t);if(pp){nf(!0);try{n(t)}finally{nf(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=Pbe.bind(null,hn,e),[i.memoizedState,e]},useRef:function(e){var t=ua();return e={current:e},t.memoizedState=e},useState:function(e){e=fI(e);var t=e.queue,n=dW.bind(null,hn,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:M5,useDeferredValue:function(e,t){var n=ua();return L5(n,e,t)},useTransition:function(){var e=fI(!1);return e=aW.bind(null,hn,e.queue,!0,!1),ua().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var i=hn,r=ua();if(Xn){if(n===void 0)throw Error(ze(407));n=n()}else{if(n=t(),Mi===null)throw Error(ze(349));Un&127||UG(i,t,n)}r.memoizedState=n;var s={value:n,getSnapshot:t};return r.queue=s,W6(FG.bind(null,i,s,e),[e]),i.flags|=2048,Xg(9,{destroy:void 0},zG.bind(null,i,s,n,t),null),n},useId:function(){var e=ua(),t=Mi.identifierPrefix;if(Xn){var n=Tc,i=kc;n=(i&~(1<<32-Oo(i)-1)).toString(32)+n,t="_"+t+"R_"+n,n=zE++,0<\/script>",s=s.removeChild(s.firstChild);break;case"select":s=typeof i.is=="string"?a.createElement("select",{is:i.is}):a.createElement("select"),i.multiple?s.multiple=!0:i.size&&(s.size=i.size);break;default:s=typeof i.is=="string"?a.createElement(r,{is:i.is}):a.createElement(r)}}s[As]=t,s[Xa]=i;e:for(a=t.child;a!==null;){if(a.tag===5||a.tag===6)s.appendChild(a.stateNode);else if(a.tag!==4&&a.tag!==27&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break e;for(;a.sibling===null;){if(a.return===null||a.return===t)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}t.stateNode=s;e:switch(Rs(s,r,i),r){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&du(t)}}return Yi(t),d2(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&du(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(ze(166));if(e=df.current,em(t)){if(e=t.stateNode,n=t.memoizedProps,i=null,r=Ns,r!==null)switch(r.tag){case 27:case 5:i=r.memoizedProps}e[As]=t,e=!!(e.nodeValue===n||i!==null&&i.suppressHydrationWarning===!0||dZ(e.nodeValue,n)),e||Af(t,!0)}else e=KE(e).createTextNode(i),e[As]=t,t.stateNode=e}return Yi(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=em(t),n!==null){if(e===null){if(!i)throw Error(ze(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ze(557));e[As]=t}else dp(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yi(t),e=!1}else n=n2(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(co(t),t):(co(t),null);if(t.flags&128)throw Error(ze(558))}return Yi(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(r=em(t),i!==null&&i.dehydrated!==null){if(e===null){if(!r)throw Error(ze(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(ze(317));r[As]=t}else dp(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yi(t),r=!1}else r=n2(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return t.flags&256?(co(t),t):(co(t),null)}return co(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,r=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(r=i.alternate.memoizedState.cachePool.pool),s=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(s=i.memoizedState.cachePool.pool),s!==r&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Xv(t,t.updateQueue),Yi(t),null);case 4:return Bg(),e===null&&Y5(t.stateNode.containerInfo),Yi(t),null;case 10:return $u(t.type),Yi(t),null;case 19:if(ys(Cr),i=t.memoizedState,i===null)return Yi(t),null;if(r=(t.flags&128)!==0,s=i.rendering,s===null)if(r)Ub(i,!1);else{if(vr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=BE(e),s!==null){for(t.flags|=128,Ub(i,!1),e=s.updateQueue,t.updateQueue=e,Xv(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)TG(n,e),n=n.sibling;return Ui(Cr,Cr.current&1|2),Xn&&Tu(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&go()>qE&&(t.flags|=128,r=!0,Ub(i,!1),t.lanes=4194304)}else{if(!r)if(e=BE(s),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,Xv(t,e),Ub(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!Xn)return Yi(t),null}else 2*go()-i.renderingStartTime>qE&&n!==536870912&&(t.flags|=128,r=!0,Ub(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(e=i.last,e!==null?e.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=go(),e.sibling=null,n=Cr.current,Ui(Cr,r?n&1|2:n&1),Xn&&Tu(t,i.treeForkCount),e):(Yi(t),null);case 22:case 23:return co(t),T5(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Yi(t),t.subtreeFlags&6&&(t.flags|=8192)):Yi(t),n=t.updateQueue,n!==null&&Xv(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&ys(Zh),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$u(Fr),Yi(t),null;case 25:return null;case 30:return null}throw Error(ze(156,t.tag))}function Qbe(e,t){switch(v5(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $u(Fr),Bg(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return jE(t),null;case 31:if(t.memoizedState!==null){if(co(t),t.alternate===null)throw Error(ze(340));dp()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(co(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ze(340));dp()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ys(Cr),null;case 4:return Bg(),null;case 10:return $u(t.type),null;case 22:case 23:return co(t),T5(),e!==null&&ys(Zh),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return $u(Fr),null;case 25:return null;default:return null}}function TW(e,t){switch(v5(t),t.tag){case 3:$u(Fr),Bg();break;case 26:case 27:case 5:jE(t);break;case 4:Bg();break;case 31:t.memoizedState!==null&&co(t);break;case 13:co(t);break;case 19:ys(Cr);break;case 10:$u(t.type);break;case 22:case 23:co(t),T5(),e!==null&&ys(Zh);break;case 24:$u(Fr)}}function h1(e,t){try{var n=t.updateQueue,i=n!==null?n.lastEffect:null;if(i!==null){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var s=n.create,a=n.inst;i=s(),a.destroy=i}n=n.next}while(n!==r)}}catch(o){xi(t,t.return,o)}}function Nf(e,t,n){try{var i=t.updateQueue,r=i!==null?i.lastEffect:null;if(r!==null){var s=r.next;i=s;do{if((i.tag&e)===e){var a=i.inst,o=a.destroy;if(o!==void 0){a.destroy=void 0,r=t;var c=n,u=o;try{u()}catch(d){xi(r,c,d)}}}i=i.next}while(i!==s)}}catch(d){xi(t,t.return,d)}}function _W(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{LG(t,n)}catch(i){xi(e,e.return,i)}}}function AW(e,t,n){n.props=mp(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(i){xi(e,t,i)}}function ZO(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof n=="function"?e.refCleanup=n(i):n.current=i}}catch(r){xi(e,t,r)}}function _c(e,t){var n=e.ref,i=e.refCleanup;if(n!==null)if(typeof i=="function")try{i()}catch(r){xi(e,t,r)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(r){xi(e,t,r)}else n.current=null}function NW(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(r){xi(e,e.return,r)}}function f2(e,t,n){try{var i=e.stateNode;oOe(i,e.type,n,t),i[Xa]=t}catch(r){xi(e,e.return,r)}}function CW(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zf(e.type)||e.tag===4}function h2(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||CW(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zf(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function yI(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ru));else if(i!==4&&(i===27&&Zf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(yI(e,t,n),e=e.sibling;e!==null;)yI(e,t,n),e=e.sibling}function XE(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(i!==4&&(i===27&&Zf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(XE(e,t,n),e=e.sibling;e!==null;)XE(e,t,n),e=e.sibling}function jW(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Rs(t,i,n),t[As]=e,t[Xa]=n}catch(s){xi(e,e.return,s)}}var Au=!1,zr=!1,p2=!1,cB=typeof WeakSet=="function"?WeakSet:Set,us=null;function Bbe(e,t){if(e=e.containerInfo,TI=nk,e=OG(e),g5(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var p;f!==n||r!==0&&f.nodeType!==3||(o=a+r),f!==s||i!==0&&f.nodeType!==3||(c=a+i),f.nodeType===3&&(a+=f.nodeValue.length),(p=f.firstChild)!==null;)h=f,f=p;for(;;){if(f===e)break t;if(h===n&&++u===r&&(o=a),h===s&&++d===i&&(c=a),(p=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=p}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(_I={focusedElem:e,selectionRange:n},nk=!1,us=t;us!==null;)if(t=us,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,us=e;else for(;us!==null;){switch(t=us,s=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n title"))),Rs(s,i,n),s[As]=e,hs(s),i=s;break e;case"link":var a=NB("link","href",r).get(i+(n.href||""));if(a){for(var o=0;oy&&(a=y,y=b,b=a);var O=P6(o,b),v=P6(o,y);if(O&&v&&(p.rangeCount!==1||p.anchorNode!==O.node||p.anchorOffset!==O.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var x=f.createRange();x.setStart(O.node,O.offset),p.removeAllRanges(),b>y?(p.addRange(x),p.extend(v.node,v.offset)):(x.setEnd(v.node,v.offset),p.addRange(x))}}}}for(f=[],p=o;p=p.parentNode;)p.nodeType===1&&f.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;on?32:n,Zt.T=null,n=wI,wI=null;var s=gf,a=Qu;if(is=0,Hg=gf=null,Qu=0,ai&6)throw Error(ze(331));var o=ai;if(ai|=4,zW(s.current),QW(s,s.current,a,n),ai=o,p1(0,!1),bo&&typeof bo.onPostCommitFiberRoot=="function")try{bo.onPostCommitFiberRoot(a1,s)}catch{}return!0}finally{ci.p=r,Zt.T=i,iZ(e,t)}}function hB(e,t,n){t=Fo(n,t),t=gI(e.stateNode,t,2),e=pf(e,t,2),e!==null&&(l1(e,2),qc(e))}function xi(e,t,n){if(e.tag===3)hB(e,e,n);else for(;t!==null;){if(t.tag===3){hB(t,e,n);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(mf===null||!mf.has(i))){e=Fo(n,e),n=yW(2),i=pf(t,n,2),i!==null&&(xW(n,i,t,e),l1(i,2),qc(i));break}}t=t.return}}function g2(e,t,n){var i=e.pingCache;if(i===null){i=e.pingCache=new Fbe;var r=new Set;i.set(t,r)}else r=i.get(t),r===void 0&&(r=new Set,i.set(t,r));r.has(n)||(V5=!0,r.add(n),e=Ybe.bind(null,e,t,n),t.then(e,e))}function Ybe(e,t,n){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Mi===e&&(Un&n)===n&&(vr===4||vr===3&&(Un&62914560)===Un&&300>go()-i_?!(ai&2)&&Yg(e,0):X5|=n,qg===Un&&(qg=0)),qc(e)}function sZ(e,t){t===0&&(t=WY()),e=Pp(e,t),e!==null&&(l1(e,t),qc(e))}function Gbe(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sZ(e,n)}function Wbe(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,r=e.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(ze(314))}i!==null&&i.delete(t),sZ(e,n)}function Zbe(e,t){return o5(e,t)}var GE=null,Em=null,EI=!1,WE=!1,b2=!1,of=0;function qc(e){e!==Em&&e.next===null&&(Em===null?GE=Em=e:Em=Em.next=e),WE=!0,EI||(EI=!0,Jbe())}function p1(e,t){if(!b2&&WE){b2=!0;do for(var n=!1,i=GE;i!==null;){if(e!==0){var r=i.pendingLanes;if(r===0)var s=0;else{var a=i.suspendedLanes,o=i.pingedLanes;s=(1<<31-Oo(42|e)+1)-1,s&=r&~(a&~o),s=s&201326741?s&201326741|1:s?s|2:0}s!==0&&(n=!0,pB(i,s))}else s=Un,s=qT(i,i===Mi?s:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),!(s&3)||o1(i,s)||(n=!0,pB(i,s));i=i.next}while(n);b2=!1}}function Kbe(){aZ()}function aZ(){WE=EI=!1;var e=0;of!==0&&cOe()&&(e=of);for(var t=go(),n=null,i=GE;i!==null;){var r=i.next,s=oZ(i,t);s===0?(i.next=null,n===null?GE=r:n.next=r,r===null&&(Em=n)):(n=i,(e!==0||s&3)&&(WE=!0)),i=r}is!==0&&is!==5||p1(e),of!==0&&(of=0)}function oZ(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,s=e.pendingLanes&-62914561;0o)break;var d=c.transferSize,f=c.initiatorType;d&&yB(f)&&(c=c.responseEnd,a+=d*(c"u"?null:document;function gZ(e,t,n){var i=D0;if(i&&typeof t=="string"&&t){var r=zo(t);r='link[rel="'+e+'"][href="'+r+'"]',typeof n=="string"&&(r+='[crossorigin="'+n+'"]'),TB.has(r)||(TB.add(r),e={rel:e,crossOrigin:n,href:t},i.querySelector(r)===null&&(t=i.createElement("link"),Rs(t,"link",e),hs(t),i.head.appendChild(t)))}}function OOe(e){fd.D(e),gZ("dns-prefetch",e,null)}function yOe(e,t){fd.C(e,t),gZ("preconnect",e,t)}function xOe(e,t,n){fd.L(e,t,n);var i=D0;if(i&&e&&t){var r='link[rel="preload"][as="'+zo(t)+'"]';t==="image"&&n&&n.imageSrcSet?(r+='[imagesrcset="'+zo(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(r+='[imagesizes="'+zo(n.imageSizes)+'"]')):r+='[href="'+zo(e)+'"]';var s=r;switch(t){case"style":s=Gg(e);break;case"script":s=$0(e)}rl.has(s)||(e=Ki({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),rl.set(s,e),i.querySelector(r)!==null||t==="style"&&i.querySelector(m1(s))||t==="script"&&i.querySelector(g1(s))||(t=i.createElement("link"),Rs(t,"link",e),hs(t),i.head.appendChild(t)))}}function vOe(e,t){fd.m(e,t);var n=D0;if(n&&e){var i=t&&typeof t.as=="string"?t.as:"script",r='link[rel="modulepreload"][as="'+zo(i)+'"][href="'+zo(e)+'"]',s=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":s=$0(e)}if(!rl.has(s)&&(e=Ki({rel:"modulepreload",href:e},t),rl.set(s,e),n.querySelector(r)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(g1(s)))return}i=n.createElement("link"),Rs(i,"link",e),hs(i),n.head.appendChild(i)}}}function wOe(e,t,n){fd.S(e,t,n);var i=D0;if(i&&e){var r=fg(i).hoistableStyles,s=Gg(e);t=t||"default";var a=r.get(s);if(!a){var o={loading:0,preload:null};if(a=i.querySelector(m1(s)))o.loading=5;else{e=Ki({rel:"stylesheet",href:e,"data-precedence":t},n),(n=rl.get(s))&&G5(e,n);var c=a=i.createElement("link");hs(c),Rs(c,"link",e),c._p=new Promise(function(u,d){c.onload=u,c.onerror=d}),c.addEventListener("load",function(){o.loading|=1}),c.addEventListener("error",function(){o.loading|=2}),o.loading|=4,jS(a,t,i)}a={type:"stylesheet",instance:a,count:1,state:o},r.set(s,a)}}}function SOe(e,t){fd.X(e,t);var n=D0;if(n&&e){var i=fg(n).hoistableScripts,r=$0(e),s=i.get(r);s||(s=n.querySelector(g1(r)),s||(e=Ki({src:e,async:!0},t),(t=rl.get(r))&&W5(e,t),s=n.createElement("script"),hs(s),Rs(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}}function EOe(e,t){fd.M(e,t);var n=D0;if(n&&e){var i=fg(n).hoistableScripts,r=$0(e),s=i.get(r);s||(s=n.querySelector(g1(r)),s||(e=Ki({src:e,async:!0,type:"module"},t),(t=rl.get(r))&&W5(e,t),s=n.createElement("script"),hs(s),Rs(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},i.set(r,s))}}function _B(e,t,n,i){var r=(r=df.current)?JE(r):null;if(!r)throw Error(ze(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Gg(n.href),n=fg(r).hoistableStyles,i=n.get(t),i||(i={type:"style",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Gg(n.href);var s=fg(r).hoistableStyles,a=s.get(e);if(a||(r=r.ownerDocument||r,a={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},s.set(e,a),(s=r.querySelector(m1(e)))&&!s._p&&(a.instance=s,a.state.loading=5),rl.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},rl.set(e,n),s||kOe(r,e,n,a.state))),t&&i===null)throw Error(ze(528,""));return a}if(t&&i!==null)throw Error(ze(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=$0(n),n=fg(r).hoistableScripts,i=n.get(t),i||(i={type:"script",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(ze(444,e))}}function Gg(e){return'href="'+zo(e)+'"'}function m1(e){return'link[rel="stylesheet"]['+e+"]"}function bZ(e){return Ki({},e,{"data-precedence":e.precedence,precedence:null})}function kOe(e,t,n,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Rs(t,"link",n),hs(t),e.head.appendChild(t))}function $0(e){return'[src="'+zo(e)+'"]'}function g1(e){return"script[async]"+e}function AB(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+zo(n.href)+'"]');if(i)return t.instance=i,hs(i),i;var r=Ki({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),hs(i),Rs(i,"style",r),jS(i,n.precedence,e),t.instance=i;case"stylesheet":r=Gg(n.href);var s=e.querySelector(m1(r));if(s)return t.state.loading|=4,t.instance=s,hs(s),s;i=bZ(n),(r=rl.get(r))&&G5(i,r),s=(e.ownerDocument||e).createElement("link"),hs(s);var a=s;return a._p=new Promise(function(o,c){a.onload=o,a.onerror=c}),Rs(s,"link",i),t.state.loading|=4,jS(s,n.precedence,e),t.instance=s;case"script":return s=$0(n.src),(r=e.querySelector(g1(s)))?(t.instance=r,hs(r),r):(i=n,(r=rl.get(s))&&(i=Ki({},n),W5(i,r)),e=e.ownerDocument||e,r=e.createElement("script"),hs(r),Rs(r,"link",i),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(ze(443,t.type))}else t.type==="stylesheet"&&!(t.state.loading&4)&&(i=t.instance,t.state.loading|=4,jS(i,n.precedence,e));return t.instance}function jS(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,s=r,a=0;a title"):null)}function TOe(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function OZ(e){return!(e.type==="stylesheet"&&!(e.state.loading&3))}function _Oe(e,t,n,i){if(n.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&!(n.state.loading&4)){if(n.instance===null){var r=Gg(i.href),s=t.querySelector(m1(r));if(s){t=s._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ek.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=s,hs(s);return}s=t.ownerDocument||t,i=bZ(i),(r=rl.get(r))&&G5(i,r),s=s.createElement("link"),hs(s);var a=s;a._p=new Promise(function(o,c){a.onload=o,a.onerror=c}),Rs(s,"link",i),n.instance=s}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ek.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var S2=0;function AOe(e,t){return e.stylesheets&&e.count===0&&IS(e,e.stylesheets),0S2?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}function ek(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)IS(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var tk=null;function IS(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,tk=new Map,t.forEach(NOe,e),tk=null,ek.call(e))}function NOe(e,t){if(!(t.state.loading&4)){var n=tk.get(e);if(n)var i=n.get(null);else{n=new Map,tk.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(TZ)}catch(e){console.error(e)}}TZ(),PY.exports=VT;var DOe=PY.exports;const $Oe=N0(DOe),tD=m.createContext({});function l_(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const c_=m.createContext(null),Gy=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class QOe extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const i=this.props.sizeRef.current;i.height=n.offsetHeight||0,i.width=n.offsetWidth||0,i.top=n.offsetTop,i.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function BOe({children:e,isPresent:t}){const n=m.useId(),i=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=m.useContext(Gy);return m.useInsertionEffect(()=>{const{width:a,height:o,top:c,left:u}=r.current;if(t||!i.current||!a||!o)return;i.current.dataset.motionPopId=n;const d=document.createElement("style");return s&&(d.nonce=s),document.head.appendChild(d),d.sheet&&d.sheet.insertRule(` [data-motion-pop-id="${n}"] { position: absolute !important; width: ${a}px !important; @@ -55,37 +55,37 @@ Error generating stack: `+i.message+` top: ${c}px !important; left: ${u}px !important; } - `),()=>{document.head.removeChild(d)}},[t]),l.jsx($Oe,{isPresent:t,childRef:i,sizeRef:r,children:m.cloneElement(e,{ref:i})})}const BOe=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:a})=>{const o=l_(UOe),c=m.useId(),u=m.useCallback(f=>{o.set(f,!0);for(const h of o.values())if(!h)return;i&&i()},[o,i]),d=m.useMemo(()=>({id:c,initial:t,isPresent:n,custom:r,onExitComplete:u,register:f=>(o.set(f,!1),()=>o.delete(f))}),s?[Math.random(),u]:[n,u]);return m.useMemo(()=>{o.forEach((f,h)=>o.set(h,!1))},[n]),m.useEffect(()=>{!n&&!o.size&&i&&i()},[n]),a==="popLayout"&&(e=l.jsx(QOe,{isPresent:n,children:e})),l.jsx(c_.Provider,{value:d,children:e})};function UOe(){return new Map}function TZ(e=!0){const t=m.useContext(c_);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=t,s=m.useId();m.useEffect(()=>{e&&r(s)},[e]);const a=m.useCallback(()=>e&&i&&i(s),[s,i,e]);return!n&&i?[!1,a]:[!0]}const Zv=e=>e.key||"";function DB(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const nD=typeof window<"u",_Z=nD?m.useLayoutEffect:m.useEffect,xf=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:s="sync",propagate:a=!1})=>{const[o,c]=TZ(a),u=m.useMemo(()=>DB(e),[e]),d=a&&!o?[]:u.map(Zv),f=m.useRef(!0),h=m.useRef(u),p=l_(()=>new Map),[g,b]=m.useState(u),[y,O]=m.useState(u);_Z(()=>{f.current=!1,h.current=u;for(let w=0;w{const E=Zv(w),S=a&&!o?!1:u===y||d.includes(E),k=()=>{if(p.has(E))p.set(E,!0);else return;let T=!0;p.forEach(A=>{A||(T=!1)}),T&&(x==null||x(),O(h.current),a&&(c==null||c()),i&&i())};return l.jsx(BOe,{isPresent:S,initial:!f.current||n?void 0:!1,custom:S?void 0:t,presenceAffectsLayout:r,mode:s,onExitComplete:S?void 0:k,children:w},E)})})},xo=e=>e;let AZ=xo;const zOe={useManualTiming:!1};function FOe(e){let t=new Set,n=new Set,i=!1,r=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function o(u){s.has(u)&&(c.schedule(u),e()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const p=f&&i?t:n;return d&&s.add(u),p.has(u)||p.add(u),u},cancel:u=>{n.delete(u),s.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[t,n]=[n,t],t.forEach(o),t.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const Kv=["read","resolveKeyframes","update","preRender","render","postRender"],VOe=40;function NZ(e,t){let n=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,a=Kv.reduce((O,v)=>(O[v]=FOe(s),O),{}),{read:o,resolveKeyframes:c,update:u,preRender:d,render:f,postRender:h}=a,p=()=>{const O=performance.now();n=!1,r.delta=i?1e3/60:Math.max(Math.min(O-r.timestamp,VOe),1),r.timestamp=O,r.isProcessing=!0,o.process(r),c.process(r),u.process(r),d.process(r),f.process(r),h.process(r),r.isProcessing=!1,n&&t&&(i=!1,e(p))},g=()=>{n=!0,i=!0,r.isProcessing||e(p)};return{schedule:Kv.reduce((O,v)=>{const x=a[v];return O[v]=(w,E=!1,S=!1)=>(n||g(),x.schedule(w,E,S)),O},{}),cancel:O=>{for(let v=0;v$B[e].some(n=>!!t[n])};function XOe(e){for(const t in e)Zg[t]={...Zg[t],...e[t]}}const qOe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function rk(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||qOe.has(e)}let jZ=e=>!rk(e);function RZ(e){e&&(jZ=t=>t.startsWith("on")?!rk(t):e(t))}try{RZ(require("@emotion/is-prop-valid").default)}catch{}function HOe(e,t,n){const i={};for(const r in e)r==="values"&&typeof e.values=="object"||(jZ(r)||n===!0&&rk(r)||!t&&!rk(r)||e.draggable&&r.startsWith("onDrag"))&&(i[r]=e[r]);return i}function YOe({children:e,isValidProp:t,...n}){t&&RZ(t),n={...m.useContext(Gy),...n},n.isStatic=l_(()=>n.isStatic);const i=m.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return l.jsx(Gy.Provider,{value:i,children:e})}function GOe(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...i)=>e(...i);return new Proxy(n,{get:(i,r)=>r==="create"?e:(t.has(r)||t.set(r,e(r)),t.get(r))})}const u_=m.createContext({});function Wy(e){return typeof e=="string"||Array.isArray(e)}function d_(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const iD=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],rD=["initial",...iD];function f_(e){return d_(e.animate)||rD.some(t=>Wy(e[t]))}function IZ(e){return!!(f_(e)||e.variants)}function WOe(e,t){if(f_(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Wy(n)?n:void 0,animate:Wy(i)?i:void 0}}return e.inherit!==!1?t:{}}function ZOe(e){const{initial:t,animate:n}=WOe(e,m.useContext(u_));return m.useMemo(()=>({initial:t,animate:n}),[QB(t),QB(n)])}function QB(e){return Array.isArray(e)?e.join(" "):e}const KOe=Symbol.for("motionComponentSymbol");function Ym(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function JOe(e,t,n){return m.useCallback(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):Ym(n)&&(n.current=i))},[t])}const sD=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),eye="framerAppearId",PZ="data-"+sD(eye),{schedule:aD}=NZ(queueMicrotask,!1),MZ=m.createContext({});function tye(e,t,n,i,r){var s,a;const{visualElement:o}=m.useContext(u_),c=m.useContext(CZ),u=m.useContext(c_),d=m.useContext(Gy).reducedMotion,f=m.useRef(null);i=i||c.renderer,!f.current&&i&&(f.current=i(e,{visualState:t,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:d}));const h=f.current,p=m.useContext(MZ);h&&!h.projection&&r&&(h.type==="html"||h.type==="svg")&&nye(f.current,n,r,p);const g=m.useRef(!1);m.useInsertionEffect(()=>{h&&g.current&&h.update(n,u)});const b=n[PZ],y=m.useRef(!!b&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,b))&&((a=window.MotionHasOptimisedAnimation)===null||a===void 0?void 0:a.call(window,b)));return _Z(()=>{h&&(g.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),aD.render(h.render),y.current&&h.animationState&&h.animationState.animateChanges())}),m.useEffect(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{var O;(O=window.MotionHandoffMarkAsComplete)===null||O===void 0||O.call(window,b)}),y.current=!1))}),h}function nye(e,t,n,i){const{layoutId:r,layout:s,drag:a,dragConstraints:o,layoutScroll:c,layoutRoot:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:LZ(e.parent)),e.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:!!a||o&&Ym(o),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:i,layoutScroll:c,layoutRoot:u})}function LZ(e){if(e)return e.options.allowProjection!==!1?e.projection:LZ(e.parent)}function iye({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:r}){var s,a;e&&XOe(e);function o(u,d){let f;const h={...m.useContext(Gy),...u,layoutId:rye(u)},{isStatic:p}=h,g=ZOe(u),b=i(u,p);if(!p&&nD){sye();const y=aye(h);f=y.MeasureLayout,g.visualElement=tye(r,b,h,t,y.ProjectionNode)}return l.jsxs(u_.Provider,{value:g,children:[f&&g.visualElement?l.jsx(f,{visualElement:g.visualElement,...h}):null,n(r,u,JOe(b,g.visualElement,d),b,p,g.visualElement)]})}o.displayName=`motion.${typeof r=="string"?r:`create(${(a=(s=r.displayName)!==null&&s!==void 0?s:r.name)!==null&&a!==void 0?a:""})`}`;const c=m.forwardRef(o);return c[KOe]=r,c}function rye({layoutId:e}){const t=m.useContext(tD).id;return t&&e!==void 0?t+"-"+e:e}function sye(e,t){m.useContext(CZ).strict}function aye(e){const{drag:t,layout:n}=Zg;if(!t&&!n)return{};const i={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}const oye=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function oD(e){return typeof e!="string"||e.includes("-")?!1:!!(oye.indexOf(e)>-1||/[A-Z]/u.test(e))}function BB(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function lD(e,t,n,i){if(typeof t=="function"){const[r,s]=BB(i);t=t(n!==void 0?n:e.custom,r,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,s]=BB(i);t=t(n!==void 0?n:e.custom,r,s)}return t}const MI=e=>Array.isArray(e),lye=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),cye=e=>MI(e)?e[e.length-1]||0:e,Ys=e=>!!(e&&e.getVelocity);function MS(e){const t=Ys(e)?e.get():e;return lye(t)?t.toValue():t}function uye({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},i,r,s){const a={latestValues:dye(i,r,s,e),renderState:t()};return n&&(a.onMount=o=>n({props:i,current:o,...a}),a.onUpdate=o=>n(o)),a}const DZ=e=>(t,n)=>{const i=m.useContext(u_),r=m.useContext(c_),s=()=>uye(e,t,i,r);return n?s():l_(s)};function dye(e,t,n,i){const r={},s=i(e,{});for(const h in s)r[h]=MS(s[h]);let{initial:a,animate:o}=e;const c=f_(e),u=IZ(e);t&&u&&!c&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let d=n?n.initial===!1:!1;d=d||a===!1;const f=d?o:a;if(f&&typeof f!="boolean"&&!d_(f)){const h=Array.isArray(f)?f:[f];for(let p=0;pt=>typeof t=="string"&&t.startsWith(e),QZ=$Z("--"),fye=$Z("var(--"),cD=e=>fye(e)?hye.test(e.split("/*")[0].trim()):!1,hye=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,BZ=(e,t)=>t&&typeof e=="number"?t.transform(e):e,ed=(e,t,n)=>n>t?t:ntypeof e=="number",parse:parseFloat,transform:e=>e},Zy={...B0,transform:e=>ed(0,1,e)},Jv={...B0,default:1},b1=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$d=b1("deg"),Lc=b1("%"),Gt=b1("px"),pye=b1("vh"),mye=b1("vw"),UB={...Lc,parse:e=>Lc.parse(e)/100,transform:e=>Lc.transform(e*100)},gye={borderWidth:Gt,borderTopWidth:Gt,borderRightWidth:Gt,borderBottomWidth:Gt,borderLeftWidth:Gt,borderRadius:Gt,radius:Gt,borderTopLeftRadius:Gt,borderTopRightRadius:Gt,borderBottomRightRadius:Gt,borderBottomLeftRadius:Gt,width:Gt,maxWidth:Gt,height:Gt,maxHeight:Gt,top:Gt,right:Gt,bottom:Gt,left:Gt,padding:Gt,paddingTop:Gt,paddingRight:Gt,paddingBottom:Gt,paddingLeft:Gt,margin:Gt,marginTop:Gt,marginRight:Gt,marginBottom:Gt,marginLeft:Gt,backgroundPositionX:Gt,backgroundPositionY:Gt},bye={rotate:$d,rotateX:$d,rotateY:$d,rotateZ:$d,scale:Jv,scaleX:Jv,scaleY:Jv,scaleZ:Jv,skew:$d,skewX:$d,skewY:$d,distance:Gt,translateX:Gt,translateY:Gt,translateZ:Gt,x:Gt,y:Gt,z:Gt,perspective:Gt,transformPerspective:Gt,opacity:Zy,originX:UB,originY:UB,originZ:Gt},zB={...B0,transform:Math.round},uD={...gye,...bye,zIndex:zB,size:Gt,fillOpacity:Zy,strokeOpacity:Zy,numOctaves:zB},Oye={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},yye=Q0.length;function xye(e,t,n){let i="",r=!0;for(let s=0;s({style:{},transform:{},transformOrigin:{},vars:{}}),UZ=()=>({...hD(),attrs:{}}),pD=e=>typeof e=="string"&&e.toLowerCase()==="svg";function zZ(e,{style:t,vars:n},i,r){Object.assign(e.style,t,r&&r.getProjectionStyles(i));for(const s in n)e.style.setProperty(s,n[s])}const FZ=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function VZ(e,t,n,i){zZ(e,t,void 0,i);for(const r in t.attrs)e.setAttribute(FZ.has(r)?r:sD(r),t.attrs[r])}const sk={};function kye(e){Object.assign(sk,e)}function XZ(e,{layout:t,layoutId:n}){return Lp.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!sk[e]||e==="opacity")}function mD(e,t,n){var i;const{style:r}=e,s={};for(const a in r)(Ys(r[a])||t.style&&Ys(t.style[a])||XZ(a,e)||((i=n==null?void 0:n.getValue(a))===null||i===void 0?void 0:i.liveStyle)!==void 0)&&(s[a]=r[a]);return s}function qZ(e,t,n){const i=mD(e,t,n);for(const r in e)if(Ys(e[r])||Ys(t[r])){const s=Q0.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;i[s]=e[r]}return i}function Tye(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const VB=["x","y","width","height","cx","cy","r"],_ye={useVisualState:DZ({scrapeMotionValuesFromProps:qZ,createRenderState:UZ,onUpdate:({props:e,prevProps:t,current:n,renderState:i,latestValues:r})=>{if(!n)return;let s=!!e.drag;if(!s){for(const o in r)if(Lp.has(o)){s=!0;break}}if(!s)return;let a=!t;if(t)for(let o=0;o{Tye(n,i),Zi.render(()=>{fD(i,r,pD(n.tagName),e.transformTemplate),VZ(n,i)})})}})},Aye={useVisualState:DZ({scrapeMotionValuesFromProps:mD,createRenderState:hD})};function HZ(e,t,n){for(const i in t)!Ys(t[i])&&!XZ(i,n)&&(e[i]=t[i])}function Nye({transformTemplate:e},t){return m.useMemo(()=>{const n=hD();return dD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Cye(e,t){const n=e.style||{},i={};return HZ(i,n,e),Object.assign(i,Nye(e,t)),i}function jye(e,t){const n={},i=Cye(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}function Rye(e,t,n,i){const r=m.useMemo(()=>{const s=UZ();return fD(s,t,pD(i),e.transformTemplate),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};HZ(s,e.style,e),r.style={...s,...r.style}}return r}function Iye(e=!1){return(n,i,r,{latestValues:s},a)=>{const c=(oD(n)?Rye:jye)(i,s,a,n),u=HOe(i,typeof n=="string",e),d=n!==m.Fragment?{...u,...c,ref:r}:{},{children:f}=i,h=m.useMemo(()=>Ys(f)?f.get():f,[f]);return m.createElement(n,{...d,children:h})}}function Pye(e,t){return function(i,{forwardMotionProps:r}={forwardMotionProps:!1}){const a={...oD(i)?_ye:Aye,preloadedFeatures:e,useRender:Iye(r),createVisualElement:t,Component:i};return iye(a)}}function YZ(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i(LS===void 0&&Dc.set(Es.isProcessing||zOe.useManualTiming?Es.timestamp:performance.now()),LS),set:e=>{LS=e,queueMicrotask(Mye)}};function bD(e,t){e.indexOf(t)===-1&&e.push(t)}function OD(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class yD{constructor(){this.subscriptions=[]}add(t){return bD(this.subscriptions,t),()=>OD(this.subscriptions,t)}notify(t,n,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,i);else for(let s=0;s!isNaN(parseFloat(e));class Dye{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,r=!0)=>{const s=Dc.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),r&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Dc.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Lye(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new yD);const i=this.events[t].add(n);return t==="change"?()=>{i(),Zi.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Dc.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>XB)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,XB);return WZ(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ky(e,t){return new Dye(e,t)}function $ye(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ky(n))}function Qye(e,t){const n=h_(e,t);let{transitionEnd:i={},transition:r={},...s}=n||{};s={...s,...i};for(const a in s){const o=cye(s[a]);$ye(e,a,o)}}function Bye(e){return!!(Ys(e)&&e.add)}function LI(e,t){const n=e.getValue("willChange");if(Bye(n))return n.add(t)}function ZZ(e){return e.props[PZ]}function xD(e){let t;return()=>(t===void 0&&(t=e()),t)}const Uye=xD(()=>window.ScrollTimeline!==void 0);class zye{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let i=0;i{if(Uye()&&r.attachTimeline)return r.attachTimeline(t);if(typeof n=="function")return n(r)});return()=>{i.forEach((r,s)=>{r&&r(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;nn[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Fye extends zye{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}const Bu=e=>e*1e3,Uu=e=>e/1e3;function vD(e){return typeof e=="function"}function qB(e,t){e.timeline=t,e.onfinish=null}const wD=e=>Array.isArray(e)&&typeof e[0]=="number",Vye={linearEasing:void 0};function Xye(e,t){const n=xD(e);return()=>{var i;return(i=Vye[t])!==null&&i!==void 0?i:n()}}const ak=Xye(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Kg=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i},KZ=(e,t,n=10)=>{let i="";const r=Math.max(Math.round(t/n),2);for(let s=0;s`cubic-bezier(${e}, ${t}, ${n}, ${i})`,DI={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:SO([0,.65,.55,1]),circOut:SO([.55,0,1,.45]),backIn:SO([.31,.01,.66,-.59]),backOut:SO([.33,1.53,.69,.99])};function eK(e,t){if(e)return typeof e=="function"&&ak()?KZ(e,t):wD(e)?SO(e):Array.isArray(e)?e.map(n=>eK(n,t)||DI.easeOut):DI[e]}const tK=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,qye=1e-7,Hye=12;function Yye(e,t,n,i,r){let s,a,o=0;do a=t+(n-t)/2,s=tK(a,i,r)-e,s>0?n=a:t=a;while(Math.abs(s)>qye&&++oYye(s,0,1,e,n);return s=>s===0||s===1?s:tK(r(s),t,i)}const nK=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,iK=e=>t=>1-e(1-t),rK=O1(.33,1.53,.69,.99),SD=iK(rK),sK=nK(SD),aK=e=>(e*=2)<1?.5*SD(e):.5*(2-Math.pow(2,-10*(e-1))),ED=e=>1-Math.sin(Math.acos(e)),oK=iK(ED),lK=nK(ED),cK=e=>/^0[^.\s]+$/u.test(e);function Gye(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||cK(e):!0}const ny=e=>Math.round(e*1e5)/1e5,kD=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Wye(e){return e==null}const Zye=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,TD=(e,t)=>n=>!!(typeof n=="string"&&Zye.test(n)&&n.startsWith(e)||t&&!Wye(n)&&Object.prototype.hasOwnProperty.call(n,t)),uK=(e,t,n)=>i=>{if(typeof i!="string")return i;const[r,s,a,o]=i.match(kD);return{[e]:parseFloat(r),[t]:parseFloat(s),[n]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},Kye=e=>ed(0,255,e),k2={...B0,transform:e=>Math.round(Kye(e))},Qh={test:TD("rgb","red"),parse:uK("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+k2.transform(e)+", "+k2.transform(t)+", "+k2.transform(n)+", "+ny(Zy.transform(i))+")"};function Jye(e){let t="",n="",i="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,i+=i,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const $I={test:TD("#"),parse:Jye,transform:Qh.transform},Gm={test:TD("hsl","hue"),parse:uK("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Lc.transform(ny(t))+", "+Lc.transform(ny(n))+", "+ny(Zy.transform(i))+")"},Vs={test:e=>Qh.test(e)||$I.test(e)||Gm.test(e),parse:e=>Qh.test(e)?Qh.parse(e):Gm.test(e)?Gm.parse(e):$I.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Qh.transform(e):Gm.transform(e)},exe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function txe(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(kD))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(exe))===null||n===void 0?void 0:n.length)||0)>0}const dK="number",fK="color",nxe="var",ixe="var(",HB="${}",rxe=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Jy(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},r=[];let s=0;const o=t.replace(rxe,c=>(Vs.test(c)?(i.color.push(s),r.push(fK),n.push(Vs.parse(c))):c.startsWith(ixe)?(i.var.push(s),r.push(nxe),n.push(c)):(i.number.push(s),r.push(dK),n.push(parseFloat(c))),++s,HB)).split(HB);return{values:n,split:o,indexes:i,types:r}}function hK(e){return Jy(e).values}function pK(e){const{split:t,types:n}=Jy(e),i=t.length;return r=>{let s="";for(let a=0;atypeof e=="number"?0:e;function axe(e){const t=hK(e);return pK(e)(t.map(sxe))}const Rf={test:txe,parse:hK,createTransformer:pK,getAnimatableNone:axe},oxe=new Set(["brightness","contrast","saturate","opacity"]);function lxe(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(kD)||[];if(!i)return e;const r=n.replace(i,"");let s=oxe.has(t)?1:0;return i!==n&&(s*=100),t+"("+s+r+")"}const cxe=/\b([a-z-]*)\(.*?\)/gu,QI={...Rf,getAnimatableNone:e=>{const t=e.match(cxe);return t?t.map(lxe).join(" "):e}},uxe={...uD,color:Vs,backgroundColor:Vs,outlineColor:Vs,fill:Vs,stroke:Vs,borderColor:Vs,borderTopColor:Vs,borderRightColor:Vs,borderBottomColor:Vs,borderLeftColor:Vs,filter:QI,WebkitFilter:QI},_D=e=>uxe[e];function mK(e,t){let n=_D(e);return n!==QI&&(n=Rf),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const dxe=new Set(["auto","none","0"]);function fxe(e,t,n){let i=0,r;for(;ie===B0||e===Gt,GB=(e,t)=>parseFloat(e.split(", ")[t]),WB=(e,t)=>(n,{transform:i})=>{if(i==="none"||!i)return 0;const r=i.match(/^matrix3d\((.+)\)$/u);if(r)return GB(r[1],t);{const s=i.match(/^matrix\((.+)\)$/u);return s?GB(s[1],e):0}},hxe=new Set(["x","y","z"]),pxe=Q0.filter(e=>!hxe.has(e));function mxe(e){const t=[];return pxe.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Jg={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:WB(4,13),y:WB(5,14)};Jg.translateX=Jg.x;Jg.translateY=Jg.y;const ep=new Set;let BI=!1,UI=!1;function gK(){if(UI){const e=Array.from(ep).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const r=mxe(i);r.length&&(n.set(i,r),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const r=n.get(i);r&&r.forEach(([s,a])=>{var o;(o=i.getValue(s))===null||o===void 0||o.set(a)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}UI=!1,BI=!1,ep.forEach(e=>e.complete()),ep.clear()}function bK(){ep.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(UI=!0)})}function gxe(){bK(),gK()}class AD{constructor(t,n,i,r,s,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=r,this.element=s,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ep.add(this),BI||(BI=!0,Zi.read(bK),Zi.resolveKeyframes(gK))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:r}=this;for(let s=0;s/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),bxe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Oxe(e){const t=bxe.exec(e);if(!t)return[,];const[,n,i,r]=t;return[`--${n??i}`,r]}function yK(e,t,n=1){const[i,r]=Oxe(e);if(!i)return;const s=window.getComputedStyle(t).getPropertyValue(i);if(s){const a=s.trim();return OK(a)?parseFloat(a):a}return cD(r)?yK(r,t,n+1):r}const xK=e=>t=>t.test(e),yxe={test:e=>e==="auto",parse:e=>e},vK=[B0,Gt,Lc,$d,mye,pye,yxe],ZB=e=>vK.find(xK(e));class wK extends AD{constructor(t,n,i,r,s){super(t,n,i,r,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c{n.getValue(c).set(u)}),this.resolveNoneKeyframes()}}const KB=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Rf.test(e)||e==="0")&&!e.startsWith("url("));function xxe(e){const t=e[0];if(e.length===1)return!0;for(let n=0;ne!==null;function p_(e,{repeat:t,repeatType:n="loop"},i){const r=e.filter(wxe),s=t&&n!=="loop"&&t%2===1?0:r.length-1;return!s||i===void 0?r[s]:i}const Sxe=40;class SK{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:r=0,repeatDelay:s=0,repeatType:a="loop",...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Dc.now(),this.options={autoplay:t,delay:n,type:i,repeat:r,repeatDelay:s,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>Sxe?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&gxe(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Dc.now(),this.hasAttemptedResolve=!0;const{name:i,type:r,velocity:s,delay:a,onComplete:o,onUpdate:c,isGenerator:u}=this.options;if(!u&&!vxe(t,i,r,s))if(a)this.options.duration=0;else{c&&c(p_(t,this.options,n)),o&&o(),this.resolveFinishedPromise();return}const d=this.initPlayback(t,n);d!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...d},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const zI=2e4;function EK(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t=zI?1/0:t}const pr=(e,t,n)=>e+(t-e)*n;function T2(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Exe({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let r=0,s=0,a=0;if(!t)r=s=a=n;else{const o=n<.5?n*(1+t):n+t-n*t,c=2*n-o;r=T2(c,o,e+1/3),s=T2(c,o,e),a=T2(c,o,e-1/3)}return{red:Math.round(r*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:i}}function ok(e,t){return n=>n>0?t:e}const _2=(e,t,n)=>{const i=e*e,r=n*(t*t-i)+i;return r<0?0:Math.sqrt(r)},kxe=[$I,Qh,Gm],Txe=e=>kxe.find(t=>t.test(e));function JB(e){const t=Txe(e);if(!t)return!1;let n=t.parse(e);return t===Gm&&(n=Exe(n)),n}const e8=(e,t)=>{const n=JB(e),i=JB(t);if(!n||!i)return ok(e,t);const r={...n};return s=>(r.red=_2(n.red,i.red,s),r.green=_2(n.green,i.green,s),r.blue=_2(n.blue,i.blue,s),r.alpha=pr(n.alpha,i.alpha,s),Qh.transform(r))},_xe=(e,t)=>n=>t(e(n)),y1=(...e)=>e.reduce(_xe),FI=new Set(["none","hidden"]);function Axe(e,t){return FI.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Nxe(e,t){return n=>pr(e,t,n)}function ND(e){return typeof e=="number"?Nxe:typeof e=="string"?cD(e)?ok:Vs.test(e)?e8:Rxe:Array.isArray(e)?kK:typeof e=="object"?Vs.test(e)?e8:Cxe:ok}function kK(e,t){const n=[...e],i=n.length,r=e.map((s,a)=>ND(s)(s,t[a]));return s=>{for(let a=0;a{for(const s in i)n[s]=i[s](r);return n}}function jxe(e,t){var n;const i=[],r={color:0,var:0,number:0};for(let s=0;s{const n=Rf.createTransformer(t),i=Jy(e),r=Jy(t);return i.indexes.var.length===r.indexes.var.length&&i.indexes.color.length===r.indexes.color.length&&i.indexes.number.length>=r.indexes.number.length?FI.has(e)&&!r.values.length||FI.has(t)&&!i.values.length?Axe(e,t):y1(kK(jxe(i,r),r.values),n):ok(e,t)};function TK(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?pr(e,t,n):ND(e)(e,t)}const Ixe=5;function _K(e,t,n){const i=Math.max(t-Ixe,0);return WZ(n-e(i),t-i)}const xr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},A2=.001;function Pxe({duration:e=xr.duration,bounce:t=xr.bounce,velocity:n=xr.velocity,mass:i=xr.mass}){let r,s,a=1-t;a=ed(xr.minDamping,xr.maxDamping,a),e=ed(xr.minDuration,xr.maxDuration,Uu(e)),a<1?(r=u=>{const d=u*a,f=d*e,h=d-n,p=VI(u,a),g=Math.exp(-f);return A2-h/p*g},s=u=>{const f=u*a*e,h=f*n+n,p=Math.pow(a,2)*Math.pow(u,2)*e,g=Math.exp(-f),b=VI(Math.pow(u,2),a);return(-r(u)+A2>0?-1:1)*((h-p)*g)/b}):(r=u=>{const d=Math.exp(-u*e),f=(u-n)*e+1;return-A2+d*f},s=u=>{const d=Math.exp(-u*e),f=(n-u)*(e*e);return d*f});const o=5/e,c=Lxe(r,s,o);if(e=Bu(e),isNaN(c))return{stiffness:xr.stiffness,damping:xr.damping,duration:e};{const u=Math.pow(c,2)*i;return{stiffness:u,damping:a*2*Math.sqrt(i*u),duration:e}}}const Mxe=12;function Lxe(e,t,n){let i=n;for(let r=1;re[n]!==void 0)}function Qxe(e){let t={velocity:xr.velocity,stiffness:xr.stiffness,damping:xr.damping,mass:xr.mass,isResolvedFromDuration:!1,...e};if(!t8(e,$xe)&&t8(e,Dxe))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),r=i*i,s=2*ed(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:xr.mass,stiffness:r,damping:s}}else{const n=Pxe(e);t={...t,...n,mass:xr.mass},t.isResolvedFromDuration=!0}return t}function AK(e=xr.visualDuration,t=xr.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:r}=n;const s=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],o={done:!1,value:s},{stiffness:c,damping:u,mass:d,duration:f,velocity:h,isResolvedFromDuration:p}=Qxe({...n,velocity:-Uu(n.velocity||0)}),g=h||0,b=u/(2*Math.sqrt(c*d)),y=a-s,O=Uu(Math.sqrt(c/d)),v=Math.abs(y)<5;i||(i=v?xr.restSpeed.granular:xr.restSpeed.default),r||(r=v?xr.restDelta.granular:xr.restDelta.default);let x;if(b<1){const E=VI(O,b);x=S=>{const k=Math.exp(-b*O*S);return a-k*((g+b*O*y)/E*Math.sin(E*S)+y*Math.cos(E*S))}}else if(b===1)x=E=>a-Math.exp(-O*E)*(y+(g+O*y)*E);else{const E=O*Math.sqrt(b*b-1);x=S=>{const k=Math.exp(-b*O*S),T=Math.min(E*S,300);return a-k*((g+b*O*y)*Math.sinh(T)+E*y*Math.cosh(T))/E}}const w={calculatedDuration:p&&f||null,next:E=>{const S=x(E);if(p)o.done=E>=f;else{let k=0;b<1&&(k=E===0?Bu(g):_K(x,E,S));const T=Math.abs(k)<=i,A=Math.abs(a-S)<=r;o.done=T&&A}return o.value=o.done?a:S,o},toString:()=>{const E=Math.min(EK(w),zI),S=KZ(k=>w.next(E*k).value,E,30);return E+"ms "+S}};return w}function n8({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:s=500,modifyTarget:a,min:o,max:c,restDelta:u=.5,restSpeed:d}){const f=e[0],h={done:!1,value:f},p=T=>o!==void 0&&Tc,g=T=>o===void 0?c:c===void 0||Math.abs(o-T)-b*Math.exp(-T/i),x=T=>O+v(T),w=T=>{const A=v(T),N=x(T);h.done=Math.abs(A)<=u,h.value=h.done?O:N};let E,S;const k=T=>{p(h.value)&&(E=T,S=AK({keyframes:[h.value,g(h.value)],velocity:_K(x,T,h.value),damping:r,stiffness:s,restDelta:u,restSpeed:d}))};return k(0),{calculatedDuration:null,next:T=>{let A=!1;return!S&&E===void 0&&(A=!0,w(T),k(T)),E!==void 0&&T>=E?S.next(T-E):(!A&&w(T),h)}}}const Bxe=O1(.42,0,1,1),Uxe=O1(0,0,.58,1),NK=O1(.42,0,.58,1),zxe=e=>Array.isArray(e)&&typeof e[0]!="number",Fxe={linear:xo,easeIn:Bxe,easeInOut:NK,easeOut:Uxe,circIn:ED,circInOut:lK,circOut:oK,backIn:SD,backInOut:sK,backOut:rK,anticipate:aK},i8=e=>{if(wD(e)){AZ(e.length===4);const[t,n,i,r]=e;return O1(t,n,i,r)}else if(typeof e=="string")return Fxe[e];return e};function Vxe(e,t,n){const i=[],r=n||TK,s=e.length-1;for(let a=0;at[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=Vxe(t,i,r),c=o.length,u=d=>{if(a&&d1)for(;fu(ed(e[0],e[s-1],d)):u}function qxe(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const r=Kg(0,t,i);e.push(pr(n,1,r))}}function Hxe(e){const t=[0];return qxe(t,e.length-1),t}function Yxe(e,t){return e.map(n=>n*t)}function Gxe(e,t){return e.map(()=>t||NK).splice(0,e.length-1)}function lk({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const r=zxe(i)?i.map(i8):i8(i),s={done:!1,value:t[0]},a=Yxe(n&&n.length===t.length?n:Hxe(t),e),o=Xxe(a,t,{ease:Array.isArray(r)?r:Gxe(t,r)});return{calculatedDuration:e,next:c=>(s.value=o(c),s.done=c>=e,s)}}const Wxe=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Zi.update(t,!0),stop:()=>jf(t),now:()=>Es.isProcessing?Es.timestamp:Dc.now()}},Zxe={decay:n8,inertia:n8,tween:lk,keyframes:lk,spring:AK},Kxe=e=>e/100;class CD extends SK{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:i,element:r,keyframes:s}=this.options,a=(r==null?void 0:r.KeyframeResolver)||AD,o=(c,u)=>this.onKeyframesResolved(c,u);this.resolver=new a(s,o,n,i,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:s,velocity:a=0}=this.options,o=vD(n)?n:Zxe[n]||lk;let c,u;o!==lk&&typeof t[0]!="number"&&(c=y1(Kxe,TK(t[0],t[1])),t=[0,100]);const d=o({...this.options,keyframes:t});s==="mirror"&&(u=o({...this.options,keyframes:[...t].reverse(),velocity:-a})),d.calculatedDuration===null&&(d.calculatedDuration=EK(d));const{calculatedDuration:f}=d,h=f+r,p=h*(i+1)-r;return{generator:d,mirroredGenerator:u,mapPercentToKeyframes:c,calculatedDuration:f,resolvedDuration:h,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:i}=this;if(!i){const{keyframes:T}=this.options;return{done:!0,value:T[T.length-1]}}const{finalKeyframe:r,generator:s,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:c,calculatedDuration:u,totalDuration:d,resolvedDuration:f}=i;if(this.startTime===null)return s.next(0);const{delay:h,repeat:p,repeatType:g,repeatDelay:b,onUpdate:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-d/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const O=this.currentTime-h*(this.speed>=0?1:-1),v=this.speed>=0?O<0:O>d;this.currentTime=Math.max(O,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=d);let x=this.currentTime,w=s;if(p){const T=Math.min(this.currentTime,d)/f;let A=Math.floor(T),N=T%1;!N&&T>=1&&(N=1),N===1&&A--,A=Math.min(A,p+1),!!(A%2)&&(g==="reverse"?(N=1-N,b&&(N-=b/f)):g==="mirror"&&(w=a)),x=ed(0,1,N)*f}const E=v?{done:!1,value:c[0]}:w.next(x);o&&(E.value=o(E.value));let{done:S}=E;!v&&u!==null&&(S=this.speed>=0?this.currentTime>=d:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&S);return k&&r!==void 0&&(E.value=p_(c,this.options,r)),y&&y(E.value),k&&this.finish(),E}get duration(){const{resolved:t}=this;return t?Uu(t.calculatedDuration):0}get time(){return Uu(this.currentTime)}set time(t){t=Bu(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Uu(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=Wxe,onPlay:n,startTime:i}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),n&&n();const r=this.driver.now();this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=r):this.startTime=i??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const Jxe=new Set(["opacity","clipPath","filter","transform"]);function e1e(e,t,n,{delay:i=0,duration:r=300,repeat:s=0,repeatType:a="loop",ease:o="easeInOut",times:c}={}){const u={[t]:n};c&&(u.offset=c);const d=eK(o,r);return Array.isArray(d)&&(u.easing=d),e.animate(u,{delay:i,duration:r,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"})}const t1e=xD(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),ck=10,n1e=2e4;function i1e(e){return vD(e.type)||e.type==="spring"||!JZ(e.ease)}function r1e(e,t){const n=new CD({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let i={done:!1,value:e[0]};const r=[];let s=0;for(;!i.done&&sthis.onKeyframesResolved(a,o),n,i,r),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:i=300,times:r,ease:s,type:a,motionValue:o,name:c,startTime:u}=this.options;if(!o.owner||!o.owner.current)return!1;if(typeof s=="string"&&ak()&&s1e(s)&&(s=CK[s]),i1e(this.options)){const{onComplete:f,onUpdate:h,motionValue:p,element:g,...b}=this.options,y=r1e(t,b);t=y.keyframes,t.length===1&&(t[1]=t[0]),i=y.duration,r=y.times,s=y.ease,a="keyframes"}const d=e1e(o.owner.current,c,t,{...this.options,duration:i,times:r,ease:s});return d.startTime=u??this.calcStartTime(),this.pendingTimeline?(qB(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{const{onComplete:f}=this.options;o.set(p_(t,this.options,n)),f&&f(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:i,times:r,type:a,ease:s,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return Uu(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return Uu(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.currentTime=Bu(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return xo;const{animation:i}=n;qB(i,t)}return xo}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:i,duration:r,type:s,ease:a,times:o}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:u,onUpdate:d,onComplete:f,element:h,...p}=this.options,g=new CD({...p,keyframes:i,duration:r,type:s,ease:a,times:o,isGenerator:!0}),b=Bu(this.time);u.setWithVelocity(g.sample(b-ck).value,g.sample(b).value,ck)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:i,repeatDelay:r,repeatType:s,damping:a,type:o}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=n.owner.getProps();return t1e()&&i&&Jxe.has(i)&&!c&&!u&&!r&&s!=="mirror"&&a!==0&&o!=="inertia"}}const a1e={type:"spring",stiffness:500,damping:25,restSpeed:10},o1e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),l1e={type:"keyframes",duration:.8},c1e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},u1e=(e,{keyframes:t})=>t.length>2?l1e:Lp.has(e)?e.startsWith("scale")?o1e(t[1]):a1e:c1e;function d1e({when:e,delay:t,delayChildren:n,staggerChildren:i,staggerDirection:r,repeat:s,repeatType:a,repeatDelay:o,from:c,elapsed:u,...d}){return!!Object.keys(d).length}const jD=(e,t,n,i={},r,s)=>a=>{const o=gD(i,e)||{},c=o.delay||i.delay||0;let{elapsed:u=0}=i;u=u-Bu(c);let d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-u,onUpdate:h=>{t.set(h),o.onUpdate&&o.onUpdate(h)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:s?void 0:r};d1e(o)||(d={...d,...u1e(e,d)}),d.duration&&(d.duration=Bu(d.duration)),d.repeatDelay&&(d.repeatDelay=Bu(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let f=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(f=!0)),f&&!s&&t.get()!==void 0){const h=p_(d.keyframes,o);if(h!==void 0)return Zi.update(()=>{d.onUpdate(h),d.onComplete()}),new Fye([])}return!s&&r8.supports(d)?new r8(d):new CD(d)};function f1e({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function jK(e,t,{delay:n=0,transitionOverride:i,type:r}={}){var s;let{transition:a=e.getDefaultTransition(),transitionEnd:o,...c}=t;i&&(a=i);const u=[],d=r&&e.animationState&&e.animationState.getState()[r];for(const f in c){const h=e.getValue(f,(s=e.latestValues[f])!==null&&s!==void 0?s:null),p=c[f];if(p===void 0||d&&f1e(d,f))continue;const g={delay:n,...gD(a||{},f)};let b=!1;if(window.MotionHandoffAnimation){const O=ZZ(e);if(O){const v=window.MotionHandoffAnimation(O,f,Zi);v!==null&&(g.startTime=v,b=!0)}}LI(e,f),h.start(jD(f,h,p,e.shouldReduceMotion&&GZ.has(f)?{type:!1}:g,e,b));const y=h.animation;y&&u.push(y)}return o&&Promise.all(u).then(()=>{Zi.update(()=>{o&&Qye(e,o)})}),u}function XI(e,t,n={}){var i;const r=h_(e,t,n.type==="exit"?(i=e.presenceContext)===null||i===void 0?void 0:i.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(s=n.transitionOverride);const a=r?()=>Promise.all(jK(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:f,staggerDirection:h}=s;return h1e(e,t,d+u,f,h,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[u,d]=c==="beforeChildren"?[a,o]:[o,a];return u().then(()=>d())}else return Promise.all([a(),o(n.delay)])}function h1e(e,t,n=0,i=0,r=1,s){const a=[],o=(e.variantChildren.size-1)*i,c=r===1?(u=0)=>u*i:(u=0)=>o-u*i;return Array.from(e.variantChildren).sort(p1e).forEach((u,d)=>{u.notify("AnimationStart",t),a.push(XI(u,t,{...s,delay:n+c(d)}).then(()=>u.notify("AnimationComplete",t)))}),Promise.all(a)}function p1e(e,t){return e.sortNodePosition(t)}function m1e(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const r=t.map(s=>XI(e,s,n));i=Promise.all(r)}else if(typeof t=="string")i=XI(e,t,n);else{const r=typeof t=="function"?h_(e,t,n.custom):t;i=Promise.all(jK(e,r,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const g1e=rD.length;function RK(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?RK(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:i})=>m1e(e,n,i)))}function x1e(e){let t=y1e(e),n=s8(),i=!0;const r=c=>(u,d)=>{var f;const h=h_(e,d,c==="exit"?(f=e.presenceContext)===null||f===void 0?void 0:f.custom:void 0);if(h){const{transition:p,transitionEnd:g,...b}=h;u={...u,...b,...g}}return u};function s(c){t=c(e)}function a(c){const{props:u}=e,d=RK(e.parent)||{},f=[],h=new Set;let p={},g=1/0;for(let y=0;yg&&w,A=!1;const N=Array.isArray(x)?x:[x];let C=N.reduce(r(O),{});E===!1&&(C={});const{prevResolvedValues:M={}}=v,L={...M,...C},P=$=>{T=!0,h.has($)&&(A=!0,h.delete($)),v.needsAnimating[$]=!0;const U=e.getValue($);U&&(U.liveStyle=!1)};for(const $ in L){const U=C[$],B=M[$];if(p.hasOwnProperty($))continue;let I=!1;MI(U)&&MI(B)?I=!YZ(U,B):I=U!==B,I?U!=null?P($):h.add($):U!==void 0&&h.has($)?P($):v.protectedKeys[$]=!0}v.prevProp=x,v.prevResolvedValues=C,v.isActive&&(p={...p,...C}),i&&e.blockInitialAnimation&&(T=!1),T&&(!(S&&k)||A)&&f.push(...N.map($=>({animation:$,options:{type:O}})))}if(h.size){const y={};h.forEach(O=>{const v=e.getBaseTarget(O),x=e.getValue(O);x&&(x.liveStyle=!0),y[O]=v??null}),f.push({animation:y})}let b=!!f.length;return i&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(b=!1),i=!1,b?t(f):Promise.resolve()}function o(c,u){var d;if(n[c].isActive===u)return Promise.resolve();(d=e.variantChildren)===null||d===void 0||d.forEach(h=>{var p;return(p=h.animationState)===null||p===void 0?void 0:p.setActive(c,u)}),n[c].isActive=u;const f=a(c);for(const h in n)n[h].protectedKeys={};return f}return{animateChanges:a,setActive:o,setAnimateFunction:s,getState:()=>n,reset:()=>{n=s8(),i=!0}}}function v1e(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!YZ(t,e):!1}function dh(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function s8(){return{animate:dh(!0),whileInView:dh(),whileHover:dh(),whileTap:dh(),whileDrag:dh(),whileFocus:dh(),exit:dh()}}class Kf{constructor(t){this.isMounted=!1,this.node=t}update(){}}class w1e extends Kf{constructor(t){super(t),t.animationState||(t.animationState=x1e(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();d_(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let S1e=0;class E1e extends Kf{constructor(){super(...arguments),this.id=S1e++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const k1e={animation:{Feature:w1e},exit:{Feature:E1e}},wl={x:!1,y:!1};function IK(){return wl.x||wl.y}function T1e(e){return e==="x"||e==="y"?wl[e]?null:(wl[e]=!0,()=>{wl[e]=!1}):wl.x||wl.y?null:(wl.x=wl.y=!0,()=>{wl.x=wl.y=!1})}const RD=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1;function ex(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function x1(e){return{point:{x:e.pageX,y:e.pageY}}}const _1e=e=>t=>RD(t)&&e(t,x1(t));function iy(e,t,n,i){return ex(e,t,_1e(n),i)}const a8=(e,t)=>Math.abs(e-t);function A1e(e,t){const n=a8(e.x,t.x),i=a8(e.y,t.y);return Math.sqrt(n**2+i**2)}class PK{constructor(t,n,{transformPagePoint:i,contextWindow:r,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=C2(this.lastMoveEventInfo,this.history),h=this.startEvent!==null,p=A1e(f.offset,{x:0,y:0})>=3;if(!h&&!p)return;const{point:g}=f,{timestamp:b}=Es;this.history.push({...g,timestamp:b});const{onStart:y,onMove:O}=this.handlers;h||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),O&&O(this.lastMoveEvent,f)},this.handlePointerMove=(f,h)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=N2(h,this.transformPagePoint),Zi.update(this.updatePoint,!0)},this.handlePointerUp=(f,h)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=C2(f.type==="pointercancel"?this.lastMoveEventInfo:N2(h,this.transformPagePoint),this.history);this.startEvent&&p&&p(f,y),g&&g(f,y)},!RD(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=i,this.contextWindow=r||window;const a=x1(t),o=N2(a,this.transformPagePoint),{point:c}=o,{timestamp:u}=Es;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(t,C2(o,this.history)),this.removeListeners=y1(iy(this.contextWindow,"pointermove",this.handlePointerMove),iy(this.contextWindow,"pointerup",this.handlePointerUp),iy(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),jf(this.updatePoint)}}function N2(e,t){return t?{point:t(e.point)}:e}function o8(e,t){return{x:e.x-t.x,y:e.y-t.y}}function C2({point:e},t){return{point:e,delta:o8(e,MK(t)),offset:o8(e,N1e(t)),velocity:C1e(t,.1)}}function N1e(e){return e[0]}function MK(e){return e[e.length-1]}function C1e(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const r=MK(e);for(;n>=0&&(i=e[n],!(r.timestamp-i.timestamp>Bu(t)));)n--;if(!i)return{x:0,y:0};const s=Uu(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const a={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}const LK=1e-4,j1e=1-LK,R1e=1+LK,DK=.01,I1e=0-DK,P1e=0+DK;function ko(e){return e.max-e.min}function M1e(e,t,n){return Math.abs(e-t)<=n}function l8(e,t,n,i=.5){e.origin=i,e.originPoint=pr(t.min,t.max,e.origin),e.scale=ko(n)/ko(t),e.translate=pr(n.min,n.max,e.origin)-e.originPoint,(e.scale>=j1e&&e.scale<=R1e||isNaN(e.scale))&&(e.scale=1),(e.translate>=I1e&&e.translate<=P1e||isNaN(e.translate))&&(e.translate=0)}function ry(e,t,n,i){l8(e.x,t.x,n.x,i?i.originX:void 0),l8(e.y,t.y,n.y,i?i.originY:void 0)}function c8(e,t,n){e.min=n.min+t.min,e.max=e.min+ko(t)}function L1e(e,t,n){c8(e.x,t.x,n.x),c8(e.y,t.y,n.y)}function u8(e,t,n){e.min=t.min-n.min,e.max=e.min+ko(t)}function sy(e,t,n){u8(e.x,t.x,n.x),u8(e.y,t.y,n.y)}function D1e(e,{min:t,max:n},i){return t!==void 0&&en&&(e=i?pr(n,e,i.max):Math.min(e,n)),e}function d8(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function $1e(e,{top:t,left:n,bottom:i,right:r}){return{x:d8(e.x,n,r),y:d8(e.y,t,i)}}function f8(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.mini?n=Kg(t.min,t.max-i,e.min):i>r&&(n=Kg(e.min,e.max-r,t.min)),ed(0,1,n)}function U1e(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const qI=.35;function z1e(e=qI){return e===!1?e=0:e===!0&&(e=qI),{x:h8(e,"left","right"),y:h8(e,"top","bottom")}}function h8(e,t,n){return{min:p8(e,t),max:p8(e,n)}}function p8(e,t){return typeof e=="number"?e:e[t]||0}const m8=()=>({translate:0,scale:1,origin:0,originPoint:0}),Wm=()=>({x:m8(),y:m8()}),g8=()=>({min:0,max:0}),Ar=()=>({x:g8(),y:g8()});function Mo(e){return[e("x"),e("y")]}function $K({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function F1e({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function V1e(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function j2(e){return e===void 0||e===1}function HI({scale:e,scaleX:t,scaleY:n}){return!j2(e)||!j2(t)||!j2(n)}function Eh(e){return HI(e)||QK(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function QK(e){return b8(e.x)||b8(e.y)}function b8(e){return e&&e!=="0%"}function uk(e,t,n){const i=e-n,r=t*i;return n+r}function O8(e,t,n,i,r){return r!==void 0&&(e=uk(e,r,i)),uk(e,n,i)+t}function YI(e,t=0,n=1,i,r){e.min=O8(e.min,t,n,i,r),e.max=O8(e.max,t,n,i,r)}function BK(e,{x:t,y:n}){YI(e.x,t.translate,t.scale,t.originPoint),YI(e.y,n.translate,n.scale,n.originPoint)}const y8=.999999999999,x8=1.0000000000001;function X1e(e,t,n,i=!1){const r=n.length;if(!r)return;t.x=t.y=1;let s,a;for(let o=0;oy8&&(t.x=1),t.yy8&&(t.y=1)}function Zm(e,t){e.min=e.min+t,e.max=e.max+t}function v8(e,t,n,i,r=.5){const s=pr(e.min,e.max,r);YI(e,t,n,s,i)}function Km(e,t){v8(e.x,t.x,t.scaleX,t.scale,t.originX),v8(e.y,t.y,t.scaleY,t.scale,t.originY)}function UK(e,t){return $K(V1e(e.getBoundingClientRect(),t))}function q1e(e,t,n){const i=UK(e,n),{scroll:r}=t;return r&&(Zm(i.x,r.offset.x),Zm(i.y,r.offset.y)),i}const zK=({current:e})=>e?e.ownerDocument.defaultView:null,H1e=new WeakMap;class Y1e{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ar(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(x1(d).point)},s=(d,f)=>{const{drag:h,dragPropagation:p,onDragStart:g}=this.getProps();if(h&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=T1e(h),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Mo(y=>{let O=this.getAxisMotionValue(y).get()||0;if(Lc.test(O)){const{projection:v}=this.visualElement;if(v&&v.layout){const x=v.layout.layoutBox[y];x&&(O=ko(x)*(parseFloat(O)/100))}}this.originPoint[y]=O}),g&&Zi.postRender(()=>g(d,f)),LI(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{const{dragPropagation:h,dragDirectionLock:p,onDirectionLock:g,onDrag:b}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:y}=f;if(p&&this.currentDirection===null){this.currentDirection=G1e(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),b&&b(d,f)},o=(d,f)=>this.stop(d,f),c=()=>Mo(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)===null||f===void 0?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new PK(t,{onSessionStart:r,onStart:s,onMove:a,onSessionEnd:o,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,contextWindow:zK(this.visualElement)})}stop(t,n){const i=this.isDragging;if(this.cancel(),!i)return;const{velocity:r}=n;this.startAnimation(r);const{onDragEnd:s}=this.getProps();s&&Zi.postRender(()=>s(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,i){const{drag:r}=this.getProps();if(!i||!ew(t,r,this.currentDirection))return;const s=this.getAxisMotionValue(t);let a=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(a=D1e(a,this.constraints[t],this.elastic[t])),s.set(a)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:i}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,s=this.constraints;n&&Ym(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&r?this.constraints=$1e(r.layoutBox,n):this.constraints=!1,this.elastic=z1e(i),s!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Mo(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=U1e(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ym(t))return!1;const i=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=q1e(i,r.root,this.visualElement.getTransformPagePoint());let a=Q1e(r.layout.layoutBox,s);if(n){const o=n(F1e(a));this.hasMutatedConstraints=!!o,o&&(a=$K(o))}return a}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),c=this.constraints||{},u=Mo(d=>{if(!ew(d,n,this.currentDirection))return;let f=c&&c[d]||{};a&&(f={min:0,max:0});const h=r?200:1e6,p=r?40:1e7,g={type:"inertia",velocity:i?t[d]:0,bounceStiffness:h,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return LI(this.visualElement,t),i.start(jD(t,i,0,n,this.visualElement,!1))}stopAnimation(){Mo(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Mo(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){Mo(n=>{const{drag:i}=this.getProps();if(!ew(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(n);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[n];s.set(t[n]-pr(a,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Ym(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Mo(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const c=o.get();r[a]=B1e({min:c,max:c},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Mo(a=>{if(!ew(a,t,null))return;const o=this.getAxisMotionValue(a),{min:c,max:u}=this.constraints[a];o.set(pr(c,u,r[a]))})}addListeners(){if(!this.visualElement.current)return;H1e.set(this.visualElement,this);const t=this.visualElement.current,n=iy(t,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(c)}),i=()=>{const{dragConstraints:c}=this.getProps();Ym(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,s=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Zi.read(i);const a=ex(window,"resize",()=>this.scalePositionWithinConstraints()),o=r.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(Mo(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=c[d].translate,f.set(f.get()+c[d].translate))}),this.visualElement.render())});return()=>{a(),n(),s(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:a=qI,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:a,dragMomentum:o}}}function ew(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function G1e(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class W1e extends Kf{constructor(t){super(t),this.removeGroupControls=xo,this.removeListeners=xo,this.controls=new Y1e(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||xo}unmount(){this.removeGroupControls(),this.removeListeners()}}const w8=e=>(t,n)=>{e&&Zi.postRender(()=>e(t,n))};class Z1e extends Kf{constructor(){super(...arguments),this.removePointerDownListener=xo}onPointerDown(t){this.session=new PK(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:zK(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:w8(t),onStart:w8(n),onMove:i,onEnd:(s,a)=>{delete this.session,r&&Zi.postRender(()=>r(s,a))}}}mount(){this.removePointerDownListener=iy(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const DS={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function S8(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Vb={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Gt.test(e))e=parseFloat(e);else return e;const n=S8(e,t.target.x),i=S8(e,t.target.y);return`${n}% ${i}%`}},K1e={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,r=Rf.parse(e);if(r.length>5)return i;const s=Rf.createTransformer(e),a=typeof r[0]!="number"?1:0,o=n.x.scale*t.x,c=n.y.scale*t.y;r[0+a]/=o,r[1+a]/=c;const u=pr(o,c,.5);return typeof r[2+a]=="number"&&(r[2+a]/=u),typeof r[3+a]=="number"&&(r[3+a]/=u),s(r)}};class J1e extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=t;kye(eve),s&&(n.group&&n.group.add(s),i&&i.register&&r&&i.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),DS.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:r,isPresent:s}=this.props,a=i.projection;return a&&(a.isPresent=s,r||t.layoutDependency!==n||n===void 0?a.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?a.promote():a.relegate()||Zi.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),aD.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=t;r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function FK(e){const[t,n]=TZ(),i=m.useContext(tD);return l.jsx(J1e,{...e,layoutGroup:i,switchLayoutGroup:m.useContext(MZ),isPresent:t,safeToRemove:n})}const eve={borderRadius:{...Vb,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Vb,borderTopRightRadius:Vb,borderBottomLeftRadius:Vb,borderBottomRightRadius:Vb,boxShadow:K1e};function tve(e,t,n){const i=Ys(e)?e:Ky(e);return i.start(jD("",i,t,n)),i.animation}function nve(e){return e instanceof SVGElement&&e.tagName!=="svg"}const ive=(e,t)=>e.depth-t.depth;class rve{constructor(){this.children=[],this.isDirty=!1}add(t){bD(this.children,t),this.isDirty=!0}remove(t){OD(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(ive),this.isDirty=!1,this.children.forEach(t)}}function sve(e,t){const n=Dc.now(),i=({timestamp:r})=>{const s=r-n;s>=t&&(jf(i),e(s-t))};return Zi.read(i,!0),()=>jf(i)}const VK=["TopLeft","TopRight","BottomLeft","BottomRight"],ave=VK.length,E8=e=>typeof e=="string"?parseFloat(e):e,k8=e=>typeof e=="number"||Gt.test(e);function ove(e,t,n,i,r,s){r?(e.opacity=pr(0,n.opacity!==void 0?n.opacity:1,lve(i)),e.opacityExit=pr(t.opacity!==void 0?t.opacity:1,0,cve(i))):s&&(e.opacity=pr(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,i));for(let a=0;ait?1:n(Kg(e,t,i))}function _8(e,t){e.min=t.min,e.max=t.max}function Po(e,t){_8(e.x,t.x),_8(e.y,t.y)}function A8(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function N8(e,t,n,i,r){return e-=t,e=uk(e,1/n,i),r!==void 0&&(e=uk(e,1/r,i)),e}function uve(e,t=0,n=1,i=.5,r,s=e,a=e){if(Lc.test(t)&&(t=parseFloat(t),t=pr(a.min,a.max,t/100)-a.min),typeof t!="number")return;let o=pr(s.min,s.max,i);e===s&&(o-=t),e.min=N8(e.min,t,n,o,r),e.max=N8(e.max,t,n,o,r)}function C8(e,t,[n,i,r],s,a){uve(e,t[n],t[i],t[r],t.scale,s,a)}const dve=["x","scaleX","originX"],fve=["y","scaleY","originY"];function j8(e,t,n,i){C8(e.x,t,dve,n?n.x:void 0,i?i.x:void 0),C8(e.y,t,fve,n?n.y:void 0,i?i.y:void 0)}function R8(e){return e.translate===0&&e.scale===1}function qK(e){return R8(e.x)&&R8(e.y)}function I8(e,t){return e.min===t.min&&e.max===t.max}function hve(e,t){return I8(e.x,t.x)&&I8(e.y,t.y)}function P8(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HK(e,t){return P8(e.x,t.x)&&P8(e.y,t.y)}function M8(e){return ko(e.x)/ko(e.y)}function L8(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class pve{constructor(){this.members=[]}add(t){bD(this.members,t),t.scheduleRender()}remove(t){if(OD(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let i;for(let r=n;r>=0;r--){const s=this.members[r];if(s.isPresent!==!1){i=s;break}}return i?(this.promote(i),!0):!1}promote(t,n){const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.instance&&i.scheduleRender(),t.scheduleRender(),t.resumeFrom=i,n&&(t.resumeFrom.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:i}=t;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function mve(e,t,n){let i="";const r=e.x.translate/t.x,s=e.y.translate/t.y,a=(n==null?void 0:n.z)||0;if((r||s||a)&&(i=`translate3d(${r}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:f,rotateY:h,skewX:p,skewY:g}=n;u&&(i=`perspective(${u}px) ${i}`),d&&(i+=`rotate(${d}deg) `),f&&(i+=`rotateX(${f}deg) `),h&&(i+=`rotateY(${h}deg) `),p&&(i+=`skewX(${p}deg) `),g&&(i+=`skewY(${g}deg) `)}const o=e.x.scale*t.x,c=e.y.scale*t.y;return(o!==1||c!==1)&&(i+=`scale(${o}, ${c})`),i||"none"}const kh={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},EO=typeof window<"u"&&window.MotionDebug!==void 0,R2=["","X","Y","Z"],gve={visibility:"hidden"},D8=1e3;let bve=0;function I2(e,t,n,i){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),i&&(i[e]=0))}function YK(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=ZZ(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Zi,!(r||s))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&YK(i)}function GK({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(a={},o=t==null?void 0:t()){this.id=bve++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,EO&&(kh.totalNodes=kh.resolvedTargetDeltas=kh.recalculatedProjection=0),this.nodes.forEach(xve),this.nodes.forEach(kve),this.nodes.forEach(Tve),this.nodes.forEach(vve),EO&&window.MotionDebug.record(kh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let c=0;cthis.root.updateBlockedByResize=!1;e(a,()=>{this.root.updateBlockedByResize=!0,f&&f(),f=sve(h,250),DS.hasAnimatedSinceResize&&(DS.hasAnimatedSinceResize=!1,this.nodes.forEach(Q8))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&d&&(c||u)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:h,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||d.getDefaultTransition()||jve,{onLayoutAnimationStart:y,onLayoutAnimationComplete:O}=d.getProps(),v=!this.targetLayout||!HK(this.targetLayout,g)||p,x=!h&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||x||h&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(f,x);const w={...gD(b,"layout"),onPlay:y,onComplete:O};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w)}else h||Q8(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,jf(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(_ve),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&YK(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c{const E=w/1e3;B8(f.x,a.x,E),B8(f.y,a.y,E),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(sy(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Nve(this.relativeTarget,this.relativeTargetOrigin,h,E),x&&hve(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=Ar()),Po(x,this.relativeTarget)),b&&(this.animationValues=d,ove(d,u,this.latestValues,E,v,O)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=E},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(jf(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Zi.update(()=>{DS.hasAnimatedSinceResize=!0,this.currentAnimation=tve(0,D8,{...a,onUpdate:o=>{this.mixTargetDelta(o),a.onUpdate&&a.onUpdate(o)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(D8),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:c,layout:u,latestValues:d}=a;if(!(!o||!c||!u)){if(this!==a&&this.layout&&u&&WK(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Ar();const f=ko(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+f;const h=ko(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+h}Po(o,c),Km(o,d),ry(this.projectionDeltaWithTransform,this.layoutCorrected,o,d)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new pve),this.sharedNodes.get(a).add(o);const u=o.options.initialPromotionConfig;o.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var a;const{layoutId:o}=this.options;return o?((a=this.getStack())===null||a===void 0?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:o}=this.options;return o?(a=this.getStack())===null||a===void 0?void 0:a.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(o=!0),!o)return;const u={};c.z&&I2("z",a,u,this.animationValues);for(let d=0;d{var o;return(o=a.currentAnimation)===null||o===void 0?void 0:o.stop()}),this.root.nodes.forEach($8),this.root.sharedNodes.clear()}}}function Ove(e){e.updateLayout()}function yve(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:r}=e.layout,{animationType:s}=e.options,a=n.source!==e.layout.source;s==="size"?Mo(f=>{const h=a?n.measuredBox[f]:n.layoutBox[f],p=ko(h);h.min=i[f].min,h.max=h.min+p}):WK(s,n.layoutBox,i)&&Mo(f=>{const h=a?n.measuredBox[f]:n.layoutBox[f],p=ko(i[f]);h.max=h.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[f].max=e.relativeTarget[f].min+p)});const o=Wm();ry(o,i,n.layoutBox);const c=Wm();a?ry(c,e.applyTransform(r,!0),n.measuredBox):ry(c,i,n.layoutBox);const u=!qK(o);let d=!1;if(!e.resumeFrom){const f=e.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:h,layout:p}=f;if(h&&p){const g=Ar();sy(g,n.layoutBox,h.layoutBox);const b=Ar();sy(b,i,p.layoutBox),HK(g,b)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=b,e.relativeTargetOrigin=g,e.relativeParent=f)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:n,delta:c,layoutDelta:o,hasLayoutChanged:u,hasRelativeTargetChanged:d})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function xve(e){EO&&kh.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function vve(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function wve(e){e.clearSnapshot()}function $8(e){e.clearMeasurements()}function Sve(e){e.isLayoutDirty=!1}function Eve(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Q8(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function kve(e){e.resolveTargetDelta()}function Tve(e){e.calcProjection()}function _ve(e){e.resetSkewAndRotation()}function Ave(e){e.removeLeadSnapshot()}function B8(e,t,n){e.translate=pr(t.translate,0,n),e.scale=pr(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function U8(e,t,n,i){e.min=pr(t.min,n.min,i),e.max=pr(t.max,n.max,i)}function Nve(e,t,n,i){U8(e.x,t.x,n.x,i),U8(e.y,t.y,n.y,i)}function Cve(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const jve={duration:.45,ease:[.4,0,.1,1]},z8=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),F8=z8("applewebkit/")&&!z8("chrome/")?Math.round:xo;function V8(e){e.min=F8(e.min),e.max=F8(e.max)}function Rve(e){V8(e.x),V8(e.y)}function WK(e,t,n){return e==="position"||e==="preserve-aspect"&&!M1e(M8(t),M8(n),.2)}function Ive(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const Pve=GK({attachResizeListener:(e,t)=>ex(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),P2={current:void 0},ZK=GK({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!P2.current){const e=new Pve({});e.mount(window),e.setOptions({layoutScroll:!0}),P2.current=e}return P2.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Mve={pan:{Feature:Z1e},drag:{Feature:W1e,ProjectionNode:ZK,MeasureLayout:FK}};function Lve(e,t,n){var i;if(e instanceof Element)return[e];if(typeof e=="string"){let r=document;const s=(i=void 0)!==null&&i!==void 0?i:r.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e)}function KK(e,t){const n=Lve(e),i=new AbortController,r={passive:!0,...t,signal:i.signal};return[n,r,()=>i.abort()]}function X8(e){return t=>{t.pointerType==="touch"||IK()||e(t)}}function Dve(e,t,n={}){const[i,r,s]=KK(e,n),a=X8(o=>{const{target:c}=o,u=t(o);if(typeof u!="function"||!c)return;const d=X8(f=>{u(f),c.removeEventListener("pointerleave",d)});c.addEventListener("pointerleave",d,r)});return i.forEach(o=>{o.addEventListener("pointerenter",a,r)}),s}function q8(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,s=i[r];s&&Zi.postRender(()=>s(t,x1(t)))}class $ve extends Kf{mount(){const{current:t}=this.node;t&&(this.unmount=Dve(t,n=>(q8(this.node,n,"Start"),i=>q8(this.node,i,"End"))))}unmount(){}}class Qve extends Kf{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=y1(ex(this.node.current,"focus",()=>this.onFocus()),ex(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const JK=(e,t)=>t?e===t?!0:JK(e,t.parentElement):!1,Bve=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Uve(e){return Bve.has(e.tagName)||e.tabIndex!==-1}const kO=new WeakSet;function H8(e){return t=>{t.key==="Enter"&&e(t)}}function M2(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const zve=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=H8(()=>{if(kO.has(n))return;M2(n,"down");const r=H8(()=>{M2(n,"up")}),s=()=>M2(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function Y8(e){return RD(e)&&!IK()}function Fve(e,t,n={}){const[i,r,s]=KK(e,n),a=o=>{const c=o.currentTarget;if(!Y8(o)||kO.has(c))return;kO.add(c);const u=t(o),d=(p,g)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),!(!Y8(p)||!kO.has(c))&&(kO.delete(c),typeof u=="function"&&u(p,{success:g}))},f=p=>{d(p,n.useGlobalTarget||JK(c,p.target))},h=p=>{d(p,!1)};window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",h,r)};return i.forEach(o=>{!Uve(o)&&o.getAttribute("tabindex")===null&&(o.tabIndex=0),(n.useGlobalTarget?window:o).addEventListener("pointerdown",a,r),o.addEventListener("focus",u=>zve(u,r),r)}),s}function G8(e,t,n){const{props:i}=e;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),s=i[r];s&&Zi.postRender(()=>s(t,x1(t)))}class Vve extends Kf{mount(){const{current:t}=this.node;t&&(this.unmount=Fve(t,n=>(G8(this.node,n,"Start"),(i,{success:r})=>G8(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const GI=new WeakMap,L2=new WeakMap,Xve=e=>{const t=GI.get(e.target);t&&t(e)},qve=e=>{e.forEach(Xve)};function Hve({root:e,...t}){const n=e||document;L2.has(n)||L2.set(n,{});const i=L2.get(n),r=JSON.stringify(t);return i[r]||(i[r]=new IntersectionObserver(qve,{root:e,...t})),i[r]}function Yve(e,t,n){const i=Hve(t);return GI.set(e,n),i.observe(e),()=>{GI.delete(e),i.unobserve(e)}}const Gve={some:0,all:1};class Wve extends Kf{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:s}=t,a={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:Gve[r]},o=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,s&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),h=u?d:f;h&&h(c)};return Yve(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Zve(t,n))&&this.startObserver()}unmount(){}}function Zve({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Kve={inView:{Feature:Wve},tap:{Feature:Vve},focus:{Feature:Qve},hover:{Feature:$ve}},Jve={layout:{ProjectionNode:ZK,MeasureLayout:FK}},dk={current:null},ID={current:!1};function eJ(){if(ID.current=!0,!!nD)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>dk.current=e.matches;e.addListener(t),t()}else dk.current=!1}const ewe=[...vK,Vs,Rf],twe=e=>ewe.find(xK(e)),W8=new WeakMap;function nwe(e,t,n){for(const i in t){const r=t[i],s=n[i];if(Ys(r))e.addValue(i,r);else if(Ys(s))e.addValue(i,Ky(r,{owner:e}));else if(s!==r)if(e.hasValue(i)){const a=e.getValue(i);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=e.getStaticValue(i);e.addValue(i,Ky(a!==void 0?a:r,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Z8=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class iwe{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:r,blockInitialAnimation:s,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=AD,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Dc.now();this.renderScheduledAtthis.bindToMotionValue(i,n)),ID.current||eJ(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:dk.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){W8.delete(this.current),this.projection&&this.projection.unmount(),jf(this.notifyUpdate),jf(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const i=Lp.has(t),r=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&Zi.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0)}),s=n.on("renderRequest",this.scheduleRender);let a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),s(),a&&a(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Zg){const n=Zg[t];if(!n)continue;const{isEnabled:i,Feature:r}=n;if(!this.features[t]&&r&&i(this.props)&&(this.features[t]=new r(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ar()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;in.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=Ky(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){var i;let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(i=this.getBaseTargetFromProps(this.props,t))!==null&&i!==void 0?i:this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(OK(r)||cK(r))?r=parseFloat(r):!twe(r)&&Rf.test(n)&&(r=mK(t,n)),this.setBaseTarget(t,Ys(r)?r.get():r)),Ys(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:i}=this.props;let r;if(typeof i=="string"||typeof i=="object"){const a=lD(this.props,i,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);a&&(r=a[t])}if(i&&r!==void 0)return r;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!Ys(s)?s:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new yD),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class tJ extends iwe{constructor(){super(...arguments),this.KeyframeResolver=wK}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Ys(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function rwe(e){return window.getComputedStyle(e)}class swe extends tJ{constructor(){super(...arguments),this.type="html",this.renderInstance=zZ}readValueFromInstance(t,n){if(Lp.has(n)){const i=_D(n);return i&&i.default||0}else{const i=rwe(t),r=(QZ(n)?i.getPropertyValue(n):i[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return UK(t,n)}build(t,n,i){dD(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return mD(t,n,i)}}class awe extends tJ{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ar}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Lp.has(n)){const i=_D(n);return i&&i.default||0}return n=FZ.has(n)?n:sD(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return qZ(t,n,i)}build(t,n,i){fD(t,n,this.isSVGTag,i.transformTemplate)}renderInstance(t,n,i,r){VZ(t,n,i,r)}mount(t){this.isSVGTag=pD(t.tagName),super.mount(t)}}const owe=(e,t)=>oD(e)?new awe(t):new swe(t,{allowProjection:e!==m.Fragment}),lwe=Pye({...k1e,...Kve,...Mve,...Jve},owe),wr=GOe(lwe);function cwe(){!ID.current&&eJ();const[e]=m.useState(dk.current);return e}function ts(){return ts=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u"||/ServerSideRendering/.test(navigator&&navigator.userAgent)?m.useEffect:m.useLayoutEffect;function km(e,t,n){var i=m.useRef(t);i.current=t,m.useEffect(function(){function r(s){i.current(s)}return e&&window.addEventListener(e,r,n),function(){e&&window.removeEventListener(e,r)}},[e])}var uwe=["container"];function dwe(e){var t=e.container,n=t===void 0?document.body:t,i=m_(e,uwe);return zi.createPortal(mn.createElement("div",ts({},i)),n)}function fwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function hwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function pwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function mwe(){return m.useEffect(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function J8(e){var t=e.touches[0],n=t.clientX,i=t.clientY;if(e.touches.length>=2){var r=e.touches[1],s=r.clientX,a=r.clientY;return[(n+s)/2,(i+a)/2,Math.sqrt(Math.pow(s-n,2)+Math.pow(a-i,2))]}return[n,i,0]}var Vd=function(e,t,n,i){var r,s=n*t,a=(s-i)/2,o=e;return s<=i?(r=1,o=0):e>0&&a-e<=0?(r=2,o=a):e<0&&a+e<=0&&(r=3,o=-a),[r,o]};function D2(e,t,n,i,r,s,a,o,c,u){a===void 0&&(a=innerWidth/2),o===void 0&&(o=innerHeight/2),c===void 0&&(c=0),u===void 0&&(u=0);var d=Vd(e,s,n,innerWidth)[0],f=Vd(t,s,i,innerHeight),h=innerWidth/2,p=innerHeight/2;return{x:a-s/r*(a-(h+e))-h+(i/n>=3&&n*s===innerWidth?0:d?c/2:c),y:o-s/r*(o-(p+t))-p+(f[0]?u/2:u),lastCX:a,lastCY:o}}function KI(e,t,n){var i=e%180!=0;return i?[n,t,i]:[t,n,i]}function $2(e,t,n){var i=KI(n,innerWidth,innerHeight),r=i[0],s=i[1],a=0,o=r,c=s,u=e/t*s,d=t/e*r;return e=s?o=u:e>=r&&tr/s?c=d:t/e>=3&&!i[2]?a=((c=d)-s)/2:o=u,{width:o,height:c,x:0,y:a,pause:!0}}function nw(e,t){var n=t.leading,i=n!==void 0&&n,r=t.maxWait,s=t.wait,a=s===void 0?r||0:s,o=m.useRef(e);o.current=e;var c=m.useRef(0),u=m.useRef(),d=function(){return u.current&&clearTimeout(u.current)},f=m.useCallback(function(){var h=[].slice.call(arguments),p=Date.now();function g(){c.current=p,d(),o.current.apply(null,h)}var b=c.current,y=p-b;if(b===0&&(i&&g(),c.current=p),r!==void 0){if(y>r)return void g()}else y=1&&s&&s())};d()}function d(){c=requestAnimationFrame(u)}}var bwe={T:0,L:0,W:0,H:0,FIT:void 0},iJ=function(){var e=m.useRef(!1);return m.useEffect(function(){return e.current=!0,function(){e.current=!1}},[]),e},Owe=["className"];function ywe(e){var t=e.className,n=t===void 0?"":t,i=m_(e,Owe);return mn.createElement("div",ts({className:"PhotoView__Spinner "+n},i),mn.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},mn.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),mn.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var xwe=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function vwe(e){var t=e.src,n=e.loaded,i=e.broken,r=e.className,s=e.onPhotoLoad,a=e.loadingElement,o=e.brokenElement,c=m_(e,xwe),u=iJ();return t&&!i?mn.createElement(mn.Fragment,null,mn.createElement("img",ts({className:"PhotoView__Photo"+(r?" "+r:""),src:t,onLoad:function(d){var f=d.target;u.current&&s({loaded:!0,naturalWidth:f.naturalWidth,naturalHeight:f.naturalHeight})},onError:function(){u.current&&s({broken:!0})},draggable:!1,alt:""},c)),!n&&(a?mn.createElement("span",{className:"PhotoView__icon"},a):mn.createElement(ywe,{className:"PhotoView__icon"}))):o?mn.createElement("span",{className:"PhotoView__icon"},typeof o=="function"?o({src:t}):o):null}var wwe={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Swe(e){var t=e.item,n=t.src,i=t.render,r=t.width,s=r===void 0?0:r,a=t.height,o=a===void 0?0:a,c=t.originRef,u=e.visible,d=e.speed,f=e.easing,h=e.wrapClassName,p=e.className,g=e.style,b=e.loadingElement,y=e.brokenElement,O=e.onPhotoTap,v=e.onMaskTap,x=e.onReachMove,w=e.onReachUp,E=e.onPhotoResize,S=e.isActive,k=e.expose,T=fk(wwe),A=T[0],N=T[1],C=m.useRef(0),M=iJ(),L=A.naturalWidth,P=L===void 0?s:L,Q=A.naturalHeight,j=Q===void 0?o:Q,$=A.width,U=$===void 0?s:$,B=A.height,I=B===void 0?o:B,X=A.loaded,q=X===void 0?!n:X,D=A.broken,H=A.x,re=A.y,fe=A.touched,Ae=A.stopRaf,J=A.maskTouched,ie=A.rotate,ue=A.scale,ye=A.CX,Se=A.CY,Re=A.lastX,Ee=A.lastY,me=A.lastCX,oe=A.lastCY,Ne=A.lastScale,Oe=A.touchTime,Ve=A.touchLength,We=A.pause,De=A.reach,mt=tp({onScale:function(je){return at(tw(je))},onRotate:function(je){ie!==je&&(k({rotate:je}),N(ts({rotate:je},$2(P,j,je))))}});function at(je,Ze,Ie){ue!==je&&(k({scale:je}),N(ts({scale:je},D2(H,re,U,I,ue,je,Ze,Ie),je<=1&&{x:0,y:0})))}var Rt=nw(function(je,Ze,Ie){if(Ie===void 0&&(Ie=0),(fe||J)&&S){var Wt=KI(ie,U,I),dn=Wt[0],Qt=Wt[1];if(Ie===0&&C.current===0){var Yt=Math.abs(je-ye)<=20,Jt=Math.abs(Ze-Se)<=20;if(Yt&&Jt)return void N({lastCX:je,lastCY:Ze});C.current=Yt?Ze>Se?3:2:1}var Ft,Ce=je-me,et=Ze-oe;if(Ie===0){var wt=Vd(Ce+Re,ue,dn,innerWidth)[0],yn=Vd(et+Ee,ue,Qt,innerHeight);Ft=function(hi,Pe,st,At){return Pe&&hi===1||At==="x"?"x":st&&hi>1||At==="y"?"y":void 0}(C.current,wt,yn[0],De),Ft!==void 0&&x(Ft,je,Ze,ue)}if(Ft==="x"||J)return void N({reach:"x"});var on=tw(ue+(Ie-Ve)/100/2*ue,P/U,.2);k({scale:on}),N(ts({touchLength:Ie,reach:Ft,scale:on},D2(H,re,U,I,ue,on,je,Ze,Ce,et)))}},{maxWait:8});function qe(je){return!Ae&&!fe&&(M.current&&N(ts({},je,{pause:u})),M.current)}var W,K,ae,pe,z,ve,Be,Je,kt=(z=function(je){return qe({x:je})},ve=function(je){return qe({y:je})},Be=function(je){return M.current&&(k({scale:je}),N({scale:je})),!fe&&M.current},Je=tp({X:function(je){return z(je)},Y:function(je){return ve(je)},S:function(je){return Be(je)}}),function(je,Ze,Ie,Wt,dn,Qt,Yt,Jt,Ft,Ce,et){var wt=KI(Ce,dn,Qt),yn=wt[0],on=wt[1],hi=Vd(je,Jt,yn,innerWidth),Pe=hi[0],st=hi[1],At=Vd(Ze,Jt,on,innerHeight),Ut=At[0],kn=At[1],wn=Date.now()-et;if(wn>=200||Jt!==Yt||Math.abs(Ft-Yt)>1){var Ai=D2(je,Ze,dn,Qt,Yt,Jt),Gn=Ai.x,xn=Ai.y,de=Pe?st:Gn!==je?Gn:null,Le=Ut?kn:xn!==Ze?xn:null;return de!==null&&jh(je,de,Je.X),Le!==null&&jh(Ze,Le,Je.Y),void(Jt!==Yt&&jh(Yt,Jt,Je.S))}var ut=(je-Ie)/wn,gt=(Ze-Wt)/wn,ln=Math.sqrt(Math.pow(ut,2)+Math.pow(gt,2)),Sn=!1,In=!1;(function(Ni,Pn){var Vt,Ji=Ni,fn=0,pi=0,ti=function(Ci){Vt||(Vt=Ci);var xs=Ci-Vt,ni=Math.sign(Ni),Ls=-.001*ni,er=Math.sign(-Ji)*Math.pow(Ji,2)*2e-4,Ya=Ji*xs+(Ls+er)*Math.pow(xs,2)/2;fn+=Ya,Vt=Ci,ni*(Ji+=(Ls+er)*xs)<=0?en():Pn(fn)?vi():en()};function vi(){pi=requestAnimationFrame(ti)}function en(){cancelAnimationFrame(pi)}vi()})(ln,function(Ni){var Pn=je+Ni*(ut/ln),Vt=Ze+Ni*(gt/ln),Ji=Vd(Pn,Yt,yn,innerWidth),fn=Ji[0],pi=Ji[1],ti=Vd(Vt,Yt,on,innerHeight),vi=ti[0],en=ti[1];if(fn&&!Sn&&(Sn=!0,Pe?jh(Pn,pi,Je.X):e9(pi,Pn+(Pn-pi),Je.X)),vi&&!In&&(In=!0,Ut?jh(Vt,en,Je.Y):e9(en,Vt+(Vt-en),Je.Y)),Sn&&In)return!1;var Ci=Sn||Je.X(pi),xs=In||Je.Y(en);return Ci&&xs})}),Mt=(W=O,K=function(je,Ze){De||at(ue!==1?1:Math.max(2,P/U),je,Ze)},ae=m.useRef(0),pe=nw(function(){ae.current=0,W.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var je=[].slice.call(arguments);ae.current+=1,pe.apply(void 0,je),ae.current>=2&&(pe.cancel(),ae.current=0,K.apply(void 0,je))});function Tt(je,Ze){if(C.current=0,(fe||J)&&S){N({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var Ie=tw(ue,P/U);if(kt(H,re,Re,Ee,U,I,ue,Ie,Ne,ie,Oe),w(je,Ze),ye===je&&Se===Ze){if(fe)return void Mt(je,Ze);J&&v(je,Ze)}}}function dt(je,Ze,Ie){Ie===void 0&&(Ie=0),N({touched:!0,CX:je,CY:Ze,lastCX:je,lastCY:Ze,lastX:H,lastY:re,lastScale:ue,touchLength:Ie,touchTime:Date.now()})}function ge(je){N({maskTouched:!0,CX:je.clientX,CY:je.clientY,lastX:H,lastY:re})}km(yu?void 0:"mousemove",function(je){je.preventDefault(),Rt(je.clientX,je.clientY)}),km(yu?void 0:"mouseup",function(je){Tt(je.clientX,je.clientY)}),km(yu?"touchmove":void 0,function(je){je.preventDefault();var Ze=J8(je);Rt.apply(void 0,Ze)},{passive:!1}),km(yu?"touchend":void 0,function(je){var Ze=je.changedTouches[0];Tt(Ze.clientX,Ze.clientY)},{passive:!1}),km("resize",nw(function(){q&&!fe&&(N($2(P,j,ie)),E())},{maxWait:8})),ZI(function(){S&&k(ts({scale:ue,rotate:ie},mt))},[S]);var lt=function(je,Ze,Ie,Wt,dn,Qt,Yt,Jt,Ft,Ce){var et=function(Gn,xn,de,Le,ut){var gt=m.useRef(!1),ln=fk({lead:!0,scale:de}),Sn=ln[0],In=Sn.lead,Ni=Sn.scale,Pn=ln[1],Vt=nw(function(Ji){try{return ut(!0),Pn({lead:!1,scale:Ji}),Promise.resolve()}catch(fn){return Promise.reject(fn)}},{wait:Le});return ZI(function(){gt.current?(ut(!1),Pn({lead:!0}),Vt(de)):gt.current=!0},[de]),In?[Gn*Ni,xn*Ni,de/Ni]:[Gn*de,xn*de,1]}(Qt,Yt,Jt,Ft,Ce),wt=et[0],yn=et[1],on=et[2],hi=function(Gn,xn,de,Le,ut){var gt=m.useState(bwe),ln=gt[0],Sn=gt[1],In=m.useState(0),Ni=In[0],Pn=In[1],Vt=m.useRef(),Ji=tp({OK:function(){return Gn&&Pn(4)}});function fn(pi){ut(!1),Pn(pi)}return m.useEffect(function(){if(Vt.current||(Vt.current=Date.now()),de){if(function(pi,ti){var vi=pi&&pi.current;if(vi&&vi.nodeType===1){var en=vi.getBoundingClientRect();ti({T:en.top,L:en.left,W:en.width,H:en.height,FIT:vi.tagName==="IMG"?getComputedStyle(vi).objectFit:void 0})}}(xn,Sn),Gn)return Date.now()-Vt.current<250?(Pn(1),requestAnimationFrame(function(){Pn(2),requestAnimationFrame(function(){return fn(3)})}),void setTimeout(Ji.OK,Le)):void Pn(4);fn(5)}},[Gn,de]),[Ni,ln]}(je,Ze,Ie,Ft,Ce),Pe=hi[0],st=hi[1],At=st.W,Ut=st.FIT,kn=innerWidth/2,wn=innerHeight/2,Ai=Pe<3||Pe>4;return[Ai?At?st.L:kn:Wt+(kn-Qt*Jt/2),Ai?At?st.T:wn:dn+(wn-Yt*Jt/2),wt,Ai&&Ut?wt*(st.H/At):yn,Pe===0?on:Ai?At/(Qt*Jt)||.01:on,Ai?Ut?1:0:1,Pe,Ut]}(u,c,q,H,re,U,I,ue,d,function(je){return N({pause:je})}),Ge=lt[4],vt=lt[6],_t="transform "+d+"ms "+f,Bt={className:p,onMouseDown:yu?void 0:function(je){je.stopPropagation(),je.button===0&&dt(je.clientX,je.clientY,0)},onTouchStart:yu?function(je){je.stopPropagation(),dt.apply(void 0,J8(je))}:void 0,onWheel:function(je){if(!De){var Ze=tw(ue-je.deltaY/100/2,P/U);N({stopRaf:!0}),at(Ze,je.clientX,je.clientY)}},style:{width:lt[2]+"px",height:lt[3]+"px",opacity:lt[5],objectFit:vt===4?void 0:lt[7],transform:ie?"rotate("+ie+"deg)":void 0,transition:vt>2?_t+", opacity "+d+"ms ease, height "+(vt<4?d/2:vt>4?d:0)+"ms "+f:void 0}};return mn.createElement("div",{className:"PhotoView__PhotoWrap"+(h?" "+h:""),style:g,onMouseDown:!yu&&S?ge:void 0,onTouchStart:yu&&S?function(je){return ge(je.touches[0])}:void 0},mn.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Ge+", 0, 0, "+Ge+", "+lt[0]+", "+lt[1]+")",transition:fe||We?void 0:_t,willChange:S?"transform":void 0}},n?mn.createElement(vwe,ts({src:n,loaded:q,broken:D},Bt,{onPhotoLoad:function(je){N(ts({},je,je.loaded&&$2(je.naturalWidth||0,je.naturalHeight||0,ie)))},loadingElement:b,brokenElement:y})):i&&i({attrs:Bt,scale:Ge,rotate:ie})))}var t9={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function Ewe(e){var t=e.loop,n=t===void 0?3:t,i=e.speed,r=e.easing,s=e.photoClosable,a=e.maskClosable,o=a===void 0||a,c=e.maskOpacity,u=c===void 0?1:c,d=e.pullClosable,f=d===void 0||d,h=e.bannerVisible,p=h===void 0||h,g=e.overlayRender,b=e.toolbarRender,y=e.className,O=e.maskClassName,v=e.photoClassName,x=e.photoWrapClassName,w=e.loadingElement,E=e.brokenElement,S=e.images,k=e.index,T=k===void 0?0:k,A=e.onIndexChange,N=e.visible,C=e.onClose,M=e.afterClose,L=e.portalContainer,P=fk(t9),Q=P[0],j=P[1],$=m.useState(0),U=$[0],B=$[1],I=Q.x,X=Q.touched,q=Q.pause,D=Q.lastCX,H=Q.lastCY,re=Q.bg,fe=re===void 0?u:re,Ae=Q.lastBg,J=Q.overlay,ie=Q.minimal,ue=Q.scale,ye=Q.rotate,Se=Q.onScale,Re=Q.onRotate,Ee=e.hasOwnProperty("index"),me=Ee?T:U,oe=Ee?A:B,Ne=m.useRef(me),Oe=S.length,Ve=S[me],We=typeof n=="boolean"?n:Oe>n,De=function(Ge,vt){var _t=m.useReducer(function(Ie){return!Ie},!1)[1],Bt=m.useRef(0),je=function(Ie){var Wt=m.useRef(Ie);function dn(Qt){Wt.current=Qt}return m.useMemo(function(){(function(Qt){Ge?(Qt(Ge),Bt.current=1):Bt.current=2})(dn)},[Ie]),[Wt.current,dn]}(Ge),Ze=je[1];return[je[0],Bt.current,function(){_t(),Bt.current===2&&(Ze(!1),vt&&vt()),Bt.current=0}]}(N,M),mt=De[0],at=De[1],Rt=De[2];ZI(function(){if(mt)return j({pause:!0,x:me*-(innerWidth+nm)}),void(Ne.current=me);j(t9)},[mt]);var qe=tp({close:function(Ge){Re&&Re(0),j({overlay:!0,lastBg:fe}),C(Ge)},changeIndex:function(Ge,vt){vt===void 0&&(vt=!1);var _t=We?Ne.current+(Ge-me):Ge,Bt=Oe-1,je=WI(_t,0,Bt),Ze=We?_t:je,Ie=innerWidth+nm;j({touched:!1,lastCX:void 0,lastCY:void 0,x:-Ie*Ze,pause:vt}),Ne.current=Ze,oe&&oe(We?Ge<0?Bt:Ge>Bt?0:Ge:je)}}),W=qe.close,K=qe.changeIndex;function ae(Ge){return Ge?W():j({overlay:!J})}function pe(){j({x:-(innerWidth+nm)*me,lastCX:void 0,lastCY:void 0,pause:!0}),Ne.current=me}function z(Ge,vt,_t,Bt){Ge==="x"?function(je){if(D!==void 0){var Ze=je-D,Ie=Ze;!We&&(me===0&&Ze>0||me===Oe-1&&Ze<0)&&(Ie=Ze/2),j({touched:!0,lastCX:D,x:-(innerWidth+nm)*Ne.current+Ie,pause:!1})}else j({touched:!0,lastCX:je,x:I,pause:!1})}(vt):Ge==="y"&&function(je,Ze){if(H!==void 0){var Ie=u===null?null:WI(u,.01,u-Math.abs(je-H)/100/4);j({touched:!0,lastCY:H,bg:Ze===1?Ie:u,minimal:Ze===1})}else j({touched:!0,lastCY:je,bg:fe,minimal:!0})}(_t,Bt)}function ve(Ge,vt){var _t=Ge-(D??Ge),Bt=vt-(H??vt),je=!1;if(_t<-40)K(me+1);else if(_t>40)K(me-1);else{var Ze=-(innerWidth+nm)*Ne.current;Math.abs(Bt)>100&&ie&&f&&(je=!0,W()),j({touched:!1,x:Ze,lastCX:void 0,lastCY:void 0,bg:u,overlay:!!je||J})}}km("keydown",function(Ge){if(N)switch(Ge.key){case"ArrowLeft":K(me-1,!0);break;case"ArrowRight":K(me+1,!0);break;case"Escape":W()}});var Be=function(Ge,vt,_t){return m.useMemo(function(){var Bt=Ge.length;return _t?Ge.concat(Ge).concat(Ge).slice(Bt+vt-1,Bt+vt+2):Ge.slice(Math.max(vt-1,0),Math.min(vt+2,Bt+1))},[Ge,vt,_t])}(S,me,We);if(!mt)return null;var Je=J&&!at,kt=N?fe:Ae,Mt=Se&&Re&&{images:S,index:me,visible:N,onClose:W,onIndexChange:K,overlayVisible:Je,overlay:Ve&&Ve.overlay,scale:ue,rotate:ye,onScale:Se,onRotate:Re},Tt=i?i(at):400,dt=r?r(at):K8,ge=i?i(3):600,lt=r?r(3):K8;return mn.createElement(dwe,{className:"PhotoView-Portal"+(Je?"":" PhotoView-Slider__clean")+(N?"":" PhotoView-Slider__willClose")+(y?" "+y:""),role:"dialog",onClick:function(Ge){return Ge.stopPropagation()},container:L},N&&mn.createElement(mwe,null),mn.createElement("div",{className:"PhotoView-Slider__Backdrop"+(O?" "+O:"")+(at===1?" PhotoView-Slider__fadeIn":at===2?" PhotoView-Slider__fadeOut":""),style:{background:kt?"rgba(0, 0, 0, "+kt+")":void 0,transitionTimingFunction:dt,transitionDuration:(X?0:Tt)+"ms",animationDuration:Tt+"ms"},onAnimationEnd:Rt}),p&&mn.createElement("div",{className:"PhotoView-Slider__BannerWrap"},mn.createElement("div",{className:"PhotoView-Slider__Counter"},me+1," / ",Oe),mn.createElement("div",{className:"PhotoView-Slider__BannerRight"},b&&Mt&&b(Mt),mn.createElement(fwe,{className:"PhotoView-Slider__toolbarIcon",onClick:W}))),Be.map(function(Ge,vt){var _t=We||me!==0?Ne.current-1+vt:me+vt;return mn.createElement(Swe,{key:We?Ge.key+"/"+Ge.src+"/"+_t:Ge.key,item:Ge,speed:Tt,easing:dt,visible:N,onReachMove:z,onReachUp:ve,onPhotoTap:function(){return ae(s)},onMaskTap:function(){return ae(o)},wrapClassName:x,className:v,style:{left:(innerWidth+nm)*_t+"px",transform:"translate3d("+I+"px, 0px, 0)",transition:X||q?void 0:"transform "+ge+"ms "+lt},loadingElement:w,brokenElement:E,onPhotoResize:pe,isActive:Ne.current===_t,expose:j})}),!yu&&p&&mn.createElement(mn.Fragment,null,(We||me!==0)&&mn.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return K(me-1,!0)}},mn.createElement(hwe,null)),(We||me+1-1){var O=u.slice();return O.splice(y,1,b),void o({images:O})}o(function(v){return{images:v.images.concat(b)}})},remove:function(b){o(function(y){var O=y.images.filter(function(v){return v.key!==b});return{images:O,index:Math.min(O.length-1,f)}})},show:function(b){var y=u.findIndex(function(O){return O.key===b});o({visible:!0,index:y}),i&&i(!0,y,a)}}),p=tp({close:function(){o({visible:!1}),i&&i(!1,f,a)},changeIndex:function(b){o({index:b}),n&&n(b,a)}}),g=m.useMemo(function(){return ts({},a,h)},[a,h]);return mn.createElement(nJ.Provider,{value:g},t,mn.createElement(Ewe,ts({images:u,visible:d,index:f,onIndexChange:p.changeIndex,onClose:p.close},r)))}var rJ=function(e){var t,n,i=e.src,r=e.render,s=e.overlay,a=e.width,o=e.height,c=e.triggers,u=c===void 0?["onClick"]:c,d=e.children,f=m.useContext(nJ),h=(t=function(){return f.nextId()},(n=m.useRef({sign:!1,fn:void 0}).current).sign||(n.sign=!0,n.fn=t()),n.fn),p=m.useRef(null);m.useImperativeHandle(d==null?void 0:d.ref,function(){return p.current}),m.useEffect(function(){return function(){f.remove(h)}},[]);var g=tp({render:function(y){return r&&r(y)},show:function(y,O){f.show(h),function(v,x){if(d){var w=d.props[v];w&&w(x)}}(y,O)}}),b=m.useMemo(function(){var y={};return u.forEach(function(O){y[O]=g.show.bind(null,O)}),y},[]);return m.useEffect(function(){f.update({key:h,src:i,originRef:p,render:g.render,overlay:s,width:a,height:o})},[i]),d?m.Children.only(m.cloneElement(d,ts({},b,{ref:p}))):null};const Awe=e=>l.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:[l.jsx("path",{d:"M22 6.017c0-1.104-.907-2.037-2.049-2l-.594.025c-2.732.148-4.952.705-7.333 1.953l-.512.279-.087.054a1 1 0 0 0 .971 1.737l.092-.046.454-.246C15.195 6.59 17.26 6.106 20 6.016v11.837c-3.034.046-5.42.582-7.99 1.99l-.517.295-.086.056a1 1 0 0 0 1.009 1.715l.09-.047.455-.258c2.105-1.157 4.045-1.645 6.537-1.738l.543-.014a1.995 1.995 0 0 0 1.95-1.8l.009-.198V6.017Z"}),l.jsx("path",{d:"M2 6.017c0-1.104.907-2.037 2.049-2l.594.025c2.732.148 4.952.705 7.333 1.953l.512.279.087.054a1 1 0 0 1-.971 1.737l-.092-.046-.454-.246C8.805 6.59 6.74 6.106 4 6.016v11.837c3.034.046 5.42.582 7.99 1.99l.517.295.086.056a1 1 0 0 1-1.009 1.715l-.09-.047-.455-.258c-2.105-1.157-4.045-1.644-6.537-1.738l-.543-.014a1.995 1.995 0 0 1-1.95-1.8L2 17.855V6.017Z"}),l.jsx("path",{d:"M13 7.5v13h-2v-13h2Z"})]}),Nwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M10.556 4a1 1 0 0 0-.97.751l-.292 1.14h5.421l-.293-1.14A1 1 0 0 0 13.453 4h-2.897Zm6.224 1.892-.421-1.639A3 3 0 0 0 13.453 2h-2.897A3 3 0 0 0 7.65 4.253l-.421 1.639H4a1 1 0 1 0 0 2h.1l1.215 11.425A3 3 0 0 0 8.3 22h7.4a3 3 0 0 0 2.984-2.683l1.214-11.425H20a1 1 0 1 0 0-2h-3.22Zm1.108 2H6.112l1.192 11.214A1 1 0 0 0 8.3 20h7.4a1 1 0 0 0 .995-.894l1.192-11.214ZM10 10a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0v-5a1 1 0 0 1 1-1Zm4 0a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0v-5a1 1 0 0 1 1-1Z",clipRule:"evenodd"})}),Cwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M16.793 2.793a3.121 3.121 0 1 1 4.414 4.414l-8.5 8.5A1 1 0 0 1 12 16H9a1 1 0 0 1-1-1v-3a1 1 0 0 1 .293-.707l8.5-8.5Zm3 1.414a1.121 1.121 0 0 0-1.586 0L10 12.414V14h1.586l8.207-8.207a1.121 1.121 0 0 0 0-1.586ZM6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-4a1 1 0 1 1 2 0v4a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h4a1 1 0 1 1 0 2H6Z",clipRule:"evenodd"})}),jwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8-10C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2Zm4.465 6.763a1 1 0 0 0-1.228-1.228l-5.5 1.5a1 1 0 0 0-.702.702l-1.5 5.5a1 1 0 0 0 1.228 1.228l5.5-1.5a1 1 0 0 0 .702-.702l1.5-5.5Zm-6.54 5.312.89-3.26 3.26-.89-.89 3.26-3.26.89Z",clipRule:"evenodd"})}),Rwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M5.91456 7.59106C4.34202 9.04124 3.28878 10.7415 2.77064 11.6971C2.66597 11.8902 2.66597 12.1098 2.77064 12.3029C3.28878 13.2585 4.34202 14.9588 5.91456 16.4089C7.48207 17.8545 9.50584 19 12.0001 19C14.4944 19 16.5182 17.8545 18.0857 16.4089C19.6582 14.9588 20.7114 13.2585 21.2296 12.3029C21.3343 12.1098 21.3343 11.8902 21.2296 11.6971C20.7114 10.7415 19.6582 9.04124 18.0857 7.59105C16.5182 6.1455 14.4944 5 12.0001 5C9.50584 5 7.48207 6.1455 5.91456 7.59106ZM4.5587 6.1208C6.36071 4.45899 8.84593 3 12.0001 3C15.1543 3 17.6395 4.45899 19.4415 6.1208C21.2385 7.77798 22.4153 9.68799 22.9878 10.7438C23.4149 11.5315 23.4149 12.4685 22.9878 13.2562C22.4153 14.312 21.2385 16.222 19.4415 17.8792C17.6395 19.541 15.1543 21 12.0001 21C8.84593 21 6.36071 19.541 4.5587 17.8792C2.76171 16.222 1.5849 14.312 1.01244 13.2562C0.585372 12.4685 0.585371 11.5315 1.01244 10.7438C1.5849 9.688 2.76171 7.77798 4.5587 6.1208ZM12.0001 9.5C10.6194 9.5 9.50011 10.6193 9.50011 12C9.50011 13.3807 10.6194 14.5 12.0001 14.5C13.3808 14.5 14.5001 13.3807 14.5001 12C14.5001 10.6193 13.3808 9.5 12.0001 9.5ZM7.50011 12C7.50011 9.51472 9.51483 7.5 12.0001 7.5C14.4854 7.5 16.5001 9.51472 16.5001 12C16.5001 14.4853 14.4854 16.5 12.0001 16.5C9.51483 16.5 7.50011 14.4853 7.50011 12Z",fill:"currentColor"})}),Iwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M11.2929 3.29289C11.6834 2.90237 12.3166 2.90237 12.7071 3.29289L16.7071 7.29289C17.0976 7.68342 17.0976 8.31658 16.7071 8.70711C16.3166 9.09763 15.6834 9.09763 15.2929 8.70711L13 6.41421V15C13 15.5523 12.5523 16 12 16C11.4477 16 11 15.5523 11 15V6.41421L8.70711 8.70711C8.31658 9.09763 7.68342 9.09763 7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289L11.2929 3.29289ZM4 14C4.55229 14 5 14.4477 5 15V15.2C5 16.0566 5.00078 16.6389 5.03755 17.089C5.07337 17.5274 5.1383 17.7516 5.21799 17.908C5.40973 18.2843 5.7157 18.5903 6.09202 18.782C6.24842 18.8617 6.47262 18.9266 6.91104 18.9624C7.36113 18.9992 7.94342 19 8.8 19H15.2C16.0566 19 16.6389 18.9992 17.089 18.9624C17.5274 18.9266 17.7516 18.8617 17.908 18.782C18.2843 18.5903 18.5903 18.2843 18.782 17.908C18.8617 17.7516 18.9266 17.5274 18.9624 17.089C18.9992 16.6389 19 16.0566 19 15.2V15C19 14.4477 19.4477 14 20 14C20.5523 14 21 14.4477 21 15V15.2413C21 16.0463 21 16.7106 20.9558 17.2518C20.9099 17.8139 20.8113 18.3306 20.564 18.816C20.1805 19.5686 19.5686 20.1805 18.816 20.564C18.3306 20.8113 17.8139 20.9099 17.2518 20.9558C16.7106 21 16.0463 21 15.2413 21H8.75868C7.95372 21 7.28936 21 6.74817 20.9558C6.18608 20.9099 5.66937 20.8113 5.18404 20.564C4.43139 20.1805 3.81947 19.5686 3.43597 18.816C3.18868 18.3306 3.09012 17.8139 3.04419 17.2518C2.99998 16.7106 2.99999 16.0463 3 15.2413L3 15C3 14.4477 3.44772 14 4 14Z",fill:"currentColor"})}),Q2=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M8.99805 16.796C8.99805 15.4164 7.87961 14.2979 6.5 14.2979C5.12039 14.2979 4.00195 15.4164 4.00195 16.796C4.00196 18.1756 5.1204 19.294 6.5 19.294C7.8796 19.294 8.99804 18.1756 8.99805 16.796ZM19.748 15.0479C19.748 14.7729 19.525 14.5499 19.25 14.5499H15.75C15.475 14.5499 15.252 14.7729 15.252 15.0479V18.5479C15.252 18.823 15.475 19.046 15.75 19.046H19.25C19.525 19.046 19.748 18.823 19.748 18.5479V15.0479ZM10.0469 3.45125C11.077 2.15921 13.0849 2.20276 14.0498 3.58113L16.4189 6.96492L16.5205 7.12215C17.5046 8.76341 16.3301 10.9023 14.3691 10.9024H9.63086C7.60676 10.9023 6.42029 8.62316 7.58105 6.96492L9.9502 3.58113L10.0469 3.45125ZM12.4082 4.73055C12.2223 4.46497 11.842 4.44826 11.6318 4.68074L11.5918 4.73055L9.22266 8.11433C8.99176 8.44435 9.22808 8.89744 9.63086 8.89754H14.3691C14.7468 8.89745 14.9774 8.49957 14.8145 8.17781L14.7773 8.11433L12.4082 4.73055ZM11.002 16.796C11.0019 19.2824 8.98638 21.2979 6.5 21.2979C4.01362 21.2979 1.99806 19.2824 1.99805 16.796C1.99805 14.3096 4.01361 12.294 6.5 12.294C8.98639 12.294 11.002 14.3096 11.002 16.796ZM21.752 18.5479C21.752 19.9297 20.6318 21.0499 19.25 21.0499H15.75C14.3682 21.0499 13.248 19.9297 13.248 18.5479V15.0479C13.2481 13.6662 14.3682 12.546 15.75 12.546H19.25C20.6318 12.546 21.7519 13.6662 21.752 15.0479V18.5479Z",fill:"currentColor"})});/** + `),()=>{document.head.removeChild(d)}},[t]),l.jsx(QOe,{isPresent:t,childRef:i,sizeRef:r,children:m.cloneElement(e,{ref:i})})}const UOe=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:a})=>{const o=l_(zOe),c=m.useId(),u=m.useCallback(f=>{o.set(f,!0);for(const h of o.values())if(!h)return;i&&i()},[o,i]),d=m.useMemo(()=>({id:c,initial:t,isPresent:n,custom:r,onExitComplete:u,register:f=>(o.set(f,!1),()=>o.delete(f))}),s?[Math.random(),u]:[n,u]);return m.useMemo(()=>{o.forEach((f,h)=>o.set(h,!1))},[n]),m.useEffect(()=>{!n&&!o.size&&i&&i()},[n]),a==="popLayout"&&(e=l.jsx(BOe,{isPresent:n,children:e})),l.jsx(c_.Provider,{value:d,children:e})};function zOe(){return new Map}function _Z(e=!0){const t=m.useContext(c_);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=t,s=m.useId();m.useEffect(()=>{e&&r(s)},[e]);const a=m.useCallback(()=>e&&i&&i(s),[s,i,e]);return!n&&i?[!1,a]:[!0]}const Zv=e=>e.key||"";function DB(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const nD=typeof window<"u",AZ=nD?m.useLayoutEffect:m.useEffect,xf=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:s="sync",propagate:a=!1})=>{const[o,c]=_Z(a),u=m.useMemo(()=>DB(e),[e]),d=a&&!o?[]:u.map(Zv),f=m.useRef(!0),h=m.useRef(u),p=l_(()=>new Map),[g,b]=m.useState(u),[y,O]=m.useState(u);AZ(()=>{f.current=!1,h.current=u;for(let w=0;w{const E=Zv(w),S=a&&!o?!1:u===y||d.includes(E),k=()=>{if(p.has(E))p.set(E,!0);else return;let T=!0;p.forEach(A=>{A||(T=!1)}),T&&(x==null||x(),O(h.current),a&&(c==null||c()),i&&i())};return l.jsx(UOe,{isPresent:S,initial:!f.current||n?void 0:!1,custom:S?void 0:t,presenceAffectsLayout:r,mode:s,onExitComplete:S?void 0:k,children:w},E)})})},xo=e=>e;let NZ=xo;const FOe={useManualTiming:!1};function VOe(e){let t=new Set,n=new Set,i=!1,r=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function o(u){s.has(u)&&(c.schedule(u),e()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const p=f&&i?t:n;return d&&s.add(u),p.has(u)||p.add(u),u},cancel:u=>{n.delete(u),s.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[t,n]=[n,t],t.forEach(o),t.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const Kv=["read","resolveKeyframes","update","preRender","render","postRender"],XOe=40;function CZ(e,t){let n=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,a=Kv.reduce((O,v)=>(O[v]=VOe(s),O),{}),{read:o,resolveKeyframes:c,update:u,preRender:d,render:f,postRender:h}=a,p=()=>{const O=performance.now();n=!1,r.delta=i?1e3/60:Math.max(Math.min(O-r.timestamp,XOe),1),r.timestamp=O,r.isProcessing=!0,o.process(r),c.process(r),u.process(r),d.process(r),f.process(r),h.process(r),r.isProcessing=!1,n&&t&&(i=!1,e(p))},g=()=>{n=!0,i=!0,r.isProcessing||e(p)};return{schedule:Kv.reduce((O,v)=>{const x=a[v];return O[v]=(w,E=!1,S=!1)=>(n||g(),x.schedule(w,E,S)),O},{}),cancel:O=>{for(let v=0;v$B[e].some(n=>!!t[n])};function qOe(e){for(const t in e)Zg[t]={...Zg[t],...e[t]}}const HOe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function rk(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||HOe.has(e)}let RZ=e=>!rk(e);function IZ(e){e&&(RZ=t=>t.startsWith("on")?!rk(t):e(t))}try{IZ(require("@emotion/is-prop-valid").default)}catch{}function YOe(e,t,n){const i={};for(const r in e)r==="values"&&typeof e.values=="object"||(RZ(r)||n===!0&&rk(r)||!t&&!rk(r)||e.draggable&&r.startsWith("onDrag"))&&(i[r]=e[r]);return i}function GOe({children:e,isValidProp:t,...n}){t&&IZ(t),n={...m.useContext(Gy),...n},n.isStatic=l_(()=>n.isStatic);const i=m.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return l.jsx(Gy.Provider,{value:i,children:e})}function WOe(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...i)=>e(...i);return new Proxy(n,{get:(i,r)=>r==="create"?e:(t.has(r)||t.set(r,e(r)),t.get(r))})}const u_=m.createContext({});function Wy(e){return typeof e=="string"||Array.isArray(e)}function d_(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const iD=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],rD=["initial",...iD];function f_(e){return d_(e.animate)||rD.some(t=>Wy(e[t]))}function PZ(e){return!!(f_(e)||e.variants)}function ZOe(e,t){if(f_(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Wy(n)?n:void 0,animate:Wy(i)?i:void 0}}return e.inherit!==!1?t:{}}function KOe(e){const{initial:t,animate:n}=ZOe(e,m.useContext(u_));return m.useMemo(()=>({initial:t,animate:n}),[QB(t),QB(n)])}function QB(e){return Array.isArray(e)?e.join(" "):e}const JOe=Symbol.for("motionComponentSymbol");function Ym(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function eye(e,t,n){return m.useCallback(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):Ym(n)&&(n.current=i))},[t])}const sD=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),tye="framerAppearId",MZ="data-"+sD(tye),{schedule:aD}=CZ(queueMicrotask,!1),LZ=m.createContext({});function nye(e,t,n,i,r){var s,a;const{visualElement:o}=m.useContext(u_),c=m.useContext(jZ),u=m.useContext(c_),d=m.useContext(Gy).reducedMotion,f=m.useRef(null);i=i||c.renderer,!f.current&&i&&(f.current=i(e,{visualState:t,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:d}));const h=f.current,p=m.useContext(LZ);h&&!h.projection&&r&&(h.type==="html"||h.type==="svg")&&iye(f.current,n,r,p);const g=m.useRef(!1);m.useInsertionEffect(()=>{h&&g.current&&h.update(n,u)});const b=n[MZ],y=m.useRef(!!b&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,b))&&((a=window.MotionHasOptimisedAnimation)===null||a===void 0?void 0:a.call(window,b)));return AZ(()=>{h&&(g.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),aD.render(h.render),y.current&&h.animationState&&h.animationState.animateChanges())}),m.useEffect(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{var O;(O=window.MotionHandoffMarkAsComplete)===null||O===void 0||O.call(window,b)}),y.current=!1))}),h}function iye(e,t,n,i){const{layoutId:r,layout:s,drag:a,dragConstraints:o,layoutScroll:c,layoutRoot:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:DZ(e.parent)),e.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:!!a||o&&Ym(o),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:i,layoutScroll:c,layoutRoot:u})}function DZ(e){if(e)return e.options.allowProjection!==!1?e.projection:DZ(e.parent)}function rye({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:r}){var s,a;e&&qOe(e);function o(u,d){let f;const h={...m.useContext(Gy),...u,layoutId:sye(u)},{isStatic:p}=h,g=KOe(u),b=i(u,p);if(!p&&nD){aye();const y=oye(h);f=y.MeasureLayout,g.visualElement=nye(r,b,h,t,y.ProjectionNode)}return l.jsxs(u_.Provider,{value:g,children:[f&&g.visualElement?l.jsx(f,{visualElement:g.visualElement,...h}):null,n(r,u,eye(b,g.visualElement,d),b,p,g.visualElement)]})}o.displayName=`motion.${typeof r=="string"?r:`create(${(a=(s=r.displayName)!==null&&s!==void 0?s:r.name)!==null&&a!==void 0?a:""})`}`;const c=m.forwardRef(o);return c[JOe]=r,c}function sye({layoutId:e}){const t=m.useContext(tD).id;return t&&e!==void 0?t+"-"+e:e}function aye(e,t){m.useContext(jZ).strict}function oye(e){const{drag:t,layout:n}=Zg;if(!t&&!n)return{};const i={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}const lye=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function oD(e){return typeof e!="string"||e.includes("-")?!1:!!(lye.indexOf(e)>-1||/[A-Z]/u.test(e))}function BB(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function lD(e,t,n,i){if(typeof t=="function"){const[r,s]=BB(i);t=t(n!==void 0?n:e.custom,r,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,s]=BB(i);t=t(n!==void 0?n:e.custom,r,s)}return t}const MI=e=>Array.isArray(e),cye=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),uye=e=>MI(e)?e[e.length-1]||0:e,Ys=e=>!!(e&&e.getVelocity);function MS(e){const t=Ys(e)?e.get():e;return cye(t)?t.toValue():t}function dye({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},i,r,s){const a={latestValues:fye(i,r,s,e),renderState:t()};return n&&(a.onMount=o=>n({props:i,current:o,...a}),a.onUpdate=o=>n(o)),a}const $Z=e=>(t,n)=>{const i=m.useContext(u_),r=m.useContext(c_),s=()=>dye(e,t,i,r);return n?s():l_(s)};function fye(e,t,n,i){const r={},s=i(e,{});for(const h in s)r[h]=MS(s[h]);let{initial:a,animate:o}=e;const c=f_(e),u=PZ(e);t&&u&&!c&&e.inherit!==!1&&(a===void 0&&(a=t.initial),o===void 0&&(o=t.animate));let d=n?n.initial===!1:!1;d=d||a===!1;const f=d?o:a;if(f&&typeof f!="boolean"&&!d_(f)){const h=Array.isArray(f)?f:[f];for(let p=0;pt=>typeof t=="string"&&t.startsWith(e),BZ=QZ("--"),hye=QZ("var(--"),cD=e=>hye(e)?pye.test(e.split("/*")[0].trim()):!1,pye=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,UZ=(e,t)=>t&&typeof e=="number"?t.transform(e):e,ed=(e,t,n)=>n>t?t:ntypeof e=="number",parse:parseFloat,transform:e=>e},Zy={...B0,transform:e=>ed(0,1,e)},Jv={...B0,default:1},b1=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$d=b1("deg"),Lc=b1("%"),Gt=b1("px"),mye=b1("vh"),gye=b1("vw"),UB={...Lc,parse:e=>Lc.parse(e)/100,transform:e=>Lc.transform(e*100)},bye={borderWidth:Gt,borderTopWidth:Gt,borderRightWidth:Gt,borderBottomWidth:Gt,borderLeftWidth:Gt,borderRadius:Gt,radius:Gt,borderTopLeftRadius:Gt,borderTopRightRadius:Gt,borderBottomRightRadius:Gt,borderBottomLeftRadius:Gt,width:Gt,maxWidth:Gt,height:Gt,maxHeight:Gt,top:Gt,right:Gt,bottom:Gt,left:Gt,padding:Gt,paddingTop:Gt,paddingRight:Gt,paddingBottom:Gt,paddingLeft:Gt,margin:Gt,marginTop:Gt,marginRight:Gt,marginBottom:Gt,marginLeft:Gt,backgroundPositionX:Gt,backgroundPositionY:Gt},Oye={rotate:$d,rotateX:$d,rotateY:$d,rotateZ:$d,scale:Jv,scaleX:Jv,scaleY:Jv,scaleZ:Jv,skew:$d,skewX:$d,skewY:$d,distance:Gt,translateX:Gt,translateY:Gt,translateZ:Gt,x:Gt,y:Gt,z:Gt,perspective:Gt,transformPerspective:Gt,opacity:Zy,originX:UB,originY:UB,originZ:Gt},zB={...B0,transform:Math.round},uD={...bye,...Oye,zIndex:zB,size:Gt,fillOpacity:Zy,strokeOpacity:Zy,numOctaves:zB},yye={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xye=Q0.length;function vye(e,t,n){let i="",r=!0;for(let s=0;s({style:{},transform:{},transformOrigin:{},vars:{}}),zZ=()=>({...hD(),attrs:{}}),pD=e=>typeof e=="string"&&e.toLowerCase()==="svg";function FZ(e,{style:t,vars:n},i,r){Object.assign(e.style,t,r&&r.getProjectionStyles(i));for(const s in n)e.style.setProperty(s,n[s])}const VZ=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function XZ(e,t,n,i){FZ(e,t,void 0,i);for(const r in t.attrs)e.setAttribute(VZ.has(r)?r:sD(r),t.attrs[r])}const sk={};function Tye(e){Object.assign(sk,e)}function qZ(e,{layout:t,layoutId:n}){return Lp.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!sk[e]||e==="opacity")}function mD(e,t,n){var i;const{style:r}=e,s={};for(const a in r)(Ys(r[a])||t.style&&Ys(t.style[a])||qZ(a,e)||((i=n==null?void 0:n.getValue(a))===null||i===void 0?void 0:i.liveStyle)!==void 0)&&(s[a]=r[a]);return s}function HZ(e,t,n){const i=mD(e,t,n);for(const r in e)if(Ys(e[r])||Ys(t[r])){const s=Q0.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;i[s]=e[r]}return i}function _ye(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const VB=["x","y","width","height","cx","cy","r"],Aye={useVisualState:$Z({scrapeMotionValuesFromProps:HZ,createRenderState:zZ,onUpdate:({props:e,prevProps:t,current:n,renderState:i,latestValues:r})=>{if(!n)return;let s=!!e.drag;if(!s){for(const o in r)if(Lp.has(o)){s=!0;break}}if(!s)return;let a=!t;if(t)for(let o=0;o{_ye(n,i),Zi.render(()=>{fD(i,r,pD(n.tagName),e.transformTemplate),XZ(n,i)})})}})},Nye={useVisualState:$Z({scrapeMotionValuesFromProps:mD,createRenderState:hD})};function YZ(e,t,n){for(const i in t)!Ys(t[i])&&!qZ(i,n)&&(e[i]=t[i])}function Cye({transformTemplate:e},t){return m.useMemo(()=>{const n=hD();return dD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jye(e,t){const n=e.style||{},i={};return YZ(i,n,e),Object.assign(i,Cye(e,t)),i}function Rye(e,t){const n={},i=jye(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}function Iye(e,t,n,i){const r=m.useMemo(()=>{const s=zZ();return fD(s,t,pD(i),e.transformTemplate),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};YZ(s,e.style,e),r.style={...s,...r.style}}return r}function Pye(e=!1){return(n,i,r,{latestValues:s},a)=>{const c=(oD(n)?Iye:Rye)(i,s,a,n),u=YOe(i,typeof n=="string",e),d=n!==m.Fragment?{...u,...c,ref:r}:{},{children:f}=i,h=m.useMemo(()=>Ys(f)?f.get():f,[f]);return m.createElement(n,{...d,children:h})}}function Mye(e,t){return function(i,{forwardMotionProps:r}={forwardMotionProps:!1}){const a={...oD(i)?Aye:Nye,preloadedFeatures:e,useRender:Pye(r),createVisualElement:t,Component:i};return rye(a)}}function GZ(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i(LS===void 0&&Dc.set(Es.isProcessing||FOe.useManualTiming?Es.timestamp:performance.now()),LS),set:e=>{LS=e,queueMicrotask(Lye)}};function bD(e,t){e.indexOf(t)===-1&&e.push(t)}function OD(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class yD{constructor(){this.subscriptions=[]}add(t){return bD(this.subscriptions,t),()=>OD(this.subscriptions,t)}notify(t,n,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,i);else for(let s=0;s!isNaN(parseFloat(e));class $ye{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,r=!0)=>{const s=Dc.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),r&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Dc.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Dye(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new yD);const i=this.events[t].add(n);return t==="change"?()=>{i(),Zi.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Dc.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>XB)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,XB);return ZZ(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ky(e,t){return new $ye(e,t)}function Qye(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ky(n))}function Bye(e,t){const n=h_(e,t);let{transitionEnd:i={},transition:r={},...s}=n||{};s={...s,...i};for(const a in s){const o=uye(s[a]);Qye(e,a,o)}}function Uye(e){return!!(Ys(e)&&e.add)}function LI(e,t){const n=e.getValue("willChange");if(Uye(n))return n.add(t)}function KZ(e){return e.props[MZ]}function xD(e){let t;return()=>(t===void 0&&(t=e()),t)}const zye=xD(()=>window.ScrollTimeline!==void 0);class Fye{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let i=0;i{if(zye()&&r.attachTimeline)return r.attachTimeline(t);if(typeof n=="function")return n(r)});return()=>{i.forEach((r,s)=>{r&&r(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;nn[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Vye extends Fye{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}const Bu=e=>e*1e3,Uu=e=>e/1e3;function vD(e){return typeof e=="function"}function qB(e,t){e.timeline=t,e.onfinish=null}const wD=e=>Array.isArray(e)&&typeof e[0]=="number",Xye={linearEasing:void 0};function qye(e,t){const n=xD(e);return()=>{var i;return(i=Xye[t])!==null&&i!==void 0?i:n()}}const ak=qye(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Kg=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i},JZ=(e,t,n=10)=>{let i="";const r=Math.max(Math.round(t/n),2);for(let s=0;s`cubic-bezier(${e}, ${t}, ${n}, ${i})`,DI={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:SO([0,.65,.55,1]),circOut:SO([.55,0,1,.45]),backIn:SO([.31,.01,.66,-.59]),backOut:SO([.33,1.53,.69,.99])};function tK(e,t){if(e)return typeof e=="function"&&ak()?JZ(e,t):wD(e)?SO(e):Array.isArray(e)?e.map(n=>tK(n,t)||DI.easeOut):DI[e]}const nK=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Hye=1e-7,Yye=12;function Gye(e,t,n,i,r){let s,a,o=0;do a=t+(n-t)/2,s=nK(a,i,r)-e,s>0?n=a:t=a;while(Math.abs(s)>Hye&&++oGye(s,0,1,e,n);return s=>s===0||s===1?s:nK(r(s),t,i)}const iK=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,rK=e=>t=>1-e(1-t),sK=O1(.33,1.53,.69,.99),SD=rK(sK),aK=iK(SD),oK=e=>(e*=2)<1?.5*SD(e):.5*(2-Math.pow(2,-10*(e-1))),ED=e=>1-Math.sin(Math.acos(e)),lK=rK(ED),cK=iK(ED),uK=e=>/^0[^.\s]+$/u.test(e);function Wye(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||uK(e):!0}const ny=e=>Math.round(e*1e5)/1e5,kD=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Zye(e){return e==null}const Kye=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,TD=(e,t)=>n=>!!(typeof n=="string"&&Kye.test(n)&&n.startsWith(e)||t&&!Zye(n)&&Object.prototype.hasOwnProperty.call(n,t)),dK=(e,t,n)=>i=>{if(typeof i!="string")return i;const[r,s,a,o]=i.match(kD);return{[e]:parseFloat(r),[t]:parseFloat(s),[n]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},Jye=e=>ed(0,255,e),k2={...B0,transform:e=>Math.round(Jye(e))},Qh={test:TD("rgb","red"),parse:dK("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+k2.transform(e)+", "+k2.transform(t)+", "+k2.transform(n)+", "+ny(Zy.transform(i))+")"};function exe(e){let t="",n="",i="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,i+=i,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const $I={test:TD("#"),parse:exe,transform:Qh.transform},Gm={test:TD("hsl","hue"),parse:dK("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Lc.transform(ny(t))+", "+Lc.transform(ny(n))+", "+ny(Zy.transform(i))+")"},Vs={test:e=>Qh.test(e)||$I.test(e)||Gm.test(e),parse:e=>Qh.test(e)?Qh.parse(e):Gm.test(e)?Gm.parse(e):$I.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Qh.transform(e):Gm.transform(e)},txe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nxe(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(kD))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(txe))===null||n===void 0?void 0:n.length)||0)>0}const fK="number",hK="color",ixe="var",rxe="var(",HB="${}",sxe=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Jy(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},r=[];let s=0;const o=t.replace(sxe,c=>(Vs.test(c)?(i.color.push(s),r.push(hK),n.push(Vs.parse(c))):c.startsWith(rxe)?(i.var.push(s),r.push(ixe),n.push(c)):(i.number.push(s),r.push(fK),n.push(parseFloat(c))),++s,HB)).split(HB);return{values:n,split:o,indexes:i,types:r}}function pK(e){return Jy(e).values}function mK(e){const{split:t,types:n}=Jy(e),i=t.length;return r=>{let s="";for(let a=0;atypeof e=="number"?0:e;function oxe(e){const t=pK(e);return mK(e)(t.map(axe))}const Rf={test:nxe,parse:pK,createTransformer:mK,getAnimatableNone:oxe},lxe=new Set(["brightness","contrast","saturate","opacity"]);function cxe(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(kD)||[];if(!i)return e;const r=n.replace(i,"");let s=lxe.has(t)?1:0;return i!==n&&(s*=100),t+"("+s+r+")"}const uxe=/\b([a-z-]*)\(.*?\)/gu,QI={...Rf,getAnimatableNone:e=>{const t=e.match(uxe);return t?t.map(cxe).join(" "):e}},dxe={...uD,color:Vs,backgroundColor:Vs,outlineColor:Vs,fill:Vs,stroke:Vs,borderColor:Vs,borderTopColor:Vs,borderRightColor:Vs,borderBottomColor:Vs,borderLeftColor:Vs,filter:QI,WebkitFilter:QI},_D=e=>dxe[e];function gK(e,t){let n=_D(e);return n!==QI&&(n=Rf),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const fxe=new Set(["auto","none","0"]);function hxe(e,t,n){let i=0,r;for(;ie===B0||e===Gt,GB=(e,t)=>parseFloat(e.split(", ")[t]),WB=(e,t)=>(n,{transform:i})=>{if(i==="none"||!i)return 0;const r=i.match(/^matrix3d\((.+)\)$/u);if(r)return GB(r[1],t);{const s=i.match(/^matrix\((.+)\)$/u);return s?GB(s[1],e):0}},pxe=new Set(["x","y","z"]),mxe=Q0.filter(e=>!pxe.has(e));function gxe(e){const t=[];return mxe.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Jg={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:WB(4,13),y:WB(5,14)};Jg.translateX=Jg.x;Jg.translateY=Jg.y;const ep=new Set;let BI=!1,UI=!1;function bK(){if(UI){const e=Array.from(ep).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const r=gxe(i);r.length&&(n.set(i,r),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const r=n.get(i);r&&r.forEach(([s,a])=>{var o;(o=i.getValue(s))===null||o===void 0||o.set(a)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}UI=!1,BI=!1,ep.forEach(e=>e.complete()),ep.clear()}function OK(){ep.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(UI=!0)})}function bxe(){OK(),bK()}class AD{constructor(t,n,i,r,s,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=r,this.element=s,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ep.add(this),BI||(BI=!0,Zi.read(OK),Zi.resolveKeyframes(bK))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:r}=this;for(let s=0;s/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Oxe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function yxe(e){const t=Oxe.exec(e);if(!t)return[,];const[,n,i,r]=t;return[`--${n??i}`,r]}function xK(e,t,n=1){const[i,r]=yxe(e);if(!i)return;const s=window.getComputedStyle(t).getPropertyValue(i);if(s){const a=s.trim();return yK(a)?parseFloat(a):a}return cD(r)?xK(r,t,n+1):r}const vK=e=>t=>t.test(e),xxe={test:e=>e==="auto",parse:e=>e},wK=[B0,Gt,Lc,$d,gye,mye,xxe],ZB=e=>wK.find(vK(e));class SK extends AD{constructor(t,n,i,r,s){super(t,n,i,r,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c{n.getValue(c).set(u)}),this.resolveNoneKeyframes()}}const KB=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Rf.test(e)||e==="0")&&!e.startsWith("url("));function vxe(e){const t=e[0];if(e.length===1)return!0;for(let n=0;ne!==null;function p_(e,{repeat:t,repeatType:n="loop"},i){const r=e.filter(Sxe),s=t&&n!=="loop"&&t%2===1?0:r.length-1;return!s||i===void 0?r[s]:i}const Exe=40;class EK{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:r=0,repeatDelay:s=0,repeatType:a="loop",...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Dc.now(),this.options={autoplay:t,delay:n,type:i,repeat:r,repeatDelay:s,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>Exe?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&bxe(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Dc.now(),this.hasAttemptedResolve=!0;const{name:i,type:r,velocity:s,delay:a,onComplete:o,onUpdate:c,isGenerator:u}=this.options;if(!u&&!wxe(t,i,r,s))if(a)this.options.duration=0;else{c&&c(p_(t,this.options,n)),o&&o(),this.resolveFinishedPromise();return}const d=this.initPlayback(t,n);d!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...d},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const zI=2e4;function kK(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t=zI?1/0:t}const pr=(e,t,n)=>e+(t-e)*n;function T2(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function kxe({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let r=0,s=0,a=0;if(!t)r=s=a=n;else{const o=n<.5?n*(1+t):n+t-n*t,c=2*n-o;r=T2(c,o,e+1/3),s=T2(c,o,e),a=T2(c,o,e-1/3)}return{red:Math.round(r*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:i}}function ok(e,t){return n=>n>0?t:e}const _2=(e,t,n)=>{const i=e*e,r=n*(t*t-i)+i;return r<0?0:Math.sqrt(r)},Txe=[$I,Qh,Gm],_xe=e=>Txe.find(t=>t.test(e));function JB(e){const t=_xe(e);if(!t)return!1;let n=t.parse(e);return t===Gm&&(n=kxe(n)),n}const e8=(e,t)=>{const n=JB(e),i=JB(t);if(!n||!i)return ok(e,t);const r={...n};return s=>(r.red=_2(n.red,i.red,s),r.green=_2(n.green,i.green,s),r.blue=_2(n.blue,i.blue,s),r.alpha=pr(n.alpha,i.alpha,s),Qh.transform(r))},Axe=(e,t)=>n=>t(e(n)),y1=(...e)=>e.reduce(Axe),FI=new Set(["none","hidden"]);function Nxe(e,t){return FI.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Cxe(e,t){return n=>pr(e,t,n)}function ND(e){return typeof e=="number"?Cxe:typeof e=="string"?cD(e)?ok:Vs.test(e)?e8:Ixe:Array.isArray(e)?TK:typeof e=="object"?Vs.test(e)?e8:jxe:ok}function TK(e,t){const n=[...e],i=n.length,r=e.map((s,a)=>ND(s)(s,t[a]));return s=>{for(let a=0;a{for(const s in i)n[s]=i[s](r);return n}}function Rxe(e,t){var n;const i=[],r={color:0,var:0,number:0};for(let s=0;s{const n=Rf.createTransformer(t),i=Jy(e),r=Jy(t);return i.indexes.var.length===r.indexes.var.length&&i.indexes.color.length===r.indexes.color.length&&i.indexes.number.length>=r.indexes.number.length?FI.has(e)&&!r.values.length||FI.has(t)&&!i.values.length?Nxe(e,t):y1(TK(Rxe(i,r),r.values),n):ok(e,t)};function _K(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?pr(e,t,n):ND(e)(e,t)}const Pxe=5;function AK(e,t,n){const i=Math.max(t-Pxe,0);return ZZ(n-e(i),t-i)}const xr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},A2=.001;function Mxe({duration:e=xr.duration,bounce:t=xr.bounce,velocity:n=xr.velocity,mass:i=xr.mass}){let r,s,a=1-t;a=ed(xr.minDamping,xr.maxDamping,a),e=ed(xr.minDuration,xr.maxDuration,Uu(e)),a<1?(r=u=>{const d=u*a,f=d*e,h=d-n,p=VI(u,a),g=Math.exp(-f);return A2-h/p*g},s=u=>{const f=u*a*e,h=f*n+n,p=Math.pow(a,2)*Math.pow(u,2)*e,g=Math.exp(-f),b=VI(Math.pow(u,2),a);return(-r(u)+A2>0?-1:1)*((h-p)*g)/b}):(r=u=>{const d=Math.exp(-u*e),f=(u-n)*e+1;return-A2+d*f},s=u=>{const d=Math.exp(-u*e),f=(n-u)*(e*e);return d*f});const o=5/e,c=Dxe(r,s,o);if(e=Bu(e),isNaN(c))return{stiffness:xr.stiffness,damping:xr.damping,duration:e};{const u=Math.pow(c,2)*i;return{stiffness:u,damping:a*2*Math.sqrt(i*u),duration:e}}}const Lxe=12;function Dxe(e,t,n){let i=n;for(let r=1;re[n]!==void 0)}function Bxe(e){let t={velocity:xr.velocity,stiffness:xr.stiffness,damping:xr.damping,mass:xr.mass,isResolvedFromDuration:!1,...e};if(!t8(e,Qxe)&&t8(e,$xe))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),r=i*i,s=2*ed(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:xr.mass,stiffness:r,damping:s}}else{const n=Mxe(e);t={...t,...n,mass:xr.mass},t.isResolvedFromDuration=!0}return t}function NK(e=xr.visualDuration,t=xr.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:r}=n;const s=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],o={done:!1,value:s},{stiffness:c,damping:u,mass:d,duration:f,velocity:h,isResolvedFromDuration:p}=Bxe({...n,velocity:-Uu(n.velocity||0)}),g=h||0,b=u/(2*Math.sqrt(c*d)),y=a-s,O=Uu(Math.sqrt(c/d)),v=Math.abs(y)<5;i||(i=v?xr.restSpeed.granular:xr.restSpeed.default),r||(r=v?xr.restDelta.granular:xr.restDelta.default);let x;if(b<1){const E=VI(O,b);x=S=>{const k=Math.exp(-b*O*S);return a-k*((g+b*O*y)/E*Math.sin(E*S)+y*Math.cos(E*S))}}else if(b===1)x=E=>a-Math.exp(-O*E)*(y+(g+O*y)*E);else{const E=O*Math.sqrt(b*b-1);x=S=>{const k=Math.exp(-b*O*S),T=Math.min(E*S,300);return a-k*((g+b*O*y)*Math.sinh(T)+E*y*Math.cosh(T))/E}}const w={calculatedDuration:p&&f||null,next:E=>{const S=x(E);if(p)o.done=E>=f;else{let k=0;b<1&&(k=E===0?Bu(g):AK(x,E,S));const T=Math.abs(k)<=i,A=Math.abs(a-S)<=r;o.done=T&&A}return o.value=o.done?a:S,o},toString:()=>{const E=Math.min(kK(w),zI),S=JZ(k=>w.next(E*k).value,E,30);return E+"ms "+S}};return w}function n8({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:s=500,modifyTarget:a,min:o,max:c,restDelta:u=.5,restSpeed:d}){const f=e[0],h={done:!1,value:f},p=T=>o!==void 0&&Tc,g=T=>o===void 0?c:c===void 0||Math.abs(o-T)-b*Math.exp(-T/i),x=T=>O+v(T),w=T=>{const A=v(T),N=x(T);h.done=Math.abs(A)<=u,h.value=h.done?O:N};let E,S;const k=T=>{p(h.value)&&(E=T,S=NK({keyframes:[h.value,g(h.value)],velocity:AK(x,T,h.value),damping:r,stiffness:s,restDelta:u,restSpeed:d}))};return k(0),{calculatedDuration:null,next:T=>{let A=!1;return!S&&E===void 0&&(A=!0,w(T),k(T)),E!==void 0&&T>=E?S.next(T-E):(!A&&w(T),h)}}}const Uxe=O1(.42,0,1,1),zxe=O1(0,0,.58,1),CK=O1(.42,0,.58,1),Fxe=e=>Array.isArray(e)&&typeof e[0]!="number",Vxe={linear:xo,easeIn:Uxe,easeInOut:CK,easeOut:zxe,circIn:ED,circInOut:cK,circOut:lK,backIn:SD,backInOut:aK,backOut:sK,anticipate:oK},i8=e=>{if(wD(e)){NZ(e.length===4);const[t,n,i,r]=e;return O1(t,n,i,r)}else if(typeof e=="string")return Vxe[e];return e};function Xxe(e,t,n){const i=[],r=n||_K,s=e.length-1;for(let a=0;at[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=Xxe(t,i,r),c=o.length,u=d=>{if(a&&d1)for(;fu(ed(e[0],e[s-1],d)):u}function Hxe(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const r=Kg(0,t,i);e.push(pr(n,1,r))}}function Yxe(e){const t=[0];return Hxe(t,e.length-1),t}function Gxe(e,t){return e.map(n=>n*t)}function Wxe(e,t){return e.map(()=>t||CK).splice(0,e.length-1)}function lk({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const r=Fxe(i)?i.map(i8):i8(i),s={done:!1,value:t[0]},a=Gxe(n&&n.length===t.length?n:Yxe(t),e),o=qxe(a,t,{ease:Array.isArray(r)?r:Wxe(t,r)});return{calculatedDuration:e,next:c=>(s.value=o(c),s.done=c>=e,s)}}const Zxe=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Zi.update(t,!0),stop:()=>jf(t),now:()=>Es.isProcessing?Es.timestamp:Dc.now()}},Kxe={decay:n8,inertia:n8,tween:lk,keyframes:lk,spring:NK},Jxe=e=>e/100;class CD extends EK{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:i,element:r,keyframes:s}=this.options,a=(r==null?void 0:r.KeyframeResolver)||AD,o=(c,u)=>this.onKeyframesResolved(c,u);this.resolver=new a(s,o,n,i,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:s,velocity:a=0}=this.options,o=vD(n)?n:Kxe[n]||lk;let c,u;o!==lk&&typeof t[0]!="number"&&(c=y1(Jxe,_K(t[0],t[1])),t=[0,100]);const d=o({...this.options,keyframes:t});s==="mirror"&&(u=o({...this.options,keyframes:[...t].reverse(),velocity:-a})),d.calculatedDuration===null&&(d.calculatedDuration=kK(d));const{calculatedDuration:f}=d,h=f+r,p=h*(i+1)-r;return{generator:d,mirroredGenerator:u,mapPercentToKeyframes:c,calculatedDuration:f,resolvedDuration:h,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:i}=this;if(!i){const{keyframes:T}=this.options;return{done:!0,value:T[T.length-1]}}const{finalKeyframe:r,generator:s,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:c,calculatedDuration:u,totalDuration:d,resolvedDuration:f}=i;if(this.startTime===null)return s.next(0);const{delay:h,repeat:p,repeatType:g,repeatDelay:b,onUpdate:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-d/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const O=this.currentTime-h*(this.speed>=0?1:-1),v=this.speed>=0?O<0:O>d;this.currentTime=Math.max(O,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=d);let x=this.currentTime,w=s;if(p){const T=Math.min(this.currentTime,d)/f;let A=Math.floor(T),N=T%1;!N&&T>=1&&(N=1),N===1&&A--,A=Math.min(A,p+1),!!(A%2)&&(g==="reverse"?(N=1-N,b&&(N-=b/f)):g==="mirror"&&(w=a)),x=ed(0,1,N)*f}const E=v?{done:!1,value:c[0]}:w.next(x);o&&(E.value=o(E.value));let{done:S}=E;!v&&u!==null&&(S=this.speed>=0?this.currentTime>=d:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&S);return k&&r!==void 0&&(E.value=p_(c,this.options,r)),y&&y(E.value),k&&this.finish(),E}get duration(){const{resolved:t}=this;return t?Uu(t.calculatedDuration):0}get time(){return Uu(this.currentTime)}set time(t){t=Bu(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Uu(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=Zxe,onPlay:n,startTime:i}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),n&&n();const r=this.driver.now();this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=r):this.startTime=i??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const e1e=new Set(["opacity","clipPath","filter","transform"]);function t1e(e,t,n,{delay:i=0,duration:r=300,repeat:s=0,repeatType:a="loop",ease:o="easeInOut",times:c}={}){const u={[t]:n};c&&(u.offset=c);const d=tK(o,r);return Array.isArray(d)&&(u.easing=d),e.animate(u,{delay:i,duration:r,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"})}const n1e=xD(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),ck=10,i1e=2e4;function r1e(e){return vD(e.type)||e.type==="spring"||!eK(e.ease)}function s1e(e,t){const n=new CD({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let i={done:!1,value:e[0]};const r=[];let s=0;for(;!i.done&&sthis.onKeyframesResolved(a,o),n,i,r),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:i=300,times:r,ease:s,type:a,motionValue:o,name:c,startTime:u}=this.options;if(!o.owner||!o.owner.current)return!1;if(typeof s=="string"&&ak()&&a1e(s)&&(s=jK[s]),r1e(this.options)){const{onComplete:f,onUpdate:h,motionValue:p,element:g,...b}=this.options,y=s1e(t,b);t=y.keyframes,t.length===1&&(t[1]=t[0]),i=y.duration,r=y.times,s=y.ease,a="keyframes"}const d=t1e(o.owner.current,c,t,{...this.options,duration:i,times:r,ease:s});return d.startTime=u??this.calcStartTime(),this.pendingTimeline?(qB(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{const{onComplete:f}=this.options;o.set(p_(t,this.options,n)),f&&f(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:i,times:r,type:a,ease:s,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return Uu(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return Uu(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.currentTime=Bu(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return xo;const{animation:i}=n;qB(i,t)}return xo}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:i,duration:r,type:s,ease:a,times:o}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:u,onUpdate:d,onComplete:f,element:h,...p}=this.options,g=new CD({...p,keyframes:i,duration:r,type:s,ease:a,times:o,isGenerator:!0}),b=Bu(this.time);u.setWithVelocity(g.sample(b-ck).value,g.sample(b).value,ck)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:i,repeatDelay:r,repeatType:s,damping:a,type:o}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=n.owner.getProps();return n1e()&&i&&e1e.has(i)&&!c&&!u&&!r&&s!=="mirror"&&a!==0&&o!=="inertia"}}const o1e={type:"spring",stiffness:500,damping:25,restSpeed:10},l1e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),c1e={type:"keyframes",duration:.8},u1e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},d1e=(e,{keyframes:t})=>t.length>2?c1e:Lp.has(e)?e.startsWith("scale")?l1e(t[1]):o1e:u1e;function f1e({when:e,delay:t,delayChildren:n,staggerChildren:i,staggerDirection:r,repeat:s,repeatType:a,repeatDelay:o,from:c,elapsed:u,...d}){return!!Object.keys(d).length}const jD=(e,t,n,i={},r,s)=>a=>{const o=gD(i,e)||{},c=o.delay||i.delay||0;let{elapsed:u=0}=i;u=u-Bu(c);let d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-u,onUpdate:h=>{t.set(h),o.onUpdate&&o.onUpdate(h)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:s?void 0:r};f1e(o)||(d={...d,...d1e(e,d)}),d.duration&&(d.duration=Bu(d.duration)),d.repeatDelay&&(d.repeatDelay=Bu(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let f=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(f=!0)),f&&!s&&t.get()!==void 0){const h=p_(d.keyframes,o);if(h!==void 0)return Zi.update(()=>{d.onUpdate(h),d.onComplete()}),new Vye([])}return!s&&r8.supports(d)?new r8(d):new CD(d)};function h1e({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function RK(e,t,{delay:n=0,transitionOverride:i,type:r}={}){var s;let{transition:a=e.getDefaultTransition(),transitionEnd:o,...c}=t;i&&(a=i);const u=[],d=r&&e.animationState&&e.animationState.getState()[r];for(const f in c){const h=e.getValue(f,(s=e.latestValues[f])!==null&&s!==void 0?s:null),p=c[f];if(p===void 0||d&&h1e(d,f))continue;const g={delay:n,...gD(a||{},f)};let b=!1;if(window.MotionHandoffAnimation){const O=KZ(e);if(O){const v=window.MotionHandoffAnimation(O,f,Zi);v!==null&&(g.startTime=v,b=!0)}}LI(e,f),h.start(jD(f,h,p,e.shouldReduceMotion&&WZ.has(f)?{type:!1}:g,e,b));const y=h.animation;y&&u.push(y)}return o&&Promise.all(u).then(()=>{Zi.update(()=>{o&&Bye(e,o)})}),u}function XI(e,t,n={}){var i;const r=h_(e,t,n.type==="exit"?(i=e.presenceContext)===null||i===void 0?void 0:i.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(s=n.transitionOverride);const a=r?()=>Promise.all(RK(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:f,staggerDirection:h}=s;return p1e(e,t,d+u,f,h,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[u,d]=c==="beforeChildren"?[a,o]:[o,a];return u().then(()=>d())}else return Promise.all([a(),o(n.delay)])}function p1e(e,t,n=0,i=0,r=1,s){const a=[],o=(e.variantChildren.size-1)*i,c=r===1?(u=0)=>u*i:(u=0)=>o-u*i;return Array.from(e.variantChildren).sort(m1e).forEach((u,d)=>{u.notify("AnimationStart",t),a.push(XI(u,t,{...s,delay:n+c(d)}).then(()=>u.notify("AnimationComplete",t)))}),Promise.all(a)}function m1e(e,t){return e.sortNodePosition(t)}function g1e(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const r=t.map(s=>XI(e,s,n));i=Promise.all(r)}else if(typeof t=="string")i=XI(e,t,n);else{const r=typeof t=="function"?h_(e,t,n.custom):t;i=Promise.all(RK(e,r,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const b1e=rD.length;function IK(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?IK(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:i})=>g1e(e,n,i)))}function v1e(e){let t=x1e(e),n=s8(),i=!0;const r=c=>(u,d)=>{var f;const h=h_(e,d,c==="exit"?(f=e.presenceContext)===null||f===void 0?void 0:f.custom:void 0);if(h){const{transition:p,transitionEnd:g,...b}=h;u={...u,...b,...g}}return u};function s(c){t=c(e)}function a(c){const{props:u}=e,d=IK(e.parent)||{},f=[],h=new Set;let p={},g=1/0;for(let y=0;yg&&w,A=!1;const N=Array.isArray(x)?x:[x];let C=N.reduce(r(O),{});E===!1&&(C={});const{prevResolvedValues:M={}}=v,L={...M,...C},P=$=>{T=!0,h.has($)&&(A=!0,h.delete($)),v.needsAnimating[$]=!0;const U=e.getValue($);U&&(U.liveStyle=!1)};for(const $ in L){const U=C[$],B=M[$];if(p.hasOwnProperty($))continue;let I=!1;MI(U)&&MI(B)?I=!GZ(U,B):I=U!==B,I?U!=null?P($):h.add($):U!==void 0&&h.has($)?P($):v.protectedKeys[$]=!0}v.prevProp=x,v.prevResolvedValues=C,v.isActive&&(p={...p,...C}),i&&e.blockInitialAnimation&&(T=!1),T&&(!(S&&k)||A)&&f.push(...N.map($=>({animation:$,options:{type:O}})))}if(h.size){const y={};h.forEach(O=>{const v=e.getBaseTarget(O),x=e.getValue(O);x&&(x.liveStyle=!0),y[O]=v??null}),f.push({animation:y})}let b=!!f.length;return i&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(b=!1),i=!1,b?t(f):Promise.resolve()}function o(c,u){var d;if(n[c].isActive===u)return Promise.resolve();(d=e.variantChildren)===null||d===void 0||d.forEach(h=>{var p;return(p=h.animationState)===null||p===void 0?void 0:p.setActive(c,u)}),n[c].isActive=u;const f=a(c);for(const h in n)n[h].protectedKeys={};return f}return{animateChanges:a,setActive:o,setAnimateFunction:s,getState:()=>n,reset:()=>{n=s8(),i=!0}}}function w1e(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!GZ(t,e):!1}function dh(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function s8(){return{animate:dh(!0),whileInView:dh(),whileHover:dh(),whileTap:dh(),whileDrag:dh(),whileFocus:dh(),exit:dh()}}class Kf{constructor(t){this.isMounted=!1,this.node=t}update(){}}class S1e extends Kf{constructor(t){super(t),t.animationState||(t.animationState=v1e(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();d_(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let E1e=0;class k1e extends Kf{constructor(){super(...arguments),this.id=E1e++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const T1e={animation:{Feature:S1e},exit:{Feature:k1e}},wl={x:!1,y:!1};function PK(){return wl.x||wl.y}function _1e(e){return e==="x"||e==="y"?wl[e]?null:(wl[e]=!0,()=>{wl[e]=!1}):wl.x||wl.y?null:(wl.x=wl.y=!0,()=>{wl.x=wl.y=!1})}const RD=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1;function ex(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function x1(e){return{point:{x:e.pageX,y:e.pageY}}}const A1e=e=>t=>RD(t)&&e(t,x1(t));function iy(e,t,n,i){return ex(e,t,A1e(n),i)}const a8=(e,t)=>Math.abs(e-t);function N1e(e,t){const n=a8(e.x,t.x),i=a8(e.y,t.y);return Math.sqrt(n**2+i**2)}class MK{constructor(t,n,{transformPagePoint:i,contextWindow:r,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=C2(this.lastMoveEventInfo,this.history),h=this.startEvent!==null,p=N1e(f.offset,{x:0,y:0})>=3;if(!h&&!p)return;const{point:g}=f,{timestamp:b}=Es;this.history.push({...g,timestamp:b});const{onStart:y,onMove:O}=this.handlers;h||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),O&&O(this.lastMoveEvent,f)},this.handlePointerMove=(f,h)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=N2(h,this.transformPagePoint),Zi.update(this.updatePoint,!0)},this.handlePointerUp=(f,h)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=C2(f.type==="pointercancel"?this.lastMoveEventInfo:N2(h,this.transformPagePoint),this.history);this.startEvent&&p&&p(f,y),g&&g(f,y)},!RD(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=i,this.contextWindow=r||window;const a=x1(t),o=N2(a,this.transformPagePoint),{point:c}=o,{timestamp:u}=Es;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(t,C2(o,this.history)),this.removeListeners=y1(iy(this.contextWindow,"pointermove",this.handlePointerMove),iy(this.contextWindow,"pointerup",this.handlePointerUp),iy(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),jf(this.updatePoint)}}function N2(e,t){return t?{point:t(e.point)}:e}function o8(e,t){return{x:e.x-t.x,y:e.y-t.y}}function C2({point:e},t){return{point:e,delta:o8(e,LK(t)),offset:o8(e,C1e(t)),velocity:j1e(t,.1)}}function C1e(e){return e[0]}function LK(e){return e[e.length-1]}function j1e(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const r=LK(e);for(;n>=0&&(i=e[n],!(r.timestamp-i.timestamp>Bu(t)));)n--;if(!i)return{x:0,y:0};const s=Uu(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const a={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}const DK=1e-4,R1e=1-DK,I1e=1+DK,$K=.01,P1e=0-$K,M1e=0+$K;function ko(e){return e.max-e.min}function L1e(e,t,n){return Math.abs(e-t)<=n}function l8(e,t,n,i=.5){e.origin=i,e.originPoint=pr(t.min,t.max,e.origin),e.scale=ko(n)/ko(t),e.translate=pr(n.min,n.max,e.origin)-e.originPoint,(e.scale>=R1e&&e.scale<=I1e||isNaN(e.scale))&&(e.scale=1),(e.translate>=P1e&&e.translate<=M1e||isNaN(e.translate))&&(e.translate=0)}function ry(e,t,n,i){l8(e.x,t.x,n.x,i?i.originX:void 0),l8(e.y,t.y,n.y,i?i.originY:void 0)}function c8(e,t,n){e.min=n.min+t.min,e.max=e.min+ko(t)}function D1e(e,t,n){c8(e.x,t.x,n.x),c8(e.y,t.y,n.y)}function u8(e,t,n){e.min=t.min-n.min,e.max=e.min+ko(t)}function sy(e,t,n){u8(e.x,t.x,n.x),u8(e.y,t.y,n.y)}function $1e(e,{min:t,max:n},i){return t!==void 0&&en&&(e=i?pr(n,e,i.max):Math.min(e,n)),e}function d8(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Q1e(e,{top:t,left:n,bottom:i,right:r}){return{x:d8(e.x,n,r),y:d8(e.y,t,i)}}function f8(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.mini?n=Kg(t.min,t.max-i,e.min):i>r&&(n=Kg(e.min,e.max-r,t.min)),ed(0,1,n)}function z1e(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const qI=.35;function F1e(e=qI){return e===!1?e=0:e===!0&&(e=qI),{x:h8(e,"left","right"),y:h8(e,"top","bottom")}}function h8(e,t,n){return{min:p8(e,t),max:p8(e,n)}}function p8(e,t){return typeof e=="number"?e:e[t]||0}const m8=()=>({translate:0,scale:1,origin:0,originPoint:0}),Wm=()=>({x:m8(),y:m8()}),g8=()=>({min:0,max:0}),Ar=()=>({x:g8(),y:g8()});function Mo(e){return[e("x"),e("y")]}function QK({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function V1e({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function X1e(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function j2(e){return e===void 0||e===1}function HI({scale:e,scaleX:t,scaleY:n}){return!j2(e)||!j2(t)||!j2(n)}function Eh(e){return HI(e)||BK(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function BK(e){return b8(e.x)||b8(e.y)}function b8(e){return e&&e!=="0%"}function uk(e,t,n){const i=e-n,r=t*i;return n+r}function O8(e,t,n,i,r){return r!==void 0&&(e=uk(e,r,i)),uk(e,n,i)+t}function YI(e,t=0,n=1,i,r){e.min=O8(e.min,t,n,i,r),e.max=O8(e.max,t,n,i,r)}function UK(e,{x:t,y:n}){YI(e.x,t.translate,t.scale,t.originPoint),YI(e.y,n.translate,n.scale,n.originPoint)}const y8=.999999999999,x8=1.0000000000001;function q1e(e,t,n,i=!1){const r=n.length;if(!r)return;t.x=t.y=1;let s,a;for(let o=0;oy8&&(t.x=1),t.yy8&&(t.y=1)}function Zm(e,t){e.min=e.min+t,e.max=e.max+t}function v8(e,t,n,i,r=.5){const s=pr(e.min,e.max,r);YI(e,t,n,s,i)}function Km(e,t){v8(e.x,t.x,t.scaleX,t.scale,t.originX),v8(e.y,t.y,t.scaleY,t.scale,t.originY)}function zK(e,t){return QK(X1e(e.getBoundingClientRect(),t))}function H1e(e,t,n){const i=zK(e,n),{scroll:r}=t;return r&&(Zm(i.x,r.offset.x),Zm(i.y,r.offset.y)),i}const FK=({current:e})=>e?e.ownerDocument.defaultView:null,Y1e=new WeakMap;class G1e{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ar(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(x1(d).point)},s=(d,f)=>{const{drag:h,dragPropagation:p,onDragStart:g}=this.getProps();if(h&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_1e(h),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Mo(y=>{let O=this.getAxisMotionValue(y).get()||0;if(Lc.test(O)){const{projection:v}=this.visualElement;if(v&&v.layout){const x=v.layout.layoutBox[y];x&&(O=ko(x)*(parseFloat(O)/100))}}this.originPoint[y]=O}),g&&Zi.postRender(()=>g(d,f)),LI(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{const{dragPropagation:h,dragDirectionLock:p,onDirectionLock:g,onDrag:b}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:y}=f;if(p&&this.currentDirection===null){this.currentDirection=W1e(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),b&&b(d,f)},o=(d,f)=>this.stop(d,f),c=()=>Mo(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)===null||f===void 0?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new MK(t,{onSessionStart:r,onStart:s,onMove:a,onSessionEnd:o,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,contextWindow:FK(this.visualElement)})}stop(t,n){const i=this.isDragging;if(this.cancel(),!i)return;const{velocity:r}=n;this.startAnimation(r);const{onDragEnd:s}=this.getProps();s&&Zi.postRender(()=>s(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,i){const{drag:r}=this.getProps();if(!i||!ew(t,r,this.currentDirection))return;const s=this.getAxisMotionValue(t);let a=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(a=$1e(a,this.constraints[t],this.elastic[t])),s.set(a)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:i}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,s=this.constraints;n&&Ym(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&r?this.constraints=Q1e(r.layoutBox,n):this.constraints=!1,this.elastic=F1e(i),s!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Mo(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=z1e(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ym(t))return!1;const i=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=H1e(i,r.root,this.visualElement.getTransformPagePoint());let a=B1e(r.layout.layoutBox,s);if(n){const o=n(V1e(a));this.hasMutatedConstraints=!!o,o&&(a=QK(o))}return a}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),c=this.constraints||{},u=Mo(d=>{if(!ew(d,n,this.currentDirection))return;let f=c&&c[d]||{};a&&(f={min:0,max:0});const h=r?200:1e6,p=r?40:1e7,g={type:"inertia",velocity:i?t[d]:0,bounceStiffness:h,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...s,...f};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return LI(this.visualElement,t),i.start(jD(t,i,0,n,this.visualElement,!1))}stopAnimation(){Mo(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Mo(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){Mo(n=>{const{drag:i}=this.getProps();if(!ew(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(n);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[n];s.set(t[n]-pr(a,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Ym(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Mo(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const c=o.get();r[a]=U1e({min:c,max:c},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Mo(a=>{if(!ew(a,t,null))return;const o=this.getAxisMotionValue(a),{min:c,max:u}=this.constraints[a];o.set(pr(c,u,r[a]))})}addListeners(){if(!this.visualElement.current)return;Y1e.set(this.visualElement,this);const t=this.visualElement.current,n=iy(t,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(c)}),i=()=>{const{dragConstraints:c}=this.getProps();Ym(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,s=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Zi.read(i);const a=ex(window,"resize",()=>this.scalePositionWithinConstraints()),o=r.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(Mo(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=c[d].translate,f.set(f.get()+c[d].translate))}),this.visualElement.render())});return()=>{a(),n(),s(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:a=qI,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:a,dragMomentum:o}}}function ew(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function W1e(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Z1e extends Kf{constructor(t){super(t),this.removeGroupControls=xo,this.removeListeners=xo,this.controls=new G1e(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||xo}unmount(){this.removeGroupControls(),this.removeListeners()}}const w8=e=>(t,n)=>{e&&Zi.postRender(()=>e(t,n))};class K1e extends Kf{constructor(){super(...arguments),this.removePointerDownListener=xo}onPointerDown(t){this.session=new MK(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:FK(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:w8(t),onStart:w8(n),onMove:i,onEnd:(s,a)=>{delete this.session,r&&Zi.postRender(()=>r(s,a))}}}mount(){this.removePointerDownListener=iy(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const DS={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function S8(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Vb={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Gt.test(e))e=parseFloat(e);else return e;const n=S8(e,t.target.x),i=S8(e,t.target.y);return`${n}% ${i}%`}},J1e={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,r=Rf.parse(e);if(r.length>5)return i;const s=Rf.createTransformer(e),a=typeof r[0]!="number"?1:0,o=n.x.scale*t.x,c=n.y.scale*t.y;r[0+a]/=o,r[1+a]/=c;const u=pr(o,c,.5);return typeof r[2+a]=="number"&&(r[2+a]/=u),typeof r[3+a]=="number"&&(r[3+a]/=u),s(r)}};class eve extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=t;Tye(tve),s&&(n.group&&n.group.add(s),i&&i.register&&r&&i.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),DS.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:r,isPresent:s}=this.props,a=i.projection;return a&&(a.isPresent=s,r||t.layoutDependency!==n||n===void 0?a.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?a.promote():a.relegate()||Zi.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),aD.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=t;r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function VK(e){const[t,n]=_Z(),i=m.useContext(tD);return l.jsx(eve,{...e,layoutGroup:i,switchLayoutGroup:m.useContext(LZ),isPresent:t,safeToRemove:n})}const tve={borderRadius:{...Vb,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Vb,borderTopRightRadius:Vb,borderBottomLeftRadius:Vb,borderBottomRightRadius:Vb,boxShadow:J1e};function nve(e,t,n){const i=Ys(e)?e:Ky(e);return i.start(jD("",i,t,n)),i.animation}function ive(e){return e instanceof SVGElement&&e.tagName!=="svg"}const rve=(e,t)=>e.depth-t.depth;class sve{constructor(){this.children=[],this.isDirty=!1}add(t){bD(this.children,t),this.isDirty=!0}remove(t){OD(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(rve),this.isDirty=!1,this.children.forEach(t)}}function ave(e,t){const n=Dc.now(),i=({timestamp:r})=>{const s=r-n;s>=t&&(jf(i),e(s-t))};return Zi.read(i,!0),()=>jf(i)}const XK=["TopLeft","TopRight","BottomLeft","BottomRight"],ove=XK.length,E8=e=>typeof e=="string"?parseFloat(e):e,k8=e=>typeof e=="number"||Gt.test(e);function lve(e,t,n,i,r,s){r?(e.opacity=pr(0,n.opacity!==void 0?n.opacity:1,cve(i)),e.opacityExit=pr(t.opacity!==void 0?t.opacity:1,0,uve(i))):s&&(e.opacity=pr(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,i));for(let a=0;ait?1:n(Kg(e,t,i))}function _8(e,t){e.min=t.min,e.max=t.max}function Po(e,t){_8(e.x,t.x),_8(e.y,t.y)}function A8(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function N8(e,t,n,i,r){return e-=t,e=uk(e,1/n,i),r!==void 0&&(e=uk(e,1/r,i)),e}function dve(e,t=0,n=1,i=.5,r,s=e,a=e){if(Lc.test(t)&&(t=parseFloat(t),t=pr(a.min,a.max,t/100)-a.min),typeof t!="number")return;let o=pr(s.min,s.max,i);e===s&&(o-=t),e.min=N8(e.min,t,n,o,r),e.max=N8(e.max,t,n,o,r)}function C8(e,t,[n,i,r],s,a){dve(e,t[n],t[i],t[r],t.scale,s,a)}const fve=["x","scaleX","originX"],hve=["y","scaleY","originY"];function j8(e,t,n,i){C8(e.x,t,fve,n?n.x:void 0,i?i.x:void 0),C8(e.y,t,hve,n?n.y:void 0,i?i.y:void 0)}function R8(e){return e.translate===0&&e.scale===1}function HK(e){return R8(e.x)&&R8(e.y)}function I8(e,t){return e.min===t.min&&e.max===t.max}function pve(e,t){return I8(e.x,t.x)&&I8(e.y,t.y)}function P8(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function YK(e,t){return P8(e.x,t.x)&&P8(e.y,t.y)}function M8(e){return ko(e.x)/ko(e.y)}function L8(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class mve{constructor(){this.members=[]}add(t){bD(this.members,t),t.scheduleRender()}remove(t){if(OD(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let i;for(let r=n;r>=0;r--){const s=this.members[r];if(s.isPresent!==!1){i=s;break}}return i?(this.promote(i),!0):!1}promote(t,n){const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.instance&&i.scheduleRender(),t.scheduleRender(),t.resumeFrom=i,n&&(t.resumeFrom.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:i}=t;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function gve(e,t,n){let i="";const r=e.x.translate/t.x,s=e.y.translate/t.y,a=(n==null?void 0:n.z)||0;if((r||s||a)&&(i=`translate3d(${r}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:f,rotateY:h,skewX:p,skewY:g}=n;u&&(i=`perspective(${u}px) ${i}`),d&&(i+=`rotate(${d}deg) `),f&&(i+=`rotateX(${f}deg) `),h&&(i+=`rotateY(${h}deg) `),p&&(i+=`skewX(${p}deg) `),g&&(i+=`skewY(${g}deg) `)}const o=e.x.scale*t.x,c=e.y.scale*t.y;return(o!==1||c!==1)&&(i+=`scale(${o}, ${c})`),i||"none"}const kh={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},EO=typeof window<"u"&&window.MotionDebug!==void 0,R2=["","X","Y","Z"],bve={visibility:"hidden"},D8=1e3;let Ove=0;function I2(e,t,n,i){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),i&&(i[e]=0))}function GK(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=KZ(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Zi,!(r||s))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&GK(i)}function WK({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(a={},o=t==null?void 0:t()){this.id=Ove++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,EO&&(kh.totalNodes=kh.resolvedTargetDeltas=kh.recalculatedProjection=0),this.nodes.forEach(vve),this.nodes.forEach(Tve),this.nodes.forEach(_ve),this.nodes.forEach(wve),EO&&window.MotionDebug.record(kh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let c=0;cthis.root.updateBlockedByResize=!1;e(a,()=>{this.root.updateBlockedByResize=!0,f&&f(),f=ave(h,250),DS.hasAnimatedSinceResize&&(DS.hasAnimatedSinceResize=!1,this.nodes.forEach(Q8))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&d&&(c||u)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:h,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||d.getDefaultTransition()||Rve,{onLayoutAnimationStart:y,onLayoutAnimationComplete:O}=d.getProps(),v=!this.targetLayout||!YK(this.targetLayout,g)||p,x=!h&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||x||h&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(f,x);const w={...gD(b,"layout"),onPlay:y,onComplete:O};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w)}else h||Q8(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,jf(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Ave),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&GK(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c{const E=w/1e3;B8(f.x,a.x,E),B8(f.y,a.y,E),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(sy(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Cve(this.relativeTarget,this.relativeTargetOrigin,h,E),x&&pve(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=Ar()),Po(x,this.relativeTarget)),b&&(this.animationValues=d,lve(d,u,this.latestValues,E,v,O)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=E},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(jf(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Zi.update(()=>{DS.hasAnimatedSinceResize=!0,this.currentAnimation=nve(0,D8,{...a,onUpdate:o=>{this.mixTargetDelta(o),a.onUpdate&&a.onUpdate(o)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(D8),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:c,layout:u,latestValues:d}=a;if(!(!o||!c||!u)){if(this!==a&&this.layout&&u&&ZK(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Ar();const f=ko(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+f;const h=ko(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+h}Po(o,c),Km(o,d),ry(this.projectionDeltaWithTransform,this.layoutCorrected,o,d)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new mve),this.sharedNodes.get(a).add(o);const u=o.options.initialPromotionConfig;o.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var a;const{layoutId:o}=this.options;return o?((a=this.getStack())===null||a===void 0?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:o}=this.options;return o?(a=this.getStack())===null||a===void 0?void 0:a.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(o=!0),!o)return;const u={};c.z&&I2("z",a,u,this.animationValues);for(let d=0;d{var o;return(o=a.currentAnimation)===null||o===void 0?void 0:o.stop()}),this.root.nodes.forEach($8),this.root.sharedNodes.clear()}}}function yve(e){e.updateLayout()}function xve(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:r}=e.layout,{animationType:s}=e.options,a=n.source!==e.layout.source;s==="size"?Mo(f=>{const h=a?n.measuredBox[f]:n.layoutBox[f],p=ko(h);h.min=i[f].min,h.max=h.min+p}):ZK(s,n.layoutBox,i)&&Mo(f=>{const h=a?n.measuredBox[f]:n.layoutBox[f],p=ko(i[f]);h.max=h.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[f].max=e.relativeTarget[f].min+p)});const o=Wm();ry(o,i,n.layoutBox);const c=Wm();a?ry(c,e.applyTransform(r,!0),n.measuredBox):ry(c,i,n.layoutBox);const u=!HK(o);let d=!1;if(!e.resumeFrom){const f=e.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:h,layout:p}=f;if(h&&p){const g=Ar();sy(g,n.layoutBox,h.layoutBox);const b=Ar();sy(b,i,p.layoutBox),YK(g,b)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=b,e.relativeTargetOrigin=g,e.relativeParent=f)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:n,delta:c,layoutDelta:o,hasLayoutChanged:u,hasRelativeTargetChanged:d})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function vve(e){EO&&kh.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function wve(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Sve(e){e.clearSnapshot()}function $8(e){e.clearMeasurements()}function Eve(e){e.isLayoutDirty=!1}function kve(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Q8(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Tve(e){e.resolveTargetDelta()}function _ve(e){e.calcProjection()}function Ave(e){e.resetSkewAndRotation()}function Nve(e){e.removeLeadSnapshot()}function B8(e,t,n){e.translate=pr(t.translate,0,n),e.scale=pr(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function U8(e,t,n,i){e.min=pr(t.min,n.min,i),e.max=pr(t.max,n.max,i)}function Cve(e,t,n,i){U8(e.x,t.x,n.x,i),U8(e.y,t.y,n.y,i)}function jve(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Rve={duration:.45,ease:[.4,0,.1,1]},z8=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),F8=z8("applewebkit/")&&!z8("chrome/")?Math.round:xo;function V8(e){e.min=F8(e.min),e.max=F8(e.max)}function Ive(e){V8(e.x),V8(e.y)}function ZK(e,t,n){return e==="position"||e==="preserve-aspect"&&!L1e(M8(t),M8(n),.2)}function Pve(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const Mve=WK({attachResizeListener:(e,t)=>ex(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),P2={current:void 0},KK=WK({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!P2.current){const e=new Mve({});e.mount(window),e.setOptions({layoutScroll:!0}),P2.current=e}return P2.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Lve={pan:{Feature:K1e},drag:{Feature:Z1e,ProjectionNode:KK,MeasureLayout:VK}};function Dve(e,t,n){var i;if(e instanceof Element)return[e];if(typeof e=="string"){let r=document;const s=(i=void 0)!==null&&i!==void 0?i:r.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e)}function JK(e,t){const n=Dve(e),i=new AbortController,r={passive:!0,...t,signal:i.signal};return[n,r,()=>i.abort()]}function X8(e){return t=>{t.pointerType==="touch"||PK()||e(t)}}function $ve(e,t,n={}){const[i,r,s]=JK(e,n),a=X8(o=>{const{target:c}=o,u=t(o);if(typeof u!="function"||!c)return;const d=X8(f=>{u(f),c.removeEventListener("pointerleave",d)});c.addEventListener("pointerleave",d,r)});return i.forEach(o=>{o.addEventListener("pointerenter",a,r)}),s}function q8(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,s=i[r];s&&Zi.postRender(()=>s(t,x1(t)))}class Qve extends Kf{mount(){const{current:t}=this.node;t&&(this.unmount=$ve(t,n=>(q8(this.node,n,"Start"),i=>q8(this.node,i,"End"))))}unmount(){}}class Bve extends Kf{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=y1(ex(this.node.current,"focus",()=>this.onFocus()),ex(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const eJ=(e,t)=>t?e===t?!0:eJ(e,t.parentElement):!1,Uve=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function zve(e){return Uve.has(e.tagName)||e.tabIndex!==-1}const kO=new WeakSet;function H8(e){return t=>{t.key==="Enter"&&e(t)}}function M2(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Fve=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=H8(()=>{if(kO.has(n))return;M2(n,"down");const r=H8(()=>{M2(n,"up")}),s=()=>M2(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function Y8(e){return RD(e)&&!PK()}function Vve(e,t,n={}){const[i,r,s]=JK(e,n),a=o=>{const c=o.currentTarget;if(!Y8(o)||kO.has(c))return;kO.add(c);const u=t(o),d=(p,g)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),!(!Y8(p)||!kO.has(c))&&(kO.delete(c),typeof u=="function"&&u(p,{success:g}))},f=p=>{d(p,n.useGlobalTarget||eJ(c,p.target))},h=p=>{d(p,!1)};window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",h,r)};return i.forEach(o=>{!zve(o)&&o.getAttribute("tabindex")===null&&(o.tabIndex=0),(n.useGlobalTarget?window:o).addEventListener("pointerdown",a,r),o.addEventListener("focus",u=>Fve(u,r),r)}),s}function G8(e,t,n){const{props:i}=e;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),s=i[r];s&&Zi.postRender(()=>s(t,x1(t)))}class Xve extends Kf{mount(){const{current:t}=this.node;t&&(this.unmount=Vve(t,n=>(G8(this.node,n,"Start"),(i,{success:r})=>G8(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const GI=new WeakMap,L2=new WeakMap,qve=e=>{const t=GI.get(e.target);t&&t(e)},Hve=e=>{e.forEach(qve)};function Yve({root:e,...t}){const n=e||document;L2.has(n)||L2.set(n,{});const i=L2.get(n),r=JSON.stringify(t);return i[r]||(i[r]=new IntersectionObserver(Hve,{root:e,...t})),i[r]}function Gve(e,t,n){const i=Yve(t);return GI.set(e,n),i.observe(e),()=>{GI.delete(e),i.unobserve(e)}}const Wve={some:0,all:1};class Zve extends Kf{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:s}=t,a={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:Wve[r]},o=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,s&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),h=u?d:f;h&&h(c)};return Gve(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Kve(t,n))&&this.startObserver()}unmount(){}}function Kve({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Jve={inView:{Feature:Zve},tap:{Feature:Xve},focus:{Feature:Bve},hover:{Feature:Qve}},ewe={layout:{ProjectionNode:KK,MeasureLayout:VK}},dk={current:null},ID={current:!1};function tJ(){if(ID.current=!0,!!nD)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>dk.current=e.matches;e.addListener(t),t()}else dk.current=!1}const twe=[...wK,Vs,Rf],nwe=e=>twe.find(vK(e)),W8=new WeakMap;function iwe(e,t,n){for(const i in t){const r=t[i],s=n[i];if(Ys(r))e.addValue(i,r);else if(Ys(s))e.addValue(i,Ky(r,{owner:e}));else if(s!==r)if(e.hasValue(i)){const a=e.getValue(i);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=e.getStaticValue(i);e.addValue(i,Ky(a!==void 0?a:r,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Z8=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class rwe{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:r,blockInitialAnimation:s,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=AD,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Dc.now();this.renderScheduledAtthis.bindToMotionValue(i,n)),ID.current||tJ(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:dk.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){W8.delete(this.current),this.projection&&this.projection.unmount(),jf(this.notifyUpdate),jf(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const i=Lp.has(t),r=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&Zi.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0)}),s=n.on("renderRequest",this.scheduleRender);let a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),s(),a&&a(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Zg){const n=Zg[t];if(!n)continue;const{isEnabled:i,Feature:r}=n;if(!this.features[t]&&r&&i(this.props)&&(this.features[t]=new r(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ar()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;in.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=Ky(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){var i;let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(i=this.getBaseTargetFromProps(this.props,t))!==null&&i!==void 0?i:this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(yK(r)||uK(r))?r=parseFloat(r):!nwe(r)&&Rf.test(n)&&(r=gK(t,n)),this.setBaseTarget(t,Ys(r)?r.get():r)),Ys(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:i}=this.props;let r;if(typeof i=="string"||typeof i=="object"){const a=lD(this.props,i,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);a&&(r=a[t])}if(i&&r!==void 0)return r;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!Ys(s)?s:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new yD),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class nJ extends rwe{constructor(){super(...arguments),this.KeyframeResolver=SK}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Ys(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function swe(e){return window.getComputedStyle(e)}class awe extends nJ{constructor(){super(...arguments),this.type="html",this.renderInstance=FZ}readValueFromInstance(t,n){if(Lp.has(n)){const i=_D(n);return i&&i.default||0}else{const i=swe(t),r=(BZ(n)?i.getPropertyValue(n):i[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return zK(t,n)}build(t,n,i){dD(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return mD(t,n,i)}}class owe extends nJ{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ar}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Lp.has(n)){const i=_D(n);return i&&i.default||0}return n=VZ.has(n)?n:sD(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return HZ(t,n,i)}build(t,n,i){fD(t,n,this.isSVGTag,i.transformTemplate)}renderInstance(t,n,i,r){XZ(t,n,i,r)}mount(t){this.isSVGTag=pD(t.tagName),super.mount(t)}}const lwe=(e,t)=>oD(e)?new owe(t):new awe(t,{allowProjection:e!==m.Fragment}),cwe=Mye({...T1e,...Jve,...Lve,...ewe},lwe),wr=WOe(cwe);function uwe(){!ID.current&&tJ();const[e]=m.useState(dk.current);return e}function ts(){return ts=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u"||/ServerSideRendering/.test(navigator&&navigator.userAgent)?m.useEffect:m.useLayoutEffect;function km(e,t,n){var i=m.useRef(t);i.current=t,m.useEffect(function(){function r(s){i.current(s)}return e&&window.addEventListener(e,r,n),function(){e&&window.removeEventListener(e,r)}},[e])}var dwe=["container"];function fwe(e){var t=e.container,n=t===void 0?document.body:t,i=m_(e,dwe);return zi.createPortal(mn.createElement("div",ts({},i)),n)}function hwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function pwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function mwe(e){return mn.createElement("svg",ts({width:"44",height:"44",viewBox:"0 0 768 768"},e),mn.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function gwe(){return m.useEffect(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function J8(e){var t=e.touches[0],n=t.clientX,i=t.clientY;if(e.touches.length>=2){var r=e.touches[1],s=r.clientX,a=r.clientY;return[(n+s)/2,(i+a)/2,Math.sqrt(Math.pow(s-n,2)+Math.pow(a-i,2))]}return[n,i,0]}var Vd=function(e,t,n,i){var r,s=n*t,a=(s-i)/2,o=e;return s<=i?(r=1,o=0):e>0&&a-e<=0?(r=2,o=a):e<0&&a+e<=0&&(r=3,o=-a),[r,o]};function D2(e,t,n,i,r,s,a,o,c,u){a===void 0&&(a=innerWidth/2),o===void 0&&(o=innerHeight/2),c===void 0&&(c=0),u===void 0&&(u=0);var d=Vd(e,s,n,innerWidth)[0],f=Vd(t,s,i,innerHeight),h=innerWidth/2,p=innerHeight/2;return{x:a-s/r*(a-(h+e))-h+(i/n>=3&&n*s===innerWidth?0:d?c/2:c),y:o-s/r*(o-(p+t))-p+(f[0]?u/2:u),lastCX:a,lastCY:o}}function KI(e,t,n){var i=e%180!=0;return i?[n,t,i]:[t,n,i]}function $2(e,t,n){var i=KI(n,innerWidth,innerHeight),r=i[0],s=i[1],a=0,o=r,c=s,u=e/t*s,d=t/e*r;return e=s?o=u:e>=r&&tr/s?c=d:t/e>=3&&!i[2]?a=((c=d)-s)/2:o=u,{width:o,height:c,x:0,y:a,pause:!0}}function nw(e,t){var n=t.leading,i=n!==void 0&&n,r=t.maxWait,s=t.wait,a=s===void 0?r||0:s,o=m.useRef(e);o.current=e;var c=m.useRef(0),u=m.useRef(),d=function(){return u.current&&clearTimeout(u.current)},f=m.useCallback(function(){var h=[].slice.call(arguments),p=Date.now();function g(){c.current=p,d(),o.current.apply(null,h)}var b=c.current,y=p-b;if(b===0&&(i&&g(),c.current=p),r!==void 0){if(y>r)return void g()}else y=1&&s&&s())};d()}function d(){c=requestAnimationFrame(u)}}var Owe={T:0,L:0,W:0,H:0,FIT:void 0},rJ=function(){var e=m.useRef(!1);return m.useEffect(function(){return e.current=!0,function(){e.current=!1}},[]),e},ywe=["className"];function xwe(e){var t=e.className,n=t===void 0?"":t,i=m_(e,ywe);return mn.createElement("div",ts({className:"PhotoView__Spinner "+n},i),mn.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},mn.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),mn.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var vwe=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function wwe(e){var t=e.src,n=e.loaded,i=e.broken,r=e.className,s=e.onPhotoLoad,a=e.loadingElement,o=e.brokenElement,c=m_(e,vwe),u=rJ();return t&&!i?mn.createElement(mn.Fragment,null,mn.createElement("img",ts({className:"PhotoView__Photo"+(r?" "+r:""),src:t,onLoad:function(d){var f=d.target;u.current&&s({loaded:!0,naturalWidth:f.naturalWidth,naturalHeight:f.naturalHeight})},onError:function(){u.current&&s({broken:!0})},draggable:!1,alt:""},c)),!n&&(a?mn.createElement("span",{className:"PhotoView__icon"},a):mn.createElement(xwe,{className:"PhotoView__icon"}))):o?mn.createElement("span",{className:"PhotoView__icon"},typeof o=="function"?o({src:t}):o):null}var Swe={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Ewe(e){var t=e.item,n=t.src,i=t.render,r=t.width,s=r===void 0?0:r,a=t.height,o=a===void 0?0:a,c=t.originRef,u=e.visible,d=e.speed,f=e.easing,h=e.wrapClassName,p=e.className,g=e.style,b=e.loadingElement,y=e.brokenElement,O=e.onPhotoTap,v=e.onMaskTap,x=e.onReachMove,w=e.onReachUp,E=e.onPhotoResize,S=e.isActive,k=e.expose,T=fk(Swe),A=T[0],N=T[1],C=m.useRef(0),M=rJ(),L=A.naturalWidth,P=L===void 0?s:L,Q=A.naturalHeight,j=Q===void 0?o:Q,$=A.width,U=$===void 0?s:$,B=A.height,I=B===void 0?o:B,X=A.loaded,q=X===void 0?!n:X,D=A.broken,H=A.x,re=A.y,fe=A.touched,Ae=A.stopRaf,J=A.maskTouched,ie=A.rotate,ue=A.scale,ye=A.CX,Se=A.CY,Re=A.lastX,Ee=A.lastY,me=A.lastCX,oe=A.lastCY,Ne=A.lastScale,Oe=A.touchTime,Ve=A.touchLength,We=A.pause,De=A.reach,mt=tp({onScale:function(je){return at(tw(je))},onRotate:function(je){ie!==je&&(k({rotate:je}),N(ts({rotate:je},$2(P,j,je))))}});function at(je,Ze,Ie){ue!==je&&(k({scale:je}),N(ts({scale:je},D2(H,re,U,I,ue,je,Ze,Ie),je<=1&&{x:0,y:0})))}var Rt=nw(function(je,Ze,Ie){if(Ie===void 0&&(Ie=0),(fe||J)&&S){var Wt=KI(ie,U,I),dn=Wt[0],Qt=Wt[1];if(Ie===0&&C.current===0){var Yt=Math.abs(je-ye)<=20,Jt=Math.abs(Ze-Se)<=20;if(Yt&&Jt)return void N({lastCX:je,lastCY:Ze});C.current=Yt?Ze>Se?3:2:1}var Ft,Ce=je-me,et=Ze-oe;if(Ie===0){var wt=Vd(Ce+Re,ue,dn,innerWidth)[0],yn=Vd(et+Ee,ue,Qt,innerHeight);Ft=function(hi,Pe,st,At){return Pe&&hi===1||At==="x"?"x":st&&hi>1||At==="y"?"y":void 0}(C.current,wt,yn[0],De),Ft!==void 0&&x(Ft,je,Ze,ue)}if(Ft==="x"||J)return void N({reach:"x"});var on=tw(ue+(Ie-Ve)/100/2*ue,P/U,.2);k({scale:on}),N(ts({touchLength:Ie,reach:Ft,scale:on},D2(H,re,U,I,ue,on,je,Ze,Ce,et)))}},{maxWait:8});function qe(je){return!Ae&&!fe&&(M.current&&N(ts({},je,{pause:u})),M.current)}var W,K,ae,pe,z,ve,Be,Je,kt=(z=function(je){return qe({x:je})},ve=function(je){return qe({y:je})},Be=function(je){return M.current&&(k({scale:je}),N({scale:je})),!fe&&M.current},Je=tp({X:function(je){return z(je)},Y:function(je){return ve(je)},S:function(je){return Be(je)}}),function(je,Ze,Ie,Wt,dn,Qt,Yt,Jt,Ft,Ce,et){var wt=KI(Ce,dn,Qt),yn=wt[0],on=wt[1],hi=Vd(je,Jt,yn,innerWidth),Pe=hi[0],st=hi[1],At=Vd(Ze,Jt,on,innerHeight),Ut=At[0],kn=At[1],wn=Date.now()-et;if(wn>=200||Jt!==Yt||Math.abs(Ft-Yt)>1){var Ai=D2(je,Ze,dn,Qt,Yt,Jt),Gn=Ai.x,xn=Ai.y,de=Pe?st:Gn!==je?Gn:null,Le=Ut?kn:xn!==Ze?xn:null;return de!==null&&jh(je,de,Je.X),Le!==null&&jh(Ze,Le,Je.Y),void(Jt!==Yt&&jh(Yt,Jt,Je.S))}var ut=(je-Ie)/wn,gt=(Ze-Wt)/wn,ln=Math.sqrt(Math.pow(ut,2)+Math.pow(gt,2)),Sn=!1,In=!1;(function(Ni,Pn){var Vt,Ji=Ni,fn=0,pi=0,ti=function(Ci){Vt||(Vt=Ci);var xs=Ci-Vt,ni=Math.sign(Ni),Ls=-.001*ni,er=Math.sign(-Ji)*Math.pow(Ji,2)*2e-4,Ya=Ji*xs+(Ls+er)*Math.pow(xs,2)/2;fn+=Ya,Vt=Ci,ni*(Ji+=(Ls+er)*xs)<=0?en():Pn(fn)?vi():en()};function vi(){pi=requestAnimationFrame(ti)}function en(){cancelAnimationFrame(pi)}vi()})(ln,function(Ni){var Pn=je+Ni*(ut/ln),Vt=Ze+Ni*(gt/ln),Ji=Vd(Pn,Yt,yn,innerWidth),fn=Ji[0],pi=Ji[1],ti=Vd(Vt,Yt,on,innerHeight),vi=ti[0],en=ti[1];if(fn&&!Sn&&(Sn=!0,Pe?jh(Pn,pi,Je.X):e9(pi,Pn+(Pn-pi),Je.X)),vi&&!In&&(In=!0,Ut?jh(Vt,en,Je.Y):e9(en,Vt+(Vt-en),Je.Y)),Sn&&In)return!1;var Ci=Sn||Je.X(pi),xs=In||Je.Y(en);return Ci&&xs})}),Mt=(W=O,K=function(je,Ze){De||at(ue!==1?1:Math.max(2,P/U),je,Ze)},ae=m.useRef(0),pe=nw(function(){ae.current=0,W.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var je=[].slice.call(arguments);ae.current+=1,pe.apply(void 0,je),ae.current>=2&&(pe.cancel(),ae.current=0,K.apply(void 0,je))});function Tt(je,Ze){if(C.current=0,(fe||J)&&S){N({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var Ie=tw(ue,P/U);if(kt(H,re,Re,Ee,U,I,ue,Ie,Ne,ie,Oe),w(je,Ze),ye===je&&Se===Ze){if(fe)return void Mt(je,Ze);J&&v(je,Ze)}}}function dt(je,Ze,Ie){Ie===void 0&&(Ie=0),N({touched:!0,CX:je,CY:Ze,lastCX:je,lastCY:Ze,lastX:H,lastY:re,lastScale:ue,touchLength:Ie,touchTime:Date.now()})}function ge(je){N({maskTouched:!0,CX:je.clientX,CY:je.clientY,lastX:H,lastY:re})}km(yu?void 0:"mousemove",function(je){je.preventDefault(),Rt(je.clientX,je.clientY)}),km(yu?void 0:"mouseup",function(je){Tt(je.clientX,je.clientY)}),km(yu?"touchmove":void 0,function(je){je.preventDefault();var Ze=J8(je);Rt.apply(void 0,Ze)},{passive:!1}),km(yu?"touchend":void 0,function(je){var Ze=je.changedTouches[0];Tt(Ze.clientX,Ze.clientY)},{passive:!1}),km("resize",nw(function(){q&&!fe&&(N($2(P,j,ie)),E())},{maxWait:8})),ZI(function(){S&&k(ts({scale:ue,rotate:ie},mt))},[S]);var lt=function(je,Ze,Ie,Wt,dn,Qt,Yt,Jt,Ft,Ce){var et=function(Gn,xn,de,Le,ut){var gt=m.useRef(!1),ln=fk({lead:!0,scale:de}),Sn=ln[0],In=Sn.lead,Ni=Sn.scale,Pn=ln[1],Vt=nw(function(Ji){try{return ut(!0),Pn({lead:!1,scale:Ji}),Promise.resolve()}catch(fn){return Promise.reject(fn)}},{wait:Le});return ZI(function(){gt.current?(ut(!1),Pn({lead:!0}),Vt(de)):gt.current=!0},[de]),In?[Gn*Ni,xn*Ni,de/Ni]:[Gn*de,xn*de,1]}(Qt,Yt,Jt,Ft,Ce),wt=et[0],yn=et[1],on=et[2],hi=function(Gn,xn,de,Le,ut){var gt=m.useState(Owe),ln=gt[0],Sn=gt[1],In=m.useState(0),Ni=In[0],Pn=In[1],Vt=m.useRef(),Ji=tp({OK:function(){return Gn&&Pn(4)}});function fn(pi){ut(!1),Pn(pi)}return m.useEffect(function(){if(Vt.current||(Vt.current=Date.now()),de){if(function(pi,ti){var vi=pi&&pi.current;if(vi&&vi.nodeType===1){var en=vi.getBoundingClientRect();ti({T:en.top,L:en.left,W:en.width,H:en.height,FIT:vi.tagName==="IMG"?getComputedStyle(vi).objectFit:void 0})}}(xn,Sn),Gn)return Date.now()-Vt.current<250?(Pn(1),requestAnimationFrame(function(){Pn(2),requestAnimationFrame(function(){return fn(3)})}),void setTimeout(Ji.OK,Le)):void Pn(4);fn(5)}},[Gn,de]),[Ni,ln]}(je,Ze,Ie,Ft,Ce),Pe=hi[0],st=hi[1],At=st.W,Ut=st.FIT,kn=innerWidth/2,wn=innerHeight/2,Ai=Pe<3||Pe>4;return[Ai?At?st.L:kn:Wt+(kn-Qt*Jt/2),Ai?At?st.T:wn:dn+(wn-Yt*Jt/2),wt,Ai&&Ut?wt*(st.H/At):yn,Pe===0?on:Ai?At/(Qt*Jt)||.01:on,Ai?Ut?1:0:1,Pe,Ut]}(u,c,q,H,re,U,I,ue,d,function(je){return N({pause:je})}),Ge=lt[4],vt=lt[6],_t="transform "+d+"ms "+f,Bt={className:p,onMouseDown:yu?void 0:function(je){je.stopPropagation(),je.button===0&&dt(je.clientX,je.clientY,0)},onTouchStart:yu?function(je){je.stopPropagation(),dt.apply(void 0,J8(je))}:void 0,onWheel:function(je){if(!De){var Ze=tw(ue-je.deltaY/100/2,P/U);N({stopRaf:!0}),at(Ze,je.clientX,je.clientY)}},style:{width:lt[2]+"px",height:lt[3]+"px",opacity:lt[5],objectFit:vt===4?void 0:lt[7],transform:ie?"rotate("+ie+"deg)":void 0,transition:vt>2?_t+", opacity "+d+"ms ease, height "+(vt<4?d/2:vt>4?d:0)+"ms "+f:void 0}};return mn.createElement("div",{className:"PhotoView__PhotoWrap"+(h?" "+h:""),style:g,onMouseDown:!yu&&S?ge:void 0,onTouchStart:yu&&S?function(je){return ge(je.touches[0])}:void 0},mn.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Ge+", 0, 0, "+Ge+", "+lt[0]+", "+lt[1]+")",transition:fe||We?void 0:_t,willChange:S?"transform":void 0}},n?mn.createElement(wwe,ts({src:n,loaded:q,broken:D},Bt,{onPhotoLoad:function(je){N(ts({},je,je.loaded&&$2(je.naturalWidth||0,je.naturalHeight||0,ie)))},loadingElement:b,brokenElement:y})):i&&i({attrs:Bt,scale:Ge,rotate:ie})))}var t9={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function kwe(e){var t=e.loop,n=t===void 0?3:t,i=e.speed,r=e.easing,s=e.photoClosable,a=e.maskClosable,o=a===void 0||a,c=e.maskOpacity,u=c===void 0?1:c,d=e.pullClosable,f=d===void 0||d,h=e.bannerVisible,p=h===void 0||h,g=e.overlayRender,b=e.toolbarRender,y=e.className,O=e.maskClassName,v=e.photoClassName,x=e.photoWrapClassName,w=e.loadingElement,E=e.brokenElement,S=e.images,k=e.index,T=k===void 0?0:k,A=e.onIndexChange,N=e.visible,C=e.onClose,M=e.afterClose,L=e.portalContainer,P=fk(t9),Q=P[0],j=P[1],$=m.useState(0),U=$[0],B=$[1],I=Q.x,X=Q.touched,q=Q.pause,D=Q.lastCX,H=Q.lastCY,re=Q.bg,fe=re===void 0?u:re,Ae=Q.lastBg,J=Q.overlay,ie=Q.minimal,ue=Q.scale,ye=Q.rotate,Se=Q.onScale,Re=Q.onRotate,Ee=e.hasOwnProperty("index"),me=Ee?T:U,oe=Ee?A:B,Ne=m.useRef(me),Oe=S.length,Ve=S[me],We=typeof n=="boolean"?n:Oe>n,De=function(Ge,vt){var _t=m.useReducer(function(Ie){return!Ie},!1)[1],Bt=m.useRef(0),je=function(Ie){var Wt=m.useRef(Ie);function dn(Qt){Wt.current=Qt}return m.useMemo(function(){(function(Qt){Ge?(Qt(Ge),Bt.current=1):Bt.current=2})(dn)},[Ie]),[Wt.current,dn]}(Ge),Ze=je[1];return[je[0],Bt.current,function(){_t(),Bt.current===2&&(Ze(!1),vt&&vt()),Bt.current=0}]}(N,M),mt=De[0],at=De[1],Rt=De[2];ZI(function(){if(mt)return j({pause:!0,x:me*-(innerWidth+nm)}),void(Ne.current=me);j(t9)},[mt]);var qe=tp({close:function(Ge){Re&&Re(0),j({overlay:!0,lastBg:fe}),C(Ge)},changeIndex:function(Ge,vt){vt===void 0&&(vt=!1);var _t=We?Ne.current+(Ge-me):Ge,Bt=Oe-1,je=WI(_t,0,Bt),Ze=We?_t:je,Ie=innerWidth+nm;j({touched:!1,lastCX:void 0,lastCY:void 0,x:-Ie*Ze,pause:vt}),Ne.current=Ze,oe&&oe(We?Ge<0?Bt:Ge>Bt?0:Ge:je)}}),W=qe.close,K=qe.changeIndex;function ae(Ge){return Ge?W():j({overlay:!J})}function pe(){j({x:-(innerWidth+nm)*me,lastCX:void 0,lastCY:void 0,pause:!0}),Ne.current=me}function z(Ge,vt,_t,Bt){Ge==="x"?function(je){if(D!==void 0){var Ze=je-D,Ie=Ze;!We&&(me===0&&Ze>0||me===Oe-1&&Ze<0)&&(Ie=Ze/2),j({touched:!0,lastCX:D,x:-(innerWidth+nm)*Ne.current+Ie,pause:!1})}else j({touched:!0,lastCX:je,x:I,pause:!1})}(vt):Ge==="y"&&function(je,Ze){if(H!==void 0){var Ie=u===null?null:WI(u,.01,u-Math.abs(je-H)/100/4);j({touched:!0,lastCY:H,bg:Ze===1?Ie:u,minimal:Ze===1})}else j({touched:!0,lastCY:je,bg:fe,minimal:!0})}(_t,Bt)}function ve(Ge,vt){var _t=Ge-(D??Ge),Bt=vt-(H??vt),je=!1;if(_t<-40)K(me+1);else if(_t>40)K(me-1);else{var Ze=-(innerWidth+nm)*Ne.current;Math.abs(Bt)>100&&ie&&f&&(je=!0,W()),j({touched:!1,x:Ze,lastCX:void 0,lastCY:void 0,bg:u,overlay:!!je||J})}}km("keydown",function(Ge){if(N)switch(Ge.key){case"ArrowLeft":K(me-1,!0);break;case"ArrowRight":K(me+1,!0);break;case"Escape":W()}});var Be=function(Ge,vt,_t){return m.useMemo(function(){var Bt=Ge.length;return _t?Ge.concat(Ge).concat(Ge).slice(Bt+vt-1,Bt+vt+2):Ge.slice(Math.max(vt-1,0),Math.min(vt+2,Bt+1))},[Ge,vt,_t])}(S,me,We);if(!mt)return null;var Je=J&&!at,kt=N?fe:Ae,Mt=Se&&Re&&{images:S,index:me,visible:N,onClose:W,onIndexChange:K,overlayVisible:Je,overlay:Ve&&Ve.overlay,scale:ue,rotate:ye,onScale:Se,onRotate:Re},Tt=i?i(at):400,dt=r?r(at):K8,ge=i?i(3):600,lt=r?r(3):K8;return mn.createElement(fwe,{className:"PhotoView-Portal"+(Je?"":" PhotoView-Slider__clean")+(N?"":" PhotoView-Slider__willClose")+(y?" "+y:""),role:"dialog",onClick:function(Ge){return Ge.stopPropagation()},container:L},N&&mn.createElement(gwe,null),mn.createElement("div",{className:"PhotoView-Slider__Backdrop"+(O?" "+O:"")+(at===1?" PhotoView-Slider__fadeIn":at===2?" PhotoView-Slider__fadeOut":""),style:{background:kt?"rgba(0, 0, 0, "+kt+")":void 0,transitionTimingFunction:dt,transitionDuration:(X?0:Tt)+"ms",animationDuration:Tt+"ms"},onAnimationEnd:Rt}),p&&mn.createElement("div",{className:"PhotoView-Slider__BannerWrap"},mn.createElement("div",{className:"PhotoView-Slider__Counter"},me+1," / ",Oe),mn.createElement("div",{className:"PhotoView-Slider__BannerRight"},b&&Mt&&b(Mt),mn.createElement(hwe,{className:"PhotoView-Slider__toolbarIcon",onClick:W}))),Be.map(function(Ge,vt){var _t=We||me!==0?Ne.current-1+vt:me+vt;return mn.createElement(Ewe,{key:We?Ge.key+"/"+Ge.src+"/"+_t:Ge.key,item:Ge,speed:Tt,easing:dt,visible:N,onReachMove:z,onReachUp:ve,onPhotoTap:function(){return ae(s)},onMaskTap:function(){return ae(o)},wrapClassName:x,className:v,style:{left:(innerWidth+nm)*_t+"px",transform:"translate3d("+I+"px, 0px, 0)",transition:X||q?void 0:"transform "+ge+"ms "+lt},loadingElement:w,brokenElement:E,onPhotoResize:pe,isActive:Ne.current===_t,expose:j})}),!yu&&p&&mn.createElement(mn.Fragment,null,(We||me!==0)&&mn.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return K(me-1,!0)}},mn.createElement(pwe,null)),(We||me+1-1){var O=u.slice();return O.splice(y,1,b),void o({images:O})}o(function(v){return{images:v.images.concat(b)}})},remove:function(b){o(function(y){var O=y.images.filter(function(v){return v.key!==b});return{images:O,index:Math.min(O.length-1,f)}})},show:function(b){var y=u.findIndex(function(O){return O.key===b});o({visible:!0,index:y}),i&&i(!0,y,a)}}),p=tp({close:function(){o({visible:!1}),i&&i(!1,f,a)},changeIndex:function(b){o({index:b}),n&&n(b,a)}}),g=m.useMemo(function(){return ts({},a,h)},[a,h]);return mn.createElement(iJ.Provider,{value:g},t,mn.createElement(kwe,ts({images:u,visible:d,index:f,onIndexChange:p.changeIndex,onClose:p.close},r)))}var sJ=function(e){var t,n,i=e.src,r=e.render,s=e.overlay,a=e.width,o=e.height,c=e.triggers,u=c===void 0?["onClick"]:c,d=e.children,f=m.useContext(iJ),h=(t=function(){return f.nextId()},(n=m.useRef({sign:!1,fn:void 0}).current).sign||(n.sign=!0,n.fn=t()),n.fn),p=m.useRef(null);m.useImperativeHandle(d==null?void 0:d.ref,function(){return p.current}),m.useEffect(function(){return function(){f.remove(h)}},[]);var g=tp({render:function(y){return r&&r(y)},show:function(y,O){f.show(h),function(v,x){if(d){var w=d.props[v];w&&w(x)}}(y,O)}}),b=m.useMemo(function(){var y={};return u.forEach(function(O){y[O]=g.show.bind(null,O)}),y},[]);return m.useEffect(function(){f.update({key:h,src:i,originRef:p,render:g.render,overlay:s,width:a,height:o})},[i]),d?m.Children.only(m.cloneElement(d,ts({},b,{ref:p}))):null};const Nwe=e=>l.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:[l.jsx("path",{d:"M22 6.017c0-1.104-.907-2.037-2.049-2l-.594.025c-2.732.148-4.952.705-7.333 1.953l-.512.279-.087.054a1 1 0 0 0 .971 1.737l.092-.046.454-.246C15.195 6.59 17.26 6.106 20 6.016v11.837c-3.034.046-5.42.582-7.99 1.99l-.517.295-.086.056a1 1 0 0 0 1.009 1.715l.09-.047.455-.258c2.105-1.157 4.045-1.645 6.537-1.738l.543-.014a1.995 1.995 0 0 0 1.95-1.8l.009-.198V6.017Z"}),l.jsx("path",{d:"M2 6.017c0-1.104.907-2.037 2.049-2l.594.025c2.732.148 4.952.705 7.333 1.953l.512.279.087.054a1 1 0 0 1-.971 1.737l-.092-.046-.454-.246C8.805 6.59 6.74 6.106 4 6.016v11.837c3.034.046 5.42.582 7.99 1.99l.517.295.086.056a1 1 0 0 1-1.009 1.715l-.09-.047-.455-.258c-2.105-1.157-4.045-1.644-6.537-1.738l-.543-.014a1.995 1.995 0 0 1-1.95-1.8L2 17.855V6.017Z"}),l.jsx("path",{d:"M13 7.5v13h-2v-13h2Z"})]}),Cwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M10.556 4a1 1 0 0 0-.97.751l-.292 1.14h5.421l-.293-1.14A1 1 0 0 0 13.453 4h-2.897Zm6.224 1.892-.421-1.639A3 3 0 0 0 13.453 2h-2.897A3 3 0 0 0 7.65 4.253l-.421 1.639H4a1 1 0 1 0 0 2h.1l1.215 11.425A3 3 0 0 0 8.3 22h7.4a3 3 0 0 0 2.984-2.683l1.214-11.425H20a1 1 0 1 0 0-2h-3.22Zm1.108 2H6.112l1.192 11.214A1 1 0 0 0 8.3 20h7.4a1 1 0 0 0 .995-.894l1.192-11.214ZM10 10a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0v-5a1 1 0 0 1 1-1Zm4 0a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0v-5a1 1 0 0 1 1-1Z",clipRule:"evenodd"})}),jwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M16.793 2.793a3.121 3.121 0 1 1 4.414 4.414l-8.5 8.5A1 1 0 0 1 12 16H9a1 1 0 0 1-1-1v-3a1 1 0 0 1 .293-.707l8.5-8.5Zm3 1.414a1.121 1.121 0 0 0-1.586 0L10 12.414V14h1.586l8.207-8.207a1.121 1.121 0 0 0 0-1.586ZM6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-4a1 1 0 1 1 2 0v4a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h4a1 1 0 1 1 0 2H6Z",clipRule:"evenodd"})}),Rwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{fillRule:"evenodd",d:"M4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8-10C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2Zm4.465 6.763a1 1 0 0 0-1.228-1.228l-5.5 1.5a1 1 0 0 0-.702.702l-1.5 5.5a1 1 0 0 0 1.228 1.228l5.5-1.5a1 1 0 0 0 .702-.702l1.5-5.5Zm-6.54 5.312.89-3.26 3.26-.89-.89 3.26-3.26.89Z",clipRule:"evenodd"})}),Iwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M5.91456 7.59106C4.34202 9.04124 3.28878 10.7415 2.77064 11.6971C2.66597 11.8902 2.66597 12.1098 2.77064 12.3029C3.28878 13.2585 4.34202 14.9588 5.91456 16.4089C7.48207 17.8545 9.50584 19 12.0001 19C14.4944 19 16.5182 17.8545 18.0857 16.4089C19.6582 14.9588 20.7114 13.2585 21.2296 12.3029C21.3343 12.1098 21.3343 11.8902 21.2296 11.6971C20.7114 10.7415 19.6582 9.04124 18.0857 7.59105C16.5182 6.1455 14.4944 5 12.0001 5C9.50584 5 7.48207 6.1455 5.91456 7.59106ZM4.5587 6.1208C6.36071 4.45899 8.84593 3 12.0001 3C15.1543 3 17.6395 4.45899 19.4415 6.1208C21.2385 7.77798 22.4153 9.68799 22.9878 10.7438C23.4149 11.5315 23.4149 12.4685 22.9878 13.2562C22.4153 14.312 21.2385 16.222 19.4415 17.8792C17.6395 19.541 15.1543 21 12.0001 21C8.84593 21 6.36071 19.541 4.5587 17.8792C2.76171 16.222 1.5849 14.312 1.01244 13.2562C0.585372 12.4685 0.585371 11.5315 1.01244 10.7438C1.5849 9.688 2.76171 7.77798 4.5587 6.1208ZM12.0001 9.5C10.6194 9.5 9.50011 10.6193 9.50011 12C9.50011 13.3807 10.6194 14.5 12.0001 14.5C13.3808 14.5 14.5001 13.3807 14.5001 12C14.5001 10.6193 13.3808 9.5 12.0001 9.5ZM7.50011 12C7.50011 9.51472 9.51483 7.5 12.0001 7.5C14.4854 7.5 16.5001 9.51472 16.5001 12C16.5001 14.4853 14.4854 16.5 12.0001 16.5C9.51483 16.5 7.50011 14.4853 7.50011 12Z",fill:"currentColor"})}),Pwe=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M11.2929 3.29289C11.6834 2.90237 12.3166 2.90237 12.7071 3.29289L16.7071 7.29289C17.0976 7.68342 17.0976 8.31658 16.7071 8.70711C16.3166 9.09763 15.6834 9.09763 15.2929 8.70711L13 6.41421V15C13 15.5523 12.5523 16 12 16C11.4477 16 11 15.5523 11 15V6.41421L8.70711 8.70711C8.31658 9.09763 7.68342 9.09763 7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289L11.2929 3.29289ZM4 14C4.55229 14 5 14.4477 5 15V15.2C5 16.0566 5.00078 16.6389 5.03755 17.089C5.07337 17.5274 5.1383 17.7516 5.21799 17.908C5.40973 18.2843 5.7157 18.5903 6.09202 18.782C6.24842 18.8617 6.47262 18.9266 6.91104 18.9624C7.36113 18.9992 7.94342 19 8.8 19H15.2C16.0566 19 16.6389 18.9992 17.089 18.9624C17.5274 18.9266 17.7516 18.8617 17.908 18.782C18.2843 18.5903 18.5903 18.2843 18.782 17.908C18.8617 17.7516 18.9266 17.5274 18.9624 17.089C18.9992 16.6389 19 16.0566 19 15.2V15C19 14.4477 19.4477 14 20 14C20.5523 14 21 14.4477 21 15V15.2413C21 16.0463 21 16.7106 20.9558 17.2518C20.9099 17.8139 20.8113 18.3306 20.564 18.816C20.1805 19.5686 19.5686 20.1805 18.816 20.564C18.3306 20.8113 17.8139 20.9099 17.2518 20.9558C16.7106 21 16.0463 21 15.2413 21H8.75868C7.95372 21 7.28936 21 6.74817 20.9558C6.18608 20.9099 5.66937 20.8113 5.18404 20.564C4.43139 20.1805 3.81947 19.5686 3.43597 18.816C3.18868 18.3306 3.09012 17.8139 3.04419 17.2518C2.99998 16.7106 2.99999 16.0463 3 15.2413L3 15C3 14.4477 3.44772 14 4 14Z",fill:"currentColor"})}),Q2=e=>l.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...e,children:l.jsx("path",{d:"M8.99805 16.796C8.99805 15.4164 7.87961 14.2979 6.5 14.2979C5.12039 14.2979 4.00195 15.4164 4.00195 16.796C4.00196 18.1756 5.1204 19.294 6.5 19.294C7.8796 19.294 8.99804 18.1756 8.99805 16.796ZM19.748 15.0479C19.748 14.7729 19.525 14.5499 19.25 14.5499H15.75C15.475 14.5499 15.252 14.7729 15.252 15.0479V18.5479C15.252 18.823 15.475 19.046 15.75 19.046H19.25C19.525 19.046 19.748 18.823 19.748 18.5479V15.0479ZM10.0469 3.45125C11.077 2.15921 13.0849 2.20276 14.0498 3.58113L16.4189 6.96492L16.5205 7.12215C17.5046 8.76341 16.3301 10.9023 14.3691 10.9024H9.63086C7.60676 10.9023 6.42029 8.62316 7.58105 6.96492L9.9502 3.58113L10.0469 3.45125ZM12.4082 4.73055C12.2223 4.46497 11.842 4.44826 11.6318 4.68074L11.5918 4.73055L9.22266 8.11433C8.99176 8.44435 9.22808 8.89744 9.63086 8.89754H14.3691C14.7468 8.89745 14.9774 8.49957 14.8145 8.17781L14.7773 8.11433L12.4082 4.73055ZM11.002 16.796C11.0019 19.2824 8.98638 21.2979 6.5 21.2979C4.01362 21.2979 1.99806 19.2824 1.99805 16.796C1.99805 14.3096 4.01361 12.294 6.5 12.294C8.98639 12.294 11.002 14.3096 11.002 16.796ZM21.752 18.5479C21.752 19.9297 20.6318 21.0499 19.25 21.0499H15.75C14.3682 21.0499 13.248 19.9297 13.248 18.5479V15.0479C13.2481 13.6662 14.3682 12.546 15.75 12.546H19.25C20.6318 12.546 21.7519 13.6662 21.752 15.0479V18.5479Z",fill:"currentColor"})});/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Pwe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),sJ=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim();/** + */const Mwe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),aJ=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim();/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */var Mwe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + */var Lwe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Lwe=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:s,iconNode:a,...o},c)=>m.createElement("svg",{ref:c,...Mwe,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:sJ("lucide",r),...o},[...a.map(([u,d])=>m.createElement(u,d)),...Array.isArray(s)?s:[s]]));/** + */const Dwe=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:s,iconNode:a,...o},c)=>m.createElement("svg",{ref:c,...Lwe,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:aJ("lucide",r),...o},[...a.map(([u,d])=>m.createElement(u,d)),...Array.isArray(s)?s:[s]]));/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Et=(e,t)=>{const n=m.forwardRef(({className:i,...r},s)=>m.createElement(Lwe,{ref:s,iconNode:t,className:sJ(`lucide-${Pwe(e)}`,i),...r}));return n.displayName=`${e}`,n};/** + */const Et=(e,t)=>{const n=m.forwardRef(({className:i,...r},s)=>m.createElement(Dwe,{ref:s,iconNode:t,className:aJ(`lucide-${Mwe(e)}`,i),...r}));return n.displayName=`${e}`,n};/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const aJ=Et("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** + */const oJ=Et("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Dwe=Et("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** + */const $we=Et("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -95,22 +95,22 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $we=Et("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** + */const Qwe=Et("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const oJ=Et("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** + */const lJ=Et("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lJ=Et("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + */const cJ=Et("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Qwe=Et("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** + */const Bwe=Et("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -120,7 +120,7 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Bwe=Et("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + */const Uwe=Et("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -130,12 +130,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const cJ=Et("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + */const uJ=Et("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Uwe=Et("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const zwe=Et("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -145,12 +145,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const zwe=Et("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** + */const Fwe=Et("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const uJ=Et("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** + */const dJ=Et("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -160,12 +160,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Fwe=Et("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** + */const Vwe=Et("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Vwe=Et("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** + */const Xwe=Et("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -190,7 +190,7 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Xwe=Et("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + */const qwe=Et("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -200,12 +200,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const qwe=Et("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** + */const Hwe=Et("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Hwe=Et("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** + */const Ywe=Et("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -215,22 +215,22 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ywe=Et("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** + */const Gwe=Et("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const dJ=Et("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** + */const fJ=Et("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Gwe=Et("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** + */const Wwe=Et("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Wwe=Et("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + */const Zwe=Et("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -240,17 +240,17 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const fJ=Et("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** + */const hJ=Et("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Zwe=Et("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + */const Kwe=Et("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Kwe=Et("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + */const Jwe=Et("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -270,12 +270,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const hJ=Et("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** + */const pJ=Et("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Jwe=Et("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** + */const eSe=Et("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -285,12 +285,12 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const eSe=Et("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** + */const tSe=Et("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const tSe=Et("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + */const nSe=Et("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -300,42 +300,42 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const nSe=Et("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** + */const iSe=Et("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const pJ=Et("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** + */const mJ=Et("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const iSe=Et("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** + */const rSe=Et("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const rSe=Et("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** + */const sSe=Et("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const sSe=Et("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** + */const aSe=Et("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const aSe=Et("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** + */const oSe=Et("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const oSe=Et("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + */const lSe=Et("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lSe=Et("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** + */const cSe=Et("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -345,22 +345,22 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const cSe=Et("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + */const uSe=Et("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const mJ=Et("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** + */const gJ=Et("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const uSe=Et("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + */const dSe=Et("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const dSe=Et("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** + */const fSe=Et("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -370,7 +370,7 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const fSe=Et("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** + */const hSe=Et("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -385,7 +385,7 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const hSe=Et("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** + */const pSe=Et("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. @@ -395,34 +395,34 @@ Error generating stack: `+i.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const pSe=Et("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** + */const mSe=Et("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const mSe=Et("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + */const gSe=Et("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xa=Et("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),a9="veadk_auth_qs";let Xb=null;function gSe(){if(Xb!==null)return Xb;const t=new URLSearchParams(window.location.search).toString();return t?(sessionStorage.setItem(a9,t),Xb=t):Xb=sessionStorage.getItem(a9)??"",window.location.search&&window.history.replaceState(null,"",window.location.pathname+window.location.hash),Xb}function vo(e){const t=gSe();if(!t)return e;const n=new URL(e,window.location.origin);return new URLSearchParams(t).forEach((i,r)=>{n.searchParams.has(r)||n.searchParams.set(r,i)}),/^https?:\/\//i.test(e)?n.toString():n.pathname+n.search+n.hash}const _o=3e4,kr=12e4,DD=1e4;function Ao(e,t=_o){if(t<=0)return e??void 0;const n=AbortSignal.timeout(t);return e?AbortSignal.any([e,n]):n}const pk="veadk_local_user",mk="veadk_local_user_tab",bSe=/^[A-Za-z0-9]{1,16}$/;function gJ(){try{const e=sessionStorage.getItem(mk);if(e)return e;const t=localStorage.getItem(pk);return t&&sessionStorage.setItem(mk,t),t}catch{try{return localStorage.getItem(pk)}catch{return null}}}function o9(e){try{sessionStorage.setItem(mk,e)}catch{}try{localStorage.setItem(pk,e)}catch{}}function OSe(){try{sessionStorage.removeItem(mk)}catch{}try{localStorage.removeItem(pk)}catch{}}function Dp(e){const t=new Headers(e),n=gJ();return n&&t.set("X-VeADK-Local-User",n),t}async function bJ(){let e;try{e=await fetch("/web/auth-config",{headers:{Accept:"application/json"},signal:Ao(void 0,DD)})}catch(t){throw console.warn("[identity] /web/auth-config is unreachable:",t),new Error("无法加载登录配置,请检查网络后重试。")}if(!e.ok)throw new Error(`登录配置服务异常(HTTP ${e.status}),请稍后重试。`);try{const t=await e.json();if(!Array.isArray(t.providers))throw new TypeError("providers is not an array");return t.providers}catch(t){throw console.warn("[identity] /web/auth-config returned an invalid response:",t),new Error("登录配置服务返回了无法解析的响应,请稍后重试。")}}function ySe(e){const t=window.location.pathname+window.location.search+window.location.hash,n=e.includes("?")?"&":"?";window.location.assign(`${e}${n}redirect=${encodeURIComponent(t)}`)}function xSe(){const e=window.location.pathname+window.location.search+window.location.hash,t=window.open("about:blank","_blank","popup,width=520,height=720");if(!t)return null;try{t.opener=null,t.location.replace(`/oauth2/login?redirect=${encodeURIComponent(e)}`)}catch{return t.close(),null}return t}async function vSe(){const[e,t]=await Promise.all([JI(),bJ()]);return e.status==="unauthenticated"&&t.length>0}function wSe(){window.location.assign("/oauth2/logout")}async function JI(){let e;try{e=await fetch("/oauth2/userinfo",{headers:{Accept:"application/json"},signal:Ao(void 0,DD)})}catch(n){throw console.warn("[identity] /oauth2/userinfo is unreachable:",n),new Error("无法连接身份服务,请检查网络后重试。")}if(e.ok){let n;try{n=await e.json()}catch(r){throw console.warn("[identity] /oauth2/userinfo returned a non-JSON response:",r),new Error("身份服务返回了无法解析的响应,请稍后重试。")}return{status:"authenticated",userId:String(n.sub??n.user_id??n.email??""),info:n}}if(e.status===401)return{status:"unauthenticated",userId:"",local:!1};if(e.status!==404)throw new Error(`身份服务异常(HTTP ${e.status}),请稍后重试。`);const t=gJ();return t?{status:"authenticated",userId:t,info:{name:t},local:!0}:{status:"unauthenticated",userId:"",local:!0}}function SSe(e){return e?String(e.name??e.preferred_username??e.email??e.sub??""):""}function ESe(e){const t=e==null?void 0:e.picture;return typeof t=="string"?t.trim():""}const eP="veadk:authentication-required";let oy=null,TO=null;function kSe(e){if(!e.redirected||!e.url)return!1;try{const t=new URL(e.url);return t.pathname.includes("/authorize")||t.pathname.includes("/oauth2/login")||t.hostname.includes(".userpool.auth.")}catch{return!1}}function TSe(e){oy||(oy=new Promise(n=>{TO=n}),window.dispatchEvent(new Event(eP)));const t=oy;return e?e.aborted?Promise.reject(e.reason??new Error("Request aborted")):new Promise((n,i)=>{const r=()=>i(e.reason??new Error("Request aborted"));e.addEventListener("abort",r,{once:!0}),t.then(()=>{e.removeEventListener("abort",r),n()},s=>{e.removeEventListener("abort",r),i(s)})}):t}function _Se(){return oy!==null}function ASe(){TO==null||TO(),TO=null,oy=null}async function y_(e,t){var i;const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失",s=n.trim().slice(0,2e3),a=s?` -响应:${s}`:"";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},${r})${a}`)}}const NSe=/\brun_sse\s*failed\s*:\s*404\b/i,CSe=/session not found/i,jSe=/(?:^|[::\s])not found\s*$/i,RSe=/Expecting (?:'[^']+'|\w+)(?: delimiter)?: line \d+ column \d+ \(char \d+\)/i,l9="提示:会话已不存在。使用 in-memory 或 SQLite 短期记忆时,多实例、进程重启或滚动发布都可能导致会话丢失;建议改用基于数据库的持久化短期记忆存储。",c9="提示:该 Runtime 未提供会话能力运行接口,可能是 Runtime 版本与当前 Studio 不兼容。",u9="提示:模型生成的工具参数格式不完整,请重新发送一次。";function iw(e){const t=String(e);return RSe.test(t)?t.includes(u9)?t:`${t} + */const xa=Et("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),a9="veadk_auth_qs";let Xb=null;function bSe(){if(Xb!==null)return Xb;const t=new URLSearchParams(window.location.search).toString();return t?(sessionStorage.setItem(a9,t),Xb=t):Xb=sessionStorage.getItem(a9)??"",window.location.search&&window.history.replaceState(null,"",window.location.pathname+window.location.hash),Xb}function vo(e){const t=bSe();if(!t)return e;const n=new URL(e,window.location.origin);return new URLSearchParams(t).forEach((i,r)=>{n.searchParams.has(r)||n.searchParams.set(r,i)}),/^https?:\/\//i.test(e)?n.toString():n.pathname+n.search+n.hash}const _o=3e4,kr=12e4,DD=1e4;function Ao(e,t=_o){if(t<=0)return e??void 0;const n=AbortSignal.timeout(t);return e?AbortSignal.any([e,n]):n}const pk="veadk_local_user",mk="veadk_local_user_tab",OSe=/^[A-Za-z0-9]{1,16}$/;function bJ(){try{const e=sessionStorage.getItem(mk);if(e)return e;const t=localStorage.getItem(pk);return t&&sessionStorage.setItem(mk,t),t}catch{try{return localStorage.getItem(pk)}catch{return null}}}function o9(e){try{sessionStorage.setItem(mk,e)}catch{}try{localStorage.setItem(pk,e)}catch{}}function ySe(){try{sessionStorage.removeItem(mk)}catch{}try{localStorage.removeItem(pk)}catch{}}function Dp(e){const t=new Headers(e),n=bJ();return n&&t.set("X-VeADK-Local-User",n),t}async function OJ(){let e;try{e=await fetch("/web/auth-config",{headers:{Accept:"application/json"},signal:Ao(void 0,DD)})}catch(t){throw console.warn("[identity] /web/auth-config is unreachable:",t),new Error("无法加载登录配置,请检查网络后重试。")}if(!e.ok)throw new Error(`登录配置服务异常(HTTP ${e.status}),请稍后重试。`);try{const t=await e.json();if(!Array.isArray(t.providers))throw new TypeError("providers is not an array");return t.providers}catch(t){throw console.warn("[identity] /web/auth-config returned an invalid response:",t),new Error("登录配置服务返回了无法解析的响应,请稍后重试。")}}function xSe(e){const t=window.location.pathname+window.location.search+window.location.hash,n=e.includes("?")?"&":"?";window.location.assign(`${e}${n}redirect=${encodeURIComponent(t)}`)}function vSe(){const e=window.location.pathname+window.location.search+window.location.hash,t=window.open("about:blank","_blank","popup,width=520,height=720");if(!t)return null;try{t.opener=null,t.location.replace(`/oauth2/login?redirect=${encodeURIComponent(e)}`)}catch{return t.close(),null}return t}async function wSe(){const[e,t]=await Promise.all([JI(),OJ()]);return e.status==="unauthenticated"&&t.length>0}function SSe(){window.location.assign("/oauth2/logout")}async function JI(){let e;try{e=await fetch("/oauth2/userinfo",{headers:{Accept:"application/json"},signal:Ao(void 0,DD)})}catch(n){throw console.warn("[identity] /oauth2/userinfo is unreachable:",n),new Error("无法连接身份服务,请检查网络后重试。")}if(e.ok){let n;try{n=await e.json()}catch(r){throw console.warn("[identity] /oauth2/userinfo returned a non-JSON response:",r),new Error("身份服务返回了无法解析的响应,请稍后重试。")}return{status:"authenticated",userId:String(n.sub??n.user_id??n.email??""),info:n}}if(e.status===401)return{status:"unauthenticated",userId:"",local:!1};if(e.status!==404)throw new Error(`身份服务异常(HTTP ${e.status}),请稍后重试。`);const t=bJ();return t?{status:"authenticated",userId:t,info:{name:t},local:!0}:{status:"unauthenticated",userId:"",local:!0}}function ESe(e){return e?String(e.name??e.preferred_username??e.email??e.sub??""):""}function kSe(e){const t=e==null?void 0:e.picture;return typeof t=="string"?t.trim():""}const eP="veadk:authentication-required";let oy=null,TO=null;function TSe(e){if(!e.redirected||!e.url)return!1;try{const t=new URL(e.url);return t.pathname.includes("/authorize")||t.pathname.includes("/oauth2/login")||t.hostname.includes(".userpool.auth.")}catch{return!1}}function _Se(e){oy||(oy=new Promise(n=>{TO=n}),window.dispatchEvent(new Event(eP)));const t=oy;return e?e.aborted?Promise.reject(e.reason??new Error("Request aborted")):new Promise((n,i)=>{const r=()=>i(e.reason??new Error("Request aborted"));e.addEventListener("abort",r,{once:!0}),t.then(()=>{e.removeEventListener("abort",r),n()},s=>{e.removeEventListener("abort",r),i(s)})}):t}function ASe(){return oy!==null}function NSe(){TO==null||TO(),TO=null,oy=null}async function y_(e,t){var i;const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失",s=n.trim().slice(0,2e3),a=s?` +响应:${s}`:"";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},${r})${a}`)}}const CSe=/\brun_sse\s*failed\s*:\s*404\b/i,jSe=/session not found/i,RSe=/(?:^|[::\s])not found\s*$/i,ISe=/Expecting (?:'[^']+'|\w+)(?: delimiter)?: line \d+ column \d+ \(char \d+\)/i,l9="提示:会话已不存在。使用 in-memory 或 SQLite 短期记忆时,多实例、进程重启或滚动发布都可能导致会话丢失;建议改用基于数据库的持久化短期记忆存储。",c9="提示:该 Runtime 未提供会话能力运行接口,可能是 Runtime 版本与当前 Studio 不兼容。",u9="提示:模型生成的工具参数格式不完整,请重新发送一次。";function iw(e){const t=String(e);return ISe.test(t)?t.includes(u9)?t:`${t} -${u9}`:NSe.test(t)?CSe.test(t)?t.includes(l9)?t:`${t} +${u9}`:CSe.test(t)?jSe.test(t)?t.includes(l9)?t:`${t} -${l9}`:jSe.test(t)?t.includes(c9)?t:`${t} +${l9}`:RSe.test(t)?t.includes(c9)?t:`${t} ${c9}`:t:t}async function*$D(e){if(!e.body)throw new Error("Response has no body");const t=e.body.getReader(),n=new TextDecoder;let i="";try{for(;;){const{done:r,value:s}=await t.read();if(r)break;i+=n.decode(s,{stream:!0});let a=i.match(/\r?\n\r?\n/);for(;(a==null?void 0:a.index)!==void 0;){const o=i.slice(0,a.index);i=i.slice(a.index+a[0].length);const c=o.split(/\r?\n/).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trimStart()).join(` -`);if(c)try{yield JSON.parse(c)}catch{c!=="[DONE]"&&c!=="ping"&&console.debug(`parseSSE: dropping unparseable frame (${c.length} chars):`,c.slice(0,200))}a=i.match(/\r?\n\r?\n/)}}}finally{try{await t.cancel()}catch{}finally{t.releaseLock()}}}const ISe=255,PSe=/[\p{L}\p{M}\p{N}\p{P}\p{Zs}]/u;function MSe(e){const t=e.normalize("NFKC").replace(/\s+/gu," ").trim(),n=new TextEncoder;let i=0,r="";for(const s of t){if(!PSe.test(s))continue;const a=n.encode(s).byteLength;if(i+a>ISe)break;r+=s,i+=a}return r.replace(/ +/g," ").trimEnd()}const tP="ap-southeast-1",QD="cn-beijing",LSe="https://ark.ap-southeast.bytepluses.com/api/v3",DSe="https://ark.cn-beijing.volces.com/api/v3/",$Se="https://console.byteplus.com/ark/region:ark+ap-southeast-1/openManagement",QSe="https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement",BSe="dola-seed-2-1-turbo-260628",USe="doubao-seed-2-1-pro-260628",zSe="skylark-embedding-vision-250615",FSe="doubao-embedding-vision-250615",VSe="seed-2-0-lite-260228",XSe="doubao-seed-2-0-lite-260428",qSe="dola-seedream-5-0-pro-260628",HSe="doubao-seedream-5-0-260128",YSe="seededit-3-0-i2i-250628",GSe="doubao-seededit-3-0-i2i-250628",WSe="dreamina-seedance-2-0-260128",ZSe="doubao-seedance-2-0-260128",OJ=[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}],yJ=[{value:tP,label:tP}];function v1(e){return e==="byteplus"?yJ:OJ}function Qi(e){var t;return((t=v1(e)[0])==null?void 0:t.value)||QD}const KSe=new Set(["cn-beijing","cn-shanghai","ap-southeast-1"]);function BD(e){return typeof e=="string"&&KSe.has(e)}function td(e,t){var i;return((i=(t?v1(t):[...OJ,...yJ]).find(r=>r.value===e))==null?void 0:i.label)||e||"-"}function t0(e){return e==="byteplus"?BSe:USe}function Dl(e){return e==="byteplus"?LSe:DSe}function JSe(e){return e==="byteplus"?$Se:QSe}function eEe(e){return e==="byteplus"?zSe:FSe}function tEe(e){return e==="byteplus"?VSe:XSe}function nEe(e){return e==="byteplus"?qSe:HSe}function iEe(e){return e==="byteplus"?YSe:GSe}function rEe(e){return e==="byteplus"?WSe:ZSe}const UD="veadk.messageFeedback.v1";function zD(e,t,n,i){return[e,t,n,i].join(":")}function FD(){if(typeof window>"u")return{};try{const e=JSON.parse(localStorage.getItem(UD)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function sEe(e,t,n){if(typeof window>"u")return;const i=FD();i[e]={...i[e]??{},[`veadk_feedback:${t}`]:n},localStorage.setItem(UD,JSON.stringify(i))}function xJ(e){if(typeof window>"u")return;const t=zD(e.runtimeId,e.appName,e.userId,e.sessionId),n=FD(),i=n[t];if(i){for(const r of e.eventIds)delete i[`veadk_feedback:${r}`];Object.keys(i).length===0?delete n[t]:n[t]=i,localStorage.setItem(UD,JSON.stringify(n))}}const QS="",VD=new Map;function vJ(e,t){VD.set(e,t)}function wJ(){VD.clear()}function Hr(e){const t=VD.get(e);return t?{app:t.app,ep:{base:t.base,apiKey:t.apiKey,runtimeId:t.runtimeId,region:t.region}}:{app:e,ep:{}}}async function Dt(e,t={},n={},i=_o){const r=!!n.runtimeId&&String(t.method??"GET").toUpperCase()==="DELETE",s={...t,...r?{method:"POST"}:{},headers:Dp(t.headers)},a=()=>{const u={...s,signal:Ao(t.signal,i)};if(n.runtimeId){const d=new URLSearchParams;n.region&&d.set("region",n.region),n.retryProbe&&d.set("probe_retry","connect"),r&&d.set("_method","DELETE");const f=d.toString()?`${e.includes("?")?"&":"?"}${d.toString()}`:"";return fetch(vo(`${QS}/web/runtime-proxy/${n.runtimeId}${e}${f}`),u)}if(n.base){const d=new Headers(u.headers);return d.set("X-AgentKit-Base",n.base),n.apiKey&&d.set("X-AgentKit-Key",n.apiKey),fetch(vo(`${QS}/agentkit-proxy${e}`),{...u,headers:d})}return fetch(vo(`${QS}${e}`),u)},o=async u=>{if(kSe(u))return!0;if(u.status!==401)return!1;try{return await vSe()}catch{return!1}};let c=await a();for(;await o(c);)await TSe(t.signal),c=await a();return c}function ri(e,t={},n=_o){return Dt(e,t,{},n)}function aEe(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{var n;if(t&&typeof t=="object"&&"msg"in t){const i=Array.isArray(t.loc)?(n=t.loc)==null?void 0:n.join("."):"",r=String(t.msg??"");return i?`${i}: ${r}`:r}return String(t)}).filter(Boolean).join(` -`):e&&typeof e=="object"?JSON.stringify(e):""}async function an(e,t){const n=`${t}(HTTP ${e.status})`,i=await e.text().catch(()=>"");if(!i)return n;try{const r=JSON.parse(i),s=aEe(r.detail??r.error);return s?`${n} +`);if(c)try{yield JSON.parse(c)}catch{c!=="[DONE]"&&c!=="ping"&&console.debug(`parseSSE: dropping unparseable frame (${c.length} chars):`,c.slice(0,200))}a=i.match(/\r?\n\r?\n/)}}}finally{try{await t.cancel()}catch{}finally{t.releaseLock()}}}const PSe=255,MSe=/[\p{L}\p{M}\p{N}\p{P}\p{Zs}]/u;function LSe(e){const t=e.normalize("NFKC").replace(/\s+/gu," ").trim(),n=new TextEncoder;let i=0,r="";for(const s of t){if(!MSe.test(s))continue;const a=n.encode(s).byteLength;if(i+a>PSe)break;r+=s,i+=a}return r.replace(/ +/g," ").trimEnd()}const tP="ap-southeast-1",QD="cn-beijing",DSe="https://ark.ap-southeast.bytepluses.com/api/v3",$Se="https://ark.cn-beijing.volces.com/api/v3/",QSe="https://console.byteplus.com/ark/region:ark+ap-southeast-1/openManagement",BSe="https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement",USe="dola-seed-2-1-turbo-260628",zSe="doubao-seed-2-1-pro-260628",FSe="skylark-embedding-vision-250615",VSe="doubao-embedding-vision-250615",XSe="seed-2-0-lite-260228",qSe="doubao-seed-2-0-lite-260428",HSe="dola-seedream-5-0-pro-260628",YSe="doubao-seedream-5-0-260128",GSe="seededit-3-0-i2i-250628",WSe="doubao-seededit-3-0-i2i-250628",ZSe="dreamina-seedance-2-0-260128",KSe="doubao-seedance-2-0-260128",yJ=[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}],xJ=[{value:tP,label:tP}];function v1(e){return e==="byteplus"?xJ:yJ}function Qi(e){var t;return((t=v1(e)[0])==null?void 0:t.value)||QD}const JSe=new Set(["cn-beijing","cn-shanghai","ap-southeast-1"]);function BD(e){return typeof e=="string"&&JSe.has(e)}function td(e,t){var i;return((i=(t?v1(t):[...yJ,...xJ]).find(r=>r.value===e))==null?void 0:i.label)||e||"-"}function t0(e){return e==="byteplus"?USe:zSe}function Dl(e){return e==="byteplus"?DSe:$Se}function eEe(e){return e==="byteplus"?QSe:BSe}function tEe(e){return e==="byteplus"?FSe:VSe}function nEe(e){return e==="byteplus"?XSe:qSe}function iEe(e){return e==="byteplus"?HSe:YSe}function rEe(e){return e==="byteplus"?GSe:WSe}function sEe(e){return e==="byteplus"?ZSe:KSe}const UD="veadk.messageFeedback.v1";function zD(e,t,n,i){return[e,t,n,i].join(":")}function FD(){if(typeof window>"u")return{};try{const e=JSON.parse(localStorage.getItem(UD)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function aEe(e,t,n){if(typeof window>"u")return;const i=FD();i[e]={...i[e]??{},[`veadk_feedback:${t}`]:n},localStorage.setItem(UD,JSON.stringify(i))}function vJ(e){if(typeof window>"u")return;const t=zD(e.runtimeId,e.appName,e.userId,e.sessionId),n=FD(),i=n[t];if(i){for(const r of e.eventIds)delete i[`veadk_feedback:${r}`];Object.keys(i).length===0?delete n[t]:n[t]=i,localStorage.setItem(UD,JSON.stringify(n))}}const QS="",VD=new Map;function wJ(e,t){VD.set(e,t)}function SJ(){VD.clear()}function Hr(e){const t=VD.get(e);return t?{app:t.app,ep:{base:t.base,apiKey:t.apiKey,runtimeId:t.runtimeId,region:t.region}}:{app:e,ep:{}}}async function Dt(e,t={},n={},i=_o){const r=!!n.runtimeId&&String(t.method??"GET").toUpperCase()==="DELETE",s={...t,...r?{method:"POST"}:{},headers:Dp(t.headers)},a=()=>{const u={...s,signal:Ao(t.signal,i)};if(n.runtimeId){const d=new URLSearchParams;n.region&&d.set("region",n.region),n.retryProbe&&d.set("probe_retry","connect"),r&&d.set("_method","DELETE");const f=d.toString()?`${e.includes("?")?"&":"?"}${d.toString()}`:"";return fetch(vo(`${QS}/web/runtime-proxy/${n.runtimeId}${e}${f}`),u)}if(n.base){const d=new Headers(u.headers);return d.set("X-AgentKit-Base",n.base),n.apiKey&&d.set("X-AgentKit-Key",n.apiKey),fetch(vo(`${QS}/agentkit-proxy${e}`),{...u,headers:d})}return fetch(vo(`${QS}${e}`),u)},o=async u=>{if(TSe(u))return!0;if(u.status!==401)return!1;try{return await wSe()}catch{return!1}};let c=await a();for(;await o(c);)await _Se(t.signal),c=await a();return c}function ri(e,t={},n=_o){return Dt(e,t,{},n)}function oEe(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{var n;if(t&&typeof t=="object"&&"msg"in t){const i=Array.isArray(t.loc)?(n=t.loc)==null?void 0:n.join("."):"",r=String(t.msg??"");return i?`${i}: ${r}`:r}return String(t)}).filter(Boolean).join(` +`):e&&typeof e=="object"?JSON.stringify(e):""}async function an(e,t){const n=`${t}(HTTP ${e.status})`,i=await e.text().catch(()=>"");if(!i)return n;try{const r=JSON.parse(i),s=oEe(r.detail??r.error);return s?`${n} ${s} 原始响应: ${i}`:`${n} 原始响应: ${i}`}catch{return`${n} 原始响应: -${i}`}}async function SJ(e,t=!1){const n=await Dt(`/web/model-api-keys${t?"?refresh=true":""}`,{signal:e,cache:"no-store"});if(!n.ok)throw new Error(await an(n,"加载 Ark API Key 失败"));return await n.json()}async function EJ(e,t){const n=await Dt(`/web/model-api-keys/${encodeURIComponent(e)}/value`,{method:"POST",signal:t,cache:"no-store"});if(!n.ok)throw new Error(await an(n,"加载 Ark API Key 失败"));return await n.json()}async function kJ(e){const t=new URLSearchParams;e!=null&&e.apiKeyId&&t.set("apiKeyId",e.apiKeyId),e!=null&&e.refresh&&t.set("refresh","true");const n=t.toString(),i=await Dt(`/web/model-options${n?`?${n}`:""}`,{signal:e==null?void 0:e.signal,cache:"no-store"});if(!i.ok)throw new Error(await an(i,"加载模型列表失败"));return await i.json()}async function TJ(){const e=await Dt("/list-apps");if(!e.ok)throw new Error(`list-apps failed: ${e.status}`);return e.json()}class z0 extends Error{constructor(){super("当前账号无权访问该 Runtime,请刷新列表或重新登录后重试。"),this.name="RuntimeAccessDeniedError"}}class ga extends Error{constructor(t,n=!1,i=!1){super(t),this.unsupported=n,this.retryable=i,this.name="RuntimeProbeError"}}const _J="Runtime 已部署成功,但当前 Studio 无法访问私网 Runtime。请使用已绑定相同 VPC 的 Studio 访问,或改用公网 / 公网+VPC 部署。",AJ="Runtime 已部署成功,但 Studio 暂时无法连接服务。网关域名可能仍在生效,或当前网络/DNS 无法访问该 Runtime,请稍后在智能体管理页重试连接。",d9=["cn-beijing","cn-shanghai"],oEe=3e4,x_=5*60*1e3,NJ=60*1e3;let CJ="volcengine";const BS=new Map,Th=new Map,_h=new Map,_l=new Map;function jJ(e,t){return`${t}:${e}`}function RJ(e){CJ=e}function Jf(e){const t=(e||"").trim();if(CJ==="byteplus")return[t&&!t.startsWith("cn-")?t:tP];const n=t&&!t.startsWith("ap-")?t:QD;return d9.includes(n)?[n,...d9.filter(i=>i!==n)]:[n]}function F0(...e){return e.map(t=>String(t??"")).join("")}function V0(e,t,n){const i=e.get(t);return i!=null&&i.value&&Date.now()-i.updatedAt<=n?i.value:null}function XD(e,t,n){return e.set(t,{value:n,updatedAt:Date.now()}),n}async function IJ(e){try{const t=await e.clone().json();return typeof t.detail=="string"?t.detail:""}catch{return""}}async function v_(e,t,n){const i=await Dt("/list-apps",{},n??{base:e,apiKey:t}),r=n!=null&&n.runtimeId?await IJ(i):"";if(n!=null&&n.runtimeId&&r==="runtime_access_denied")throw new z0;if(n!=null&&n.runtimeId&&r==="runtime_private_endpoint_unreachable")throw new ga(_J);if(n!=null&&n.runtimeId&&["runtime_proxy_connect_error","runtime_proxy_timeout","runtime_json_connect_error","runtime_json_timeout"].includes(r))throw new ga(AJ,!1,!0);if(n!=null&&n.runtimeId&&i.status===404)throw new ga("该 Runtime 的 Agent Server 未提供连接接口,请确认 Runtime 已就绪且版本兼容。",!0,!0);if(n!=null&&n.runtimeId&&(i.status===401||i.status===403))throw new ga("Runtime 服务拒绝了连接请求,请检查 Runtime 的鉴权配置。");if(!i.ok)throw new Error(await an(i,"读取 Agent 列表失败"));const s=await i.json();return n!=null&&n.runtimeId&&BS.set(jJ(n.runtimeId,n.region??""),{apps:s,expiresAt:Date.now()+oEe}),s}async function PJ(e,t){const{app:n,ep:i}=Hr(e),r=await Dt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},i);if(!r.ok){const a=`创建会话失败 (${r.status})`,o=await an(r,"创建会话失败");throw new Error(o===a?a:`${a}:${o}`)}return(await r.json()).id}async function qD(e,t){const{app:n,ep:i}=Hr(e),r=await Dt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{},i);if(!r.ok)throw new Error(`list sessions failed: ${r.status}`);return r.json()}async function gk(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(`/apps/${i}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}`,{},r);if(!s.ok){const o=await an(s,"读取会话失败");throw new Error(`get session failed: ${s.status}:${o}`)}const a=await s.json();if(r.runtimeId){const o=zD(r.runtimeId,i,t,n);a.state={...FD()[o]??{},...a.state??{}}}return a}async function MJ(e){const{app:t,ep:n}=Hr(e.appName);if(!n.runtimeId)throw new Error("只有连接到 AgentKit Runtime 的会话支持反馈回流");if(!n.region)throw new Error("Runtime 缺少地域信息,无法提交反馈");const i=await Dt("/web/evaluation/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:n.runtimeId,region:n.region,appName:t,userId:e.userId,sessionId:e.sessionId,eventId:e.eventId,rating:e.rating,comment:e.comment??""})},{},kr);if(!i.ok)throw new Error(await an(i,"提交反馈失败"));const r=await i.json(),s=zD(n.runtimeId,t,e.userId,e.sessionId);return sEe(s,e.eventId,r),r}async function w_(e,t={}){const n=F0(e.runtimeId,e.region||"cn-beijing",e.appName,e.pageSize??100),i=V0(_l,n,NJ);if(!t.force&&i)return i;const r=_l.get(n);if(!t.force&&(r!=null&&r.promise))return r.promise;let s=null;const a=(async()=>{for(const o of Jf(e.region)){const c=new URLSearchParams({runtimeId:e.runtimeId,region:o,appName:e.appName,page_size:String(e.pageSize??100)}),u=await Dt(`/web/evaluation/feedback-cases?${c.toString()}`);if(u.ok)return XD(_l,n,await u.json());s=new Error(await an(u,"读取评测集失败"))}throw s??new Error("读取评测集失败")})();_l.set(n,{...r,promise:a,updatedAt:(r==null?void 0:r.updatedAt)??0});try{return await a}finally{const o=_l.get(n);(o==null?void 0:o.promise)===a&&_l.set(n,{value:o.value,updatedAt:o.updatedAt})}}async function LJ(e){let t=null;for(const n of Jf(e.region)){const i=new URLSearchParams({runtimeId:e.runtimeId,region:n,appName:e.appName,userId:e.userId}),r=await Dt(`/web/evaluation/statuses?${i.toString()}`);if(r.ok)return r.json();t=new Error(await an(r,"读取自动评测状态失败"))}throw t??new Error("读取自动评测状态失败")}async function DJ(e){let t=null;for(const n of Jf(e.region)){const i=new URLSearchParams({runtimeId:e.runtimeId,region:n,appName:e.appName}),r=await Dt(`/web/evaluation/optimizations?${i.toString()}`);if(r.ok)return r.json();t=new Error(await an(r,"读取优化项失败"))}throw t??new Error("读取优化项失败")}function $J(e){return V0(_l,F0(e.runtimeId,e.region||"cn-beijing",e.appName,e.pageSize??100),NJ)}function nP(e){w_(e).catch(()=>{})}function QJ(e){w_(e,{force:!0}).catch(()=>{})}function BJ(e,t){return["good","bad"].map(n=>{const i=e.find(r=>r.kind===n);return{kind:n,evaluationSetId:(i==null?void 0:i.evaluationSetId)??null,evaluationSetName:(i==null?void 0:i.evaluationSetName)??null,workspaceId:(i==null?void 0:i.workspaceId)??null,itemCount:t.filter(r=>r.kind===n).length}})}function US(e){const t=e.comment??"",n=e.rating==="bad"&&!!t.trim();for(const[i,r]of _l.entries()){const s=r.value;if(!s||s.runtimeId!==e.runtimeId||s.agentName!==e.appName)continue;const a=s.items.filter(c=>c.sessionId!==e.sessionId||c.messageId!==e.messageId),o=e.rating?[{id:`local:${e.runtimeId}:${e.sessionId}:${e.messageId}`,itemKey:`local:${e.messageId}`,kind:e.rating,input:e.input,output:e.output,referenceOutput:e.referenceOutput??e.output,comment:t,agentName:e.appName,sessionId:e.sessionId,messageId:e.messageId,runtimeId:e.runtimeId,invocationId:e.invocationId??"",userId:e.userId,createdAt:e.createdAt??new Date().toISOString(),evaluationSetId:"",evaluationSetName:"",workspaceId:"",source:"user",score:n?0:null,reason:n?t:""},...a]:a;_l.set(i,{value:{...s,sets:BJ(s.sets,o),items:o},updatedAt:Date.now(),promise:r.promise})}}async function UJ(e){let t=null;for(const n of Jf(e.region)){const i=await Dt("/web/evaluation/feedback-cases/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e.runtimeId,region:n,appName:e.appName,itemIds:e.itemIds})},{},kr);if(i.ok){const r=await i.json(),s=new Set(e.itemIds);for(const[a,o]of _l.entries()){const c=o.value;if(!c||c.runtimeId!==e.runtimeId||c.agentName!==e.appName)continue;const u=c.items.filter(d=>!s.has(d.id));_l.set(a,{value:{...c,sets:BJ(c.sets,u),items:u},updatedAt:Date.now()})}return r}t=new Error(await an(i,"删除评测案例失败"))}throw t??new Error("删除评测案例失败")}async function iP(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(`/apps/${i}/users/${encodeURIComponent(t)}/sessions/${n}`,{method:"DELETE"},r);if(!s.ok&&s.status!==404)throw new Error(`delete session failed: ${s.status}`)}function lEe(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"="),i=window.atob(n),r=new Uint8Array(i.length);for(let s=0;sURL.revokeObjectURL(o),0)}async function zJ(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=r==null?"":`?version=${encodeURIComponent(r)}`,c=`/apps/${encodeURIComponent(s)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(i)}${o}`,u=await Dt(c,{},a,kr);if(!u.ok)throw new Error(await an(u,"下载文件失败"));const d=await u.json(),f=d.inlineData??d.inline_data;if(!(f!=null&&f.data))throw new Error("文件内容不可用");const h=lEe(f.data),p=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);return{blob:new Blob([p],{type:f.mimeType??f.mime_type??"application/octet-stream"}),downloadName:f.displayName??f.display_name??i}}async function YD(e,t,n,i,r){const{blob:s}=await zJ(e,t,n,i,r);return URL.createObjectURL(s)}async function cEe(e){const t=await Dt("/web/media/capabilities");if(!t.ok)throw new Error(await an(t,"media capabilities failed"));return t.json()}async function FJ(e,t,n,i){const{app:r}=Hr(e),s=new FormData;s.set("app_name",r),s.set("user_id",t),s.set("session_id",n),s.set("file",i);const a=await Dt("/web/media",{method:"POST",body:s},{},kr);if(!a.ok)throw new Error(await an(a,"文件上传失败"));return{...await a.json(),status:"ready"}}async function rP(e,t,n){const{app:i}=Hr(e),r=`/web/media/${encodeURIComponent(i)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/delete`,s=await Dt(r,{method:"POST"});if(!s.ok&&s.status!==404)throw new Error(await an(s,"media cleanup failed"))}function VJ(e){try{const t=new URL(e);if(t.protocol!=="veadk-media:"||t.hostname!=="apps")return;const n=t.pathname.split("/").filter(Boolean).map(decodeURIComponent);return n.length!==7||n[1]!=="users"||n[3]!=="sessions"||n[5]!=="media"?void 0:`/web/media/${n.map(encodeURIComponent).filter((i,r)=>![1,3,5].includes(r)).join("/")}`}catch{return}}async function zS(e,t){const n=VJ(t);if(!n)throw new Error("Invalid VeADK media URI");const i=await Dt(`${n}/delete`,{method:"POST"});if(!i.ok&&i.status!==404)throw new Error(await an(i,"media cleanup failed"))}function XJ(e,t){if(t.startsWith("data:")||t.startsWith("blob:")||/^https?:/.test(t))return t;const n=VJ(t);if(!n)return t;const i=`${n}/content`;return vo(`${QS}${i}`)}async function bk(e,t,n){const{app:i,ep:r}=Hr(e);let s;if(r.runtimeId){const c=new URLSearchParams({runtimeId:r.runtimeId,sessionId:t,region:r.region??"cn-beijing"});if(n&&c.set("endTimeMs",String(Math.round(n))),s=await Dt(`/web/runtime-trace?${c.toString()}`),s.status===404)throw new Error("该 Agent 暂未开启链路观测,请到控制台打开后使用。")}else s=await Dt(`/dev/apps/${encodeURIComponent(i)}/debug/trace/session/${encodeURIComponent(t)}`,{},r);if(!s.ok)throw new Error(await an(s,"加载调用链路失败"));const a=s.headers.get("content-type")??"";if(!a.includes("application/json")){const c=a.split(";",1)[0]||"Content-Type 缺失";throw new Error(`trace failed: 服务端返回了非 JSON 响应(${c}),请检查 Studio API 代理配置`)}const o=await s.json();if(!Array.isArray(o))throw new Error("trace failed: 返回格式无效");return o}async function sP(e){const t=await Dt("/web/issue-feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await an(t,"问题反馈上报失败"));if((await t.json()).submitted!==!0)throw new Error("问题反馈上报失败:服务端未确认提交结果");return{submitted:!0}}function GD(e){const t=n=>({id:String(n.id??""),kind:n.kind==="skill"?"skill":"tool",name:String(n.name??""),custom:n.custom===!0,description:typeof n.description=="string"?n.description:void 0,skillSourceId:typeof n.skill_source_id=="string"?n.skill_source_id:void 0,version:typeof n.version=="string"?n.version:void 0});return{schemaVersion:Number(e.schema_version??1),revision:Number(e.revision??0),tools:Array.isArray(e.tools)?e.tools.map(n=>t(n)):[],skills:Array.isArray(e.skills)?e.skills.map(n=>t(n)):[]}}function WD(e,t,n){return`/harness/apps/${encodeURIComponent(e)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/capabilities`}async function aP(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(WD(i,t,n),{},r);if(!s.ok)throw new Error(await an(s,"读取会话能力失败"));return GD(await s.json())}async function ZD(e){const{ep:t}=Hr(e),n=await Dt("/harness/capabilities/tools",{},t);if(!n.ok)throw new Error(await an(n,"读取内置工具失败"));return((await n.json()).tools??[]).map(r=>{var s;return((s=r.name)==null?void 0:s.trim())??""}).filter(Boolean)}async function uEe(e){const{ep:t}=Hr(e),n=await Dt("/harness/skills/spaces?region=all",{},t);if(!n.ok)throw new Error(await an(n,"读取 Skill Space 失败"));return(await n.json()).items??[]}async function dEe(e,t,n){const{ep:i}=Hr(e),r=new URLSearchParams({region:n||"cn-beijing"}),s=`/harness/skills/spaces/${encodeURIComponent(t)}/skills?${r.toString()}`,a=await Dt(s,{},i);if(!a.ok)throw new Error(await an(a,"读取 Skill 列表失败"));return(await a.json()).items??[]}async function qJ(e,t,n=1,i=20){const{ep:r}=Hr(e),s=new URLSearchParams({query:t,page_number:String(n),page_size:String(i)}),a=await Dt(`/harness/skills/findskill?${s.toString()}`,{},r);if(!a.ok)throw new Error(await an(a,"搜索 Skill Hub 失败"));const o=await a.json();return{items:o.items??[],totalCount:Number(o.totalCount??0)}}async function oP(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=await Dt(WD(s,t,n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:i.kind,name:i.name,skill_source_id:i.skillSourceId,description:i.description,version:i.version,expected_revision:r})},a);if(!o.ok)throw new Error(await an(o,"添加会话能力失败"));return GD(await o.json())}async function HJ(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=`${WD(s,t,n)}/${encodeURIComponent(i)}?expected_revision=${r}`,c=await Dt(o,{method:"DELETE"},a);if(!c.ok)throw new Error(await an(c,"移除会话能力失败"));return GD(await c.json())}async function YJ(e,t,n=!0){const i=await Dt(`/web/agent-info/${e}`,{},t);if(!i.ok)throw new Error(`agent-info failed: ${i.status}`);const r=await i.json();if(n&&!r.draft)try{const s=await Dt(`/web/agent-draft/${e}`,{},t);if(s.ok){const a=await s.json();r.draft=a.draft}}catch{}return{appName:e,name:r.name??e,description:r.description??"",type:r.type,model:r.model??"",tools:r.tools??[],skillsPreviewSupported:Array.isArray(r.skills),skills:r.skills??[],subAgents:r.subAgents??[],components:r.components??[],searchSources:r.searchSources??[],graph:r.graph,draft:r.draft}}async function GJ(e){const{app:t,ep:n}=Hr(e);return YJ(t,n,!1)}async function fEe(e,t,n){let i=null;for(const r of Jf(t)){const s={runtimeId:e,region:r};try{const a=jJ(e,r),o=BS.get(a);o&&o.expiresAt<=Date.now()&&BS.delete(a);const c=BS.get(a),u=n||(c==null?void 0:c.apps[0])||(await v_("","",s))[0];if(!u)throw new Error("该 Runtime 未提供可预览的 Agent。");return YJ(u,s)}catch(a){if(a instanceof z0||a instanceof ga&&!a.unsupported)throw a;i=a instanceof Error?a:new Error(String(a))}}throw i??new Error("该 Runtime 未提供可预览的 Agent。")}async function Ok(e,t,n={},i={}){const r=typeof n=="string"?n:void 0,s=typeof n=="string"?i:n,a=F0(e,t||"cn-beijing",r??""),o=V0(Th,a,x_);if(!s.force&&o)return o;const c=Th.get(a);if(!s.force&&(c!=null&&c.promise))return c.promise;const u=fEe(e,t,r).then(d=>XD(Th,a,d));Th.set(a,{...c,promise:u,updatedAt:(c==null?void 0:c.updatedAt)??0});try{return await u}finally{const d=Th.get(a);(d==null?void 0:d.promise)===u&&Th.set(a,{value:d.value,updatedAt:d.updatedAt})}}function WJ(e,t,n=""){return V0(Th,F0(e,t||"cn-beijing",n),x_)}function ZJ(e,t,n=""){Ok(e,t,n).catch(()=>{})}async function KJ(e,t,n,i){const{app:r,ep:s}=Hr(e),a=new URLSearchParams({source:t,app_name:r,q:n,user_id:i}),o=await Dt(`/web/search?${a.toString()}`,{},s);if(!o.ok)throw new Error(await an(o,"Agent 检索失败"));return o.json()}async function JJ(e,t){const{app:n}=Hr(e),i=await Dt(`/web/search?source=web&app_name=${encodeURIComponent(n)}&q=${encodeURIComponent(t)}`);if(!i.ok)throw new Error(`web search failed: ${i.status}`);return i.json()}async function*lP({appName:e,userId:t,sessionId:n,text:i,attachments:r=[],invocation:s,functionResponses:a=[],signal:o,sessionCapabilities:c=!1}){const{app:u,ep:d}=Hr(e),f=r.flatMap(b=>b.status&&b.status!=="ready"?[]:b.uri?[{fileData:{mimeType:b.mimeType,fileUri:b.uri,displayName:b.name},partMetadata:{veadkMedia:{id:b.id,uri:b.uri,name:b.name,mimeType:b.mimeType,sizeBytes:b.sizeBytes}}}]:b.data?[{inlineData:{mimeType:b.mimeType,data:b.data,displayName:b.name}}]:[]),h=s&&(s.skills.length>0||s.targetAgent)?s:void 0,p=[...f,...a.map(b=>({functionResponse:{id:b.id,name:b.name,response:b.response}})),...i.trim()?[{text:i}]:[]];if(h&&p.length>0){const b=p[0],y=b.partMetadata;p[0]={...b,partMetadata:{...y,veadkInvocation:h}}}const g=await Dt(c?"/harness/run_sse":"/run_sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:u,user_id:t,session_id:n,new_message:{role:"user",parts:p},streaming:!0,custom_metadata:h?{veadkInvocation:h}:void 0}),signal:o},d,0);if(!g.ok){const b=await an(g,"运行会话失败");throw new Error(iw(`run_sse failed: ${g.status}:${b}`))}for await(const b of $D(g)){const y=b;typeof y.error=="string"&&(y.error=iw(y.error)),typeof y.errorMessage=="string"&&(y.errorMessage=iw(y.errorMessage)),typeof y.error_message=="string"&&(y.error_message=iw(y.error_message)),yield y}}async function eee(e,t){const n=new URLSearchParams({name:e,region:t}),i=await Dt(`/web/runtime-name-availability?${n.toString()}`,{cache:"no-store"});if(!i.ok)throw new Error(await an(i,"检查 Runtime 名称失败"));const r=await i.json();if(typeof r.available!="boolean")throw new Error("检查 Runtime 名称失败:服务返回格式错误");return{available:r.available}}async function tee(e,t){const n=new URLSearchParams({kind:e.kind,region:e.region});e.registry&&n.set("registry",e.registry),e.namespace&&n.set("namespace",e.namespace),e.workspaceId&&n.set("workspaceId",e.workspaceId),e.search&&n.set("search",e.search),e.pageNumber&&n.set("pageNumber",String(e.pageNumber)),e.pageSize&&n.set("pageSize",String(e.pageSize));const i=await Dt(`/web/deployment-resources?${n.toString()}`,{signal:t});if(!i.ok)throw new Error(await an(i,"加载云资源失败"));const r=await i.json();if(typeof r.serviceRegion!="string"||!Array.isArray(r.items)||typeof r.pageNumber!="number"||typeof r.pageSize!="number"||typeof r.totalCount!="number"||typeof r.hasMore!="boolean")throw new Error("云资源列表响应格式无效");const s=r.items.map(a=>{if(!a||typeof a!="object"||typeof a.id!="string"||typeof a.name!="string"||typeof a.region!="string"||typeof a.status!="string")throw new Error("云资源列表响应格式无效");return a});return{serviceRegion:r.serviceRegion,items:s,pageNumber:r.pageNumber,pageSize:r.pageSize,totalCount:r.totalCount,hasMore:r.hasMore}}async function nee(e){var r;const t=await Dt("/web/system-info",{signal:e});if(!t.ok)throw new Error(await an(t,"加载系统信息失败"));const n=await t.json();if(typeof((r=n.storage)==null?void 0:r.tosAddress)!="string"||!Array.isArray(n.sandboxTools))throw new Error("系统信息响应格式无效");const i=n.sandboxTools.map(s=>{if(!s||typeof s!="object"||typeof s.kind!="string"||typeof s.label!="string"||typeof s.toolId!="string"||typeof s.snapshot!="boolean")throw new Error("系统信息响应格式无效");return s});return{storage:{tosAddress:n.storage.tosAddress},sandboxTools:i}}async function KD(e){const t=await Dt("/web/identity/user-pools",{signal:e});if(!t.ok)throw new Error(await an(t,"加载用户池失败"));const n=await t.json();if(!Array.isArray(n.items))throw new Error("用户池列表响应格式无效");return n.items.map(i=>{if(!i||typeof i!="object"||typeof i.uid!="string"||typeof i.name!="string"||typeof i.domain!="string"||typeof i.region!="string"||typeof i.isCurrent!="boolean")throw new Error("用户池列表响应格式无效");return i})}const ly=new Map;async function w1(e,t,n,i){var f,h,p,g,b;const r=i==null?void 0:i.taskId,s=r?new AbortController:void 0;r&&s&&ly.set(r,s);const a=()=>{r&&ly.get(r)===s&&ly.delete(r)};let o;try{const y=!!(i!=null&&i.migrationTaskId);(f=i==null?void 0:i.onStage)==null||f.call(i,{level:"info",phase:"upload",message:y?"正在校验迁移产物":"正在上传代码包",pct:0}),o=await Dt("/web/deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},signal:s==null?void 0:s.signal,body:JSON.stringify({name:e,files:y?[]:t,config:n,taskId:r,migrationTaskId:i==null?void 0:i.migrationTaskId,runtimeId:i==null?void 0:i.runtimeId,runtimeName:i==null?void 0:i.runtimeName,appName:i==null?void 0:i.appName,sessionStorage:i==null?void 0:i.sessionStorage,minInstance:i==null?void 0:i.minInstance,maxInstance:i==null?void 0:i.maxInstance,createEvaluationSets:i==null?void 0:i.createEvaluationSets,description:MSe((i==null?void 0:i.description)??""),authentication:i==null?void 0:i.authentication,im:i==null?void 0:i.im,envs:i==null?void 0:i.envs,resources:i==null?void 0:i.resources})},{},0),(h=i==null?void 0:i.onStage)==null||h.call(i,{level:"success",phase:"upload",message:y?"迁移产物校验完成":"代码包上传完成",pct:100})}catch(y){throw a(),y}if(!o.ok){const y=await an(o,"部署失败");throw a(),new Error(y)}let c=null;try{for await(const y of $D(o)){const O=y;if(O&&O.done){c=O;break}O&&O.message&&((p=i==null?void 0:i.onStage)==null||p.call(i,O))}}catch(y){throw a(),y}if(a(),!c)throw new Error("部署失败:连接中断");if(!c.success)throw new Error(c.error||"部署失败");if(!c.agentName)throw new Error("部署失败:返回缺少 Agent 名称");if(!c.runtimeId&&!c.url)throw new Error("部署失败:返回缺少 AgentKit 连接信息");const u=(g=c.runtimeName)!=null&&g.trim()?c.agentName:e,d=((b=c.runtimeName)==null?void 0:b.trim())||c.agentName;return{apikey:c.apikey??"",url:c.url??"",agentName:u,runtimeName:d,runtimeId:c.runtimeId,consoleUrl:c.consoleUrl,region:c.region,version:c.version,warnings:c.warnings,feishuChannel:c.feishuChannel}}async function iee(e){var n;const t=await Dt("/web/cancel-deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e})});if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`取消部署失败 (${t.status})`)}(n=ly.get(e))==null||n.abort(),ly.delete(e)}async function hEe(e=QD){const t=await Dt(`/web/my-runtimes?region=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`加载失败 (${t.status})`);return(await t.json()).runtimes??[]}const nx={title:"AgentKit Studio",logoUrl:""},cP={enabled:!1},B2={studio:!1,version:"",provider:"volcengine",branding:nx,features:{newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,agentUsage:!1,addAgentkit:!0,generatedAgentTestRun:!0},defaultView:"chat",agentsSource:"local",telemetry:cP};function pEe(e){if(!e||typeof e!="object")return cP;const t=e;if(t.enabled!==!0||!t.studio||typeof t.studio!="object")return cP;const n=t.studio;return{enabled:!0,studio:{deployId:typeof n.deployId=="string"?n.deployId:"",userPoolId:typeof n.userPoolId=="string"?n.userPoolId:"",applicationId:typeof n.applicationId=="string"?n.applicationId:"",functionId:typeof n.functionId=="string"?n.functionId:"",region:typeof n.region=="string"?n.region:"",project:typeof n.project=="string"?n.project:"",version:typeof n.version=="string"?n.version:"",accountId:typeof n.accountId=="string"?n.accountId:""}}}async function ree(){var e,t;try{const n=await Dt("/web/ui-config");if(!n.ok)return B2;const i=await n.json(),r=typeof((e=i.branding)==null?void 0:e.logoUrl)=="string"?i.branding.logoUrl:nx.logoUrl,s=i.provider==="byteplus"?"byteplus":"volcengine";return RJ(s),{studio:i.studio??!1,version:typeof i.version=="string"?i.version:"",provider:s,branding:{title:typeof((t=i.branding)==null?void 0:t.title)=="string"?i.branding.title:nx.title,logoUrl:r?vo(r):""},features:{...B2.features,...i.features??{}},defaultView:i.defaultView??"chat",agentsSource:i.agentsSource==="cloud"?"cloud":"local",telemetry:pEe(i.telemetry)}}catch{return B2}}const see={role:"user",telemetry:{userId:"",accountId:""},capabilities:{createAgents:!1,manageAgents:!1,runtimeScope:"mine"}};async function aee(){var n,i,r,s;const e=await Dt("/web/access");if(!e.ok)throw new Error(`加载权限失败 (${e.status})`);const t=await e.json();if(!["admin","developer","user"].includes(t.role)||typeof((n=t.telemetry)==null?void 0:n.userId)!="string"||t.telemetry.accountId!==void 0&&typeof t.telemetry.accountId!="string"||typeof((i=t.capabilities)==null?void 0:i.createAgents)!="boolean"||typeof((r=t.capabilities)==null?void 0:r.manageAgents)!="boolean"||!["all","mine"].includes((s=t.capabilities)==null?void 0:s.runtimeScope))throw new Error("权限服务返回了无法解析的响应");return t}async function oee(e,t){const n=new URLSearchParams;e&&n.set("targetVersion",e),t&&n.set("startedAt",String(t));const i=n.size?`?${n.toString()}`:"",r=await Dt(`/web/studio-update${i}`);if(!r.ok)throw new Error(`检查 Studio 更新失败 (${r.status})`);return await r.json()}async function lee(e){const t=await Dt("/web/studio-update",{method:"POST",headers:{"Content-Type":"application/json","X-VeADK-Studio-Update":"1"},body:JSON.stringify({version:e})},{},kr);if(!t.ok){let n="";try{const i=await t.json();n=typeof i.detail=="string"?i.detail:""}catch{n=""}throw new Error(n||`提交 Studio 更新失败 (${t.status})`)}return await t.json()}async function cee({runtimeId:e,region:t,appName:n,page:i=1,pageSize:r=20,signal:s}){const a=new URLSearchParams({runtimeId:e,region:t,appName:n,page:String(i),pageSize:String(r)}),o=await Dt(`/web/agent-usage?${a.toString()}`,{signal:s});if(!o.ok)throw new Error(await an(o,"加载 Agent 用量失败"));const c=o.headers.get("content-type")||"未提供",u=c.toLowerCase();if(!u.includes("application/json")&&!u.includes("+json"))throw new Error(`加载 Agent 用量失败:服务端返回非 JSON 响应(HTTP ${o.status},Content-Type: ${c})。请确认当前服务以 Studio 模式启动,并检查代理或网关配置。`);try{return await o.json()}catch{throw new Error(`加载 Agent 用量失败:服务端返回了无法解析的 JSON(HTTP ${o.status},Content-Type: ${c})。请稍后重试;若问题持续,请检查代理或网关配置。`)}}async function S_(e={}){const t=new URLSearchParams({scope:e.scope??"all",page_size:String(e.pageSize??30),region:e.region??"all"});e.nextToken&&t.set("next_token",e.nextToken);const n=await Dt(`/web/runtimes?${t.toString()}`);if(!n.ok){const r=await an(n,"加载 Runtime 失败");throw new Error(r)}const i=await n.json();return{runtimes:i.runtimes??[],nextToken:i.nextToken??""}}async function JD(e,t,n={}){try{const i={runtimeId:e,region:t};return n.retryProbe&&(i.retryProbe=!0),await v_("","",i)}catch(i){if(i instanceof z0||i instanceof ga)throw i;return null}}async function uee(e,t,n={}){const i={runtimeId:e,region:t};n.retryProbe&&(i.retryProbe=!0);const r=await Dt("/.well-known/agent-card.json",{},i),s=await IJ(r);if(s==="runtime_access_denied")throw new z0;if(s==="runtime_private_endpoint_unreachable")throw new ga(_J);if(["runtime_proxy_connect_error","runtime_proxy_timeout"].includes(s))throw new ga(AJ);if(r.status===404)return null;if(r.status===401||r.status===403)throw new ga("Runtime 服务拒绝了 A2A 探测请求,请检查 Runtime 的鉴权配置。");if(!r.ok)throw new Error(await an(r,"读取 A2A Agent Card 失败"));const a=await r.json().catch(()=>null),o=typeof(a==null?void 0:a.url)=="string"?a.url.trim():"";return o?{name:typeof(a==null?void 0:a.name)=="string"?a.name:"",description:typeof(a==null?void 0:a.description)=="string"?a.description:"",endpoint:o}:null}async function dee(e,t){const n=new URLSearchParams({runtimeId:e,region:t}),i=await Dt(`/web/runtime-api-key/reveal?${n.toString()}`,{method:"POST",cache:"no-store"});if(!i.ok)throw new Error(await an(i,"读取 Runtime API Key 失败"));const r=await i.json();if(typeof r.apiKey!="string"||!r.apiKey)throw new Error("Runtime 未返回可用的 API Key");return r.apiKey}async function fee(e,t){const n=await Dt("/web/delete-runtime",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e,region:t})});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(i||`删除失败 (${n.status})`)}}async function hee({runtimeId:e,region:t,appName:n,signal:i}){const r=new URLSearchParams({runtimeId:e,region:t});n&&r.set("appName",n);const s=await Dt(`/web/runtime-update-capability?${r.toString()}`,{signal:i});if(!s.ok)throw new Error(await mEe(s));return await s.json()}async function mEe(e){const t=await e.json().catch(()=>null),n=typeof(t==null?void 0:t.detail)=="string"?t.detail:"";return e.status===403?"当前账号没有管理该 Runtime 的权限。":e.status===404?n==="runtime_not_found"?"该 Runtime 不存在或已被删除。":"当前账号无法访问该 Runtime。":`检查 Runtime 更新能力失败(HTTP ${e.status}),请稍后重试。`}async function gEe(e,t){let n=null;for(const i of Jf(t)){const r=await Dt(`/web/runtime-detail?runtimeId=${encodeURIComponent(e)}®ion=${encodeURIComponent(i)}`);if(r.ok)return r.json();n=new Error(await an(r,"加载 Runtime 详情失败"))}throw n??new Error("加载 Runtime 详情失败")}async function e$(e,t="cn-beijing",n={}){const i=F0(e,t||"cn-beijing"),r=V0(_h,i,x_);if(!n.force&&r)return r;const s=_h.get(i);if(!n.force&&(s!=null&&s.promise))return s.promise;const a=gEe(e,t).then(o=>XD(_h,i,o));_h.set(i,{...s,promise:a,updatedAt:(s==null?void 0:s.updatedAt)??0});try{return await a}finally{const o=_h.get(i);(o==null?void 0:o.promise)===a&&_h.set(i,{value:o.value,updatedAt:o.updatedAt})}}function pee(e,t="cn-beijing"){return V0(_h,F0(e,t||"cn-beijing"),x_)}function mee(e,t="cn-beijing"){e$(e,t).catch(()=>{})}async function t$(e){const t=await Dt("/web/generated-agent-projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await an(t,"生成项目失败"));return t.json()}const bEe=19e4;async function gee(e){const t=await Dt("/web/generated-agent-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requirement:e})},{},bEe);if(!t.ok)throw new Error(await an(t,"生成 Agent 配置失败"));return y_(t,"生成 Agent 配置失败")}async function bee(e,t){const n=await Dt("/web/generated-agent-test-runs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,runtimeId:t==null?void 0:t.runtimeId,runtimeRegion:t==null?void 0:t.region})});if(!n.ok)throw new Error(await an(n,"创建调试运行失败"));return y_(n,"创建调试运行失败")}async function Oee(e,t){const n=await Dt(`/web/generated-agent-test-runs/${e}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t})});if(!n.ok)throw new Error(await an(n,"创建调试会话失败"));return(await y_(n,"创建调试会话失败")).id}async function yee(e,t){const n=await Dt(`/web/generated-agent-test-runs/${encodeURIComponent(e)}/trace/session/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(await an(n,"加载调试调用链路失败"));const i=await y_(n,"加载调试调用链路失败");if(!Array.isArray(i))throw new Error("加载调试调用链路失败:返回格式无效");return i}async function*xee({runId:e,userId:t,sessionId:n,text:i,signal:r}){const s=i.trim()?[{text:i}]:[],a=await Dt(`/web/generated-agent-test-runs/${e}/run_sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:t,session_id:n,new_message:{role:"user",parts:s},streaming:!0}),signal:r},{},0);if(!a.ok)throw new Error(await an(a,"调试运行失败"));for await(const o of $D(a))yield o}async function Tm(e){const t=await Dt(`/web/generated-agent-test-runs/${e}`,{method:"DELETE"});if(!t.ok&&t.status!==404)throw new Error(await an(t,"清理调试运行失败"))}const OEe=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SITE_BRANDING:nx,DEFAULT_STUDIO_ACCESS:see,RuntimeAccessDeniedError:z0,RuntimeProbeError:ga,addSessionCapability:oP,cancelAgentkitDeployment:iee,checkRuntimeNameAvailability:eee,clearMessageFeedbackCache:xJ,clearRemoteApps:wJ,componentSearch:KJ,createGeneratedAgentTestRun:bee,createGeneratedAgentTestSession:Oee,createSession:PJ,deleteAgentFeedbackCases:UJ,deleteGeneratedAgentTestRun:Tm,deleteMedia:zS,deleteRuntime:fee,deleteSession:iP,deleteSessionMedia:rP,deployAgentkitProject:w1,downloadArtifact:HD,fetchRemoteApps:v_,generateAgentDraftFromRequirement:gee,generateAgentProject:t$,getAgentFeedbackCases:w_,getAgentInfo:GJ,getAgentOptimizations:DJ,getAgentUsage:cee,getAutomaticEvaluationStatuses:LJ,getCachedAgentFeedbackCases:$J,getCachedRuntimeAgentInfo:WJ,getCachedRuntimeDetail:pee,getGeneratedAgentTestTrace:yee,getMediaCapabilities:cEe,getMyRuntimes:hEe,getRuntimeAgentInfo:Ok,getRuntimeDetail:e$,getRuntimeUpdateCapability:hee,getRuntimes:S_,getSession:gk,getSessionCapabilities:aP,getSessionTrace:bk,getStudioAccess:aee,getStudioUpdateStatus:oee,getSystemInfo:nee,getUiConfig:ree,listApps:TJ,listDeploymentResources:tee,listIdentityUserPools:KD,listModelApiKeys:SJ,listModelOptions:kJ,listSessionBuiltinTools:ZD,listSessionSkillSpaces:uEe,listSessionSkillsInSpace:dEe,listSessions:qD,mediaContentUrl:XJ,prefetchAgentFeedbackCases:nP,prefetchRuntimeAgentInfo:ZJ,prefetchRuntimeDetail:mee,previewArtifact:YD,probeRuntimeA2a:uee,probeRuntimeApps:JD,refreshAgentFeedbackCases:QJ,registerRemoteApp:vJ,removeSessionCapability:HJ,revealModelApiKey:EJ,revealRuntimeApiKey:dee,runGeneratedAgentTestSSE:xee,runSSE:lP,runtimeRegionCandidates:Jf,searchSessionPublicSkills:qJ,setClientCloudProvider:RJ,startStudioUpdate:lee,studioFetch:ri,submitIssueFeedback:sP,submitMessageFeedback:MJ,uploadMedia:FJ,upsertCachedAgentFeedbackCase:US,webSearch:JJ},Symbol.toStringTag,{value:"Module"})),f9=Object.freeze({totalTokenCount:0,promptTokenCount:0,candidatesTokenCount:0,thoughtsTokenCount:0,cachedContentTokenCount:0}),FS=Object.freeze({modelName:"",current:f9,cumulative:f9}),yEe={totalTokenCount:"total_token_count",promptTokenCount:"prompt_token_count",candidatesTokenCount:"candidates_token_count",thoughtsTokenCount:"thoughts_token_count",cachedContentTokenCount:"cached_content_token_count"},xEe=24,vEe=64,wEe=16;function rw(e){var o,c;const t=e.trim();if(!t)return 0;const n=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu,i=((o=t.match(n))==null?void 0:o.length)??0,r=t.replace(n," "),s=(r.match(/[A-Za-z0-9_]+/g)??[]).reduce((u,d)=>u+Math.max(1,Math.ceil(d.length/4)),0),a=((c=r.match(/[^\sA-Za-z0-9_]/g))==null?void 0:c.length)??0;return i+s+a}function SEe(e){var o,c,u;const t=((o=e.instruction)==null?void 0:o.trim())??"",n=((c=e.tools)==null?void 0:c.filter(d=>d.trim()))??[],i=((u=e.skills)==null?void 0:u.filter(d=>d.name.trim()))??[],r=rw(t),s=n.reduce((d,f)=>d+vEe+rw(f),0),a=i.reduce((d,f)=>d+wEe+rw(f.name)+rw(f.description??""),0);return xEe+r+s+a}function EEe({usage:e,contextWindow:t,estimatedSystemTokens:n}){const i=Math.max(1,Math.round(t)),r=Math.max(0,e.current.promptTokenCount),s=Math.max(r,e.current.totalTokenCount),a=Math.min(i,r>0?Math.min(r,Math.max(0,n??0)):Math.max(0,n??0)),o=Math.max(0,r-a),c=r>0?Math.max(0,s-r):Math.max(0,s),u=r>0?s:a+c;return{systemTokens:a,inputTokens:o,outputTokens:c,remainingTokens:Math.max(0,i-u),usedTokens:u,contextWindow:i}}function kEe(e){const t=[{kind:"system",tokens:e.systemTokens},{kind:"input",tokens:e.inputTokens},{kind:"output",tokens:e.outputTokens},{kind:"remaining",tokens:e.remainingTokens}],n=e.contextWindow/100;let i=0;const r=t.map(s=>{const a=i;return i+=s.tokens,{...s,start:a,end:i}});return Array.from({length:100},(s,a)=>{const o=a*n,c=o+n,u=r.flatMap(d=>{const f=Math.max(0,Math.min(c,d.end)-Math.max(o,d.start));return f>0?[{kind:d.kind,share:f/n}]:[]});return{index:a,slices:u}})}function qb(e,t){const n=e,i=n[t]??n[yEe[t]];return typeof i=="number"&&Number.isFinite(i)&&i>0?Math.round(i):0}function TEe(e){const t=qb(e,"promptTokenCount"),n=qb(e,"candidatesTokenCount"),i=qb(e,"thoughtsTokenCount");return{totalTokenCount:qb(e,"totalTokenCount")||t+n+i,promptTokenCount:t,candidatesTokenCount:n,thoughtsTokenCount:i,cachedContentTokenCount:qb(e,"cachedContentTokenCount")}}function _Ee(e,t){return{totalTokenCount:e.totalTokenCount+t.totalTokenCount,promptTokenCount:e.promptTokenCount+t.promptTokenCount,candidatesTokenCount:e.candidatesTokenCount+t.candidatesTokenCount,thoughtsTokenCount:e.thoughtsTokenCount+t.thoughtsTokenCount,cachedContentTokenCount:e.cachedContentTokenCount+t.cachedContentTokenCount}}function vee(e,t){if(!t)return e;const n=typeof t.modelVersion=="string"?t.modelVersion.trim():"",i=typeof t.model_version=="string"?t.model_version.trim():"",r=n||i||e.modelName,s=t.usageMetadata??t.usage_metadata;if(!s)return r===e.modelName?e:{...e,modelName:r};const a=TEe(s);return a.totalTokenCount===0?r===e.modelName?e:{...e,modelName:r}:{modelName:r,current:a,cumulative:_Ee(e.cumulative,a)}}function h9(e){return e.reduce((t,n)=>vee(t,n),FS)}function p9(e){return e.blocks.flatMap(t=>t.kind==="tool"?[{name:t.name,args:t.args,response:t.response,done:t.done}]:[])}function AEe(e){const t=e.attributes;return String(t["invocation.id"]??t["gen_ai.invocation.id"]??t["gcp.vertex.agent.invocation_id"]??"")}function NEe(e,t){if(!t)return e;const n=new Set(e.filter(r=>AEe(r)===t).map(r=>r.trace_id)),i=e.filter(r=>n.has(r.trace_id));return i.length>0?i:e}function U2(e){return!!(e&&[...e.tools,...e.skills].some(t=>t.custom))}const CEe="send_a2ui_json_to_client",jEe="validated_a2ui_json",uP="adk_request_credential",m9="transfer_to_agent";function REe(e){var i,r,s,a;const t=e,n=((i=t==null?void 0:t.exchangedAuthCredential)==null?void 0:i.oauth2)??((r=t==null?void 0:t.exchanged_auth_credential)==null?void 0:r.oauth2)??((s=t==null?void 0:t.rawAuthCredential)==null?void 0:s.oauth2)??((a=t==null?void 0:t.raw_auth_credential)==null?void 0:a.oauth2);return(n==null?void 0:n.authUri)??(n==null?void 0:n.auth_uri)}function Pu(){return{blocks:[],liveStart:0}}const g9=e=>e.functionCall??e.function_call,dP=e=>e.functionResponse??e.function_response;function IEe(e){if(!e||typeof e!="object")return"";const t=e,n=t.agentName??t.agent_name;return typeof n=="string"?n:""}function PEe(e){return e.replace(/-/g,"+").replace(/_/g,"/")}function wee(e){const t=[];for(const[n,i]of e.entries()){const r=i.partMetadata??i.part_metadata,s=r==null?void 0:r.veadkTransport;if((s==null?void 0:s.hidden)===!0)continue;const a=r==null?void 0:r.veadkMedia;if(typeof(a==null?void 0:a.uri)=="string"){t.push({id:String(a.id??a.uri),mimeType:typeof a.mimeType=="string"?a.mimeType:void 0,uri:a.uri,name:typeof a.name=="string"?a.name:void 0,sizeBytes:typeof a.sizeBytes=="number"?a.sizeBytes:void 0});continue}const o=i.inlineData??i.inline_data;if(o&&o.data){t.push({id:`inline-${n}-${o.displayName??o.display_name??"media"}`,mimeType:o.mimeType??o.mime_type,data:PEe(o.data),name:o.displayName??o.display_name});continue}const c=i.fileData??i.file_data,u=(c==null?void 0:c.fileUri)??(c==null?void 0:c.file_uri);c&&u&&t.push({id:u,mimeType:c.mimeType??c.mime_type,uri:u,name:c.displayName??c.display_name})}return t}function fP(e){const t=e.partMetadata??e.part_metadata,n=t==null?void 0:t.veadkTransport;return(n==null?void 0:n.hideText)===!0?void 0:e.text}const MEe=new Set(["llm","sequential","parallel","loop","a2a"]);function LEe(e){var t;for(const n of e){const i=(t=n.partMetadata??n.part_metadata)==null?void 0:t.veadkInvocation;if(!i||typeof i!="object")continue;const r=i,s=Array.isArray(r.skills)?r.skills.flatMap(c=>{if(!c||typeof c!="object")return[];const u=c;return typeof u.name=="string"?[{name:u.name,description:typeof u.description=="string"?u.description:""}]:[]}):[];let a;const o=r.targetAgent;if(o&&typeof o=="object"){const c=o,u=c.type;typeof c.name=="string"&&typeof u=="string"&&MEe.has(u)&&Array.isArray(c.path)&&(a={name:c.name,description:typeof c.description=="string"?c.description:"",type:u,path:c.path.filter(d=>typeof d=="string")})}if(s.length>0||a)return{skills:s,targetAgent:a}}}function DEe(e,t){if(!t.length)return;const n=e[e.length-1];(n==null?void 0:n.kind)==="attachment"?n.files.push(...t):e.push({kind:"attachment",files:t})}function $Ee(e,t){if(!t.length)return;const n=e[e.length-1];if((n==null?void 0:n.kind)==="artifact"){for(const i of t)n.files.some(r=>r.filename===i.filename&&r.version===i.version)||n.files.push(i);return}e.push({kind:"artifact",files:t})}function b9(e,t,n){const i=e[e.length-1];i&&i.kind===t?i.text+=n:e.push(t==="thinking"?{kind:t,text:n,done:!1}:{kind:t,text:n})}function sw(e){for(const t of e)t.kind==="thinking"&&(t.done=!0)}function yk(e,t){var o,c,u,d,f,h;const n=e.blocks.map(p=>({...p}));let i=e.liveStart;const r=((o=t.content)==null?void 0:o.parts)??[],s=r.some(p=>g9(p)||dP(p));if(t.partial&&!s){for(const p of r){const g=fP(p);typeof g=="string"&&g&&b9(n,p.thought?"thinking":"text",g)}return{blocks:n,liveStart:i}}n.length=i;for(const p of r){const g=g9(p),b=dP(p),y=wee([p]),O=fP(p);if(typeof O=="string"&&O)b9(n,p.thought?"thinking":"text",O);else if(y.length)sw(n),DEe(n,y);else if(g)if(sw(n),g.name===m9){const v=IEe(g.args)||((c=t.actions)==null?void 0:c.transferToAgent)||((u=t.actions)==null?void 0:u.transfer_to_agent)||"未知 Agent";n.push({kind:"agent-transfer",agentName:v,done:!1})}else if(g.name===uP){const v=g.args??{},x=v.authConfig??v.auth_config??v,E=String(v.functionCallId??v.function_call_id??"").replace(/^_adk_toolset_auth_/,"")||void 0;n.push({kind:"auth",callId:g.id??"",label:E,authUri:REe(x),authConfig:x,done:!1})}else n.push({kind:"tool",name:g.name??"",args:g.args,done:!1});else if(b){if(sw(n),b.name===m9)for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="agent-transfer"&&!x.done){x.done=!0;break}}if(b.name===uP)for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="auth"&&!x.done){x.done=!0;break}}for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="tool"&&!x.done&&x.name===b.name){x.done=!0,x.response=b.response;break}}if(b.name===CEe){const v=((d=b.response)==null?void 0:d[jEe])??[];if(v.length){const x=n[n.length-1];x&&x.kind==="a2ui"?x.messages.push(...v):n.push({kind:"a2ui",messages:v})}}}}const a=((f=t.actions)==null?void 0:f.artifactDelta)??((h=t.actions)==null?void 0:h.artifact_delta);return a&&$Ee(n,Object.entries(a).map(([p,g])=>({filename:p,version:g}))),sw(n),i=n.length,{blocks:n,liveStart:i}}function QEe(e,t={}){var r,s;const n=[];let i=Pu();for(const a of e)if(a.author==="user"){const c=((r=a.content)==null?void 0:r.parts)??[];if(c.some(p=>{var g;return((g=dP(p))==null?void 0:g.name)===uP})){for(let p=n.length-1;p>=0;p--)if(n[p].role==="assistant"){for(let g=n[p].blocks.length-1;g>=0;g--){const b=n[p].blocks[g];if(b.kind==="auth"){b.done=!0;break}}break}}const u=c.map(fP).filter(p=>!!p).join(""),d=wee(c),f=LEe(c);if(!u&&!d.length&&!f){i=Pu();continue}const h=[];f&&h.push({kind:"invocation",value:f}),d.length&&h.push({kind:"attachment",files:d}),u&&h.push({kind:"text",text:u}),n.push({role:"user",blocks:h,meta:{ts:a.timestamp}}),i=Pu()}else{const c=a.author??"";let u=n[n.length-1];(!u||u.role!=="assistant"||c&&((s=u.meta)==null?void 0:s.author)!==c)&&(u={role:"assistant",blocks:[],meta:{author:c||void 0}},n.push(u),i=Pu()),i=yk(i,a),u.blocks=i.blocks;const d=a.usageMetadata??a.usage_metadata,f=u.meta??(u.meta={});c&&(f.author=c),d!=null&&d.totalTokenCount&&(f.tokens=d.totalTokenCount),a.timestamp&&(f.ts=a.timestamp),a.id&&(f.eventId=a.id);const h=a.invocationId??a.invocation_id;h&&(f.invocationId=h)}for(const a of n){const o=a.meta,c=o==null?void 0:o.eventId;if(!c)continue;const u=t[`veadk_feedback:${c}`];if(!u||typeof u!="object")continue;const d=u;d.rating!=="good"&&d.rating!=="bad"||(o.feedback=u)}return n}function E_(e){var t,n;for(const i of e??[])if(i.author==="user"||((t=i.content)==null?void 0:t.role)==="user"){const r=(((n=i.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(r)return r}return"新会话"}const BEe=50,O9=48;function UEe(e){return(e.events??[]).flatMap(t=>{var r,s;const i=(((r=t.content)==null?void 0:r.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return i?[{text:i,role:t.author??((s=t.content)==null?void 0:s.role)??"",ts:t.timestamp}]:[]})}function zEe(e){var t,n;for(const i of e.events??[])if(i.author==="user"||((t=i.content)==null?void 0:t.role)==="user"){const r=(((n=i.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(r)return r}return"未命名会话"}function FEe(e,t,n){const i=Math.max(0,t-O9),r=Math.min(e.length,t+n+O9);return(i>0?"…":"")+e.slice(i,r).trim()+(r{var c;if((c=o.events)!=null&&c.length)return o;try{return await gk(t,e,o.id)}catch{return o}})),a=[];for(const o of s)for(const{text:c,role:u,ts:d}of UEe(o)){const f=c.toLowerCase().indexOf(i);if(f!==-1){a.push({type:"session",appId:t,sessionId:o.id,title:zEe(o),snippet:FEe(c,f,i.length),role:u,ts:d??o.lastUpdateTime});break}}return a.sort((o,c)=>(c.ts??0)-(o.ts??0)),a.slice(0,BEe)}async function XEe(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await JJ(e,t.trim())}catch(a){const o=String(a);return{results:[],note:o.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${o}`}}const{mounted:i,results:r,error:s}=n;return i?s?{results:[],note:s}:{results:r.map((a,o)=>({type:"web",index:o,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function qEe(e,t,n,i){if(!t||!i.trim())return{results:[]};const r=await KJ(t,e,i.trim(),n);if(!r.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(r.error)return{results:[],note:r.error};const s=r.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:r.results.map((a,o)=>e==="knowledge"?{type:"knowledge",index:o,content:a.content,sourceName:s,sourceType:r.sourceType}:{type:"memory",index:o,content:a.content,sourceName:s,sourceType:r.sourceType,author:a.author,ts:a.timestamp})}}async function HEe(e,t,n){return e==="session"?{results:await VEe(n.userId,n.appId,t)}:e==="web"?XEe(n.appId,t):qEe(e,n.appId,n.userId,t)}function See({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),l.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function YEe({open:e}){return l.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function GEe({active:e=!1,onClick:t}){return l.jsxs("button",{className:`new-chat${e?" is-active":""}`,onClick:t,"aria-label":"搜索","aria-current":e?"page":void 0,title:"搜索",children:[l.jsx(See,{}),l.jsx("span",{className:"sidebar-nav-label",children:"搜索"})]})}function WEe(e,t,n){const i=!!e,r=new Set((t==null?void 0:t.searchSources)??[]),s=a=>i?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:i,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:i&&r.has("web"),description:"通过 web_search 工具检索",unavailableLabel:s(" web_search 工具")},{id:"knowledge",label:"知识库",ready:i&&r.has("knowledge"),unavailableLabel:s("知识库")},{id:"memory",label:"长期记忆",ready:i&&r.has("memory"),unavailableLabel:s("长期记忆")}]}function xk(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function y9(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function ZEe({userId:e,appId:t,agentInfo:n,capabilitiesLoading:i,agentLabel:r,onOpenSession:s}){var Q,j;const[a,o]=m.useState("session"),[c,u]=m.useState(""),[d,f]=m.useState([]),[h,p]=m.useState(),[g,b]=m.useState(!1),[y,O]=m.useState(!1),[v,x]=m.useState(!1),w=m.useRef(0),E=m.useRef(null),S=WEe(t,n,i),k=S.find($=>$.id===a),T=a==="knowledge"?(Q=n==null?void 0:n.components)==null?void 0:Q.find($=>$.source==="knowledgebase"||$.kind==="knowledgebase"):a==="memory"?(j=n==null?void 0:n.components)==null?void 0:j.find($=>$.source==="long_term_memory"||$.kind==="memory"):void 0;m.useEffect(()=>{w.current+=1,o("session"),f([]),p(void 0),O(!1),b(!1),x(!1)},[t]),m.useEffect(()=>{if(!v)return;function $(U){var B;(B=E.current)!=null&&B.contains(U.target)||x(!1)}return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[v]);async function A($,U){var q;const B=$.trim();if(!B||!((q=S.find(D=>D.id===U))!=null&&q.ready))return;const I=++w.current;b(!0),O(!0);let X;try{X=await HEe(U,B,{userId:e,appId:t})}catch(D){const H=D instanceof Error?D.message:String(D);X={results:[],note:`搜索失败:${H}`}}I===w.current&&(f(X.results),p(X.note),b(!1))}function N($){w.current+=1,u($),f([]),p(void 0),O(!1),b(!1)}function C($){w.current+=1,o($),x(!1),f([]),p(void 0),O(!1),b(!1)}const M=!!(k!=null&&k.ready),L=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(T==null?void 0:T.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(T==null?void 0:T.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",P=T!=null&&T.backend?xk(T.backend):"";return l.jsxs("div",{className:"search",children:[l.jsxs("div",{className:"search-box",children:[l.jsxs("div",{className:"search-source-picker-wrap",ref:E,children:[l.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(k==null?void 0:k.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":v,onClick:()=>x($=>!$),children:[l.jsx("span",{children:(k==null?void 0:k.label)??"搜索类型"}),P&&l.jsx("small",{children:P}),l.jsx(YEe,{open:v})]}),v&&l.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:S.map($=>{var I,X;const U=$.id==="knowledge"?(I=n==null?void 0:n.components)==null?void 0:I.find(q=>q.source==="knowledgebase"||q.kind==="knowledgebase"):$.id==="memory"?(X=n==null?void 0:n.components)==null?void 0:X.find(q=>q.source==="long_term_memory"||q.kind==="memory"):void 0,B=U?[U.name,U.backend?xk(U.backend):""].filter(Boolean).join(" · "):$.ready?$.description:$.unavailableLabel;return l.jsxs("button",{type:"button",role:"option","aria-selected":a===$.id,disabled:!$.ready,onClick:()=>C($.id),children:[l.jsx("span",{children:$.label}),B&&l.jsx("small",{children:B})]},$.id)})})]}),l.jsx("span",{className:"search-box-divider","aria-hidden":!0}),l.jsx("input",{className:"search-input",value:c,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),A(c,a))},placeholder:L,disabled:!M,autoFocus:!0}),l.jsx("button",{className:"search-go",onClick:()=>void A(c,a),disabled:!c.trim()||g,"aria-label":"搜索",children:g?l.jsx(Kn,{className:"icon spin"}):l.jsx(See,{className:"icon"})})]}),l.jsx("div",{className:"search-results",children:M?y?g?null:h?l.jsx("div",{className:"search-empty",children:h}):d.length===0&&y?l.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map(($,U)=>l.jsx(KEe,{result:$,agentLabel:r,onOpen:s},U)):l.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):l.jsx("div",{className:"search-empty",children:t?i?"正在读取当前 Agent 的检索能力…":(k==null?void 0:k.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function KEe({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return l.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[l.jsx(pJ,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title}),l.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${y9(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return l.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[l.jsx(O_,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title||e.url}),l.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&l.jsx(e0,{className:"search-result-ext"})]})]}),e.summary&&l.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(x9,{source:"knowledge"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${xk(e.sourceType)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(x9,{source:"memory"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${xk(e.sourceType)}`:"",e.ts?` · ${y9(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function x9({source:e,className:t="search-result-icon"}){return e==="knowledge"?l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),l.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),l.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}function Pf({className:e="icon"}){return l.jsxs("svg",{className:`${e} sidebar-agent-face`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"4.25",y:"5.25",width:"15.5",height:"13.5",rx:"4.75"}),l.jsx("path",{className:"sidebar-agent-face__eye",d:"M8.5 10.7v2"}),l.jsx("path",{className:"sidebar-agent-face__eye",d:"M15.5 10.7v2"})]})}function JEe({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"9.3",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 10.2 11.3 4.8c.5-.8 1.7-.45 1.7.5v3.8h4.2a2.1 2.1 0 0 1 2.04 2.6l-1.4 5.75A2.1 2.1 0 0 1 15.8 19H8"})]})}function eke({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 13.8 11.3 19.2c.5.8 1.7.45 1.7-.5v-3.8h4.2a2.1 2.1 0 0 0 2.04-2.6l-1.4-5.75A2.1 2.1 0 0 0 15.8 5H8"})]})}function Eee(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5.25 4.25h9.5a2.5 2.5 0 0 1 2.5 2.5v3.5"}),l.jsx("path",{d:"M13.25 17.75h-8a2.5 2.5 0 0 1-2.5-2.5v-8a3 3 0 0 1 3-3"}),l.jsx("path",{d:"M7 8.25h5.5M7 11.75h3.25"}),l.jsx("path",{d:"m13.35 16.65.42-2.16 4.76-4.76a1.35 1.35 0 0 1 1.91 1.91l-4.76 4.76-2.33.25Z"}),l.jsx("path",{d:"m17.65 10.6 1.9 1.9"})]})}const n$="/assets/logo-DCsNZy-k.svg",i$="data:image/svg+xml,%3csvg%20width='28'%20height='23'%20viewBox='0%200%2028%2023'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.1957%209.44218C17.0253%209.58161%2016.7774%209.47317%2016.7774%209.24079V8.01696V0.611967C16.7774%200.395085%2016.514%200.271152%2016.3591%200.410576L6.04172%209.16334C5.87132%209.30276%205.62345%209.19432%205.62345%208.96194V2.98218C5.62345%202.81178%205.48403%202.67235%205.31362%202.67235H0.309832C0.139424%202.67235%200%202.81178%200%202.98218V21.7115C0%2021.9284%200.263357%2022.0524%200.418273%2021.9129L10.7202%2013.1602C10.8906%2013.0207%2011.1385%2013.1292%2011.1385%2013.3616V22.0059C11.1385%2022.2228%2011.4018%2022.3467%2011.5567%2022.2073L21.8586%2013.4545C22.0291%2013.3151%2022.2769%2013.4235%2022.2769%2013.6559V19.6357C22.2769%2019.8061%2022.4163%2019.9455%2022.5868%2019.9455H27.5905C27.7609%2019.9455%2027.9004%2019.8061%2027.9004%2019.6357V0.890816C27.9004%200.673934%2027.637%200.550001%2027.4821%200.689425L17.1957%209.44218Z'%20fill='%230066FC'/%3e%3c/svg%3e",v9="(max-width: 860px)";function tke(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"7",cy:"7",r:"2.25"}),l.jsx("circle",{cx:"17",cy:"7",r:"2.25"}),l.jsx("circle",{cx:"7",cy:"17",r:"2.25"}),l.jsx("circle",{cx:"17",cy:"17",r:"2.25"})]})}function nke(e){let t=2166136261;for(const i of e)t^=i.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const ike={admin:"管理员",developer:"开发者",user:"普通用户"};function w9({role:e}){const t=ike[e];return l.jsx("span",{className:`studio-role-badge studio-role-badge--${e}`,title:t,children:t})}function rke({access:e,userInfo:t,onSystemInfo:n,onLogout:i}){const[r,s]=m.useState(!1),[a,o]=m.useState("");if(!t)return null;const c=SSe(t),u=typeof t.email=="string"?t.email:"",d=(c||"U").slice(0,1).toUpperCase(),f=nke(c||u||d),h=ESe(t),p=h===a?"":h;return l.jsxs("div",{className:"sidebar-user",children:[l.jsxs("button",{className:"sidebar-user-btn",onClick:()=>s(g=>!g),title:u?`${c} -${u}`:c,children:[l.jsxs("span",{className:`account-avatar${p?" has-image":""}`,style:f,children:[d,p?l.jsx("img",{className:"account-avatar-image",src:p,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>o(p)}):null]}),l.jsxs("span",{className:"sidebar-user-identity",children:[l.jsxs("span",{className:"sidebar-user-primary",children:[l.jsx("span",{className:"sidebar-user-name",children:c}),l.jsx(w9,{role:e.role})]}),u&&u!==c&&l.jsx("span",{className:"sidebar-user-email",children:u})]})]}),r&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>s(!1)}),l.jsxs("div",{className:"account-pop sidebar-user-pop",children:[l.jsxs("div",{className:"account-head",children:[l.jsxs("span",{className:`account-avatar account-avatar--lg${p?" has-image":""}`,style:f,children:[d,p?l.jsx("img",{className:"account-avatar-image",src:p,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>o(p)}):null]}),l.jsxs("div",{className:"account-id",children:[l.jsxs("div",{className:"account-name-row",children:[l.jsx("div",{className:"account-name",children:c}),l.jsx(w9,{role:e.role})]}),u&&u!==c&&l.jsx("div",{className:"account-sub",children:u})]})]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{s(!1),n()},children:[l.jsx(hd,{className:"icon"})," 系统信息"]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{s(!1),i()},children:[l.jsx(tSe,{className:"icon"})," 退出登录"]})]})]})]})}function ske({branding:e,cloudProvider:t,sessions:n,currentSessionId:i,activePage:r,features:s,access:a,streamingSids:o,evaluatingSids:c,sandboxHistory:u,onNewChat:d,onSearch:f,onQuickCreate:h,onLibrary:p,onAddAgent:g,onMyAgents:b,onApplications:y,onSystemInfo:O,onIssueFeedback:v,onPickSession:x,onDeleteSession:w,userInfo:E,onLogout:S}){const k=j=>(s==null?void 0:s[j])!==!1,[T,A]=m.useState(null),N=m.useRef(typeof window<"u"&&window.matchMedia(v9).matches),[C,M]=m.useState(N.current),L=[...n].sort((j,$)=>($.lastUpdateTime??0)-(j.lastUpdateTime??0)),P=()=>{N.current=!1,M(j=>!j),A(null)};m.useEffect(()=>{const j=window.matchMedia(v9),$=U=>{U.matches?M(B=>B||(N.current=!0,!0)):N.current&&(N.current=!1,M(!1))};return j.addEventListener("change",$),()=>j.removeEventListener("change",$)},[]);const Q=t==="byteplus"?i$:n$;return l.jsxs("aside",{className:`sidebar ${C?"is-collapsed":""}`,children:[l.jsxs("div",{className:"sidebar-top",children:[l.jsxs("div",{className:"sidebar-brand-row",children:[l.jsxs("button",{type:"button",className:"brand",onClick:d,"aria-label":"返回首页",title:"返回首页",children:[l.jsx("img",{className:"brand-logo",src:e.logoUrl||Q,width:20,height:20,alt:"","aria-hidden":!0}),l.jsx("span",{className:"brand-title",children:e.title})]}),l.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:P,"aria-label":C?"展开侧边栏":"收起侧边栏",title:C?"展开侧边栏":"收起侧边栏",children:C?l.jsx(aSe,{className:"icon"}):l.jsx(sSe,{className:"icon"})})]}),k("newChat")&&l.jsxs("button",{className:`new-chat new-chat--conversation${r==="new-chat"?" is-active":""}`,onClick:d,"aria-label":"新会话","aria-current":r==="new-chat"?"page":void 0,title:"新会话",children:[l.jsx(Gs,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),l.jsxs("button",{className:`new-chat new-chat--agents${r==="agents"?" is-active":""}`,onClick:b,"aria-label":"智能体","aria-current":r==="agents"?"page":void 0,title:"智能体",children:[l.jsx(Pf,{}),l.jsx("span",{className:"sidebar-nav-label",children:"智能体"})]}),l.jsxs("button",{className:`new-chat new-chat--library${r==="library"?" is-active":""}`,onClick:p,"aria-label":"库","aria-current":r==="library"?"page":void 0,title:"库",children:[l.jsx(Awe,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"库"})]}),k("search")&&l.jsx(GEe,{active:r==="search",onClick:f}),l.jsxs("button",{className:`new-chat new-chat--applications${r==="applications"?" is-active":""}`,onClick:y,"aria-label":"自动化","aria-current":r==="applications"?"page":void 0,title:"自动化",children:[l.jsx(tke,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"自动化"}),l.jsx("span",{className:"sidebar-beta-badge",children:"Beta"})]})]}),k("history")&&l.jsxs("div",{className:"sidebar-history",children:[l.jsxs("div",{className:"history-head",children:[l.jsx("span",{children:"历史会话"}),k("newChat")&&l.jsx("button",{type:"button",className:"history-new-chat",onClick:(u==null?void 0:u.onNew)??d,disabled:u==null?void 0:u.newDisabled,"aria-label":"新建会话",title:"新建会话",children:l.jsx(Gs,{className:"icon"})})]}),l.jsx("div",{className:"history-list",children:u?l.jsxs(l.Fragment,{children:[u.loading&&u.threads.length===0?l.jsx("div",{className:"history-empty",role:"status",children:"正在加载历史会话…"}):null,u.error?l.jsx("div",{className:"history-error",role:"alert",children:u.error}):null,!u.loading&&!u.error&&u.threads.length===0?l.jsx("div",{className:"history-empty",children:"暂无会话"}):null,u.threads.map(j=>{const $=j.id===u.currentThreadId,U=j.name||j.preview||`Thread ${j.id.slice(0,8)}`,B=j.id===u.busyThreadId;return l.jsxs("div",{className:`history-item ${$?"active":""}`,children:[l.jsxs("button",{type:"button",className:"history-item-btn",onClick:()=>u.onSelect(j.id),"aria-current":$?"page":void 0,title:U,disabled:B,children:[l.jsx("span",{className:"history-title",children:U}),$?l.jsx("span",{className:"history-current-badge",children:"当前"}):null]}),l.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${U}`,title:"更多",disabled:B,onClick:()=>A(I=>I===j.id?null:j.id),children:l.jsx(i9,{className:"icon"})}),T===j.id?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>A(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{A(null),u.onDelete(j)},children:[l.jsx(If,{className:"icon"})," 删除"]})})]}):null]},j.id)}),u.hasMore?l.jsx("button",{type:"button",className:"history-load-more",disabled:u.loading,onClick:u.onLoadMore,children:u.loading?"加载中…":"加载更多"}):null]}):l.jsxs(l.Fragment,{children:[L.length===0&&l.jsx("div",{className:"history-empty",children:"暂无会话"}),L.map(j=>{const $=E_(j.events),U=(o==null?void 0:o.has(j.id))===!0,B=!U&&(c==null?void 0:c.has(j.id))===!0;return l.jsxs("div",{className:`history-item ${j.id===i?"active":""}`,children:[l.jsxs("button",{className:"history-item-btn",onClick:()=>x(j.id),"aria-current":j.id===i?"page":void 0,title:$,children:[U&&l.jsx("span",{className:"history-streaming",title:"正在生成…","aria-label":"正在生成"}),l.jsx("span",{className:"history-title",children:$}),B&&l.jsxs("span",{className:"history-evaluating-status",title:"正在自动评测",children:[l.jsx("span",{className:"history-evaluating","aria-hidden":"true"}),"评测中"]})]}),l.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${$}`,title:"更多",onClick:()=>A(I=>I===j.id?null:j.id),children:l.jsx(i9,{className:"icon"})}),T===j.id&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>A(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{className:"menu-item menu-item--danger",onClick:()=>{A(null),w(j.id)},children:[l.jsx(If,{className:"icon"})," 删除"]})})]})]},j.id)})]})})]}),l.jsxs("div",{className:"sidebar-footer",children:[l.jsxs("button",{type:"button",className:`sidebar-feedback${r==="feedback"?" is-active":""}`,onClick:v,"aria-label":"问题反馈","aria-current":r==="feedback"?"page":void 0,title:"问题反馈",children:[l.jsx(Eee,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"问题反馈"})]}),l.jsx(rke,{access:a,userInfo:E,onSystemInfo:O,onLogout:S})]})]})}function Yr(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n{}};function k_(){for(var e=0,t=arguments.length,n={},i;e=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}VS.prototype=k_.prototype={constructor:VS,on:function(e,t){var n=this._,i=oke(e+"",n),r,s=-1,a=i.length;if(arguments.length<2){for(;++s0)for(var n=new Array(r),i=0,r,s;i=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),E9.hasOwnProperty(t)?{space:E9[t],local:e}:e}function cke(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hP&&t.documentElement.namespaceURI===hP?t.createElement(e):t.createElementNS(n,e)}}function uke(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kee(e){var t=T_(e);return(t.local?uke:cke)(t)}function dke(){}function r$(e){return e==null?dke:function(){return this.querySelector(e)}}function fke(e){typeof e!="function"&&(e=r$(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r=x&&(x=v+1);!(E=y[x])&&++x=0;)(a=i[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function Dke(e){e||(e=$ke);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,i=n.length,r=new Array(i),s=0;st?1:e>=t?0:NaN}function Qke(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Bke(){return Array.from(this)}function Uke(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Kke:typeof t=="function"?eTe:Jke)(e,t,n??"")):n0(this.node(),e)}function n0(e,t){return e.style.getPropertyValue(t)||Cee(e).getComputedStyle(e,null).getPropertyValue(t)}function nTe(e){return function(){delete this[e]}}function iTe(e,t){return function(){this[e]=t}}function rTe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function sTe(e,t){return arguments.length>1?this.each((t==null?nTe:typeof t=="function"?rTe:iTe)(e,t)):this.node()[e]}function jee(e){return e.trim().split(/^|\s+/)}function s$(e){return e.classList||new Ree(e)}function Ree(e){this._node=e,this._names=jee(e.getAttribute("class")||"")}Ree.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Iee(e,t){for(var n=s$(e),i=-1,r=t.length;++i=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function ITe(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n()=>e;function pP(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:s,x:a,y:o,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}pP.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function FTe(e){return!e.ctrlKey&&!e.button}function VTe(){return this.parentNode}function XTe(e,t){return t??{x:e.x,y:e.y}}function qTe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qee(){var e=FTe,t=VTe,n=XTe,i=qTe,r={},s=k_("start","drag","end"),a=0,o,c,u,d,f=0;function h(w){w.on("mousedown.drag",p).filter(i).on("touchstart.drag",y).on("touchmove.drag",O,zTe).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,E){if(!(d||!e.call(this,w,E))){var S=x(this,t.call(this,w,E),w,E,"mouse");S&&(fo(w.view).on("mousemove.drag",g,ix).on("mouseup.drag",b,ix),Dee(w.view),z2(w),u=!1,o=w.clientX,c=w.clientY,S("start",w))}}function g(w){if(yg(w),!u){var E=w.clientX-o,S=w.clientY-c;u=E*E+S*S>f}r.mouse("drag",w)}function b(w){fo(w.view).on("mousemove.drag mouseup.drag",null),$ee(w.view,u),yg(w),r.mouse("end",w)}function y(w,E){if(e.call(this,w,E)){var S=w.changedTouches,k=t.call(this,w,E),T=S.length,A,N;for(A=0;A>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ow(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ow(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=YTe.exec(e))?new Da(t[1],t[2],t[3],1):(t=GTe.exec(e))?new Da(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=WTe.exec(e))?ow(t[1],t[2],t[3],t[4]):(t=ZTe.exec(e))?ow(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=KTe.exec(e))?j9(t[1],t[2]/100,t[3]/100,1):(t=JTe.exec(e))?j9(t[1],t[2]/100,t[3]/100,t[4]):k9.hasOwnProperty(e)?A9(k9[e]):e==="transparent"?new Da(NaN,NaN,NaN,0):null}function A9(e){return new Da(e>>16&255,e>>8&255,e&255,1)}function ow(e,t,n,i){return i<=0&&(e=t=n=NaN),new Da(e,t,n,i)}function n_e(e){return e instanceof E1||(e=gp(e)),e?(e=e.rgb(),new Da(e.r,e.g,e.b,e.opacity)):new Da}function mP(e,t,n,i){return arguments.length===1?n_e(e):new Da(e,t,n,i??1)}function Da(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}a$(Da,mP,Bee(E1,{brighter(e){return e=e==null?wk:Math.pow(wk,e),new Da(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?rx:Math.pow(rx,e),new Da(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Da(ip(this.r),ip(this.g),ip(this.b),Sk(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:N9,formatHex:N9,formatHex8:i_e,formatRgb:C9,toString:C9}));function N9(){return`#${Bh(this.r)}${Bh(this.g)}${Bh(this.b)}`}function i_e(){return`#${Bh(this.r)}${Bh(this.g)}${Bh(this.b)}${Bh((isNaN(this.opacity)?1:this.opacity)*255)}`}function C9(){const e=Sk(this.opacity);return`${e===1?"rgb(":"rgba("}${ip(this.r)}, ${ip(this.g)}, ${ip(this.b)}${e===1?")":`, ${e})`}`}function Sk(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ip(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bh(e){return e=ip(e),(e<16?"0":"")+e.toString(16)}function j9(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Nl(e,t,n,i)}function Uee(e){if(e instanceof Nl)return new Nl(e.h,e.s,e.l,e.opacity);if(e instanceof E1||(e=gp(e)),!e)return new Nl;if(e instanceof Nl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),a=NaN,o=s-r,c=(s+r)/2;return o?(t===s?a=(n-i)/o+(n0&&c<1?0:a,new Nl(a,o,c,e.opacity)}function r_e(e,t,n,i){return arguments.length===1?Uee(e):new Nl(e,t,n,i??1)}function Nl(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}a$(Nl,r_e,Bee(E1,{brighter(e){return e=e==null?wk:Math.pow(wk,e),new Nl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?rx:Math.pow(rx,e),new Nl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Da(F2(e>=240?e-240:e+120,r,i),F2(e,r,i),F2(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Nl(R9(this.h),lw(this.s),lw(this.l),Sk(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Sk(this.opacity);return`${e===1?"hsl(":"hsla("}${R9(this.h)}, ${lw(this.s)*100}%, ${lw(this.l)*100}%${e===1?")":`, ${e})`}`}}));function R9(e){return e=(e||0)%360,e<0?e+360:e}function lw(e){return Math.max(0,Math.min(1,e||0))}function F2(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const o$=e=>()=>e;function s_e(e,t){return function(n){return e+n*t}}function a_e(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function o_e(e){return(e=+e)==1?zee:function(t,n){return n-t?a_e(t,n,e):o$(isNaN(t)?n:t)}}function zee(e,t){var n=t-e;return n?s_e(e,n):o$(isNaN(e)?t:e)}const Ek=function e(t){var n=o_e(t);function i(r,s){var a=n((r=mP(r)).r,(s=mP(s)).r),o=n(r.g,s.g),c=n(r.b,s.b),u=zee(r.opacity,s.opacity);return function(d){return r.r=a(d),r.g=o(d),r.b=c(d),r.opacity=u(d),r+""}}return i.gamma=e,i}(1);function l_e(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;rn&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(i=i[0])===(r=r[0])?o[a]?o[a]+=r:o[++a]=r:(o[++a]=null,c.push({i:a,x:Oc(i,r)})),n=V2.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:Oc(u,d)})):d&&f.push(r(f)+"rotate("+d+i)}function o(u,d,f,h){u!==d?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:Oc(u,d)}):d&&f.push(r(f)+"skewX("+d+i)}function c(u,d,f,h,p,g){if(u!==f||d!==h){var b=p.push(r(p)+"scale(",null,",",null,")");g.push({i:b-4,x:Oc(u,f)},{i:b-2,x:Oc(d,h)})}else(f!==1||h!==1)&&p.push(r(p)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(p){for(var g=-1,b=h.length,y;++g=0&&e._call.call(void 0,t),e=e._next;--i0}function M9(){bp=(Tk=ax.now())+__,i0=_O=0;try{S_e()}finally{i0=0,k_e(),bp=0}}function E_e(){var e=ax.now(),t=e-Tk;t>qee&&(__-=t,Tk=e)}function k_e(){for(var e,t=kk,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:kk=n);AO=e,OP(i)}function OP(e){if(!i0){_O&&(_O=clearTimeout(_O));var t=e-bp;t>24?(e<1/0&&(_O=setTimeout(M9,e-ax.now()-__)),Hb&&(Hb=clearInterval(Hb))):(Hb||(Tk=ax.now(),Hb=setInterval(E_e,qee)),i0=1,Hee(M9))}}function L9(e,t,n){var i=new _k;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var T_e=k_("start","end","cancel","interrupt"),__e=[],Gee=0,D9=1,yP=2,qS=3,$9=4,xP=5,HS=6;function A_(e,t,n,i,r,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;A_e(e,n,{name:t,index:i,group:r,on:T_e,tween:__e,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Gee})}function c$(e,t){var n=Fl(e,t);if(n.state>Gee)throw new Error("too late; already scheduled");return n}function Yc(e,t){var n=Fl(e,t);if(n.state>qS)throw new Error("too late; already running");return n}function Fl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function A_e(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Yee(s,0,n.time);function s(u){n.state=D9,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,p;if(n.state!==D9)return c();for(d in i)if(p=i[d],p.name===n.name){if(p.state===qS)return L9(a);p.state===$9?(p.state=HS,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete i[d]):+dyP&&i.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function rAe(e,t,n){var i,r,s=iAe(t)?c$:Yc;return function(){var a=s(this,e),o=a.on;o!==i&&(r=(i=o).copy()).on(t,n),a.on=r}}function sAe(e,t){var n=this._id;return arguments.length<2?Fl(this.node(),n).on.on(e):this.each(rAe(n,e,t))}function aAe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function oAe(){return this.on("end.remove",aAe(this._id))}function lAe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=r$(e));for(var i=this._groups,r=i.length,s=new Array(r),a=0;a()=>e;function IAe(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Mu(e,t,n){this.k=e,this.x=t,this.y=n}Mu.prototype={constructor:Mu,scale:function(e){return e===1?this:new Mu(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Mu(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var N_=new Mu(1,0,0);Jee.prototype=Mu.prototype;function Jee(e){for(;!e.__zoom;)if(!(e=e.parentNode))return N_;return e.__zoom}function X2(e){e.stopImmediatePropagation()}function Yb(e){e.preventDefault(),e.stopImmediatePropagation()}function PAe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function MAe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Q9(){return this.__zoom||N_}function LAe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function DAe(){return navigator.maxTouchPoints||"ontouchstart"in this}function $Ae(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function ete(){var e=PAe,t=MAe,n=$Ae,i=LAe,r=DAe,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,c=XS,u=k_("start","zoom","end"),d,f,h,p=500,g=150,b=0,y=10;function O(P){P.property("__zoom",Q9).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",N).filter(r).on("touchstart.zoom",C).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}O.transform=function(P,Q,j,$){var U=P.selection?P.selection():P;U.property("__zoom",Q9),P!==U?E(P,Q,j,$):U.interrupt().each(function(){S(this,arguments).event($).start().zoom(null,typeof Q=="function"?Q.apply(this,arguments):Q).end()})},O.scaleBy=function(P,Q,j,$){O.scaleTo(P,function(){var U=this.__zoom.k,B=typeof Q=="function"?Q.apply(this,arguments):Q;return U*B},j,$)},O.scaleTo=function(P,Q,j,$){O.transform(P,function(){var U=t.apply(this,arguments),B=this.__zoom,I=j==null?w(U):typeof j=="function"?j.apply(this,arguments):j,X=B.invert(I),q=typeof Q=="function"?Q.apply(this,arguments):Q;return n(x(v(B,q),I,X),U,a)},j,$)},O.translateBy=function(P,Q,j,$){O.transform(P,function(){return n(this.__zoom.translate(typeof Q=="function"?Q.apply(this,arguments):Q,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),a)},null,$)},O.translateTo=function(P,Q,j,$,U){O.transform(P,function(){var B=t.apply(this,arguments),I=this.__zoom,X=$==null?w(B):typeof $=="function"?$.apply(this,arguments):$;return n(N_.translate(X[0],X[1]).scale(I.k).translate(typeof Q=="function"?-Q.apply(this,arguments):-Q,typeof j=="function"?-j.apply(this,arguments):-j),B,a)},$,U)};function v(P,Q){return Q=Math.max(s[0],Math.min(s[1],Q)),Q===P.k?P:new Mu(Q,P.x,P.y)}function x(P,Q,j){var $=Q[0]-j[0]*P.k,U=Q[1]-j[1]*P.k;return $===P.x&&U===P.y?P:new Mu(P.k,$,U)}function w(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function E(P,Q,j,$){P.on("start.zoom",function(){S(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event($).end()}).tween("zoom",function(){var U=this,B=arguments,I=S(U,B).event($),X=t.apply(U,B),q=j==null?w(X):typeof j=="function"?j.apply(U,B):j,D=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),H=U.__zoom,re=typeof Q=="function"?Q.apply(U,B):Q,fe=c(H.invert(q).concat(D/H.k),re.invert(q).concat(D/re.k));return function(Ae){if(Ae===1)Ae=re;else{var J=fe(Ae),ie=D/J[2];Ae=new Mu(ie,q[0]-J[0]*ie,q[1]-J[1]*ie)}I.zoom(null,Ae)}})}function S(P,Q,j){return!j&&P.__zooming||new k(P,Q)}function k(P,Q){this.that=P,this.args=Q,this.active=0,this.sourceEvent=null,this.extent=t.apply(P,Q),this.taps=0}k.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,Q){return this.mouse&&P!=="mouse"&&(this.mouse[1]=Q.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=Q.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=Q.invert(this.touch1[0])),this.that.__zoom=Q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var Q=fo(this.that).datum();u.call(P,this.that,new IAe(P,{sourceEvent:this.sourceEvent,target:O,transform:this.that.__zoom,dispatch:u}),Q)}};function T(P,...Q){if(!e.apply(this,arguments))return;var j=S(this,Q).event(P),$=this.__zoom,U=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),B=Tl(P);if(j.wheel)(j.mouse[0][0]!==B[0]||j.mouse[0][1]!==B[1])&&(j.mouse[1]=$.invert(j.mouse[0]=B)),clearTimeout(j.wheel);else{if($.k===U)return;j.mouse=[B,$.invert(B)],YS(this),j.start()}Yb(P),j.wheel=setTimeout(I,g),j.zoom("mouse",n(x(v($,U),j.mouse[0],j.mouse[1]),j.extent,a));function I(){j.wheel=null,j.end()}}function A(P,...Q){if(h||!e.apply(this,arguments))return;var j=P.currentTarget,$=S(this,Q,!0).event(P),U=fo(P.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",D,!0),B=Tl(P,j),I=P.clientX,X=P.clientY;Dee(P.view),X2(P),$.mouse=[B,this.__zoom.invert(B)],YS(this),$.start();function q(H){if(Yb(H),!$.moved){var re=H.clientX-I,fe=H.clientY-X;$.moved=re*re+fe*fe>b}$.event(H).zoom("mouse",n(x($.that.__zoom,$.mouse[0]=Tl(H,j),$.mouse[1]),$.extent,a))}function D(H){U.on("mousemove.zoom mouseup.zoom",null),$ee(H.view,$.moved),Yb(H),$.event(H).end()}}function N(P,...Q){if(e.apply(this,arguments)){var j=this.__zoom,$=Tl(P.changedTouches?P.changedTouches[0]:P,this),U=j.invert($),B=j.k*(P.shiftKey?.5:2),I=n(x(v(j,B),$,U),t.apply(this,Q),a);Yb(P),o>0?fo(this).transition().duration(o).call(E,I,$,P):fo(this).call(O.transform,I,$,P)}}function C(P,...Q){if(e.apply(this,arguments)){var j=P.touches,$=j.length,U=S(this,Q,P.changedTouches.length===$).event(P),B,I,X,q;for(X2(P),I=0;I<$;++I)X=j[I],q=Tl(X,this),q=[q,this.__zoom.invert(q),X.identifier],U.touch0?!U.touch1&&U.touch0[2]!==q[2]&&(U.touch1=q,U.taps=0):(U.touch0=q,B=!0,U.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(U.taps<2&&(f=q[0],d=setTimeout(function(){d=null},p)),YS(this),U.start())}}function M(P,...Q){if(this.__zooming){var j=S(this,Q).event(P),$=P.changedTouches,U=$.length,B,I,X,q;for(Yb(P),B=0;B`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ox=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],tte=["Enter"," ","Escape"],nte={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var r0;(function(e){e.Strict="strict",e.Loose="loose"})(r0||(r0={}));var rp;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(rp||(rp={}));var lx;(function(e){e.Partial="partial",e.Full="full"})(lx||(lx={}));const ite={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Kd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Kd||(Kd={}));var cx;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(cx||(cx={}));var St;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(St||(St={}));const B9={[St.Left]:St.Right,[St.Right]:St.Left,[St.Top]:St.Bottom,[St.Bottom]:St.Top};function rte(e){return e===null?null:e?"valid":"invalid"}const ste=e=>"id"in e&&"source"in e&&"target"in e,QAe=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),d$=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),k1=(e,t=[0,0])=>{const{width:n,height:i}=pd(e),r=e.origin??t,s=n*r[0],a=i*r[1];return{x:e.position.x-s,y:e.position.y-a}},BAe=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const s=typeof r=="string";let a=!t.nodeLookup&&!s?r:void 0;t.nodeLookup&&(a=s?t.nodeLookup.get(r):d$(r)?r:t.nodeLookup.get(r.id));const o=a?Ak(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return C_(i,o)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return j_(n)},T1=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=C_(n,Ak(r)),i=!0)}),i?j_(n):{x:0,y:0,width:0,height:0}},f$=(e,t,[n,i,r]=[0,0,1],s=!1,a=!1)=>{const o={...X0(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const p=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,b=ux(o,a0(u)),y=(p??0)*(g??0),O=s&&b>0;(!u.internals.handleBounds||O||b>=y||u.dragging)&&c.push(u)}return c},UAe=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function zAe(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function FAe({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:s},a){if(e.size===0)return!0;const o=zAe(e,a),c=T1(o),u=p$(c,t,n,(a==null?void 0:a.minZoom)??r,(a==null?void 0:a.maxZoom)??s,(a==null?void 0:a.padding)??.1);return await i.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function ate({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:s}){const a=n.get(e),o=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=o?o.internals.positionAbsolute:{x:0,y:0},d=a.origin??i;let f=a.extent||r;if(a.extent==="parent"&&!a.expandParent)if(!o)s==null||s("005",$l.error005());else{const p=o.measured.width,g=o.measured.height;p&&g&&(f=[[c,u],[c+p,u+g]])}else o&&yp(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=yp(f)?Op(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(s==null||s("015",$l.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function VAe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const s=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const p=s.has(h.id),g=!p&&h.parentId&&a.find(b=>b.id===h.parentId);(p||g)&&a.push(h)}const o=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),d=UAe(a,c);for(const h of c)o.has(h.id)&&!d.find(g=>g.id===h.id)&&d.push(h);if(!r)return{edges:d,nodes:a};const f=await r({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const s0=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Op=(e={x:0,y:0},t,n)=>({x:s0(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:s0(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ote(e,t,n){const{width:i,height:r}=pd(n),{x:s,y:a}=n.internals.positionAbsolute;return Op(e,[[s,a],[s+i,a+r]],t)}const U9=(e,t,n)=>en?-s0(Math.abs(e-n),1,t)/t:0,h$=(e,t,n=15,i=40)=>{const r=U9(e.x,i,t.width-i)*n,s=U9(e.y,i,t.height-i)*n;return[r,s]},C_=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),vP=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),j_=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),a0=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=d$(e)?e.internals.positionAbsolute:k1(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},Ak=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=d$(e)?e.internals.positionAbsolute:k1(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},lte=(e,t)=>j_(C_(vP(e),vP(t))),ux=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},z9=e=>jl(e.width)&&jl(e.height)&&jl(e.x)&&jl(e.y),jl=e=>!isNaN(e)&&isFinite(e),cte=(e,t)=>(n,i)=>{},_1=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),X0=({x:e,y:t},[n,i,r],s=!1,a=[1,1])=>{const o={x:(e-n)/r,y:(t-i)/r};return s?_1(o,a):o},o0=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function im(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function XAe(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=im(e,n),r=im(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=im(e.top??e.y??0,n),r=im(e.bottom??e.y??0,n),s=im(e.left??e.x??0,t),a=im(e.right??e.x??0,t);return{top:i,right:a,bottom:r,left:s,x:s+a,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function qAe(e,t,n,i,r,s){const{x:a,y:o}=o0(e,[t,n,i]),{x:c,y:u}=o0({x:e.x+e.width,y:e.y+e.height},[t,n,i]),d=r-c,f=s-u;return{left:Math.floor(a),top:Math.floor(o),right:Math.floor(d),bottom:Math.floor(f)}}const p$=(e,t,n,i,r,s)=>{const a=XAe(s,t,n),o=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(o,c),d=s0(u,i,r),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*d,g=n/2-h*d,b=qAe(e,p,g,d,t,n),y={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:p-y.left+y.right,y:g-y.top+y.bottom,zoom:d}},dx=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function yp(e){return e!=null&&e!=="parent"}function pd(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function m$(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ute(e,t={width:0,height:0},n,i,r){const s={...e},a=i.get(n);if(a){const o=a.origin||r;s.x+=a.internals.positionAbsolute.x-(t.width??0)*o[0],s.y+=a.internals.positionAbsolute.y-(t.height??0)*o[1]}return s}function F9(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function HAe(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function YAe(e){return{...nte,...e||{}}}function uy(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:s,y:a}=Rl(e),o=X0({x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?_1(o,t):o;return{xSnapped:c,ySnapped:u,...o}}const g$=e=>({width:e.offsetWidth,height:e.offsetHeight}),dte=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},GAe=["INPUT","SELECT","TEXTAREA"];function fte(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:GAe.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const hte=e=>"clientX"in e,Rl=(e,t)=>{var s,a;const n=hte(e),i=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,r=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},V9=(e,t,n,i,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(a=>{const o=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:r,position:a.getAttribute("data-handlepos"),x:(o.left-n.left)/i,y:(o.top-n.top)/i,...g$(a)}})};function pte({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:a,targetControlY:o}){const c=e*.125+r*.375+a*.375+n*.125,u=t*.125+s*.375+o*.375+i*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function dw(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function X9({pos:e,x1:t,y1:n,x2:i,y2:r,c:s}){switch(e){case St.Left:return[t-dw(t-i,s),n];case St.Right:return[t+dw(i-t,s),n];case St.Top:return[t,n-dw(n-r,s)];case St.Bottom:return[t,n+dw(r-n,s)]}}function mte({sourceX:e,sourceY:t,sourcePosition:n=St.Bottom,targetX:i,targetY:r,targetPosition:s=St.Top,curvature:a=.25}){const[o,c]=X9({pos:n,x1:e,y1:t,x2:i,y2:r,c:a}),[u,d]=X9({pos:s,x1:i,y1:r,x2:e,y2:t,c:a}),[f,h,p,g]=pte({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${c} ${u},${d} ${i},${r}`,f,h,p,g]}function gte({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,s=n0}const KAe=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,JAe=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),eNe=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",$l.error006()),t;const i=n.getEdgeId||KAe;let r;return ste(e)?r={...e}:r={...e,id:i(e)},JAe(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function bte({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,s,a,o]=gte({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,s,a,o]}const q9={[St.Left]:{x:-1,y:0},[St.Right]:{x:1,y:0},[St.Top]:{x:0,y:-1},[St.Bottom]:{x:0,y:1}},tNe=({source:e,sourcePosition:t=St.Bottom,target:n})=>t===St.Left||t===St.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function nNe({source:e,sourcePosition:t=St.Bottom,target:n,targetPosition:i=St.Top,center:r,offset:s,stepPosition:a}){const o=q9[t],c=q9[i],u={x:e.x+o.x*s,y:e.y+o.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},f=tNe({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",p=f[h];let g=[],b,y;const O={x:0,y:0},v={x:0,y:0},[,,x,w]=gte({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[h]*c[h]===-1){h==="x"?(b=r.x??u.x+(d.x-u.x)*a,y=r.y??(u.y+d.y)/2):(b=r.x??(u.x+d.x)/2,y=r.y??u.y+(d.y-u.y)*a);const T=[{x:b,y:u.y},{x:b,y:d.y}],A=[{x:u.x,y},{x:d.x,y}];o[h]===p?g=h==="x"?T:A:g=h==="x"?A:T}else{const T=[{x:u.x,y:d.y}],A=[{x:d.x,y:u.y}];if(h==="x"?g=o.x===p?A:T:g=o.y===p?T:A,t===i){const P=Math.abs(e[h]-n[h]);if(P<=s){const Q=Math.min(s-1,s-P);o[h]===p?O[h]=(u[h]>e[h]?-1:1)*Q:v[h]=(d[h]>n[h]?-1:1)*Q}}if(t!==i){const P=h==="x"?"y":"x",Q=o[h]===c[P],j=u[P]>d[P],$=u[P]=L?(b=(N.x+C.x)/2,y=g[0].y):(b=g[0].x,y=(N.y+C.y)/2)}const E={x:u.x+O.x,y:u.y+O.y},S={x:d.x+v.x,y:d.y+v.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,y,x,w]}function iNe(e,t,n,i){const r=Math.min(H9(e,t)/2,H9(t,n)/2,i),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function wP(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function sNe(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const s=new Set;return e.reduce((a,o)=>([o.markerStart||i,o.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=wP(c,t);s.has(u)||(a.push({id:u,color:c.color||n,...c}),s.add(u))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))}const Ote=1e3,aNe=10,b$={nodeOrigin:[0,0],nodeExtent:ox,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oNe={...b$,checkEquality:!0};function O$(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function lNe(e,t,n){const i=O$(b$,n);for(const r of e.values())if(r.parentId)x$(r,e,t,i);else{const s=k1(r,i.nodeOrigin),a=yp(r.extent)?r.extent:i.nodeExtent,o=Op(s,a,pd(r));r.internals.positionAbsolute=o}}function cNe(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const s={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(s):r.type==="target"&&i.push(s)}return{source:n,target:i}}function y$(e){return e==="manual"}function SP(e,t,n,i={}){var d,f;const r=O$(oNe,i),s={i:0},a=new Map(t),o=r!=null&&r.elevateNodesOnSelect&&!y$(r.zIndexMode)?Ote:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let p=a.get(h.id);if(r.checkEquality&&h===(p==null?void 0:p.internals.userNode))t.set(h.id,p);else{const g=k1(h,r.nodeOrigin),b=yp(h.extent)?h.extent:r.nodeExtent,y=Op(g,b,pd(h));p={...r.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:y,handleBounds:cNe(h,p),z:yte(h,o,r.zIndexMode),userNode:h}},t.set(h.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),h.parentId&&x$(p,t,n,i,s),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function uNe(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function x$(e,t,n,i,r){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:o,zIndexMode:c}=O$(b$,i),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}uNe(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*aNe),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const f=s&&!y$(c)?Ote:0,{x:h,y:p,z:g}=dNe(e,d,a,o,f,c),{positionAbsolute:b}=e.internals,y=h!==b.x||p!==b.y;(y||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,y:p}:b,z:g}})}function yte(e,t,n){const i=jl(e.zIndex)?e.zIndex:0;return y$(n)?i:i+(e.selected?t:0)}function dNe(e,t,n,i,r,s){const{x:a,y:o}=t.internals.positionAbsolute,c=pd(e),u=k1(e,n),d=yp(e.extent)?Op(u,e.extent,c):u;let f=Op({x:a+d.x,y:o+d.y},i,c);e.extent==="parent"&&(f=ote(f,c,t));const h=yte(e,r,s),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function v$(e,t,n,i=[0,0]){var a;const r=[],s=new Map;for(const o of e){const c=t.get(o.parentId);if(!c)continue;const u=((a=s.get(o.parentId))==null?void 0:a.expandedRect)??a0(c),d=lte(u,o.rect);s.set(o.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:o,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=pd(c),h=c.origin??i,p=o.x0||g>0||O||v)&&(r.push({id:u,type:"position",position:{x:c.position.x-p+O,y:c.position.y-g+v}}),(x=n.get(u))==null||x.forEach(w=>{e.some(E=>E.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+g}})})),(f.width0){const p=v$(h,t,n,r);u.push(...p)}return{changes:u,updatedInternals:c}}async function hNe({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:s}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],i);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function Z9(e,t,n,i,r,s){let a=r;const o=i.get(a)||new Map;i.set(a,o.set(n,t)),a=`${r}-${e}`;const c=i.get(a)||new Map;if(i.set(a,c.set(n,t)),s){a=`${r}-${e}-${s}`;const u=i.get(a)||new Map;i.set(a,u.set(n,t))}}function xte(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:s,sourceHandle:a=null,targetHandle:o=null}=i,c={edgeId:i.id,source:r,target:s,sourceHandle:a,targetHandle:o},u=`${r}-${a}--${s}-${o}`,d=`${s}-${o}--${r}-${a}`;Z9("source",c,d,e,r,a),Z9("target",c,u,e,s,o),t.set(i.id,i)}}function vte(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:vte(n,t):!1}function K9(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function pNe(e,t,n,i){const r=new Map;for(const[s,a]of e)if((a.selected||a.id===i)&&(!a.parentId||!vte(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const o=e.get(s);o&&r.set(s,{id:s,position:o.position||{x:0,y:0},distance:{x:n.x-o.internals.positionAbsolute.x,y:n.y-o.internals.positionAbsolute.y},extent:o.extent,parentId:o.parentId,origin:o.origin,expandParent:o.expandParent,internals:{positionAbsolute:o.internals.positionAbsolute||{x:0,y:0}},measured:{width:o.measured.width??0,height:o.measured.height??0}})}return r}function q2({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var a,o,c;const r=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&r.push({...f,position:d.position,dragging:i})}if(!e)return[r[0],r];const s=(o=n.get(e))==null?void 0:o.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:i}:r[0],r]}function mNe({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:i-r.distance.y},a=_1(s,t);return{x:a.x-s.x,y:a.y-s.y}}function gNe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let s={x:null,y:null},a=0,o=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,p=!1,g=!1,b=null;function y({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:E,nodeId:S,nodeClickDistance:k=0}){h=fo(w);function T({x:M,y:L}){const{nodeLookup:P,nodeExtent:Q,snapGrid:j,snapToGrid:$,nodeOrigin:U,onNodeDrag:B,onSelectionDrag:I,onError:X,updateNodePositions:q}=t();s={x:M,y:L};let D=!1;const H=o.size>1,re=H&&Q?vP(T1(o)):null,fe=H&&$?mNe({dragItems:o,snapGrid:j,x:M,y:L}):null;for(const[Ae,J]of o){if(!P.has(Ae))continue;let ie={x:M-J.distance.x,y:L-J.distance.y};$&&(ie=fe?{x:Math.round(ie.x+fe.x),y:Math.round(ie.y+fe.y)}:_1(ie,j));let ue=null;if(H&&Q&&!J.extent&&re){const{positionAbsolute:Re}=J.internals,Ee=Re.x-re.x+Q[0][0],me=Re.x+J.measured.width-re.x2+Q[1][0],oe=Re.y-re.y+Q[0][1],Ne=Re.y+J.measured.height-re.y2+Q[1][1];ue=[[Ee,oe],[me,Ne]]}const{position:ye,positionAbsolute:Se}=ate({nodeId:Ae,nextPosition:ie,nodeLookup:P,nodeExtent:ue||Q,nodeOrigin:U,onError:X});D=D||J.position.x!==ye.x||J.position.y!==ye.y,J.position=ye,J.internals.positionAbsolute=Se}if(g=g||D,!!D&&(q(o,!0),b&&(i||B||!S&&I))){const[Ae,J]=q2({nodeId:S,dragItems:o,nodeLookup:P});i==null||i(b,o,Ae,J),B==null||B(b,Ae,J),S||I==null||I(b,J)}}async function A(){if(!d)return;const{transform:M,panBy:L,autoPanSpeed:P,autoPanOnNodeDrag:Q}=t();if(!Q){c=!1,cancelAnimationFrame(a);return}const[j,$]=h$(u,d,P);(j!==0||$!==0)&&(s.x=(s.x??0)-j/M[2],s.y=(s.y??0)-$/M[2],await L({x:j,y:$})&&T(s)),a=requestAnimationFrame(A)}function N(M){var H;const{nodeLookup:L,multiSelectionActive:P,nodesDraggable:Q,transform:j,snapGrid:$,snapToGrid:U,selectNodesOnDrag:B,onNodeDragStart:I,onSelectionDragStart:X,unselectNodesAndEdges:q}=t();f=!0,(!B||!E)&&!P&&S&&((H=L.get(S))!=null&&H.selected||q()),E&&B&&S&&(e==null||e(S));const D=uy(M.sourceEvent,{transform:j,snapGrid:$,snapToGrid:U,containerBounds:d});if(s=D,o=pNe(L,Q,D,S),o.size>0&&(n||I||!S&&X)){const[re,fe]=q2({nodeId:S,dragItems:o,nodeLookup:L});n==null||n(M.sourceEvent,o,re,fe),I==null||I(M.sourceEvent,re,fe),S||X==null||X(M.sourceEvent,fe)}}const C=Qee().clickDistance(k).on("start",M=>{const{domNode:L,nodeDragThreshold:P,transform:Q,snapGrid:j,snapToGrid:$}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,g=!1,b=M.sourceEvent,P===0&&N(M),s=uy(M.sourceEvent,{transform:Q,snapGrid:j,snapToGrid:$,containerBounds:d}),u=Rl(M.sourceEvent,d)}).on("drag",M=>{const{autoPanOnNodeDrag:L,transform:P,snapGrid:Q,snapToGrid:j,nodeDragThreshold:$,nodeLookup:U}=t(),B=uy(M.sourceEvent,{transform:P,snapGrid:Q,snapToGrid:j,containerBounds:d});if(b=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||S&&!U.has(S))&&(p=!0),!p){if(!c&&L&&f&&(c=!0,A()),!f){const I=Rl(M.sourceEvent,d),X=I.x-u.x,q=I.y-u.y;Math.sqrt(X*X+q*q)>$&&N(M)}(s.x!==B.xSnapped||s.y!==B.ySnapped)&&o&&f&&(u=Rl(M.sourceEvent,d),T(B))}}).on("end",M=>{if(!f||p){p&&o.size>0&&t().updateNodePositions(o,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),o.size>0){const{nodeLookup:L,updateNodePositions:P,onNodeDragStop:Q,onSelectionDragStop:j}=t();if(g&&(P(o,!1),g=!1),r||Q||!S&&j){const[$,U]=q2({nodeId:S,dragItems:o,nodeLookup:L,dragging:!1});r==null||r(M.sourceEvent,o,$,U),Q==null||Q(M.sourceEvent,$,U),S||j==null||j(M.sourceEvent,U)}}}).filter(M=>{const L=M.target;return!M.button&&(!v||!K9(L,`.${v}`,w))&&(!x||K9(L,x,w))});h.call(C)}function O(){h==null||h.on(".drag",null)}return{update:y,destroy:O}}function bNe(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())ux(r,a0(s))>0&&i.push(s);return i}const ONe=250;function yNe(e,t,n,i){var o,c;let r=[],s=1/0;const a=bNe(e,n,t+ONe);for(const u of a){const d=[...((o=u.internals.handleBounds)==null?void 0:o.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(i.nodeId===f.nodeId&&i.type===f.type&&i.id===f.id)continue;const{x:h,y:p}=xp(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));g>t||(g1){const u=i.type==="source"?"target":"source";return r.find(d=>d.type===u)??r[0]}return r[0]}function wte(e,t,n,i,r,s=!1){var u,d,f;const a=i.get(e);if(!a)return null;const o=r==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?o==null?void 0:o.find(h=>h.id===n):o==null?void 0:o[0])??null;return c&&s?{...c,...xp(a,c,c.position,!0)}:c}function Ste(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function xNe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ete=()=>!0;function vNe(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:s,isTarget:a,domNode:o,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:p,onConnectStart:g,onConnect:b,onConnectEnd:y,isValidConnection:O=Ete,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:E,autoPanSpeed:S,dragThreshold:k=1,handleDomNode:T}){const A=dte(e.target);let N=0,C;const{x:M,y:L}=Rl(e),P=Ste(s,T),Q=o==null?void 0:o.getBoundingClientRect();let j=!1;if(!Q||!P)return;const $=wte(r,P,i,c,t);if(!$)return;let U=Rl(e,Q),B=!1,I=null,X=!1,q=null;function D(){if(!d||!Q)return;const[ye,Se]=h$(U,Q,S);h({x:ye,y:Se}),N=requestAnimationFrame(D)}const H={...$,nodeId:r,type:P,position:$.position},re=c.get(r);let Ae={inProgress:!0,isValid:null,from:xp(re,H,St.Left,!0),fromHandle:H,fromPosition:H.position,fromNode:re,to:U,toHandle:null,toPosition:B9[H.position],toNode:null,pointer:U};function J(){j=!0,x(Ae),g==null||g(e,{nodeId:r,handleId:i,handleType:P})}k===0&&J();function ie(ye){if(!j){const{x:Ne,y:Oe}=Rl(ye),Ve=Ne-M,We=Oe-L;if(!(Ve*Ve+We*We>k*k))return;J()}if(!E()||!H){ue(ye);return}const Se=w();U=Rl(ye,Q),C=yNe(X0(U,Se,!1,[1,1]),n,c,H),B||(D(),B=!0);const Re=kte(ye,{handle:C,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:a?"target":"source",isValidConnection:O,doc:A,lib:u,flowId:f,nodeLookup:c});q=Re.handleDomNode,I=Re.connection,X=xNe(!!C,Re.isValid);const Ee=c.get(r),me=Ee?xp(Ee,H,St.Left,!0):Ae.from,oe={...Ae,from:me,isValid:X,to:Re.toHandle&&X?o0({x:Re.toHandle.x,y:Re.toHandle.y},Se):U,toHandle:Re.toHandle,toPosition:X&&Re.toHandle?Re.toHandle.position:B9[H.position],toNode:Re.toHandle?c.get(Re.toHandle.nodeId):null,pointer:U};x(oe),Ae=oe}function ue(ye){if(!("touches"in ye&&ye.touches.length>0)){if(j){(C||q)&&I&&X&&(b==null||b(I));const{inProgress:Se,...Re}=Ae,Ee={...Re,toPosition:Ae.toHandle?Ae.toPosition:null};y==null||y(ye,Ee),s&&(v==null||v(ye,Ee))}p(),cancelAnimationFrame(N),B=!1,X=!1,I=null,q=null,A.removeEventListener("mousemove",ie),A.removeEventListener("mouseup",ue),A.removeEventListener("touchmove",ie),A.removeEventListener("touchend",ue)}}A.addEventListener("mousemove",ie),A.addEventListener("mouseup",ue),A.addEventListener("touchmove",ie),A.addEventListener("touchend",ue)}function kte(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s,doc:a,lib:o,flowId:c,isValidConnection:u=Ete,nodeLookup:d}){const f=s==="target",h=t?a.querySelector(`.${o}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:g}=Rl(e),b=a.elementFromPoint(p,g),y=b!=null&&b.classList.contains(`${o}-flow__handle`)?b:h,O={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Ste(void 0,y),x=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),E=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!x||!v)return O;const k={source:f?x:i,sourceHandle:f?w:r,target:f?i:x,targetHandle:f?r:w};O.connection=k;const A=E&&S&&(n===r0.Strict?f&&v==="source"||!f&&v==="target":x!==i||w!==r);O.isValid=A&&u(k),O.toHandle=wte(x,v,w,d,n,!0)}return O}const EP={onPointerDown:vNe,isValid:kte};function wNe({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=fo(e);function s({translateExtent:o,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const w=n(),E=x.sourceEvent.ctrlKey&&dx()?10:1,S=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,k=w[2]*Math.pow(2,S*E);t.scaleTo(k)};let b=[0,0];const y=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(b=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},O=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const E=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],S=[E[0]-b[0],E[1]-b[1]];b=E;const k=i()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),T={x:w[0]-S[0]*k,y:w[1]-S[1]*k},A=[[0,0],[c,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},A,o)},v=ete().on("start",y).on("zoom",f?O:null).on("zoom.wheel",h?g:null);r.call(v,{})}function a(){r.on("zoom",null)}return{update:s,destroy:a,pointer:Tl}}const R_=e=>({x:e.x,y:e.y,zoom:e.k}),H2=({x:e,y:t,zoom:n})=>N_.translate(e,t).scale(n),Jm=(e,t)=>e.target.closest(`.${t}`),Tte=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),SNe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Y2=(e,t=0,n=SNe,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},_te=e=>{const t=e.ctrlKey&&dx()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ENe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:o,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Jm(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const y=Tl(d),O=_te(d),v=f*Math.pow(2,O);i.scaleTo(n,v,y,d);return}const h=d.deltaMode===1?20:1;let p=r===rp.Vertical?0:d.deltaX*h,g=r===rp.Horizontal?0:d.deltaY*h;!dx()&&d.shiftKey&&r!==rp.Vertical&&(p=d.deltaY*h,g=0),i.translateBy(n,-(p/f)*s,-(g/f)*s,{internal:!0});const b=R_(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,o==null||o(d,b))}}function kNe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const s=i.type==="wheel",a=!t&&s&&!i.ctrlKey,o=Jm(i,e);if(i.ctrlKey&&s&&o&&i.preventDefault(),a||o)return null;i.preventDefault(),n.call(this,i,r)}}function TNe({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var s,a,o;if((s=i.sourceEvent)!=null&&s.internal)return;const r=R_(i.transform);e.mouseButton=((a=i.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((o=i.sourceEvent)==null?void 0:o.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function _Ne({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return s=>{var a,o;e.usedRightMouseButton=!!(n&&Tte(t,e.mouseButton??0)),(a=s.sourceEvent)!=null&&a.sync||i([s.transform.x,s.transform.y,s.transform.k]),r&&!((o=s.sourceEvent)!=null&&o.internal)&&(r==null||r(s.sourceEvent,R_(s.transform)))}}function ANe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:s}){return a=>{var o;if(!((o=a.sourceEvent)!=null&&o.internal)&&(e.isZoomingOrPanning=!1,s&&Tte(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=R_(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(a.sourceEvent,c)},n?150:0)}}}function NNe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:o,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var y;const h=e||t,p=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Jm(f,`${u}-flow__node`)||Jm(f,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!s&&!n||a||d&&!g||Jm(f,o)&&g||Jm(f,c)&&(!g||r&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((y=f.touches)==null?void 0:y.length)>1)return f.preventDefault(),!1;if(!h&&!r&&!p&&g||!i&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(i)&&!i.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function CNe({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:s,onPanZoomStart:a,onPanZoomEnd:o,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=ete().scaleExtent([t,n]).translateExtent(i),h=fo(e).call(f);v({x:r.x,y:r.y,zoom:s0(r.zoom,t,n)},[[0,0],[d.width,d.height]],i);const p=h.on("wheel.zoom"),g=h.on("dblclick.zoom");f.wheelDelta(_te);async function b(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).transform(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}function y({noWheelClassName:C,noPanClassName:M,onPaneContextMenu:L,userSelectionActive:P,panOnScroll:Q,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:U,preventScrolling:B,zoomOnPinch:I,zoomOnScroll:X,zoomOnDoubleClick:q,zoomActivationKeyPressed:D,lib:H,onTransformChange:re,connectionInProgress:fe,paneClickDistance:Ae,selectionOnDrag:J}){P&&!u.isZoomingOrPanning&&O();const ie=Q&&!D&&!P;f.clickDistance(J?1/0:!jl(Ae)||Ae<0?0:Ae);const ue=ie?ENe({zoomPanValues:u,noWheelClassName:C,d3Selection:h,d3Zoom:f,panOnScrollMode:$,panOnScrollSpeed:U,zoomOnPinch:I,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:o}):kNe({noWheelClassName:C,preventScrolling:B,d3ZoomHandler:p});h.on("wheel.zoom",ue,{passive:!1});const ye=TNe({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",ye);const Se=_Ne({zoomPanValues:u,panOnDrag:j,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:re});f.on("zoom",Se);const Re=ANe({zoomPanValues:u,panOnDrag:j,panOnScroll:Q,onPaneContextMenu:L,onPanZoomEnd:o,onDraggingChange:c});f.on("end",Re);const Ee=NNe({zoomActivationKeyPressed:D,panOnDrag:j,zoomOnScroll:X,panOnScroll:Q,zoomOnDoubleClick:q,zoomOnPinch:I,userSelectionActive:P,noPanClassName:M,noWheelClassName:C,lib:H,connectionInProgress:fe});f.filter(Ee),q?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function O(){f.on("zoom",null)}async function v(C,M,L){const P=H2(C),Q=f==null?void 0:f.constrain()(P,M,L);return Q&&await b(Q),Q}async function x(C,M){const L=H2(C);return await b(L,M),L}function w(C){if(h){const M=H2(C),L=h.property("__zoom");(L.k!==C.zoom||L.x!==C.x||L.y!==C.y)&&(f==null||f.transform(h,M,null,{sync:!0}))}}function E(){const C=h?Jee(h.node()):{x:0,y:0,k:1};return{x:C.x,y:C.y,zoom:C.k}}async function S(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).scaleTo(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}async function k(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).scaleBy(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}function T(C){f==null||f.scaleExtent(C)}function A(C){f==null||f.translateExtent(C)}function N(C){const M=!jl(C)||C<0?0:C;f==null||f.clickDistance(M)}return{update:y,destroy:O,setViewport:x,setViewportConstrained:v,getViewport:E,scaleTo:S,scaleBy:k,setScaleExtent:T,setTranslateExtent:A,syncViewport:w,setClickDistance:N}}var l0;(function(e){e.Line="line",e.Handle="handle"})(l0||(l0={}));function jNe({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:s}){const a=e-t,o=n-i,c=[a>0?1:a<0?-1:0,o>0?1:o<0?-1:0];return a&&r&&(c[0]=c[0]*-1),o&&s&&(c[1]=c[1]*-1),c}function J9(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Rd(e,t){return Math.max(0,t-e)}function Id(e,t){return Math.max(0,e-t)}function fw(e,t,n){return Math.max(0,t-e,e-n)}function eU(e,t){return e?!t:t}function RNe(e,t,n,i,r,s,a,o){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:b,maxWidth:y,minHeight:O,maxHeight:v}=i,{x,y:w,width:E,height:S,aspectRatio:k}=e;let T=Math.floor(d?p-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const N=E+(c?-T:T),C=S+(u?-A:A),M=-s[0]*E,L=-s[1]*S;let P=fw(N,b,y),Q=fw(C,O,v);if(a){let U=0,B=0;c&&T<0?U=Rd(x+T+M,a[0][0]):!c&&T>0&&(U=Id(x+N+M,a[1][0])),u&&A<0?B=Rd(w+A+L,a[0][1]):!u&&A>0&&(B=Id(w+C+L,a[1][1])),P=Math.max(P,U),Q=Math.max(Q,B)}if(o){let U=0,B=0;c&&T>0?U=Id(x+T,o[0][0]):!c&&T<0&&(U=Rd(x+N,o[1][0])),u&&A>0?B=Id(w+A,o[0][1]):!u&&A<0&&(B=Rd(w+C,o[1][1])),P=Math.max(P,U),Q=Math.max(Q,B)}if(r){if(d){const U=fw(N/k,O,v)*k;if(P=Math.max(P,U),a){let B=0;!c&&!u||c&&!u&&h?B=Id(w+L+N/k,a[1][1])*k:B=Rd(w+L+(c?T:-T)/k,a[0][1])*k,P=Math.max(P,B)}if(o){let B=0;!c&&!u||c&&!u&&h?B=Rd(w+N/k,o[1][1])*k:B=Id(w+(c?T:-T)/k,o[0][1])*k,P=Math.max(P,B)}}if(f){const U=fw(C*k,b,y)/k;if(Q=Math.max(Q,U),a){let B=0;!c&&!u||u&&!c&&h?B=Id(x+C*k+M,a[1][0])/k:B=Rd(x+(u?A:-A)*k+M,a[0][0])/k,Q=Math.max(Q,B)}if(o){let B=0;!c&&!u||u&&!c&&h?B=Rd(x+C*k,o[1][0])/k:B=Id(x+(u?A:-A)*k,o[0][0])/k,Q=Math.max(Q,B)}}}A=A+(A<0?Q:-Q),T=T+(T<0?P:-P),r&&(h?N>C*k?A=(eU(c,u)?-T:T)/k:T=(eU(c,u)?-A:A)*k:d?(A=T/k,u=c):(T=A*k,c=u));const j=c?x+T:x,$=u?w+A:w;return{width:E+(c?-T:T),height:S+(u?-A:A),x:s[0]*T*(c?-1:1)+j,y:s[1]*A*(u?-1:1)+$}}const Ate={width:0,height:0,x:0,y:0},INe={...Ate,pointerX:0,pointerY:0,aspectRatio:1};function PNe(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,a=e.measured.height??0,o=n[0]*s,c=n[1]*a;return[[i-o,r-c],[i+s-o,r+a-c]]}function MNe({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const s=fo(e);let a={controlDirection:J9("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function o({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:g,onResizeEnd:b,shouldResize:y}){let O={...Ate},v={...INe};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:J9(u)};let x,w=null,E=[],S,k,T,A=!1;const N=Qee().on("start",C=>{const{nodeLookup:M,transform:L,snapGrid:P,snapToGrid:Q,nodeOrigin:j,paneDomNode:$}=n();if(x=M.get(t),!x)return;w=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:U,ySnapped:B}=uy(C.sourceEvent,{transform:L,snapGrid:P,snapToGrid:Q,containerBounds:w});O={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...O,pointerX:U,pointerY:B,aspectRatio:O.width/O.height},S=void 0,k=yp(x.extent)?x.extent:void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(S=M.get(x.parentId)),S&&x.extent==="parent"&&(k=[[0,0],[S.measured.width,S.measured.height]]),E=[],T=void 0;for(const[I,X]of M)if(X.parentId===t&&(E.push({id:I,position:{...X.position},extent:X.extent}),X.extent==="parent"||X.expandParent)){const q=PNe(X,x,X.origin??j);T?T=[[Math.min(q[0][0],T[0][0]),Math.min(q[0][1],T[0][1])],[Math.max(q[1][0],T[1][0]),Math.max(q[1][1],T[1][1])]]:T=q}p==null||p(C,{...O})}).on("drag",C=>{const{transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q}=n(),j=uy(C.sourceEvent,{transform:M,snapGrid:L,snapToGrid:P,containerBounds:w}),$=[];if(!x)return;const{x:U,y:B,width:I,height:X}=O,q={},D=x.origin??Q,{width:H,height:re,x:fe,y:Ae}=RNe(v,a.controlDirection,j,a.boundaries,a.keepAspectRatio,D,k,T),J=H!==I,ie=re!==X,ue=fe!==U&&J,ye=Ae!==B&&ie;if(!ue&&!ye&&!J&&!ie)return;if((ue||ye||D[0]===1||D[1]===1)&&(q.x=ue?fe:O.x,q.y=ye?Ae:O.y,O.x=q.x,O.y=q.y,E.length>0)){const me=fe-U,oe=Ae-B;for(const Ne of E)Ne.position={x:Ne.position.x-me+D[0]*(H-I),y:Ne.position.y-oe+D[1]*(re-X)},$.push(Ne)}if((J||ie)&&(q.width=J&&(!a.resizeDirection||a.resizeDirection==="horizontal")?H:O.width,q.height=ie&&(!a.resizeDirection||a.resizeDirection==="vertical")?re:O.height,O.width=q.width,O.height=q.height),S&&x.expandParent){const me=D[0]*(q.width??0);q.x&&q.x{A&&(b==null||b(C,{...O}),r==null||r({...O}),A=!1)});s.call(N)}function c(){s.on(".drag",null)}return{update:o,destroy:c}}var Nte={exports:{}},Cte={},jte={exports:{}},Rte={};/** +${i}`}}async function EJ(e,t=!1){const n=await Dt(`/web/model-api-keys${t?"?refresh=true":""}`,{signal:e,cache:"no-store"});if(!n.ok)throw new Error(await an(n,"加载 Ark API Key 失败"));return await n.json()}async function kJ(e,t){const n=await Dt(`/web/model-api-keys/${encodeURIComponent(e)}/value`,{method:"POST",signal:t,cache:"no-store"});if(!n.ok)throw new Error(await an(n,"加载 Ark API Key 失败"));return await n.json()}async function TJ(e){const t=new URLSearchParams;e!=null&&e.apiKeyId&&t.set("apiKeyId",e.apiKeyId),e!=null&&e.refresh&&t.set("refresh","true");const n=t.toString(),i=await Dt(`/web/model-options${n?`?${n}`:""}`,{signal:e==null?void 0:e.signal,cache:"no-store"});if(!i.ok)throw new Error(await an(i,"加载模型列表失败"));return await i.json()}async function _J(){const e=await Dt("/list-apps");if(!e.ok)throw new Error(`list-apps failed: ${e.status}`);return e.json()}class z0 extends Error{constructor(){super("当前账号无权访问该 Runtime,请刷新列表或重新登录后重试。"),this.name="RuntimeAccessDeniedError"}}class ga extends Error{constructor(t,n=!1,i=!1){super(t),this.unsupported=n,this.retryable=i,this.name="RuntimeProbeError"}}const AJ="Runtime 已部署成功,但当前 Studio 无法访问私网 Runtime。请使用已绑定相同 VPC 的 Studio 访问,或改用公网 / 公网+VPC 部署。",NJ="Runtime 已部署成功,但 Studio 暂时无法连接服务。网关域名可能仍在生效,或当前网络/DNS 无法访问该 Runtime,请稍后在智能体管理页重试连接。",d9=["cn-beijing","cn-shanghai"],lEe=3e4,x_=5*60*1e3,CJ=60*1e3;let jJ="volcengine";const BS=new Map,Th=new Map,_h=new Map,_l=new Map;function RJ(e,t){return`${t}:${e}`}function IJ(e){jJ=e}function Jf(e){const t=(e||"").trim();if(jJ==="byteplus")return[t&&!t.startsWith("cn-")?t:tP];const n=t&&!t.startsWith("ap-")?t:QD;return d9.includes(n)?[n,...d9.filter(i=>i!==n)]:[n]}function F0(...e){return e.map(t=>String(t??"")).join("")}function V0(e,t,n){const i=e.get(t);return i!=null&&i.value&&Date.now()-i.updatedAt<=n?i.value:null}function XD(e,t,n){return e.set(t,{value:n,updatedAt:Date.now()}),n}async function PJ(e){try{const t=await e.clone().json();return typeof t.detail=="string"?t.detail:""}catch{return""}}async function v_(e,t,n){const i=await Dt("/list-apps",{},n??{base:e,apiKey:t}),r=n!=null&&n.runtimeId?await PJ(i):"";if(n!=null&&n.runtimeId&&r==="runtime_access_denied")throw new z0;if(n!=null&&n.runtimeId&&r==="runtime_private_endpoint_unreachable")throw new ga(AJ);if(n!=null&&n.runtimeId&&["runtime_proxy_connect_error","runtime_proxy_timeout","runtime_json_connect_error","runtime_json_timeout"].includes(r))throw new ga(NJ,!1,!0);if(n!=null&&n.runtimeId&&i.status===404)throw new ga("该 Runtime 的 Agent Server 未提供连接接口,请确认 Runtime 已就绪且版本兼容。",!0,!0);if(n!=null&&n.runtimeId&&(i.status===401||i.status===403))throw new ga("Runtime 服务拒绝了连接请求,请检查 Runtime 的鉴权配置。");if(!i.ok)throw new Error(await an(i,"读取 Agent 列表失败"));const s=await i.json();return n!=null&&n.runtimeId&&BS.set(RJ(n.runtimeId,n.region??""),{apps:s,expiresAt:Date.now()+lEe}),s}async function MJ(e,t){const{app:n,ep:i}=Hr(e),r=await Dt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},i);if(!r.ok){const a=`创建会话失败 (${r.status})`,o=await an(r,"创建会话失败");throw new Error(o===a?a:`${a}:${o}`)}return(await r.json()).id}async function qD(e,t){const{app:n,ep:i}=Hr(e),r=await Dt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{},i);if(!r.ok)throw new Error(`list sessions failed: ${r.status}`);return r.json()}async function gk(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(`/apps/${i}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}`,{},r);if(!s.ok){const o=await an(s,"读取会话失败");throw new Error(`get session failed: ${s.status}:${o}`)}const a=await s.json();if(r.runtimeId){const o=zD(r.runtimeId,i,t,n);a.state={...FD()[o]??{},...a.state??{}}}return a}async function LJ(e){const{app:t,ep:n}=Hr(e.appName);if(!n.runtimeId)throw new Error("只有连接到 AgentKit Runtime 的会话支持反馈回流");if(!n.region)throw new Error("Runtime 缺少地域信息,无法提交反馈");const i=await Dt("/web/evaluation/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:n.runtimeId,region:n.region,appName:t,userId:e.userId,sessionId:e.sessionId,eventId:e.eventId,rating:e.rating,comment:e.comment??""})},{},kr);if(!i.ok)throw new Error(await an(i,"提交反馈失败"));const r=await i.json(),s=zD(n.runtimeId,t,e.userId,e.sessionId);return aEe(s,e.eventId,r),r}async function w_(e,t={}){const n=F0(e.runtimeId,e.region||"cn-beijing",e.appName,e.pageSize??100),i=V0(_l,n,CJ);if(!t.force&&i)return i;const r=_l.get(n);if(!t.force&&(r!=null&&r.promise))return r.promise;let s=null;const a=(async()=>{for(const o of Jf(e.region)){const c=new URLSearchParams({runtimeId:e.runtimeId,region:o,appName:e.appName,page_size:String(e.pageSize??100)}),u=await Dt(`/web/evaluation/feedback-cases?${c.toString()}`);if(u.ok)return XD(_l,n,await u.json());s=new Error(await an(u,"读取评测集失败"))}throw s??new Error("读取评测集失败")})();_l.set(n,{...r,promise:a,updatedAt:(r==null?void 0:r.updatedAt)??0});try{return await a}finally{const o=_l.get(n);(o==null?void 0:o.promise)===a&&_l.set(n,{value:o.value,updatedAt:o.updatedAt})}}async function DJ(e){let t=null;for(const n of Jf(e.region)){const i=new URLSearchParams({runtimeId:e.runtimeId,region:n,appName:e.appName,userId:e.userId}),r=await Dt(`/web/evaluation/statuses?${i.toString()}`);if(r.ok)return r.json();t=new Error(await an(r,"读取自动评测状态失败"))}throw t??new Error("读取自动评测状态失败")}async function $J(e){let t=null;for(const n of Jf(e.region)){const i=new URLSearchParams({runtimeId:e.runtimeId,region:n,appName:e.appName}),r=await Dt(`/web/evaluation/optimizations?${i.toString()}`);if(r.ok)return r.json();t=new Error(await an(r,"读取优化项失败"))}throw t??new Error("读取优化项失败")}function QJ(e){return V0(_l,F0(e.runtimeId,e.region||"cn-beijing",e.appName,e.pageSize??100),CJ)}function nP(e){w_(e).catch(()=>{})}function BJ(e){w_(e,{force:!0}).catch(()=>{})}function UJ(e,t){return["good","bad"].map(n=>{const i=e.find(r=>r.kind===n);return{kind:n,evaluationSetId:(i==null?void 0:i.evaluationSetId)??null,evaluationSetName:(i==null?void 0:i.evaluationSetName)??null,workspaceId:(i==null?void 0:i.workspaceId)??null,itemCount:t.filter(r=>r.kind===n).length}})}function US(e){const t=e.comment??"",n=e.rating==="bad"&&!!t.trim();for(const[i,r]of _l.entries()){const s=r.value;if(!s||s.runtimeId!==e.runtimeId||s.agentName!==e.appName)continue;const a=s.items.filter(c=>c.sessionId!==e.sessionId||c.messageId!==e.messageId),o=e.rating?[{id:`local:${e.runtimeId}:${e.sessionId}:${e.messageId}`,itemKey:`local:${e.messageId}`,kind:e.rating,input:e.input,output:e.output,referenceOutput:e.referenceOutput??e.output,comment:t,agentName:e.appName,sessionId:e.sessionId,messageId:e.messageId,runtimeId:e.runtimeId,invocationId:e.invocationId??"",userId:e.userId,createdAt:e.createdAt??new Date().toISOString(),evaluationSetId:"",evaluationSetName:"",workspaceId:"",source:"user",score:n?0:null,reason:n?t:""},...a]:a;_l.set(i,{value:{...s,sets:UJ(s.sets,o),items:o},updatedAt:Date.now(),promise:r.promise})}}async function zJ(e){let t=null;for(const n of Jf(e.region)){const i=await Dt("/web/evaluation/feedback-cases/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e.runtimeId,region:n,appName:e.appName,itemIds:e.itemIds})},{},kr);if(i.ok){const r=await i.json(),s=new Set(e.itemIds);for(const[a,o]of _l.entries()){const c=o.value;if(!c||c.runtimeId!==e.runtimeId||c.agentName!==e.appName)continue;const u=c.items.filter(d=>!s.has(d.id));_l.set(a,{value:{...c,sets:UJ(c.sets,u),items:u},updatedAt:Date.now()})}return r}t=new Error(await an(i,"删除评测案例失败"))}throw t??new Error("删除评测案例失败")}async function iP(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(`/apps/${i}/users/${encodeURIComponent(t)}/sessions/${n}`,{method:"DELETE"},r);if(!s.ok&&s.status!==404)throw new Error(`delete session failed: ${s.status}`)}function cEe(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"="),i=window.atob(n),r=new Uint8Array(i.length);for(let s=0;sURL.revokeObjectURL(o),0)}async function FJ(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=r==null?"":`?version=${encodeURIComponent(r)}`,c=`/apps/${encodeURIComponent(s)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(i)}${o}`,u=await Dt(c,{},a,kr);if(!u.ok)throw new Error(await an(u,"下载文件失败"));const d=await u.json(),f=d.inlineData??d.inline_data;if(!(f!=null&&f.data))throw new Error("文件内容不可用");const h=cEe(f.data),p=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);return{blob:new Blob([p],{type:f.mimeType??f.mime_type??"application/octet-stream"}),downloadName:f.displayName??f.display_name??i}}async function YD(e,t,n,i,r){const{blob:s}=await FJ(e,t,n,i,r);return URL.createObjectURL(s)}async function uEe(e){const t=await Dt("/web/media/capabilities");if(!t.ok)throw new Error(await an(t,"media capabilities failed"));return t.json()}async function VJ(e,t,n,i){const{app:r}=Hr(e),s=new FormData;s.set("app_name",r),s.set("user_id",t),s.set("session_id",n),s.set("file",i);const a=await Dt("/web/media",{method:"POST",body:s},{},kr);if(!a.ok)throw new Error(await an(a,"文件上传失败"));return{...await a.json(),status:"ready"}}async function rP(e,t,n){const{app:i}=Hr(e),r=`/web/media/${encodeURIComponent(i)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/delete`,s=await Dt(r,{method:"POST"});if(!s.ok&&s.status!==404)throw new Error(await an(s,"media cleanup failed"))}function XJ(e){try{const t=new URL(e);if(t.protocol!=="veadk-media:"||t.hostname!=="apps")return;const n=t.pathname.split("/").filter(Boolean).map(decodeURIComponent);return n.length!==7||n[1]!=="users"||n[3]!=="sessions"||n[5]!=="media"?void 0:`/web/media/${n.map(encodeURIComponent).filter((i,r)=>![1,3,5].includes(r)).join("/")}`}catch{return}}async function zS(e,t){const n=XJ(t);if(!n)throw new Error("Invalid VeADK media URI");const i=await Dt(`${n}/delete`,{method:"POST"});if(!i.ok&&i.status!==404)throw new Error(await an(i,"media cleanup failed"))}function qJ(e,t){if(t.startsWith("data:")||t.startsWith("blob:")||/^https?:/.test(t))return t;const n=XJ(t);if(!n)return t;const i=`${n}/content`;return vo(`${QS}${i}`)}async function bk(e,t,n){const{app:i,ep:r}=Hr(e);let s;if(r.runtimeId){const c=new URLSearchParams({runtimeId:r.runtimeId,sessionId:t,region:r.region??"cn-beijing"});if(n&&c.set("endTimeMs",String(Math.round(n))),s=await Dt(`/web/runtime-trace?${c.toString()}`),s.status===404)throw new Error("该 Agent 暂未开启链路观测,请到控制台打开后使用。")}else s=await Dt(`/dev/apps/${encodeURIComponent(i)}/debug/trace/session/${encodeURIComponent(t)}`,{},r);if(!s.ok)throw new Error(await an(s,"加载调用链路失败"));const a=s.headers.get("content-type")??"";if(!a.includes("application/json")){const c=a.split(";",1)[0]||"Content-Type 缺失";throw new Error(`trace failed: 服务端返回了非 JSON 响应(${c}),请检查 Studio API 代理配置`)}const o=await s.json();if(!Array.isArray(o))throw new Error("trace failed: 返回格式无效");return o}async function sP(e){const t=await Dt("/web/issue-feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await an(t,"问题反馈上报失败"));if((await t.json()).submitted!==!0)throw new Error("问题反馈上报失败:服务端未确认提交结果");return{submitted:!0}}function GD(e){const t=n=>({id:String(n.id??""),kind:n.kind==="skill"?"skill":"tool",name:String(n.name??""),custom:n.custom===!0,description:typeof n.description=="string"?n.description:void 0,skillSourceId:typeof n.skill_source_id=="string"?n.skill_source_id:void 0,version:typeof n.version=="string"?n.version:void 0});return{schemaVersion:Number(e.schema_version??1),revision:Number(e.revision??0),tools:Array.isArray(e.tools)?e.tools.map(n=>t(n)):[],skills:Array.isArray(e.skills)?e.skills.map(n=>t(n)):[]}}function WD(e,t,n){return`/harness/apps/${encodeURIComponent(e)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/capabilities`}async function aP(e,t,n){const{app:i,ep:r}=Hr(e),s=await Dt(WD(i,t,n),{},r);if(!s.ok)throw new Error(await an(s,"读取会话能力失败"));return GD(await s.json())}async function ZD(e){const{ep:t}=Hr(e),n=await Dt("/harness/capabilities/tools",{},t);if(!n.ok)throw new Error(await an(n,"读取内置工具失败"));return((await n.json()).tools??[]).map(r=>{var s;return((s=r.name)==null?void 0:s.trim())??""}).filter(Boolean)}async function dEe(e){const{ep:t}=Hr(e),n=await Dt("/harness/skills/spaces?region=all",{},t);if(!n.ok)throw new Error(await an(n,"读取 Skill Space 失败"));return(await n.json()).items??[]}async function fEe(e,t,n){const{ep:i}=Hr(e),r=new URLSearchParams({region:n||"cn-beijing"}),s=`/harness/skills/spaces/${encodeURIComponent(t)}/skills?${r.toString()}`,a=await Dt(s,{},i);if(!a.ok)throw new Error(await an(a,"读取 Skill 列表失败"));return(await a.json()).items??[]}async function HJ(e,t,n=1,i=20){const{ep:r}=Hr(e),s=new URLSearchParams({query:t,page_number:String(n),page_size:String(i)}),a=await Dt(`/harness/skills/findskill?${s.toString()}`,{},r);if(!a.ok)throw new Error(await an(a,"搜索 Skill Hub 失败"));const o=await a.json();return{items:o.items??[],totalCount:Number(o.totalCount??0)}}async function oP(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=await Dt(WD(s,t,n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:i.kind,name:i.name,skill_source_id:i.skillSourceId,description:i.description,version:i.version,expected_revision:r})},a);if(!o.ok)throw new Error(await an(o,"添加会话能力失败"));return GD(await o.json())}async function YJ(e,t,n,i,r){const{app:s,ep:a}=Hr(e),o=`${WD(s,t,n)}/${encodeURIComponent(i)}?expected_revision=${r}`,c=await Dt(o,{method:"DELETE"},a);if(!c.ok)throw new Error(await an(c,"移除会话能力失败"));return GD(await c.json())}async function GJ(e,t,n=!0){const i=await Dt(`/web/agent-info/${e}`,{},t);if(!i.ok)throw new Error(`agent-info failed: ${i.status}`);const r=await i.json();if(n&&!r.draft)try{const s=await Dt(`/web/agent-draft/${e}`,{},t);if(s.ok){const a=await s.json();r.draft=a.draft}}catch{}return{appName:e,name:r.name??e,description:r.description??"",type:r.type,model:r.model??"",tools:r.tools??[],skillsPreviewSupported:Array.isArray(r.skills),skills:r.skills??[],subAgents:r.subAgents??[],components:r.components??[],searchSources:r.searchSources??[],graph:r.graph,draft:r.draft}}async function WJ(e){const{app:t,ep:n}=Hr(e);return GJ(t,n,!1)}async function hEe(e,t,n){let i=null;for(const r of Jf(t)){const s={runtimeId:e,region:r};try{const a=RJ(e,r),o=BS.get(a);o&&o.expiresAt<=Date.now()&&BS.delete(a);const c=BS.get(a),u=n||(c==null?void 0:c.apps[0])||(await v_("","",s))[0];if(!u)throw new Error("该 Runtime 未提供可预览的 Agent。");return GJ(u,s)}catch(a){if(a instanceof z0||a instanceof ga&&!a.unsupported)throw a;i=a instanceof Error?a:new Error(String(a))}}throw i??new Error("该 Runtime 未提供可预览的 Agent。")}async function Ok(e,t,n={},i={}){const r=typeof n=="string"?n:void 0,s=typeof n=="string"?i:n,a=F0(e,t||"cn-beijing",r??""),o=V0(Th,a,x_);if(!s.force&&o)return o;const c=Th.get(a);if(!s.force&&(c!=null&&c.promise))return c.promise;const u=hEe(e,t,r).then(d=>XD(Th,a,d));Th.set(a,{...c,promise:u,updatedAt:(c==null?void 0:c.updatedAt)??0});try{return await u}finally{const d=Th.get(a);(d==null?void 0:d.promise)===u&&Th.set(a,{value:d.value,updatedAt:d.updatedAt})}}function ZJ(e,t,n=""){return V0(Th,F0(e,t||"cn-beijing",n),x_)}function KJ(e,t,n=""){Ok(e,t,n).catch(()=>{})}async function JJ(e,t,n,i){const{app:r,ep:s}=Hr(e),a=new URLSearchParams({source:t,app_name:r,q:n,user_id:i}),o=await Dt(`/web/search?${a.toString()}`,{},s);if(!o.ok)throw new Error(await an(o,"Agent 检索失败"));return o.json()}async function eee(e,t){const{app:n}=Hr(e),i=await Dt(`/web/search?source=web&app_name=${encodeURIComponent(n)}&q=${encodeURIComponent(t)}`);if(!i.ok)throw new Error(`web search failed: ${i.status}`);return i.json()}async function*lP({appName:e,userId:t,sessionId:n,text:i,attachments:r=[],invocation:s,functionResponses:a=[],signal:o,sessionCapabilities:c=!1}){const{app:u,ep:d}=Hr(e),f=r.flatMap(b=>b.status&&b.status!=="ready"?[]:b.uri?[{fileData:{mimeType:b.mimeType,fileUri:b.uri,displayName:b.name},partMetadata:{veadkMedia:{id:b.id,uri:b.uri,name:b.name,mimeType:b.mimeType,sizeBytes:b.sizeBytes}}}]:b.data?[{inlineData:{mimeType:b.mimeType,data:b.data,displayName:b.name}}]:[]),h=s&&(s.skills.length>0||s.targetAgent)?s:void 0,p=[...f,...a.map(b=>({functionResponse:{id:b.id,name:b.name,response:b.response}})),...i.trim()?[{text:i}]:[]];if(h&&p.length>0){const b=p[0],y=b.partMetadata;p[0]={...b,partMetadata:{...y,veadkInvocation:h}}}const g=await Dt(c?"/harness/run_sse":"/run_sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:u,user_id:t,session_id:n,new_message:{role:"user",parts:p},streaming:!0,custom_metadata:h?{veadkInvocation:h}:void 0}),signal:o},d,0);if(!g.ok){const b=await an(g,"运行会话失败");throw new Error(iw(`run_sse failed: ${g.status}:${b}`))}for await(const b of $D(g)){const y=b;typeof y.error=="string"&&(y.error=iw(y.error)),typeof y.errorMessage=="string"&&(y.errorMessage=iw(y.errorMessage)),typeof y.error_message=="string"&&(y.error_message=iw(y.error_message)),yield y}}async function tee(e,t){const n=new URLSearchParams({name:e,region:t}),i=await Dt(`/web/runtime-name-availability?${n.toString()}`,{cache:"no-store"});if(!i.ok)throw new Error(await an(i,"检查 Runtime 名称失败"));const r=await i.json();if(typeof r.available!="boolean")throw new Error("检查 Runtime 名称失败:服务返回格式错误");return{available:r.available}}async function nee(e,t){const n=new URLSearchParams({kind:e.kind,region:e.region});e.registry&&n.set("registry",e.registry),e.namespace&&n.set("namespace",e.namespace),e.workspaceId&&n.set("workspaceId",e.workspaceId),e.search&&n.set("search",e.search),e.pageNumber&&n.set("pageNumber",String(e.pageNumber)),e.pageSize&&n.set("pageSize",String(e.pageSize));const i=await Dt(`/web/deployment-resources?${n.toString()}`,{signal:t});if(!i.ok)throw new Error(await an(i,"加载云资源失败"));const r=await i.json();if(typeof r.serviceRegion!="string"||!Array.isArray(r.items)||typeof r.pageNumber!="number"||typeof r.pageSize!="number"||typeof r.totalCount!="number"||typeof r.hasMore!="boolean")throw new Error("云资源列表响应格式无效");const s=r.items.map(a=>{if(!a||typeof a!="object"||typeof a.id!="string"||typeof a.name!="string"||typeof a.region!="string"||typeof a.status!="string")throw new Error("云资源列表响应格式无效");return a});return{serviceRegion:r.serviceRegion,items:s,pageNumber:r.pageNumber,pageSize:r.pageSize,totalCount:r.totalCount,hasMore:r.hasMore}}async function iee(e){var r;const t=await Dt("/web/system-info",{signal:e});if(!t.ok)throw new Error(await an(t,"加载系统信息失败"));const n=await t.json();if(typeof((r=n.storage)==null?void 0:r.tosAddress)!="string"||!Array.isArray(n.sandboxTools))throw new Error("系统信息响应格式无效");const i=n.sandboxTools.map(s=>{if(!s||typeof s!="object"||typeof s.kind!="string"||typeof s.label!="string"||typeof s.toolId!="string"||typeof s.snapshot!="boolean")throw new Error("系统信息响应格式无效");return s});return{storage:{tosAddress:n.storage.tosAddress},sandboxTools:i}}async function KD(e){const t=await Dt("/web/identity/user-pools",{signal:e});if(!t.ok)throw new Error(await an(t,"加载用户池失败"));const n=await t.json();if(!Array.isArray(n.items))throw new Error("用户池列表响应格式无效");return n.items.map(i=>{if(!i||typeof i!="object"||typeof i.uid!="string"||typeof i.name!="string"||typeof i.domain!="string"||typeof i.region!="string"||typeof i.isCurrent!="boolean")throw new Error("用户池列表响应格式无效");return i})}const ly=new Map;async function w1(e,t,n,i){var f,h,p,g,b;const r=i==null?void 0:i.taskId,s=r?new AbortController:void 0;r&&s&&ly.set(r,s);const a=()=>{r&&ly.get(r)===s&&ly.delete(r)};let o;try{const y=!!(i!=null&&i.migrationTaskId);(f=i==null?void 0:i.onStage)==null||f.call(i,{level:"info",phase:"upload",message:y?"正在校验迁移产物":"正在上传代码包",pct:0}),o=await Dt("/web/deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},signal:s==null?void 0:s.signal,body:JSON.stringify({name:e,files:y?[]:t,config:n,taskId:r,migrationTaskId:i==null?void 0:i.migrationTaskId,runtimeId:i==null?void 0:i.runtimeId,runtimeName:i==null?void 0:i.runtimeName,appName:i==null?void 0:i.appName,sessionStorage:i==null?void 0:i.sessionStorage,minInstance:i==null?void 0:i.minInstance,maxInstance:i==null?void 0:i.maxInstance,createEvaluationSets:i==null?void 0:i.createEvaluationSets,description:LSe((i==null?void 0:i.description)??""),authentication:i==null?void 0:i.authentication,im:i==null?void 0:i.im,envs:i==null?void 0:i.envs,resources:i==null?void 0:i.resources})},{},0),(h=i==null?void 0:i.onStage)==null||h.call(i,{level:"success",phase:"upload",message:y?"迁移产物校验完成":"代码包上传完成",pct:100})}catch(y){throw a(),y}if(!o.ok){const y=await an(o,"部署失败");throw a(),new Error(y)}let c=null;try{for await(const y of $D(o)){const O=y;if(O&&O.done){c=O;break}O&&O.message&&((p=i==null?void 0:i.onStage)==null||p.call(i,O))}}catch(y){throw a(),y}if(a(),!c)throw new Error("部署失败:连接中断");if(!c.success)throw new Error(c.error||"部署失败");if(!c.agentName)throw new Error("部署失败:返回缺少 Agent 名称");if(!c.runtimeId&&!c.url)throw new Error("部署失败:返回缺少 AgentKit 连接信息");const u=(g=c.runtimeName)!=null&&g.trim()?c.agentName:e,d=((b=c.runtimeName)==null?void 0:b.trim())||c.agentName;return{apikey:c.apikey??"",url:c.url??"",agentName:u,runtimeName:d,runtimeId:c.runtimeId,consoleUrl:c.consoleUrl,region:c.region,version:c.version,warnings:c.warnings,feishuChannel:c.feishuChannel}}async function ree(e){var n;const t=await Dt("/web/cancel-deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e})});if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`取消部署失败 (${t.status})`)}(n=ly.get(e))==null||n.abort(),ly.delete(e)}async function pEe(e=QD){const t=await Dt(`/web/my-runtimes?region=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`加载失败 (${t.status})`);return(await t.json()).runtimes??[]}const nx={title:"AgentKit Studio",logoUrl:""},cP={enabled:!1},B2={studio:!1,version:"",provider:"volcengine",branding:nx,features:{newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,agentUsage:!1,addAgentkit:!0,generatedAgentTestRun:!0},defaultView:"chat",agentsSource:"local",telemetry:cP};function mEe(e){if(!e||typeof e!="object")return cP;const t=e;if(t.enabled!==!0||!t.studio||typeof t.studio!="object")return cP;const n=t.studio;return{enabled:!0,studio:{deployId:typeof n.deployId=="string"?n.deployId:"",userPoolId:typeof n.userPoolId=="string"?n.userPoolId:"",applicationId:typeof n.applicationId=="string"?n.applicationId:"",functionId:typeof n.functionId=="string"?n.functionId:"",region:typeof n.region=="string"?n.region:"",project:typeof n.project=="string"?n.project:"",version:typeof n.version=="string"?n.version:"",accountId:typeof n.accountId=="string"?n.accountId:""}}}async function see(){var e,t;try{const n=await Dt("/web/ui-config");if(!n.ok)return B2;const i=await n.json(),r=typeof((e=i.branding)==null?void 0:e.logoUrl)=="string"?i.branding.logoUrl:nx.logoUrl,s=i.provider==="byteplus"?"byteplus":"volcengine";return IJ(s),{studio:i.studio??!1,version:typeof i.version=="string"?i.version:"",provider:s,branding:{title:typeof((t=i.branding)==null?void 0:t.title)=="string"?i.branding.title:nx.title,logoUrl:r?vo(r):""},features:{...B2.features,...i.features??{}},defaultView:i.defaultView??"chat",agentsSource:i.agentsSource==="cloud"?"cloud":"local",telemetry:mEe(i.telemetry)}}catch{return B2}}const aee={role:"user",telemetry:{userId:"",accountId:""},capabilities:{createAgents:!1,manageAgents:!1,runtimeScope:"mine"}};async function oee(){var n,i,r,s;const e=await Dt("/web/access");if(!e.ok)throw new Error(`加载权限失败 (${e.status})`);const t=await e.json();if(!["admin","developer","user"].includes(t.role)||typeof((n=t.telemetry)==null?void 0:n.userId)!="string"||t.telemetry.accountId!==void 0&&typeof t.telemetry.accountId!="string"||typeof((i=t.capabilities)==null?void 0:i.createAgents)!="boolean"||typeof((r=t.capabilities)==null?void 0:r.manageAgents)!="boolean"||!["all","mine"].includes((s=t.capabilities)==null?void 0:s.runtimeScope))throw new Error("权限服务返回了无法解析的响应");return t}async function lee(e,t){const n=new URLSearchParams;e&&n.set("targetVersion",e),t&&n.set("startedAt",String(t));const i=n.size?`?${n.toString()}`:"",r=await Dt(`/web/studio-update${i}`);if(!r.ok)throw new Error(`检查 Studio 更新失败 (${r.status})`);return await r.json()}async function cee(e){const t=await Dt("/web/studio-update",{method:"POST",headers:{"Content-Type":"application/json","X-VeADK-Studio-Update":"1"},body:JSON.stringify({version:e})},{},kr);if(!t.ok){let n="";try{const i=await t.json();n=typeof i.detail=="string"?i.detail:""}catch{n=""}throw new Error(n||`提交 Studio 更新失败 (${t.status})`)}return await t.json()}async function uee({runtimeId:e,region:t,appName:n,page:i=1,pageSize:r=20,signal:s}){const a=new URLSearchParams({runtimeId:e,region:t,appName:n,page:String(i),pageSize:String(r)}),o=await Dt(`/web/agent-usage?${a.toString()}`,{signal:s});if(!o.ok)throw new Error(await an(o,"加载 Agent 用量失败"));const c=o.headers.get("content-type")||"未提供",u=c.toLowerCase();if(!u.includes("application/json")&&!u.includes("+json"))throw new Error(`加载 Agent 用量失败:服务端返回非 JSON 响应(HTTP ${o.status},Content-Type: ${c})。请确认当前服务以 Studio 模式启动,并检查代理或网关配置。`);try{return await o.json()}catch{throw new Error(`加载 Agent 用量失败:服务端返回了无法解析的 JSON(HTTP ${o.status},Content-Type: ${c})。请稍后重试;若问题持续,请检查代理或网关配置。`)}}async function S_(e={}){const t=new URLSearchParams({scope:e.scope??"all",page_size:String(e.pageSize??30),region:e.region??"all"});e.nextToken&&t.set("next_token",e.nextToken);const n=await Dt(`/web/runtimes?${t.toString()}`);if(!n.ok){const r=await an(n,"加载 Runtime 失败");throw new Error(r)}const i=await n.json();return{runtimes:i.runtimes??[],nextToken:i.nextToken??""}}async function JD(e,t,n={}){try{const i={runtimeId:e,region:t};return n.retryProbe&&(i.retryProbe=!0),await v_("","",i)}catch(i){if(i instanceof z0||i instanceof ga)throw i;return null}}async function dee(e,t,n={}){const i={runtimeId:e,region:t};n.retryProbe&&(i.retryProbe=!0);const r=await Dt("/.well-known/agent-card.json",{},i),s=await PJ(r);if(s==="runtime_access_denied")throw new z0;if(s==="runtime_private_endpoint_unreachable")throw new ga(AJ);if(["runtime_proxy_connect_error","runtime_proxy_timeout"].includes(s))throw new ga(NJ);if(r.status===404)return null;if(r.status===401||r.status===403)throw new ga("Runtime 服务拒绝了 A2A 探测请求,请检查 Runtime 的鉴权配置。");if(!r.ok)throw new Error(await an(r,"读取 A2A Agent Card 失败"));const a=await r.json().catch(()=>null),o=typeof(a==null?void 0:a.url)=="string"?a.url.trim():"";return o?{name:typeof(a==null?void 0:a.name)=="string"?a.name:"",description:typeof(a==null?void 0:a.description)=="string"?a.description:"",endpoint:o}:null}async function fee(e,t){const n=new URLSearchParams({runtimeId:e,region:t}),i=await Dt(`/web/runtime-api-key/reveal?${n.toString()}`,{method:"POST",cache:"no-store"});if(!i.ok)throw new Error(await an(i,"读取 Runtime API Key 失败"));const r=await i.json();if(typeof r.apiKey!="string"||!r.apiKey)throw new Error("Runtime 未返回可用的 API Key");return r.apiKey}async function hee(e,t){const n=await Dt("/web/delete-runtime",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e,region:t})});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(i||`删除失败 (${n.status})`)}}async function pee({runtimeId:e,region:t,appName:n,signal:i}){const r=new URLSearchParams({runtimeId:e,region:t});n&&r.set("appName",n);const s=await Dt(`/web/runtime-update-capability?${r.toString()}`,{signal:i});if(!s.ok)throw new Error(await gEe(s));return await s.json()}async function gEe(e){const t=await e.json().catch(()=>null),n=typeof(t==null?void 0:t.detail)=="string"?t.detail:"";return e.status===403?"当前账号没有管理该 Runtime 的权限。":e.status===404?n==="runtime_not_found"?"该 Runtime 不存在或已被删除。":"当前账号无法访问该 Runtime。":`检查 Runtime 更新能力失败(HTTP ${e.status}),请稍后重试。`}async function bEe(e,t){let n=null;for(const i of Jf(t)){const r=await Dt(`/web/runtime-detail?runtimeId=${encodeURIComponent(e)}®ion=${encodeURIComponent(i)}`);if(r.ok)return r.json();n=new Error(await an(r,"加载 Runtime 详情失败"))}throw n??new Error("加载 Runtime 详情失败")}async function e$(e,t="cn-beijing",n={}){const i=F0(e,t||"cn-beijing"),r=V0(_h,i,x_);if(!n.force&&r)return r;const s=_h.get(i);if(!n.force&&(s!=null&&s.promise))return s.promise;const a=bEe(e,t).then(o=>XD(_h,i,o));_h.set(i,{...s,promise:a,updatedAt:(s==null?void 0:s.updatedAt)??0});try{return await a}finally{const o=_h.get(i);(o==null?void 0:o.promise)===a&&_h.set(i,{value:o.value,updatedAt:o.updatedAt})}}function mee(e,t="cn-beijing"){return V0(_h,F0(e,t||"cn-beijing"),x_)}function gee(e,t="cn-beijing"){e$(e,t).catch(()=>{})}async function t$(e){const t=await Dt("/web/generated-agent-projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await an(t,"生成项目失败"));return t.json()}const OEe=19e4;async function bee(e){const t=await Dt("/web/generated-agent-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requirement:e})},{},OEe);if(!t.ok)throw new Error(await an(t,"生成 Agent 配置失败"));return y_(t,"生成 Agent 配置失败")}async function Oee(e,t){const n=await Dt("/web/generated-agent-test-runs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,runtimeId:t==null?void 0:t.runtimeId,runtimeRegion:t==null?void 0:t.region})});if(!n.ok)throw new Error(await an(n,"创建调试运行失败"));return y_(n,"创建调试运行失败")}async function yee(e,t){const n=await Dt(`/web/generated-agent-test-runs/${e}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t})});if(!n.ok)throw new Error(await an(n,"创建调试会话失败"));return(await y_(n,"创建调试会话失败")).id}async function xee(e,t){const n=await Dt(`/web/generated-agent-test-runs/${encodeURIComponent(e)}/trace/session/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(await an(n,"加载调试调用链路失败"));const i=await y_(n,"加载调试调用链路失败");if(!Array.isArray(i))throw new Error("加载调试调用链路失败:返回格式无效");return i}async function*vee({runId:e,userId:t,sessionId:n,text:i,signal:r}){const s=i.trim()?[{text:i}]:[],a=await Dt(`/web/generated-agent-test-runs/${e}/run_sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:t,session_id:n,new_message:{role:"user",parts:s},streaming:!0}),signal:r},{},0);if(!a.ok)throw new Error(await an(a,"调试运行失败"));for await(const o of $D(a))yield o}async function Tm(e){const t=await Dt(`/web/generated-agent-test-runs/${e}`,{method:"DELETE"});if(!t.ok&&t.status!==404)throw new Error(await an(t,"清理调试运行失败"))}const yEe=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SITE_BRANDING:nx,DEFAULT_STUDIO_ACCESS:aee,RuntimeAccessDeniedError:z0,RuntimeProbeError:ga,addSessionCapability:oP,cancelAgentkitDeployment:ree,checkRuntimeNameAvailability:tee,clearMessageFeedbackCache:vJ,clearRemoteApps:SJ,componentSearch:JJ,createGeneratedAgentTestRun:Oee,createGeneratedAgentTestSession:yee,createSession:MJ,deleteAgentFeedbackCases:zJ,deleteGeneratedAgentTestRun:Tm,deleteMedia:zS,deleteRuntime:hee,deleteSession:iP,deleteSessionMedia:rP,deployAgentkitProject:w1,downloadArtifact:HD,fetchRemoteApps:v_,generateAgentDraftFromRequirement:bee,generateAgentProject:t$,getAgentFeedbackCases:w_,getAgentInfo:WJ,getAgentOptimizations:$J,getAgentUsage:uee,getAutomaticEvaluationStatuses:DJ,getCachedAgentFeedbackCases:QJ,getCachedRuntimeAgentInfo:ZJ,getCachedRuntimeDetail:mee,getGeneratedAgentTestTrace:xee,getMediaCapabilities:uEe,getMyRuntimes:pEe,getRuntimeAgentInfo:Ok,getRuntimeDetail:e$,getRuntimeUpdateCapability:pee,getRuntimes:S_,getSession:gk,getSessionCapabilities:aP,getSessionTrace:bk,getStudioAccess:oee,getStudioUpdateStatus:lee,getSystemInfo:iee,getUiConfig:see,listApps:_J,listDeploymentResources:nee,listIdentityUserPools:KD,listModelApiKeys:EJ,listModelOptions:TJ,listSessionBuiltinTools:ZD,listSessionSkillSpaces:dEe,listSessionSkillsInSpace:fEe,listSessions:qD,mediaContentUrl:qJ,prefetchAgentFeedbackCases:nP,prefetchRuntimeAgentInfo:KJ,prefetchRuntimeDetail:gee,previewArtifact:YD,probeRuntimeA2a:dee,probeRuntimeApps:JD,refreshAgentFeedbackCases:BJ,registerRemoteApp:wJ,removeSessionCapability:YJ,revealModelApiKey:kJ,revealRuntimeApiKey:fee,runGeneratedAgentTestSSE:vee,runSSE:lP,runtimeRegionCandidates:Jf,searchSessionPublicSkills:HJ,setClientCloudProvider:IJ,startStudioUpdate:cee,studioFetch:ri,submitIssueFeedback:sP,submitMessageFeedback:LJ,uploadMedia:VJ,upsertCachedAgentFeedbackCase:US,webSearch:eee},Symbol.toStringTag,{value:"Module"})),f9=Object.freeze({totalTokenCount:0,promptTokenCount:0,candidatesTokenCount:0,thoughtsTokenCount:0,cachedContentTokenCount:0}),FS=Object.freeze({modelName:"",current:f9,cumulative:f9}),xEe={totalTokenCount:"total_token_count",promptTokenCount:"prompt_token_count",candidatesTokenCount:"candidates_token_count",thoughtsTokenCount:"thoughts_token_count",cachedContentTokenCount:"cached_content_token_count"},vEe=24,wEe=64,SEe=16;function rw(e){var o,c;const t=e.trim();if(!t)return 0;const n=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu,i=((o=t.match(n))==null?void 0:o.length)??0,r=t.replace(n," "),s=(r.match(/[A-Za-z0-9_]+/g)??[]).reduce((u,d)=>u+Math.max(1,Math.ceil(d.length/4)),0),a=((c=r.match(/[^\sA-Za-z0-9_]/g))==null?void 0:c.length)??0;return i+s+a}function EEe(e){var o,c,u;const t=((o=e.instruction)==null?void 0:o.trim())??"",n=((c=e.tools)==null?void 0:c.filter(d=>d.trim()))??[],i=((u=e.skills)==null?void 0:u.filter(d=>d.name.trim()))??[],r=rw(t),s=n.reduce((d,f)=>d+wEe+rw(f),0),a=i.reduce((d,f)=>d+SEe+rw(f.name)+rw(f.description??""),0);return vEe+r+s+a}function kEe({usage:e,contextWindow:t,estimatedSystemTokens:n}){const i=Math.max(1,Math.round(t)),r=Math.max(0,e.current.promptTokenCount),s=Math.max(r,e.current.totalTokenCount),a=Math.min(i,r>0?Math.min(r,Math.max(0,n??0)):Math.max(0,n??0)),o=Math.max(0,r-a),c=r>0?Math.max(0,s-r):Math.max(0,s),u=r>0?s:a+c;return{systemTokens:a,inputTokens:o,outputTokens:c,remainingTokens:Math.max(0,i-u),usedTokens:u,contextWindow:i}}function TEe(e){const t=[{kind:"system",tokens:e.systemTokens},{kind:"input",tokens:e.inputTokens},{kind:"output",tokens:e.outputTokens},{kind:"remaining",tokens:e.remainingTokens}],n=e.contextWindow/100;let i=0;const r=t.map(s=>{const a=i;return i+=s.tokens,{...s,start:a,end:i}});return Array.from({length:100},(s,a)=>{const o=a*n,c=o+n,u=r.flatMap(d=>{const f=Math.max(0,Math.min(c,d.end)-Math.max(o,d.start));return f>0?[{kind:d.kind,share:f/n}]:[]});return{index:a,slices:u}})}function qb(e,t){const n=e,i=n[t]??n[xEe[t]];return typeof i=="number"&&Number.isFinite(i)&&i>0?Math.round(i):0}function _Ee(e){const t=qb(e,"promptTokenCount"),n=qb(e,"candidatesTokenCount"),i=qb(e,"thoughtsTokenCount");return{totalTokenCount:qb(e,"totalTokenCount")||t+n+i,promptTokenCount:t,candidatesTokenCount:n,thoughtsTokenCount:i,cachedContentTokenCount:qb(e,"cachedContentTokenCount")}}function AEe(e,t){return{totalTokenCount:e.totalTokenCount+t.totalTokenCount,promptTokenCount:e.promptTokenCount+t.promptTokenCount,candidatesTokenCount:e.candidatesTokenCount+t.candidatesTokenCount,thoughtsTokenCount:e.thoughtsTokenCount+t.thoughtsTokenCount,cachedContentTokenCount:e.cachedContentTokenCount+t.cachedContentTokenCount}}function wee(e,t){if(!t)return e;const n=typeof t.modelVersion=="string"?t.modelVersion.trim():"",i=typeof t.model_version=="string"?t.model_version.trim():"",r=n||i||e.modelName,s=t.usageMetadata??t.usage_metadata;if(!s)return r===e.modelName?e:{...e,modelName:r};const a=_Ee(s);return a.totalTokenCount===0?r===e.modelName?e:{...e,modelName:r}:{modelName:r,current:a,cumulative:AEe(e.cumulative,a)}}function h9(e){return e.reduce((t,n)=>wee(t,n),FS)}function p9(e){return e.blocks.flatMap(t=>t.kind==="tool"?[{name:t.name,args:t.args,response:t.response,done:t.done}]:[])}function NEe(e){const t=e.attributes;return String(t["invocation.id"]??t["gen_ai.invocation.id"]??t["gcp.vertex.agent.invocation_id"]??"")}function CEe(e,t){if(!t)return e;const n=new Set(e.filter(r=>NEe(r)===t).map(r=>r.trace_id)),i=e.filter(r=>n.has(r.trace_id));return i.length>0?i:e}function U2(e){return!!(e&&[...e.tools,...e.skills].some(t=>t.custom))}const jEe="send_a2ui_json_to_client",REe="validated_a2ui_json",uP="adk_request_credential",m9="transfer_to_agent";function IEe(e){var i,r,s,a;const t=e,n=((i=t==null?void 0:t.exchangedAuthCredential)==null?void 0:i.oauth2)??((r=t==null?void 0:t.exchanged_auth_credential)==null?void 0:r.oauth2)??((s=t==null?void 0:t.rawAuthCredential)==null?void 0:s.oauth2)??((a=t==null?void 0:t.raw_auth_credential)==null?void 0:a.oauth2);return(n==null?void 0:n.authUri)??(n==null?void 0:n.auth_uri)}function Pu(){return{blocks:[],liveStart:0}}const g9=e=>e.functionCall??e.function_call,dP=e=>e.functionResponse??e.function_response;function PEe(e){if(!e||typeof e!="object")return"";const t=e,n=t.agentName??t.agent_name;return typeof n=="string"?n:""}function MEe(e){return e.replace(/-/g,"+").replace(/_/g,"/")}function See(e){const t=[];for(const[n,i]of e.entries()){const r=i.partMetadata??i.part_metadata,s=r==null?void 0:r.veadkTransport;if((s==null?void 0:s.hidden)===!0)continue;const a=r==null?void 0:r.veadkMedia;if(typeof(a==null?void 0:a.uri)=="string"){t.push({id:String(a.id??a.uri),mimeType:typeof a.mimeType=="string"?a.mimeType:void 0,uri:a.uri,name:typeof a.name=="string"?a.name:void 0,sizeBytes:typeof a.sizeBytes=="number"?a.sizeBytes:void 0});continue}const o=i.inlineData??i.inline_data;if(o&&o.data){t.push({id:`inline-${n}-${o.displayName??o.display_name??"media"}`,mimeType:o.mimeType??o.mime_type,data:MEe(o.data),name:o.displayName??o.display_name});continue}const c=i.fileData??i.file_data,u=(c==null?void 0:c.fileUri)??(c==null?void 0:c.file_uri);c&&u&&t.push({id:u,mimeType:c.mimeType??c.mime_type,uri:u,name:c.displayName??c.display_name})}return t}function fP(e){const t=e.partMetadata??e.part_metadata,n=t==null?void 0:t.veadkTransport;return(n==null?void 0:n.hideText)===!0?void 0:e.text}const LEe=new Set(["llm","sequential","parallel","loop","a2a"]);function DEe(e){var t;for(const n of e){const i=(t=n.partMetadata??n.part_metadata)==null?void 0:t.veadkInvocation;if(!i||typeof i!="object")continue;const r=i,s=Array.isArray(r.skills)?r.skills.flatMap(c=>{if(!c||typeof c!="object")return[];const u=c;return typeof u.name=="string"?[{name:u.name,description:typeof u.description=="string"?u.description:""}]:[]}):[];let a;const o=r.targetAgent;if(o&&typeof o=="object"){const c=o,u=c.type;typeof c.name=="string"&&typeof u=="string"&&LEe.has(u)&&Array.isArray(c.path)&&(a={name:c.name,description:typeof c.description=="string"?c.description:"",type:u,path:c.path.filter(d=>typeof d=="string")})}if(s.length>0||a)return{skills:s,targetAgent:a}}}function $Ee(e,t){if(!t.length)return;const n=e[e.length-1];(n==null?void 0:n.kind)==="attachment"?n.files.push(...t):e.push({kind:"attachment",files:t})}function QEe(e,t){if(!t.length)return;const n=e[e.length-1];if((n==null?void 0:n.kind)==="artifact"){for(const i of t)n.files.some(r=>r.filename===i.filename&&r.version===i.version)||n.files.push(i);return}e.push({kind:"artifact",files:t})}function b9(e,t,n){const i=e[e.length-1];i&&i.kind===t?i.text+=n:e.push(t==="thinking"?{kind:t,text:n,done:!1}:{kind:t,text:n})}function sw(e){for(const t of e)t.kind==="thinking"&&(t.done=!0)}function yk(e,t){var o,c,u,d,f,h;const n=e.blocks.map(p=>({...p}));let i=e.liveStart;const r=((o=t.content)==null?void 0:o.parts)??[],s=r.some(p=>g9(p)||dP(p));if(t.partial&&!s){for(const p of r){const g=fP(p);typeof g=="string"&&g&&b9(n,p.thought?"thinking":"text",g)}return{blocks:n,liveStart:i}}n.length=i;for(const p of r){const g=g9(p),b=dP(p),y=See([p]),O=fP(p);if(typeof O=="string"&&O)b9(n,p.thought?"thinking":"text",O);else if(y.length)sw(n),$Ee(n,y);else if(g)if(sw(n),g.name===m9){const v=PEe(g.args)||((c=t.actions)==null?void 0:c.transferToAgent)||((u=t.actions)==null?void 0:u.transfer_to_agent)||"未知 Agent";n.push({kind:"agent-transfer",agentName:v,done:!1})}else if(g.name===uP){const v=g.args??{},x=v.authConfig??v.auth_config??v,E=String(v.functionCallId??v.function_call_id??"").replace(/^_adk_toolset_auth_/,"")||void 0;n.push({kind:"auth",callId:g.id??"",label:E,authUri:IEe(x),authConfig:x,done:!1})}else n.push({kind:"tool",name:g.name??"",args:g.args,done:!1});else if(b){if(sw(n),b.name===m9)for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="agent-transfer"&&!x.done){x.done=!0;break}}if(b.name===uP)for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="auth"&&!x.done){x.done=!0;break}}for(let v=n.length-1;v>=0;v--){const x=n[v];if(x.kind==="tool"&&!x.done&&x.name===b.name){x.done=!0,x.response=b.response;break}}if(b.name===jEe){const v=((d=b.response)==null?void 0:d[REe])??[];if(v.length){const x=n[n.length-1];x&&x.kind==="a2ui"?x.messages.push(...v):n.push({kind:"a2ui",messages:v})}}}}const a=((f=t.actions)==null?void 0:f.artifactDelta)??((h=t.actions)==null?void 0:h.artifact_delta);return a&&QEe(n,Object.entries(a).map(([p,g])=>({filename:p,version:g}))),sw(n),i=n.length,{blocks:n,liveStart:i}}function BEe(e,t={}){var r,s;const n=[];let i=Pu();for(const a of e)if(a.author==="user"){const c=((r=a.content)==null?void 0:r.parts)??[];if(c.some(p=>{var g;return((g=dP(p))==null?void 0:g.name)===uP})){for(let p=n.length-1;p>=0;p--)if(n[p].role==="assistant"){for(let g=n[p].blocks.length-1;g>=0;g--){const b=n[p].blocks[g];if(b.kind==="auth"){b.done=!0;break}}break}}const u=c.map(fP).filter(p=>!!p).join(""),d=See(c),f=DEe(c);if(!u&&!d.length&&!f){i=Pu();continue}const h=[];f&&h.push({kind:"invocation",value:f}),d.length&&h.push({kind:"attachment",files:d}),u&&h.push({kind:"text",text:u}),n.push({role:"user",blocks:h,meta:{ts:a.timestamp}}),i=Pu()}else{const c=a.author??"";let u=n[n.length-1];(!u||u.role!=="assistant"||c&&((s=u.meta)==null?void 0:s.author)!==c)&&(u={role:"assistant",blocks:[],meta:{author:c||void 0}},n.push(u),i=Pu()),i=yk(i,a),u.blocks=i.blocks;const d=a.usageMetadata??a.usage_metadata,f=u.meta??(u.meta={});c&&(f.author=c),d!=null&&d.totalTokenCount&&(f.tokens=d.totalTokenCount),a.timestamp&&(f.ts=a.timestamp),a.id&&(f.eventId=a.id);const h=a.invocationId??a.invocation_id;h&&(f.invocationId=h)}for(const a of n){const o=a.meta,c=o==null?void 0:o.eventId;if(!c)continue;const u=t[`veadk_feedback:${c}`];if(!u||typeof u!="object")continue;const d=u;d.rating!=="good"&&d.rating!=="bad"||(o.feedback=u)}return n}function E_(e){var t,n;for(const i of e??[])if(i.author==="user"||((t=i.content)==null?void 0:t.role)==="user"){const r=(((n=i.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(r)return r}return"新会话"}const UEe=50,O9=48;function zEe(e){return(e.events??[]).flatMap(t=>{var r,s;const i=(((r=t.content)==null?void 0:r.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return i?[{text:i,role:t.author??((s=t.content)==null?void 0:s.role)??"",ts:t.timestamp}]:[]})}function FEe(e){var t,n;for(const i of e.events??[])if(i.author==="user"||((t=i.content)==null?void 0:t.role)==="user"){const r=(((n=i.content)==null?void 0:n.parts)??[]).map(s=>s.text).find(Boolean);if(r)return r}return"未命名会话"}function VEe(e,t,n){const i=Math.max(0,t-O9),r=Math.min(e.length,t+n+O9);return(i>0?"…":"")+e.slice(i,r).trim()+(r{var c;if((c=o.events)!=null&&c.length)return o;try{return await gk(t,e,o.id)}catch{return o}})),a=[];for(const o of s)for(const{text:c,role:u,ts:d}of zEe(o)){const f=c.toLowerCase().indexOf(i);if(f!==-1){a.push({type:"session",appId:t,sessionId:o.id,title:FEe(o),snippet:VEe(c,f,i.length),role:u,ts:d??o.lastUpdateTime});break}}return a.sort((o,c)=>(c.ts??0)-(o.ts??0)),a.slice(0,UEe)}async function qEe(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await eee(e,t.trim())}catch(a){const o=String(a);return{results:[],note:o.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${o}`}}const{mounted:i,results:r,error:s}=n;return i?s?{results:[],note:s}:{results:r.map((a,o)=>({type:"web",index:o,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function HEe(e,t,n,i){if(!t||!i.trim())return{results:[]};const r=await JJ(t,e,i.trim(),n);if(!r.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(r.error)return{results:[],note:r.error};const s=r.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:r.results.map((a,o)=>e==="knowledge"?{type:"knowledge",index:o,content:a.content,sourceName:s,sourceType:r.sourceType}:{type:"memory",index:o,content:a.content,sourceName:s,sourceType:r.sourceType,author:a.author,ts:a.timestamp})}}async function YEe(e,t,n){return e==="session"?{results:await XEe(n.userId,n.appId,t)}:e==="web"?qEe(n.appId,t):HEe(e,n.appId,n.userId,t)}function Eee({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),l.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function GEe({open:e}){return l.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function WEe({active:e=!1,onClick:t}){return l.jsxs("button",{className:`new-chat${e?" is-active":""}`,onClick:t,"aria-label":"搜索","aria-current":e?"page":void 0,title:"搜索",children:[l.jsx(Eee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"搜索"})]})}function ZEe(e,t,n){const i=!!e,r=new Set((t==null?void 0:t.searchSources)??[]),s=a=>i?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:i,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:i&&r.has("web"),description:"通过 web_search 工具检索",unavailableLabel:s(" web_search 工具")},{id:"knowledge",label:"知识库",ready:i&&r.has("knowledge"),unavailableLabel:s("知识库")},{id:"memory",label:"长期记忆",ready:i&&r.has("memory"),unavailableLabel:s("长期记忆")}]}function xk(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function y9(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function KEe({userId:e,appId:t,agentInfo:n,capabilitiesLoading:i,agentLabel:r,onOpenSession:s}){var Q,j;const[a,o]=m.useState("session"),[c,u]=m.useState(""),[d,f]=m.useState([]),[h,p]=m.useState(),[g,b]=m.useState(!1),[y,O]=m.useState(!1),[v,x]=m.useState(!1),w=m.useRef(0),E=m.useRef(null),S=ZEe(t,n,i),k=S.find($=>$.id===a),T=a==="knowledge"?(Q=n==null?void 0:n.components)==null?void 0:Q.find($=>$.source==="knowledgebase"||$.kind==="knowledgebase"):a==="memory"?(j=n==null?void 0:n.components)==null?void 0:j.find($=>$.source==="long_term_memory"||$.kind==="memory"):void 0;m.useEffect(()=>{w.current+=1,o("session"),f([]),p(void 0),O(!1),b(!1),x(!1)},[t]),m.useEffect(()=>{if(!v)return;function $(U){var B;(B=E.current)!=null&&B.contains(U.target)||x(!1)}return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[v]);async function A($,U){var q;const B=$.trim();if(!B||!((q=S.find(D=>D.id===U))!=null&&q.ready))return;const I=++w.current;b(!0),O(!0);let X;try{X=await YEe(U,B,{userId:e,appId:t})}catch(D){const H=D instanceof Error?D.message:String(D);X={results:[],note:`搜索失败:${H}`}}I===w.current&&(f(X.results),p(X.note),b(!1))}function N($){w.current+=1,u($),f([]),p(void 0),O(!1),b(!1)}function C($){w.current+=1,o($),x(!1),f([]),p(void 0),O(!1),b(!1)}const M=!!(k!=null&&k.ready),L=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(T==null?void 0:T.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(T==null?void 0:T.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",P=T!=null&&T.backend?xk(T.backend):"";return l.jsxs("div",{className:"search",children:[l.jsxs("div",{className:"search-box",children:[l.jsxs("div",{className:"search-source-picker-wrap",ref:E,children:[l.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(k==null?void 0:k.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":v,onClick:()=>x($=>!$),children:[l.jsx("span",{children:(k==null?void 0:k.label)??"搜索类型"}),P&&l.jsx("small",{children:P}),l.jsx(GEe,{open:v})]}),v&&l.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:S.map($=>{var I,X;const U=$.id==="knowledge"?(I=n==null?void 0:n.components)==null?void 0:I.find(q=>q.source==="knowledgebase"||q.kind==="knowledgebase"):$.id==="memory"?(X=n==null?void 0:n.components)==null?void 0:X.find(q=>q.source==="long_term_memory"||q.kind==="memory"):void 0,B=U?[U.name,U.backend?xk(U.backend):""].filter(Boolean).join(" · "):$.ready?$.description:$.unavailableLabel;return l.jsxs("button",{type:"button",role:"option","aria-selected":a===$.id,disabled:!$.ready,onClick:()=>C($.id),children:[l.jsx("span",{children:$.label}),B&&l.jsx("small",{children:B})]},$.id)})})]}),l.jsx("span",{className:"search-box-divider","aria-hidden":!0}),l.jsx("input",{className:"search-input",value:c,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),A(c,a))},placeholder:L,disabled:!M,autoFocus:!0}),l.jsx("button",{className:"search-go",onClick:()=>void A(c,a),disabled:!c.trim()||g,"aria-label":"搜索",children:g?l.jsx(Kn,{className:"icon spin"}):l.jsx(Eee,{className:"icon"})})]}),l.jsx("div",{className:"search-results",children:M?y?g?null:h?l.jsx("div",{className:"search-empty",children:h}):d.length===0&&y?l.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map(($,U)=>l.jsx(JEe,{result:$,agentLabel:r,onOpen:s},U)):l.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):l.jsx("div",{className:"search-empty",children:t?i?"正在读取当前 Agent 的检索能力…":(k==null?void 0:k.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function JEe({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return l.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[l.jsx(mJ,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title}),l.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${y9(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return l.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[l.jsx(O_,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title||e.url}),l.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&l.jsx(e0,{className:"search-result-ext"})]})]}),e.summary&&l.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(x9,{source:"knowledge"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${xk(e.sourceType)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(x9,{source:"memory"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${xk(e.sourceType)}`:"",e.ts?` · ${y9(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function x9({source:e,className:t="search-result-icon"}){return e==="knowledge"?l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),l.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),l.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}function Pf({className:e="icon"}){return l.jsxs("svg",{className:`${e} sidebar-agent-face`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"4.25",y:"5.25",width:"15.5",height:"13.5",rx:"4.75"}),l.jsx("path",{className:"sidebar-agent-face__eye",d:"M8.5 10.7v2"}),l.jsx("path",{className:"sidebar-agent-face__eye",d:"M15.5 10.7v2"})]})}function eke({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"9.3",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 10.2 11.3 4.8c.5-.8 1.7-.45 1.7.5v3.8h4.2a2.1 2.1 0 0 1 2.04 2.6l-1.4 5.75A2.1 2.1 0 0 1 15.8 19H8"})]})}function tke({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 13.8 11.3 19.2c.5.8 1.7.45 1.7-.5v-3.8h4.2a2.1 2.1 0 0 0 2.04-2.6l-1.4-5.75A2.1 2.1 0 0 0 15.8 5H8"})]})}function kee(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5.25 4.25h9.5a2.5 2.5 0 0 1 2.5 2.5v3.5"}),l.jsx("path",{d:"M13.25 17.75h-8a2.5 2.5 0 0 1-2.5-2.5v-8a3 3 0 0 1 3-3"}),l.jsx("path",{d:"M7 8.25h5.5M7 11.75h3.25"}),l.jsx("path",{d:"m13.35 16.65.42-2.16 4.76-4.76a1.35 1.35 0 0 1 1.91 1.91l-4.76 4.76-2.33.25Z"}),l.jsx("path",{d:"m17.65 10.6 1.9 1.9"})]})}const n$="/assets/logo-DCsNZy-k.svg",i$="data:image/svg+xml,%3csvg%20width='28'%20height='23'%20viewBox='0%200%2028%2023'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.1957%209.44218C17.0253%209.58161%2016.7774%209.47317%2016.7774%209.24079V8.01696V0.611967C16.7774%200.395085%2016.514%200.271152%2016.3591%200.410576L6.04172%209.16334C5.87132%209.30276%205.62345%209.19432%205.62345%208.96194V2.98218C5.62345%202.81178%205.48403%202.67235%205.31362%202.67235H0.309832C0.139424%202.67235%200%202.81178%200%202.98218V21.7115C0%2021.9284%200.263357%2022.0524%200.418273%2021.9129L10.7202%2013.1602C10.8906%2013.0207%2011.1385%2013.1292%2011.1385%2013.3616V22.0059C11.1385%2022.2228%2011.4018%2022.3467%2011.5567%2022.2073L21.8586%2013.4545C22.0291%2013.3151%2022.2769%2013.4235%2022.2769%2013.6559V19.6357C22.2769%2019.8061%2022.4163%2019.9455%2022.5868%2019.9455H27.5905C27.7609%2019.9455%2027.9004%2019.8061%2027.9004%2019.6357V0.890816C27.9004%200.673934%2027.637%200.550001%2027.4821%200.689425L17.1957%209.44218Z'%20fill='%230066FC'/%3e%3c/svg%3e",v9="(max-width: 860px)";function nke(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"7",cy:"7",r:"2.25"}),l.jsx("circle",{cx:"17",cy:"7",r:"2.25"}),l.jsx("circle",{cx:"7",cy:"17",r:"2.25"}),l.jsx("circle",{cx:"17",cy:"17",r:"2.25"})]})}function ike(e){let t=2166136261;for(const i of e)t^=i.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const rke={admin:"管理员",developer:"开发者",user:"普通用户"};function w9({role:e}){const t=rke[e];return l.jsx("span",{className:`studio-role-badge studio-role-badge--${e}`,title:t,children:t})}function ske({access:e,userInfo:t,onSystemInfo:n,onLogout:i}){const[r,s]=m.useState(!1),[a,o]=m.useState("");if(!t)return null;const c=ESe(t),u=typeof t.email=="string"?t.email:"",d=(c||"U").slice(0,1).toUpperCase(),f=ike(c||u||d),h=kSe(t),p=h===a?"":h;return l.jsxs("div",{className:"sidebar-user",children:[l.jsxs("button",{className:"sidebar-user-btn",onClick:()=>s(g=>!g),title:u?`${c} +${u}`:c,children:[l.jsxs("span",{className:`account-avatar${p?" has-image":""}`,style:f,children:[d,p?l.jsx("img",{className:"account-avatar-image",src:p,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>o(p)}):null]}),l.jsxs("span",{className:"sidebar-user-identity",children:[l.jsxs("span",{className:"sidebar-user-primary",children:[l.jsx("span",{className:"sidebar-user-name",children:c}),l.jsx(w9,{role:e.role})]}),u&&u!==c&&l.jsx("span",{className:"sidebar-user-email",children:u})]})]}),r&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>s(!1)}),l.jsxs("div",{className:"account-pop sidebar-user-pop",children:[l.jsxs("div",{className:"account-head",children:[l.jsxs("span",{className:`account-avatar account-avatar--lg${p?" has-image":""}`,style:f,children:[d,p?l.jsx("img",{className:"account-avatar-image",src:p,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>o(p)}):null]}),l.jsxs("div",{className:"account-id",children:[l.jsxs("div",{className:"account-name-row",children:[l.jsx("div",{className:"account-name",children:c}),l.jsx(w9,{role:e.role})]}),u&&u!==c&&l.jsx("div",{className:"account-sub",children:u})]})]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{s(!1),n()},children:[l.jsx(hd,{className:"icon"})," 系统信息"]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{s(!1),i()},children:[l.jsx(nSe,{className:"icon"})," 退出登录"]})]})]})]})}function ake({branding:e,cloudProvider:t,sessions:n,currentSessionId:i,activePage:r,features:s,access:a,streamingSids:o,evaluatingSids:c,sandboxHistory:u,onNewChat:d,onSearch:f,onQuickCreate:h,onLibrary:p,onAddAgent:g,onMyAgents:b,onApplications:y,onSystemInfo:O,onIssueFeedback:v,onPickSession:x,onDeleteSession:w,userInfo:E,onLogout:S}){const k=j=>(s==null?void 0:s[j])!==!1,[T,A]=m.useState(null),N=m.useRef(typeof window<"u"&&window.matchMedia(v9).matches),[C,M]=m.useState(N.current),L=[...n].sort((j,$)=>($.lastUpdateTime??0)-(j.lastUpdateTime??0)),P=()=>{N.current=!1,M(j=>!j),A(null)};m.useEffect(()=>{const j=window.matchMedia(v9),$=U=>{U.matches?M(B=>B||(N.current=!0,!0)):N.current&&(N.current=!1,M(!1))};return j.addEventListener("change",$),()=>j.removeEventListener("change",$)},[]);const Q=t==="byteplus"?i$:n$;return l.jsxs("aside",{className:`sidebar ${C?"is-collapsed":""}`,children:[l.jsxs("div",{className:"sidebar-top",children:[l.jsxs("div",{className:"sidebar-brand-row",children:[l.jsxs("button",{type:"button",className:"brand",onClick:d,"aria-label":"返回首页",title:"返回首页",children:[l.jsx("img",{className:"brand-logo",src:e.logoUrl||Q,width:20,height:20,alt:"","aria-hidden":!0}),l.jsx("span",{className:"brand-title",children:e.title})]}),l.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:P,"aria-label":C?"展开侧边栏":"收起侧边栏",title:C?"展开侧边栏":"收起侧边栏",children:C?l.jsx(oSe,{className:"icon"}):l.jsx(aSe,{className:"icon"})})]}),k("newChat")&&l.jsxs("button",{className:`new-chat new-chat--conversation${r==="new-chat"?" is-active":""}`,onClick:d,"aria-label":"新会话","aria-current":r==="new-chat"?"page":void 0,title:"新会话",children:[l.jsx(Gs,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),l.jsxs("button",{className:`new-chat new-chat--agents${r==="agents"?" is-active":""}`,onClick:b,"aria-label":"智能体","aria-current":r==="agents"?"page":void 0,title:"智能体",children:[l.jsx(Pf,{}),l.jsx("span",{className:"sidebar-nav-label",children:"智能体"})]}),l.jsxs("button",{className:`new-chat new-chat--library${r==="library"?" is-active":""}`,onClick:p,"aria-label":"库","aria-current":r==="library"?"page":void 0,title:"库",children:[l.jsx(Nwe,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"库"})]}),k("search")&&l.jsx(WEe,{active:r==="search",onClick:f}),l.jsxs("button",{className:`new-chat new-chat--applications${r==="applications"?" is-active":""}`,onClick:y,"aria-label":"自动化","aria-current":r==="applications"?"page":void 0,title:"自动化",children:[l.jsx(nke,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"自动化"}),l.jsx("span",{className:"sidebar-beta-badge",children:"Beta"})]})]}),k("history")&&l.jsxs("div",{className:"sidebar-history",children:[l.jsxs("div",{className:"history-head",children:[l.jsx("span",{children:"历史会话"}),k("newChat")&&l.jsx("button",{type:"button",className:"history-new-chat",onClick:(u==null?void 0:u.onNew)??d,disabled:u==null?void 0:u.newDisabled,"aria-label":"新建会话",title:"新建会话",children:l.jsx(Gs,{className:"icon"})})]}),l.jsx("div",{className:"history-list",children:u?l.jsxs(l.Fragment,{children:[u.loading&&u.threads.length===0?l.jsx("div",{className:"history-empty",role:"status",children:"正在加载历史会话…"}):null,u.error?l.jsx("div",{className:"history-error",role:"alert",children:u.error}):null,!u.loading&&!u.error&&u.threads.length===0?l.jsx("div",{className:"history-empty",children:"暂无会话"}):null,u.threads.map(j=>{const $=j.id===u.currentThreadId,U=j.name||j.preview||`Thread ${j.id.slice(0,8)}`,B=j.id===u.busyThreadId;return l.jsxs("div",{className:`history-item ${$?"active":""}`,children:[l.jsxs("button",{type:"button",className:"history-item-btn",onClick:()=>u.onSelect(j.id),"aria-current":$?"page":void 0,title:U,disabled:B,children:[l.jsx("span",{className:"history-title",children:U}),$?l.jsx("span",{className:"history-current-badge",children:"当前"}):null]}),l.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${U}`,title:"更多",disabled:B,onClick:()=>A(I=>I===j.id?null:j.id),children:l.jsx(i9,{className:"icon"})}),T===j.id?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>A(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{type:"button",className:"menu-item menu-item--danger",onClick:()=>{A(null),u.onDelete(j)},children:[l.jsx(If,{className:"icon"})," 删除"]})})]}):null]},j.id)}),u.hasMore?l.jsx("button",{type:"button",className:"history-load-more",disabled:u.loading,onClick:u.onLoadMore,children:u.loading?"加载中…":"加载更多"}):null]}):l.jsxs(l.Fragment,{children:[L.length===0&&l.jsx("div",{className:"history-empty",children:"暂无会话"}),L.map(j=>{const $=E_(j.events),U=(o==null?void 0:o.has(j.id))===!0,B=!U&&(c==null?void 0:c.has(j.id))===!0;return l.jsxs("div",{className:`history-item ${j.id===i?"active":""}`,children:[l.jsxs("button",{className:"history-item-btn",onClick:()=>x(j.id),"aria-current":j.id===i?"page":void 0,title:$,children:[U&&l.jsx("span",{className:"history-streaming",title:"正在生成…","aria-label":"正在生成"}),l.jsx("span",{className:"history-title",children:$}),B&&l.jsxs("span",{className:"history-evaluating-status",title:"正在自动评测",children:[l.jsx("span",{className:"history-evaluating","aria-hidden":"true"}),"评测中"]})]}),l.jsx("button",{type:"button",className:"history-more","aria-label":`管理历史会话:${$}`,title:"更多",onClick:()=>A(I=>I===j.id?null:j.id),children:l.jsx(i9,{className:"icon"})}),T===j.id&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>A(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{className:"menu-item menu-item--danger",onClick:()=>{A(null),w(j.id)},children:[l.jsx(If,{className:"icon"})," 删除"]})})]})]},j.id)})]})})]}),l.jsxs("div",{className:"sidebar-footer",children:[l.jsxs("button",{type:"button",className:`sidebar-feedback${r==="feedback"?" is-active":""}`,onClick:v,"aria-label":"问题反馈","aria-current":r==="feedback"?"page":void 0,title:"问题反馈",children:[l.jsx(kee,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"问题反馈"})]}),l.jsx(ske,{access:a,userInfo:E,onSystemInfo:O,onLogout:S})]})]})}function Yr(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n{}};function k_(){for(var e=0,t=arguments.length,n={},i;e=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}VS.prototype=k_.prototype={constructor:VS,on:function(e,t){var n=this._,i=lke(e+"",n),r,s=-1,a=i.length;if(arguments.length<2){for(;++s0)for(var n=new Array(r),i=0,r,s;i=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),E9.hasOwnProperty(t)?{space:E9[t],local:e}:e}function uke(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hP&&t.documentElement.namespaceURI===hP?t.createElement(e):t.createElementNS(n,e)}}function dke(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Tee(e){var t=T_(e);return(t.local?dke:uke)(t)}function fke(){}function r$(e){return e==null?fke:function(){return this.querySelector(e)}}function hke(e){typeof e!="function"&&(e=r$(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r=x&&(x=v+1);!(E=y[x])&&++x=0;)(a=i[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function $ke(e){e||(e=Qke);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,i=n.length,r=new Array(i),s=0;st?1:e>=t?0:NaN}function Bke(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Uke(){return Array.from(this)}function zke(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Jke:typeof t=="function"?tTe:eTe)(e,t,n??"")):n0(this.node(),e)}function n0(e,t){return e.style.getPropertyValue(t)||jee(e).getComputedStyle(e,null).getPropertyValue(t)}function iTe(e){return function(){delete this[e]}}function rTe(e,t){return function(){this[e]=t}}function sTe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function aTe(e,t){return arguments.length>1?this.each((t==null?iTe:typeof t=="function"?sTe:rTe)(e,t)):this.node()[e]}function Ree(e){return e.trim().split(/^|\s+/)}function s$(e){return e.classList||new Iee(e)}function Iee(e){this._node=e,this._names=Ree(e.getAttribute("class")||"")}Iee.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Pee(e,t){for(var n=s$(e),i=-1,r=t.length;++i=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function PTe(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n()=>e;function pP(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:s,x:a,y:o,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}pP.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function VTe(e){return!e.ctrlKey&&!e.button}function XTe(){return this.parentNode}function qTe(e,t){return t??{x:e.x,y:e.y}}function HTe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bee(){var e=VTe,t=XTe,n=qTe,i=HTe,r={},s=k_("start","drag","end"),a=0,o,c,u,d,f=0;function h(w){w.on("mousedown.drag",p).filter(i).on("touchstart.drag",y).on("touchmove.drag",O,FTe).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,E){if(!(d||!e.call(this,w,E))){var S=x(this,t.call(this,w,E),w,E,"mouse");S&&(fo(w.view).on("mousemove.drag",g,ix).on("mouseup.drag",b,ix),$ee(w.view),z2(w),u=!1,o=w.clientX,c=w.clientY,S("start",w))}}function g(w){if(yg(w),!u){var E=w.clientX-o,S=w.clientY-c;u=E*E+S*S>f}r.mouse("drag",w)}function b(w){fo(w.view).on("mousemove.drag mouseup.drag",null),Qee(w.view,u),yg(w),r.mouse("end",w)}function y(w,E){if(e.call(this,w,E)){var S=w.changedTouches,k=t.call(this,w,E),T=S.length,A,N;for(A=0;A>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ow(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ow(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=GTe.exec(e))?new Da(t[1],t[2],t[3],1):(t=WTe.exec(e))?new Da(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ZTe.exec(e))?ow(t[1],t[2],t[3],t[4]):(t=KTe.exec(e))?ow(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=JTe.exec(e))?j9(t[1],t[2]/100,t[3]/100,1):(t=e_e.exec(e))?j9(t[1],t[2]/100,t[3]/100,t[4]):k9.hasOwnProperty(e)?A9(k9[e]):e==="transparent"?new Da(NaN,NaN,NaN,0):null}function A9(e){return new Da(e>>16&255,e>>8&255,e&255,1)}function ow(e,t,n,i){return i<=0&&(e=t=n=NaN),new Da(e,t,n,i)}function i_e(e){return e instanceof E1||(e=gp(e)),e?(e=e.rgb(),new Da(e.r,e.g,e.b,e.opacity)):new Da}function mP(e,t,n,i){return arguments.length===1?i_e(e):new Da(e,t,n,i??1)}function Da(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}a$(Da,mP,Uee(E1,{brighter(e){return e=e==null?wk:Math.pow(wk,e),new Da(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?rx:Math.pow(rx,e),new Da(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Da(ip(this.r),ip(this.g),ip(this.b),Sk(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:N9,formatHex:N9,formatHex8:r_e,formatRgb:C9,toString:C9}));function N9(){return`#${Bh(this.r)}${Bh(this.g)}${Bh(this.b)}`}function r_e(){return`#${Bh(this.r)}${Bh(this.g)}${Bh(this.b)}${Bh((isNaN(this.opacity)?1:this.opacity)*255)}`}function C9(){const e=Sk(this.opacity);return`${e===1?"rgb(":"rgba("}${ip(this.r)}, ${ip(this.g)}, ${ip(this.b)}${e===1?")":`, ${e})`}`}function Sk(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ip(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bh(e){return e=ip(e),(e<16?"0":"")+e.toString(16)}function j9(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Nl(e,t,n,i)}function zee(e){if(e instanceof Nl)return new Nl(e.h,e.s,e.l,e.opacity);if(e instanceof E1||(e=gp(e)),!e)return new Nl;if(e instanceof Nl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),a=NaN,o=s-r,c=(s+r)/2;return o?(t===s?a=(n-i)/o+(n0&&c<1?0:a,new Nl(a,o,c,e.opacity)}function s_e(e,t,n,i){return arguments.length===1?zee(e):new Nl(e,t,n,i??1)}function Nl(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}a$(Nl,s_e,Uee(E1,{brighter(e){return e=e==null?wk:Math.pow(wk,e),new Nl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?rx:Math.pow(rx,e),new Nl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Da(F2(e>=240?e-240:e+120,r,i),F2(e,r,i),F2(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Nl(R9(this.h),lw(this.s),lw(this.l),Sk(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Sk(this.opacity);return`${e===1?"hsl(":"hsla("}${R9(this.h)}, ${lw(this.s)*100}%, ${lw(this.l)*100}%${e===1?")":`, ${e})`}`}}));function R9(e){return e=(e||0)%360,e<0?e+360:e}function lw(e){return Math.max(0,Math.min(1,e||0))}function F2(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const o$=e=>()=>e;function a_e(e,t){return function(n){return e+n*t}}function o_e(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function l_e(e){return(e=+e)==1?Fee:function(t,n){return n-t?o_e(t,n,e):o$(isNaN(t)?n:t)}}function Fee(e,t){var n=t-e;return n?a_e(e,n):o$(isNaN(e)?t:e)}const Ek=function e(t){var n=l_e(t);function i(r,s){var a=n((r=mP(r)).r,(s=mP(s)).r),o=n(r.g,s.g),c=n(r.b,s.b),u=Fee(r.opacity,s.opacity);return function(d){return r.r=a(d),r.g=o(d),r.b=c(d),r.opacity=u(d),r+""}}return i.gamma=e,i}(1);function c_e(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;rn&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(i=i[0])===(r=r[0])?o[a]?o[a]+=r:o[++a]=r:(o[++a]=null,c.push({i:a,x:Oc(i,r)})),n=V2.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:Oc(u,d)})):d&&f.push(r(f)+"rotate("+d+i)}function o(u,d,f,h){u!==d?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:Oc(u,d)}):d&&f.push(r(f)+"skewX("+d+i)}function c(u,d,f,h,p,g){if(u!==f||d!==h){var b=p.push(r(p)+"scale(",null,",",null,")");g.push({i:b-4,x:Oc(u,f)},{i:b-2,x:Oc(d,h)})}else(f!==1||h!==1)&&p.push(r(p)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(p){for(var g=-1,b=h.length,y;++g=0&&e._call.call(void 0,t),e=e._next;--i0}function M9(){bp=(Tk=ax.now())+__,i0=_O=0;try{E_e()}finally{i0=0,T_e(),bp=0}}function k_e(){var e=ax.now(),t=e-Tk;t>Hee&&(__-=t,Tk=e)}function T_e(){for(var e,t=kk,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:kk=n);AO=e,OP(i)}function OP(e){if(!i0){_O&&(_O=clearTimeout(_O));var t=e-bp;t>24?(e<1/0&&(_O=setTimeout(M9,e-ax.now()-__)),Hb&&(Hb=clearInterval(Hb))):(Hb||(Tk=ax.now(),Hb=setInterval(k_e,Hee)),i0=1,Yee(M9))}}function L9(e,t,n){var i=new _k;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var __e=k_("start","end","cancel","interrupt"),A_e=[],Wee=0,D9=1,yP=2,qS=3,$9=4,xP=5,HS=6;function A_(e,t,n,i,r,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;N_e(e,n,{name:t,index:i,group:r,on:__e,tween:A_e,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Wee})}function c$(e,t){var n=Fl(e,t);if(n.state>Wee)throw new Error("too late; already scheduled");return n}function Yc(e,t){var n=Fl(e,t);if(n.state>qS)throw new Error("too late; already running");return n}function Fl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function N_e(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Gee(s,0,n.time);function s(u){n.state=D9,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,p;if(n.state!==D9)return c();for(d in i)if(p=i[d],p.name===n.name){if(p.state===qS)return L9(a);p.state===$9?(p.state=HS,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete i[d]):+dyP&&i.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function sAe(e,t,n){var i,r,s=rAe(t)?c$:Yc;return function(){var a=s(this,e),o=a.on;o!==i&&(r=(i=o).copy()).on(t,n),a.on=r}}function aAe(e,t){var n=this._id;return arguments.length<2?Fl(this.node(),n).on.on(e):this.each(sAe(n,e,t))}function oAe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function lAe(){return this.on("end.remove",oAe(this._id))}function cAe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=r$(e));for(var i=this._groups,r=i.length,s=new Array(r),a=0;a()=>e;function PAe(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Mu(e,t,n){this.k=e,this.x=t,this.y=n}Mu.prototype={constructor:Mu,scale:function(e){return e===1?this:new Mu(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Mu(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var N_=new Mu(1,0,0);ete.prototype=Mu.prototype;function ete(e){for(;!e.__zoom;)if(!(e=e.parentNode))return N_;return e.__zoom}function X2(e){e.stopImmediatePropagation()}function Yb(e){e.preventDefault(),e.stopImmediatePropagation()}function MAe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function LAe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Q9(){return this.__zoom||N_}function DAe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $Ae(){return navigator.maxTouchPoints||"ontouchstart"in this}function QAe(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function tte(){var e=MAe,t=LAe,n=QAe,i=DAe,r=$Ae,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,c=XS,u=k_("start","zoom","end"),d,f,h,p=500,g=150,b=0,y=10;function O(P){P.property("__zoom",Q9).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",N).filter(r).on("touchstart.zoom",C).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}O.transform=function(P,Q,j,$){var U=P.selection?P.selection():P;U.property("__zoom",Q9),P!==U?E(P,Q,j,$):U.interrupt().each(function(){S(this,arguments).event($).start().zoom(null,typeof Q=="function"?Q.apply(this,arguments):Q).end()})},O.scaleBy=function(P,Q,j,$){O.scaleTo(P,function(){var U=this.__zoom.k,B=typeof Q=="function"?Q.apply(this,arguments):Q;return U*B},j,$)},O.scaleTo=function(P,Q,j,$){O.transform(P,function(){var U=t.apply(this,arguments),B=this.__zoom,I=j==null?w(U):typeof j=="function"?j.apply(this,arguments):j,X=B.invert(I),q=typeof Q=="function"?Q.apply(this,arguments):Q;return n(x(v(B,q),I,X),U,a)},j,$)},O.translateBy=function(P,Q,j,$){O.transform(P,function(){return n(this.__zoom.translate(typeof Q=="function"?Q.apply(this,arguments):Q,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),a)},null,$)},O.translateTo=function(P,Q,j,$,U){O.transform(P,function(){var B=t.apply(this,arguments),I=this.__zoom,X=$==null?w(B):typeof $=="function"?$.apply(this,arguments):$;return n(N_.translate(X[0],X[1]).scale(I.k).translate(typeof Q=="function"?-Q.apply(this,arguments):-Q,typeof j=="function"?-j.apply(this,arguments):-j),B,a)},$,U)};function v(P,Q){return Q=Math.max(s[0],Math.min(s[1],Q)),Q===P.k?P:new Mu(Q,P.x,P.y)}function x(P,Q,j){var $=Q[0]-j[0]*P.k,U=Q[1]-j[1]*P.k;return $===P.x&&U===P.y?P:new Mu(P.k,$,U)}function w(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function E(P,Q,j,$){P.on("start.zoom",function(){S(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event($).end()}).tween("zoom",function(){var U=this,B=arguments,I=S(U,B).event($),X=t.apply(U,B),q=j==null?w(X):typeof j=="function"?j.apply(U,B):j,D=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),H=U.__zoom,re=typeof Q=="function"?Q.apply(U,B):Q,fe=c(H.invert(q).concat(D/H.k),re.invert(q).concat(D/re.k));return function(Ae){if(Ae===1)Ae=re;else{var J=fe(Ae),ie=D/J[2];Ae=new Mu(ie,q[0]-J[0]*ie,q[1]-J[1]*ie)}I.zoom(null,Ae)}})}function S(P,Q,j){return!j&&P.__zooming||new k(P,Q)}function k(P,Q){this.that=P,this.args=Q,this.active=0,this.sourceEvent=null,this.extent=t.apply(P,Q),this.taps=0}k.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,Q){return this.mouse&&P!=="mouse"&&(this.mouse[1]=Q.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=Q.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=Q.invert(this.touch1[0])),this.that.__zoom=Q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var Q=fo(this.that).datum();u.call(P,this.that,new PAe(P,{sourceEvent:this.sourceEvent,target:O,transform:this.that.__zoom,dispatch:u}),Q)}};function T(P,...Q){if(!e.apply(this,arguments))return;var j=S(this,Q).event(P),$=this.__zoom,U=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),B=Tl(P);if(j.wheel)(j.mouse[0][0]!==B[0]||j.mouse[0][1]!==B[1])&&(j.mouse[1]=$.invert(j.mouse[0]=B)),clearTimeout(j.wheel);else{if($.k===U)return;j.mouse=[B,$.invert(B)],YS(this),j.start()}Yb(P),j.wheel=setTimeout(I,g),j.zoom("mouse",n(x(v($,U),j.mouse[0],j.mouse[1]),j.extent,a));function I(){j.wheel=null,j.end()}}function A(P,...Q){if(h||!e.apply(this,arguments))return;var j=P.currentTarget,$=S(this,Q,!0).event(P),U=fo(P.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",D,!0),B=Tl(P,j),I=P.clientX,X=P.clientY;$ee(P.view),X2(P),$.mouse=[B,this.__zoom.invert(B)],YS(this),$.start();function q(H){if(Yb(H),!$.moved){var re=H.clientX-I,fe=H.clientY-X;$.moved=re*re+fe*fe>b}$.event(H).zoom("mouse",n(x($.that.__zoom,$.mouse[0]=Tl(H,j),$.mouse[1]),$.extent,a))}function D(H){U.on("mousemove.zoom mouseup.zoom",null),Qee(H.view,$.moved),Yb(H),$.event(H).end()}}function N(P,...Q){if(e.apply(this,arguments)){var j=this.__zoom,$=Tl(P.changedTouches?P.changedTouches[0]:P,this),U=j.invert($),B=j.k*(P.shiftKey?.5:2),I=n(x(v(j,B),$,U),t.apply(this,Q),a);Yb(P),o>0?fo(this).transition().duration(o).call(E,I,$,P):fo(this).call(O.transform,I,$,P)}}function C(P,...Q){if(e.apply(this,arguments)){var j=P.touches,$=j.length,U=S(this,Q,P.changedTouches.length===$).event(P),B,I,X,q;for(X2(P),I=0;I<$;++I)X=j[I],q=Tl(X,this),q=[q,this.__zoom.invert(q),X.identifier],U.touch0?!U.touch1&&U.touch0[2]!==q[2]&&(U.touch1=q,U.taps=0):(U.touch0=q,B=!0,U.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(U.taps<2&&(f=q[0],d=setTimeout(function(){d=null},p)),YS(this),U.start())}}function M(P,...Q){if(this.__zooming){var j=S(this,Q).event(P),$=P.changedTouches,U=$.length,B,I,X,q;for(Yb(P),B=0;B`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ox=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],nte=["Enter"," ","Escape"],ite={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var r0;(function(e){e.Strict="strict",e.Loose="loose"})(r0||(r0={}));var rp;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(rp||(rp={}));var lx;(function(e){e.Partial="partial",e.Full="full"})(lx||(lx={}));const rte={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Kd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Kd||(Kd={}));var cx;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(cx||(cx={}));var St;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(St||(St={}));const B9={[St.Left]:St.Right,[St.Right]:St.Left,[St.Top]:St.Bottom,[St.Bottom]:St.Top};function ste(e){return e===null?null:e?"valid":"invalid"}const ate=e=>"id"in e&&"source"in e&&"target"in e,BAe=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),d$=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),k1=(e,t=[0,0])=>{const{width:n,height:i}=pd(e),r=e.origin??t,s=n*r[0],a=i*r[1];return{x:e.position.x-s,y:e.position.y-a}},UAe=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const s=typeof r=="string";let a=!t.nodeLookup&&!s?r:void 0;t.nodeLookup&&(a=s?t.nodeLookup.get(r):d$(r)?r:t.nodeLookup.get(r.id));const o=a?Ak(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return C_(i,o)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return j_(n)},T1=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=C_(n,Ak(r)),i=!0)}),i?j_(n):{x:0,y:0,width:0,height:0}},f$=(e,t,[n,i,r]=[0,0,1],s=!1,a=!1)=>{const o={...X0(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const p=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,b=ux(o,a0(u)),y=(p??0)*(g??0),O=s&&b>0;(!u.internals.handleBounds||O||b>=y||u.dragging)&&c.push(u)}return c},zAe=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function FAe(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function VAe({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:s},a){if(e.size===0)return!0;const o=FAe(e,a),c=T1(o),u=p$(c,t,n,(a==null?void 0:a.minZoom)??r,(a==null?void 0:a.maxZoom)??s,(a==null?void 0:a.padding)??.1);return await i.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function ote({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:s}){const a=n.get(e),o=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=o?o.internals.positionAbsolute:{x:0,y:0},d=a.origin??i;let f=a.extent||r;if(a.extent==="parent"&&!a.expandParent)if(!o)s==null||s("005",$l.error005());else{const p=o.measured.width,g=o.measured.height;p&&g&&(f=[[c,u],[c+p,u+g]])}else o&&yp(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=yp(f)?Op(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(s==null||s("015",$l.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function XAe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const s=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const p=s.has(h.id),g=!p&&h.parentId&&a.find(b=>b.id===h.parentId);(p||g)&&a.push(h)}const o=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),d=zAe(a,c);for(const h of c)o.has(h.id)&&!d.find(g=>g.id===h.id)&&d.push(h);if(!r)return{edges:d,nodes:a};const f=await r({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const s0=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Op=(e={x:0,y:0},t,n)=>({x:s0(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:s0(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function lte(e,t,n){const{width:i,height:r}=pd(n),{x:s,y:a}=n.internals.positionAbsolute;return Op(e,[[s,a],[s+i,a+r]],t)}const U9=(e,t,n)=>en?-s0(Math.abs(e-n),1,t)/t:0,h$=(e,t,n=15,i=40)=>{const r=U9(e.x,i,t.width-i)*n,s=U9(e.y,i,t.height-i)*n;return[r,s]},C_=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),vP=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),j_=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),a0=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=d$(e)?e.internals.positionAbsolute:k1(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},Ak=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=d$(e)?e.internals.positionAbsolute:k1(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},cte=(e,t)=>j_(C_(vP(e),vP(t))),ux=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},z9=e=>jl(e.width)&&jl(e.height)&&jl(e.x)&&jl(e.y),jl=e=>!isNaN(e)&&isFinite(e),ute=(e,t)=>(n,i)=>{},_1=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),X0=({x:e,y:t},[n,i,r],s=!1,a=[1,1])=>{const o={x:(e-n)/r,y:(t-i)/r};return s?_1(o,a):o},o0=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function im(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function qAe(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=im(e,n),r=im(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=im(e.top??e.y??0,n),r=im(e.bottom??e.y??0,n),s=im(e.left??e.x??0,t),a=im(e.right??e.x??0,t);return{top:i,right:a,bottom:r,left:s,x:s+a,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function HAe(e,t,n,i,r,s){const{x:a,y:o}=o0(e,[t,n,i]),{x:c,y:u}=o0({x:e.x+e.width,y:e.y+e.height},[t,n,i]),d=r-c,f=s-u;return{left:Math.floor(a),top:Math.floor(o),right:Math.floor(d),bottom:Math.floor(f)}}const p$=(e,t,n,i,r,s)=>{const a=qAe(s,t,n),o=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(o,c),d=s0(u,i,r),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*d,g=n/2-h*d,b=HAe(e,p,g,d,t,n),y={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:p-y.left+y.right,y:g-y.top+y.bottom,zoom:d}},dx=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function yp(e){return e!=null&&e!=="parent"}function pd(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function m$(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function dte(e,t={width:0,height:0},n,i,r){const s={...e},a=i.get(n);if(a){const o=a.origin||r;s.x+=a.internals.positionAbsolute.x-(t.width??0)*o[0],s.y+=a.internals.positionAbsolute.y-(t.height??0)*o[1]}return s}function F9(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function YAe(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function GAe(e){return{...ite,...e||{}}}function uy(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:s,y:a}=Rl(e),o=X0({x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?_1(o,t):o;return{xSnapped:c,ySnapped:u,...o}}const g$=e=>({width:e.offsetWidth,height:e.offsetHeight}),fte=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},WAe=["INPUT","SELECT","TEXTAREA"];function hte(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:WAe.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const pte=e=>"clientX"in e,Rl=(e,t)=>{var s,a;const n=pte(e),i=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,r=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},V9=(e,t,n,i,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(a=>{const o=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:r,position:a.getAttribute("data-handlepos"),x:(o.left-n.left)/i,y:(o.top-n.top)/i,...g$(a)}})};function mte({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:a,targetControlY:o}){const c=e*.125+r*.375+a*.375+n*.125,u=t*.125+s*.375+o*.375+i*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function dw(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function X9({pos:e,x1:t,y1:n,x2:i,y2:r,c:s}){switch(e){case St.Left:return[t-dw(t-i,s),n];case St.Right:return[t+dw(i-t,s),n];case St.Top:return[t,n-dw(n-r,s)];case St.Bottom:return[t,n+dw(r-n,s)]}}function gte({sourceX:e,sourceY:t,sourcePosition:n=St.Bottom,targetX:i,targetY:r,targetPosition:s=St.Top,curvature:a=.25}){const[o,c]=X9({pos:n,x1:e,y1:t,x2:i,y2:r,c:a}),[u,d]=X9({pos:s,x1:i,y1:r,x2:e,y2:t,c:a}),[f,h,p,g]=mte({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${c} ${u},${d} ${i},${r}`,f,h,p,g]}function bte({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,s=n0}const JAe=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,eNe=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),tNe=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",$l.error006()),t;const i=n.getEdgeId||JAe;let r;return ate(e)?r={...e}:r={...e,id:i(e)},eNe(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Ote({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,s,a,o]=bte({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,s,a,o]}const q9={[St.Left]:{x:-1,y:0},[St.Right]:{x:1,y:0},[St.Top]:{x:0,y:-1},[St.Bottom]:{x:0,y:1}},nNe=({source:e,sourcePosition:t=St.Bottom,target:n})=>t===St.Left||t===St.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function iNe({source:e,sourcePosition:t=St.Bottom,target:n,targetPosition:i=St.Top,center:r,offset:s,stepPosition:a}){const o=q9[t],c=q9[i],u={x:e.x+o.x*s,y:e.y+o.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},f=nNe({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",p=f[h];let g=[],b,y;const O={x:0,y:0},v={x:0,y:0},[,,x,w]=bte({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[h]*c[h]===-1){h==="x"?(b=r.x??u.x+(d.x-u.x)*a,y=r.y??(u.y+d.y)/2):(b=r.x??(u.x+d.x)/2,y=r.y??u.y+(d.y-u.y)*a);const T=[{x:b,y:u.y},{x:b,y:d.y}],A=[{x:u.x,y},{x:d.x,y}];o[h]===p?g=h==="x"?T:A:g=h==="x"?A:T}else{const T=[{x:u.x,y:d.y}],A=[{x:d.x,y:u.y}];if(h==="x"?g=o.x===p?A:T:g=o.y===p?T:A,t===i){const P=Math.abs(e[h]-n[h]);if(P<=s){const Q=Math.min(s-1,s-P);o[h]===p?O[h]=(u[h]>e[h]?-1:1)*Q:v[h]=(d[h]>n[h]?-1:1)*Q}}if(t!==i){const P=h==="x"?"y":"x",Q=o[h]===c[P],j=u[P]>d[P],$=u[P]=L?(b=(N.x+C.x)/2,y=g[0].y):(b=g[0].x,y=(N.y+C.y)/2)}const E={x:u.x+O.x,y:u.y+O.y},S={x:d.x+v.x,y:d.y+v.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,y,x,w]}function rNe(e,t,n,i){const r=Math.min(H9(e,t)/2,H9(t,n)/2,i),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function wP(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function aNe(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const s=new Set;return e.reduce((a,o)=>([o.markerStart||i,o.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=wP(c,t);s.has(u)||(a.push({id:u,color:c.color||n,...c}),s.add(u))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))}const yte=1e3,oNe=10,b$={nodeOrigin:[0,0],nodeExtent:ox,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},lNe={...b$,checkEquality:!0};function O$(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function cNe(e,t,n){const i=O$(b$,n);for(const r of e.values())if(r.parentId)x$(r,e,t,i);else{const s=k1(r,i.nodeOrigin),a=yp(r.extent)?r.extent:i.nodeExtent,o=Op(s,a,pd(r));r.internals.positionAbsolute=o}}function uNe(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const s={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(s):r.type==="target"&&i.push(s)}return{source:n,target:i}}function y$(e){return e==="manual"}function SP(e,t,n,i={}){var d,f;const r=O$(lNe,i),s={i:0},a=new Map(t),o=r!=null&&r.elevateNodesOnSelect&&!y$(r.zIndexMode)?yte:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let p=a.get(h.id);if(r.checkEquality&&h===(p==null?void 0:p.internals.userNode))t.set(h.id,p);else{const g=k1(h,r.nodeOrigin),b=yp(h.extent)?h.extent:r.nodeExtent,y=Op(g,b,pd(h));p={...r.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:y,handleBounds:uNe(h,p),z:xte(h,o,r.zIndexMode),userNode:h}},t.set(h.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),h.parentId&&x$(p,t,n,i,s),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function dNe(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function x$(e,t,n,i,r){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:o,zIndexMode:c}=O$(b$,i),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}dNe(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*oNe),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const f=s&&!y$(c)?yte:0,{x:h,y:p,z:g}=fNe(e,d,a,o,f,c),{positionAbsolute:b}=e.internals,y=h!==b.x||p!==b.y;(y||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,y:p}:b,z:g}})}function xte(e,t,n){const i=jl(e.zIndex)?e.zIndex:0;return y$(n)?i:i+(e.selected?t:0)}function fNe(e,t,n,i,r,s){const{x:a,y:o}=t.internals.positionAbsolute,c=pd(e),u=k1(e,n),d=yp(e.extent)?Op(u,e.extent,c):u;let f=Op({x:a+d.x,y:o+d.y},i,c);e.extent==="parent"&&(f=lte(f,c,t));const h=xte(e,r,s),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function v$(e,t,n,i=[0,0]){var a;const r=[],s=new Map;for(const o of e){const c=t.get(o.parentId);if(!c)continue;const u=((a=s.get(o.parentId))==null?void 0:a.expandedRect)??a0(c),d=cte(u,o.rect);s.set(o.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:o,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=pd(c),h=c.origin??i,p=o.x0||g>0||O||v)&&(r.push({id:u,type:"position",position:{x:c.position.x-p+O,y:c.position.y-g+v}}),(x=n.get(u))==null||x.forEach(w=>{e.some(E=>E.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+g}})})),(f.width0){const p=v$(h,t,n,r);u.push(...p)}return{changes:u,updatedInternals:c}}async function pNe({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:s}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],i);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function Z9(e,t,n,i,r,s){let a=r;const o=i.get(a)||new Map;i.set(a,o.set(n,t)),a=`${r}-${e}`;const c=i.get(a)||new Map;if(i.set(a,c.set(n,t)),s){a=`${r}-${e}-${s}`;const u=i.get(a)||new Map;i.set(a,u.set(n,t))}}function vte(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:s,sourceHandle:a=null,targetHandle:o=null}=i,c={edgeId:i.id,source:r,target:s,sourceHandle:a,targetHandle:o},u=`${r}-${a}--${s}-${o}`,d=`${s}-${o}--${r}-${a}`;Z9("source",c,d,e,r,a),Z9("target",c,u,e,s,o),t.set(i.id,i)}}function wte(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:wte(n,t):!1}function K9(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function mNe(e,t,n,i){const r=new Map;for(const[s,a]of e)if((a.selected||a.id===i)&&(!a.parentId||!wte(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const o=e.get(s);o&&r.set(s,{id:s,position:o.position||{x:0,y:0},distance:{x:n.x-o.internals.positionAbsolute.x,y:n.y-o.internals.positionAbsolute.y},extent:o.extent,parentId:o.parentId,origin:o.origin,expandParent:o.expandParent,internals:{positionAbsolute:o.internals.positionAbsolute||{x:0,y:0}},measured:{width:o.measured.width??0,height:o.measured.height??0}})}return r}function q2({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var a,o,c;const r=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&r.push({...f,position:d.position,dragging:i})}if(!e)return[r[0],r];const s=(o=n.get(e))==null?void 0:o.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:i}:r[0],r]}function gNe({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:i-r.distance.y},a=_1(s,t);return{x:a.x-s.x,y:a.y-s.y}}function bNe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let s={x:null,y:null},a=0,o=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,p=!1,g=!1,b=null;function y({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:E,nodeId:S,nodeClickDistance:k=0}){h=fo(w);function T({x:M,y:L}){const{nodeLookup:P,nodeExtent:Q,snapGrid:j,snapToGrid:$,nodeOrigin:U,onNodeDrag:B,onSelectionDrag:I,onError:X,updateNodePositions:q}=t();s={x:M,y:L};let D=!1;const H=o.size>1,re=H&&Q?vP(T1(o)):null,fe=H&&$?gNe({dragItems:o,snapGrid:j,x:M,y:L}):null;for(const[Ae,J]of o){if(!P.has(Ae))continue;let ie={x:M-J.distance.x,y:L-J.distance.y};$&&(ie=fe?{x:Math.round(ie.x+fe.x),y:Math.round(ie.y+fe.y)}:_1(ie,j));let ue=null;if(H&&Q&&!J.extent&&re){const{positionAbsolute:Re}=J.internals,Ee=Re.x-re.x+Q[0][0],me=Re.x+J.measured.width-re.x2+Q[1][0],oe=Re.y-re.y+Q[0][1],Ne=Re.y+J.measured.height-re.y2+Q[1][1];ue=[[Ee,oe],[me,Ne]]}const{position:ye,positionAbsolute:Se}=ote({nodeId:Ae,nextPosition:ie,nodeLookup:P,nodeExtent:ue||Q,nodeOrigin:U,onError:X});D=D||J.position.x!==ye.x||J.position.y!==ye.y,J.position=ye,J.internals.positionAbsolute=Se}if(g=g||D,!!D&&(q(o,!0),b&&(i||B||!S&&I))){const[Ae,J]=q2({nodeId:S,dragItems:o,nodeLookup:P});i==null||i(b,o,Ae,J),B==null||B(b,Ae,J),S||I==null||I(b,J)}}async function A(){if(!d)return;const{transform:M,panBy:L,autoPanSpeed:P,autoPanOnNodeDrag:Q}=t();if(!Q){c=!1,cancelAnimationFrame(a);return}const[j,$]=h$(u,d,P);(j!==0||$!==0)&&(s.x=(s.x??0)-j/M[2],s.y=(s.y??0)-$/M[2],await L({x:j,y:$})&&T(s)),a=requestAnimationFrame(A)}function N(M){var H;const{nodeLookup:L,multiSelectionActive:P,nodesDraggable:Q,transform:j,snapGrid:$,snapToGrid:U,selectNodesOnDrag:B,onNodeDragStart:I,onSelectionDragStart:X,unselectNodesAndEdges:q}=t();f=!0,(!B||!E)&&!P&&S&&((H=L.get(S))!=null&&H.selected||q()),E&&B&&S&&(e==null||e(S));const D=uy(M.sourceEvent,{transform:j,snapGrid:$,snapToGrid:U,containerBounds:d});if(s=D,o=mNe(L,Q,D,S),o.size>0&&(n||I||!S&&X)){const[re,fe]=q2({nodeId:S,dragItems:o,nodeLookup:L});n==null||n(M.sourceEvent,o,re,fe),I==null||I(M.sourceEvent,re,fe),S||X==null||X(M.sourceEvent,fe)}}const C=Bee().clickDistance(k).on("start",M=>{const{domNode:L,nodeDragThreshold:P,transform:Q,snapGrid:j,snapToGrid:$}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,g=!1,b=M.sourceEvent,P===0&&N(M),s=uy(M.sourceEvent,{transform:Q,snapGrid:j,snapToGrid:$,containerBounds:d}),u=Rl(M.sourceEvent,d)}).on("drag",M=>{const{autoPanOnNodeDrag:L,transform:P,snapGrid:Q,snapToGrid:j,nodeDragThreshold:$,nodeLookup:U}=t(),B=uy(M.sourceEvent,{transform:P,snapGrid:Q,snapToGrid:j,containerBounds:d});if(b=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||S&&!U.has(S))&&(p=!0),!p){if(!c&&L&&f&&(c=!0,A()),!f){const I=Rl(M.sourceEvent,d),X=I.x-u.x,q=I.y-u.y;Math.sqrt(X*X+q*q)>$&&N(M)}(s.x!==B.xSnapped||s.y!==B.ySnapped)&&o&&f&&(u=Rl(M.sourceEvent,d),T(B))}}).on("end",M=>{if(!f||p){p&&o.size>0&&t().updateNodePositions(o,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),o.size>0){const{nodeLookup:L,updateNodePositions:P,onNodeDragStop:Q,onSelectionDragStop:j}=t();if(g&&(P(o,!1),g=!1),r||Q||!S&&j){const[$,U]=q2({nodeId:S,dragItems:o,nodeLookup:L,dragging:!1});r==null||r(M.sourceEvent,o,$,U),Q==null||Q(M.sourceEvent,$,U),S||j==null||j(M.sourceEvent,U)}}}).filter(M=>{const L=M.target;return!M.button&&(!v||!K9(L,`.${v}`,w))&&(!x||K9(L,x,w))});h.call(C)}function O(){h==null||h.on(".drag",null)}return{update:y,destroy:O}}function ONe(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())ux(r,a0(s))>0&&i.push(s);return i}const yNe=250;function xNe(e,t,n,i){var o,c;let r=[],s=1/0;const a=ONe(e,n,t+yNe);for(const u of a){const d=[...((o=u.internals.handleBounds)==null?void 0:o.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(i.nodeId===f.nodeId&&i.type===f.type&&i.id===f.id)continue;const{x:h,y:p}=xp(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));g>t||(g1){const u=i.type==="source"?"target":"source";return r.find(d=>d.type===u)??r[0]}return r[0]}function Ste(e,t,n,i,r,s=!1){var u,d,f;const a=i.get(e);if(!a)return null;const o=r==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?o==null?void 0:o.find(h=>h.id===n):o==null?void 0:o[0])??null;return c&&s?{...c,...xp(a,c,c.position,!0)}:c}function Ete(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function vNe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const kte=()=>!0;function wNe(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:s,isTarget:a,domNode:o,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:p,onConnectStart:g,onConnect:b,onConnectEnd:y,isValidConnection:O=kte,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:E,autoPanSpeed:S,dragThreshold:k=1,handleDomNode:T}){const A=fte(e.target);let N=0,C;const{x:M,y:L}=Rl(e),P=Ete(s,T),Q=o==null?void 0:o.getBoundingClientRect();let j=!1;if(!Q||!P)return;const $=Ste(r,P,i,c,t);if(!$)return;let U=Rl(e,Q),B=!1,I=null,X=!1,q=null;function D(){if(!d||!Q)return;const[ye,Se]=h$(U,Q,S);h({x:ye,y:Se}),N=requestAnimationFrame(D)}const H={...$,nodeId:r,type:P,position:$.position},re=c.get(r);let Ae={inProgress:!0,isValid:null,from:xp(re,H,St.Left,!0),fromHandle:H,fromPosition:H.position,fromNode:re,to:U,toHandle:null,toPosition:B9[H.position],toNode:null,pointer:U};function J(){j=!0,x(Ae),g==null||g(e,{nodeId:r,handleId:i,handleType:P})}k===0&&J();function ie(ye){if(!j){const{x:Ne,y:Oe}=Rl(ye),Ve=Ne-M,We=Oe-L;if(!(Ve*Ve+We*We>k*k))return;J()}if(!E()||!H){ue(ye);return}const Se=w();U=Rl(ye,Q),C=xNe(X0(U,Se,!1,[1,1]),n,c,H),B||(D(),B=!0);const Re=Tte(ye,{handle:C,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:a?"target":"source",isValidConnection:O,doc:A,lib:u,flowId:f,nodeLookup:c});q=Re.handleDomNode,I=Re.connection,X=vNe(!!C,Re.isValid);const Ee=c.get(r),me=Ee?xp(Ee,H,St.Left,!0):Ae.from,oe={...Ae,from:me,isValid:X,to:Re.toHandle&&X?o0({x:Re.toHandle.x,y:Re.toHandle.y},Se):U,toHandle:Re.toHandle,toPosition:X&&Re.toHandle?Re.toHandle.position:B9[H.position],toNode:Re.toHandle?c.get(Re.toHandle.nodeId):null,pointer:U};x(oe),Ae=oe}function ue(ye){if(!("touches"in ye&&ye.touches.length>0)){if(j){(C||q)&&I&&X&&(b==null||b(I));const{inProgress:Se,...Re}=Ae,Ee={...Re,toPosition:Ae.toHandle?Ae.toPosition:null};y==null||y(ye,Ee),s&&(v==null||v(ye,Ee))}p(),cancelAnimationFrame(N),B=!1,X=!1,I=null,q=null,A.removeEventListener("mousemove",ie),A.removeEventListener("mouseup",ue),A.removeEventListener("touchmove",ie),A.removeEventListener("touchend",ue)}}A.addEventListener("mousemove",ie),A.addEventListener("mouseup",ue),A.addEventListener("touchmove",ie),A.addEventListener("touchend",ue)}function Tte(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s,doc:a,lib:o,flowId:c,isValidConnection:u=kte,nodeLookup:d}){const f=s==="target",h=t?a.querySelector(`.${o}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:g}=Rl(e),b=a.elementFromPoint(p,g),y=b!=null&&b.classList.contains(`${o}-flow__handle`)?b:h,O={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Ete(void 0,y),x=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),E=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!x||!v)return O;const k={source:f?x:i,sourceHandle:f?w:r,target:f?i:x,targetHandle:f?r:w};O.connection=k;const A=E&&S&&(n===r0.Strict?f&&v==="source"||!f&&v==="target":x!==i||w!==r);O.isValid=A&&u(k),O.toHandle=Ste(x,v,w,d,n,!0)}return O}const EP={onPointerDown:wNe,isValid:Tte};function SNe({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=fo(e);function s({translateExtent:o,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const w=n(),E=x.sourceEvent.ctrlKey&&dx()?10:1,S=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,k=w[2]*Math.pow(2,S*E);t.scaleTo(k)};let b=[0,0];const y=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(b=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},O=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const E=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],S=[E[0]-b[0],E[1]-b[1]];b=E;const k=i()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),T={x:w[0]-S[0]*k,y:w[1]-S[1]*k},A=[[0,0],[c,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},A,o)},v=tte().on("start",y).on("zoom",f?O:null).on("zoom.wheel",h?g:null);r.call(v,{})}function a(){r.on("zoom",null)}return{update:s,destroy:a,pointer:Tl}}const R_=e=>({x:e.x,y:e.y,zoom:e.k}),H2=({x:e,y:t,zoom:n})=>N_.translate(e,t).scale(n),Jm=(e,t)=>e.target.closest(`.${t}`),_te=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),ENe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Y2=(e,t=0,n=ENe,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},Ate=e=>{const t=e.ctrlKey&&dx()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function kNe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:o,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Jm(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const y=Tl(d),O=Ate(d),v=f*Math.pow(2,O);i.scaleTo(n,v,y,d);return}const h=d.deltaMode===1?20:1;let p=r===rp.Vertical?0:d.deltaX*h,g=r===rp.Horizontal?0:d.deltaY*h;!dx()&&d.shiftKey&&r!==rp.Vertical&&(p=d.deltaY*h,g=0),i.translateBy(n,-(p/f)*s,-(g/f)*s,{internal:!0});const b=R_(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,o==null||o(d,b))}}function TNe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const s=i.type==="wheel",a=!t&&s&&!i.ctrlKey,o=Jm(i,e);if(i.ctrlKey&&s&&o&&i.preventDefault(),a||o)return null;i.preventDefault(),n.call(this,i,r)}}function _Ne({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var s,a,o;if((s=i.sourceEvent)!=null&&s.internal)return;const r=R_(i.transform);e.mouseButton=((a=i.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((o=i.sourceEvent)==null?void 0:o.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function ANe({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return s=>{var a,o;e.usedRightMouseButton=!!(n&&_te(t,e.mouseButton??0)),(a=s.sourceEvent)!=null&&a.sync||i([s.transform.x,s.transform.y,s.transform.k]),r&&!((o=s.sourceEvent)!=null&&o.internal)&&(r==null||r(s.sourceEvent,R_(s.transform)))}}function NNe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:s}){return a=>{var o;if(!((o=a.sourceEvent)!=null&&o.internal)&&(e.isZoomingOrPanning=!1,s&&_te(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=R_(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(a.sourceEvent,c)},n?150:0)}}}function CNe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:o,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var y;const h=e||t,p=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Jm(f,`${u}-flow__node`)||Jm(f,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!s&&!n||a||d&&!g||Jm(f,o)&&g||Jm(f,c)&&(!g||r&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((y=f.touches)==null?void 0:y.length)>1)return f.preventDefault(),!1;if(!h&&!r&&!p&&g||!i&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(i)&&!i.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function jNe({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:s,onPanZoomStart:a,onPanZoomEnd:o,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=tte().scaleExtent([t,n]).translateExtent(i),h=fo(e).call(f);v({x:r.x,y:r.y,zoom:s0(r.zoom,t,n)},[[0,0],[d.width,d.height]],i);const p=h.on("wheel.zoom"),g=h.on("dblclick.zoom");f.wheelDelta(Ate);async function b(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).transform(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}function y({noWheelClassName:C,noPanClassName:M,onPaneContextMenu:L,userSelectionActive:P,panOnScroll:Q,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:U,preventScrolling:B,zoomOnPinch:I,zoomOnScroll:X,zoomOnDoubleClick:q,zoomActivationKeyPressed:D,lib:H,onTransformChange:re,connectionInProgress:fe,paneClickDistance:Ae,selectionOnDrag:J}){P&&!u.isZoomingOrPanning&&O();const ie=Q&&!D&&!P;f.clickDistance(J?1/0:!jl(Ae)||Ae<0?0:Ae);const ue=ie?kNe({zoomPanValues:u,noWheelClassName:C,d3Selection:h,d3Zoom:f,panOnScrollMode:$,panOnScrollSpeed:U,zoomOnPinch:I,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:o}):TNe({noWheelClassName:C,preventScrolling:B,d3ZoomHandler:p});h.on("wheel.zoom",ue,{passive:!1});const ye=_Ne({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",ye);const Se=ANe({zoomPanValues:u,panOnDrag:j,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:re});f.on("zoom",Se);const Re=NNe({zoomPanValues:u,panOnDrag:j,panOnScroll:Q,onPaneContextMenu:L,onPanZoomEnd:o,onDraggingChange:c});f.on("end",Re);const Ee=CNe({zoomActivationKeyPressed:D,panOnDrag:j,zoomOnScroll:X,panOnScroll:Q,zoomOnDoubleClick:q,zoomOnPinch:I,userSelectionActive:P,noPanClassName:M,noWheelClassName:C,lib:H,connectionInProgress:fe});f.filter(Ee),q?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function O(){f.on("zoom",null)}async function v(C,M,L){const P=H2(C),Q=f==null?void 0:f.constrain()(P,M,L);return Q&&await b(Q),Q}async function x(C,M){const L=H2(C);return await b(L,M),L}function w(C){if(h){const M=H2(C),L=h.property("__zoom");(L.k!==C.zoom||L.x!==C.x||L.y!==C.y)&&(f==null||f.transform(h,M,null,{sync:!0}))}}function E(){const C=h?ete(h.node()):{x:0,y:0,k:1};return{x:C.x,y:C.y,zoom:C.k}}async function S(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).scaleTo(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}async function k(C,M){return h?new Promise(L=>{f==null||f.interpolate((M==null?void 0:M.interpolate)==="linear"?cy:XS).scaleBy(Y2(h,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),C)}):!1}function T(C){f==null||f.scaleExtent(C)}function A(C){f==null||f.translateExtent(C)}function N(C){const M=!jl(C)||C<0?0:C;f==null||f.clickDistance(M)}return{update:y,destroy:O,setViewport:x,setViewportConstrained:v,getViewport:E,scaleTo:S,scaleBy:k,setScaleExtent:T,setTranslateExtent:A,syncViewport:w,setClickDistance:N}}var l0;(function(e){e.Line="line",e.Handle="handle"})(l0||(l0={}));function RNe({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:s}){const a=e-t,o=n-i,c=[a>0?1:a<0?-1:0,o>0?1:o<0?-1:0];return a&&r&&(c[0]=c[0]*-1),o&&s&&(c[1]=c[1]*-1),c}function J9(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Rd(e,t){return Math.max(0,t-e)}function Id(e,t){return Math.max(0,e-t)}function fw(e,t,n){return Math.max(0,t-e,e-n)}function eU(e,t){return e?!t:t}function INe(e,t,n,i,r,s,a,o){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:b,maxWidth:y,minHeight:O,maxHeight:v}=i,{x,y:w,width:E,height:S,aspectRatio:k}=e;let T=Math.floor(d?p-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const N=E+(c?-T:T),C=S+(u?-A:A),M=-s[0]*E,L=-s[1]*S;let P=fw(N,b,y),Q=fw(C,O,v);if(a){let U=0,B=0;c&&T<0?U=Rd(x+T+M,a[0][0]):!c&&T>0&&(U=Id(x+N+M,a[1][0])),u&&A<0?B=Rd(w+A+L,a[0][1]):!u&&A>0&&(B=Id(w+C+L,a[1][1])),P=Math.max(P,U),Q=Math.max(Q,B)}if(o){let U=0,B=0;c&&T>0?U=Id(x+T,o[0][0]):!c&&T<0&&(U=Rd(x+N,o[1][0])),u&&A>0?B=Id(w+A,o[0][1]):!u&&A<0&&(B=Rd(w+C,o[1][1])),P=Math.max(P,U),Q=Math.max(Q,B)}if(r){if(d){const U=fw(N/k,O,v)*k;if(P=Math.max(P,U),a){let B=0;!c&&!u||c&&!u&&h?B=Id(w+L+N/k,a[1][1])*k:B=Rd(w+L+(c?T:-T)/k,a[0][1])*k,P=Math.max(P,B)}if(o){let B=0;!c&&!u||c&&!u&&h?B=Rd(w+N/k,o[1][1])*k:B=Id(w+(c?T:-T)/k,o[0][1])*k,P=Math.max(P,B)}}if(f){const U=fw(C*k,b,y)/k;if(Q=Math.max(Q,U),a){let B=0;!c&&!u||u&&!c&&h?B=Id(x+C*k+M,a[1][0])/k:B=Rd(x+(u?A:-A)*k+M,a[0][0])/k,Q=Math.max(Q,B)}if(o){let B=0;!c&&!u||u&&!c&&h?B=Rd(x+C*k,o[1][0])/k:B=Id(x+(u?A:-A)*k,o[0][0])/k,Q=Math.max(Q,B)}}}A=A+(A<0?Q:-Q),T=T+(T<0?P:-P),r&&(h?N>C*k?A=(eU(c,u)?-T:T)/k:T=(eU(c,u)?-A:A)*k:d?(A=T/k,u=c):(T=A*k,c=u));const j=c?x+T:x,$=u?w+A:w;return{width:E+(c?-T:T),height:S+(u?-A:A),x:s[0]*T*(c?-1:1)+j,y:s[1]*A*(u?-1:1)+$}}const Nte={width:0,height:0,x:0,y:0},PNe={...Nte,pointerX:0,pointerY:0,aspectRatio:1};function MNe(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,a=e.measured.height??0,o=n[0]*s,c=n[1]*a;return[[i-o,r-c],[i+s-o,r+a-c]]}function LNe({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const s=fo(e);let a={controlDirection:J9("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function o({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:g,onResizeEnd:b,shouldResize:y}){let O={...Nte},v={...PNe};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:J9(u)};let x,w=null,E=[],S,k,T,A=!1;const N=Bee().on("start",C=>{const{nodeLookup:M,transform:L,snapGrid:P,snapToGrid:Q,nodeOrigin:j,paneDomNode:$}=n();if(x=M.get(t),!x)return;w=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:U,ySnapped:B}=uy(C.sourceEvent,{transform:L,snapGrid:P,snapToGrid:Q,containerBounds:w});O={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...O,pointerX:U,pointerY:B,aspectRatio:O.width/O.height},S=void 0,k=yp(x.extent)?x.extent:void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(S=M.get(x.parentId)),S&&x.extent==="parent"&&(k=[[0,0],[S.measured.width,S.measured.height]]),E=[],T=void 0;for(const[I,X]of M)if(X.parentId===t&&(E.push({id:I,position:{...X.position},extent:X.extent}),X.extent==="parent"||X.expandParent)){const q=MNe(X,x,X.origin??j);T?T=[[Math.min(q[0][0],T[0][0]),Math.min(q[0][1],T[0][1])],[Math.max(q[1][0],T[1][0]),Math.max(q[1][1],T[1][1])]]:T=q}p==null||p(C,{...O})}).on("drag",C=>{const{transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q}=n(),j=uy(C.sourceEvent,{transform:M,snapGrid:L,snapToGrid:P,containerBounds:w}),$=[];if(!x)return;const{x:U,y:B,width:I,height:X}=O,q={},D=x.origin??Q,{width:H,height:re,x:fe,y:Ae}=INe(v,a.controlDirection,j,a.boundaries,a.keepAspectRatio,D,k,T),J=H!==I,ie=re!==X,ue=fe!==U&&J,ye=Ae!==B&&ie;if(!ue&&!ye&&!J&&!ie)return;if((ue||ye||D[0]===1||D[1]===1)&&(q.x=ue?fe:O.x,q.y=ye?Ae:O.y,O.x=q.x,O.y=q.y,E.length>0)){const me=fe-U,oe=Ae-B;for(const Ne of E)Ne.position={x:Ne.position.x-me+D[0]*(H-I),y:Ne.position.y-oe+D[1]*(re-X)},$.push(Ne)}if((J||ie)&&(q.width=J&&(!a.resizeDirection||a.resizeDirection==="horizontal")?H:O.width,q.height=ie&&(!a.resizeDirection||a.resizeDirection==="vertical")?re:O.height,O.width=q.width,O.height=q.height),S&&x.expandParent){const me=D[0]*(q.width??0);q.x&&q.x{A&&(b==null||b(C,{...O}),r==null||r({...O}),A=!1)});s.call(N)}function c(){s.on(".drag",null)}return{update:o,destroy:c}}var Cte={exports:{}},jte={},Rte={exports:{}},Ite={};/** * @license React * use-sync-external-store-shim.production.js * @@ -430,7 +430,7 @@ ${u}`:c,children:[l.jsxs("span",{className:`account-avatar${p?" has-image":""}`, * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var c0=m;function LNe(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var DNe=typeof Object.is=="function"?Object.is:LNe,$Ne=c0.useState,QNe=c0.useEffect,BNe=c0.useLayoutEffect,UNe=c0.useDebugValue;function zNe(e,t){var n=t(),i=$Ne({inst:{value:n,getSnapshot:t}}),r=i[0].inst,s=i[1];return BNe(function(){r.value=n,r.getSnapshot=t,G2(r)&&s({inst:r})},[e,n,t]),QNe(function(){return G2(r)&&s({inst:r}),e(function(){G2(r)&&s({inst:r})})},[e]),UNe(n),n}function G2(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!DNe(e,n)}catch{return!0}}function FNe(e,t){return t()}var VNe=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?FNe:zNe;Rte.useSyncExternalStore=c0.useSyncExternalStore!==void 0?c0.useSyncExternalStore:VNe;jte.exports=Rte;var XNe=jte.exports;/** + */var c0=m;function DNe(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $Ne=typeof Object.is=="function"?Object.is:DNe,QNe=c0.useState,BNe=c0.useEffect,UNe=c0.useLayoutEffect,zNe=c0.useDebugValue;function FNe(e,t){var n=t(),i=QNe({inst:{value:n,getSnapshot:t}}),r=i[0].inst,s=i[1];return UNe(function(){r.value=n,r.getSnapshot=t,G2(r)&&s({inst:r})},[e,n,t]),BNe(function(){return G2(r)&&s({inst:r}),e(function(){G2(r)&&s({inst:r})})},[e]),zNe(n),n}function G2(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$Ne(e,n)}catch{return!0}}function VNe(e,t){return t()}var XNe=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?VNe:FNe;Ite.useSyncExternalStore=c0.useSyncExternalStore!==void 0?c0.useSyncExternalStore:XNe;Rte.exports=Ite;var qNe=Rte.exports;/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -438,26 +438,26 @@ ${u}`:c,children:[l.jsxs("span",{className:`account-avatar${p?" has-image":""}`, * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var I_=m,qNe=XNe;function HNe(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var YNe=typeof Object.is=="function"?Object.is:HNe,GNe=qNe.useSyncExternalStore,WNe=I_.useRef,ZNe=I_.useEffect,KNe=I_.useMemo,JNe=I_.useDebugValue;Cte.useSyncExternalStoreWithSelector=function(e,t,n,i,r){var s=WNe(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=KNe(function(){function c(p){if(!u){if(u=!0,d=p,p=i(p),r!==void 0&&a.hasValue){var g=a.value;if(r(g,p))return f=g}return f=p}if(g=f,YNe(d,p))return g;var b=i(p);return r!==void 0&&r(g,b)?(d=p,g):(d=p,f=b)}var u=!1,d,f,h=n===void 0?null:n;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,n,i,r]);var o=GNe(e,s[0],s[1]);return ZNe(function(){a.hasValue=!0,a.value=o},[o]),JNe(o),o};Nte.exports=Cte;var e2e=Nte.exports;const t2e=N0(e2e),n2e={},tU=e=>{let t;const n=new Set,i=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,p))}},r=()=>t,c={setState:i,getState:r,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(n2e?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(i,r,c);return c},i2e=e=>e?tU(e):tU,{useDebugValue:r2e}=mn,{useSyncExternalStoreWithSelector:s2e}=t2e,a2e=e=>e;function Ite(e,t=a2e,n){const i=s2e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return r2e(i),i}const nU=(e,t)=>{const n=i2e(e),i=(r,s=t)=>Ite(n,r,s);return Object.assign(i,n),i},o2e=(e,t)=>e?nU(e,t):nU;function cr(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[i,r]of e)if(!Object.is(r,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}const P_=m.createContext(null),l2e=P_.Provider,Pte=$l.error001("react");function zn(e,t){const n=m.useContext(P_);if(n===null)throw new Error(Pte);return Ite(n,e,t)}function ur(){const e=m.useContext(P_);if(e===null)throw new Error(Pte);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const iU={display:"none"},c2e={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Mte="react-flow__node-desc",Lte="react-flow__edge-desc",u2e="react-flow__aria-live",d2e=e=>e.ariaLiveMessage,f2e=e=>e.ariaLabelConfig;function h2e({rfId:e}){const t=zn(d2e);return l.jsx("div",{id:`${u2e}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:c2e,children:t})}function p2e({rfId:e,disableKeyboardA11y:t}){const n=zn(f2e);return l.jsxs(l.Fragment,{children:[l.jsx("div",{id:`${Mte}-${e}`,style:iU,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),l.jsx("div",{id:`${Lte}-${e}`,style:iU,children:n["edge.a11yDescription.default"]}),!t&&l.jsx(h2e,{rfId:e})]})}const M_=m.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},s)=>{const a=`${e}`.split("-");return l.jsx("div",{className:Yr(["react-flow__panel",n,...a]),style:i,ref:s,...r,children:t})});M_.displayName="Panel";function m2e({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l.jsx(M_,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:l.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const g2e=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},hw=e=>e.id;function b2e(e,t){return cr(e.selectedNodes.map(hw),t.selectedNodes.map(hw))&&cr(e.selectedEdges.map(hw),t.selectedEdges.map(hw))}function O2e({onSelectionChange:e}){const t=ur(),{selectedNodes:n,selectedEdges:i}=zn(g2e,b2e);return m.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,i,e]),null}const y2e=e=>!!e.onSelectionChangeHandlers;function x2e({onSelectionChange:e}){const t=zn(y2e);return e||t?l.jsx(O2e,{onSelectionChange:e}):null}const Dte=[0,0],v2e={x:0,y:0,zoom:1},w2e=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],rU=[...w2e,"rfId"],S2e=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),sU={translateExtent:ox,nodeOrigin:Dte,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function E2e(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:a,reset:o,setDefaultNodesAndEdges:c}=zn(S2e,cr),u=ur();m.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=sU,o()}),[]);const d=m.useRef(sU);return m.useEffect(()=>{for(const f of rU){const h=e[f],p=d.current[f];h!==p&&(typeof e[f]>"u"||(f==="nodes"?t(h):f==="edges"?n(h):f==="minZoom"?i(h):f==="maxZoom"?r(h):f==="translateExtent"?s(h):f==="nodeExtent"?a(h):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:YAe(h)}):f==="fitView"?u.setState({fitViewQueued:h}):f==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[f]:h})))}d.current=e},rU.map(f=>e[f])),null}function aU(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function k2e(e){var i;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const r=aU(),s=()=>n(r!=null&&r.matches?"dark":"light");return s(),r==null||r.addEventListener("change",s),()=>{r==null||r.removeEventListener("change",s)}},[e]),t!==null?t:(i=aU())!=null&&i.matches?"dark":"light"}const oU=typeof document<"u"?document:null;function fx(e=null,t={target:oU,actInsideInputWithModifier:!0}){const[n,i]=m.useState(!1),r=m.useRef(!1),s=m.useRef(new Set([])),[a,o]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",` + */var I_=m,HNe=qNe;function YNe(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var GNe=typeof Object.is=="function"?Object.is:YNe,WNe=HNe.useSyncExternalStore,ZNe=I_.useRef,KNe=I_.useEffect,JNe=I_.useMemo,e2e=I_.useDebugValue;jte.useSyncExternalStoreWithSelector=function(e,t,n,i,r){var s=ZNe(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=JNe(function(){function c(p){if(!u){if(u=!0,d=p,p=i(p),r!==void 0&&a.hasValue){var g=a.value;if(r(g,p))return f=g}return f=p}if(g=f,GNe(d,p))return g;var b=i(p);return r!==void 0&&r(g,b)?(d=p,g):(d=p,f=b)}var u=!1,d,f,h=n===void 0?null:n;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,n,i,r]);var o=WNe(e,s[0],s[1]);return KNe(function(){a.hasValue=!0,a.value=o},[o]),e2e(o),o};Cte.exports=jte;var t2e=Cte.exports;const n2e=N0(t2e),i2e={},tU=e=>{let t;const n=new Set,i=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,p))}},r=()=>t,c={setState:i,getState:r,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(i2e?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(i,r,c);return c},r2e=e=>e?tU(e):tU,{useDebugValue:s2e}=mn,{useSyncExternalStoreWithSelector:a2e}=n2e,o2e=e=>e;function Pte(e,t=o2e,n){const i=a2e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return s2e(i),i}const nU=(e,t)=>{const n=r2e(e),i=(r,s=t)=>Pte(n,r,s);return Object.assign(i,n),i},l2e=(e,t)=>e?nU(e,t):nU;function cr(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[i,r]of e)if(!Object.is(r,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}const P_=m.createContext(null),c2e=P_.Provider,Mte=$l.error001("react");function zn(e,t){const n=m.useContext(P_);if(n===null)throw new Error(Mte);return Pte(n,e,t)}function ur(){const e=m.useContext(P_);if(e===null)throw new Error(Mte);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const iU={display:"none"},u2e={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lte="react-flow__node-desc",Dte="react-flow__edge-desc",d2e="react-flow__aria-live",f2e=e=>e.ariaLiveMessage,h2e=e=>e.ariaLabelConfig;function p2e({rfId:e}){const t=zn(f2e);return l.jsx("div",{id:`${d2e}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:u2e,children:t})}function m2e({rfId:e,disableKeyboardA11y:t}){const n=zn(h2e);return l.jsxs(l.Fragment,{children:[l.jsx("div",{id:`${Lte}-${e}`,style:iU,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),l.jsx("div",{id:`${Dte}-${e}`,style:iU,children:n["edge.a11yDescription.default"]}),!t&&l.jsx(p2e,{rfId:e})]})}const M_=m.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},s)=>{const a=`${e}`.split("-");return l.jsx("div",{className:Yr(["react-flow__panel",n,...a]),style:i,ref:s,...r,children:t})});M_.displayName="Panel";function g2e({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l.jsx(M_,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:l.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const b2e=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},hw=e=>e.id;function O2e(e,t){return cr(e.selectedNodes.map(hw),t.selectedNodes.map(hw))&&cr(e.selectedEdges.map(hw),t.selectedEdges.map(hw))}function y2e({onSelectionChange:e}){const t=ur(),{selectedNodes:n,selectedEdges:i}=zn(b2e,O2e);return m.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,i,e]),null}const x2e=e=>!!e.onSelectionChangeHandlers;function v2e({onSelectionChange:e}){const t=zn(x2e);return e||t?l.jsx(y2e,{onSelectionChange:e}):null}const $te=[0,0],w2e={x:0,y:0,zoom:1},S2e=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],rU=[...S2e,"rfId"],E2e=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),sU={translateExtent:ox,nodeOrigin:$te,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function k2e(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:a,reset:o,setDefaultNodesAndEdges:c}=zn(E2e,cr),u=ur();m.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=sU,o()}),[]);const d=m.useRef(sU);return m.useEffect(()=>{for(const f of rU){const h=e[f],p=d.current[f];h!==p&&(typeof e[f]>"u"||(f==="nodes"?t(h):f==="edges"?n(h):f==="minZoom"?i(h):f==="maxZoom"?r(h):f==="translateExtent"?s(h):f==="nodeExtent"?a(h):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:GAe(h)}):f==="fitView"?u.setState({fitViewQueued:h}):f==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[f]:h})))}d.current=e},rU.map(f=>e[f])),null}function aU(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function T2e(e){var i;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const r=aU(),s=()=>n(r!=null&&r.matches?"dark":"light");return s(),r==null||r.addEventListener("change",s),()=>{r==null||r.removeEventListener("change",s)}},[e]),t!==null?t:(i=aU())!=null&&i.matches?"dark":"light"}const oU=typeof document<"u"?document:null;function fx(e=null,t={target:oU,actInsideInputWithModifier:!0}){const[n,i]=m.useState(!1),r=m.useRef(!1),s=m.useRef(new Set([])),[a,o]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",` `).replace(` `,` +`).split(` -`)),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??oU,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=p=>{var y,O;if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!u)&&fte(p))return!1;const b=cU(p.code,o);if(s.current.add(p[b]),lU(a,s.current,!1)){const v=((O=(y=p.composedPath)==null?void 0:y.call(p))==null?void 0:O[0])||p.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(r.current||!x)&&p.preventDefault(),i(!0)}},f=p=>{const g=cU(p.code,o);lU(a,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(p[g]),p.key==="Meta"&&s.current.clear(),r.current=!1},h=()=>{s.current.clear(),i(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,i]),n}function lU(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function cU(e,t){return t.includes(e)?"code":"key"}const T2e=()=>{const e=ur();return m.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,s],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:s,maxZoom:a,panZoom:o}=e.getState(),c=p$(t,i,r,s,a,(n==null?void 0:n.padding)??.1);return o?(await o.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:s,domNode:a}=e.getState();if(!a)return t;const{x:o,y:c}=a.getBoundingClientRect(),u={x:t.x-o,y:t.y-c},d=n.snapGrid??r,f=n.snapToGrid??s;return X0(u,i,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:s}=i.getBoundingClientRect(),a=o0(t,n);return{x:a.x+r,y:a.y+s}}}),[])};function $te(e,t){const n=[],i=new Map,r=[];for(const s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")i.set(s.id,[s]);else{const a=i.get(s.id);a?a.push(s):i.set(s.id,[s])}for(const s of t){const a=i.get(s.id);if(!a){n.push(s);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const o={...s};for(const c of a)_2e(c,o);n.push(o)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function _2e(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Qte(e,t){return $te(e,t)}function Bte(e,t){return $te(e,t)}function Ah(e,t){return{id:e,type:"select",selected:t}}function eg(e,t=new Set,n=!1){const i=[];for(const[r,s]of e){const a=t.has(r);!(s.selected===void 0&&!a)&&s.selected!==a&&(n&&(s.selected=a),i.push(Ah(s.id,a)))}return i}function uU({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(s=>[s.id,s]));for(const[s,a]of e.entries()){const o=t.get(a.id),c=((r=o==null?void 0:o.internals)==null?void 0:r.userNode)??o;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:s})}for(const[s]of t)i.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function dU(e){return{id:e.id,type:"remove"}}const A2e=cte();function N2e(e,t,n={}){return eNe(e,t,{...n,onError:n.onError??A2e})}const fU=e=>QAe(e),C2e=e=>ste(e);function Ute(e){return m.forwardRef(e)}const j2e=typeof window<"u"?m.useLayoutEffect:m.useEffect;function hU(e){const[t,n]=m.useState(BigInt(0)),[i]=m.useState(()=>R2e(()=>n(r=>r+BigInt(1))));return j2e(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function R2e(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const zte=m.createContext(null);function I2e({children:e}){const t=ur(),n=m.useCallback(o=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:h,fitViewQueued:p,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const O of o)b=typeof O=="function"?O(b):O;let y=uU({items:b,lookup:h});for(const O of g.values())y=O(y);d&&u(b),y.length>0?f==null||f(y):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:O,nodes:v,setNodes:x}=t.getState();O&&x(v)})},[]),i=hU(n),r=m.useCallback(o=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:h}=t.getState();let p=c;for(const g of o)p=typeof g=="function"?g(p):g;d?u(p):f&&f(uU({items:p,lookup:h}))},[]),s=hU(r),a=m.useMemo(()=>({nodeQueue:i,edgeQueue:s}),[]);return l.jsx(zte.Provider,{value:a,children:e})}function P2e(){const e=m.useContext(zte);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const M2e=e=>!!e.panZoom;function L_(){const e=T2e(),t=ur(),n=P2e(),i=zn(M2e),r=m.useMemo(()=>{const s=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},o=f=>{n.edgeQueue.push(f)},c=f=>{var O,v;const{nodeLookup:h,nodeOrigin:p}=t.getState(),g=fU(f)?f:h.get(f.id),b=g.parentId?ute(g.position,g.measured,g.parentId,h,p):g.position,y={...g,position:b,width:((O=g.measured)==null?void 0:O.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return a0(y)},u=(f,h,p={replace:!1})=>{a(g=>g.map(b=>{if(b.id===f){const y=typeof h=="function"?h(b):h;return p.replace&&fU(y)?y:{...b,...y}}return b}))},d=(f,h,p={replace:!1})=>{o(g=>g.map(b=>{if(b.id===f){const y=typeof h=="function"?h(b):h;return p.replace&&C2e(y)?y:{...b,...y}}return b}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var h;return(h=s(f))==null?void 0:h.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(h=>({...h}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:o,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:p}=t.getState(),[g,b,y]=p;return{nodes:f.map(O=>({...O})),edges:h.map(O=>({...O})),viewport:{x:g,y:b,zoom:y}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:p,edges:g,onNodesDelete:b,onEdgesDelete:y,triggerNodeChanges:O,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:w}=t.getState(),{nodes:E,edges:S}=await VAe({nodesToRemove:f,edgesToRemove:h,nodes:p,edges:g,onBeforeDelete:w}),k=S.length>0,T=E.length>0;if(k){const A=S.map(dU);y==null||y(S),v(A)}if(T){const A=E.map(dU);b==null||b(E),O(A)}return(T||k)&&(x==null||x({nodes:E,edges:S})),{deletedNodes:E,deletedEdges:S}},getIntersectingNodes:(f,h=!0,p)=>{const g=z9(f),b=g?f:c(f),y=p!==void 0;return b?(p||t.getState().nodes).filter(O=>{const v=t.getState().nodeLookup.get(O.id);if(v&&!g&&(O.id===f.id||!v.internals.positionAbsolute))return!1;const x=a0(y?O:v),w=ux(x,b);return h&&w>0||w>=x.width*x.height||w>=b.width*b.height}):[]},isNodeIntersecting:(f,h,p=!0)=>{const b=z9(f)?f:c(f);if(!b)return!1;const y=ux(b,h);return p&&y>0||y>=h.width*h.height||y>=b.width*b.height},updateNode:u,updateNodeData:(f,h,p={replace:!1})=>{u(f,g=>{const b=typeof h=="function"?h(g):h;return p.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},p)},updateEdge:d,updateEdgeData:(f,h,p={replace:!1})=>{d(f,g=>{const b=typeof h=="function"?h(g):h;return p.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},p)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:p}=t.getState();return BAe(f,{nodeLookup:h,nodeOrigin:p})},getHandleConnections:({type:f,id:h,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${f}${h?`-${h}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:f,handleId:h,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}${f?h?`-${f}-${h}`:`-${f}`:""}`))==null?void 0:g.values())??[])},fitView:async f=>{const h=t.getState().fitViewResolver??HAe();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(p=>[...p]),h.promise}}},[]);return m.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const pU=e=>e.selected,L2e=typeof window<"u"?window:void 0;function D2e({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ur(),{deleteElements:i}=L_(),r=fx(e,{actInsideInputWithModifier:!1}),s=fx(t,{target:L2e});m.useEffect(()=>{if(r){const{edges:a,nodes:o}=n.getState();i({nodes:o.filter(pU),edges:a.filter(pU)}),n.setState({nodesSelectionActive:!1})}},[r]),m.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function $2e(e){const t=ur();m.useEffect(()=>{const n=()=>{var r,s,a,o;if(!e.current||!(((s=(r=e.current).checkVisibility)==null?void 0:s.call(r))??!0))return!1;const i=g$(e.current);(i.height===0||i.width===0)&&((o=(a=t.getState()).onError)==null||o.call(a,"004",$l.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const D_={position:"absolute",width:"100%",height:"100%",top:0,left:0},Q2e=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function B2e({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:r=.5,panOnScrollMode:s=rp.Free,zoomOnDoubleClick:a=!0,panOnDrag:o=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:p=!0,children:g,noWheelClassName:b,noPanClassName:y,onViewportChange:O,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:w}){const E=ur(),S=m.useRef(null),{userSelectionActive:k,lib:T,connectionInProgress:A}=zn(Q2e,cr),N=fx(h),C=m.useRef();$2e(S);const M=m.useCallback(L=>{O==null||O({x:L[0],y:L[1],zoom:L[2]}),v||E.setState({transform:L})},[O,v]);return m.useEffect(()=>{if(S.current){C.current=CNe({domNode:S.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:j=>E.setState($=>$.paneDragging===j?$:{paneDragging:j}),onPanZoomStart:(j,$)=>{const{onViewportChangeStart:U,onMoveStart:B}=E.getState();B==null||B(j,$),U==null||U($)},onPanZoom:(j,$)=>{const{onViewportChange:U,onMove:B}=E.getState();B==null||B(j,$),U==null||U($)},onPanZoomEnd:(j,$)=>{const{onViewportChangeEnd:U,onMoveEnd:B}=E.getState();B==null||B(j,$),U==null||U($)}});const{x:L,y:P,zoom:Q}=C.current.getViewport();return E.setState({panZoom:C.current,transform:[L,P,Q],domNode:S.current.closest(".react-flow")}),()=>{var j;(j=C.current)==null||j.destroy()}}},[]),m.useEffect(()=>{var L;(L=C.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:r,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:o,zoomActivationKeyPressed:N,preventScrolling:p,noPanClassName:y,userSelectionActive:k,noWheelClassName:b,lib:T,onTransformChange:M,connectionInProgress:A,selectionOnDrag:w,paneClickDistance:x})},[e,t,n,i,r,s,a,o,N,p,y,k,b,T,M,A,w,x]),l.jsx("div",{className:"react-flow__renderer",ref:S,style:D_,children:g})}const U2e=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function z2e(){const{userSelectionActive:e,userSelectionRect:t}=zn(U2e,cr);return e&&t?l.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const W2=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},F2e=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function V2e({isSelecting:e,selectionKeyPressed:t,selectionMode:n=lx.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:g,children:b}){const y=m.useRef(0),O=ur(),{userSelectionActive:v,elementsSelectable:x,dragging:w,connectionInProgress:E,panBy:S,autoPanSpeed:k}=zn(F2e,cr),T=x&&(e||v),A=m.useRef(null),N=m.useRef(),C=m.useRef(new Set),M=m.useRef(new Set),L=m.useRef(!1),P=m.useRef({x:0,y:0}),Q=m.useRef(!1),j=J=>{if(L.current||E){L.current=!1;return}u==null||u(J),O.getState().resetSelectedElements(),O.setState({nodesSelectionActive:!1})},$=J=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){J.preventDefault();return}d==null||d(J)},U=f?J=>f(J):void 0,B=J=>{L.current&&(J.stopPropagation(),L.current=!1)},I=J=>{var Ne,Oe;const{domNode:ie,transform:ue}=O.getState();if(N.current=ie==null?void 0:ie.getBoundingClientRect(),!N.current)return;const ye=J.target===A.current;if(!ye&&!!J.target.closest(".nokey")||!e||!(a&&ye||t)||J.button!==0||!J.isPrimary)return;(Oe=(Ne=J.target)==null?void 0:Ne.setPointerCapture)==null||Oe.call(Ne,J.pointerId),L.current=!1;const{x:Ee,y:me}=Rl(J.nativeEvent,N.current),oe=X0({x:Ee,y:me},ue);O.setState({userSelectionRect:{width:0,height:0,startX:oe.x,startY:oe.y,x:Ee,y:me}}),ye||(J.stopPropagation(),J.preventDefault())};function X(J,ie){const{userSelectionRect:ue}=O.getState();if(!ue)return;const{transform:ye,nodeLookup:Se,edgeLookup:Re,connectionLookup:Ee,triggerNodeChanges:me,triggerEdgeChanges:oe,defaultEdgeOptions:Ne}=O.getState(),Oe={x:ue.startX,y:ue.startY},{x:Ve,y:We}=o0(Oe,ye),De={startX:Oe.x,startY:Oe.y,x:Jqe.id)),M.current=new Set;const Rt=(Ne==null?void 0:Ne.selectable)??!0;for(const qe of C.current){const W=Ee.get(qe);if(W)for(const{edgeId:K}of W.values()){const ae=Re.get(K);ae&&(ae.selectable??Rt)&&M.current.add(K)}}if(!F9(mt,C.current)){const qe=eg(Se,C.current,!0);me(qe)}if(!F9(at,M.current)){const qe=eg(Re,M.current);oe(qe)}O.setState({userSelectionRect:De,userSelectionActive:!0,nodesSelectionActive:!1})}function q(){if(!r||!N.current)return;const[J,ie]=h$(P.current,N.current,k);S({x:J,y:ie}).then(ue=>{if(!L.current||!ue){y.current=requestAnimationFrame(q);return}const{x:ye,y:Se}=P.current;X(ye,Se),y.current=requestAnimationFrame(q)})}const D=()=>{cancelAnimationFrame(y.current),y.current=0,Q.current=!1};m.useEffect(()=>()=>D(),[]);const H=J=>{const{userSelectionRect:ie,transform:ue,resetSelectedElements:ye}=O.getState();if(!N.current||!ie)return;const{x:Se,y:Re}=Rl(J.nativeEvent,N.current);P.current={x:Se,y:Re};const Ee=o0({x:ie.startX,y:ie.startY},ue);if(!L.current){const me=t?0:s;if(Math.hypot(Se-Ee.x,Re-Ee.y)<=me)return;ye(),o==null||o(J)}L.current=!0,Q.current||(q(),Q.current=!0),X(Se,Re)},re=J=>{var ie,ue;J.button===0&&((ue=(ie=J.target)==null?void 0:ie.releasePointerCapture)==null||ue.call(ie,J.pointerId),!v&&J.target===A.current&&O.getState().userSelectionRect&&(j==null||j(J)),O.setState({userSelectionActive:!1,userSelectionRect:null}),L.current&&(c==null||c(J),O.setState({nodesSelectionActive:C.current.size>0})),D())},fe=J=>{var ie,ue;(ue=(ie=J.target)==null?void 0:ie.releasePointerCapture)==null||ue.call(ie,J.pointerId),D()},Ae=i===!0||Array.isArray(i)&&i.includes(0);return l.jsxs("div",{className:Yr(["react-flow__pane",{draggable:Ae,dragging:w,selection:e}]),onClick:T?void 0:W2(j,A),onContextMenu:W2($,A),onWheel:W2(U,A),onPointerEnter:T?void 0:h,onPointerMove:T?H:p,onPointerUp:T?re:void 0,onPointerCancel:T?fe:void 0,onPointerDownCapture:T?I:void 0,onClickCapture:T?B:void 0,onPointerLeave:g,ref:A,style:D_,children:[b,l.jsx(z2e,{})]})}function kP({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:a,nodeLookup:o,onError:c}=t.getState(),u=o.get(e);if(!u){c==null||c("012",$l.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=i==null?void 0:i.current)==null?void 0:d.blur()})):r([e])}function Fte({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:s,nodeClickDistance:a}){const o=ur(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=gNe({getStoreItems:()=>o.getState(),onNodeMouseDown:f=>{kP({id:f,store:o,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,i,t,s,e,r,a]),c}const X2e=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Vte(){const e=ur();return m.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:s,nodesDraggable:a,onError:o,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,h=X2e(a),p=r?s[0]:5,g=r?s[1]:5,b=n.direction.x*p*n.factor,y=n.direction.y*g*n.factor;for(const[,O]of u){if(!h(O))continue;let v={x:O.internals.positionAbsolute.x+b,y:O.internals.positionAbsolute.y+y};r&&(v=_1(v,s));const{position:x,positionAbsolute:w}=ate({nodeId:O.id,nextPosition:v,nodeLookup:u,nodeExtent:i,nodeOrigin:d,onError:o});O.position=x,O.internals.positionAbsolute=w,f.set(O.id,O)}c(f)},[])}const w$=m.createContext(null),q2e=w$.Provider;w$.Consumer;const Xte=()=>m.useContext(w$),H2e=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Y2e=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:s,connection:a}=i,{fromHandle:o,toHandle:c,isValid:u}=a,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,connectingTo:d,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:s===r0.Strict?(o==null?void 0:o.type)!==n:e!==(o==null?void 0:o.nodeId)||t!==(o==null?void 0:o.id),connectionInProcess:!!o,clickConnectionInProcess:!!r,valid:d&&u}};function G2e({type:e="source",position:t=St.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:a,onConnect:o,children:c,className:u,onMouseDown:d,onTouchStart:f,...h},p){var Q,j;const g=a||null,b=e==="target",y=ur(),O=Xte(),{connectOnClick:v,noPanClassName:x,rfId:w}=zn(H2e,cr),{connectingFrom:E,connectingTo:S,clickConnecting:k,isPossibleEndHandle:T,connectionInProcess:A,clickConnectionInProcess:N,valid:C}=zn(Y2e(O,g,e),cr);O||(j=(Q=y.getState()).onError)==null||j.call(Q,"010",$l.error010());const M=$=>{const{defaultEdgeOptions:U,onConnect:B,hasDefaultEdges:I}=y.getState(),X={...U,...$};if(I){const{edges:q,setEdges:D,onError:H}=y.getState();D(N2e(X,q,{onError:H}))}B==null||B(X),o==null||o(X)},L=$=>{if(!O)return;const U=hte($.nativeEvent);if(r&&(U&&$.button===0||!U)){const B=y.getState();EP.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:B.autoPanOnConnect,connectionMode:B.connectionMode,connectionRadius:B.connectionRadius,domNode:B.domNode,nodeLookup:B.nodeLookup,lib:B.lib,isTarget:b,handleId:g,nodeId:O,flowId:B.rfId,panBy:B.panBy,cancelConnection:B.cancelConnection,onConnectStart:B.onConnectStart,onConnectEnd:(...I)=>{var X,q;return(q=(X=y.getState()).onConnectEnd)==null?void 0:q.call(X,...I)},updateConnection:B.updateConnection,onConnect:M,isValidConnection:n||((...I)=>{var X,q;return((q=(X=y.getState()).isValidConnection)==null?void 0:q.call(X,...I))??!0}),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:B.autoPanSpeed,dragThreshold:B.connectionDragThreshold})}U?d==null||d($):f==null||f($)},P=$=>{const{onClickConnectStart:U,onClickConnectEnd:B,connectionClickStartHandle:I,connectionMode:X,isValidConnection:q,lib:D,rfId:H,nodeLookup:re,connection:fe}=y.getState();if(!O||!I&&!r)return;if(!I){U==null||U($.nativeEvent,{nodeId:O,handleId:g,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:O,type:e,id:g}});return}const Ae=dte($.target),J=n||q,{connection:ie,isValid:ue}=EP.isValid($.nativeEvent,{handle:{nodeId:O,id:g,type:e},connectionMode:X,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:J,flowId:H,doc:Ae,lib:D,nodeLookup:re});ue&&ie&&M(ie);const ye=structuredClone(fe);delete ye.inProgress,ye.toPosition=ye.toHandle?ye.toHandle.position:null,B==null||B($,ye),y.setState({connectionClickStartHandle:null})};return l.jsx("div",{"data-handleid":g,"data-nodeid":O,"data-handlepos":t,"data-id":`${w}-${O}-${g}-${e}`,className:Yr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!b,target:b,connectable:i,connectablestart:r,connectableend:s,clickconnecting:k,connectingfrom:E,connectingto:S,valid:C,connectionindicator:i&&(!A||T)&&(A||N?s:r)}]),onMouseDown:L,onTouchStart:L,onClick:v?P:void 0,ref:p,...h,children:c})}const $a=m.memo(Ute(G2e));function W2e({data:e,isConnectable:t,sourcePosition:n=St.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx($a,{type:"source",position:n,isConnectable:t})]})}function Z2e({data:e,isConnectable:t,targetPosition:n=St.Top,sourcePosition:i=St.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx($a,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l.jsx($a,{type:"source",position:i,isConnectable:t})]})}function K2e(){return null}function J2e({data:e,isConnectable:t,targetPosition:n=St.Top}){return l.jsxs(l.Fragment,{children:[l.jsx($a,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ck={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},mU={input:W2e,default:Z2e,output:J2e,group:K2e};function eCe(e){var t,n,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const tCe=e=>{const{width:t,height:n,x:i,y:r}=T1(e.nodeLookup,{filter:s=>!!s.selected});return{width:jl(t)?t:null,height:jl(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function nCe({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=ur(),{width:r,height:s,transformString:a,userSelectionActive:o}=zn(tCe,cr),c=Vte(),u=m.useRef(null);m.useEffect(()=>{var p;n||(p=u.current)==null||p.focus({preventScroll:!0})},[n]);const d=!o&&r!==null&&s!==null;if(Fte({nodeRef:u,disabled:!d}),!d)return null;const f=e?p=>{const g=i.getState().nodes.filter(b=>b.selected);e(p,g)}:void 0,h=p=>{Object.prototype.hasOwnProperty.call(Ck,p.key)&&(p.preventDefault(),c({direction:Ck[p.key],factor:p.shiftKey?4:1}))};return l.jsx("div",{className:Yr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:l.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:r,height:s}})})}const gU=typeof window<"u"?window:void 0,iCe=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function qte({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,paneClickDistance:o,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:y,elementsSelectable:O,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:w,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:k,panOnDrag:T,autoPanOnSelection:A,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:L,preventScrolling:P,onSelectionContextMenu:Q,noWheelClassName:j,noPanClassName:$,disableKeyboardA11y:U,onViewportChange:B,isControlledViewport:I}){const{nodesSelectionActive:X,userSelectionActive:q}=zn(iCe,cr),D=fx(u,{target:gU}),H=fx(b,{target:gU}),re=H||T,fe=H||w,Ae=d&&re!==!0,J=D||q||Ae;return D2e({deleteKeyCode:c,multiSelectionKeyCode:g}),l.jsx(B2e,{onPaneContextMenu:s,elementsSelectable:O,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:fe,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:k,panOnDrag:!D&&re,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:L,zoomActivationKeyCode:y,preventScrolling:P,noWheelClassName:j,noPanClassName:$,onViewportChange:B,isControlledViewport:I,paneClickDistance:o,selectionOnDrag:Ae,children:l.jsxs(V2e,{onSelectionStart:h,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:re,autoPanOnSelection:A,isSelecting:!!J,selectionMode:f,selectionKeyPressed:D,paneClickDistance:o,selectionOnDrag:Ae,children:[e,X&&l.jsx(nCe,{onSelectionContextMenu:Q,noPanClassName:$,disableKeyboardA11y:U})]})})}qte.displayName="FlowRenderer";const rCe=m.memo(qte),sCe=e=>t=>e?f$(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function aCe(e){return zn(m.useCallback(sCe(e),[e]),cr)}const oCe=e=>e.updateNodeInternals;function lCe(){const e=zn(oCe),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const s=r.target.getAttribute("data-id");i.set(s,{id:s,nodeElement:r.target,force:!0})}),e(i)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function cCe({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=ur(),s=m.useRef(null),a=m.useRef(null),o=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.useEffect(()=>{s.current&&!e.hidden&&(!d||a.current!==s.current)&&(a.current&&(i==null||i.unobserve(a.current)),i==null||i.observe(s.current),a.current=s.current)},[d,e.hidden]),m.useEffect(()=>()=>{a.current&&(i==null||i.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(s.current){const f=u.current!==t,h=o.current!==e.sourcePosition,p=c.current!==e.targetPosition;(f||h||p)&&(u.current=t,o.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function uCe({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:s,onDoubleClick:a,nodesDraggable:o,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:h,noPanClassName:p,disableKeyboardA11y:g,rfId:b,nodeTypes:y,nodeClickDistance:O,onError:v}){const{node:x,internals:w,isParent:E}=zn(J=>{const ie=J.nodeLookup.get(e),ue=J.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:ue}},cr);let S=x.type||"default",k=(y==null?void 0:y[S])||mU[S];k===void 0&&(v==null||v("003",$l.error003(S)),S="default",k=(y==null?void 0:y.default)||mU.default);const T=!!(x.draggable||o&&typeof x.draggable>"u"),A=!!(x.selectable||c&&typeof x.selectable>"u"),N=!!(x.connectable||u&&typeof x.connectable>"u"),C=!!(x.focusable||d&&typeof x.focusable>"u"),M=ur(),L=m$(x),P=cCe({node:x,nodeType:S,hasDimensions:L,resizeObserver:f}),Q=Fte({nodeRef:P,disabled:x.hidden||!T,noDragClassName:h,handleSelector:x.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:O}),j=Vte();if(x.hidden)return null;const $=pd(x),U=eCe(x),B=A||T||t||n||i||r,I=n?J=>n(J,{...w.userNode}):void 0,X=i?J=>i(J,{...w.userNode}):void 0,q=r?J=>r(J,{...w.userNode}):void 0,D=s?J=>s(J,{...w.userNode}):void 0,H=a?J=>a(J,{...w.userNode}):void 0,re=J=>{const{selectNodesOnDrag:ie,nodeDragThreshold:ue}=M.getState();A&&(!ie||!T||ue>0)&&kP({id:e,store:M,nodeRef:P}),t&&t(J,{...w.userNode})},fe=J=>{if(!(fte(J.nativeEvent)||g)){if(tte.includes(J.key)&&A){const ie=J.key==="Escape";kP({id:e,store:M,unselect:ie,nodeRef:P})}else if(T&&x.selected&&Object.prototype.hasOwnProperty.call(Ck,J.key)){J.preventDefault();const{ariaLabelConfig:ie}=M.getState();M.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:J.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),j({direction:Ck[J.key],factor:J.shiftKey?4:1})}}},Ae=()=>{var Ee;if(g||!((Ee=P.current)!=null&&Ee.matches(":focus-visible")))return;const{transform:J,width:ie,height:ue,autoPanOnNodeFocus:ye,setCenter:Se}=M.getState();if(!ye)return;f$(new Map([[e,x]]),{x:0,y:0,width:ie,height:ue},J,!0).length>0||Se(x.position.x+$.width/2,x.position.y+$.height/2,{zoom:J[2]})};return l.jsx("div",{className:Yr(["react-flow__node",`react-flow__node-${S}`,{[p]:T},x.className,{selected:x.selected,selectable:A,parent:E,draggable:T,dragging:Q}]),ref:P,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:B?"all":"none",visibility:L?"visible":"hidden",...x.style,...U},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:X,onMouseLeave:q,onContextMenu:D,onClick:re,onDoubleClick:H,onKeyDown:C?fe:void 0,tabIndex:C?0:void 0,onFocus:C?Ae:void 0,role:x.ariaRole??(C?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Mte}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:l.jsx(q2e,{value:e,children:l.jsx(k,{id:e,data:x.data,type:S,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:x.selected??!1,selectable:A,draggable:T,deletable:x.deletable??!0,isConnectable:N,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:Q,dragHandle:x.dragHandle,zIndex:w.z,parentId:x.parentId,...$})})})}var dCe=m.memo(uCe);const fCe=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Hte(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,onError:s}=zn(fCe,cr),a=aCe(e.onlyRenderVisibleElements),o=lCe();return l.jsx("div",{className:"react-flow__nodes",style:D_,children:a.map(c=>l.jsx(dCe,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:s},c))})}Hte.displayName="NodeRenderer";const hCe=m.memo(Hte);function pCe(e){return zn(m.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const s=n.nodeLookup.get(r.source),a=n.nodeLookup.get(r.target);s&&a&&ZAe({sourceNode:s,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),cr)}const mCe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return l.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},gCe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return l.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bU={[cx.Arrow]:mCe,[cx.ArrowClosed]:gCe};function bCe(e){const t=ur();return m.useMemo(()=>{var r,s;return Object.prototype.hasOwnProperty.call(bU,e)?bU[e]:((s=(r=t.getState()).onError)==null||s.call(r,"009",$l.error009(e)),null)},[e])}const OCe=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const c=bCe(t);return c?l.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:o,refX:"0",refY:"0",children:l.jsx(c,{color:n,strokeWidth:a})}):null},Yte=({defaultColor:e,rfId:t})=>{const n=zn(s=>s.edges),i=zn(s=>s.defaultEdgeOptions),r=m.useMemo(()=>sNe(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?l.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:l.jsx("defs",{children:r.map(s=>l.jsx(OCe,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};Yte.displayName="MarkerDefinitions";var yCe=m.memo(Yte);function Gte({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:c,className:u,...d}){const[f,h]=m.useState({x:1,y:0,width:0,height:0}),p=Yr(["react-flow__edge-textwrapper",u]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const b=g.current.getBBox();h({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?l.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...d,children:[r&&l.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:o,ry:o}),l.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:i,children:n}),c]}):null}Gte.displayName="EdgeText";const xCe=m.memo(Gte);function A1({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return l.jsxs(l.Fragment,{children:[l.jsx("path",{...d,d:e,fill:"none",className:Yr(["react-flow__edge-path",d.className])}),u?l.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,i&&jl(t)&&jl(n)?l.jsx(xCe,{x:t,y:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c}):null]})}function OU({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===St.Left||e===St.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function Wte({sourceX:e,sourceY:t,sourcePosition:n=St.Bottom,targetX:i,targetY:r,targetPosition:s=St.Top}){const[a,o]=OU({pos:n,x1:e,y1:t,x2:i,y2:r}),[c,u]=OU({pos:s,x1:i,y1:r,x2:e,y2:t}),[d,f,h,p]=pte({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:o,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${o} ${c},${u} ${i},${r}`,d,f,h,p]}function Zte(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:a,targetPosition:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:O})=>{const[v,x,w]=Wte({sourceX:n,sourceY:i,sourcePosition:a,targetX:r,targetY:s,targetPosition:o}),E=e.isInternal?void 0:t;return l.jsx(A1,{id:E,path:v,labelX:x,labelY:w,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:O})})}const vCe=Zte({isInternal:!1}),Kte=Zte({isInternal:!0});vCe.displayName="SimpleBezierEdge";Kte.displayName="SimpleBezierEdgeInternal";function Jte(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,sourcePosition:p=St.Bottom,targetPosition:g=St.Top,markerEnd:b,markerStart:y,pathOptions:O,interactionWidth:v})=>{const[x,w,E]=Nk({sourceX:n,sourceY:i,sourcePosition:p,targetX:r,targetY:s,targetPosition:g,borderRadius:O==null?void 0:O.borderRadius,offset:O==null?void 0:O.offset,stepPosition:O==null?void 0:O.stepPosition}),S=e.isInternal?void 0:t;return l.jsx(A1,{id:S,path:x,labelX:w,labelY:E,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:b,markerStart:y,interactionWidth:v})})}const ene=Jte({isInternal:!1}),tne=Jte({isInternal:!0});ene.displayName="SmoothStepEdge";tne.displayName="SmoothStepEdgeInternal";function nne(e){return m.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return l.jsx(ene,{...n,id:i,pathOptions:m.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const wCe=nne({isInternal:!1}),ine=nne({isInternal:!0});wCe.displayName="StepEdge";ine.displayName="StepEdgeInternal";function rne(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:g,interactionWidth:b})=>{const[y,O,v]=bte({sourceX:n,sourceY:i,targetX:r,targetY:s}),x=e.isInternal?void 0:t;return l.jsx(A1,{id:x,path:y,labelX:O,labelY:v,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:g,interactionWidth:b})})}const SCe=rne({isInternal:!1}),sne=rne({isInternal:!0});SCe.displayName="StraightEdge";sne.displayName="StraightEdgeInternal";function ane(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:a=St.Bottom,targetPosition:o=St.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,pathOptions:O,interactionWidth:v})=>{const[x,w,E]=mte({sourceX:n,sourceY:i,sourcePosition:a,targetX:r,targetY:s,targetPosition:o,curvature:O==null?void 0:O.curvature}),S=e.isInternal?void 0:t;return l.jsx(A1,{id:S,path:x,labelX:w,labelY:E,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:v})})}const ECe=ane({isInternal:!1}),one=ane({isInternal:!0});ECe.displayName="BezierEdge";one.displayName="BezierEdgeInternal";const yU={default:one,straight:sne,step:ine,smoothstep:tne,simplebezier:Kte},xU={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},kCe=(e,t,n)=>n===St.Left?e-t:n===St.Right?e+t:e,TCe=(e,t,n)=>n===St.Top?e-t:n===St.Bottom?e+t:e,vU="react-flow__edgeupdater";function wU({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:s,onMouseOut:a,type:o}){return l.jsx("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:a,className:Yr([vU,`${vU}-${o}`]),cx:kCe(t,i,e),cy:TCe(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function _Ce({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:s,targetY:a,sourcePosition:o,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:h,setUpdateHover:p}){const g=ur(),b=(w,E)=>{if(w.button!==0)return;const{autoPanOnConnect:S,domNode:k,connectionMode:T,connectionRadius:A,lib:N,onConnectStart:C,cancelConnection:M,nodeLookup:L,rfId:P,panBy:Q,updateConnection:j}=g.getState(),$=E.type==="target",U=(X,q)=>{h(!1),f==null||f(X,n,E.type,q)},B=X=>u==null?void 0:u(n,X),I=(X,q)=>{h(!0),d==null||d(w,n,E.type),C==null||C(X,q)};EP.onPointerDown(w.nativeEvent,{autoPanOnConnect:S,connectionMode:T,connectionRadius:A,domNode:k,handleId:E.id,nodeId:E.nodeId,nodeLookup:L,isTarget:$,edgeUpdaterType:E.type,lib:N,flowId:P,cancelConnection:M,panBy:Q,isValidConnection:(...X)=>{var q,D;return((D=(q=g.getState()).isValidConnection)==null?void 0:D.call(q,...X))??!0},onConnect:B,onConnectStart:I,onConnectEnd:(...X)=>{var q,D;return(D=(q=g.getState()).onConnectEnd)==null?void 0:D.call(q,...X)},onReconnectEnd:U,updateConnection:j,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>b(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),O=w=>b(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>p(!0),x=()=>p(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx(wU,{position:o,centerX:i,centerY:r,radius:t,onMouseDown:y,onMouseEnter:v,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&l.jsx(wU,{position:c,centerX:s,centerY:a,radius:t,onMouseDown:O,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function ACe({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:s,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,rfId:g,edgeTypes:b,noPanClassName:y,onError:O,disableKeyboardA11y:v}){let x=zn(Se=>Se.edgeLookup.get(e));const w=zn(Se=>Se.defaultEdgeOptions);x=w?{...w,...x}:x;let E=x.type||"default",S=(b==null?void 0:b[E])||yU[E];S===void 0&&(O==null||O("011",$l.error011(E)),E="default",S=(b==null?void 0:b.default)||yU.default);const k=!!(x.focusable||t&&typeof x.focusable>"u"),T=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),A=!!(x.selectable||i&&typeof x.selectable>"u"),N=m.useRef(null),[C,M]=m.useState(!1),[L,P]=m.useState(!1),Q=ur(),{zIndex:j,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q}=zn(m.useCallback(Se=>{const Re=Se.nodeLookup.get(x.source),Ee=Se.nodeLookup.get(x.target);if(!Re||!Ee)return{zIndex:x.zIndex,...xU};const me=rNe({id:e,sourceNode:Re,targetNode:Ee,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:Se.connectionMode,onError:O});return{zIndex:WAe({selected:x.selected,zIndex:x.zIndex,sourceNode:Re,targetNode:Ee,elevateOnSelect:Se.elevateEdgesOnSelect,zIndexMode:Se.zIndexMode}),...me||xU}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),cr),D=m.useMemo(()=>x.markerStart?`url('#${wP(x.markerStart,g)}')`:void 0,[x.markerStart,g]),H=m.useMemo(()=>x.markerEnd?`url('#${wP(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||$===null||U===null||B===null||I===null)return null;const re=Se=>{var oe;const{addSelectedEdges:Re,unselectNodesAndEdges:Ee,multiSelectionActive:me}=Q.getState();A&&(Q.setState({nodesSelectionActive:!1}),x.selected&&me?(Ee({nodes:[],edges:[x]}),(oe=N.current)==null||oe.blur()):Re([e])),r&&r(Se,x)},fe=s?Se=>{s(Se,{...x})}:void 0,Ae=a?Se=>{a(Se,{...x})}:void 0,J=o?Se=>{o(Se,{...x})}:void 0,ie=c?Se=>{c(Se,{...x})}:void 0,ue=u?Se=>{u(Se,{...x})}:void 0,ye=Se=>{var Re;if(!v&&tte.includes(Se.key)&&A){const{unselectNodesAndEdges:Ee,addSelectedEdges:me}=Q.getState();Se.key==="Escape"?((Re=N.current)==null||Re.blur(),Ee({edges:[x]})):me([e])}};return l.jsx("svg",{style:{zIndex:j},children:l.jsxs("g",{className:Yr(["react-flow__edge",`react-flow__edge-${E}`,x.className,y,{selected:x.selected,animated:x.animated,inactive:!A&&!r,updating:C,selectable:A}]),onClick:re,onDoubleClick:fe,onContextMenu:Ae,onMouseEnter:J,onMouseMove:ie,onMouseLeave:ue,onKeyDown:k?ye:void 0,tabIndex:k?0:void 0,role:x.ariaRole??(k?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":k?`${Lte}-${g}`:void 0,ref:N,...x.domAttributes,children:[!L&&l.jsx(S,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:A,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:D,markerEnd:H,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),T&&l.jsx(_Ce,{edge:x,isReconnectable:T,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q,setUpdateHover:M,setReconnecting:P})]})})}var NCe=m.memo(ACe);const CCe=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function lne({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:s,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:h,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:y,edgesReconnectable:O,elementsSelectable:v,onError:x}=zn(CCe,cr),w=pCe(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(yCe,{defaultColor:e,rfId:n}),w.map(E=>l.jsx(NCe,{id:E,edgesFocusable:y,edgesReconnectable:O,elementsSelectable:v,noPanClassName:r,onReconnect:s,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:h,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:i,disableKeyboardA11y:b},E))]})}lne.displayName="EdgeRenderer";const jCe=m.memo(lne),RCe=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function ICe({children:e}){const t=zn(RCe);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function PCe(e){const t=L_(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const MCe=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function LCe(e){const t=zn(MCe),n=ur();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function DCe(e){return e.connection.inProgress?{...e.connection,to:X0(e.connection.to,e.transform)}:{...e.connection}}function $Ce(e){return DCe}function QCe(e){const t=$Ce();return zn(t,cr)}const BCe=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function UCe({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:s,height:a,isValid:o,inProgress:c}=zn(BCe,cr);return!(s&&r&&c)?null:l.jsx("svg",{style:e,width:s,height:a,className:"react-flow__connectionline react-flow__container",children:l.jsx("g",{className:Yr(["react-flow__connection",rte(o)]),children:l.jsx(cne,{style:t,type:n,CustomComponent:i,isValid:o})})})}const cne=({style:e,type:t=Kd.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:s,fromNode:a,fromHandle:o,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:h,pointer:p}=QCe();if(!r)return;if(n)return l.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:o,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:h,connectionStatus:rte(i),toNode:d,toHandle:f,pointer:p});let g="";const b={sourceX:s.x,sourceY:s.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case Kd.Bezier:[g]=mte(b);break;case Kd.SimpleBezier:[g]=Wte(b);break;case Kd.Step:[g]=Nk({...b,borderRadius:0});break;case Kd.SmoothStep:[g]=Nk(b);break;default:[g]=bte(b)}return l.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};cne.displayName="ConnectionLine";const zCe={};function SU(e=zCe){m.useRef(e),ur(),m.useEffect(()=>{},[e])}function FCe(){ur(),m.useRef(!1),m.useEffect(()=>{},[])}function une({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:a,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:h,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:y,connectionLineContainerStyle:O,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:k,deleteKeyCode:T,onlyRenderVisibleElements:A,elementsSelectable:N,defaultViewport:C,translateExtent:M,minZoom:L,maxZoom:P,preventScrolling:Q,defaultMarkerColor:j,zoomOnScroll:$,zoomOnPinch:U,panOnScroll:B,panOnScrollSpeed:I,panOnScrollMode:X,zoomOnDoubleClick:q,panOnDrag:D,autoPanOnSelection:H,onPaneClick:re,onPaneMouseEnter:fe,onPaneMouseMove:Ae,onPaneMouseLeave:J,onPaneScroll:ie,onPaneContextMenu:ue,paneClickDistance:ye,nodeClickDistance:Se,onEdgeContextMenu:Re,onEdgeMouseEnter:Ee,onEdgeMouseMove:me,onEdgeMouseLeave:oe,reconnectRadius:Ne,onReconnect:Oe,onReconnectStart:Ve,onReconnectEnd:We,noDragClassName:De,noWheelClassName:mt,noPanClassName:at,disableKeyboardA11y:Rt,nodeExtent:qe,rfId:W,viewport:K,onViewportChange:ae}){return SU(e),SU(t),FCe(),PCe(n),LCe(K),l.jsx(rCe,{onPaneClick:re,onPaneMouseEnter:fe,onPaneMouseMove:Ae,onPaneMouseLeave:J,onPaneContextMenu:ue,onPaneScroll:ie,paneClickDistance:ye,deleteKeyCode:T,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:N,zoomOnScroll:$,zoomOnPinch:U,zoomOnDoubleClick:q,panOnScroll:B,panOnScrollSpeed:I,panOnScrollMode:X,panOnDrag:D,autoPanOnSelection:H,defaultViewport:C,translateExtent:M,minZoom:L,maxZoom:P,onSelectionContextMenu:f,preventScrolling:Q,noDragClassName:De,noWheelClassName:mt,noPanClassName:at,disableKeyboardA11y:Rt,onViewportChange:ae,isControlledViewport:!!K,children:l.jsxs(ICe,{children:[l.jsx(jCe,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:a,onReconnect:Oe,onReconnectStart:Ve,onReconnectEnd:We,onlyRenderVisibleElements:A,onEdgeContextMenu:Re,onEdgeMouseEnter:Ee,onEdgeMouseMove:me,onEdgeMouseLeave:oe,reconnectRadius:Ne,defaultMarkerColor:j,noPanClassName:at,disableKeyboardA11y:Rt,rfId:W}),l.jsx(UCe,{style:b,type:g,component:y,containerStyle:O}),l.jsx("div",{className:"react-flow__edgelabel-renderer"}),l.jsx(hCe,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:s,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:Se,onlyRenderVisibleElements:A,noPanClassName:at,noDragClassName:De,disableKeyboardA11y:Rt,nodeExtent:qe,rfId:W}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}une.displayName="GraphView";const VCe=m.memo(une),XCe=cte(),EU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:h="basic"}={})=>{const p=new Map,g=new Map,b=new Map,y=new Map,O=i??t??[],v=n??e??[],x=d??[0,0],w=f??ox;xte(b,y,O);const{nodesInitialized:E}=SP(v,p,g,{nodeOrigin:x,nodeExtent:w,zIndexMode:h});let S=[0,0,1];if(a&&r&&s){const k=T1(p,{filter:C=>!!((C.width||C.initialWidth)&&(C.height||C.initialHeight))}),{x:T,y:A,zoom:N}=p$(k,r,s,c,u,(o==null?void 0:o.padding)??.1);S=[T,A,N]}return{rfId:"1",width:r??0,height:s??0,transform:S,nodes:v,nodesInitialized:E,nodeLookup:p,parentLookup:g,edges:O,edgeLookup:y,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ox,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:r0.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:o,fitViewResolver:null,connection:{...ite},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:XCe,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:nte,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},qCe=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h})=>o2e((p,g)=>{async function b(){const{nodeLookup:y,panZoom:O,fitViewOptions:v,fitViewResolver:x,width:w,height:E,minZoom:S,maxZoom:k}=g();O&&(await FAe({nodes:y,width:w,height:E,panZoom:O,minZoom:S,maxZoom:k},v),x==null||x.resolve(!0),p({fitViewResolver:null}))}return{...EU({nodes:e,edges:t,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:i,zIndexMode:h}),setNodes:y=>{const{nodeLookup:O,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:w,fitViewQueued:E,zIndexMode:S,nodesSelectionActive:k}=g(),{nodesInitialized:T,hasSelectedNodes:A}=SP(y,O,v,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:S}),N=k&&A;E&&T?(b(),p({nodes:y,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:N})):p({nodes:y,nodesInitialized:T,nodesSelectionActive:N})},setEdges:y=>{const{connectionLookup:O,edgeLookup:v}=g();xte(O,v,y),p({edges:y})},setDefaultNodesAndEdges:(y,O)=>{if(y){const{setNodes:v}=g();v(y),p({hasDefaultNodes:!0})}if(O){const{setEdges:v}=g();v(O),p({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:O,nodeLookup:v,parentLookup:x,domNode:w,nodeOrigin:E,nodeExtent:S,debug:k,fitViewQueued:T,zIndexMode:A}=g(),{changes:N,updatedInternals:C}=fNe(y,v,x,w,E,S,A);C&&(lNe(v,x,{nodeOrigin:E,nodeExtent:S,zIndexMode:A}),T?(b(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(N==null?void 0:N.length)>0&&(k&&console.log("React Flow: trigger node changes",N),O==null||O(N)))},updateNodePositions:(y,O=!1)=>{const v=[];let x=[];const{nodeLookup:w,triggerNodeChanges:E,connection:S,updateConnection:k,onNodesChangeMiddlewareMap:T}=g();for(const[A,N]of y){const C=w.get(A),M=!!(C!=null&&C.expandParent&&(C!=null&&C.parentId)&&(N!=null&&N.position)),L={id:A,type:"position",position:M?{x:Math.max(0,N.position.x),y:Math.max(0,N.position.y)}:N.position,dragging:O};if(C&&S.inProgress&&S.fromNode.id===C.id){const P=xp(C,S.fromHandle,St.Left,!0);k({...S,from:P})}M&&C.parentId&&v.push({id:A,parentId:C.parentId,rect:{...N.internals.positionAbsolute,width:N.measured.width??0,height:N.measured.height??0}}),x.push(L)}if(v.length>0){const{parentLookup:A,nodeOrigin:N}=g(),C=v$(v,w,A,N);x.push(...C)}for(const A of T.values())x=A(x);E(x)},triggerNodeChanges:y=>{const{onNodesChange:O,setNodes:v,nodes:x,hasDefaultNodes:w,debug:E}=g();if(y!=null&&y.length){if(w){const S=Qte(y,x);v(S)}E&&console.log("React Flow: trigger node changes",y),O==null||O(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:O,setEdges:v,edges:x,hasDefaultEdges:w,debug:E}=g();if(y!=null&&y.length){if(w){const S=Bte(y,x);v(S)}E&&console.log("React Flow: trigger edge changes",y),O==null||O(y)}},addSelectedNodes:y=>{const{multiSelectionActive:O,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(O){const S=y.map(k=>Ah(k,!0));w(S);return}w(eg(x,new Set([...y]),!0)),E(eg(v))},addSelectedEdges:y=>{const{multiSelectionActive:O,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(O){const S=y.map(k=>Ah(k,!0));E(S);return}E(eg(v,new Set([...y]))),w(eg(x,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:O}={})=>{const{edges:v,nodes:x,nodeLookup:w,triggerNodeChanges:E,triggerEdgeChanges:S}=g(),k=y||x,T=O||v,A=[];for(const C of k){if(!C.selected)continue;const M=w.get(C.id);M&&(M.selected=!1),A.push(Ah(C.id,!1))}const N=[];for(const C of T)C.selected&&N.push(Ah(C.id,!1));E(A),S(N)},setMinZoom:y=>{const{panZoom:O,maxZoom:v}=g();O==null||O.setScaleExtent([y,v]),p({minZoom:y})},setMaxZoom:y=>{const{panZoom:O,minZoom:v}=g();O==null||O.setScaleExtent([v,y]),p({maxZoom:y})},setTranslateExtent:y=>{var O;(O=g().panZoom)==null||O.setTranslateExtent(y),p({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:O,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:w}=g();if(!w)return;const E=O.reduce((k,T)=>T.selected?[...k,Ah(T.id,!1)]:k,[]),S=y.reduce((k,T)=>T.selected?[...k,Ah(T.id,!1)]:k,[]);v(E),x(S)},setNodeExtent:y=>{const{nodes:O,nodeLookup:v,parentLookup:x,nodeOrigin:w,elevateNodesOnSelect:E,nodeExtent:S,zIndexMode:k}=g();y[0][0]===S[0][0]&&y[0][1]===S[0][1]&&y[1][0]===S[1][0]&&y[1][1]===S[1][1]||(SP(O,v,x,{nodeOrigin:w,nodeExtent:y,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:k}),p({nodeExtent:y}))},panBy:y=>{const{transform:O,width:v,height:x,panZoom:w,translateExtent:E}=g();return hNe({delta:y,panZoom:w,transform:O,translateExtent:E,width:v,height:x})},setCenter:async(y,O,v)=>{const{width:x,height:w,maxZoom:E,panZoom:S}=g();if(!S)return!1;const k=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:E;return await S.setViewport({x:x/2-y*k,y:w/2-O*k,zoom:k},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),!0},cancelConnection:()=>{p({connection:{...ite}})},updateConnection:y=>{p({connection:y})},reset:()=>p({...EU()})}},Object.is);function dne({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:s,initialMinZoom:a,initialMaxZoom:o,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:p}){const[g]=m.useState(()=>qCe({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:u,minZoom:a,maxZoom:o,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:h}));return l.jsx(l2e,{value:g,children:l.jsx(I2e,{children:p})})}function HCe({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p}){return m.useContext(P_)?l.jsx(l.Fragment,{children:e}):l.jsx(dne,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:s,initialHeight:a,fitView:o,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p,children:e})}const YCe={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function GCe({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:s,edgeTypes:a,onNodeClick:o,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:p,onConnectStart:g,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:O,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:S,onNodeDragStart:k,onNodeDrag:T,onNodeDragStop:A,onNodesDelete:N,onEdgesDelete:C,onDelete:M,onSelectionChange:L,onSelectionDragStart:P,onSelectionDrag:Q,onSelectionDragStop:j,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:B,onBeforeDelete:I,connectionMode:X,connectionLineType:q=Kd.Bezier,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:re,deleteKeyCode:fe="Backspace",selectionKeyCode:Ae="Shift",selectionOnDrag:J=!1,selectionMode:ie=lx.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:ye=dx()?"Meta":"Control",zoomActivationKeyCode:Se=dx()?"Meta":"Control",snapToGrid:Re,snapGrid:Ee,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:oe,nodesDraggable:Ne,autoPanOnNodeFocus:Oe,nodesConnectable:Ve,nodesFocusable:We,nodeOrigin:De=Dte,edgesFocusable:mt,edgesReconnectable:at,elementsSelectable:Rt=!0,defaultViewport:qe=v2e,minZoom:W=.5,maxZoom:K=2,translateExtent:ae=ox,preventScrolling:pe=!0,nodeExtent:z,defaultMarkerColor:ve="#b1b1b7",zoomOnScroll:Be=!0,zoomOnPinch:Je=!0,panOnScroll:kt=!1,panOnScrollSpeed:Mt=.5,panOnScrollMode:Tt=rp.Free,zoomOnDoubleClick:dt=!0,panOnDrag:ge=!0,onPaneClick:lt,onPaneMouseEnter:Ge,onPaneMouseMove:vt,onPaneMouseLeave:_t,onPaneScroll:Bt,onPaneContextMenu:je,paneClickDistance:Ze=1,nodeClickDistance:Ie=0,children:Wt,onReconnect:dn,onReconnectStart:Qt,onReconnectEnd:Yt,onEdgeContextMenu:Jt,onEdgeDoubleClick:Ft,onEdgeMouseEnter:Ce,onEdgeMouseMove:et,onEdgeMouseLeave:wt,reconnectRadius:yn=10,onNodesChange:on,onEdgesChange:hi,noDragClassName:Pe="nodrag",noWheelClassName:st="nowheel",noPanClassName:At="nopan",fitView:Ut,fitViewOptions:kn,connectOnClick:wn,attributionPosition:Ai,proOptions:Gn,defaultEdgeOptions:xn,elevateNodesOnSelect:de=!0,elevateEdgesOnSelect:Le=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:gt,autoPanOnNodeDrag:ln,autoPanOnSelection:Sn=!0,autoPanSpeed:In,connectionRadius:Ni,isValidConnection:Pn,onError:Vt,style:Ji,id:fn,nodeDragThreshold:pi,connectionDragThreshold:ti,viewport:vi,onViewportChange:en,width:Ci,height:xs,colorMode:ni="light",debug:Ls,onScroll:er,ariaLabelConfig:Ya,zIndexMode:mr="basic",...gr},ul){const Sa=fn||"1",as=k2e(ni),Mn=m.useCallback(vs=>{vs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),er==null||er(vs)},[er]);return l.jsx("div",{"data-testid":"rf__wrapper",...gr,onScroll:Mn,style:{...Ji,...YCe},ref:ul,className:Yr(["react-flow",r,as]),id:fn,role:"application",children:l.jsxs(HCe,{nodes:e,edges:t,width:Ci,height:xs,fitView:Ut,fitViewOptions:kn,minZoom:W,maxZoom:K,nodeOrigin:De,nodeExtent:z,zIndexMode:mr,children:[l.jsx(E2e,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:p,onConnectStart:g,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:O,nodesDraggable:Ne,autoPanOnNodeFocus:Oe,nodesConnectable:Ve,nodesFocusable:We,edgesFocusable:mt,edgesReconnectable:at,elementsSelectable:Rt,elevateNodesOnSelect:de,elevateEdgesOnSelect:Le,minZoom:W,maxZoom:K,nodeExtent:z,onNodesChange:on,onEdgesChange:hi,snapToGrid:Re,snapGrid:Ee,connectionMode:X,translateExtent:ae,connectOnClick:wn,defaultEdgeOptions:xn,fitView:Ut,fitViewOptions:kn,onNodesDelete:N,onEdgesDelete:C,onDelete:M,onNodeDragStart:k,onNodeDrag:T,onNodeDragStop:A,onSelectionDrag:Q,onSelectionDragStart:P,onSelectionDragStop:j,onMove:d,onMoveStart:f,onMoveEnd:h,noPanClassName:At,nodeOrigin:De,rfId:Sa,autoPanOnConnect:gt,autoPanOnNodeDrag:ln,autoPanSpeed:In,onError:Vt,connectionRadius:Ni,isValidConnection:Pn,selectNodesOnDrag:oe,nodeDragThreshold:pi,connectionDragThreshold:ti,onBeforeDelete:I,debug:Ls,ariaLabelConfig:Ya,zIndexMode:mr}),l.jsx(VCe,{onInit:u,onNodeClick:o,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:a,connectionLineType:q,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:re,selectionKeyCode:Ae,selectionOnDrag:J,selectionMode:ie,deleteKeyCode:fe,multiSelectionKeyCode:ye,panActivationKeyCode:ue,zoomActivationKeyCode:Se,onlyRenderVisibleElements:me,defaultViewport:qe,translateExtent:ae,minZoom:W,maxZoom:K,preventScrolling:pe,zoomOnScroll:Be,zoomOnPinch:Je,zoomOnDoubleClick:dt,panOnScroll:kt,panOnScrollSpeed:Mt,panOnScrollMode:Tt,panOnDrag:ge,autoPanOnSelection:Sn,onPaneClick:lt,onPaneMouseEnter:Ge,onPaneMouseMove:vt,onPaneMouseLeave:_t,onPaneScroll:Bt,onPaneContextMenu:je,paneClickDistance:Ze,nodeClickDistance:Ie,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:B,onReconnect:dn,onReconnectStart:Qt,onReconnectEnd:Yt,onEdgeContextMenu:Jt,onEdgeDoubleClick:Ft,onEdgeMouseEnter:Ce,onEdgeMouseMove:et,onEdgeMouseLeave:wt,reconnectRadius:yn,defaultMarkerColor:ve,noDragClassName:Pe,noWheelClassName:st,noPanClassName:At,rfId:Sa,disableKeyboardA11y:ut,nodeExtent:z,viewport:vi,onViewportChange:en}),l.jsx(x2e,{onSelectionChange:L}),Wt,l.jsx(m2e,{proOptions:Gn,position:Ai}),l.jsx(p2e,{rfId:Sa,disableKeyboardA11y:ut})]})})}var WCe=Ute(GCe);const ZCe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function KCe({children:e}){const t=zn(ZCe);return t?zi.createPortal(e,t):null}function JCe(e){const[t,n]=m.useState(e),i=m.useCallback(r=>n(s=>Qte(r,s)),[]);return[t,n,i]}function eje(e){const[t,n]=m.useState(e),i=m.useCallback(r=>n(s=>Bte(r,s)),[]);return[t,n,i]}const tje=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(const[,{internals:n}]of t.nodeLookup)if(n.handleBounds===void 0||!m$(n.userNode))return!1;return!0};function nje(e={includeHiddenNodes:!1}){return zn(tje(e))}function ije({dimensions:e,lineWidth:t,variant:n,className:i}){return l.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Yr(["react-flow__background-pattern",n,i])})}function rje({radius:e,className:t}){return l.jsx("circle",{cx:e,cy:e,r:e,className:Yr(["react-flow__background-pattern","dots",t])})}var vf;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(vf||(vf={}));const sje={[vf.Dots]:1,[vf.Lines]:1,[vf.Cross]:6},aje=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function fne({id:e,variant:t=vf.Dots,gap:n=20,size:i,lineWidth:r=1,offset:s=0,color:a,bgColor:o,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:h,patternId:p}=zn(aje,cr),g=i||sje[t],b=t===vf.Dots,y=t===vf.Cross,O=Array.isArray(n)?n:[n,n],v=[O[0]*h[2]||1,O[1]*h[2]||1],x=g*h[2],w=Array.isArray(s)?s:[s,s],E=y?[x,x]:v,S=[w[0]*h[2]||1+E[0]/2,w[1]*h[2]||1+E[1]/2],k=`${p}${e||""}`;return l.jsxs("svg",{className:Yr(["react-flow__background",u]),style:{...c,...D_,"--xy-background-color-props":o,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[l.jsx("pattern",{id:k,x:h[0]%v[0],y:h[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?l.jsx(rje,{radius:x/2,className:d}):l.jsx(ije,{dimensions:E,lineWidth:r,variant:t,className:d})}),l.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}fne.displayName="Background";const oje=m.memo(fne);function lje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function cje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function dje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function fje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function pw({children:e,className:t,...n}){return l.jsx("button",{type:"button",className:Yr(["react-flow__controls-button",t]),...n,children:e})}const hje=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function hne({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:h="vertical","aria-label":p}){const g=ur(),{isInteractive:b,minZoomReached:y,maxZoomReached:O,ariaLabelConfig:v}=zn(hje,cr),{zoomIn:x,zoomOut:w,fitView:E}=L_(),S=()=>{x(),s==null||s()},k=()=>{w(),a==null||a()},T=()=>{E(r),o==null||o()},A=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},N=h==="horizontal"?"horizontal":"vertical";return l.jsxs(M_,{className:Yr(["react-flow__controls",N,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??v["controls.ariaLabel"],children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(pw,{onClick:S,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:O,children:l.jsx(lje,{})}),l.jsx(pw,{onClick:k,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:y,children:l.jsx(cje,{})})]}),n&&l.jsx(pw,{className:"react-flow__controls-fitview",onClick:T,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:l.jsx(uje,{})}),i&&l.jsx(pw,{className:"react-flow__controls-interactive",onClick:A,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?l.jsx(fje,{}):l.jsx(dje,{})}),d]})}hne.displayName="Controls";const pje=m.memo(hne);function mje({id:e,x:t,y:n,width:i,height:r,style:s,color:a,strokeColor:o,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:h,onClick:p}){const{background:g,backgroundColor:b}=s||{},y=a||g||b;return l.jsx("rect",{className:Yr(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:d,ry:d,width:i,height:r,style:{fill:y,stroke:o,strokeWidth:c},shapeRendering:f,onClick:p?O=>p(O,e):void 0})}const gje=m.memo(mje),bje=e=>e.nodes.map(t=>t.id),Z2=e=>e instanceof Function?e:()=>e;function Oje({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:s=gje,onClick:a}){const o=zn(bje,cr),c=Z2(t),u=Z2(e),d=Z2(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return l.jsx(l.Fragment,{children:o.map(h=>l.jsx(xje,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:s,onClick:a,shapeRendering:f},h))})}function yje({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:o,onClick:c}){const{node:u,x:d,y:f,width:h,height:p}=zn(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const y=b.internals.userNode,{x:O,y:v}=b.internals.positionAbsolute,{width:x,height:w}=pd(y);return{node:y,x:O,y:v,width:x,height:w}},cr);return!u||u.hidden||!m$(u)?null:l.jsx(o,{x:d,y:f,width:h,height:p,style:u.style,selected:!!u.selected,className:i(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:s,shapeRendering:a,onClick:c,id:u.id})}const xje=m.memo(yje);var vje=m.memo(Oje);const wje=200,Sje=150,Eje=e=>!e.hidden,kje=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?lte(T1(e.nodeLookup,{filter:Eje}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Tje="react-flow__minimap-desc";function pne({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:o,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:h="bottom-right",onClick:p,onNodeClick:g,pannable:b=!1,zoomable:y=!1,ariaLabel:O,inversePan:v,zoomStep:x=1,offsetScale:w=5}){const E=ur(),S=m.useRef(null),{boundingRect:k,viewBB:T,rfId:A,panZoom:N,translateExtent:C,flowWidth:M,flowHeight:L,ariaLabelConfig:P}=zn(kje,cr),Q=(e==null?void 0:e.width)??wje,j=(e==null?void 0:e.height)??Sje,$=k.width/Q,U=k.height/j,B=Math.max($,U),I=B*Q,X=B*j,q=w*B,D=k.x-(I-k.width)/2-q,H=k.y-(X-k.height)/2-q,re=I+q*2,fe=X+q*2,Ae=`${Tje}-${A}`,J=m.useRef(0),ie=m.useRef();J.current=B,m.useEffect(()=>{if(S.current&&N)return ie.current=wNe({domNode:S.current,panZoom:N,getTransform:()=>E.getState().transform,getViewScale:()=>J.current}),()=>{var Re;(Re=ie.current)==null||Re.destroy()}},[N]),m.useEffect(()=>{var Re;(Re=ie.current)==null||Re.update({translateExtent:C,width:M,height:L,inversePan:v,pannable:b,zoomStep:x,zoomable:y})},[b,y,v,x,C,M,L]);const ue=p?Re=>{var oe;const[Ee,me]=((oe=ie.current)==null?void 0:oe.pointer(Re))||[0,0];p(Re,{x:Ee,y:me})}:void 0,ye=g?m.useCallback((Re,Ee)=>{const me=E.getState().nodeLookup.get(Ee).internals.userNode;g(Re,me)},[]):void 0,Se=O??P["minimap.ariaLabel"];return l.jsx(M_,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*B:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Yr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:l.jsxs("svg",{width:Q,height:j,viewBox:`${D} ${H} ${re} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Ae,ref:S,onClick:ue,children:[Se&&l.jsx("title",{id:Ae,children:Se}),l.jsx(vje,{onClick:ye,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:a,nodeComponent:o}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${D-q},${H-q}h${re+q*2}v${fe+q*2}h${-re-q*2}z - M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pne.displayName="MiniMap";m.memo(pne);const _je=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Aje={[l0.Line]:"right",[l0.Handle]:"bottom-right"};function Nje({nodeId:e,position:t,variant:n=l0.Handle,className:i,style:r=void 0,children:s,color:a,minWidth:o=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:p=!0,shouldResize:g,onResizeStart:b,onResize:y,onResizeEnd:O}){const v=Xte(),x=typeof e=="string"?e:v,w=ur(),E=m.useRef(null),S=n===l0.Handle,k=zn(m.useCallback(_je(S&&p),[S,p]),cr),T=m.useRef(null),A=t??Aje[n];m.useEffect(()=>{if(!(!E.current||!x))return T.current||(T.current=MNe({domNode:E.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:C,transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q,domNode:j}=w.getState();return{nodeLookup:C,transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q,paneDomNode:j}},onChange:(C,M)=>{const{triggerNodeChanges:L,nodeLookup:P,parentLookup:Q,nodeOrigin:j}=w.getState(),$=[],U={x:C.x,y:C.y},B=P.get(x);if(B&&B.expandParent&&B.parentId){const I=B.origin??j,X=C.width??B.measured.width??0,q=C.height??B.measured.height??0,D={id:B.id,parentId:B.parentId,rect:{width:X,height:q,...ute({x:C.x??B.position.x,y:C.y??B.position.y},{width:X,height:q},B.parentId,P,I)}},H=v$([D],P,Q,j);$.push(...H),U.x=C.x?Math.max(I[0]*X,C.x):void 0,U.y=C.y?Math.max(I[1]*q,C.y):void 0}if(U.x!==void 0&&U.y!==void 0){const I={id:x,type:"position",position:{...U}};$.push(I)}if(C.width!==void 0&&C.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:C.width,height:C.height}};$.push(X)}for(const I of M){const X={...I,type:"position"};$.push(X)}L($)},onEnd:({width:C,height:M})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:C,height:M}};w.getState().triggerNodeChanges([L])}})),T.current.update({controlPosition:A,boundaries:{minWidth:o,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:h,onResizeStart:b,onResize:y,onResizeEnd:O,shouldResize:g}),()=>{var C;(C=T.current)==null||C.destroy()}},[A,o,c,u,d,f,b,y,O,g]);const N=A.split("-");return l.jsx("div",{className:Yr(["react-flow__resize-control","nodrag",...N,n,i]),ref:E,style:{...r,scale:k,...a&&{[S?"backgroundColor":"borderColor"]:a}},children:s})}m.memo(Nje);var mne=Object.defineProperty,Cje=(e,t,n)=>t in e?mne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jje=(e,t)=>{for(var n in t)mne(e,n,{get:t[n],enumerable:!0})},Rje=(e,t,n)=>Cje(e,t+"",n),gne={};jje(gne,{Graph:()=>al,alg:()=>S$,json:()=>One,version:()=>Mje});var Ije=Object.defineProperty,bne=(e,t)=>{for(var n in t)Ije(e,n,{get:t[n],enumerable:!0})},al=class{constructor(t){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},t&&(this._isDirected="directed"in t?t.directed:!0,this._isMultigraph="multigraph"in t?t.multigraph:!1,this._isCompound="compound"in t?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return typeof t!="function"?this._defaultNodeLabelFn=()=>t:this._defaultNodeLabelFn=t,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(t=>Object.keys(this._in[t]).length===0)}sinks(){return this.nodes().filter(t=>Object.keys(this._out[t]).length===0)}setNodes(t,n){return t.forEach(i=>{n!==void 0?this.setNode(i,n):this.setNode(i)}),this}setNode(t,n){return t in this._nodes?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]="\0",this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return t in this._nodes}removeNode(t){if(t in this._nodes){let n=i=>this.removeEdge(this._edgeObjs[i]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(i=>{this.setParent(i)}),delete this._children[t]),Object.keys(this._in[t]).forEach(n),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n="\0";else{n+="";for(let i=n;i!==void 0;i=this.parent(i))if(i===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}parent(t){if(this._isCompound){let n=this._parent[t];if(n!=="\0")return n}}children(t="\0"){if(this._isCompound){let n=this._children[t];if(n)return Object.keys(n)}else{if(t==="\0")return this.nodes();if(this.hasNode(t))return[]}return[]}predecessors(t){let n=this._preds[t];if(n)return Object.keys(n)}successors(t){let n=this._sucs[t];if(n)return Object.keys(n)}neighbors(t){let n=this.predecessors(t);if(n){let i=new Set(n);for(let r of this.successors(t))i.add(r);return Array.from(i.values())}}isLeaf(t){let n;return this.isDirected()?n=this.successors(t):n=this.neighbors(t),n.length===0}filterNodes(t){let n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,a])=>{t(s)&&n.setNode(s,a)}),Object.values(this._edgeObjs).forEach(s=>{n.hasNode(s.v)&&n.hasNode(s.w)&&n.setEdge(s,this.edge(s))});let i={},r=s=>{let a=this.parent(s);return!a||n.hasNode(a)?(i[s]=a??void 0,a??void 0):a in i?i[a]:r(a)};return this._isCompound&&n.nodes().forEach(s=>n.setParent(s,r(s))),n}setDefaultEdgeLabel(t){return typeof t!="function"?this._defaultEdgeLabelFn=()=>t:this._defaultEdgeLabelFn=t,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,n){return t.reduce((i,r)=>(n!==void 0?this.setEdge(i,r,n):this.setEdge(i,r),r)),this}setEdge(t,n,i,r){let s,a,o,c,u=!1;typeof t=="object"&&t!==null&&"v"in t?(s=t.v,a=t.w,o=t.name,arguments.length===2&&(c=n,u=!0)):(s=t,a=n,o=r,arguments.length>2&&(c=i,u=!0)),s=""+s,a=""+a,o!==void 0&&(o=""+o);let d=NO(this._isDirected,s,a,o);if(d in this._edgeLabels)return u&&(this._edgeLabels[d]=c),this;if(o!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(a),this._edgeLabels[d]=u?c:this._defaultEdgeLabelFn(s,a,o);let f=Pje(this._isDirected,s,a,o);return s=f.v,a=f.w,Object.freeze(f),this._edgeObjs[d]=f,kU(this._preds[a],s),kU(this._sucs[s],a),this._in[a][d]=f,this._out[s][d]=f,this._edgeCount++,this}edge(t,n,i){let r=arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i);return this._edgeLabels[r]}edgeAsObj(t,n,i){let r=arguments.length===1?this.edge(t):this.edge(t,n,i);return typeof r!="object"?{label:r}:r}hasEdge(t,n,i){return(arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i))in this._edgeLabels}removeEdge(t,n,i){let r=arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i),s=this._edgeObjs[r];if(s){let a=s.v,o=s.w;delete this._edgeLabels[r],delete this._edgeObjs[r],TU(this._preds[o],a),TU(this._sucs[a],o),delete this._in[o][r],delete this._out[a][r],this._edgeCount--}return this}inEdges(t,n){return this.isDirected()?this.filterEdges(this._in[t],t,n):this.nodeEdges(t,n)}outEdges(t,n){return this.isDirected()?this.filterEdges(this._out[t],t,n):this.nodeEdges(t,n)}nodeEdges(t,n){if(t in this._nodes)return this.filterEdges({...this._in[t],...this._out[t]},t,n)}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}filterEdges(t,n,i){if(!t)return;let r=Object.values(t);return i?r.filter(s=>s.v===n&&s.w===i||s.v===i&&s.w===n):r}};function kU(e,t){e[t]?e[t]++:e[t]=1}function TU(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function NO(e,t,n,i){let r=""+t,s=""+n;if(!e&&r>s){let a=r;r=s,s=a}return r+""+s+""+(i===void 0?"\0":i)}function Pje(e,t,n,i){let r=""+t,s=""+n;if(!e&&r>s){let o=r;r=s,s=o}let a={v:r,w:s};return i&&(a.name=i),a}function K2(e,t){return NO(e,t.v,t.w,t.name)}var Mje="4.0.1",One={};bne(One,{read:()=>Qje,write:()=>Lje});function Lje(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Dje(e),edges:$je(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Dje(e){return e.nodes().map(t=>{let n=e.node(t),i=e.parent(t),r={v:t};return n!==void 0&&(r.value=n),i!==void 0&&(r.parent=i),r})}function $je(e){return e.edges().map(t=>{let n=e.edge(t),i={v:t.v,w:t.w};return t.name!==void 0&&(i.name=t.name),n!==void 0&&(i.value=n),i})}function Qje(e){let t=new al(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var S$={};bne(S$,{CycleException:()=>Rk,bellmanFord:()=>yne,components:()=>zje,dijkstra:()=>jk,dijkstraAll:()=>Xje,findCycles:()=>qje,floydWarshall:()=>Yje,isAcyclic:()=>Wje,postorder:()=>Kje,preorder:()=>Jje,prim:()=>eRe,shortestPaths:()=>tRe,tarjan:()=>vne,topsort:()=>wne});var Bje=()=>1;function yne(e,t,n,i){return Uje(e,String(t),n||Bje,i||function(r){return e.outEdges(r)})}function Uje(e,t,n,i){let r={},s,a=0,o=e.nodes(),c=function(f){let h=n(f);r[f.v].distance+he.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,i=String(e);if(!(i in n)){let r=this._arr,s=r.length;return n[i]=s,r.push({key:i,priority:t}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let i=this._arr[n].priority;if(t>i)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${i} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,i=n+1,r=e;n>1,!(t[i].priority1;function jk(e,t,n,i){let r=function(s){return e.outEdges(s)};return Vje(e,String(t),n||Fje,i||r)}function Vje(e,t,n,i){let r={},s=new xne,a,o,c=function(u){let d=u.v!==a?u.v:u.w,f=r[d],h=n(u),p=o.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+u+" Weight: "+h);p0&&(a=s.removeMin(),o=r[a],o.distance!==Number.POSITIVE_INFINITY);)i(a).forEach(c);return r}function Xje(e,t,n){return e.nodes().reduce(function(i,r){return i[r]=jk(e,r,t,n),i},{})}function vne(e){let t=0,n=[],i={},r=[];function s(a){let o=i[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),e.successors(a).forEach(function(c){c in i?i[c].onStack&&(o.lowlink=Math.min(o.lowlink,i[c].index)):(s(c),o.lowlink=Math.min(o.lowlink,i[c].lowlink))}),o.lowlink===o.index){let c=[],u;do u=n.pop(),i[u].onStack=!1,c.push(u);while(a!==u);r.push(c)}}return e.nodes().forEach(function(a){a in i||s(a)}),r}function qje(e){return vne(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Hje=()=>1;function Yje(e,t,n){return Gje(e,t||Hje,n||function(i){return e.outEdges(i)})}function Gje(e,t,n){let i={},r=e.nodes();return r.forEach(function(s){i[s]={},i[s][s]={distance:0,predecessor:""},r.forEach(function(a){s!==a&&(i[s][a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(s).forEach(function(a){let o=a.v===s?a.w:a.v,c=t(a);i[s][o]={distance:c,predecessor:s}})}),r.forEach(function(s){let a=i[s];r.forEach(function(o){let c=i[o];r.forEach(function(u){let d=c[s],f=a[u],h=c[u],p=d.distance+f.distance;p{var c;return(c=e.isDirected()?e.successors(o):e.neighbors(o))!=null?c:[]},a={};return t.forEach(function(o){if(!e.hasNode(o))throw new Error("Graph does not have node: "+o);r=Sne(e,o,n==="post",a,s,i,r)}),r}function Sne(e,t,n,i,r,s,a){return t in i||(i[t]=!0,n||(a=s(a,t)),r(t).forEach(function(o){a=Sne(e,o,n,i,r,s,a)}),n&&(a=s(a,t))),a}function Ene(e,t,n){return Zje(e,t,n,function(i,r){return i.push(r),i},[])}function Kje(e,t){return Ene(e,t,"post")}function Jje(e,t){return Ene(e,t,"pre")}function eRe(e,t){let n=new al,i={},r=new xne,s;function a(c){let u=c.v===s?c.w:c.v,d=r.priority(u);if(d!==void 0){let f=t(c);f0;){if(s=r.removeMin(),s in i)n.setEdge(s,i[s]);else{if(o)throw new Error("Input graph is not connected: "+e);o=!0}e.nodeEdges(s).forEach(a)}return n}function tRe(e,t,n,i){return nRe(e,t,n,i??(r=>{let s=e.outEdges(r);return s??[]}))}function nRe(e,t,n,i){if(n===void 0)return jk(e,t,n,i);let r=!1,s=e.nodes();for(let a=0;at.setNode(n,e.node(n))),e.edges().forEach(n=>{let i=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:i.weight+r.weight,minlen:Math.max(i.minlen,r.minlen)})}),t}function kne(e){let t=new al({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function _U(e,t){let n=e.x,i=e.y,r=t.x-n,s=t.y-i,a=e.width/2,o=e.height/2;if(!r&&!s)throw new Error("Not possible to find intersection inside of the rectangle");let c,u;return Math.abs(s)*a>Math.abs(r)*o?(s<0&&(o=-o),c=o*r/s,u=o):(r<0&&(a=-a),c=a,u=a*s/r),{x:n+c,y:i+u}}function N1(e){let t=hx(_ne(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let i=e.node(n),r=i.rank;r!==void 0&&(t[r]||(t[r]=[]),t[r][i.order]=n)}),t}function rRe(e){let t=e.nodes().map(i=>{let r=e.node(i).rank;return r===void 0?Number.MAX_VALUE:r}),n=Ac(Math.min,t);e.nodes().forEach(i=>{let r=e.node(i);Object.hasOwn(r,"rank")&&(r.rank-=n)})}function sRe(e){let t=e.nodes().map(a=>e.node(a).rank).filter(a=>a!==void 0),n=Ac(Math.min,t),i=[];e.nodes().forEach(a=>{let o=e.node(a).rank-n;i[o]||(i[o]=[]),i[o].push(a)});let r=0,s=e.graph().nodeRankFactor;Array.from(i).forEach((a,o)=>{a===void 0&&o%s!==0?--r:a!==void 0&&r&&a.forEach(c=>e.node(c).rank+=r)})}function AU(e,t,n,i){let r={width:0,height:0};return arguments.length>=4&&(r.rank=n,r.order=i),q0(e,"border",r,t)}function aRe(e,t=Tne){let n=[];for(let i=0;iTne){let n=aRe(t);return e(...n.map(i=>e(...i)))}else return e(...t)}function _ne(e){let t=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MIN_VALUE:i});return Ac(Math.max,t)}function oRe(e,t){let n={lhs:[],rhs:[]};return e.forEach(i=>{t(i)?n.lhs.push(i):n.rhs.push(i)}),n}function Ane(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Nne(e,t){return t()}var lRe=0;function E$(e){let t=++lRe;return e+(""+t)}function hx(e,t,n=1){t==null&&(t=e,e=0);let i=s=>sti[t]:n=t,Object.entries(e).reduce((i,[r,s])=>(i[r]=n(s,r),i),{})}function cRe(e,t){return e.reduce((n,i,r)=>(n[i]=t[r],n),{})}var Q_="\0",uRe="3.0.0",dRe=class{constructor(){Rje(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return NU(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&NU(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,fRe)),n=n._prev;return"["+e.join(", ")+"]"}};function NU(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function fRe(e,t){if(e!=="_next"&&e!=="_prev")return t}var hRe=dRe,pRe=()=>1;function mRe(e,t){if(e.nodeCount()<=1)return[];let n=bRe(e,t||pRe);return gRe(n.graph,n.buckets,n.zeroIdx).flatMap(i=>e.outEdges(i.v,i.w)||[])}function gRe(e,t,n){var i;let r=[],s=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)J2(e,t,n,o);for(;o=s.dequeue();)J2(e,t,n,o);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(o=(i=t[c])==null?void 0:i.dequeue(),o){r=r.concat(J2(e,t,n,o,!0)||[]);break}}}return r}function J2(e,t,n,i,r){let s=[],a=r?s:void 0;return(e.inEdges(i.v)||[]).forEach(o=>{let c=e.edge(o),u=e.node(o.v);r&&s.push({v:o.v,w:o.w}),u.out-=c,TP(t,n,u)}),(e.outEdges(i.v)||[]).forEach(o=>{let c=e.edge(o),u=o.w,d=e.node(u);d.in-=c,TP(t,n,d)}),e.removeNode(i.v),a}function bRe(e,t){let n=new al,i=0,r=0;e.nodes().forEach(o=>{n.setNode(o,{v:o,in:0,out:0})}),e.edges().forEach(o=>{let c=n.edge(o.v,o.w)||0,u=t(o),d=c+u;n.setEdge(o.v,o.w,d);let f=n.node(o.v),h=n.node(o.w);r=Math.max(r,f.out+=u),i=Math.max(i,h.in+=u)});let s=ORe(r+i+3).map(()=>new hRe),a=i+1;return n.nodes().forEach(o=>{TP(s,a,n.node(o))}),{graph:n,buckets:s,zeroIdx:a}}function TP(e,t,n){var i,r,s;n.out?n.in?(s=e[n.out-n.in+t])==null||s.enqueue(n):(r=e[e.length-1])==null||r.enqueue(n):(i=e[0])==null||i.enqueue(n)}function ORe(e){let t=[];for(let n=0;n{let i=e.edge(n);e.removeEdge(n),i.forwardName=n.name,i.reversed=!0,e.setEdge(n.w,n.v,i,E$("rev"))});function t(n){return i=>n.edge(i).weight}}function xRe(e){let t=[],n={},i={};function r(s){Object.hasOwn(i,s)||(i[s]=!0,n[s]=!0,e.outEdges(s).forEach(a=>{Object.hasOwn(n,a.w)?t.push(a):r(a.w)}),delete n[s])}return e.nodes().forEach(r),t}function vRe(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let i=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,i)}})}function wRe(e){e.graph().dummyChains=[],e.edges().forEach(t=>SRe(e,t))}function SRe(e,t){let n=t.v,i=e.node(n).rank,r=t.w,s=e.node(r).rank,a=t.name,o=e.edge(t),c=o.labelRank;if(s===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i{let n=e.node(t),i=n.edgeLabel,r;for(e.setEdge(n.edgeObj,i);n.dummy;)r=e.successors(t)[0],e.removeNode(t),i.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height),t=r,n=e.node(t)})}function k$(e){let t={};function n(i){let r=e.node(i);if(Object.hasOwn(t,i))return r.rank;t[i]=!0;let s=e.outEdges(i),a=s?s.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],o=Ac(Math.min,a);return o===Number.POSITIVE_INFINITY&&(o=0),r.rank=o}e.sources().forEach(n)}function u0(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Cne=kRe;function kRe(e){let t=new al({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let i=n[0],r=e.nodeCount();t.setNode(i,{});let s,a;for(;TRe(t,e){let a=s.v,o=i===a?s.w:a;!e.hasNode(o)&&!u0(t,s)&&(e.setNode(o,{}),e.setEdge(i,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function _Re(e,t){return t.edges().reduce((n,i)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(i.v)!==e.hasNode(i.w)&&(r=u0(t,i)),rt.node(i).rank+=n)}var{preorder:NRe,postorder:CRe}=S$,jRe=$p;$p.initLowLimValues=_$;$p.initCutValues=T$;$p.calcCutValue=jne;$p.leaveEdge=Ine;$p.enterEdge=Pne;$p.exchangeEdges=Mne;function $p(e){e=iRe(e),k$(e);let t=Cne(e);_$(t),T$(t,e);let n,i;for(;n=Ine(t);)i=Pne(t,e,n),Mne(t,e,n,i)}function T$(e,t){let n=CRe(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(i=>RRe(e,t,i))}function RRe(e,t,n){let i=e.node(n).parent,r=e.edge(n,i);r.cutvalue=jne(e,t,n)}function jne(e,t,n){let i=e.node(n).parent,r=!0,s=t.edge(n,i),a=0;s||(r=!1,s=t.edge(i,n)),a=s.weight;let o=t.nodeEdges(n);return o&&o.forEach(c=>{let u=c.v===n,d=u?c.w:c.v;if(d!==i){let f=u===r,h=t.edge(c).weight;if(a+=f?h:-h,PRe(e,n,d)){let p=e.edge(n,d).cutvalue;a+=f?-p:p}}}),a}function _$(e,t){arguments.length<2&&(t=e.nodes()[0]),Rne(e,{},1,t)}function Rne(e,t,n,i,r){let s=n,a=e.node(i);t[i]=!0;let o=e.neighbors(i);return o&&o.forEach(c=>{Object.hasOwn(t,c)||(n=Rne(e,t,n,c,i))}),a.low=s,a.lim=n++,r?a.parent=r:delete a.parent,n}function Ine(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Pne(e,t,n){let i=n.v,r=n.w;t.hasEdge(i,r)||(i=n.w,r=n.v);let s=e.node(i),a=e.node(r),o=s,c=!1;return s.lim>a.lim&&(o=a,c=!0),t.edges().filter(u=>c===CU(e,e.node(u.v),o)&&c!==CU(e,e.node(u.w),o)).reduce((u,d)=>u0(t,d)!e.node(r).parent);if(!n)return;let i=NRe(e,[n]);i=i.slice(1),i.forEach(r=>{let s=e.node(r).parent,a=t.edge(r,s),o=!1;a||(a=t.edge(s,r),o=!0),t.node(r).rank=t.node(s).rank+(o?a.minlen:-a.minlen)})}function PRe(e,t,n){return e.hasEdge(t,n)}function CU(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var MRe=LRe;function LRe(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":jU(e);break;case"tight-tree":$Re(e);break;case"longest-path":DRe(e);break;case"none":break;default:jU(e)}}var DRe=k$;function $Re(e){k$(e),Cne(e)}function jU(e){jRe(e)}var QRe=BRe;function BRe(e){let t=zRe(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),r=i.edgeObj,s=URe(e,t,r.v,r.w),a=s.path,o=s.lca,c=0,u=a[c],d=!0;for(;n!==r.w;){if(i=e.node(n),d){for(;(u=a[c])!==o&&e.node(u).maxRanka||o>t[c].lim));let u=c,d=i;for(;(d=e.parent(d))!==u;)s.push(d);return{path:r.concat(s.reverse()),lca:u}}function zRe(e){let t={},n=0;function i(r){let s=n;e.children(r).forEach(i),t[r]={low:s,lim:n++}}return e.children(Q_).forEach(i),t}function FRe(e){let t=q0(e,"root",{},"_root"),n=VRe(e),i=Object.values(n),r=Ac(Math.max,i)-1,s=2*r+1;e.graph().nestingRoot=t,e.edges().forEach(o=>e.edge(o).minlen*=s);let a=XRe(e)+1;e.children(Q_).forEach(o=>Lne(e,t,s,a,r,n,o)),e.graph().nodeRankFactor=s}function Lne(e,t,n,i,r,s,a){var o;let c=e.children(a);if(!c.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}let u=AU(e,"_bt"),d=AU(e,"_bb"),f=e.node(a);e.setParent(u,a),f.borderTop=u,e.setParent(d,a),f.borderBottom=d,c.forEach(h=>{var p;Lne(e,t,n,i,r,s,h);let g=e.node(h),b=g.borderTop?g.borderTop:h,y=g.borderBottom?g.borderBottom:h,O=g.borderTop?i:2*i,v=b!==y?1:r-((p=s[a])!=null?p:0)+1;e.setEdge(u,b,{weight:O,minlen:v,nestingEdge:!0}),e.setEdge(y,d,{weight:O,minlen:v,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,u,{weight:0,minlen:r+((o=s[a])!=null?o:0)})}function VRe(e){let t={};function n(i,r){let s=e.children(i);s&&s.length&&s.forEach(a=>n(a,r+1)),t[i]=r}return e.children(Q_).forEach(i=>n(i,1)),t}function XRe(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function qRe(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var HRe=YRe;function YRe(e){function t(n){let i=e.children(n),r=e.node(n);if(i.length&&i.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let s=r.minRank,a=r.maxRank+1;sIU(e.node(t))),e.edges().forEach(t=>IU(e.edge(t)))}function IU(e){let t=e.width;e.width=e.height,e.height=t}function ZRe(e){e.nodes().forEach(t=>eC(e.node(t))),e.edges().forEach(t=>{var n;let i=e.edge(t);(n=i.points)==null||n.forEach(eC),Object.hasOwn(i,"y")&&eC(i)})}function eC(e){e.y=-e.y}function KRe(e){e.nodes().forEach(t=>tC(e.node(t))),e.edges().forEach(t=>{var n;let i=e.edge(t);(n=i.points)==null||n.forEach(tC),Object.hasOwn(i,"x")&&tC(i)})}function tC(e){let t=e.x;e.x=e.y,e.y=t}function JRe(e){let t={},n=e.nodes().filter(o=>!e.children(o).length),i=n.map(o=>e.node(o).rank),r=Ac(Math.max,i),s=hx(r+1).map(()=>[]);function a(o){if(t[o])return;t[o]=!0;let c=e.node(o);s[c.rank].push(o);let u=e.successors(o);u&&u.forEach(a)}return n.sort((o,c)=>e.node(o).rank-e.node(c).rank).forEach(a),s}function eIe(e,t){let n=0;for(let i=1;id)),r=t.flatMap(u=>{let d=e.outEdges(u);return d?d.map(f=>({pos:i[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),s=1;for(;s{let d=u.pos+s;o[d]+=u.weight;let f=0;for(;d>0;)d%2&&(f+=o[d+1]),d=d-1>>1,o[d]+=u.weight;c+=u.weight*f}),c}function nIe(e,t=[]){return t.map(n=>{let i=e.inEdges(n);if(!i||!i.length)return{v:n};{let r=i.reduce((s,a)=>{let o=e.edge(a),c=e.node(a.v);return{sum:s.sum+o.weight*c.order,weight:s.weight+o.weight}},{sum:0,weight:0});return{v:n,barycenter:r.sum/r.weight,weight:r.weight}}})}function iIe(e,t){let n={};e.forEach((r,s)=>{let a={indegree:0,in:[],out:[],vs:[r.v],i:s};r.barycenter!==void 0&&(a.barycenter=r.barycenter,a.weight=r.weight),n[r.v]=a}),t.edges().forEach(r=>{let s=n[r.v],a=n[r.w];s!==void 0&&a!==void 0&&(a.indegree++,s.out.push(a))});let i=Object.values(n).filter(r=>!r.indegree);return rIe(i)}function rIe(e){let t=[];function n(r){return s=>{s.merged||(s.barycenter===void 0||r.barycenter===void 0||s.barycenter>=r.barycenter)&&sIe(r,s)}}function i(r){return s=>{s.in.push(r),--s.indegree===0&&e.push(s)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(i(r))}return t.filter(r=>!r.merged).map(r=>Ik(r,["vs","i","barycenter","weight"]))}function sIe(e,t){let n=0,i=0;e.weight&&(n+=e.barycenter*e.weight,i+=e.weight),t.weight&&(n+=t.barycenter*t.weight,i+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/i,e.weight=i,e.i=Math.min(t.i,e.i),t.merged=!0}function aIe(e,t){let n=oRe(e,d=>Object.hasOwn(d,"barycenter")),i=n.lhs,r=n.rhs.sort((d,f)=>f.i-d.i),s=[],a=0,o=0,c=0;i.sort(oIe(!!t)),c=PU(s,r,c),i.forEach(d=>{c+=d.vs.length,s.push(d.vs),a+=d.barycenter*d.weight,o+=d.weight,c=PU(s,r,c)});let u={vs:s.flat(1)};return o&&(u.barycenter=a/o,u.weight=o),u}function PU(e,t,n){let i;for(;t.length&&(i=t[t.length-1]).i<=n;)t.pop(),e.push(i.vs),n++;return n}function oIe(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}function $ne(e,t,n,i){let r=e.children(t),s=e.node(t),a=s?s.borderLeft:void 0,o=s?s.borderRight:void 0,c={};a&&(r=r.filter(h=>h!==a&&h!==o));let u=nIe(e,r);u.forEach(h=>{if(e.children(h.v).length){let p=$ne(e,h.v,n,i);c[h.v]=p,Object.hasOwn(p,"barycenter")&&cIe(h,p)}});let d=iIe(u,n);lIe(d,c);let f=aIe(d,i);if(a&&o){f.vs=[a,f.vs,o].flat(1);let h=e.predecessors(a);if(h&&h.length){let p=e.node(h[0]),g=e.predecessors(o),b=e.node(g[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+p.order+b.order)/(f.weight+2),f.weight+=2}}return f}function lIe(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(i=>t[i]?t[i].vs:i)})}function cIe(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function uIe(e,t,n,i){i||(i=e.nodes());let r=dIe(e),s=new al({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(a=>e.node(a));return i.forEach(a=>{let o=e.node(a),c=e.parent(a);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){s.setNode(a),s.setParent(a,c||r);let u=e[n](a);u&&u.forEach(d=>{let f=d.v===a?d.w:d.v,h=s.edge(f,a),p=h!==void 0?h.weight:0;s.setEdge(f,a,{weight:e.edge(d).weight+p})}),Object.hasOwn(o,"minRank")&&s.setNode(a,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),s}function dIe(e){let t;for(;e.hasNode(t=E$("_root")););return t}function fIe(e,t,n){let i={},r;n.forEach(s=>{let a=e.parent(s),o,c;for(;a;){if(o=e.parent(a),o?(c=i[o],i[o]=a):(c=r,r=a),c&&c!==a){t.setEdge(c,a);return}a=o}})}function Qne(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,Qne);return}let n=_ne(e),i=MU(e,hx(1,n+1),"inEdges"),r=MU(e,hx(n-1,-1,-1),"outEdges"),s=JRe(e);if(LU(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,o,c=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){hIe(u%2?i:r,u%4>=2,c),s=N1(e);let f=eIe(e,s);f{i.has(s)||i.set(s,[]),i.get(s).push(a)};for(let s of e.nodes()){let a=e.node(s);if(typeof a.rank=="number"&&r(a.rank,s),typeof a.minRank=="number"&&typeof a.maxRank=="number")for(let o=a.minRank;o<=a.maxRank;o++)o!==a.rank&&r(o,s)}return t.map(function(s){return uIe(e,s,n,i.get(s)||[])})}function hIe(e,t,n){let i=new al;e.forEach(function(r){n.forEach(o=>i.setEdge(o.left,o.right));let s=r.graph().root,a=$ne(r,s,i,t);a.vs.forEach((o,c)=>r.node(o).order=c),fIe(r,i,a.vs)})}function LU(e,t){Object.values(t).forEach(n=>n.forEach((i,r)=>e.node(i).order=r))}function pIe(e,t){let n={};function i(r,s){let a=0,o=0,c=r.length,u=s[s.length-1];return s.forEach((d,f)=>{let h=gIe(e,d),p=h?e.node(h).order:c;(h||d===u)&&(s.slice(o,f+1).forEach(g=>{let b=e.predecessors(g);b&&b.forEach(y=>{let O=e.node(y),v=O.order;(v{let f=s[d];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(p=>{if(p===void 0)return;let g=e.node(p);g.dummy&&(g.orderu)&&Bne(n,p,f)})}})}function r(s,a){let o=-1,c=-1,u=0;return a.forEach((d,f)=>{if(e.node(d).dummy==="border"){let h=e.predecessors(d);if(h&&h.length){let p=h[0];if(p===void 0)return;c=e.node(p).order,i(a,u,f,o,c),u=f,o=c}}i(a,u,a.length,c,s.length)}),a}return t.length&&t.reduce(r),n}function gIe(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(i=>e.node(i).dummy)}}function Bne(e,t,n){if(t>n){let r=t;t=n,n=r}let i=e[t];i||(e[t]=i={}),i[n]=!0}function bIe(e,t,n){if(t>n){let r=t;t=n,n=r}let i=e[t];return i!==void 0&&Object.hasOwn(i,n)}function OIe(e,t,n,i){let r={},s={},a={};return t.forEach(o=>{o.forEach((c,u)=>{r[c]=c,s[c]=c,a[c]=u})}),t.forEach(o=>{let c=-1;o.forEach(u=>{let d=i(u);if(d&&d.length){let f=d.sort((p,g)=>{let b=a[p],y=a[g];return(b!==void 0?b:0)-(y!==void 0?y:0)}),h=(f.length-1)/2;for(let p=Math.floor(h),g=Math.ceil(h);p<=g;++p){let b=f[p];if(b===void 0)continue;let y=a[b];if(y!==void 0&&s[u]===u&&c{var O;let v=(O=s[y.v])!=null?O:0,x=a.edge(y);return Math.max(b,v+(x!==void 0?x:0))},0):s[p]=0}function d(p){let g=a.outEdges(p),b=Number.POSITIVE_INFINITY;g&&(b=g.reduce((O,v)=>{let x=s[v.w],w=a.edge(v);return Math.min(O,(x!==void 0?x:0)-(w!==void 0?w:0))},Number.POSITIVE_INFINITY));let y=e.node(p);b!==Number.POSITIVE_INFINITY&&y.borderType!==o&&(s[p]=Math.max(s[p]!==void 0?s[p]:0,b))}function f(p){return a.predecessors(p)||[]}function h(p){return a.successors(p)||[]}return c(u,f),c(d,h),Object.keys(i).forEach(p=>{var g;let b=n[p];b!==void 0&&(s[p]=(g=s[b])!=null?g:0)}),s}function xIe(e,t,n,i){let r=new al,s=e.graph(),a=kIe(s.nodesep,s.edgesep,i);return t.forEach(o=>{let c;o.forEach(u=>{let d=n[u];if(d!==void 0){if(r.setNode(d),c!==void 0){let f=n[c];if(f!==void 0){let h=r.edge(f,d);r.setEdge(f,d,Math.max(a(e,u,c),h||0))}}c=u}})}),r}function vIe(e,t){return Object.values(t).reduce((n,i)=>{let r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;Object.entries(i).forEach(([o,c])=>{let u=TIe(e,o)/2;r=Math.max(c+u,r),s=Math.min(c-u,s)});let a=r-s;return a{["l","r"].forEach(a=>{let o=s+a,c=e[o];if(!c||c===t)return;let u=Object.values(c),d=i-Ac(Math.min,u);a!=="l"&&(d=r-Ac(Math.max,u)),d&&(e[o]=$_(c,f=>f+d))})})}function SIe(e,t=void 0){let n=e.ul;return n?$_(n,(i,r)=>{var s,a;if(t){let c=t.toLowerCase(),u=e[c];if(u&&u[r]!==void 0)return u[r]}let o=Object.values(e).map(c=>{let u=c[r];return u!==void 0?u:0}).sort((c,u)=>c-u);return(((s=o[1])!=null?s:0)+((a=o[2])!=null?a:0))/2}):{}}function EIe(e){let t=N1(e),n=Object.assign(pIe(e,t),mIe(e,t)),i={},r;["u","d"].forEach(a=>{r=a==="u"?t:Object.values(t).reverse(),["l","r"].forEach(o=>{o==="r"&&(r=r.map(d=>Object.values(d).reverse()));let c=OIe(e,r,n,d=>(a==="u"?e.predecessors(d):e.successors(d))||[]),u=yIe(e,r,c.root,c.align,o==="r");o==="r"&&(u=$_(u,d=>-d)),i[a+o]=u})});let s=vIe(e,i);return wIe(i,s),SIe(i,e.graph().align)}function kIe(e,t,n){return(i,r,s)=>{let a=i.node(r),o=i.node(s),c=0,u;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":u=-a.width/2;break;case"r":u=a.width/2;break}if(u&&(c+=n?u:-u),u=void 0,c+=(a.dummy?t:e)/2,c+=(o.dummy?t:e)/2,c+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":u=o.width/2;break;case"r":u=-o.width/2;break}return u&&(c+=n?u:-u),c}}function TIe(e,t){return e.node(t).width}function _Ie(e){e=kne(e),AIe(e),Object.entries(EIe(e)).forEach(([t,n])=>e.node(t).x=n)}function AIe(e){let t=N1(e),n=e.graph(),i=n.ranksep,r=n.rankalign,s=0;t.forEach(a=>{let o=a.reduce((c,u)=>{var d;let f=(d=e.node(u).height)!=null?d:0;return c>f?c:f},0);a.forEach(c=>{let u=e.node(c);r==="top"?u.y=s+u.height/2:r==="bottom"?u.y=s+o-u.height/2:u.y=s+o/2}),s+=o+i})}function NIe(e,t={}){let n=t.debugTiming?Ane:Nne;return n("layout",()=>{let i=n(" buildLayoutGraph",()=>QIe(e));return n(" runLayout",()=>CIe(i,n,t)),n(" updateInputGraph",()=>jIe(e,i)),i})}function CIe(e,t,n){t(" makeSpaceForEdgeLabels",()=>BIe(e)),t(" removeSelfEdges",()=>GIe(e)),t(" acyclic",()=>yRe(e)),t(" nestingGraph.run",()=>FRe(e)),t(" rank",()=>MRe(kne(e))),t(" injectEdgeLabelProxies",()=>UIe(e)),t(" removeEmptyRanks",()=>sRe(e)),t(" nestingGraph.cleanup",()=>qRe(e)),t(" normalizeRanks",()=>rRe(e)),t(" assignRankMinMax",()=>zIe(e)),t(" removeEdgeLabelProxies",()=>FIe(e)),t(" normalize.run",()=>wRe(e)),t(" parentDummyChains",()=>QRe(e)),t(" addBorderSegments",()=>HRe(e)),t(" order",()=>Qne(e,n)),t(" insertSelfEdges",()=>WIe(e)),t(" adjustCoordinateSystem",()=>GRe(e)),t(" position",()=>_Ie(e)),t(" positionSelfEdges",()=>ZIe(e)),t(" removeBorderNodes",()=>YIe(e)),t(" normalize.undo",()=>ERe(e)),t(" fixupEdgeLabelCoords",()=>qIe(e)),t(" undoCoordinateSystem",()=>WRe(e)),t(" translateGraph",()=>VIe(e)),t(" assignNodeIntersects",()=>XIe(e)),t(" reversePoints",()=>HIe(e)),t(" acyclic.undo",()=>vRe(e))}function jIe(e,t){e.nodes().forEach(n=>{let i=e.node(n),r=t.node(n);i&&(i.x=r.x,i.y=r.y,i.order=r.order,i.rank=r.rank,t.children(n).length&&(i.width=r.width,i.height=r.height))}),e.edges().forEach(n=>{let i=e.edge(n),r=t.edge(n);i.points=r.points,Object.hasOwn(r,"x")&&(i.x=r.x,i.y=r.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var RIe=["nodesep","edgesep","ranksep","marginx","marginy"],IIe={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},PIe=["acyclicer","ranker","rankdir","align","rankalign"],MIe=["width","height","rank"],DU={width:0,height:0},LIe=["minlen","weight","width","height","labeloffset"],DIe={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$Ie=["labelpos"];function QIe(e){let t=new al({multigraph:!0,compound:!0}),n=iC(e.graph());return t.setGraph(Object.assign({},IIe,nC(n,RIe),Ik(n,PIe))),e.nodes().forEach(i=>{let r=iC(e.node(i)),s=nC(r,MIe);Object.keys(DU).forEach(o=>{s[o]===void 0&&(s[o]=DU[o])}),t.setNode(i,s);let a=e.parent(i);a!==void 0&&t.setParent(i,a)}),e.edges().forEach(i=>{let r=iC(e.edge(i));t.setEdge(i,Object.assign({},DIe,nC(r,LIe),Ik(r,$Ie)))}),t}function BIe(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let i=e.edge(n);i.minlen*=2,i.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function UIe(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let i=e.node(t.v),r={rank:(e.node(t.w).rank-i.rank)/2+i.rank,e:t};q0(e,"edge-proxy",r,"_ep")}})}function zIe(e){let t=0;e.nodes().forEach(n=>{let i=e.node(n);i.borderTop&&(i.minRank=e.node(i.borderTop).rank,i.maxRank=e.node(i.borderBottom).rank,t=Math.max(t,i.maxRank))}),e.graph().maxRank=t}function FIe(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let i=n;e.edge(i.e).labelRank=n.rank,e.removeNode(t)}})}function VIe(e){let t=Number.POSITIVE_INFINITY,n=0,i=Number.POSITIVE_INFINITY,r=0,s=e.graph(),a=s.marginx||0,o=s.marginy||0;function c(u){let d=u.x,f=u.y,h=u.width,p=u.height;t=Math.min(t,d-h/2),n=Math.max(n,d+h/2),i=Math.min(i,f-p/2),r=Math.max(r,f+p/2)}e.nodes().forEach(u=>c(e.node(u))),e.edges().forEach(u=>{let d=e.edge(u);Object.hasOwn(d,"x")&&c(d)}),t-=a,i-=o,e.nodes().forEach(u=>{let d=e.node(u);d.x-=t,d.y-=i}),e.edges().forEach(u=>{let d=e.edge(u);d.points.forEach(f=>{f.x-=t,f.y-=i}),Object.hasOwn(d,"x")&&(d.x-=t),Object.hasOwn(d,"y")&&(d.y-=i)}),s.width=n-t+a,s.height=r-i+o}function XIe(e){e.edges().forEach(t=>{let n=e.edge(t),i=e.node(t.v),r=e.node(t.w),s,a;n.points?(s=n.points[0],a=n.points[n.points.length-1]):(n.points=[],s=r,a=i),n.points.unshift(_U(i,s)),n.points.push(_U(r,a))})}function qIe(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function HIe(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function YIe(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),i=e.node(n.borderTop),r=e.node(n.borderBottom),s=e.node(n.borderLeft[n.borderLeft.length-1]),a=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(a.x-s.x),n.height=Math.abs(r.y-i.y),n.x=s.x+n.width/2,n.y=i.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function GIe(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function WIe(e){N1(e).forEach(t=>{let n=0;t.forEach((i,r)=>{let s=e.node(i);s.order=r+n,(s.selfEdges||[]).forEach(a=>{q0(e,"selfedge",{width:a.label.width,height:a.label.height,rank:s.rank,order:r+ ++n,e:a.e,label:a.label},"_se")}),delete s.selfEdges})})}function ZIe(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let i=n,r=e.node(i.e.v),s=r.x+r.width/2,a=r.y,o=n.x-s,c=r.height/2;e.setEdge(i.e,i.label),e.removeNode(t),i.label.points=[{x:s+2*o/3,y:a-c},{x:s+5*o/6,y:a-c},{x:s+o,y:a},{x:s+5*o/6,y:a+c},{x:s+2*o/3,y:a+c}],i.label.x=n.x,i.label.y=n.y}})}function nC(e,t){return $_(Ik(e,t),Number)}function iC(e){let t={};return e&&Object.entries(e).forEach(([n,i])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=i}),t}function KIe(e){let t=N1(e),n=new al({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(i=>{n.setNode(i,{label:i}),n.setParent(i,"layer"+e.node(i).rank)}),e.edges().forEach(i=>n.setEdge(i.v,i.w,{},i.name)),t.forEach((i,r)=>{let s="layer"+r;n.setNode(s,{rank:"same"}),i.reduce((a,o)=>(n.setEdge(a,o,{style:"invis"}),o))}),n}var JIe={graphlib:gne,version:uRe,layout:NIe,debug:KIe,util:{time:Ane,notime:Nne}},$U=JIe;/*! For license information please see dagre.esm.js.LEGAL.txt */const CO={llm:{label:"智能体",description:"理解任务并直接完成一个具体工作",icon:lJ},sequential:{label:"分步协作",description:"内部步骤按照顺序依次执行",icon:Jwe},parallel:{label:"同时处理",description:"内部步骤同时工作,完成后统一汇总",icon:Dwe},loop:{label:"循环执行",description:"重复执行内部步骤,直到满足停止条件",icon:mJ},a2a:{label:"远程智能体",description:"调用已经存在的远程 Agent",icon:O_}},_P=220,AP=88,QU=96,BU=34,dy=64,rC=310,tg=24,Une=56,NP=40,UU=40,ePe=18,tPe=58,nPe=!1,iPe=e=>e==="sequential"||e==="parallel"||e==="loop";function CP(e,t){const n=e.agentType??"llm";return iPe(n)||n==="llm"&&(t.length===0||e.subAgents.length>0)}function jP(e,t=[],n="horizontal",i=!1){const r=e.agentType??"llm";if(!CP(e,t))return{width:_P,height:AP};if(i&&e.subAgents.length===0)return{width:rC,height:dy};const s=e.subAgents.map((f,h)=>jP(f,[...t,h],n,i)),a=s.length?Math.max(...s.map(f=>f.width)):0,o=s.length?Math.max(...s.map(f=>f.height)):0,c=s.length&&r!=="parallel"?Une:tg,u=n==="horizontal"?r!=="parallel":r==="parallel",d=s.length?r==="parallel"?ePe+UU:r==="loop"?tPe:0:UU;return u?{width:Math.max(rC,s.reduce((f,h)=>f+h.width,0)+NP*Math.max(0,s.length-1)+c*2),height:dy+tg+o+d+tg}:{width:Math.max(rC,a+tg*2),height:dy+c+s.reduce((f,h)=>f+h.height,0)+NP*Math.max(0,s.length-1)+d+c}}function Gb(e){return e.length===0?"agent-root":`agent-${e.join("-")}`}function rPe(e,t){return e.length===t.length&&e.every((n,i)=>n===t[i])}function zU(e){const t=n=>[n.agentType??"llm",n.subAgents.map(t)];return JSON.stringify(t(e))}function Wb(e,t,n,i){const r=(i==null?void 0:i.tone)==="sequential"?"hsl(213 40% 40%)":(i==null?void 0:i.tone)==="loop"?"hsl(151 34% 34%)":"hsl(220 9% 38%)";return{id:`${e}-${t}${i!=null&&i.loop?"-loop":""}`,source:e,target:t,sourceHandle:i!=null&&i.loop?"loop-source":void 0,targetHandle:i!=null&&i.loop?"loop-target":void 0,label:n,type:"insertStep",data:i?{insert:i.insert,loop:i.loop,tone:i.tone}:void 0,animated:i==null?void 0:i.loop,markerEnd:{type:cx.ArrowClosed,width:16,height:16,color:r},style:{stroke:r,strokeWidth:1.5},labelStyle:{fill:"hsl(215 14% 42%)",fontSize:10,fontWeight:600},labelBgStyle:{fill:"hsl(var(--background))",fillOpacity:.92}}}function FU(e,t,n=!1){const i=[{id:"terminal-input",type:"terminal",position:{x:0,y:0},data:{kind:"terminal",title:"用户请求"},selectable:!1,draggable:!1},{id:"terminal-output",type:"terminal",position:{x:0,y:0},data:{kind:"terminal",title:"最终回复"},selectable:!1,draggable:!1}],r=[];function s(d,f,h,p,g){const b=d.agentType??"llm",y=Gb(f);return CP(d,f)?(a(d,f,h,p,g),y):(i.push({id:y,type:"agent",parentId:h,extent:"parent",position:p,data:{kind:"agent",path:f,agent:d,title:b==="a2a"?"远程智能体":d.name.trim()||(f.length===0?"主 Agent":"未命名步骤"),pattern:b,description:d.description.trim()||CO[b].description,childCount:d.subAgents.length,containedIn:g}}),y)}function a(d,f,h,p={x:0,y:0},g){const b=d.agentType??"sequential",y=Gb(f),O=jP(d,f,t,n);i.push({id:y,type:"group",parentId:h,extent:h?"parent":void 0,position:p,style:{width:O.width,height:O.height},data:{kind:"agent",path:f,agent:d,title:d.name.trim()||(f.length===0?"主 Agent":CO[b].label),pattern:b,description:d.description.trim()||CO[b].description,childCount:d.subAgents.length,containedIn:g,layoutWidth:O.width,layoutHeight:O.height,compactEmptyGroup:n&&d.subAgents.length===0}});const v=d.subAgents.map((k,T)=>jP(k,[...f,T],t,n)),x=v.length&&b!=="parallel"?Une:tg,w=t==="horizontal"?b!=="parallel":b==="parallel";let E=x;const S=d.subAgents.map((k,T)=>{const A=v[T],N=w?{x:E,y:dy+tg}:{x:(O.width-A.width)/2,y:dy+E};return E+=(w?A.width:A.height)+NP,s(k,[...f,T],y,N,b)});if(b==="sequential"||b==="loop"){for(let k=0;k1&&r.push(Wb(S[S.length-1],S[0],"继续循环",{loop:!0,tone:"loop"}))}return y}const o=(d,f)=>{const h=d.agentType??"llm",p=Gb(f);if(CP(d,f))return a(d,f),[p];if(i.push({id:p,type:"agent",position:{x:0,y:0},data:{kind:"agent",path:f,agent:d,title:h==="a2a"?"远程智能体":d.name.trim()||(f.length===0?"主 Agent":"未命名步骤"),pattern:h,description:d.description.trim()||CO[h].description,childCount:d.subAgents.length}}),d.subAgents.length===0)return[p];const g=[];return d.subAgents.forEach((b,y)=>{const O=[...f,y],v=Gb(O);r.push(Wb(p,v,"调用",{insert:{parentPath:f,index:y}})),g.push(...o(b,O))}),g},c=Gb([]),u=o(e,[]);return r.push(Wb("terminal-input",c)),u.forEach(d=>r.push(Wb(d,"terminal-output"))),sPe(i,r,t)}function sPe(e,t,n){const i=new $U.graphlib.Graph().setDefaultEdgeLabel(()=>({}));i.setGraph({rankdir:n==="vertical"?"TB":"LR",ranksep:50,nodesep:34,edgesep:14,marginx:24,marginy:24});const r=new Set(e.filter(s=>!s.parentId).map(s=>s.id));return e.filter(s=>!s.parentId).forEach(s=>{const a=s.data.kind==="terminal";i.setNode(s.id,{width:a?QU:s.data.layoutWidth??_P,height:a?BU:s.data.layoutHeight??AP})}),t.filter(s=>r.has(s.source)&&r.has(s.target)).forEach(s=>i.setEdge(s.source,s.target)),$U.layout(i),{nodes:e.map(s=>{if(s.parentId)return s;const a=i.node(s.id),o=s.data.kind==="terminal",c=o?QU:s.data.layoutWidth??_P,u=o?BU:s.data.layoutHeight??AP;return{...s,position:{x:a.x-c/2,y:a.y-u/2}}}),edges:t}}const B_=m.createContext(null),U_=m.createContext("horizontal");function aPe({id:e,sourceX:t,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:a,markerEnd:o,style:c,label:u,data:d}){const f=m.useContext(B_),[h,p]=m.useState(!1),[g,b,y]=Nk({sourceX:t,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:a,offset:d!=null&&d.loop?28:20});return l.jsxs(l.Fragment,{children:[l.jsx(A1,{id:e,path:g,markerEnd:o,style:c}),f&&(d==null?void 0:d.insert)&&l.jsx("path",{d:g,className:"abc-edge-hover-path",onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1)}),(u||f&&(d==null?void 0:d.insert))&&l.jsx(KCe,{children:l.jsxs("div",{className:`abc-edge-tools${f&&(d!=null&&d.insert)?" can-insert":""}${h?" is-visible":""}`,style:{transform:`translate(-50%, -50%) translate(${b}px, ${y}px)`},onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1),children:[u&&l.jsx("span",{className:"abc-edge-label",children:u}),f&&(d==null?void 0:d.insert)&&l.jsx("button",{type:"button",className:"abc-edge-add nodrag nopan","aria-label":"在这里插入步骤",title:"在这里插入步骤",onClick:O=>{O.stopPropagation(),f==null||f.onInsert(d.insert.parentPath,d.insert.index)},children:l.jsx(Gs,{})})]})})]})}function oPe({data:e,selected:t}){const n=m.useContext(B_),i=m.useContext(U_),r=i==="vertical"?St.Top:St.Left,s=i==="vertical"?St.Bottom:St.Right,a=i==="vertical"?St.Right:St.Bottom,o=e.pattern??"llm",c=CO[o],u=c.icon;return l.jsxs("div",{className:`abc-node is-${o}${e.containedIn?` is-contained-in-${e.containedIn}`:""}${t?" is-selected":""}`,children:[l.jsx($a,{type:"target",position:r,className:"abc-handle"}),o!=="llm"&&l.jsx("span",{className:"abc-node-icon",children:l.jsx(u,{})}),l.jsxs("span",{className:"abc-node-copy",children:[l.jsx("span",{className:"abc-node-meta",children:l.jsx("span",{children:c.label})}),l.jsx("strong",{children:e.title}),l.jsx("small",{children:e.description})]}),n&&e.path!==void 0&&e.path.length>0&&l.jsx("button",{type:"button",className:"abc-node-delete nodrag nopan","aria-label":`删除 ${e.title}`,title:"删除节点",onClick:d=>{d.stopPropagation(),n==null||n.onDelete(e.path)},children:l.jsx(If,{})}),l.jsx($a,{type:"source",position:s,className:"abc-handle"}),e.containedIn==="loop"&&l.jsxs(l.Fragment,{children:[l.jsx($a,{id:"loop-target",type:"target",position:a,className:"abc-handle abc-loop-handle"}),l.jsx($a,{id:"loop-source",type:"source",position:a,className:"abc-handle abc-loop-handle"})]})]})}function lPe({data:e,selected:t}){const n=m.useContext(B_),i=m.useContext(U_),r=i==="vertical"?St.Top:St.Left,s=i==="vertical"?St.Bottom:St.Right,a=i==="vertical"?St.Right:St.Bottom,o=e.pattern??"sequential",c=e.childCount??0,u=o==="llm"?"添加子 Agent":o==="parallel"?"添加一个同时处理的步骤":o==="loop"?"添加循环步骤":"添加下一个步骤";return l.jsxs("div",{className:`abc-group is-${o}${e.compactEmptyGroup?" is-compact-empty":""}${t?" is-selected":""}`,children:[l.jsx($a,{type:"target",position:r,className:"abc-handle"}),l.jsx("header",{className:"abc-group-head",children:l.jsxs("span",{children:[l.jsx("strong",{title:e.title,children:e.title}),l.jsx("small",{children:e.description})]})}),n&&e.path!==void 0&&c>0&&o!=="parallel"&&l.jsxs("div",{className:"abc-group-boundary-actions",children:[l.jsx("button",{type:"button",className:"abc-group-boundary-add is-start nodrag nopan","aria-label":"添加到最前",title:"添加到最前",onClick:d=>{d.stopPropagation(),n.onInsert(e.path,0)},children:l.jsx(Gs,{})}),l.jsx("button",{type:"button",className:"abc-group-boundary-add is-end nodrag nopan","aria-label":"添加到最后",title:"添加到最后",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:l.jsx(Gs,{})})]}),n&&e.path!==void 0&&c>0&&o==="parallel"&&l.jsxs("button",{type:"button",className:"abc-group-add abc-group-add-bottom nodrag nopan",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:[l.jsx(Gs,{}),l.jsx("span",{children:u})]}),n&&e.path!==void 0&&c===0&&l.jsxs("button",{type:"button",className:"abc-group-add abc-group-add-empty nodrag nopan",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:[l.jsx(Gs,{}),l.jsx("span",{children:u})]}),n&&e.path!==void 0&&e.path.length>0&&l.jsx("button",{type:"button",className:"abc-node-delete nodrag nopan","aria-label":`删除 ${e.title}`,title:"删除节点",onClick:d=>{d.stopPropagation(),n==null||n.onDelete(e.path)},children:l.jsx(If,{})}),l.jsx($a,{type:"source",position:s,className:"abc-handle"}),e.containedIn==="loop"&&l.jsxs(l.Fragment,{children:[l.jsx($a,{id:"loop-target",type:"target",position:a,className:"abc-handle abc-loop-handle"}),l.jsx($a,{id:"loop-source",type:"source",position:a,className:"abc-handle abc-loop-handle"})]})]})}function cPe({data:e}){const t=m.useContext(U_);return l.jsxs("div",{className:"abc-terminal",children:[l.jsx($a,{type:"target",position:t==="vertical"?St.Top:St.Left,className:"abc-handle"}),l.jsx("span",{children:e.title}),l.jsx($a,{type:"source",position:t==="vertical"?St.Bottom:St.Right,className:"abc-handle"})]})}const uPe={agent:oPe,group:lPe,terminal:cPe},dPe={insertStep:aPe};function fPe({draft:e,selectedPath:t,onSelect:n,onAdd:i,onInsert:r,onDelete:s,readOnly:a=!1,interactivePreview:o=!1,direction:c="horizontal"}){const u=m.useMemo(()=>FU(e,c,a),[]),[d,f,h]=JCe(u.nodes),[p,g,b]=eje(u.edges),y=nje(),O=m.useRef(`${c}:${a?"readonly":"editable"}:${zU(e)}`),v=m.useRef(null),{fitView:x}=L_(),w=m.useMemo(()=>FU(e,c,a),[c,e,a]),[E,S]=m.useState(()=>window.matchMedia("(max-width: 860px)").matches),k=m.useMemo(()=>a?{padding:.16,minZoom:.05,maxZoom:.9}:E?{padding:.08,minZoom:.35,maxZoom:.9}:{padding:.14,minZoom:.42,maxZoom:1.1},[E,a]),T=m.useCallback((N=0)=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{const C=v.current;if(C&&(C.clientWidth===0||C.clientHeight===0)&&N<8){T(N+1);return}x(k)})})},[k,x]);m.useEffect(()=>{const N=window.matchMedia("(max-width: 860px)"),C=M=>S(M.matches);return N.addEventListener("change",C),()=>N.removeEventListener("change",C)},[]),m.useEffect(()=>{const N=`${c}:${a?"readonly":"editable"}:${zU(e)}`,C=N!==O.current;O.current=N,g(w.edges),f(M=>{const L=new Map(M.map(P=>[P.id,P]));return w.nodes.map(P=>{const Q=L.get(P.id);return{...P,measured:!C&&Q&&Q.type===P.type?Q.measured:void 0,position:!C&&Q?Q.position:P.position,selected:P.data.kind==="agent"&&!!P.data.path&&rPe(P.data.path,t)}})}),C&&T()},[w,e,T,t,g,f]),m.useEffect(()=>{T()},[E,T]),m.useEffect(()=>{y&&T()},[w,T,y]),m.useEffect(()=>{if(!a||!v.current)return;const N=new ResizeObserver(()=>T());return N.observe(v.current),T(),()=>N.disconnect()},[T,a]);const A=m.useMemo(()=>a?null:{onAdd:i,onInsert:r,onDelete:s},[i,s,r,a]);return l.jsx(U_.Provider,{value:c,children:l.jsx(B_.Provider,{value:A,children:l.jsx("section",{className:`abc-root is-${c}${a?" is-readonly":""}`,"aria-label":a?"只读 Agent 执行画布":"Agent 执行画布",children:l.jsx("div",{ref:v,className:"abc-canvas",children:l.jsxs(WCe,{nodes:d,edges:p,nodeTypes:uPe,edgeTypes:dPe,onNodesChange:h,onEdgesChange:b,onNodeClick:(N,C)=>{!a&&C.data.kind==="agent"&&C.data.path&&n(C.data.path)},nodesDraggable:!a,nodesConnectable:!1,nodesFocusable:!a,elementsSelectable:!a,edgesFocusable:!1,edgesReconnectable:!1,panOnDrag:!a||o,zoomOnDoubleClick:o,zoomOnPinch:!a||o,zoomOnScroll:!a||o,fitView:!0,fitViewOptions:k,onInit:()=>T(),minZoom:a?.05:.35,maxZoom:1.6,proOptions:{hideAttribution:!0},children:[l.jsx(oje,{gap:20,size:1.2,color:"hsl(34 20% 82%)"}),(!a||o)&&l.jsx(pje,{showInteractive:!1}),nPe]})})})})})}function px(e){return l.jsx(dne,{children:l.jsx(fPe,{...e})})}const hPe="https://ark.cn-beijing.volces.com/api/v3/",GS=[{key:"MODEL_EMBEDDING_NAME",required:!1,placeholder:"doubao-embedding-vision-250615",comment:"向量化模型(记忆/知识库需要)"},{key:"MODEL_EMBEDDING_DIM",required:!1,placeholder:"2048"},{key:"MODEL_EMBEDDING_API_BASE",required:!1,placeholder:hPe}],mx=[],Pk={label:"控制台",url:"https://console.volcengine.com/vikingdb/openviking"},pPe={label:"文档",url:"https://github.com/volcengine/OpenViking/blob/main/docs/zh/api/05-sessions.md"},zne="https://api.vikingdb.cn-beijing.volces.com/openviking",mPe=`{ +`)),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??oU,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=p=>{var y,O;if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!u)&&hte(p))return!1;const b=cU(p.code,o);if(s.current.add(p[b]),lU(a,s.current,!1)){const v=((O=(y=p.composedPath)==null?void 0:y.call(p))==null?void 0:O[0])||p.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(r.current||!x)&&p.preventDefault(),i(!0)}},f=p=>{const g=cU(p.code,o);lU(a,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(p[g]),p.key==="Meta"&&s.current.clear(),r.current=!1},h=()=>{s.current.clear(),i(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,i]),n}function lU(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function cU(e,t){return t.includes(e)?"code":"key"}const _2e=()=>{const e=ur();return m.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,s],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:s,maxZoom:a,panZoom:o}=e.getState(),c=p$(t,i,r,s,a,(n==null?void 0:n.padding)??.1);return o?(await o.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:s,domNode:a}=e.getState();if(!a)return t;const{x:o,y:c}=a.getBoundingClientRect(),u={x:t.x-o,y:t.y-c},d=n.snapGrid??r,f=n.snapToGrid??s;return X0(u,i,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:s}=i.getBoundingClientRect(),a=o0(t,n);return{x:a.x+r,y:a.y+s}}}),[])};function Qte(e,t){const n=[],i=new Map,r=[];for(const s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")i.set(s.id,[s]);else{const a=i.get(s.id);a?a.push(s):i.set(s.id,[s])}for(const s of t){const a=i.get(s.id);if(!a){n.push(s);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const o={...s};for(const c of a)A2e(c,o);n.push(o)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function A2e(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Bte(e,t){return Qte(e,t)}function Ute(e,t){return Qte(e,t)}function Ah(e,t){return{id:e,type:"select",selected:t}}function eg(e,t=new Set,n=!1){const i=[];for(const[r,s]of e){const a=t.has(r);!(s.selected===void 0&&!a)&&s.selected!==a&&(n&&(s.selected=a),i.push(Ah(s.id,a)))}return i}function uU({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(s=>[s.id,s]));for(const[s,a]of e.entries()){const o=t.get(a.id),c=((r=o==null?void 0:o.internals)==null?void 0:r.userNode)??o;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:s})}for(const[s]of t)i.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function dU(e){return{id:e.id,type:"remove"}}const N2e=ute();function C2e(e,t,n={}){return tNe(e,t,{...n,onError:n.onError??N2e})}const fU=e=>BAe(e),j2e=e=>ate(e);function zte(e){return m.forwardRef(e)}const R2e=typeof window<"u"?m.useLayoutEffect:m.useEffect;function hU(e){const[t,n]=m.useState(BigInt(0)),[i]=m.useState(()=>I2e(()=>n(r=>r+BigInt(1))));return R2e(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function I2e(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Fte=m.createContext(null);function P2e({children:e}){const t=ur(),n=m.useCallback(o=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:h,fitViewQueued:p,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const O of o)b=typeof O=="function"?O(b):O;let y=uU({items:b,lookup:h});for(const O of g.values())y=O(y);d&&u(b),y.length>0?f==null||f(y):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:O,nodes:v,setNodes:x}=t.getState();O&&x(v)})},[]),i=hU(n),r=m.useCallback(o=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:h}=t.getState();let p=c;for(const g of o)p=typeof g=="function"?g(p):g;d?u(p):f&&f(uU({items:p,lookup:h}))},[]),s=hU(r),a=m.useMemo(()=>({nodeQueue:i,edgeQueue:s}),[]);return l.jsx(Fte.Provider,{value:a,children:e})}function M2e(){const e=m.useContext(Fte);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const L2e=e=>!!e.panZoom;function L_(){const e=_2e(),t=ur(),n=M2e(),i=zn(L2e),r=m.useMemo(()=>{const s=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},o=f=>{n.edgeQueue.push(f)},c=f=>{var O,v;const{nodeLookup:h,nodeOrigin:p}=t.getState(),g=fU(f)?f:h.get(f.id),b=g.parentId?dte(g.position,g.measured,g.parentId,h,p):g.position,y={...g,position:b,width:((O=g.measured)==null?void 0:O.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return a0(y)},u=(f,h,p={replace:!1})=>{a(g=>g.map(b=>{if(b.id===f){const y=typeof h=="function"?h(b):h;return p.replace&&fU(y)?y:{...b,...y}}return b}))},d=(f,h,p={replace:!1})=>{o(g=>g.map(b=>{if(b.id===f){const y=typeof h=="function"?h(b):h;return p.replace&&j2e(y)?y:{...b,...y}}return b}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var h;return(h=s(f))==null?void 0:h.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(h=>({...h}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:o,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:p}=t.getState(),[g,b,y]=p;return{nodes:f.map(O=>({...O})),edges:h.map(O=>({...O})),viewport:{x:g,y:b,zoom:y}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:p,edges:g,onNodesDelete:b,onEdgesDelete:y,triggerNodeChanges:O,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:w}=t.getState(),{nodes:E,edges:S}=await XAe({nodesToRemove:f,edgesToRemove:h,nodes:p,edges:g,onBeforeDelete:w}),k=S.length>0,T=E.length>0;if(k){const A=S.map(dU);y==null||y(S),v(A)}if(T){const A=E.map(dU);b==null||b(E),O(A)}return(T||k)&&(x==null||x({nodes:E,edges:S})),{deletedNodes:E,deletedEdges:S}},getIntersectingNodes:(f,h=!0,p)=>{const g=z9(f),b=g?f:c(f),y=p!==void 0;return b?(p||t.getState().nodes).filter(O=>{const v=t.getState().nodeLookup.get(O.id);if(v&&!g&&(O.id===f.id||!v.internals.positionAbsolute))return!1;const x=a0(y?O:v),w=ux(x,b);return h&&w>0||w>=x.width*x.height||w>=b.width*b.height}):[]},isNodeIntersecting:(f,h,p=!0)=>{const b=z9(f)?f:c(f);if(!b)return!1;const y=ux(b,h);return p&&y>0||y>=h.width*h.height||y>=b.width*b.height},updateNode:u,updateNodeData:(f,h,p={replace:!1})=>{u(f,g=>{const b=typeof h=="function"?h(g):h;return p.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},p)},updateEdge:d,updateEdgeData:(f,h,p={replace:!1})=>{d(f,g=>{const b=typeof h=="function"?h(g):h;return p.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},p)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:p}=t.getState();return UAe(f,{nodeLookup:h,nodeOrigin:p})},getHandleConnections:({type:f,id:h,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${f}${h?`-${h}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:f,handleId:h,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}${f?h?`-${f}-${h}`:`-${f}`:""}`))==null?void 0:g.values())??[])},fitView:async f=>{const h=t.getState().fitViewResolver??YAe();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(p=>[...p]),h.promise}}},[]);return m.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const pU=e=>e.selected,D2e=typeof window<"u"?window:void 0;function $2e({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ur(),{deleteElements:i}=L_(),r=fx(e,{actInsideInputWithModifier:!1}),s=fx(t,{target:D2e});m.useEffect(()=>{if(r){const{edges:a,nodes:o}=n.getState();i({nodes:o.filter(pU),edges:a.filter(pU)}),n.setState({nodesSelectionActive:!1})}},[r]),m.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function Q2e(e){const t=ur();m.useEffect(()=>{const n=()=>{var r,s,a,o;if(!e.current||!(((s=(r=e.current).checkVisibility)==null?void 0:s.call(r))??!0))return!1;const i=g$(e.current);(i.height===0||i.width===0)&&((o=(a=t.getState()).onError)==null||o.call(a,"004",$l.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const D_={position:"absolute",width:"100%",height:"100%",top:0,left:0},B2e=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function U2e({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:r=.5,panOnScrollMode:s=rp.Free,zoomOnDoubleClick:a=!0,panOnDrag:o=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:p=!0,children:g,noWheelClassName:b,noPanClassName:y,onViewportChange:O,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:w}){const E=ur(),S=m.useRef(null),{userSelectionActive:k,lib:T,connectionInProgress:A}=zn(B2e,cr),N=fx(h),C=m.useRef();Q2e(S);const M=m.useCallback(L=>{O==null||O({x:L[0],y:L[1],zoom:L[2]}),v||E.setState({transform:L})},[O,v]);return m.useEffect(()=>{if(S.current){C.current=jNe({domNode:S.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:j=>E.setState($=>$.paneDragging===j?$:{paneDragging:j}),onPanZoomStart:(j,$)=>{const{onViewportChangeStart:U,onMoveStart:B}=E.getState();B==null||B(j,$),U==null||U($)},onPanZoom:(j,$)=>{const{onViewportChange:U,onMove:B}=E.getState();B==null||B(j,$),U==null||U($)},onPanZoomEnd:(j,$)=>{const{onViewportChangeEnd:U,onMoveEnd:B}=E.getState();B==null||B(j,$),U==null||U($)}});const{x:L,y:P,zoom:Q}=C.current.getViewport();return E.setState({panZoom:C.current,transform:[L,P,Q],domNode:S.current.closest(".react-flow")}),()=>{var j;(j=C.current)==null||j.destroy()}}},[]),m.useEffect(()=>{var L;(L=C.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:r,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:o,zoomActivationKeyPressed:N,preventScrolling:p,noPanClassName:y,userSelectionActive:k,noWheelClassName:b,lib:T,onTransformChange:M,connectionInProgress:A,selectionOnDrag:w,paneClickDistance:x})},[e,t,n,i,r,s,a,o,N,p,y,k,b,T,M,A,w,x]),l.jsx("div",{className:"react-flow__renderer",ref:S,style:D_,children:g})}const z2e=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function F2e(){const{userSelectionActive:e,userSelectionRect:t}=zn(z2e,cr);return e&&t?l.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const W2=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},V2e=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function X2e({isSelecting:e,selectionKeyPressed:t,selectionMode:n=lx.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:g,children:b}){const y=m.useRef(0),O=ur(),{userSelectionActive:v,elementsSelectable:x,dragging:w,connectionInProgress:E,panBy:S,autoPanSpeed:k}=zn(V2e,cr),T=x&&(e||v),A=m.useRef(null),N=m.useRef(),C=m.useRef(new Set),M=m.useRef(new Set),L=m.useRef(!1),P=m.useRef({x:0,y:0}),Q=m.useRef(!1),j=J=>{if(L.current||E){L.current=!1;return}u==null||u(J),O.getState().resetSelectedElements(),O.setState({nodesSelectionActive:!1})},$=J=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){J.preventDefault();return}d==null||d(J)},U=f?J=>f(J):void 0,B=J=>{L.current&&(J.stopPropagation(),L.current=!1)},I=J=>{var Ne,Oe;const{domNode:ie,transform:ue}=O.getState();if(N.current=ie==null?void 0:ie.getBoundingClientRect(),!N.current)return;const ye=J.target===A.current;if(!ye&&!!J.target.closest(".nokey")||!e||!(a&&ye||t)||J.button!==0||!J.isPrimary)return;(Oe=(Ne=J.target)==null?void 0:Ne.setPointerCapture)==null||Oe.call(Ne,J.pointerId),L.current=!1;const{x:Ee,y:me}=Rl(J.nativeEvent,N.current),oe=X0({x:Ee,y:me},ue);O.setState({userSelectionRect:{width:0,height:0,startX:oe.x,startY:oe.y,x:Ee,y:me}}),ye||(J.stopPropagation(),J.preventDefault())};function X(J,ie){const{userSelectionRect:ue}=O.getState();if(!ue)return;const{transform:ye,nodeLookup:Se,edgeLookup:Re,connectionLookup:Ee,triggerNodeChanges:me,triggerEdgeChanges:oe,defaultEdgeOptions:Ne}=O.getState(),Oe={x:ue.startX,y:ue.startY},{x:Ve,y:We}=o0(Oe,ye),De={startX:Oe.x,startY:Oe.y,x:Jqe.id)),M.current=new Set;const Rt=(Ne==null?void 0:Ne.selectable)??!0;for(const qe of C.current){const W=Ee.get(qe);if(W)for(const{edgeId:K}of W.values()){const ae=Re.get(K);ae&&(ae.selectable??Rt)&&M.current.add(K)}}if(!F9(mt,C.current)){const qe=eg(Se,C.current,!0);me(qe)}if(!F9(at,M.current)){const qe=eg(Re,M.current);oe(qe)}O.setState({userSelectionRect:De,userSelectionActive:!0,nodesSelectionActive:!1})}function q(){if(!r||!N.current)return;const[J,ie]=h$(P.current,N.current,k);S({x:J,y:ie}).then(ue=>{if(!L.current||!ue){y.current=requestAnimationFrame(q);return}const{x:ye,y:Se}=P.current;X(ye,Se),y.current=requestAnimationFrame(q)})}const D=()=>{cancelAnimationFrame(y.current),y.current=0,Q.current=!1};m.useEffect(()=>()=>D(),[]);const H=J=>{const{userSelectionRect:ie,transform:ue,resetSelectedElements:ye}=O.getState();if(!N.current||!ie)return;const{x:Se,y:Re}=Rl(J.nativeEvent,N.current);P.current={x:Se,y:Re};const Ee=o0({x:ie.startX,y:ie.startY},ue);if(!L.current){const me=t?0:s;if(Math.hypot(Se-Ee.x,Re-Ee.y)<=me)return;ye(),o==null||o(J)}L.current=!0,Q.current||(q(),Q.current=!0),X(Se,Re)},re=J=>{var ie,ue;J.button===0&&((ue=(ie=J.target)==null?void 0:ie.releasePointerCapture)==null||ue.call(ie,J.pointerId),!v&&J.target===A.current&&O.getState().userSelectionRect&&(j==null||j(J)),O.setState({userSelectionActive:!1,userSelectionRect:null}),L.current&&(c==null||c(J),O.setState({nodesSelectionActive:C.current.size>0})),D())},fe=J=>{var ie,ue;(ue=(ie=J.target)==null?void 0:ie.releasePointerCapture)==null||ue.call(ie,J.pointerId),D()},Ae=i===!0||Array.isArray(i)&&i.includes(0);return l.jsxs("div",{className:Yr(["react-flow__pane",{draggable:Ae,dragging:w,selection:e}]),onClick:T?void 0:W2(j,A),onContextMenu:W2($,A),onWheel:W2(U,A),onPointerEnter:T?void 0:h,onPointerMove:T?H:p,onPointerUp:T?re:void 0,onPointerCancel:T?fe:void 0,onPointerDownCapture:T?I:void 0,onClickCapture:T?B:void 0,onPointerLeave:g,ref:A,style:D_,children:[b,l.jsx(F2e,{})]})}function kP({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:a,nodeLookup:o,onError:c}=t.getState(),u=o.get(e);if(!u){c==null||c("012",$l.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=i==null?void 0:i.current)==null?void 0:d.blur()})):r([e])}function Vte({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:s,nodeClickDistance:a}){const o=ur(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=bNe({getStoreItems:()=>o.getState(),onNodeMouseDown:f=>{kP({id:f,store:o,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,i,t,s,e,r,a]),c}const q2e=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Xte(){const e=ur();return m.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:s,nodesDraggable:a,onError:o,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,h=q2e(a),p=r?s[0]:5,g=r?s[1]:5,b=n.direction.x*p*n.factor,y=n.direction.y*g*n.factor;for(const[,O]of u){if(!h(O))continue;let v={x:O.internals.positionAbsolute.x+b,y:O.internals.positionAbsolute.y+y};r&&(v=_1(v,s));const{position:x,positionAbsolute:w}=ote({nodeId:O.id,nextPosition:v,nodeLookup:u,nodeExtent:i,nodeOrigin:d,onError:o});O.position=x,O.internals.positionAbsolute=w,f.set(O.id,O)}c(f)},[])}const w$=m.createContext(null),H2e=w$.Provider;w$.Consumer;const qte=()=>m.useContext(w$),Y2e=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),G2e=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:s,connection:a}=i,{fromHandle:o,toHandle:c,isValid:u}=a,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,connectingTo:d,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:s===r0.Strict?(o==null?void 0:o.type)!==n:e!==(o==null?void 0:o.nodeId)||t!==(o==null?void 0:o.id),connectionInProcess:!!o,clickConnectionInProcess:!!r,valid:d&&u}};function W2e({type:e="source",position:t=St.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:a,onConnect:o,children:c,className:u,onMouseDown:d,onTouchStart:f,...h},p){var Q,j;const g=a||null,b=e==="target",y=ur(),O=qte(),{connectOnClick:v,noPanClassName:x,rfId:w}=zn(Y2e,cr),{connectingFrom:E,connectingTo:S,clickConnecting:k,isPossibleEndHandle:T,connectionInProcess:A,clickConnectionInProcess:N,valid:C}=zn(G2e(O,g,e),cr);O||(j=(Q=y.getState()).onError)==null||j.call(Q,"010",$l.error010());const M=$=>{const{defaultEdgeOptions:U,onConnect:B,hasDefaultEdges:I}=y.getState(),X={...U,...$};if(I){const{edges:q,setEdges:D,onError:H}=y.getState();D(C2e(X,q,{onError:H}))}B==null||B(X),o==null||o(X)},L=$=>{if(!O)return;const U=pte($.nativeEvent);if(r&&(U&&$.button===0||!U)){const B=y.getState();EP.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:B.autoPanOnConnect,connectionMode:B.connectionMode,connectionRadius:B.connectionRadius,domNode:B.domNode,nodeLookup:B.nodeLookup,lib:B.lib,isTarget:b,handleId:g,nodeId:O,flowId:B.rfId,panBy:B.panBy,cancelConnection:B.cancelConnection,onConnectStart:B.onConnectStart,onConnectEnd:(...I)=>{var X,q;return(q=(X=y.getState()).onConnectEnd)==null?void 0:q.call(X,...I)},updateConnection:B.updateConnection,onConnect:M,isValidConnection:n||((...I)=>{var X,q;return((q=(X=y.getState()).isValidConnection)==null?void 0:q.call(X,...I))??!0}),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:B.autoPanSpeed,dragThreshold:B.connectionDragThreshold})}U?d==null||d($):f==null||f($)},P=$=>{const{onClickConnectStart:U,onClickConnectEnd:B,connectionClickStartHandle:I,connectionMode:X,isValidConnection:q,lib:D,rfId:H,nodeLookup:re,connection:fe}=y.getState();if(!O||!I&&!r)return;if(!I){U==null||U($.nativeEvent,{nodeId:O,handleId:g,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:O,type:e,id:g}});return}const Ae=fte($.target),J=n||q,{connection:ie,isValid:ue}=EP.isValid($.nativeEvent,{handle:{nodeId:O,id:g,type:e},connectionMode:X,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:J,flowId:H,doc:Ae,lib:D,nodeLookup:re});ue&&ie&&M(ie);const ye=structuredClone(fe);delete ye.inProgress,ye.toPosition=ye.toHandle?ye.toHandle.position:null,B==null||B($,ye),y.setState({connectionClickStartHandle:null})};return l.jsx("div",{"data-handleid":g,"data-nodeid":O,"data-handlepos":t,"data-id":`${w}-${O}-${g}-${e}`,className:Yr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!b,target:b,connectable:i,connectablestart:r,connectableend:s,clickconnecting:k,connectingfrom:E,connectingto:S,valid:C,connectionindicator:i&&(!A||T)&&(A||N?s:r)}]),onMouseDown:L,onTouchStart:L,onClick:v?P:void 0,ref:p,...h,children:c})}const $a=m.memo(zte(W2e));function Z2e({data:e,isConnectable:t,sourcePosition:n=St.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx($a,{type:"source",position:n,isConnectable:t})]})}function K2e({data:e,isConnectable:t,targetPosition:n=St.Top,sourcePosition:i=St.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx($a,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l.jsx($a,{type:"source",position:i,isConnectable:t})]})}function J2e(){return null}function eCe({data:e,isConnectable:t,targetPosition:n=St.Top}){return l.jsxs(l.Fragment,{children:[l.jsx($a,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ck={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},mU={input:Z2e,default:K2e,output:eCe,group:J2e};function tCe(e){var t,n,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const nCe=e=>{const{width:t,height:n,x:i,y:r}=T1(e.nodeLookup,{filter:s=>!!s.selected});return{width:jl(t)?t:null,height:jl(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function iCe({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=ur(),{width:r,height:s,transformString:a,userSelectionActive:o}=zn(nCe,cr),c=Xte(),u=m.useRef(null);m.useEffect(()=>{var p;n||(p=u.current)==null||p.focus({preventScroll:!0})},[n]);const d=!o&&r!==null&&s!==null;if(Vte({nodeRef:u,disabled:!d}),!d)return null;const f=e?p=>{const g=i.getState().nodes.filter(b=>b.selected);e(p,g)}:void 0,h=p=>{Object.prototype.hasOwnProperty.call(Ck,p.key)&&(p.preventDefault(),c({direction:Ck[p.key],factor:p.shiftKey?4:1}))};return l.jsx("div",{className:Yr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:l.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:r,height:s}})})}const gU=typeof window<"u"?window:void 0,rCe=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Hte({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,paneClickDistance:o,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:y,elementsSelectable:O,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:w,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:k,panOnDrag:T,autoPanOnSelection:A,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:L,preventScrolling:P,onSelectionContextMenu:Q,noWheelClassName:j,noPanClassName:$,disableKeyboardA11y:U,onViewportChange:B,isControlledViewport:I}){const{nodesSelectionActive:X,userSelectionActive:q}=zn(rCe,cr),D=fx(u,{target:gU}),H=fx(b,{target:gU}),re=H||T,fe=H||w,Ae=d&&re!==!0,J=D||q||Ae;return $2e({deleteKeyCode:c,multiSelectionKeyCode:g}),l.jsx(U2e,{onPaneContextMenu:s,elementsSelectable:O,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:fe,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:k,panOnDrag:!D&&re,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:L,zoomActivationKeyCode:y,preventScrolling:P,noWheelClassName:j,noPanClassName:$,onViewportChange:B,isControlledViewport:I,paneClickDistance:o,selectionOnDrag:Ae,children:l.jsxs(X2e,{onSelectionStart:h,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:re,autoPanOnSelection:A,isSelecting:!!J,selectionMode:f,selectionKeyPressed:D,paneClickDistance:o,selectionOnDrag:Ae,children:[e,X&&l.jsx(iCe,{onSelectionContextMenu:Q,noPanClassName:$,disableKeyboardA11y:U})]})})}Hte.displayName="FlowRenderer";const sCe=m.memo(Hte),aCe=e=>t=>e?f$(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function oCe(e){return zn(m.useCallback(aCe(e),[e]),cr)}const lCe=e=>e.updateNodeInternals;function cCe(){const e=zn(lCe),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const s=r.target.getAttribute("data-id");i.set(s,{id:s,nodeElement:r.target,force:!0})}),e(i)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function uCe({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=ur(),s=m.useRef(null),a=m.useRef(null),o=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.useEffect(()=>{s.current&&!e.hidden&&(!d||a.current!==s.current)&&(a.current&&(i==null||i.unobserve(a.current)),i==null||i.observe(s.current),a.current=s.current)},[d,e.hidden]),m.useEffect(()=>()=>{a.current&&(i==null||i.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(s.current){const f=u.current!==t,h=o.current!==e.sourcePosition,p=c.current!==e.targetPosition;(f||h||p)&&(u.current=t,o.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function dCe({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:s,onDoubleClick:a,nodesDraggable:o,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:h,noPanClassName:p,disableKeyboardA11y:g,rfId:b,nodeTypes:y,nodeClickDistance:O,onError:v}){const{node:x,internals:w,isParent:E}=zn(J=>{const ie=J.nodeLookup.get(e),ue=J.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:ue}},cr);let S=x.type||"default",k=(y==null?void 0:y[S])||mU[S];k===void 0&&(v==null||v("003",$l.error003(S)),S="default",k=(y==null?void 0:y.default)||mU.default);const T=!!(x.draggable||o&&typeof x.draggable>"u"),A=!!(x.selectable||c&&typeof x.selectable>"u"),N=!!(x.connectable||u&&typeof x.connectable>"u"),C=!!(x.focusable||d&&typeof x.focusable>"u"),M=ur(),L=m$(x),P=uCe({node:x,nodeType:S,hasDimensions:L,resizeObserver:f}),Q=Vte({nodeRef:P,disabled:x.hidden||!T,noDragClassName:h,handleSelector:x.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:O}),j=Xte();if(x.hidden)return null;const $=pd(x),U=tCe(x),B=A||T||t||n||i||r,I=n?J=>n(J,{...w.userNode}):void 0,X=i?J=>i(J,{...w.userNode}):void 0,q=r?J=>r(J,{...w.userNode}):void 0,D=s?J=>s(J,{...w.userNode}):void 0,H=a?J=>a(J,{...w.userNode}):void 0,re=J=>{const{selectNodesOnDrag:ie,nodeDragThreshold:ue}=M.getState();A&&(!ie||!T||ue>0)&&kP({id:e,store:M,nodeRef:P}),t&&t(J,{...w.userNode})},fe=J=>{if(!(hte(J.nativeEvent)||g)){if(nte.includes(J.key)&&A){const ie=J.key==="Escape";kP({id:e,store:M,unselect:ie,nodeRef:P})}else if(T&&x.selected&&Object.prototype.hasOwnProperty.call(Ck,J.key)){J.preventDefault();const{ariaLabelConfig:ie}=M.getState();M.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:J.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),j({direction:Ck[J.key],factor:J.shiftKey?4:1})}}},Ae=()=>{var Ee;if(g||!((Ee=P.current)!=null&&Ee.matches(":focus-visible")))return;const{transform:J,width:ie,height:ue,autoPanOnNodeFocus:ye,setCenter:Se}=M.getState();if(!ye)return;f$(new Map([[e,x]]),{x:0,y:0,width:ie,height:ue},J,!0).length>0||Se(x.position.x+$.width/2,x.position.y+$.height/2,{zoom:J[2]})};return l.jsx("div",{className:Yr(["react-flow__node",`react-flow__node-${S}`,{[p]:T},x.className,{selected:x.selected,selectable:A,parent:E,draggable:T,dragging:Q}]),ref:P,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:B?"all":"none",visibility:L?"visible":"hidden",...x.style,...U},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:X,onMouseLeave:q,onContextMenu:D,onClick:re,onDoubleClick:H,onKeyDown:C?fe:void 0,tabIndex:C?0:void 0,onFocus:C?Ae:void 0,role:x.ariaRole??(C?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Lte}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:l.jsx(H2e,{value:e,children:l.jsx(k,{id:e,data:x.data,type:S,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:x.selected??!1,selectable:A,draggable:T,deletable:x.deletable??!0,isConnectable:N,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:Q,dragHandle:x.dragHandle,zIndex:w.z,parentId:x.parentId,...$})})})}var fCe=m.memo(dCe);const hCe=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Yte(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,onError:s}=zn(hCe,cr),a=oCe(e.onlyRenderVisibleElements),o=cCe();return l.jsx("div",{className:"react-flow__nodes",style:D_,children:a.map(c=>l.jsx(fCe,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:s},c))})}Yte.displayName="NodeRenderer";const pCe=m.memo(Yte);function mCe(e){return zn(m.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const s=n.nodeLookup.get(r.source),a=n.nodeLookup.get(r.target);s&&a&&KAe({sourceNode:s,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),cr)}const gCe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return l.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},bCe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return l.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bU={[cx.Arrow]:gCe,[cx.ArrowClosed]:bCe};function OCe(e){const t=ur();return m.useMemo(()=>{var r,s;return Object.prototype.hasOwnProperty.call(bU,e)?bU[e]:((s=(r=t.getState()).onError)==null||s.call(r,"009",$l.error009(e)),null)},[e])}const yCe=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const c=OCe(t);return c?l.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:o,refX:"0",refY:"0",children:l.jsx(c,{color:n,strokeWidth:a})}):null},Gte=({defaultColor:e,rfId:t})=>{const n=zn(s=>s.edges),i=zn(s=>s.defaultEdgeOptions),r=m.useMemo(()=>aNe(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?l.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:l.jsx("defs",{children:r.map(s=>l.jsx(yCe,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};Gte.displayName="MarkerDefinitions";var xCe=m.memo(Gte);function Wte({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:c,className:u,...d}){const[f,h]=m.useState({x:1,y:0,width:0,height:0}),p=Yr(["react-flow__edge-textwrapper",u]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const b=g.current.getBBox();h({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?l.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...d,children:[r&&l.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:o,ry:o}),l.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:i,children:n}),c]}):null}Wte.displayName="EdgeText";const vCe=m.memo(Wte);function A1({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return l.jsxs(l.Fragment,{children:[l.jsx("path",{...d,d:e,fill:"none",className:Yr(["react-flow__edge-path",d.className])}),u?l.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,i&&jl(t)&&jl(n)?l.jsx(vCe,{x:t,y:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c}):null]})}function OU({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===St.Left||e===St.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function Zte({sourceX:e,sourceY:t,sourcePosition:n=St.Bottom,targetX:i,targetY:r,targetPosition:s=St.Top}){const[a,o]=OU({pos:n,x1:e,y1:t,x2:i,y2:r}),[c,u]=OU({pos:s,x1:i,y1:r,x2:e,y2:t}),[d,f,h,p]=mte({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:o,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${o} ${c},${u} ${i},${r}`,d,f,h,p]}function Kte(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:a,targetPosition:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:O})=>{const[v,x,w]=Zte({sourceX:n,sourceY:i,sourcePosition:a,targetX:r,targetY:s,targetPosition:o}),E=e.isInternal?void 0:t;return l.jsx(A1,{id:E,path:v,labelX:x,labelY:w,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:O})})}const wCe=Kte({isInternal:!1}),Jte=Kte({isInternal:!0});wCe.displayName="SimpleBezierEdge";Jte.displayName="SimpleBezierEdgeInternal";function ene(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,sourcePosition:p=St.Bottom,targetPosition:g=St.Top,markerEnd:b,markerStart:y,pathOptions:O,interactionWidth:v})=>{const[x,w,E]=Nk({sourceX:n,sourceY:i,sourcePosition:p,targetX:r,targetY:s,targetPosition:g,borderRadius:O==null?void 0:O.borderRadius,offset:O==null?void 0:O.offset,stepPosition:O==null?void 0:O.stepPosition}),S=e.isInternal?void 0:t;return l.jsx(A1,{id:S,path:x,labelX:w,labelY:E,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:b,markerStart:y,interactionWidth:v})})}const tne=ene({isInternal:!1}),nne=ene({isInternal:!0});tne.displayName="SmoothStepEdge";nne.displayName="SmoothStepEdgeInternal";function ine(e){return m.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return l.jsx(tne,{...n,id:i,pathOptions:m.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const SCe=ine({isInternal:!1}),rne=ine({isInternal:!0});SCe.displayName="StepEdge";rne.displayName="StepEdgeInternal";function sne(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:g,interactionWidth:b})=>{const[y,O,v]=Ote({sourceX:n,sourceY:i,targetX:r,targetY:s}),x=e.isInternal?void 0:t;return l.jsx(A1,{id:x,path:y,labelX:O,labelY:v,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:g,interactionWidth:b})})}const ECe=sne({isInternal:!1}),ane=sne({isInternal:!0});ECe.displayName="StraightEdge";ane.displayName="StraightEdgeInternal";function one(e){return m.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:a=St.Bottom,targetPosition:o=St.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,pathOptions:O,interactionWidth:v})=>{const[x,w,E]=gte({sourceX:n,sourceY:i,sourcePosition:a,targetX:r,targetY:s,targetPosition:o,curvature:O==null?void 0:O.curvature}),S=e.isInternal?void 0:t;return l.jsx(A1,{id:S,path:x,labelX:w,labelY:E,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:y,interactionWidth:v})})}const kCe=one({isInternal:!1}),lne=one({isInternal:!0});kCe.displayName="BezierEdge";lne.displayName="BezierEdgeInternal";const yU={default:lne,straight:ane,step:rne,smoothstep:nne,simplebezier:Jte},xU={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},TCe=(e,t,n)=>n===St.Left?e-t:n===St.Right?e+t:e,_Ce=(e,t,n)=>n===St.Top?e-t:n===St.Bottom?e+t:e,vU="react-flow__edgeupdater";function wU({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:s,onMouseOut:a,type:o}){return l.jsx("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:a,className:Yr([vU,`${vU}-${o}`]),cx:TCe(t,i,e),cy:_Ce(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function ACe({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:s,targetY:a,sourcePosition:o,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:h,setUpdateHover:p}){const g=ur(),b=(w,E)=>{if(w.button!==0)return;const{autoPanOnConnect:S,domNode:k,connectionMode:T,connectionRadius:A,lib:N,onConnectStart:C,cancelConnection:M,nodeLookup:L,rfId:P,panBy:Q,updateConnection:j}=g.getState(),$=E.type==="target",U=(X,q)=>{h(!1),f==null||f(X,n,E.type,q)},B=X=>u==null?void 0:u(n,X),I=(X,q)=>{h(!0),d==null||d(w,n,E.type),C==null||C(X,q)};EP.onPointerDown(w.nativeEvent,{autoPanOnConnect:S,connectionMode:T,connectionRadius:A,domNode:k,handleId:E.id,nodeId:E.nodeId,nodeLookup:L,isTarget:$,edgeUpdaterType:E.type,lib:N,flowId:P,cancelConnection:M,panBy:Q,isValidConnection:(...X)=>{var q,D;return((D=(q=g.getState()).isValidConnection)==null?void 0:D.call(q,...X))??!0},onConnect:B,onConnectStart:I,onConnectEnd:(...X)=>{var q,D;return(D=(q=g.getState()).onConnectEnd)==null?void 0:D.call(q,...X)},onReconnectEnd:U,updateConnection:j,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>b(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),O=w=>b(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>p(!0),x=()=>p(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx(wU,{position:o,centerX:i,centerY:r,radius:t,onMouseDown:y,onMouseEnter:v,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&l.jsx(wU,{position:c,centerX:s,centerY:a,radius:t,onMouseDown:O,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function NCe({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:s,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,rfId:g,edgeTypes:b,noPanClassName:y,onError:O,disableKeyboardA11y:v}){let x=zn(Se=>Se.edgeLookup.get(e));const w=zn(Se=>Se.defaultEdgeOptions);x=w?{...w,...x}:x;let E=x.type||"default",S=(b==null?void 0:b[E])||yU[E];S===void 0&&(O==null||O("011",$l.error011(E)),E="default",S=(b==null?void 0:b.default)||yU.default);const k=!!(x.focusable||t&&typeof x.focusable>"u"),T=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),A=!!(x.selectable||i&&typeof x.selectable>"u"),N=m.useRef(null),[C,M]=m.useState(!1),[L,P]=m.useState(!1),Q=ur(),{zIndex:j,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q}=zn(m.useCallback(Se=>{const Re=Se.nodeLookup.get(x.source),Ee=Se.nodeLookup.get(x.target);if(!Re||!Ee)return{zIndex:x.zIndex,...xU};const me=sNe({id:e,sourceNode:Re,targetNode:Ee,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:Se.connectionMode,onError:O});return{zIndex:ZAe({selected:x.selected,zIndex:x.zIndex,sourceNode:Re,targetNode:Ee,elevateOnSelect:Se.elevateEdgesOnSelect,zIndexMode:Se.zIndexMode}),...me||xU}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),cr),D=m.useMemo(()=>x.markerStart?`url('#${wP(x.markerStart,g)}')`:void 0,[x.markerStart,g]),H=m.useMemo(()=>x.markerEnd?`url('#${wP(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||$===null||U===null||B===null||I===null)return null;const re=Se=>{var oe;const{addSelectedEdges:Re,unselectNodesAndEdges:Ee,multiSelectionActive:me}=Q.getState();A&&(Q.setState({nodesSelectionActive:!1}),x.selected&&me?(Ee({nodes:[],edges:[x]}),(oe=N.current)==null||oe.blur()):Re([e])),r&&r(Se,x)},fe=s?Se=>{s(Se,{...x})}:void 0,Ae=a?Se=>{a(Se,{...x})}:void 0,J=o?Se=>{o(Se,{...x})}:void 0,ie=c?Se=>{c(Se,{...x})}:void 0,ue=u?Se=>{u(Se,{...x})}:void 0,ye=Se=>{var Re;if(!v&&nte.includes(Se.key)&&A){const{unselectNodesAndEdges:Ee,addSelectedEdges:me}=Q.getState();Se.key==="Escape"?((Re=N.current)==null||Re.blur(),Ee({edges:[x]})):me([e])}};return l.jsx("svg",{style:{zIndex:j},children:l.jsxs("g",{className:Yr(["react-flow__edge",`react-flow__edge-${E}`,x.className,y,{selected:x.selected,animated:x.animated,inactive:!A&&!r,updating:C,selectable:A}]),onClick:re,onDoubleClick:fe,onContextMenu:Ae,onMouseEnter:J,onMouseMove:ie,onMouseLeave:ue,onKeyDown:k?ye:void 0,tabIndex:k?0:void 0,role:x.ariaRole??(k?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":k?`${Dte}-${g}`:void 0,ref:N,...x.domAttributes,children:[!L&&l.jsx(S,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:A,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:D,markerEnd:H,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),T&&l.jsx(ACe,{edge:x,isReconnectable:T,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,sourceX:$,sourceY:U,targetX:B,targetY:I,sourcePosition:X,targetPosition:q,setUpdateHover:M,setReconnecting:P})]})})}var CCe=m.memo(NCe);const jCe=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function cne({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:s,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:h,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:y,edgesReconnectable:O,elementsSelectable:v,onError:x}=zn(jCe,cr),w=mCe(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(xCe,{defaultColor:e,rfId:n}),w.map(E=>l.jsx(CCe,{id:E,edgesFocusable:y,edgesReconnectable:O,elementsSelectable:v,noPanClassName:r,onReconnect:s,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:h,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:i,disableKeyboardA11y:b},E))]})}cne.displayName="EdgeRenderer";const RCe=m.memo(cne),ICe=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function PCe({children:e}){const t=zn(ICe);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function MCe(e){const t=L_(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const LCe=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function DCe(e){const t=zn(LCe),n=ur();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function $Ce(e){return e.connection.inProgress?{...e.connection,to:X0(e.connection.to,e.transform)}:{...e.connection}}function QCe(e){return $Ce}function BCe(e){const t=QCe();return zn(t,cr)}const UCe=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function zCe({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:s,height:a,isValid:o,inProgress:c}=zn(UCe,cr);return!(s&&r&&c)?null:l.jsx("svg",{style:e,width:s,height:a,className:"react-flow__connectionline react-flow__container",children:l.jsx("g",{className:Yr(["react-flow__connection",ste(o)]),children:l.jsx(une,{style:t,type:n,CustomComponent:i,isValid:o})})})}const une=({style:e,type:t=Kd.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:s,fromNode:a,fromHandle:o,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:h,pointer:p}=BCe();if(!r)return;if(n)return l.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:o,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:h,connectionStatus:ste(i),toNode:d,toHandle:f,pointer:p});let g="";const b={sourceX:s.x,sourceY:s.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case Kd.Bezier:[g]=gte(b);break;case Kd.SimpleBezier:[g]=Zte(b);break;case Kd.Step:[g]=Nk({...b,borderRadius:0});break;case Kd.SmoothStep:[g]=Nk(b);break;default:[g]=Ote(b)}return l.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};une.displayName="ConnectionLine";const FCe={};function SU(e=FCe){m.useRef(e),ur(),m.useEffect(()=>{},[e])}function VCe(){ur(),m.useRef(!1),m.useEffect(()=>{},[])}function dne({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:a,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:h,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:y,connectionLineContainerStyle:O,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:k,deleteKeyCode:T,onlyRenderVisibleElements:A,elementsSelectable:N,defaultViewport:C,translateExtent:M,minZoom:L,maxZoom:P,preventScrolling:Q,defaultMarkerColor:j,zoomOnScroll:$,zoomOnPinch:U,panOnScroll:B,panOnScrollSpeed:I,panOnScrollMode:X,zoomOnDoubleClick:q,panOnDrag:D,autoPanOnSelection:H,onPaneClick:re,onPaneMouseEnter:fe,onPaneMouseMove:Ae,onPaneMouseLeave:J,onPaneScroll:ie,onPaneContextMenu:ue,paneClickDistance:ye,nodeClickDistance:Se,onEdgeContextMenu:Re,onEdgeMouseEnter:Ee,onEdgeMouseMove:me,onEdgeMouseLeave:oe,reconnectRadius:Ne,onReconnect:Oe,onReconnectStart:Ve,onReconnectEnd:We,noDragClassName:De,noWheelClassName:mt,noPanClassName:at,disableKeyboardA11y:Rt,nodeExtent:qe,rfId:W,viewport:K,onViewportChange:ae}){return SU(e),SU(t),VCe(),MCe(n),DCe(K),l.jsx(sCe,{onPaneClick:re,onPaneMouseEnter:fe,onPaneMouseMove:Ae,onPaneMouseLeave:J,onPaneContextMenu:ue,onPaneScroll:ie,paneClickDistance:ye,deleteKeyCode:T,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:N,zoomOnScroll:$,zoomOnPinch:U,zoomOnDoubleClick:q,panOnScroll:B,panOnScrollSpeed:I,panOnScrollMode:X,panOnDrag:D,autoPanOnSelection:H,defaultViewport:C,translateExtent:M,minZoom:L,maxZoom:P,onSelectionContextMenu:f,preventScrolling:Q,noDragClassName:De,noWheelClassName:mt,noPanClassName:at,disableKeyboardA11y:Rt,onViewportChange:ae,isControlledViewport:!!K,children:l.jsxs(PCe,{children:[l.jsx(RCe,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:a,onReconnect:Oe,onReconnectStart:Ve,onReconnectEnd:We,onlyRenderVisibleElements:A,onEdgeContextMenu:Re,onEdgeMouseEnter:Ee,onEdgeMouseMove:me,onEdgeMouseLeave:oe,reconnectRadius:Ne,defaultMarkerColor:j,noPanClassName:at,disableKeyboardA11y:Rt,rfId:W}),l.jsx(zCe,{style:b,type:g,component:y,containerStyle:O}),l.jsx("div",{className:"react-flow__edgelabel-renderer"}),l.jsx(pCe,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:s,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:Se,onlyRenderVisibleElements:A,noPanClassName:at,noDragClassName:De,disableKeyboardA11y:Rt,nodeExtent:qe,rfId:W}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}dne.displayName="GraphView";const XCe=m.memo(dne),qCe=ute(),EU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:h="basic"}={})=>{const p=new Map,g=new Map,b=new Map,y=new Map,O=i??t??[],v=n??e??[],x=d??[0,0],w=f??ox;vte(b,y,O);const{nodesInitialized:E}=SP(v,p,g,{nodeOrigin:x,nodeExtent:w,zIndexMode:h});let S=[0,0,1];if(a&&r&&s){const k=T1(p,{filter:C=>!!((C.width||C.initialWidth)&&(C.height||C.initialHeight))}),{x:T,y:A,zoom:N}=p$(k,r,s,c,u,(o==null?void 0:o.padding)??.1);S=[T,A,N]}return{rfId:"1",width:r??0,height:s??0,transform:S,nodes:v,nodesInitialized:E,nodeLookup:p,parentLookup:g,edges:O,edgeLookup:y,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ox,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:r0.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:o,fitViewResolver:null,connection:{...rte},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:qCe,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ite,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},HCe=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h})=>l2e((p,g)=>{async function b(){const{nodeLookup:y,panZoom:O,fitViewOptions:v,fitViewResolver:x,width:w,height:E,minZoom:S,maxZoom:k}=g();O&&(await VAe({nodes:y,width:w,height:E,panZoom:O,minZoom:S,maxZoom:k},v),x==null||x.resolve(!0),p({fitViewResolver:null}))}return{...EU({nodes:e,edges:t,width:r,height:s,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:i,zIndexMode:h}),setNodes:y=>{const{nodeLookup:O,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:w,fitViewQueued:E,zIndexMode:S,nodesSelectionActive:k}=g(),{nodesInitialized:T,hasSelectedNodes:A}=SP(y,O,v,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:S}),N=k&&A;E&&T?(b(),p({nodes:y,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:N})):p({nodes:y,nodesInitialized:T,nodesSelectionActive:N})},setEdges:y=>{const{connectionLookup:O,edgeLookup:v}=g();vte(O,v,y),p({edges:y})},setDefaultNodesAndEdges:(y,O)=>{if(y){const{setNodes:v}=g();v(y),p({hasDefaultNodes:!0})}if(O){const{setEdges:v}=g();v(O),p({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:O,nodeLookup:v,parentLookup:x,domNode:w,nodeOrigin:E,nodeExtent:S,debug:k,fitViewQueued:T,zIndexMode:A}=g(),{changes:N,updatedInternals:C}=hNe(y,v,x,w,E,S,A);C&&(cNe(v,x,{nodeOrigin:E,nodeExtent:S,zIndexMode:A}),T?(b(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(N==null?void 0:N.length)>0&&(k&&console.log("React Flow: trigger node changes",N),O==null||O(N)))},updateNodePositions:(y,O=!1)=>{const v=[];let x=[];const{nodeLookup:w,triggerNodeChanges:E,connection:S,updateConnection:k,onNodesChangeMiddlewareMap:T}=g();for(const[A,N]of y){const C=w.get(A),M=!!(C!=null&&C.expandParent&&(C!=null&&C.parentId)&&(N!=null&&N.position)),L={id:A,type:"position",position:M?{x:Math.max(0,N.position.x),y:Math.max(0,N.position.y)}:N.position,dragging:O};if(C&&S.inProgress&&S.fromNode.id===C.id){const P=xp(C,S.fromHandle,St.Left,!0);k({...S,from:P})}M&&C.parentId&&v.push({id:A,parentId:C.parentId,rect:{...N.internals.positionAbsolute,width:N.measured.width??0,height:N.measured.height??0}}),x.push(L)}if(v.length>0){const{parentLookup:A,nodeOrigin:N}=g(),C=v$(v,w,A,N);x.push(...C)}for(const A of T.values())x=A(x);E(x)},triggerNodeChanges:y=>{const{onNodesChange:O,setNodes:v,nodes:x,hasDefaultNodes:w,debug:E}=g();if(y!=null&&y.length){if(w){const S=Bte(y,x);v(S)}E&&console.log("React Flow: trigger node changes",y),O==null||O(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:O,setEdges:v,edges:x,hasDefaultEdges:w,debug:E}=g();if(y!=null&&y.length){if(w){const S=Ute(y,x);v(S)}E&&console.log("React Flow: trigger edge changes",y),O==null||O(y)}},addSelectedNodes:y=>{const{multiSelectionActive:O,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(O){const S=y.map(k=>Ah(k,!0));w(S);return}w(eg(x,new Set([...y]),!0)),E(eg(v))},addSelectedEdges:y=>{const{multiSelectionActive:O,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(O){const S=y.map(k=>Ah(k,!0));E(S);return}E(eg(v,new Set([...y]))),w(eg(x,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:O}={})=>{const{edges:v,nodes:x,nodeLookup:w,triggerNodeChanges:E,triggerEdgeChanges:S}=g(),k=y||x,T=O||v,A=[];for(const C of k){if(!C.selected)continue;const M=w.get(C.id);M&&(M.selected=!1),A.push(Ah(C.id,!1))}const N=[];for(const C of T)C.selected&&N.push(Ah(C.id,!1));E(A),S(N)},setMinZoom:y=>{const{panZoom:O,maxZoom:v}=g();O==null||O.setScaleExtent([y,v]),p({minZoom:y})},setMaxZoom:y=>{const{panZoom:O,minZoom:v}=g();O==null||O.setScaleExtent([v,y]),p({maxZoom:y})},setTranslateExtent:y=>{var O;(O=g().panZoom)==null||O.setTranslateExtent(y),p({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:O,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:w}=g();if(!w)return;const E=O.reduce((k,T)=>T.selected?[...k,Ah(T.id,!1)]:k,[]),S=y.reduce((k,T)=>T.selected?[...k,Ah(T.id,!1)]:k,[]);v(E),x(S)},setNodeExtent:y=>{const{nodes:O,nodeLookup:v,parentLookup:x,nodeOrigin:w,elevateNodesOnSelect:E,nodeExtent:S,zIndexMode:k}=g();y[0][0]===S[0][0]&&y[0][1]===S[0][1]&&y[1][0]===S[1][0]&&y[1][1]===S[1][1]||(SP(O,v,x,{nodeOrigin:w,nodeExtent:y,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:k}),p({nodeExtent:y}))},panBy:y=>{const{transform:O,width:v,height:x,panZoom:w,translateExtent:E}=g();return pNe({delta:y,panZoom:w,transform:O,translateExtent:E,width:v,height:x})},setCenter:async(y,O,v)=>{const{width:x,height:w,maxZoom:E,panZoom:S}=g();if(!S)return!1;const k=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:E;return await S.setViewport({x:x/2-y*k,y:w/2-O*k,zoom:k},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),!0},cancelConnection:()=>{p({connection:{...rte}})},updateConnection:y=>{p({connection:y})},reset:()=>p({...EU()})}},Object.is);function fne({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:s,initialMinZoom:a,initialMaxZoom:o,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:p}){const[g]=m.useState(()=>HCe({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:u,minZoom:a,maxZoom:o,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:h}));return l.jsx(c2e,{value:g,children:l.jsx(P2e,{children:p})})}function YCe({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p}){return m.useContext(P_)?l.jsx(l.Fragment,{children:e}):l.jsx(fne,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:s,initialHeight:a,fitView:o,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p,children:e})}const GCe={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function WCe({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:s,edgeTypes:a,onNodeClick:o,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:p,onConnectStart:g,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:O,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:S,onNodeDragStart:k,onNodeDrag:T,onNodeDragStop:A,onNodesDelete:N,onEdgesDelete:C,onDelete:M,onSelectionChange:L,onSelectionDragStart:P,onSelectionDrag:Q,onSelectionDragStop:j,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:B,onBeforeDelete:I,connectionMode:X,connectionLineType:q=Kd.Bezier,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:re,deleteKeyCode:fe="Backspace",selectionKeyCode:Ae="Shift",selectionOnDrag:J=!1,selectionMode:ie=lx.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:ye=dx()?"Meta":"Control",zoomActivationKeyCode:Se=dx()?"Meta":"Control",snapToGrid:Re,snapGrid:Ee,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:oe,nodesDraggable:Ne,autoPanOnNodeFocus:Oe,nodesConnectable:Ve,nodesFocusable:We,nodeOrigin:De=$te,edgesFocusable:mt,edgesReconnectable:at,elementsSelectable:Rt=!0,defaultViewport:qe=w2e,minZoom:W=.5,maxZoom:K=2,translateExtent:ae=ox,preventScrolling:pe=!0,nodeExtent:z,defaultMarkerColor:ve="#b1b1b7",zoomOnScroll:Be=!0,zoomOnPinch:Je=!0,panOnScroll:kt=!1,panOnScrollSpeed:Mt=.5,panOnScrollMode:Tt=rp.Free,zoomOnDoubleClick:dt=!0,panOnDrag:ge=!0,onPaneClick:lt,onPaneMouseEnter:Ge,onPaneMouseMove:vt,onPaneMouseLeave:_t,onPaneScroll:Bt,onPaneContextMenu:je,paneClickDistance:Ze=1,nodeClickDistance:Ie=0,children:Wt,onReconnect:dn,onReconnectStart:Qt,onReconnectEnd:Yt,onEdgeContextMenu:Jt,onEdgeDoubleClick:Ft,onEdgeMouseEnter:Ce,onEdgeMouseMove:et,onEdgeMouseLeave:wt,reconnectRadius:yn=10,onNodesChange:on,onEdgesChange:hi,noDragClassName:Pe="nodrag",noWheelClassName:st="nowheel",noPanClassName:At="nopan",fitView:Ut,fitViewOptions:kn,connectOnClick:wn,attributionPosition:Ai,proOptions:Gn,defaultEdgeOptions:xn,elevateNodesOnSelect:de=!0,elevateEdgesOnSelect:Le=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:gt,autoPanOnNodeDrag:ln,autoPanOnSelection:Sn=!0,autoPanSpeed:In,connectionRadius:Ni,isValidConnection:Pn,onError:Vt,style:Ji,id:fn,nodeDragThreshold:pi,connectionDragThreshold:ti,viewport:vi,onViewportChange:en,width:Ci,height:xs,colorMode:ni="light",debug:Ls,onScroll:er,ariaLabelConfig:Ya,zIndexMode:mr="basic",...gr},ul){const Sa=fn||"1",as=T2e(ni),Mn=m.useCallback(vs=>{vs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),er==null||er(vs)},[er]);return l.jsx("div",{"data-testid":"rf__wrapper",...gr,onScroll:Mn,style:{...Ji,...GCe},ref:ul,className:Yr(["react-flow",r,as]),id:fn,role:"application",children:l.jsxs(YCe,{nodes:e,edges:t,width:Ci,height:xs,fitView:Ut,fitViewOptions:kn,minZoom:W,maxZoom:K,nodeOrigin:De,nodeExtent:z,zIndexMode:mr,children:[l.jsx(k2e,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:p,onConnectStart:g,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:O,nodesDraggable:Ne,autoPanOnNodeFocus:Oe,nodesConnectable:Ve,nodesFocusable:We,edgesFocusable:mt,edgesReconnectable:at,elementsSelectable:Rt,elevateNodesOnSelect:de,elevateEdgesOnSelect:Le,minZoom:W,maxZoom:K,nodeExtent:z,onNodesChange:on,onEdgesChange:hi,snapToGrid:Re,snapGrid:Ee,connectionMode:X,translateExtent:ae,connectOnClick:wn,defaultEdgeOptions:xn,fitView:Ut,fitViewOptions:kn,onNodesDelete:N,onEdgesDelete:C,onDelete:M,onNodeDragStart:k,onNodeDrag:T,onNodeDragStop:A,onSelectionDrag:Q,onSelectionDragStart:P,onSelectionDragStop:j,onMove:d,onMoveStart:f,onMoveEnd:h,noPanClassName:At,nodeOrigin:De,rfId:Sa,autoPanOnConnect:gt,autoPanOnNodeDrag:ln,autoPanSpeed:In,onError:Vt,connectionRadius:Ni,isValidConnection:Pn,selectNodesOnDrag:oe,nodeDragThreshold:pi,connectionDragThreshold:ti,onBeforeDelete:I,debug:Ls,ariaLabelConfig:Ya,zIndexMode:mr}),l.jsx(XCe,{onInit:u,onNodeClick:o,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:a,connectionLineType:q,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:re,selectionKeyCode:Ae,selectionOnDrag:J,selectionMode:ie,deleteKeyCode:fe,multiSelectionKeyCode:ye,panActivationKeyCode:ue,zoomActivationKeyCode:Se,onlyRenderVisibleElements:me,defaultViewport:qe,translateExtent:ae,minZoom:W,maxZoom:K,preventScrolling:pe,zoomOnScroll:Be,zoomOnPinch:Je,zoomOnDoubleClick:dt,panOnScroll:kt,panOnScrollSpeed:Mt,panOnScrollMode:Tt,panOnDrag:ge,autoPanOnSelection:Sn,onPaneClick:lt,onPaneMouseEnter:Ge,onPaneMouseMove:vt,onPaneMouseLeave:_t,onPaneScroll:Bt,onPaneContextMenu:je,paneClickDistance:Ze,nodeClickDistance:Ie,onSelectionContextMenu:$,onSelectionStart:U,onSelectionEnd:B,onReconnect:dn,onReconnectStart:Qt,onReconnectEnd:Yt,onEdgeContextMenu:Jt,onEdgeDoubleClick:Ft,onEdgeMouseEnter:Ce,onEdgeMouseMove:et,onEdgeMouseLeave:wt,reconnectRadius:yn,defaultMarkerColor:ve,noDragClassName:Pe,noWheelClassName:st,noPanClassName:At,rfId:Sa,disableKeyboardA11y:ut,nodeExtent:z,viewport:vi,onViewportChange:en}),l.jsx(v2e,{onSelectionChange:L}),Wt,l.jsx(g2e,{proOptions:Gn,position:Ai}),l.jsx(m2e,{rfId:Sa,disableKeyboardA11y:ut})]})})}var ZCe=zte(WCe);const KCe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function JCe({children:e}){const t=zn(KCe);return t?zi.createPortal(e,t):null}function eje(e){const[t,n]=m.useState(e),i=m.useCallback(r=>n(s=>Bte(r,s)),[]);return[t,n,i]}function tje(e){const[t,n]=m.useState(e),i=m.useCallback(r=>n(s=>Ute(r,s)),[]);return[t,n,i]}const nje=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(const[,{internals:n}]of t.nodeLookup)if(n.handleBounds===void 0||!m$(n.userNode))return!1;return!0};function ije(e={includeHiddenNodes:!1}){return zn(nje(e))}function rje({dimensions:e,lineWidth:t,variant:n,className:i}){return l.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Yr(["react-flow__background-pattern",n,i])})}function sje({radius:e,className:t}){return l.jsx("circle",{cx:e,cy:e,r:e,className:Yr(["react-flow__background-pattern","dots",t])})}var vf;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(vf||(vf={}));const aje={[vf.Dots]:1,[vf.Lines]:1,[vf.Cross]:6},oje=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hne({id:e,variant:t=vf.Dots,gap:n=20,size:i,lineWidth:r=1,offset:s=0,color:a,bgColor:o,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:h,patternId:p}=zn(oje,cr),g=i||aje[t],b=t===vf.Dots,y=t===vf.Cross,O=Array.isArray(n)?n:[n,n],v=[O[0]*h[2]||1,O[1]*h[2]||1],x=g*h[2],w=Array.isArray(s)?s:[s,s],E=y?[x,x]:v,S=[w[0]*h[2]||1+E[0]/2,w[1]*h[2]||1+E[1]/2],k=`${p}${e||""}`;return l.jsxs("svg",{className:Yr(["react-flow__background",u]),style:{...c,...D_,"--xy-background-color-props":o,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[l.jsx("pattern",{id:k,x:h[0]%v[0],y:h[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?l.jsx(sje,{radius:x/2,className:d}):l.jsx(rje,{dimensions:E,lineWidth:r,variant:t,className:d})}),l.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}hne.displayName="Background";const lje=m.memo(hne);function cje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function uje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function fje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function hje(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function pw({children:e,className:t,...n}){return l.jsx("button",{type:"button",className:Yr(["react-flow__controls-button",t]),...n,children:e})}const pje=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function pne({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:h="vertical","aria-label":p}){const g=ur(),{isInteractive:b,minZoomReached:y,maxZoomReached:O,ariaLabelConfig:v}=zn(pje,cr),{zoomIn:x,zoomOut:w,fitView:E}=L_(),S=()=>{x(),s==null||s()},k=()=>{w(),a==null||a()},T=()=>{E(r),o==null||o()},A=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},N=h==="horizontal"?"horizontal":"vertical";return l.jsxs(M_,{className:Yr(["react-flow__controls",N,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??v["controls.ariaLabel"],children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(pw,{onClick:S,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:O,children:l.jsx(cje,{})}),l.jsx(pw,{onClick:k,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:y,children:l.jsx(uje,{})})]}),n&&l.jsx(pw,{className:"react-flow__controls-fitview",onClick:T,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:l.jsx(dje,{})}),i&&l.jsx(pw,{className:"react-flow__controls-interactive",onClick:A,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?l.jsx(hje,{}):l.jsx(fje,{})}),d]})}pne.displayName="Controls";const mje=m.memo(pne);function gje({id:e,x:t,y:n,width:i,height:r,style:s,color:a,strokeColor:o,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:h,onClick:p}){const{background:g,backgroundColor:b}=s||{},y=a||g||b;return l.jsx("rect",{className:Yr(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:d,ry:d,width:i,height:r,style:{fill:y,stroke:o,strokeWidth:c},shapeRendering:f,onClick:p?O=>p(O,e):void 0})}const bje=m.memo(gje),Oje=e=>e.nodes.map(t=>t.id),Z2=e=>e instanceof Function?e:()=>e;function yje({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:s=bje,onClick:a}){const o=zn(Oje,cr),c=Z2(t),u=Z2(e),d=Z2(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return l.jsx(l.Fragment,{children:o.map(h=>l.jsx(vje,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:s,onClick:a,shapeRendering:f},h))})}function xje({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:o,onClick:c}){const{node:u,x:d,y:f,width:h,height:p}=zn(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const y=b.internals.userNode,{x:O,y:v}=b.internals.positionAbsolute,{width:x,height:w}=pd(y);return{node:y,x:O,y:v,width:x,height:w}},cr);return!u||u.hidden||!m$(u)?null:l.jsx(o,{x:d,y:f,width:h,height:p,style:u.style,selected:!!u.selected,className:i(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:s,shapeRendering:a,onClick:c,id:u.id})}const vje=m.memo(xje);var wje=m.memo(yje);const Sje=200,Eje=150,kje=e=>!e.hidden,Tje=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?cte(T1(e.nodeLookup,{filter:kje}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_je="react-flow__minimap-desc";function mne({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:o,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:h="bottom-right",onClick:p,onNodeClick:g,pannable:b=!1,zoomable:y=!1,ariaLabel:O,inversePan:v,zoomStep:x=1,offsetScale:w=5}){const E=ur(),S=m.useRef(null),{boundingRect:k,viewBB:T,rfId:A,panZoom:N,translateExtent:C,flowWidth:M,flowHeight:L,ariaLabelConfig:P}=zn(Tje,cr),Q=(e==null?void 0:e.width)??Sje,j=(e==null?void 0:e.height)??Eje,$=k.width/Q,U=k.height/j,B=Math.max($,U),I=B*Q,X=B*j,q=w*B,D=k.x-(I-k.width)/2-q,H=k.y-(X-k.height)/2-q,re=I+q*2,fe=X+q*2,Ae=`${_je}-${A}`,J=m.useRef(0),ie=m.useRef();J.current=B,m.useEffect(()=>{if(S.current&&N)return ie.current=SNe({domNode:S.current,panZoom:N,getTransform:()=>E.getState().transform,getViewScale:()=>J.current}),()=>{var Re;(Re=ie.current)==null||Re.destroy()}},[N]),m.useEffect(()=>{var Re;(Re=ie.current)==null||Re.update({translateExtent:C,width:M,height:L,inversePan:v,pannable:b,zoomStep:x,zoomable:y})},[b,y,v,x,C,M,L]);const ue=p?Re=>{var oe;const[Ee,me]=((oe=ie.current)==null?void 0:oe.pointer(Re))||[0,0];p(Re,{x:Ee,y:me})}:void 0,ye=g?m.useCallback((Re,Ee)=>{const me=E.getState().nodeLookup.get(Ee).internals.userNode;g(Re,me)},[]):void 0,Se=O??P["minimap.ariaLabel"];return l.jsx(M_,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*B:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Yr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:l.jsxs("svg",{width:Q,height:j,viewBox:`${D} ${H} ${re} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Ae,ref:S,onClick:ue,children:[Se&&l.jsx("title",{id:Ae,children:Se}),l.jsx(wje,{onClick:ye,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:a,nodeComponent:o}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${D-q},${H-q}h${re+q*2}v${fe+q*2}h${-re-q*2}z + M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}mne.displayName="MiniMap";m.memo(mne);const Aje=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Nje={[l0.Line]:"right",[l0.Handle]:"bottom-right"};function Cje({nodeId:e,position:t,variant:n=l0.Handle,className:i,style:r=void 0,children:s,color:a,minWidth:o=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:p=!0,shouldResize:g,onResizeStart:b,onResize:y,onResizeEnd:O}){const v=qte(),x=typeof e=="string"?e:v,w=ur(),E=m.useRef(null),S=n===l0.Handle,k=zn(m.useCallback(Aje(S&&p),[S,p]),cr),T=m.useRef(null),A=t??Nje[n];m.useEffect(()=>{if(!(!E.current||!x))return T.current||(T.current=LNe({domNode:E.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:C,transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q,domNode:j}=w.getState();return{nodeLookup:C,transform:M,snapGrid:L,snapToGrid:P,nodeOrigin:Q,paneDomNode:j}},onChange:(C,M)=>{const{triggerNodeChanges:L,nodeLookup:P,parentLookup:Q,nodeOrigin:j}=w.getState(),$=[],U={x:C.x,y:C.y},B=P.get(x);if(B&&B.expandParent&&B.parentId){const I=B.origin??j,X=C.width??B.measured.width??0,q=C.height??B.measured.height??0,D={id:B.id,parentId:B.parentId,rect:{width:X,height:q,...dte({x:C.x??B.position.x,y:C.y??B.position.y},{width:X,height:q},B.parentId,P,I)}},H=v$([D],P,Q,j);$.push(...H),U.x=C.x?Math.max(I[0]*X,C.x):void 0,U.y=C.y?Math.max(I[1]*q,C.y):void 0}if(U.x!==void 0&&U.y!==void 0){const I={id:x,type:"position",position:{...U}};$.push(I)}if(C.width!==void 0&&C.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:C.width,height:C.height}};$.push(X)}for(const I of M){const X={...I,type:"position"};$.push(X)}L($)},onEnd:({width:C,height:M})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:C,height:M}};w.getState().triggerNodeChanges([L])}})),T.current.update({controlPosition:A,boundaries:{minWidth:o,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:h,onResizeStart:b,onResize:y,onResizeEnd:O,shouldResize:g}),()=>{var C;(C=T.current)==null||C.destroy()}},[A,o,c,u,d,f,b,y,O,g]);const N=A.split("-");return l.jsx("div",{className:Yr(["react-flow__resize-control","nodrag",...N,n,i]),ref:E,style:{...r,scale:k,...a&&{[S?"backgroundColor":"borderColor"]:a}},children:s})}m.memo(Cje);var gne=Object.defineProperty,jje=(e,t,n)=>t in e?gne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rje=(e,t)=>{for(var n in t)gne(e,n,{get:t[n],enumerable:!0})},Ije=(e,t,n)=>jje(e,t+"",n),bne={};Rje(bne,{Graph:()=>al,alg:()=>S$,json:()=>yne,version:()=>Lje});var Pje=Object.defineProperty,One=(e,t)=>{for(var n in t)Pje(e,n,{get:t[n],enumerable:!0})},al=class{constructor(t){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},t&&(this._isDirected="directed"in t?t.directed:!0,this._isMultigraph="multigraph"in t?t.multigraph:!1,this._isCompound="compound"in t?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return typeof t!="function"?this._defaultNodeLabelFn=()=>t:this._defaultNodeLabelFn=t,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(t=>Object.keys(this._in[t]).length===0)}sinks(){return this.nodes().filter(t=>Object.keys(this._out[t]).length===0)}setNodes(t,n){return t.forEach(i=>{n!==void 0?this.setNode(i,n):this.setNode(i)}),this}setNode(t,n){return t in this._nodes?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]="\0",this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return t in this._nodes}removeNode(t){if(t in this._nodes){let n=i=>this.removeEdge(this._edgeObjs[i]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(i=>{this.setParent(i)}),delete this._children[t]),Object.keys(this._in[t]).forEach(n),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n="\0";else{n+="";for(let i=n;i!==void 0;i=this.parent(i))if(i===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}parent(t){if(this._isCompound){let n=this._parent[t];if(n!=="\0")return n}}children(t="\0"){if(this._isCompound){let n=this._children[t];if(n)return Object.keys(n)}else{if(t==="\0")return this.nodes();if(this.hasNode(t))return[]}return[]}predecessors(t){let n=this._preds[t];if(n)return Object.keys(n)}successors(t){let n=this._sucs[t];if(n)return Object.keys(n)}neighbors(t){let n=this.predecessors(t);if(n){let i=new Set(n);for(let r of this.successors(t))i.add(r);return Array.from(i.values())}}isLeaf(t){let n;return this.isDirected()?n=this.successors(t):n=this.neighbors(t),n.length===0}filterNodes(t){let n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,a])=>{t(s)&&n.setNode(s,a)}),Object.values(this._edgeObjs).forEach(s=>{n.hasNode(s.v)&&n.hasNode(s.w)&&n.setEdge(s,this.edge(s))});let i={},r=s=>{let a=this.parent(s);return!a||n.hasNode(a)?(i[s]=a??void 0,a??void 0):a in i?i[a]:r(a)};return this._isCompound&&n.nodes().forEach(s=>n.setParent(s,r(s))),n}setDefaultEdgeLabel(t){return typeof t!="function"?this._defaultEdgeLabelFn=()=>t:this._defaultEdgeLabelFn=t,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,n){return t.reduce((i,r)=>(n!==void 0?this.setEdge(i,r,n):this.setEdge(i,r),r)),this}setEdge(t,n,i,r){let s,a,o,c,u=!1;typeof t=="object"&&t!==null&&"v"in t?(s=t.v,a=t.w,o=t.name,arguments.length===2&&(c=n,u=!0)):(s=t,a=n,o=r,arguments.length>2&&(c=i,u=!0)),s=""+s,a=""+a,o!==void 0&&(o=""+o);let d=NO(this._isDirected,s,a,o);if(d in this._edgeLabels)return u&&(this._edgeLabels[d]=c),this;if(o!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(a),this._edgeLabels[d]=u?c:this._defaultEdgeLabelFn(s,a,o);let f=Mje(this._isDirected,s,a,o);return s=f.v,a=f.w,Object.freeze(f),this._edgeObjs[d]=f,kU(this._preds[a],s),kU(this._sucs[s],a),this._in[a][d]=f,this._out[s][d]=f,this._edgeCount++,this}edge(t,n,i){let r=arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i);return this._edgeLabels[r]}edgeAsObj(t,n,i){let r=arguments.length===1?this.edge(t):this.edge(t,n,i);return typeof r!="object"?{label:r}:r}hasEdge(t,n,i){return(arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i))in this._edgeLabels}removeEdge(t,n,i){let r=arguments.length===1?K2(this._isDirected,t):NO(this._isDirected,t,n,i),s=this._edgeObjs[r];if(s){let a=s.v,o=s.w;delete this._edgeLabels[r],delete this._edgeObjs[r],TU(this._preds[o],a),TU(this._sucs[a],o),delete this._in[o][r],delete this._out[a][r],this._edgeCount--}return this}inEdges(t,n){return this.isDirected()?this.filterEdges(this._in[t],t,n):this.nodeEdges(t,n)}outEdges(t,n){return this.isDirected()?this.filterEdges(this._out[t],t,n):this.nodeEdges(t,n)}nodeEdges(t,n){if(t in this._nodes)return this.filterEdges({...this._in[t],...this._out[t]},t,n)}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}filterEdges(t,n,i){if(!t)return;let r=Object.values(t);return i?r.filter(s=>s.v===n&&s.w===i||s.v===i&&s.w===n):r}};function kU(e,t){e[t]?e[t]++:e[t]=1}function TU(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function NO(e,t,n,i){let r=""+t,s=""+n;if(!e&&r>s){let a=r;r=s,s=a}return r+""+s+""+(i===void 0?"\0":i)}function Mje(e,t,n,i){let r=""+t,s=""+n;if(!e&&r>s){let o=r;r=s,s=o}let a={v:r,w:s};return i&&(a.name=i),a}function K2(e,t){return NO(e,t.v,t.w,t.name)}var Lje="4.0.1",yne={};One(yne,{read:()=>Bje,write:()=>Dje});function Dje(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:$je(e),edges:Qje(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function $je(e){return e.nodes().map(t=>{let n=e.node(t),i=e.parent(t),r={v:t};return n!==void 0&&(r.value=n),i!==void 0&&(r.parent=i),r})}function Qje(e){return e.edges().map(t=>{let n=e.edge(t),i={v:t.v,w:t.w};return t.name!==void 0&&(i.name=t.name),n!==void 0&&(i.value=n),i})}function Bje(e){let t=new al(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var S$={};One(S$,{CycleException:()=>Rk,bellmanFord:()=>xne,components:()=>Fje,dijkstra:()=>jk,dijkstraAll:()=>qje,findCycles:()=>Hje,floydWarshall:()=>Gje,isAcyclic:()=>Zje,postorder:()=>Jje,preorder:()=>eRe,prim:()=>tRe,shortestPaths:()=>nRe,tarjan:()=>wne,topsort:()=>Sne});var Uje=()=>1;function xne(e,t,n,i){return zje(e,String(t),n||Uje,i||function(r){return e.outEdges(r)})}function zje(e,t,n,i){let r={},s,a=0,o=e.nodes(),c=function(f){let h=n(f);r[f.v].distance+he.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,i=String(e);if(!(i in n)){let r=this._arr,s=r.length;return n[i]=s,r.push({key:i,priority:t}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let i=this._arr[n].priority;if(t>i)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${i} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,i=n+1,r=e;n>1,!(t[i].priority1;function jk(e,t,n,i){let r=function(s){return e.outEdges(s)};return Xje(e,String(t),n||Vje,i||r)}function Xje(e,t,n,i){let r={},s=new vne,a,o,c=function(u){let d=u.v!==a?u.v:u.w,f=r[d],h=n(u),p=o.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+u+" Weight: "+h);p0&&(a=s.removeMin(),o=r[a],o.distance!==Number.POSITIVE_INFINITY);)i(a).forEach(c);return r}function qje(e,t,n){return e.nodes().reduce(function(i,r){return i[r]=jk(e,r,t,n),i},{})}function wne(e){let t=0,n=[],i={},r=[];function s(a){let o=i[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),e.successors(a).forEach(function(c){c in i?i[c].onStack&&(o.lowlink=Math.min(o.lowlink,i[c].index)):(s(c),o.lowlink=Math.min(o.lowlink,i[c].lowlink))}),o.lowlink===o.index){let c=[],u;do u=n.pop(),i[u].onStack=!1,c.push(u);while(a!==u);r.push(c)}}return e.nodes().forEach(function(a){a in i||s(a)}),r}function Hje(e){return wne(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Yje=()=>1;function Gje(e,t,n){return Wje(e,t||Yje,n||function(i){return e.outEdges(i)})}function Wje(e,t,n){let i={},r=e.nodes();return r.forEach(function(s){i[s]={},i[s][s]={distance:0,predecessor:""},r.forEach(function(a){s!==a&&(i[s][a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(s).forEach(function(a){let o=a.v===s?a.w:a.v,c=t(a);i[s][o]={distance:c,predecessor:s}})}),r.forEach(function(s){let a=i[s];r.forEach(function(o){let c=i[o];r.forEach(function(u){let d=c[s],f=a[u],h=c[u],p=d.distance+f.distance;p{var c;return(c=e.isDirected()?e.successors(o):e.neighbors(o))!=null?c:[]},a={};return t.forEach(function(o){if(!e.hasNode(o))throw new Error("Graph does not have node: "+o);r=Ene(e,o,n==="post",a,s,i,r)}),r}function Ene(e,t,n,i,r,s,a){return t in i||(i[t]=!0,n||(a=s(a,t)),r(t).forEach(function(o){a=Ene(e,o,n,i,r,s,a)}),n&&(a=s(a,t))),a}function kne(e,t,n){return Kje(e,t,n,function(i,r){return i.push(r),i},[])}function Jje(e,t){return kne(e,t,"post")}function eRe(e,t){return kne(e,t,"pre")}function tRe(e,t){let n=new al,i={},r=new vne,s;function a(c){let u=c.v===s?c.w:c.v,d=r.priority(u);if(d!==void 0){let f=t(c);f0;){if(s=r.removeMin(),s in i)n.setEdge(s,i[s]);else{if(o)throw new Error("Input graph is not connected: "+e);o=!0}e.nodeEdges(s).forEach(a)}return n}function nRe(e,t,n,i){return iRe(e,t,n,i??(r=>{let s=e.outEdges(r);return s??[]}))}function iRe(e,t,n,i){if(n===void 0)return jk(e,t,n,i);let r=!1,s=e.nodes();for(let a=0;at.setNode(n,e.node(n))),e.edges().forEach(n=>{let i=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:i.weight+r.weight,minlen:Math.max(i.minlen,r.minlen)})}),t}function Tne(e){let t=new al({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function _U(e,t){let n=e.x,i=e.y,r=t.x-n,s=t.y-i,a=e.width/2,o=e.height/2;if(!r&&!s)throw new Error("Not possible to find intersection inside of the rectangle");let c,u;return Math.abs(s)*a>Math.abs(r)*o?(s<0&&(o=-o),c=o*r/s,u=o):(r<0&&(a=-a),c=a,u=a*s/r),{x:n+c,y:i+u}}function N1(e){let t=hx(Ane(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let i=e.node(n),r=i.rank;r!==void 0&&(t[r]||(t[r]=[]),t[r][i.order]=n)}),t}function sRe(e){let t=e.nodes().map(i=>{let r=e.node(i).rank;return r===void 0?Number.MAX_VALUE:r}),n=Ac(Math.min,t);e.nodes().forEach(i=>{let r=e.node(i);Object.hasOwn(r,"rank")&&(r.rank-=n)})}function aRe(e){let t=e.nodes().map(a=>e.node(a).rank).filter(a=>a!==void 0),n=Ac(Math.min,t),i=[];e.nodes().forEach(a=>{let o=e.node(a).rank-n;i[o]||(i[o]=[]),i[o].push(a)});let r=0,s=e.graph().nodeRankFactor;Array.from(i).forEach((a,o)=>{a===void 0&&o%s!==0?--r:a!==void 0&&r&&a.forEach(c=>e.node(c).rank+=r)})}function AU(e,t,n,i){let r={width:0,height:0};return arguments.length>=4&&(r.rank=n,r.order=i),q0(e,"border",r,t)}function oRe(e,t=_ne){let n=[];for(let i=0;i_ne){let n=oRe(t);return e(...n.map(i=>e(...i)))}else return e(...t)}function Ane(e){let t=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MIN_VALUE:i});return Ac(Math.max,t)}function lRe(e,t){let n={lhs:[],rhs:[]};return e.forEach(i=>{t(i)?n.lhs.push(i):n.rhs.push(i)}),n}function Nne(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Cne(e,t){return t()}var cRe=0;function E$(e){let t=++cRe;return e+(""+t)}function hx(e,t,n=1){t==null&&(t=e,e=0);let i=s=>sti[t]:n=t,Object.entries(e).reduce((i,[r,s])=>(i[r]=n(s,r),i),{})}function uRe(e,t){return e.reduce((n,i,r)=>(n[i]=t[r],n),{})}var Q_="\0",dRe="3.0.0",fRe=class{constructor(){Ije(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return NU(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&NU(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,hRe)),n=n._prev;return"["+e.join(", ")+"]"}};function NU(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function hRe(e,t){if(e!=="_next"&&e!=="_prev")return t}var pRe=fRe,mRe=()=>1;function gRe(e,t){if(e.nodeCount()<=1)return[];let n=ORe(e,t||mRe);return bRe(n.graph,n.buckets,n.zeroIdx).flatMap(i=>e.outEdges(i.v,i.w)||[])}function bRe(e,t,n){var i;let r=[],s=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)J2(e,t,n,o);for(;o=s.dequeue();)J2(e,t,n,o);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(o=(i=t[c])==null?void 0:i.dequeue(),o){r=r.concat(J2(e,t,n,o,!0)||[]);break}}}return r}function J2(e,t,n,i,r){let s=[],a=r?s:void 0;return(e.inEdges(i.v)||[]).forEach(o=>{let c=e.edge(o),u=e.node(o.v);r&&s.push({v:o.v,w:o.w}),u.out-=c,TP(t,n,u)}),(e.outEdges(i.v)||[]).forEach(o=>{let c=e.edge(o),u=o.w,d=e.node(u);d.in-=c,TP(t,n,d)}),e.removeNode(i.v),a}function ORe(e,t){let n=new al,i=0,r=0;e.nodes().forEach(o=>{n.setNode(o,{v:o,in:0,out:0})}),e.edges().forEach(o=>{let c=n.edge(o.v,o.w)||0,u=t(o),d=c+u;n.setEdge(o.v,o.w,d);let f=n.node(o.v),h=n.node(o.w);r=Math.max(r,f.out+=u),i=Math.max(i,h.in+=u)});let s=yRe(r+i+3).map(()=>new pRe),a=i+1;return n.nodes().forEach(o=>{TP(s,a,n.node(o))}),{graph:n,buckets:s,zeroIdx:a}}function TP(e,t,n){var i,r,s;n.out?n.in?(s=e[n.out-n.in+t])==null||s.enqueue(n):(r=e[e.length-1])==null||r.enqueue(n):(i=e[0])==null||i.enqueue(n)}function yRe(e){let t=[];for(let n=0;n{let i=e.edge(n);e.removeEdge(n),i.forwardName=n.name,i.reversed=!0,e.setEdge(n.w,n.v,i,E$("rev"))});function t(n){return i=>n.edge(i).weight}}function vRe(e){let t=[],n={},i={};function r(s){Object.hasOwn(i,s)||(i[s]=!0,n[s]=!0,e.outEdges(s).forEach(a=>{Object.hasOwn(n,a.w)?t.push(a):r(a.w)}),delete n[s])}return e.nodes().forEach(r),t}function wRe(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let i=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,i)}})}function SRe(e){e.graph().dummyChains=[],e.edges().forEach(t=>ERe(e,t))}function ERe(e,t){let n=t.v,i=e.node(n).rank,r=t.w,s=e.node(r).rank,a=t.name,o=e.edge(t),c=o.labelRank;if(s===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i{let n=e.node(t),i=n.edgeLabel,r;for(e.setEdge(n.edgeObj,i);n.dummy;)r=e.successors(t)[0],e.removeNode(t),i.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height),t=r,n=e.node(t)})}function k$(e){let t={};function n(i){let r=e.node(i);if(Object.hasOwn(t,i))return r.rank;t[i]=!0;let s=e.outEdges(i),a=s?s.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],o=Ac(Math.min,a);return o===Number.POSITIVE_INFINITY&&(o=0),r.rank=o}e.sources().forEach(n)}function u0(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var jne=TRe;function TRe(e){let t=new al({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let i=n[0],r=e.nodeCount();t.setNode(i,{});let s,a;for(;_Re(t,e){let a=s.v,o=i===a?s.w:a;!e.hasNode(o)&&!u0(t,s)&&(e.setNode(o,{}),e.setEdge(i,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function ARe(e,t){return t.edges().reduce((n,i)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(i.v)!==e.hasNode(i.w)&&(r=u0(t,i)),rt.node(i).rank+=n)}var{preorder:CRe,postorder:jRe}=S$,RRe=$p;$p.initLowLimValues=_$;$p.initCutValues=T$;$p.calcCutValue=Rne;$p.leaveEdge=Pne;$p.enterEdge=Mne;$p.exchangeEdges=Lne;function $p(e){e=rRe(e),k$(e);let t=jne(e);_$(t),T$(t,e);let n,i;for(;n=Pne(t);)i=Mne(t,e,n),Lne(t,e,n,i)}function T$(e,t){let n=jRe(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(i=>IRe(e,t,i))}function IRe(e,t,n){let i=e.node(n).parent,r=e.edge(n,i);r.cutvalue=Rne(e,t,n)}function Rne(e,t,n){let i=e.node(n).parent,r=!0,s=t.edge(n,i),a=0;s||(r=!1,s=t.edge(i,n)),a=s.weight;let o=t.nodeEdges(n);return o&&o.forEach(c=>{let u=c.v===n,d=u?c.w:c.v;if(d!==i){let f=u===r,h=t.edge(c).weight;if(a+=f?h:-h,MRe(e,n,d)){let p=e.edge(n,d).cutvalue;a+=f?-p:p}}}),a}function _$(e,t){arguments.length<2&&(t=e.nodes()[0]),Ine(e,{},1,t)}function Ine(e,t,n,i,r){let s=n,a=e.node(i);t[i]=!0;let o=e.neighbors(i);return o&&o.forEach(c=>{Object.hasOwn(t,c)||(n=Ine(e,t,n,c,i))}),a.low=s,a.lim=n++,r?a.parent=r:delete a.parent,n}function Pne(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Mne(e,t,n){let i=n.v,r=n.w;t.hasEdge(i,r)||(i=n.w,r=n.v);let s=e.node(i),a=e.node(r),o=s,c=!1;return s.lim>a.lim&&(o=a,c=!0),t.edges().filter(u=>c===CU(e,e.node(u.v),o)&&c!==CU(e,e.node(u.w),o)).reduce((u,d)=>u0(t,d)!e.node(r).parent);if(!n)return;let i=CRe(e,[n]);i=i.slice(1),i.forEach(r=>{let s=e.node(r).parent,a=t.edge(r,s),o=!1;a||(a=t.edge(s,r),o=!0),t.node(r).rank=t.node(s).rank+(o?a.minlen:-a.minlen)})}function MRe(e,t,n){return e.hasEdge(t,n)}function CU(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var LRe=DRe;function DRe(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":jU(e);break;case"tight-tree":QRe(e);break;case"longest-path":$Re(e);break;case"none":break;default:jU(e)}}var $Re=k$;function QRe(e){k$(e),jne(e)}function jU(e){RRe(e)}var BRe=URe;function URe(e){let t=FRe(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),r=i.edgeObj,s=zRe(e,t,r.v,r.w),a=s.path,o=s.lca,c=0,u=a[c],d=!0;for(;n!==r.w;){if(i=e.node(n),d){for(;(u=a[c])!==o&&e.node(u).maxRanka||o>t[c].lim));let u=c,d=i;for(;(d=e.parent(d))!==u;)s.push(d);return{path:r.concat(s.reverse()),lca:u}}function FRe(e){let t={},n=0;function i(r){let s=n;e.children(r).forEach(i),t[r]={low:s,lim:n++}}return e.children(Q_).forEach(i),t}function VRe(e){let t=q0(e,"root",{},"_root"),n=XRe(e),i=Object.values(n),r=Ac(Math.max,i)-1,s=2*r+1;e.graph().nestingRoot=t,e.edges().forEach(o=>e.edge(o).minlen*=s);let a=qRe(e)+1;e.children(Q_).forEach(o=>Dne(e,t,s,a,r,n,o)),e.graph().nodeRankFactor=s}function Dne(e,t,n,i,r,s,a){var o;let c=e.children(a);if(!c.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}let u=AU(e,"_bt"),d=AU(e,"_bb"),f=e.node(a);e.setParent(u,a),f.borderTop=u,e.setParent(d,a),f.borderBottom=d,c.forEach(h=>{var p;Dne(e,t,n,i,r,s,h);let g=e.node(h),b=g.borderTop?g.borderTop:h,y=g.borderBottom?g.borderBottom:h,O=g.borderTop?i:2*i,v=b!==y?1:r-((p=s[a])!=null?p:0)+1;e.setEdge(u,b,{weight:O,minlen:v,nestingEdge:!0}),e.setEdge(y,d,{weight:O,minlen:v,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,u,{weight:0,minlen:r+((o=s[a])!=null?o:0)})}function XRe(e){let t={};function n(i,r){let s=e.children(i);s&&s.length&&s.forEach(a=>n(a,r+1)),t[i]=r}return e.children(Q_).forEach(i=>n(i,1)),t}function qRe(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function HRe(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var YRe=GRe;function GRe(e){function t(n){let i=e.children(n),r=e.node(n);if(i.length&&i.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let s=r.minRank,a=r.maxRank+1;sIU(e.node(t))),e.edges().forEach(t=>IU(e.edge(t)))}function IU(e){let t=e.width;e.width=e.height,e.height=t}function KRe(e){e.nodes().forEach(t=>eC(e.node(t))),e.edges().forEach(t=>{var n;let i=e.edge(t);(n=i.points)==null||n.forEach(eC),Object.hasOwn(i,"y")&&eC(i)})}function eC(e){e.y=-e.y}function JRe(e){e.nodes().forEach(t=>tC(e.node(t))),e.edges().forEach(t=>{var n;let i=e.edge(t);(n=i.points)==null||n.forEach(tC),Object.hasOwn(i,"x")&&tC(i)})}function tC(e){let t=e.x;e.x=e.y,e.y=t}function eIe(e){let t={},n=e.nodes().filter(o=>!e.children(o).length),i=n.map(o=>e.node(o).rank),r=Ac(Math.max,i),s=hx(r+1).map(()=>[]);function a(o){if(t[o])return;t[o]=!0;let c=e.node(o);s[c.rank].push(o);let u=e.successors(o);u&&u.forEach(a)}return n.sort((o,c)=>e.node(o).rank-e.node(c).rank).forEach(a),s}function tIe(e,t){let n=0;for(let i=1;id)),r=t.flatMap(u=>{let d=e.outEdges(u);return d?d.map(f=>({pos:i[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),s=1;for(;s{let d=u.pos+s;o[d]+=u.weight;let f=0;for(;d>0;)d%2&&(f+=o[d+1]),d=d-1>>1,o[d]+=u.weight;c+=u.weight*f}),c}function iIe(e,t=[]){return t.map(n=>{let i=e.inEdges(n);if(!i||!i.length)return{v:n};{let r=i.reduce((s,a)=>{let o=e.edge(a),c=e.node(a.v);return{sum:s.sum+o.weight*c.order,weight:s.weight+o.weight}},{sum:0,weight:0});return{v:n,barycenter:r.sum/r.weight,weight:r.weight}}})}function rIe(e,t){let n={};e.forEach((r,s)=>{let a={indegree:0,in:[],out:[],vs:[r.v],i:s};r.barycenter!==void 0&&(a.barycenter=r.barycenter,a.weight=r.weight),n[r.v]=a}),t.edges().forEach(r=>{let s=n[r.v],a=n[r.w];s!==void 0&&a!==void 0&&(a.indegree++,s.out.push(a))});let i=Object.values(n).filter(r=>!r.indegree);return sIe(i)}function sIe(e){let t=[];function n(r){return s=>{s.merged||(s.barycenter===void 0||r.barycenter===void 0||s.barycenter>=r.barycenter)&&aIe(r,s)}}function i(r){return s=>{s.in.push(r),--s.indegree===0&&e.push(s)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(i(r))}return t.filter(r=>!r.merged).map(r=>Ik(r,["vs","i","barycenter","weight"]))}function aIe(e,t){let n=0,i=0;e.weight&&(n+=e.barycenter*e.weight,i+=e.weight),t.weight&&(n+=t.barycenter*t.weight,i+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/i,e.weight=i,e.i=Math.min(t.i,e.i),t.merged=!0}function oIe(e,t){let n=lRe(e,d=>Object.hasOwn(d,"barycenter")),i=n.lhs,r=n.rhs.sort((d,f)=>f.i-d.i),s=[],a=0,o=0,c=0;i.sort(lIe(!!t)),c=PU(s,r,c),i.forEach(d=>{c+=d.vs.length,s.push(d.vs),a+=d.barycenter*d.weight,o+=d.weight,c=PU(s,r,c)});let u={vs:s.flat(1)};return o&&(u.barycenter=a/o,u.weight=o),u}function PU(e,t,n){let i;for(;t.length&&(i=t[t.length-1]).i<=n;)t.pop(),e.push(i.vs),n++;return n}function lIe(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}function Qne(e,t,n,i){let r=e.children(t),s=e.node(t),a=s?s.borderLeft:void 0,o=s?s.borderRight:void 0,c={};a&&(r=r.filter(h=>h!==a&&h!==o));let u=iIe(e,r);u.forEach(h=>{if(e.children(h.v).length){let p=Qne(e,h.v,n,i);c[h.v]=p,Object.hasOwn(p,"barycenter")&&uIe(h,p)}});let d=rIe(u,n);cIe(d,c);let f=oIe(d,i);if(a&&o){f.vs=[a,f.vs,o].flat(1);let h=e.predecessors(a);if(h&&h.length){let p=e.node(h[0]),g=e.predecessors(o),b=e.node(g[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+p.order+b.order)/(f.weight+2),f.weight+=2}}return f}function cIe(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(i=>t[i]?t[i].vs:i)})}function uIe(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function dIe(e,t,n,i){i||(i=e.nodes());let r=fIe(e),s=new al({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(a=>e.node(a));return i.forEach(a=>{let o=e.node(a),c=e.parent(a);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){s.setNode(a),s.setParent(a,c||r);let u=e[n](a);u&&u.forEach(d=>{let f=d.v===a?d.w:d.v,h=s.edge(f,a),p=h!==void 0?h.weight:0;s.setEdge(f,a,{weight:e.edge(d).weight+p})}),Object.hasOwn(o,"minRank")&&s.setNode(a,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),s}function fIe(e){let t;for(;e.hasNode(t=E$("_root")););return t}function hIe(e,t,n){let i={},r;n.forEach(s=>{let a=e.parent(s),o,c;for(;a;){if(o=e.parent(a),o?(c=i[o],i[o]=a):(c=r,r=a),c&&c!==a){t.setEdge(c,a);return}a=o}})}function Bne(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,Bne);return}let n=Ane(e),i=MU(e,hx(1,n+1),"inEdges"),r=MU(e,hx(n-1,-1,-1),"outEdges"),s=eIe(e);if(LU(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,o,c=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){pIe(u%2?i:r,u%4>=2,c),s=N1(e);let f=tIe(e,s);f{i.has(s)||i.set(s,[]),i.get(s).push(a)};for(let s of e.nodes()){let a=e.node(s);if(typeof a.rank=="number"&&r(a.rank,s),typeof a.minRank=="number"&&typeof a.maxRank=="number")for(let o=a.minRank;o<=a.maxRank;o++)o!==a.rank&&r(o,s)}return t.map(function(s){return dIe(e,s,n,i.get(s)||[])})}function pIe(e,t,n){let i=new al;e.forEach(function(r){n.forEach(o=>i.setEdge(o.left,o.right));let s=r.graph().root,a=Qne(r,s,i,t);a.vs.forEach((o,c)=>r.node(o).order=c),hIe(r,i,a.vs)})}function LU(e,t){Object.values(t).forEach(n=>n.forEach((i,r)=>e.node(i).order=r))}function mIe(e,t){let n={};function i(r,s){let a=0,o=0,c=r.length,u=s[s.length-1];return s.forEach((d,f)=>{let h=bIe(e,d),p=h?e.node(h).order:c;(h||d===u)&&(s.slice(o,f+1).forEach(g=>{let b=e.predecessors(g);b&&b.forEach(y=>{let O=e.node(y),v=O.order;(v{let f=s[d];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(p=>{if(p===void 0)return;let g=e.node(p);g.dummy&&(g.orderu)&&Une(n,p,f)})}})}function r(s,a){let o=-1,c=-1,u=0;return a.forEach((d,f)=>{if(e.node(d).dummy==="border"){let h=e.predecessors(d);if(h&&h.length){let p=h[0];if(p===void 0)return;c=e.node(p).order,i(a,u,f,o,c),u=f,o=c}}i(a,u,a.length,c,s.length)}),a}return t.length&&t.reduce(r),n}function bIe(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(i=>e.node(i).dummy)}}function Une(e,t,n){if(t>n){let r=t;t=n,n=r}let i=e[t];i||(e[t]=i={}),i[n]=!0}function OIe(e,t,n){if(t>n){let r=t;t=n,n=r}let i=e[t];return i!==void 0&&Object.hasOwn(i,n)}function yIe(e,t,n,i){let r={},s={},a={};return t.forEach(o=>{o.forEach((c,u)=>{r[c]=c,s[c]=c,a[c]=u})}),t.forEach(o=>{let c=-1;o.forEach(u=>{let d=i(u);if(d&&d.length){let f=d.sort((p,g)=>{let b=a[p],y=a[g];return(b!==void 0?b:0)-(y!==void 0?y:0)}),h=(f.length-1)/2;for(let p=Math.floor(h),g=Math.ceil(h);p<=g;++p){let b=f[p];if(b===void 0)continue;let y=a[b];if(y!==void 0&&s[u]===u&&c{var O;let v=(O=s[y.v])!=null?O:0,x=a.edge(y);return Math.max(b,v+(x!==void 0?x:0))},0):s[p]=0}function d(p){let g=a.outEdges(p),b=Number.POSITIVE_INFINITY;g&&(b=g.reduce((O,v)=>{let x=s[v.w],w=a.edge(v);return Math.min(O,(x!==void 0?x:0)-(w!==void 0?w:0))},Number.POSITIVE_INFINITY));let y=e.node(p);b!==Number.POSITIVE_INFINITY&&y.borderType!==o&&(s[p]=Math.max(s[p]!==void 0?s[p]:0,b))}function f(p){return a.predecessors(p)||[]}function h(p){return a.successors(p)||[]}return c(u,f),c(d,h),Object.keys(i).forEach(p=>{var g;let b=n[p];b!==void 0&&(s[p]=(g=s[b])!=null?g:0)}),s}function vIe(e,t,n,i){let r=new al,s=e.graph(),a=TIe(s.nodesep,s.edgesep,i);return t.forEach(o=>{let c;o.forEach(u=>{let d=n[u];if(d!==void 0){if(r.setNode(d),c!==void 0){let f=n[c];if(f!==void 0){let h=r.edge(f,d);r.setEdge(f,d,Math.max(a(e,u,c),h||0))}}c=u}})}),r}function wIe(e,t){return Object.values(t).reduce((n,i)=>{let r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;Object.entries(i).forEach(([o,c])=>{let u=_Ie(e,o)/2;r=Math.max(c+u,r),s=Math.min(c-u,s)});let a=r-s;return a{["l","r"].forEach(a=>{let o=s+a,c=e[o];if(!c||c===t)return;let u=Object.values(c),d=i-Ac(Math.min,u);a!=="l"&&(d=r-Ac(Math.max,u)),d&&(e[o]=$_(c,f=>f+d))})})}function EIe(e,t=void 0){let n=e.ul;return n?$_(n,(i,r)=>{var s,a;if(t){let c=t.toLowerCase(),u=e[c];if(u&&u[r]!==void 0)return u[r]}let o=Object.values(e).map(c=>{let u=c[r];return u!==void 0?u:0}).sort((c,u)=>c-u);return(((s=o[1])!=null?s:0)+((a=o[2])!=null?a:0))/2}):{}}function kIe(e){let t=N1(e),n=Object.assign(mIe(e,t),gIe(e,t)),i={},r;["u","d"].forEach(a=>{r=a==="u"?t:Object.values(t).reverse(),["l","r"].forEach(o=>{o==="r"&&(r=r.map(d=>Object.values(d).reverse()));let c=yIe(e,r,n,d=>(a==="u"?e.predecessors(d):e.successors(d))||[]),u=xIe(e,r,c.root,c.align,o==="r");o==="r"&&(u=$_(u,d=>-d)),i[a+o]=u})});let s=wIe(e,i);return SIe(i,s),EIe(i,e.graph().align)}function TIe(e,t,n){return(i,r,s)=>{let a=i.node(r),o=i.node(s),c=0,u;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":u=-a.width/2;break;case"r":u=a.width/2;break}if(u&&(c+=n?u:-u),u=void 0,c+=(a.dummy?t:e)/2,c+=(o.dummy?t:e)/2,c+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":u=o.width/2;break;case"r":u=-o.width/2;break}return u&&(c+=n?u:-u),c}}function _Ie(e,t){return e.node(t).width}function AIe(e){e=Tne(e),NIe(e),Object.entries(kIe(e)).forEach(([t,n])=>e.node(t).x=n)}function NIe(e){let t=N1(e),n=e.graph(),i=n.ranksep,r=n.rankalign,s=0;t.forEach(a=>{let o=a.reduce((c,u)=>{var d;let f=(d=e.node(u).height)!=null?d:0;return c>f?c:f},0);a.forEach(c=>{let u=e.node(c);r==="top"?u.y=s+u.height/2:r==="bottom"?u.y=s+o-u.height/2:u.y=s+o/2}),s+=o+i})}function CIe(e,t={}){let n=t.debugTiming?Nne:Cne;return n("layout",()=>{let i=n(" buildLayoutGraph",()=>BIe(e));return n(" runLayout",()=>jIe(i,n,t)),n(" updateInputGraph",()=>RIe(e,i)),i})}function jIe(e,t,n){t(" makeSpaceForEdgeLabels",()=>UIe(e)),t(" removeSelfEdges",()=>WIe(e)),t(" acyclic",()=>xRe(e)),t(" nestingGraph.run",()=>VRe(e)),t(" rank",()=>LRe(Tne(e))),t(" injectEdgeLabelProxies",()=>zIe(e)),t(" removeEmptyRanks",()=>aRe(e)),t(" nestingGraph.cleanup",()=>HRe(e)),t(" normalizeRanks",()=>sRe(e)),t(" assignRankMinMax",()=>FIe(e)),t(" removeEdgeLabelProxies",()=>VIe(e)),t(" normalize.run",()=>SRe(e)),t(" parentDummyChains",()=>BRe(e)),t(" addBorderSegments",()=>YRe(e)),t(" order",()=>Bne(e,n)),t(" insertSelfEdges",()=>ZIe(e)),t(" adjustCoordinateSystem",()=>WRe(e)),t(" position",()=>AIe(e)),t(" positionSelfEdges",()=>KIe(e)),t(" removeBorderNodes",()=>GIe(e)),t(" normalize.undo",()=>kRe(e)),t(" fixupEdgeLabelCoords",()=>HIe(e)),t(" undoCoordinateSystem",()=>ZRe(e)),t(" translateGraph",()=>XIe(e)),t(" assignNodeIntersects",()=>qIe(e)),t(" reversePoints",()=>YIe(e)),t(" acyclic.undo",()=>wRe(e))}function RIe(e,t){e.nodes().forEach(n=>{let i=e.node(n),r=t.node(n);i&&(i.x=r.x,i.y=r.y,i.order=r.order,i.rank=r.rank,t.children(n).length&&(i.width=r.width,i.height=r.height))}),e.edges().forEach(n=>{let i=e.edge(n),r=t.edge(n);i.points=r.points,Object.hasOwn(r,"x")&&(i.x=r.x,i.y=r.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var IIe=["nodesep","edgesep","ranksep","marginx","marginy"],PIe={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},MIe=["acyclicer","ranker","rankdir","align","rankalign"],LIe=["width","height","rank"],DU={width:0,height:0},DIe=["minlen","weight","width","height","labeloffset"],$Ie={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},QIe=["labelpos"];function BIe(e){let t=new al({multigraph:!0,compound:!0}),n=iC(e.graph());return t.setGraph(Object.assign({},PIe,nC(n,IIe),Ik(n,MIe))),e.nodes().forEach(i=>{let r=iC(e.node(i)),s=nC(r,LIe);Object.keys(DU).forEach(o=>{s[o]===void 0&&(s[o]=DU[o])}),t.setNode(i,s);let a=e.parent(i);a!==void 0&&t.setParent(i,a)}),e.edges().forEach(i=>{let r=iC(e.edge(i));t.setEdge(i,Object.assign({},$Ie,nC(r,DIe),Ik(r,QIe)))}),t}function UIe(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let i=e.edge(n);i.minlen*=2,i.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function zIe(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let i=e.node(t.v),r={rank:(e.node(t.w).rank-i.rank)/2+i.rank,e:t};q0(e,"edge-proxy",r,"_ep")}})}function FIe(e){let t=0;e.nodes().forEach(n=>{let i=e.node(n);i.borderTop&&(i.minRank=e.node(i.borderTop).rank,i.maxRank=e.node(i.borderBottom).rank,t=Math.max(t,i.maxRank))}),e.graph().maxRank=t}function VIe(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let i=n;e.edge(i.e).labelRank=n.rank,e.removeNode(t)}})}function XIe(e){let t=Number.POSITIVE_INFINITY,n=0,i=Number.POSITIVE_INFINITY,r=0,s=e.graph(),a=s.marginx||0,o=s.marginy||0;function c(u){let d=u.x,f=u.y,h=u.width,p=u.height;t=Math.min(t,d-h/2),n=Math.max(n,d+h/2),i=Math.min(i,f-p/2),r=Math.max(r,f+p/2)}e.nodes().forEach(u=>c(e.node(u))),e.edges().forEach(u=>{let d=e.edge(u);Object.hasOwn(d,"x")&&c(d)}),t-=a,i-=o,e.nodes().forEach(u=>{let d=e.node(u);d.x-=t,d.y-=i}),e.edges().forEach(u=>{let d=e.edge(u);d.points.forEach(f=>{f.x-=t,f.y-=i}),Object.hasOwn(d,"x")&&(d.x-=t),Object.hasOwn(d,"y")&&(d.y-=i)}),s.width=n-t+a,s.height=r-i+o}function qIe(e){e.edges().forEach(t=>{let n=e.edge(t),i=e.node(t.v),r=e.node(t.w),s,a;n.points?(s=n.points[0],a=n.points[n.points.length-1]):(n.points=[],s=r,a=i),n.points.unshift(_U(i,s)),n.points.push(_U(r,a))})}function HIe(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function YIe(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function GIe(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),i=e.node(n.borderTop),r=e.node(n.borderBottom),s=e.node(n.borderLeft[n.borderLeft.length-1]),a=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(a.x-s.x),n.height=Math.abs(r.y-i.y),n.x=s.x+n.width/2,n.y=i.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function WIe(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function ZIe(e){N1(e).forEach(t=>{let n=0;t.forEach((i,r)=>{let s=e.node(i);s.order=r+n,(s.selfEdges||[]).forEach(a=>{q0(e,"selfedge",{width:a.label.width,height:a.label.height,rank:s.rank,order:r+ ++n,e:a.e,label:a.label},"_se")}),delete s.selfEdges})})}function KIe(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let i=n,r=e.node(i.e.v),s=r.x+r.width/2,a=r.y,o=n.x-s,c=r.height/2;e.setEdge(i.e,i.label),e.removeNode(t),i.label.points=[{x:s+2*o/3,y:a-c},{x:s+5*o/6,y:a-c},{x:s+o,y:a},{x:s+5*o/6,y:a+c},{x:s+2*o/3,y:a+c}],i.label.x=n.x,i.label.y=n.y}})}function nC(e,t){return $_(Ik(e,t),Number)}function iC(e){let t={};return e&&Object.entries(e).forEach(([n,i])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=i}),t}function JIe(e){let t=N1(e),n=new al({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(i=>{n.setNode(i,{label:i}),n.setParent(i,"layer"+e.node(i).rank)}),e.edges().forEach(i=>n.setEdge(i.v,i.w,{},i.name)),t.forEach((i,r)=>{let s="layer"+r;n.setNode(s,{rank:"same"}),i.reduce((a,o)=>(n.setEdge(a,o,{style:"invis"}),o))}),n}var ePe={graphlib:bne,version:dRe,layout:CIe,debug:JIe,util:{time:Nne,notime:Cne}},$U=ePe;/*! For license information please see dagre.esm.js.LEGAL.txt */const CO={llm:{label:"智能体",description:"理解任务并直接完成一个具体工作",icon:cJ},sequential:{label:"分步协作",description:"内部步骤按照顺序依次执行",icon:eSe},parallel:{label:"同时处理",description:"内部步骤同时工作,完成后统一汇总",icon:$we},loop:{label:"循环执行",description:"重复执行内部步骤,直到满足停止条件",icon:gJ},a2a:{label:"远程智能体",description:"调用已经存在的远程 Agent",icon:O_}},_P=220,AP=88,QU=96,BU=34,dy=64,rC=310,tg=24,zne=56,NP=40,UU=40,tPe=18,nPe=58,iPe=!1,rPe=e=>e==="sequential"||e==="parallel"||e==="loop";function CP(e,t){const n=e.agentType??"llm";return rPe(n)||n==="llm"&&(t.length===0||e.subAgents.length>0)}function jP(e,t=[],n="horizontal",i=!1){const r=e.agentType??"llm";if(!CP(e,t))return{width:_P,height:AP};if(i&&e.subAgents.length===0)return{width:rC,height:dy};const s=e.subAgents.map((f,h)=>jP(f,[...t,h],n,i)),a=s.length?Math.max(...s.map(f=>f.width)):0,o=s.length?Math.max(...s.map(f=>f.height)):0,c=s.length&&r!=="parallel"?zne:tg,u=n==="horizontal"?r!=="parallel":r==="parallel",d=s.length?r==="parallel"?tPe+UU:r==="loop"?nPe:0:UU;return u?{width:Math.max(rC,s.reduce((f,h)=>f+h.width,0)+NP*Math.max(0,s.length-1)+c*2),height:dy+tg+o+d+tg}:{width:Math.max(rC,a+tg*2),height:dy+c+s.reduce((f,h)=>f+h.height,0)+NP*Math.max(0,s.length-1)+d+c}}function Gb(e){return e.length===0?"agent-root":`agent-${e.join("-")}`}function sPe(e,t){return e.length===t.length&&e.every((n,i)=>n===t[i])}function zU(e){const t=n=>[n.agentType??"llm",n.subAgents.map(t)];return JSON.stringify(t(e))}function Wb(e,t,n,i){const r=(i==null?void 0:i.tone)==="sequential"?"hsl(213 40% 40%)":(i==null?void 0:i.tone)==="loop"?"hsl(151 34% 34%)":"hsl(220 9% 38%)";return{id:`${e}-${t}${i!=null&&i.loop?"-loop":""}`,source:e,target:t,sourceHandle:i!=null&&i.loop?"loop-source":void 0,targetHandle:i!=null&&i.loop?"loop-target":void 0,label:n,type:"insertStep",data:i?{insert:i.insert,loop:i.loop,tone:i.tone}:void 0,animated:i==null?void 0:i.loop,markerEnd:{type:cx.ArrowClosed,width:16,height:16,color:r},style:{stroke:r,strokeWidth:1.5},labelStyle:{fill:"hsl(215 14% 42%)",fontSize:10,fontWeight:600},labelBgStyle:{fill:"hsl(var(--background))",fillOpacity:.92}}}function FU(e,t,n=!1){const i=[{id:"terminal-input",type:"terminal",position:{x:0,y:0},data:{kind:"terminal",title:"用户请求"},selectable:!1,draggable:!1},{id:"terminal-output",type:"terminal",position:{x:0,y:0},data:{kind:"terminal",title:"最终回复"},selectable:!1,draggable:!1}],r=[];function s(d,f,h,p,g){const b=d.agentType??"llm",y=Gb(f);return CP(d,f)?(a(d,f,h,p,g),y):(i.push({id:y,type:"agent",parentId:h,extent:"parent",position:p,data:{kind:"agent",path:f,agent:d,title:b==="a2a"?"远程智能体":d.name.trim()||(f.length===0?"主 Agent":"未命名步骤"),pattern:b,description:d.description.trim()||CO[b].description,childCount:d.subAgents.length,containedIn:g}}),y)}function a(d,f,h,p={x:0,y:0},g){const b=d.agentType??"sequential",y=Gb(f),O=jP(d,f,t,n);i.push({id:y,type:"group",parentId:h,extent:h?"parent":void 0,position:p,style:{width:O.width,height:O.height},data:{kind:"agent",path:f,agent:d,title:d.name.trim()||(f.length===0?"主 Agent":CO[b].label),pattern:b,description:d.description.trim()||CO[b].description,childCount:d.subAgents.length,containedIn:g,layoutWidth:O.width,layoutHeight:O.height,compactEmptyGroup:n&&d.subAgents.length===0}});const v=d.subAgents.map((k,T)=>jP(k,[...f,T],t,n)),x=v.length&&b!=="parallel"?zne:tg,w=t==="horizontal"?b!=="parallel":b==="parallel";let E=x;const S=d.subAgents.map((k,T)=>{const A=v[T],N=w?{x:E,y:dy+tg}:{x:(O.width-A.width)/2,y:dy+E};return E+=(w?A.width:A.height)+NP,s(k,[...f,T],y,N,b)});if(b==="sequential"||b==="loop"){for(let k=0;k1&&r.push(Wb(S[S.length-1],S[0],"继续循环",{loop:!0,tone:"loop"}))}return y}const o=(d,f)=>{const h=d.agentType??"llm",p=Gb(f);if(CP(d,f))return a(d,f),[p];if(i.push({id:p,type:"agent",position:{x:0,y:0},data:{kind:"agent",path:f,agent:d,title:h==="a2a"?"远程智能体":d.name.trim()||(f.length===0?"主 Agent":"未命名步骤"),pattern:h,description:d.description.trim()||CO[h].description,childCount:d.subAgents.length}}),d.subAgents.length===0)return[p];const g=[];return d.subAgents.forEach((b,y)=>{const O=[...f,y],v=Gb(O);r.push(Wb(p,v,"调用",{insert:{parentPath:f,index:y}})),g.push(...o(b,O))}),g},c=Gb([]),u=o(e,[]);return r.push(Wb("terminal-input",c)),u.forEach(d=>r.push(Wb(d,"terminal-output"))),aPe(i,r,t)}function aPe(e,t,n){const i=new $U.graphlib.Graph().setDefaultEdgeLabel(()=>({}));i.setGraph({rankdir:n==="vertical"?"TB":"LR",ranksep:50,nodesep:34,edgesep:14,marginx:24,marginy:24});const r=new Set(e.filter(s=>!s.parentId).map(s=>s.id));return e.filter(s=>!s.parentId).forEach(s=>{const a=s.data.kind==="terminal";i.setNode(s.id,{width:a?QU:s.data.layoutWidth??_P,height:a?BU:s.data.layoutHeight??AP})}),t.filter(s=>r.has(s.source)&&r.has(s.target)).forEach(s=>i.setEdge(s.source,s.target)),$U.layout(i),{nodes:e.map(s=>{if(s.parentId)return s;const a=i.node(s.id),o=s.data.kind==="terminal",c=o?QU:s.data.layoutWidth??_P,u=o?BU:s.data.layoutHeight??AP;return{...s,position:{x:a.x-c/2,y:a.y-u/2}}}),edges:t}}const B_=m.createContext(null),U_=m.createContext("horizontal");function oPe({id:e,sourceX:t,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:a,markerEnd:o,style:c,label:u,data:d}){const f=m.useContext(B_),[h,p]=m.useState(!1),[g,b,y]=Nk({sourceX:t,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:a,offset:d!=null&&d.loop?28:20});return l.jsxs(l.Fragment,{children:[l.jsx(A1,{id:e,path:g,markerEnd:o,style:c}),f&&(d==null?void 0:d.insert)&&l.jsx("path",{d:g,className:"abc-edge-hover-path",onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1)}),(u||f&&(d==null?void 0:d.insert))&&l.jsx(JCe,{children:l.jsxs("div",{className:`abc-edge-tools${f&&(d!=null&&d.insert)?" can-insert":""}${h?" is-visible":""}`,style:{transform:`translate(-50%, -50%) translate(${b}px, ${y}px)`},onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1),children:[u&&l.jsx("span",{className:"abc-edge-label",children:u}),f&&(d==null?void 0:d.insert)&&l.jsx("button",{type:"button",className:"abc-edge-add nodrag nopan","aria-label":"在这里插入步骤",title:"在这里插入步骤",onClick:O=>{O.stopPropagation(),f==null||f.onInsert(d.insert.parentPath,d.insert.index)},children:l.jsx(Gs,{})})]})})]})}function lPe({data:e,selected:t}){const n=m.useContext(B_),i=m.useContext(U_),r=i==="vertical"?St.Top:St.Left,s=i==="vertical"?St.Bottom:St.Right,a=i==="vertical"?St.Right:St.Bottom,o=e.pattern??"llm",c=CO[o],u=c.icon;return l.jsxs("div",{className:`abc-node is-${o}${e.containedIn?` is-contained-in-${e.containedIn}`:""}${t?" is-selected":""}`,children:[l.jsx($a,{type:"target",position:r,className:"abc-handle"}),o!=="llm"&&l.jsx("span",{className:"abc-node-icon",children:l.jsx(u,{})}),l.jsxs("span",{className:"abc-node-copy",children:[l.jsx("span",{className:"abc-node-meta",children:l.jsx("span",{children:c.label})}),l.jsx("strong",{children:e.title}),l.jsx("small",{children:e.description})]}),n&&e.path!==void 0&&e.path.length>0&&l.jsx("button",{type:"button",className:"abc-node-delete nodrag nopan","aria-label":`删除 ${e.title}`,title:"删除节点",onClick:d=>{d.stopPropagation(),n==null||n.onDelete(e.path)},children:l.jsx(If,{})}),l.jsx($a,{type:"source",position:s,className:"abc-handle"}),e.containedIn==="loop"&&l.jsxs(l.Fragment,{children:[l.jsx($a,{id:"loop-target",type:"target",position:a,className:"abc-handle abc-loop-handle"}),l.jsx($a,{id:"loop-source",type:"source",position:a,className:"abc-handle abc-loop-handle"})]})]})}function cPe({data:e,selected:t}){const n=m.useContext(B_),i=m.useContext(U_),r=i==="vertical"?St.Top:St.Left,s=i==="vertical"?St.Bottom:St.Right,a=i==="vertical"?St.Right:St.Bottom,o=e.pattern??"sequential",c=e.childCount??0,u=o==="llm"?"添加子 Agent":o==="parallel"?"添加一个同时处理的步骤":o==="loop"?"添加循环步骤":"添加下一个步骤";return l.jsxs("div",{className:`abc-group is-${o}${e.compactEmptyGroup?" is-compact-empty":""}${t?" is-selected":""}`,children:[l.jsx($a,{type:"target",position:r,className:"abc-handle"}),l.jsx("header",{className:"abc-group-head",children:l.jsxs("span",{children:[l.jsx("strong",{title:e.title,children:e.title}),l.jsx("small",{children:e.description})]})}),n&&e.path!==void 0&&c>0&&o!=="parallel"&&l.jsxs("div",{className:"abc-group-boundary-actions",children:[l.jsx("button",{type:"button",className:"abc-group-boundary-add is-start nodrag nopan","aria-label":"添加到最前",title:"添加到最前",onClick:d=>{d.stopPropagation(),n.onInsert(e.path,0)},children:l.jsx(Gs,{})}),l.jsx("button",{type:"button",className:"abc-group-boundary-add is-end nodrag nopan","aria-label":"添加到最后",title:"添加到最后",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:l.jsx(Gs,{})})]}),n&&e.path!==void 0&&c>0&&o==="parallel"&&l.jsxs("button",{type:"button",className:"abc-group-add abc-group-add-bottom nodrag nopan",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:[l.jsx(Gs,{}),l.jsx("span",{children:u})]}),n&&e.path!==void 0&&c===0&&l.jsxs("button",{type:"button",className:"abc-group-add abc-group-add-empty nodrag nopan",onClick:d=>{d.stopPropagation(),n.onAdd(e.path)},children:[l.jsx(Gs,{}),l.jsx("span",{children:u})]}),n&&e.path!==void 0&&e.path.length>0&&l.jsx("button",{type:"button",className:"abc-node-delete nodrag nopan","aria-label":`删除 ${e.title}`,title:"删除节点",onClick:d=>{d.stopPropagation(),n==null||n.onDelete(e.path)},children:l.jsx(If,{})}),l.jsx($a,{type:"source",position:s,className:"abc-handle"}),e.containedIn==="loop"&&l.jsxs(l.Fragment,{children:[l.jsx($a,{id:"loop-target",type:"target",position:a,className:"abc-handle abc-loop-handle"}),l.jsx($a,{id:"loop-source",type:"source",position:a,className:"abc-handle abc-loop-handle"})]})]})}function uPe({data:e}){const t=m.useContext(U_);return l.jsxs("div",{className:"abc-terminal",children:[l.jsx($a,{type:"target",position:t==="vertical"?St.Top:St.Left,className:"abc-handle"}),l.jsx("span",{children:e.title}),l.jsx($a,{type:"source",position:t==="vertical"?St.Bottom:St.Right,className:"abc-handle"})]})}const dPe={agent:lPe,group:cPe,terminal:uPe},fPe={insertStep:oPe};function hPe({draft:e,selectedPath:t,onSelect:n,onAdd:i,onInsert:r,onDelete:s,readOnly:a=!1,interactivePreview:o=!1,direction:c="horizontal"}){const u=m.useMemo(()=>FU(e,c,a),[]),[d,f,h]=eje(u.nodes),[p,g,b]=tje(u.edges),y=ije(),O=m.useRef(`${c}:${a?"readonly":"editable"}:${zU(e)}`),v=m.useRef(null),{fitView:x}=L_(),w=m.useMemo(()=>FU(e,c,a),[c,e,a]),[E,S]=m.useState(()=>window.matchMedia("(max-width: 860px)").matches),k=m.useMemo(()=>a?{padding:.16,minZoom:.05,maxZoom:.9}:E?{padding:.08,minZoom:.35,maxZoom:.9}:{padding:.14,minZoom:.42,maxZoom:1.1},[E,a]),T=m.useCallback((N=0)=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{const C=v.current;if(C&&(C.clientWidth===0||C.clientHeight===0)&&N<8){T(N+1);return}x(k)})})},[k,x]);m.useEffect(()=>{const N=window.matchMedia("(max-width: 860px)"),C=M=>S(M.matches);return N.addEventListener("change",C),()=>N.removeEventListener("change",C)},[]),m.useEffect(()=>{const N=`${c}:${a?"readonly":"editable"}:${zU(e)}`,C=N!==O.current;O.current=N,g(w.edges),f(M=>{const L=new Map(M.map(P=>[P.id,P]));return w.nodes.map(P=>{const Q=L.get(P.id);return{...P,measured:!C&&Q&&Q.type===P.type?Q.measured:void 0,position:!C&&Q?Q.position:P.position,selected:P.data.kind==="agent"&&!!P.data.path&&sPe(P.data.path,t)}})}),C&&T()},[w,e,T,t,g,f]),m.useEffect(()=>{T()},[E,T]),m.useEffect(()=>{y&&T()},[w,T,y]),m.useEffect(()=>{if(!a||!v.current)return;const N=new ResizeObserver(()=>T());return N.observe(v.current),T(),()=>N.disconnect()},[T,a]);const A=m.useMemo(()=>a?null:{onAdd:i,onInsert:r,onDelete:s},[i,s,r,a]);return l.jsx(U_.Provider,{value:c,children:l.jsx(B_.Provider,{value:A,children:l.jsx("section",{className:`abc-root is-${c}${a?" is-readonly":""}`,"aria-label":a?"只读 Agent 执行画布":"Agent 执行画布",children:l.jsx("div",{ref:v,className:"abc-canvas",children:l.jsxs(ZCe,{nodes:d,edges:p,nodeTypes:dPe,edgeTypes:fPe,onNodesChange:h,onEdgesChange:b,onNodeClick:(N,C)=>{!a&&C.data.kind==="agent"&&C.data.path&&n(C.data.path)},nodesDraggable:!a,nodesConnectable:!1,nodesFocusable:!a,elementsSelectable:!a,edgesFocusable:!1,edgesReconnectable:!1,panOnDrag:!a||o,zoomOnDoubleClick:o,zoomOnPinch:!a||o,zoomOnScroll:!a||o,fitView:!0,fitViewOptions:k,onInit:()=>T(),minZoom:a?.05:.35,maxZoom:1.6,proOptions:{hideAttribution:!0},children:[l.jsx(lje,{gap:20,size:1.2,color:"hsl(34 20% 82%)"}),(!a||o)&&l.jsx(mje,{showInteractive:!1}),iPe]})})})})})}function px(e){return l.jsx(fne,{children:l.jsx(hPe,{...e})})}const pPe="https://ark.cn-beijing.volces.com/api/v3/",GS=[{key:"MODEL_EMBEDDING_NAME",required:!1,placeholder:"doubao-embedding-vision-250615",comment:"向量化模型(记忆/知识库需要)"},{key:"MODEL_EMBEDDING_DIM",required:!1,placeholder:"2048"},{key:"MODEL_EMBEDDING_API_BASE",required:!1,placeholder:pPe}],mx=[],Pk={label:"控制台",url:"https://console.volcengine.com/vikingdb/openviking"},mPe={label:"文档",url:"https://github.com/volcengine/OpenViking/blob/main/docs/zh/api/05-sessions.md"},Fne="https://api.vikingdb.cn-beijing.volces.com/openviking",gPe=`{ "self": {"enabled": true}, "peer": {"enabled": true}, "working_memory": {"enabled": true}, "memory_types": null -}`,gPe=[{key:"DATABASE_VIKING_PROJECT",required:!1,placeholder:"default"},{key:"DATABASE_VIKING_REGION",required:!1},{key:"DATABASE_VIKING_COLLECTION_KIND",required:!1},{key:"DATABASE_VIKING_RESOURCE_ID",required:!1}],Zb=[{key:"FEISHU_APP_ID",required:!0,placeholder:"cli_xxx",comment:"飞书应用 App ID"},{key:"FEISHU_APP_SECRET",required:!0,placeholder:"输入 App Secret",comment:"飞书应用 App Secret"}],Pl={topK:"3",region:"cn-beijing",endpoint:"https://open.volcengineapi.com/"},Fne=[{key:"REGISTRY_SPACE_ID",required:!0,placeholder:"请选择智能体中心",comment:"AgentKit 智能体中心"},{key:"REGISTRY_TOP_K",required:!1,placeholder:Pl.topK,comment:"召回 Agent 数量"},{key:"REGISTRY_REGION",required:!1,placeholder:Pl.region,comment:"AgentKit 智能体中心地域"},{key:"REGISTRY_ENDPOINT",required:!1,placeholder:Pl.endpoint,comment:"AgentKit 智能体中心 OpenAPI 地址"}],Qp=[{id:"web_search",label:"联网搜索",desc:"火山引擎 Web Search,获取实时信息。",importLine:"from veadk.tools.builtin_tools.web_search import web_search",toolNames:["web_search"],env:mx},{id:"parallel_web_search",label:"并行联网搜索",desc:"并行发起多条搜索查询,更快汇总。",importLine:"from veadk.tools.builtin_tools.parallel_web_search import parallel_web_search",toolNames:["parallel_web_search"],env:mx},{id:"link_reader",label:"网页读取",desc:"抓取并阅读给定链接的正文内容。",importLine:"from veadk.tools.builtin_tools.link_reader import link_reader",toolNames:["link_reader"],env:[]},{id:"web_scraper",label:"网页爬取",desc:"结构化爬取网页(需要 Scraper 服务)。",importLine:"from veadk.tools.builtin_tools.web_scraper import web_scraper",toolNames:["web_scraper"],env:[{key:"TOOL_WEB_SCRAPER_ENDPOINT",required:!0},{key:"TOOL_WEB_SCRAPER_API_KEY",required:!0}]},{id:"image_generate",label:"图像生成",desc:"文生图(Doubao Seedream)。",importLine:"from veadk.tools.builtin_tools.image_generate import image_generate",toolNames:["image_generate"],env:[{key:"MODEL_IMAGE_NAME",required:!1,placeholder:"doubao-seedream-5-0-260128"}]},{id:"image_edit",label:"图像编辑",desc:"图生图 / 编辑(Doubao SeedEdit)。",importLine:"from veadk.tools.builtin_tools.image_edit import image_edit",toolNames:["image_edit"],env:[{key:"MODEL_EDIT_NAME",required:!1,placeholder:"doubao-seededit-3-0-i2i-250628"}]},{id:"video_generate",label:"视频生成",desc:"文/图生视频(Doubao Seedance),含任务查询。",importLine:"from veadk.tools.builtin_tools.video_generate import video_generate, video_task_query",toolNames:["video_generate","video_task_query"],env:[{key:"MODEL_VIDEO_NAME",required:!1,placeholder:"doubao-seedance-2-0-260128"}]},{id:"text_to_speech",label:"语音合成 (TTS)",desc:"把文本转成语音(火山语音)。",importLine:"from veadk.tools.builtin_tools.tts import text_to_speech",toolNames:["text_to_speech"],env:[{key:"TOOL_VESPEECH_APP_ID",required:!0},{key:"TOOL_VESPEECH_SPEAKER",required:!1,placeholder:"zh_female_vv_uranus_bigtts"}]},{id:"run_code",label:"代码执行",desc:"在沙箱中执行代码",importLine:"from veadk.tools.builtin_tools.run_code import run_code",toolNames:["run_code"],env:[{key:"AGENTKIT_TOOL_ID",required:!0,placeholder:"t-xxxx",comment:"代码执行沙箱 ID"},{key:"AGENTKIT_TOOL_REGION",required:!1,placeholder:"cn-beijing",comment:"AgentKit Tools 地域"}]},{id:"vesearch",label:"VeSearch 智能搜索",desc:"火山 VeSearch(需要 bot 端点)。",importLine:"from veadk.tools.builtin_tools.vesearch import vesearch",toolNames:["vesearch"],env:[{key:"TOOL_VESEARCH_ENDPOINT",required:!0,comment:"VeSearch bot_id"}]}],bPe=new Set(["web_scraper","text_to_speech","vesearch"]),OPe=new Set(["web_search","parallel_web_search"]),yPe=Qp.filter(e=>!bPe.has(e.id));function Vne(e="volcengine"){const t=e==="byteplus"?OPe:new Set;return yPe.filter(n=>!t.has(n.id))}const RP=[{id:"local",label:"本地内存",desc:"进程内,不持久化。适合开发调试。",env:[]},{id:"sqlite",label:"SQLite 文件",desc:"持久化到本地 .db 文件。",extraArgs:'local_database_path="./short_term_memory.db"',env:[]},{id:"mysql",label:"MySQL",desc:"持久化到 MySQL。",env:[{key:"DATABASE_MYSQL_HOST",required:!0},{key:"DATABASE_MYSQL_USER",required:!0},{key:"DATABASE_MYSQL_PASSWORD",required:!0},{key:"DATABASE_MYSQL_DATABASE",required:!0}]},{id:"postgresql",label:"PostgreSQL",desc:"持久化到 PostgreSQL。",env:[{key:"DATABASE_POSTGRESQL_HOST",required:!0},{key:"DATABASE_POSTGRESQL_PORT",required:!1,placeholder:"5432"},{key:"DATABASE_POSTGRESQL_USER",required:!0},{key:"DATABASE_POSTGRESQL_PASSWORD",required:!0},{key:"DATABASE_POSTGRESQL_DATABASE",required:!0}]}],IP=[{id:"local",label:"本地向量库",desc:"进程内 llama-index 向量库。",env:GS,pipExtra:"extensions",needsEmbedding:!0},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"redis",label:"Redis",desc:"Redis 向量检索。",env:[{key:"DATABASE_REDIS_HOST",required:!0},{key:"DATABASE_REDIS_PORT",required:!1,placeholder:"6379"},{key:"DATABASE_REDIS_PASSWORD",required:!1},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"viking",label:"VikingDB Memory",desc:"VikingDB 记忆库(支持用户画像)。",env:mx},{id:"openviking",label:"OpenViking Memory",desc:"OpenViking 长期记忆,按用户维度保存和检索偏好、事件与实体。",env:[{key:"DATABASE_OPENVIKING_URL",required:!0,placeholder:zne,comment:"OpenViking 服务地址",link:Pk},{key:"DATABASE_OPENVIKING_API_KEY",required:!0,comment:"OpenViking API Key",link:Pk},{key:"DATABASE_OPENVIKING_USER_ID",required:!1,placeholder:"default",comment:"记忆归属 ID",help:"对应 viking://user/<此值>/peers/<请求用户>/memories 中的 user 段;用于隔离 Agent、租户或业务场景,默认 default。"},{key:"DATABASE_OPENVIKING_MEMORY_POLICY",required:!1,placeholder:mPe,comment:"记忆策略",multiline:!0,format:"json",help:"记忆的抽取策略和隔离策略,不填写时使用官方默认策略。",link:pPe}]},{id:"mem0",label:"Mem0",desc:"Mem0 托管记忆服务。",env:[{key:"DATABASE_MEM0_API_KEY",required:!0},{key:"DATABASE_MEM0_BASE_URL",required:!1}],pipExtra:"database"}],wf="viking",PP=[{id:"viking",label:"VikingDB Knowledge",desc:"VikingDB 知识库。",env:gPe},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"context_search",label:"Context Search",desc:"火山 Context Search 引擎(无需向量化)。",env:[...mx,{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ID",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ENDPOINT",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_APIKEY",required:!0}]},{id:"openviking",label:"OpenViking Knowledge",desc:"OpenViking 资源目录知识库,无需向量化模型配置。",env:[{key:"DATABASE_OPENVIKING_URL",required:!0,placeholder:zne,comment:"OpenViking 服务地址",link:Pk},{key:"DATABASE_OPENVIKING_API_KEY",required:!0,comment:"OpenViking API Key",link:Pk},{key:"DATABASE_OPENVIKING_USER_ID",required:!1,placeholder:"default",comment:"知识库归属 ID",help:"未配置资源目录时用于默认路径 viking://user/<此值>/resources/<知识库索引>/,默认 default。"},{key:"DATABASE_OPENVIKING_TARGET_URI",required:!1,placeholder:"viking://user/default/resources//",comment:"知识库资源目录",help:"留空时由 KnowledgeBase index 自动生成;填写后直接检索该 OpenViking 资源目录,优先级最高。"}]}],xPe=[{id:"apmplus",label:"APMPlus",desc:"火山 APMPlus 应用性能监控。",enableFlag:"ENABLE_APMPLUS",env:[{key:"OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME",required:!1}]},{id:"cozeloop",label:"CozeLoop",desc:"扣子 CozeLoop 链路观测。",enableFlag:"ENABLE_COZELOOP",env:[{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY",required:!0},{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME",required:!1,comment:"CozeLoop space_id"}]},{id:"tls",label:"TLS (日志服务)",desc:"火山 TLS 日志服务导出。",enableFlag:"ENABLE_TLS",env:[...mx,{key:"OBSERVABILITY_OPENTELEMETRY_TLS_SERVICE_NAME",required:!1,comment:"TLS topic_id,留空自动创建"}]}],vPe="一个基于 VeADK 构建的智能助手,理解用户意图并调用合适的工具完成任务。",wPe=`你是一个专业、可靠的智能助手。 +}`,bPe=[{key:"DATABASE_VIKING_PROJECT",required:!1,placeholder:"default"},{key:"DATABASE_VIKING_REGION",required:!1},{key:"DATABASE_VIKING_COLLECTION_KIND",required:!1},{key:"DATABASE_VIKING_RESOURCE_ID",required:!1}],Zb=[{key:"FEISHU_APP_ID",required:!0,placeholder:"cli_xxx",comment:"飞书应用 App ID"},{key:"FEISHU_APP_SECRET",required:!0,placeholder:"输入 App Secret",comment:"飞书应用 App Secret"}],Pl={topK:"3",region:"cn-beijing",endpoint:"https://open.volcengineapi.com/"},Vne=[{key:"REGISTRY_SPACE_ID",required:!0,placeholder:"请选择智能体中心",comment:"AgentKit 智能体中心"},{key:"REGISTRY_TOP_K",required:!1,placeholder:Pl.topK,comment:"召回 Agent 数量"},{key:"REGISTRY_REGION",required:!1,placeholder:Pl.region,comment:"AgentKit 智能体中心地域"},{key:"REGISTRY_ENDPOINT",required:!1,placeholder:Pl.endpoint,comment:"AgentKit 智能体中心 OpenAPI 地址"}],Qp=[{id:"web_search",label:"联网搜索",desc:"火山引擎 Web Search,获取实时信息。",importLine:"from veadk.tools.builtin_tools.web_search import web_search",toolNames:["web_search"],env:mx},{id:"parallel_web_search",label:"并行联网搜索",desc:"并行发起多条搜索查询,更快汇总。",importLine:"from veadk.tools.builtin_tools.parallel_web_search import parallel_web_search",toolNames:["parallel_web_search"],env:mx},{id:"link_reader",label:"网页读取",desc:"抓取并阅读给定链接的正文内容。",importLine:"from veadk.tools.builtin_tools.link_reader import link_reader",toolNames:["link_reader"],env:[]},{id:"web_scraper",label:"网页爬取",desc:"结构化爬取网页(需要 Scraper 服务)。",importLine:"from veadk.tools.builtin_tools.web_scraper import web_scraper",toolNames:["web_scraper"],env:[{key:"TOOL_WEB_SCRAPER_ENDPOINT",required:!0},{key:"TOOL_WEB_SCRAPER_API_KEY",required:!0}]},{id:"image_generate",label:"图像生成",desc:"文生图(Doubao Seedream)。",importLine:"from veadk.tools.builtin_tools.image_generate import image_generate",toolNames:["image_generate"],env:[{key:"MODEL_IMAGE_NAME",required:!1,placeholder:"doubao-seedream-5-0-260128"}]},{id:"image_edit",label:"图像编辑",desc:"图生图 / 编辑(Doubao SeedEdit)。",importLine:"from veadk.tools.builtin_tools.image_edit import image_edit",toolNames:["image_edit"],env:[{key:"MODEL_EDIT_NAME",required:!1,placeholder:"doubao-seededit-3-0-i2i-250628"}]},{id:"video_generate",label:"视频生成",desc:"文/图生视频(Doubao Seedance),含任务查询。",importLine:"from veadk.tools.builtin_tools.video_generate import video_generate, video_task_query",toolNames:["video_generate","video_task_query"],env:[{key:"MODEL_VIDEO_NAME",required:!1,placeholder:"doubao-seedance-2-0-260128"}]},{id:"text_to_speech",label:"语音合成 (TTS)",desc:"把文本转成语音(火山语音)。",importLine:"from veadk.tools.builtin_tools.tts import text_to_speech",toolNames:["text_to_speech"],env:[{key:"TOOL_VESPEECH_APP_ID",required:!0},{key:"TOOL_VESPEECH_SPEAKER",required:!1,placeholder:"zh_female_vv_uranus_bigtts"}]},{id:"run_code",label:"代码执行",desc:"在沙箱中执行代码",importLine:"from veadk.tools.builtin_tools.run_code import run_code",toolNames:["run_code"],env:[{key:"AGENTKIT_TOOL_ID",required:!0,placeholder:"t-xxxx",comment:"代码执行沙箱 ID"},{key:"AGENTKIT_TOOL_REGION",required:!1,placeholder:"cn-beijing",comment:"AgentKit Tools 地域"}]},{id:"vesearch",label:"VeSearch 智能搜索",desc:"火山 VeSearch(需要 bot 端点)。",importLine:"from veadk.tools.builtin_tools.vesearch import vesearch",toolNames:["vesearch"],env:[{key:"TOOL_VESEARCH_ENDPOINT",required:!0,comment:"VeSearch bot_id"}]}],OPe=new Set(["web_scraper","text_to_speech","vesearch"]),yPe=new Set(["web_search","parallel_web_search"]),xPe=Qp.filter(e=>!OPe.has(e.id));function Xne(e="volcengine"){const t=e==="byteplus"?yPe:new Set;return xPe.filter(n=>!t.has(n.id))}const RP=[{id:"local",label:"本地内存",desc:"进程内,不持久化。适合开发调试。",env:[]},{id:"sqlite",label:"SQLite 文件",desc:"持久化到本地 .db 文件。",extraArgs:'local_database_path="./short_term_memory.db"',env:[]},{id:"mysql",label:"MySQL",desc:"持久化到 MySQL。",env:[{key:"DATABASE_MYSQL_HOST",required:!0},{key:"DATABASE_MYSQL_USER",required:!0},{key:"DATABASE_MYSQL_PASSWORD",required:!0},{key:"DATABASE_MYSQL_DATABASE",required:!0}]},{id:"postgresql",label:"PostgreSQL",desc:"持久化到 PostgreSQL。",env:[{key:"DATABASE_POSTGRESQL_HOST",required:!0},{key:"DATABASE_POSTGRESQL_PORT",required:!1,placeholder:"5432"},{key:"DATABASE_POSTGRESQL_USER",required:!0},{key:"DATABASE_POSTGRESQL_PASSWORD",required:!0},{key:"DATABASE_POSTGRESQL_DATABASE",required:!0}]}],IP=[{id:"local",label:"本地向量库",desc:"进程内 llama-index 向量库。",env:GS,pipExtra:"extensions",needsEmbedding:!0},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"redis",label:"Redis",desc:"Redis 向量检索。",env:[{key:"DATABASE_REDIS_HOST",required:!0},{key:"DATABASE_REDIS_PORT",required:!1,placeholder:"6379"},{key:"DATABASE_REDIS_PASSWORD",required:!1},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"viking",label:"VikingDB Memory",desc:"VikingDB 记忆库(支持用户画像)。",env:mx},{id:"openviking",label:"OpenViking Memory",desc:"OpenViking 长期记忆,按用户维度保存和检索偏好、事件与实体。",env:[{key:"DATABASE_OPENVIKING_URL",required:!0,placeholder:Fne,comment:"OpenViking 服务地址",link:Pk},{key:"DATABASE_OPENVIKING_API_KEY",required:!0,comment:"OpenViking API Key",link:Pk},{key:"DATABASE_OPENVIKING_USER_ID",required:!1,placeholder:"default",comment:"记忆归属 ID",help:"对应 viking://user/<此值>/peers/<请求用户>/memories 中的 user 段;用于隔离 Agent、租户或业务场景,默认 default。"},{key:"DATABASE_OPENVIKING_MEMORY_POLICY",required:!1,placeholder:gPe,comment:"记忆策略",multiline:!0,format:"json",help:"记忆的抽取策略和隔离策略,不填写时使用官方默认策略。",link:mPe}]},{id:"mem0",label:"Mem0",desc:"Mem0 托管记忆服务。",env:[{key:"DATABASE_MEM0_API_KEY",required:!0},{key:"DATABASE_MEM0_BASE_URL",required:!1}],pipExtra:"database"}],wf="viking",PP=[{id:"viking",label:"VikingDB Knowledge",desc:"VikingDB 知识库。",env:bPe},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...GS],pipExtra:"extensions",needsEmbedding:!0},{id:"context_search",label:"Context Search",desc:"火山 Context Search 引擎(无需向量化)。",env:[...mx,{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ID",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ENDPOINT",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_APIKEY",required:!0}]},{id:"openviking",label:"OpenViking Knowledge",desc:"OpenViking 资源目录知识库,无需向量化模型配置。",env:[{key:"DATABASE_OPENVIKING_URL",required:!0,placeholder:Fne,comment:"OpenViking 服务地址",link:Pk},{key:"DATABASE_OPENVIKING_API_KEY",required:!0,comment:"OpenViking API Key",link:Pk},{key:"DATABASE_OPENVIKING_USER_ID",required:!1,placeholder:"default",comment:"知识库归属 ID",help:"未配置资源目录时用于默认路径 viking://user/<此值>/resources/<知识库索引>/,默认 default。"},{key:"DATABASE_OPENVIKING_TARGET_URI",required:!1,placeholder:"viking://user/default/resources//",comment:"知识库资源目录",help:"留空时由 KnowledgeBase index 自动生成;填写后直接检索该 OpenViking 资源目录,优先级最高。"}]}],vPe=[{id:"apmplus",label:"APMPlus",desc:"火山 APMPlus 应用性能监控。",enableFlag:"ENABLE_APMPLUS",env:[{key:"OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME",required:!1}]},{id:"cozeloop",label:"CozeLoop",desc:"扣子 CozeLoop 链路观测。",enableFlag:"ENABLE_COZELOOP",env:[{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY",required:!0},{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME",required:!1,comment:"CozeLoop space_id"}]},{id:"tls",label:"TLS (日志服务)",desc:"火山 TLS 日志服务导出。",enableFlag:"ENABLE_TLS",env:[...mx,{key:"OBSERVABILITY_OPENTELEMETRY_TLS_SERVICE_NAME",required:!1,comment:"TLS topic_id,留空自动创建"}]}],wPe="一个基于 VeADK 构建的智能助手,理解用户意图并调用合适的工具完成任务。",SPe=`你是一个专业、可靠的智能助手。 你的目标是准确理解用户的需求,并给出条理清晰、简洁有用的回答。 约束: - 信息不足时主动提问澄清,不要臆造事实。 - 需要时合理调用可用的工具,并说明关键结论。 -- 保持礼貌、专业的语气。`;function el(e="volcengine"){return{name:"",description:vPe,instruction:wPe,agentType:"llm",cloudProvider:e,maxIterations:3,a2aUrl:"",tools:[],skills:[],memory:{shortTerm:!1,longTerm:!1},knowledgebase:!1,tracing:!1,subAgents:[],builtinTools:[],customTools:[],mcpTools:[],a2aRegistry:{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},modelName:t0(e),modelSource:"ark",modelProvider:"",modelApiBase:"",shortTermBackend:"local",longTermBackend:"local",autoSaveSession:!1,knowledgebaseBackend:wf,knowledgebaseIndex:"",tracingExporters:[],selectedSkills:[],deployment:{feishuEnabled:!1,modelApiKeyId:"",modelApiKeyName:""}}}const SPe="/web/skill-management";class EPe extends Error{constructor(t,n,i="SKILL_MANAGEMENT_ERROR",r="",s,a=""){super(t),this.status=n,this.code=i,this.statusText=r,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function md(e,t={},n=_o){return fetch(vo(`${SPe}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function Xne(e,t){let n=t,i="SKILL_MANAGEMENT_ERROR",r;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,i=a.detail.code||i,r=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new EPe(n,e.status,i,e.statusText,r,s)}async function gd(e,t){if(!e.ok)throw await Xne(e,t);return e.json()}async function kPe(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),gd(await md(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function TPe(e){return gd(await md("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function _Pe(e){return gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function APe(e){const t=new URLSearchParams({region:e.region});await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function NPe(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},kr),"上传 Skill 失败")}async function CPe(e){return gd(await md("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},kr),"校验 Skill 失败")}async function jPe(e){const t=new URLSearchParams({region:e.region});await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function RPe(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version);const n=await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function IPe(e){var o;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version);const n=await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},kr);n.ok||await gd(n,"下载 Skill 失败");const r=((o=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:o[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=r,a.click(),URL.revokeObjectURL(s)}async function z_(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(!t.ok)throw await Xne(t,"AgentKit Skills 请求失败");return t.json()}async function A$(){return(await z_("/web/skill-spaces?region=all")).items||[]}async function N$(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function PPe(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function MPe(e,t,n,i,r){const s=[];n&&s.push(`version=${encodeURIComponent(n)}`),i&&s.push(`region=${encodeURIComponent(i)}`),r&&s.push(`project=${encodeURIComponent(r)}`);const a=s.length>0?`?${s.join("&")}`:"";return z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${a}`)}function LPe(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function DPe(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}function VU({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M4.5 6.7h4.2M12.3 6.7h7.2"}),l.jsx("path",{d:"M4.5 12h8.2M16.3 12h3.2"}),l.jsx("path",{d:"M4.5 17.3h2.7M10.8 17.3h8.7"}),l.jsx("circle",{cx:"10.5",cy:"6.7",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"12",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"9",cy:"17.3",r:"1.8",fill:"currentColor",stroke:"none"})]})}const $Pe={coding:"智能编程",get_city_weather:"城市天气查询",get_location_weather:"位置天气查询",web_fetch:"网页内容获取"};function MP(e){const t=Qp.find(n=>n.id===e||n.toolNames.includes(e));return $Pe[e]??(t==null?void 0:t.label)??e}function XU(e){const t=Qp.find(i=>i.id===e||i.toolNames.includes(e));return((t==null?void 0:t.desc)??"由 VeADK 提供的内置工具").replace(/[。.]+$/,"")}function QPe(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function BPe(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"5.8",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.2 15.2 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function qU(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function qne({title:e,description:t,icon:n,wide:i=!1,onClose:r,children:s}){const a=m.useRef(`session-capability-${Math.random().toString(36).slice(2)}`);return m.useEffect(()=>{const o=document.body.style.overflow;document.body.style.overflow="hidden";const c=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=o}},[r]),zi.createPortal(l.jsxs("div",{className:"session-capability-dialog-layer",children:[l.jsx("button",{type:"button",className:"session-capability-dialog-scrim","aria-label":"关闭弹窗",onClick:r}),l.jsxs("section",{className:`session-capability-dialog${i?" is-wide":""}`,role:"dialog","aria-modal":"true","aria-labelledby":a.current,children:[l.jsxs("header",{className:`session-capability-dialog-head${n?"":" is-iconless"}`,children:[n&&l.jsx("span",{className:"session-capability-dialog-mark",children:n}),l.jsxs("div",{children:[l.jsx("h2",{id:a.current,children:e}),l.jsx("p",{children:t})]}),l.jsx("button",{type:"button",className:"session-capability-dialog-close","aria-label":`关闭${e}`,onClick:r,children:l.jsx(QPe,{})})]}),s]})]}),document.body)}function WS({value:e,placeholder:t,label:n,onChange:i,autoFocus:r=!1}){return l.jsxs("label",{className:"session-capability-search",children:[l.jsx(BPe,{}),l.jsx("input",{value:e,"aria-label":n,placeholder:t,autoFocus:r,onChange:s=>i(s.target.value)})]})}function UPe({agentName:e,tools:t,selectedNames:n,mutating:i,onAdd:r,onClose:s}){const[a,o]=m.useState(""),[c,u]=m.useState(""),d=m.useMemo(()=>new Set(n),[n]),f=m.useMemo(()=>{const p=a.trim().toLowerCase();return t.filter(g=>p?`${MP(g)} ${g} ${XU(g)}`.toLowerCase().includes(p):!0)},[a,t]),h=async p=>{u(p);const g=await r({kind:"tool",name:p});u(""),g&&s()};return l.jsx(qne,{title:"添加内置工具",description:`添加后仅对 ${e} 的当前会话生效`,icon:l.jsx(VU,{}),onClose:s,children:l.jsxs("div",{className:"session-tool-dialog-body",children:[l.jsx(WS,{value:a,label:"搜索内置工具",placeholder:"搜索中文名称或工具标识",onChange:o,autoFocus:!0}),l.jsx("div",{className:"session-tool-picker",role:"list","aria-label":"可用内置工具",children:f.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的内置工具"}):f.map(p=>{const g=d.has(p),b=c===p;return l.jsxs("article",{className:"session-tool-option",role:"listitem",children:[l.jsx("span",{className:"session-tool-option-icon",children:l.jsx(VU,{})}),l.jsxs("span",{className:"session-tool-option-copy",children:[l.jsx("strong",{children:MP(p)}),l.jsx("code",{children:p}),l.jsx("span",{children:XU(p)})]}),l.jsx("button",{type:"button",disabled:g||i||!!c,onClick:()=>void h(p),children:g?"已添加":b?"添加中…":"添加"})]},p)})})]})})}function zPe({appName:e,agentName:t,selectedNames:n,mutating:i,onAdd:r,onClose:s}){const[a,o]=m.useState("public"),[c,u]=m.useState(""),[d,f]=m.useState([]),[h,p]=m.useState(0),[g,b]=m.useState(!0),[y,O]=m.useState(""),[v,x]=m.useState([]),[w,E]=m.useState(null),[S,k]=m.useState([]),[T,A]=m.useState(""),[N,C]=m.useState(""),[M,L]=m.useState(!0),[P,Q]=m.useState(!1),[j,$]=m.useState(""),[U,B]=m.useState(""),I=m.useMemo(()=>new Set(n),[n]);m.useEffect(()=>{if(a!=="public")return;let re=!0;const fe=window.setTimeout(()=>{b(!0),O(""),qJ(e,c.trim()).then(Ae=>{re&&(f(Ae.items),p(Ae.totalCount))}).catch(Ae=>{re&&(f([]),p(0),O(Ae instanceof Error?Ae.message:"搜索 Skill Hub 失败"))}).finally(()=>{re&&b(!1)})},250);return()=>{re=!1,window.clearTimeout(fe)}},[e,c,a]),m.useEffect(()=>{if(a!=="agentkit")return;let re=!0;return L(!0),$(""),A$().then(fe=>{re&&(x(fe),E(fe[0]??null))}).catch(fe=>{re&&$(fe instanceof Error?fe.message:"读取 Skill Space 失败")}).finally(()=>{re&&L(!1)}),()=>{re=!1}},[a]),m.useEffect(()=>{if(a!=="agentkit")return;if(!w){k([]);return}let re=!0;return Q(!0),$(""),N$(w.id,w.region).then(fe=>{re&&k(fe)}).catch(fe=>{re&&$(fe instanceof Error?fe.message:"读取技能失败")}).finally(()=>{re&&Q(!1)}),()=>{re=!1}},[w,a]);const X=m.useMemo(()=>{const re=T.trim().toLowerCase();return re?v.filter(fe=>`${fe.name} ${fe.id} ${fe.description}`.toLowerCase().includes(re)):v},[T,v]),q=m.useMemo(()=>{const re=N.trim().toLowerCase();return re?S.filter(fe=>`${fe.skillName} ${fe.skillDescription}`.toLowerCase().includes(re)):S},[N,S]),D=async re=>{if(!w)return;B(re.skillId);const fe=await r({kind:"skill",name:re.skillName,skillSourceId:w.id,description:re.skillDescription,version:re.version});B(""),fe&&s()},H=async re=>{B(re.slug);const fe=await r({kind:"skill",name:re.name,skillSourceId:`findskill:${re.slug}`,description:re.description,version:re.version||re.updatedAt});B(""),fe&&s()};return l.jsx(qne,{title:"添加技能",description:`从公域 Skill Hub 或 AgentKit Skill 中心添加到 ${t} 当前会话`,wide:!0,onClose:s,children:l.jsxs("div",{className:"session-skill-dialog-body",children:[l.jsxs("div",{className:"session-skill-source-tabs",role:"tablist","aria-label":"技能来源",children:[l.jsxs("button",{type:"button",role:"tab","aria-selected":a==="public",className:a==="public"?"is-active":"",onClick:()=>o("public"),children:["Skill Hub",l.jsx("span",{children:"公域"})]}),l.jsx("button",{type:"button",role:"tab","aria-selected":a==="agentkit",className:a==="agentkit"?"is-active":"",onClick:()=>o("agentkit"),children:"AgentKit Skill 中心"})]}),a==="public"?l.jsxs("section",{className:"session-public-skill-browser","aria-label":"Skill Hub 公域技能",children:[l.jsxs("div",{className:"session-public-skill-head",children:[l.jsx(WS,{value:c,label:"搜索 Skill Hub",placeholder:"搜索技能名称、用途或关键词",onChange:u,autoFocus:!0}),l.jsxs("span",{children:[h.toLocaleString()," 个公域技能"]})]}),l.jsx("div",{className:"session-public-skill-list",children:y?l.jsx("div",{className:"session-capability-error",children:y}):g?l.jsx("div",{className:"session-capability-loading",children:"正在搜索 Skill Hub…"}):d.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的公域技能"}):d.map(re=>{const fe=I.has(re.name),Ae=U===re.slug;return l.jsxs("article",{className:"session-skill-option session-public-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:re.name}),l.jsx("span",{children:re.description||"暂无描述"}),l.jsxs("small",{children:[re.sourceRepo||re.sourceType||"FindSkill",l.jsx("span",{"aria-hidden":"true",children:" · "}),re.downloadCount.toLocaleString()," 次下载",re.evaluationScore>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",children:" · "}),re.evaluationScore.toFixed(1)," 分"]})]})]}),l.jsx("button",{type:"button",disabled:fe||i||!!U,onClick:()=>void H(re),children:fe?"已添加":Ae?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(qU,{}),"添加"]})})]},re.slug)})})]}):l.jsxs("div",{className:"session-skill-browser",children:[l.jsxs("section",{className:"session-skill-spaces","aria-label":"Skill Space 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Skill Space"}),l.jsx("span",{children:v.length})]}),l.jsx(WS,{value:T,label:"搜索 Skill Space",placeholder:"搜索空间",onChange:A,autoFocus:!0})]}),l.jsx("div",{className:"session-skill-pane-list",children:M?l.jsx("div",{className:"session-capability-loading",children:"正在读取 Skill Space…"}):X.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的 Skill Space"}):X.map(re=>l.jsx("button",{type:"button",className:`session-skill-space${(w==null?void 0:w.id)===re.id?" is-active":""}`,onClick:()=>{E(re),C("")},children:l.jsxs("span",{children:[l.jsx("strong",{children:re.name||re.id}),l.jsx("small",{children:re.description||re.id}),l.jsxs("em",{children:[re.skillCount??0," 个技能"]})]})},`${re.projectName??"default"}:${re.id}`))})]}),l.jsxs("section",{className:"session-skill-results","aria-label":"AgentKit Skill 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{title:w==null?void 0:w.name,children:(w==null?void 0:w.name)||"选择 Skill Space"}),l.jsx("span",{children:S.length})]}),l.jsx(WS,{value:N,label:"搜索 AgentKit 技能",placeholder:"搜索技能名称或描述",onChange:C})]}),l.jsx("div",{className:"session-skill-pane-list",children:j?l.jsx("div",{className:"session-capability-error",children:j}):w?P?l.jsx("div",{className:"session-capability-loading",children:"正在读取技能…"}):q.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的技能"}):q.map(re=>{const fe=I.has(re.skillName),Ae=U===re.skillId;return l.jsxs("article",{className:"session-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:re.skillName}),l.jsx("span",{children:re.skillDescription||"暂无描述"}),l.jsxs("small",{children:["版本 ",re.version||"—"]})]}),l.jsx("button",{type:"button",disabled:fe||i||!!U,onClick:()=>void D(re),children:fe?"已添加":Ae?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(qU,{}),"添加"]})})]},`${re.skillId}:${re.version}`)}):l.jsx("div",{className:"session-capability-empty",children:"选择一个 Skill Space 查看技能"})})]})]})]})})}function oi({as:e="span",className:t="",duration:n=4,spread:i=20,children:r,style:s,...a}){const o=Math.min(Math.max(i,5),45);return l.jsx(e,{className:`text-shimmer${t?` ${t}`:""}`,style:{...s,backgroundImage:`linear-gradient(to right, hsl(var(--muted-foreground)) ${50-o}%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground)) ${50+o}%)`,animationDuration:`${n}s`},...a,children:r})}function Hne(e){return 1+e.children.reduce((t,n)=>t+Hne(n),0)}function Yne(e){return e.id||e.name}function FPe(e,t){const n=Yne(e);if(e.id&&e.name&&e.name!==n)return e.name;if(t&&n==="agent")return"主 Agent";const i=/^agent_sub_(\d+)$/.exec(n);return i?`子 Agent ${i[1]}`:e.name||n}function Gne(e,t=!0){return{...e,id:Yne(e),name:FPe(e,t),children:e.children.map(n=>Gne(n,!1))}}function Wne(e){const t=el();return{...t,name:e.name,description:e.description,instruction:e.instruction||t.instruction,agentType:e.type,modelName:e.model,tools:e.tools??[],skills:(e.skills??[]).map(n=>n.name),subAgents:e.children.map(Wne)}}function VPe(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function XPe(e){return[...new Map(e.filter(t=>t.name.trim()).map(t=>[t.name.trim(),{...t,name:t.name.trim()}])).values()]}function sC({title:e,count:t}){return l.jsxs("div",{className:"topo-module-title",children:[l.jsx("span",{className:"topo-module-label",title:e,children:e}),t!==void 0&&l.jsx("span",{className:"topo-section-count","aria-label":`${t} 项`,children:t})]})}function qPe({appName:e,info:t,loading:n,variant:i="rail",capabilities:r=null,capabilityLoading:s=!1,capabilityMutating:a=!1,builtinTools:o=[],onAddCapability:c,onRemoveCapability:u}){const[d,f]=m.useState(null),[h,p]=m.useState(!1),g=m.useRef(null),b=()=>{p(!1),window.requestAnimationFrame(()=>{var S;return(S=g.current)==null?void 0:S.focus()})};if(m.useEffect(()=>{if(!h)return;const S=document.body.style.overflow,k=T=>{T.key==="Escape"&&b()};return document.body.style.overflow="hidden",document.addEventListener("keydown",k),()=>{document.body.style.overflow=S,document.removeEventListener("keydown",k)}},[h]),n&&!t)return l.jsx("aside",{className:`topo is-loading${i==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息","aria-live":"polite",children:l.jsx(oi,{as:"span",className:"topo-loading-label",duration:2.2,children:"正在读取 Agent 信息…"})});if(!t)return null;const y=Gne(t.graph??{id:t.name,name:t.name,description:t.description,type:t.type??"llm",model:t.model,tools:t.tools,skills:t.skills,path:[t.name],mentionable:!1,children:[]}),O=(r==null?void 0:r.tools)??VPe(t.tools).map(S=>({id:`base:tool:${S}`,kind:"tool",name:S,custom:!1})),v=(r==null?void 0:r.skills)??XPe(t.skills).map(S=>({id:`base:skill:${S.name}`,kind:"skill",name:S.name,description:S.description,custom:!1})),x=!!(r&&c&&u),w=Wne(y),E=S=>l.jsx(px,{draft:w,direction:"horizontal",selectedPath:[],onSelect:()=>{},onAdd:()=>{},onInsert:()=>{},onDelete:()=>{},readOnly:!0,interactivePreview:!0},S);return l.jsxs(l.Fragment,{children:[l.jsxs("aside",{className:`topo${i==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息与拓扑",children:[l.jsxs("section",{className:"topo-agent-card","aria-label":"Agent 信息",children:[l.jsxs("div",{className:"topo-agent-heading",children:[l.jsx("h2",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]}),t.description&&l.jsx("p",{className:"topo-description",title:t.description,children:t.description})]}),l.jsxs("div",{className:"topo-module-stack",children:[l.jsxs("section",{className:"topo-module-card topo-tools-card","aria-label":"工具",children:[l.jsx(sC,{title:"工具",count:O.length}),l.jsx("div",{className:"topo-module-scroll topo-tools-scroll",role:"region","aria-label":"工具列表",tabIndex:0,children:O.length>0?l.jsx("div",{className:"topo-tool-list",children:O.map(S=>l.jsxs("div",{className:"topo-tool",title:S.name,children:[l.jsxs("span",{className:"topo-capability-title",children:[l.jsxs("span",{className:"topo-capability-copy",children:[l.jsx("span",{className:"topo-capability-name",children:MP(S.name)}),l.jsx("code",{children:S.name})]}),S.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"})]}),S.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除工具 ${S.name}`,title:"移除",disabled:a,onClick:()=>u==null?void 0:u(S.id),children:"×"})]},S.id))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),x&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加内置工具",disabled:s||a,onClick:()=>f("tool"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加工具"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-skills-card","aria-label":"技能",children:[l.jsx(sC,{title:"技能",count:t.skillsPreviewSupported?v.length:void 0}),l.jsx("div",{className:"topo-module-scroll topo-skills-scroll",role:"region","aria-label":"技能列表",tabIndex:0,children:t.skillsPreviewSupported?v.length>0?l.jsx("div",{className:"topo-skill-list",children:v.map(S=>l.jsxs("div",{className:"topo-skill",title:S.description||S.name,children:[l.jsxs("div",{className:"topo-skill-title",children:[l.jsx("span",{className:"topo-skill-name",children:S.name}),S.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"}),S.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除技能 ${S.name}`,title:"移除",disabled:a,onClick:()=>u==null?void 0:u(S.id),children:"×"})]}),S.description&&l.jsx("span",{className:"topo-skill-description",children:S.description})]},`${S.name}:${S.description}`))}):l.jsx("div",{className:"topo-empty",children:"未配置"}):l.jsx("div",{className:"topo-empty",children:"暂不支持预览"})}),x&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加技能",disabled:s||a,onClick:()=>f("skill"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加技能"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-topology","aria-label":"Agent 画布",children:[l.jsxs("div",{className:"topo-canvas-heading",children:[l.jsx(sC,{title:"结构拓扑",count:Hne(y)}),l.jsx("button",{ref:g,type:"button",className:"topo-canvas-expand","aria-label":"全屏查看 Agent 画布",title:"全屏查看",onClick:()=>p(!0),children:l.jsx(np,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"topo-canvas-preview",role:"region","aria-label":"Agent 执行画布",children:E(`conversation-canvas:${e}`)})]})]}),d==="tool"&&c&&l.jsx(UPe,{agentName:t.name,tools:o,selectedNames:O.map(S=>S.name),mutating:a,onAdd:c,onClose:()=>f(null)}),d==="skill"&&c&&l.jsx(zPe,{appName:e,agentName:t.name,selectedNames:v.map(S=>S.name),mutating:a,onAdd:c,onClose:()=>f(null)})]}),h&&zi.createPortal(l.jsxs("section",{className:"topo-canvas-dialog",role:"dialog","aria-modal":"true","aria-label":"全屏 Agent 执行画布",children:[l.jsxs("header",{className:"topo-canvas-dialog-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Agent 执行画布"}),l.jsx("span",{children:t.name})]}),l.jsx("button",{type:"button","aria-label":"关闭全屏画布",title:"关闭",onClick:b,autoFocus:!0,children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"topo-canvas-dialog-body",children:E(`conversation-canvas-fullscreen:${e}`)})]}),document.body)]})}const H0={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};function HU(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("rect",{x:"3.75",y:"5.25",width:"16.5",height:"13.5",rx:"2"}),l.jsx("path",{d:"m10.25 9 4.8 3-4.8 3V9Z"})]})}function HPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("circle",{cx:"10.7",cy:"10.7",r:"6.1"}),l.jsx("path",{d:"m15.25 15.25 4.2 4.2"})]})}function YPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M12 3.75v10.5M8.4 10.8 12 14.4l3.6-3.6"}),l.jsx("path",{d:"M5 17.25v2h14v-2"})]})}function GPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M8.75 8.75 6.9 10.6a3.4 3.4 0 0 0 4.8 4.8l1.85-1.85"}),l.jsx("path",{d:"m15.25 15.25 1.85-1.85a3.4 3.4 0 0 0-4.8-4.8l-1.85 1.85"}),l.jsx("path",{d:"m9.4 14.6 5.2-5.2"})]})}function WPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M5 19h3.2L18.6 8.6a1.7 1.7 0 0 0 0-2.4l-.8-.8a1.7 1.7 0 0 0-2.4 0L5 15.8V19Z"}),l.jsx("path",{d:"m13.9 6.9 3.2 3.2M5 15.8 8.2 19"})]})}function Zne(e){return l.jsx("svg",{...H0,...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}const ZPe=180,YU=500,GU=10,WU=32;function KPe(e){return Array.from(new Set(e.split(/[,,]/).map(t=>t.trim()).filter(Boolean)))}function JPe({artifact:e,busy:t,error:n,onClose:i,onSave:r}){const[s,a]=m.useState(e.name),[o,c]=m.useState(e.description??""),[u,d]=m.useState((e.tags??[]).join(",")),[f,h]=m.useState(""),p=m.useId(),g=m.useId(),b=m.useRef(null),y=m.useRef(null),O=m.useRef(t),v=m.useRef(i);m.useEffect(()=>{O.current=t,v.current=i},[t,i]),m.useEffect(()=>{var T,A;const E=document.body.style.overflow,S=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(T=y.current)==null||T.focus(),(A=y.current)==null||A.select();const k=N=>{if(N.key==="Escape"&&!O.current){N.preventDefault(),v.current();return}if(N.key!=="Tab")return;const C=b.current;if(!C)return;const M=Array.from(C.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(Q=>Q.getClientRects().length>0);if(M.length===0){N.preventDefault();return}const L=M[0],P=M[M.length-1];N.shiftKey&&document.activeElement===L?(N.preventDefault(),P.focus()):!N.shiftKey&&document.activeElement===P&&(N.preventDefault(),L.focus())};return window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k),document.body.style.overflow=E,S!=null&&S.isConnected&&S.focus()}},[]);const x=E=>{var T;E.preventDefault();const S=s.trim(),k=KPe(u);if(!S){h("请输入产物名称"),(T=y.current)==null||T.focus();return}if(k.length>GU){h(`标签最多 ${GU} 个`);return}if(k.some(A=>A.length>WU)){h(`单个标签不能超过 ${WU} 个字符`);return}h(""),r({name:S,description:o.trim(),tags:k})},w=f||n;return zi.createPortal(l.jsx("div",{className:"artifact-edit-backdrop",onMouseDown:E=>{E.target===E.currentTarget&&!t&&i()},children:l.jsxs("section",{ref:b,className:"artifact-edit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":g,"aria-busy":t||void 0,children:[l.jsxs("header",{className:"artifact-edit-dialog__header",children:[l.jsxs("div",{children:[l.jsx("h2",{id:p,children:"编辑产物信息"}),l.jsx("p",{id:g,children:"内容文件不会被修改"})]}),l.jsx("button",{type:"button",onClick:i,disabled:t,"aria-label":"关闭编辑框",children:l.jsx(Zne,{})})]}),l.jsxs("form",{onSubmit:x,children:[l.jsxs("div",{className:"artifact-edit-dialog__body",children:[l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"名称"}),l.jsx("input",{ref:y,value:s,maxLength:ZPe,disabled:t,"aria-invalid":!!w||void 0,onChange:E=>{a(E.target.value),h("")}})]}),l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{value:o,maxLength:YU,disabled:t,rows:4,placeholder:"补充用途、版本或使用说明",onChange:E=>c(E.target.value)}),l.jsxs("small",{children:[o.length,"/",YU]})]}),l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"标签"}),l.jsx("input",{value:u,disabled:t,placeholder:"使用逗号分隔,最多 10 个",onChange:E=>{d(E.target.value),h("")}})]}),w?l.jsx("div",{className:"artifact-edit-error",role:"alert",children:w}):null]}),l.jsxs("footer",{className:"artifact-edit-dialog__actions",children:[l.jsx("button",{type:"button",onClick:i,disabled:t,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:t,children:t?"保存中":"保存"})]})]})]})}),document.body)}function eMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"5.5",cy:"12",r:"1.4"}),l.jsx("circle",{cx:"12",cy:"12",r:"1.4"}),l.jsx("circle",{cx:"18.5",cy:"12",r:"1.4"})]})}function Kne({label:e,menuLabel:t,items:n,className:i="",placement:r="bottom-end"}){const[s,a]=m.useState(!1),o=m.useRef(null),c=m.useRef(null),u=m.useRef([]);m.useEffect(()=>{if(!s)return;const f=p=>{var g;(g=o.current)!=null&&g.contains(p.target)||a(!1)},h=p=>{var g;p.key==="Escape"&&(p.preventDefault(),a(!1),(g=c.current)==null||g.focus())};return window.addEventListener("pointerdown",f),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",f),window.removeEventListener("keydown",h)}},[s]),m.useEffect(()=>{var f;s&&((f=u.current.find(h=>h&&!h.disabled))==null||f.focus())},[s]);const d=f=>{var b;if(!s||!["ArrowDown","ArrowUp","Home","End"].includes(f.key))return;f.preventDefault();const h=u.current.filter(y=>!!(y&&!y.disabled));if(h.length===0)return;const p=h.indexOf(document.activeElement),g=f.key==="Home"?0:f.key==="End"?h.length-1:(p+(f.key==="ArrowDown"?1:-1)+h.length)%h.length;(b=h[g])==null||b.focus()};return l.jsxs("div",{className:"studio-action-menu",ref:o,onKeyDown:d,children:[l.jsx("button",{ref:c,type:"button",className:`studio-action-menu__trigger ${i}`.trim(),"aria-label":e,"aria-haspopup":"menu","aria-expanded":s,disabled:n.length===0,onClick:()=>a(f=>!f),children:l.jsx(eMe,{})}),s?l.jsx("div",{className:`studio-action-menu__popover studio-action-menu__popover--${r}`,role:"menu","aria-label":t,children:n.map((f,h)=>l.jsx("button",{ref:p=>{u.current[h]=p},type:"button",role:"menuitem",className:`studio-action-menu__item${f.danger?" is-danger":""}`,disabled:f.disabled,title:f.title,onClick:()=>{a(!1),f.onSelect()},children:f.label},f.label))}):null]})}function tMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 4.2 21 19H3L12 4.2Z"}),l.jsx("path",{d:"M12 9.4v4.2"}),l.jsx("path",{d:"M12 16.8h.01"})]})}function nMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function Mf({title:e,description:t,confirmLabel:n,cancelLabel:i="取消",closeLabel:r="关闭确认框",variant:s="warning",busy:a=!1,onCancel:o,onConfirm:c}){const u=m.useId(),d=m.useId(),f=m.useRef(null),h=m.useRef(a),p=m.useRef(o);return m.useEffect(()=>{h.current=a,p.current=o},[a,o]),m.useEffect(()=>{var O;const g=document.body.style.overflow,b=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(O=f.current)==null||O.focus();const y=v=>{v.key==="Escape"&&!h.current&&p.current()};return window.addEventListener("keydown",y),()=>{document.body.style.overflow=g,window.removeEventListener("keydown",y),b!=null&&b.isConnected&&b.focus()}},[]),zi.createPortal(l.jsx("div",{className:"studio-confirm-backdrop",onMouseDown:g=>{g.target===g.currentTarget&&!a&&o()},children:l.jsxs("section",{className:`studio-confirm-dialog studio-confirm-dialog--${s}`,role:"alertdialog","aria-modal":"true","aria-labelledby":u,"aria-describedby":d,"aria-busy":a||void 0,children:[l.jsxs("header",{className:"studio-confirm-head",children:[l.jsxs("div",{className:"studio-confirm-title-wrap",children:[l.jsx("span",{className:"studio-confirm-title-icon","aria-hidden":"true",children:l.jsx(tMe,{})}),l.jsx("h2",{id:u,children:e})]}),l.jsx("button",{type:"button",className:"studio-confirm-close",onClick:o,disabled:a,"aria-label":r,children:l.jsx(nMe,{})})]}),l.jsx("div",{className:"studio-confirm-body",children:l.jsx("p",{id:d,children:t})}),l.jsxs("footer",{className:"studio-confirm-actions",children:[l.jsx("button",{ref:f,type:"button",onClick:o,disabled:a,children:i}),l.jsx("button",{type:"button",className:"studio-confirm-primary",onClick:c,disabled:a,children:n})]})]})}),document.body)}const iMe=new Set(["avif","bmp","gif","heic","jpeg","jpg","png","svg","tif","tiff","webp"]),rMe=new Set(["avi","m4v","mkv","mov","mp4","mpeg","mpg","webm"]),sMe=new Set(["csv","htm","html","json","md","pdf","svg","txt","xml","yaml","yml"]);function Jne(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLocaleLowerCase()}function Mk(e,t){if(!Number.isFinite(e))return t;const n=e;return n>1e10?n:n*1e3}function aMe(e){var t,n;return((t=e.actions)==null?void 0:t.artifactDelta)??((n=e.actions)==null?void 0:n.artifact_delta)}function oMe(e){return`${e.replace(/\.pptx$/i,"")}.preview.webp`}function lMe(e){var t;return(((t=e.content)==null?void 0:t.parts)??[]).map(n=>n.functionResponse??n.function_response).filter(n=>!!n)}function cMe(e){if(!e)return{};const t=e.result;return t&&typeof t=="object"&&!Array.isArray(t)?t:e}function ZU(e,t,n){var i;if(/\.[A-Za-z0-9]{2,8}$/.test(e))return e;try{const r=new URL(t).pathname.split("/").filter(Boolean),a=((i=(r[r.length-1]??"").match(/\.[A-Za-z0-9]{2,8}$/))==null?void 0:i[0])??"";if(a)return`${e}${a}`}catch{}return`${e}.${n==="image"?"png":"mp4"}`}function uMe(e,t){const n=cMe(t),i=e==="image_generate"||e.endsWith("_image_generate"),r=["video_generate","video_task_query"].some(u=>e===u||e.endsWith(`_${u}`));if(!i&&!r)return[];const s=i?"image":"video",a=[],o=n.success_list;if(Array.isArray(o)){for(const u of o)if(!(!u||typeof u!="object"||Array.isArray(u)))for(const[d,f]of Object.entries(u))typeof f=="string"&&f.startsWith("https://")&&a.push({name:ZU(d,f,s),url:f,type:s})}const c=n.video_url;if(r&&typeof c=="string"&&c.startsWith("https://")){const u=typeof n.task_id=="string"?n.task_id:void 0;a.push({name:ZU(u||"generated-video",c,s),url:c,type:s,taskId:u})}return a}function KU(e,t){return new Date(Mk(e,t)||Date.now()).toISOString()}function dMe(e){var i;const t=[],n=new Set;for(const r of e)for(const s of r.sessions){const a=Mk(s.lastUpdateTime,Date.now()),o=E_(s.events);for(const c of s.events??[])for(const u of lMe(c)){const d=(u==null?void 0:u.name)??"";for(const f of uMe(d,u==null?void 0:u.response)){const h=`${s.id}:${c.id??""}:${d}:${f.url}`;n.has(h)||(n.add(h),t.push({sourceUrl:f.url,name:f.name,mimeType:f.type==="image"?"image/png":"video/mp4",appName:r.appName,agentId:r.agentId,agentName:((i=r.agentName)==null?void 0:i.trim())||r.appName,sessionId:s.id,sessionTitle:o,sessionUpdatedAt:KU(s.lastUpdateTime,a),createdAt:KU(c.timestamp,a),origin:{runtimeId:r.runtimeId,region:r.region,eventId:c.id,invocationId:c.invocationId??c.invocation_id,toolName:d,taskId:f.taskId}}))}}}return t}function eie(e){const t=Jne(e);return iMe.has(t)?"image":rMe.has(t)?"video":"document"}function fMe(e){const t=eie(e);return t==="image"?"image":t==="video"?"video":sMe.has(Jne(e))?"frame":"unavailable"}function hMe(e){var n;const t=[];for(const i of e)for(const r of i.sessions){const s=Mk(r.lastUpdateTime,0),a=new Map;for(const o of r.events??[]){const c=aMe(o);if(!c)continue;const u=Mk(o.timestamp,s);for(const[d,f]of Object.entries(c)){if(!d||!Number.isFinite(f))continue;const h=a.get(d);(!h||f>=h.version)&&a.set(d,{filename:d,version:f,createdAt:u})}}for(const o of a.values()){if(/\.preview\.webp$/i.test(o.filename))continue;const c=a.get(oMe(o.filename)),u=c??o,d=c?"image":fMe(o.filename);t.push({id:`${i.appName}:${r.id}:${o.filename}:${o.version}`,appName:i.appName,agentId:i.agentId,sessionId:r.id,sessionTitle:E_(r.events),agentName:((n=i.agentName)==null?void 0:n.trim())||i.appName,sessionUpdatedAt:s,name:o.filename,version:o.version,type:eie(o.filename),createdAt:o.createdAt||s,preview:{filename:u.filename,version:u.version,mode:d}})}}return t.sort((i,r)=>r.createdAt-i.createdAt||i.name.localeCompare(r.name,"zh-CN"))}function tie(e){if(!e)return"时间未知";const t=new Date(e);if(Number.isNaN(t.getTime()))return"时间未知";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?new Intl.DateTimeFormat("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t):new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}function nie(e){return!e||e<=0?"":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(e<10*1024*1024?1:0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}const aC=40,pMe=[{id:"document",label:"文档"},{id:"image",label:"图片"},{id:"video",label:"视频"}],mMe={document:"文档",image:"图片",video:"视频"};function mw(e){return e instanceof Error?e.message:String(e)}function iie({artifact:e,large:t=!1}){return l.jsx("div",{className:`library-artifact-preview library-artifact-preview--${e.type}${t?" is-large":""}`,children:e.thumbnailUrl?l.jsxs(l.Fragment,{children:[l.jsx("img",{className:"library-artifact-preview-media",src:e.thumbnailUrl,alt:"",loading:"lazy"}),e.type==="video"?l.jsx("span",{className:"artifact-video-play is-overlay","aria-hidden":"true",children:l.jsx(HU,{})}):null]}):e.type==="document"?l.jsxs("div",{className:"artifact-document-sheet","aria-hidden":"true",children:[l.jsx("span",{className:"is-title"}),l.jsx("span",{}),l.jsx("span",{}),l.jsx("span",{className:"is-short"})]}):e.type==="image"?l.jsxs("div",{className:"artifact-image-scene","aria-hidden":"true",children:[l.jsx("span",{className:"artifact-image-sun"}),l.jsx("span",{className:"artifact-image-plane artifact-image-plane--back"}),l.jsx("span",{className:"artifact-image-plane artifact-image-plane--front"})]}):l.jsxs("div",{className:"artifact-video-frame","aria-hidden":"true",children:[l.jsx("span",{className:"artifact-video-orbit"}),l.jsx("span",{className:"artifact-video-node artifact-video-node--one"}),l.jsx("span",{className:"artifact-video-node artifact-video-node--two"}),l.jsx("span",{className:"artifact-video-play",children:l.jsx(HU,{})})]})})}function gMe({artifact:e,pendingAction:t,disabled:n,onPreview:i,onDownload:r,onEdit:s,onDelete:a,onOpenSource:o}){const c=t===`download:${e.id}`;return l.jsxs("tr",{className:"library-artifact-row",children:[l.jsx("td",{className:"library-artifact-file",children:l.jsxs("button",{type:"button",className:"library-artifact-preview-trigger","aria-label":`预览 ${e.name}`,disabled:n||!!t,onClick:()=>i(e),children:[l.jsx("div",{className:"library-artifact-thumbnail",children:l.jsx(iie,{artifact:e})}),l.jsxs("div",{className:"library-artifact-row-title",children:[l.jsx("span",{className:"library-artifact-row-name",title:e.name,children:e.name}),l.jsx("span",{className:"library-artifact-row-size",children:nie(e.sizeBytes)||"—"})]})]})}),l.jsx("td",{className:"library-artifact-source-cell",children:o?l.jsxs("button",{type:"button",className:"library-artifact-source-link",title:`${e.agentName} / ${e.sessionTitle}`,onClick:()=>o(e),children:[l.jsx("span",{children:e.agentName}),l.jsx("span",{"aria-hidden":"true",children:"/"}),l.jsx("span",{children:e.sessionTitle})]}):l.jsxs("span",{title:`${e.agentName} / ${e.sessionTitle}`,children:[e.agentName," / ",e.sessionTitle]})}),l.jsx("td",{className:"library-artifact-time",children:tie(e.updatedAt??e.createdAt)}),l.jsx("td",{className:"library-artifact-actions-cell",children:l.jsx("div",{className:"library-artifact-actions",children:l.jsx(Kne,{label:`更多操作 ${e.name}`,menuLabel:`${e.name} 操作`,placement:"bottom-end",items:[{label:c?"下载中":"下载",onSelect:()=>r(e),disabled:n||!!t},...s?[{label:"编辑信息",onSelect:()=>s(e),disabled:n||!!t||e.canManage===!1}]:[],...a?[{label:"删除产物",onSelect:()=>a(e),disabled:n||!!t||e.canManage===!1,danger:!0}]:[]]})})})]})}function bMe({sources:e=[],items:t,userId:n="",active:i=!0,activationRevision:r=0,loading:s=!1,error:a="",onRetry:o,onEdit:c,onDelete:u,onDownload:d,onOpenSource:f}){var qe,W;const[h,p]=m.useState(null),[g,b]=m.useState(""),[y,O]=m.useState(null),[v,x]=m.useState(""),[w,E]=m.useState(""),[S,k]=m.useState(""),[T,A]=m.useState(""),[N,C]=m.useState({}),[M,L]=m.useState(()=>new Set),[P,Q]=m.useState(null),[j,$]=m.useState(!1),[U,B]=m.useState(""),[I,X]=m.useState(null),[q,D]=m.useState(!1),[H,re]=m.useState(aC),fe=m.useRef(null),Ae=m.useRef(null),J=m.useRef(0),ie=m.useRef(null),ue=m.useRef(null),ye=m.useRef(!1),Se=m.useCallback(()=>{J.current+=1,O(null),x(""),E("")},[]),Re=m.useMemo(()=>t?[...t]:hMe(e),[t,e]),Ee=m.useMemo(()=>Re.filter(K=>!M.has(K.id)).map(K=>N[K.id]??K),[Re,N,M]);m.useEffect(()=>()=>{J.current+=1},[]),m.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),m.useEffect(()=>{var z;if(!y)return;const K=document.activeElement,ae=document.body.style.overflow;document.body.style.overflow="hidden",(z=fe.current)==null||z.focus();const pe=ve=>{if(ve.key==="Escape"){ve.preventDefault(),Se();return}if(ve.key!=="Tab")return;const Be=Ae.current;if(!Be)return;const Je=Array.from(Be.querySelectorAll('button:not([disabled]), video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(Tt=>Tt.getClientRects().length>0);if(Je.length===0){ve.preventDefault();return}const kt=Je[0],Mt=Je[Je.length-1];ve.shiftKey&&document.activeElement===kt?(ve.preventDefault(),Mt.focus()):!ve.shiftKey&&document.activeElement===Mt&&(ve.preventDefault(),kt.focus())};return document.addEventListener("keydown",pe),()=>{document.removeEventListener("keydown",pe),document.body.style.overflow=ae,K!=null&&K.isConnected&&K.focus()}},[Se,y]);const me=async K=>{const ae=J.current+1;if(J.current=ae,k(""),x(""),O(K),K.preview.mode!=="unavailable"){if(K.contentUrl){x(K.contentUrl);return}E(`preview:${K.id}`);try{const pe=await YD(K.appName,n,K.sessionId,K.preview.filename,K.preview.version);if(J.current!==ae){URL.revokeObjectURL(pe);return}x(pe)}catch(pe){J.current===ae&&k(`无法预览“${K.name}”:${mw(pe)}`)}finally{J.current===ae&&E("")}}},oe=async K=>{k(""),E(`download:${K.id}`);try{d?await d(K):await HD(K.appName,n,K.sessionId,K.name,K.version),A(`已开始下载 ${K.name}`)}catch(ae){k(`无法下载“${K.name}”:${mw(ae)}`)}finally{E("")}},Ne=async K=>{if(!(!P||!c)){$(!0),B("");try{const pe=await c(P,K)??{...P,...K,updatedAt:Date.now()};C(z=>({...z,[P.id]:pe})),A(`已更新 ${pe.name}`),Q(null)}catch(ae){B(mw(ae))}finally{$(!1)}}},Oe=async()=>{if(!(!I||!u)){D(!0),k("");try{await u(I),L(K=>new Set([...K,I.id])),A(`已删除 ${I.name}`),(y==null?void 0:y.id)===I.id&&Se(),X(null)}catch(K){k(`无法删除“${I.name}”:${mw(K)}`),X(null)}finally{D(!1)}}},Ve=m.useMemo(()=>{const K=g.trim().toLocaleLowerCase();return Ee.filter(ae=>h&&ae.type!==h?!1:K?[ae.name,ae.sessionTitle,ae.agentName].some(pe=>pe.toLocaleLowerCase().includes(K)):!0)},[h,Ee,g]),We=m.useMemo(()=>Ve.slice(0,H),[Ve,H]),De=H{ye.current||(ye.current=!0,re(K=>K+aC))},[]);m.useEffect(()=>{re(aC)},[r,h,g,Ve.length]),m.useEffect(()=>{ye.current=!1},[H]),m.useEffect(()=>{const K=ue.current,ae=ie.current;if(!i||!K||!ae||!De)return;const pe=new IntersectionObserver(([z])=>{z.isIntersecting&&mt()},{root:ae,rootMargin:"240px 0px",threshold:.01});return pe.observe(K),()=>pe.disconnect()},[i,De,mt,H]);const at=()=>{const K=ie.current;!i||!K||!De||K.scrollHeight-K.scrollTop-K.clientHeight<=240&&mt()},Rt=!!g.trim()||h!==null;return l.jsxs("div",{className:"artifact-library-page",children:[l.jsxs("div",{className:"artifact-library-toolbar library-resource-toolbar",children:[l.jsx("nav",{className:"artifact-type-pills","aria-label":"产物类型",children:pMe.map(K=>l.jsx("button",{type:"button",className:`artifact-type-pill${h===K.id?" is-active":""}`,"aria-pressed":h===K.id,onClick:()=>p(ae=>ae===K.id?null:K.id),children:K.label},K.id))}),l.jsxs("label",{className:"artifact-library-search",children:[l.jsx(HPe,{}),l.jsx("input",{type:"search","aria-label":"搜索产物",value:g,onChange:K=>b(K.target.value),placeholder:"搜索产物或会话"})]})]}),a&&Ee.length>0?l.jsxs("div",{className:"artifact-library-banner",role:"alert",children:[l.jsx("span",{children:a}),o?l.jsx("button",{type:"button",onClick:o,children:"重试"}):null]}):null,S?l.jsxs("div",{className:"artifact-library-banner",role:"alert",children:[l.jsx("span",{children:S}),l.jsx("button",{type:"button",onClick:()=>k(""),children:"关闭"})]}):null,l.jsx("section",{ref:ie,className:"artifact-library-results","aria-label":"产物列表",onScroll:at,children:l.jsxs("div",{className:"artifact-library-panel",children:[s&&Ee.length===0?l.jsx("div",{className:"artifact-library-empty",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"p",duration:2.4,children:"正在加载产物"})}):a&&Ee.length===0?l.jsxs("div",{className:"artifact-library-empty is-error",role:"alert",children:[l.jsx("p",{children:"产物加载失败"}),l.jsx("span",{children:a}),o?l.jsx("button",{type:"button",onClick:o,children:"重新加载"}):null]}):Ve.length===0?l.jsxs("div",{className:"artifact-library-empty",children:[l.jsx("p",{children:Rt?"没有找到匹配的产物":"您还没有任何产物"}),l.jsx("span",{children:Rt?"请尝试搜索其他名称或切换类型":"聊天中生成的产物会自动显示在这里"})]}):l.jsx("div",{className:"artifact-library-list",children:l.jsxs("table",{className:"artifact-library-table",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"artifact-library-table__file-column"}),l.jsx("col",{className:"artifact-library-table__source-column"}),l.jsx("col",{className:"artifact-library-table__time-column"}),l.jsx("col",{className:"artifact-library-table__actions-column"})]}),l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"名称"}),l.jsx("th",{scope:"col",children:"来源"}),l.jsx("th",{scope:"col",children:"修改时间"}),l.jsx("th",{scope:"col",className:"artifact-library-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:We.map(K=>l.jsx(gMe,{artifact:K,pendingAction:w,disabled:!n&&!t,onPreview:ae=>void me(ae),onDownload:ae=>void oe(ae),onEdit:c?ae=>{B(""),Q(ae)}:void 0,onDelete:u?X:void 0,onOpenSource:f},K.id))})]})}),De?l.jsx("div",{ref:ue,className:"artifact-library-load-more",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",duration:2.4,children:"正在加载更多产物"})}):null]})}),l.jsx("p",{className:"artifact-library-status","aria-live":"polite",children:T}),y?l.jsxs("div",{className:"artifact-library-preview-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"artifact-library-preview-title",children:[l.jsx("button",{type:"button",className:"artifact-library-preview-backdrop","aria-label":"关闭预览",onClick:Se}),l.jsxs("div",{ref:Ae,className:"artifact-library-preview-panel",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("h2",{id:"artifact-library-preview-title",children:y.name}),l.jsxs("p",{children:[mMe[y.type]," / 版本 ",y.version]})]}),l.jsx("button",{ref:fe,type:"button","aria-label":"关闭预览",onClick:Se,children:l.jsx(Zne,{})})]}),l.jsxs("div",{className:"artifact-library-preview-content",children:[l.jsx("div",{className:"artifact-library-preview-canvas",children:w===`preview:${y.id}`?l.jsx(oi,{as:"span",duration:2.4,children:"正在加载预览"}):v&&y.preview.mode==="image"?l.jsx("img",{src:v,alt:`${y.name} 预览`}):v&&y.preview.mode==="video"?l.jsx("video",{src:v,controls:!0,"aria-label":`${y.name} 预览`}):v&&y.preview.mode==="frame"?l.jsx("iframe",{src:v,title:`${y.name} 预览`}):l.jsxs("div",{className:"artifact-library-preview-unavailable",children:[l.jsx(iie,{artifact:y,large:!0}),l.jsx("p",{children:S?"预览加载失败,请稍后重试或下载查看":"当前格式暂不支持在线预览,请下载查看"})]})}),l.jsxs("aside",{className:"artifact-library-preview-details","aria-label":"产物来源",children:[y.description?l.jsx("p",{className:"artifact-library-preview-description",children:y.description}):null,l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Agent"}),l.jsx("dd",{title:y.agentName,children:y.agentName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"会话"}),l.jsx("dd",{title:y.sessionTitle,children:y.sessionTitle})]}),(qe=y.origin)!=null&&qe.toolName?l.jsxs("div",{children:[l.jsx("dt",{children:"生成工具"}),l.jsx("dd",{children:y.origin.toolName})]}):null,l.jsxs("div",{children:[l.jsx("dt",{children:"生成时间"}),l.jsx("dd",{children:tie(y.createdAt)})]}),y.sizeBytes?l.jsxs("div",{children:[l.jsx("dt",{children:"文件大小"}),l.jsx("dd",{children:nie(y.sizeBytes)})]}):null]}),(W=y.tags)!=null&&W.length?l.jsx("div",{className:"artifact-library-preview-tags","aria-label":"标签",children:y.tags.map(K=>l.jsx("span",{children:K},K))}):null]})]}),l.jsxs("footer",{children:[l.jsxs("div",{className:"artifact-library-preview-footer-start",children:[f?l.jsxs("button",{type:"button",className:"is-secondary",onClick:()=>{const K=y;Se(),f(K)},children:[l.jsx(GPe,{}),"查看会话"]}):null,c?l.jsxs("button",{type:"button",className:"is-secondary",disabled:y.canManage===!1,onClick:()=>{const K=y;Se(),B(""),Q(K)},children:[l.jsx(WPe,{}),"编辑信息"]}):null]}),l.jsxs("button",{type:"button",disabled:w.startsWith("download:")||!n&&!t,onClick:()=>void oe(y),children:[l.jsx(YPe,{}),"下载"]})]})]})]}):null,P?l.jsx(JPe,{artifact:P,busy:j,error:U,onClose:()=>{j||Q(null)},onSave:K=>void Ne(K)}):null,I?l.jsx(Mf,{title:"删除产物?",description:`“${I.name}”将从产物库永久删除,聊天记录不会受到影响。`,confirmLabel:q?"删除中":"删除",closeLabel:"关闭删除确认框",variant:"danger",busy:q,onCancel:()=>{q||X(null)},onConfirm:()=>void Oe()}):null]})}function OMe(e,t){if(e&&typeof e=="object"&&"detail"in e){const n=e.detail;if(typeof n=="string"&&n.trim())return n}return t}async function C1(e,t){if(e.ok)return e;let n;try{n=await e.json()}catch{n=void 0}throw new Error(OMe(n,`${t}(${e.status})`))}function oC(e){if(typeof e=="number")return e;if(typeof e!="string")return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function rie(e){const t=e;return{...t,createdAt:oC(t.createdAt),updatedAt:oC(t.updatedAt),sessionUpdatedAt:oC(t.sessionUpdatedAt)}}async function sie(e){const t=await e.json();return Array.isArray(t.items)?t.items.map(rie):[]}async function yMe(){const e=await C1(await ri("/web/artifacts"),"读取产物库失败");return sie(e)}async function xMe(e){if(e.length===0)return yMe();const t=await C1(await ri("/web/artifacts/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidates:e})},24e4),"同步聊天产物失败");return sie(t)}async function vMe(e,t){const n=await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),"更新产物失败");return rie(await n.json())}async function wMe(e){await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}`,{method:"DELETE"}),"删除产物失败")}async function SMe(e){const n=await(await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}/content?download=true`,{},24e4),"下载产物失败")).blob(),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}function aie(e){var t,n,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t{const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const n=t.offsetWidth;let i=.985;n<=80?i=.96:n<=150?i=.97:n<=220?i=.98:n>600&&(i=.995),t.style.setProperty("--scale",i.toString())},LP=(e,t)=>{const n=()=>{const a=setTimeout(e);return()=>{clearTimeout(a)}};if(!AMe||typeof window.requestAnimationFrame!="function"||lie&&document.visibilityState==="hidden")return n();let r=2,s=window.requestAnimationFrame(function a(){r-=1,r===0?e():s=window.requestAnimationFrame(a)});return()=>{typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(s)}},C$=e=>Object.keys(e).reduce((n,i)=>{const r=e[i];if(r||r===0){const s=i.startsWith("--")?"":"--",a=typeof r=="number"?`${r}px`:r;n[`${s}${i}`]=a}return n},{}),ZS=e=>{e.preventDefault()},uie=e=>e.querySelectorAll('a[href], input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex^="-"]), [contenteditable]'),NMe=e=>{const t=m.Children.toArray(e),n=[];let i="";const r=()=>{i!==""&&(n.push(i),i="")};for(const s of t)if(!(s==null||typeof s=="boolean")){if(typeof s=="string"||typeof s=="number"){i+=String(s);continue}r(),n.push(s)}return r(),n},j$=e=>{const t=NMe(e),n=m.Children.count(t);return m.Children.map(t,i=>{if(typeof i=="string"&&i.trim())return n<=1?i:l.jsx("span",{children:i});if(m.isValidElement(i)){const r=i,{children:s,...a}=r.props;return s!=null?m.cloneElement(r,a,j$(s)):r}return i})};m.createContext(null);var CMe=typeof tf=="object"&&tf&&tf.Object===Object&&tf,jMe=typeof self=="object"&&self&&self.Object===Object&&self;CMe||jMe||Function("return this")();var RMe=typeof window<"u"?m.useLayoutEffect:m.useEffect;function IMe(){const e=m.useRef(!1);return m.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),m.useCallback(()=>e.current,[])}var JU={width:void 0,height:void 0};function PMe(e){const{ref:t,box:n="content-box"}=e,[{width:i,height:r},s]=m.useState(JU),a=IMe(),o=m.useRef({...JU}),c=m.useRef(void 0);return c.current=e.onResize,m.useEffect(()=>{if(!t.current||typeof window>"u"||!("ResizeObserver"in window))return;const u=new ResizeObserver(([d])=>{const f=n==="border-box"?"borderBoxSize":n==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",h=e7(d,f,"inlineSize"),p=e7(d,f,"blockSize");if(o.current.width!==h||o.current.height!==p){const b={width:h,height:p};o.current.width=h,o.current.height=p,c.current?c.current(b):a()&&s(b)}});return u.observe(t.current,{box:n}),()=>{u.disconnect()}},[n,t,a]),{width:i,height:r}}function e7(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:t==="contentBoxSize"?e.contentRect[n==="inlineSize"?"width":"height"]:void 0}function R$(e,t){const n=m.useRef(e);RMe(()=>{n.current=e},[e]),m.useEffect(()=>{if(!t&&t!==0)return;const i=setTimeout(()=>{n.current()},t);return()=>{clearTimeout(i)}},[t])}const MMe="_LoadingIndicator_7yl6f_1",LMe={LoadingIndicator:MMe},DMe=({className:e,size:t,strokeWidth:n,style:i,...r})=>l.jsx("div",{...r,className:Ps(LMe.LoadingIndicator,e),style:i||C$({"indicator-size":t,"indicator-stroke":n})});function die(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const $Me=()=>oie,t7=(e,t=!1,n="TransitionGroup")=>{const i=[];return m.Children.forEach(e,r=>{if(r&&typeof r=="object"&&"key"in r&&r.key)i.push(r);else if(t)throw new Error(`Child elements of <${n} /> must include a \`key\``)}),i},rm=()=>{},sm=e=>{const t=m.useRef(e);return t.current=e,m.useCallback(n=>t.current(n),[])};function QMe(e,t,n,i){const r=e.reduce((c,u)=>({...c,[u.key]:1}),{}),s=t.reduce((c,u)=>({...c,[u.component.key]:1}),{}),a=e.filter(c=>!s[c.key]).map(n),o=t.map(c=>({...c,component:e.find(({key:u})=>u===c.component.key)||c.component,shouldRender:!!r[c.component.key]}));return i==="append"?o.concat(a):a.concat(o)}function BMe(e,t,n){if((oie||kMe)&&t&&n>1)throw new Error(`Cannot use forwardRef with multiple children in <${e} />`)}const UMe="_TransitionGroupChild_1hv1z_1",zMe={TransitionGroupChild:UMe},fie={enter:!1,enterActive:!1,exit:!1,exitActive:!1,interrupted:!1},FMe=e=>({...fie,enter:!e}),VMe=(e,t)=>{switch(t.type){case"enter-before":return{enter:!0,enterActive:!1,exit:!1,exitActive:!1,interrupted:e.interrupted||e.exit};case"enter-active":return{enter:!0,enterActive:!0,exit:!1,exitActive:!1,interrupted:!1};case"exit-before":return{enter:!1,enterActive:!1,exit:!0,exitActive:!1,interrupted:e.interrupted||e.enter};case"exit-active":return{enter:!1,enterActive:!1,exit:!0,exitActive:!0,interrupted:!1};case"done":default:return fie}},XMe=({ref:e,as:t,children:n,className:i,transitionId:r,style:s,preventMountTransition:a,shouldRender:o,enterDuration:c,exitDuration:u,removeChild:d,onEnter:f,onEnterActive:h,onEnterComplete:p,onExit:g,onExitActive:b,onExitComplete:y})=>{const[O,v]=m.useReducer(VMe,FMe(a||!1)),x=m.useRef(!1),w=m.useRef(null),E=m.useRef(c);E.current=c;const S=m.useRef(u);S.current=u;const k=m.useRef(null),T=m.useCallback(A=>{const N=w.current;if(!(!N||A===k.current))switch(k.current=A,A){case"enter":f(N);break;case"enter-active":h(N);break;case"enter-complete":p(N);break;case"exit":g(N);break;case"exit-active":b(N);break;case"exit-complete":y(N);break}},[f,h,p,g,b,y]);return mn.useLayoutEffect(()=>{if(!o){let C;v({type:"exit-before"}),T("exit");const M=LP(()=>{v({type:"exit-active"}),T("exit-active"),C=window.setTimeout(()=>{T("exit-complete"),d()},S.current)});return()=>{M(),C!==void 0&&clearTimeout(C)}}if(a&&!x.current){x.current=!0;return}let A;v({type:"enter-before"}),T("enter");const N=LP(()=>{v({type:"enter-active"}),T("enter-active"),A=window.setTimeout(()=>{v({type:"done"}),T("enter-complete")},E.current)});return()=>{N(),A!==void 0&&clearTimeout(A)}},[o,a,d,T]),m.useEffect(()=>()=>{x.current=!1},[]),l.jsx(t,{ref:die([w,e]),className:Ps(i,zMe.TransitionGroupChild),"data-transition-id":r,style:s,"data-entering":O.enter?"":void 0,"data-entering-active":O.enterActive?"":void 0,"data-exiting":O.exit?"":void 0,"data-exiting-active":O.exitActive?"":void 0,"data-interrupted":O.interrupted?"":void 0,children:n})},qMe=e=>{const{enterMountDelay:t,preventMountTransition:n}=e,i=!n&&t!=null?t:null,[r,s]=m.useState(i==null);return R$(()=>s(!0),r?null:i),r?l.jsx(XMe,{...e}):null},hie=e=>{const{ref:t,as:n="span",children:i,className:r,transitionId:s,style:a,enterDuration:o=0,exitDuration:c=0,preventInitialTransition:u=!0,enterMountDelay:d,insertMethod:f="append",disableAnimations:h=$Me()}=e,p=sm(e.onEnter??rm),g=sm(e.onEnterActive??rm),b=sm(e.onEnterComplete??rm),y=sm(e.onExit??rm),O=sm(e.onExitActive??rm),v=sm(e.onExitComplete??rm);m.Children.forEach(i,S=>{if(S&&!S.key)throw new Error("Child elements of must include a `key`")});const x=m.useCallback(S=>({component:S,shouldRender:!0,removeChild:()=>{E(k=>k.filter(T=>S.key!==T.component.key))},onEnter:p,onEnterActive:g,onEnterComplete:b,onExit:y,onExitActive:O,onExitComplete:v}),[p,g,b,y,O,v]),[w,E]=m.useState(()=>t7(i).map(S=>({...x(S),preventMountTransition:u})));return m.useLayoutEffect(()=>{E(S=>{const k=t7(i);return QMe(k,S,x,f)})},[i,f,x]),BMe("TransitionGroup",t,m.Children.count(i)),h?l.jsx(l.Fragment,{children:m.Children.map(i,S=>l.jsx(n,{ref:t,className:r,style:a,"data-transition-id":s,children:S}))}):l.jsx(l.Fragment,{children:w.map(({component:S,...k})=>l.jsx(qMe,{...k,as:n,className:r,transitionId:s,enterDuration:o,exitDuration:c,enterMountDelay:d,style:a,ref:t,children:S},S.key))})},HMe="_Button_1864l_1",YMe="_ButtonInner_1864l_4",GMe="_ButtonLoader_1864l_749",lC={Button:HMe,ButtonInner:YMe,ButtonLoader:GMe},zu=e=>{const{type:t="button",color:n="primary",variant:i="solid",pill:r=!0,uniform:s=!1,size:a="md",iconSize:o,gutterSize:c,loading:u,selected:d,block:f,opticallyAlign:h,children:p,className:g,onClick:b,disabled:y,disabledTone:O,inert:v=u,...x}=e,w=y||v,E=m.useCallback(S=>{y||b==null||b(S)},[b,y]);return l.jsxs("button",{type:t,className:Ps(lC.Button,g),"data-color":n,"data-variant":i,"data-pill":r?"":void 0,"data-uniform":s?"":void 0,"data-size":a,"data-gutter-size":c,"data-icon-size":o,"data-loading":u?"":void 0,"data-selected":d?"":void 0,"data-block":f?"":void 0,"data-optically-align":h,onPointerEnter:cie,disabled:w,"aria-disabled":w,tabIndex:w?-1:void 0,"data-disabled":y?"":void 0,"data-disabled-tone":y?O:void 0,onClick:E,...x,children:[l.jsx(hie,{className:lC.ButtonLoader,enterDuration:250,exitDuration:150,children:u&&l.jsx(DMe,{},"loader")}),l.jsx("span",{className:lC.ButtonInner,children:j$(p)})]})};var WMe=Object.defineProperty,I$=(e,t)=>WMe(e,"name",{value:t,configurable:!0});function DP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}I$(DP,"setRef");function pie(...e){return t=>{let n=!1;const i=e.map(r=>{const s=DP(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;rZMe(e,"name",{value:t,configurable:!0});function Lf(e){const t=m.forwardRef((n,i)=>{let{children:r,...s}=n,a=null,o=!1;const c=[];$P(r)&&typeof gw=="function"&&(r=gw(r._payload)),m.Children.forEach(r,h=>{var p;if(xie(h)){o=!0;const g=h;let b="child"in g.props?g.props.child:g.props.children;$P(b)&&typeof gw=="function"&&(b=gw(b._payload)),a=KMe(g,b),c.push((p=a==null?void 0:a.props)==null?void 0:p.children)}else c.push(h)}),a?a=m.cloneElement(a,void 0,c):!o&&m.Children.count(r)===1&&m.isValidElement(r)&&(a=r);const u=a?yie(a):void 0,d=Sr(i,u);if(!a){if(r||r===0)throw new Error(o?tLe(e):eLe(e));return r}const f=Oie(s,a.props??{});return a.type!==m.Fragment&&(f.ref=i?d:u),m.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}Vl(Lf,"createSlot");var mie=Lf("Slot"),gie=Symbol.for("radix.slottable");function bie(e){const t=Vl(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=gie,t}Vl(bie,"createSlottable");var KMe=Vl((e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Oie(e,t){const n={...t};for(const i in t){const r=e[i],s=t[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{const c=s(...o);return r(...o),c}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}Vl(Oie,"mergeProps");function yie(e){var i,r;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Vl(yie,"getElementRef");function xie(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gie}Vl(xie,"isSlottable");var JMe=Symbol.for("react.lazy");function $P(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===JMe&&"_payload"in e&&vie(e._payload)}Vl($P,"isLazyComponent");function vie(e){return typeof e=="object"&&e!==null&&"then"in e}Vl(vie,"isPromiseLike");var eLe=Vl(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),tLe=Vl(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),gw=j0[" use ".trim().toString()],nLe=Object.defineProperty,iLe=(e,t)=>nLe(e,"name",{value:t,configurable:!0}),rLe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qr=rLe.reduce((e,t)=>{const n=Lf(`Primitive.${t}`),i=m.forwardRef((r,s)=>{const{asChild:a,...o}=r,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...o,ref:s})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function wie(e,t){e&&zi.flushSync(()=>e.dispatchEvent(t))}iLe(wie,"dispatchDiscreteCustomEvent");var sLe=Object.defineProperty,aLe=(e,t)=>sLe(e,"name",{value:t,configurable:!0}),oLe=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),lLe=m.forwardRef(aLe(function(t,n){return l.jsx(qr.span,{...t,ref:n,style:{...oLe,...t.style}})},"VisuallyHidden")),cLe=lLe,uLe=Object.defineProperty,Xo=(e,t)=>uLe(e,"name",{value:t,configurable:!0});function dLe(e,t){const n=m.createContext(t);n.displayName=e+"Context";const i=Xo(s=>{const{children:a,...o}=s,c=m.useMemo(()=>o,Object.values(o));return l.jsx(n.Provider,{value:c,children:a})},"Provider");i.displayName=e+"Provider";function r(s,a={}){const{optional:o=!1}=a,c=m.useContext(n);if(c)return c;if(t!==void 0)return t;if(!o)throw new Error(`\`${s}\` must be used within \`${e}\``)}return Xo(r,"useContext"),[i,r]}Xo(dLe,"createContext");function Xl(e,t=[]){let n=[];function i(s,a){const o=m.createContext(a);o.displayName=s+"Context";const c=n.length;n=[...n,a];const u=Xo(f=>{var O;const{scope:h,children:p,...g}=f,b=((O=h==null?void 0:h[e])==null?void 0:O[c])||o,y=m.useMemo(()=>g,Object.values(g));return l.jsx(b.Provider,{value:y,children:p})},"Provider");u.displayName=s+"Provider";function d(f,h,p={}){var O;const{optional:g=!1}=p,b=((O=h==null?void 0:h[e])==null?void 0:O[c])||o,y=m.useContext(b);if(y)return y;if(a!==void 0)return a;if(!g)throw new Error(`\`${f}\` must be used within \`${s}\``)}return Xo(d,"useContext"),[u,d]}Xo(i,"createContext");const r=Xo(()=>{const s=n.map(a=>m.createContext(a));return Xo(function(o){const c=(o==null?void 0:o[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...o,[e]:c}}),[o,c])},"useScope")},"createScope");return r.scopeName=e,[i,Sie(r,...t)]}Xo(Xl,"createContextScope");function Sie(...e){const t=e[0];if(e.length===1)return t;const n=Xo(()=>{const i=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return Xo(function(s){const a=i.reduce((o,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...o,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Xo(Sie,"composeContextScopes");var fLe=Object.defineProperty,ps=(e,t)=>fLe(e,"name",{value:t,configurable:!0});function Eie(e){const t=e+"CollectionProvider",[n,i]=Xl(t),[r,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=ps(b=>{const{scope:y,children:O}=b,v=m.useRef(null),x=m.useRef(new Map).current;return l.jsx(r,{scope:y,itemMap:x,collectionRef:v,children:O})},"CollectionProvider");a.displayName=t;const o=e+"CollectionSlot",c=Lf(o),u=m.forwardRef((b,y)=>{const{scope:O,children:v}=b,x=s(o,O),w=Sr(y,x.collectionRef);return l.jsx(c,{ref:w,children:v})});u.displayName=o;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Lf(d),p=m.forwardRef((b,y)=>{const{scope:O,children:v,...x}=b,w=m.useRef(null),E=Sr(y,w),S=s(d,O);return m.useEffect(()=>(S.itemMap.set(w,{ref:w,...x}),()=>void S.itemMap.delete(w))),l.jsx(h,{[f]:"",ref:E,children:v})});p.displayName=d;function g(b){const y=s(e+"CollectionConsumer",b);return m.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((S,k)=>x.indexOf(S.ref.current)-x.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return ps(g,"useCollection"),[{Provider:a,Slot:u,ItemSlot:p},g,i]}ps(Eie,"createCollection");var n7=new WeakMap,Qr,oo,cC=(oo=class extends Map{constructor(n){super(n);l6(this,Qr);BN(this,Qr,[...super.keys()]),n7.set(this,!0)}set(n,i){return n7.get(this)&&(this.has(n)?Fs(this,Qr)[Fs(this,Qr).indexOf(n)]=n:Fs(this,Qr).push(n)),super.set(n,i),this}insert(n,i,r){const s=this.has(i),a=Fs(this,Qr).length,o=P$(n);let c=o>=0?o:a+o;const u=c<0||c>=a?-1:c;if(u===this.size||s&&u===this.size-1||u===-1)return this.set(i,r),this;const d=this.size+(s?0:1);o<0&&c++;const f=[...Fs(this,Qr)];let h,p=!1;for(let g=c;g=this.size&&(s=this.size-1),this.at(s)}keyFrom(n,i){const r=this.indexOf(n);if(r===-1)return;let s=r+i;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return s;r++}}findIndex(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return r;r++}return-1}filter(n,i){const r=[];let s=0;for(const a of this)Reflect.apply(n,i,[a,s,this])&&r.push(a),s++;return new oo(r)}map(n,i){const r=[];let s=0;for(const a of this)r.push([a[0],Reflect.apply(n,i,[a,s,this])]),s++;return new oo(r)}reduce(...n){const[i,r]=n;let s=0,a=r??this.at(0);for(const o of this)s===0&&n.length===1?a=o:a=Reflect.apply(i,this,[a,o,s,this]),s++;return a}reduceRight(...n){const[i,r]=n;let s=r??this.at(-1);for(let a=this.size-1;a>=0;a--){const o=this.at(a);a===this.size-1&&n.length===1?s=o:s=Reflect.apply(i,this,[s,o,a,this])}return s}toSorted(n){const i=[...this.entries()].sort(n);return new oo(i)}toReversed(){const n=new oo;for(let i=this.size-1;i>=0;i--){const r=this.keyAt(i),s=this.get(r);n.set(r,s)}return n}toSpliced(...n){const i=[...this.entries()];return i.splice(...n),new oo(i)}slice(n,i){const r=new oo;let s=this.size-1;if(n===void 0)return r;n<0&&(n=n+this.size),i!==void 0&&i>0&&(s=i-1);for(let a=n;a<=s;a++){const o=this.keyAt(a),c=this.get(o);r.set(o,c)}return r}every(n,i){let r=0;for(const s of this){if(!Reflect.apply(n,i,[s,r,this]))return!1;r++}return!0}some(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return!0;r++}return!1}},Qr=new WeakMap,ps(oo,"OrderedDict"),oo);function KS(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=kie(e,t);return n===-1?void 0:e[n]}ps(KS,"at");function kie(e,t){const n=e.length,i=P$(t),r=i>=0?i:n+i;return r<0||r>=n?-1:r}ps(kie,"toSafeIndex");function P$(e){return e!==e||e===0?0:Math.trunc(e)}ps(P$,"toSafeInteger");function hLe(e){const t=e+"CollectionProvider",[n,i]=Xl(t),[r,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new cC,setItemMap:ps(()=>{},"setItemMap")}),a=ps(({state:x,...w})=>x?l.jsx(c,{...w,state:x}):l.jsx(o,{...w}),"CollectionProvider");a.displayName=t;const o=ps(x=>{const w=y();return l.jsx(c,{...x,state:w})},"CollectionInit");o.displayName=t+"Init";const c=ps(x=>{const{scope:w,children:E,state:S}=x,k=m.useRef(null),[T,A]=m.useState(null),N=Sr(k,A),[C,M]=S;return m.useEffect(()=>{if(!T)return;const L=Aie(()=>{});return L.observe(T,{childList:!0,subtree:!0}),()=>{L.disconnect()}},[T]),l.jsx(r,{scope:w,itemMap:C,setItemMap:M,collectionRef:N,collectionRefObject:k,collectionElement:T,children:E})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",d=Lf(u),f=m.forwardRef((x,w)=>{const{scope:E,children:S}=x,k=s(u,E),T=Sr(w,k.collectionRef);return l.jsx(d,{ref:T,children:S})});f.displayName=u;const h=e+"CollectionItemSlot",p="data-radix-collection-item",g=Lf(h),b=m.forwardRef((x,w)=>{const{scope:E,children:S,...k}=x,T=m.useRef(null),[A,N]=m.useState(null),C=Sr(w,T,N),M=s(h,E),{setItemMap:L}=M,P=m.useRef(k);Tie(P.current,k)||(P.current=k);const Q=P.current;return m.useEffect(()=>{const j=Q;return L($=>A?$.has(A)?$.set(A,{...j,element:A}).toSorted(QP):($.set(A,{...j,element:A}),$.toSorted(QP)):$),()=>{L($=>!A||!$.has(A)?$:($.delete(A),new cC($)))}},[A,Q,L]),l.jsx(g,{[p]:"",ref:C,children:S})});b.displayName=h;function y(){return m.useState(new cC)}ps(y,"useInitCollection");function O(x){const{itemMap:w}=s(e+"CollectionConsumer",x);return w}return ps(O,"useCollection"),[{Provider:a,Slot:f,ItemSlot:b},{createCollectionScope:i,useCollection:O,useInitCollection:y}]}ps(hLe,"createCollection");function Tie(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}ps(Tie,"shallowEqual");function _ie(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}ps(_ie,"isElementPreceding");function QP(e,t){return!e[1].element||!t[1].element?0:_ie(e[1].element,t[1].element)?-1:1}ps(QP,"sortByDocumentPosition");function Aie(e){return new MutationObserver(n=>{for(const i of n)if(i.type==="childList"){e();return}})}ps(Aie,"getChildListObserver");var pLe=Object.defineProperty,Y0=(e,t)=>pLe(e,"name",{value:t,configurable:!0}),Nie=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ti(e,t,{checkForDefaultPrevented:n=!0}={}){return Y0(function(r){if(e==null||e(r),n===!1||!r||!r.defaultPrevented)return t==null?void 0:t(r)},"handleEvent")}Y0(Ti,"composeEventHandlers");function mLe(e){var t;if(!Nie)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Y0(mLe,"getOwnerWindow");function BP(e){if(!Nie)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Y0(BP,"getOwnerDocument");function Cie(e,t=!1){const{activeElement:n}=BP(e);if(!(n!=null&&n.nodeName))return null;if(jie(n)&&n.contentDocument)return Cie(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=BP(n).getElementById(i);if(r)return r}}return n}Y0(Cie,"getActiveElement");function jie(e){return e.tagName==="IFRAME"}Y0(jie,"isFrame");var tl=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},gLe=Object.defineProperty,bLe=(e,t)=>gLe(e,"name",{value:t,configurable:!0}),i7=j0[" useEffectEvent ".trim().toString()],r7=j0[" useInsertionEffect ".trim().toString()];function Rie(e){if(typeof i7=="function")return i7(e);const t=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof r7=="function"?r7(()=>{t.current=e}):tl(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var i;return(i=t.current)==null?void 0:i.call(t,...n)},[])}bLe(Rie,"useEffectEvent");var OLe=Object.defineProperty,j1=(e,t)=>OLe(e,"name",{value:t,configurable:!0}),yLe=j0[" useInsertionEffect ".trim().toString()]||tl;function bd({prop:e,defaultProp:t,onChange:n=j1(()=>{},"onChange"),caller:i}){const[r,s,a]=Iie({defaultProp:t,onChange:n}),o=e!==void 0,c=o?e:r,u=m.useCallback(d=>{var f;if(o){const h=Pie(d)?d(e):d;h!==e&&((f=a.current)==null||f.call(a,h))}else s(d)},[o,e,s,a]);return[c,u]}j1(bd,"useControllableState");function Iie({defaultProp:e,onChange:t}){const[n,i]=m.useState(e),r=m.useRef(n),s=m.useRef(t);return yLe(()=>{s.current=t},[t]),m.useEffect(()=>{var a;r.current!==n&&((a=s.current)==null||a.call(s,n),r.current=n)},[n,r]),[n,i,s]}j1(Iie,"useUncontrolledState");function Pie(e){return typeof e=="function"}j1(Pie,"isFunction");var s7=Symbol("RADIX:SYNC_STATE");function xLe(e,t,n,i){const{prop:r,defaultProp:s,onChange:a,caller:o}=t,c=r!==void 0,u=Rie(a),d=[{...n,state:s}];i&&d.push(i);const[f,h]=m.useReducer((y,O)=>{if(O.type===s7)return{...y,state:O.state};const v=e(y,O);return c&&!Object.is(v.state,y.state)&&u(v.state),v},...d),p=f.state,g=m.useRef(p);m.useEffect(()=>{g.current!==p&&(g.current=p,c||u(p))},[p,g,c]);const b=m.useMemo(()=>r!==void 0?{...f,state:r}:f,[f,r]);return m.useEffect(()=>{c&&!Object.is(r,f.state)&&h({type:s7,state:r})},[r,f.state,c]),[b,h]}j1(xLe,"useControllableStateReducer");var vLe=Object.defineProperty,id=(e,t)=>vLe(e,"name",{value:t,configurable:!0});function Mie(e,t){return m.useReducer((n,i)=>t[n][i]??n,e)}id(Mie,"useStateMachine");var G0=id(e=>{const{present:t,children:n}=e,i=Lie(t),r=typeof n=="function"?n({present:i.isPresent}):m.Children.only(n),s=Die(i.ref,$ie(r));return typeof n=="function"||i.isPresent?m.cloneElement(r,{ref:s}):null},"Presence");function Lie(e){const[t,n]=m.useState(),i=m.useRef(null),r=m.useRef(e),s=m.useRef("none"),a=m.useRef(void 0),o=e?"mounted":"unmounted",[c,u]=Mie(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{c==="mounted"?(s.current=a.current??_m(i.current),a.current=void 0):s.current="none"},[c]),tl(()=>{const d=i.current,f=r.current;if(f!==e){const p=s.current,g=_m(d);e?(a.current=g,u("MOUNT")):g==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,u]),tl(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,h=id(g=>{const y=_m(i.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(u("ANIMATION_END"),!r.current)){const O=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=O)})}},"handleAnimationEnd"),p=id(g=>{g.target===t&&(s.current=_m(i.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:m.useCallback(d=>{if(d){const f=getComputedStyle(d);i.current=f,a.current=_m(f)}else i.current=null;n(d)},[])}}id(Lie,"usePresence");function UP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}id(UP,"setRef");function Die(...e){const t=m.useRef(e);return t.current=e,m.useCallback(n=>{const i=t.current;let r=!1;const s=i.map(a=>{const o=UP(a,n);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;awLe(e,"name",{value:t,configurable:!0}),ELe=j0[" useId ".trim().toString()]||(()=>{}),kLe=0;function F_(e){const[t,n]=m.useState(ELe());return tl(()=>{e||n(i=>i??String(kLe++))},[e]),e||(t?`radix-${t}`:"")}SLe(F_,"useId");var TLe=Object.defineProperty,_Le=(e,t)=>TLe(e,"name",{value:t,configurable:!0}),ALe=m.createContext(void 0);function V_(e){const t=m.useContext(ALe);return e||t||"ltr"}_Le(V_,"useDirection");var NLe=Object.defineProperty,CLe=(e,t)=>NLe(e,"name",{value:t,configurable:!0});function Df(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var i;return(i=t.current)==null?void 0:i.call(t,...n)},[])}CLe(Df,"useCallbackRef");var jLe=Object.defineProperty,fs=(e,t)=>jLe(e,"name",{value:t,configurable:!0}),zP="dismissableLayer.update",RLe="dismissableLayer.pointerDownOutside",ILe="dismissableLayer.focusOutside",a7,Qie=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Bie=m.forwardRef(fs(function(t,n){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:u,...d}=t,f=m.useContext(Qie),[h,p]=m.useState(null),g=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=m.useState({}),y=Sr(n,p),O=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),x=v?O.indexOf(v):-1,w=h?O.indexOf(h):-1,E=f.layersWithOutsidePointerEventsDisabled.size>0,S=w>=x,k=m.useRef(!1),T=Uie(M=>{a==null||a(M),c==null||c(M),M.defaultPrevented||u==null||u()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(M=>{if(!(M instanceof Node))return!1;const L=[...f.branches].some(P=>P.contains(M));return S&&!L},[f.branches,S])}),A=zie(M=>{if(r&&k.current)return;const L=M.target;[...f.branches].some(Q=>Q.contains(L))||(o==null||o(M),c==null||c(M),M.defaultPrevented||u==null||u())},g),N=h?w===O.length-1:!1,C=Df(M=>{M.key==="Escape"&&(s==null||s(M),!M.defaultPrevented&&u&&(M.preventDefault(),u()))});return m.useEffect(()=>{if(N)return g.addEventListener("keydown",C,{capture:!0}),()=>g.removeEventListener("keydown",C,{capture:!0})},[g,N,C]),m.useEffect(()=>{if(h)return i&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(a7=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(h)),f.layers.add(h),FP(),()=>{i&&(f.layersWithOutsidePointerEventsDisabled.delete(h),f.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=a7))}},[h,g,i,f]),m.useEffect(()=>()=>{h&&(f.layers.delete(h),f.layersWithOutsidePointerEventsDisabled.delete(h),FP())},[h,f]),m.useEffect(()=>{const M=fs(()=>b({}),"handleUpdate");return document.addEventListener(zP,M),()=>document.removeEventListener(zP,M)},[]),l.jsx(qr.div,{...d,ref:y,style:{pointerEvents:E?S?"auto":"none":void 0,...t.style},onFocusCapture:Ti(t.onFocusCapture,A.onFocusCapture),onBlurCapture:Ti(t.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Ti(t.onPointerDownCapture,T.onPointerDownCapture)})},"DismissableLayer"));function PLe(){const e=m.useContext(Qie),[t,n]=m.useState(null);return m.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}fs(PLe,"useDismissableLayerSurface");var MLe=fs(()=>!0,"IS_TRUE");function Uie(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:s,shouldHandlePointerDownOutside:a=MLe}=t,o=Df(e),c=m.useRef(!1),u=m.useRef(!1),d=m.useRef(new Map),f=m.useRef(()=>{});return m.useEffect(()=>{function h(){u.current=!1,r.current=!1,d.current.clear()}fs(h,"resetOutsideInteraction");function p(){return Array.from(d.current.values()).some(Boolean)}fs(p,"isOutsideInteractionIntercepted");function g(x){if(!u.current)return;const w=x.target;w instanceof Node&&[...s].some(S=>S.contains(w))||d.current.set(x.type,!0),x.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}fs(g,"handleInteractionCapture");function b(x){u.current&&d.current.set(x.type,!1)}fs(b,"handleInteractionBubble");const y=fs(x=>{if(x.target&&!c.current){let w=function(){n.removeEventListener("click",f.current);const S=p();h(),S||M$(RLe,o,E,{discrete:!0})};if(fs(w,"handleAndDispatchPointerDownOutsideEvent"),!a(x.target)){n.removeEventListener("click",f.current),h(),c.current=!1;return}const E={originalEvent:x};u.current=!0,r.current=i&&x.button===0,d.current.clear(),!i||x.button!==0?w():(n.removeEventListener("click",f.current),f.current=w,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),h();c.current=!1},"handlePointerDown"),O=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const x of O)n.addEventListener(x,g,!0),n.addEventListener(x,b);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",y),n.removeEventListener("click",f.current);for(const x of O)n.removeEventListener(x,g,!0),n.removeEventListener(x,b)}},[n,o,i,r,s,a]),{onPointerDownCapture:fs(()=>c.current=!0,"onPointerDownCapture")}}fs(Uie,"usePointerDownOutside");function zie(e,t=globalThis==null?void 0:globalThis.document){const n=Df(e),i=m.useRef(!1);return m.useEffect(()=>{const r=fs(s=>{s.target&&!i.current&&M$(ILe,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:fs(()=>i.current=!0,"onFocusCapture"),onBlurCapture:fs(()=>i.current=!1,"onBlurCapture")}}fs(zie,"useFocusOutside");function FP(){const e=new CustomEvent(zP);document.dispatchEvent(e)}fs(FP,"dispatchUpdate");function M$(e,t,n,{discrete:i}){const r=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),i?wie(r,s):r.dispatchEvent(s)}fs(M$,"handleAndDispatchCustomEvent");var LLe=Object.defineProperty,ba=(e,t)=>LLe(e,"name",{value:t,configurable:!0}),uC="focusScope.autoFocusOnMount",dC="focusScope.autoFocusOnUnmount",o7={bubbles:!1,cancelable:!0},DLe=m.forwardRef(ba(function(t,n){const{loop:i=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[c,u]=m.useState(null),d=Df(s),f=Df(a),h=m.useRef(null),p=Sr(n,u),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let y=function(w){if(g.paused||!c)return;const E=w.target;c.contains(E)?h.current=E:Eu(h.current,{select:!0})},O=function(w){if(g.paused||!c)return;const E=w.relatedTarget;E!==null&&(c.contains(E)||Eu(h.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&Eu(c)};ba(y,"handleFocusIn"),ba(O,"handleFocusOut"),ba(v,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",O);const x=new MutationObserver(v);return c&&x.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",O),x.disconnect()}}},[r,c,g.paused]),m.useEffect(()=>{if(c){l7.add(g);const y=document.activeElement;if(!c.contains(y)){const v=new CustomEvent(uC,o7);c.addEventListener(uC,d),c.dispatchEvent(v),v.defaultPrevented||(Fie(Yie(L$(c)),{select:!0}),document.activeElement===y&&Eu(c))}return()=>{c.removeEventListener(uC,d),setTimeout(()=>{const v=new CustomEvent(dC,o7);c.addEventListener(dC,f),c.dispatchEvent(v),v.defaultPrevented||Eu(y??document.body,{select:!0}),c.removeEventListener(dC,f),l7.remove(g)},0)}}},[c,d,f,g]);const b=m.useCallback(y=>{if(!i&&!r||g.paused)return;const O=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,v=document.activeElement;if(O&&v){const x=y.currentTarget,[w,E]=Vie(x);w&&E?!y.shiftKey&&v===E?(y.preventDefault(),i&&Eu(w,{select:!0})):y.shiftKey&&v===w&&(y.preventDefault(),i&&Eu(E,{select:!0})):v===x&&y.preventDefault()}},[i,r,g.paused]);return l.jsx(qr.div,{tabIndex:-1,...o,ref:p,onKeyDown:b})},"FocusScope"));function Fie(e,{select:t=!1}={}){const n=document.activeElement;for(const i of e)if(Eu(i,{select:t}),document.activeElement!==n)return}ba(Fie,"focusFirst");function Vie(e){const t=L$(e),n=VP(t,e),i=VP(t.reverse(),e);return[n,i]}ba(Vie,"getTabbableEdges");function L$(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ba(i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}ba(L$,"getTabbableCandidates");function VP(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const i of e)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):Xie(i,{upTo:t})))return i}ba(VP,"findVisible");function Xie(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}ba(Xie,"isHidden");function qie(e){return e instanceof HTMLInputElement&&"select"in e}ba(qie,"isSelectableInput");function Eu(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&qie(e)&&t&&e.select()}}ba(Eu,"focus");var l7=Hie();function Hie(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=XP(e,t),e.unshift(t)},remove(t){var n;e=XP(e,t),(n=e[0])==null||n.resume()}}}ba(Hie,"createFocusScopesStack");function XP(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}ba(XP,"arrayRemove");function Yie(e){return e.filter(t=>t.tagName!=="A")}ba(Yie,"removeLinks");var $Le=Object.defineProperty,QLe=(e,t)=>$Le(e,"name",{value:t,configurable:!0}),Gie=m.forwardRef(QLe(function(t,n){var c;const{container:i,...r}=t,[s,a]=m.useState(!1);tl(()=>a(!0),[]);const o=i||s&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?zi.createPortal(l.jsx(qr.div,{...r,ref:n}),o):null},"Portal")),BLe=Object.defineProperty,D$=(e,t)=>BLe(e,"name",{value:t,configurable:!0}),bw=0,dc=null;function ULe(e){return $$(),e.children}D$(ULe,"FocusGuards");function $$(){m.useEffect(()=>{dc||(dc={start:qP(),end:qP()});const{start:e,end:t}=dc;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),bw++,()=>{bw===1&&(dc==null||dc.start.remove(),dc==null||dc.end.remove(),dc=null),bw=Math.max(0,bw-1)}},[])}D$($$,"useFocusGuards");function qP(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}D$(qP,"createFocusGuard");var vc=function(){return vc=Object.assign||function(t){for(var n,i=1,r=arguments.length;i"u")return r5e;var t=s5e(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},o5e=Jie(),wg="data-scroll-locked",l5e=function(e,t,n,i){var r=e.left,s=e.top,a=e.right,o=e.gap;return n===void 0&&(n="margin"),` - .`.concat(FLe,` { +- 保持礼貌、专业的语气。`;function el(e="volcengine"){return{name:"",description:wPe,instruction:SPe,agentType:"llm",cloudProvider:e,maxIterations:3,a2aUrl:"",tools:[],skills:[],memory:{shortTerm:!1,longTerm:!1},knowledgebase:!1,tracing:!1,subAgents:[],builtinTools:[],customTools:[],mcpTools:[],a2aRegistry:{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},modelName:t0(e),modelSource:"ark",modelProvider:"",modelApiBase:"",shortTermBackend:"local",longTermBackend:"local",autoSaveSession:!1,knowledgebaseBackend:wf,knowledgebaseIndex:"",tracingExporters:[],selectedSkills:[],deployment:{feishuEnabled:!1,modelApiKeyId:"",modelApiKeyName:""}}}const EPe="/web/skill-management";class kPe extends Error{constructor(t,n,i="SKILL_MANAGEMENT_ERROR",r="",s,a=""){super(t),this.status=n,this.code=i,this.statusText=r,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function md(e,t={},n=_o){return fetch(vo(`${EPe}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function qne(e,t){let n=t,i="SKILL_MANAGEMENT_ERROR",r;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,i=a.detail.code||i,r=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new kPe(n,e.status,i,e.statusText,r,s)}async function gd(e,t){if(!e.ok)throw await qne(e,t);return e.json()}async function TPe(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),gd(await md(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function _Pe(e){return gd(await md("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function APe(e){return gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function NPe(e){const t=new URLSearchParams({region:e.region});await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function CPe(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},kr),"上传 Skill 失败")}async function jPe(e){return gd(await md("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},kr),"校验 Skill 失败")}async function RPe(e){const t=new URLSearchParams({region:e.region});await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function IPe(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version);const n=await gd(await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function PPe(e){var o;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version);const n=await md(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},kr);n.ok||await gd(n,"下载 Skill 失败");const r=((o=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:o[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=r,a.click(),URL.revokeObjectURL(s)}async function z_(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(!t.ok)throw await qne(t,"AgentKit Skills 请求失败");return t.json()}async function A$(){return(await z_("/web/skill-spaces?region=all")).items||[]}async function N$(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function MPe(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function LPe(e,t,n,i,r){const s=[];n&&s.push(`version=${encodeURIComponent(n)}`),i&&s.push(`region=${encodeURIComponent(i)}`),r&&s.push(`project=${encodeURIComponent(r)}`);const a=s.length>0?`?${s.join("&")}`:"";return z_(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${a}`)}function DPe(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function $Pe(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}function VU({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M4.5 6.7h4.2M12.3 6.7h7.2"}),l.jsx("path",{d:"M4.5 12h8.2M16.3 12h3.2"}),l.jsx("path",{d:"M4.5 17.3h2.7M10.8 17.3h8.7"}),l.jsx("circle",{cx:"10.5",cy:"6.7",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"12",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"9",cy:"17.3",r:"1.8",fill:"currentColor",stroke:"none"})]})}const QPe={coding:"智能编程",get_city_weather:"城市天气查询",get_location_weather:"位置天气查询",web_fetch:"网页内容获取"};function MP(e){const t=Qp.find(n=>n.id===e||n.toolNames.includes(e));return QPe[e]??(t==null?void 0:t.label)??e}function XU(e){const t=Qp.find(i=>i.id===e||i.toolNames.includes(e));return((t==null?void 0:t.desc)??"由 VeADK 提供的内置工具").replace(/[。.]+$/,"")}function BPe(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function UPe(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"5.8",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.2 15.2 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function qU(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Hne({title:e,description:t,icon:n,wide:i=!1,onClose:r,children:s}){const a=m.useRef(`session-capability-${Math.random().toString(36).slice(2)}`);return m.useEffect(()=>{const o=document.body.style.overflow;document.body.style.overflow="hidden";const c=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=o}},[r]),zi.createPortal(l.jsxs("div",{className:"session-capability-dialog-layer",children:[l.jsx("button",{type:"button",className:"session-capability-dialog-scrim","aria-label":"关闭弹窗",onClick:r}),l.jsxs("section",{className:`session-capability-dialog${i?" is-wide":""}`,role:"dialog","aria-modal":"true","aria-labelledby":a.current,children:[l.jsxs("header",{className:`session-capability-dialog-head${n?"":" is-iconless"}`,children:[n&&l.jsx("span",{className:"session-capability-dialog-mark",children:n}),l.jsxs("div",{children:[l.jsx("h2",{id:a.current,children:e}),l.jsx("p",{children:t})]}),l.jsx("button",{type:"button",className:"session-capability-dialog-close","aria-label":`关闭${e}`,onClick:r,children:l.jsx(BPe,{})})]}),s]})]}),document.body)}function WS({value:e,placeholder:t,label:n,onChange:i,autoFocus:r=!1}){return l.jsxs("label",{className:"session-capability-search",children:[l.jsx(UPe,{}),l.jsx("input",{value:e,"aria-label":n,placeholder:t,autoFocus:r,onChange:s=>i(s.target.value)})]})}function zPe({agentName:e,tools:t,selectedNames:n,mutating:i,onAdd:r,onClose:s}){const[a,o]=m.useState(""),[c,u]=m.useState(""),d=m.useMemo(()=>new Set(n),[n]),f=m.useMemo(()=>{const p=a.trim().toLowerCase();return t.filter(g=>p?`${MP(g)} ${g} ${XU(g)}`.toLowerCase().includes(p):!0)},[a,t]),h=async p=>{u(p);const g=await r({kind:"tool",name:p});u(""),g&&s()};return l.jsx(Hne,{title:"添加内置工具",description:`添加后仅对 ${e} 的当前会话生效`,icon:l.jsx(VU,{}),onClose:s,children:l.jsxs("div",{className:"session-tool-dialog-body",children:[l.jsx(WS,{value:a,label:"搜索内置工具",placeholder:"搜索中文名称或工具标识",onChange:o,autoFocus:!0}),l.jsx("div",{className:"session-tool-picker",role:"list","aria-label":"可用内置工具",children:f.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的内置工具"}):f.map(p=>{const g=d.has(p),b=c===p;return l.jsxs("article",{className:"session-tool-option",role:"listitem",children:[l.jsx("span",{className:"session-tool-option-icon",children:l.jsx(VU,{})}),l.jsxs("span",{className:"session-tool-option-copy",children:[l.jsx("strong",{children:MP(p)}),l.jsx("code",{children:p}),l.jsx("span",{children:XU(p)})]}),l.jsx("button",{type:"button",disabled:g||i||!!c,onClick:()=>void h(p),children:g?"已添加":b?"添加中…":"添加"})]},p)})})]})})}function FPe({appName:e,agentName:t,selectedNames:n,mutating:i,onAdd:r,onClose:s}){const[a,o]=m.useState("public"),[c,u]=m.useState(""),[d,f]=m.useState([]),[h,p]=m.useState(0),[g,b]=m.useState(!0),[y,O]=m.useState(""),[v,x]=m.useState([]),[w,E]=m.useState(null),[S,k]=m.useState([]),[T,A]=m.useState(""),[N,C]=m.useState(""),[M,L]=m.useState(!0),[P,Q]=m.useState(!1),[j,$]=m.useState(""),[U,B]=m.useState(""),I=m.useMemo(()=>new Set(n),[n]);m.useEffect(()=>{if(a!=="public")return;let re=!0;const fe=window.setTimeout(()=>{b(!0),O(""),HJ(e,c.trim()).then(Ae=>{re&&(f(Ae.items),p(Ae.totalCount))}).catch(Ae=>{re&&(f([]),p(0),O(Ae instanceof Error?Ae.message:"搜索 Skill Hub 失败"))}).finally(()=>{re&&b(!1)})},250);return()=>{re=!1,window.clearTimeout(fe)}},[e,c,a]),m.useEffect(()=>{if(a!=="agentkit")return;let re=!0;return L(!0),$(""),A$().then(fe=>{re&&(x(fe),E(fe[0]??null))}).catch(fe=>{re&&$(fe instanceof Error?fe.message:"读取 Skill Space 失败")}).finally(()=>{re&&L(!1)}),()=>{re=!1}},[a]),m.useEffect(()=>{if(a!=="agentkit")return;if(!w){k([]);return}let re=!0;return Q(!0),$(""),N$(w.id,w.region).then(fe=>{re&&k(fe)}).catch(fe=>{re&&$(fe instanceof Error?fe.message:"读取技能失败")}).finally(()=>{re&&Q(!1)}),()=>{re=!1}},[w,a]);const X=m.useMemo(()=>{const re=T.trim().toLowerCase();return re?v.filter(fe=>`${fe.name} ${fe.id} ${fe.description}`.toLowerCase().includes(re)):v},[T,v]),q=m.useMemo(()=>{const re=N.trim().toLowerCase();return re?S.filter(fe=>`${fe.skillName} ${fe.skillDescription}`.toLowerCase().includes(re)):S},[N,S]),D=async re=>{if(!w)return;B(re.skillId);const fe=await r({kind:"skill",name:re.skillName,skillSourceId:w.id,description:re.skillDescription,version:re.version});B(""),fe&&s()},H=async re=>{B(re.slug);const fe=await r({kind:"skill",name:re.name,skillSourceId:`findskill:${re.slug}`,description:re.description,version:re.version||re.updatedAt});B(""),fe&&s()};return l.jsx(Hne,{title:"添加技能",description:`从公域 Skill Hub 或 AgentKit Skill 中心添加到 ${t} 当前会话`,wide:!0,onClose:s,children:l.jsxs("div",{className:"session-skill-dialog-body",children:[l.jsxs("div",{className:"session-skill-source-tabs",role:"tablist","aria-label":"技能来源",children:[l.jsxs("button",{type:"button",role:"tab","aria-selected":a==="public",className:a==="public"?"is-active":"",onClick:()=>o("public"),children:["Skill Hub",l.jsx("span",{children:"公域"})]}),l.jsx("button",{type:"button",role:"tab","aria-selected":a==="agentkit",className:a==="agentkit"?"is-active":"",onClick:()=>o("agentkit"),children:"AgentKit Skill 中心"})]}),a==="public"?l.jsxs("section",{className:"session-public-skill-browser","aria-label":"Skill Hub 公域技能",children:[l.jsxs("div",{className:"session-public-skill-head",children:[l.jsx(WS,{value:c,label:"搜索 Skill Hub",placeholder:"搜索技能名称、用途或关键词",onChange:u,autoFocus:!0}),l.jsxs("span",{children:[h.toLocaleString()," 个公域技能"]})]}),l.jsx("div",{className:"session-public-skill-list",children:y?l.jsx("div",{className:"session-capability-error",children:y}):g?l.jsx("div",{className:"session-capability-loading",children:"正在搜索 Skill Hub…"}):d.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的公域技能"}):d.map(re=>{const fe=I.has(re.name),Ae=U===re.slug;return l.jsxs("article",{className:"session-skill-option session-public-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:re.name}),l.jsx("span",{children:re.description||"暂无描述"}),l.jsxs("small",{children:[re.sourceRepo||re.sourceType||"FindSkill",l.jsx("span",{"aria-hidden":"true",children:" · "}),re.downloadCount.toLocaleString()," 次下载",re.evaluationScore>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",children:" · "}),re.evaluationScore.toFixed(1)," 分"]})]})]}),l.jsx("button",{type:"button",disabled:fe||i||!!U,onClick:()=>void H(re),children:fe?"已添加":Ae?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(qU,{}),"添加"]})})]},re.slug)})})]}):l.jsxs("div",{className:"session-skill-browser",children:[l.jsxs("section",{className:"session-skill-spaces","aria-label":"Skill Space 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Skill Space"}),l.jsx("span",{children:v.length})]}),l.jsx(WS,{value:T,label:"搜索 Skill Space",placeholder:"搜索空间",onChange:A,autoFocus:!0})]}),l.jsx("div",{className:"session-skill-pane-list",children:M?l.jsx("div",{className:"session-capability-loading",children:"正在读取 Skill Space…"}):X.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的 Skill Space"}):X.map(re=>l.jsx("button",{type:"button",className:`session-skill-space${(w==null?void 0:w.id)===re.id?" is-active":""}`,onClick:()=>{E(re),C("")},children:l.jsxs("span",{children:[l.jsx("strong",{children:re.name||re.id}),l.jsx("small",{children:re.description||re.id}),l.jsxs("em",{children:[re.skillCount??0," 个技能"]})]})},`${re.projectName??"default"}:${re.id}`))})]}),l.jsxs("section",{className:"session-skill-results","aria-label":"AgentKit Skill 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{title:w==null?void 0:w.name,children:(w==null?void 0:w.name)||"选择 Skill Space"}),l.jsx("span",{children:S.length})]}),l.jsx(WS,{value:N,label:"搜索 AgentKit 技能",placeholder:"搜索技能名称或描述",onChange:C})]}),l.jsx("div",{className:"session-skill-pane-list",children:j?l.jsx("div",{className:"session-capability-error",children:j}):w?P?l.jsx("div",{className:"session-capability-loading",children:"正在读取技能…"}):q.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的技能"}):q.map(re=>{const fe=I.has(re.skillName),Ae=U===re.skillId;return l.jsxs("article",{className:"session-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:re.skillName}),l.jsx("span",{children:re.skillDescription||"暂无描述"}),l.jsxs("small",{children:["版本 ",re.version||"—"]})]}),l.jsx("button",{type:"button",disabled:fe||i||!!U,onClick:()=>void D(re),children:fe?"已添加":Ae?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(qU,{}),"添加"]})})]},`${re.skillId}:${re.version}`)}):l.jsx("div",{className:"session-capability-empty",children:"选择一个 Skill Space 查看技能"})})]})]})]})})}function oi({as:e="span",className:t="",duration:n=4,spread:i=20,children:r,style:s,...a}){const o=Math.min(Math.max(i,5),45);return l.jsx(e,{className:`text-shimmer${t?` ${t}`:""}`,style:{...s,backgroundImage:`linear-gradient(to right, hsl(var(--muted-foreground)) ${50-o}%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground)) ${50+o}%)`,animationDuration:`${n}s`},...a,children:r})}function Yne(e){return 1+e.children.reduce((t,n)=>t+Yne(n),0)}function Gne(e){return e.id||e.name}function VPe(e,t){const n=Gne(e);if(e.id&&e.name&&e.name!==n)return e.name;if(t&&n==="agent")return"主 Agent";const i=/^agent_sub_(\d+)$/.exec(n);return i?`子 Agent ${i[1]}`:e.name||n}function Wne(e,t=!0){return{...e,id:Gne(e),name:VPe(e,t),children:e.children.map(n=>Wne(n,!1))}}function Zne(e){const t=el();return{...t,name:e.name,description:e.description,instruction:e.instruction||t.instruction,agentType:e.type,modelName:e.model,tools:e.tools??[],skills:(e.skills??[]).map(n=>n.name),subAgents:e.children.map(Zne)}}function XPe(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function qPe(e){return[...new Map(e.filter(t=>t.name.trim()).map(t=>[t.name.trim(),{...t,name:t.name.trim()}])).values()]}function sC({title:e,count:t}){return l.jsxs("div",{className:"topo-module-title",children:[l.jsx("span",{className:"topo-module-label",title:e,children:e}),t!==void 0&&l.jsx("span",{className:"topo-section-count","aria-label":`${t} 项`,children:t})]})}function HPe({appName:e,info:t,loading:n,variant:i="rail",capabilities:r=null,capabilityLoading:s=!1,capabilityMutating:a=!1,builtinTools:o=[],onAddCapability:c,onRemoveCapability:u}){const[d,f]=m.useState(null),[h,p]=m.useState(!1),g=m.useRef(null),b=()=>{p(!1),window.requestAnimationFrame(()=>{var S;return(S=g.current)==null?void 0:S.focus()})};if(m.useEffect(()=>{if(!h)return;const S=document.body.style.overflow,k=T=>{T.key==="Escape"&&b()};return document.body.style.overflow="hidden",document.addEventListener("keydown",k),()=>{document.body.style.overflow=S,document.removeEventListener("keydown",k)}},[h]),n&&!t)return l.jsx("aside",{className:`topo is-loading${i==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息","aria-live":"polite",children:l.jsx(oi,{as:"span",className:"topo-loading-label",duration:2.2,children:"正在读取 Agent 信息…"})});if(!t)return null;const y=Wne(t.graph??{id:t.name,name:t.name,description:t.description,type:t.type??"llm",model:t.model,tools:t.tools,skills:t.skills,path:[t.name],mentionable:!1,children:[]}),O=(r==null?void 0:r.tools)??XPe(t.tools).map(S=>({id:`base:tool:${S}`,kind:"tool",name:S,custom:!1})),v=(r==null?void 0:r.skills)??qPe(t.skills).map(S=>({id:`base:skill:${S.name}`,kind:"skill",name:S.name,description:S.description,custom:!1})),x=!!(r&&c&&u),w=Zne(y),E=S=>l.jsx(px,{draft:w,direction:"horizontal",selectedPath:[],onSelect:()=>{},onAdd:()=>{},onInsert:()=>{},onDelete:()=>{},readOnly:!0,interactivePreview:!0},S);return l.jsxs(l.Fragment,{children:[l.jsxs("aside",{className:`topo${i==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息与拓扑",children:[l.jsxs("section",{className:"topo-agent-card","aria-label":"Agent 信息",children:[l.jsxs("div",{className:"topo-agent-heading",children:[l.jsx("h2",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]}),t.description&&l.jsx("p",{className:"topo-description",title:t.description,children:t.description})]}),l.jsxs("div",{className:"topo-module-stack",children:[l.jsxs("section",{className:"topo-module-card topo-tools-card","aria-label":"工具",children:[l.jsx(sC,{title:"工具",count:O.length}),l.jsx("div",{className:"topo-module-scroll topo-tools-scroll",role:"region","aria-label":"工具列表",tabIndex:0,children:O.length>0?l.jsx("div",{className:"topo-tool-list",children:O.map(S=>l.jsxs("div",{className:"topo-tool",title:S.name,children:[l.jsxs("span",{className:"topo-capability-title",children:[l.jsxs("span",{className:"topo-capability-copy",children:[l.jsx("span",{className:"topo-capability-name",children:MP(S.name)}),l.jsx("code",{children:S.name})]}),S.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"})]}),S.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除工具 ${S.name}`,title:"移除",disabled:a,onClick:()=>u==null?void 0:u(S.id),children:"×"})]},S.id))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),x&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加内置工具",disabled:s||a,onClick:()=>f("tool"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加工具"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-skills-card","aria-label":"技能",children:[l.jsx(sC,{title:"技能",count:t.skillsPreviewSupported?v.length:void 0}),l.jsx("div",{className:"topo-module-scroll topo-skills-scroll",role:"region","aria-label":"技能列表",tabIndex:0,children:t.skillsPreviewSupported?v.length>0?l.jsx("div",{className:"topo-skill-list",children:v.map(S=>l.jsxs("div",{className:"topo-skill",title:S.description||S.name,children:[l.jsxs("div",{className:"topo-skill-title",children:[l.jsx("span",{className:"topo-skill-name",children:S.name}),S.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"}),S.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除技能 ${S.name}`,title:"移除",disabled:a,onClick:()=>u==null?void 0:u(S.id),children:"×"})]}),S.description&&l.jsx("span",{className:"topo-skill-description",children:S.description})]},`${S.name}:${S.description}`))}):l.jsx("div",{className:"topo-empty",children:"未配置"}):l.jsx("div",{className:"topo-empty",children:"暂不支持预览"})}),x&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加技能",disabled:s||a,onClick:()=>f("skill"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加技能"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-topology","aria-label":"Agent 画布",children:[l.jsxs("div",{className:"topo-canvas-heading",children:[l.jsx(sC,{title:"结构拓扑",count:Yne(y)}),l.jsx("button",{ref:g,type:"button",className:"topo-canvas-expand","aria-label":"全屏查看 Agent 画布",title:"全屏查看",onClick:()=>p(!0),children:l.jsx(np,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"topo-canvas-preview",role:"region","aria-label":"Agent 执行画布",children:E(`conversation-canvas:${e}`)})]})]}),d==="tool"&&c&&l.jsx(zPe,{agentName:t.name,tools:o,selectedNames:O.map(S=>S.name),mutating:a,onAdd:c,onClose:()=>f(null)}),d==="skill"&&c&&l.jsx(FPe,{appName:e,agentName:t.name,selectedNames:v.map(S=>S.name),mutating:a,onAdd:c,onClose:()=>f(null)})]}),h&&zi.createPortal(l.jsxs("section",{className:"topo-canvas-dialog",role:"dialog","aria-modal":"true","aria-label":"全屏 Agent 执行画布",children:[l.jsxs("header",{className:"topo-canvas-dialog-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Agent 执行画布"}),l.jsx("span",{children:t.name})]}),l.jsx("button",{type:"button","aria-label":"关闭全屏画布",title:"关闭",onClick:b,autoFocus:!0,children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"topo-canvas-dialog-body",children:E(`conversation-canvas-fullscreen:${e}`)})]}),document.body)]})}const H0={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};function HU(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("rect",{x:"3.75",y:"5.25",width:"16.5",height:"13.5",rx:"2"}),l.jsx("path",{d:"m10.25 9 4.8 3-4.8 3V9Z"})]})}function YPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("circle",{cx:"10.7",cy:"10.7",r:"6.1"}),l.jsx("path",{d:"m15.25 15.25 4.2 4.2"})]})}function GPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M12 3.75v10.5M8.4 10.8 12 14.4l3.6-3.6"}),l.jsx("path",{d:"M5 17.25v2h14v-2"})]})}function WPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M8.75 8.75 6.9 10.6a3.4 3.4 0 0 0 4.8 4.8l1.85-1.85"}),l.jsx("path",{d:"m15.25 15.25 1.85-1.85a3.4 3.4 0 0 0-4.8-4.8l-1.85 1.85"}),l.jsx("path",{d:"m9.4 14.6 5.2-5.2"})]})}function ZPe(e){return l.jsxs("svg",{...H0,...e,children:[l.jsx("path",{d:"M5 19h3.2L18.6 8.6a1.7 1.7 0 0 0 0-2.4l-.8-.8a1.7 1.7 0 0 0-2.4 0L5 15.8V19Z"}),l.jsx("path",{d:"m13.9 6.9 3.2 3.2M5 15.8 8.2 19"})]})}function Kne(e){return l.jsx("svg",{...H0,...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}const KPe=180,YU=500,GU=10,WU=32;function JPe(e){return Array.from(new Set(e.split(/[,,]/).map(t=>t.trim()).filter(Boolean)))}function eMe({artifact:e,busy:t,error:n,onClose:i,onSave:r}){const[s,a]=m.useState(e.name),[o,c]=m.useState(e.description??""),[u,d]=m.useState((e.tags??[]).join(",")),[f,h]=m.useState(""),p=m.useId(),g=m.useId(),b=m.useRef(null),y=m.useRef(null),O=m.useRef(t),v=m.useRef(i);m.useEffect(()=>{O.current=t,v.current=i},[t,i]),m.useEffect(()=>{var T,A;const E=document.body.style.overflow,S=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(T=y.current)==null||T.focus(),(A=y.current)==null||A.select();const k=N=>{if(N.key==="Escape"&&!O.current){N.preventDefault(),v.current();return}if(N.key!=="Tab")return;const C=b.current;if(!C)return;const M=Array.from(C.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(Q=>Q.getClientRects().length>0);if(M.length===0){N.preventDefault();return}const L=M[0],P=M[M.length-1];N.shiftKey&&document.activeElement===L?(N.preventDefault(),P.focus()):!N.shiftKey&&document.activeElement===P&&(N.preventDefault(),L.focus())};return window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k),document.body.style.overflow=E,S!=null&&S.isConnected&&S.focus()}},[]);const x=E=>{var T;E.preventDefault();const S=s.trim(),k=JPe(u);if(!S){h("请输入产物名称"),(T=y.current)==null||T.focus();return}if(k.length>GU){h(`标签最多 ${GU} 个`);return}if(k.some(A=>A.length>WU)){h(`单个标签不能超过 ${WU} 个字符`);return}h(""),r({name:S,description:o.trim(),tags:k})},w=f||n;return zi.createPortal(l.jsx("div",{className:"artifact-edit-backdrop",onMouseDown:E=>{E.target===E.currentTarget&&!t&&i()},children:l.jsxs("section",{ref:b,className:"artifact-edit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":g,"aria-busy":t||void 0,children:[l.jsxs("header",{className:"artifact-edit-dialog__header",children:[l.jsxs("div",{children:[l.jsx("h2",{id:p,children:"编辑产物信息"}),l.jsx("p",{id:g,children:"内容文件不会被修改"})]}),l.jsx("button",{type:"button",onClick:i,disabled:t,"aria-label":"关闭编辑框",children:l.jsx(Kne,{})})]}),l.jsxs("form",{onSubmit:x,children:[l.jsxs("div",{className:"artifact-edit-dialog__body",children:[l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"名称"}),l.jsx("input",{ref:y,value:s,maxLength:KPe,disabled:t,"aria-invalid":!!w||void 0,onChange:E=>{a(E.target.value),h("")}})]}),l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{value:o,maxLength:YU,disabled:t,rows:4,placeholder:"补充用途、版本或使用说明",onChange:E=>c(E.target.value)}),l.jsxs("small",{children:[o.length,"/",YU]})]}),l.jsxs("label",{className:"artifact-edit-field",children:[l.jsx("span",{children:"标签"}),l.jsx("input",{value:u,disabled:t,placeholder:"使用逗号分隔,最多 10 个",onChange:E=>{d(E.target.value),h("")}})]}),w?l.jsx("div",{className:"artifact-edit-error",role:"alert",children:w}):null]}),l.jsxs("footer",{className:"artifact-edit-dialog__actions",children:[l.jsx("button",{type:"button",onClick:i,disabled:t,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:t,children:t?"保存中":"保存"})]})]})]})}),document.body)}function tMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"5.5",cy:"12",r:"1.4"}),l.jsx("circle",{cx:"12",cy:"12",r:"1.4"}),l.jsx("circle",{cx:"18.5",cy:"12",r:"1.4"})]})}function Jne({label:e,menuLabel:t,items:n,className:i="",placement:r="bottom-end"}){const[s,a]=m.useState(!1),o=m.useRef(null),c=m.useRef(null),u=m.useRef([]);m.useEffect(()=>{if(!s)return;const f=p=>{var g;(g=o.current)!=null&&g.contains(p.target)||a(!1)},h=p=>{var g;p.key==="Escape"&&(p.preventDefault(),a(!1),(g=c.current)==null||g.focus())};return window.addEventListener("pointerdown",f),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",f),window.removeEventListener("keydown",h)}},[s]),m.useEffect(()=>{var f;s&&((f=u.current.find(h=>h&&!h.disabled))==null||f.focus())},[s]);const d=f=>{var b;if(!s||!["ArrowDown","ArrowUp","Home","End"].includes(f.key))return;f.preventDefault();const h=u.current.filter(y=>!!(y&&!y.disabled));if(h.length===0)return;const p=h.indexOf(document.activeElement),g=f.key==="Home"?0:f.key==="End"?h.length-1:(p+(f.key==="ArrowDown"?1:-1)+h.length)%h.length;(b=h[g])==null||b.focus()};return l.jsxs("div",{className:"studio-action-menu",ref:o,onKeyDown:d,children:[l.jsx("button",{ref:c,type:"button",className:`studio-action-menu__trigger ${i}`.trim(),"aria-label":e,"aria-haspopup":"menu","aria-expanded":s,disabled:n.length===0,onClick:()=>a(f=>!f),children:l.jsx(tMe,{})}),s?l.jsx("div",{className:`studio-action-menu__popover studio-action-menu__popover--${r}`,role:"menu","aria-label":t,children:n.map((f,h)=>l.jsx("button",{ref:p=>{u.current[h]=p},type:"button",role:"menuitem",className:`studio-action-menu__item${f.danger?" is-danger":""}`,disabled:f.disabled,title:f.title,onClick:()=>{a(!1),f.onSelect()},children:f.label},f.label))}):null]})}function nMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 4.2 21 19H3L12 4.2Z"}),l.jsx("path",{d:"M12 9.4v4.2"}),l.jsx("path",{d:"M12 16.8h.01"})]})}function iMe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function Mf({title:e,description:t,confirmLabel:n,cancelLabel:i="取消",closeLabel:r="关闭确认框",variant:s="warning",busy:a=!1,onCancel:o,onConfirm:c}){const u=m.useId(),d=m.useId(),f=m.useRef(null),h=m.useRef(a),p=m.useRef(o);return m.useEffect(()=>{h.current=a,p.current=o},[a,o]),m.useEffect(()=>{var O;const g=document.body.style.overflow,b=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(O=f.current)==null||O.focus();const y=v=>{v.key==="Escape"&&!h.current&&p.current()};return window.addEventListener("keydown",y),()=>{document.body.style.overflow=g,window.removeEventListener("keydown",y),b!=null&&b.isConnected&&b.focus()}},[]),zi.createPortal(l.jsx("div",{className:"studio-confirm-backdrop",onMouseDown:g=>{g.target===g.currentTarget&&!a&&o()},children:l.jsxs("section",{className:`studio-confirm-dialog studio-confirm-dialog--${s}`,role:"alertdialog","aria-modal":"true","aria-labelledby":u,"aria-describedby":d,"aria-busy":a||void 0,children:[l.jsxs("header",{className:"studio-confirm-head",children:[l.jsxs("div",{className:"studio-confirm-title-wrap",children:[l.jsx("span",{className:"studio-confirm-title-icon","aria-hidden":"true",children:l.jsx(nMe,{})}),l.jsx("h2",{id:u,children:e})]}),l.jsx("button",{type:"button",className:"studio-confirm-close",onClick:o,disabled:a,"aria-label":r,children:l.jsx(iMe,{})})]}),l.jsx("div",{className:"studio-confirm-body",children:l.jsx("p",{id:d,children:t})}),l.jsxs("footer",{className:"studio-confirm-actions",children:[l.jsx("button",{ref:f,type:"button",onClick:o,disabled:a,children:i}),l.jsx("button",{type:"button",className:"studio-confirm-primary",onClick:c,disabled:a,children:n})]})]})}),document.body)}const rMe=new Set(["avif","bmp","gif","heic","jpeg","jpg","png","svg","tif","tiff","webp"]),sMe=new Set(["avi","m4v","mkv","mov","mp4","mpeg","mpg","webm"]),aMe=new Set(["csv","htm","html","json","md","pdf","svg","txt","xml","yaml","yml"]);function eie(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLocaleLowerCase()}function Mk(e,t){if(!Number.isFinite(e))return t;const n=e;return n>1e10?n:n*1e3}function oMe(e){var t,n;return((t=e.actions)==null?void 0:t.artifactDelta)??((n=e.actions)==null?void 0:n.artifact_delta)}function lMe(e){return`${e.replace(/\.pptx$/i,"")}.preview.webp`}function cMe(e){var t;return(((t=e.content)==null?void 0:t.parts)??[]).map(n=>n.functionResponse??n.function_response).filter(n=>!!n)}function uMe(e){if(!e)return{};const t=e.result;return t&&typeof t=="object"&&!Array.isArray(t)?t:e}function ZU(e,t,n){var i;if(/\.[A-Za-z0-9]{2,8}$/.test(e))return e;try{const r=new URL(t).pathname.split("/").filter(Boolean),a=((i=(r[r.length-1]??"").match(/\.[A-Za-z0-9]{2,8}$/))==null?void 0:i[0])??"";if(a)return`${e}${a}`}catch{}return`${e}.${n==="image"?"png":"mp4"}`}function dMe(e,t){const n=uMe(t),i=e==="image_generate"||e.endsWith("_image_generate"),r=["video_generate","video_task_query"].some(u=>e===u||e.endsWith(`_${u}`));if(!i&&!r)return[];const s=i?"image":"video",a=[],o=n.success_list;if(Array.isArray(o)){for(const u of o)if(!(!u||typeof u!="object"||Array.isArray(u)))for(const[d,f]of Object.entries(u))typeof f=="string"&&f.startsWith("https://")&&a.push({name:ZU(d,f,s),url:f,type:s})}const c=n.video_url;if(r&&typeof c=="string"&&c.startsWith("https://")){const u=typeof n.task_id=="string"?n.task_id:void 0;a.push({name:ZU(u||"generated-video",c,s),url:c,type:s,taskId:u})}return a}function KU(e,t){return new Date(Mk(e,t)||Date.now()).toISOString()}function fMe(e){var i;const t=[],n=new Set;for(const r of e)for(const s of r.sessions){const a=Mk(s.lastUpdateTime,Date.now()),o=E_(s.events);for(const c of s.events??[])for(const u of cMe(c)){const d=(u==null?void 0:u.name)??"";for(const f of dMe(d,u==null?void 0:u.response)){const h=`${s.id}:${c.id??""}:${d}:${f.url}`;n.has(h)||(n.add(h),t.push({sourceUrl:f.url,name:f.name,mimeType:f.type==="image"?"image/png":"video/mp4",appName:r.appName,agentId:r.agentId,agentName:((i=r.agentName)==null?void 0:i.trim())||r.appName,sessionId:s.id,sessionTitle:o,sessionUpdatedAt:KU(s.lastUpdateTime,a),createdAt:KU(c.timestamp,a),origin:{runtimeId:r.runtimeId,region:r.region,eventId:c.id,invocationId:c.invocationId??c.invocation_id,toolName:d,taskId:f.taskId}}))}}}return t}function tie(e){const t=eie(e);return rMe.has(t)?"image":sMe.has(t)?"video":"document"}function hMe(e){const t=tie(e);return t==="image"?"image":t==="video"?"video":aMe.has(eie(e))?"frame":"unavailable"}function pMe(e){var n;const t=[];for(const i of e)for(const r of i.sessions){const s=Mk(r.lastUpdateTime,0),a=new Map;for(const o of r.events??[]){const c=oMe(o);if(!c)continue;const u=Mk(o.timestamp,s);for(const[d,f]of Object.entries(c)){if(!d||!Number.isFinite(f))continue;const h=a.get(d);(!h||f>=h.version)&&a.set(d,{filename:d,version:f,createdAt:u})}}for(const o of a.values()){if(/\.preview\.webp$/i.test(o.filename))continue;const c=a.get(lMe(o.filename)),u=c??o,d=c?"image":hMe(o.filename);t.push({id:`${i.appName}:${r.id}:${o.filename}:${o.version}`,appName:i.appName,agentId:i.agentId,sessionId:r.id,sessionTitle:E_(r.events),agentName:((n=i.agentName)==null?void 0:n.trim())||i.appName,sessionUpdatedAt:s,name:o.filename,version:o.version,type:tie(o.filename),createdAt:o.createdAt||s,preview:{filename:u.filename,version:u.version,mode:d}})}}return t.sort((i,r)=>r.createdAt-i.createdAt||i.name.localeCompare(r.name,"zh-CN"))}function nie(e){if(!e)return"时间未知";const t=new Date(e);if(Number.isNaN(t.getTime()))return"时间未知";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?new Intl.DateTimeFormat("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t):new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}function iie(e){return!e||e<=0?"":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(e<10*1024*1024?1:0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}const aC=40,mMe=[{id:"document",label:"文档"},{id:"image",label:"图片"},{id:"video",label:"视频"}],gMe={document:"文档",image:"图片",video:"视频"};function mw(e){return e instanceof Error?e.message:String(e)}function rie({artifact:e,large:t=!1}){return l.jsx("div",{className:`library-artifact-preview library-artifact-preview--${e.type}${t?" is-large":""}`,children:e.thumbnailUrl?l.jsxs(l.Fragment,{children:[l.jsx("img",{className:"library-artifact-preview-media",src:e.thumbnailUrl,alt:"",loading:"lazy"}),e.type==="video"?l.jsx("span",{className:"artifact-video-play is-overlay","aria-hidden":"true",children:l.jsx(HU,{})}):null]}):e.type==="document"?l.jsxs("div",{className:"artifact-document-sheet","aria-hidden":"true",children:[l.jsx("span",{className:"is-title"}),l.jsx("span",{}),l.jsx("span",{}),l.jsx("span",{className:"is-short"})]}):e.type==="image"?l.jsxs("div",{className:"artifact-image-scene","aria-hidden":"true",children:[l.jsx("span",{className:"artifact-image-sun"}),l.jsx("span",{className:"artifact-image-plane artifact-image-plane--back"}),l.jsx("span",{className:"artifact-image-plane artifact-image-plane--front"})]}):l.jsxs("div",{className:"artifact-video-frame","aria-hidden":"true",children:[l.jsx("span",{className:"artifact-video-orbit"}),l.jsx("span",{className:"artifact-video-node artifact-video-node--one"}),l.jsx("span",{className:"artifact-video-node artifact-video-node--two"}),l.jsx("span",{className:"artifact-video-play",children:l.jsx(HU,{})})]})})}function bMe({artifact:e,pendingAction:t,disabled:n,onPreview:i,onDownload:r,onEdit:s,onDelete:a,onOpenSource:o}){const c=t===`download:${e.id}`;return l.jsxs("tr",{className:"library-artifact-row",children:[l.jsx("td",{className:"library-artifact-file",children:l.jsxs("button",{type:"button",className:"library-artifact-preview-trigger","aria-label":`预览 ${e.name}`,disabled:n||!!t,onClick:()=>i(e),children:[l.jsx("div",{className:"library-artifact-thumbnail",children:l.jsx(rie,{artifact:e})}),l.jsxs("div",{className:"library-artifact-row-title",children:[l.jsx("span",{className:"library-artifact-row-name",title:e.name,children:e.name}),l.jsx("span",{className:"library-artifact-row-size",children:iie(e.sizeBytes)||"—"})]})]})}),l.jsx("td",{className:"library-artifact-source-cell",children:o?l.jsxs("button",{type:"button",className:"library-artifact-source-link",title:`${e.agentName} / ${e.sessionTitle}`,onClick:()=>o(e),children:[l.jsx("span",{children:e.agentName}),l.jsx("span",{"aria-hidden":"true",children:"/"}),l.jsx("span",{children:e.sessionTitle})]}):l.jsxs("span",{title:`${e.agentName} / ${e.sessionTitle}`,children:[e.agentName," / ",e.sessionTitle]})}),l.jsx("td",{className:"library-artifact-time",children:nie(e.updatedAt??e.createdAt)}),l.jsx("td",{className:"library-artifact-actions-cell",children:l.jsx("div",{className:"library-artifact-actions",children:l.jsx(Jne,{label:`更多操作 ${e.name}`,menuLabel:`${e.name} 操作`,placement:"bottom-end",items:[{label:c?"下载中":"下载",onSelect:()=>r(e),disabled:n||!!t},...s?[{label:"编辑信息",onSelect:()=>s(e),disabled:n||!!t||e.canManage===!1}]:[],...a?[{label:"删除产物",onSelect:()=>a(e),disabled:n||!!t||e.canManage===!1,danger:!0}]:[]]})})})]})}function OMe({sources:e=[],items:t,userId:n="",active:i=!0,activationRevision:r=0,loading:s=!1,error:a="",onRetry:o,onEdit:c,onDelete:u,onDownload:d,onOpenSource:f}){var qe,W;const[h,p]=m.useState(null),[g,b]=m.useState(""),[y,O]=m.useState(null),[v,x]=m.useState(""),[w,E]=m.useState(""),[S,k]=m.useState(""),[T,A]=m.useState(""),[N,C]=m.useState({}),[M,L]=m.useState(()=>new Set),[P,Q]=m.useState(null),[j,$]=m.useState(!1),[U,B]=m.useState(""),[I,X]=m.useState(null),[q,D]=m.useState(!1),[H,re]=m.useState(aC),fe=m.useRef(null),Ae=m.useRef(null),J=m.useRef(0),ie=m.useRef(null),ue=m.useRef(null),ye=m.useRef(!1),Se=m.useCallback(()=>{J.current+=1,O(null),x(""),E("")},[]),Re=m.useMemo(()=>t?[...t]:pMe(e),[t,e]),Ee=m.useMemo(()=>Re.filter(K=>!M.has(K.id)).map(K=>N[K.id]??K),[Re,N,M]);m.useEffect(()=>()=>{J.current+=1},[]),m.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),m.useEffect(()=>{var z;if(!y)return;const K=document.activeElement,ae=document.body.style.overflow;document.body.style.overflow="hidden",(z=fe.current)==null||z.focus();const pe=ve=>{if(ve.key==="Escape"){ve.preventDefault(),Se();return}if(ve.key!=="Tab")return;const Be=Ae.current;if(!Be)return;const Je=Array.from(Be.querySelectorAll('button:not([disabled]), video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(Tt=>Tt.getClientRects().length>0);if(Je.length===0){ve.preventDefault();return}const kt=Je[0],Mt=Je[Je.length-1];ve.shiftKey&&document.activeElement===kt?(ve.preventDefault(),Mt.focus()):!ve.shiftKey&&document.activeElement===Mt&&(ve.preventDefault(),kt.focus())};return document.addEventListener("keydown",pe),()=>{document.removeEventListener("keydown",pe),document.body.style.overflow=ae,K!=null&&K.isConnected&&K.focus()}},[Se,y]);const me=async K=>{const ae=J.current+1;if(J.current=ae,k(""),x(""),O(K),K.preview.mode!=="unavailable"){if(K.contentUrl){x(K.contentUrl);return}E(`preview:${K.id}`);try{const pe=await YD(K.appName,n,K.sessionId,K.preview.filename,K.preview.version);if(J.current!==ae){URL.revokeObjectURL(pe);return}x(pe)}catch(pe){J.current===ae&&k(`无法预览“${K.name}”:${mw(pe)}`)}finally{J.current===ae&&E("")}}},oe=async K=>{k(""),E(`download:${K.id}`);try{d?await d(K):await HD(K.appName,n,K.sessionId,K.name,K.version),A(`已开始下载 ${K.name}`)}catch(ae){k(`无法下载“${K.name}”:${mw(ae)}`)}finally{E("")}},Ne=async K=>{if(!(!P||!c)){$(!0),B("");try{const pe=await c(P,K)??{...P,...K,updatedAt:Date.now()};C(z=>({...z,[P.id]:pe})),A(`已更新 ${pe.name}`),Q(null)}catch(ae){B(mw(ae))}finally{$(!1)}}},Oe=async()=>{if(!(!I||!u)){D(!0),k("");try{await u(I),L(K=>new Set([...K,I.id])),A(`已删除 ${I.name}`),(y==null?void 0:y.id)===I.id&&Se(),X(null)}catch(K){k(`无法删除“${I.name}”:${mw(K)}`),X(null)}finally{D(!1)}}},Ve=m.useMemo(()=>{const K=g.trim().toLocaleLowerCase();return Ee.filter(ae=>h&&ae.type!==h?!1:K?[ae.name,ae.sessionTitle,ae.agentName].some(pe=>pe.toLocaleLowerCase().includes(K)):!0)},[h,Ee,g]),We=m.useMemo(()=>Ve.slice(0,H),[Ve,H]),De=H{ye.current||(ye.current=!0,re(K=>K+aC))},[]);m.useEffect(()=>{re(aC)},[r,h,g,Ve.length]),m.useEffect(()=>{ye.current=!1},[H]),m.useEffect(()=>{const K=ue.current,ae=ie.current;if(!i||!K||!ae||!De)return;const pe=new IntersectionObserver(([z])=>{z.isIntersecting&&mt()},{root:ae,rootMargin:"240px 0px",threshold:.01});return pe.observe(K),()=>pe.disconnect()},[i,De,mt,H]);const at=()=>{const K=ie.current;!i||!K||!De||K.scrollHeight-K.scrollTop-K.clientHeight<=240&&mt()},Rt=!!g.trim()||h!==null;return l.jsxs("div",{className:"artifact-library-page",children:[l.jsxs("div",{className:"artifact-library-toolbar library-resource-toolbar",children:[l.jsx("nav",{className:"artifact-type-pills","aria-label":"产物类型",children:mMe.map(K=>l.jsx("button",{type:"button",className:`artifact-type-pill${h===K.id?" is-active":""}`,"aria-pressed":h===K.id,onClick:()=>p(ae=>ae===K.id?null:K.id),children:K.label},K.id))}),l.jsxs("label",{className:"artifact-library-search",children:[l.jsx(YPe,{}),l.jsx("input",{type:"search","aria-label":"搜索产物",value:g,onChange:K=>b(K.target.value),placeholder:"搜索产物或会话"})]})]}),a&&Ee.length>0?l.jsxs("div",{className:"artifact-library-banner",role:"alert",children:[l.jsx("span",{children:a}),o?l.jsx("button",{type:"button",onClick:o,children:"重试"}):null]}):null,S?l.jsxs("div",{className:"artifact-library-banner",role:"alert",children:[l.jsx("span",{children:S}),l.jsx("button",{type:"button",onClick:()=>k(""),children:"关闭"})]}):null,l.jsx("section",{ref:ie,className:"artifact-library-results","aria-label":"产物列表",onScroll:at,children:l.jsxs("div",{className:"artifact-library-panel",children:[s&&Ee.length===0?l.jsx("div",{className:"artifact-library-empty",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"p",duration:2.4,children:"正在加载产物"})}):a&&Ee.length===0?l.jsxs("div",{className:"artifact-library-empty is-error",role:"alert",children:[l.jsx("p",{children:"产物加载失败"}),l.jsx("span",{children:a}),o?l.jsx("button",{type:"button",onClick:o,children:"重新加载"}):null]}):Ve.length===0?l.jsxs("div",{className:"artifact-library-empty",children:[l.jsx("p",{children:Rt?"没有找到匹配的产物":"您还没有任何产物"}),l.jsx("span",{children:Rt?"请尝试搜索其他名称或切换类型":"聊天中生成的产物会自动显示在这里"})]}):l.jsx("div",{className:"artifact-library-list",children:l.jsxs("table",{className:"artifact-library-table",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"artifact-library-table__file-column"}),l.jsx("col",{className:"artifact-library-table__source-column"}),l.jsx("col",{className:"artifact-library-table__time-column"}),l.jsx("col",{className:"artifact-library-table__actions-column"})]}),l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"名称"}),l.jsx("th",{scope:"col",children:"来源"}),l.jsx("th",{scope:"col",children:"修改时间"}),l.jsx("th",{scope:"col",className:"artifact-library-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:We.map(K=>l.jsx(bMe,{artifact:K,pendingAction:w,disabled:!n&&!t,onPreview:ae=>void me(ae),onDownload:ae=>void oe(ae),onEdit:c?ae=>{B(""),Q(ae)}:void 0,onDelete:u?X:void 0,onOpenSource:f},K.id))})]})}),De?l.jsx("div",{ref:ue,className:"artifact-library-load-more",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",duration:2.4,children:"正在加载更多产物"})}):null]})}),l.jsx("p",{className:"artifact-library-status","aria-live":"polite",children:T}),y?l.jsxs("div",{className:"artifact-library-preview-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"artifact-library-preview-title",children:[l.jsx("button",{type:"button",className:"artifact-library-preview-backdrop","aria-label":"关闭预览",onClick:Se}),l.jsxs("div",{ref:Ae,className:"artifact-library-preview-panel",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("h2",{id:"artifact-library-preview-title",children:y.name}),l.jsxs("p",{children:[gMe[y.type]," / 版本 ",y.version]})]}),l.jsx("button",{ref:fe,type:"button","aria-label":"关闭预览",onClick:Se,children:l.jsx(Kne,{})})]}),l.jsxs("div",{className:"artifact-library-preview-content",children:[l.jsx("div",{className:"artifact-library-preview-canvas",children:w===`preview:${y.id}`?l.jsx(oi,{as:"span",duration:2.4,children:"正在加载预览"}):v&&y.preview.mode==="image"?l.jsx("img",{src:v,alt:`${y.name} 预览`}):v&&y.preview.mode==="video"?l.jsx("video",{src:v,controls:!0,"aria-label":`${y.name} 预览`}):v&&y.preview.mode==="frame"?l.jsx("iframe",{src:v,title:`${y.name} 预览`}):l.jsxs("div",{className:"artifact-library-preview-unavailable",children:[l.jsx(rie,{artifact:y,large:!0}),l.jsx("p",{children:S?"预览加载失败,请稍后重试或下载查看":"当前格式暂不支持在线预览,请下载查看"})]})}),l.jsxs("aside",{className:"artifact-library-preview-details","aria-label":"产物来源",children:[y.description?l.jsx("p",{className:"artifact-library-preview-description",children:y.description}):null,l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Agent"}),l.jsx("dd",{title:y.agentName,children:y.agentName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"会话"}),l.jsx("dd",{title:y.sessionTitle,children:y.sessionTitle})]}),(qe=y.origin)!=null&&qe.toolName?l.jsxs("div",{children:[l.jsx("dt",{children:"生成工具"}),l.jsx("dd",{children:y.origin.toolName})]}):null,l.jsxs("div",{children:[l.jsx("dt",{children:"生成时间"}),l.jsx("dd",{children:nie(y.createdAt)})]}),y.sizeBytes?l.jsxs("div",{children:[l.jsx("dt",{children:"文件大小"}),l.jsx("dd",{children:iie(y.sizeBytes)})]}):null]}),(W=y.tags)!=null&&W.length?l.jsx("div",{className:"artifact-library-preview-tags","aria-label":"标签",children:y.tags.map(K=>l.jsx("span",{children:K},K))}):null]})]}),l.jsxs("footer",{children:[l.jsxs("div",{className:"artifact-library-preview-footer-start",children:[f?l.jsxs("button",{type:"button",className:"is-secondary",onClick:()=>{const K=y;Se(),f(K)},children:[l.jsx(WPe,{}),"查看会话"]}):null,c?l.jsxs("button",{type:"button",className:"is-secondary",disabled:y.canManage===!1,onClick:()=>{const K=y;Se(),B(""),Q(K)},children:[l.jsx(ZPe,{}),"编辑信息"]}):null]}),l.jsxs("button",{type:"button",disabled:w.startsWith("download:")||!n&&!t,onClick:()=>void oe(y),children:[l.jsx(GPe,{}),"下载"]})]})]})]}):null,P?l.jsx(eMe,{artifact:P,busy:j,error:U,onClose:()=>{j||Q(null)},onSave:K=>void Ne(K)}):null,I?l.jsx(Mf,{title:"删除产物?",description:`“${I.name}”将从产物库永久删除,聊天记录不会受到影响。`,confirmLabel:q?"删除中":"删除",closeLabel:"关闭删除确认框",variant:"danger",busy:q,onCancel:()=>{q||X(null)},onConfirm:()=>void Oe()}):null]})}function yMe(e,t){if(e&&typeof e=="object"&&"detail"in e){const n=e.detail;if(typeof n=="string"&&n.trim())return n}return t}async function C1(e,t){if(e.ok)return e;let n;try{n=await e.json()}catch{n=void 0}throw new Error(yMe(n,`${t}(${e.status})`))}function oC(e){if(typeof e=="number")return e;if(typeof e!="string")return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function sie(e){const t=e;return{...t,createdAt:oC(t.createdAt),updatedAt:oC(t.updatedAt),sessionUpdatedAt:oC(t.sessionUpdatedAt)}}async function aie(e){const t=await e.json();return Array.isArray(t.items)?t.items.map(sie):[]}async function xMe(){const e=await C1(await ri("/web/artifacts"),"读取产物库失败");return aie(e)}async function vMe(e){if(e.length===0)return xMe();const t=await C1(await ri("/web/artifacts/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidates:e})},24e4),"同步聊天产物失败");return aie(t)}async function wMe(e,t){const n=await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),"更新产物失败");return sie(await n.json())}async function SMe(e){await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}`,{method:"DELETE"}),"删除产物失败")}async function EMe(e){const n=await(await C1(await ri(`/web/artifacts/${encodeURIComponent(e.id)}/content?download=true`,{},24e4),"下载产物失败")).blob(),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}function oie(e){var t,n,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t{const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const n=t.offsetWidth;let i=.985;n<=80?i=.96:n<=150?i=.97:n<=220?i=.98:n>600&&(i=.995),t.style.setProperty("--scale",i.toString())},LP=(e,t)=>{const n=()=>{const a=setTimeout(e);return()=>{clearTimeout(a)}};if(!NMe||typeof window.requestAnimationFrame!="function"||cie&&document.visibilityState==="hidden")return n();let r=2,s=window.requestAnimationFrame(function a(){r-=1,r===0?e():s=window.requestAnimationFrame(a)});return()=>{typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(s)}},C$=e=>Object.keys(e).reduce((n,i)=>{const r=e[i];if(r||r===0){const s=i.startsWith("--")?"":"--",a=typeof r=="number"?`${r}px`:r;n[`${s}${i}`]=a}return n},{}),ZS=e=>{e.preventDefault()},die=e=>e.querySelectorAll('a[href], input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex^="-"]), [contenteditable]'),CMe=e=>{const t=m.Children.toArray(e),n=[];let i="";const r=()=>{i!==""&&(n.push(i),i="")};for(const s of t)if(!(s==null||typeof s=="boolean")){if(typeof s=="string"||typeof s=="number"){i+=String(s);continue}r(),n.push(s)}return r(),n},j$=e=>{const t=CMe(e),n=m.Children.count(t);return m.Children.map(t,i=>{if(typeof i=="string"&&i.trim())return n<=1?i:l.jsx("span",{children:i});if(m.isValidElement(i)){const r=i,{children:s,...a}=r.props;return s!=null?m.cloneElement(r,a,j$(s)):r}return i})};m.createContext(null);var jMe=typeof tf=="object"&&tf&&tf.Object===Object&&tf,RMe=typeof self=="object"&&self&&self.Object===Object&&self;jMe||RMe||Function("return this")();var IMe=typeof window<"u"?m.useLayoutEffect:m.useEffect;function PMe(){const e=m.useRef(!1);return m.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),m.useCallback(()=>e.current,[])}var JU={width:void 0,height:void 0};function MMe(e){const{ref:t,box:n="content-box"}=e,[{width:i,height:r},s]=m.useState(JU),a=PMe(),o=m.useRef({...JU}),c=m.useRef(void 0);return c.current=e.onResize,m.useEffect(()=>{if(!t.current||typeof window>"u"||!("ResizeObserver"in window))return;const u=new ResizeObserver(([d])=>{const f=n==="border-box"?"borderBoxSize":n==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",h=e7(d,f,"inlineSize"),p=e7(d,f,"blockSize");if(o.current.width!==h||o.current.height!==p){const b={width:h,height:p};o.current.width=h,o.current.height=p,c.current?c.current(b):a()&&s(b)}});return u.observe(t.current,{box:n}),()=>{u.disconnect()}},[n,t,a]),{width:i,height:r}}function e7(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:t==="contentBoxSize"?e.contentRect[n==="inlineSize"?"width":"height"]:void 0}function R$(e,t){const n=m.useRef(e);IMe(()=>{n.current=e},[e]),m.useEffect(()=>{if(!t&&t!==0)return;const i=setTimeout(()=>{n.current()},t);return()=>{clearTimeout(i)}},[t])}const LMe="_LoadingIndicator_7yl6f_1",DMe={LoadingIndicator:LMe},$Me=({className:e,size:t,strokeWidth:n,style:i,...r})=>l.jsx("div",{...r,className:Ps(DMe.LoadingIndicator,e),style:i||C$({"indicator-size":t,"indicator-stroke":n})});function fie(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const QMe=()=>lie,t7=(e,t=!1,n="TransitionGroup")=>{const i=[];return m.Children.forEach(e,r=>{if(r&&typeof r=="object"&&"key"in r&&r.key)i.push(r);else if(t)throw new Error(`Child elements of <${n} /> must include a \`key\``)}),i},rm=()=>{},sm=e=>{const t=m.useRef(e);return t.current=e,m.useCallback(n=>t.current(n),[])};function BMe(e,t,n,i){const r=e.reduce((c,u)=>({...c,[u.key]:1}),{}),s=t.reduce((c,u)=>({...c,[u.component.key]:1}),{}),a=e.filter(c=>!s[c.key]).map(n),o=t.map(c=>({...c,component:e.find(({key:u})=>u===c.component.key)||c.component,shouldRender:!!r[c.component.key]}));return i==="append"?o.concat(a):a.concat(o)}function UMe(e,t,n){if((lie||TMe)&&t&&n>1)throw new Error(`Cannot use forwardRef with multiple children in <${e} />`)}const zMe="_TransitionGroupChild_1hv1z_1",FMe={TransitionGroupChild:zMe},hie={enter:!1,enterActive:!1,exit:!1,exitActive:!1,interrupted:!1},VMe=e=>({...hie,enter:!e}),XMe=(e,t)=>{switch(t.type){case"enter-before":return{enter:!0,enterActive:!1,exit:!1,exitActive:!1,interrupted:e.interrupted||e.exit};case"enter-active":return{enter:!0,enterActive:!0,exit:!1,exitActive:!1,interrupted:!1};case"exit-before":return{enter:!1,enterActive:!1,exit:!0,exitActive:!1,interrupted:e.interrupted||e.enter};case"exit-active":return{enter:!1,enterActive:!1,exit:!0,exitActive:!0,interrupted:!1};case"done":default:return hie}},qMe=({ref:e,as:t,children:n,className:i,transitionId:r,style:s,preventMountTransition:a,shouldRender:o,enterDuration:c,exitDuration:u,removeChild:d,onEnter:f,onEnterActive:h,onEnterComplete:p,onExit:g,onExitActive:b,onExitComplete:y})=>{const[O,v]=m.useReducer(XMe,VMe(a||!1)),x=m.useRef(!1),w=m.useRef(null),E=m.useRef(c);E.current=c;const S=m.useRef(u);S.current=u;const k=m.useRef(null),T=m.useCallback(A=>{const N=w.current;if(!(!N||A===k.current))switch(k.current=A,A){case"enter":f(N);break;case"enter-active":h(N);break;case"enter-complete":p(N);break;case"exit":g(N);break;case"exit-active":b(N);break;case"exit-complete":y(N);break}},[f,h,p,g,b,y]);return mn.useLayoutEffect(()=>{if(!o){let C;v({type:"exit-before"}),T("exit");const M=LP(()=>{v({type:"exit-active"}),T("exit-active"),C=window.setTimeout(()=>{T("exit-complete"),d()},S.current)});return()=>{M(),C!==void 0&&clearTimeout(C)}}if(a&&!x.current){x.current=!0;return}let A;v({type:"enter-before"}),T("enter");const N=LP(()=>{v({type:"enter-active"}),T("enter-active"),A=window.setTimeout(()=>{v({type:"done"}),T("enter-complete")},E.current)});return()=>{N(),A!==void 0&&clearTimeout(A)}},[o,a,d,T]),m.useEffect(()=>()=>{x.current=!1},[]),l.jsx(t,{ref:fie([w,e]),className:Ps(i,FMe.TransitionGroupChild),"data-transition-id":r,style:s,"data-entering":O.enter?"":void 0,"data-entering-active":O.enterActive?"":void 0,"data-exiting":O.exit?"":void 0,"data-exiting-active":O.exitActive?"":void 0,"data-interrupted":O.interrupted?"":void 0,children:n})},HMe=e=>{const{enterMountDelay:t,preventMountTransition:n}=e,i=!n&&t!=null?t:null,[r,s]=m.useState(i==null);return R$(()=>s(!0),r?null:i),r?l.jsx(qMe,{...e}):null},pie=e=>{const{ref:t,as:n="span",children:i,className:r,transitionId:s,style:a,enterDuration:o=0,exitDuration:c=0,preventInitialTransition:u=!0,enterMountDelay:d,insertMethod:f="append",disableAnimations:h=QMe()}=e,p=sm(e.onEnter??rm),g=sm(e.onEnterActive??rm),b=sm(e.onEnterComplete??rm),y=sm(e.onExit??rm),O=sm(e.onExitActive??rm),v=sm(e.onExitComplete??rm);m.Children.forEach(i,S=>{if(S&&!S.key)throw new Error("Child elements of must include a `key`")});const x=m.useCallback(S=>({component:S,shouldRender:!0,removeChild:()=>{E(k=>k.filter(T=>S.key!==T.component.key))},onEnter:p,onEnterActive:g,onEnterComplete:b,onExit:y,onExitActive:O,onExitComplete:v}),[p,g,b,y,O,v]),[w,E]=m.useState(()=>t7(i).map(S=>({...x(S),preventMountTransition:u})));return m.useLayoutEffect(()=>{E(S=>{const k=t7(i);return BMe(k,S,x,f)})},[i,f,x]),UMe("TransitionGroup",t,m.Children.count(i)),h?l.jsx(l.Fragment,{children:m.Children.map(i,S=>l.jsx(n,{ref:t,className:r,style:a,"data-transition-id":s,children:S}))}):l.jsx(l.Fragment,{children:w.map(({component:S,...k})=>l.jsx(HMe,{...k,as:n,className:r,transitionId:s,enterDuration:o,exitDuration:c,enterMountDelay:d,style:a,ref:t,children:S},S.key))})},YMe="_Button_1864l_1",GMe="_ButtonInner_1864l_4",WMe="_ButtonLoader_1864l_749",lC={Button:YMe,ButtonInner:GMe,ButtonLoader:WMe},zu=e=>{const{type:t="button",color:n="primary",variant:i="solid",pill:r=!0,uniform:s=!1,size:a="md",iconSize:o,gutterSize:c,loading:u,selected:d,block:f,opticallyAlign:h,children:p,className:g,onClick:b,disabled:y,disabledTone:O,inert:v=u,...x}=e,w=y||v,E=m.useCallback(S=>{y||b==null||b(S)},[b,y]);return l.jsxs("button",{type:t,className:Ps(lC.Button,g),"data-color":n,"data-variant":i,"data-pill":r?"":void 0,"data-uniform":s?"":void 0,"data-size":a,"data-gutter-size":c,"data-icon-size":o,"data-loading":u?"":void 0,"data-selected":d?"":void 0,"data-block":f?"":void 0,"data-optically-align":h,onPointerEnter:uie,disabled:w,"aria-disabled":w,tabIndex:w?-1:void 0,"data-disabled":y?"":void 0,"data-disabled-tone":y?O:void 0,onClick:E,...x,children:[l.jsx(pie,{className:lC.ButtonLoader,enterDuration:250,exitDuration:150,children:u&&l.jsx($Me,{},"loader")}),l.jsx("span",{className:lC.ButtonInner,children:j$(p)})]})};var ZMe=Object.defineProperty,I$=(e,t)=>ZMe(e,"name",{value:t,configurable:!0});function DP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}I$(DP,"setRef");function mie(...e){return t=>{let n=!1;const i=e.map(r=>{const s=DP(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;rKMe(e,"name",{value:t,configurable:!0});function Lf(e){const t=m.forwardRef((n,i)=>{let{children:r,...s}=n,a=null,o=!1;const c=[];$P(r)&&typeof gw=="function"&&(r=gw(r._payload)),m.Children.forEach(r,h=>{var p;if(vie(h)){o=!0;const g=h;let b="child"in g.props?g.props.child:g.props.children;$P(b)&&typeof gw=="function"&&(b=gw(b._payload)),a=JMe(g,b),c.push((p=a==null?void 0:a.props)==null?void 0:p.children)}else c.push(h)}),a?a=m.cloneElement(a,void 0,c):!o&&m.Children.count(r)===1&&m.isValidElement(r)&&(a=r);const u=a?xie(a):void 0,d=Sr(i,u);if(!a){if(r||r===0)throw new Error(o?nLe(e):tLe(e));return r}const f=yie(s,a.props??{});return a.type!==m.Fragment&&(f.ref=i?d:u),m.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}Vl(Lf,"createSlot");var gie=Lf("Slot"),bie=Symbol.for("radix.slottable");function Oie(e){const t=Vl(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=bie,t}Vl(Oie,"createSlottable");var JMe=Vl((e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function yie(e,t){const n={...t};for(const i in t){const r=e[i],s=t[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{const c=s(...o);return r(...o),c}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}Vl(yie,"mergeProps");function xie(e){var i,r;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Vl(xie,"getElementRef");function vie(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bie}Vl(vie,"isSlottable");var eLe=Symbol.for("react.lazy");function $P(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===eLe&&"_payload"in e&&wie(e._payload)}Vl($P,"isLazyComponent");function wie(e){return typeof e=="object"&&e!==null&&"then"in e}Vl(wie,"isPromiseLike");var tLe=Vl(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),nLe=Vl(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),gw=j0[" use ".trim().toString()],iLe=Object.defineProperty,rLe=(e,t)=>iLe(e,"name",{value:t,configurable:!0}),sLe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qr=sLe.reduce((e,t)=>{const n=Lf(`Primitive.${t}`),i=m.forwardRef((r,s)=>{const{asChild:a,...o}=r,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...o,ref:s})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function Sie(e,t){e&&zi.flushSync(()=>e.dispatchEvent(t))}rLe(Sie,"dispatchDiscreteCustomEvent");var aLe=Object.defineProperty,oLe=(e,t)=>aLe(e,"name",{value:t,configurable:!0}),lLe=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),cLe=m.forwardRef(oLe(function(t,n){return l.jsx(qr.span,{...t,ref:n,style:{...lLe,...t.style}})},"VisuallyHidden")),uLe=cLe,dLe=Object.defineProperty,Xo=(e,t)=>dLe(e,"name",{value:t,configurable:!0});function fLe(e,t){const n=m.createContext(t);n.displayName=e+"Context";const i=Xo(s=>{const{children:a,...o}=s,c=m.useMemo(()=>o,Object.values(o));return l.jsx(n.Provider,{value:c,children:a})},"Provider");i.displayName=e+"Provider";function r(s,a={}){const{optional:o=!1}=a,c=m.useContext(n);if(c)return c;if(t!==void 0)return t;if(!o)throw new Error(`\`${s}\` must be used within \`${e}\``)}return Xo(r,"useContext"),[i,r]}Xo(fLe,"createContext");function Xl(e,t=[]){let n=[];function i(s,a){const o=m.createContext(a);o.displayName=s+"Context";const c=n.length;n=[...n,a];const u=Xo(f=>{var O;const{scope:h,children:p,...g}=f,b=((O=h==null?void 0:h[e])==null?void 0:O[c])||o,y=m.useMemo(()=>g,Object.values(g));return l.jsx(b.Provider,{value:y,children:p})},"Provider");u.displayName=s+"Provider";function d(f,h,p={}){var O;const{optional:g=!1}=p,b=((O=h==null?void 0:h[e])==null?void 0:O[c])||o,y=m.useContext(b);if(y)return y;if(a!==void 0)return a;if(!g)throw new Error(`\`${f}\` must be used within \`${s}\``)}return Xo(d,"useContext"),[u,d]}Xo(i,"createContext");const r=Xo(()=>{const s=n.map(a=>m.createContext(a));return Xo(function(o){const c=(o==null?void 0:o[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...o,[e]:c}}),[o,c])},"useScope")},"createScope");return r.scopeName=e,[i,Eie(r,...t)]}Xo(Xl,"createContextScope");function Eie(...e){const t=e[0];if(e.length===1)return t;const n=Xo(()=>{const i=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return Xo(function(s){const a=i.reduce((o,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...o,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Xo(Eie,"composeContextScopes");var hLe=Object.defineProperty,ps=(e,t)=>hLe(e,"name",{value:t,configurable:!0});function kie(e){const t=e+"CollectionProvider",[n,i]=Xl(t),[r,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=ps(b=>{const{scope:y,children:O}=b,v=m.useRef(null),x=m.useRef(new Map).current;return l.jsx(r,{scope:y,itemMap:x,collectionRef:v,children:O})},"CollectionProvider");a.displayName=t;const o=e+"CollectionSlot",c=Lf(o),u=m.forwardRef((b,y)=>{const{scope:O,children:v}=b,x=s(o,O),w=Sr(y,x.collectionRef);return l.jsx(c,{ref:w,children:v})});u.displayName=o;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Lf(d),p=m.forwardRef((b,y)=>{const{scope:O,children:v,...x}=b,w=m.useRef(null),E=Sr(y,w),S=s(d,O);return m.useEffect(()=>(S.itemMap.set(w,{ref:w,...x}),()=>void S.itemMap.delete(w))),l.jsx(h,{[f]:"",ref:E,children:v})});p.displayName=d;function g(b){const y=s(e+"CollectionConsumer",b);return m.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((S,k)=>x.indexOf(S.ref.current)-x.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return ps(g,"useCollection"),[{Provider:a,Slot:u,ItemSlot:p},g,i]}ps(kie,"createCollection");var n7=new WeakMap,Qr,oo,cC=(oo=class extends Map{constructor(n){super(n);l6(this,Qr);BN(this,Qr,[...super.keys()]),n7.set(this,!0)}set(n,i){return n7.get(this)&&(this.has(n)?Fs(this,Qr)[Fs(this,Qr).indexOf(n)]=n:Fs(this,Qr).push(n)),super.set(n,i),this}insert(n,i,r){const s=this.has(i),a=Fs(this,Qr).length,o=P$(n);let c=o>=0?o:a+o;const u=c<0||c>=a?-1:c;if(u===this.size||s&&u===this.size-1||u===-1)return this.set(i,r),this;const d=this.size+(s?0:1);o<0&&c++;const f=[...Fs(this,Qr)];let h,p=!1;for(let g=c;g=this.size&&(s=this.size-1),this.at(s)}keyFrom(n,i){const r=this.indexOf(n);if(r===-1)return;let s=r+i;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return s;r++}}findIndex(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return r;r++}return-1}filter(n,i){const r=[];let s=0;for(const a of this)Reflect.apply(n,i,[a,s,this])&&r.push(a),s++;return new oo(r)}map(n,i){const r=[];let s=0;for(const a of this)r.push([a[0],Reflect.apply(n,i,[a,s,this])]),s++;return new oo(r)}reduce(...n){const[i,r]=n;let s=0,a=r??this.at(0);for(const o of this)s===0&&n.length===1?a=o:a=Reflect.apply(i,this,[a,o,s,this]),s++;return a}reduceRight(...n){const[i,r]=n;let s=r??this.at(-1);for(let a=this.size-1;a>=0;a--){const o=this.at(a);a===this.size-1&&n.length===1?s=o:s=Reflect.apply(i,this,[s,o,a,this])}return s}toSorted(n){const i=[...this.entries()].sort(n);return new oo(i)}toReversed(){const n=new oo;for(let i=this.size-1;i>=0;i--){const r=this.keyAt(i),s=this.get(r);n.set(r,s)}return n}toSpliced(...n){const i=[...this.entries()];return i.splice(...n),new oo(i)}slice(n,i){const r=new oo;let s=this.size-1;if(n===void 0)return r;n<0&&(n=n+this.size),i!==void 0&&i>0&&(s=i-1);for(let a=n;a<=s;a++){const o=this.keyAt(a),c=this.get(o);r.set(o,c)}return r}every(n,i){let r=0;for(const s of this){if(!Reflect.apply(n,i,[s,r,this]))return!1;r++}return!0}some(n,i){let r=0;for(const s of this){if(Reflect.apply(n,i,[s,r,this]))return!0;r++}return!1}},Qr=new WeakMap,ps(oo,"OrderedDict"),oo);function KS(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Tie(e,t);return n===-1?void 0:e[n]}ps(KS,"at");function Tie(e,t){const n=e.length,i=P$(t),r=i>=0?i:n+i;return r<0||r>=n?-1:r}ps(Tie,"toSafeIndex");function P$(e){return e!==e||e===0?0:Math.trunc(e)}ps(P$,"toSafeInteger");function pLe(e){const t=e+"CollectionProvider",[n,i]=Xl(t),[r,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new cC,setItemMap:ps(()=>{},"setItemMap")}),a=ps(({state:x,...w})=>x?l.jsx(c,{...w,state:x}):l.jsx(o,{...w}),"CollectionProvider");a.displayName=t;const o=ps(x=>{const w=y();return l.jsx(c,{...x,state:w})},"CollectionInit");o.displayName=t+"Init";const c=ps(x=>{const{scope:w,children:E,state:S}=x,k=m.useRef(null),[T,A]=m.useState(null),N=Sr(k,A),[C,M]=S;return m.useEffect(()=>{if(!T)return;const L=Nie(()=>{});return L.observe(T,{childList:!0,subtree:!0}),()=>{L.disconnect()}},[T]),l.jsx(r,{scope:w,itemMap:C,setItemMap:M,collectionRef:N,collectionRefObject:k,collectionElement:T,children:E})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",d=Lf(u),f=m.forwardRef((x,w)=>{const{scope:E,children:S}=x,k=s(u,E),T=Sr(w,k.collectionRef);return l.jsx(d,{ref:T,children:S})});f.displayName=u;const h=e+"CollectionItemSlot",p="data-radix-collection-item",g=Lf(h),b=m.forwardRef((x,w)=>{const{scope:E,children:S,...k}=x,T=m.useRef(null),[A,N]=m.useState(null),C=Sr(w,T,N),M=s(h,E),{setItemMap:L}=M,P=m.useRef(k);_ie(P.current,k)||(P.current=k);const Q=P.current;return m.useEffect(()=>{const j=Q;return L($=>A?$.has(A)?$.set(A,{...j,element:A}).toSorted(QP):($.set(A,{...j,element:A}),$.toSorted(QP)):$),()=>{L($=>!A||!$.has(A)?$:($.delete(A),new cC($)))}},[A,Q,L]),l.jsx(g,{[p]:"",ref:C,children:S})});b.displayName=h;function y(){return m.useState(new cC)}ps(y,"useInitCollection");function O(x){const{itemMap:w}=s(e+"CollectionConsumer",x);return w}return ps(O,"useCollection"),[{Provider:a,Slot:f,ItemSlot:b},{createCollectionScope:i,useCollection:O,useInitCollection:y}]}ps(pLe,"createCollection");function _ie(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}ps(_ie,"shallowEqual");function Aie(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}ps(Aie,"isElementPreceding");function QP(e,t){return!e[1].element||!t[1].element?0:Aie(e[1].element,t[1].element)?-1:1}ps(QP,"sortByDocumentPosition");function Nie(e){return new MutationObserver(n=>{for(const i of n)if(i.type==="childList"){e();return}})}ps(Nie,"getChildListObserver");var mLe=Object.defineProperty,Y0=(e,t)=>mLe(e,"name",{value:t,configurable:!0}),Cie=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ti(e,t,{checkForDefaultPrevented:n=!0}={}){return Y0(function(r){if(e==null||e(r),n===!1||!r||!r.defaultPrevented)return t==null?void 0:t(r)},"handleEvent")}Y0(Ti,"composeEventHandlers");function gLe(e){var t;if(!Cie)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Y0(gLe,"getOwnerWindow");function BP(e){if(!Cie)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Y0(BP,"getOwnerDocument");function jie(e,t=!1){const{activeElement:n}=BP(e);if(!(n!=null&&n.nodeName))return null;if(Rie(n)&&n.contentDocument)return jie(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=BP(n).getElementById(i);if(r)return r}}return n}Y0(jie,"getActiveElement");function Rie(e){return e.tagName==="IFRAME"}Y0(Rie,"isFrame");var tl=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},bLe=Object.defineProperty,OLe=(e,t)=>bLe(e,"name",{value:t,configurable:!0}),i7=j0[" useEffectEvent ".trim().toString()],r7=j0[" useInsertionEffect ".trim().toString()];function Iie(e){if(typeof i7=="function")return i7(e);const t=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof r7=="function"?r7(()=>{t.current=e}):tl(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var i;return(i=t.current)==null?void 0:i.call(t,...n)},[])}OLe(Iie,"useEffectEvent");var yLe=Object.defineProperty,j1=(e,t)=>yLe(e,"name",{value:t,configurable:!0}),xLe=j0[" useInsertionEffect ".trim().toString()]||tl;function bd({prop:e,defaultProp:t,onChange:n=j1(()=>{},"onChange"),caller:i}){const[r,s,a]=Pie({defaultProp:t,onChange:n}),o=e!==void 0,c=o?e:r,u=m.useCallback(d=>{var f;if(o){const h=Mie(d)?d(e):d;h!==e&&((f=a.current)==null||f.call(a,h))}else s(d)},[o,e,s,a]);return[c,u]}j1(bd,"useControllableState");function Pie({defaultProp:e,onChange:t}){const[n,i]=m.useState(e),r=m.useRef(n),s=m.useRef(t);return xLe(()=>{s.current=t},[t]),m.useEffect(()=>{var a;r.current!==n&&((a=s.current)==null||a.call(s,n),r.current=n)},[n,r]),[n,i,s]}j1(Pie,"useUncontrolledState");function Mie(e){return typeof e=="function"}j1(Mie,"isFunction");var s7=Symbol("RADIX:SYNC_STATE");function vLe(e,t,n,i){const{prop:r,defaultProp:s,onChange:a,caller:o}=t,c=r!==void 0,u=Iie(a),d=[{...n,state:s}];i&&d.push(i);const[f,h]=m.useReducer((y,O)=>{if(O.type===s7)return{...y,state:O.state};const v=e(y,O);return c&&!Object.is(v.state,y.state)&&u(v.state),v},...d),p=f.state,g=m.useRef(p);m.useEffect(()=>{g.current!==p&&(g.current=p,c||u(p))},[p,g,c]);const b=m.useMemo(()=>r!==void 0?{...f,state:r}:f,[f,r]);return m.useEffect(()=>{c&&!Object.is(r,f.state)&&h({type:s7,state:r})},[r,f.state,c]),[b,h]}j1(vLe,"useControllableStateReducer");var wLe=Object.defineProperty,id=(e,t)=>wLe(e,"name",{value:t,configurable:!0});function Lie(e,t){return m.useReducer((n,i)=>t[n][i]??n,e)}id(Lie,"useStateMachine");var G0=id(e=>{const{present:t,children:n}=e,i=Die(t),r=typeof n=="function"?n({present:i.isPresent}):m.Children.only(n),s=$ie(i.ref,Qie(r));return typeof n=="function"||i.isPresent?m.cloneElement(r,{ref:s}):null},"Presence");function Die(e){const[t,n]=m.useState(),i=m.useRef(null),r=m.useRef(e),s=m.useRef("none"),a=m.useRef(void 0),o=e?"mounted":"unmounted",[c,u]=Lie(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{c==="mounted"?(s.current=a.current??_m(i.current),a.current=void 0):s.current="none"},[c]),tl(()=>{const d=i.current,f=r.current;if(f!==e){const p=s.current,g=_m(d);e?(a.current=g,u("MOUNT")):g==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,u]),tl(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,h=id(g=>{const y=_m(i.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(u("ANIMATION_END"),!r.current)){const O=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=O)})}},"handleAnimationEnd"),p=id(g=>{g.target===t&&(s.current=_m(i.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:m.useCallback(d=>{if(d){const f=getComputedStyle(d);i.current=f,a.current=_m(f)}else i.current=null;n(d)},[])}}id(Die,"usePresence");function UP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}id(UP,"setRef");function $ie(...e){const t=m.useRef(e);return t.current=e,m.useCallback(n=>{const i=t.current;let r=!1;const s=i.map(a=>{const o=UP(a,n);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;aSLe(e,"name",{value:t,configurable:!0}),kLe=j0[" useId ".trim().toString()]||(()=>{}),TLe=0;function F_(e){const[t,n]=m.useState(kLe());return tl(()=>{e||n(i=>i??String(TLe++))},[e]),e||(t?`radix-${t}`:"")}ELe(F_,"useId");var _Le=Object.defineProperty,ALe=(e,t)=>_Le(e,"name",{value:t,configurable:!0}),NLe=m.createContext(void 0);function V_(e){const t=m.useContext(NLe);return e||t||"ltr"}ALe(V_,"useDirection");var CLe=Object.defineProperty,jLe=(e,t)=>CLe(e,"name",{value:t,configurable:!0});function Df(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var i;return(i=t.current)==null?void 0:i.call(t,...n)},[])}jLe(Df,"useCallbackRef");var RLe=Object.defineProperty,fs=(e,t)=>RLe(e,"name",{value:t,configurable:!0}),zP="dismissableLayer.update",ILe="dismissableLayer.pointerDownOutside",PLe="dismissableLayer.focusOutside",a7,Bie=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Uie=m.forwardRef(fs(function(t,n){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:u,...d}=t,f=m.useContext(Bie),[h,p]=m.useState(null),g=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=m.useState({}),y=Sr(n,p),O=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),x=v?O.indexOf(v):-1,w=h?O.indexOf(h):-1,E=f.layersWithOutsidePointerEventsDisabled.size>0,S=w>=x,k=m.useRef(!1),T=zie(M=>{a==null||a(M),c==null||c(M),M.defaultPrevented||u==null||u()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(M=>{if(!(M instanceof Node))return!1;const L=[...f.branches].some(P=>P.contains(M));return S&&!L},[f.branches,S])}),A=Fie(M=>{if(r&&k.current)return;const L=M.target;[...f.branches].some(Q=>Q.contains(L))||(o==null||o(M),c==null||c(M),M.defaultPrevented||u==null||u())},g),N=h?w===O.length-1:!1,C=Df(M=>{M.key==="Escape"&&(s==null||s(M),!M.defaultPrevented&&u&&(M.preventDefault(),u()))});return m.useEffect(()=>{if(N)return g.addEventListener("keydown",C,{capture:!0}),()=>g.removeEventListener("keydown",C,{capture:!0})},[g,N,C]),m.useEffect(()=>{if(h)return i&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(a7=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(h)),f.layers.add(h),FP(),()=>{i&&(f.layersWithOutsidePointerEventsDisabled.delete(h),f.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=a7))}},[h,g,i,f]),m.useEffect(()=>()=>{h&&(f.layers.delete(h),f.layersWithOutsidePointerEventsDisabled.delete(h),FP())},[h,f]),m.useEffect(()=>{const M=fs(()=>b({}),"handleUpdate");return document.addEventListener(zP,M),()=>document.removeEventListener(zP,M)},[]),l.jsx(qr.div,{...d,ref:y,style:{pointerEvents:E?S?"auto":"none":void 0,...t.style},onFocusCapture:Ti(t.onFocusCapture,A.onFocusCapture),onBlurCapture:Ti(t.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Ti(t.onPointerDownCapture,T.onPointerDownCapture)})},"DismissableLayer"));function MLe(){const e=m.useContext(Bie),[t,n]=m.useState(null);return m.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}fs(MLe,"useDismissableLayerSurface");var LLe=fs(()=>!0,"IS_TRUE");function zie(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:s,shouldHandlePointerDownOutside:a=LLe}=t,o=Df(e),c=m.useRef(!1),u=m.useRef(!1),d=m.useRef(new Map),f=m.useRef(()=>{});return m.useEffect(()=>{function h(){u.current=!1,r.current=!1,d.current.clear()}fs(h,"resetOutsideInteraction");function p(){return Array.from(d.current.values()).some(Boolean)}fs(p,"isOutsideInteractionIntercepted");function g(x){if(!u.current)return;const w=x.target;w instanceof Node&&[...s].some(S=>S.contains(w))||d.current.set(x.type,!0),x.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}fs(g,"handleInteractionCapture");function b(x){u.current&&d.current.set(x.type,!1)}fs(b,"handleInteractionBubble");const y=fs(x=>{if(x.target&&!c.current){let w=function(){n.removeEventListener("click",f.current);const S=p();h(),S||M$(ILe,o,E,{discrete:!0})};if(fs(w,"handleAndDispatchPointerDownOutsideEvent"),!a(x.target)){n.removeEventListener("click",f.current),h(),c.current=!1;return}const E={originalEvent:x};u.current=!0,r.current=i&&x.button===0,d.current.clear(),!i||x.button!==0?w():(n.removeEventListener("click",f.current),f.current=w,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),h();c.current=!1},"handlePointerDown"),O=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const x of O)n.addEventListener(x,g,!0),n.addEventListener(x,b);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",y),n.removeEventListener("click",f.current);for(const x of O)n.removeEventListener(x,g,!0),n.removeEventListener(x,b)}},[n,o,i,r,s,a]),{onPointerDownCapture:fs(()=>c.current=!0,"onPointerDownCapture")}}fs(zie,"usePointerDownOutside");function Fie(e,t=globalThis==null?void 0:globalThis.document){const n=Df(e),i=m.useRef(!1);return m.useEffect(()=>{const r=fs(s=>{s.target&&!i.current&&M$(PLe,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:fs(()=>i.current=!0,"onFocusCapture"),onBlurCapture:fs(()=>i.current=!1,"onBlurCapture")}}fs(Fie,"useFocusOutside");function FP(){const e=new CustomEvent(zP);document.dispatchEvent(e)}fs(FP,"dispatchUpdate");function M$(e,t,n,{discrete:i}){const r=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),i?Sie(r,s):r.dispatchEvent(s)}fs(M$,"handleAndDispatchCustomEvent");var DLe=Object.defineProperty,ba=(e,t)=>DLe(e,"name",{value:t,configurable:!0}),uC="focusScope.autoFocusOnMount",dC="focusScope.autoFocusOnUnmount",o7={bubbles:!1,cancelable:!0},$Le=m.forwardRef(ba(function(t,n){const{loop:i=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[c,u]=m.useState(null),d=Df(s),f=Df(a),h=m.useRef(null),p=Sr(n,u),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let y=function(w){if(g.paused||!c)return;const E=w.target;c.contains(E)?h.current=E:Eu(h.current,{select:!0})},O=function(w){if(g.paused||!c)return;const E=w.relatedTarget;E!==null&&(c.contains(E)||Eu(h.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&Eu(c)};ba(y,"handleFocusIn"),ba(O,"handleFocusOut"),ba(v,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",O);const x=new MutationObserver(v);return c&&x.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",O),x.disconnect()}}},[r,c,g.paused]),m.useEffect(()=>{if(c){l7.add(g);const y=document.activeElement;if(!c.contains(y)){const v=new CustomEvent(uC,o7);c.addEventListener(uC,d),c.dispatchEvent(v),v.defaultPrevented||(Vie(Gie(L$(c)),{select:!0}),document.activeElement===y&&Eu(c))}return()=>{c.removeEventListener(uC,d),setTimeout(()=>{const v=new CustomEvent(dC,o7);c.addEventListener(dC,f),c.dispatchEvent(v),v.defaultPrevented||Eu(y??document.body,{select:!0}),c.removeEventListener(dC,f),l7.remove(g)},0)}}},[c,d,f,g]);const b=m.useCallback(y=>{if(!i&&!r||g.paused)return;const O=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,v=document.activeElement;if(O&&v){const x=y.currentTarget,[w,E]=Xie(x);w&&E?!y.shiftKey&&v===E?(y.preventDefault(),i&&Eu(w,{select:!0})):y.shiftKey&&v===w&&(y.preventDefault(),i&&Eu(E,{select:!0})):v===x&&y.preventDefault()}},[i,r,g.paused]);return l.jsx(qr.div,{tabIndex:-1,...o,ref:p,onKeyDown:b})},"FocusScope"));function Vie(e,{select:t=!1}={}){const n=document.activeElement;for(const i of e)if(Eu(i,{select:t}),document.activeElement!==n)return}ba(Vie,"focusFirst");function Xie(e){const t=L$(e),n=VP(t,e),i=VP(t.reverse(),e);return[n,i]}ba(Xie,"getTabbableEdges");function L$(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ba(i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}ba(L$,"getTabbableCandidates");function VP(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const i of e)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):qie(i,{upTo:t})))return i}ba(VP,"findVisible");function qie(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}ba(qie,"isHidden");function Hie(e){return e instanceof HTMLInputElement&&"select"in e}ba(Hie,"isSelectableInput");function Eu(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Hie(e)&&t&&e.select()}}ba(Eu,"focus");var l7=Yie();function Yie(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=XP(e,t),e.unshift(t)},remove(t){var n;e=XP(e,t),(n=e[0])==null||n.resume()}}}ba(Yie,"createFocusScopesStack");function XP(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}ba(XP,"arrayRemove");function Gie(e){return e.filter(t=>t.tagName!=="A")}ba(Gie,"removeLinks");var QLe=Object.defineProperty,BLe=(e,t)=>QLe(e,"name",{value:t,configurable:!0}),Wie=m.forwardRef(BLe(function(t,n){var c;const{container:i,...r}=t,[s,a]=m.useState(!1);tl(()=>a(!0),[]);const o=i||s&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?zi.createPortal(l.jsx(qr.div,{...r,ref:n}),o):null},"Portal")),ULe=Object.defineProperty,D$=(e,t)=>ULe(e,"name",{value:t,configurable:!0}),bw=0,dc=null;function zLe(e){return $$(),e.children}D$(zLe,"FocusGuards");function $$(){m.useEffect(()=>{dc||(dc={start:qP(),end:qP()});const{start:e,end:t}=dc;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),bw++,()=>{bw===1&&(dc==null||dc.start.remove(),dc==null||dc.end.remove(),dc=null),bw=Math.max(0,bw-1)}},[])}D$($$,"useFocusGuards");function qP(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}D$(qP,"createFocusGuard");var vc=function(){return vc=Object.assign||function(t){for(var n,i=1,r=arguments.length;i"u")return s5e;var t=a5e(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},l5e=ere(),wg="data-scroll-locked",c5e=function(e,t,n,i){var r=e.left,s=e.top,a=e.right,o=e.gap;return n===void 0&&(n="margin"),` + .`.concat(VLe,` { overflow: hidden `).concat(i,`; padding-right: `).concat(o,"px ").concat(i,`; } @@ -491,75 +491,75 @@ ${u}`:c,children:[l.jsxs("span",{className:`account-avatar${p?" has-image":""}`, } body[`).concat(wg,`] { - `).concat(VLe,": ").concat(o,`px; + `).concat(XLe,": ").concat(o,`px; } -`)},u7=function(){var e=parseInt(document.body.getAttribute(wg)||"0",10);return isFinite(e)?e:0},c5e=function(){m.useEffect(function(){return document.body.setAttribute(wg,(u7()+1).toString()),function(){var e=u7()-1;e<=0?document.body.removeAttribute(wg):document.body.setAttribute(wg,e.toString())}},[])},u5e=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,r=i===void 0?"margin":i;c5e();var s=m.useMemo(function(){return a5e(r)},[r]);return m.createElement(o5e,{styles:l5e(s,!t,r,n?"":"!important")})},HP=!1;if(typeof window<"u")try{var Ow=Object.defineProperty({},"passive",{get:function(){return HP=!0,!0}});window.addEventListener("test",Ow,Ow),window.removeEventListener("test",Ow,Ow)}catch{HP=!1}var am=HP?{passive:!1}:!1,d5e=function(e){return e.tagName==="TEXTAREA"},ere=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!d5e(e)&&n[t]==="visible")},f5e=function(e){return ere(e,"overflowY")},h5e=function(e){return ere(e,"overflowX")},d7=function(e,t){var n=t.ownerDocument,i=t;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var r=tre(e,i);if(r){var s=nre(e,i),a=s[1],o=s[2];if(a>o)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},p5e=function(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;return[t,n,i]},m5e=function(e){var t=e.scrollLeft,n=e.scrollWidth,i=e.clientWidth;return[t,n,i]},tre=function(e,t){return e==="v"?f5e(t):h5e(t)},nre=function(e,t){return e==="v"?p5e(t):m5e(t)},g5e=function(e,t){return e==="h"&&t==="rtl"?-1:1},b5e=function(e,t,n,i,r){var s=g5e(e,window.getComputedStyle(t).direction),a=s*i,o=n.target,c=t.contains(o),u=!1,d=a>0,f=0,h=0;do{if(!o)break;var p=nre(e,o),g=p[0],b=p[1],y=p[2],O=b-y-s*g;(g||O)&&tre(e,o)&&(f+=O,h+=g);var v=o.parentNode;o=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&o!==document.body||c&&(t.contains(o)||t===o));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},yw=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},f7=function(e){return[e.deltaX,e.deltaY]},h7=function(e){return e&&"current"in e?e.current:e},O5e=function(e,t){return e[0]===t[0]&&e[1]===t[1]},y5e=function(e){return` +`)},u7=function(){var e=parseInt(document.body.getAttribute(wg)||"0",10);return isFinite(e)?e:0},u5e=function(){m.useEffect(function(){return document.body.setAttribute(wg,(u7()+1).toString()),function(){var e=u7()-1;e<=0?document.body.removeAttribute(wg):document.body.setAttribute(wg,e.toString())}},[])},d5e=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,r=i===void 0?"margin":i;u5e();var s=m.useMemo(function(){return o5e(r)},[r]);return m.createElement(l5e,{styles:c5e(s,!t,r,n?"":"!important")})},HP=!1;if(typeof window<"u")try{var Ow=Object.defineProperty({},"passive",{get:function(){return HP=!0,!0}});window.addEventListener("test",Ow,Ow),window.removeEventListener("test",Ow,Ow)}catch{HP=!1}var am=HP?{passive:!1}:!1,f5e=function(e){return e.tagName==="TEXTAREA"},tre=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!f5e(e)&&n[t]==="visible")},h5e=function(e){return tre(e,"overflowY")},p5e=function(e){return tre(e,"overflowX")},d7=function(e,t){var n=t.ownerDocument,i=t;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var r=nre(e,i);if(r){var s=ire(e,i),a=s[1],o=s[2];if(a>o)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},m5e=function(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;return[t,n,i]},g5e=function(e){var t=e.scrollLeft,n=e.scrollWidth,i=e.clientWidth;return[t,n,i]},nre=function(e,t){return e==="v"?h5e(t):p5e(t)},ire=function(e,t){return e==="v"?m5e(t):g5e(t)},b5e=function(e,t){return e==="h"&&t==="rtl"?-1:1},O5e=function(e,t,n,i,r){var s=b5e(e,window.getComputedStyle(t).direction),a=s*i,o=n.target,c=t.contains(o),u=!1,d=a>0,f=0,h=0;do{if(!o)break;var p=ire(e,o),g=p[0],b=p[1],y=p[2],O=b-y-s*g;(g||O)&&nre(e,o)&&(f+=O,h+=g);var v=o.parentNode;o=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&o!==document.body||c&&(t.contains(o)||t===o));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},yw=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},f7=function(e){return[e.deltaX,e.deltaY]},h7=function(e){return e&&"current"in e?e.current:e},y5e=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x5e=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},x5e=0,om=[];function v5e(e){var t=m.useRef([]),n=m.useRef([0,0]),i=m.useRef(),r=m.useState(x5e++)[0],s=m.useState(Jie)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var b=zLe([e.lockRef.current],(e.shards||[]).map(h7),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var o=m.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!a.current.allowPinchZoom;var O=yw(b),v=n.current,x="deltaX"in b?b.deltaX:v[0]-O[0],w="deltaY"in b?b.deltaY:v[1]-O[1],E,S=b.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in b&&k==="h"&&S.type==="range")return!1;var T=window.getSelection(),A=T&&T.anchorNode,N=A?A===S||A.contains(S):!1;if(N)return!1;var C=d7(k,S);if(!C)return!0;if(C?E=k:(E=k==="v"?"h":"v",C=d7(k,S)),!C)return!1;if(!i.current&&"changedTouches"in b&&(x||w)&&(i.current=E),!E)return!0;var M=i.current||E;return b5e(M,y,b,M==="h"?x:w)},[]),c=m.useCallback(function(b){var y=b;if(!(!om.length||om[om.length-1]!==s)){var O="deltaY"in y?f7(y):yw(y),v=t.current.filter(function(E){return E.name===y.type&&(E.target===y.target||y.target===E.shadowParent)&&O5e(E.delta,O)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(a.current.shards||[]).map(h7).filter(Boolean).filter(function(E){return E.contains(y.target)}),w=x.length>0?o(y,x[0]):!a.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),u=m.useCallback(function(b,y,O,v){var x={name:b,delta:y,target:O,should:v,shadowParent:w5e(O)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),d=m.useCallback(function(b){n.current=yw(b),i.current=void 0},[]),f=m.useCallback(function(b){u(b.type,f7(b),b.target,o(b,e.lockRef.current))},[]),h=m.useCallback(function(b){u(b.type,yw(b),b.target,o(b,e.lockRef.current))},[]);m.useEffect(function(){return om.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,am),document.addEventListener("touchmove",c,am),document.addEventListener("touchstart",d,am),function(){om=om.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,am),document.removeEventListener("touchmove",c,am),document.removeEventListener("touchstart",d,am)}},[]);var p=e.removeScrollBar,g=e.inert;return m.createElement(m.Fragment,null,g?m.createElement(s,{styles:y5e(r)}):null,p?m.createElement(u5e,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function w5e(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const S5e=ZLe(Kie,v5e);var ire=m.forwardRef(function(e,t){return m.createElement(X_,vc({},e,{ref:t,sideCar:S5e}))});ire.classNames=X_.classNames;var E5e=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lm=new WeakMap,xw=new WeakMap,vw={},mC=0,rre=function(e){return e&&(e.host||rre(e.parentNode))},k5e=function(e,t){return t.map(function(n){if(e.contains(n))return n;var i=rre(n);return i&&e.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},T5e=function(e,t,n,i){var r=k5e(t,Array.isArray(e)?e:[e]);vw[n]||(vw[n]=new WeakMap);var s=vw[n],a=[],o=new Set,c=new Set(r),u=function(f){!f||o.has(f)||(o.add(f),u(f.parentNode))};r.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(o.has(h))d(h);else try{var p=h.getAttribute(i),g=p!==null&&p!=="false",b=(lm.get(h)||0)+1,y=(s.get(h)||0)+1;lm.set(h,b),s.set(h,y),a.push(h),b===1&&g&&xw.set(h,!0),y===1&&h.setAttribute(n,"true"),g||h.setAttribute(i,"true")}catch(O){console.error("aria-hidden: cannot operate on ",h,O)}})};return d(t),o.clear(),mC++,function(){a.forEach(function(f){var h=lm.get(f)-1,p=s.get(f)-1;lm.set(f,h),s.set(f,p),h||(xw.has(f)||f.removeAttribute(i),xw.delete(f)),p||f.removeAttribute(n)}),mC--,mC||(lm=new WeakMap,lm=new WeakMap,xw=new WeakMap,vw={})}},_5e=function(e,t,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=E5e(e);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),T5e(i,r,n,"aria-hidden")):function(){return null}},A5e=Object.defineProperty,N5e=(e,t)=>A5e(e,"name",{value:t,configurable:!0});function q_(e){const[t,n]=m.useState(void 0);return tl(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let a,o;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,o=u.blockSize}else a=e.offsetWidth,o=e.offsetHeight;n({width:a,height:o})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else n(void 0)},[e]),t}N5e(q_,"useSize");var C5e=Object.defineProperty,rd=(e,t)=>C5e(e,"name",{value:t,configurable:!0}),Q$="Checkbox",[j5e,vOt]=Xl(Q$),[R5e,B$]=j5e(Q$);function sre(e){const{__scopeCheckbox:t,checked:n,children:i,defaultChecked:r,disabled:s,form:a,name:o,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,p]=bd({prop:n,defaultProp:r??!1,onChange:c,caller:Q$}),[g,b]=m.useState(null),[y,O]=m.useState(null),v=m.useRef(!1),[x,w]=m.useReducer(k=>k+1,0),E=g?!!a||!!g.closest("form"):!0,S={checked:h,disabled:s,setChecked:p,control:g,setControl:b,name:o,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:Fu(r)?!1:r,isFormControl:E,bubbleInput:y,setBubbleInput:O};return l.jsx(R5e,{scope:t,...S,children:are(f)?f(S):i})}rd(sre,"CheckboxProvider");var I5e="CheckboxTrigger",P5e=m.forwardRef(rd(function({__scopeCheckbox:t,onKeyDown:n,onClick:i,...r},s){const{control:a,value:o,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:p,onUserInteraction:g,isFormControl:b,bubbleInput:y}=B$(I5e,t),O=Sr(s,f),v=m.useRef(u);return m.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const w=rd(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[a,h]),l.jsx(qr.button,{type:"button",role:"checkbox","aria-checked":Fu(u)?"mixed":u,"aria-required":d,"data-state":U$(u),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:O,onKeyDown:Ti(n,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Ti(i,x=>{g(),h(w=>Fu(w)?!0:!w),y&&b&&(p.current=x.isPropagationStopped(),p.current||x.stopPropagation())})})},"CheckboxTrigger")),M5e=m.forwardRef(rd(function(t,n){const{__scopeCheckbox:i,name:r,checked:s,defaultChecked:a,required:o,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return l.jsx(sre,{__scopeCheckbox:i,checked:s,defaultChecked:a,disabled:c,required:o,onCheckedChange:d,name:r,form:f,value:u,internal_do_not_use_render:({isFormControl:p})=>l.jsxs(l.Fragment,{children:[l.jsx(P5e,{...h,ref:n,__scopeCheckbox:i}),p&&l.jsx(Q5e,{__scopeCheckbox:i})]})})},"Checkbox")),L5e="CheckboxIndicator",D5e=m.forwardRef(rd(function(t,n){const{__scopeCheckbox:i,forceMount:r,...s}=t,a=B$(L5e,i);return l.jsx(G0,{present:r||Fu(a.checked)||a.checked===!0,children:l.jsx(qr.span,{"data-state":U$(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),$5e="CheckboxBubbleInput",Q5e=m.forwardRef(rd(function({__scopeCheckbox:t,onClick:n,...i},r){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:p,form:g,bubbleInput:b,setBubbleInput:y}=B$($5e,t),O=Sr(r,y),v=q_(s),x=m.useRef(!1),w=m.useRef(c),E=m.useRef(o);m.useEffect(()=>{const k=b;if(!k)return;const T=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(T,"checked").set,C=o!==E.current;E.current=o;const M=w.current!==c;w.current=c;const L=!(C&&a.current);if(M&&N){x.current=!C;const P=new Event("click",{bubbles:L});k.indeterminate=Fu(c),N.call(k,Fu(c)?!1:c),k.dispatchEvent(P),x.current=!1}},[b,c,a,o]);const S=m.useRef(Fu(c)?!1:c);return l.jsx(qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??S.current,required:d,disabled:f,name:h,value:p,form:g,...i,tabIndex:-1,ref:O,onClick:Ti(n,k=>{x.current&&k.stopPropagation()}),style:{...i.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function are(e){return typeof e=="function"}rd(are,"isFunction");function Fu(e){return e==="indeterminate"}rd(Fu,"isIndeterminate");function U$(e){return Fu(e)?"indeterminate":e?"checked":"unchecked"}rd(U$,"getState");const B5e=["top","right","bottom","left"],$f=Math.min,Vu=Math.max,Lk=Math.round,ww=Math.floor,Xu=e=>({x:e,y:e}),U5e={left:"right",right:"left",bottom:"top",top:"bottom"};function ore(e,t,n){return Vu(e,$f(t,n))}function sd(e,t){return typeof e=="function"?e(t):e}function Qf(e){return e.split("-")[0]}function W0(e){return e.split("-")[1]}function z$(e){return e==="x"?"y":"x"}function F$(e){return e==="y"?"height":"width"}function Nc(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function V$(e){return z$(Nc(e))}function z5e(e,t,n){n===void 0&&(n=!1);const i=W0(e),r=V$(e),s=F$(r);let a=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Dk(a)),[a,Dk(a)]}function F5e(e){const t=Dk(e);return[YP(e),t,YP(t)]}function YP(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const p7=["left","right"],m7=["right","left"],V5e=["top","bottom"],X5e=["bottom","top"];function q5e(e,t,n){switch(e){case"top":case"bottom":return n?t?m7:p7:t?p7:m7;case"left":case"right":return t?V5e:X5e;default:return[]}}function H5e(e,t,n,i){const r=W0(e);let s=q5e(Qf(e),n==="start",i);return r&&(s=s.map(a=>a+"-"+r),t&&(s=s.concat(s.map(YP)))),s}function Dk(e){const t=Qf(e);return U5e[t]+e.slice(t.length)}function Y5e(e){var t,n,i,r;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(i=e.bottom)!=null?i:0,left:(r=e.left)!=null?r:0}}function lre(e){return typeof e!="number"?Y5e(e):{top:e,right:e,bottom:e,left:e}}function $k(e){const{x:t,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:t,right:t+i,bottom:n+r,x:t,y:n}}function g7(e,t,n){let{reference:i,floating:r}=e;const s=Nc(t),a=V$(t),o=F$(a),c=Qf(t),u=s==="y",d=i.x+i.width/2-r.width/2,f=i.y+i.height/2-r.height/2,h=i[o]/2-r[o]/2;let p;switch(c){case"top":p={x:d,y:i.y-r.height};break;case"bottom":p={x:d,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:f};break;case"left":p={x:i.x-r.width,y:f};break;default:p={x:i.x,y:i.y}}const g=W0(t);return g&&(p[a]+=h*(g==="end"?1:-1)*(n&&u?-1:1)),p}async function G5e(e,t){var n;t===void 0&&(t={});const{x:i,y:r,platform:s,rects:a,elements:o,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=sd(t,e),g=lre(p),y=o[h?f==="floating"?"reference":"floating":f],O=$k(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:i,y:r,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),w=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},E=$k(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:x,strategy:c}):v);return{top:(O.top-E.top+g.top)/w.y,bottom:(E.bottom-O.bottom+g.bottom)/w.y,left:(O.left-E.left+g.left)/w.x,right:(E.right-O.right+g.right)/w.x}}const W5e=50,Z5e=async(e,t,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:a}=n,o=a.detectOverflow?a:{...a,detectOverflow:G5e},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:f}=g7(u,i,c),h=i,p=0;const g={};for(let b=0;b({name:"arrow",options:e,async fn(t){const{x:n,y:i,placement:r,rects:s,platform:a,elements:o,middlewareData:c}=t,{element:u,padding:d=0}=sd(e,t)||{};if(u==null)return{};const f=lre(d),h={x:n,y:i},p=V$(r),g=F$(p),b=await a.getDimensions(u),y=p==="y",O=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[p]-h[p]-s.floating[g],E=h[p]-s.reference[p],S=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let k=S?S[x]:0;(!k||!await(a.isElement==null?void 0:a.isElement(S)))&&(k=o.floating[x]||s.floating[g]);const T=w/2-E/2,A=k/2-b[g]/2-1,N=$f(f[O],A),C=$f(f[v],A),M=k-b[g]-C,L=k/2-b[g]/2+T,P=ore(N,L,M),Q=!c.arrow&&W0(r)!=null&&L!==P&&s.reference[g]/2-(LP<=0)){var C,M;const P=(((C=s.flip)==null?void 0:C.index)||0)+1,Q=k[P];if(Q&&(!(f==="alignment"?v!==Nc(Q):!1)||N.every(U=>Nc(U.placement)===v?U.overflows[0]>0:!0)))return{data:{index:P,overflows:N},reset:{placement:Q}};let j=(M=N.filter($=>$.overflows[0]<=0).sort(($,U)=>$.overflows[1]-U.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(p){case"bestFit":{var L;const $=(L=N.filter(U=>{if(S){const B=Nc(U.placement);return B===v||B==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(B=>B>0).reduce((B,I)=>B+I,0)]).sort((U,B)=>U[1]-B[1])[0])==null?void 0:L[0];$&&(j=$);break}case"initialPlacement":j=o;break}if(r!==j)return{reset:{placement:j}}}return{}}}};function b7(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function O7(e){return B5e.some(t=>e[t]>=0)}const eDe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:i}=t,{strategy:r="referenceHidden",...s}=sd(e,t);switch(r){case"referenceHidden":{const a=await i.detectOverflow(t,{...s,elementContext:"reference"}),o=b7(a,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:O7(o)}}}case"escaped":{const a=await i.detectOverflow(t,{...s,altBoundary:!0}),o=b7(a,n.floating);return{data:{escapedOffsets:o,escaped:O7(o)}}}default:return{}}}}},cre=new Set(["left","top"]);async function tDe(e,t){const{placement:n,platform:i,elements:r}=e,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),a=Qf(n),o=W0(n),c=Nc(n)==="y",u=cre.has(a)?-1:1,d=s&&c?-1:1,f=sd(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return o&&typeof g=="number"&&(p=o==="end"?g*-1:g),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const nDe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:r,y:s,placement:a,middlewareData:o}=t,c=await tDe(t,e);return a===((n=o.offset)==null?void 0:n.placement)&&(i=o.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:a}}}}},iDe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:r,platform:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:c={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...u}=sd(e,t),d={x:n,y:i},f=await s.detectOverflow(t,u),h=Nc(r),p=z$(h);let g=d[p],b=d[h];const y=(v,x)=>ore(x+f[v==="y"?"top":"left"],x,x-f[v==="y"?"bottom":"right"]);a&&(g=y(p,g)),o&&(b=y(h,b));const O=c.fn({...t,[p]:g,[h]:b});return{...O,data:{x:O.x-n,y:O.y-i,enabled:{[p]:a,[h]:o}}}}}},rDe=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,i;const{x:r,y:s,placement:a,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:f=!0}=sd(e,t),h={x:r,y:s},p=Nc(a),g=z$(p);let b=h[g],y=h[p];const O=sd(u,t),v=typeof O=="number"?{mainAxis:O,crossAxis:0}:{mainAxis:(n=O.mainAxis)!=null?n:0,crossAxis:(i=O.crossAxis)!=null?i:0};if(d){const E=g==="y"?"height":"width",S=o.reference[g]-o.floating[E]+v.mainAxis,k=o.reference[g]+o.reference[E]-v.mainAxis;bk&&(b=k)}if(f){var x,w;const E=g==="y"?"width":"height",S=cre.has(Qf(a)),k=o.reference[p]-o.floating[E]+(S&&((x=c.offset)==null?void 0:x[p])||0)+(S?0:v.crossAxis),T=o.reference[p]+o.reference[E]+(S?0:((w=c.offset)==null?void 0:w[p])||0)-(S?v.crossAxis:0);yT&&(y=T)}return{[g]:b,[p]:y}}}},sDe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:i,platform:r,elements:s}=t,{apply:a=()=>{},...o}=sd(e,t),c=await r.detectOverflow(t,o),u=Qf(n),d=W0(n),f=Nc(n)==="y",{width:h,height:p}=i.floating;let g,b;u==="top"||u==="bottom"?(g=u,b=d===(await(r.isRTL==null?void 0:r.isRTL(s.floating))?"start":"end")?"left":"right"):(b=u,g=d==="end"?"top":"bottom");const y=p-c.top-c.bottom,O=h-c.left-c.right,v=$f(p-c[g],y),x=$f(h-c[b],O),w=t.middlewareData.shift,E=!w;let S=v,k=x;w!=null&&w.enabled.x&&(k=O),w!=null&&w.enabled.y&&(S=y),E&&!d&&(f?k=h-2*Vu(c.left,c.right):S=p-2*Vu(c.top,c.bottom)),await a({...t,availableWidth:k,availableHeight:S});const T=await r.getDimensions(s.floating);return h!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function H_(){return typeof window<"u"}function Z0(e){return ure(e)?(e.nodeName||"").toLowerCase():"#document"}function za(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Od(e){var t;return(t=(ure(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ure(e){return H_()?e instanceof Node||e instanceof za(e).Node:!1}function Uc(e){return H_()?e instanceof Element||e instanceof za(e).Element:!1}function eh(e){return H_()?e instanceof HTMLElement||e instanceof za(e).HTMLElement:!1}function y7(e){return!H_()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof za(e).ShadowRoot}function Y_(e){const{overflow:t,overflowX:n,overflowY:i,display:r}=zc(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&r!=="inline"&&r!=="contents"}function aDe(e){return/^(table|td|th)$/.test(Z0(e))}function G_(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const oDe=/transform|translate|scale|rotate|perspective|filter/,lDe=/paint|layout|strict|content/,fh=e=>!!e&&e!=="none";let gC;function X$(e){const t=Uc(e)?zc(e):e;return fh(t.transform)||fh(t.translate)||fh(t.scale)||fh(t.rotate)||fh(t.perspective)||!q$()&&(fh(t.backdropFilter)||fh(t.filter))||oDe.test(t.willChange||"")||lDe.test(t.contain||"")}function cDe(e){let t=vp(e);for(;eh(t)&&!gx(t);){if(X$(t))return t;if(G_(t))return null;t=vp(t)}return null}function q$(){return gC==null&&(gC=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),gC}function gx(e){return/^(html|body|#document)$/.test(Z0(e))}function zc(e){return za(e).getComputedStyle(e)}function W_(e){return Uc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vp(e){if(Z0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||y7(e)&&e.host||Od(e);return y7(t)?t.host:t}function dre(e){const t=vp(e);return gx(t)?(e.ownerDocument||e).body:eh(t)&&Y_(t)?t:dre(t)}function bx(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=dre(e),s=r===((i=e.ownerDocument)==null?void 0:i.body),a=za(r);if(s){const o=GP(a);return t.concat(a,a.visualViewport||[],Y_(r)?r:[],o&&n?bx(o):[])}else return t.concat(r,bx(r,[],n))}function GP(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fre(e){const t=zc(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const r=eh(e),s=r?e.offsetWidth:n,a=r?e.offsetHeight:i,o=Lk(n)!==s||Lk(i)!==a;return o&&(n=s,i=a),{width:n,height:i,$:o}}function H$(e){return Uc(e)?e:e.contextElement}function Sg(e){const t=H$(e);if(!eh(t))return Xu(1);const n=t.getBoundingClientRect(),{width:i,height:r,$:s}=fre(t);let a=(s?Lk(n.width):n.width)/i,o=(s?Lk(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const uDe=Xu(0);function hre(e){const t=za(e);return!q$()||!t.visualViewport?uDe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function dDe(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===za(e)}function wp(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=H$(e);let a=Xu(1);t&&(i?Uc(i)&&(a=Sg(i)):a=Sg(e));const o=dDe(s,n,i)?hre(s):Xu(0);let c=(r.left+o.x)/a.x,u=(r.top+o.y)/a.y,d=r.width/a.x,f=r.height/a.y;if(s&&i){const h=za(s),p=Uc(i)?za(i):i;let g=h,b=GP(g);for(;b&&p!==g;){const y=Sg(b),O=b.getBoundingClientRect(),v=zc(b),x=O.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,w=O.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=x,u+=w,g=za(b),b=GP(g)}}return $k({width:d,height:f,x:c,y:u})}function Z_(e,t){const n=W_(e).scrollLeft;return t?t.left+n:wp(Od(e)).left+n}function pre(e,t){const n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Z_(e,n),r=n.top+t.scrollTop;return{x:i,y:r}}function fDe(e){let{elements:t,rect:n,offsetParent:i,strategy:r}=e;const s=r==="fixed",a=Od(i),o=t?G_(t.floating):!1;if(i===a||o&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Xu(1);const d=Xu(0),f=eh(i);if((f||!s)&&((Z0(i)!=="body"||Y_(a))&&(c=W_(i)),f)){const p=wp(i);u=Sg(i),d.x=p.x+i.clientLeft,d.y=p.y+i.clientTop}const h=a&&!f&&!s?pre(a,c):Xu(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function hDe(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function pDe(e){const t=W_(e),n=e.ownerDocument.body,i=Vu(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=Vu(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Z_(e);const a=-t.scrollTop;return zc(n).direction==="rtl"&&(s+=Vu(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:a}}const mDe=25;function gDe(e,t,n){n===void 0&&(n="viewport");const i=n==="layoutViewport",r=za(e),s=Od(e),a=r.visualViewport;let o=s.clientWidth,c=s.clientHeight,u=0,d=0;if(a){const h=!q$()||t==="fixed";i?h||(u=-a.offsetLeft,d=-a.offsetTop):(o=a.width,c=a.height,h&&(u=a.offsetLeft,d=a.offsetTop))}if(Z_(s)<=0){const h=s.ownerDocument,p=h.body,g=getComputedStyle(p),b=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(s.clientWidth-p.clientWidth-b),O=getComputedStyle(s).scrollbarGutter==="stable both-edges"?y/2:y;O<=mDe&&(o-=O)}return{width:o,height:c,x:u,y:d}}function bDe(e,t){const n=wp(e,!0,t==="fixed"),i=n.top+e.clientTop,r=n.left+e.clientLeft,s=Sg(e),a=e.clientWidth*s.x,o=e.clientHeight*s.y,c=r*s.x,u=i*s.y;return{width:a,height:o,x:c,y:u}}function x7(e,t,n){let i;if(t==="viewport"||t==="layoutViewport")i=gDe(e,n,t);else if(t==="document")i=pDe(Od(e));else if(Uc(t))i=bDe(t,n);else{const r=hre(e);i={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return $k(i)}function ODe(e,t){const n=t.get(e);if(n)return n;let i=bx(e,[],!1).filter(o=>Uc(o)&&Z0(o)!=="body"),r=null;const s=zc(e).position==="fixed";let a=s?vp(e):e;for(;Uc(a)&&!gx(a);){const o=zc(a),c=X$(a),u=r?r.position:s?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&o.position==="static")?i=i.filter(f=>f!==a):r=o,a=vp(a)}return t.set(e,i),i}function yDe(e){let{element:t,boundary:n,rootBoundary:i,strategy:r}=e;const a=[...n==="clippingAncestors"?G_(t)?[]:ODe(t,this._c):[].concat(n),i],o=x7(t,a[0],r);let c=o.top,u=o.right,d=o.bottom,f=o.left;for(let h=1;h{o(!1,1e-7)},1e3)}k=!1}try{i=new IntersectionObserver(T,{...S,root:s.ownerDocument})}catch{i=new IntersectionObserver(T,S)}i.observe(e)}const c=za(e),u=()=>o(n);return c.addEventListener("resize",u),o(!0),()=>{c.removeEventListener("resize",u),a()}}function TDe(e,t,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,u=H$(e),d=r||s?[...u?bx(u):[],...t?bx(t):[]]:[];d.forEach(O=>{r&&O.addEventListener("scroll",n),s&&O.addEventListener("resize",n)});const f=u&&o?kDe(u,n,s):null;let h=-1,p=null;a&&(p=new ResizeObserver(O=>{let[v]=O;v&&v.target===u&&p&&t&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),u&&!c&&p.observe(u),t&&p.observe(t));let g,b=c?wp(e):null;c&&y();function y(){const O=wp(e);b&&!gre(b,O)&&n(),b=O,g=requestAnimationFrame(y)}return n(),()=>{var O;d.forEach(v=>{r&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(O=p)==null||O.disconnect(),p=null,c&&cancelAnimationFrame(g)}}const _De=nDe,ADe=iDe,NDe=J5e,CDe=sDe,jDe=eDe,w7=K5e,RDe=rDe,IDe=(e,t,n)=>{const i=new Map,r=n??{},s={...EDe,...r.platform,_c:i};return Z5e(e,t,{...r,platform:s})};var PDe=typeof document<"u",MDe=function(){},tE=PDe?m.useLayoutEffect:MDe;function Qk(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,i,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(i=n;i--!==0;)if(!Qk(e[i],t[i]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(t,r[i]))return!1;for(i=n;i--!==0;){const s=r[i];if(!(s==="_owner"&&e.$$typeof)&&!Qk(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function bre(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function S7(e,t){const n=bre(e);return Math.round(t*n)/n}function OC(e){const t=m.useRef(e);return tE(()=>{t.current=e}),t}function LDe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:a}={},transform:o=!0,whileElementsMounted:c,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(i);Qk(h,i)||p(i);const[g,b]=m.useState(null),[y,O]=m.useState(null),v=m.useCallback(U=>{U!==S.current&&(S.current=U,b(U))},[]),x=m.useCallback(U=>{U!==k.current&&(k.current=U,O(U))},[]),w=s||g,E=a||y,S=m.useRef(null),k=m.useRef(null),T=m.useRef(d),A=c!=null,N=OC(c),C=OC(r),M=OC(u),L=m.useCallback(()=>{if(!S.current||!k.current)return;const U={placement:t,strategy:n,middleware:h};C.current&&(U.platform=C.current),IDe(S.current,k.current,U).then(B=>{const I={...B,isPositioned:M.current!==!1};P.current&&!Qk(T.current,I)&&(T.current=I,zi.flushSync(()=>{f(I)}))})},[h,t,n,C,M]);tE(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[u]);const P=m.useRef(!1);tE(()=>(P.current=!0,()=>{P.current=!1}),[]),tE(()=>{if(w&&(S.current=w),E&&(k.current=E),w&&E){if(N.current)return N.current(w,E,L);L()}},[w,E,L,N,A]);const Q=m.useMemo(()=>({reference:S,floating:k,setReference:v,setFloating:x}),[v,x]),j=m.useMemo(()=>({reference:w,floating:E}),[w,E]),$=m.useMemo(()=>{const U={position:n,left:0,top:0};if(!j.floating)return U;const B=S7(j.floating,d.x),I=S7(j.floating,d.y);return o?{...U,transform:"translate("+B+"px, "+I+"px)",...bre(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:I}},[n,o,j.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:Q,elements:j,floatingStyles:$}),[d,L,Q,j,$])}const DDe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:i,padding:r}=typeof e=="function"?e(n):e;return i&&t(i)?i.current!=null?w7({element:i.current,padding:r}).fn(n):{}:i?w7({element:i,padding:r}).fn(n):{}}}},$De=(e,t)=>{const n=_De(e);return{name:n.name,fn:n.fn,options:[e,t]}},QDe=(e,t)=>{const n=ADe(e);return{name:n.name,fn:n.fn,options:[e,t]}},BDe=(e,t)=>({fn:RDe(e).fn,options:[e,t]}),UDe=(e,t)=>{const n=NDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},zDe=(e,t)=>{const n=CDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},FDe=(e,t)=>{const n=jDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},VDe=(e,t)=>{const n=DDe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var XDe=Object.defineProperty,Sf=(e,t)=>XDe(e,"name",{value:t,configurable:!0}),Ore="Popper",[yre,K_]=Xl(Ore),[qDe,xre]=yre(Ore),HDe=Sf(e=>{const{__scopePopper:t,children:n}=e,[i,r]=m.useState(null),[s,a]=m.useState(void 0);return l.jsx(qDe,{scope:t,anchor:i,onAnchorChange:r,placementState:s,setPlacementState:a,children:n})},"Popper"),YDe="PopperAnchor",GDe=m.forwardRef(Sf(function(t,n){const{__scopePopper:i,virtualRef:r,...s}=t,a=xre(YDe,i),o=m.useRef(null),c=a.onAnchorChange,u=m.useCallback(b=>{o.current=b,b&&c(b)},[c]),d=Sr(n,u),f=m.useRef(null);m.useEffect(()=>{if(!r)return;const b=f.current;f.current=r.current,b!==f.current&&c(f.current)});const h=a.placementState&&J_(a.placementState),p=h==null?void 0:h[0],g=h==null?void 0:h[1];return r?null:l.jsx(qr.div,{"data-radix-popper-side":p,"data-radix-popper-align":g,...s,ref:d})},"PopperAnchor")),vre="PopperContent",[WDe,wOt]=yre(vre),ZDe=m.forwardRef(Sf(function(t,n){var ie,ue,ye,Se,Re,Ee,me;const{__scopePopper:i,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=t,O=xre(vre,i),[v,x]=m.useState(null),w=Sr(n,x),[E,S]=m.useState(null),k=q_(E),T=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,N=r+(a!=="center"?"-"+a:""),C=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},M=Array.isArray(d)?d:[d],L=M.length>0,P={padding:C,boundary:M.filter(wre),altBoundary:L},{refs:Q,floatingStyles:j,placement:$,isPositioned:U,middlewareData:B}=LDe({strategy:"fixed",placement:N,whileElementsMounted:Sf((...oe)=>TDe(...oe,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:O.anchor},middleware:[$De({mainAxis:s+A,alignmentAxis:o}),u&&QDe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?BDe():void 0,...P}),u&&UDe({...P}),zDe({...P,apply:Sf(({elements:oe,rects:Ne,availableWidth:Oe,availableHeight:Ve})=>{const{width:We,height:De}=Ne.reference,mt=oe.floating.style;mt.setProperty("--radix-popper-available-width",`${Oe}px`),mt.setProperty("--radix-popper-available-height",`${Ve}px`),mt.setProperty("--radix-popper-anchor-width",`${We}px`),mt.setProperty("--radix-popper-anchor-height",`${De}px`)},"apply")}),E&&VDe({element:E,padding:c}),KDe({arrowWidth:T,arrowHeight:A}),p&&FDe({strategy:"referenceHidden",...P,boundary:L?P.boundary:void 0})]}),I=O.setPlacementState;tl(()=>(I($),()=>{I(void 0)}),[$,I]);const[X,q]=J_($),D=Df(b);tl(()=>{U&&(D==null||D())},[U,D]);const H=(ie=B.arrow)==null?void 0:ie.x,re=(ue=B.arrow)==null?void 0:ue.y,fe=((ye=B.arrow)==null?void 0:ye.centerOffset)!==0,[Ae,J]=m.useState();return tl(()=>{v&&J(window.getComputedStyle(v).zIndex)},[v]),l.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:U?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(Se=B.transformOrigin)==null?void 0:Se.x,(Re=B.transformOrigin)==null?void 0:Re.y].join(" "),...((Ee=B.hide)==null?void 0:Ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(WDe,{scope:i,placedSide:X,placedAlign:q,onArrowChange:S,arrowX:H,arrowY:re,shouldHideArrow:fe,children:l.jsx(qr.div,{"data-side":X,"data-align":q,...y,ref:w,style:{...y.style,animation:U?(me=y.style)==null?void 0:me.animation:"none"}})})})},"PopperContent"));function wre(e){return e!==null}Sf(wre,"isNotNull");var KDe=Sf(e=>({name:"transformOrigin",options:e,fn(t){var y,O,v;const{placement:n,rects:i,middlewareData:r}=t,a=((y=r.arrow)==null?void 0:y.centerOffset)!==0,o=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=J_(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((O=r.arrow)==null?void 0:O.x)??0)+o/2,p=(((v=r.arrow)==null?void 0:v.y)??0)+c/2;let g="",b="";return u==="bottom"?(g=a?f:`${h}px`,b=`${-c}px`):u==="top"?(g=a?f:`${h}px`,b=`${i.floating.height+c}px`):u==="right"?(g=`${-c}px`,b=a?f:`${p}px`):u==="left"&&(g=`${i.floating.width+c}px`,b=a?f:`${p}px`),{data:{x:g,y:b}}}}),"transformOrigin");function J_(e){const[t,n="center"]=e.split("-");return[t,n]}Sf(J_,"getSideAndAlignFromPlacement");var Sre=HDe,Ere=GDe,kre=ZDe,JDe=Object.defineProperty,Y$=(e,t)=>JDe(e,"name",{value:t,configurable:!0}),yC=!1;function Tre(){const[e,t]=m.useState(yC);return m.useEffect(()=>{yC||(yC=!0,t(!0))},[]),e}Y$(Tre,"useIsHydrated");var _re=j0[" useSyncExternalStore ".trim().toString()];function Are(){return()=>{}}Y$(Are,"subscribe");function Nre(){return _re(Are,()=>!0,()=>!1)}Y$(Nre,"useIsHydratedModern");var e$e=typeof _re=="function"?Nre:Tre,t$e=Object.defineProperty,Bp=(e,t)=>t$e(e,"name",{value:t,configurable:!0}),xC="rovingFocusGroup.onEntryFocus",n$e={bubbles:!1,cancelable:!0},eA="RovingFocusGroup",[WP,Cre,i$e]=Eie(eA),[r$e,tA]=Xl(eA,[i$e]),[s$e,a$e]=r$e(eA),o$e=m.forwardRef(Bp(function(t,n){return l.jsx(WP.Provider,{scope:t.__scopeRovingFocusGroup,children:l.jsx(WP.Slot,{scope:t.__scopeRovingFocusGroup,children:l.jsx(l$e,{...t,ref:n})})})},"RovingFocusGroup")),l$e=m.forwardRef(Bp(function(t,n){const{__scopeRovingFocusGroup:i,orientation:r,loop:s=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=t,p=m.useRef(null),g=Sr(n,p),b=V_(a),[y,O]=bd({prop:o,defaultProp:c??null,onChange:u,caller:eA}),[v,x]=m.useState(!1),w=Df(d),E=Cre(i),S=m.useRef(!1),[k,T]=m.useState(0);return m.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(xC,w),()=>A.removeEventListener(xC,w)},[w]),l.jsx(s$e,{scope:i,orientation:r,dir:b,loop:s,currentTabStopId:y,onItemFocus:m.useCallback(A=>O(A),[O]),onItemShiftTab:m.useCallback(()=>x(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>T(A=>A-1),[]),children:l.jsx(qr.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:Ti(t.onMouseDown,()=>{S.current=!0}),onFocus:Ti(t.onFocus,A=>{const N=!S.current;if(A.target===A.currentTarget&&N&&!v){const C=new CustomEvent(xC,n$e);if(A.currentTarget.dispatchEvent(C),!C.defaultPrevented){const M=E().filter($=>$.focusable),L=M.find($=>$.active),P=M.find($=>$.id===y),j=[L,P,...M].filter(Boolean).map($=>$.ref.current);G$(j,f)}}S.current=!1}),onBlur:Ti(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),c$e="RovingFocusGroupItem",u$e=m.forwardRef(Bp(function(t,n){const{__scopeRovingFocusGroup:i,focusable:r=!0,active:s=!1,tabStopId:a,children:o,...c}=t,u=F_(),d=a||u,f=a$e(c$e,i),h=f.currentTabStopId===d,p=Cre(i),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=f,O=e$e();return tl(()=>{if(!(!O||!r))return g(),()=>b()},[O,r,g,b]),m.useEffect(()=>{if(!(O||!r))return g(),()=>b()},[O,r,g,b]),l.jsx(WP.ItemSlot,{scope:i,id:d,focusable:r,active:s,children:l.jsx(qr.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:Ti(t.onMouseDown,v=>{r?f.onItemFocus(d):v.preventDefault()}),onFocus:Ti(t.onFocus,()=>f.onItemFocus(d)),onKeyDown:Ti(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const x=Rre(v,f.orientation,f.dir);if(x!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=p().filter(S=>S.focusable).map(S=>S.ref.current);if(x==="last")E.reverse();else if(x==="prev"||x==="next"){x==="prev"&&E.reverse();const S=E.indexOf(v.currentTarget);E=f.loop?Ire(E,S+1):E.slice(S+1)}setTimeout(()=>G$(E))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:y!=null}):o})})},"RovingFocusGroupItem")),d$e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jre(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Bp(jre,"getDirectionAwareKey");function Rre(e,t,n){const i=jre(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return d$e[i]}Bp(Rre,"getFocusIntent");function G$(e,t=!1){const n=document.activeElement;for(const i of e)if(i===n||(i.focus({preventScroll:t}),document.activeElement!==n))return}Bp(G$,"focusFirst");function Ire(e,t){return e.map((n,i)=>e[(t+i)%e.length])}Bp(Ire,"wrapArray");var Pre=o$e,Mre=u$e,f$e=Object.defineProperty,th=(e,t)=>f$e(e,"name",{value:t,configurable:!0}),W$="Popover",[Lre,SOt]=Xl(W$,[K_]),Z$=K_(),[h$e,K0]=Lre(W$),p$e=th(e=>{const{__scopePopover:t,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:a=!1}=e,o=Z$(t),c=m.useRef(null),[u,d]=m.useState(!1),[f,h]=bd({prop:i,defaultProp:r??!1,onChange:s,caller:W$});return l.jsx(Sre,{...o,children:l.jsx(h$e,{scope:t,contentId:F_(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:u,onCustomAnchorAdd:m.useCallback(()=>d(!0),[]),onCustomAnchorRemove:m.useCallback(()=>d(!1),[]),modal:a,children:n})})},"Popover"),m$e="PopoverTrigger",g$e=m.forwardRef(th(function(t,n){const{__scopePopover:i,...r}=t,s=K0(m$e,i),a=Z$(i),o=Sr(n,s.triggerRef),c=l.jsx(qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":K$(s.open),...r,ref:o,onClick:Ti(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:l.jsx(Ere,{asChild:!0,...a,children:c})},"PopoverTrigger")),Dre="PopoverPortal",[b$e,O$e]=Lre(Dre,{forceMount:void 0}),y$e=th(e=>{const{__scopePopover:t,forceMount:n,children:i,container:r}=e,s=K0(Dre,t);return l.jsx(b$e,{scope:t,forceMount:n,children:l.jsx(G0,{present:n||s.open,children:l.jsx(Gie,{asChild:!0,container:r,children:i})})})},"PopoverPortal"),Ox="PopoverContent",x$e=m.forwardRef(th(function(t,n){const i=O$e(Ox,t.__scopePopover),{forceMount:r=i.forceMount,...s}=t,a=K0(Ox,t.__scopePopover);return l.jsx(G0,{present:r||a.open,children:a.modal?l.jsx(w$e,{...s,ref:n}):l.jsx(S$e,{...s,ref:n})})},"PopoverContent")),v$e=Lf("PopoverContent.RemoveScroll"),w$e=m.forwardRef(th(function(t,n){const i=K0(Ox,t.__scopePopover),r=m.useRef(null),s=Sr(n,r),a=m.useRef(!1);return m.useEffect(()=>{const o=r.current;if(o)return _5e(o)},[]),l.jsx(ire,{as:v$e,allowPinchZoom:!0,children:l.jsx($re,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ti(t.onCloseAutoFocus,o=>{var c;o.preventDefault(),a.current||(c=i.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Ti(t.onPointerDownOutside,o=>{const c=o.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Ti(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),S$e=m.forwardRef(th(function(t,n){const i=K0(Ox,t.__scopePopover),r=m.useRef(!1),s=m.useRef(!1);return l.jsx($re,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,a),a.defaultPrevented||(r.current||(c=i.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var u,d;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;((d=i.triggerRef.current)==null?void 0:d.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})},"PopoverContentNonModal")),$re=m.forwardRef(th(function(t,n){const{__scopePopover:i,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=t,p=K0(Ox,i),g=Z$(i);return $$(),l.jsx(DLe,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:l.jsx(Bie,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>p.onOpenChange(!1),deferPointerDownOutside:!0,children:l.jsx(kre,{"data-state":K$(p.open),role:"dialog",id:p.contentId,...g,...h,ref:n,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function K$(e){return e?"open":"closed"}th(K$,"getState");var E$e=p$e,k$e=g$e,T$e=y$e,_$e=x$e,A$e=Object.defineProperty,Zs=(e,t)=>A$e(e,"name",{value:t,configurable:!0}),Qre="Radio",[N$e,Bre]=Xl(Qre),[C$e,nA]=N$e(Qre);function Ure(e){const{__scopeRadio:t,checked:n=!1,children:i,disabled:r,form:s,name:a,onCheck:o,required:c,value:u="on",internal_do_not_use_render:d}=e,[f,h]=m.useState(null),[p,g]=m.useState(null),b=m.useRef(!1),[y,O]=m.useReducer(w=>w+1,0),v=f?!!s||!!f.closest("form"):!0,x={checked:n,disabled:r,required:c,name:a,form:s,value:u,control:f,setControl:h,hasConsumerStoppedPropagationRef:b,userInteractionCount:y,onUserInteraction:O,isFormControl:v,bubbleInput:p,setBubbleInput:g,onCheck:Zs(()=>o==null?void 0:o(),"onCheck")};return l.jsx(C$e,{scope:t,...x,children:zre(d)?d(x):i})}Zs(Ure,"RadioProvider");var j$e="RadioTrigger",R$e=m.forwardRef(Zs(function({__scopeRadio:t,onClick:n,...i},r){const{checked:s,disabled:a,value:o,setControl:c,onCheck:u,hasConsumerStoppedPropagationRef:d,onUserInteraction:f,isFormControl:h,bubbleInput:p}=nA(j$e,t),g=Sr(r,c);return l.jsx(qr.button,{type:"button",role:"radio","aria-checked":s,"data-state":J$(s),"data-disabled":a?"":void 0,disabled:a,value:o,...i,ref:g,onClick:Ti(n,b=>{s||(f(),u()),p&&h&&(d.current=b.isPropagationStopped(),d.current||b.stopPropagation())})})},"RadioTrigger")),I$e="RadioIndicator",P$e=m.forwardRef(Zs(function(t,n){const{__scopeRadio:i,forceMount:r,...s}=t,a=nA(I$e,i);return l.jsx(G0,{present:r||a.checked,children:l.jsx(qr.span,{"data-state":J$(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n})})},"RadioIndicator")),M$e="RadioBubbleInput",L$e=m.forwardRef(Zs(function({__scopeRadio:t,onClick:n,...i},r){const{control:s,checked:a,required:o,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:p,hasConsumerStoppedPropagationRef:g,userInteractionCount:b}=nA(M$e,t),y=Sr(r,p),O=q_(s),v=m.useRef(!1),x=m.useRef(a),w=m.useRef(b);m.useEffect(()=>{const S=h;if(!S)return;const k=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(k,"checked").set,N=b!==w.current;w.current=b;const C=x.current!==a;x.current=a;const M=!(N&&g.current);if(C&&A){v.current=!N;const L=new Event("click",{bubbles:M});A.call(S,a),S.dispatchEvent(L),v.current=!1}},[h,a,g,b]);const E=m.useRef(a);return l.jsx(qr.input,{type:"radio","aria-hidden":!0,defaultChecked:E.current,required:o,disabled:c,name:u,value:d,form:f,...i,tabIndex:-1,ref:y,onClick:Ti(n,S=>{v.current&&S.stopPropagation()}),style:{...i.style,...O,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"RadioBubbleInput"));function zre(e){return typeof e=="function"}Zs(zre,"isFunction");function J$(e){return e?"checked":"unchecked"}Zs(J$,"getState");var D$e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],e3="RadioGroup",[$$e,EOt]=Xl(e3,[tA,Bre]),Fre=tA(),iA=Bre(),[Q$e,B$e]=$$e(e3),U$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,name:r,form:s,defaultValue:a,value:o,required:c=!1,disabled:u=!1,orientation:d,dir:f,loop:h=!0,onValueChange:p,...g}=t,b=Fre(i),y=V_(f),[O,v]=bd({prop:o,defaultProp:a??null,onChange:p,caller:e3}),[x,w]=m.useState(null),E=Sr(n,w),S=m.useRef(O);return m.useEffect(()=>{const k=s?x==null?void 0:x.ownerDocument.getElementById(s):x==null?void 0:x.closest("form");if(k instanceof HTMLFormElement){const T=Zs(()=>v(S.current),"reset");return k.addEventListener("reset",T),()=>k.removeEventListener("reset",T)}},[x,s,v]),l.jsx(Q$e,{scope:i,name:r,form:s,required:c,disabled:u,value:O,onValueChange:v,children:l.jsx(Pre,{asChild:!0,...b,orientation:d,dir:y,loop:h,children:l.jsx(qr.div,{role:"radiogroup","aria-required":c,"aria-orientation":d,"data-disabled":u?"":void 0,dir:y,...g,ref:E})})})},"RadioGroup")),z$e="RadioGroupItemProvider",F$e="RadioGroupItemTrigger";function Vre(e){const{__scopeRadioGroup:t,value:n,disabled:i,children:r,internal_do_not_use_render:s}=e,a=B$e(z$e,t),o=iA(t),c=a.disabled||i;return l.jsx(Ure,{...o,checked:a.value===n,disabled:c,required:a.required,name:a.name,form:a.form,value:n,onCheck:()=>a.onValueChange(n),internal_do_not_use_render:s,children:r})}Zs(Vre,"RadioGroupItemProvider");var V$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=Fre(i),a=iA(i),{checked:o,disabled:c}=nA(F$e,a.__scopeRadio),u=m.useRef(null),d=Sr(n,u),f=m.useRef(!1);return m.useEffect(()=>{const h=Zs(g=>{D$e.includes(g.key)&&(f.current=!0)},"handleKeyDown"),p=Zs(()=>f.current=!1,"handleKeyUp");return document.addEventListener("keydown",h),document.addEventListener("keyup",p),()=>{document.removeEventListener("keydown",h),document.removeEventListener("keyup",p)}},[]),l.jsx(Mre,{asChild:!0,...s,focusable:!c,active:o,children:l.jsx(R$e,{...a,...r,ref:d,onKeyDown:Ti(r.onKeyDown,h=>{h.key==="Enter"&&h.preventDefault()}),onFocus:Ti(r.onFocus,()=>{var h;f.current&&((h=u.current)==null||h.click())})})})},"RadioGroupItemTrigger")),X$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,value:r,disabled:s,...a}=t;return l.jsx(Vre,{__scopeRadioGroup:i,value:r,disabled:s,internal_do_not_use_render:({isFormControl:o})=>l.jsxs(l.Fragment,{children:[l.jsx(V$e,{...a,ref:n,__scopeRadioGroup:i}),o&&l.jsx(q$e,{__scopeRadioGroup:i})]})})},"RadioGroupItem")),q$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=iA(i);return l.jsx(L$e,{...s,...r,ref:n})},"RadioGroupItemBubbleInput")),H$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=iA(i);return l.jsx(P$e,{...s,...r,ref:n})},"RadioGroupIndicator")),Y$e=Object.defineProperty,G$e=(e,t)=>Y$e(e,"name",{value:t,configurable:!0}),W$e="Toggle",Z$e=m.forwardRef(G$e(function(t,n){const{pressed:i,defaultPressed:r,onPressedChange:s,...a}=t,[o,c]=bd({prop:i,onChange:s,defaultProp:r??!1,caller:W$e});return l.jsx(qr.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":t.disabled?"":void 0,...a,ref:n,onClick:Ti(t.onClick,()=>{t.disabled||c(!o)})})},"Toggle")),K$e=Object.defineProperty,Bf=(e,t)=>K$e(e,"name",{value:t,configurable:!0}),J0="ToggleGroup",[Xre,kOt]=Xl(J0,[tA]),qre=tA(),J$e=m.forwardRef(Bf(function(t,n){const{type:i,...r}=t;if(i==="single"){const s=r;return l.jsx(e3e,{role:"radiogroup",...s,ref:n})}if(i==="multiple"){const s=r;return l.jsx(t3e,{role:"toolbar",...s,ref:n})}throw new Error(`Missing prop \`type\` expected on \`${J0}\``)},"ToggleGroup")),[Hre,Yre]=Xre(J0),e3e=m.forwardRef(Bf(function(t,n){const{value:i,defaultValue:r,onValueChange:s=Bf(()=>{},"onValueChange"),...a}=t,[o,c]=bd({prop:i,defaultProp:r??"",onChange:s,caller:J0});return l.jsx(Hre,{scope:t.__scopeToggleGroup,type:"single",value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:c,onItemDeactivate:m.useCallback(()=>c(""),[c]),children:l.jsx(Gre,{...a,ref:n})})},"ToggleGroupImplSingle")),t3e=m.forwardRef(Bf(function(t,n){const{value:i,defaultValue:r,onValueChange:s=Bf(()=>{},"onValueChange"),...a}=t,[o,c]=bd({prop:i,defaultProp:r??[],onChange:s,caller:J0}),u=m.useCallback(f=>c((h=[])=>[...h,f]),[c]),d=m.useCallback(f=>c((h=[])=>h.filter(p=>p!==f)),[c]);return l.jsx(Hre,{scope:t.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:u,onItemDeactivate:d,children:l.jsx(Gre,{...a,ref:n})})},"ToggleGroupImplMultiple")),[n3e,i3e]=Xre(J0),Gre=m.forwardRef(Bf(function(t,n){const{__scopeToggleGroup:i,disabled:r=!1,rovingFocus:s=!0,orientation:a,dir:o,loop:c=!0,...u}=t,d=qre(i),f=V_(o),h={dir:f,...u};return l.jsx(n3e,{scope:i,rovingFocus:s,disabled:r,children:s?l.jsx(Pre,{asChild:!0,...d,orientation:a,dir:f,loop:c,children:l.jsx(qr.div,{...h,ref:n})}):l.jsx(qr.div,{...h,ref:n})})},"ToggleGroupImpl")),ZP="ToggleGroupItem",r3e=m.forwardRef(Bf(function(t,n){const i=Yre(ZP,t.__scopeToggleGroup),r=i3e(ZP,t.__scopeToggleGroup),s=qre(t.__scopeToggleGroup),a=i.value.includes(t.value),o=r.disabled||t.disabled,c={...t,pressed:a,disabled:o},u=m.useRef(null);return r.rovingFocus?l.jsx(Mre,{asChild:!0,...s,focusable:!o,active:a,ref:u,children:l.jsx(E7,{...c,ref:n})}):l.jsx(E7,{...c,ref:n})},"ToggleGroupItem")),E7=m.forwardRef(Bf(function(t,n){const{__scopeToggleGroup:i,value:r,...s}=t,a=Yre(ZP,i),o={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},c=a.type==="single"?o:void 0;return l.jsx(Z$e,{...c,...s,ref:n,onPressedChange:u=>{u?a.onItemActivate(r):a.onItemDeactivate(r)}})},"ToggleGroupItemImpl")),s3e=Object.defineProperty,bs=(e,t)=>s3e(e,"name",{value:t,configurable:!0}),[t3,TOt]=Xl("Tooltip",[K_]),n3=K_(),a3e="TooltipProvider",o3e=700,KP="tooltip.open",[l3e,i3]=t3(a3e),c3e=bs(e=>{const{__scopeTooltip:t,delayDuration:n=o3e,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=e,a=m.useRef(!0),o=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(l3e,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{i<=0||(window.clearTimeout(c.current),a.current=!1)},[i]),onClose:m.useCallback(()=>{i<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i))},[i]),isPointerInTransitRef:o,onPointerInTransitChange:m.useCallback(u=>{o.current=u},[]),disableHoverableContent:r,children:s})},"TooltipProvider"),JP="Tooltip",[u3e,R1]=t3(JP),d3e=bs(e=>{const{__scopeTooltip:t,children:n,open:i,defaultOpen:r,onOpenChange:s,disableHoverableContent:a,delayDuration:o}=e,c=i3(JP,e.__scopeTooltip),u=n3(t),[d,f]=m.useState(null),[h,p]=m.useState(void 0),g=F_(),b=m.useRef(0),y=a??c.disableHoverableContent,O=o??c.delayDuration,v=m.useRef(!1),[x,w]=bd({prop:i,defaultProp:r??!1,onChange:bs(N=>{N?(c.onOpen(),document.dispatchEvent(new CustomEvent(KP))):c.onClose(),s==null||s(N)},"onChange"),caller:JP}),E=m.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),S=m.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,w(!0)},[w]),k=m.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w(!1)},[w]),T=m.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,w(!0),b.current=0},O)},[O,w]);m.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]);const A=h??g;return l.jsx(Sre,{...u,children:l.jsx(u3e,{scope:t,contentId:A,setContentId:p,open:x,stateAttribute:E,trigger:d,onTriggerChange:f,onTriggerEnter:m.useCallback(()=>{c.isOpenDelayedRef.current?T():S()},[c.isOpenDelayedRef,T,S]),onTriggerLeave:m.useCallback(()=>{y?k():(window.clearTimeout(b.current),b.current=0)},[k,y]),onOpen:S,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),k7="TooltipTrigger",f3e=m.forwardRef(bs(function(t,n){const{__scopeTooltip:i,...r}=t,s=R1(k7,i),a=i3(k7,i),o=n3(i),c=m.useRef(null),u=Sr(n,c,s.onTriggerChange),d=m.useRef(!1),f=m.useRef(!1),h=m.useCallback(()=>d.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),l.jsx(Ere,{asChild:!0,...o,children:l.jsx(qr.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:u,onPointerMove:Ti(t.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),f.current=!0)}),onPointerLeave:Ti(t.onPointerLeave,()=>{s.onTriggerLeave(),f.current=!1}),onPointerDown:Ti(t.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ti(t.onFocus,()=>{d.current||s.onOpen()}),onBlur:Ti(t.onBlur,s.onClose),onClick:Ti(t.onClick,s.onClose)})})},"TooltipTrigger")),Wre="TooltipPortal",[h3e,p3e]=t3(Wre,{forceMount:void 0}),m3e=bs(e=>{const{__scopeTooltip:t,forceMount:n,children:i,container:r}=e,s=R1(Wre,t);return l.jsx(h3e,{scope:t,forceMount:n,children:l.jsx(G0,{present:n||s.open,children:l.jsx(Gie,{asChild:!0,container:r,children:i})})})},"TooltipPortal"),yx="TooltipContent",g3e=m.forwardRef(bs(function(t,n){const i=p3e(yx,t.__scopeTooltip),{forceMount:r=i.forceMount,side:s="top",...a}=t,o=R1(yx,t.__scopeTooltip);return l.jsx(G0,{present:r||o.open,children:o.disableHoverableContent?l.jsx(Zre,{side:s,...a,ref:n}):l.jsx(b3e,{side:s,...a,ref:n})})},"TooltipContent")),b3e=m.forwardRef(bs(function(t,n){const i=R1(yx,t.__scopeTooltip),r=i3(yx,t.__scopeTooltip),s=m.useRef(null),a=Sr(n,s),[o,c]=m.useState(null),{trigger:u,onClose:d}=i,f=s.current,{onPointerInTransitChange:h}=r,p=m.useCallback(()=>{c(null),h(!1)},[h]),g=m.useCallback((b,y)=>{const O=b.currentTarget,v={x:b.clientX,y:b.clientY},x=Kre(v,O.getBoundingClientRect()),w=Jre(v,x),E=ese(y.getBoundingClientRect()),S=nse([...w,...E]);c(S),h(!0)},[h]);return m.useEffect(()=>()=>p(),[p]),m.useEffect(()=>{if(u&&f){const b=bs(O=>g(O,f),"handleTriggerLeave"),y=bs(O=>g(O,u),"handleContentLeave");return u.addEventListener("pointerleave",b),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",y)}}},[u,f,g,p]),m.useEffect(()=>{if(o){const b=bs(y=>{const O=y.target,v={x:y.clientX,y:y.clientY},x=(u==null?void 0:u.contains(O))||(f==null?void 0:f.contains(O)),w=!tse(v,o);x?p():w&&(p(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,f,o,d,p]),l.jsx(Zre,{...t,ref:a})},"TooltipContentHoverable")),O3e=bie("TooltipContent"),Zre=m.forwardRef(bs(function(t,n){const{__scopeTooltip:i,children:r,"aria-label":s,id:a,onEscapeKeyDown:o,onPointerDownOutside:c,...u}=t,d=R1(yx,i),f=n3(i),{onClose:h}=d;m.useEffect(()=>(document.addEventListener(KP,h),()=>document.removeEventListener(KP,h)),[h]),m.useEffect(()=>{if(d.trigger){const g=bs(b=>{b.target instanceof Node&&b.target.contains(d.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]);const{setContentId:p}=d;return tl(()=>(p(a),()=>{p(void 0)}),[a,p]),l.jsx(Bie,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:l.jsxs(kre,{"data-state":d.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:d.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(O3e,{children:r}),s?l.jsx(cLe,{id:d.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function Kre(e,t){const n=Math.abs(t.top-e.y),i=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}bs(Kre,"getExitSideFromRect");function Jre(e,t,n=5){const i=[];switch(t){case"top":i.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":i.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":i.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":i.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return i}bs(Jre,"getPaddedExitPoints");function ese(e){const{top:t,right:n,bottom:i,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:i},{x:r,y:i}]}bs(ese,"getPointsFromRect");function tse(e,t){const{x:n,y:i}=e;let r=!1;for(let s=0,a=t.length-1;si!=h>i&&n<(f-u)*(i-d)/(h-d)+u&&(r=!r)}return r}bs(tse,"isPointInPolygon");function nse(e){const t=e.slice();return t.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),ise(t)}bs(nse,"getHull");function ise(e){if(e.length<=1)return e.slice();const t=[];for(let i=0;i=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}bs(ise,"getHullPresorted");var y3e=c3e,x3e=d3e,rse=f3e,v3e=m3e,w3e=g3e;function eM(e){const t=m.useRef(e);return t.current=e,t}let d0=[],Sw=!1;const T7=e=>{var t,n;if(e.key==="Escape"){const[i]=d0;i&&(e.preventDefault(),(n=(t=i.callback).current)==null||n.call(t))}},sse=()=>{d0.length>0&&!Sw?(document.body.addEventListener("keydown",T7),Sw=!0):d0.length===0&&Sw&&(document.body.removeEventListener("keydown",T7),Sw=!1)},S3e=e=>{d0.unshift(e),sse()},E3e=({id:e})=>{d0=d0.filter(t=>t.id!==e),sse()},ase=(e,t)=>{const n=m.useId(),i=eM(t);m.useEffect(()=>{if(!e)return;const r={id:n,callback:i};return S3e(r),()=>E3e(r)},[n,e,i])},k3e="_Tooltip_16g2y_1",T3e="_TriggerDecorator_16g2y_73",ose={Tooltip:k3e,TriggerDecorator:T3e},sp=e=>{const{ref:t,children:n,content:i,forceOpen:r=i===null?!1:void 0,maxWidth:s=300,openDelay:a=150,interactive:o=!1,compact:c=!1,preventUnintentionalClickToClose:u,align:d,alignOffset:f=0,side:h,sideOffset:p=5,gutterSize:g="md",contentClassName:b,onPointerDown:y,onClick:O,...v}=e,[x,w]=m.useState(!1),[E,S]=m.useState(!1);R$(()=>S(!1),E?400:null);const k=r??x,T=N=>{typeof r!="boolean"&&(w(N),u&&S(N))},A=N=>{u&&E&&(N.preventDefault(),N.stopPropagation())};return l.jsxs(lse,{open:k,delayDuration:a,onOpenChange:T,disableHoverableContent:!o,children:[l.jsx(rse,{asChild:!0,children:l.jsx(mie,{...v,ref:t,onPointerDown:N=>{A(N),y==null||y(N)},onClick:N=>{A(N),O==null||O(N)},children:n})}),l.jsx(cse,{maxWidth:s,compact:c,align:d,alignOffset:f,side:h,sideOffset:p,gutterSize:g,className:b,children:i})]})},lse=({children:e,open:t,onOpenChange:n,...i})=>(ase(t,()=>{n(!1)}),l.jsx(y3e,{children:l.jsx(x3e,{open:t,onOpenChange:n,...i,children:e})})),cse=({children:e,maxWidth:t=300,compact:n=!1,clickable:i=void 0,alignOffset:r=0,sideOffset:s=5,gutterSize:a="md",className:o,style:c,...u})=>l.jsx(v3e,{children:l.jsx(w3e,{...u,className:Ps(ose.Tooltip,o),"data-compact":n,"data-clickable":i,"data-gutter-size":a,alignOffset:r,sideOffset:s,collisionPadding:15,hideWhenDetached:!0,style:{...c,maxWidth:t},onEscapeKeyDown:ZS,children:e})}),_3e=({children:e,asChild:t=!0,...n})=>l.jsx(rse,{asChild:t,...n,children:e}),A3e=e=>{const{children:t,className:n,focusable:i=!0,ref:r,...s}=e,a=typeof t=="string";return l.jsx(mie,{ref:r,...s,className:Ps(ose.TriggerDecorator,n),tabIndex:i?0:void 0,children:a?l.jsx("span",{children:t}):t})};sp.Root=lse;sp.Content=cse;sp.Trigger=_3e;sp.TriggerDecorator=A3e;const use="KNOWLEDGE_PROVIDER_ASSOCIATION_INVALID";class rA extends Error{constructor(n,i,r={}){super(n);Or(this,"status");Or(this,"errorCode");Or(this,"requestId");Or(this,"diagnostics");Or(this,"detail");Or(this,"payload");Or(this,"rawBody");this.name="KnowledgeRequestError",this.status=i;const s=typeof r=="string"?{errorCode:r}:r;this.errorCode=s.errorCode||"",this.requestId=s.requestId||"",this.diagnostics=s.diagnostics,this.detail=s.detail,this.payload=s.payload,this.rawBody=s.rawBody||""}}class dse extends Error{constructor(n){super(n.map(({region:i,error:r})=>`${i}: ${r.message||"读取知识库失败"}`).join(` -`));Or(this,"failures");this.name="KnowledgeRegionAggregateError",this.failures=n}}const N3e=new Set(["ak","apikey","sk","accesskey","accesskeyid","authorization","authkey","clientsecret","cookie","credential","credentials","password","passwd","privatekey","secret","secretaccesskey","secretkey","securitytoken","sessiontoken","setcookie","token"]),C3e=6,_7=50,fse=4e3;function j3e(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function R3e(e){const t=j3e(e);return N3e.has(t)||t.endsWith("password")||t.endsWith("secret")||t.endsWith("token")||t.endsWith("credential")}function I3e(e){return/<\s*(?:!doctype|html|head|body|script|style)\b/i.test(e)}function jO(e){return I3e(e)?"[HTML 内容已隐藏]":e.replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [已脱敏]").replace(/\b(?:set-)?cookie\s*:\s*[^\r\n]*/gi,"cookie: [已脱敏]").replace(/\bAKLT[A-Za-z0-9_-]{6,}\b/g,"[已脱敏]").replace(/((?:access[_-]?key(?:[_-]?id)?|secret(?:[_-]?(?:access)?[_-]?key)?|session[_-]?token|security[_-]?token|client[_-]?secret|api[_-]?key|authorization|cookie|[a-z0-9_-]*(?:password|secret|token)|credential|ak|sk)\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;&]+)/gi,"$1[已脱敏]").replace(/([?&](?:access[_-]?key|api[_-]?key|client[_-]?secret|security[_-]?token|session[_-]?token|secret|token|password|authorization|cookie|credential)=)[^&#\s]+/gi,"$1[已脱敏]")}function tM(e,t=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return jO(e).slice(0,fse);if(typeof e!="object")return;if(t>=C3e)return"[内容过深,已截断]";if(n.has(e))return"[循环引用]";if(n.add(e),Array.isArray(e))return e.slice(0,_7).map(r=>tM(r,t+1,n));const i={};return Object.entries(e).slice(0,_7).forEach(([r,s])=>{i[r]=R3e(r)?"[已脱敏]":tM(s,t+1,n)}),i}function A7(e){if(e===void 0)return"";const t=tM(e);if(typeof t=="string")return t;if(t===void 0)return"";try{return JSON.stringify(t).slice(0,fse)}catch{return"[诊断信息无法显示]"}}function qs(e,t){if(e instanceof dse)return e.failures.map(({region:a,error:o})=>`${a} +`)},v5e=0,om=[];function w5e(e){var t=m.useRef([]),n=m.useRef([0,0]),i=m.useRef(),r=m.useState(v5e++)[0],s=m.useState(ere)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var b=FLe([e.lockRef.current],(e.shards||[]).map(h7),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var o=m.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!a.current.allowPinchZoom;var O=yw(b),v=n.current,x="deltaX"in b?b.deltaX:v[0]-O[0],w="deltaY"in b?b.deltaY:v[1]-O[1],E,S=b.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in b&&k==="h"&&S.type==="range")return!1;var T=window.getSelection(),A=T&&T.anchorNode,N=A?A===S||A.contains(S):!1;if(N)return!1;var C=d7(k,S);if(!C)return!0;if(C?E=k:(E=k==="v"?"h":"v",C=d7(k,S)),!C)return!1;if(!i.current&&"changedTouches"in b&&(x||w)&&(i.current=E),!E)return!0;var M=i.current||E;return O5e(M,y,b,M==="h"?x:w)},[]),c=m.useCallback(function(b){var y=b;if(!(!om.length||om[om.length-1]!==s)){var O="deltaY"in y?f7(y):yw(y),v=t.current.filter(function(E){return E.name===y.type&&(E.target===y.target||y.target===E.shadowParent)&&y5e(E.delta,O)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(a.current.shards||[]).map(h7).filter(Boolean).filter(function(E){return E.contains(y.target)}),w=x.length>0?o(y,x[0]):!a.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),u=m.useCallback(function(b,y,O,v){var x={name:b,delta:y,target:O,should:v,shadowParent:S5e(O)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),d=m.useCallback(function(b){n.current=yw(b),i.current=void 0},[]),f=m.useCallback(function(b){u(b.type,f7(b),b.target,o(b,e.lockRef.current))},[]),h=m.useCallback(function(b){u(b.type,yw(b),b.target,o(b,e.lockRef.current))},[]);m.useEffect(function(){return om.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,am),document.addEventListener("touchmove",c,am),document.addEventListener("touchstart",d,am),function(){om=om.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,am),document.removeEventListener("touchmove",c,am),document.removeEventListener("touchstart",d,am)}},[]);var p=e.removeScrollBar,g=e.inert;return m.createElement(m.Fragment,null,g?m.createElement(s,{styles:x5e(r)}):null,p?m.createElement(d5e,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function S5e(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const E5e=KLe(Jie,w5e);var rre=m.forwardRef(function(e,t){return m.createElement(X_,vc({},e,{ref:t,sideCar:E5e}))});rre.classNames=X_.classNames;var k5e=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lm=new WeakMap,xw=new WeakMap,vw={},mC=0,sre=function(e){return e&&(e.host||sre(e.parentNode))},T5e=function(e,t){return t.map(function(n){if(e.contains(n))return n;var i=sre(n);return i&&e.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},_5e=function(e,t,n,i){var r=T5e(t,Array.isArray(e)?e:[e]);vw[n]||(vw[n]=new WeakMap);var s=vw[n],a=[],o=new Set,c=new Set(r),u=function(f){!f||o.has(f)||(o.add(f),u(f.parentNode))};r.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(o.has(h))d(h);else try{var p=h.getAttribute(i),g=p!==null&&p!=="false",b=(lm.get(h)||0)+1,y=(s.get(h)||0)+1;lm.set(h,b),s.set(h,y),a.push(h),b===1&&g&&xw.set(h,!0),y===1&&h.setAttribute(n,"true"),g||h.setAttribute(i,"true")}catch(O){console.error("aria-hidden: cannot operate on ",h,O)}})};return d(t),o.clear(),mC++,function(){a.forEach(function(f){var h=lm.get(f)-1,p=s.get(f)-1;lm.set(f,h),s.set(f,p),h||(xw.has(f)||f.removeAttribute(i),xw.delete(f)),p||f.removeAttribute(n)}),mC--,mC||(lm=new WeakMap,lm=new WeakMap,xw=new WeakMap,vw={})}},A5e=function(e,t,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=k5e(e);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),_5e(i,r,n,"aria-hidden")):function(){return null}},N5e=Object.defineProperty,C5e=(e,t)=>N5e(e,"name",{value:t,configurable:!0});function q_(e){const[t,n]=m.useState(void 0);return tl(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let a,o;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,o=u.blockSize}else a=e.offsetWidth,o=e.offsetHeight;n({width:a,height:o})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else n(void 0)},[e]),t}C5e(q_,"useSize");var j5e=Object.defineProperty,rd=(e,t)=>j5e(e,"name",{value:t,configurable:!0}),Q$="Checkbox",[R5e,wOt]=Xl(Q$),[I5e,B$]=R5e(Q$);function are(e){const{__scopeCheckbox:t,checked:n,children:i,defaultChecked:r,disabled:s,form:a,name:o,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,p]=bd({prop:n,defaultProp:r??!1,onChange:c,caller:Q$}),[g,b]=m.useState(null),[y,O]=m.useState(null),v=m.useRef(!1),[x,w]=m.useReducer(k=>k+1,0),E=g?!!a||!!g.closest("form"):!0,S={checked:h,disabled:s,setChecked:p,control:g,setControl:b,name:o,form:a,value:d,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:w,required:u,defaultChecked:Fu(r)?!1:r,isFormControl:E,bubbleInput:y,setBubbleInput:O};return l.jsx(I5e,{scope:t,...S,children:ore(f)?f(S):i})}rd(are,"CheckboxProvider");var P5e="CheckboxTrigger",M5e=m.forwardRef(rd(function({__scopeCheckbox:t,onKeyDown:n,onClick:i,...r},s){const{control:a,value:o,disabled:c,checked:u,required:d,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:p,onUserInteraction:g,isFormControl:b,bubbleInput:y}=B$(P5e,t),O=Sr(s,f),v=m.useRef(u);return m.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const w=rd(()=>h(v.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[a,h]),l.jsx(qr.button,{type:"button",role:"checkbox","aria-checked":Fu(u)?"mixed":u,"aria-required":d,"data-state":U$(u),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:O,onKeyDown:Ti(n,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Ti(i,x=>{g(),h(w=>Fu(w)?!0:!w),y&&b&&(p.current=x.isPropagationStopped(),p.current||x.stopPropagation())})})},"CheckboxTrigger")),L5e=m.forwardRef(rd(function(t,n){const{__scopeCheckbox:i,name:r,checked:s,defaultChecked:a,required:o,disabled:c,value:u,onCheckedChange:d,form:f,...h}=t;return l.jsx(are,{__scopeCheckbox:i,checked:s,defaultChecked:a,disabled:c,required:o,onCheckedChange:d,name:r,form:f,value:u,internal_do_not_use_render:({isFormControl:p})=>l.jsxs(l.Fragment,{children:[l.jsx(M5e,{...h,ref:n,__scopeCheckbox:i}),p&&l.jsx(B5e,{__scopeCheckbox:i})]})})},"Checkbox")),D5e="CheckboxIndicator",$5e=m.forwardRef(rd(function(t,n){const{__scopeCheckbox:i,forceMount:r,...s}=t,a=B$(D5e,i);return l.jsx(G0,{present:r||Fu(a.checked)||a.checked===!0,children:l.jsx(qr.span,{"data-state":U$(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),Q5e="CheckboxBubbleInput",B5e=m.forwardRef(rd(function({__scopeCheckbox:t,onClick:n,...i},r){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:c,defaultChecked:u,required:d,disabled:f,name:h,value:p,form:g,bubbleInput:b,setBubbleInput:y}=B$(Q5e,t),O=Sr(r,y),v=q_(s),x=m.useRef(!1),w=m.useRef(c),E=m.useRef(o);m.useEffect(()=>{const k=b;if(!k)return;const T=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(T,"checked").set,C=o!==E.current;E.current=o;const M=w.current!==c;w.current=c;const L=!(C&&a.current);if(M&&N){x.current=!C;const P=new Event("click",{bubbles:L});k.indeterminate=Fu(c),N.call(k,Fu(c)?!1:c),k.dispatchEvent(P),x.current=!1}},[b,c,a,o]);const S=m.useRef(Fu(c)?!1:c);return l.jsx(qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??S.current,required:d,disabled:f,name:h,value:p,form:g,...i,tabIndex:-1,ref:O,onClick:Ti(n,k=>{x.current&&k.stopPropagation()}),style:{...i.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function ore(e){return typeof e=="function"}rd(ore,"isFunction");function Fu(e){return e==="indeterminate"}rd(Fu,"isIndeterminate");function U$(e){return Fu(e)?"indeterminate":e?"checked":"unchecked"}rd(U$,"getState");const U5e=["top","right","bottom","left"],$f=Math.min,Vu=Math.max,Lk=Math.round,ww=Math.floor,Xu=e=>({x:e,y:e}),z5e={left:"right",right:"left",bottom:"top",top:"bottom"};function lre(e,t,n){return Vu(e,$f(t,n))}function sd(e,t){return typeof e=="function"?e(t):e}function Qf(e){return e.split("-")[0]}function W0(e){return e.split("-")[1]}function z$(e){return e==="x"?"y":"x"}function F$(e){return e==="y"?"height":"width"}function Nc(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function V$(e){return z$(Nc(e))}function F5e(e,t,n){n===void 0&&(n=!1);const i=W0(e),r=V$(e),s=F$(r);let a=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Dk(a)),[a,Dk(a)]}function V5e(e){const t=Dk(e);return[YP(e),t,YP(t)]}function YP(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const p7=["left","right"],m7=["right","left"],X5e=["top","bottom"],q5e=["bottom","top"];function H5e(e,t,n){switch(e){case"top":case"bottom":return n?t?m7:p7:t?p7:m7;case"left":case"right":return t?X5e:q5e;default:return[]}}function Y5e(e,t,n,i){const r=W0(e);let s=H5e(Qf(e),n==="start",i);return r&&(s=s.map(a=>a+"-"+r),t&&(s=s.concat(s.map(YP)))),s}function Dk(e){const t=Qf(e);return z5e[t]+e.slice(t.length)}function G5e(e){var t,n,i,r;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(i=e.bottom)!=null?i:0,left:(r=e.left)!=null?r:0}}function cre(e){return typeof e!="number"?G5e(e):{top:e,right:e,bottom:e,left:e}}function $k(e){const{x:t,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:t,right:t+i,bottom:n+r,x:t,y:n}}function g7(e,t,n){let{reference:i,floating:r}=e;const s=Nc(t),a=V$(t),o=F$(a),c=Qf(t),u=s==="y",d=i.x+i.width/2-r.width/2,f=i.y+i.height/2-r.height/2,h=i[o]/2-r[o]/2;let p;switch(c){case"top":p={x:d,y:i.y-r.height};break;case"bottom":p={x:d,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:f};break;case"left":p={x:i.x-r.width,y:f};break;default:p={x:i.x,y:i.y}}const g=W0(t);return g&&(p[a]+=h*(g==="end"?1:-1)*(n&&u?-1:1)),p}async function W5e(e,t){var n;t===void 0&&(t={});const{x:i,y:r,platform:s,rects:a,elements:o,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=sd(t,e),g=cre(p),y=o[h?f==="floating"?"reference":"floating":f],O=$k(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:i,y:r,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),w=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},E=$k(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:x,strategy:c}):v);return{top:(O.top-E.top+g.top)/w.y,bottom:(E.bottom-O.bottom+g.bottom)/w.y,left:(O.left-E.left+g.left)/w.x,right:(E.right-O.right+g.right)/w.x}}const Z5e=50,K5e=async(e,t,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:a}=n,o=a.detectOverflow?a:{...a,detectOverflow:W5e},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:f}=g7(u,i,c),h=i,p=0;const g={};for(let b=0;b({name:"arrow",options:e,async fn(t){const{x:n,y:i,placement:r,rects:s,platform:a,elements:o,middlewareData:c}=t,{element:u,padding:d=0}=sd(e,t)||{};if(u==null)return{};const f=cre(d),h={x:n,y:i},p=V$(r),g=F$(p),b=await a.getDimensions(u),y=p==="y",O=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[p]-h[p]-s.floating[g],E=h[p]-s.reference[p],S=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let k=S?S[x]:0;(!k||!await(a.isElement==null?void 0:a.isElement(S)))&&(k=o.floating[x]||s.floating[g]);const T=w/2-E/2,A=k/2-b[g]/2-1,N=$f(f[O],A),C=$f(f[v],A),M=k-b[g]-C,L=k/2-b[g]/2+T,P=lre(N,L,M),Q=!c.arrow&&W0(r)!=null&&L!==P&&s.reference[g]/2-(LP<=0)){var C,M;const P=(((C=s.flip)==null?void 0:C.index)||0)+1,Q=k[P];if(Q&&(!(f==="alignment"?v!==Nc(Q):!1)||N.every(U=>Nc(U.placement)===v?U.overflows[0]>0:!0)))return{data:{index:P,overflows:N},reset:{placement:Q}};let j=(M=N.filter($=>$.overflows[0]<=0).sort(($,U)=>$.overflows[1]-U.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(p){case"bestFit":{var L;const $=(L=N.filter(U=>{if(S){const B=Nc(U.placement);return B===v||B==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(B=>B>0).reduce((B,I)=>B+I,0)]).sort((U,B)=>U[1]-B[1])[0])==null?void 0:L[0];$&&(j=$);break}case"initialPlacement":j=o;break}if(r!==j)return{reset:{placement:j}}}return{}}}};function b7(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function O7(e){return U5e.some(t=>e[t]>=0)}const tDe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:i}=t,{strategy:r="referenceHidden",...s}=sd(e,t);switch(r){case"referenceHidden":{const a=await i.detectOverflow(t,{...s,elementContext:"reference"}),o=b7(a,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:O7(o)}}}case"escaped":{const a=await i.detectOverflow(t,{...s,altBoundary:!0}),o=b7(a,n.floating);return{data:{escapedOffsets:o,escaped:O7(o)}}}default:return{}}}}},ure=new Set(["left","top"]);async function nDe(e,t){const{placement:n,platform:i,elements:r}=e,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),a=Qf(n),o=W0(n),c=Nc(n)==="y",u=ure.has(a)?-1:1,d=s&&c?-1:1,f=sd(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return o&&typeof g=="number"&&(p=o==="end"?g*-1:g),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const iDe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:r,y:s,placement:a,middlewareData:o}=t,c=await nDe(t,e);return a===((n=o.offset)==null?void 0:n.placement)&&(i=o.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:a}}}}},rDe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:r,platform:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:c={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...u}=sd(e,t),d={x:n,y:i},f=await s.detectOverflow(t,u),h=Nc(r),p=z$(h);let g=d[p],b=d[h];const y=(v,x)=>lre(x+f[v==="y"?"top":"left"],x,x-f[v==="y"?"bottom":"right"]);a&&(g=y(p,g)),o&&(b=y(h,b));const O=c.fn({...t,[p]:g,[h]:b});return{...O,data:{x:O.x-n,y:O.y-i,enabled:{[p]:a,[h]:o}}}}}},sDe=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,i;const{x:r,y:s,placement:a,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:f=!0}=sd(e,t),h={x:r,y:s},p=Nc(a),g=z$(p);let b=h[g],y=h[p];const O=sd(u,t),v=typeof O=="number"?{mainAxis:O,crossAxis:0}:{mainAxis:(n=O.mainAxis)!=null?n:0,crossAxis:(i=O.crossAxis)!=null?i:0};if(d){const E=g==="y"?"height":"width",S=o.reference[g]-o.floating[E]+v.mainAxis,k=o.reference[g]+o.reference[E]-v.mainAxis;bk&&(b=k)}if(f){var x,w;const E=g==="y"?"width":"height",S=ure.has(Qf(a)),k=o.reference[p]-o.floating[E]+(S&&((x=c.offset)==null?void 0:x[p])||0)+(S?0:v.crossAxis),T=o.reference[p]+o.reference[E]+(S?0:((w=c.offset)==null?void 0:w[p])||0)-(S?v.crossAxis:0);yT&&(y=T)}return{[g]:b,[p]:y}}}},aDe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:i,platform:r,elements:s}=t,{apply:a=()=>{},...o}=sd(e,t),c=await r.detectOverflow(t,o),u=Qf(n),d=W0(n),f=Nc(n)==="y",{width:h,height:p}=i.floating;let g,b;u==="top"||u==="bottom"?(g=u,b=d===(await(r.isRTL==null?void 0:r.isRTL(s.floating))?"start":"end")?"left":"right"):(b=u,g=d==="end"?"top":"bottom");const y=p-c.top-c.bottom,O=h-c.left-c.right,v=$f(p-c[g],y),x=$f(h-c[b],O),w=t.middlewareData.shift,E=!w;let S=v,k=x;w!=null&&w.enabled.x&&(k=O),w!=null&&w.enabled.y&&(S=y),E&&!d&&(f?k=h-2*Vu(c.left,c.right):S=p-2*Vu(c.top,c.bottom)),await a({...t,availableWidth:k,availableHeight:S});const T=await r.getDimensions(s.floating);return h!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function H_(){return typeof window<"u"}function Z0(e){return dre(e)?(e.nodeName||"").toLowerCase():"#document"}function za(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Od(e){var t;return(t=(dre(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dre(e){return H_()?e instanceof Node||e instanceof za(e).Node:!1}function Uc(e){return H_()?e instanceof Element||e instanceof za(e).Element:!1}function eh(e){return H_()?e instanceof HTMLElement||e instanceof za(e).HTMLElement:!1}function y7(e){return!H_()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof za(e).ShadowRoot}function Y_(e){const{overflow:t,overflowX:n,overflowY:i,display:r}=zc(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&r!=="inline"&&r!=="contents"}function oDe(e){return/^(table|td|th)$/.test(Z0(e))}function G_(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const lDe=/transform|translate|scale|rotate|perspective|filter/,cDe=/paint|layout|strict|content/,fh=e=>!!e&&e!=="none";let gC;function X$(e){const t=Uc(e)?zc(e):e;return fh(t.transform)||fh(t.translate)||fh(t.scale)||fh(t.rotate)||fh(t.perspective)||!q$()&&(fh(t.backdropFilter)||fh(t.filter))||lDe.test(t.willChange||"")||cDe.test(t.contain||"")}function uDe(e){let t=vp(e);for(;eh(t)&&!gx(t);){if(X$(t))return t;if(G_(t))return null;t=vp(t)}return null}function q$(){return gC==null&&(gC=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),gC}function gx(e){return/^(html|body|#document)$/.test(Z0(e))}function zc(e){return za(e).getComputedStyle(e)}function W_(e){return Uc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vp(e){if(Z0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||y7(e)&&e.host||Od(e);return y7(t)?t.host:t}function fre(e){const t=vp(e);return gx(t)?(e.ownerDocument||e).body:eh(t)&&Y_(t)?t:fre(t)}function bx(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=fre(e),s=r===((i=e.ownerDocument)==null?void 0:i.body),a=za(r);if(s){const o=GP(a);return t.concat(a,a.visualViewport||[],Y_(r)?r:[],o&&n?bx(o):[])}else return t.concat(r,bx(r,[],n))}function GP(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hre(e){const t=zc(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const r=eh(e),s=r?e.offsetWidth:n,a=r?e.offsetHeight:i,o=Lk(n)!==s||Lk(i)!==a;return o&&(n=s,i=a),{width:n,height:i,$:o}}function H$(e){return Uc(e)?e:e.contextElement}function Sg(e){const t=H$(e);if(!eh(t))return Xu(1);const n=t.getBoundingClientRect(),{width:i,height:r,$:s}=hre(t);let a=(s?Lk(n.width):n.width)/i,o=(s?Lk(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const dDe=Xu(0);function pre(e){const t=za(e);return!q$()||!t.visualViewport?dDe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function fDe(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===za(e)}function wp(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=H$(e);let a=Xu(1);t&&(i?Uc(i)&&(a=Sg(i)):a=Sg(e));const o=fDe(s,n,i)?pre(s):Xu(0);let c=(r.left+o.x)/a.x,u=(r.top+o.y)/a.y,d=r.width/a.x,f=r.height/a.y;if(s&&i){const h=za(s),p=Uc(i)?za(i):i;let g=h,b=GP(g);for(;b&&p!==g;){const y=Sg(b),O=b.getBoundingClientRect(),v=zc(b),x=O.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,w=O.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=x,u+=w,g=za(b),b=GP(g)}}return $k({width:d,height:f,x:c,y:u})}function Z_(e,t){const n=W_(e).scrollLeft;return t?t.left+n:wp(Od(e)).left+n}function mre(e,t){const n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Z_(e,n),r=n.top+t.scrollTop;return{x:i,y:r}}function hDe(e){let{elements:t,rect:n,offsetParent:i,strategy:r}=e;const s=r==="fixed",a=Od(i),o=t?G_(t.floating):!1;if(i===a||o&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Xu(1);const d=Xu(0),f=eh(i);if((f||!s)&&((Z0(i)!=="body"||Y_(a))&&(c=W_(i)),f)){const p=wp(i);u=Sg(i),d.x=p.x+i.clientLeft,d.y=p.y+i.clientTop}const h=a&&!f&&!s?mre(a,c):Xu(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function pDe(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function mDe(e){const t=W_(e),n=e.ownerDocument.body,i=Vu(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=Vu(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Z_(e);const a=-t.scrollTop;return zc(n).direction==="rtl"&&(s+=Vu(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:a}}const gDe=25;function bDe(e,t,n){n===void 0&&(n="viewport");const i=n==="layoutViewport",r=za(e),s=Od(e),a=r.visualViewport;let o=s.clientWidth,c=s.clientHeight,u=0,d=0;if(a){const h=!q$()||t==="fixed";i?h||(u=-a.offsetLeft,d=-a.offsetTop):(o=a.width,c=a.height,h&&(u=a.offsetLeft,d=a.offsetTop))}if(Z_(s)<=0){const h=s.ownerDocument,p=h.body,g=getComputedStyle(p),b=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(s.clientWidth-p.clientWidth-b),O=getComputedStyle(s).scrollbarGutter==="stable both-edges"?y/2:y;O<=gDe&&(o-=O)}return{width:o,height:c,x:u,y:d}}function ODe(e,t){const n=wp(e,!0,t==="fixed"),i=n.top+e.clientTop,r=n.left+e.clientLeft,s=Sg(e),a=e.clientWidth*s.x,o=e.clientHeight*s.y,c=r*s.x,u=i*s.y;return{width:a,height:o,x:c,y:u}}function x7(e,t,n){let i;if(t==="viewport"||t==="layoutViewport")i=bDe(e,n,t);else if(t==="document")i=mDe(Od(e));else if(Uc(t))i=ODe(t,n);else{const r=pre(e);i={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return $k(i)}function yDe(e,t){const n=t.get(e);if(n)return n;let i=bx(e,[],!1).filter(o=>Uc(o)&&Z0(o)!=="body"),r=null;const s=zc(e).position==="fixed";let a=s?vp(e):e;for(;Uc(a)&&!gx(a);){const o=zc(a),c=X$(a),u=r?r.position:s?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&o.position==="static")?i=i.filter(f=>f!==a):r=o,a=vp(a)}return t.set(e,i),i}function xDe(e){let{element:t,boundary:n,rootBoundary:i,strategy:r}=e;const a=[...n==="clippingAncestors"?G_(t)?[]:yDe(t,this._c):[].concat(n),i],o=x7(t,a[0],r);let c=o.top,u=o.right,d=o.bottom,f=o.left;for(let h=1;h{o(!1,1e-7)},1e3)}k=!1}try{i=new IntersectionObserver(T,{...S,root:s.ownerDocument})}catch{i=new IntersectionObserver(T,S)}i.observe(e)}const c=za(e),u=()=>o(n);return c.addEventListener("resize",u),o(!0),()=>{c.removeEventListener("resize",u),a()}}function _De(e,t,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,u=H$(e),d=r||s?[...u?bx(u):[],...t?bx(t):[]]:[];d.forEach(O=>{r&&O.addEventListener("scroll",n),s&&O.addEventListener("resize",n)});const f=u&&o?TDe(u,n,s):null;let h=-1,p=null;a&&(p=new ResizeObserver(O=>{let[v]=O;v&&v.target===u&&p&&t&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),u&&!c&&p.observe(u),t&&p.observe(t));let g,b=c?wp(e):null;c&&y();function y(){const O=wp(e);b&&!bre(b,O)&&n(),b=O,g=requestAnimationFrame(y)}return n(),()=>{var O;d.forEach(v=>{r&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(O=p)==null||O.disconnect(),p=null,c&&cancelAnimationFrame(g)}}const ADe=iDe,NDe=rDe,CDe=eDe,jDe=aDe,RDe=tDe,w7=J5e,IDe=sDe,PDe=(e,t,n)=>{const i=new Map,r=n??{},s={...kDe,...r.platform,_c:i};return K5e(e,t,{...r,platform:s})};var MDe=typeof document<"u",LDe=function(){},tE=MDe?m.useLayoutEffect:LDe;function Qk(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,i,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(i=n;i--!==0;)if(!Qk(e[i],t[i]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(t,r[i]))return!1;for(i=n;i--!==0;){const s=r[i];if(!(s==="_owner"&&e.$$typeof)&&!Qk(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ore(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function S7(e,t){const n=Ore(e);return Math.round(t*n)/n}function OC(e){const t=m.useRef(e);return tE(()=>{t.current=e}),t}function DDe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:a}={},transform:o=!0,whileElementsMounted:c,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(i);Qk(h,i)||p(i);const[g,b]=m.useState(null),[y,O]=m.useState(null),v=m.useCallback(U=>{U!==S.current&&(S.current=U,b(U))},[]),x=m.useCallback(U=>{U!==k.current&&(k.current=U,O(U))},[]),w=s||g,E=a||y,S=m.useRef(null),k=m.useRef(null),T=m.useRef(d),A=c!=null,N=OC(c),C=OC(r),M=OC(u),L=m.useCallback(()=>{if(!S.current||!k.current)return;const U={placement:t,strategy:n,middleware:h};C.current&&(U.platform=C.current),PDe(S.current,k.current,U).then(B=>{const I={...B,isPositioned:M.current!==!1};P.current&&!Qk(T.current,I)&&(T.current=I,zi.flushSync(()=>{f(I)}))})},[h,t,n,C,M]);tE(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[u]);const P=m.useRef(!1);tE(()=>(P.current=!0,()=>{P.current=!1}),[]),tE(()=>{if(w&&(S.current=w),E&&(k.current=E),w&&E){if(N.current)return N.current(w,E,L);L()}},[w,E,L,N,A]);const Q=m.useMemo(()=>({reference:S,floating:k,setReference:v,setFloating:x}),[v,x]),j=m.useMemo(()=>({reference:w,floating:E}),[w,E]),$=m.useMemo(()=>{const U={position:n,left:0,top:0};if(!j.floating)return U;const B=S7(j.floating,d.x),I=S7(j.floating,d.y);return o?{...U,transform:"translate("+B+"px, "+I+"px)",...Ore(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:I}},[n,o,j.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:Q,elements:j,floatingStyles:$}),[d,L,Q,j,$])}const $De=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:i,padding:r}=typeof e=="function"?e(n):e;return i&&t(i)?i.current!=null?w7({element:i.current,padding:r}).fn(n):{}:i?w7({element:i,padding:r}).fn(n):{}}}},QDe=(e,t)=>{const n=ADe(e);return{name:n.name,fn:n.fn,options:[e,t]}},BDe=(e,t)=>{const n=NDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},UDe=(e,t)=>({fn:IDe(e).fn,options:[e,t]}),zDe=(e,t)=>{const n=CDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},FDe=(e,t)=>{const n=jDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},VDe=(e,t)=>{const n=RDe(e);return{name:n.name,fn:n.fn,options:[e,t]}},XDe=(e,t)=>{const n=$De(e);return{name:n.name,fn:n.fn,options:[e,t]}};var qDe=Object.defineProperty,Sf=(e,t)=>qDe(e,"name",{value:t,configurable:!0}),yre="Popper",[xre,K_]=Xl(yre),[HDe,vre]=xre(yre),YDe=Sf(e=>{const{__scopePopper:t,children:n}=e,[i,r]=m.useState(null),[s,a]=m.useState(void 0);return l.jsx(HDe,{scope:t,anchor:i,onAnchorChange:r,placementState:s,setPlacementState:a,children:n})},"Popper"),GDe="PopperAnchor",WDe=m.forwardRef(Sf(function(t,n){const{__scopePopper:i,virtualRef:r,...s}=t,a=vre(GDe,i),o=m.useRef(null),c=a.onAnchorChange,u=m.useCallback(b=>{o.current=b,b&&c(b)},[c]),d=Sr(n,u),f=m.useRef(null);m.useEffect(()=>{if(!r)return;const b=f.current;f.current=r.current,b!==f.current&&c(f.current)});const h=a.placementState&&J_(a.placementState),p=h==null?void 0:h[0],g=h==null?void 0:h[1];return r?null:l.jsx(qr.div,{"data-radix-popper-side":p,"data-radix-popper-align":g,...s,ref:d})},"PopperAnchor")),wre="PopperContent",[ZDe,SOt]=xre(wre),KDe=m.forwardRef(Sf(function(t,n){var ie,ue,ye,Se,Re,Ee,me;const{__scopePopper:i,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=t,O=vre(wre,i),[v,x]=m.useState(null),w=Sr(n,x),[E,S]=m.useState(null),k=q_(E),T=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,N=r+(a!=="center"?"-"+a:""),C=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},M=Array.isArray(d)?d:[d],L=M.length>0,P={padding:C,boundary:M.filter(Sre),altBoundary:L},{refs:Q,floatingStyles:j,placement:$,isPositioned:U,middlewareData:B}=DDe({strategy:"fixed",placement:N,whileElementsMounted:Sf((...oe)=>_De(...oe,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:O.anchor},middleware:[QDe({mainAxis:s+A,alignmentAxis:o}),u&&BDe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?UDe():void 0,...P}),u&&zDe({...P}),FDe({...P,apply:Sf(({elements:oe,rects:Ne,availableWidth:Oe,availableHeight:Ve})=>{const{width:We,height:De}=Ne.reference,mt=oe.floating.style;mt.setProperty("--radix-popper-available-width",`${Oe}px`),mt.setProperty("--radix-popper-available-height",`${Ve}px`),mt.setProperty("--radix-popper-anchor-width",`${We}px`),mt.setProperty("--radix-popper-anchor-height",`${De}px`)},"apply")}),E&&XDe({element:E,padding:c}),JDe({arrowWidth:T,arrowHeight:A}),p&&VDe({strategy:"referenceHidden",...P,boundary:L?P.boundary:void 0})]}),I=O.setPlacementState;tl(()=>(I($),()=>{I(void 0)}),[$,I]);const[X,q]=J_($),D=Df(b);tl(()=>{U&&(D==null||D())},[U,D]);const H=(ie=B.arrow)==null?void 0:ie.x,re=(ue=B.arrow)==null?void 0:ue.y,fe=((ye=B.arrow)==null?void 0:ye.centerOffset)!==0,[Ae,J]=m.useState();return tl(()=>{v&&J(window.getComputedStyle(v).zIndex)},[v]),l.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:U?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(Se=B.transformOrigin)==null?void 0:Se.x,(Re=B.transformOrigin)==null?void 0:Re.y].join(" "),...((Ee=B.hide)==null?void 0:Ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(ZDe,{scope:i,placedSide:X,placedAlign:q,onArrowChange:S,arrowX:H,arrowY:re,shouldHideArrow:fe,children:l.jsx(qr.div,{"data-side":X,"data-align":q,...y,ref:w,style:{...y.style,animation:U?(me=y.style)==null?void 0:me.animation:"none"}})})})},"PopperContent"));function Sre(e){return e!==null}Sf(Sre,"isNotNull");var JDe=Sf(e=>({name:"transformOrigin",options:e,fn(t){var y,O,v;const{placement:n,rects:i,middlewareData:r}=t,a=((y=r.arrow)==null?void 0:y.centerOffset)!==0,o=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=J_(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((O=r.arrow)==null?void 0:O.x)??0)+o/2,p=(((v=r.arrow)==null?void 0:v.y)??0)+c/2;let g="",b="";return u==="bottom"?(g=a?f:`${h}px`,b=`${-c}px`):u==="top"?(g=a?f:`${h}px`,b=`${i.floating.height+c}px`):u==="right"?(g=`${-c}px`,b=a?f:`${p}px`):u==="left"&&(g=`${i.floating.width+c}px`,b=a?f:`${p}px`),{data:{x:g,y:b}}}}),"transformOrigin");function J_(e){const[t,n="center"]=e.split("-");return[t,n]}Sf(J_,"getSideAndAlignFromPlacement");var Ere=YDe,kre=WDe,Tre=KDe,e$e=Object.defineProperty,Y$=(e,t)=>e$e(e,"name",{value:t,configurable:!0}),yC=!1;function _re(){const[e,t]=m.useState(yC);return m.useEffect(()=>{yC||(yC=!0,t(!0))},[]),e}Y$(_re,"useIsHydrated");var Are=j0[" useSyncExternalStore ".trim().toString()];function Nre(){return()=>{}}Y$(Nre,"subscribe");function Cre(){return Are(Nre,()=>!0,()=>!1)}Y$(Cre,"useIsHydratedModern");var t$e=typeof Are=="function"?Cre:_re,n$e=Object.defineProperty,Bp=(e,t)=>n$e(e,"name",{value:t,configurable:!0}),xC="rovingFocusGroup.onEntryFocus",i$e={bubbles:!1,cancelable:!0},eA="RovingFocusGroup",[WP,jre,r$e]=kie(eA),[s$e,tA]=Xl(eA,[r$e]),[a$e,o$e]=s$e(eA),l$e=m.forwardRef(Bp(function(t,n){return l.jsx(WP.Provider,{scope:t.__scopeRovingFocusGroup,children:l.jsx(WP.Slot,{scope:t.__scopeRovingFocusGroup,children:l.jsx(c$e,{...t,ref:n})})})},"RovingFocusGroup")),c$e=m.forwardRef(Bp(function(t,n){const{__scopeRovingFocusGroup:i,orientation:r,loop:s=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=t,p=m.useRef(null),g=Sr(n,p),b=V_(a),[y,O]=bd({prop:o,defaultProp:c??null,onChange:u,caller:eA}),[v,x]=m.useState(!1),w=Df(d),E=jre(i),S=m.useRef(!1),[k,T]=m.useState(0);return m.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(xC,w),()=>A.removeEventListener(xC,w)},[w]),l.jsx(a$e,{scope:i,orientation:r,dir:b,loop:s,currentTabStopId:y,onItemFocus:m.useCallback(A=>O(A),[O]),onItemShiftTab:m.useCallback(()=>x(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>T(A=>A-1),[]),children:l.jsx(qr.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:Ti(t.onMouseDown,()=>{S.current=!0}),onFocus:Ti(t.onFocus,A=>{const N=!S.current;if(A.target===A.currentTarget&&N&&!v){const C=new CustomEvent(xC,i$e);if(A.currentTarget.dispatchEvent(C),!C.defaultPrevented){const M=E().filter($=>$.focusable),L=M.find($=>$.active),P=M.find($=>$.id===y),j=[L,P,...M].filter(Boolean).map($=>$.ref.current);G$(j,f)}}S.current=!1}),onBlur:Ti(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),u$e="RovingFocusGroupItem",d$e=m.forwardRef(Bp(function(t,n){const{__scopeRovingFocusGroup:i,focusable:r=!0,active:s=!1,tabStopId:a,children:o,...c}=t,u=F_(),d=a||u,f=o$e(u$e,i),h=f.currentTabStopId===d,p=jre(i),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=f,O=t$e();return tl(()=>{if(!(!O||!r))return g(),()=>b()},[O,r,g,b]),m.useEffect(()=>{if(!(O||!r))return g(),()=>b()},[O,r,g,b]),l.jsx(WP.ItemSlot,{scope:i,id:d,focusable:r,active:s,children:l.jsx(qr.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:Ti(t.onMouseDown,v=>{r?f.onItemFocus(d):v.preventDefault()}),onFocus:Ti(t.onFocus,()=>f.onItemFocus(d)),onKeyDown:Ti(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const x=Ire(v,f.orientation,f.dir);if(x!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=p().filter(S=>S.focusable).map(S=>S.ref.current);if(x==="last")E.reverse();else if(x==="prev"||x==="next"){x==="prev"&&E.reverse();const S=E.indexOf(v.currentTarget);E=f.loop?Pre(E,S+1):E.slice(S+1)}setTimeout(()=>G$(E))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:y!=null}):o})})},"RovingFocusGroupItem")),f$e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Rre(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Bp(Rre,"getDirectionAwareKey");function Ire(e,t,n){const i=Rre(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return f$e[i]}Bp(Ire,"getFocusIntent");function G$(e,t=!1){const n=document.activeElement;for(const i of e)if(i===n||(i.focus({preventScroll:t}),document.activeElement!==n))return}Bp(G$,"focusFirst");function Pre(e,t){return e.map((n,i)=>e[(t+i)%e.length])}Bp(Pre,"wrapArray");var Mre=l$e,Lre=d$e,h$e=Object.defineProperty,th=(e,t)=>h$e(e,"name",{value:t,configurable:!0}),W$="Popover",[Dre,EOt]=Xl(W$,[K_]),Z$=K_(),[p$e,K0]=Dre(W$),m$e=th(e=>{const{__scopePopover:t,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:a=!1}=e,o=Z$(t),c=m.useRef(null),[u,d]=m.useState(!1),[f,h]=bd({prop:i,defaultProp:r??!1,onChange:s,caller:W$});return l.jsx(Ere,{...o,children:l.jsx(p$e,{scope:t,contentId:F_(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:u,onCustomAnchorAdd:m.useCallback(()=>d(!0),[]),onCustomAnchorRemove:m.useCallback(()=>d(!1),[]),modal:a,children:n})})},"Popover"),g$e="PopoverTrigger",b$e=m.forwardRef(th(function(t,n){const{__scopePopover:i,...r}=t,s=K0(g$e,i),a=Z$(i),o=Sr(n,s.triggerRef),c=l.jsx(qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":K$(s.open),...r,ref:o,onClick:Ti(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?c:l.jsx(kre,{asChild:!0,...a,children:c})},"PopoverTrigger")),$re="PopoverPortal",[O$e,y$e]=Dre($re,{forceMount:void 0}),x$e=th(e=>{const{__scopePopover:t,forceMount:n,children:i,container:r}=e,s=K0($re,t);return l.jsx(O$e,{scope:t,forceMount:n,children:l.jsx(G0,{present:n||s.open,children:l.jsx(Wie,{asChild:!0,container:r,children:i})})})},"PopoverPortal"),Ox="PopoverContent",v$e=m.forwardRef(th(function(t,n){const i=y$e(Ox,t.__scopePopover),{forceMount:r=i.forceMount,...s}=t,a=K0(Ox,t.__scopePopover);return l.jsx(G0,{present:r||a.open,children:a.modal?l.jsx(S$e,{...s,ref:n}):l.jsx(E$e,{...s,ref:n})})},"PopoverContent")),w$e=Lf("PopoverContent.RemoveScroll"),S$e=m.forwardRef(th(function(t,n){const i=K0(Ox,t.__scopePopover),r=m.useRef(null),s=Sr(n,r),a=m.useRef(!1);return m.useEffect(()=>{const o=r.current;if(o)return A5e(o)},[]),l.jsx(rre,{as:w$e,allowPinchZoom:!0,children:l.jsx(Qre,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ti(t.onCloseAutoFocus,o=>{var c;o.preventDefault(),a.current||(c=i.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Ti(t.onPointerDownOutside,o=>{const c=o.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Ti(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),E$e=m.forwardRef(th(function(t,n){const i=K0(Ox,t.__scopePopover),r=m.useRef(!1),s=m.useRef(!1);return l.jsx(Qre,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,a),a.defaultPrevented||(r.current||(c=i.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var u,d;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;((d=i.triggerRef.current)==null?void 0:d.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})},"PopoverContentNonModal")),Qre=m.forwardRef(th(function(t,n){const{__scopePopover:i,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=t,p=K0(Ox,i),g=Z$(i);return $$(),l.jsx($Le,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:l.jsx(Uie,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>p.onOpenChange(!1),deferPointerDownOutside:!0,children:l.jsx(Tre,{"data-state":K$(p.open),role:"dialog",id:p.contentId,...g,...h,ref:n,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function K$(e){return e?"open":"closed"}th(K$,"getState");var k$e=m$e,T$e=b$e,_$e=x$e,A$e=v$e,N$e=Object.defineProperty,Zs=(e,t)=>N$e(e,"name",{value:t,configurable:!0}),Bre="Radio",[C$e,Ure]=Xl(Bre),[j$e,nA]=C$e(Bre);function zre(e){const{__scopeRadio:t,checked:n=!1,children:i,disabled:r,form:s,name:a,onCheck:o,required:c,value:u="on",internal_do_not_use_render:d}=e,[f,h]=m.useState(null),[p,g]=m.useState(null),b=m.useRef(!1),[y,O]=m.useReducer(w=>w+1,0),v=f?!!s||!!f.closest("form"):!0,x={checked:n,disabled:r,required:c,name:a,form:s,value:u,control:f,setControl:h,hasConsumerStoppedPropagationRef:b,userInteractionCount:y,onUserInteraction:O,isFormControl:v,bubbleInput:p,setBubbleInput:g,onCheck:Zs(()=>o==null?void 0:o(),"onCheck")};return l.jsx(j$e,{scope:t,...x,children:Fre(d)?d(x):i})}Zs(zre,"RadioProvider");var R$e="RadioTrigger",I$e=m.forwardRef(Zs(function({__scopeRadio:t,onClick:n,...i},r){const{checked:s,disabled:a,value:o,setControl:c,onCheck:u,hasConsumerStoppedPropagationRef:d,onUserInteraction:f,isFormControl:h,bubbleInput:p}=nA(R$e,t),g=Sr(r,c);return l.jsx(qr.button,{type:"button",role:"radio","aria-checked":s,"data-state":J$(s),"data-disabled":a?"":void 0,disabled:a,value:o,...i,ref:g,onClick:Ti(n,b=>{s||(f(),u()),p&&h&&(d.current=b.isPropagationStopped(),d.current||b.stopPropagation())})})},"RadioTrigger")),P$e="RadioIndicator",M$e=m.forwardRef(Zs(function(t,n){const{__scopeRadio:i,forceMount:r,...s}=t,a=nA(P$e,i);return l.jsx(G0,{present:r||a.checked,children:l.jsx(qr.span,{"data-state":J$(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:n})})},"RadioIndicator")),L$e="RadioBubbleInput",D$e=m.forwardRef(Zs(function({__scopeRadio:t,onClick:n,...i},r){const{control:s,checked:a,required:o,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:p,hasConsumerStoppedPropagationRef:g,userInteractionCount:b}=nA(L$e,t),y=Sr(r,p),O=q_(s),v=m.useRef(!1),x=m.useRef(a),w=m.useRef(b);m.useEffect(()=>{const S=h;if(!S)return;const k=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(k,"checked").set,N=b!==w.current;w.current=b;const C=x.current!==a;x.current=a;const M=!(N&&g.current);if(C&&A){v.current=!N;const L=new Event("click",{bubbles:M});A.call(S,a),S.dispatchEvent(L),v.current=!1}},[h,a,g,b]);const E=m.useRef(a);return l.jsx(qr.input,{type:"radio","aria-hidden":!0,defaultChecked:E.current,required:o,disabled:c,name:u,value:d,form:f,...i,tabIndex:-1,ref:y,onClick:Ti(n,S=>{v.current&&S.stopPropagation()}),style:{...i.style,...O,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"RadioBubbleInput"));function Fre(e){return typeof e=="function"}Zs(Fre,"isFunction");function J$(e){return e?"checked":"unchecked"}Zs(J$,"getState");var $$e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],e3="RadioGroup",[Q$e,kOt]=Xl(e3,[tA,Ure]),Vre=tA(),iA=Ure(),[B$e,U$e]=Q$e(e3),z$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,name:r,form:s,defaultValue:a,value:o,required:c=!1,disabled:u=!1,orientation:d,dir:f,loop:h=!0,onValueChange:p,...g}=t,b=Vre(i),y=V_(f),[O,v]=bd({prop:o,defaultProp:a??null,onChange:p,caller:e3}),[x,w]=m.useState(null),E=Sr(n,w),S=m.useRef(O);return m.useEffect(()=>{const k=s?x==null?void 0:x.ownerDocument.getElementById(s):x==null?void 0:x.closest("form");if(k instanceof HTMLFormElement){const T=Zs(()=>v(S.current),"reset");return k.addEventListener("reset",T),()=>k.removeEventListener("reset",T)}},[x,s,v]),l.jsx(B$e,{scope:i,name:r,form:s,required:c,disabled:u,value:O,onValueChange:v,children:l.jsx(Mre,{asChild:!0,...b,orientation:d,dir:y,loop:h,children:l.jsx(qr.div,{role:"radiogroup","aria-required":c,"aria-orientation":d,"data-disabled":u?"":void 0,dir:y,...g,ref:E})})})},"RadioGroup")),F$e="RadioGroupItemProvider",V$e="RadioGroupItemTrigger";function Xre(e){const{__scopeRadioGroup:t,value:n,disabled:i,children:r,internal_do_not_use_render:s}=e,a=U$e(F$e,t),o=iA(t),c=a.disabled||i;return l.jsx(zre,{...o,checked:a.value===n,disabled:c,required:a.required,name:a.name,form:a.form,value:n,onCheck:()=>a.onValueChange(n),internal_do_not_use_render:s,children:r})}Zs(Xre,"RadioGroupItemProvider");var X$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=Vre(i),a=iA(i),{checked:o,disabled:c}=nA(V$e,a.__scopeRadio),u=m.useRef(null),d=Sr(n,u),f=m.useRef(!1);return m.useEffect(()=>{const h=Zs(g=>{$$e.includes(g.key)&&(f.current=!0)},"handleKeyDown"),p=Zs(()=>f.current=!1,"handleKeyUp");return document.addEventListener("keydown",h),document.addEventListener("keyup",p),()=>{document.removeEventListener("keydown",h),document.removeEventListener("keyup",p)}},[]),l.jsx(Lre,{asChild:!0,...s,focusable:!c,active:o,children:l.jsx(I$e,{...a,...r,ref:d,onKeyDown:Ti(r.onKeyDown,h=>{h.key==="Enter"&&h.preventDefault()}),onFocus:Ti(r.onFocus,()=>{var h;f.current&&((h=u.current)==null||h.click())})})})},"RadioGroupItemTrigger")),q$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,value:r,disabled:s,...a}=t;return l.jsx(Xre,{__scopeRadioGroup:i,value:r,disabled:s,internal_do_not_use_render:({isFormControl:o})=>l.jsxs(l.Fragment,{children:[l.jsx(X$e,{...a,ref:n,__scopeRadioGroup:i}),o&&l.jsx(H$e,{__scopeRadioGroup:i})]})})},"RadioGroupItem")),H$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=iA(i);return l.jsx(D$e,{...s,...r,ref:n})},"RadioGroupItemBubbleInput")),Y$e=m.forwardRef(Zs(function(t,n){const{__scopeRadioGroup:i,...r}=t,s=iA(i);return l.jsx(M$e,{...s,...r,ref:n})},"RadioGroupIndicator")),G$e=Object.defineProperty,W$e=(e,t)=>G$e(e,"name",{value:t,configurable:!0}),Z$e="Toggle",K$e=m.forwardRef(W$e(function(t,n){const{pressed:i,defaultPressed:r,onPressedChange:s,...a}=t,[o,c]=bd({prop:i,onChange:s,defaultProp:r??!1,caller:Z$e});return l.jsx(qr.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":t.disabled?"":void 0,...a,ref:n,onClick:Ti(t.onClick,()=>{t.disabled||c(!o)})})},"Toggle")),J$e=Object.defineProperty,Bf=(e,t)=>J$e(e,"name",{value:t,configurable:!0}),J0="ToggleGroup",[qre,TOt]=Xl(J0,[tA]),Hre=tA(),e3e=m.forwardRef(Bf(function(t,n){const{type:i,...r}=t;if(i==="single"){const s=r;return l.jsx(t3e,{role:"radiogroup",...s,ref:n})}if(i==="multiple"){const s=r;return l.jsx(n3e,{role:"toolbar",...s,ref:n})}throw new Error(`Missing prop \`type\` expected on \`${J0}\``)},"ToggleGroup")),[Yre,Gre]=qre(J0),t3e=m.forwardRef(Bf(function(t,n){const{value:i,defaultValue:r,onValueChange:s=Bf(()=>{},"onValueChange"),...a}=t,[o,c]=bd({prop:i,defaultProp:r??"",onChange:s,caller:J0});return l.jsx(Yre,{scope:t.__scopeToggleGroup,type:"single",value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:c,onItemDeactivate:m.useCallback(()=>c(""),[c]),children:l.jsx(Wre,{...a,ref:n})})},"ToggleGroupImplSingle")),n3e=m.forwardRef(Bf(function(t,n){const{value:i,defaultValue:r,onValueChange:s=Bf(()=>{},"onValueChange"),...a}=t,[o,c]=bd({prop:i,defaultProp:r??[],onChange:s,caller:J0}),u=m.useCallback(f=>c((h=[])=>[...h,f]),[c]),d=m.useCallback(f=>c((h=[])=>h.filter(p=>p!==f)),[c]);return l.jsx(Yre,{scope:t.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:u,onItemDeactivate:d,children:l.jsx(Wre,{...a,ref:n})})},"ToggleGroupImplMultiple")),[i3e,r3e]=qre(J0),Wre=m.forwardRef(Bf(function(t,n){const{__scopeToggleGroup:i,disabled:r=!1,rovingFocus:s=!0,orientation:a,dir:o,loop:c=!0,...u}=t,d=Hre(i),f=V_(o),h={dir:f,...u};return l.jsx(i3e,{scope:i,rovingFocus:s,disabled:r,children:s?l.jsx(Mre,{asChild:!0,...d,orientation:a,dir:f,loop:c,children:l.jsx(qr.div,{...h,ref:n})}):l.jsx(qr.div,{...h,ref:n})})},"ToggleGroupImpl")),ZP="ToggleGroupItem",s3e=m.forwardRef(Bf(function(t,n){const i=Gre(ZP,t.__scopeToggleGroup),r=r3e(ZP,t.__scopeToggleGroup),s=Hre(t.__scopeToggleGroup),a=i.value.includes(t.value),o=r.disabled||t.disabled,c={...t,pressed:a,disabled:o},u=m.useRef(null);return r.rovingFocus?l.jsx(Lre,{asChild:!0,...s,focusable:!o,active:a,ref:u,children:l.jsx(E7,{...c,ref:n})}):l.jsx(E7,{...c,ref:n})},"ToggleGroupItem")),E7=m.forwardRef(Bf(function(t,n){const{__scopeToggleGroup:i,value:r,...s}=t,a=Gre(ZP,i),o={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},c=a.type==="single"?o:void 0;return l.jsx(K$e,{...c,...s,ref:n,onPressedChange:u=>{u?a.onItemActivate(r):a.onItemDeactivate(r)}})},"ToggleGroupItemImpl")),a3e=Object.defineProperty,bs=(e,t)=>a3e(e,"name",{value:t,configurable:!0}),[t3,_Ot]=Xl("Tooltip",[K_]),n3=K_(),o3e="TooltipProvider",l3e=700,KP="tooltip.open",[c3e,i3]=t3(o3e),u3e=bs(e=>{const{__scopeTooltip:t,delayDuration:n=l3e,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=e,a=m.useRef(!0),o=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(c3e,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{i<=0||(window.clearTimeout(c.current),a.current=!1)},[i]),onClose:m.useCallback(()=>{i<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i))},[i]),isPointerInTransitRef:o,onPointerInTransitChange:m.useCallback(u=>{o.current=u},[]),disableHoverableContent:r,children:s})},"TooltipProvider"),JP="Tooltip",[d3e,R1]=t3(JP),f3e=bs(e=>{const{__scopeTooltip:t,children:n,open:i,defaultOpen:r,onOpenChange:s,disableHoverableContent:a,delayDuration:o}=e,c=i3(JP,e.__scopeTooltip),u=n3(t),[d,f]=m.useState(null),[h,p]=m.useState(void 0),g=F_(),b=m.useRef(0),y=a??c.disableHoverableContent,O=o??c.delayDuration,v=m.useRef(!1),[x,w]=bd({prop:i,defaultProp:r??!1,onChange:bs(N=>{N?(c.onOpen(),document.dispatchEvent(new CustomEvent(KP))):c.onClose(),s==null||s(N)},"onChange"),caller:JP}),E=m.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),S=m.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,w(!0)},[w]),k=m.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w(!1)},[w]),T=m.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,w(!0),b.current=0},O)},[O,w]);m.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]);const A=h??g;return l.jsx(Ere,{...u,children:l.jsx(d3e,{scope:t,contentId:A,setContentId:p,open:x,stateAttribute:E,trigger:d,onTriggerChange:f,onTriggerEnter:m.useCallback(()=>{c.isOpenDelayedRef.current?T():S()},[c.isOpenDelayedRef,T,S]),onTriggerLeave:m.useCallback(()=>{y?k():(window.clearTimeout(b.current),b.current=0)},[k,y]),onOpen:S,onClose:k,disableHoverableContent:y,children:n})})},"Tooltip"),k7="TooltipTrigger",h3e=m.forwardRef(bs(function(t,n){const{__scopeTooltip:i,...r}=t,s=R1(k7,i),a=i3(k7,i),o=n3(i),c=m.useRef(null),u=Sr(n,c,s.onTriggerChange),d=m.useRef(!1),f=m.useRef(!1),h=m.useCallback(()=>d.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),l.jsx(kre,{asChild:!0,...o,children:l.jsx(qr.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:u,onPointerMove:Ti(t.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),f.current=!0)}),onPointerLeave:Ti(t.onPointerLeave,()=>{s.onTriggerLeave(),f.current=!1}),onPointerDown:Ti(t.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ti(t.onFocus,()=>{d.current||s.onOpen()}),onBlur:Ti(t.onBlur,s.onClose),onClick:Ti(t.onClick,s.onClose)})})},"TooltipTrigger")),Zre="TooltipPortal",[p3e,m3e]=t3(Zre,{forceMount:void 0}),g3e=bs(e=>{const{__scopeTooltip:t,forceMount:n,children:i,container:r}=e,s=R1(Zre,t);return l.jsx(p3e,{scope:t,forceMount:n,children:l.jsx(G0,{present:n||s.open,children:l.jsx(Wie,{asChild:!0,container:r,children:i})})})},"TooltipPortal"),yx="TooltipContent",b3e=m.forwardRef(bs(function(t,n){const i=m3e(yx,t.__scopeTooltip),{forceMount:r=i.forceMount,side:s="top",...a}=t,o=R1(yx,t.__scopeTooltip);return l.jsx(G0,{present:r||o.open,children:o.disableHoverableContent?l.jsx(Kre,{side:s,...a,ref:n}):l.jsx(O3e,{side:s,...a,ref:n})})},"TooltipContent")),O3e=m.forwardRef(bs(function(t,n){const i=R1(yx,t.__scopeTooltip),r=i3(yx,t.__scopeTooltip),s=m.useRef(null),a=Sr(n,s),[o,c]=m.useState(null),{trigger:u,onClose:d}=i,f=s.current,{onPointerInTransitChange:h}=r,p=m.useCallback(()=>{c(null),h(!1)},[h]),g=m.useCallback((b,y)=>{const O=b.currentTarget,v={x:b.clientX,y:b.clientY},x=Jre(v,O.getBoundingClientRect()),w=ese(v,x),E=tse(y.getBoundingClientRect()),S=ise([...w,...E]);c(S),h(!0)},[h]);return m.useEffect(()=>()=>p(),[p]),m.useEffect(()=>{if(u&&f){const b=bs(O=>g(O,f),"handleTriggerLeave"),y=bs(O=>g(O,u),"handleContentLeave");return u.addEventListener("pointerleave",b),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",y)}}},[u,f,g,p]),m.useEffect(()=>{if(o){const b=bs(y=>{const O=y.target,v={x:y.clientX,y:y.clientY},x=(u==null?void 0:u.contains(O))||(f==null?void 0:f.contains(O)),w=!nse(v,o);x?p():w&&(p(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,f,o,d,p]),l.jsx(Kre,{...t,ref:a})},"TooltipContentHoverable")),y3e=Oie("TooltipContent"),Kre=m.forwardRef(bs(function(t,n){const{__scopeTooltip:i,children:r,"aria-label":s,id:a,onEscapeKeyDown:o,onPointerDownOutside:c,...u}=t,d=R1(yx,i),f=n3(i),{onClose:h}=d;m.useEffect(()=>(document.addEventListener(KP,h),()=>document.removeEventListener(KP,h)),[h]),m.useEffect(()=>{if(d.trigger){const g=bs(b=>{b.target instanceof Node&&b.target.contains(d.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]);const{setContentId:p}=d;return tl(()=>(p(a),()=>{p(void 0)}),[a,p]),l.jsx(Uie,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:l.jsxs(Tre,{"data-state":d.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:d.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(y3e,{children:r}),s?l.jsx(uLe,{id:d.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function Jre(e,t){const n=Math.abs(t.top-e.y),i=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}bs(Jre,"getExitSideFromRect");function ese(e,t,n=5){const i=[];switch(t){case"top":i.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":i.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":i.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":i.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return i}bs(ese,"getPaddedExitPoints");function tse(e){const{top:t,right:n,bottom:i,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:i},{x:r,y:i}]}bs(tse,"getPointsFromRect");function nse(e,t){const{x:n,y:i}=e;let r=!1;for(let s=0,a=t.length-1;si!=h>i&&n<(f-u)*(i-d)/(h-d)+u&&(r=!r)}return r}bs(nse,"isPointInPolygon");function ise(e){const t=e.slice();return t.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),rse(t)}bs(ise,"getHull");function rse(e){if(e.length<=1)return e.slice();const t=[];for(let i=0;i=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}bs(rse,"getHullPresorted");var x3e=u3e,v3e=f3e,sse=h3e,w3e=g3e,S3e=b3e;function eM(e){const t=m.useRef(e);return t.current=e,t}let d0=[],Sw=!1;const T7=e=>{var t,n;if(e.key==="Escape"){const[i]=d0;i&&(e.preventDefault(),(n=(t=i.callback).current)==null||n.call(t))}},ase=()=>{d0.length>0&&!Sw?(document.body.addEventListener("keydown",T7),Sw=!0):d0.length===0&&Sw&&(document.body.removeEventListener("keydown",T7),Sw=!1)},E3e=e=>{d0.unshift(e),ase()},k3e=({id:e})=>{d0=d0.filter(t=>t.id!==e),ase()},ose=(e,t)=>{const n=m.useId(),i=eM(t);m.useEffect(()=>{if(!e)return;const r={id:n,callback:i};return E3e(r),()=>k3e(r)},[n,e,i])},T3e="_Tooltip_16g2y_1",_3e="_TriggerDecorator_16g2y_73",lse={Tooltip:T3e,TriggerDecorator:_3e},sp=e=>{const{ref:t,children:n,content:i,forceOpen:r=i===null?!1:void 0,maxWidth:s=300,openDelay:a=150,interactive:o=!1,compact:c=!1,preventUnintentionalClickToClose:u,align:d,alignOffset:f=0,side:h,sideOffset:p=5,gutterSize:g="md",contentClassName:b,onPointerDown:y,onClick:O,...v}=e,[x,w]=m.useState(!1),[E,S]=m.useState(!1);R$(()=>S(!1),E?400:null);const k=r??x,T=N=>{typeof r!="boolean"&&(w(N),u&&S(N))},A=N=>{u&&E&&(N.preventDefault(),N.stopPropagation())};return l.jsxs(cse,{open:k,delayDuration:a,onOpenChange:T,disableHoverableContent:!o,children:[l.jsx(sse,{asChild:!0,children:l.jsx(gie,{...v,ref:t,onPointerDown:N=>{A(N),y==null||y(N)},onClick:N=>{A(N),O==null||O(N)},children:n})}),l.jsx(use,{maxWidth:s,compact:c,align:d,alignOffset:f,side:h,sideOffset:p,gutterSize:g,className:b,children:i})]})},cse=({children:e,open:t,onOpenChange:n,...i})=>(ose(t,()=>{n(!1)}),l.jsx(x3e,{children:l.jsx(v3e,{open:t,onOpenChange:n,...i,children:e})})),use=({children:e,maxWidth:t=300,compact:n=!1,clickable:i=void 0,alignOffset:r=0,sideOffset:s=5,gutterSize:a="md",className:o,style:c,...u})=>l.jsx(w3e,{children:l.jsx(S3e,{...u,className:Ps(lse.Tooltip,o),"data-compact":n,"data-clickable":i,"data-gutter-size":a,alignOffset:r,sideOffset:s,collisionPadding:15,hideWhenDetached:!0,style:{...c,maxWidth:t},onEscapeKeyDown:ZS,children:e})}),A3e=({children:e,asChild:t=!0,...n})=>l.jsx(sse,{asChild:t,...n,children:e}),N3e=e=>{const{children:t,className:n,focusable:i=!0,ref:r,...s}=e,a=typeof t=="string";return l.jsx(gie,{ref:r,...s,className:Ps(lse.TriggerDecorator,n),tabIndex:i?0:void 0,children:a?l.jsx("span",{children:t}):t})};sp.Root=cse;sp.Content=use;sp.Trigger=A3e;sp.TriggerDecorator=N3e;const dse="KNOWLEDGE_PROVIDER_ASSOCIATION_INVALID";class rA extends Error{constructor(n,i,r={}){super(n);Or(this,"status");Or(this,"errorCode");Or(this,"requestId");Or(this,"diagnostics");Or(this,"detail");Or(this,"payload");Or(this,"rawBody");this.name="KnowledgeRequestError",this.status=i;const s=typeof r=="string"?{errorCode:r}:r;this.errorCode=s.errorCode||"",this.requestId=s.requestId||"",this.diagnostics=s.diagnostics,this.detail=s.detail,this.payload=s.payload,this.rawBody=s.rawBody||""}}class fse extends Error{constructor(n){super(n.map(({region:i,error:r})=>`${i}: ${r.message||"读取知识库失败"}`).join(` +`));Or(this,"failures");this.name="KnowledgeRegionAggregateError",this.failures=n}}const C3e=new Set(["ak","apikey","sk","accesskey","accesskeyid","authorization","authkey","clientsecret","cookie","credential","credentials","password","passwd","privatekey","secret","secretaccesskey","secretkey","securitytoken","sessiontoken","setcookie","token"]),j3e=6,_7=50,hse=4e3;function R3e(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function I3e(e){const t=R3e(e);return C3e.has(t)||t.endsWith("password")||t.endsWith("secret")||t.endsWith("token")||t.endsWith("credential")}function P3e(e){return/<\s*(?:!doctype|html|head|body|script|style)\b/i.test(e)}function jO(e){return P3e(e)?"[HTML 内容已隐藏]":e.replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [已脱敏]").replace(/\b(?:set-)?cookie\s*:\s*[^\r\n]*/gi,"cookie: [已脱敏]").replace(/\bAKLT[A-Za-z0-9_-]{6,}\b/g,"[已脱敏]").replace(/((?:access[_-]?key(?:[_-]?id)?|secret(?:[_-]?(?:access)?[_-]?key)?|session[_-]?token|security[_-]?token|client[_-]?secret|api[_-]?key|authorization|cookie|[a-z0-9_-]*(?:password|secret|token)|credential|ak|sk)\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;&]+)/gi,"$1[已脱敏]").replace(/([?&](?:access[_-]?key|api[_-]?key|client[_-]?secret|security[_-]?token|session[_-]?token|secret|token|password|authorization|cookie|credential)=)[^&#\s]+/gi,"$1[已脱敏]")}function tM(e,t=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return jO(e).slice(0,hse);if(typeof e!="object")return;if(t>=j3e)return"[内容过深,已截断]";if(n.has(e))return"[循环引用]";if(n.add(e),Array.isArray(e))return e.slice(0,_7).map(r=>tM(r,t+1,n));const i={};return Object.entries(e).slice(0,_7).forEach(([r,s])=>{i[r]=I3e(r)?"[已脱敏]":tM(s,t+1,n)}),i}function A7(e){if(e===void 0)return"";const t=tM(e);if(typeof t=="string")return t;if(t===void 0)return"";try{return JSON.stringify(t).slice(0,hse)}catch{return"[诊断信息无法显示]"}}function qs(e,t){if(e instanceof fse)return e.failures.map(({region:a,error:o})=>`${a} ${qs(o,t)}`).join(` `);if(!(e instanceof rA))return(e instanceof Error?jO(e.message):"")||t;const n=jO(e.message)||t,i=[Number.isFinite(e.status)?`状态码:${e.status}`:"",e.errorCode?`错误码:${jO(e.errorCode)}`:"",e.requestId?`请求 ID:${jO(e.requestId)}`:""].filter(Boolean).join(" · "),r=A7(e.diagnostics),s=A7(e.detail);return[n,i,r?`诊断:${r}`:"",s&&s!==n?`详情:${s}`:""].filter(Boolean).join(` -`)}function nE(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim();return""}function P3e(e){return Array.isArray(e)?e.map(t=>{const n=Ql(t),i=nE(n.msg,n.message);if(!i)return"";const r=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").map(String).join("."):"";return r?`${r}: ${i}`:i}).filter(Boolean).join("; "):""}function M3e(e,t=!0){const n=Ql(e),i=Object.prototype.hasOwnProperty.call(n,"detail")?n.detail:typeof e=="string"?e:void 0,r=Ql(i);return{message:typeof i=="string"?t?i.trim():"":nE(r.message,n.message,P3e(i)),errorCode:nE(r.errorCode,n.errorCode),requestId:nE(r.requestId,r.request_id,r.RequestId,n.requestId,n.request_id),diagnostics:r.diagnostics??n.diagnostics,detail:i,payload:e}}function Ql(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function fi(e){return typeof e=="string"?e:""}function xx(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function r3(e){const t=Ql(e);return{id:fi(t.id),name:fi(t.name),description:fi(t.description),providerType:fi(t.providerType),providerKnowledgeId:fi(t.providerKnowledgeId),projectName:fi(t.projectName),region:fi(t.region),status:fi(t.status),createdAt:fi(t.createdAt),updatedAt:fi(t.updatedAt),ownerId:fi(t.ownerId),ownerLabel:fi(t.ownerLabel),canManage:t.canManage===!0}}function I1(e){const t=Ql(e);return{id:fi(t.id),name:fi(t.name),type:fi(t.type),sizeBytes:xx(t.sizeBytes,0),status:fi(t.status),url:fi(t.url),tosPath:fi(t.tosPath),metadata:Ql(t.metadata),createdAt:fi(t.createdAt),updatedAt:fi(t.updatedAt)}}function L3e(e){const t=Ql(e),n=t.attachment,i=Ql(n);return{id:fi(t.id),title:fi(t.title),content:fi(t.content),attachmentUrl:fi(t.attachmentUrl)||fi(i.url)||fi(i.previewUrl),attachmentType:fi(t.attachmentType)||fi(i.type)||fi(i.mimeType),attachment:n,tableFields:t.tableFields}}async function Gc(e,t={},n=_o){var f;const i=Dp(t.headers);i.set("accept","application/json"),t.body&&!(t.body instanceof FormData)&&i.set("content-type","application/json");const r=await fetch(e,{...t,headers:i,signal:Ao(t.signal,n)});if(r.ok)return r.status===204?void 0:r.json();const s=await r.text();let a=s,o=!1;if(s)try{a=JSON.parse(s),o=!0}catch{}const c=((f=r.headers.get("content-type"))==null?void 0:f.toLowerCase())||"",u=M3e(a,o||c.startsWith("text/plain")),d=r.status===401?"请先登录后再访问知识库":r.status===403?"你没有权限操作这个知识库":r.status===404?"知识库或知识内容不存在":r.status===409?"知识库当前状态不允许执行此操作":`知识库请求失败 (${r.status})`;throw new rA(u.message||d,r.status,{errorCode:u.errorCode,requestId:u.requestId,diagnostics:u.diagnostics,detail:u.detail,payload:u.payload,rawBody:s})}function eb(e){const t=new URLSearchParams;e.trim()&&t.set("region",e.trim());const n=t.toString();return n?`?${n}`:""}async function D3e(e){var r;const t=new URLSearchParams({region:e.region,pageSize:String(e.pageSize??30)});(r=e.projectName)!=null&&r.trim()&&t.set("projectName",e.projectName.trim()),e.nextToken&&t.set("nextToken",e.nextToken);const n=await Gc(`/web/knowledge-bases?${t.toString()}`,{signal:e.signal}),i=Ql(n);return{items:Array.isArray(i.items)?i.items.map(r3):[],nextToken:fi(i.nextToken)}}function $3e(e){return`${e.region}\0${e.id}`}async function Q3e(e){var o;const t=[...new Set(e.regions.map(c=>c.trim()).filter(Boolean))],n=e.nextTokens?t.filter(c=>{var u;return!!((u=e.nextTokens)!=null&&u[c])}):t;if(n.length===0)return{items:[],nextTokens:{},failures:[]};const i=await Promise.allSettled(n.map(async c=>{var u;return{region:c,page:await D3e({region:c,projectName:e.projectName,nextToken:(u=e.nextTokens)==null?void 0:u[c],pageSize:e.pageSize,signal:e.signal})}}));if((o=e.signal)!=null&&o.aborted)throw new DOMException("Aborted","AbortError");const r=[],s={},a=new Map;if(i.forEach((c,u)=>{var f;const d=n[u];if(c.status==="rejected"){const h=(f=e.nextTokens)==null?void 0:f[d];h&&(s[d]=h),r.push({region:d,error:c.reason instanceof Error?c.reason:new Error("读取知识库失败")});return}c.value.page.nextToken&&(s[d]=c.value.page.nextToken),c.value.page.items.forEach(h=>{const p=h.region?h:{...h,region:d};a.set($3e(p),p)})}),r.length===n.length)throw new dse(r);return{items:[...a.values()],nextTokens:s,failures:r}}function B3e(e){return Gc("/web/knowledge-bases",{method:"POST",body:JSON.stringify(e)},kr).then(r3)}function U3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}${eb(t)}`,{method:"PATCH",body:JSON.stringify(n)}).then(r3)}function z3e(e,t){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}${eb(t)}`,{method:"DELETE"},kr)}async function F3e(e,t){var s;const n=new URLSearchParams({region:t.region,offset:String(t.offset??0),limit:String(t.limit??30)});(s=t.documentType)!=null&&s.trim()&&n.set("documentType",t.documentType.trim());const i=await Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents?${n.toString()}`,{signal:t.signal}),r=Ql(i);return{items:Array.isArray(r.items)?r.items.map(I1):[],offset:xx(r.offset,0),limit:xx(r.limit,t.limit??30),hasMore:r.hasMore===!0}}async function V3e(e,t,n){const i=new URLSearchParams({region:n.region,offset:String(n.offset??0),limit:String(n.limit??20)}),r=await Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}/preview?${i.toString()}`,{signal:n.signal}),s=Ql(r);return{document:I1(s.document),chunks:Array.isArray(s.chunks)?s.chunks.map(L3e):[],offset:xx(s.offset,0),limit:xx(s.limit,n.limit??20),hasMore:s.hasMore===!0}}function X3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents${eb(t)}`,{method:"POST",body:JSON.stringify(n)},kr).then(I1)}function q3e(e,t,n){var r,s;const i=new FormData;return i.set("file",n.file),(r=n.name)!=null&&r.trim()&&i.set("name",n.name.trim()),(s=n.documentType)!=null&&s.trim()&&i.set("documentType",n.documentType.trim()),n.metadata&&i.set("metadata",JSON.stringify(n.metadata)),Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/upload${eb(t)}`,{method:"POST",body:i},kr).then(I1)}function H3e(e,t,n,i){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${eb(n)}`,{method:"PATCH",body:JSON.stringify(i)}).then(I1)}function Y3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${eb(n)}`,{method:"DELETE"},kr)}function G3e({secondaryAction:e,primaryAction:t,menuLabel:n,menuAriaLabel:i,menuActions:r}){return l.jsxs("footer",{className:"library-resource-card__actions",children:[l.jsx("button",{type:"button",className:"library-resource-card__action library-resource-card__action--secondary",disabled:e.disabled,title:e.title,onClick:e.onClick,children:e.label}),l.jsx("button",{type:"button",className:"library-resource-card__action library-resource-card__action--primary",disabled:t.disabled,title:t.title,onClick:t.onClick,children:t.label}),l.jsx(Kne,{label:n,menuLabel:i,className:"library-resource-card__action library-resource-card__more",placement:"top-end",items:r.map(s=>({label:s.label,onSelect:s.onClick,disabled:s.disabled,danger:s.danger,title:s.title}))})]})}function hse({className:e="",title:t,status:n,description:i,metadata:r,secondaryAction:s,primaryAction:a,menuLabel:o,menuAriaLabel:c,menuActions:u}){return l.jsxs("article",{className:`my-agent-card library-resource-card ${e}`.trim(),children:[l.jsxs("div",{className:"my-agent-card-content",children:[l.jsxs("div",{className:"my-agent-card-title",children:[l.jsx("div",{className:"my-agent-card-title-copy",children:l.jsx("h3",{title:t,children:t})}),n]}),l.jsx("p",{className:"my-agent-description",title:i,children:i}),l.jsx("dl",{className:"my-agent-meta",children:r.map((d,f)=>l.jsxs("div",{className:f===0?"my-agent-created-at":"my-agent-region",children:[l.jsx("dt",{children:d.label}),l.jsx("dd",{title:d.title,children:d.value})]},`${d.label}:${f}`))})]}),l.jsx(G3e,{secondaryAction:s,primaryAction:a,menuLabel:o,menuAriaLabel:c,menuActions:u})]})}function W3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),l.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),l.jsx("path",{d:"M9 7h6M9 10h4"})]})}function Z3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),l.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function K3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.3"}),l.jsx("path",{d:"m15.5 15.5 4 4"})]})}function J3e(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function N7(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function e4e(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}function P1({title:e,children:t,onClose:n,busy:i=!1,className:r=""}){const s=m.useId(),a=m.useRef(null),o=m.useRef(null),c=m.useRef(i),u=m.useRef(n);return m.useEffect(()=>{c.current=i,u.current=n},[i,n]),m.useEffect(()=>{var p;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(p=a.current)==null||p.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=o.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),zi.createPortal(l.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!i&&n()},children:l.jsxs("section",{ref:o,className:`knowledge-dialog${r?` ${r}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":i||void 0,children:[l.jsxs("header",{className:"knowledge-dialog__header",children:[l.jsx("h2",{id:s,children:e}),l.jsx("button",{ref:a,type:"button",onClick:n,disabled:i,"aria-label":"关闭",children:l.jsx(J3e,{})})]}),t]})}),document.body)}function sA({message:e}){return e?l.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function nM(e){return e instanceof DOMException&&e.name==="AbortError"}function t4e(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}function n4e(e){const t=e.trim().toLowerCase();return["ready","active","available","success"].includes(t)?"可用":["creating","pending","processing","indexing"].includes(t)?"处理中":["failed","error","unavailable"].includes(t)?"异常":e||"未知"}const pse=[".jpg",".jpeg",".png"].join(","),i4e=new Set(pse.split(",")),mse=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),r4e=new Set(mse.split(",")),s4e=200*1024*1024;function iM(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function a4e(e,t){return e.size>s4e?"单个文件不能超过 200 MB":t==="image"?i4e.has(iM(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":r4e.has(iM(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function s3(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function gse(e){var r;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),i=n.includes(".")?(r=n.split(".").pop())==null?void 0:r.trim():"";return i?i.toUpperCase():"-"}function o4e({onClose:e,onCreated:t}){const[n,i]=m.useState(""),[r,s]=m.useState(""),[a,o]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=n.trim(),p=!!(h&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(h)),g=async b=>{if(b.preventDefault(),o(!0),!h||p)return;u(!0),f("");const y={name:h,description:r.trim()||void 0};try{t(await B3e(y))}catch(O){f(qs(O,"创建知识库失败"))}finally{u(!1)}};return l.jsx(P1,{title:"新建知识库",onClose:e,busy:c,children:l.jsxs("form",{onSubmit:b=>void g(b),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:n,maxLength:48,"aria-invalid":a&&p||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>o(!0),onChange:b=>i(b.target.value)})]}),l.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${a&&p?" is-error":""}`,role:a&&p?"alert":void 0,children:a&&p?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:r,maxLength:80,onChange:b=>s(b.target.value)})]}),l.jsx(sA,{message:d})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:e,disabled:c,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:c||!h||p,children:c?"创建中":"创建"})]})]})})}function l4e({item:e,onClose:t,onUpdated:n}){const[i,r]=m.useState(e.description),[s,a]=m.useState(!1),[o,c]=m.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await U3e(e.id,e.region,{description:i.trim()}))}catch(f){c(qs(f,"更新知识库失败"))}finally{a(!1)}};return l.jsx(P1,{title:"编辑知识库",onClose:t,busy:s,children:l.jsxs("form",{onSubmit:d=>void u(d),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{value:e.name,disabled:!0})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{autoFocus:!0,value:i,maxLength:80,onChange:d=>r(d.target.value)})]}),l.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),l.jsx(sA,{message:o})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function bse(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function c4e({base:e,onClose:t,onCreated:n,onAssociationInvalid:i}){const[r,s]=m.useState("document"),[a,o]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(null),[g,b]=m.useState(!1),[y,O]=m.useState("{}"),[v,x]=m.useState(!1),[w,E]=m.useState(""),S=m.useRef(null),k=m.useRef(0),T=C=>{v||C===r||(s(C),p(null),f(""),o(""),u(""),E(""),b(!1),k.current=0,S.current&&(S.current.value=""))},A=C=>{if(!C||r==="web")return;const M=a4e(C,r);if(M){p(null),o(""),u(""),E(M);return}p(C),E(""),o(C.name.replace(/\.[^.]+$/,"")),u(iM(C.name).slice(1))},N=async C=>{if(C.preventDefault(),r==="web"?!d.trim():!h)return;let M;try{M=bse(y)}catch(L){E(qs(L,"Metadata 格式错误"));return}x(!0),E("");try{if(r==="web"){const L={sourceType:"url",name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:M,url:d.trim()};await X3e(e.id,e.region,L)}else h&&await q3e(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:M});n()}catch(L){L instanceof rA&&L.errorCode===use?i(L):E(qs(L,r==="web"?"添加网页失败":"上传文件失败"))}finally{x(!1)}};return l.jsx(P1,{title:"添加数据",onClose:t,busy:v,children:l.jsxs("form",{onSubmit:C=>void N(C),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([C,M])=>l.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${C}-tab`,"aria-controls":`knowledge-source-${C}-panel`,"aria-selected":r===C,tabIndex:r===C?0:-1,className:r===C?"is-active":"",disabled:v,onClick:()=>T(C),onKeyDown:L=>{const P=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;L.preventDefault();const Q=P.indexOf(C),j=L.key==="Home"?P[0]:L.key==="End"?P[P.length-1]:P[(Q+(L.key==="ArrowRight"?1:-1)+P.length)%P.length];T(j),requestAnimationFrame(()=>{var $;return($=document.getElementById(`knowledge-source-${j}-tab`))==null?void 0:$.focus()})},children:M},C))}),l.jsx("div",{id:`knowledge-source-${r}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${r}-tab`,children:r==="web"?l.jsxs("label",{children:[l.jsx("span",{children:"网页 URL"}),l.jsx("input",{autoFocus:!0,type:"url",value:d,disabled:v,onChange:C=>f(C.target.value),placeholder:"https://example.com/article"})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:S,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:r==="image"?pse:mse,disabled:v,onChange:C=>{var M;A(((M=C.currentTarget.files)==null?void 0:M[0])??null),C.currentTarget.value=""}}),l.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:v,onClick:()=>{var C;return(C=S.current)==null?void 0:C.click()},onDragEnter:C=>{C.preventDefault(),!v&&(k.current+=1,b(!0))},onDragOver:C=>{C.preventDefault(),v||(C.dataTransfer.dropEffect="copy")},onDragLeave:C=>{C.preventDefault(),k.current=Math.max(0,k.current-1),k.current===0&&b(!1)},onDrop:C=>{var M;C.preventDefault(),k.current=0,b(!1),v||A(((M=C.dataTransfer.files)==null?void 0:M[0])??null)},children:[l.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),l.jsx("span",{children:h?`${s3(h.size)} · 点击可重新选择`:r==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),l.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v?l.jsx(oi,{children:"正在上传文件并添加到知识库"}):null})]})}),l.jsxs("div",{className:"knowledge-dialog__fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称(可选)"}),l.jsx("input",{value:a,disabled:v,maxLength:256,onChange:C=>o(C.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"类型(可选)"}),l.jsx("input",{value:c,disabled:v,maxLength:64,onChange:C=>u(C.target.value),placeholder:r==="web"?"html":"pdf、docx、png"})]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Metadata(JSON)"}),l.jsx("textarea",{className:"is-code",value:y,disabled:v,onChange:C=>O(C.target.value),spellCheck:!1})]}),l.jsx(sA,{message:w})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:t,disabled:v,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:v||(r==="web"?!d.trim():!h),children:v?r==="web"?"添加中":"上传中":r==="web"?"添加网页":"上传文件"})]})]})})}function u4e({base:e,item:t,onClose:n,onUpdated:i}){const[r,s]=m.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,o]=m.useState(!1),[c,u]=m.useState(""),d=async f=>{f.preventDefault();let h;try{h=bse(r)}catch(p){u(qs(p,"Metadata 格式错误"));return}o(!0),u("");try{i(await H3e(e.id,t.id,e.region,{metadata:h}))}catch(p){u(qs(p,"更新知识失败"))}finally{o(!1)}};return l.jsx(P1,{title:"编辑知识 Metadata",onClose:n,busy:a,children:l.jsxs("form",{onSubmit:f=>void d(f),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"知识"}),l.jsx("input",{value:t.name||t.id,disabled:!0})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Metadata(JSON)"}),l.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:r,onChange:f=>s(f.target.value),spellCheck:!1})]}),l.jsx(sA,{message:c})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const Ose=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),yse=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),xse=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),d4e=new Set(["pdf"]),f4e=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),h4e=new Set(["creating","indexing","pending","processing","queued","submitted"]),p4e=new Set(["error","failed","unavailable"]);function C7(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Ew(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function m4e(e){if(Array.isArray(e)){if(e.length===0)return null;const i=e.map(C7);if(i.some(r=>Object.keys(r).length>0)){const r=[...new Set(i.flatMap(s=>Object.keys(s)))];return{columns:r,rows:i.map(s=>r.map(a=>Ew(s[a])))}}return{columns:["值"],rows:e.map(r=>[Ew(r)])}}const t=C7(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,i])=>Array.isArray(i))){const i=n.map(([s])=>s),r=Math.max(...n.map(([,s])=>s.length));return{columns:i,rows:Array.from({length:r},(s,a)=>n.map(([,o])=>Ew(o[a])))}}return{columns:["字段","值"],rows:n.map(([i,r])=>[i,Ew(r)])}}function vse(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function g4e(e){const t=vse(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function b4e(e){var r;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],i=n.includes(".")?((r=n.split(".").pop())==null?void 0:r.toLocaleLowerCase())??"":"";return Ose.has(i)?"image":yse.has(i)?"audio":xse.has(i)?"video":d4e.has(i)?"pdf":t||i?"file":"none"}function O4e(e){const t=e.status.trim().toLocaleLowerCase();if(h4e.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(p4e.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=gse(e).toLocaleLowerCase();return n==="pdf"||f4e.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:Ose.has(n)||yse.has(n)||xse.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function y4e({chunk:e}){const[t,n]=m.useState(!1),i=vse(e.attachmentUrl),r=b4e(e);return!i||r==="none"?null:t?l.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):r==="image"?l.jsx("img",{className:"knowledge-preview__image",src:i,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):r==="audio"?l.jsx("audio",{className:"knowledge-preview__audio",src:i,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):r==="video"?l.jsx("video",{className:"knowledge-preview__video",src:i,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):r==="pdf"?l.jsxs("div",{className:"knowledge-preview__pdf",children:[l.jsx("iframe",{src:i,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):l.jsxs("div",{className:"knowledge-preview__file-fallback",children:[l.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function x4e({base:e,item:t,onClose:n}){const[i,r]=m.useState([]),[s,a]=m.useState(t),[o,c]=m.useState(!0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(""),b=m.useRef(0),y=m.useRef(null),O=m.useCallback(async(w=0)=>{var k;(k=y.current)==null||k.abort();const E=new AbortController;y.current=E;const S=b.current+1;b.current=S,w>0?d(!0):c(!0),g(""),w===0&&(r([]),h(!1));try{const T=await V3e(e.id,t.id,{region:e.region,offset:w,signal:E.signal});if(b.current!==S)return;a(T.document.id?T.document:t),r(A=>w>0?[...A,...T.chunks]:T.chunks),h(T.hasMore)}catch(T){!nM(T)&&b.current===S&&g(qs(T,"加载数据预览失败"))}finally{b.current===S&&(c(!1),d(!1))}},[e.id,e.region,t]);m.useEffect(()=>(O(),()=>{var w;(w=y.current)==null||w.abort(),b.current+=1}),[O]);const v=g4e(s.url||t.url),x=O4e(s);return l.jsx(P1,{title:t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:l.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||v?l.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?l.jsx("span",{children:s3(s.sizeBytes)}):null,v?l.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,l.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o?l.jsx("div",{className:"knowledge-preview__state",role:"status",children:l.jsx(oi,{as:"span",duration:2.4,children:"正在加载数据预览"})}):p&&i.length===0?l.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[l.jsx("p",{children:p}),l.jsx("button",{type:"button",onClick:()=>void O(),children:"重试"})]}):i.length===0?l.jsxs("div",{className:"knowledge-preview__state",children:[l.jsx("p",{children:x.title}),l.jsx("span",{children:v?"您可以打开原网页查看来源内容。":x.detail}),l.jsx("button",{type:"button",onClick:()=>void O(),children:"重新加载"})]}):l.jsxs("div",{className:"knowledge-preview__chunks",children:[i.map((w,E)=>{const S=m4e(w.tableFields),k=w.id||`${E}:${w.title}`;return l.jsxs("article",{className:"knowledge-preview__chunk",children:[l.jsx("header",{children:l.jsx("h3",{children:w.title||`片段 ${E+1}`})}),w.content?l.jsx("p",{className:"knowledge-preview__content",children:w.content}):null,S?l.jsx("div",{className:"knowledge-preview__table-wrap",children:l.jsxs("table",{children:[l.jsx("thead",{children:l.jsx("tr",{children:S.columns.map((T,A)=>l.jsx("th",{scope:"col",children:T},`${T}:${A}`))})}),l.jsx("tbody",{children:S.rows.map((T,A)=>l.jsx("tr",{children:T.map((N,C)=>l.jsx("td",{children:N},C))},A))})]})}):null,l.jsx(y4e,{chunk:w})]},k)}),p?l.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:p}):null,f?l.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:u,onClick:()=>void O(i.length),children:u?l.jsx(oi,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function v4e({cloudProvider:e,active:t=!0,activationRevision:n=0}){const[i,r]=m.useState([]),[s,a]=m.useState({}),[o,c]=m.useState([]),[u,d]=m.useState(""),[f,h]=m.useState(""),[p,g]=m.useState(!0),[b,y]=m.useState(!1),[O,v]=m.useState(""),[x,w]=m.useState([]),[E,S]=m.useState(!1),[k,T]=m.useState(""),[A,N]=m.useState(""),[C,M]=m.useState(""),[L,P]=m.useState(!1),[Q,j]=m.useState(!1),[$,U]=m.useState(!1),[B,I]=m.useState(null),[X,q]=m.useState(null),[D,H]=m.useState(null),[re,fe]=m.useState(null),[Ae,J]=m.useState(null),[ie,ue]=m.useState(!1),ye=m.useRef(0),Se=m.useRef(0),Re=m.useRef([]),Ee=m.useRef(!1),me=m.useRef(!1),oe=m.useRef(null),Ne=m.useRef(null),Oe=m.useRef({}),Ve=m.useRef(!1),We=m.useRef(null),De=m.useRef(null),mt=m.useRef(null),at=m.useRef(null),Rt=m.useMemo(()=>v1(e).map(ge=>ge.value),[e]),qe=m.useCallback(ge=>`${ge.region}\0${ge.id}`,[]),W=i.find(ge=>qe(ge)===u)??null,K=!!(W&&C===qe(W)),ae=m.useMemo(()=>{const ge=f.trim().toLocaleLowerCase();return ge?i.filter(lt=>[lt.name,lt.description,lt.ownerLabel,lt.providerKnowledgeId].some(Ge=>Ge.toLocaleLowerCase().includes(ge))):i},[i,f]);m.useEffect(()=>{q(null)},[W==null?void 0:W.id,W==null?void 0:W.region]);const pe=m.useCallback(async(ge=!1)=>{var vt;if(ge&&(Ve.current||Object.keys(Oe.current).length===0))return;(vt=oe.current)==null||vt.abort();const lt=new AbortController;oe.current=lt;const Ge=ye.current+1;ye.current=Ge,Ve.current=!0,ge?y(!0):g(!0),v(""),ge||c([]);try{const _t=await Q3e({regions:Rt,nextTokens:ge?Oe.current:void 0,signal:lt.signal});if(ye.current!==Ge)return;r(je=>ge?[...je,..._t.items.filter(Ze=>!je.some(Ie=>qe(Ie)===qe(Ze)))]:_t.items),Oe.current=_t.nextTokens,a(_t.nextTokens);const Bt=_t.failures.map(({region:je,error:Ze})=>`${td(je,e)}:${qs(Ze,"加载失败")}`);c(je=>ge?[...new Set([...je,...Bt])]:Bt),ge||d(je=>_t.items.some(Ze=>qe(Ze)===je)?je:"")}catch(_t){if(nM(_t))return;ye.current===Ge&&(ge?c(Bt=>[...new Set([...Bt,qs(_t,"加载更多知识库失败")])]):v(qs(_t,"加载知识库失败")))}finally{ye.current===Ge&&(Ve.current=!1,g(!1),y(!1))}},[qe,e,Rt]),z=m.useCallback(async(ge,lt=!1)=>{var _t;if(lt&&Ee.current)return;(_t=Ne.current)==null||_t.abort();const Ge=new AbortController;Ne.current=Ge;const vt=Se.current+1;Se.current=vt,lt||(Re.current=[],me.current=!1,w([]),P(!1),N("")),Ee.current=!0,S(!0),lt?N(""):T("");try{const Bt=await F3e(ge.id,{region:ge.region,offset:lt?Re.current.length:0,signal:Ge.signal});if(Se.current!==vt)return;M(Wt=>Wt===qe(ge)?"":Wt);const je=Re.current,Ze=lt?[...je,...Bt.items.filter(Wt=>!Wt.id||!je.some(dn=>dn.id===Wt.id))]:Bt.items,Ie=Bt.hasMore&&(!lt||Ze.length>je.length);Re.current=Ze,me.current=Ie,w(Ze),P(Ie)}catch(Bt){if(nM(Bt))return;Se.current===vt&&(Bt instanceof rA&&Bt.errorCode===use&&(M(qe(ge)),I(Ze=>Ze&&qe(Ze)===qe(ge)?null:Ze)),lt?N(qs(Bt,"加载更多数据失败")):T(qs(Bt,"加载数据失败")))}finally{Se.current===vt&&(Ee.current=!1,S(!1))}},[qe]);m.useEffect(()=>{var ge;(ge=oe.current)==null||ge.abort(),ye.current+=1,Ve.current=!1,Oe.current={},r([]),a({}),c([]),d(""),M(""),v(""),g(!0)},[e]),m.useEffect(()=>{if(t)return pe(),()=>{var ge;(ge=oe.current)==null||ge.abort(),ye.current+=1,Ve.current=!1}},[t,n,pe]),m.useEffect(()=>{var ge,lt;if(!t){(ge=Ne.current)==null||ge.abort(),Se.current+=1,Ee.current=!1;return}if(!W){(lt=Ne.current)==null||lt.abort(),Se.current+=1,Re.current=[],Ee.current=!1,me.current=!1,w([]),P(!1),N("");return}return z(W),()=>{var Ge;(Ge=Ne.current)==null||Ge.abort(),Se.current+=1,Ee.current=!1}},[t,n,W==null?void 0:W.id,W==null?void 0:W.region]);const ve=t&&!W&&!f.trim()&&!p&&!b&&!O&&Object.keys(s).length>0;m.useEffect(()=>{const ge=De.current,lt=We.current;if(!ge||!lt||!ve)return;const Ge=new IntersectionObserver(([vt])=>{vt.isIntersecting&&pe(!0)},{root:lt,rootMargin:"240px 0px",threshold:.01});return Ge.observe(ge),()=>Ge.disconnect()},[ve,pe]);const Be=()=>{const ge=We.current;!ge||!ve||ge.scrollHeight-ge.scrollTop-ge.clientHeight<=240&&pe(!0)},Je=!!(W&&x.length>0&&L&&!E&&!A);m.useEffect(()=>{const ge=at.current,lt=mt.current;if(!W||!ge||!lt||!Je)return;const Ge=new IntersectionObserver(([vt])=>{vt.isIntersecting&&z(W,!0)},{root:mt.current,rootMargin:"240px 0px",threshold:.01});return Ge.observe(ge),()=>Ge.disconnect()},[Je,z,W==null?void 0:W.id,W==null?void 0:W.region]);const kt=()=>{const ge=mt.current;if(!W||!ge||!me.current||Ee.current||A)return;const{scrollHeight:lt,scrollTop:Ge,clientHeight:vt}=ge;lt-Ge-vt<=240&&z(W,!0)},Mt=ge=>{r(lt=>lt.map(Ge=>qe(Ge)===qe(ge)?ge:Ge))},Tt=async()=>{if(re){ue(!0);try{await z3e(re.id,re.region),r(ge=>ge.filter(lt=>qe(lt)!==qe(re))),M(ge=>ge===qe(re)?"":ge),u===qe(re)&&d(""),fe(null)}catch(ge){v(qs(ge,"删除知识库失败")),fe(null)}finally{ue(!1)}}},dt=async()=>{if(!(!W||!Ae)){ue(!0);try{await Y3e(W.id,Ae.id,W.region);const ge=Re.current.filter(lt=>lt.id!==Ae.id);Re.current=ge,w(ge),J(null)}catch(ge){T(qs(ge,"删除知识失败")),J(null)}finally{ue(!1)}}};return l.jsxs("section",{className:`knowledge-library${W?" is-detail":" my-agents-page"}`,"aria-label":"知识库",children:[W?l.jsxs("div",{className:"knowledge-library__detail",children:[l.jsxs("header",{className:"knowledge-detail-head",children:[l.jsxs("div",{className:"knowledge-detail-head__title",children:[l.jsx("button",{type:"button",className:"knowledge-back-button",onClick:()=>d(""),"aria-label":"返回知识库列表",children:l.jsx(e4e,{})}),l.jsxs("div",{children:[l.jsx("h2",{title:W.name,children:W.name}),l.jsx("p",{children:W.description||"暂无描述"})]})]}),W.canManage&&l.jsxs("div",{className:"knowledge-detail-head__actions",children:[l.jsx("button",{type:"button",onClick:()=>U(!0),children:"编辑"}),l.jsx("button",{type:"button",className:"is-danger",onClick:()=>fe(W),children:"删除"})]})]}),l.jsxs("dl",{className:"knowledge-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Provider"}),l.jsx("dd",{children:W.providerType||"-"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Knowledge ID"}),l.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:W.providerKnowledgeId,children:W.providerKnowledgeId||"-"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"项目"}),l.jsx("dd",{children:W.projectName||"default"})]}),W.ownerLabel&&l.jsxs("div",{children:[l.jsx("dt",{children:"创建者"}),l.jsx("dd",{children:W.ownerLabel})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"更新时间"}),l.jsx("dd",{children:t4e(W.updatedAt)||"-"})]})]}),l.jsxs("section",{className:"knowledge-documents",children:[l.jsxs("header",{className:"knowledge-documents__head",children:[l.jsx("h3",{children:"数据"}),W.canManage&&l.jsxs("button",{type:"button",className:"knowledge-primary-button",disabled:K,title:K?"底层 Provider 知识库已不存在":void 0,onClick:()=>I(W),children:[l.jsx(N7,{}),l.jsx("span",{children:K?"关联已失效":"添加数据"})]})]}),l.jsx("div",{className:`knowledge-documents__body${x.length>0?" is-table":""}`,"aria-live":"polite",children:E&&x.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载数据"})]}):k&&x.length===0?l.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[l.jsx("p",{children:k}),K&&W.canManage?l.jsx("button",{type:"button",onClick:()=>fe(W),children:"删除失效关联"}):l.jsx("button",{type:"button",onClick:()=>void z(W),children:"重试"})]}):x.length===0?l.jsxs("div",{className:"knowledge-library__state",children:[l.jsx(Z3e,{}),l.jsx("p",{children:"这个知识库还没有数据"}),W.canManage&&l.jsx("button",{type:"button",onClick:()=>I(W),children:"添加第一项数据"})]}):l.jsxs("div",{ref:mt,className:"knowledge-document-table-wrap","aria-busy":E||void 0,onScroll:kt,children:[l.jsxs("table",{className:"knowledge-document-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"名称"}),l.jsx("th",{scope:"col",children:"格式"}),l.jsx("th",{scope:"col",children:"大小"}),l.jsx("th",{scope:"col",className:"knowledge-document-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:x.map(ge=>l.jsxs("tr",{children:[l.jsx("td",{className:"knowledge-document-table__name",title:ge.name||ge.id,children:ge.name||ge.id}),l.jsx("td",{children:gse(ge)}),l.jsx("td",{children:s3(ge.sizeBytes)}),l.jsx("td",{children:l.jsxs("div",{className:"knowledge-document-table__actions",children:[l.jsx(sp,{content:"预览",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"secondary",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`预览 ${ge.name||ge.id}`,onClick:()=>q(ge),children:l.jsx(Rwe,{"aria-hidden":"true"})})}),W.canManage?l.jsxs(l.Fragment,{children:[l.jsx(sp,{content:"编辑",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"secondary",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`编辑 ${ge.name||ge.id}`,onClick:()=>H(ge),children:l.jsx(Cwe,{"aria-hidden":"true"})})}),l.jsx(sp,{content:"删除",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"danger",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`删除 ${ge.name||ge.id}`,onClick:()=>J(ge),children:l.jsx(Nwe,{"aria-hidden":"true"})})})]}):null]})})]},ge.id))})]}),E?l.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多数据"})]}):A?l.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[l.jsx("span",{children:A}),l.jsx("button",{type:"button",onClick:()=>void z(W,!0),children:"重试加载"})]}):L?l.jsx("div",{ref:at,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null]})})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"knowledge-library__toolbar my-agent-type-bar library-resource-toolbar",children:[l.jsx("div",{className:"knowledge-library__toolbar-actions library-resource-toolbar__controls",children:l.jsxs("button",{type:"button",className:"my-agent-create-primary",onClick:()=>j(!0),children:[l.jsx(N7,{}),l.jsx("span",{children:"新建知识库"})]})}),l.jsxs("label",{className:"knowledge-library__search my-agent-search",children:[l.jsx(K3e,{}),l.jsx("input",{type:"search",value:f,onChange:ge=>h(ge.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),l.jsxs("div",{ref:We,className:"knowledge-library__results my-agent-results","aria-live":"polite",onScroll:Be,children:[o.length>0&&!p&&l.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[l.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),l.jsx("button",{type:"button",onClick:()=>void pe(),children:"重试"})]}),p&&i.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载知识库"})]}):O?l.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[l.jsx("p",{children:O}),l.jsx("button",{type:"button",onClick:()=>void pe(),children:"重试"})]}):ae.length===0?l.jsxs("div",{className:"knowledge-library__state",children:[l.jsx(W3e,{}),l.jsx("p",{children:f.trim()?"没有匹配的知识库":"您还没有任何知识库"})]}):l.jsx("div",{className:"knowledge-library__grid my-agent-grid",children:ae.map(ge=>l.jsx(hse,{className:"knowledge-card",title:ge.name,status:l.jsx("span",{className:`knowledge-status is-${ge.status.toLowerCase()}`,children:n4e(ge.status)}),description:ge.description||"暂无描述",metadata:[{label:"创建者",value:ge.ownerLabel||"—",title:ge.ownerLabel||"—"},{label:"项目",value:ge.projectName||"default",title:ge.projectName||"default"}],secondaryAction:{label:C===qe(ge)?"关联已失效":"添加数据",disabled:!ge.canManage||C===qe(ge),title:ge.canManage?C===qe(ge)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>I(ge)},primaryAction:{label:"查看详情",onClick:()=>d(qe(ge))},menuLabel:`更多知识库操作:${ge.name}`,menuAriaLabel:`${ge.name}知识库操作`,menuActions:[{label:"编辑知识库",disabled:!ge.canManage,title:ge.canManage?void 0:"您没有管理此知识库的权限",onClick:()=>{d(qe(ge)),U(!0)}},{label:"删除知识库",danger:!0,disabled:!ge.canManage||ie,title:ge.canManage?void 0:"您没有管理此知识库的权限",onClick:()=>fe(ge)}]},qe(ge)))}),ve||b?l.jsx("div",{ref:De,className:"my-agent-load-more",role:"status","aria-live":"polite",children:b?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多知识库"})]}):ve?l.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),Q&&l.jsx(o4e,{onClose:()=>j(!1),onCreated:ge=>{r(lt=>[ge,...lt]),d(qe(ge)),j(!1)}}),W&&$&&l.jsx(l4e,{item:W,onClose:()=>U(!1),onUpdated:ge=>{Mt(ge),U(!1)}}),W&&X&&l.jsx(x4e,{base:W,item:X,onClose:()=>q(null)}),B&&l.jsx(c4e,{base:B,onClose:()=>I(null),onAssociationInvalid:ge=>{M(qe(B)),W&&qe(W)===qe(B)&&T(qs(ge,"知识库关联已失效")),I(null)},onCreated:()=>{W&&qe(W)===qe(B)&&z(W),I(null)}}),W&&D&&l.jsx(u4e,{base:W,item:D,onClose:()=>H(null),onUpdated:ge=>{const lt=Re.current.map(Ge=>Ge.id===ge.id?ge:Ge);Re.current=lt,w(lt),H(null)}}),re&&l.jsx(Mf,{title:"删除知识库?",description:`将删除 ${re.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:ie?"删除中":"删除",variant:"danger",busy:ie,onCancel:()=>fe(null),onConfirm:()=>void Tt()}),Ae&&l.jsx(Mf,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${Ae.name||Ae.id},此操作无法撤销。`,confirmLabel:ie?"删除中":"删除",variant:"danger",busy:ie,onCancel:()=>J(null),onConfirm:()=>void dt()})]})}const w4e="_EmptyMessage_1r5gu_1",S4e="_IconBadge_1r5gu_16",E4e="_Title_1r5gu_54",k4e="_Description_1r5gu_69",T4e="_ActionRow_1r5gu_77",M1={EmptyMessage:w4e,IconBadge:S4e,Title:E4e,Description:k4e,ActionRow:T4e},Oi=({children:e,className:t,fill:n="static"})=>l.jsx("div",{className:Ps(M1.EmptyMessage,t),"data-fill":n,children:e}),_4e=({size:e="md",color:t="secondary",children:n,className:i})=>l.jsx("div",{className:Ps(M1.IconBadge,i),"data-size":e,"data-color":t,children:n}),A4e=({children:e,className:t,color:n="secondary"})=>l.jsx("div",{className:Ps(M1.Title,t),"data-color":n,children:e}),N4e=({children:e,className:t})=>l.jsx("div",{className:Ps(M1.Description,t),children:e}),C4e=({children:e,className:t})=>l.jsx("div",{className:Ps(M1.ActionRow,t),children:e});Oi.Icon=_4e;Oi.Title=A4e;Oi.Description=N4e;Oi.ActionRow=C4e;const j4e="/web/skill-workbench";class rM extends Error{constructor(t,n,i="SKILL_WORKBENCH_ERROR",r=!1,s="",a,o=""){super(t),this.status=n,this.code=i,this.retryable=r,this.statusText=s,this.originalError=a,this.rawResponse=o,this.name="SkillWorkbenchApiError"}}function nl(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function j7(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function R4e(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function Fc(e,t={},n=_o){return fetch(vo(`${j4e}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function a3(e,t){var i;const n=await e.text().catch(()=>"");try{const r=nl(JSON.parse(n),"错误响应"),s=r.detail&&typeof r.detail=="object"?nl(r.detail,"错误详情"):r;return new rM(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失";return new rM(`${t}(HTTP ${e.status},Content-Type: ${r})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Uf(e,t){if(!e.ok)throw await a3(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const i=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${i}),请检查代理或网关配置。`)}return e.json()}function I4e(e){return Array.isArray(e)?e.map(t=>{const n=nl(t,"Skill 会话活动"),i=n.kind,r=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(i))||!["running","done"].includes(String(r)))throw new Error("Skill 会话活动格式错误。");if(i==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:i,status:r,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:i,status:r,text:n.text}}):[]}function P4e(e){if(e==null)return;const t=nl(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!BD(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function vx(e){const t=nl(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(o=>{const c=nl(o,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const r=j7(t.toolId,"Tool ID"),s=j7(t.sessionId,"Session ID"),a=R4e(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...r?{toolId:r}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:I4e(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:P4e(t.publication)}:{}}}async function aA(e){const t=nl(await Uf(await Fc("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const i=n;return typeof i.id=="string"&&typeof i.label=="string"?[{id:i.id,label:i.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function M4e(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const i=await Fc(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},kr);return vx(await Uf(i,"开始优化 Skill 失败"))}const t=await Fc("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},kr);return vx(await Uf(t,"开始 Skill 会话失败"))}async function L4e(e,t){return vx(await Uf(await Fc(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function vC(e,t,n){const i=new URLSearchParams;i.set("expected_revision",String(t));const r=nl(await Uf(await Fc(`/tasks/${encodeURIComponent(e)}/artifact?${i.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(r.jobId!==e||r.revision!==t||!Number.isSafeInteger(r.revision)||r.revision<1||typeof r.sha256!="string"||!/^[0-9a-f]{64}$/.test(r.sha256)||typeof r.name!="string"||typeof r.description!="string"||!Array.isArray(r.files))throw new Error("Skill 产物格式错误。");const s=r.files.map(a=>{const o=nl(a,"Skill 产物文件");if(typeof o.path!="string"||typeof o.size!="number"||typeof o.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:o.path,size:o.size,content:o.content}});return{jobId:r.jobId,revision:r.revision,sha256:r.sha256,name:r.name,description:r.description,files:s}}async function wC(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},kr);return vx(await Uf(t,"继续调整 Skill 失败"))}async function D4e(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return vx(await Uf(t,"停止当前 Skill 任务失败"))}async function $4e(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await a3(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const i=new Set(["preparing","uploading","registering","activating","publishing"]);let r=null,s="";const a=new TextDecoder,o=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=nl(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!i.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const p=nl(d.error,"发布错误");throw new rM(typeof p.message=="string"?p.message:"发布 Skill 失败",500,typeof p.code=="string"?p.code:"SKILL_PUBLISH_FAILED",p.retryable===!0,"",p.originalError&&typeof p.originalError=="object"?p.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=nl(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(p=>typeof p=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!BD(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");r={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await o.read();s+=a.decode(u,{stream:!d});const f=s.split(` -`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!r)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return r}async function Q4e(e){await Uf(await Fc(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function B4e(e,t,n){var c;const i=new URLSearchParams;i.set("expected_revision",String(t)),i.set("expected_sha256",n);const r=await Fc(`/tasks/${encodeURIComponent(e)}/download?${i.toString()}`,{},kr);if(!r.ok)throw await a3(r,"下载 Skill 失败");const a=((c=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",o=URL.createObjectURL(await r.blob());try{const u=document.createElement("a");u.href=o,u.download=a,u.click()}finally{URL.revokeObjectURL(o)}}const U4e={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function z4e(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(const r of n){if(i==null||typeof i!="object")return;i=i[r]}return i}function F4e(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function V4e(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function o3(e,t){if(F4e(e))return z4e(t,e.path);if(V4e(e)){const n=U4e[e.call],i={};for(const[r,s]of Object.entries(e.args??{}))i[r]=o3(s,t);return n?n(i):`[unknown fn: ${e.call}]`}return e}function X4e(e,t){const n=o3(e,t);return n==null?"":typeof n=="string"?n:String(n)}const wse=new Map;function Up(e,t){wse.set(e,t)}function q4e(e){return wse.get(e)}function H4e(e,t,n){const i=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(let s=0;so3(i,e.dataModel),resolveString:i=>X4e(i,e.dataModel),dispatchAction:t,render:i=>{if(!i)return null;const r=e.components[i];if(!r)return null;const s=q4e(r.component)??Y4e;return l.jsx(s,{node:r,ctx:n},i)}};return l.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function Ese(e){const t=m.useRef(null),n=m.useRef(!0),i=28,r=m.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:r}}function _Ot(){}function R7(e){const t=[],n=String(e||"");let i=n.indexOf(","),r=0,s=!1;for(;!s;){i===-1&&(i=n.length,s=!0);const a=n.slice(r,i).trim();(a||!s)&&t.push(a),r=i+1,i=n.indexOf(",",r)}return t}function kse(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const W4e=/[$_\p{ID_Start}]/u,Z4e=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,K4e=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,J4e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eQe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tse={};function AOt(e){return e?W4e.test(String.fromCodePoint(e)):!1}function NOt(e,t){const i=(t||Tse).jsx?K4e:Z4e;return e?i.test(String.fromCodePoint(e)):!1}function I7(e,t){return(Tse.jsx?eQe:J4e).test(e)}const tQe=/[ \t\n\f\r]/g;function nQe(e){return typeof e=="object"?e.type==="text"?P7(e.value):!1:P7(e)}function P7(e){return e.replace(tQe,"")===""}let L1=class{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}};L1.prototype.normal={};L1.prototype.property={};L1.prototype.space=void 0;function _se(e,t){const n={},i={};for(const r of e)Object.assign(n,r.property),Object.assign(i,r.normal);return new L1(n,i,t)}function wx(e){return e.toLowerCase()}class Ha{constructor(t,n){this.attribute=n,this.property=t}}Ha.prototype.attribute="";Ha.prototype.booleanish=!1;Ha.prototype.boolean=!1;Ha.prototype.commaOrSpaceSeparated=!1;Ha.prototype.commaSeparated=!1;Ha.prototype.defined=!1;Ha.prototype.mustUseProperty=!1;Ha.prototype.number=!1;Ha.prototype.overloadedBoolean=!1;Ha.prototype.property="";Ha.prototype.spaceSeparated=!1;Ha.prototype.space=void 0;let iQe=0;const pn=zp(),Br=zp(),sM=zp(),rt=zp(),$i=zp(),Eg=zp(),io=zp();function zp(){return 2**++iQe}const aM=Object.freeze(Object.defineProperty({__proto__:null,boolean:pn,booleanish:Br,commaOrSpaceSeparated:io,commaSeparated:Eg,number:rt,overloadedBoolean:sM,spaceSeparated:$i},Symbol.toStringTag,{value:"Module"})),SC=Object.keys(aM);class l3 extends Ha{constructor(t,n,i,r){let s=-1;if(super(t,n),M7(this,"space",r),typeof i=="number")for(;++s4&&n.slice(0,4)==="data"&&lQe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(L7,uQe);i="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!L7.test(s)){let a=s.replace(oQe,cQe);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}r=l3}return new r(i,t)}function cQe(e){return"-"+e.toLowerCase()}function uQe(e){return e.charAt(1).toUpperCase()}const D1=_se([Ase,rQe,jse,Rse,Ise],"html"),nh=_se([Ase,sQe,jse,Rse,Ise],"svg");function D7(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Pse(e){return e.join(" ").trim()}var c3={},$7=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,dQe=/\n/g,fQe=/^\s*/,hQe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,pQe=/^:\s*/,mQe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,gQe=/^[;\s]*/,bQe=/^\s+|\s+$/g,OQe=` -`,Q7="/",B7="*",Rh="",yQe="comment",xQe="declaration";function vQe(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,i=1;function r(g){var b=g.match(dQe);b&&(n+=b.length);var y=g.lastIndexOf(OQe);i=~y?g.length-y:i+g.length}function s(){var g={line:n,column:i};return function(b){return b.position=new a(g),u(),b}}function a(g){this.start=g,this.end={line:n,column:i},this.source=t.source}a.prototype.content=e;function o(g){var b=new Error(t.source+":"+n+":"+i+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=i,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var y=b[0];return r(y),e=e.slice(y.length),b}}function u(){c(fQe)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=s();if(!(Q7!=e.charAt(0)||B7!=e.charAt(1))){for(var b=2;Rh!=e.charAt(b)&&(B7!=e.charAt(b)||Q7!=e.charAt(b+1));)++b;if(b+=2,Rh===e.charAt(b-1))return o("End of comment missing");var y=e.slice(2,b-2);return i+=2,r(y),e=e.slice(b),i+=2,g({type:yQe,comment:y})}}function h(){var g=s(),b=c(hQe);if(b){if(f(),!c(pQe))return o("property missing ':'");var y=c(mQe),O=g({type:xQe,property:U7(b[0].replace($7,Rh)),value:y?U7(y[0].replace($7,Rh)):Rh});return c(gQe),O}}function p(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),p()}function U7(e){return e?e.replace(bQe,Rh):Rh}var wQe=vQe,SQe=tf&&tf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(c3,"__esModule",{value:!0});c3.default=kQe;const EQe=SQe(wQe);function kQe(e,t){let n=null;if(!e||typeof e!="string")return n;const i=(0,EQe.default)(e),r=typeof t=="function";return i.forEach(s=>{if(s.type!=="declaration")return;const{property:a,value:o}=s;r?t(a,o,s):o&&(n=n||{},n[a]=o)}),n}var lA={};Object.defineProperty(lA,"__esModule",{value:!0});lA.camelCase=void 0;var TQe=/^--[a-zA-Z0-9_-]+$/,_Qe=/-([a-z])/g,AQe=/^[^-]+$/,NQe=/^-(webkit|moz|ms|o|khtml)-/,CQe=/^-(ms)-/,jQe=function(e){return!e||AQe.test(e)||TQe.test(e)},RQe=function(e,t){return t.toUpperCase()},z7=function(e,t){return"".concat(t,"-")},IQe=function(e,t){return t===void 0&&(t={}),jQe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(CQe,z7):e=e.replace(NQe,z7),e.replace(_Qe,RQe))};lA.camelCase=IQe;var PQe=tf&&tf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},MQe=PQe(c3),LQe=lA;function oM(e,t){var n={};return!e||typeof e!="string"||(0,MQe.default)(e,function(i,r){i&&r&&(n[(0,LQe.camelCase)(i,t)]=r)}),n}oM.default=oM;var DQe=oM;const $Qe=N0(DQe),cA=Mse("end"),Wc=Mse("start");function Mse(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function QQe(e){const t=Wc(e),n=cA(e);if(t&&n)return{start:t,end:n}}function fy(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?F7(e.position):"start"in e||"end"in e?F7(e):"line"in e||"column"in e?lM(e):""}function lM(e){return V7(e&&e.line)+":"+V7(e&&e.column)}function F7(e){return lM(e&&e.start)+"-"+lM(e&&e.end)}function V7(e){return e&&typeof e=="number"?e:1}class Js extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let r="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=!0,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof i=="string"){const c=i.indexOf(":");c===-1?s.ruleId=i:(s.source=i.slice(0,c),s.ruleId=i.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=fy(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Js.prototype.file="";Js.prototype.name="";Js.prototype.reason="";Js.prototype.message="";Js.prototype.stack="";Js.prototype.column=void 0;Js.prototype.line=void 0;Js.prototype.ancestors=void 0;Js.prototype.cause=void 0;Js.prototype.fatal=void 0;Js.prototype.place=void 0;Js.prototype.ruleId=void 0;Js.prototype.source=void 0;const u3={}.hasOwnProperty,BQe=new Map,UQe=/[A-Z]/g,zQe=new Set(["table","tbody","thead","tfoot","tr"]),FQe=new Set(["td","th"]),Lse="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function VQe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=KQe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=ZQe(n,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?nh:D1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Dse(r,e,void 0);return s&&typeof s!="string"?s:r.create(e,r.Fragment,{children:s||void 0},void 0)}function Dse(e,t,n){if(t.type==="element")return XQe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qQe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return YQe(e,t,n);if(t.type==="mdxjsEsm")return HQe(e,t);if(t.type==="root")return GQe(e,t,n);if(t.type==="text")return WQe(e,t)}function XQe(e,t,n){const i=e.schema;let r=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(r=nh,e.schema=r),e.ancestors.push(t);const s=Qse(e,t.tagName,!1),a=JQe(e,t);let o=f3(e,t);return zQe.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!nQe(c):!0})),$se(e,a,s,t),d3(a,o),e.ancestors.pop(),e.schema=i,e.create(t,s,a,n)}function qQe(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Sx(e,t.position)}function HQe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sx(e,t.position)}function YQe(e,t,n){const i=e.schema;let r=i;t.name==="svg"&&i.space==="html"&&(r=nh,e.schema=r),e.ancestors.push(t);const s=t.name===null?e.Fragment:Qse(e,t.name,!0),a=e6e(e,t),o=f3(e,t);return $se(e,a,s,t),d3(a,o),e.ancestors.pop(),e.schema=i,e.create(t,s,a,n)}function GQe(e,t,n){const i={};return d3(i,f3(e,t)),e.create(t,e.Fragment,i,n)}function WQe(e,t){return t.value}function $se(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function d3(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ZQe(e,t,n){return i;function i(r,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function KQe(e,t){return n;function n(i,r,s,a){const o=Array.isArray(s.children),c=Wc(i);return t(r,s,a,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function JQe(e,t){const n={};let i,r;for(r in t.properties)if(r!=="children"&&u3.call(t.properties,r)){const s=t6e(e,r,t.properties[r]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&FQe.has(t.tagName)?i=o:n[a]=o}}if(i){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function e6e(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const s=i.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Sx(e,t.position);else{const r=i.name;let s;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const o=i.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else Sx(e,t.position);else s=i.value===null?!0:i.value;n[r]=s}return n}function f3(e,t){const n=[];let i=-1;const r=e.passKeys?new Map:BQe;for(;++ir?0:r+t:t=t>r?r:t,n=n>0?n:0,i.length<1e4)a=Array.from(i),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s0?(wo(e,e.length,0,t),e):t}const H7={}.hasOwnProperty;function Use(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ml(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pa=ih(/[A-Za-z]/),Ws=ih(/[\dA-Za-z]/),u6e=ih(/[#-'*+\--9=?A-Z^-~]/);function Bk(e){return e!==null&&(e<32||e===127)}const cM=ih(/\d/),d6e=ih(/[\dA-Fa-f]/),f6e=ih(/[!-/:-@[-`{-~]/);function Ht(e){return e!==null&&e<-2}function Li(e){return e!==null&&(e<0||e===32)}function Rn(e){return e===-2||e===-1||e===32}const uA=ih(new RegExp("\\p{P}|\\p{S}","u")),Sp=ih(/\s/);function ih(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function nb(e){const t=[];let n=-1,i=0,r=0;for(;++n55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),r=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(i,n),encodeURIComponent(a)),i=n+r+1,a=""),r&&(n+=r,r=0)}return t.join("")+e.slice(i)}function Yn(e,t,n,i){const r=i?i-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(c){return Rn(c)?(e.enter(n),o(c)):t(c)}function o(c){return Rn(c)&&s++a))return;const k=t.events.length;let T=k,A,N;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(A){N=t.events[T][1].end;break}A=!0}for(O(i),S=k;Sx;){const E=n[w];t.containerState=E[1],E[0].exit.call(t,e)}n.length=x}function v(){r.write([null]),s=void 0,r=void 0,t.containerState._closeFlow=void 0}}function b6e(e,t,n){return Yn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function f0(e){if(e===null||Li(e)||Sp(e))return 1;if(uA(e))return 2}function dA(e,t,n){const i=[];let r=-1;for(;++r1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[i][1].end},h={...e[n][1].start};G7(f,-c),G7(h,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[i][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},r={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[i][1].end={...a.start},e[n][1].start={...o.end},u=[],e[i][1].end.offset-e[i][1].start.offset&&(u=Bo(u,[["enter",e[i][1],t],["exit",e[i][1],t]])),u=Bo(u,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Bo(u,dA(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),u=Bo(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Bo(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,wo(e,i-1,n-i+3,u),n=i+u.length-d-2;break}}for(n=-1;++n0&&Rn(S)?Yn(e,v,"linePrefix",s+1)(S):v(S)}function v(S){return S===null||Ht(S)?e.check(W7,b,w)(S):(e.enter("codeFlowValue"),x(S))}function x(S){return S===null||Ht(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),x)}function w(S){return e.exit("codeFenced"),t(S)}function E(S,k,T){let A=0;return N;function N(Q){return S.enter("lineEnding"),S.consume(Q),S.exit("lineEnding"),C}function C(Q){return S.enter("codeFencedFence"),Rn(Q)?Yn(S,M,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):M(Q)}function M(Q){return Q===o?(S.enter("codeFencedFenceSequence"),L(Q)):T(Q)}function L(Q){return Q===o?(A++,S.consume(Q),L):A>=a?(S.exit("codeFencedFenceSequence"),Rn(Q)?Yn(S,P,"whitespace")(Q):P(Q)):T(Q)}function P(Q){return Q===null||Ht(Q)?(S.exit("codeFencedFence"),k(Q)):T(Q)}}}function N6e(e,t,n){const i=this;return r;function r(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return i.parser.lazy[i.now().line]?n(a):t(a)}}const kC={name:"codeIndented",tokenize:j6e},C6e={partial:!0,tokenize:R6e};function j6e(e,t,n){const i=this;return r;function r(u){return e.enter("codeIndented"),Yn(e,s,"linePrefix",5)(u)}function s(u){const d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):Ht(u)?e.attempt(C6e,a,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ht(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function R6e(e,t,n){const i=this;return r;function r(a){return i.parser.lazy[i.now().line]?n(a):Ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r):Yn(e,s,"linePrefix",5)(a)}function s(a){const o=i.events[i.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):Ht(a)?r(a):n(a)}}const I6e={name:"codeText",previous:M6e,resolve:P6e,tokenize:L6e};function P6e(e){let t=e.length-4,n=3,i,r;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const r=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return i&&Kb(this.left,i),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Kb(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Kb(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(a):e.interrupt(i.parser.constructs.flow,n,t)(a)}}function Hse(e,t,n,i,r,s,a,o,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(O){return O===60?(e.enter(i),e.enter(r),e.enter(s),e.consume(O),e.exit(s),h):O===null||O===32||O===41||Bk(O)?n(O):(e.enter(i),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(O))}function h(O){return O===62?(e.enter(s),e.consume(O),e.exit(s),e.exit(r),e.exit(i),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(O))}function p(O){return O===62?(e.exit("chunkString"),e.exit(o),h(O)):O===null||O===60||Ht(O)?n(O):(e.consume(O),O===92?g:p)}function g(O){return O===60||O===62||O===92?(e.consume(O),p):p(O)}function b(O){return!d&&(O===null||O===41||Li(O))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(i),t(O)):d999||p===null||p===91||p===93&&!c||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(r),e.consume(p),e.exit(r),e.exit(i),t):Ht(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Ht(p)||o++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!Rn(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function Gse(e,t,n,i,r,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(i),e.enter(r),e.consume(h),e.exit(r),a=h===40?41:h,c):n(h)}function c(h){return h===a?(e.enter(r),e.consume(h),e.exit(r),e.exit(i),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),c(a)):h===null?n(h):Ht(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Yn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||Ht(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function hy(e,t){let n;return i;function i(r){return Ht(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,i):Rn(r)?Yn(e,i,n?"linePrefix":"lineSuffix")(r):t(r)}}const V6e={name:"definition",tokenize:q6e},X6e={partial:!0,tokenize:H6e};function q6e(e,t,n){const i=this;let r;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return Yse.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return r=Ml(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return Li(p)?hy(e,u)(p):u(p)}function u(p){return Hse(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(X6e,f,f)(p)}function f(p){return Rn(p)?Yn(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Ht(p)?(e.exit("definition"),i.parser.defined.push(r),t(p)):n(p)}}function H6e(e,t,n){return i;function i(o){return Li(o)?hy(e,r)(o):n(o)}function r(o){return Gse(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Rn(o)?Yn(e,a,"whitespace")(o):a(o)}function a(o){return o===null||Ht(o)?t(o):n(o)}}const Y6e={name:"hardBreakEscape",tokenize:G6e};function G6e(e,t,n){return i;function i(s){return e.enter("hardBreakEscape"),e.consume(s),r}function r(s){return Ht(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const W6e={name:"headingAtx",resolve:Z6e,tokenize:K6e};function Z6e(e,t){let n=e.length-2,i=3,r,s;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(r={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},s={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},wo(e,i,n-i+1,[["enter",r,t],["enter",s,t],["exit",s,t],["exit",r,t]])),e}function K6e(e,t,n){let i=0;return r;function r(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&i++<6?(e.consume(d),a):d===null||Li(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||Ht(d)?(e.exit("atxHeading"),t(d)):Rn(d)?Yn(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||Li(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const J6e=["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"],K7=["pre","script","style","textarea"],eBe={concrete:!0,name:"htmlFlow",resolveTo:iBe,tokenize:rBe},tBe={partial:!0,tokenize:aBe},nBe={partial:!0,tokenize:sBe};function iBe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function rBe(e,t,n){const i=this;let r,s,a,o,c;return u;function u(D){return d(D)}function d(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),f}function f(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),s=!0,b):D===63?(e.consume(D),r=3,i.interrupt?t:I):pa(D)?(e.consume(D),a=String.fromCharCode(D),y):n(D)}function h(D){return D===45?(e.consume(D),r=2,p):D===91?(e.consume(D),r=5,o=0,g):pa(D)?(e.consume(D),r=4,i.interrupt?t:I):n(D)}function p(D){return D===45?(e.consume(D),i.interrupt?t:I):n(D)}function g(D){const H="CDATA[";return D===H.charCodeAt(o++)?(e.consume(D),o===H.length?i.interrupt?t:M:g):n(D)}function b(D){return pa(D)?(e.consume(D),a=String.fromCharCode(D),y):n(D)}function y(D){if(D===null||D===47||D===62||Li(D)){const H=D===47,re=a.toLowerCase();return!H&&!s&&K7.includes(re)?(r=1,i.interrupt?t(D):M(D)):J6e.includes(a.toLowerCase())?(r=6,H?(e.consume(D),O):i.interrupt?t(D):M(D)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(D):s?v(D):x(D))}return D===45||Ws(D)?(e.consume(D),a+=String.fromCharCode(D),y):n(D)}function O(D){return D===62?(e.consume(D),i.interrupt?t:M):n(D)}function v(D){return Rn(D)?(e.consume(D),v):N(D)}function x(D){return D===47?(e.consume(D),N):D===58||D===95||pa(D)?(e.consume(D),w):Rn(D)?(e.consume(D),x):N(D)}function w(D){return D===45||D===46||D===58||D===95||Ws(D)?(e.consume(D),w):E(D)}function E(D){return D===61?(e.consume(D),S):Rn(D)?(e.consume(D),E):x(D)}function S(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),c=D,k):Rn(D)?(e.consume(D),S):T(D)}function k(D){return D===c?(e.consume(D),c=null,A):D===null||Ht(D)?n(D):(e.consume(D),k)}function T(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||Li(D)?E(D):(e.consume(D),T)}function A(D){return D===47||D===62||Rn(D)?x(D):n(D)}function N(D){return D===62?(e.consume(D),C):n(D)}function C(D){return D===null||Ht(D)?M(D):Rn(D)?(e.consume(D),C):n(D)}function M(D){return D===45&&r===2?(e.consume(D),j):D===60&&r===1?(e.consume(D),$):D===62&&r===4?(e.consume(D),X):D===63&&r===3?(e.consume(D),I):D===93&&r===5?(e.consume(D),B):Ht(D)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(tBe,q,L)(D)):D===null||Ht(D)?(e.exit("htmlFlowData"),L(D)):(e.consume(D),M)}function L(D){return e.check(nBe,P,q)(D)}function P(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return D===null||Ht(D)?L(D):(e.enter("htmlFlowData"),M(D))}function j(D){return D===45?(e.consume(D),I):M(D)}function $(D){return D===47?(e.consume(D),a="",U):M(D)}function U(D){if(D===62){const H=a.toLowerCase();return K7.includes(H)?(e.consume(D),X):M(D)}return pa(D)&&a.length<8?(e.consume(D),a+=String.fromCharCode(D),U):M(D)}function B(D){return D===93?(e.consume(D),I):M(D)}function I(D){return D===62?(e.consume(D),X):D===45&&r===2?(e.consume(D),I):M(D)}function X(D){return D===null||Ht(D)?(e.exit("htmlFlowData"),q(D)):(e.consume(D),X)}function q(D){return e.exit("htmlFlow"),t(D)}}function sBe(e,t,n){const i=this;return r;function r(a){return Ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return i.parser.lazy[i.now().line]?n(a):t(a)}}function aBe(e,t,n){return i;function i(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt($1,t,n)}}const oBe={name:"htmlText",tokenize:lBe};function lBe(e,t,n){const i=this;let r,s,a;return o;function o(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),c}function c(I){return I===33?(e.consume(I),u):I===47?(e.consume(I),E):I===63?(e.consume(I),x):pa(I)?(e.consume(I),T):n(I)}function u(I){return I===45?(e.consume(I),d):I===91?(e.consume(I),s=0,g):pa(I)?(e.consume(I),v):n(I)}function d(I){return I===45?(e.consume(I),p):n(I)}function f(I){return I===null?n(I):I===45?(e.consume(I),h):Ht(I)?(a=f,$(I)):(e.consume(I),f)}function h(I){return I===45?(e.consume(I),p):f(I)}function p(I){return I===62?j(I):I===45?h(I):f(I)}function g(I){const X="CDATA[";return I===X.charCodeAt(s++)?(e.consume(I),s===X.length?b:g):n(I)}function b(I){return I===null?n(I):I===93?(e.consume(I),y):Ht(I)?(a=b,$(I)):(e.consume(I),b)}function y(I){return I===93?(e.consume(I),O):b(I)}function O(I){return I===62?j(I):I===93?(e.consume(I),O):b(I)}function v(I){return I===null||I===62?j(I):Ht(I)?(a=v,$(I)):(e.consume(I),v)}function x(I){return I===null?n(I):I===63?(e.consume(I),w):Ht(I)?(a=x,$(I)):(e.consume(I),x)}function w(I){return I===62?j(I):x(I)}function E(I){return pa(I)?(e.consume(I),S):n(I)}function S(I){return I===45||Ws(I)?(e.consume(I),S):k(I)}function k(I){return Ht(I)?(a=k,$(I)):Rn(I)?(e.consume(I),k):j(I)}function T(I){return I===45||Ws(I)?(e.consume(I),T):I===47||I===62||Li(I)?A(I):n(I)}function A(I){return I===47?(e.consume(I),j):I===58||I===95||pa(I)?(e.consume(I),N):Ht(I)?(a=A,$(I)):Rn(I)?(e.consume(I),A):j(I)}function N(I){return I===45||I===46||I===58||I===95||Ws(I)?(e.consume(I),N):C(I)}function C(I){return I===61?(e.consume(I),M):Ht(I)?(a=C,$(I)):Rn(I)?(e.consume(I),C):A(I)}function M(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),r=I,L):Ht(I)?(a=M,$(I)):Rn(I)?(e.consume(I),M):(e.consume(I),P)}function L(I){return I===r?(e.consume(I),r=void 0,Q):I===null?n(I):Ht(I)?(a=L,$(I)):(e.consume(I),L)}function P(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||Li(I)?A(I):(e.consume(I),P)}function Q(I){return I===47||I===62||Li(I)?A(I):n(I)}function j(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function $(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),U}function U(I){return Rn(I)?Yn(e,B,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):B(I)}function B(I){return e.enter("htmlTextData"),a(I)}}const m3={name:"labelEnd",resolveAll:fBe,resolveTo:hBe,tokenize:pBe},cBe={tokenize:mBe},uBe={tokenize:gBe},dBe={tokenize:bBe};function fBe(e){let t=-1;const n=[];for(;++t=3&&(u===null||Ht(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===r?(e.consume(u),i++,c):(e.exit("thematicBreakSequence"),Rn(u)?Yn(e,o,"whitespace")(u):o(u))}}const Na={continuation:{tokenize:_Be},exit:NBe,name:"list",tokenize:TBe},EBe={partial:!0,tokenize:CBe},kBe={partial:!0,tokenize:ABe};function TBe(e,t,n){const i=this,r=i.events[i.events.length-1];let s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,a=0;return o;function o(p){const g=i.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!i.containerState.marker||p===i.containerState.marker:cM(p)){if(i.containerState.type||(i.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(iE,n,u)(p):u(p);if(!i.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return cM(p)&&++a<10?(e.consume(p),c):(!i.interrupt||a<2)&&(i.containerState.marker?p===i.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||p,e.check($1,i.interrupt?n:d,e.attempt(EBe,h,f))}function d(p){return i.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Rn(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return i.containerState.size=s+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function _Be(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check($1,r,s);function r(o){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Yn(e,t,"listItemIndent",i.containerState.size+1)(o)}function s(o){return i.containerState.furtherBlankLines||!Rn(o)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(o)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(kBe,t,a)(o))}function a(o){return i.containerState._closeFlow=!0,i.interrupt=void 0,Yn(e,e.attempt(Na,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function ABe(e,t,n){const i=this;return Yn(e,r,"listItemIndent",i.containerState.size+1);function r(s){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?t(s):n(s)}}function NBe(e){e.exit(this.containerState.type)}function CBe(e,t,n){const i=this;return Yn(e,r,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(s){const a=i.events[i.events.length-1];return!Rn(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const J7={name:"setextUnderline",resolveTo:jBe,tokenize:RBe};function jBe(e,t){let n=e.length,i,r,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(r=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",s?(e.splice(r,0,["enter",a,t]),e.splice(s+1,0,["exit",e[i][1],t]),e[i][1].end={...e[s][1].end}):e[i][1]=a,e.push(["exit",a,t]),e}function RBe(e,t,n){const i=this;let r;return s;function s(u){let d=i.events.length,f;for(;d--;)if(i.events[d][1].type!=="lineEnding"&&i.events[d][1].type!=="linePrefix"&&i.events[d][1].type!=="content"){f=i.events[d][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||f)?(e.enter("setextHeadingLine"),r=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===r?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Rn(u)?Yn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Ht(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const IBe={tokenize:PBe};function PBe(e){const t=this,n=e.attempt($1,i,e.attempt(this.parser.constructs.flowInitial,r,Yn(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Q6e,r)),"linePrefix")));return n;function i(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const MBe={resolveAll:Zse()},LBe=Wse("string"),DBe=Wse("text");function Wse(e){return{resolveAll:Zse(e==="text"?$Be:void 0),tokenize:t};function t(n){const i=this,r=this.parser.constructs[e],s=n.attempt(r,a,o);return a;function a(d){return u(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=r[d];let h=-1;if(f)for(;++h-1){const o=a[0];typeof o=="string"?a[0]=o.slice(i):a.shift()}s>0&&a.push(e[r].slice(0,s))}return a}function ZBe(e,t){let n=-1;const i=[];let r;for(;++n{const n=Ql(t),i=nE(n.msg,n.message);if(!i)return"";const r=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").map(String).join("."):"";return r?`${r}: ${i}`:i}).filter(Boolean).join("; "):""}function L3e(e,t=!0){const n=Ql(e),i=Object.prototype.hasOwnProperty.call(n,"detail")?n.detail:typeof e=="string"?e:void 0,r=Ql(i);return{message:typeof i=="string"?t?i.trim():"":nE(r.message,n.message,M3e(i)),errorCode:nE(r.errorCode,n.errorCode),requestId:nE(r.requestId,r.request_id,r.RequestId,n.requestId,n.request_id),diagnostics:r.diagnostics??n.diagnostics,detail:i,payload:e}}function Ql(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function fi(e){return typeof e=="string"?e:""}function xx(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function r3(e){const t=Ql(e);return{id:fi(t.id),name:fi(t.name),description:fi(t.description),providerType:fi(t.providerType),providerKnowledgeId:fi(t.providerKnowledgeId),projectName:fi(t.projectName),region:fi(t.region),status:fi(t.status),createdAt:fi(t.createdAt),updatedAt:fi(t.updatedAt),ownerId:fi(t.ownerId),ownerLabel:fi(t.ownerLabel),canManage:t.canManage===!0}}function I1(e){const t=Ql(e);return{id:fi(t.id),name:fi(t.name),type:fi(t.type),sizeBytes:xx(t.sizeBytes,0),status:fi(t.status),url:fi(t.url),tosPath:fi(t.tosPath),metadata:Ql(t.metadata),createdAt:fi(t.createdAt),updatedAt:fi(t.updatedAt)}}function D3e(e){const t=Ql(e),n=t.attachment,i=Ql(n);return{id:fi(t.id),title:fi(t.title),content:fi(t.content),attachmentUrl:fi(t.attachmentUrl)||fi(i.url)||fi(i.previewUrl),attachmentType:fi(t.attachmentType)||fi(i.type)||fi(i.mimeType),attachment:n,tableFields:t.tableFields}}async function Gc(e,t={},n=_o){var f;const i=Dp(t.headers);i.set("accept","application/json"),t.body&&!(t.body instanceof FormData)&&i.set("content-type","application/json");const r=await fetch(e,{...t,headers:i,signal:Ao(t.signal,n)});if(r.ok)return r.status===204?void 0:r.json();const s=await r.text();let a=s,o=!1;if(s)try{a=JSON.parse(s),o=!0}catch{}const c=((f=r.headers.get("content-type"))==null?void 0:f.toLowerCase())||"",u=L3e(a,o||c.startsWith("text/plain")),d=r.status===401?"请先登录后再访问知识库":r.status===403?"你没有权限操作这个知识库":r.status===404?"知识库或知识内容不存在":r.status===409?"知识库当前状态不允许执行此操作":`知识库请求失败 (${r.status})`;throw new rA(u.message||d,r.status,{errorCode:u.errorCode,requestId:u.requestId,diagnostics:u.diagnostics,detail:u.detail,payload:u.payload,rawBody:s})}function eb(e){const t=new URLSearchParams;e.trim()&&t.set("region",e.trim());const n=t.toString();return n?`?${n}`:""}async function $3e(e){var r;const t=new URLSearchParams({region:e.region,pageSize:String(e.pageSize??30)});(r=e.projectName)!=null&&r.trim()&&t.set("projectName",e.projectName.trim()),e.nextToken&&t.set("nextToken",e.nextToken);const n=await Gc(`/web/knowledge-bases?${t.toString()}`,{signal:e.signal}),i=Ql(n);return{items:Array.isArray(i.items)?i.items.map(r3):[],nextToken:fi(i.nextToken)}}function Q3e(e){return`${e.region}\0${e.id}`}async function B3e(e){var o;const t=[...new Set(e.regions.map(c=>c.trim()).filter(Boolean))],n=e.nextTokens?t.filter(c=>{var u;return!!((u=e.nextTokens)!=null&&u[c])}):t;if(n.length===0)return{items:[],nextTokens:{},failures:[]};const i=await Promise.allSettled(n.map(async c=>{var u;return{region:c,page:await $3e({region:c,projectName:e.projectName,nextToken:(u=e.nextTokens)==null?void 0:u[c],pageSize:e.pageSize,signal:e.signal})}}));if((o=e.signal)!=null&&o.aborted)throw new DOMException("Aborted","AbortError");const r=[],s={},a=new Map;if(i.forEach((c,u)=>{var f;const d=n[u];if(c.status==="rejected"){const h=(f=e.nextTokens)==null?void 0:f[d];h&&(s[d]=h),r.push({region:d,error:c.reason instanceof Error?c.reason:new Error("读取知识库失败")});return}c.value.page.nextToken&&(s[d]=c.value.page.nextToken),c.value.page.items.forEach(h=>{const p=h.region?h:{...h,region:d};a.set(Q3e(p),p)})}),r.length===n.length)throw new fse(r);return{items:[...a.values()],nextTokens:s,failures:r}}function U3e(e){return Gc("/web/knowledge-bases",{method:"POST",body:JSON.stringify(e)},kr).then(r3)}function z3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}${eb(t)}`,{method:"PATCH",body:JSON.stringify(n)}).then(r3)}function F3e(e,t){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}${eb(t)}`,{method:"DELETE"},kr)}async function V3e(e,t){var s;const n=new URLSearchParams({region:t.region,offset:String(t.offset??0),limit:String(t.limit??30)});(s=t.documentType)!=null&&s.trim()&&n.set("documentType",t.documentType.trim());const i=await Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents?${n.toString()}`,{signal:t.signal}),r=Ql(i);return{items:Array.isArray(r.items)?r.items.map(I1):[],offset:xx(r.offset,0),limit:xx(r.limit,t.limit??30),hasMore:r.hasMore===!0}}async function X3e(e,t,n){const i=new URLSearchParams({region:n.region,offset:String(n.offset??0),limit:String(n.limit??20)}),r=await Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}/preview?${i.toString()}`,{signal:n.signal}),s=Ql(r);return{document:I1(s.document),chunks:Array.isArray(s.chunks)?s.chunks.map(D3e):[],offset:xx(s.offset,0),limit:xx(s.limit,n.limit??20),hasMore:s.hasMore===!0}}function q3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents${eb(t)}`,{method:"POST",body:JSON.stringify(n)},kr).then(I1)}function H3e(e,t,n){var r,s;const i=new FormData;return i.set("file",n.file),(r=n.name)!=null&&r.trim()&&i.set("name",n.name.trim()),(s=n.documentType)!=null&&s.trim()&&i.set("documentType",n.documentType.trim()),n.metadata&&i.set("metadata",JSON.stringify(n.metadata)),Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/upload${eb(t)}`,{method:"POST",body:i},kr).then(I1)}function Y3e(e,t,n,i){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${eb(n)}`,{method:"PATCH",body:JSON.stringify(i)}).then(I1)}function G3e(e,t,n){return Gc(`/web/knowledge-bases/${encodeURIComponent(e)}/documents/${encodeURIComponent(t)}${eb(n)}`,{method:"DELETE"},kr)}function W3e({secondaryAction:e,primaryAction:t,menuLabel:n,menuAriaLabel:i,menuActions:r}){return l.jsxs("footer",{className:"library-resource-card__actions",children:[l.jsx("button",{type:"button",className:"library-resource-card__action library-resource-card__action--secondary",disabled:e.disabled,title:e.title,onClick:e.onClick,children:e.label}),l.jsx("button",{type:"button",className:"library-resource-card__action library-resource-card__action--primary",disabled:t.disabled,title:t.title,onClick:t.onClick,children:t.label}),l.jsx(Jne,{label:n,menuLabel:i,className:"library-resource-card__action library-resource-card__more",placement:"top-end",items:r.map(s=>({label:s.label,onSelect:s.onClick,disabled:s.disabled,danger:s.danger,title:s.title}))})]})}function pse({className:e="",title:t,status:n,description:i,metadata:r,secondaryAction:s,primaryAction:a,menuLabel:o,menuAriaLabel:c,menuActions:u}){return l.jsxs("article",{className:`my-agent-card library-resource-card ${e}`.trim(),children:[l.jsxs("div",{className:"my-agent-card-content",children:[l.jsxs("div",{className:"my-agent-card-title",children:[l.jsx("div",{className:"my-agent-card-title-copy",children:l.jsx("h3",{title:t,children:t})}),n]}),l.jsx("p",{className:"my-agent-description",title:i,children:i}),l.jsx("dl",{className:"my-agent-meta",children:r.map((d,f)=>l.jsxs("div",{className:f===0?"my-agent-created-at":"my-agent-region",children:[l.jsx("dt",{children:d.label}),l.jsx("dd",{title:d.title,children:d.value})]},`${d.label}:${f}`))})]}),l.jsx(W3e,{secondaryAction:s,primaryAction:a,menuLabel:o,menuAriaLabel:c,menuActions:u})]})}function Z3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),l.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),l.jsx("path",{d:"M9 7h6M9 10h4"})]})}function K3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),l.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function J3e(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.3"}),l.jsx("path",{d:"m15.5 15.5 4 4"})]})}function e4e(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function N7(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function t4e(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}function P1({title:e,children:t,onClose:n,busy:i=!1,className:r=""}){const s=m.useId(),a=m.useRef(null),o=m.useRef(null),c=m.useRef(i),u=m.useRef(n);return m.useEffect(()=>{c.current=i,u.current=n},[i,n]),m.useEffect(()=>{var p;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(p=a.current)==null||p.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=o.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),zi.createPortal(l.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!i&&n()},children:l.jsxs("section",{ref:o,className:`knowledge-dialog${r?` ${r}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":i||void 0,children:[l.jsxs("header",{className:"knowledge-dialog__header",children:[l.jsx("h2",{id:s,children:e}),l.jsx("button",{ref:a,type:"button",onClick:n,disabled:i,"aria-label":"关闭",children:l.jsx(e4e,{})})]}),t]})}),document.body)}function sA({message:e}){return e?l.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function nM(e){return e instanceof DOMException&&e.name==="AbortError"}function n4e(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}function i4e(e){const t=e.trim().toLowerCase();return["ready","active","available","success"].includes(t)?"可用":["creating","pending","processing","indexing"].includes(t)?"处理中":["failed","error","unavailable"].includes(t)?"异常":e||"未知"}const mse=[".jpg",".jpeg",".png"].join(","),r4e=new Set(mse.split(",")),gse=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),s4e=new Set(gse.split(",")),a4e=200*1024*1024;function iM(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function o4e(e,t){return e.size>a4e?"单个文件不能超过 200 MB":t==="image"?r4e.has(iM(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":s4e.has(iM(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function s3(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function bse(e){var r;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),i=n.includes(".")?(r=n.split(".").pop())==null?void 0:r.trim():"";return i?i.toUpperCase():"-"}function l4e({onClose:e,onCreated:t}){const[n,i]=m.useState(""),[r,s]=m.useState(""),[a,o]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=n.trim(),p=!!(h&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(h)),g=async b=>{if(b.preventDefault(),o(!0),!h||p)return;u(!0),f("");const y={name:h,description:r.trim()||void 0};try{t(await U3e(y))}catch(O){f(qs(O,"创建知识库失败"))}finally{u(!1)}};return l.jsx(P1,{title:"新建知识库",onClose:e,busy:c,children:l.jsxs("form",{onSubmit:b=>void g(b),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:n,maxLength:48,"aria-invalid":a&&p||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>o(!0),onChange:b=>i(b.target.value)})]}),l.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${a&&p?" is-error":""}`,role:a&&p?"alert":void 0,children:a&&p?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:r,maxLength:80,onChange:b=>s(b.target.value)})]}),l.jsx(sA,{message:d})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:e,disabled:c,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:c||!h||p,children:c?"创建中":"创建"})]})]})})}function c4e({item:e,onClose:t,onUpdated:n}){const[i,r]=m.useState(e.description),[s,a]=m.useState(!1),[o,c]=m.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await z3e(e.id,e.region,{description:i.trim()}))}catch(f){c(qs(f,"更新知识库失败"))}finally{a(!1)}};return l.jsx(P1,{title:"编辑知识库",onClose:t,busy:s,children:l.jsxs("form",{onSubmit:d=>void u(d),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{value:e.name,disabled:!0})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{autoFocus:!0,value:i,maxLength:80,onChange:d=>r(d.target.value)})]}),l.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),l.jsx(sA,{message:o})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function Ose(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function u4e({base:e,onClose:t,onCreated:n,onAssociationInvalid:i}){const[r,s]=m.useState("document"),[a,o]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(null),[g,b]=m.useState(!1),[y,O]=m.useState("{}"),[v,x]=m.useState(!1),[w,E]=m.useState(""),S=m.useRef(null),k=m.useRef(0),T=C=>{v||C===r||(s(C),p(null),f(""),o(""),u(""),E(""),b(!1),k.current=0,S.current&&(S.current.value=""))},A=C=>{if(!C||r==="web")return;const M=o4e(C,r);if(M){p(null),o(""),u(""),E(M);return}p(C),E(""),o(C.name.replace(/\.[^.]+$/,"")),u(iM(C.name).slice(1))},N=async C=>{if(C.preventDefault(),r==="web"?!d.trim():!h)return;let M;try{M=Ose(y)}catch(L){E(qs(L,"Metadata 格式错误"));return}x(!0),E("");try{if(r==="web"){const L={sourceType:"url",name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:M,url:d.trim()};await q3e(e.id,e.region,L)}else h&&await H3e(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:M});n()}catch(L){L instanceof rA&&L.errorCode===dse?i(L):E(qs(L,r==="web"?"添加网页失败":"上传文件失败"))}finally{x(!1)}};return l.jsx(P1,{title:"添加数据",onClose:t,busy:v,children:l.jsxs("form",{onSubmit:C=>void N(C),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([C,M])=>l.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${C}-tab`,"aria-controls":`knowledge-source-${C}-panel`,"aria-selected":r===C,tabIndex:r===C?0:-1,className:r===C?"is-active":"",disabled:v,onClick:()=>T(C),onKeyDown:L=>{const P=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;L.preventDefault();const Q=P.indexOf(C),j=L.key==="Home"?P[0]:L.key==="End"?P[P.length-1]:P[(Q+(L.key==="ArrowRight"?1:-1)+P.length)%P.length];T(j),requestAnimationFrame(()=>{var $;return($=document.getElementById(`knowledge-source-${j}-tab`))==null?void 0:$.focus()})},children:M},C))}),l.jsx("div",{id:`knowledge-source-${r}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${r}-tab`,children:r==="web"?l.jsxs("label",{children:[l.jsx("span",{children:"网页 URL"}),l.jsx("input",{autoFocus:!0,type:"url",value:d,disabled:v,onChange:C=>f(C.target.value),placeholder:"https://example.com/article"})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:S,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:r==="image"?mse:gse,disabled:v,onChange:C=>{var M;A(((M=C.currentTarget.files)==null?void 0:M[0])??null),C.currentTarget.value=""}}),l.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:v,onClick:()=>{var C;return(C=S.current)==null?void 0:C.click()},onDragEnter:C=>{C.preventDefault(),!v&&(k.current+=1,b(!0))},onDragOver:C=>{C.preventDefault(),v||(C.dataTransfer.dropEffect="copy")},onDragLeave:C=>{C.preventDefault(),k.current=Math.max(0,k.current-1),k.current===0&&b(!1)},onDrop:C=>{var M;C.preventDefault(),k.current=0,b(!1),v||A(((M=C.dataTransfer.files)==null?void 0:M[0])??null)},children:[l.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),l.jsx("span",{children:h?`${s3(h.size)} · 点击可重新选择`:r==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),l.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v?l.jsx(oi,{children:"正在上传文件并添加到知识库"}):null})]})}),l.jsxs("div",{className:"knowledge-dialog__fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称(可选)"}),l.jsx("input",{value:a,disabled:v,maxLength:256,onChange:C=>o(C.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"类型(可选)"}),l.jsx("input",{value:c,disabled:v,maxLength:64,onChange:C=>u(C.target.value),placeholder:r==="web"?"html":"pdf、docx、png"})]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Metadata(JSON)"}),l.jsx("textarea",{className:"is-code",value:y,disabled:v,onChange:C=>O(C.target.value),spellCheck:!1})]}),l.jsx(sA,{message:w})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:t,disabled:v,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:v||(r==="web"?!d.trim():!h),children:v?r==="web"?"添加中":"上传中":r==="web"?"添加网页":"上传文件"})]})]})})}function d4e({base:e,item:t,onClose:n,onUpdated:i}){const[r,s]=m.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,o]=m.useState(!1),[c,u]=m.useState(""),d=async f=>{f.preventDefault();let h;try{h=Ose(r)}catch(p){u(qs(p,"Metadata 格式错误"));return}o(!0),u("");try{i(await Y3e(e.id,t.id,e.region,{metadata:h}))}catch(p){u(qs(p,"更新知识失败"))}finally{o(!1)}};return l.jsx(P1,{title:"编辑知识 Metadata",onClose:n,busy:a,children:l.jsxs("form",{onSubmit:f=>void d(f),children:[l.jsxs("div",{className:"knowledge-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"知识"}),l.jsx("input",{value:t.name||t.id,disabled:!0})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Metadata(JSON)"}),l.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:r,onChange:f=>s(f.target.value),spellCheck:!1})]}),l.jsx(sA,{message:c})]}),l.jsxs("footer",{className:"knowledge-dialog__actions",children:[l.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),l.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const yse=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),xse=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),vse=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),f4e=new Set(["pdf"]),h4e=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),p4e=new Set(["creating","indexing","pending","processing","queued","submitted"]),m4e=new Set(["error","failed","unavailable"]);function C7(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Ew(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function g4e(e){if(Array.isArray(e)){if(e.length===0)return null;const i=e.map(C7);if(i.some(r=>Object.keys(r).length>0)){const r=[...new Set(i.flatMap(s=>Object.keys(s)))];return{columns:r,rows:i.map(s=>r.map(a=>Ew(s[a])))}}return{columns:["值"],rows:e.map(r=>[Ew(r)])}}const t=C7(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,i])=>Array.isArray(i))){const i=n.map(([s])=>s),r=Math.max(...n.map(([,s])=>s.length));return{columns:i,rows:Array.from({length:r},(s,a)=>n.map(([,o])=>Ew(o[a])))}}return{columns:["字段","值"],rows:n.map(([i,r])=>[i,Ew(r)])}}function wse(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function b4e(e){const t=wse(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function O4e(e){var r;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],i=n.includes(".")?((r=n.split(".").pop())==null?void 0:r.toLocaleLowerCase())??"":"";return yse.has(i)?"image":xse.has(i)?"audio":vse.has(i)?"video":f4e.has(i)?"pdf":t||i?"file":"none"}function y4e(e){const t=e.status.trim().toLocaleLowerCase();if(p4e.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(m4e.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=bse(e).toLocaleLowerCase();return n==="pdf"||h4e.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:yse.has(n)||xse.has(n)||vse.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function x4e({chunk:e}){const[t,n]=m.useState(!1),i=wse(e.attachmentUrl),r=O4e(e);return!i||r==="none"?null:t?l.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):r==="image"?l.jsx("img",{className:"knowledge-preview__image",src:i,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):r==="audio"?l.jsx("audio",{className:"knowledge-preview__audio",src:i,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):r==="video"?l.jsx("video",{className:"knowledge-preview__video",src:i,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):r==="pdf"?l.jsxs("div",{className:"knowledge-preview__pdf",children:[l.jsx("iframe",{src:i,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):l.jsxs("div",{className:"knowledge-preview__file-fallback",children:[l.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function v4e({base:e,item:t,onClose:n}){const[i,r]=m.useState([]),[s,a]=m.useState(t),[o,c]=m.useState(!0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(""),b=m.useRef(0),y=m.useRef(null),O=m.useCallback(async(w=0)=>{var k;(k=y.current)==null||k.abort();const E=new AbortController;y.current=E;const S=b.current+1;b.current=S,w>0?d(!0):c(!0),g(""),w===0&&(r([]),h(!1));try{const T=await X3e(e.id,t.id,{region:e.region,offset:w,signal:E.signal});if(b.current!==S)return;a(T.document.id?T.document:t),r(A=>w>0?[...A,...T.chunks]:T.chunks),h(T.hasMore)}catch(T){!nM(T)&&b.current===S&&g(qs(T,"加载数据预览失败"))}finally{b.current===S&&(c(!1),d(!1))}},[e.id,e.region,t]);m.useEffect(()=>(O(),()=>{var w;(w=y.current)==null||w.abort(),b.current+=1}),[O]);const v=b4e(s.url||t.url),x=y4e(s);return l.jsx(P1,{title:t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:l.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||v?l.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?l.jsx("span",{children:s3(s.sizeBytes)}):null,v?l.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,l.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o?l.jsx("div",{className:"knowledge-preview__state",role:"status",children:l.jsx(oi,{as:"span",duration:2.4,children:"正在加载数据预览"})}):p&&i.length===0?l.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[l.jsx("p",{children:p}),l.jsx("button",{type:"button",onClick:()=>void O(),children:"重试"})]}):i.length===0?l.jsxs("div",{className:"knowledge-preview__state",children:[l.jsx("p",{children:x.title}),l.jsx("span",{children:v?"您可以打开原网页查看来源内容。":x.detail}),l.jsx("button",{type:"button",onClick:()=>void O(),children:"重新加载"})]}):l.jsxs("div",{className:"knowledge-preview__chunks",children:[i.map((w,E)=>{const S=g4e(w.tableFields),k=w.id||`${E}:${w.title}`;return l.jsxs("article",{className:"knowledge-preview__chunk",children:[l.jsx("header",{children:l.jsx("h3",{children:w.title||`片段 ${E+1}`})}),w.content?l.jsx("p",{className:"knowledge-preview__content",children:w.content}):null,S?l.jsx("div",{className:"knowledge-preview__table-wrap",children:l.jsxs("table",{children:[l.jsx("thead",{children:l.jsx("tr",{children:S.columns.map((T,A)=>l.jsx("th",{scope:"col",children:T},`${T}:${A}`))})}),l.jsx("tbody",{children:S.rows.map((T,A)=>l.jsx("tr",{children:T.map((N,C)=>l.jsx("td",{children:N},C))},A))})]})}):null,l.jsx(x4e,{chunk:w})]},k)}),p?l.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:p}):null,f?l.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:u,onClick:()=>void O(i.length),children:u?l.jsx(oi,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function w4e({cloudProvider:e,active:t=!0,activationRevision:n=0}){const[i,r]=m.useState([]),[s,a]=m.useState({}),[o,c]=m.useState([]),[u,d]=m.useState(""),[f,h]=m.useState(""),[p,g]=m.useState(!0),[b,y]=m.useState(!1),[O,v]=m.useState(""),[x,w]=m.useState([]),[E,S]=m.useState(!1),[k,T]=m.useState(""),[A,N]=m.useState(""),[C,M]=m.useState(""),[L,P]=m.useState(!1),[Q,j]=m.useState(!1),[$,U]=m.useState(!1),[B,I]=m.useState(null),[X,q]=m.useState(null),[D,H]=m.useState(null),[re,fe]=m.useState(null),[Ae,J]=m.useState(null),[ie,ue]=m.useState(!1),ye=m.useRef(0),Se=m.useRef(0),Re=m.useRef([]),Ee=m.useRef(!1),me=m.useRef(!1),oe=m.useRef(null),Ne=m.useRef(null),Oe=m.useRef({}),Ve=m.useRef(!1),We=m.useRef(null),De=m.useRef(null),mt=m.useRef(null),at=m.useRef(null),Rt=m.useMemo(()=>v1(e).map(ge=>ge.value),[e]),qe=m.useCallback(ge=>`${ge.region}\0${ge.id}`,[]),W=i.find(ge=>qe(ge)===u)??null,K=!!(W&&C===qe(W)),ae=m.useMemo(()=>{const ge=f.trim().toLocaleLowerCase();return ge?i.filter(lt=>[lt.name,lt.description,lt.ownerLabel,lt.providerKnowledgeId].some(Ge=>Ge.toLocaleLowerCase().includes(ge))):i},[i,f]);m.useEffect(()=>{q(null)},[W==null?void 0:W.id,W==null?void 0:W.region]);const pe=m.useCallback(async(ge=!1)=>{var vt;if(ge&&(Ve.current||Object.keys(Oe.current).length===0))return;(vt=oe.current)==null||vt.abort();const lt=new AbortController;oe.current=lt;const Ge=ye.current+1;ye.current=Ge,Ve.current=!0,ge?y(!0):g(!0),v(""),ge||c([]);try{const _t=await B3e({regions:Rt,nextTokens:ge?Oe.current:void 0,signal:lt.signal});if(ye.current!==Ge)return;r(je=>ge?[...je,..._t.items.filter(Ze=>!je.some(Ie=>qe(Ie)===qe(Ze)))]:_t.items),Oe.current=_t.nextTokens,a(_t.nextTokens);const Bt=_t.failures.map(({region:je,error:Ze})=>`${td(je,e)}:${qs(Ze,"加载失败")}`);c(je=>ge?[...new Set([...je,...Bt])]:Bt),ge||d(je=>_t.items.some(Ze=>qe(Ze)===je)?je:"")}catch(_t){if(nM(_t))return;ye.current===Ge&&(ge?c(Bt=>[...new Set([...Bt,qs(_t,"加载更多知识库失败")])]):v(qs(_t,"加载知识库失败")))}finally{ye.current===Ge&&(Ve.current=!1,g(!1),y(!1))}},[qe,e,Rt]),z=m.useCallback(async(ge,lt=!1)=>{var _t;if(lt&&Ee.current)return;(_t=Ne.current)==null||_t.abort();const Ge=new AbortController;Ne.current=Ge;const vt=Se.current+1;Se.current=vt,lt||(Re.current=[],me.current=!1,w([]),P(!1),N("")),Ee.current=!0,S(!0),lt?N(""):T("");try{const Bt=await V3e(ge.id,{region:ge.region,offset:lt?Re.current.length:0,signal:Ge.signal});if(Se.current!==vt)return;M(Wt=>Wt===qe(ge)?"":Wt);const je=Re.current,Ze=lt?[...je,...Bt.items.filter(Wt=>!Wt.id||!je.some(dn=>dn.id===Wt.id))]:Bt.items,Ie=Bt.hasMore&&(!lt||Ze.length>je.length);Re.current=Ze,me.current=Ie,w(Ze),P(Ie)}catch(Bt){if(nM(Bt))return;Se.current===vt&&(Bt instanceof rA&&Bt.errorCode===dse&&(M(qe(ge)),I(Ze=>Ze&&qe(Ze)===qe(ge)?null:Ze)),lt?N(qs(Bt,"加载更多数据失败")):T(qs(Bt,"加载数据失败")))}finally{Se.current===vt&&(Ee.current=!1,S(!1))}},[qe]);m.useEffect(()=>{var ge;(ge=oe.current)==null||ge.abort(),ye.current+=1,Ve.current=!1,Oe.current={},r([]),a({}),c([]),d(""),M(""),v(""),g(!0)},[e]),m.useEffect(()=>{if(t)return pe(),()=>{var ge;(ge=oe.current)==null||ge.abort(),ye.current+=1,Ve.current=!1}},[t,n,pe]),m.useEffect(()=>{var ge,lt;if(!t){(ge=Ne.current)==null||ge.abort(),Se.current+=1,Ee.current=!1;return}if(!W){(lt=Ne.current)==null||lt.abort(),Se.current+=1,Re.current=[],Ee.current=!1,me.current=!1,w([]),P(!1),N("");return}return z(W),()=>{var Ge;(Ge=Ne.current)==null||Ge.abort(),Se.current+=1,Ee.current=!1}},[t,n,W==null?void 0:W.id,W==null?void 0:W.region]);const ve=t&&!W&&!f.trim()&&!p&&!b&&!O&&Object.keys(s).length>0;m.useEffect(()=>{const ge=De.current,lt=We.current;if(!ge||!lt||!ve)return;const Ge=new IntersectionObserver(([vt])=>{vt.isIntersecting&&pe(!0)},{root:lt,rootMargin:"240px 0px",threshold:.01});return Ge.observe(ge),()=>Ge.disconnect()},[ve,pe]);const Be=()=>{const ge=We.current;!ge||!ve||ge.scrollHeight-ge.scrollTop-ge.clientHeight<=240&&pe(!0)},Je=!!(W&&x.length>0&&L&&!E&&!A);m.useEffect(()=>{const ge=at.current,lt=mt.current;if(!W||!ge||!lt||!Je)return;const Ge=new IntersectionObserver(([vt])=>{vt.isIntersecting&&z(W,!0)},{root:mt.current,rootMargin:"240px 0px",threshold:.01});return Ge.observe(ge),()=>Ge.disconnect()},[Je,z,W==null?void 0:W.id,W==null?void 0:W.region]);const kt=()=>{const ge=mt.current;if(!W||!ge||!me.current||Ee.current||A)return;const{scrollHeight:lt,scrollTop:Ge,clientHeight:vt}=ge;lt-Ge-vt<=240&&z(W,!0)},Mt=ge=>{r(lt=>lt.map(Ge=>qe(Ge)===qe(ge)?ge:Ge))},Tt=async()=>{if(re){ue(!0);try{await F3e(re.id,re.region),r(ge=>ge.filter(lt=>qe(lt)!==qe(re))),M(ge=>ge===qe(re)?"":ge),u===qe(re)&&d(""),fe(null)}catch(ge){v(qs(ge,"删除知识库失败")),fe(null)}finally{ue(!1)}}},dt=async()=>{if(!(!W||!Ae)){ue(!0);try{await G3e(W.id,Ae.id,W.region);const ge=Re.current.filter(lt=>lt.id!==Ae.id);Re.current=ge,w(ge),J(null)}catch(ge){T(qs(ge,"删除知识失败")),J(null)}finally{ue(!1)}}};return l.jsxs("section",{className:`knowledge-library${W?" is-detail":" my-agents-page"}`,"aria-label":"知识库",children:[W?l.jsxs("div",{className:"knowledge-library__detail",children:[l.jsxs("header",{className:"knowledge-detail-head",children:[l.jsxs("div",{className:"knowledge-detail-head__title",children:[l.jsx("button",{type:"button",className:"knowledge-back-button",onClick:()=>d(""),"aria-label":"返回知识库列表",children:l.jsx(t4e,{})}),l.jsxs("div",{children:[l.jsx("h2",{title:W.name,children:W.name}),l.jsx("p",{children:W.description||"暂无描述"})]})]}),W.canManage&&l.jsxs("div",{className:"knowledge-detail-head__actions",children:[l.jsx("button",{type:"button",onClick:()=>U(!0),children:"编辑"}),l.jsx("button",{type:"button",className:"is-danger",onClick:()=>fe(W),children:"删除"})]})]}),l.jsxs("dl",{className:"knowledge-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Provider"}),l.jsx("dd",{children:W.providerType||"-"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Knowledge ID"}),l.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:W.providerKnowledgeId,children:W.providerKnowledgeId||"-"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"项目"}),l.jsx("dd",{children:W.projectName||"default"})]}),W.ownerLabel&&l.jsxs("div",{children:[l.jsx("dt",{children:"创建者"}),l.jsx("dd",{children:W.ownerLabel})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"更新时间"}),l.jsx("dd",{children:n4e(W.updatedAt)||"-"})]})]}),l.jsxs("section",{className:"knowledge-documents",children:[l.jsxs("header",{className:"knowledge-documents__head",children:[l.jsx("h3",{children:"数据"}),W.canManage&&l.jsxs("button",{type:"button",className:"knowledge-primary-button",disabled:K,title:K?"底层 Provider 知识库已不存在":void 0,onClick:()=>I(W),children:[l.jsx(N7,{}),l.jsx("span",{children:K?"关联已失效":"添加数据"})]})]}),l.jsx("div",{className:`knowledge-documents__body${x.length>0?" is-table":""}`,"aria-live":"polite",children:E&&x.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载数据"})]}):k&&x.length===0?l.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[l.jsx("p",{children:k}),K&&W.canManage?l.jsx("button",{type:"button",onClick:()=>fe(W),children:"删除失效关联"}):l.jsx("button",{type:"button",onClick:()=>void z(W),children:"重试"})]}):x.length===0?l.jsxs("div",{className:"knowledge-library__state",children:[l.jsx(K3e,{}),l.jsx("p",{children:"这个知识库还没有数据"}),W.canManage&&l.jsx("button",{type:"button",onClick:()=>I(W),children:"添加第一项数据"})]}):l.jsxs("div",{ref:mt,className:"knowledge-document-table-wrap","aria-busy":E||void 0,onScroll:kt,children:[l.jsxs("table",{className:"knowledge-document-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"名称"}),l.jsx("th",{scope:"col",children:"格式"}),l.jsx("th",{scope:"col",children:"大小"}),l.jsx("th",{scope:"col",className:"knowledge-document-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:x.map(ge=>l.jsxs("tr",{children:[l.jsx("td",{className:"knowledge-document-table__name",title:ge.name||ge.id,children:ge.name||ge.id}),l.jsx("td",{children:bse(ge)}),l.jsx("td",{children:s3(ge.sizeBytes)}),l.jsx("td",{children:l.jsxs("div",{className:"knowledge-document-table__actions",children:[l.jsx(sp,{content:"预览",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"secondary",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`预览 ${ge.name||ge.id}`,onClick:()=>q(ge),children:l.jsx(Iwe,{"aria-hidden":"true"})})}),W.canManage?l.jsxs(l.Fragment,{children:[l.jsx(sp,{content:"编辑",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"secondary",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`编辑 ${ge.name||ge.id}`,onClick:()=>H(ge),children:l.jsx(jwe,{"aria-hidden":"true"})})}),l.jsx(sp,{content:"删除",compact:!0,children:l.jsx(zu,{type:"button",className:"knowledge-document-action-button",color:"danger",variant:"ghost",size:"sm",iconSize:"sm",uniform:!0,"aria-label":`删除 ${ge.name||ge.id}`,onClick:()=>J(ge),children:l.jsx(Cwe,{"aria-hidden":"true"})})})]}):null]})})]},ge.id))})]}),E?l.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多数据"})]}):A?l.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[l.jsx("span",{children:A}),l.jsx("button",{type:"button",onClick:()=>void z(W,!0),children:"重试加载"})]}):L?l.jsx("div",{ref:at,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null]})})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"knowledge-library__toolbar my-agent-type-bar library-resource-toolbar",children:[l.jsx("div",{className:"knowledge-library__toolbar-actions library-resource-toolbar__controls",children:l.jsxs("button",{type:"button",className:"my-agent-create-primary",onClick:()=>j(!0),children:[l.jsx(N7,{}),l.jsx("span",{children:"新建知识库"})]})}),l.jsxs("label",{className:"knowledge-library__search my-agent-search",children:[l.jsx(J3e,{}),l.jsx("input",{type:"search",value:f,onChange:ge=>h(ge.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),l.jsxs("div",{ref:We,className:"knowledge-library__results my-agent-results","aria-live":"polite",onScroll:Be,children:[o.length>0&&!p&&l.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[l.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),l.jsx("button",{type:"button",onClick:()=>void pe(),children:"重试"})]}),p&&i.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载知识库"})]}):O?l.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[l.jsx("p",{children:O}),l.jsx("button",{type:"button",onClick:()=>void pe(),children:"重试"})]}):ae.length===0?l.jsxs("div",{className:"knowledge-library__state",children:[l.jsx(Z3e,{}),l.jsx("p",{children:f.trim()?"没有匹配的知识库":"您还没有任何知识库"})]}):l.jsx("div",{className:"knowledge-library__grid my-agent-grid",children:ae.map(ge=>l.jsx(pse,{className:"knowledge-card",title:ge.name,status:l.jsx("span",{className:`knowledge-status is-${ge.status.toLowerCase()}`,children:i4e(ge.status)}),description:ge.description||"暂无描述",metadata:[{label:"创建者",value:ge.ownerLabel||"—",title:ge.ownerLabel||"—"},{label:"项目",value:ge.projectName||"default",title:ge.projectName||"default"}],secondaryAction:{label:C===qe(ge)?"关联已失效":"添加数据",disabled:!ge.canManage||C===qe(ge),title:ge.canManage?C===qe(ge)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>I(ge)},primaryAction:{label:"查看详情",onClick:()=>d(qe(ge))},menuLabel:`更多知识库操作:${ge.name}`,menuAriaLabel:`${ge.name}知识库操作`,menuActions:[{label:"编辑知识库",disabled:!ge.canManage,title:ge.canManage?void 0:"您没有管理此知识库的权限",onClick:()=>{d(qe(ge)),U(!0)}},{label:"删除知识库",danger:!0,disabled:!ge.canManage||ie,title:ge.canManage?void 0:"您没有管理此知识库的权限",onClick:()=>fe(ge)}]},qe(ge)))}),ve||b?l.jsx("div",{ref:De,className:"my-agent-load-more",role:"status","aria-live":"polite",children:b?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多知识库"})]}):ve?l.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),Q&&l.jsx(l4e,{onClose:()=>j(!1),onCreated:ge=>{r(lt=>[ge,...lt]),d(qe(ge)),j(!1)}}),W&&$&&l.jsx(c4e,{item:W,onClose:()=>U(!1),onUpdated:ge=>{Mt(ge),U(!1)}}),W&&X&&l.jsx(v4e,{base:W,item:X,onClose:()=>q(null)}),B&&l.jsx(u4e,{base:B,onClose:()=>I(null),onAssociationInvalid:ge=>{M(qe(B)),W&&qe(W)===qe(B)&&T(qs(ge,"知识库关联已失效")),I(null)},onCreated:()=>{W&&qe(W)===qe(B)&&z(W),I(null)}}),W&&D&&l.jsx(d4e,{base:W,item:D,onClose:()=>H(null),onUpdated:ge=>{const lt=Re.current.map(Ge=>Ge.id===ge.id?ge:Ge);Re.current=lt,w(lt),H(null)}}),re&&l.jsx(Mf,{title:"删除知识库?",description:`将删除 ${re.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:ie?"删除中":"删除",variant:"danger",busy:ie,onCancel:()=>fe(null),onConfirm:()=>void Tt()}),Ae&&l.jsx(Mf,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${Ae.name||Ae.id},此操作无法撤销。`,confirmLabel:ie?"删除中":"删除",variant:"danger",busy:ie,onCancel:()=>J(null),onConfirm:()=>void dt()})]})}const S4e="_EmptyMessage_1r5gu_1",E4e="_IconBadge_1r5gu_16",k4e="_Title_1r5gu_54",T4e="_Description_1r5gu_69",_4e="_ActionRow_1r5gu_77",M1={EmptyMessage:S4e,IconBadge:E4e,Title:k4e,Description:T4e,ActionRow:_4e},Oi=({children:e,className:t,fill:n="static"})=>l.jsx("div",{className:Ps(M1.EmptyMessage,t),"data-fill":n,children:e}),A4e=({size:e="md",color:t="secondary",children:n,className:i})=>l.jsx("div",{className:Ps(M1.IconBadge,i),"data-size":e,"data-color":t,children:n}),N4e=({children:e,className:t,color:n="secondary"})=>l.jsx("div",{className:Ps(M1.Title,t),"data-color":n,children:e}),C4e=({children:e,className:t})=>l.jsx("div",{className:Ps(M1.Description,t),children:e}),j4e=({children:e,className:t})=>l.jsx("div",{className:Ps(M1.ActionRow,t),children:e});Oi.Icon=A4e;Oi.Title=N4e;Oi.Description=C4e;Oi.ActionRow=j4e;const R4e="/web/skill-workbench";class rM extends Error{constructor(t,n,i="SKILL_WORKBENCH_ERROR",r=!1,s="",a,o=""){super(t),this.status=n,this.code=i,this.retryable=r,this.statusText=s,this.originalError=a,this.rawResponse=o,this.name="SkillWorkbenchApiError"}}function nl(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function j7(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function I4e(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function Fc(e,t={},n=_o){return fetch(vo(`${R4e}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function a3(e,t){var i;const n=await e.text().catch(()=>"");try{const r=nl(JSON.parse(n),"错误响应"),s=r.detail&&typeof r.detail=="object"?nl(r.detail,"错误详情"):r;return new rM(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失";return new rM(`${t}(HTTP ${e.status},Content-Type: ${r})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Uf(e,t){if(!e.ok)throw await a3(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const i=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${i}),请检查代理或网关配置。`)}return e.json()}function P4e(e){return Array.isArray(e)?e.map(t=>{const n=nl(t,"Skill 会话活动"),i=n.kind,r=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(i))||!["running","done"].includes(String(r)))throw new Error("Skill 会话活动格式错误。");if(i==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:i,status:r,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:i,status:r,text:n.text}}):[]}function M4e(e){if(e==null)return;const t=nl(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!BD(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function vx(e){const t=nl(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(o=>{const c=nl(o,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const r=j7(t.toolId,"Tool ID"),s=j7(t.sessionId,"Session ID"),a=I4e(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...r?{toolId:r}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:P4e(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:M4e(t.publication)}:{}}}async function aA(e){const t=nl(await Uf(await Fc("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const i=n;return typeof i.id=="string"&&typeof i.label=="string"?[{id:i.id,label:i.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function L4e(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const i=await Fc(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},kr);return vx(await Uf(i,"开始优化 Skill 失败"))}const t=await Fc("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},kr);return vx(await Uf(t,"开始 Skill 会话失败"))}async function D4e(e,t){return vx(await Uf(await Fc(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function vC(e,t,n){const i=new URLSearchParams;i.set("expected_revision",String(t));const r=nl(await Uf(await Fc(`/tasks/${encodeURIComponent(e)}/artifact?${i.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(r.jobId!==e||r.revision!==t||!Number.isSafeInteger(r.revision)||r.revision<1||typeof r.sha256!="string"||!/^[0-9a-f]{64}$/.test(r.sha256)||typeof r.name!="string"||typeof r.description!="string"||!Array.isArray(r.files))throw new Error("Skill 产物格式错误。");const s=r.files.map(a=>{const o=nl(a,"Skill 产物文件");if(typeof o.path!="string"||typeof o.size!="number"||typeof o.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:o.path,size:o.size,content:o.content}});return{jobId:r.jobId,revision:r.revision,sha256:r.sha256,name:r.name,description:r.description,files:s}}async function wC(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},kr);return vx(await Uf(t,"继续调整 Skill 失败"))}async function $4e(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return vx(await Uf(t,"停止当前 Skill 任务失败"))}async function Q4e(e){const t=await Fc(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await a3(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const i=new Set(["preparing","uploading","registering","activating","publishing"]);let r=null,s="";const a=new TextDecoder,o=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=nl(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!i.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const p=nl(d.error,"发布错误");throw new rM(typeof p.message=="string"?p.message:"发布 Skill 失败",500,typeof p.code=="string"?p.code:"SKILL_PUBLISH_FAILED",p.retryable===!0,"",p.originalError&&typeof p.originalError=="object"?p.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=nl(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(p=>typeof p=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!BD(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");r={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await o.read();s+=a.decode(u,{stream:!d});const f=s.split(` +`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!r)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return r}async function B4e(e){await Uf(await Fc(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function U4e(e,t,n){var c;const i=new URLSearchParams;i.set("expected_revision",String(t)),i.set("expected_sha256",n);const r=await Fc(`/tasks/${encodeURIComponent(e)}/download?${i.toString()}`,{},kr);if(!r.ok)throw await a3(r,"下载 Skill 失败");const a=((c=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",o=URL.createObjectURL(await r.blob());try{const u=document.createElement("a");u.href=o,u.download=a,u.click()}finally{URL.revokeObjectURL(o)}}const z4e={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function F4e(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(const r of n){if(i==null||typeof i!="object")return;i=i[r]}return i}function V4e(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function X4e(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function o3(e,t){if(V4e(e))return F4e(t,e.path);if(X4e(e)){const n=z4e[e.call],i={};for(const[r,s]of Object.entries(e.args??{}))i[r]=o3(s,t);return n?n(i):`[unknown fn: ${e.call}]`}return e}function q4e(e,t){const n=o3(e,t);return n==null?"":typeof n=="string"?n:String(n)}const Sse=new Map;function Up(e,t){Sse.set(e,t)}function H4e(e){return Sse.get(e)}function Y4e(e,t,n){const i=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(let s=0;so3(i,e.dataModel),resolveString:i=>q4e(i,e.dataModel),dispatchAction:t,render:i=>{if(!i)return null;const r=e.components[i];if(!r)return null;const s=H4e(r.component)??G4e;return l.jsx(s,{node:r,ctx:n},i)}};return l.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function kse(e){const t=m.useRef(null),n=m.useRef(!0),i=28,r=m.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:r}}function AOt(){}function R7(e){const t=[],n=String(e||"");let i=n.indexOf(","),r=0,s=!1;for(;!s;){i===-1&&(i=n.length,s=!0);const a=n.slice(r,i).trim();(a||!s)&&t.push(a),r=i+1,i=n.indexOf(",",r)}return t}function Tse(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Z4e=/[$_\p{ID_Start}]/u,K4e=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,J4e=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,eQe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tQe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_se={};function NOt(e){return e?Z4e.test(String.fromCodePoint(e)):!1}function COt(e,t){const i=(t||_se).jsx?J4e:K4e;return e?i.test(String.fromCodePoint(e)):!1}function I7(e,t){return(_se.jsx?tQe:eQe).test(e)}const nQe=/[ \t\n\f\r]/g;function iQe(e){return typeof e=="object"?e.type==="text"?P7(e.value):!1:P7(e)}function P7(e){return e.replace(nQe,"")===""}let L1=class{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}};L1.prototype.normal={};L1.prototype.property={};L1.prototype.space=void 0;function Ase(e,t){const n={},i={};for(const r of e)Object.assign(n,r.property),Object.assign(i,r.normal);return new L1(n,i,t)}function wx(e){return e.toLowerCase()}class Ha{constructor(t,n){this.attribute=n,this.property=t}}Ha.prototype.attribute="";Ha.prototype.booleanish=!1;Ha.prototype.boolean=!1;Ha.prototype.commaOrSpaceSeparated=!1;Ha.prototype.commaSeparated=!1;Ha.prototype.defined=!1;Ha.prototype.mustUseProperty=!1;Ha.prototype.number=!1;Ha.prototype.overloadedBoolean=!1;Ha.prototype.property="";Ha.prototype.spaceSeparated=!1;Ha.prototype.space=void 0;let rQe=0;const pn=zp(),Br=zp(),sM=zp(),rt=zp(),$i=zp(),Eg=zp(),io=zp();function zp(){return 2**++rQe}const aM=Object.freeze(Object.defineProperty({__proto__:null,boolean:pn,booleanish:Br,commaOrSpaceSeparated:io,commaSeparated:Eg,number:rt,overloadedBoolean:sM,spaceSeparated:$i},Symbol.toStringTag,{value:"Module"})),SC=Object.keys(aM);class l3 extends Ha{constructor(t,n,i,r){let s=-1;if(super(t,n),M7(this,"space",r),typeof i=="number")for(;++s4&&n.slice(0,4)==="data"&&cQe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(L7,dQe);i="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!L7.test(s)){let a=s.replace(lQe,uQe);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}r=l3}return new r(i,t)}function uQe(e){return"-"+e.toLowerCase()}function dQe(e){return e.charAt(1).toUpperCase()}const D1=Ase([Nse,sQe,Rse,Ise,Pse],"html"),nh=Ase([Nse,aQe,Rse,Ise,Pse],"svg");function D7(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Mse(e){return e.join(" ").trim()}var c3={},$7=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,fQe=/\n/g,hQe=/^\s*/,pQe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,mQe=/^:\s*/,gQe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,bQe=/^[;\s]*/,OQe=/^\s+|\s+$/g,yQe=` +`,Q7="/",B7="*",Rh="",xQe="comment",vQe="declaration";function wQe(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,i=1;function r(g){var b=g.match(fQe);b&&(n+=b.length);var y=g.lastIndexOf(yQe);i=~y?g.length-y:i+g.length}function s(){var g={line:n,column:i};return function(b){return b.position=new a(g),u(),b}}function a(g){this.start=g,this.end={line:n,column:i},this.source=t.source}a.prototype.content=e;function o(g){var b=new Error(t.source+":"+n+":"+i+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=i,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var y=b[0];return r(y),e=e.slice(y.length),b}}function u(){c(hQe)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=s();if(!(Q7!=e.charAt(0)||B7!=e.charAt(1))){for(var b=2;Rh!=e.charAt(b)&&(B7!=e.charAt(b)||Q7!=e.charAt(b+1));)++b;if(b+=2,Rh===e.charAt(b-1))return o("End of comment missing");var y=e.slice(2,b-2);return i+=2,r(y),e=e.slice(b),i+=2,g({type:xQe,comment:y})}}function h(){var g=s(),b=c(pQe);if(b){if(f(),!c(mQe))return o("property missing ':'");var y=c(gQe),O=g({type:vQe,property:U7(b[0].replace($7,Rh)),value:y?U7(y[0].replace($7,Rh)):Rh});return c(bQe),O}}function p(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),p()}function U7(e){return e?e.replace(OQe,Rh):Rh}var SQe=wQe,EQe=tf&&tf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(c3,"__esModule",{value:!0});c3.default=TQe;const kQe=EQe(SQe);function TQe(e,t){let n=null;if(!e||typeof e!="string")return n;const i=(0,kQe.default)(e),r=typeof t=="function";return i.forEach(s=>{if(s.type!=="declaration")return;const{property:a,value:o}=s;r?t(a,o,s):o&&(n=n||{},n[a]=o)}),n}var lA={};Object.defineProperty(lA,"__esModule",{value:!0});lA.camelCase=void 0;var _Qe=/^--[a-zA-Z0-9_-]+$/,AQe=/-([a-z])/g,NQe=/^[^-]+$/,CQe=/^-(webkit|moz|ms|o|khtml)-/,jQe=/^-(ms)-/,RQe=function(e){return!e||NQe.test(e)||_Qe.test(e)},IQe=function(e,t){return t.toUpperCase()},z7=function(e,t){return"".concat(t,"-")},PQe=function(e,t){return t===void 0&&(t={}),RQe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(jQe,z7):e=e.replace(CQe,z7),e.replace(AQe,IQe))};lA.camelCase=PQe;var MQe=tf&&tf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},LQe=MQe(c3),DQe=lA;function oM(e,t){var n={};return!e||typeof e!="string"||(0,LQe.default)(e,function(i,r){i&&r&&(n[(0,DQe.camelCase)(i,t)]=r)}),n}oM.default=oM;var $Qe=oM;const QQe=N0($Qe),cA=Lse("end"),Wc=Lse("start");function Lse(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function BQe(e){const t=Wc(e),n=cA(e);if(t&&n)return{start:t,end:n}}function fy(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?F7(e.position):"start"in e||"end"in e?F7(e):"line"in e||"column"in e?lM(e):""}function lM(e){return V7(e&&e.line)+":"+V7(e&&e.column)}function F7(e){return lM(e&&e.start)+"-"+lM(e&&e.end)}function V7(e){return e&&typeof e=="number"?e:1}class Js extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let r="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=!0,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof i=="string"){const c=i.indexOf(":");c===-1?s.ruleId=i:(s.source=i.slice(0,c),s.ruleId=i.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=fy(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Js.prototype.file="";Js.prototype.name="";Js.prototype.reason="";Js.prototype.message="";Js.prototype.stack="";Js.prototype.column=void 0;Js.prototype.line=void 0;Js.prototype.ancestors=void 0;Js.prototype.cause=void 0;Js.prototype.fatal=void 0;Js.prototype.place=void 0;Js.prototype.ruleId=void 0;Js.prototype.source=void 0;const u3={}.hasOwnProperty,UQe=new Map,zQe=/[A-Z]/g,FQe=new Set(["table","tbody","thead","tfoot","tr"]),VQe=new Set(["td","th"]),Dse="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function XQe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=JQe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=KQe(n,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?nh:D1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=$se(r,e,void 0);return s&&typeof s!="string"?s:r.create(e,r.Fragment,{children:s||void 0},void 0)}function $se(e,t,n){if(t.type==="element")return qQe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return HQe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return GQe(e,t,n);if(t.type==="mdxjsEsm")return YQe(e,t);if(t.type==="root")return WQe(e,t,n);if(t.type==="text")return ZQe(e,t)}function qQe(e,t,n){const i=e.schema;let r=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(r=nh,e.schema=r),e.ancestors.push(t);const s=Bse(e,t.tagName,!1),a=e6e(e,t);let o=f3(e,t);return FQe.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!iQe(c):!0})),Qse(e,a,s,t),d3(a,o),e.ancestors.pop(),e.schema=i,e.create(t,s,a,n)}function HQe(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Sx(e,t.position)}function YQe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sx(e,t.position)}function GQe(e,t,n){const i=e.schema;let r=i;t.name==="svg"&&i.space==="html"&&(r=nh,e.schema=r),e.ancestors.push(t);const s=t.name===null?e.Fragment:Bse(e,t.name,!0),a=t6e(e,t),o=f3(e,t);return Qse(e,a,s,t),d3(a,o),e.ancestors.pop(),e.schema=i,e.create(t,s,a,n)}function WQe(e,t,n){const i={};return d3(i,f3(e,t)),e.create(t,e.Fragment,i,n)}function ZQe(e,t){return t.value}function Qse(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function d3(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function KQe(e,t,n){return i;function i(r,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function JQe(e,t){return n;function n(i,r,s,a){const o=Array.isArray(s.children),c=Wc(i);return t(r,s,a,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function e6e(e,t){const n={};let i,r;for(r in t.properties)if(r!=="children"&&u3.call(t.properties,r)){const s=n6e(e,r,t.properties[r]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&VQe.has(t.tagName)?i=o:n[a]=o}}if(i){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function t6e(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const s=i.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Sx(e,t.position);else{const r=i.name;let s;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const o=i.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else Sx(e,t.position);else s=i.value===null?!0:i.value;n[r]=s}return n}function f3(e,t){const n=[];let i=-1;const r=e.passKeys?new Map:UQe;for(;++ir?0:r+t:t=t>r?r:t,n=n>0?n:0,i.length<1e4)a=Array.from(i),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s0?(wo(e,e.length,0,t),e):t}const H7={}.hasOwnProperty;function zse(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ml(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pa=ih(/[A-Za-z]/),Ws=ih(/[\dA-Za-z]/),d6e=ih(/[#-'*+\--9=?A-Z^-~]/);function Bk(e){return e!==null&&(e<32||e===127)}const cM=ih(/\d/),f6e=ih(/[\dA-Fa-f]/),h6e=ih(/[!-/:-@[-`{-~]/);function Ht(e){return e!==null&&e<-2}function Li(e){return e!==null&&(e<0||e===32)}function Rn(e){return e===-2||e===-1||e===32}const uA=ih(new RegExp("\\p{P}|\\p{S}","u")),Sp=ih(/\s/);function ih(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function nb(e){const t=[];let n=-1,i=0,r=0;for(;++n55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),r=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(i,n),encodeURIComponent(a)),i=n+r+1,a=""),r&&(n+=r,r=0)}return t.join("")+e.slice(i)}function Yn(e,t,n,i){const r=i?i-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(c){return Rn(c)?(e.enter(n),o(c)):t(c)}function o(c){return Rn(c)&&s++a))return;const k=t.events.length;let T=k,A,N;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(A){N=t.events[T][1].end;break}A=!0}for(O(i),S=k;Sx;){const E=n[w];t.containerState=E[1],E[0].exit.call(t,e)}n.length=x}function v(){r.write([null]),s=void 0,r=void 0,t.containerState._closeFlow=void 0}}function O6e(e,t,n){return Yn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function f0(e){if(e===null||Li(e)||Sp(e))return 1;if(uA(e))return 2}function dA(e,t,n){const i=[];let r=-1;for(;++r1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[i][1].end},h={...e[n][1].start};G7(f,-c),G7(h,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[i][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},r={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[i][1].end={...a.start},e[n][1].start={...o.end},u=[],e[i][1].end.offset-e[i][1].start.offset&&(u=Bo(u,[["enter",e[i][1],t],["exit",e[i][1],t]])),u=Bo(u,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Bo(u,dA(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),u=Bo(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Bo(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,wo(e,i-1,n-i+3,u),n=i+u.length-d-2;break}}for(n=-1;++n0&&Rn(S)?Yn(e,v,"linePrefix",s+1)(S):v(S)}function v(S){return S===null||Ht(S)?e.check(W7,b,w)(S):(e.enter("codeFlowValue"),x(S))}function x(S){return S===null||Ht(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),x)}function w(S){return e.exit("codeFenced"),t(S)}function E(S,k,T){let A=0;return N;function N(Q){return S.enter("lineEnding"),S.consume(Q),S.exit("lineEnding"),C}function C(Q){return S.enter("codeFencedFence"),Rn(Q)?Yn(S,M,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):M(Q)}function M(Q){return Q===o?(S.enter("codeFencedFenceSequence"),L(Q)):T(Q)}function L(Q){return Q===o?(A++,S.consume(Q),L):A>=a?(S.exit("codeFencedFenceSequence"),Rn(Q)?Yn(S,P,"whitespace")(Q):P(Q)):T(Q)}function P(Q){return Q===null||Ht(Q)?(S.exit("codeFencedFence"),k(Q)):T(Q)}}}function C6e(e,t,n){const i=this;return r;function r(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return i.parser.lazy[i.now().line]?n(a):t(a)}}const kC={name:"codeIndented",tokenize:R6e},j6e={partial:!0,tokenize:I6e};function R6e(e,t,n){const i=this;return r;function r(u){return e.enter("codeIndented"),Yn(e,s,"linePrefix",5)(u)}function s(u){const d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):Ht(u)?e.attempt(j6e,a,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ht(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function I6e(e,t,n){const i=this;return r;function r(a){return i.parser.lazy[i.now().line]?n(a):Ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r):Yn(e,s,"linePrefix",5)(a)}function s(a){const o=i.events[i.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):Ht(a)?r(a):n(a)}}const P6e={name:"codeText",previous:L6e,resolve:M6e,tokenize:D6e};function M6e(e){let t=e.length-4,n=3,i,r;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const r=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return i&&Kb(this.left,i),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Kb(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Kb(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(a):e.interrupt(i.parser.constructs.flow,n,t)(a)}}function Yse(e,t,n,i,r,s,a,o,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(O){return O===60?(e.enter(i),e.enter(r),e.enter(s),e.consume(O),e.exit(s),h):O===null||O===32||O===41||Bk(O)?n(O):(e.enter(i),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(O))}function h(O){return O===62?(e.enter(s),e.consume(O),e.exit(s),e.exit(r),e.exit(i),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(O))}function p(O){return O===62?(e.exit("chunkString"),e.exit(o),h(O)):O===null||O===60||Ht(O)?n(O):(e.consume(O),O===92?g:p)}function g(O){return O===60||O===62||O===92?(e.consume(O),p):p(O)}function b(O){return!d&&(O===null||O===41||Li(O))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(i),t(O)):d999||p===null||p===91||p===93&&!c||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(r),e.consume(p),e.exit(r),e.exit(i),t):Ht(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Ht(p)||o++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!Rn(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function Wse(e,t,n,i,r,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(i),e.enter(r),e.consume(h),e.exit(r),a=h===40?41:h,c):n(h)}function c(h){return h===a?(e.enter(r),e.consume(h),e.exit(r),e.exit(i),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),c(a)):h===null?n(h):Ht(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Yn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||Ht(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function hy(e,t){let n;return i;function i(r){return Ht(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,i):Rn(r)?Yn(e,i,n?"linePrefix":"lineSuffix")(r):t(r)}}const X6e={name:"definition",tokenize:H6e},q6e={partial:!0,tokenize:Y6e};function H6e(e,t,n){const i=this;let r;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return Gse.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return r=Ml(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return Li(p)?hy(e,u)(p):u(p)}function u(p){return Yse(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(q6e,f,f)(p)}function f(p){return Rn(p)?Yn(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Ht(p)?(e.exit("definition"),i.parser.defined.push(r),t(p)):n(p)}}function Y6e(e,t,n){return i;function i(o){return Li(o)?hy(e,r)(o):n(o)}function r(o){return Wse(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Rn(o)?Yn(e,a,"whitespace")(o):a(o)}function a(o){return o===null||Ht(o)?t(o):n(o)}}const G6e={name:"hardBreakEscape",tokenize:W6e};function W6e(e,t,n){return i;function i(s){return e.enter("hardBreakEscape"),e.consume(s),r}function r(s){return Ht(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Z6e={name:"headingAtx",resolve:K6e,tokenize:J6e};function K6e(e,t){let n=e.length-2,i=3,r,s;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(r={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},s={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},wo(e,i,n-i+1,[["enter",r,t],["enter",s,t],["exit",s,t],["exit",r,t]])),e}function J6e(e,t,n){let i=0;return r;function r(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&i++<6?(e.consume(d),a):d===null||Li(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||Ht(d)?(e.exit("atxHeading"),t(d)):Rn(d)?Yn(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||Li(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const eBe=["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"],K7=["pre","script","style","textarea"],tBe={concrete:!0,name:"htmlFlow",resolveTo:rBe,tokenize:sBe},nBe={partial:!0,tokenize:oBe},iBe={partial:!0,tokenize:aBe};function rBe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function sBe(e,t,n){const i=this;let r,s,a,o,c;return u;function u(D){return d(D)}function d(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),f}function f(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),s=!0,b):D===63?(e.consume(D),r=3,i.interrupt?t:I):pa(D)?(e.consume(D),a=String.fromCharCode(D),y):n(D)}function h(D){return D===45?(e.consume(D),r=2,p):D===91?(e.consume(D),r=5,o=0,g):pa(D)?(e.consume(D),r=4,i.interrupt?t:I):n(D)}function p(D){return D===45?(e.consume(D),i.interrupt?t:I):n(D)}function g(D){const H="CDATA[";return D===H.charCodeAt(o++)?(e.consume(D),o===H.length?i.interrupt?t:M:g):n(D)}function b(D){return pa(D)?(e.consume(D),a=String.fromCharCode(D),y):n(D)}function y(D){if(D===null||D===47||D===62||Li(D)){const H=D===47,re=a.toLowerCase();return!H&&!s&&K7.includes(re)?(r=1,i.interrupt?t(D):M(D)):eBe.includes(a.toLowerCase())?(r=6,H?(e.consume(D),O):i.interrupt?t(D):M(D)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(D):s?v(D):x(D))}return D===45||Ws(D)?(e.consume(D),a+=String.fromCharCode(D),y):n(D)}function O(D){return D===62?(e.consume(D),i.interrupt?t:M):n(D)}function v(D){return Rn(D)?(e.consume(D),v):N(D)}function x(D){return D===47?(e.consume(D),N):D===58||D===95||pa(D)?(e.consume(D),w):Rn(D)?(e.consume(D),x):N(D)}function w(D){return D===45||D===46||D===58||D===95||Ws(D)?(e.consume(D),w):E(D)}function E(D){return D===61?(e.consume(D),S):Rn(D)?(e.consume(D),E):x(D)}function S(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(e.consume(D),c=D,k):Rn(D)?(e.consume(D),S):T(D)}function k(D){return D===c?(e.consume(D),c=null,A):D===null||Ht(D)?n(D):(e.consume(D),k)}function T(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||Li(D)?E(D):(e.consume(D),T)}function A(D){return D===47||D===62||Rn(D)?x(D):n(D)}function N(D){return D===62?(e.consume(D),C):n(D)}function C(D){return D===null||Ht(D)?M(D):Rn(D)?(e.consume(D),C):n(D)}function M(D){return D===45&&r===2?(e.consume(D),j):D===60&&r===1?(e.consume(D),$):D===62&&r===4?(e.consume(D),X):D===63&&r===3?(e.consume(D),I):D===93&&r===5?(e.consume(D),B):Ht(D)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(nBe,q,L)(D)):D===null||Ht(D)?(e.exit("htmlFlowData"),L(D)):(e.consume(D),M)}function L(D){return e.check(iBe,P,q)(D)}function P(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return D===null||Ht(D)?L(D):(e.enter("htmlFlowData"),M(D))}function j(D){return D===45?(e.consume(D),I):M(D)}function $(D){return D===47?(e.consume(D),a="",U):M(D)}function U(D){if(D===62){const H=a.toLowerCase();return K7.includes(H)?(e.consume(D),X):M(D)}return pa(D)&&a.length<8?(e.consume(D),a+=String.fromCharCode(D),U):M(D)}function B(D){return D===93?(e.consume(D),I):M(D)}function I(D){return D===62?(e.consume(D),X):D===45&&r===2?(e.consume(D),I):M(D)}function X(D){return D===null||Ht(D)?(e.exit("htmlFlowData"),q(D)):(e.consume(D),X)}function q(D){return e.exit("htmlFlow"),t(D)}}function aBe(e,t,n){const i=this;return r;function r(a){return Ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return i.parser.lazy[i.now().line]?n(a):t(a)}}function oBe(e,t,n){return i;function i(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt($1,t,n)}}const lBe={name:"htmlText",tokenize:cBe};function cBe(e,t,n){const i=this;let r,s,a;return o;function o(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),c}function c(I){return I===33?(e.consume(I),u):I===47?(e.consume(I),E):I===63?(e.consume(I),x):pa(I)?(e.consume(I),T):n(I)}function u(I){return I===45?(e.consume(I),d):I===91?(e.consume(I),s=0,g):pa(I)?(e.consume(I),v):n(I)}function d(I){return I===45?(e.consume(I),p):n(I)}function f(I){return I===null?n(I):I===45?(e.consume(I),h):Ht(I)?(a=f,$(I)):(e.consume(I),f)}function h(I){return I===45?(e.consume(I),p):f(I)}function p(I){return I===62?j(I):I===45?h(I):f(I)}function g(I){const X="CDATA[";return I===X.charCodeAt(s++)?(e.consume(I),s===X.length?b:g):n(I)}function b(I){return I===null?n(I):I===93?(e.consume(I),y):Ht(I)?(a=b,$(I)):(e.consume(I),b)}function y(I){return I===93?(e.consume(I),O):b(I)}function O(I){return I===62?j(I):I===93?(e.consume(I),O):b(I)}function v(I){return I===null||I===62?j(I):Ht(I)?(a=v,$(I)):(e.consume(I),v)}function x(I){return I===null?n(I):I===63?(e.consume(I),w):Ht(I)?(a=x,$(I)):(e.consume(I),x)}function w(I){return I===62?j(I):x(I)}function E(I){return pa(I)?(e.consume(I),S):n(I)}function S(I){return I===45||Ws(I)?(e.consume(I),S):k(I)}function k(I){return Ht(I)?(a=k,$(I)):Rn(I)?(e.consume(I),k):j(I)}function T(I){return I===45||Ws(I)?(e.consume(I),T):I===47||I===62||Li(I)?A(I):n(I)}function A(I){return I===47?(e.consume(I),j):I===58||I===95||pa(I)?(e.consume(I),N):Ht(I)?(a=A,$(I)):Rn(I)?(e.consume(I),A):j(I)}function N(I){return I===45||I===46||I===58||I===95||Ws(I)?(e.consume(I),N):C(I)}function C(I){return I===61?(e.consume(I),M):Ht(I)?(a=C,$(I)):Rn(I)?(e.consume(I),C):A(I)}function M(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),r=I,L):Ht(I)?(a=M,$(I)):Rn(I)?(e.consume(I),M):(e.consume(I),P)}function L(I){return I===r?(e.consume(I),r=void 0,Q):I===null?n(I):Ht(I)?(a=L,$(I)):(e.consume(I),L)}function P(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||Li(I)?A(I):(e.consume(I),P)}function Q(I){return I===47||I===62||Li(I)?A(I):n(I)}function j(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function $(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),U}function U(I){return Rn(I)?Yn(e,B,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):B(I)}function B(I){return e.enter("htmlTextData"),a(I)}}const m3={name:"labelEnd",resolveAll:hBe,resolveTo:pBe,tokenize:mBe},uBe={tokenize:gBe},dBe={tokenize:bBe},fBe={tokenize:OBe};function hBe(e){let t=-1;const n=[];for(;++t=3&&(u===null||Ht(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===r?(e.consume(u),i++,c):(e.exit("thematicBreakSequence"),Rn(u)?Yn(e,o,"whitespace")(u):o(u))}}const Na={continuation:{tokenize:ABe},exit:CBe,name:"list",tokenize:_Be},kBe={partial:!0,tokenize:jBe},TBe={partial:!0,tokenize:NBe};function _Be(e,t,n){const i=this,r=i.events[i.events.length-1];let s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,a=0;return o;function o(p){const g=i.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!i.containerState.marker||p===i.containerState.marker:cM(p)){if(i.containerState.type||(i.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(iE,n,u)(p):u(p);if(!i.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return cM(p)&&++a<10?(e.consume(p),c):(!i.interrupt||a<2)&&(i.containerState.marker?p===i.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||p,e.check($1,i.interrupt?n:d,e.attempt(kBe,h,f))}function d(p){return i.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Rn(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return i.containerState.size=s+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function ABe(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check($1,r,s);function r(o){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Yn(e,t,"listItemIndent",i.containerState.size+1)(o)}function s(o){return i.containerState.furtherBlankLines||!Rn(o)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(o)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(TBe,t,a)(o))}function a(o){return i.containerState._closeFlow=!0,i.interrupt=void 0,Yn(e,e.attempt(Na,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function NBe(e,t,n){const i=this;return Yn(e,r,"listItemIndent",i.containerState.size+1);function r(s){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?t(s):n(s)}}function CBe(e){e.exit(this.containerState.type)}function jBe(e,t,n){const i=this;return Yn(e,r,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(s){const a=i.events[i.events.length-1];return!Rn(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const J7={name:"setextUnderline",resolveTo:RBe,tokenize:IBe};function RBe(e,t){let n=e.length,i,r,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(r=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",s?(e.splice(r,0,["enter",a,t]),e.splice(s+1,0,["exit",e[i][1],t]),e[i][1].end={...e[s][1].end}):e[i][1]=a,e.push(["exit",a,t]),e}function IBe(e,t,n){const i=this;let r;return s;function s(u){let d=i.events.length,f;for(;d--;)if(i.events[d][1].type!=="lineEnding"&&i.events[d][1].type!=="linePrefix"&&i.events[d][1].type!=="content"){f=i.events[d][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||f)?(e.enter("setextHeadingLine"),r=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===r?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Rn(u)?Yn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Ht(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const PBe={tokenize:MBe};function MBe(e){const t=this,n=e.attempt($1,i,e.attempt(this.parser.constructs.flowInitial,r,Yn(e,e.attempt(this.parser.constructs.flow,r,e.attempt(B6e,r)),"linePrefix")));return n;function i(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const LBe={resolveAll:Kse()},DBe=Zse("string"),$Be=Zse("text");function Zse(e){return{resolveAll:Kse(e==="text"?QBe:void 0),tokenize:t};function t(n){const i=this,r=this.parser.constructs[e],s=n.attempt(r,a,o);return a;function a(d){return u(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=r[d];let h=-1;if(f)for(;++h-1){const o=a[0];typeof o=="string"?a[0]=o.slice(i):a.shift()}s>0&&a.push(e[r].slice(0,s))}return a}function KBe(e,t){let n=-1;const i=[];let r;for(;++n0){const ve=ae.tokenStack[ae.tokenStack.length-1];(ve[1]||tz).call(ae,void 0,ve[0])}for(K.position={start:Pd(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:Pd(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},z=-1;++z0&&(i.className=["language-"+r[0]]);let s={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function d8e(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function f8e(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function h8e(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),r=nb(i.toLowerCase()),s=e.footnoteOrder.indexOf(i);let a,o=e.footnoteCounts.get(i);o===void 0?(o=0,e.footnoteOrder.push(i),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(i,o);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function p8e(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function m8e(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function eae(e,t){const n=t.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const r=e.all(t),s=r[0];s&&s.type==="text"?s.value="["+s.value:r.unshift({type:"text",value:"["});const a=r[r.length-1];return a&&a.type==="text"?a.value+=i:r.push({type:"text",value:i}),r}function g8e(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return eae(e,t);const r={src:nb(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(r.title=i.title);const s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,s),e.applyData(t,s)}function b8e(e,t){const n={src:nb(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)}function O8e(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)}function y8e(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return eae(e,t);const r={href:nb(i.url||"")};i.title!==null&&i.title!==void 0&&(r.title=i.title);const s={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function x8e(e,t){const n={href:nb(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function v8e(e,t,n){const i=e.all(t),r=n?w8e(n):tae(t),s={},a=[];if(typeof t.checked=="boolean"){const d=i[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},i.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o0){const ve=ae.tokenStack[ae.tokenStack.length-1];(ve[1]||tz).call(ae,void 0,ve[0])}for(K.position={start:Pd(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:Pd(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},z=-1;++z0&&(i.className=["language-"+r[0]]);let s={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function f8e(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function h8e(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function p8e(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),r=nb(i.toLowerCase()),s=e.footnoteOrder.indexOf(i);let a,o=e.footnoteCounts.get(i);o===void 0?(o=0,e.footnoteOrder.push(i),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(i,o);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function m8e(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function g8e(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function tae(e,t){const n=t.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const r=e.all(t),s=r[0];s&&s.type==="text"?s.value="["+s.value:r.unshift({type:"text",value:"["});const a=r[r.length-1];return a&&a.type==="text"?a.value+=i:r.push({type:"text",value:i}),r}function b8e(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return tae(e,t);const r={src:nb(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(r.title=i.title);const s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,s),e.applyData(t,s)}function O8e(e,t){const n={src:nb(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)}function y8e(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)}function x8e(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return tae(e,t);const r={href:nb(i.url||"")};i.title!==null&&i.title!==void 0&&(r.title=i.title);const s={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function v8e(e,t){const n={href:nb(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function w8e(e,t,n){const i=e.all(t),r=n?S8e(n):nae(t),s={},a=[];if(typeof t.checked=="boolean"){const d=i[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},i.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o1}function S8e(e,t){const n={},i=e.all(t);let r=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++r0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=Wc(t.children[1]),c=cA(t.children[t.children.length-1]);o&&c&&(a.position={start:o,end:c}),r.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function A8e(e,t,n){const i=n?n.children:void 0,s=(i?i.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let c=-1;const u=[];for(;++c0,!0),i[0]),r=i.index+i[0].length,i=n.exec(t);return s.push(rz(t.slice(r),r>0,!1)),s.join("")}function rz(e,t,n){let i=0,r=e.length;if(t){let s=e.codePointAt(i);for(;s===nz||s===iz;)i++,s=e.codePointAt(i)}if(n){let s=e.codePointAt(r-1);for(;s===nz||s===iz;)r--,s=e.codePointAt(r-1)}return r>i?e.slice(i,r):""}function j8e(e,t){const n={type:"text",value:C8e(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function R8e(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const I8e={blockquote:l8e,break:c8e,code:u8e,delete:d8e,emphasis:f8e,footnoteReference:h8e,heading:p8e,html:m8e,imageReference:g8e,image:b8e,inlineCode:O8e,linkReference:y8e,link:x8e,listItem:v8e,list:S8e,paragraph:E8e,root:k8e,strong:T8e,table:_8e,tableCell:N8e,tableRow:A8e,text:j8e,thematicBreak:R8e,toml:kw,yaml:kw,definition:kw,footnoteDefinition:kw};function kw(){}const nae=-1,fA=0,py=1,Uk=2,g3=3,b3=4,O3=5,y3=6,iae=7,rae=8,P8e=typeof self=="object"?self:globalThis,sz=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new P8e[e](t)},M8e=(e,t)=>{const n=(r,s)=>(e.set(s,r),r),i=r=>{if(e.has(r))return e.get(r);const[s,a]=t[r];switch(s){case fA:case nae:return n(a,r);case py:{const o=n([],r);for(const c of a)o.push(i(c));return o}case Uk:{const o=n({},r);for(const[c,u]of a)o[i(c)]=i(u);return o}case g3:return n(new Date(a),r);case b3:{const{source:o,flags:c}=a;return n(new RegExp(o,c),r)}case O3:{const o=n(new Map,r);for(const[c,u]of a)o.set(i(c),i(u));return o}case y3:{const o=n(new Set,r);for(const c of a)o.add(i(c));return o}case iae:{const{name:o,message:c}=a;return n(sz(o,c),r)}case rae:return n(BigInt(a),r);case"BigInt":return n(Object(BigInt(a)),r);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(sz(s,a),r)};return i},az=e=>M8e(new Map,e)(0),cm="",{toString:L8e}={},{keys:D8e}=Object,Jb=e=>{const t=typeof e;if(t!=="object"||!e)return[fA,t];const n=L8e.call(e).slice(8,-1);switch(n){case"Array":return[py,cm];case"Object":return[Uk,cm];case"Date":return[g3,cm];case"RegExp":return[b3,cm];case"Map":return[O3,cm];case"Set":return[y3,cm];case"DataView":return[py,n]}return n.includes("Array")?[py,n]:n.includes("Error")?[iae,n]:[Uk,n]},Tw=([e,t])=>e===fA&&(t==="function"||t==="symbol"),$8e=(e,t,n,i)=>{const r=(a,o)=>{const c=i.push(a)-1;return n.set(o,c),c},s=a=>{if(n.has(a))return n.get(a);let[o,c]=Jb(a);switch(o){case fA:{let d=a;switch(c){case"bigint":o=rae,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return r([nae],a)}return r([o,d],a)}case py:{if(c){let h=a;return c==="DataView"?h=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(h=new Uint8Array(a)),r([c,[...h]],a)}const d=[],f=r([o,d],a);for(const h of a)d.push(s(h));return f}case Uk:{if(c)switch(c){case"BigInt":return r([c,a.toString()],a);case"Boolean":case"Number":case"String":return r([c,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],f=r([o,d],a);for(const h of D8e(a))(e||!Tw(Jb(a[h])))&&d.push([s(h),s(a[h])]);return f}case g3:return r([o,a.toISOString()],a);case b3:{const{source:d,flags:f}=a;return r([o,{source:d,flags:f}],a)}case O3:{const d=[],f=r([o,d],a);for(const[h,p]of a)(e||!(Tw(Jb(h))||Tw(Jb(p))))&&d.push([s(h),s(p)]);return f}case y3:{const d=[],f=r([o,d],a);for(const h of a)(e||!Tw(Jb(h)))&&d.push(s(h));return f}}const{message:u}=a;return r([o,{name:c,message:u}],a)};return s},oz=(e,{json:t,lossy:n}={})=>{const i=[];return $8e(!(t||n),!!t,new Map,i)(e),i},h0=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?az(oz(e,t)):structuredClone(e):(e,t)=>az(oz(e,t));function Q8e(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function B8e(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function U8e(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Q8e,i=e.options.footnoteBackLabel||B8e,r=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let c=-1;for(;++c0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(c,p);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(c,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const y=d[d.length-1];if(y&&y.type==="element"&&y.tagName==="p"){const v=y.children[y.children.length-1];v&&v.type==="text"?v.value+=" ":y.children.push({type:"text",value:" "}),y.children.push(...g)}else d.push(...g);const O={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(d,!0)};e.patch(u,O),o.push(O)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...h0(a),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:` +`});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function S8e(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let i=-1;for(;!t&&++i1}function E8e(e,t){const n={},i=e.all(t);let r=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++r0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=Wc(t.children[1]),c=cA(t.children[t.children.length-1]);o&&c&&(a.position={start:o,end:c}),r.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function N8e(e,t,n){const i=n?n.children:void 0,s=(i?i.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let c=-1;const u=[];for(;++c0,!0),i[0]),r=i.index+i[0].length,i=n.exec(t);return s.push(rz(t.slice(r),r>0,!1)),s.join("")}function rz(e,t,n){let i=0,r=e.length;if(t){let s=e.codePointAt(i);for(;s===nz||s===iz;)i++,s=e.codePointAt(i)}if(n){let s=e.codePointAt(r-1);for(;s===nz||s===iz;)r--,s=e.codePointAt(r-1)}return r>i?e.slice(i,r):""}function R8e(e,t){const n={type:"text",value:j8e(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function I8e(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const P8e={blockquote:c8e,break:u8e,code:d8e,delete:f8e,emphasis:h8e,footnoteReference:p8e,heading:m8e,html:g8e,imageReference:b8e,image:O8e,inlineCode:y8e,linkReference:x8e,link:v8e,listItem:w8e,list:E8e,paragraph:k8e,root:T8e,strong:_8e,table:A8e,tableCell:C8e,tableRow:N8e,text:R8e,thematicBreak:I8e,toml:kw,yaml:kw,definition:kw,footnoteDefinition:kw};function kw(){}const iae=-1,fA=0,py=1,Uk=2,g3=3,b3=4,O3=5,y3=6,rae=7,sae=8,M8e=typeof self=="object"?self:globalThis,sz=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new M8e[e](t)},L8e=(e,t)=>{const n=(r,s)=>(e.set(s,r),r),i=r=>{if(e.has(r))return e.get(r);const[s,a]=t[r];switch(s){case fA:case iae:return n(a,r);case py:{const o=n([],r);for(const c of a)o.push(i(c));return o}case Uk:{const o=n({},r);for(const[c,u]of a)o[i(c)]=i(u);return o}case g3:return n(new Date(a),r);case b3:{const{source:o,flags:c}=a;return n(new RegExp(o,c),r)}case O3:{const o=n(new Map,r);for(const[c,u]of a)o.set(i(c),i(u));return o}case y3:{const o=n(new Set,r);for(const c of a)o.add(i(c));return o}case rae:{const{name:o,message:c}=a;return n(sz(o,c),r)}case sae:return n(BigInt(a),r);case"BigInt":return n(Object(BigInt(a)),r);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(sz(s,a),r)};return i},az=e=>L8e(new Map,e)(0),cm="",{toString:D8e}={},{keys:$8e}=Object,Jb=e=>{const t=typeof e;if(t!=="object"||!e)return[fA,t];const n=D8e.call(e).slice(8,-1);switch(n){case"Array":return[py,cm];case"Object":return[Uk,cm];case"Date":return[g3,cm];case"RegExp":return[b3,cm];case"Map":return[O3,cm];case"Set":return[y3,cm];case"DataView":return[py,n]}return n.includes("Array")?[py,n]:n.includes("Error")?[rae,n]:[Uk,n]},Tw=([e,t])=>e===fA&&(t==="function"||t==="symbol"),Q8e=(e,t,n,i)=>{const r=(a,o)=>{const c=i.push(a)-1;return n.set(o,c),c},s=a=>{if(n.has(a))return n.get(a);let[o,c]=Jb(a);switch(o){case fA:{let d=a;switch(c){case"bigint":o=sae,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return r([iae],a)}return r([o,d],a)}case py:{if(c){let h=a;return c==="DataView"?h=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(h=new Uint8Array(a)),r([c,[...h]],a)}const d=[],f=r([o,d],a);for(const h of a)d.push(s(h));return f}case Uk:{if(c)switch(c){case"BigInt":return r([c,a.toString()],a);case"Boolean":case"Number":case"String":return r([c,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],f=r([o,d],a);for(const h of $8e(a))(e||!Tw(Jb(a[h])))&&d.push([s(h),s(a[h])]);return f}case g3:return r([o,a.toISOString()],a);case b3:{const{source:d,flags:f}=a;return r([o,{source:d,flags:f}],a)}case O3:{const d=[],f=r([o,d],a);for(const[h,p]of a)(e||!(Tw(Jb(h))||Tw(Jb(p))))&&d.push([s(h),s(p)]);return f}case y3:{const d=[],f=r([o,d],a);for(const h of a)(e||!Tw(Jb(h)))&&d.push(s(h));return f}}const{message:u}=a;return r([o,{name:c,message:u}],a)};return s},oz=(e,{json:t,lossy:n}={})=>{const i=[];return Q8e(!(t||n),!!t,new Map,i)(e),i},h0=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?az(oz(e,t)):structuredClone(e):(e,t)=>az(oz(e,t));function B8e(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function U8e(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function z8e(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||B8e,i=e.options.footnoteBackLabel||U8e,r=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let c=-1;for(;++c0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(c,p);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(c,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const y=d[d.length-1];if(y&&y.type==="element"&&y.tagName==="p"){const v=y.children[y.children.length-1];v&&v.type==="text"?v.value+=" ":y.children.push({type:"text",value:" "}),y.children.push(...g)}else d.push(...g);const O={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(d,!0)};e.patch(u,O),o.push(O)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...h0(a),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:` -`}]}}const Q1=function(e){if(e==null)return X8e;if(typeof e=="function")return hA(e);if(typeof e=="object")return Array.isArray(e)?z8e(e):F8e(e);if(typeof e=="string")return V8e(e);throw new Error("Expected function, string, or object as test")};function z8e(e){const t=[];let n=-1;for(;++n":""))+")"})}return h;function h(){let p=sae,g,b,y;if((!t||s(c,u,d[d.length-1]||void 0))&&(p=G8e(n(c,d)),p[0]===dM))return p;if("children"in c&&c.children){const O=c;if(O.children&&p[0]!==Y8e)for(b=(i?O.children.length:-1)+a,y=d.concat(O);b>-1&&b":""))+")"})}return h;function h(){let p=aae,g,b,y;if((!t||s(c,u,d[d.length-1]||void 0))&&(p=W8e(n(c,d)),p[0]===dM))return p;if("children"in c&&c.children){const O=c;if(O.children&&p[0]!==G8e)for(b=(i?O.children.length:-1)+a,y=d.concat(O);b>-1&&b0&&n.push({type:"text",value:` -`}),n}function lz(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cz(e,t){const n=Z8e(e,t),i=n.one(e,void 0),r=U8e(n),s=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return r&&s.children.push({type:"text",value:` -`},r),s}function n9e(e,t){return e&&"run"in e?async function(n,i){const r=cz(n,{file:i,...t});await e.run(r,i)}:function(n,i){return cz(n,{file:i,...e||t})}}function uz(e){if(e)throw e}var rE=Object.prototype.hasOwnProperty,oae=Object.prototype.toString,dz=Object.defineProperty,fz=Object.getOwnPropertyDescriptor,hz=function(t){return typeof Array.isArray=="function"?Array.isArray(t):oae.call(t)==="[object Array]"},pz=function(t){if(!t||oae.call(t)!=="[object Object]")return!1;var n=rE.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&rE.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!i)return!1;var r;for(r in t);return typeof r>"u"||rE.call(t,r)},mz=function(t,n){dz&&n.name==="__proto__"?dz(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},gz=function(t,n){if(n==="__proto__")if(rE.call(t,n)){if(fz)return fz(t,n).value}else return;return t[n]},i9e=function e(){var t,n,i,r,s,a,o=arguments[0],c=1,u=arguments.length,d=!1;for(typeof o=="boolean"&&(d=o,o=arguments[1]||{},c=2),(o==null||typeof o!="object"&&typeof o!="function")&&(o={});ca.length;let c;o&&a.push(r);try{c=e.apply(this,a)}catch(u){const d=u;if(o&&n)throw d;return r(d)}o||(c&&c.then&&typeof c.then=="function"?c.then(s,r):c instanceof Error?r(c):s(c))}function r(a,...o){n||(n=!0,t(a,...o))}function s(a){r(null,a)}}const bc={basename:a9e,dirname:o9e,extname:l9e,join:c9e,sep:"/"};function a9e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');U1(e);let n=0,i=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else i<0&&(s=!0,i=r+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,o=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=!0,a=r+1),o>-1&&(e.codePointAt(r)===t.codePointAt(o--)?o<0&&(i=r):(o=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function o9e(e){if(U1(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function l9e(e){U1(e);let t=e.length,n=-1,i=0,r=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1)}return r<0||n<0||s===0||s===1&&r===n-1&&r===i+1?"":e.slice(r,n)}function c9e(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function d9e(e,t){let n="",i=0,r=-1,s=0,a=-1,o,c;for(;++a<=e.length;){if(a2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",i=0):(n=n.slice(0,c),i=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",i=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),i=a-r-1;r=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function U1(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const f9e={cwd:h9e};function h9e(){return"/"}function pM(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function p9e(e){if(typeof e=="string")e=new URL(e);else if(!pM(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return m9e(e)}function m9e(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n0){let[p,...g]=d;const b=i[h][1];hM(b)&&hM(p)&&(p=_C(!0,b,p)),i[h]=[u,p,...g]}}}}const y9e=new x3().freeze();function jC(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function RC(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function IC(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Oz(e){if(!hM(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yz(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function _w(e){return x9e(e)?e:new lae(e)}function x9e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function v9e(e){return typeof e=="string"||w9e(e)}function w9e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const S9e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",xz=[],vz={allowDangerousHtml:!0},E9e=/^(https?|ircs?|mailto|xmpp)$/i,k9e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function T9e(e){const t=_9e(e),n=A9e(e);return N9e(t.runSync(t.parse(n),n),e)}function _9e(e){const t=e.rehypePlugins||xz,n=e.remarkPlugins||xz,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...vz}:vz;return y9e().use(o8e).use(n).use(n9e,i).use(t)}function A9e(e){const t=e.children||"",n=new lae;return typeof t=="string"&&(n.value=t),n}function N9e(e,t){const n=t.allowedElements,i=t.allowElement,r=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,c=t.urlTransform||C9e;for(const d of k9e)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+S9e+d.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),B1(e,u),VQe(e,{Fragment:l.Fragment,components:r,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return a?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let p;for(p in EC)if(Object.hasOwn(EC,p)&&Object.hasOwn(d.properties,p)){const g=d.properties[p],b=EC[p];(b===null||b.includes(d.tagName))&&(d.properties[p]=c(String(g||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!p&&i&&typeof f=="number"&&(p=!i(d,f,h)),p&&h&&typeof f=="number")return o&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function C9e(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),r=e.indexOf("/");return t===-1||r!==-1&&t>r||n!==-1&&t>n||i!==-1&&t>i||E9e.test(e.slice(0,t))?e:""}function wz(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let i=0,r=n.indexOf(t);for(;r!==-1;)i++,r=n.indexOf(t,r+t.length);return i}function j9e(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function R9e(e,t,n){const r=Q1((n||{}).ignore||[]),s=I9e(t);let a=-1;for(;++a0?{type:"text",value:S}:void 0),S===!1?h.lastIndex=w+1:(g!==w&&v.push({type:"text",value:u.value.slice(g,w)}),Array.isArray(S)?v.push(...S):S&&v.push(S),g=w+x[0].length,O=!0),!h.global)break;x=h.exec(u.value)}return O?(g?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],i=n.indexOf(")");const r=wz(e,"(");let s=wz(e,")");for(;i!==-1&&r>s;)e+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),s++;return[e,n]}function cae(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Sp(n)||uA(n))&&(!t||n!==47)}uae.peek=nUe;function Y9e(){this.buffer()}function G9e(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function W9e(){this.buffer()}function Z9e(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function K9e(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ml(this.sliceSerialize(e)).toLowerCase(),n.label=t}function J9e(e){this.exit(e)}function eUe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ml(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tUe(e){this.exit(e)}function nUe(){return"["}function uae(e,t,n,i){const r=n.createTracker(i);let s=r.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=r.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=r.move("]"),s}function iUe(){return{enter:{gfmFootnoteCallString:Y9e,gfmFootnoteCall:G9e,gfmFootnoteDefinitionLabelString:W9e,gfmFootnoteDefinition:Z9e},exit:{gfmFootnoteCallString:K9e,gfmFootnoteCall:J9e,gfmFootnoteDefinitionLabelString:eUe,gfmFootnoteDefinition:tUe}}}function rUe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:uae},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(i,r,s,a){const o=s.createTracker(a);let c=o.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return c+=o.move(s.safe(s.associationId(i),{before:c,after:"]"})),d(),c+=o.move("]:"),i.children&&i.children.length>0&&(o.shift(4),c+=o.move((t?` -`:" ")+s.indentLines(s.containerFlow(i,o.current()),t?dae:sUe))),u(),c}}function sUe(e,t,n){return t===0?e:dae(e,t,n)}function dae(e,t,n){return(n?"":" ")+e}const aUe=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];fae.peek=dUe;function oUe(){return{canContainEols:["delete"],enter:{strikethrough:cUe},exit:{strikethrough:uUe}}}function lUe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:aUe}],handlers:{delete:fae}}}function cUe(e){this.enter({type:"delete",children:[]},e)}function uUe(e){this.exit(e)}function fae(e,t,n,i){const r=n.createTracker(i),s=n.enter("strikethrough");let a=r.move("~~");return a+=n.containerPhrasing(e,{...r.current(),before:a,after:"~"}),a+=r.move("~~"),s(),a}function dUe(){return"~"}function fUe(e){return e.length}function hUe(e,t){const n=t||{},i=(n.align||[]).concat(),r=n.stringLength||fUe,s=[],a=[],o=[],c=[];let u=0,d=-1;for(;++du&&(u=e[d].length);++Oc[O])&&(c[O]=x)}b.push(v)}a[d]=b,o[d]=y}let f=-1;if(typeof i=="object"&&"length"in i)for(;++fc[f]&&(c[f]=v),p[f]=v),h[f]=x}a.splice(1,0,h),o.splice(1,0,p),d=-1;const g=[];for(;++d "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),gUe);return r(),a}function gUe(e,t,n){return">"+(n?"":" ")+e}function bUe(e,t){return kz(e,t.inConstruct,!0)&&!kz(e,t.notInConstruct,!1)}function kz(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let i=-1;for(;++ia&&(a=s):s=1,r=i+t.length,i=n.indexOf(t,r);return a}function yUe(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function xUe(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function vUe(e,t,n,i){const r=xUe(n),s=e.value||"",a=r==="`"?"GraveAccent":"Tilde";if(yUe(e,n)){const f=n.enter("codeIndented"),h=n.indentLines(s,wUe);return f(),h}const o=n.createTracker(i),c=r.repeat(Math.max(OUe(s,r)+1,3)),u=n.enter("codeFenced");let d=o.move(c);if(e.lang){const f=n.enter(`codeFencedLang${a}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:` +`}),n}function lz(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cz(e,t){const n=K8e(e,t),i=n.one(e,void 0),r=z8e(n),s=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return r&&s.children.push({type:"text",value:` +`},r),s}function i9e(e,t){return e&&"run"in e?async function(n,i){const r=cz(n,{file:i,...t});await e.run(r,i)}:function(n,i){return cz(n,{file:i,...e||t})}}function uz(e){if(e)throw e}var rE=Object.prototype.hasOwnProperty,lae=Object.prototype.toString,dz=Object.defineProperty,fz=Object.getOwnPropertyDescriptor,hz=function(t){return typeof Array.isArray=="function"?Array.isArray(t):lae.call(t)==="[object Array]"},pz=function(t){if(!t||lae.call(t)!=="[object Object]")return!1;var n=rE.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&rE.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!i)return!1;var r;for(r in t);return typeof r>"u"||rE.call(t,r)},mz=function(t,n){dz&&n.name==="__proto__"?dz(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},gz=function(t,n){if(n==="__proto__")if(rE.call(t,n)){if(fz)return fz(t,n).value}else return;return t[n]},r9e=function e(){var t,n,i,r,s,a,o=arguments[0],c=1,u=arguments.length,d=!1;for(typeof o=="boolean"&&(d=o,o=arguments[1]||{},c=2),(o==null||typeof o!="object"&&typeof o!="function")&&(o={});ca.length;let c;o&&a.push(r);try{c=e.apply(this,a)}catch(u){const d=u;if(o&&n)throw d;return r(d)}o||(c&&c.then&&typeof c.then=="function"?c.then(s,r):c instanceof Error?r(c):s(c))}function r(a,...o){n||(n=!0,t(a,...o))}function s(a){r(null,a)}}const bc={basename:o9e,dirname:l9e,extname:c9e,join:u9e,sep:"/"};function o9e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');U1(e);let n=0,i=-1,r=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else i<0&&(s=!0,i=r+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,o=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(s){n=r+1;break}}else a<0&&(s=!0,a=r+1),o>-1&&(e.codePointAt(r)===t.codePointAt(o--)?o<0&&(i=r):(o=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function l9e(e){if(U1(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function c9e(e){U1(e);let t=e.length,n=-1,i=0,r=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?r<0?r=t:s!==1&&(s=1):r>-1&&(s=-1)}return r<0||n<0||s===0||s===1&&r===n-1&&r===i+1?"":e.slice(r,n)}function u9e(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function f9e(e,t){let n="",i=0,r=-1,s=0,a=-1,o,c;for(;++a<=e.length;){if(a2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",i=0):(n=n.slice(0,c),i=n.length-1-n.lastIndexOf("/")),r=a,s=0;continue}}else if(n.length>0){n="",i=0,r=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),i=a-r-1;r=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function U1(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const h9e={cwd:p9e};function p9e(){return"/"}function pM(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function m9e(e){if(typeof e=="string")e=new URL(e);else if(!pM(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return g9e(e)}function g9e(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n0){let[p,...g]=d;const b=i[h][1];hM(b)&&hM(p)&&(p=_C(!0,b,p)),i[h]=[u,p,...g]}}}}const x9e=new x3().freeze();function jC(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function RC(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function IC(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Oz(e){if(!hM(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yz(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function _w(e){return v9e(e)?e:new cae(e)}function v9e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function w9e(e){return typeof e=="string"||S9e(e)}function S9e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const E9e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",xz=[],vz={allowDangerousHtml:!0},k9e=/^(https?|ircs?|mailto|xmpp)$/i,T9e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _9e(e){const t=A9e(e),n=N9e(e);return C9e(t.runSync(t.parse(n),n),e)}function A9e(e){const t=e.rehypePlugins||xz,n=e.remarkPlugins||xz,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...vz}:vz;return x9e().use(l8e).use(n).use(i9e,i).use(t)}function N9e(e){const t=e.children||"",n=new cae;return typeof t=="string"&&(n.value=t),n}function C9e(e,t){const n=t.allowedElements,i=t.allowElement,r=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,c=t.urlTransform||j9e;for(const d of T9e)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+E9e+d.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),B1(e,u),XQe(e,{Fragment:l.Fragment,components:r,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return a?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let p;for(p in EC)if(Object.hasOwn(EC,p)&&Object.hasOwn(d.properties,p)){const g=d.properties[p],b=EC[p];(b===null||b.includes(d.tagName))&&(d.properties[p]=c(String(g||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!p&&i&&typeof f=="number"&&(p=!i(d,f,h)),p&&h&&typeof f=="number")return o&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function j9e(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),r=e.indexOf("/");return t===-1||r!==-1&&t>r||n!==-1&&t>n||i!==-1&&t>i||k9e.test(e.slice(0,t))?e:""}function wz(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let i=0,r=n.indexOf(t);for(;r!==-1;)i++,r=n.indexOf(t,r+t.length);return i}function R9e(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function I9e(e,t,n){const r=Q1((n||{}).ignore||[]),s=P9e(t);let a=-1;for(;++a0?{type:"text",value:S}:void 0),S===!1?h.lastIndex=w+1:(g!==w&&v.push({type:"text",value:u.value.slice(g,w)}),Array.isArray(S)?v.push(...S):S&&v.push(S),g=w+x[0].length,O=!0),!h.global)break;x=h.exec(u.value)}return O?(g?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],i=n.indexOf(")");const r=wz(e,"(");let s=wz(e,")");for(;i!==-1&&r>s;)e+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),s++;return[e,n]}function uae(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Sp(n)||uA(n))&&(!t||n!==47)}dae.peek=iUe;function G9e(){this.buffer()}function W9e(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Z9e(){this.buffer()}function K9e(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function J9e(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ml(this.sliceSerialize(e)).toLowerCase(),n.label=t}function eUe(e){this.exit(e)}function tUe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ml(this.sliceSerialize(e)).toLowerCase(),n.label=t}function nUe(e){this.exit(e)}function iUe(){return"["}function dae(e,t,n,i){const r=n.createTracker(i);let s=r.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=r.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=r.move("]"),s}function rUe(){return{enter:{gfmFootnoteCallString:G9e,gfmFootnoteCall:W9e,gfmFootnoteDefinitionLabelString:Z9e,gfmFootnoteDefinition:K9e},exit:{gfmFootnoteCallString:J9e,gfmFootnoteCall:eUe,gfmFootnoteDefinitionLabelString:tUe,gfmFootnoteDefinition:nUe}}}function sUe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:dae},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(i,r,s,a){const o=s.createTracker(a);let c=o.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return c+=o.move(s.safe(s.associationId(i),{before:c,after:"]"})),d(),c+=o.move("]:"),i.children&&i.children.length>0&&(o.shift(4),c+=o.move((t?` +`:" ")+s.indentLines(s.containerFlow(i,o.current()),t?fae:aUe))),u(),c}}function aUe(e,t,n){return t===0?e:fae(e,t,n)}function fae(e,t,n){return(n?"":" ")+e}const oUe=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];hae.peek=fUe;function lUe(){return{canContainEols:["delete"],enter:{strikethrough:uUe},exit:{strikethrough:dUe}}}function cUe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:oUe}],handlers:{delete:hae}}}function uUe(e){this.enter({type:"delete",children:[]},e)}function dUe(e){this.exit(e)}function hae(e,t,n,i){const r=n.createTracker(i),s=n.enter("strikethrough");let a=r.move("~~");return a+=n.containerPhrasing(e,{...r.current(),before:a,after:"~"}),a+=r.move("~~"),s(),a}function fUe(){return"~"}function hUe(e){return e.length}function pUe(e,t){const n=t||{},i=(n.align||[]).concat(),r=n.stringLength||hUe,s=[],a=[],o=[],c=[];let u=0,d=-1;for(;++du&&(u=e[d].length);++Oc[O])&&(c[O]=x)}b.push(v)}a[d]=b,o[d]=y}let f=-1;if(typeof i=="object"&&"length"in i)for(;++fc[f]&&(c[f]=v),p[f]=v),h[f]=x}a.splice(1,0,h),o.splice(1,0,p),d=-1;const g=[];for(;++d "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),bUe);return r(),a}function bUe(e,t,n){return">"+(n?"":" ")+e}function OUe(e,t){return kz(e,t.inConstruct,!0)&&!kz(e,t.notInConstruct,!1)}function kz(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let i=-1;for(;++ia&&(a=s):s=1,r=i+t.length,i=n.indexOf(t,r);return a}function xUe(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function vUe(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function wUe(e,t,n,i){const r=vUe(n),s=e.value||"",a=r==="`"?"GraveAccent":"Tilde";if(xUe(e,n)){const f=n.enter("codeIndented"),h=n.indentLines(s,SUe);return f(),h}const o=n.createTracker(i),c=r.repeat(Math.max(yUe(s,r)+1,3)),u=n.enter("codeFenced");let d=o.move(c);if(e.lang){const f=n.enter(`codeFencedLang${a}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:` `,encode:["`"],...o.current()})),f()}return d+=o.move(` `),s&&(d+=o.move(s+` -`)),d+=o.move(c),u(),d}function wUe(e,t,n){return(n?"":" ")+e}function v3(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function SUe(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const c=n.createTracker(i);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":` -`,...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),o()),a(),u}function EUe(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ex(e){return"&#x"+e.toString(16).toUpperCase()+";"}function zk(e,t,n){const i=f0(e),r=f0(t);return i===void 0?r===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}pae.peek=kUe;function pae(e,t,n,i){const r=EUe(n),s=n.enter("emphasis"),a=n.createTracker(i),o=a.move(r);let c=a.move(n.containerPhrasing(e,{after:r,before:o,...a.current()}));const u=c.charCodeAt(0),d=zk(i.before.charCodeAt(i.before.length-1),u,r);d.inside&&(c=Ex(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=zk(i.after.charCodeAt(0),f,r);h.inside&&(c=c.slice(0,-1)+Ex(f));const p=a.move(r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+c+p}function kUe(e,t,n){return n.options.emphasis||"*"}function TUe(e,t){let n=!1;return B1(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return n=!0,dM}),!!((!e.depth||e.depth<3)&&h3(e)&&(t.options.setext||n))}function _Ue(e,t,n,i){const r=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(i);if(TUe(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:` +`)),d+=o.move(c),u(),d}function SUe(e,t,n){return(n?"":" ")+e}function v3(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function EUe(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const c=n.createTracker(i);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":` +`,...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),o()),a(),u}function kUe(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ex(e){return"&#x"+e.toString(16).toUpperCase()+";"}function zk(e,t,n){const i=f0(e),r=f0(t);return i===void 0?r===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}mae.peek=TUe;function mae(e,t,n,i){const r=kUe(n),s=n.enter("emphasis"),a=n.createTracker(i),o=a.move(r);let c=a.move(n.containerPhrasing(e,{after:r,before:o,...a.current()}));const u=c.charCodeAt(0),d=zk(i.before.charCodeAt(i.before.length-1),u,r);d.inside&&(c=Ex(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=zk(i.after.charCodeAt(0),f,r);h.inside&&(c=c.slice(0,-1)+Ex(f));const p=a.move(r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+c+p}function TUe(e,t,n){return n.options.emphasis||"*"}function _Ue(e,t){let n=!1;return B1(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return n=!0,dM}),!!((!e.depth||e.depth<3)&&h3(e)&&(t.options.setext||n))}function AUe(e,t,n,i){const r=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(i);if(_Ue(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:` `,after:` `});return f(),d(),h+` `+(r===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(` `))+1))}const a="#".repeat(r),o=n.enter("headingAtx"),c=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:` -`,...s.current()});return/^[\t ]/.test(u)&&(u=Ex(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),c(),o(),u}mae.peek=AUe;function mae(e){return e.value||""}function AUe(){return"<"}gae.peek=NUe;function gae(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const c=n.createTracker(i);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),o()),u+=c.move(")"),a(),u}function NUe(){return"!"}bae.peek=CUe;function bae(e,t,n,i){const r=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(i);let c=o.move("![");const u=n.safe(e.alt,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),r==="full"||!u||u!==f?c+=o.move(f+"]"):r==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function CUe(){return"!"}Oae.peek=jUe;function Oae(e,t,n){let i=e.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(i);)r+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++s\u007F]/.test(e.url))}xae.peek=RUe;function xae(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.createTracker(i);let o,c;if(yae(e,n)){const d=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=d,f}o=n.enter("link"),c=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=a.move(" "+r),u+=a.move(n.safe(e.title,{before:u,after:r,...a.current()})),u+=a.move(r),c()),u+=a.move(")"),o(),u}function RUe(e,t,n){return yae(e,n)?"<":"["}vae.peek=IUe;function vae(e,t,n,i){const r=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(i);let c=o.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),r==="full"||!u||u!==f?c+=o.move(f+"]"):r==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function IUe(){return"["}function w3(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function PUe(e){const t=w3(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function MUe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function wae(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function LUe(e,t,n,i){const r=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?MUe(n):w3(n);const o=e.ordered?a==="."?")":".":PUe(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),wae(n)===a&&d){let f=-1;for(;++f-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(r==="tab"||r==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(i);o.move(s+" ".repeat(a-s.length)),o.shift(a);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),d);return c(),u;function d(f,h,p){return h?(p?"":" ".repeat(a))+f:(p?s:s+" ".repeat(a-s.length))+f}}function QUe(e,t,n,i){const r=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,i);return s(),r(),a}const BUe=Q1(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function UUe(e,t,n,i){return(e.children.some(function(a){return BUe(a)})?n.containerPhrasing:n.containerFlow).call(n,e,i)}function zUe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Sae.peek=FUe;function Sae(e,t,n,i){const r=zUe(n),s=n.enter("strong"),a=n.createTracker(i),o=a.move(r+r);let c=a.move(n.containerPhrasing(e,{after:r,before:o,...a.current()}));const u=c.charCodeAt(0),d=zk(i.before.charCodeAt(i.before.length-1),u,r);d.inside&&(c=Ex(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=zk(i.after.charCodeAt(0),f,r);h.inside&&(c=c.slice(0,-1)+Ex(f));const p=a.move(r+r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+c+p}function FUe(e,t,n){return n.options.strong||"*"}function VUe(e,t,n,i){return n.safe(e.value,i)}function XUe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function qUe(e,t,n){const i=(wae(n)+(n.options.ruleSpaces?" ":"")).repeat(XUe(n));return n.options.ruleSpaces?i.slice(0,-1):i}const Eae={blockquote:mUe,break:Tz,code:vUe,definition:SUe,emphasis:pae,hardBreak:Tz,heading:_Ue,html:mae,image:gae,imageReference:bae,inlineCode:Oae,link:xae,linkReference:vae,list:LUe,listItem:$Ue,paragraph:QUe,root:UUe,strong:Sae,text:VUe,thematicBreak:qUe};function HUe(){return{enter:{table:YUe,tableData:_z,tableHeader:_z,tableRow:WUe},exit:{codeText:ZUe,table:GUe,tableData:DC,tableHeader:DC,tableRow:DC}}}function YUe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function GUe(e){this.exit(e),this.data.inTable=void 0}function WUe(e){this.enter({type:"tableRow",children:[]},e)}function DC(e){this.exit(e)}function _z(e){this.enter({type:"tableCell",children:[]},e)}function ZUe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,KUe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function KUe(e,t){return t==="|"?t:e}function JUe(e){const t=e||{},n=t.tableCellPadding,i=t.tablePipeAlign,r=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,...s.current()});return/^[\t ]/.test(u)&&(u=Ex(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),c(),o(),u}gae.peek=NUe;function gae(e){return e.value||""}function NUe(){return"<"}bae.peek=CUe;function bae(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const c=n.createTracker(i);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),o()),u+=c.move(")"),a(),u}function CUe(){return"!"}Oae.peek=jUe;function Oae(e,t,n,i){const r=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(i);let c=o.move("![");const u=n.safe(e.alt,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),r==="full"||!u||u!==f?c+=o.move(f+"]"):r==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function jUe(){return"!"}yae.peek=RUe;function yae(e,t,n){let i=e.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(i);)r+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++s\u007F]/.test(e.url))}vae.peek=IUe;function vae(e,t,n,i){const r=v3(n),s=r==='"'?"Quote":"Apostrophe",a=n.createTracker(i);let o,c;if(xae(e,n)){const d=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=d,f}o=n.enter("link"),c=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=a.move(" "+r),u+=a.move(n.safe(e.title,{before:u,after:r,...a.current()})),u+=a.move(r),c()),u+=a.move(")"),o(),u}function IUe(e,t,n){return xae(e,n)?"<":"["}wae.peek=PUe;function wae(e,t,n,i){const r=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(i);let c=o.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),r==="full"||!u||u!==f?c+=o.move(f+"]"):r==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function PUe(){return"["}function w3(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function MUe(e){const t=w3(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function LUe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Sae(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function DUe(e,t,n,i){const r=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?LUe(n):w3(n);const o=e.ordered?a==="."?")":".":MUe(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Sae(n)===a&&d){let f=-1;for(;++f-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(r==="tab"||r==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(i);o.move(s+" ".repeat(a-s.length)),o.shift(a);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),d);return c(),u;function d(f,h,p){return h?(p?"":" ".repeat(a))+f:(p?s:s+" ".repeat(a-s.length))+f}}function BUe(e,t,n,i){const r=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,i);return s(),r(),a}const UUe=Q1(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function zUe(e,t,n,i){return(e.children.some(function(a){return UUe(a)})?n.containerPhrasing:n.containerFlow).call(n,e,i)}function FUe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Eae.peek=VUe;function Eae(e,t,n,i){const r=FUe(n),s=n.enter("strong"),a=n.createTracker(i),o=a.move(r+r);let c=a.move(n.containerPhrasing(e,{after:r,before:o,...a.current()}));const u=c.charCodeAt(0),d=zk(i.before.charCodeAt(i.before.length-1),u,r);d.inside&&(c=Ex(u)+c.slice(1));const f=c.charCodeAt(c.length-1),h=zk(i.after.charCodeAt(0),f,r);h.inside&&(c=c.slice(0,-1)+Ex(f));const p=a.move(r+r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+c+p}function VUe(e,t,n){return n.options.strong||"*"}function XUe(e,t,n,i){return n.safe(e.value,i)}function qUe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HUe(e,t,n){const i=(Sae(n)+(n.options.ruleSpaces?" ":"")).repeat(qUe(n));return n.options.ruleSpaces?i.slice(0,-1):i}const kae={blockquote:gUe,break:Tz,code:wUe,definition:EUe,emphasis:mae,hardBreak:Tz,heading:AUe,html:gae,image:bae,imageReference:Oae,inlineCode:yae,link:vae,linkReference:wae,list:DUe,listItem:QUe,paragraph:BUe,root:zUe,strong:Eae,text:XUe,thematicBreak:HUe};function YUe(){return{enter:{table:GUe,tableData:_z,tableHeader:_z,tableRow:ZUe},exit:{codeText:KUe,table:WUe,tableData:DC,tableHeader:DC,tableRow:DC}}}function GUe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function WUe(e){this.exit(e),this.data.inTable=void 0}function ZUe(e){this.enter({type:"tableRow",children:[]},e)}function DC(e){this.exit(e)}function _z(e){this.enter({type:"tableCell",children:[]},e)}function KUe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,JUe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function JUe(e,t){return t==="|"?t:e}function e7e(e){const t=e||{},n=t.tableCellPadding,i=t.tablePipeAlign,r=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:a,tableCell:c,tableRow:o}};function a(p,g,b,y){return u(d(p,b,y),p.align)}function o(p,g,b,y){const O=f(p,b,y),v=u([O]);return v.slice(0,v.indexOf(` -`))}function c(p,g,b,y){const O=b.enter("tableCell"),v=b.enter("phrasing"),x=b.containerPhrasing(p,{...y,before:s,after:s});return v(),O(),x}function u(p,g){return hUe(p,{align:g,alignDelimiters:i,padding:n,stringLength:r})}function d(p,g,b){const y=p.children;let O=-1;const v=[],x=g.enter("table");for(;++O0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const b7e={tokenize:k7e,partial:!0};function O7e(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:w7e,continuation:{tokenize:S7e},exit:E7e}},text:{91:{name:"gfmFootnoteCall",tokenize:v7e},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:y7e,resolveTo:x7e}}}}function y7e(e,t,n){const i=this;let r=i.events.length;const s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;r--;){const c=i.events[r][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!a||!a._balanced)return n(c);const u=Ml(i.sliceSerialize({start:a.end,end:i.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function x7e(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...o),e}function v7e(e,t,n){const i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!a||f===null||f===91||Li(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return r.includes(Ml(i.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Li(f)||(a=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function w7e(e,t,n){const i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s,a=0,o;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!o||g===null||g===91||Li(g))return n(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=Ml(i.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Li(g)||(o=!0),a++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),r.includes(s)||r.push(s),Yn(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function S7e(e,t,n){return e.check($1,t,e.attempt(b7e,t,n))}function E7e(e){e.exit("gfmFootnoteDefinition")}function k7e(e,t,n){const i=this;return Yn(e,r,"gfmFootnoteDefinitionIndent",5);function r(s){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function T7e(e){let n=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:s,resolveAll:r};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function r(a,o){let c=-1;for(;++c1?c(g):(a.consume(g),f++,p);if(f<2&&!n)return c(g);const y=a.exit("strikethroughSequenceTemporary"),O=f0(g);return y._open=!O||O===2&&!!b,y._close=!b||b===2&&!!O,o(g)}}}class _7e{constructor(){this.map=[]}add(t,n,i){A7e(this,t,n,i)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];i.push(t.slice()),t.length=0;let r=i.pop();for(;r;){for(const s of r)t.push(s);r=i.pop()}this.map.length=0}}function A7e(e,t,n,i){let r=0;if(!(n===0&&i.length===0)){for(;r-1;){const P=i.events[C][1].type;if(P==="lineEnding"||P==="linePrefix")C--;else break}const M=C>-1?i.events[C][1].type:null,L=M==="tableHead"||M==="tableRow"?S:c;return L===S&&i.parser.lazy[i.now().line]?n(N):L(N)}function c(N){return e.enter("tableHead"),e.enter("tableRow"),u(N)}function u(N){return N===124||(a=!0,s+=1),d(N)}function d(N){return N===null?n(N):Ht(N)?s>1?(s=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),p):n(N):Rn(N)?Yn(e,d,"whitespace")(N):(s+=1,a&&(a=!1,r+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(N)))}function f(N){return N===null||N===124||Li(N)?(e.exit("data"),d(N)):(e.consume(N),N===92?h:f)}function h(N){return N===92||N===124?(e.consume(N),f):f(N)}function p(N){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(N):(e.enter("tableDelimiterRow"),a=!1,Rn(N)?Yn(e,g,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?y(N):N===124?(a=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),b):E(N)}function b(N){return Rn(N)?Yn(e,y,"whitespace")(N):y(N)}function y(N){return N===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),O):N===45?(s+=1,O(N)):N===null||Ht(N)?w(N):E(N)}function O(N){return N===45?(e.enter("tableDelimiterFiller"),v(N)):E(N)}function v(N){return N===45?(e.consume(N),v):N===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(N))}function x(N){return Rn(N)?Yn(e,w,"whitespace")(N):w(N)}function w(N){return N===124?g(N):N===null||Ht(N)?!a||r!==s?E(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):E(N)}function E(N){return n(N)}function S(N){return e.enter("tableRow"),k(N)}function k(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),k):N===null||Ht(N)?(e.exit("tableRow"),t(N)):Rn(N)?Yn(e,k,"whitespace")(N):(e.enter("data"),T(N))}function T(N){return N===null||N===124||Li(N)?(e.exit("data"),k(N)):(e.consume(N),N===92?A:T)}function A(N){return N===92||N===124?(e.consume(N),T):T(N)}}function R7e(e,t){let n=-1,i=!0,r=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,c=0,u,d,f;const h=new _7e;for(;++nn[2]+1){const g=n[2]+1,b=n[3]-n[2]-1;e.add(g,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return r!==void 0&&(s.end=Object.assign({},Am(t.events,r)),e.add(r,0,[["exit",s,t]]),s=void 0),s}function Nz(e,t,n,i,r){const s=[],a=Am(t.events,n);r&&(r.end=Object.assign({},a),s.push(["exit",r,t])),i.end=Object.assign({},a),s.push(["exit",i,t]),e.add(n+1,0,s)}function Am(e,t){const n=e[t],i=n[0]==="enter"?"start":"end";return n[1][i]}const I7e={name:"tasklistCheck",tokenize:M7e};function P7e(){return{text:{91:I7e}}}function M7e(e,t,n){const i=this;return r;function r(c){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Li(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(c)}function o(c){return Ht(c)?t(c):Rn(c)?e.check({tokenize:L7e},t,n)(c):n(c)}}function L7e(e,t,n){return Yn(e,i,"whitespace");function i(r){return r===null?n(r):t(r)}}function D7e(e){return Use([l7e(),O7e(),T7e(e),C7e(),P7e()])}const $7e={};function Q7e(e){const t=this,n=e||$7e,i=t.data(),r=i.micromarkExtensions||(i.micromarkExtensions=[]),s=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);r.push(D7e(n)),s.push(r7e()),a.push(s7e(n))}const Cz=function(e,t,n){const i=Q1(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++tu&&(u=d):d&&(u!==void 0&&u>-1&&c.push(` -`.repeat(u)||" "),u=-1,c.push(d))}return c.join("")}function Pae(e,t,n){return e.type==="element"?H7e(e,t,n):e.type==="text"?n.whitespace==="normal"?Mae(e,n):Y7e(e):[]}function H7e(e,t,n){const i=Lae(e,n),r=e.children||[];let s=-1,a=[];if(X7e(e))return a;let o,c;for(gM(e)||Pz(e)&&Cz(t,e,Pz)?c=` -`:V7e(e)?(o=2,c=2):Iae(e)&&(o=1,c=1);++s]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],y=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],O=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],w={type:b,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:y},E={className:"function.dispatch",relevance:0,keywords:{_hint:O},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},S=[E,f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:w,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:w,illegal:"",keywords:w,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:w},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function tze(e){const t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=eze(e),i=n.keywords;return i.type=[...i.type,...t.type],i.literal=[...i.literal,...t.literal],i.built_in=[...i.built_in,...t.built_in],i._hints=t._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function Dae(e){const t=e.regex,n={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});const r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(o);const c={match:/\\"/},u={className:"string",begin:/'/,end:/'/},d={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],p=e.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),g={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],O={match:/(\/[a-z._-]+)+/},v=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],x=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],w=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],E=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:y,built_in:[...v,...x,"set","shopt",...w,...E]},contains:[p,e.SHEBANG(),g,f,s,a,O,o,c,u,d,n]}}function nze(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="decltype\\(auto\\)",r="[a-zA-Z_]\\w*::",a="("+i+"|"+t.optional(r)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",y={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},O=[f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],v={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:y,contains:O.concat([{begin:/\(/,end:/\)/,keywords:y,contains:O.concat(["self"]),relevance:0}]),relevance:0},x={begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:y,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:y,relevance:0},{begin:p,returnBegin:!0,contains:[e.inherit(h,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:y,disableAutodetect:!0,illegal:"=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:f,strings:u,keywords:y}}}function ize(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="decltype\\(auto\\)",r="[a-zA-Z_]\\w*::",a="(?!struct)("+i+"|"+t.optional(r)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],y=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],O=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],w={type:b,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:y},E={className:"function.dispatch",relevance:0,keywords:{_hint:O},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},S=[E,f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:w,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:w,illegal:"",keywords:w,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:w},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function rze(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],i=["default","false","null","true"],r=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],a={keyword:r.concat(s),built_in:t,literal:i},o=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),c={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},u={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},d={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=e.inherit(d,{illegal:/\n/}),h={className:"subst",begin:/\{/,end:/\}/,keywords:a},p=e.inherit(h,{illegal:/\n/}),g={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,p]},b={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]},y=e.inherit(b,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},p]});h.contains=[b,g,d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,e.C_BLOCK_COMMENT_MODE],p.contains=[y,g,f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const O={variants:[u,b,g,d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},v={begin:"<",end:">",contains:[{beginKeywords:"in out"},o]},x=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",w={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:a,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:""},{begin:""}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},O,c,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},o,v,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[o,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[o,v,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+x+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:a,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,v],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,relevance:0,contains:[O,c,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},w]}}const sze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),aze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],oze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],lze=[...aze,...oze],cze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),uze=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),dze=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),fze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function hze(e){const t=e.regex,n=sze(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",s=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",o=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,i,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+uze.join("|")+")"},{begin:":(:)?("+dze.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+fze.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...o,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...o,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:cze.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...o,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+lze.join("|")+")\\b"}]}}function pze(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function mze(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"Qae(e,t,n-1))}function bze(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",i=n+Qae("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},d={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[d,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+i+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,Mz,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Mz,u]}}const Lz="[A-Za-z$_][0-9A-Za-z$_]*",Oze=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],yze=["true","false","null","undefined","NaN","Infinity"],Bae=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Uae=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],zae=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xze=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],vze=[].concat(zae,Bae,Uae);function Fae(e){const t=e.regex,n=(U,{after:B})=>{const I="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,B)=>{const I=U[0].length+U.index,X=U.input[I];if(X==="<"||X===","){B.ignoreMatch();return}X===">"&&(n(U,{after:I})||B.ignoreMatch());let q;const D=U.input.substring(I);if(q=D.match(/^\s*=/)){B.ignoreMatch();return}if((q=D.match(/^\s+extends\s+/))&&q.index===0){B.ignoreMatch();return}}},o={$pattern:Lz,keyword:Oze,literal:yze,built_in:vze,"variable.language":xze},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(x)});const w=[].concat(v,h.contains),E=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(w)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E},k={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Bae,...Uae]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},C={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function M(U){return t.concat("(?!",U.join("|"),")")}const L={match:t.concat(/\b/,M([...zae,"super","import"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},j="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,v,{match:/\$\d+/},f,T,{scope:"attr",match:i+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:j,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,C,k,Q,{match:/\$[(.]/}]}}function Vae(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},i=["true","false","null"],r={scope:"literal",beginKeywords:i.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:i},contains:[t,n,e.QUOTE_STRING_MODE,r,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Cm="[0-9](_*[0-9])*",jw=`\\.(${Cm})`,Rw="[0-9a-fA-F](_*[0-9a-fA-F])*",wze={className:"number",variants:[{begin:`(\\b(${Cm})((${jw})|\\.)?|(${jw}))[eE][+-]?(${Cm})[fFdD]?\\b`},{begin:`\\b(${Cm})((${jw})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${jw})[fFdD]?\\b`},{begin:`\\b(${Cm})[fFdD]\\b`},{begin:`\\b0[xX]((${Rw})\\.?|(${Rw})?\\.(${Rw}))[pP][+-]?(${Cm})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Rw})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Sze(e){const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},i={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},r={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},a={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,r]}]};r.contains.push(a);const o={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},c={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(a,{className:"string"}),"self"]}]},u=wze,d=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),f={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},h=f;return h.variants[1].contains=[f],f.variants[1].contains=[h],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,d,n,i,o,c,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin://,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[f,e.C_LINE_COMMENT_MODE,d],relevance:0},e.C_LINE_COMMENT_MODE,d,o,c,a,e.C_NUMBER_MODE]},d]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},o,c]},a,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:` -`},u]}}const Eze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),kze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Tze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],_ze=[...kze,...Tze],Aze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Xae=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),qae=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Nze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),Cze=Xae.concat(qae).sort().reverse();function jze(e){const t=Eze(e),n=Cze,i="and or not only",r="[\\w-]+",s="("+r+"|@\\{"+r+"\\})",a=[],o=[],c=function(x){return{className:"string",begin:"~?"+x+".*?"+x}},u=function(x,w,E){return{className:x,begin:w,relevance:E}},d={$pattern:/[a-z-]+/,keyword:i,attribute:Aze.join(" ")},f={begin:"\\(",end:"\\)",contains:o,keywords:d,relevance:0};o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,c("'"),c('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,f,u("variable","@@?"+r,10),u("variable","@\\{"+r+"\\}"),u("built_in","~?`[^`]*?`"),{className:"attribute",begin:r+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const h=o.concat({begin:/\{/,end:/\}/,contains:a}),p={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(o)},g={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Nze.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:o}}]},b={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:d,returnEnd:!0,contains:o,relevance:0}},y={className:"variable",variants:[{begin:"@"+r+"\\s*:",relevance:15},{begin:"@"+r}],starts:{end:"[;}]",returnEnd:!0,contains:h}},O={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,p,u("keyword","all\\b"),u("variable","@\\{"+r+"\\}"),{begin:"\\b("+_ze.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,u("selector-tag",s,0),u("selector-id","#"+s),u("selector-class","\\."+s,0),u("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Xae.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+qae.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:h},{begin:"!important"},t.FUNCTION_DISPATCH]},v={begin:r+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[O]};return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,y,v,g,O,p,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:a}}function Rze(e){const t="\\[=*\\[",n="\\]=*\\]",i={begin:t,end:n,contains:["self"]},r=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[i],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:r.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:r}].concat(r)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[i],relevance:5}])}}function Hae(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%",subLanguage:"xml",relevance:0},i={begin:"^[-\\*]{3,}",end:"$"},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},o=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,o,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},d={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},f=e.inherit(u,{contains:[]}),h=e.inherit(d,{contains:[]});u.contains.push(h),d.contains.push(f);let p=[n,c];return[u,d,f,h].forEach(O=>{O.contains=O.contains.concat(p)}),p=p.concat(u,d),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:p},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:p}]}]},n,s,u,d,{className:"quote",begin:"^>\\s+",contains:p,end:"$"},r,i,c,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Ize(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,o={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},c={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:o,illegal:"/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+c.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:c,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function Pze(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],i=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},a={begin:/->\{/,end:/\}/},o={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[o]},u={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},d=[e.BACKSLASH_ESCAPE,s,c],f=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],h=(b,y,O="\\1")=>{const v=O==="\\1"?O:t.concat(O,y);return t.concat(t.concat("(?:",b,")"),y,/(?:\\.|[^\\\/])*?/,v,/(?:\\.|[^\\\/])*?/,O,i)},p=(b,y,O)=>t.concat(t.concat("(?:",b,")"),y,/(?:\\.|[^\\\/])*?/,O,i),g=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),a,{className:"string",contains:d,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},u,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:h("s|tr|y",t.either(...f,{capture:!0}))},{begin:h("s|tr|y","\\(","\\)")},{begin:h("s|tr|y","\\[","\\]")},{begin:h("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:p("(?:m|qr)?",/\//,/\//)},{begin:p("m|qr",t.either(...f,{capture:!0}),/\1/)},{begin:p("m|qr",/\(/,/\)/)},{begin:p("m|qr",/\[/,/\]/)},{begin:p("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o,u]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=g,a.contains=g,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:g}}function Mze(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,i=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),r=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=t.concat(/[A-Z]+/,n),a={scope:"variable",match:"\\$+"+i},o={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},c={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},u=e.inherit(e.APOS_STRING_MODE,{illegal:null}),d=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)}),f={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(c),"on:begin":(P,Q)=>{Q.data._beginMatch=P[1]||P[2]},"on:end":(P,Q)=>{Q.data._beginMatch!==P[1]&&Q.ignoreMatch()}},h=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p=`[ -]`,g={scope:"string",variants:[d,u,f,h]},b={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},y=["false","null","true"],O=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],v=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],w={keyword:O,literal:(P=>{const Q=[];return P.forEach(j=>{Q.push(j),j.toLowerCase()===j?Q.push(j.toUpperCase()):Q.push(j.toLowerCase())}),Q})(y),built_in:v},E=P=>P.map(Q=>Q.replace(/\|\d+$/,"")),S={variants:[{match:[/new/,t.concat(p,"+"),t.concat("(?!",E(v).join("\\b|"),"\\b)"),r],scope:{1:"keyword",4:"title.class"}}]},k=t.concat(i,"\\b(?!\\()"),T={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),k],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[r,t.concat(/::/,t.lookahead(/(?!class\b)/)),k],scope:{1:"title.class",3:"variable.constant"}},{match:[r,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[r,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},A={scope:"attr",match:t.concat(i,t.lookahead(":"),t.lookahead(/(?!::)/))},N={relevance:0,begin:/\(/,end:/\)/,keywords:w,contains:[A,a,T,e.C_BLOCK_COMMENT_MODE,g,b,S]},C={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",E(O).join("\\b|"),"|",E(v).join("\\b|"),"\\b)"),i,t.concat(p,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[N]};N.contains.push(C);const M=[A,T,e.C_BLOCK_COMMENT_MODE,g,b,S],L={begin:t.concat(/#\[\s*\\?/,t.either(r,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:y,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:y,keyword:["new","array"]},contains:["self",...M]},...M,{scope:"meta",variants:[{match:r},{match:s}]}]};return{case_insensitive:!1,keywords:w,contains:[L,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},o,{scope:"variable.language",match:/\$this\b/},a,C,T,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},S,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:w,contains:["self",L,a,T,e.C_BLOCK_COMMENT_MODE,g,b]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},g,b]}}function Lze(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function Dze(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Gae(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],o={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:o,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,d,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,d,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",p=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,g=`\\b|${i.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${p}))[eE][+-]?(${h})[jJ]?(?=${g})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${h})[jJ](?=${g})`}]},y={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:o,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},O={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:["self",c,b,f,e.HASH_COMMENT_MODE]}]};return u.contains=[f,b,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:o,illegal:/(<\/|\?)|=>/,contains:[c,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,y,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[O]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,O,f]}]}}function $ze(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Qze(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),r=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[r,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:r},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Bze(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),r=t.concat(i,/(::\w+)*/),a={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},o={className:"doctag",begin:"@[A-Za-z]+"},c={begin:"#<",end:">"},u=[e.COMMENT("#","$",{contains:[o]}),e.COMMENT("^=begin","^=end",{contains:[o],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],d={className:"subst",begin:/#\{/,end:/\}/,keywords:a},f={className:"string",contains:[e.BACKSLASH_ESCAPE,d],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,d]})]}]},h="[1-9](_?[0-9])*|0",p="[0-9](_?[0-9])*",g={className:"number",relevance:0,variants:[{begin:`\\b(${h})(\\.(${p}))?([eE][+-]?(${p})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},b={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:a}]},S=[f,{variants:[{match:[/class\s+/,r,/\s+<\s+/,r]},{match:[/\b(class|module)\s+/,r]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:a},{match:[/(include|extend)\s+/,r],scope:{2:"title.class"},keywords:a},{relevance:0,match:[r,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:i,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[f,{begin:n}],relevance:0},g,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:a},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,d],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(c,u),relevance:0}].concat(c,u);d.contains=S,b.contains=S;const N=[{begin:/^\s*=>/,starts:{end:"$",contains:S}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:a,contains:S}}];return u.unshift(c),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:a,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(N).concat(u).concat(S)}}function Uze(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,r,t.lookahead(/\s*\(/))},a="([ui](8|16|32|64|128|size)|f(32|64))?",o=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],c=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],d=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:d,keyword:o,literal:c,built_in:u},illegal:""},s]}}const zze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Fze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Vze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],Xze=[...Fze,...Vze],qze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Hze=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Yze=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Gze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Wze(e){const t=zze(e),n=Yze,i=Hze,r="@[a-z-]+",s="and or not only",o={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+Xze.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+i.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},o,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Gze.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,o,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:r,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:qze.join(" ")},contains:[{begin:r,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},o,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function Zze(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Kze(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],a=["double precision","large object","with timezone","without timezone"],o=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=d,g=[...u,...c].filter(E=>!d.includes(E)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},O={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(E){return t.concat(/\b/,t.either(...E.map(S=>S.replace(/\s+/,"\\s+"))),/\b/)}const x={scope:"keyword",match:v(h),relevance:0};function w(E,{exceptions:S,when:k}={}){const T=k;return S=S||[],E.map(A=>A.match(/\|\d+$/)||S.includes(A)?A:T(A)?`${A}|0`:A)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:w(g,{when:E=>E.length<3}),literal:s,type:o,built_in:f},contains:[{scope:"type",match:v(a)},x,O,b,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,y]}}function Wae(e){return e?typeof e=="string"?e:e.source:null}function eO(e){return wi("(?=",e,")")}function wi(...e){return e.map(n=>Wae(n)).join("")}function Jze(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function da(...e){return"("+(Jze(e).capture?"":"?:")+e.map(i=>Wae(i)).join("|")+")"}const k3=e=>wi(/\b/,e,/\w$/.test(e)?/\b/:/\B/),eFe=["Protocol","Type"].map(k3),Dz=["init","self"].map(k3),tFe=["Any","Self"],$C=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],$z=["false","nil","true"],nFe=["assignment","associativity","higherThan","left","lowerThan","none","right"],iFe=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Qz=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Zae=da(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Kae=da(Zae,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),QC=wi(Zae,Kae,"*"),Jae=da(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Fk=da(Jae,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),mc=wi(Jae,Fk,"*"),Iw=wi(/[A-Z]/,Fk,"*"),rFe=["attached","autoclosure",wi(/convention\(/,da("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",wi(/objc\(/,mc,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],sFe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function aFe(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),i=[e.C_LINE_COMMENT_MODE,n],r={match:[/\./,da(...eFe,...Dz)],className:{2:"keyword"}},s={match:wi(/\./,da(...$C)),relevance:0},a=$C.filter(oe=>typeof oe=="string").concat(["_|0"]),o=$C.filter(oe=>typeof oe!="string").concat(tFe).map(k3),c={variants:[{className:"keyword",match:da(...o,...Dz)}]},u={$pattern:da(/\b\w+/,/#\w+/),keyword:a.concat(iFe),literal:$z},d=[r,s,c],f={match:wi(/\./,da(...Qz)),relevance:0},h={className:"built_in",match:wi(/\b/,da(...Qz),/(?=\()/)},p=[f,h],g={match:/->/,relevance:0},b={className:"operator",relevance:0,variants:[{match:QC},{match:`\\.(\\.|${Kae})+`}]},y=[g,b],O="([0-9]_*)+",v="([0-9a-fA-F]_*)+",x={className:"number",relevance:0,variants:[{match:`\\b(${O})(\\.(${O}))?([eE][+-]?(${O}))?\\b`},{match:`\\b0x(${v})(\\.(${v}))?([pP][+-]?(${O}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},w=(oe="")=>({className:"subst",variants:[{match:wi(/\\/,oe,/[0\\tnr"']/)},{match:wi(/\\/,oe,/u\{[0-9a-fA-F]{1,8}\}/)}]}),E=(oe="")=>({className:"subst",match:wi(/\\/,oe,/[\t ]*(?:[\r\n]|\r\n)/)}),S=(oe="")=>({className:"subst",label:"interpol",begin:wi(/\\/,oe,/\(/),end:/\)/}),k=(oe="")=>({begin:wi(oe,/"""/),end:wi(/"""/,oe),contains:[w(oe),E(oe),S(oe)]}),T=(oe="")=>({begin:wi(oe,/"/),end:wi(/"/,oe),contains:[w(oe),S(oe)]}),A={className:"string",variants:[k(),k("#"),k("##"),k("###"),T(),T("#"),T("##"),T("###")]},N=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],C={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:N},M=oe=>{const Ne=wi(oe,/\//),Oe=wi(/\//,oe);return{begin:Ne,end:Oe,contains:[...N,{scope:"comment",begin:`#(?!.*${Oe})`,end:/$/}]}},L={scope:"regexp",variants:[M("###"),M("##"),M("#"),C]},P={match:wi(/`/,mc,/`/)},Q={className:"variable",match:/\$\d+/},j={className:"variable",match:`\\$${Fk}+`},$=[P,Q,j],U={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:sFe,contains:[...y,x,A]}]}},B={scope:"keyword",match:wi(/@/,da(...rFe),eO(da(/\(/,/\s+/)))},I={scope:"meta",match:wi(/@/,mc)},X=[U,B,I],q={match:eO(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:wi(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Fk,"+")},{className:"type",match:Iw,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:wi(/\s+&\s+/,eO(Iw)),relevance:0}]},D={begin://,keywords:u,contains:[...i,...d,...X,g,q]};q.contains.push(D);const H={match:wi(mc,/\s*:/),keywords:"_|0",relevance:0},re={begin:/\(/,end:/\)/,relevance:0,keywords:u,contains:["self",H,...i,L,...d,...p,...y,x,A,...$,...X,q]},fe={begin://,keywords:"repeat each",contains:[...i,q]},Ae={begin:da(eO(wi(mc,/\s*:/)),eO(wi(mc,/\s+/,mc,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:mc}]},J={begin:/\(/,end:/\)/,keywords:u,contains:[Ae,...i,...d,...y,x,A,...X,q,re],endsParent:!0,illegal:/["']/},ie={match:[/(func|macro)/,/\s+/,da(P.match,mc,QC)],className:{1:"keyword",3:"title.function"},contains:[fe,J,t],illegal:[/\[/,/%/]},ue={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[fe,J,t],illegal:/\[|%/},ye={match:[/operator/,/\s+/,QC],className:{1:"keyword",3:"title"}},Se={begin:[/precedencegroup/,/\s+/,Iw],className:{1:"keyword",3:"title"},contains:[q],keywords:[...nFe,...$z],end:/}/},Re={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Ee={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},me={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,mc,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:u,contains:[fe,...d,{begin:/:/,end:/\{/,keywords:u,contains:[{scope:"title.class.inherited",match:Iw},...d],relevance:0}]};for(const oe of A.variants){const Ne=oe.contains.find(Ve=>Ve.label==="interpol");Ne.keywords=u;const Oe=[...d,...p,...y,x,A,...$];Ne.contains=[...Oe,{begin:/\(/,end:/\)/,contains:["self",...Oe]}]}return{name:"Swift",keywords:u,contains:[...i,ie,ue,Re,Ee,me,ye,Se,{beginKeywords:"import",end:/$/,contains:[...i],relevance:0},L,...d,...p,...y,x,A,...$,...X,q,re]}}const Vk="[A-Za-z$_][0-9A-Za-z$_]*",eoe=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],toe=["true","false","null","undefined","NaN","Infinity"],noe=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ioe=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],roe=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],soe=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],aoe=[].concat(roe,noe,ioe);function oFe(e){const t=e.regex,n=(U,{after:B})=>{const I="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,B)=>{const I=U[0].length+U.index,X=U.input[I];if(X==="<"||X===","){B.ignoreMatch();return}X===">"&&(n(U,{after:I})||B.ignoreMatch());let q;const D=U.input.substring(I);if(q=D.match(/^\s*=/)){B.ignoreMatch();return}if((q=D.match(/^\s+extends\s+/))&&q.index===0){B.ignoreMatch();return}}},o={$pattern:Vk,keyword:eoe,literal:toe,built_in:aoe,"variable.language":soe},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(x)});const w=[].concat(v,h.contains),E=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(w)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E},k={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...noe,...ioe]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},C={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function M(U){return t.concat("(?!",U.join("|"),")")}const L={match:t.concat(/\b/,M([...roe,"super","import"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},j="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,v,{match:/\$\d+/},f,T,{scope:"attr",match:i+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:j,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,C,k,Q,{match:/\$[(.]/}]}}function ooe(e){const t=e.regex,n=oFe(e),i=Vk,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[n.exports.CLASS_REFERENCE]},o={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Vk,keyword:eoe.concat(c),literal:toe,built_in:aoe.concat(r),"variable.language":soe},d={className:"meta",begin:"@"+i},f=(b,y,O)=>{const v=b.contains.findIndex(x=>x.label===y);if(v===-1)throw new Error("can not find mode to replace");b.contains.splice(v,1,O)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(b=>b.scope==="attr"),p=Object.assign({},h,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,p]),n.contains=n.contains.concat([d,s,a,p]),f(n,"shebang",e.SHEBANG()),f(n,"use_strict",o);const g=n.contains.find(b=>b.label==="func.def");return g.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function lFe(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},i={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},r=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,a=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,o=/\d{1,2}(:\d{1,2}){1,2}/,c={className:"literal",variants:[{begin:t.concat(/# */,t.either(s,r),/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,t.either(s,r),/ +/,t.either(a,o),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},d={className:"label",begin:/^\w+:/},f=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),h=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,i,c,u,d,f,h,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[h]}]}}function cFe(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),i=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],r={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},a={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},o={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},c={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:i},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,a,r,e.QUOTE_STRING_MODE,c,u,o]}}function uFe(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=e.inherit(s,{begin:/\(/,end:/\)/}),o=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin://,relevance:10,contains:[s,c,o,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin://,contains:[s,a,c,o]}]}]},e.COMMENT(//,{relevance:10}),{begin://,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(//,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function loe(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},o=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),h={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},p={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},g={begin:/\{/,end:/\}/,contains:[p],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[p],illegal:"\\n",relevance:0},y=[i,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},h,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},g,b,s,a],O=[...y];return O.pop(),O.push(o),p.contains=O,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:y}}const dFe={arduino:tze,bash:Dae,c:nze,cpp:ize,csharp:rze,css:hze,diff:pze,go:mze,graphql:gze,ini:$ae,java:bze,javascript:Fae,json:Vae,kotlin:Sze,less:jze,lua:Rze,makefile:Hae,markdown:Yae,objectivec:Ize,perl:Pze,php:Mze,"php-template":Lze,plaintext:Dze,python:Gae,"python-repl":$ze,r:Qze,ruby:Bze,rust:Uze,scss:Wze,shell:Zze,sql:Kze,swift:aFe,typescript:ooe,vbnet:lFe,wasm:cFe,xml:uFe,yaml:loe};function coe(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{const n=e[t],i=typeof n;(i==="object"||i==="function")&&!Object.isFrozen(n)&&coe(n)}),e}let Bz=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function uoe(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function lf(e,...t){const n=Object.create(null);for(const i in e)n[i]=e[i];return t.forEach(function(i){for(const r in i)n[r]=i[r]}),n}const fFe="",Uz=e=>!!e.scope,hFe=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map((i,r)=>`${i}${"_".repeat(r+1)}`)].join(" ")}return`${t}${e}`};class pFe{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=uoe(t)}openNode(t){if(!Uz(t))return;const n=hFe(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Uz(t)&&(this.buffer+=fFe)}value(){return this.buffer}span(t){this.buffer+=``}}const zz=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class T3{constructor(){this.rootNode=zz(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){const n=zz({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(i=>this._walk(t,i)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{T3._collapse(n)}))}}class mFe extends T3{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){const i=t.root;n&&(i.scope=`language:${n}`),this.add(i)}toHTML(){return new pFe(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function kx(e){return e?typeof e=="string"?e:e.source:null}function doe(e){return Vp("(?=",e,")")}function gFe(e){return Vp("(?:",e,")*")}function bFe(e){return Vp("(?:",e,")?")}function Vp(...e){return e.map(n=>kx(n)).join("")}function OFe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function _3(...e){return"("+(OFe(e).capture?"":"?:")+e.map(i=>kx(i)).join("|")+")"}function foe(e){return new RegExp(e.toString()+"|").exec("").length-1}function yFe(e,t){const n=e&&e.exec(t);return n&&n.index===0}const xFe=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A3(e,{joinWith:t}){let n=0;return e.map(i=>{n+=1;const r=n;let s=kx(i),a="";for(;s.length>0;){const o=xFe.exec(s);if(!o){a+=s;break}a+=s.substring(0,o.index),s=s.substring(o.index+o[0].length),o[0][0]==="\\"&&o[1]?a+="\\"+String(Number(o[1])+r):(a+=o[0],o[0]==="("&&n++)}return a}).map(i=>`(${i})`).join(t)}const vFe=/\b\B/,hoe="[a-zA-Z]\\w*",N3="[a-zA-Z_]\\w*",poe="\\b\\d+(\\.\\d+)?",moe="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",goe="\\b(0b[01]+)",wFe="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SFe=(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=Vp(t,/.*\b/,e.binary,/\b.*/)),lf({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,i)=>{n.index!==0&&i.ignoreMatch()}},e)},Tx={begin:"\\\\[\\s\\S]",relevance:0},EFe={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Tx]},kFe={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Tx]},TFe={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/},pA=function(e,t,n={}){const i=lf({scope:"comment",begin:e,end:t,contains:[]},n);i.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 r=_3("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 i.contains.push({begin:Vp(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},_Fe=pA("//","$"),AFe=pA("/\\*","\\*/"),NFe=pA("#","$"),CFe={scope:"number",begin:poe,relevance:0},jFe={scope:"number",begin:moe,relevance:0},RFe={scope:"number",begin:goe,relevance:0},IFe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Tx,{begin:/\[/,end:/\]/,relevance:0,contains:[Tx]}]},PFe={scope:"title",begin:hoe,relevance:0},MFe={scope:"title",begin:N3,relevance:0},LFe={begin:"\\.\\s*"+N3,relevance:0},DFe=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})};var Pw=Object.freeze({__proto__:null,APOS_STRING_MODE:EFe,BACKSLASH_ESCAPE:Tx,BINARY_NUMBER_MODE:RFe,BINARY_NUMBER_RE:goe,COMMENT:pA,C_BLOCK_COMMENT_MODE:AFe,C_LINE_COMMENT_MODE:_Fe,C_NUMBER_MODE:jFe,C_NUMBER_RE:moe,END_SAME_AS_BEGIN:DFe,HASH_COMMENT_MODE:NFe,IDENT_RE:hoe,MATCH_NOTHING_RE:vFe,METHOD_GUARD:LFe,NUMBER_MODE:CFe,NUMBER_RE:poe,PHRASAL_WORDS_MODE:TFe,QUOTE_STRING_MODE:kFe,REGEXP_MODE:IFe,RE_STARTERS_RE:wFe,SHEBANG:SFe,TITLE_MODE:PFe,UNDERSCORE_IDENT_RE:N3,UNDERSCORE_TITLE_MODE:MFe});function $Fe(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function QFe(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function BFe(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=$Fe,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function UFe(e,t){Array.isArray(e.illegal)&&(e.illegal=_3(...e.illegal))}function zFe(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function FFe(e,t){e.relevance===void 0&&(e.relevance=1)}const VFe=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach(i=>{delete e[i]}),e.keywords=n.keywords,e.begin=Vp(n.beforeMatch,doe(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},XFe=["of","and","for","in","not","or","if","then","parent","list","value"],qFe="keyword";function boe(e,t,n=qFe){const i=Object.create(null);return typeof e=="string"?r(n,e.split(" ")):Array.isArray(e)?r(n,e):Object.keys(e).forEach(function(s){Object.assign(i,boe(e[s],t,s))}),i;function r(s,a){t&&(a=a.map(o=>o.toLowerCase())),a.forEach(function(o){const c=o.split("|");i[c[0]]=[s,HFe(c[0],c[1])]})}}function HFe(e,t){return t?Number(t):YFe(e)?0:1}function YFe(e){return XFe.includes(e.toLowerCase())}const Fz={},ap=e=>{console.error(e)},Vz=(e,...t)=>{console.log(`WARN: ${e}`,...t)},um=(e,t)=>{Fz[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Fz[`${e}/${t}`]=!0)},Xk=new Error;function Ooe(e,t,{key:n}){let i=0;const r=e[n],s={},a={};for(let o=1;o<=t.length;o++)a[o+i]=r[o],s[o+i]=!0,i+=foe(t[o-1]);e[n]=a,e[n]._emit=s,e[n]._multi=!0}function GFe(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ap("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Xk;if(typeof e.beginScope!="object"||e.beginScope===null)throw ap("beginScope must be object"),Xk;Ooe(e,e.begin,{key:"beginScope"}),e.begin=A3(e.begin,{joinWith:""})}}function WFe(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ap("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Xk;if(typeof e.endScope!="object"||e.endScope===null)throw ap("endScope must be object"),Xk;Ooe(e,e.end,{key:"endScope"}),e.end=A3(e.end,{joinWith:""})}}function ZFe(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function KFe(e){ZFe(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),GFe(e),WFe(e)}function JFe(e){function t(a,o){return new RegExp(kx(a),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(o?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(o,c){c.position=this.position++,this.matchIndexes[this.matchAt]=c,this.regexes.push([c,o]),this.matchAt+=foe(o)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const o=this.regexes.map(c=>c[1]);this.matcherRe=t(A3(o,{joinWith:"|"}),!0),this.lastIndex=0}exec(o){this.matcherRe.lastIndex=this.lastIndex;const c=this.matcherRe.exec(o);if(!c)return null;const u=c.findIndex((f,h)=>h>0&&f!==void 0),d=this.matchIndexes[u];return c.splice(0,u),Object.assign(c,d)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(o){if(this.multiRegexes[o])return this.multiRegexes[o];const c=new n;return this.rules.slice(o).forEach(([u,d])=>c.addRule(u,d)),c.compile(),this.multiRegexes[o]=c,c}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(o,c){this.rules.push([o,c]),c.type==="begin"&&this.count++}exec(o){const c=this.getMatcher(this.regexIndex);c.lastIndex=this.lastIndex;let u=c.exec(o);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const d=this.getMatcher(0);d.lastIndex=this.lastIndex+1,u=d.exec(o)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function r(a){const o=new i;return a.contains.forEach(c=>o.addRule(c.begin,{rule:c,type:"begin"})),a.terminatorEnd&&o.addRule(a.terminatorEnd,{type:"end"}),a.illegal&&o.addRule(a.illegal,{type:"illegal"}),o}function s(a,o){const c=a;if(a.isCompiled)return c;[QFe,zFe,KFe,VFe].forEach(d=>d(a,o)),e.compilerExtensions.forEach(d=>d(a,o)),a.__beforeBegin=null,[BFe,UFe,FFe].forEach(d=>d(a,o)),a.isCompiled=!0;let u=null;return typeof a.keywords=="object"&&a.keywords.$pattern&&(a.keywords=Object.assign({},a.keywords),u=a.keywords.$pattern,delete a.keywords.$pattern),u=u||/\w+/,a.keywords&&(a.keywords=boe(a.keywords,e.case_insensitive)),c.keywordPatternRe=t(u,!0),o&&(a.begin||(a.begin=/\B|\b/),c.beginRe=t(c.begin),!a.end&&!a.endsWithParent&&(a.end=/\B|\b/),a.end&&(c.endRe=t(c.end)),c.terminatorEnd=kx(c.end)||"",a.endsWithParent&&o.terminatorEnd&&(c.terminatorEnd+=(a.end?"|":"")+o.terminatorEnd)),a.illegal&&(c.illegalRe=t(a.illegal)),a.contains||(a.contains=[]),a.contains=[].concat(...a.contains.map(function(d){return eVe(d==="self"?a:d)})),a.contains.forEach(function(d){s(d,c)}),a.starts&&s(a.starts,o),c.matcher=r(c),c}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=lf(e.classNameAliases||{}),s(e)}function yoe(e){return e?e.endsWithParent||yoe(e.starts):!1}function eVe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return lf(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:yoe(e)?lf(e,{starts:e.starts?lf(e.starts):null}):Object.isFrozen(e)?lf(e):e}var tVe="11.11.1";class nVe extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}}const BC=uoe,Xz=lf,qz=Symbol("nomatch"),iVe=7,xoe=function(e){const t=Object.create(null),n=Object.create(null),i=[];let r=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",a={disableAutodetect:!0,name:"Plain text",contains:[]};let o={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:mFe};function c(j){return o.noHighlightRe.test(j)}function u(j){let $=j.className+" ";$+=j.parentNode?j.parentNode.className:"";const U=o.languageDetectRe.exec($);if(U){const B=T(U[1]);return B||(Vz(s.replace("{}",U[1])),Vz("Falling back to no-highlight mode for this block.",j)),B?U[1]:"no-highlight"}return $.split(/\s+/).find(B=>c(B)||T(B))}function d(j,$,U){let B="",I="";typeof $=="object"?(B=j,U=$.ignoreIllegals,I=$.language):(um("10.7.0","highlight(lang, code, ...args) has been deprecated."),um("10.7.0",`Please use highlight(code, options) instead. -https://github.com/highlightjs/highlight.js/issues/2277`),I=j,B=$),U===void 0&&(U=!0);const X={code:B,language:I};P("before:highlight",X);const q=X.result?X.result:f(X.language,X.code,U);return q.code=X.code,P("after:highlight",q),q}function f(j,$,U,B){const I=Object.create(null);function X(W,K){return W.keywords[K]}function q(){if(!Oe.keywords){We.addText(De);return}let W=0;Oe.keywordPatternRe.lastIndex=0;let K=Oe.keywordPatternRe.exec(De),ae="";for(;K;){ae+=De.substring(W,K.index);const pe=me.case_insensitive?K[0].toLowerCase():K[0],z=X(Oe,pe);if(z){const[ve,Be]=z;if(We.addText(ae),ae="",I[pe]=(I[pe]||0)+1,I[pe]<=iVe&&(mt+=Be),ve.startsWith("_"))ae+=K[0];else{const Je=me.classNameAliases[ve]||ve;re(K[0],Je)}}else ae+=K[0];W=Oe.keywordPatternRe.lastIndex,K=Oe.keywordPatternRe.exec(De)}ae+=De.substring(W),We.addText(ae)}function D(){if(De==="")return;let W=null;if(typeof Oe.subLanguage=="string"){if(!t[Oe.subLanguage]){We.addText(De);return}W=f(Oe.subLanguage,De,!0,Ve[Oe.subLanguage]),Ve[Oe.subLanguage]=W._top}else W=p(De,Oe.subLanguage.length?Oe.subLanguage:null);Oe.relevance>0&&(mt+=W.relevance),We.__addSublanguage(W._emitter,W.language)}function H(){Oe.subLanguage!=null?D():q(),De=""}function re(W,K){W!==""&&(We.startScope(K),We.addText(W),We.endScope())}function fe(W,K){let ae=1;const pe=K.length-1;for(;ae<=pe;){if(!W._emit[ae]){ae++;continue}const z=me.classNameAliases[W[ae]]||W[ae],ve=K[ae];z?re(ve,z):(De=ve,q(),De=""),ae++}}function Ae(W,K){return W.scope&&typeof W.scope=="string"&&We.openNode(me.classNameAliases[W.scope]||W.scope),W.beginScope&&(W.beginScope._wrap?(re(De,me.classNameAliases[W.beginScope._wrap]||W.beginScope._wrap),De=""):W.beginScope._multi&&(fe(W.beginScope,K),De="")),Oe=Object.create(W,{parent:{value:Oe}}),Oe}function J(W,K,ae){let pe=yFe(W.endRe,ae);if(pe){if(W["on:end"]){const z=new Bz(W);W["on:end"](K,z),z.isMatchIgnored&&(pe=!1)}if(pe){for(;W.endsParent&&W.parent;)W=W.parent;return W}}if(W.endsWithParent)return J(W.parent,K,ae)}function ie(W){return Oe.matcher.regexIndex===0?(De+=W[0],1):(qe=!0,0)}function ue(W){const K=W[0],ae=W.rule,pe=new Bz(ae),z=[ae.__beforeBegin,ae["on:begin"]];for(const ve of z)if(ve&&(ve(W,pe),pe.isMatchIgnored))return ie(K);return ae.skip?De+=K:(ae.excludeBegin&&(De+=K),H(),!ae.returnBegin&&!ae.excludeBegin&&(De=K)),Ae(ae,W),ae.returnBegin?0:K.length}function ye(W){const K=W[0],ae=$.substring(W.index),pe=J(Oe,W,ae);if(!pe)return qz;const z=Oe;Oe.endScope&&Oe.endScope._wrap?(H(),re(K,Oe.endScope._wrap)):Oe.endScope&&Oe.endScope._multi?(H(),fe(Oe.endScope,W)):z.skip?De+=K:(z.returnEnd||z.excludeEnd||(De+=K),H(),z.excludeEnd&&(De=K));do Oe.scope&&We.closeNode(),!Oe.skip&&!Oe.subLanguage&&(mt+=Oe.relevance),Oe=Oe.parent;while(Oe!==pe.parent);return pe.starts&&Ae(pe.starts,W),z.returnEnd?0:K.length}function Se(){const W=[];for(let K=Oe;K!==me;K=K.parent)K.scope&&W.unshift(K.scope);W.forEach(K=>We.openNode(K))}let Re={};function Ee(W,K){const ae=K&&K[0];if(De+=W,ae==null)return H(),0;if(Re.type==="begin"&&K.type==="end"&&Re.index===K.index&&ae===""){if(De+=$.slice(K.index,K.index+1),!r){const pe=new Error(`0 width match regex (${j})`);throw pe.languageName=j,pe.badRule=Re.rule,pe}return 1}if(Re=K,K.type==="begin")return ue(K);if(K.type==="illegal"&&!U){const pe=new Error('Illegal lexeme "'+ae+'" for mode "'+(Oe.scope||"")+'"');throw pe.mode=Oe,pe}else if(K.type==="end"){const pe=ye(K);if(pe!==qz)return pe}if(K.type==="illegal"&&ae==="")return De+=` -`,1;if(Rt>1e5&&Rt>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return De+=ae,ae.length}const me=T(j);if(!me)throw ap(s.replace("{}",j)),new Error('Unknown language: "'+j+'"');const oe=JFe(me);let Ne="",Oe=B||oe;const Ve={},We=new o.__emitter(o);Se();let De="",mt=0,at=0,Rt=0,qe=!1;try{if(me.__emitTokens)me.__emitTokens($,We);else{for(Oe.matcher.considerAll();;){Rt++,qe?qe=!1:Oe.matcher.considerAll(),Oe.matcher.lastIndex=at;const W=Oe.matcher.exec($);if(!W)break;const K=$.substring(at,W.index),ae=Ee(K,W);at=W.index+ae}Ee($.substring(at))}return We.finalize(),Ne=We.toHTML(),{language:j,value:Ne,relevance:mt,illegal:!1,_emitter:We,_top:Oe}}catch(W){if(W.message&&W.message.includes("Illegal"))return{language:j,value:BC($),illegal:!0,relevance:0,_illegalBy:{message:W.message,index:at,context:$.slice(at-100,at+100),mode:W.mode,resultSoFar:Ne},_emitter:We};if(r)return{language:j,value:BC($),illegal:!1,relevance:0,errorRaised:W,_emitter:We,_top:Oe};throw W}}function h(j){const $={value:BC(j),illegal:!1,relevance:0,_top:a,_emitter:new o.__emitter(o)};return $._emitter.addText(j),$}function p(j,$){$=$||o.languages||Object.keys(t);const U=h(j),B=$.filter(T).filter(N).map(H=>f(H,j,!1));B.unshift(U);const I=B.sort((H,re)=>{if(H.relevance!==re.relevance)return re.relevance-H.relevance;if(H.language&&re.language){if(T(H.language).supersetOf===re.language)return 1;if(T(re.language).supersetOf===H.language)return-1}return 0}),[X,q]=I,D=X;return D.secondBest=q,D}function g(j,$,U){const B=$&&n[$]||U;j.classList.add("hljs"),j.classList.add(`language-${B}`)}function b(j){let $=null;const U=u(j);if(c(U))return;if(P("before:highlightElement",{el:j,language:U}),j.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",j);return}if(j.children.length>0&&(o.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(j)),o.throwUnescapedHTML))throw new nVe("One of your code blocks includes unescaped HTML.",j.innerHTML);$=j;const B=$.textContent,I=U?d(B,{language:U,ignoreIllegals:!0}):p(B);j.innerHTML=I.value,j.dataset.highlighted="yes",g(j,U,I.language),j.result={language:I.language,re:I.relevance,relevance:I.relevance},I.secondBest&&(j.secondBest={language:I.secondBest.language,relevance:I.secondBest.relevance}),P("after:highlightElement",{el:j,result:I,text:B})}function y(j){o=Xz(o,j)}const O=()=>{w(),um("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function v(){w(),um("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let x=!1;function w(){function j(){w()}if(document.readyState==="loading"){x||window.addEventListener("DOMContentLoaded",j,!1),x=!0;return}document.querySelectorAll(o.cssSelector).forEach(b)}function E(j,$){let U=null;try{U=$(e)}catch(B){if(ap("Language definition for '{}' could not be registered.".replace("{}",j)),r)ap(B);else throw B;U=a}U.name||(U.name=j),t[j]=U,U.rawDefinition=$.bind(null,e),U.aliases&&A(U.aliases,{languageName:j})}function S(j){delete t[j];for(const $ of Object.keys(n))n[$]===j&&delete n[$]}function k(){return Object.keys(t)}function T(j){return j=(j||"").toLowerCase(),t[j]||t[n[j]]}function A(j,{languageName:$}){typeof j=="string"&&(j=[j]),j.forEach(U=>{n[U.toLowerCase()]=$})}function N(j){const $=T(j);return $&&!$.disableAutodetect}function C(j){j["before:highlightBlock"]&&!j["before:highlightElement"]&&(j["before:highlightElement"]=$=>{j["before:highlightBlock"](Object.assign({block:$.el},$))}),j["after:highlightBlock"]&&!j["after:highlightElement"]&&(j["after:highlightElement"]=$=>{j["after:highlightBlock"](Object.assign({block:$.el},$))})}function M(j){C(j),i.push(j)}function L(j){const $=i.indexOf(j);$!==-1&&i.splice($,1)}function P(j,$){const U=j;i.forEach(function(B){B[U]&&B[U]($)})}function Q(j){return um("10.7.0","highlightBlock will be removed entirely in v12.0"),um("10.7.0","Please use highlightElement now."),b(j)}Object.assign(e,{highlight:d,highlightAuto:p,highlightAll:w,highlightElement:b,highlightBlock:Q,configure:y,initHighlighting:O,initHighlightingOnLoad:v,registerLanguage:E,unregisterLanguage:S,listLanguages:k,getLanguage:T,registerAliases:A,autoDetection:N,inherit:Xz,addPlugin:M,removePlugin:L}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString=tVe,e.regex={concat:Vp,lookahead:doe,either:_3,optional:bFe,anyNumberOfTimes:gFe};for(const j in Pw)typeof Pw[j]=="object"&&coe(Pw[j]);return Object.assign(e,Pw),e},p0=xoe({});p0.newInstance=()=>xoe({});var rVe=p0;p0.HighlightJS=p0;p0.default=p0;const Fa=N0(rVe),Hz={},sVe="hljs-";function aVe(e){const t=Fa.newInstance();return e&&s(e),{highlight:n,highlightAuto:i,listLanguages:r,register:s,registerAlias:a,registered:o};function n(c,u,d){const f=d||Hz,h=typeof f.prefix=="string"?f.prefix:sVe;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:oVe,classPrefix:h});const p=t.highlight(u,{ignoreIllegals:!0,language:c});if(p.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:p.errorRaised});const g=p._emitter.root,b=g.data;return b.language=p.language,b.relevance=p.relevance,g}function i(c,u){const f=(u||Hz).subset||r();let h=-1,p=0,g;for(;++hp&&(p=y.data.relevance,g=y)}return g||{type:"root",children:[],data:{language:void 0,relevance:p}}}function r(){return t.listLanguages()}function s(c,u){if(typeof c=="string")t.registerLanguage(c,u);else{let d;for(d in c)Object.hasOwn(c,d)&&t.registerLanguage(d,c[d])}}function a(c,u){if(typeof c=="string")t.registerAliases(typeof u=="string"?u:[...u],{languageName:c});else{let d;for(d in c)if(Object.hasOwn(c,d)){const f=c[d];t.registerAliases(typeof f=="string"?f:[...f],{languageName:d})}}}function o(c){return!!t.getLanguage(c)}}class oVe{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],r=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:r}):i.children.push(...r)}openNode(t){const n=this,i=t.split(".").map(function(a,o){return o?a+"_".repeat(o):n.options.classPrefix+a}),r=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:i},children:[]};r.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const lVe={};function Yz(e){const t=e||lVe,n=t.aliases,i=t.detect||!1,r=t.languages||dFe,s=t.plainText,a=t.prefix,o=t.subset;let c="hljs";const u=aVe(r);if(n&&u.registerAlias(n),a){const d=a.indexOf("-");c=d===-1?a:a.slice(0,d)}return function(d,f){B1(d,"element",function(h,p,g){if(h.tagName!=="code"||!g||g.type!=="element"||g.tagName!=="pre")return;const b=cVe(h);if(b===!1||!b&&!i||b&&s&&s.includes(b))return;Array.isArray(h.properties.className)||(h.properties.className=[]),h.properties.className.includes(c)||h.properties.className.unshift(c);const y=q7e(h,{whitespace:"pre"});let O;try{O=b?u.highlight(b,y,{prefix:a}):u.highlightAuto(y,{prefix:a,subset:o})}catch(v){const x=v;if(b&&/Unknown language/.test(x.message)){f.message("Cannot highlight as `"+b+"`, it’s not registered",{ancestors:[g,h],cause:x,place:h.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw x}!b&&O.data&&O.data.language&&h.properties.className.push("language-"+O.data.language),O.children.length>0&&(h.children=O.children)})}}function cVe(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n-1&&s<=t.length){let a=0;for(;;){let o=n[a];if(o===void 0){const c=Zz(t,n[a-1]);o=c===-1?t.length+1:c+1,n[a]=o}if(o>s)return{line:a+1,column:s-(a>0?n[a-1]:0)+1,offset:s};a++}}}function r(s){if(s&&typeof s.line=="number"&&typeof s.column=="number"&&!Number.isNaN(s.line)&&!Number.isNaN(s.column)){for(;n.length1?n[s.line-2]:0)+s.column-1;if(a=55296&&e<=57343}function MVe(e){return e>=56320&&e<=57343}function LVe(e,t){return(e-55296)*1024+9216+t}function Toe(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function _oe(e){return e>=64976&&e<=65007||PVe.has(e)}var $e;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})($e||($e={}));const DVe=65536;class $Ve{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=DVe,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:i,col:r,offset:s}=this,a=r+n,o=s+n;return{code:t,startLine:i,endLine:i,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if(MVe(n))return this.pos++,this._addGap(),LVe(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Z.EOF;return this._err($e.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let i=0;i=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Z.EOF;const i=this.html.charCodeAt(n);return i===Z.CARRIAGE_RETURN?Z.LINE_FEED:i}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Z.EOF;let t=this.html.charCodeAt(this.pos);return t===Z.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Z.LINE_FEED):t===Z.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,koe(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===Z.LINE_FEED||t===Z.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){Toe(t)?this._err($e.controlCharacterInInputStream):_oe(t)&&this._err($e.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const QVe=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),BVe=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function UVe(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=BVe.get(e))!==null&&t!==void 0?t:e}var ms;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(ms||(ms={}));const zVe=32;var cf;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(cf||(cf={}));function OM(e){return e>=ms.ZERO&&e<=ms.NINE}function FVe(e){return e>=ms.UPPER_A&&e<=ms.UPPER_F||e>=ms.LOWER_A&&e<=ms.LOWER_F}function VVe(e){return e>=ms.UPPER_A&&e<=ms.UPPER_Z||e>=ms.LOWER_A&&e<=ms.LOWER_Z||OM(e)}function XVe(e){return e===ms.EQUALS||VVe(e)}var cs;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(cs||(cs={}));var Nu;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Nu||(Nu={}));class qVe{constructor(t,n,i){this.decodeTree=t,this.emitCodePoint=n,this.errors=i,this.state=cs.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Nu.Strict}startEntity(t){this.decodeMode=t,this.state=cs.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case cs.EntityStart:return t.charCodeAt(n)===ms.NUM?(this.state=cs.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=cs.NamedEntity,this.stateNamedEntity(t,n));case cs.NumericStart:return this.stateNumericStart(t,n);case cs.NumericDecimal:return this.stateNumericDecimal(t,n);case cs.NumericHex:return this.stateNumericHex(t,n);case cs.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|zVe)===ms.LOWER_X?(this.state=cs.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=cs.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,i,r){if(n!==i){const s=i-n;this.result=this.result*Math.pow(r,s)+Number.parseInt(t.substr(n,s),r),this.consumed+=s}}stateNumericHex(t,n){const i=n;for(;n>14;for(;n>14,s!==0){if(a===ms.SEMI)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);this.decodeMode!==Nu.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:i}=this,r=(i[n]&cf.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,r,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,i){const{decodeTree:r}=this;return this.emitCodePoint(n===1?r[t]&~cf.VALUE_LENGTH:r[t+1],i),n===3&&this.emitCodePoint(r[t+2],i),i}end(){var t;switch(this.state){case cs.NamedEntity:return this.result!==0&&(this.decodeMode!==Nu.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case cs.NumericDecimal:return this.emitNumericEntity(0,2);case cs.NumericHex:return this.emitNumericEntity(0,3);case cs.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case cs.EntityStart:return 0}}}function HVe(e,t,n,i){const r=(t&cf.BRANCH_LENGTH)>>7,s=t&cf.JUMP_TABLE;if(r===0)return s!==0&&i===s?n:-1;if(s){const c=i-s;return c<0||c>=r?-1:e[n+c]-1}let a=n,o=a+r-1;for(;a<=o;){const c=a+o>>>1,u=e[c];if(ui)o=c-1;else return e[c+r]}return-1}var Ye;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Ye||(Ye={}));var op;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(op||(op={}));var Uo;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Uo||(Uo={}));var ke;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(ke||(ke={}));var _;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(_||(_={}));const YVe=new Map([[ke.A,_.A],[ke.ADDRESS,_.ADDRESS],[ke.ANNOTATION_XML,_.ANNOTATION_XML],[ke.APPLET,_.APPLET],[ke.AREA,_.AREA],[ke.ARTICLE,_.ARTICLE],[ke.ASIDE,_.ASIDE],[ke.B,_.B],[ke.BASE,_.BASE],[ke.BASEFONT,_.BASEFONT],[ke.BGSOUND,_.BGSOUND],[ke.BIG,_.BIG],[ke.BLOCKQUOTE,_.BLOCKQUOTE],[ke.BODY,_.BODY],[ke.BR,_.BR],[ke.BUTTON,_.BUTTON],[ke.CAPTION,_.CAPTION],[ke.CENTER,_.CENTER],[ke.CODE,_.CODE],[ke.COL,_.COL],[ke.COLGROUP,_.COLGROUP],[ke.DD,_.DD],[ke.DESC,_.DESC],[ke.DETAILS,_.DETAILS],[ke.DIALOG,_.DIALOG],[ke.DIR,_.DIR],[ke.DIV,_.DIV],[ke.DL,_.DL],[ke.DT,_.DT],[ke.EM,_.EM],[ke.EMBED,_.EMBED],[ke.FIELDSET,_.FIELDSET],[ke.FIGCAPTION,_.FIGCAPTION],[ke.FIGURE,_.FIGURE],[ke.FONT,_.FONT],[ke.FOOTER,_.FOOTER],[ke.FOREIGN_OBJECT,_.FOREIGN_OBJECT],[ke.FORM,_.FORM],[ke.FRAME,_.FRAME],[ke.FRAMESET,_.FRAMESET],[ke.H1,_.H1],[ke.H2,_.H2],[ke.H3,_.H3],[ke.H4,_.H4],[ke.H5,_.H5],[ke.H6,_.H6],[ke.HEAD,_.HEAD],[ke.HEADER,_.HEADER],[ke.HGROUP,_.HGROUP],[ke.HR,_.HR],[ke.HTML,_.HTML],[ke.I,_.I],[ke.IMG,_.IMG],[ke.IMAGE,_.IMAGE],[ke.INPUT,_.INPUT],[ke.IFRAME,_.IFRAME],[ke.KEYGEN,_.KEYGEN],[ke.LABEL,_.LABEL],[ke.LI,_.LI],[ke.LINK,_.LINK],[ke.LISTING,_.LISTING],[ke.MAIN,_.MAIN],[ke.MALIGNMARK,_.MALIGNMARK],[ke.MARQUEE,_.MARQUEE],[ke.MATH,_.MATH],[ke.MENU,_.MENU],[ke.META,_.META],[ke.MGLYPH,_.MGLYPH],[ke.MI,_.MI],[ke.MO,_.MO],[ke.MN,_.MN],[ke.MS,_.MS],[ke.MTEXT,_.MTEXT],[ke.NAV,_.NAV],[ke.NOBR,_.NOBR],[ke.NOFRAMES,_.NOFRAMES],[ke.NOEMBED,_.NOEMBED],[ke.NOSCRIPT,_.NOSCRIPT],[ke.OBJECT,_.OBJECT],[ke.OL,_.OL],[ke.OPTGROUP,_.OPTGROUP],[ke.OPTION,_.OPTION],[ke.P,_.P],[ke.PARAM,_.PARAM],[ke.PLAINTEXT,_.PLAINTEXT],[ke.PRE,_.PRE],[ke.RB,_.RB],[ke.RP,_.RP],[ke.RT,_.RT],[ke.RTC,_.RTC],[ke.RUBY,_.RUBY],[ke.S,_.S],[ke.SCRIPT,_.SCRIPT],[ke.SEARCH,_.SEARCH],[ke.SECTION,_.SECTION],[ke.SELECT,_.SELECT],[ke.SOURCE,_.SOURCE],[ke.SMALL,_.SMALL],[ke.SPAN,_.SPAN],[ke.STRIKE,_.STRIKE],[ke.STRONG,_.STRONG],[ke.STYLE,_.STYLE],[ke.SUB,_.SUB],[ke.SUMMARY,_.SUMMARY],[ke.SUP,_.SUP],[ke.TABLE,_.TABLE],[ke.TBODY,_.TBODY],[ke.TEMPLATE,_.TEMPLATE],[ke.TEXTAREA,_.TEXTAREA],[ke.TFOOT,_.TFOOT],[ke.TD,_.TD],[ke.TH,_.TH],[ke.THEAD,_.THEAD],[ke.TITLE,_.TITLE],[ke.TR,_.TR],[ke.TRACK,_.TRACK],[ke.TT,_.TT],[ke.U,_.U],[ke.UL,_.UL],[ke.SVG,_.SVG],[ke.VAR,_.VAR],[ke.WBR,_.WBR],[ke.XMP,_.XMP]]);function rb(e){var t;return(t=YVe.get(e))!==null&&t!==void 0?t:_.UNKNOWN}const nt=_,GVe={[Ye.HTML]:new Set([nt.ADDRESS,nt.APPLET,nt.AREA,nt.ARTICLE,nt.ASIDE,nt.BASE,nt.BASEFONT,nt.BGSOUND,nt.BLOCKQUOTE,nt.BODY,nt.BR,nt.BUTTON,nt.CAPTION,nt.CENTER,nt.COL,nt.COLGROUP,nt.DD,nt.DETAILS,nt.DIR,nt.DIV,nt.DL,nt.DT,nt.EMBED,nt.FIELDSET,nt.FIGCAPTION,nt.FIGURE,nt.FOOTER,nt.FORM,nt.FRAME,nt.FRAMESET,nt.H1,nt.H2,nt.H3,nt.H4,nt.H5,nt.H6,nt.HEAD,nt.HEADER,nt.HGROUP,nt.HR,nt.HTML,nt.IFRAME,nt.IMG,nt.INPUT,nt.LI,nt.LINK,nt.LISTING,nt.MAIN,nt.MARQUEE,nt.MENU,nt.META,nt.NAV,nt.NOEMBED,nt.NOFRAMES,nt.NOSCRIPT,nt.OBJECT,nt.OL,nt.P,nt.PARAM,nt.PLAINTEXT,nt.PRE,nt.SCRIPT,nt.SECTION,nt.SELECT,nt.SOURCE,nt.STYLE,nt.SUMMARY,nt.TABLE,nt.TBODY,nt.TD,nt.TEMPLATE,nt.TEXTAREA,nt.TFOOT,nt.TH,nt.THEAD,nt.TITLE,nt.TR,nt.TRACK,nt.UL,nt.WBR,nt.XMP]),[Ye.MATHML]:new Set([nt.MI,nt.MO,nt.MN,nt.MS,nt.MTEXT,nt.ANNOTATION_XML]),[Ye.SVG]:new Set([nt.TITLE,nt.FOREIGN_OBJECT,nt.DESC]),[Ye.XLINK]:new Set,[Ye.XML]:new Set,[Ye.XMLNS]:new Set},yM=new Set([nt.H1,nt.H2,nt.H3,nt.H4,nt.H5,nt.H6]);ke.STYLE,ke.SCRIPT,ke.XMP,ke.IFRAME,ke.NOEMBED,ke.NOFRAMES,ke.PLAINTEXT;var ne;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(ne||(ne={}));const jr={DATA:ne.DATA,RCDATA:ne.RCDATA,RAWTEXT:ne.RAWTEXT,SCRIPT_DATA:ne.SCRIPT_DATA,PLAINTEXT:ne.PLAINTEXT,CDATA_SECTION:ne.CDATA_SECTION};function WVe(e){return e>=Z.DIGIT_0&&e<=Z.DIGIT_9}function RO(e){return e>=Z.LATIN_CAPITAL_A&&e<=Z.LATIN_CAPITAL_Z}function ZVe(e){return e>=Z.LATIN_SMALL_A&&e<=Z.LATIN_SMALL_Z}function Qd(e){return ZVe(e)||RO(e)}function Jz(e){return Qd(e)||WVe(e)}function Mw(e){return e+32}function Noe(e){return e===Z.SPACE||e===Z.LINE_FEED||e===Z.TABULATION||e===Z.FORM_FEED}function eF(e){return Noe(e)||e===Z.SOLIDUS||e===Z.GREATER_THAN_SIGN}function KVe(e){return e===Z.NULL?$e.nullCharacterReference:e>1114111?$e.characterReferenceOutsideUnicodeRange:koe(e)?$e.surrogateCharacterReference:_oe(e)?$e.noncharacterCharacterReference:Toe(e)||e===Z.CARRIAGE_RETURN?$e.controlCharacterReference:null}class JVe{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=ne.DATA,this.returnState=ne.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new $Ve(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new qVe(QVe,(i,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(i)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err($e.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:i=>{this._err($e.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+i)},validateNumericCharacterReference:i=>{const r=KVe(i);r&&this._err(r,1)}}:void 0)}_err(t,n=0){var i,r;(r=(i=this.handler).onParseError)===null||r===void 0||r.call(i,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,n,i){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||i==null||i()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n0&&this._err($e.endTagWithAttributes),t.selfClosing&&this._err($e.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case En.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case En.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case En.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:En.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=Noe(t)?En.WHITESPACE_CHARACTER:t===Z.NULL?En.NULL_CHARACTER:En.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(En.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=ne.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nu.Attribute:Nu.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===ne.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ne.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ne.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case ne.DATA:{this._stateData(t);break}case ne.RCDATA:{this._stateRcdata(t);break}case ne.RAWTEXT:{this._stateRawtext(t);break}case ne.SCRIPT_DATA:{this._stateScriptData(t);break}case ne.PLAINTEXT:{this._statePlaintext(t);break}case ne.TAG_OPEN:{this._stateTagOpen(t);break}case ne.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case ne.TAG_NAME:{this._stateTagName(t);break}case ne.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case ne.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case ne.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case ne.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case ne.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case ne.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case ne.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case ne.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case ne.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case ne.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case ne.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case ne.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case ne.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case ne.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case ne.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case ne.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case ne.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case ne.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case ne.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case ne.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case ne.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case ne.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case ne.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case ne.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case ne.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case ne.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case ne.BOGUS_COMMENT:{this._stateBogusComment(t);break}case ne.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case ne.COMMENT_START:{this._stateCommentStart(t);break}case ne.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case ne.COMMENT:{this._stateComment(t);break}case ne.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case ne.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case ne.COMMENT_END:{this._stateCommentEnd(t);break}case ne.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case ne.DOCTYPE:{this._stateDoctype(t);break}case ne.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case ne.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case ne.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case ne.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case ne.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case ne.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case ne.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case ne.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case ne.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case ne.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case ne.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case ne.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case ne.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case ne.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case ne.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case ne.CDATA_SECTION:{this._stateCdataSection(t);break}case ne.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case ne.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case ne.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case ne.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.TAG_OPEN;break}case Z.AMPERSAND:{this._startCharacterReference();break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitCodePoint(t);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case Z.AMPERSAND:{this._startCharacterReference();break}case Z.LESS_THAN_SIGN:{this.state=ne.RCDATA_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.RAWTEXT_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.SCRIPT_DATA_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(Qd(t))this._createStartTagToken(),this.state=ne.TAG_NAME,this._stateTagName(t);else switch(t){case Z.EXCLAMATION_MARK:{this.state=ne.MARKUP_DECLARATION_OPEN;break}case Z.SOLIDUS:{this.state=ne.END_TAG_OPEN;break}case Z.QUESTION_MARK:{this._err($e.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ne.BOGUS_COMMENT,this._stateBogusComment(t);break}case Z.EOF:{this._err($e.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err($e.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ne.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(Qd(t))this._createEndTagToken(),this.state=ne.TAG_NAME,this._stateTagName(t);else switch(t){case Z.GREATER_THAN_SIGN:{this._err($e.missingEndTagName),this.state=ne.DATA;break}case Z.EOF:{this._err($e.eofBeforeTagName),this._emitChars("");break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this.state=ne.SCRIPT_DATA_ESCAPED,this._emitChars(rr);break}case Z.EOF:{this._err($e.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ne.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===Z.SOLIDUS?this.state=ne.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Qd(t)?(this._emitChars("<"),this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=ne.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){Qd(t)?(this.state=ne.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("");break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(rr);break}case Z.EOF:{this._err($e.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===Z.SOLIDUS?(this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Aa.SCRIPT,!1)&&eF(this.preprocessor.peek(Aa.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const i=this._indexOf(t);this.items[i]=n,i===this.stackTop&&(this.current=n)}insertAfter(t,n,i){const r=this._indexOf(t)+1;this.items.splice(r,0,n),this.tagIDs.splice(r,0,i),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==Ye.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop=0;i--)if(t.has(this.tagIDs[i])&&this.treeAdapter.getNamespaceURI(this.items[i])===n)return i;return-1}clearBackTo(t,n){const i=this._indexOfTagNames(t,n);this.shortenToLength(i+1)}clearBackToTableContext(){this.clearBackTo(rXe,Ye.HTML)}clearBackToTableBodyContext(){this.clearBackTo(iXe,Ye.HTML)}clearBackToTableRowContext(){this.clearBackTo(nXe,Ye.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===_.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===_.HTML}hasInDynamicScope(t,n){for(let i=this.stackTop;i>=0;i--){const r=this.tagIDs[i];switch(this.treeAdapter.getNamespaceURI(this.items[i])){case Ye.HTML:{if(r===t)return!0;if(n.has(r))return!1;break}case Ye.SVG:{if(iF.has(r))return!1;break}case Ye.MATHML:{if(nF.has(r))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,qk)}hasInListItemScope(t){return this.hasInDynamicScope(t,eXe)}hasInButtonScope(t){return this.hasInDynamicScope(t,tXe)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case Ye.HTML:{if(yM.has(n))return!0;if(qk.has(n))return!1;break}case Ye.SVG:{if(iF.has(n))return!1;break}case Ye.MATHML:{if(nF.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Ye.HTML)switch(this.tagIDs[n]){case t:return!0;case _.TABLE:case _.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ye.HTML)switch(this.tagIDs[t]){case _.TBODY:case _.THEAD:case _.TFOOT:return!0;case _.TABLE:case _.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Ye.HTML)switch(this.tagIDs[n]){case t:return!0;case _.OPTION:case _.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&Coe.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&tF.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&tF.has(this.currentTagId);)this.pop()}}const UC=3;var yc;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(yc||(yc={}));const rF={type:yc.Marker};class oXe{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const i=[],r=n.length,s=this.treeAdapter.getTagName(t),a=this.treeAdapter.getNamespaceURI(t);for(let o=0;o[a.name,a.value]));let s=0;for(let a=0;ar.get(c.name)===c.value)&&(s+=1,s>=UC&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(rF)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:yc.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const i=this.entries.indexOf(this.bookmark);this.entries.splice(i,0,{type:yc.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(rF);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(i=>i.type===yc.Marker||this.treeAdapter.getTagName(i.element)===t);return n&&n.type===yc.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===yc.Element&&n.element===t)}}const Bd={createDocument(){return{nodeName:"#document",mode:Uo.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const i=e.childNodes.indexOf(n);e.childNodes.splice(i,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,i){const r=e.childNodes.find(s=>s.nodeName==="#documentType");if(r)r.name=t,r.publicId=n,r.systemId=i;else{const s={nodeName:"#documentType",name:t,publicId:n,systemId:i,parentNode:null};Bd.appendChild(e,s)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(Bd.isTextNode(n)){n.value+=t;return}}Bd.appendChild(e,Bd.createTextNode(t))},insertTextBefore(e,t,n){const i=e.childNodes[e.childNodes.indexOf(n)-1];i&&Bd.isTextNode(i)?i.value+=t:Bd.insertBefore(e,Bd.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(i=>i.name));for(let i=0;ie.startsWith(n))}function hXe(e){return e.name===joe&&e.publicId===null&&(e.systemId===null||e.systemId===lXe)}function pXe(e){if(e.name!==joe)return Uo.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===cXe)return Uo.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),dXe.has(n))return Uo.QUIRKS;let i=t===null?uXe:Roe;if(sF(n,i))return Uo.QUIRKS;if(i=t===null?Ioe:fXe,sF(n,i))return Uo.LIMITED_QUIRKS}return Uo.NO_QUIRKS}const aF={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},mXe="definitionurl",gXe="definitionURL",bXe=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),OXe=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Ye.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Ye.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Ye.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Ye.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Ye.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Ye.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Ye.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Ye.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Ye.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Ye.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Ye.XMLNS}]]),yXe=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),xXe=new Set([_.B,_.BIG,_.BLOCKQUOTE,_.BODY,_.BR,_.CENTER,_.CODE,_.DD,_.DIV,_.DL,_.DT,_.EM,_.EMBED,_.H1,_.H2,_.H3,_.H4,_.H5,_.H6,_.HEAD,_.HR,_.I,_.IMG,_.LI,_.LISTING,_.MENU,_.META,_.NOBR,_.OL,_.P,_.PRE,_.RUBY,_.S,_.SMALL,_.SPAN,_.STRONG,_.STRIKE,_.SUB,_.SUP,_.TABLE,_.TT,_.U,_.UL,_.VAR]);function vXe(e){const t=e.tagID;return t===_.FONT&&e.attrs.some(({name:i})=>i===op.COLOR||i===op.SIZE||i===op.FACE)||xXe.has(t)}function Poe(e){for(let t=0;t0&&this._setContextModes(t,n)}onItemPop(t,n){var i,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(r=(i=this.treeAdapter).onItemPop)===null||r===void 0||r.call(i,t,this.openElements.current),n){let s,a;this.openElements.stackTop===0&&this.fragmentContext?(s=this.fragmentContext,a=this.fragmentContextID):{current:s,currentTagId:a}=this.openElements,this._setContextModes(s,a)}}_setContextModes(t,n){const i=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===Ye.HTML;this.currentNotInHTML=!i,this.tokenizer.inForeignNode=!i&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,Ye.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=ce.TEXT}switchToPlaintextParsing(){this.insertionMode=ce.TEXT,this.originalInsertionMode=ce.IN_BODY,this.tokenizer.state=jr.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===ke.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Ye.HTML))switch(this.fragmentContextID){case _.TITLE:case _.TEXTAREA:{this.tokenizer.state=jr.RCDATA;break}case _.STYLE:case _.XMP:case _.IFRAME:case _.NOEMBED:case _.NOFRAMES:case _.NOSCRIPT:{this.tokenizer.state=jr.RAWTEXT;break}case _.SCRIPT:{this.tokenizer.state=jr.SCRIPT_DATA;break}case _.PLAINTEXT:{this.tokenizer.state=jr.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",i=t.publicId||"",r=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,i,r),t.location){const a=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));a&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const i=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,i)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const i=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(i??this.document,t)}}_appendElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location)}_insertElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location),this.openElements.push(i,t.tagID)}_insertFakeElement(t,n){const i=this.treeAdapter.createElement(t,Ye.HTML,[]);this._attachElementToTree(i,null),this.openElements.push(i,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,Ye.HTML,t.attrs),i=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,i),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(ke.HTML,Ye.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,_.HTML)}_appendCommentNode(t,n){const i=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,i),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,t.location)}_insertCharacters(t){let n,i;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:i}=this._findFosterParentingLocation(),i?this.treeAdapter.insertTextBefore(n,t.chars,i):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const r=this.treeAdapter.getChildNodes(n),s=i?r.lastIndexOf(i):r.length,a=r[s-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:c,endCol:u,endOffset:d}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:c,endCol:u,endOffset:d})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_adoptNodes(t,n){for(let i=this.treeAdapter.getFirstChild(t);i;i=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(i),this.treeAdapter.appendChild(n,i)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const i=n.location,r=this.treeAdapter.getTagName(t),s=n.type===En.END_TAG&&r===n.tagName?{endTag:{...i},endLine:i.endLine,endCol:i.endCol,endOffset:i.endOffset}:{endLine:i.startLine,endCol:i.startCol,endOffset:i.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,s)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,i;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,i=this.fragmentContextID):{current:n,currentTagId:i}=this.openElements,t.tagID===_.SVG&&this.treeAdapter.getTagName(n)===ke.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===Ye.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===_.MGLYPH||t.tagID===_.MALIGNMARK)&&i!==void 0&&!this._isIntegrationPoint(i,n,Ye.HTML)}_processToken(t){switch(t.type){case En.CHARACTER:{this.onCharacter(t);break}case En.NULL_CHARACTER:{this.onNullCharacter(t);break}case En.COMMENT:{this.onComment(t);break}case En.DOCTYPE:{this.onDoctype(t);break}case En.START_TAG:{this._processStartTag(t);break}case En.END_TAG:{this.onEndTag(t);break}case En.EOF:{this.onEof(t);break}case En.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,i){const r=this.treeAdapter.getNamespaceURI(n),s=this.treeAdapter.getAttrList(n);return kXe(t,r,s,i)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(r=>r.type===yc.Marker||this.openElements.contains(r.element)),i=n===-1?t-1:n-1;for(let r=i;r>=0;r--){const s=this.activeFormattingElements.entries[r];this._insertElement(s.token,this.treeAdapter.getNamespaceURI(s.element)),s.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=ce.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(_.P),this.openElements.popUntilTagNamePopped(_.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case _.TR:{this.insertionMode=ce.IN_ROW;return}case _.TBODY:case _.THEAD:case _.TFOOT:{this.insertionMode=ce.IN_TABLE_BODY;return}case _.CAPTION:{this.insertionMode=ce.IN_CAPTION;return}case _.COLGROUP:{this.insertionMode=ce.IN_COLUMN_GROUP;return}case _.TABLE:{this.insertionMode=ce.IN_TABLE;return}case _.BODY:{this.insertionMode=ce.IN_BODY;return}case _.FRAMESET:{this.insertionMode=ce.IN_FRAMESET;return}case _.SELECT:{this._resetInsertionModeForSelect(t);return}case _.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case _.HTML:{this.insertionMode=this.headElement?ce.AFTER_HEAD:ce.BEFORE_HEAD;return}case _.TD:case _.TH:{if(t>0){this.insertionMode=ce.IN_CELL;return}break}case _.HEAD:{if(t>0){this.insertionMode=ce.IN_HEAD;return}break}}this.insertionMode=ce.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const i=this.openElements.tagIDs[n];if(i===_.TEMPLATE)break;if(i===_.TABLE){this.insertionMode=ce.IN_SELECT_IN_TABLE;return}}this.insertionMode=ce.IN_SELECT}_isElementCausesFosterParenting(t){return Loe.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case _.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===Ye.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case _.TABLE:{const i=this.treeAdapter.getParentNode(n);return i?{parent:i,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const i=this.treeAdapter.getNamespaceURI(t);return GVe[i].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){sHe(this,t);return}switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.IN_BODY:case ce.IN_CAPTION:case ce.IN_CELL:case ce.IN_TEMPLATE:{$oe(this,t);break}case ce.TEXT:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_TABLE_TEXT:{Voe(this,t);break}case ce.IN_COLUMN_GROUP:{Hk(this,t);break}case ce.AFTER_BODY:{Yk(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){rHe(this,t);return}switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.TEXT:{this._insertCharacters(t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_COLUMN_GROUP:{Hk(this,t);break}case ce.AFTER_BODY:{Yk(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){xM(this,t);return}switch(this.insertionMode){case ce.INITIAL:case ce.BEFORE_HTML:case ce.BEFORE_HEAD:case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:case ce.IN_BODY:case ce.IN_TABLE:case ce.IN_CAPTION:case ce.IN_COLUMN_GROUP:case ce.IN_TABLE_BODY:case ce.IN_ROW:case ce.IN_CELL:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:case ce.IN_TEMPLATE:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:{xM(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.AFTER_BODY:{LXe(this,t);break}case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{DXe(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case ce.INITIAL:{$Xe(this,t);break}case ce.BEFORE_HEAD:case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:{this._err(t,$e.misplacedDoctype);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,$e.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?aHe(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{QXe(this,t);break}case ce.BEFORE_HEAD:{UXe(this,t);break}case ce.IN_HEAD:{ql(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{VXe(this,t);break}case ce.AFTER_HEAD:{qXe(this,t);break}case ce.IN_BODY:{ea(this,t);break}case ce.IN_TABLE:{m0(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_CAPTION:{zqe(this,t);break}case ce.IN_COLUMN_GROUP:{M3(this,t);break}case ce.IN_TABLE_BODY:{bA(this,t);break}case ce.IN_ROW:{OA(this,t);break}case ce.IN_CELL:{Xqe(this,t);break}case ce.IN_SELECT:{Hoe(this,t);break}case ce.IN_SELECT_IN_TABLE:{Hqe(this,t);break}case ce.IN_TEMPLATE:{Gqe(this,t);break}case ce.AFTER_BODY:{Zqe(this,t);break}case ce.IN_FRAMESET:{Kqe(this,t);break}case ce.AFTER_FRAMESET:{eHe(this,t);break}case ce.AFTER_AFTER_BODY:{nHe(this,t);break}case ce.AFTER_AFTER_FRAMESET:{iHe(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?oHe(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{BXe(this,t);break}case ce.BEFORE_HEAD:{zXe(this,t);break}case ce.IN_HEAD:{FXe(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{XXe(this,t);break}case ce.AFTER_HEAD:{HXe(this,t);break}case ce.IN_BODY:{gA(this,t);break}case ce.TEXT:{Rqe(this,t);break}case ce.IN_TABLE:{_x(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_CAPTION:{Fqe(this,t);break}case ce.IN_COLUMN_GROUP:{Vqe(this,t);break}case ce.IN_TABLE_BODY:{vM(this,t);break}case ce.IN_ROW:{qoe(this,t);break}case ce.IN_CELL:{qqe(this,t);break}case ce.IN_SELECT:{Yoe(this,t);break}case ce.IN_SELECT_IN_TABLE:{Yqe(this,t);break}case ce.IN_TEMPLATE:{Wqe(this,t);break}case ce.AFTER_BODY:{Woe(this,t);break}case ce.IN_FRAMESET:{Jqe(this,t);break}case ce.AFTER_FRAMESET:{tHe(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onEof(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.IN_BODY:case ce.IN_TABLE:case ce.IN_CAPTION:case ce.IN_COLUMN_GROUP:case ce.IN_TABLE_BODY:case ce.IN_ROW:case ce.IN_CELL:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:{zoe(this,t);break}case ce.TEXT:{Iqe(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_TEMPLATE:{Goe(this,t);break}case ce.AFTER_BODY:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{P3(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===Z.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:case ce.TEXT:case ce.IN_COLUMN_GROUP:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:{this._insertCharacters(t);break}case ce.IN_BODY:case ce.IN_CAPTION:case ce.IN_CELL:case ce.IN_TEMPLATE:case ce.AFTER_BODY:case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{Doe(this,t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_TABLE_TEXT:{Foe(this,t);break}}}};function CXe(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):Uoe(e,t),n}function jXe(e,t){let n=null,i=e.openElements.stackTop;for(;i>=0;i--){const r=e.openElements.items[i];if(r===t.element)break;e._isSpecialElement(r,e.openElements.tagIDs[i])&&(n=r)}return n||(e.openElements.shortenToLength(Math.max(i,0)),e.activeFormattingElements.removeEntry(t)),n}function RXe(e,t,n){let i=t,r=e.openElements.getCommonAncestor(t);for(let s=0,a=r;a!==n;s++,a=r){r=e.openElements.getCommonAncestor(a);const o=e.activeFormattingElements.getElementEntry(a),c=o&&s>=AXe;!o||c?(c&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=IXe(e,o),i===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(i),e.treeAdapter.appendChild(a,i),i=a)}return i}function IXe(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),i=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,i),t.element=i,i}function PXe(e,t,n){const i=e.treeAdapter.getTagName(t),r=rb(i);if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const s=e.treeAdapter.getNamespaceURI(t);r===_.TEMPLATE&&s===Ye.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function MXe(e,t,n){const i=e.treeAdapter.getNamespaceURI(n.element),{token:r}=n,s=e.treeAdapter.createElement(r.tagName,i,r.attrs);e._adoptNodes(t,s),e.treeAdapter.appendChild(t,s),e.activeFormattingElements.insertElementAfterBookmark(s,r),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,s,r.tagID)}function I3(e,t){for(let n=0;n<_Xe;n++){const i=CXe(e,t);if(!i)break;const r=jXe(e,i);if(!r)break;e.activeFormattingElements.bookmark=i;const s=RXe(e,r,i.element),a=e.openElements.getCommonAncestor(i.element);e.treeAdapter.detachNode(s),a&&PXe(e,a,s),MXe(e,r,i)}}function xM(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function LXe(e,t){e._appendCommentNode(t,e.openElements.items[0])}function DXe(e,t){e._appendCommentNode(t,e.document)}function P3(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let i=e.openElements.stackTop;i>=n;i--)e._setEndLocation(e.openElements.items[i],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const i=e.openElements.items[0],r=e.treeAdapter.getNodeSourceCodeLocation(i);if(r&&!r.endTag&&(e._setEndLocation(i,t),e.openElements.stackTop>=1)){const s=e.openElements.items[1],a=e.treeAdapter.getNodeSourceCodeLocation(s);a&&!a.endTag&&e._setEndLocation(s,t)}}}}function $Xe(e,t){e._setDocumentType(t);const n=t.forceQuirks?Uo.QUIRKS:pXe(t);hXe(t)||e._err(t,$e.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=ce.BEFORE_HTML}function tO(e,t){e._err(t,$e.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Uo.QUIRKS),e.insertionMode=ce.BEFORE_HTML,e._processToken(t)}function QXe(e,t){t.tagID===_.HTML?(e._insertElement(t,Ye.HTML),e.insertionMode=ce.BEFORE_HEAD):my(e,t)}function BXe(e,t){const n=t.tagID;(n===_.HTML||n===_.HEAD||n===_.BODY||n===_.BR)&&my(e,t)}function my(e,t){e._insertFakeRootElement(),e.insertionMode=ce.BEFORE_HEAD,e._processToken(t)}function UXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.HEAD:{e._insertElement(t,Ye.HTML),e.headElement=e.openElements.current,e.insertionMode=ce.IN_HEAD;break}default:gy(e,t)}}function zXe(e,t){const n=t.tagID;n===_.HEAD||n===_.BODY||n===_.HTML||n===_.BR?gy(e,t):e._err(t,$e.endTagWithoutMatchingOpenElement)}function gy(e,t){e._insertFakeElement(ke.HEAD,_.HEAD),e.headElement=e.openElements.current,e.insertionMode=ce.IN_HEAD,e._processToken(t)}function ql(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:{e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0;break}case _.TITLE:{e._switchToTextParsing(t,jr.RCDATA);break}case _.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,jr.RAWTEXT):(e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_HEAD_NO_SCRIPT);break}case _.NOFRAMES:case _.STYLE:{e._switchToTextParsing(t,jr.RAWTEXT);break}case _.SCRIPT:{e._switchToTextParsing(t,jr.SCRIPT_DATA);break}case _.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=ce.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(ce.IN_TEMPLATE);break}case _.HEAD:{e._err(t,$e.misplacedStartTagForHeadElement);break}default:by(e,t)}}function FXe(e,t){switch(t.tagID){case _.HEAD:{e.openElements.pop(),e.insertionMode=ce.AFTER_HEAD;break}case _.BODY:case _.BR:case _.HTML:{by(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function Xp(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==_.TEMPLATE&&e._err(t,$e.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(_.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,$e.endTagWithoutMatchingOpenElement)}function by(e,t){e.openElements.pop(),e.insertionMode=ce.AFTER_HEAD,e._processToken(t)}function VXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BASEFONT:case _.BGSOUND:case _.HEAD:case _.LINK:case _.META:case _.NOFRAMES:case _.STYLE:{ql(e,t);break}case _.NOSCRIPT:{e._err(t,$e.nestedNoscriptInHead);break}default:Oy(e,t)}}function XXe(e,t){switch(t.tagID){case _.NOSCRIPT:{e.openElements.pop(),e.insertionMode=ce.IN_HEAD;break}case _.BR:{Oy(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function Oy(e,t){const n=t.type===En.EOF?$e.openElementsLeftAfterEof:$e.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=ce.IN_HEAD,e._processToken(t)}function qXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BODY:{e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=ce.IN_BODY;break}case _.FRAMESET:{e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_FRAMESET;break}case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:case _.NOFRAMES:case _.SCRIPT:case _.STYLE:case _.TEMPLATE:case _.TITLE:{e._err(t,$e.abandonedHeadElementChild),e.openElements.push(e.headElement,_.HEAD),ql(e,t),e.openElements.remove(e.headElement);break}case _.HEAD:{e._err(t,$e.misplacedStartTagForHeadElement);break}default:yy(e,t)}}function HXe(e,t){switch(t.tagID){case _.BODY:case _.HTML:case _.BR:{yy(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function yy(e,t){e._insertFakeElement(ke.BODY,_.BODY),e.insertionMode=ce.IN_BODY,mA(e,t)}function mA(e,t){switch(t.type){case En.CHARACTER:{$oe(e,t);break}case En.WHITESPACE_CHARACTER:{Doe(e,t);break}case En.COMMENT:{xM(e,t);break}case En.START_TAG:{ea(e,t);break}case En.END_TAG:{gA(e,t);break}case En.EOF:{zoe(e,t);break}}}function Doe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function $oe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function YXe(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function GXe(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function WXe(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_FRAMESET)}function ZXe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML)}function KXe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&yM.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Ye.HTML)}function JXe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function eqe(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),n||(e.formElement=e.openElements.current))}function tqe(e,t){e.framesetOk=!1;const n=t.tagID;for(let i=e.openElements.stackTop;i>=0;i--){const r=e.openElements.tagIDs[i];if(n===_.LI&&r===_.LI||(n===_.DD||n===_.DT)&&(r===_.DD||r===_.DT)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.popUntilTagNamePopped(r);break}if(r!==_.ADDRESS&&r!==_.DIV&&r!==_.P&&e._isSpecialElement(e.openElements.items[i],r))break}e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML)}function nqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.tokenizer.state=jr.PLAINTEXT}function iqe(e,t){e.openElements.hasInScope(_.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(_.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.framesetOk=!1}function rqe(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(ke.A);n&&(I3(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function sqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function aqe(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(_.NOBR)&&(I3(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function oqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function lqe(e,t){e.treeAdapter.getDocumentMode(e.document)!==Uo.QUIRKS&&e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=ce.IN_TABLE}function Qoe(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ye.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Boe(e){const t=Aoe(e,op.TYPE);return t!=null&&t.toLowerCase()===TXe}function cqe(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ye.HTML),Boe(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function uqe(e,t){e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0}function dqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._appendElement(t,Ye.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function fqe(e,t){t.tagName=ke.IMG,t.tagID=_.IMG,Qoe(e,t)}function hqe(e,t){e._insertElement(t,Ye.HTML),e.skipNextNewLine=!0,e.tokenizer.state=jr.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=ce.TEXT}function pqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,jr.RAWTEXT)}function mqe(e,t){e.framesetOk=!1,e._switchToTextParsing(t,jr.RAWTEXT)}function cF(e,t){e._switchToTextParsing(t,jr.RAWTEXT)}function gqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===ce.IN_TABLE||e.insertionMode===ce.IN_CAPTION||e.insertionMode===ce.IN_TABLE_BODY||e.insertionMode===ce.IN_ROW||e.insertionMode===ce.IN_CELL?ce.IN_SELECT_IN_TABLE:ce.IN_SELECT}function bqe(e,t){e.openElements.currentTagId===_.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML)}function Oqe(e,t){e.openElements.hasInScope(_.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Ye.HTML)}function yqe(e,t){e.openElements.hasInScope(_.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(_.RTC),e._insertElement(t,Ye.HTML)}function xqe(e,t){e._reconstructActiveFormattingElements(),Poe(t),R3(t),t.selfClosing?e._appendElement(t,Ye.MATHML):e._insertElement(t,Ye.MATHML),t.ackSelfClosing=!0}function vqe(e,t){e._reconstructActiveFormattingElements(),Moe(t),R3(t),t.selfClosing?e._appendElement(t,Ye.SVG):e._insertElement(t,Ye.SVG),t.ackSelfClosing=!0}function uF(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML)}function ea(e,t){switch(t.tagID){case _.I:case _.S:case _.B:case _.U:case _.EM:case _.TT:case _.BIG:case _.CODE:case _.FONT:case _.SMALL:case _.STRIKE:case _.STRONG:{sqe(e,t);break}case _.A:{rqe(e,t);break}case _.H1:case _.H2:case _.H3:case _.H4:case _.H5:case _.H6:{KXe(e,t);break}case _.P:case _.DL:case _.OL:case _.UL:case _.DIV:case _.DIR:case _.NAV:case _.MAIN:case _.MENU:case _.ASIDE:case _.CENTER:case _.FIGURE:case _.FOOTER:case _.HEADER:case _.HGROUP:case _.DIALOG:case _.DETAILS:case _.ADDRESS:case _.ARTICLE:case _.SEARCH:case _.SECTION:case _.SUMMARY:case _.FIELDSET:case _.BLOCKQUOTE:case _.FIGCAPTION:{ZXe(e,t);break}case _.LI:case _.DD:case _.DT:{tqe(e,t);break}case _.BR:case _.IMG:case _.WBR:case _.AREA:case _.EMBED:case _.KEYGEN:{Qoe(e,t);break}case _.HR:{dqe(e,t);break}case _.RB:case _.RTC:{Oqe(e,t);break}case _.RT:case _.RP:{yqe(e,t);break}case _.PRE:case _.LISTING:{JXe(e,t);break}case _.XMP:{pqe(e,t);break}case _.SVG:{vqe(e,t);break}case _.HTML:{YXe(e,t);break}case _.BASE:case _.LINK:case _.META:case _.STYLE:case _.TITLE:case _.SCRIPT:case _.BGSOUND:case _.BASEFONT:case _.TEMPLATE:{ql(e,t);break}case _.BODY:{GXe(e,t);break}case _.FORM:{eqe(e,t);break}case _.NOBR:{aqe(e,t);break}case _.MATH:{xqe(e,t);break}case _.TABLE:{lqe(e,t);break}case _.INPUT:{cqe(e,t);break}case _.PARAM:case _.TRACK:case _.SOURCE:{uqe(e,t);break}case _.IMAGE:{fqe(e,t);break}case _.BUTTON:{iqe(e,t);break}case _.APPLET:case _.OBJECT:case _.MARQUEE:{oqe(e,t);break}case _.IFRAME:{mqe(e,t);break}case _.SELECT:{gqe(e,t);break}case _.OPTION:case _.OPTGROUP:{bqe(e,t);break}case _.NOEMBED:case _.NOFRAMES:{cF(e,t);break}case _.FRAMESET:{WXe(e,t);break}case _.TEXTAREA:{hqe(e,t);break}case _.NOSCRIPT:{e.options.scriptingEnabled?cF(e,t):uF(e,t);break}case _.PLAINTEXT:{nqe(e,t);break}case _.COL:case _.TH:case _.TD:case _.TR:case _.HEAD:case _.FRAME:case _.TBODY:case _.TFOOT:case _.THEAD:case _.CAPTION:case _.COLGROUP:break;default:uF(e,t)}}function wqe(e,t){if(e.openElements.hasInScope(_.BODY)&&(e.insertionMode=ce.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Sqe(e,t){e.openElements.hasInScope(_.BODY)&&(e.insertionMode=ce.AFTER_BODY,Woe(e,t))}function Eqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function kqe(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(_.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(_.FORM):n&&e.openElements.remove(n))}function Tqe(e){e.openElements.hasInButtonScope(_.P)||e._insertFakeElement(ke.P,_.P),e._closePElement()}function _qe(e){e.openElements.hasInListItemScope(_.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(_.LI),e.openElements.popUntilTagNamePopped(_.LI))}function Aqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Nqe(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function Cqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function jqe(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(ke.BR,_.BR),e.openElements.pop(),e.framesetOk=!1}function Uoe(e,t){const n=t.tagName,i=t.tagID;for(let r=e.openElements.stackTop;r>0;r--){const s=e.openElements.items[r],a=e.openElements.tagIDs[r];if(i===a&&(i!==_.UNKNOWN||e.treeAdapter.getTagName(s)===n)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.stackTop>=r&&e.openElements.shortenToLength(r);break}if(e._isSpecialElement(s,a))break}}function gA(e,t){switch(t.tagID){case _.A:case _.B:case _.I:case _.S:case _.U:case _.EM:case _.TT:case _.BIG:case _.CODE:case _.FONT:case _.NOBR:case _.SMALL:case _.STRIKE:case _.STRONG:{I3(e,t);break}case _.P:{Tqe(e);break}case _.DL:case _.UL:case _.OL:case _.DIR:case _.DIV:case _.NAV:case _.PRE:case _.MAIN:case _.MENU:case _.ASIDE:case _.BUTTON:case _.CENTER:case _.FIGURE:case _.FOOTER:case _.HEADER:case _.HGROUP:case _.DIALOG:case _.ADDRESS:case _.ARTICLE:case _.DETAILS:case _.SEARCH:case _.SECTION:case _.SUMMARY:case _.LISTING:case _.FIELDSET:case _.BLOCKQUOTE:case _.FIGCAPTION:{Eqe(e,t);break}case _.LI:{_qe(e);break}case _.DD:case _.DT:{Aqe(e,t);break}case _.H1:case _.H2:case _.H3:case _.H4:case _.H5:case _.H6:{Nqe(e);break}case _.BR:{jqe(e);break}case _.BODY:{wqe(e,t);break}case _.HTML:{Sqe(e,t);break}case _.FORM:{kqe(e);break}case _.APPLET:case _.OBJECT:case _.MARQUEE:{Cqe(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:Uoe(e,t)}}function zoe(e,t){e.tmplInsertionModeStack.length>0?Goe(e,t):P3(e,t)}function Rqe(e,t){var n;t.tagID===_.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function Iqe(e,t){e._err(t,$e.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function zC(e,t){if(e.openElements.currentTagId!==void 0&&Loe.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=ce.IN_TABLE_TEXT,t.type){case En.CHARACTER:{Voe(e,t);break}case En.WHITESPACE_CHARACTER:{Foe(e,t);break}}else z1(e,t)}function Pqe(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_CAPTION}function Mqe(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_COLUMN_GROUP}function Lqe(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ke.COLGROUP,_.COLGROUP),e.insertionMode=ce.IN_COLUMN_GROUP,M3(e,t)}function Dqe(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_TABLE_BODY}function $qe(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ke.TBODY,_.TBODY),e.insertionMode=ce.IN_TABLE_BODY,bA(e,t)}function Qqe(e,t){e.openElements.hasInTableScope(_.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function Bqe(e,t){Boe(t)?e._appendElement(t,Ye.HTML):z1(e,t),t.ackSelfClosing=!0}function Uqe(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Ye.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function m0(e,t){switch(t.tagID){case _.TD:case _.TH:case _.TR:{$qe(e,t);break}case _.STYLE:case _.SCRIPT:case _.TEMPLATE:{ql(e,t);break}case _.COL:{Lqe(e,t);break}case _.FORM:{Uqe(e,t);break}case _.TABLE:{Qqe(e,t);break}case _.TBODY:case _.TFOOT:case _.THEAD:{Dqe(e,t);break}case _.INPUT:{Bqe(e,t);break}case _.CAPTION:{Pqe(e,t);break}case _.COLGROUP:{Mqe(e,t);break}default:z1(e,t)}}function _x(e,t){switch(t.tagID){case _.TABLE:{e.openElements.hasInTableScope(_.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TABLE),e._resetInsertionMode());break}case _.TEMPLATE:{Xp(e,t);break}case _.BODY:case _.CAPTION:case _.COL:case _.COLGROUP:case _.HTML:case _.TBODY:case _.TD:case _.TFOOT:case _.TH:case _.THEAD:case _.TR:break;default:z1(e,t)}}function z1(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,mA(e,t),e.fosterParentingEnabled=n}function Foe(e,t){e.pendingCharacterTokens.push(t)}function Voe(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function nO(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n0&&e.openElements.currentTagId===_.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===_.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===_.OPTGROUP&&e.openElements.pop();break}case _.OPTION:{e.openElements.currentTagId===_.OPTION&&e.openElements.pop();break}case _.SELECT:{e.openElements.hasInSelectScope(_.SELECT)&&(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode());break}case _.TEMPLATE:{Xp(e,t);break}}}function Hqe(e,t){const n=t.tagID;n===_.CAPTION||n===_.TABLE||n===_.TBODY||n===_.TFOOT||n===_.THEAD||n===_.TR||n===_.TD||n===_.TH?(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Hoe(e,t)}function Yqe(e,t){const n=t.tagID;n===_.CAPTION||n===_.TABLE||n===_.TBODY||n===_.TFOOT||n===_.THEAD||n===_.TR||n===_.TD||n===_.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Yoe(e,t)}function Gqe(e,t){switch(t.tagID){case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:case _.NOFRAMES:case _.SCRIPT:case _.STYLE:case _.TEMPLATE:case _.TITLE:{ql(e,t);break}case _.CAPTION:case _.COLGROUP:case _.TBODY:case _.TFOOT:case _.THEAD:{e.tmplInsertionModeStack[0]=ce.IN_TABLE,e.insertionMode=ce.IN_TABLE,m0(e,t);break}case _.COL:{e.tmplInsertionModeStack[0]=ce.IN_COLUMN_GROUP,e.insertionMode=ce.IN_COLUMN_GROUP,M3(e,t);break}case _.TR:{e.tmplInsertionModeStack[0]=ce.IN_TABLE_BODY,e.insertionMode=ce.IN_TABLE_BODY,bA(e,t);break}case _.TD:case _.TH:{e.tmplInsertionModeStack[0]=ce.IN_ROW,e.insertionMode=ce.IN_ROW,OA(e,t);break}default:e.tmplInsertionModeStack[0]=ce.IN_BODY,e.insertionMode=ce.IN_BODY,ea(e,t)}}function Wqe(e,t){t.tagID===_.TEMPLATE&&Xp(e,t)}function Goe(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(_.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):P3(e,t)}function Zqe(e,t){t.tagID===_.HTML?ea(e,t):Yk(e,t)}function Woe(e,t){var n;if(t.tagID===_.HTML){if(e.fragmentContext||(e.insertionMode=ce.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===_.HTML){e._setEndLocation(e.openElements.items[0],t);const i=e.openElements.items[1];i&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(i))===null||n===void 0)&&n.endTag)&&e._setEndLocation(i,t)}}else Yk(e,t)}function Yk(e,t){e.insertionMode=ce.IN_BODY,mA(e,t)}function Kqe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.FRAMESET:{e._insertElement(t,Ye.HTML);break}case _.FRAME:{e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0;break}case _.NOFRAMES:{ql(e,t);break}}}function Jqe(e,t){t.tagID===_.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==_.FRAMESET&&(e.insertionMode=ce.AFTER_FRAMESET))}function eHe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.NOFRAMES:{ql(e,t);break}}}function tHe(e,t){t.tagID===_.HTML&&(e.insertionMode=ce.AFTER_AFTER_FRAMESET)}function nHe(e,t){t.tagID===_.HTML?ea(e,t):aE(e,t)}function aE(e,t){e.insertionMode=ce.IN_BODY,mA(e,t)}function iHe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.NOFRAMES:{ql(e,t);break}}}function rHe(e,t){t.chars=rr,e._insertCharacters(t)}function sHe(e,t){e._insertCharacters(t),e.framesetOk=!1}function Zoe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Ye.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function aHe(e,t){if(vXe(t))Zoe(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),i=e.treeAdapter.getNamespaceURI(n);i===Ye.MATHML?Poe(t):i===Ye.SVG&&(wXe(t),Moe(t)),R3(t),t.selfClosing?e._appendElement(t,i):e._insertElement(t,i),t.ackSelfClosing=!0}}function oHe(e,t){if(t.tagID===_.P||t.tagID===_.BR){Zoe(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const i=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(i)===Ye.HTML){e._endTagOutsideForeignContent(t);break}const r=e.treeAdapter.getTagName(i);if(r.toLowerCase()===t.tagName){t.tagName=r,e.openElements.shortenToLength(n);break}}}ke.AREA,ke.BASE,ke.BASEFONT,ke.BGSOUND,ke.BR,ke.COL,ke.EMBED,ke.FRAME,ke.HR,ke.IMG,ke.INPUT,ke.KEYGEN,ke.LINK,ke.META,ke.PARAM,ke.SOURCE,ke.TRACK,ke.WBR;const lHe=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,cHe=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),dF={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function Koe(e,t){const n=yHe(e),i=hae("type",{handlers:{root:uHe,element:dHe,text:fHe,comment:ele,doctype:hHe,raw:mHe},unknown:gHe}),r={parser:n?new lF(dF):lF.getFragmentParser(void 0,dF),handle(o){i(o,r)},stitches:!1,options:t||{}};i(e,r),sb(r,Wc());const s=n?r.parser.document:r.parser.getFragment(),a=xVe(s,{file:r.options.file});return r.stitches&&B1(a,"comment",function(o,c,u){const d=o;if(d.value.stitch&&u&&c!==void 0){const f=u.children;return f[c]=d.value.stitch,c}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function Joe(e,t){let n=-1;if(e)for(;++n4&&(t.parser.tokenizer.state=0);const n={type:En.CHARACTER,chars:e.value,location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function hHe(e,t){const n={type:En.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function pHe(e,t){t.stitches=!0;const n=xHe(e);if("children"in e&&"children"in n){const i=Koe({type:"root",children:e.children},t.options);n.children=i.children}ele({type:"comment",value:{stitch:n}},t)}function ele(e,t){const n=e.value,i={type:En.COMMENT,data:n,location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken)}function mHe(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,tle(t,Wc(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(lHe,"<$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function gHe(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))pHe(n,t);else{let i="";throw cHe.has(n.type)&&(i=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+i)}}function sb(e,t){tle(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=jr.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function tle(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function bHe(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===jr.PLAINTEXT)return;sb(t,Wc(e));const i=t.parser.openElements.current;let r="namespaceURI"in i?i.namespaceURI:Uh.html;r===Uh.html&&n==="svg"&&(r=Uh.svg);const s=kVe({...e,children:[]},{space:r===Uh.svg?"svg":"html"}),a={type:En.START_TAG,tagName:n,tagID:rb(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in s?s.attrs:[],location:F1(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function OHe(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&IVe.includes(n)||t.parser.tokenizer.state===jr.PLAINTEXT)return;sb(t,cA(e));const i={type:En.END_TAG,tagName:n,tagID:rb(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:F1(e)};t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===jr.RCDATA||t.parser.tokenizer.state===jr.RAWTEXT||t.parser.tokenizer.state===jr.SCRIPT_DATA)&&(t.parser.tokenizer.state=jr.DATA)}function yHe(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function F1(e){const t=Wc(e)||{line:void 0,column:void 0,offset:void 0},n=cA(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function xHe(e){return"children"in e?h0({...e,children:[]}):h0(e)}function vHe(e){return function(t,n){return Koe(t,{...e,file:n})}}const nle=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function ile(e){if(!e)return!1;try{const t=e.toLowerCase();return nle.some(n=>t.includes(n))}catch{return!1}}function wHe(e){var i;const t=(i=e==null?void 0:e.properties)==null?void 0:i.href;if(!t)return!1;if(ile(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const r=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return nle.some(s=>r.includes(s))}return!1}function SHe({text:e,className:t,allowRawHtml:n=!0}){const[i,r]=m.useState(null),s=(c,u)=>{if(c.src)return c.src;if(u){const d=h=>{var p;if(!h)return null;if(h.type==="source"&&((p=h.properties)!=null&&p.src))return h.properties.src;if(h.children)for(const g of h.children){const b=d(g);if(b)return b}return null},f=d({children:u});if(f)return f}return""},a=c=>{try{const d=new URL(c).pathname.split("/");return d[d.length-1]||"video.mp4"}catch{return"video.mp4"}},o=c=>c?Array.isArray(c)?c.map(u=>(u==null?void 0:u.value)||"").join("")||"video":(c==null?void 0:c.value)||"video":"video";return l.jsxs("div",{className:t?`md ${t}`:"md",children:[l.jsx(T9e,{remarkPlugins:[Q7e],rehypePlugins:n?[vHe,Yz]:[Yz],components:{a:({node:c,...u})=>{const d=u.href;if(d&&(ile(d)||wHe(c))){const f=d,h=o(c==null?void 0:c.children);return l.jsxs("div",{className:"video-container",children:[l.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${h}`,onClick:()=>r({src:f,title:h}),children:[l.jsx("video",{src:f,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),l.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]}),l.jsx("div",{className:"video-caption",children:l.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:h})})]})}return l.jsx("a",{...u,target:"_blank",rel:"noopener noreferrer"})},img:({node:c,src:u,alt:d,...f})=>{const h=l.jsx("img",{...f,src:u,alt:d??"",loading:"lazy"});return u?l.jsx(rJ,{src:u,children:l.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${d||"图片"}`,children:[h,l.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]})}):h},video:({node:c,src:u,children:d,...f})=>{const h=s({src:u},d);return h?l.jsx("div",{className:"video-container",children:l.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>r({src:h}),children:[l.jsx("video",{src:h,...f,playsInline:!0,className:"video-thumbnail",children:d}),l.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]})}):l.jsx("video",{src:u,controls:!0,playsInline:!0,className:"video-inline",...f,children:d})}},children:e}),i&&l.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>r(null),children:l.jsxs("div",{className:"video-viewer",onClick:c=>c.stopPropagation(),children:[l.jsxs("div",{className:"video-viewer-header",children:[l.jsx("div",{className:"video-viewer-title",children:i.title||a(i.src)}),l.jsxs("nav",{className:"video-viewer-nav",children:[l.jsx("a",{href:i.src,download:i.title||a(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:l.jsx(b_,{})}),l.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>r(null),children:l.jsx(xa,{})})]})]}),l.jsx("div",{className:"video-viewer-body",children:l.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const qp=m.memo(SHe);function yA({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:i}){return e.skills.length===0&&!e.targetAgent?null:l.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(r=>l.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:r.description,children:[l.jsx(tx,{"aria-hidden":!0}),l.jsxs("span",{children:[t,r.name]}),n?l.jsx("button",{type:"button",onClick:()=>n(r.name),"aria-label":`移除技能 ${r.name}`,children:l.jsx(xa,{})}):null]},r.name)),e.targetAgent?l.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[l.jsx(oJ,{"aria-hidden":!0}),l.jsx("span",{children:e.targetAgent.name}),i?l.jsx("button",{type:"button",onClick:i,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:l.jsx(xa,{})}):null]}):null]})}function L3(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function rle(e){var n,i,r,s;const t=L3(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((i=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:i.toUpperCase())??"VIDEO":t==="image"?((s=(r=e.mimeType)==null?void 0:r.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function sle(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function ale(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?XJ(t,e.uri):""}function EHe({kind:e}){return e==="image"?l.jsx(LD,{}):e==="video"?l.jsx(dJ,{}):e==="pdf"?l.jsx(Ywe,{}):l.jsx(PD,{})}function xA({appName:e,items:t,compact:n=!1,onRemove:i}){const[r,s]=m.useState(null);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const o=L3(a.mimeType),c=ale(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=l.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:o==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[o==="image"&&c?l.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):o==="video"&&c?l.jsxs("div",{className:"media-card-video-container",children:[l.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),l.jsx("span",{className:"media-card-video-play",children:l.jsx(lSe,{})})]}):l.jsx("span",{className:"media-card-icon",children:l.jsx(EHe,{kind:o})}),l.jsxs("span",{className:"media-card-copy",children:[l.jsx("span",{className:"media-card-name",children:a.name??"附件"}),l.jsxs("span",{className:"media-card-meta",children:[l.jsx("span",{className:"media-card-type",children:rle(a)}),a.status==="uploading"?l.jsxs(l.Fragment,{children:[l.jsx(Kn,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":sle(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?l.jsx(np,{className:"media-card-open"}):null]});return l.jsxs(wr.div,{className:`media-card media-card--${o}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[o==="image"&&!u?l.jsx(rJ,{src:c,children:d}):d,i?l.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>i(a.id),children:l.jsx(xa,{})}):null]},a.id)})}),l.jsx(xf,{children:r?l.jsx(kHe,{appName:e,item:r,onClose:()=>s(null)}):null})]})}function kHe({appName:e,item:t,onClose:n}){const i=m.useMemo(()=>ale(t,e),[e,t]),r=L3(t.mimeType),[s,a]=m.useState(""),[o,c]=m.useState(r==="text"||r==="markdown"),[u,d]=m.useState("");return m.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),m.useEffect(()=>{if(r!=="text"&&r!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(i,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[r,i]),l.jsx(wr.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:l.jsxs(wr.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[l.jsxs("header",{className:"media-viewer-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:t.name??"附件"}),l.jsxs("span",{children:[rle(t),t.sizeBytes?` · ${sle(t.sizeBytes)}`:""]})]}),l.jsxs("nav",{children:[l.jsx("a",{href:i,download:t.name,"aria-label":"下载",children:l.jsx(b_,{})}),l.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:l.jsx(xa,{})})]})]}),l.jsxs("div",{className:`media-viewer-body media-viewer-body--${r}`,children:[r==="image"?l.jsx("img",{src:i,alt:t.name??"图片"}):null,r==="video"?l.jsx("div",{className:"media-viewer-video-wrapper",children:l.jsx("video",{src:i,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,r==="pdf"?l.jsx("iframe",{src:i,title:t.name??"PDF"}):null,o?l.jsxs("div",{className:"media-viewer-loading",children:[l.jsx(Kn,{})," 正在读取文档…"]}):null,!o&&u?l.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!o&&r==="markdown"?l.jsx("div",{className:"media-document",children:l.jsx(qp,{text:s})}):null,!o&&r==="text"?l.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function THe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),l.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function _He(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),l.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),l.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),l.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function D3(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),l.jsxs("g",{className:"video-generate-icon__clapper",children:[l.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),l.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),l.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function AHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),l.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),l.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function NHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),l.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),l.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function CHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),l.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),l.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),l.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function jHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),l.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),l.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function RHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),l.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),l.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),l.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function ole(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function IHe({definition:e,label:t,done:n,open:i,onToggle:r}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return l.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:r,"aria-expanded":i,children:[l.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:l.jsx(s,{})}),n?l.jsx("span",{className:"builtin-tool-label",children:a}):l.jsx(oi,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),l.jsx(ole,{className:`builtin-tool-chevron${i?" is-open":""}`})]})}const PHe={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:THe},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:RHe},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:_He},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:D3},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:AHe},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:NHe},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:CHe},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:jHe}};function MHe(e){return PHe[e]}function LHe(e){return l.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}const lle="send_a2ui_json_to_client",DHe=28;function $He(e,t,n){let i=t;for(let r=0;r65535?2:1}return i}function QHe(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function cle(e,t,n,i){const[r,s]=m.useState(()=>t?"":e),a=m.useRef(r),o=m.useRef(e),c=m.useRef(null),u=m.useRef(0),d=m.useRef(n);return o.current=e,d.current=n,m.useEffect(()=>{const f=a.current,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||h||!e.startsWith(f)){c.current!==null&&window.cancelAnimationFrame(c.current),c.current=null,f!==e&&(a.current=e,s(e));return}if(f===e||c.current!==null)return;const p=g=>{const b=o.current,y=a.current;if(!b.startsWith(y)){a.current=b,s(b),c.current=null;return}if(g-u.current{var f;(f=d.current)==null||f.call(d)},[r]),m.useEffect(()=>{r===e&&(i==null||i())},[r,i,e]),m.useEffect(()=>()=>{c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)},[]),r}function BHe(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M14.3 5.25a4.6 4.6 0 0 0-5.55 5.55L3.6 15.95a1.8 1.8 0 0 0 0 2.55l1.9 1.9a1.8 1.8 0 0 0 2.55 0l5.15-5.15a4.6 4.6 0 0 0 5.55-5.55l-2.9 2.9-2.45-.55-.55-2.45 2.9-2.9a4.6 4.6 0 0 0-1.45-1.45Z"})})}function UHe(e,t){if(e!=="load_skill"||t==null||typeof t!="object"||Array.isArray(t))return;const n=t.skill_name;if(!(typeof n!="string"||!n.trim()))return`使用 ${n.trim()} 技能`}function ule({text:e,done:t,answerStarted:n=!1,streaming:i=!1,onStreamFrame:r}){const[s,a]=m.useState(!(t||n)),o=m.useRef(!1);m.useEffect(()=>{o.current||a(!(t||n))},[n,t]);const c=()=>{o.current=!0,a(p=>!p)},u=e.replace(/^\s+/,""),d=cle(u,!t||i,r),{ref:f,onScroll:h}=Ese(d);return l.jsxs("div",{className:"block-thinking",children:[l.jsxs("button",{className:"think-head",onClick:c,type:"button",children:[l.jsx("span",{className:"think-icon","aria-hidden":"true",children:l.jsx(LHe,{className:`thinking-logo ${t?"":"is-active"}`})}),t?l.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):l.jsx(oi,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),l.jsx(U0,{className:`chev ${s?"open":""}`})]}),l.jsx("div",{className:`think-collapse ${s&&d?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsx("div",{className:"think-body scroll",ref:f,onScroll:h,children:d})})})]})}function dle(){return l.jsx(ule,{text:"",done:!1})}const zHe=m.memo(function({text:t,streaming:n,onStreamFrame:i,onStreamComplete:r}){const s=cle(t,n,i,r);return s?l.jsx("div",{className:"bubble",children:l.jsx(qp,{text:s})}):null});function FHe({name:e,args:t,response:n,done:i}){const[r,s]=m.useState(!1),a=e===lle?"渲染 UI":e,o=MHe(e),c=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),u=c&&c.length>2e3?c.slice(0,2e3)+` -…(已截断)`:c;return l.jsxs(wr.div,{className:`block-tool${o?" block-tool--builtin":""}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[o?l.jsx(IHe,{definition:o,label:UHe(e,t),done:i,open:r,onToggle:()=>s(d=>!d)}):l.jsxs("button",{className:"tool-head tool-head--generic",onClick:()=>s(d=>!d),type:"button","aria-expanded":r,children:[l.jsx("span",{className:"tool-icon tool-icon--generic","aria-hidden":"true",children:l.jsx(BHe,{})}),i?l.jsx("span",{className:"tool-name",children:a}):l.jsx(oi,{className:"tool-name",duration:2.2,spread:15,children:a}),l.jsx(ole,{className:`tool-chevron${r?" is-open":""}`})]}),l.jsx("div",{className:`think-collapse ${r?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsxs("div",{className:"tool-detail",children:[t!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"参数"}),l.jsx("pre",{className:"tool-args",children:JSON.stringify(t,null,2)})]}),u!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"返回"}),l.jsx("pre",{className:"tool-args tool-result",children:u})]})]})})})]})}function VHe({block:e,onDownload:t,onPreview:n}){const[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(null);m.useEffect(()=>()=>{o&&URL.revokeObjectURL(o.url)},[o]);const u=()=>c(null),d=async(p,g)=>{if(t){r(`download:${p}`),a("");try{await t(p,g)}catch(b){a(b instanceof Error?b.message:String(b))}finally{r("")}}},f=async(p,g,b)=>{if(n){r(`preview:${b}`),a("");try{const y=await n(p,g);c({name:b,url:y})}catch(y){a(y instanceof Error?y.message:String(y))}finally{r("")}}},h=e.files.filter(p=>!p.filename.endsWith(".preview.webp"));return l.jsxs("div",{className:"artifact-list",children:[h.map(p=>{const g=`${p.filename.replace(/\.pptx$/i,"")}.preview.webp`,b=e.files.find(y=>y.filename===g);return l.jsxs("div",{className:"artifact-card",children:[l.jsx("span",{className:"artifact-card__icon","aria-hidden":"true",children:l.jsx(PD,{})}),l.jsxs("span",{className:"artifact-card__copy",children:[l.jsx("span",{className:"artifact-card__name",children:p.filename}),l.jsx("span",{className:"artifact-card__hint",children:"PowerPoint 演示文稿"})]}),l.jsxs("span",{className:"artifact-card__actions",children:[b&&l.jsxs("button",{className:"artifact-card__action",type:"button",disabled:!n||i!=="",onClick:()=>void f(b.filename,b.version,p.filename),children:[i===`preview:${p.filename}`?l.jsx(Kn,{className:"spin"}):l.jsx(Xwe,{}),"预览"]}),l.jsxs("button",{className:"artifact-card__action artifact-card__action--primary",type:"button",disabled:!t||i!=="",onClick:()=>void d(p.filename,p.version),children:[i===`download:${p.filename}`?l.jsx(Kn,{className:"spin"}):l.jsx(b_,{}),"下载"]})]})]},`${p.filename}:${p.version}`)}),s&&l.jsx("div",{className:"artifact-card__error",children:s}),o&&l.jsxs("div",{className:"artifact-preview",role:"dialog","aria-modal":"true","aria-label":`${o.name} 预览`,children:[l.jsx("button",{className:"artifact-preview__backdrop",type:"button","aria-label":"关闭预览",onClick:u}),l.jsxs("div",{className:"artifact-preview__panel",children:[l.jsxs("div",{className:"artifact-preview__header",children:[l.jsx("span",{children:o.name}),l.jsx("button",{type:"button","aria-label":"关闭预览",onClick:u,children:l.jsx(xa,{})})]}),l.jsx("div",{className:"artifact-preview__canvas",children:l.jsx("img",{src:o.url,alt:`${o.name} 幻灯片预览`})})]})]})]})}function XHe({block:e,onAuth:t}){const[n,i]=m.useState(e.done?"done":"idle"),[r,s]=m.useState(""),a=e.label||"MCP 工具集",o=(()=>{try{return e.authUri?new URL(e.authUri).host:""}catch{return""}})(),c=async()=>{if(t){s(""),i("authorizing");try{await t(e),i("done")}catch(d){s(d instanceof Error?d.message:String(d)),i("idle")}}};return e.done||n==="done"?l.jsxs(wr.div,{className:"auth-card-collapsed",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:[l.jsx(s9,{className:"auth-card-icon auth-card-icon--done"}),l.jsxs("span",{children:["已授权 · ",a]})]}):l.jsxs(wr.div,{className:"auth-card",initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[l.jsxs("div",{className:"auth-card-head",children:[l.jsx(s9,{className:"auth-card-icon"}),l.jsxs("span",{className:"auth-card-title",children:[a," 需要授权"]})]}),l.jsxs("p",{className:"auth-card-desc",children:["工具集 ",l.jsx("code",{className:"auth-card-code",children:a})," 使用 OAuth 保护, 需登录授权后方可调用。",o&&l.jsxs(l.Fragment,{children:[" ","将跳转至 ",l.jsx("code",{className:"auth-card-code",children:o})," 完成登录,"]}),"授权完成后对话自动继续。"]}),l.jsx("button",{className:"auth-card-btn",onClick:c,disabled:n==="authorizing"||!e.authUri,children:n==="authorizing"?l.jsxs(l.Fragment,{children:[l.jsx(Kn,{className:"cw-i spin"})," 等待授权…"]}):l.jsx(l.Fragment,{children:"去授权"})}),!e.authUri&&l.jsx("div",{className:"auth-card-err",children:"未在事件中找到授权地址。"}),r&&l.jsx("div",{className:"auth-card-err",children:r})]})}function vA({blocks:e,appName:t="",streaming:n=!1,onStreamFrame:i,onStreamComplete:r,onAction:s,onAuth:a,onArtifactDownload:o,onArtifactPreview:c}){const u=e.reduce((d,f,h)=>f.kind==="text"?h:d,-1);return l.jsx(l.Fragment,{children:e.map((d,f)=>{switch(d.kind){case"thinking":{const h=e.slice(f+1).some(p=>p.kind==="text"&&!!p.text.trim());return l.jsx(ule,{text:d.text,done:d.done,answerStarted:h,streaming:n,onStreamFrame:i},f)}case"text":{const h=d.text.replace(/^\s+/,"");return h?l.jsx(zHe,{text:h,streaming:n,onStreamFrame:i,onStreamComplete:f===u?r:void 0},f):null}case"attachment":return l.jsx(xA,{appName:t,items:d.files},f);case"artifact":return l.jsx(VHe,{block:d,onDownload:o,onPreview:c},f);case"invocation":return l.jsx(yA,{value:d.value},f);case"tool":return d.name===lle&&d.done?null:l.jsx(FHe,{name:d.name,args:d.args,response:d.response,done:d.done},f);case"agent-transfer":return null;case"auth":return l.jsx(XHe,{block:d,onAuth:a},f);case"a2ui":return Sse(d.messages).filter(h=>h.components[h.rootId]).map(h=>l.jsx(wr.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},transition:{type:"spring",stiffness:380,damping:30},children:l.jsx(G4e,{surface:h,onAction:s})},`${f}-${h.surfaceId}`));default:return null}})})}const qHe=()=>{};function HHe(e){if(e.kind==="message")return{kind:"text",text:e.text};if(e.kind==="thinking")return{kind:"thinking",text:e.text,done:e.status==="done"};if(e.kind==="tool")return{kind:"tool",name:e.name,args:e.args,response:e.response,done:e.status==="done"};throw new Error("不支持的 Skill 对话活动")}function YHe({activities:e}){const t=m.useMemo(()=>e.filter(n=>n.kind!=="status").map(HHe),[e]);return t.length===0?null:l.jsx("div",{className:"skill-conversation","aria-label":"Skill 生成对话","aria-live":"polite",children:l.jsx(vA,{blocks:t,onAction:qHe})})}function fF(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function FC({label:e,value:t,options:n,onChange:i,disabled:r=!1,allowCustom:s=!1,required:a=!1,placeholder:o="请选择",error:c}){const u=m.useId(),d=m.useId(),f=m.useId(),h=m.useRef(null),p=m.useRef(null),g=m.useRef(null),b=m.useRef(null),y=m.useRef([]),O=n.findIndex(L=>L.value===t),v=t.trim().toLocaleLowerCase(),x=s&&v?n.filter(L=>L.value.toLocaleLowerCase().includes(v)||L.label.toLocaleLowerCase().includes(v)):n,[w,E]=m.useState(!1),[S,k]=m.useState(Math.max(0,O)),T=O>=0?n[O]:void 0,A=r||!s&&n.length===0,N=(L=!1)=>{E(!1),L&&window.requestAnimationFrame(()=>{var P,Q;return s?(P=g.current)==null?void 0:P.focus():(Q=p.current)==null?void 0:Q.focus()})},C=L=>{A||x.length!==0&&(k(Math.min(Math.max(L,0),x.length-1)),E(!0))};m.useEffect(()=>{if(!w)return;const L=b.current,P=s?void 0:window.requestAnimationFrame(()=>{var U;(U=y.current[S])==null||U.focus()}),Q=U=>{if(!L)return;const B=L.scrollTop<=0,I=L.scrollTop+L.clientHeight>=L.scrollHeight-1;(L.scrollHeight<=L.clientHeight||U.deltaY<0&&B||U.deltaY>0&&I)&&U.preventDefault(),U.stopPropagation()},j=U=>{var B;U.target instanceof Node&&!((B=h.current)!=null&&B.contains(U.target))&&N()},$=U=>{U.key==="Escape"&&N(!0)};return L==null||L.addEventListener("wheel",Q,{passive:!1}),window.addEventListener("pointerdown",j),window.addEventListener("keydown",$),()=>{P!==void 0&&window.cancelAnimationFrame(P),L==null||L.removeEventListener("wheel",Q),window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",$)}},[S,s,w]);const M=L=>{var Q;if(x.length===0)return;const P=(L+x.length)%x.length;k(P),(Q=y.current[P])==null||Q.focus()};return l.jsxs("div",{ref:h,className:`skill-config-select${w?" is-open":""}`,onBlur:L=>{var P;(!L.relatedTarget||!((P=h.current)!=null&&P.contains(L.relatedTarget)))&&N()},children:[l.jsxs("span",{id:d,className:"skill-config-select__label",children:[e,a?l.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"}):null]}),s?l.jsxs("div",{className:`skill-config-select__trigger is-editable${r?" is-disabled":""}`,"aria-expanded":w,children:[l.jsx("input",{ref:g,value:t,disabled:r,role:"combobox","aria-autocomplete":"list","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,"aria-invalid":!!c,"aria-describedby":c?f:void 0,placeholder:o,onChange:L=>{i(L.target.value),k(0),n.length>0&&E(!0)},onClick:()=>{!w&&x.length>0&&C(0)},onKeyDown:L=>{var P,Q;if(!(L.nativeEvent.isComposing||L.keyCode===229))if(L.key==="ArrowDown")L.preventDefault(),w?(P=y.current[S])==null||P.focus():C(0);else if(L.key==="ArrowUp")L.preventDefault(),w?(Q=y.current[x.length-1])==null||Q.focus():C(x.length-1);else if(L.key==="Enter"&&w){L.preventDefault();const j=x[S];j&&i(j.value),N()}else L.key==="Escape"&&(L.preventDefault(),N())}}),l.jsx("button",{type:"button",className:"skill-config-select__toggle",disabled:r||n.length===0,"aria-label":w?"收起模型选项":"展开模型选项",onClick:()=>{w?N():C(0)},children:l.jsx(fF,{})})]}):l.jsxs("button",{ref:p,type:"button",className:"skill-config-select__trigger",disabled:A,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,onClick:()=>{w?N():C(O>=0?O:0)},onKeyDown:L=>{L.key==="ArrowDown"?(L.preventDefault(),C(O>=0?O:0)):L.key==="ArrowUp"&&(L.preventDefault(),C(O>=0?O:n.length-1))},children:[l.jsx("span",{className:T?void 0:"is-placeholder",title:T==null?void 0:T.label,children:(T==null?void 0:T.label)||(n.length===0?"暂无可用选项":o)}),l.jsx(fF,{})]}),w?l.jsxs("div",{ref:b,id:u,className:"skill-config-select__menu",role:"listbox","aria-labelledby":d,children:[x.length===0?l.jsx("div",{className:"skill-config-select__empty",role:"status",children:"没有匹配项,可直接使用当前模型 ID"}):null,x.map((L,P)=>{const Q=L.value===t;return l.jsx("button",{ref:j=>{y.current[P]=j},type:"button",role:"option","aria-selected":Q,tabIndex:P===S?0:-1,className:`skill-config-select__option${Q?" is-selected":""}`,title:L.label,onFocus:()=>k(P),onClick:()=>{i(L.value),N(!0)},onKeyDown:j=>{j.key==="ArrowDown"?(j.preventDefault(),M(P+1)):j.key==="ArrowUp"?(j.preventDefault(),M(P-1)):j.key==="Home"?(j.preventDefault(),M(0)):j.key==="End"&&(j.preventDefault(),M(n.length-1))},children:L.label},L.value)})]}):null,c?l.jsx("span",{id:f,className:"skill-config-select__error",role:"alert",children:c}):null]})}function ds(e,t){return e instanceof Error?e:typeof e=="string"&&e.trim()?new Error(e.trim()):new Error(t)}function ho({error:e}){var r,s,a,o,c;const t=e,n=(s=(r=t.originalError)==null?void 0:r.message)==null?void 0:s.trim(),i=[typeof t.status=="number"?`HTTP ${t.status}${t.statusText?` ${t.statusText}`:""}`:"",t.code?`错误码:${t.code}`:"",(a=t.originalError)!=null&&a.type?`错误类型:${t.originalError.type}`:"",(o=t.originalError)!=null&&o.repr&&t.originalError.repr!==n?`异常表示:${t.originalError.repr}`:"",(c=t.rawResponse)!=null&&c.trim()?`服务端原始响应: +`))}function c(p,g,b,y){const O=b.enter("tableCell"),v=b.enter("phrasing"),x=b.containerPhrasing(p,{...y,before:s,after:s});return v(),O(),x}function u(p,g){return pUe(p,{align:g,alignDelimiters:i,padding:n,stringLength:r})}function d(p,g,b){const y=p.children;let O=-1;const v=[],x=g.enter("table");for(;++O0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const O7e={tokenize:T7e,partial:!0};function y7e(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:S7e,continuation:{tokenize:E7e},exit:k7e}},text:{91:{name:"gfmFootnoteCall",tokenize:w7e},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:x7e,resolveTo:v7e}}}}function x7e(e,t,n){const i=this;let r=i.events.length;const s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;r--;){const c=i.events[r][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!a||!a._balanced)return n(c);const u=Ml(i.sliceSerialize({start:a.end,end:i.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function v7e(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...o),e}function w7e(e,t,n){const i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!a||f===null||f===91||Li(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return r.includes(Ml(i.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Li(f)||(a=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function S7e(e,t,n){const i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s,a=0,o;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!o||g===null||g===91||Li(g))return n(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=Ml(i.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Li(g)||(o=!0),a++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),r.includes(s)||r.push(s),Yn(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function E7e(e,t,n){return e.check($1,t,e.attempt(O7e,t,n))}function k7e(e){e.exit("gfmFootnoteDefinition")}function T7e(e,t,n){const i=this;return Yn(e,r,"gfmFootnoteDefinitionIndent",5);function r(s){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function _7e(e){let n=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:s,resolveAll:r};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function r(a,o){let c=-1;for(;++c1?c(g):(a.consume(g),f++,p);if(f<2&&!n)return c(g);const y=a.exit("strikethroughSequenceTemporary"),O=f0(g);return y._open=!O||O===2&&!!b,y._close=!b||b===2&&!!O,o(g)}}}class A7e{constructor(){this.map=[]}add(t,n,i){N7e(this,t,n,i)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];i.push(t.slice()),t.length=0;let r=i.pop();for(;r;){for(const s of r)t.push(s);r=i.pop()}this.map.length=0}}function N7e(e,t,n,i){let r=0;if(!(n===0&&i.length===0)){for(;r-1;){const P=i.events[C][1].type;if(P==="lineEnding"||P==="linePrefix")C--;else break}const M=C>-1?i.events[C][1].type:null,L=M==="tableHead"||M==="tableRow"?S:c;return L===S&&i.parser.lazy[i.now().line]?n(N):L(N)}function c(N){return e.enter("tableHead"),e.enter("tableRow"),u(N)}function u(N){return N===124||(a=!0,s+=1),d(N)}function d(N){return N===null?n(N):Ht(N)?s>1?(s=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),p):n(N):Rn(N)?Yn(e,d,"whitespace")(N):(s+=1,a&&(a=!1,r+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(N)))}function f(N){return N===null||N===124||Li(N)?(e.exit("data"),d(N)):(e.consume(N),N===92?h:f)}function h(N){return N===92||N===124?(e.consume(N),f):f(N)}function p(N){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(N):(e.enter("tableDelimiterRow"),a=!1,Rn(N)?Yn(e,g,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?y(N):N===124?(a=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),b):E(N)}function b(N){return Rn(N)?Yn(e,y,"whitespace")(N):y(N)}function y(N){return N===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),O):N===45?(s+=1,O(N)):N===null||Ht(N)?w(N):E(N)}function O(N){return N===45?(e.enter("tableDelimiterFiller"),v(N)):E(N)}function v(N){return N===45?(e.consume(N),v):N===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(N))}function x(N){return Rn(N)?Yn(e,w,"whitespace")(N):w(N)}function w(N){return N===124?g(N):N===null||Ht(N)?!a||r!==s?E(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):E(N)}function E(N){return n(N)}function S(N){return e.enter("tableRow"),k(N)}function k(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),k):N===null||Ht(N)?(e.exit("tableRow"),t(N)):Rn(N)?Yn(e,k,"whitespace")(N):(e.enter("data"),T(N))}function T(N){return N===null||N===124||Li(N)?(e.exit("data"),k(N)):(e.consume(N),N===92?A:T)}function A(N){return N===92||N===124?(e.consume(N),T):T(N)}}function I7e(e,t){let n=-1,i=!0,r=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,c=0,u,d,f;const h=new A7e;for(;++nn[2]+1){const g=n[2]+1,b=n[3]-n[2]-1;e.add(g,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return r!==void 0&&(s.end=Object.assign({},Am(t.events,r)),e.add(r,0,[["exit",s,t]]),s=void 0),s}function Nz(e,t,n,i,r){const s=[],a=Am(t.events,n);r&&(r.end=Object.assign({},a),s.push(["exit",r,t])),i.end=Object.assign({},a),s.push(["exit",i,t]),e.add(n+1,0,s)}function Am(e,t){const n=e[t],i=n[0]==="enter"?"start":"end";return n[1][i]}const P7e={name:"tasklistCheck",tokenize:L7e};function M7e(){return{text:{91:P7e}}}function L7e(e,t,n){const i=this;return r;function r(c){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Li(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(c)}function o(c){return Ht(c)?t(c):Rn(c)?e.check({tokenize:D7e},t,n)(c):n(c)}}function D7e(e,t,n){return Yn(e,i,"whitespace");function i(r){return r===null?n(r):t(r)}}function $7e(e){return zse([c7e(),y7e(),_7e(e),j7e(),M7e()])}const Q7e={};function B7e(e){const t=this,n=e||Q7e,i=t.data(),r=i.micromarkExtensions||(i.micromarkExtensions=[]),s=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);r.push($7e(n)),s.push(s7e()),a.push(a7e(n))}const Cz=function(e,t,n){const i=Q1(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++tu&&(u=d):d&&(u!==void 0&&u>-1&&c.push(` +`.repeat(u)||" "),u=-1,c.push(d))}return c.join("")}function Mae(e,t,n){return e.type==="element"?Y7e(e,t,n):e.type==="text"?n.whitespace==="normal"?Lae(e,n):G7e(e):[]}function Y7e(e,t,n){const i=Dae(e,n),r=e.children||[];let s=-1,a=[];if(q7e(e))return a;let o,c;for(gM(e)||Pz(e)&&Cz(t,e,Pz)?c=` +`:X7e(e)?(o=2,c=2):Pae(e)&&(o=1,c=1);++s]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],y=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],O=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],w={type:b,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:y},E={className:"function.dispatch",relevance:0,keywords:{_hint:O},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},S=[E,f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:w,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:w,illegal:"",keywords:w,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:w},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function nze(e){const t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=tze(e),i=n.keywords;return i.type=[...i.type,...t.type],i.literal=[...i.literal,...t.literal],i.built_in=[...i.built_in,...t.built_in],i._hints=t._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function $ae(e){const t=e.regex,n={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});const r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(o);const c={match:/\\"/},u={className:"string",begin:/'/,end:/'/},d={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],p=e.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),g={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],O={match:/(\/[a-z._-]+)+/},v=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],x=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],w=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],E=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:y,built_in:[...v,...x,"set","shopt",...w,...E]},contains:[p,e.SHEBANG(),g,f,s,a,O,o,c,u,d,n]}}function ize(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="decltype\\(auto\\)",r="[a-zA-Z_]\\w*::",a="("+i+"|"+t.optional(r)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",y={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},O=[f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],v={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:y,contains:O.concat([{begin:/\(/,end:/\)/,keywords:y,contains:O.concat(["self"]),relevance:0}]),relevance:0},x={begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:y,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:y,relevance:0},{begin:p,returnBegin:!0,contains:[e.inherit(h,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:y,disableAutodetect:!0,illegal:"=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:f,strings:u,keywords:y}}}function rze(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="decltype\\(auto\\)",r="[a-zA-Z_]\\w*::",a="(?!struct)("+i+"|"+t.optional(r)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:t.optional(r)+e.IDENT_RE,relevance:0},p=t.optional(r)+e.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],y=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],O=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],w={type:b,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:y},E={className:"function.dispatch",relevance:0,keywords:{_hint:O},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},S=[E,f,o,n,e.C_BLOCK_COMMENT_MODE,d,u],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:i,keywords:w,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,d,o,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,d,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:w,illegal:"",keywords:w,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:w},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function sze(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],i=["default","false","null","true"],r=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],a={keyword:r.concat(s),built_in:t,literal:i},o=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),c={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},u={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},d={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=e.inherit(d,{illegal:/\n/}),h={className:"subst",begin:/\{/,end:/\}/,keywords:a},p=e.inherit(h,{illegal:/\n/}),g={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,p]},b={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]},y=e.inherit(b,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},p]});h.contains=[b,g,d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,e.C_BLOCK_COMMENT_MODE],p.contains=[y,g,f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const O={variants:[u,b,g,d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},v={begin:"<",end:">",contains:[{beginKeywords:"in out"},o]},x=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",w={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:a,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:""},{begin:""}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},O,c,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},o,v,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[o,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[o,v,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+x+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:a,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,v],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,relevance:0,contains:[O,c,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},w]}}const aze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),oze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],lze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],cze=[...oze,...lze],uze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),dze=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),fze=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),hze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function pze(e){const t=e.regex,n=aze(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",s=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",o=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,i,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+dze.join("|")+")"},{begin:":(:)?("+fze.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+hze.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...o,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...o,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:uze.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...o,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+cze.join("|")+")\\b"}]}}function mze(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function gze(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"Bae(e,t,n-1))}function Oze(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",i=n+Bae("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},d={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[d,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+i+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,Mz,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Mz,u]}}const Lz="[A-Za-z$_][0-9A-Za-z$_]*",yze=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],xze=["true","false","null","undefined","NaN","Infinity"],Uae=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],zae=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Fae=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],vze=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],wze=[].concat(Fae,Uae,zae);function Vae(e){const t=e.regex,n=(U,{after:B})=>{const I="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,B)=>{const I=U[0].length+U.index,X=U.input[I];if(X==="<"||X===","){B.ignoreMatch();return}X===">"&&(n(U,{after:I})||B.ignoreMatch());let q;const D=U.input.substring(I);if(q=D.match(/^\s*=/)){B.ignoreMatch();return}if((q=D.match(/^\s+extends\s+/))&&q.index===0){B.ignoreMatch();return}}},o={$pattern:Lz,keyword:yze,literal:xze,built_in:wze,"variable.language":vze},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(x)});const w=[].concat(v,h.contains),E=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(w)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E},k={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Uae,...zae]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},C={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function M(U){return t.concat("(?!",U.join("|"),")")}const L={match:t.concat(/\b/,M([...Fae,"super","import"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},j="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,v,{match:/\$\d+/},f,T,{scope:"attr",match:i+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:j,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,C,k,Q,{match:/\$[(.]/}]}}function Xae(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},i=["true","false","null"],r={scope:"literal",beginKeywords:i.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:i},contains:[t,n,e.QUOTE_STRING_MODE,r,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Cm="[0-9](_*[0-9])*",jw=`\\.(${Cm})`,Rw="[0-9a-fA-F](_*[0-9a-fA-F])*",Sze={className:"number",variants:[{begin:`(\\b(${Cm})((${jw})|\\.)?|(${jw}))[eE][+-]?(${Cm})[fFdD]?\\b`},{begin:`\\b(${Cm})((${jw})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${jw})[fFdD]?\\b`},{begin:`\\b(${Cm})[fFdD]\\b`},{begin:`\\b0[xX]((${Rw})\\.?|(${Rw})?\\.(${Rw}))[pP][+-]?(${Cm})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Rw})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Eze(e){const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},i={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},r={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},a={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,r]}]};r.contains.push(a);const o={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},c={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(a,{className:"string"}),"self"]}]},u=Sze,d=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),f={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},h=f;return h.variants[1].contains=[f],f.variants[1].contains=[h],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,d,n,i,o,c,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin://,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[f,e.C_LINE_COMMENT_MODE,d],relevance:0},e.C_LINE_COMMENT_MODE,d,o,c,a,e.C_NUMBER_MODE]},d]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},o,c]},a,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:` +`},u]}}const kze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Tze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],_ze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],Aze=[...Tze,..._ze],Nze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),qae=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Hae=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Cze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),jze=qae.concat(Hae).sort().reverse();function Rze(e){const t=kze(e),n=jze,i="and or not only",r="[\\w-]+",s="("+r+"|@\\{"+r+"\\})",a=[],o=[],c=function(x){return{className:"string",begin:"~?"+x+".*?"+x}},u=function(x,w,E){return{className:x,begin:w,relevance:E}},d={$pattern:/[a-z-]+/,keyword:i,attribute:Nze.join(" ")},f={begin:"\\(",end:"\\)",contains:o,keywords:d,relevance:0};o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,c("'"),c('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,f,u("variable","@@?"+r,10),u("variable","@\\{"+r+"\\}"),u("built_in","~?`[^`]*?`"),{className:"attribute",begin:r+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const h=o.concat({begin:/\{/,end:/\}/,contains:a}),p={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(o)},g={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Cze.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:o}}]},b={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:d,returnEnd:!0,contains:o,relevance:0}},y={className:"variable",variants:[{begin:"@"+r+"\\s*:",relevance:15},{begin:"@"+r}],starts:{end:"[;}]",returnEnd:!0,contains:h}},O={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,p,u("keyword","all\\b"),u("variable","@\\{"+r+"\\}"),{begin:"\\b("+Aze.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,u("selector-tag",s,0),u("selector-id","#"+s),u("selector-class","\\."+s,0),u("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+qae.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Hae.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:h},{begin:"!important"},t.FUNCTION_DISPATCH]},v={begin:r+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[O]};return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,y,v,g,O,p,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:a}}function Ize(e){const t="\\[=*\\[",n="\\]=*\\]",i={begin:t,end:n,contains:["self"]},r=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[i],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:r.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:r}].concat(r)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[i],relevance:5}])}}function Yae(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%",subLanguage:"xml",relevance:0},i={begin:"^[-\\*]{3,}",end:"$"},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},o=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,o,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},d={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},f=e.inherit(u,{contains:[]}),h=e.inherit(d,{contains:[]});u.contains.push(h),d.contains.push(f);let p=[n,c];return[u,d,f,h].forEach(O=>{O.contains=O.contains.concat(p)}),p=p.concat(u,d),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:p},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:p}]}]},n,s,u,d,{className:"quote",begin:"^>\\s+",contains:p,end:"$"},r,i,c,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Pze(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,o={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},c={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:o,illegal:"/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+c.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:c,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function Mze(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],i=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},a={begin:/->\{/,end:/\}/},o={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[o]},u={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},d=[e.BACKSLASH_ESCAPE,s,c],f=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],h=(b,y,O="\\1")=>{const v=O==="\\1"?O:t.concat(O,y);return t.concat(t.concat("(?:",b,")"),y,/(?:\\.|[^\\\/])*?/,v,/(?:\\.|[^\\\/])*?/,O,i)},p=(b,y,O)=>t.concat(t.concat("(?:",b,")"),y,/(?:\\.|[^\\\/])*?/,O,i),g=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),a,{className:"string",contains:d,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},u,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:h("s|tr|y",t.either(...f,{capture:!0}))},{begin:h("s|tr|y","\\(","\\)")},{begin:h("s|tr|y","\\[","\\]")},{begin:h("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:p("(?:m|qr)?",/\//,/\//)},{begin:p("m|qr",t.either(...f,{capture:!0}),/\1/)},{begin:p("m|qr",/\(/,/\)/)},{begin:p("m|qr",/\[/,/\]/)},{begin:p("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o,u]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=g,a.contains=g,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:g}}function Lze(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,i=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),r=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=t.concat(/[A-Z]+/,n),a={scope:"variable",match:"\\$+"+i},o={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},c={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},u=e.inherit(e.APOS_STRING_MODE,{illegal:null}),d=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)}),f={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(c),"on:begin":(P,Q)=>{Q.data._beginMatch=P[1]||P[2]},"on:end":(P,Q)=>{Q.data._beginMatch!==P[1]&&Q.ignoreMatch()}},h=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p=`[ +]`,g={scope:"string",variants:[d,u,f,h]},b={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},y=["false","null","true"],O=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],v=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],w={keyword:O,literal:(P=>{const Q=[];return P.forEach(j=>{Q.push(j),j.toLowerCase()===j?Q.push(j.toUpperCase()):Q.push(j.toLowerCase())}),Q})(y),built_in:v},E=P=>P.map(Q=>Q.replace(/\|\d+$/,"")),S={variants:[{match:[/new/,t.concat(p,"+"),t.concat("(?!",E(v).join("\\b|"),"\\b)"),r],scope:{1:"keyword",4:"title.class"}}]},k=t.concat(i,"\\b(?!\\()"),T={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),k],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[r,t.concat(/::/,t.lookahead(/(?!class\b)/)),k],scope:{1:"title.class",3:"variable.constant"}},{match:[r,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[r,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},A={scope:"attr",match:t.concat(i,t.lookahead(":"),t.lookahead(/(?!::)/))},N={relevance:0,begin:/\(/,end:/\)/,keywords:w,contains:[A,a,T,e.C_BLOCK_COMMENT_MODE,g,b,S]},C={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",E(O).join("\\b|"),"|",E(v).join("\\b|"),"\\b)"),i,t.concat(p,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[N]};N.contains.push(C);const M=[A,T,e.C_BLOCK_COMMENT_MODE,g,b,S],L={begin:t.concat(/#\[\s*\\?/,t.either(r,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:y,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:y,keyword:["new","array"]},contains:["self",...M]},...M,{scope:"meta",variants:[{match:r},{match:s}]}]};return{case_insensitive:!1,keywords:w,contains:[L,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},o,{scope:"variable.language",match:/\$this\b/},a,C,T,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},S,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:w,contains:["self",L,a,T,e.C_BLOCK_COMMENT_MODE,g,b]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},g,b]}}function Dze(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function $ze(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Wae(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],o={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:o,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,d,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,d,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",p=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,g=`\\b|${i.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${p}))[eE][+-]?(${h})[jJ]?(?=${g})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${h})[jJ](?=${g})`}]},y={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:o,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},O={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:["self",c,b,f,e.HASH_COMMENT_MODE]}]};return u.contains=[f,b,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:o,illegal:/(<\/|\?)|=>/,contains:[c,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,y,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[O]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,O,f]}]}}function Qze(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Bze(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),r=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[r,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:r},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Uze(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),r=t.concat(i,/(::\w+)*/),a={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},o={className:"doctag",begin:"@[A-Za-z]+"},c={begin:"#<",end:">"},u=[e.COMMENT("#","$",{contains:[o]}),e.COMMENT("^=begin","^=end",{contains:[o],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],d={className:"subst",begin:/#\{/,end:/\}/,keywords:a},f={className:"string",contains:[e.BACKSLASH_ESCAPE,d],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,d]})]}]},h="[1-9](_?[0-9])*|0",p="[0-9](_?[0-9])*",g={className:"number",relevance:0,variants:[{begin:`\\b(${h})(\\.(${p}))?([eE][+-]?(${p})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},b={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:a}]},S=[f,{variants:[{match:[/class\s+/,r,/\s+<\s+/,r]},{match:[/\b(class|module)\s+/,r]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:a},{match:[/(include|extend)\s+/,r],scope:{2:"title.class"},keywords:a},{relevance:0,match:[r,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:i,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[f,{begin:n}],relevance:0},g,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:a},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,d],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(c,u),relevance:0}].concat(c,u);d.contains=S,b.contains=S;const N=[{begin:/^\s*=>/,starts:{end:"$",contains:S}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:a,contains:S}}];return u.unshift(c),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:a,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(N).concat(u).concat(S)}}function zze(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,r,t.lookahead(/\s*\(/))},a="([ui](8|16|32|64|128|size)|f(32|64))?",o=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],c=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],d=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:d,keyword:o,literal:c,built_in:u},illegal:""},s]}}const Fze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Vze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Xze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],qze=[...Vze,...Xze],Hze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Yze=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Gze=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Wze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Zze(e){const t=Fze(e),n=Gze,i=Yze,r="@[a-z-]+",s="and or not only",o={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+qze.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+i.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},o,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Wze.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,o,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:r,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:Hze.join(" ")},contains:[{begin:r,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},o,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function Kze(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Jze(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],a=["double precision","large object","with timezone","without timezone"],o=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=d,g=[...u,...c].filter(E=>!d.includes(E)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},O={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(E){return t.concat(/\b/,t.either(...E.map(S=>S.replace(/\s+/,"\\s+"))),/\b/)}const x={scope:"keyword",match:v(h),relevance:0};function w(E,{exceptions:S,when:k}={}){const T=k;return S=S||[],E.map(A=>A.match(/\|\d+$/)||S.includes(A)?A:T(A)?`${A}|0`:A)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:w(g,{when:E=>E.length<3}),literal:s,type:o,built_in:f},contains:[{scope:"type",match:v(a)},x,O,b,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,y]}}function Zae(e){return e?typeof e=="string"?e:e.source:null}function eO(e){return wi("(?=",e,")")}function wi(...e){return e.map(n=>Zae(n)).join("")}function eFe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function da(...e){return"("+(eFe(e).capture?"":"?:")+e.map(i=>Zae(i)).join("|")+")"}const k3=e=>wi(/\b/,e,/\w$/.test(e)?/\b/:/\B/),tFe=["Protocol","Type"].map(k3),Dz=["init","self"].map(k3),nFe=["Any","Self"],$C=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],$z=["false","nil","true"],iFe=["assignment","associativity","higherThan","left","lowerThan","none","right"],rFe=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Qz=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Kae=da(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Jae=da(Kae,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),QC=wi(Kae,Jae,"*"),eoe=da(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Fk=da(eoe,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),mc=wi(eoe,Fk,"*"),Iw=wi(/[A-Z]/,Fk,"*"),sFe=["attached","autoclosure",wi(/convention\(/,da("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",wi(/objc\(/,mc,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],aFe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function oFe(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),i=[e.C_LINE_COMMENT_MODE,n],r={match:[/\./,da(...tFe,...Dz)],className:{2:"keyword"}},s={match:wi(/\./,da(...$C)),relevance:0},a=$C.filter(oe=>typeof oe=="string").concat(["_|0"]),o=$C.filter(oe=>typeof oe!="string").concat(nFe).map(k3),c={variants:[{className:"keyword",match:da(...o,...Dz)}]},u={$pattern:da(/\b\w+/,/#\w+/),keyword:a.concat(rFe),literal:$z},d=[r,s,c],f={match:wi(/\./,da(...Qz)),relevance:0},h={className:"built_in",match:wi(/\b/,da(...Qz),/(?=\()/)},p=[f,h],g={match:/->/,relevance:0},b={className:"operator",relevance:0,variants:[{match:QC},{match:`\\.(\\.|${Jae})+`}]},y=[g,b],O="([0-9]_*)+",v="([0-9a-fA-F]_*)+",x={className:"number",relevance:0,variants:[{match:`\\b(${O})(\\.(${O}))?([eE][+-]?(${O}))?\\b`},{match:`\\b0x(${v})(\\.(${v}))?([pP][+-]?(${O}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},w=(oe="")=>({className:"subst",variants:[{match:wi(/\\/,oe,/[0\\tnr"']/)},{match:wi(/\\/,oe,/u\{[0-9a-fA-F]{1,8}\}/)}]}),E=(oe="")=>({className:"subst",match:wi(/\\/,oe,/[\t ]*(?:[\r\n]|\r\n)/)}),S=(oe="")=>({className:"subst",label:"interpol",begin:wi(/\\/,oe,/\(/),end:/\)/}),k=(oe="")=>({begin:wi(oe,/"""/),end:wi(/"""/,oe),contains:[w(oe),E(oe),S(oe)]}),T=(oe="")=>({begin:wi(oe,/"/),end:wi(/"/,oe),contains:[w(oe),S(oe)]}),A={className:"string",variants:[k(),k("#"),k("##"),k("###"),T(),T("#"),T("##"),T("###")]},N=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],C={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:N},M=oe=>{const Ne=wi(oe,/\//),Oe=wi(/\//,oe);return{begin:Ne,end:Oe,contains:[...N,{scope:"comment",begin:`#(?!.*${Oe})`,end:/$/}]}},L={scope:"regexp",variants:[M("###"),M("##"),M("#"),C]},P={match:wi(/`/,mc,/`/)},Q={className:"variable",match:/\$\d+/},j={className:"variable",match:`\\$${Fk}+`},$=[P,Q,j],U={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:aFe,contains:[...y,x,A]}]}},B={scope:"keyword",match:wi(/@/,da(...sFe),eO(da(/\(/,/\s+/)))},I={scope:"meta",match:wi(/@/,mc)},X=[U,B,I],q={match:eO(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:wi(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Fk,"+")},{className:"type",match:Iw,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:wi(/\s+&\s+/,eO(Iw)),relevance:0}]},D={begin://,keywords:u,contains:[...i,...d,...X,g,q]};q.contains.push(D);const H={match:wi(mc,/\s*:/),keywords:"_|0",relevance:0},re={begin:/\(/,end:/\)/,relevance:0,keywords:u,contains:["self",H,...i,L,...d,...p,...y,x,A,...$,...X,q]},fe={begin://,keywords:"repeat each",contains:[...i,q]},Ae={begin:da(eO(wi(mc,/\s*:/)),eO(wi(mc,/\s+/,mc,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:mc}]},J={begin:/\(/,end:/\)/,keywords:u,contains:[Ae,...i,...d,...y,x,A,...X,q,re],endsParent:!0,illegal:/["']/},ie={match:[/(func|macro)/,/\s+/,da(P.match,mc,QC)],className:{1:"keyword",3:"title.function"},contains:[fe,J,t],illegal:[/\[/,/%/]},ue={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[fe,J,t],illegal:/\[|%/},ye={match:[/operator/,/\s+/,QC],className:{1:"keyword",3:"title"}},Se={begin:[/precedencegroup/,/\s+/,Iw],className:{1:"keyword",3:"title"},contains:[q],keywords:[...iFe,...$z],end:/}/},Re={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Ee={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},me={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,mc,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:u,contains:[fe,...d,{begin:/:/,end:/\{/,keywords:u,contains:[{scope:"title.class.inherited",match:Iw},...d],relevance:0}]};for(const oe of A.variants){const Ne=oe.contains.find(Ve=>Ve.label==="interpol");Ne.keywords=u;const Oe=[...d,...p,...y,x,A,...$];Ne.contains=[...Oe,{begin:/\(/,end:/\)/,contains:["self",...Oe]}]}return{name:"Swift",keywords:u,contains:[...i,ie,ue,Re,Ee,me,ye,Se,{beginKeywords:"import",end:/$/,contains:[...i],relevance:0},L,...d,...p,...y,x,A,...$,...X,q,re]}}const Vk="[A-Za-z$_][0-9A-Za-z$_]*",toe=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],noe=["true","false","null","undefined","NaN","Infinity"],ioe=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],roe=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],soe=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],aoe=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ooe=[].concat(soe,ioe,roe);function lFe(e){const t=e.regex,n=(U,{after:B})=>{const I="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,B)=>{const I=U[0].length+U.index,X=U.input[I];if(X==="<"||X===","){B.ignoreMatch();return}X===">"&&(n(U,{after:I})||B.ignoreMatch());let q;const D=U.input.substring(I);if(q=D.match(/^\s*=/)){B.ignoreMatch();return}if((q=D.match(/^\s+extends\s+/))&&q.index===0){B.ignoreMatch();return}}},o={$pattern:Vk,keyword:toe,literal:noe,built_in:ooe,"variable.language":aoe},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(x)});const w=[].concat(v,h.contains),E=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(w)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E},k={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...ioe,...roe]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},C={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function M(U){return t.concat("(?!",U.join("|"),")")}const L={match:t.concat(/\b/,M([...soe,"super","import"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},j="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",$={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,g,b,y,v,{match:/\$\d+/},f,T,{scope:"attr",match:i+t.lookahead(":"),relevance:0},$,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:j,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,C,k,Q,{match:/\$[(.]/}]}}function loe(e){const t=e.regex,n=lFe(e),i=Vk,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[n.exports.CLASS_REFERENCE]},o={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Vk,keyword:toe.concat(c),literal:noe,built_in:ooe.concat(r),"variable.language":aoe},d={className:"meta",begin:"@"+i},f=(b,y,O)=>{const v=b.contains.findIndex(x=>x.label===y);if(v===-1)throw new Error("can not find mode to replace");b.contains.splice(v,1,O)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(b=>b.scope==="attr"),p=Object.assign({},h,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,p]),n.contains=n.contains.concat([d,s,a,p]),f(n,"shebang",e.SHEBANG()),f(n,"use_strict",o);const g=n.contains.find(b=>b.label==="func.def");return g.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function cFe(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},i={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},r=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,a=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,o=/\d{1,2}(:\d{1,2}){1,2}/,c={className:"literal",variants:[{begin:t.concat(/# */,t.either(s,r),/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,t.either(s,r),/ +/,t.either(a,o),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},d={className:"label",begin:/^\w+:/},f=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),h=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,i,c,u,d,f,h,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[h]}]}}function uFe(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),i=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],r={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},a={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},o={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},c={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:i},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,a,r,e.QUOTE_STRING_MODE,c,u,o]}}function dFe(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=e.inherit(s,{begin:/\(/,end:/\)/}),o=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin://,relevance:10,contains:[s,c,o,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin://,contains:[s,a,c,o]}]}]},e.COMMENT(//,{relevance:10}),{begin://,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(//,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function coe(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},o=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),h={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},p={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},g={begin:/\{/,end:/\}/,contains:[p],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[p],illegal:"\\n",relevance:0},y=[i,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},h,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},g,b,s,a],O=[...y];return O.pop(),O.push(o),p.contains=O,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:y}}const fFe={arduino:nze,bash:$ae,c:ize,cpp:rze,csharp:sze,css:pze,diff:mze,go:gze,graphql:bze,ini:Qae,java:Oze,javascript:Vae,json:Xae,kotlin:Eze,less:Rze,lua:Ize,makefile:Yae,markdown:Gae,objectivec:Pze,perl:Mze,php:Lze,"php-template":Dze,plaintext:$ze,python:Wae,"python-repl":Qze,r:Bze,ruby:Uze,rust:zze,scss:Zze,shell:Kze,sql:Jze,swift:oFe,typescript:loe,vbnet:cFe,wasm:uFe,xml:dFe,yaml:coe};function uoe(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{const n=e[t],i=typeof n;(i==="object"||i==="function")&&!Object.isFrozen(n)&&uoe(n)}),e}let Bz=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function doe(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function lf(e,...t){const n=Object.create(null);for(const i in e)n[i]=e[i];return t.forEach(function(i){for(const r in i)n[r]=i[r]}),n}const hFe="",Uz=e=>!!e.scope,pFe=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map((i,r)=>`${i}${"_".repeat(r+1)}`)].join(" ")}return`${t}${e}`};class mFe{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=doe(t)}openNode(t){if(!Uz(t))return;const n=pFe(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Uz(t)&&(this.buffer+=hFe)}value(){return this.buffer}span(t){this.buffer+=``}}const zz=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class T3{constructor(){this.rootNode=zz(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){const n=zz({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(i=>this._walk(t,i)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{T3._collapse(n)}))}}class gFe extends T3{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){const i=t.root;n&&(i.scope=`language:${n}`),this.add(i)}toHTML(){return new mFe(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function kx(e){return e?typeof e=="string"?e:e.source:null}function foe(e){return Vp("(?=",e,")")}function bFe(e){return Vp("(?:",e,")*")}function OFe(e){return Vp("(?:",e,")?")}function Vp(...e){return e.map(n=>kx(n)).join("")}function yFe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function _3(...e){return"("+(yFe(e).capture?"":"?:")+e.map(i=>kx(i)).join("|")+")"}function hoe(e){return new RegExp(e.toString()+"|").exec("").length-1}function xFe(e,t){const n=e&&e.exec(t);return n&&n.index===0}const vFe=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A3(e,{joinWith:t}){let n=0;return e.map(i=>{n+=1;const r=n;let s=kx(i),a="";for(;s.length>0;){const o=vFe.exec(s);if(!o){a+=s;break}a+=s.substring(0,o.index),s=s.substring(o.index+o[0].length),o[0][0]==="\\"&&o[1]?a+="\\"+String(Number(o[1])+r):(a+=o[0],o[0]==="("&&n++)}return a}).map(i=>`(${i})`).join(t)}const wFe=/\b\B/,poe="[a-zA-Z]\\w*",N3="[a-zA-Z_]\\w*",moe="\\b\\d+(\\.\\d+)?",goe="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",boe="\\b(0b[01]+)",SFe="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",EFe=(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=Vp(t,/.*\b/,e.binary,/\b.*/)),lf({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,i)=>{n.index!==0&&i.ignoreMatch()}},e)},Tx={begin:"\\\\[\\s\\S]",relevance:0},kFe={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Tx]},TFe={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Tx]},_Fe={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/},pA=function(e,t,n={}){const i=lf({scope:"comment",begin:e,end:t,contains:[]},n);i.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 r=_3("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 i.contains.push({begin:Vp(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},AFe=pA("//","$"),NFe=pA("/\\*","\\*/"),CFe=pA("#","$"),jFe={scope:"number",begin:moe,relevance:0},RFe={scope:"number",begin:goe,relevance:0},IFe={scope:"number",begin:boe,relevance:0},PFe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Tx,{begin:/\[/,end:/\]/,relevance:0,contains:[Tx]}]},MFe={scope:"title",begin:poe,relevance:0},LFe={scope:"title",begin:N3,relevance:0},DFe={begin:"\\.\\s*"+N3,relevance:0},$Fe=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})};var Pw=Object.freeze({__proto__:null,APOS_STRING_MODE:kFe,BACKSLASH_ESCAPE:Tx,BINARY_NUMBER_MODE:IFe,BINARY_NUMBER_RE:boe,COMMENT:pA,C_BLOCK_COMMENT_MODE:NFe,C_LINE_COMMENT_MODE:AFe,C_NUMBER_MODE:RFe,C_NUMBER_RE:goe,END_SAME_AS_BEGIN:$Fe,HASH_COMMENT_MODE:CFe,IDENT_RE:poe,MATCH_NOTHING_RE:wFe,METHOD_GUARD:DFe,NUMBER_MODE:jFe,NUMBER_RE:moe,PHRASAL_WORDS_MODE:_Fe,QUOTE_STRING_MODE:TFe,REGEXP_MODE:PFe,RE_STARTERS_RE:SFe,SHEBANG:EFe,TITLE_MODE:MFe,UNDERSCORE_IDENT_RE:N3,UNDERSCORE_TITLE_MODE:LFe});function QFe(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function BFe(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function UFe(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=QFe,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function zFe(e,t){Array.isArray(e.illegal)&&(e.illegal=_3(...e.illegal))}function FFe(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function VFe(e,t){e.relevance===void 0&&(e.relevance=1)}const XFe=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach(i=>{delete e[i]}),e.keywords=n.keywords,e.begin=Vp(n.beforeMatch,foe(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},qFe=["of","and","for","in","not","or","if","then","parent","list","value"],HFe="keyword";function Ooe(e,t,n=HFe){const i=Object.create(null);return typeof e=="string"?r(n,e.split(" ")):Array.isArray(e)?r(n,e):Object.keys(e).forEach(function(s){Object.assign(i,Ooe(e[s],t,s))}),i;function r(s,a){t&&(a=a.map(o=>o.toLowerCase())),a.forEach(function(o){const c=o.split("|");i[c[0]]=[s,YFe(c[0],c[1])]})}}function YFe(e,t){return t?Number(t):GFe(e)?0:1}function GFe(e){return qFe.includes(e.toLowerCase())}const Fz={},ap=e=>{console.error(e)},Vz=(e,...t)=>{console.log(`WARN: ${e}`,...t)},um=(e,t)=>{Fz[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Fz[`${e}/${t}`]=!0)},Xk=new Error;function yoe(e,t,{key:n}){let i=0;const r=e[n],s={},a={};for(let o=1;o<=t.length;o++)a[o+i]=r[o],s[o+i]=!0,i+=hoe(t[o-1]);e[n]=a,e[n]._emit=s,e[n]._multi=!0}function WFe(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ap("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Xk;if(typeof e.beginScope!="object"||e.beginScope===null)throw ap("beginScope must be object"),Xk;yoe(e,e.begin,{key:"beginScope"}),e.begin=A3(e.begin,{joinWith:""})}}function ZFe(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ap("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Xk;if(typeof e.endScope!="object"||e.endScope===null)throw ap("endScope must be object"),Xk;yoe(e,e.end,{key:"endScope"}),e.end=A3(e.end,{joinWith:""})}}function KFe(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function JFe(e){KFe(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),WFe(e),ZFe(e)}function eVe(e){function t(a,o){return new RegExp(kx(a),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(o?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(o,c){c.position=this.position++,this.matchIndexes[this.matchAt]=c,this.regexes.push([c,o]),this.matchAt+=hoe(o)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const o=this.regexes.map(c=>c[1]);this.matcherRe=t(A3(o,{joinWith:"|"}),!0),this.lastIndex=0}exec(o){this.matcherRe.lastIndex=this.lastIndex;const c=this.matcherRe.exec(o);if(!c)return null;const u=c.findIndex((f,h)=>h>0&&f!==void 0),d=this.matchIndexes[u];return c.splice(0,u),Object.assign(c,d)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(o){if(this.multiRegexes[o])return this.multiRegexes[o];const c=new n;return this.rules.slice(o).forEach(([u,d])=>c.addRule(u,d)),c.compile(),this.multiRegexes[o]=c,c}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(o,c){this.rules.push([o,c]),c.type==="begin"&&this.count++}exec(o){const c=this.getMatcher(this.regexIndex);c.lastIndex=this.lastIndex;let u=c.exec(o);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const d=this.getMatcher(0);d.lastIndex=this.lastIndex+1,u=d.exec(o)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function r(a){const o=new i;return a.contains.forEach(c=>o.addRule(c.begin,{rule:c,type:"begin"})),a.terminatorEnd&&o.addRule(a.terminatorEnd,{type:"end"}),a.illegal&&o.addRule(a.illegal,{type:"illegal"}),o}function s(a,o){const c=a;if(a.isCompiled)return c;[BFe,FFe,JFe,XFe].forEach(d=>d(a,o)),e.compilerExtensions.forEach(d=>d(a,o)),a.__beforeBegin=null,[UFe,zFe,VFe].forEach(d=>d(a,o)),a.isCompiled=!0;let u=null;return typeof a.keywords=="object"&&a.keywords.$pattern&&(a.keywords=Object.assign({},a.keywords),u=a.keywords.$pattern,delete a.keywords.$pattern),u=u||/\w+/,a.keywords&&(a.keywords=Ooe(a.keywords,e.case_insensitive)),c.keywordPatternRe=t(u,!0),o&&(a.begin||(a.begin=/\B|\b/),c.beginRe=t(c.begin),!a.end&&!a.endsWithParent&&(a.end=/\B|\b/),a.end&&(c.endRe=t(c.end)),c.terminatorEnd=kx(c.end)||"",a.endsWithParent&&o.terminatorEnd&&(c.terminatorEnd+=(a.end?"|":"")+o.terminatorEnd)),a.illegal&&(c.illegalRe=t(a.illegal)),a.contains||(a.contains=[]),a.contains=[].concat(...a.contains.map(function(d){return tVe(d==="self"?a:d)})),a.contains.forEach(function(d){s(d,c)}),a.starts&&s(a.starts,o),c.matcher=r(c),c}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=lf(e.classNameAliases||{}),s(e)}function xoe(e){return e?e.endsWithParent||xoe(e.starts):!1}function tVe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return lf(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:xoe(e)?lf(e,{starts:e.starts?lf(e.starts):null}):Object.isFrozen(e)?lf(e):e}var nVe="11.11.1";class iVe extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}}const BC=doe,Xz=lf,qz=Symbol("nomatch"),rVe=7,voe=function(e){const t=Object.create(null),n=Object.create(null),i=[];let r=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",a={disableAutodetect:!0,name:"Plain text",contains:[]};let o={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:gFe};function c(j){return o.noHighlightRe.test(j)}function u(j){let $=j.className+" ";$+=j.parentNode?j.parentNode.className:"";const U=o.languageDetectRe.exec($);if(U){const B=T(U[1]);return B||(Vz(s.replace("{}",U[1])),Vz("Falling back to no-highlight mode for this block.",j)),B?U[1]:"no-highlight"}return $.split(/\s+/).find(B=>c(B)||T(B))}function d(j,$,U){let B="",I="";typeof $=="object"?(B=j,U=$.ignoreIllegals,I=$.language):(um("10.7.0","highlight(lang, code, ...args) has been deprecated."),um("10.7.0",`Please use highlight(code, options) instead. +https://github.com/highlightjs/highlight.js/issues/2277`),I=j,B=$),U===void 0&&(U=!0);const X={code:B,language:I};P("before:highlight",X);const q=X.result?X.result:f(X.language,X.code,U);return q.code=X.code,P("after:highlight",q),q}function f(j,$,U,B){const I=Object.create(null);function X(W,K){return W.keywords[K]}function q(){if(!Oe.keywords){We.addText(De);return}let W=0;Oe.keywordPatternRe.lastIndex=0;let K=Oe.keywordPatternRe.exec(De),ae="";for(;K;){ae+=De.substring(W,K.index);const pe=me.case_insensitive?K[0].toLowerCase():K[0],z=X(Oe,pe);if(z){const[ve,Be]=z;if(We.addText(ae),ae="",I[pe]=(I[pe]||0)+1,I[pe]<=rVe&&(mt+=Be),ve.startsWith("_"))ae+=K[0];else{const Je=me.classNameAliases[ve]||ve;re(K[0],Je)}}else ae+=K[0];W=Oe.keywordPatternRe.lastIndex,K=Oe.keywordPatternRe.exec(De)}ae+=De.substring(W),We.addText(ae)}function D(){if(De==="")return;let W=null;if(typeof Oe.subLanguage=="string"){if(!t[Oe.subLanguage]){We.addText(De);return}W=f(Oe.subLanguage,De,!0,Ve[Oe.subLanguage]),Ve[Oe.subLanguage]=W._top}else W=p(De,Oe.subLanguage.length?Oe.subLanguage:null);Oe.relevance>0&&(mt+=W.relevance),We.__addSublanguage(W._emitter,W.language)}function H(){Oe.subLanguage!=null?D():q(),De=""}function re(W,K){W!==""&&(We.startScope(K),We.addText(W),We.endScope())}function fe(W,K){let ae=1;const pe=K.length-1;for(;ae<=pe;){if(!W._emit[ae]){ae++;continue}const z=me.classNameAliases[W[ae]]||W[ae],ve=K[ae];z?re(ve,z):(De=ve,q(),De=""),ae++}}function Ae(W,K){return W.scope&&typeof W.scope=="string"&&We.openNode(me.classNameAliases[W.scope]||W.scope),W.beginScope&&(W.beginScope._wrap?(re(De,me.classNameAliases[W.beginScope._wrap]||W.beginScope._wrap),De=""):W.beginScope._multi&&(fe(W.beginScope,K),De="")),Oe=Object.create(W,{parent:{value:Oe}}),Oe}function J(W,K,ae){let pe=xFe(W.endRe,ae);if(pe){if(W["on:end"]){const z=new Bz(W);W["on:end"](K,z),z.isMatchIgnored&&(pe=!1)}if(pe){for(;W.endsParent&&W.parent;)W=W.parent;return W}}if(W.endsWithParent)return J(W.parent,K,ae)}function ie(W){return Oe.matcher.regexIndex===0?(De+=W[0],1):(qe=!0,0)}function ue(W){const K=W[0],ae=W.rule,pe=new Bz(ae),z=[ae.__beforeBegin,ae["on:begin"]];for(const ve of z)if(ve&&(ve(W,pe),pe.isMatchIgnored))return ie(K);return ae.skip?De+=K:(ae.excludeBegin&&(De+=K),H(),!ae.returnBegin&&!ae.excludeBegin&&(De=K)),Ae(ae,W),ae.returnBegin?0:K.length}function ye(W){const K=W[0],ae=$.substring(W.index),pe=J(Oe,W,ae);if(!pe)return qz;const z=Oe;Oe.endScope&&Oe.endScope._wrap?(H(),re(K,Oe.endScope._wrap)):Oe.endScope&&Oe.endScope._multi?(H(),fe(Oe.endScope,W)):z.skip?De+=K:(z.returnEnd||z.excludeEnd||(De+=K),H(),z.excludeEnd&&(De=K));do Oe.scope&&We.closeNode(),!Oe.skip&&!Oe.subLanguage&&(mt+=Oe.relevance),Oe=Oe.parent;while(Oe!==pe.parent);return pe.starts&&Ae(pe.starts,W),z.returnEnd?0:K.length}function Se(){const W=[];for(let K=Oe;K!==me;K=K.parent)K.scope&&W.unshift(K.scope);W.forEach(K=>We.openNode(K))}let Re={};function Ee(W,K){const ae=K&&K[0];if(De+=W,ae==null)return H(),0;if(Re.type==="begin"&&K.type==="end"&&Re.index===K.index&&ae===""){if(De+=$.slice(K.index,K.index+1),!r){const pe=new Error(`0 width match regex (${j})`);throw pe.languageName=j,pe.badRule=Re.rule,pe}return 1}if(Re=K,K.type==="begin")return ue(K);if(K.type==="illegal"&&!U){const pe=new Error('Illegal lexeme "'+ae+'" for mode "'+(Oe.scope||"")+'"');throw pe.mode=Oe,pe}else if(K.type==="end"){const pe=ye(K);if(pe!==qz)return pe}if(K.type==="illegal"&&ae==="")return De+=` +`,1;if(Rt>1e5&&Rt>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return De+=ae,ae.length}const me=T(j);if(!me)throw ap(s.replace("{}",j)),new Error('Unknown language: "'+j+'"');const oe=eVe(me);let Ne="",Oe=B||oe;const Ve={},We=new o.__emitter(o);Se();let De="",mt=0,at=0,Rt=0,qe=!1;try{if(me.__emitTokens)me.__emitTokens($,We);else{for(Oe.matcher.considerAll();;){Rt++,qe?qe=!1:Oe.matcher.considerAll(),Oe.matcher.lastIndex=at;const W=Oe.matcher.exec($);if(!W)break;const K=$.substring(at,W.index),ae=Ee(K,W);at=W.index+ae}Ee($.substring(at))}return We.finalize(),Ne=We.toHTML(),{language:j,value:Ne,relevance:mt,illegal:!1,_emitter:We,_top:Oe}}catch(W){if(W.message&&W.message.includes("Illegal"))return{language:j,value:BC($),illegal:!0,relevance:0,_illegalBy:{message:W.message,index:at,context:$.slice(at-100,at+100),mode:W.mode,resultSoFar:Ne},_emitter:We};if(r)return{language:j,value:BC($),illegal:!1,relevance:0,errorRaised:W,_emitter:We,_top:Oe};throw W}}function h(j){const $={value:BC(j),illegal:!1,relevance:0,_top:a,_emitter:new o.__emitter(o)};return $._emitter.addText(j),$}function p(j,$){$=$||o.languages||Object.keys(t);const U=h(j),B=$.filter(T).filter(N).map(H=>f(H,j,!1));B.unshift(U);const I=B.sort((H,re)=>{if(H.relevance!==re.relevance)return re.relevance-H.relevance;if(H.language&&re.language){if(T(H.language).supersetOf===re.language)return 1;if(T(re.language).supersetOf===H.language)return-1}return 0}),[X,q]=I,D=X;return D.secondBest=q,D}function g(j,$,U){const B=$&&n[$]||U;j.classList.add("hljs"),j.classList.add(`language-${B}`)}function b(j){let $=null;const U=u(j);if(c(U))return;if(P("before:highlightElement",{el:j,language:U}),j.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",j);return}if(j.children.length>0&&(o.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(j)),o.throwUnescapedHTML))throw new iVe("One of your code blocks includes unescaped HTML.",j.innerHTML);$=j;const B=$.textContent,I=U?d(B,{language:U,ignoreIllegals:!0}):p(B);j.innerHTML=I.value,j.dataset.highlighted="yes",g(j,U,I.language),j.result={language:I.language,re:I.relevance,relevance:I.relevance},I.secondBest&&(j.secondBest={language:I.secondBest.language,relevance:I.secondBest.relevance}),P("after:highlightElement",{el:j,result:I,text:B})}function y(j){o=Xz(o,j)}const O=()=>{w(),um("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function v(){w(),um("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let x=!1;function w(){function j(){w()}if(document.readyState==="loading"){x||window.addEventListener("DOMContentLoaded",j,!1),x=!0;return}document.querySelectorAll(o.cssSelector).forEach(b)}function E(j,$){let U=null;try{U=$(e)}catch(B){if(ap("Language definition for '{}' could not be registered.".replace("{}",j)),r)ap(B);else throw B;U=a}U.name||(U.name=j),t[j]=U,U.rawDefinition=$.bind(null,e),U.aliases&&A(U.aliases,{languageName:j})}function S(j){delete t[j];for(const $ of Object.keys(n))n[$]===j&&delete n[$]}function k(){return Object.keys(t)}function T(j){return j=(j||"").toLowerCase(),t[j]||t[n[j]]}function A(j,{languageName:$}){typeof j=="string"&&(j=[j]),j.forEach(U=>{n[U.toLowerCase()]=$})}function N(j){const $=T(j);return $&&!$.disableAutodetect}function C(j){j["before:highlightBlock"]&&!j["before:highlightElement"]&&(j["before:highlightElement"]=$=>{j["before:highlightBlock"](Object.assign({block:$.el},$))}),j["after:highlightBlock"]&&!j["after:highlightElement"]&&(j["after:highlightElement"]=$=>{j["after:highlightBlock"](Object.assign({block:$.el},$))})}function M(j){C(j),i.push(j)}function L(j){const $=i.indexOf(j);$!==-1&&i.splice($,1)}function P(j,$){const U=j;i.forEach(function(B){B[U]&&B[U]($)})}function Q(j){return um("10.7.0","highlightBlock will be removed entirely in v12.0"),um("10.7.0","Please use highlightElement now."),b(j)}Object.assign(e,{highlight:d,highlightAuto:p,highlightAll:w,highlightElement:b,highlightBlock:Q,configure:y,initHighlighting:O,initHighlightingOnLoad:v,registerLanguage:E,unregisterLanguage:S,listLanguages:k,getLanguage:T,registerAliases:A,autoDetection:N,inherit:Xz,addPlugin:M,removePlugin:L}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString=nVe,e.regex={concat:Vp,lookahead:foe,either:_3,optional:OFe,anyNumberOfTimes:bFe};for(const j in Pw)typeof Pw[j]=="object"&&uoe(Pw[j]);return Object.assign(e,Pw),e},p0=voe({});p0.newInstance=()=>voe({});var sVe=p0;p0.HighlightJS=p0;p0.default=p0;const Fa=N0(sVe),Hz={},aVe="hljs-";function oVe(e){const t=Fa.newInstance();return e&&s(e),{highlight:n,highlightAuto:i,listLanguages:r,register:s,registerAlias:a,registered:o};function n(c,u,d){const f=d||Hz,h=typeof f.prefix=="string"?f.prefix:aVe;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:lVe,classPrefix:h});const p=t.highlight(u,{ignoreIllegals:!0,language:c});if(p.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:p.errorRaised});const g=p._emitter.root,b=g.data;return b.language=p.language,b.relevance=p.relevance,g}function i(c,u){const f=(u||Hz).subset||r();let h=-1,p=0,g;for(;++hp&&(p=y.data.relevance,g=y)}return g||{type:"root",children:[],data:{language:void 0,relevance:p}}}function r(){return t.listLanguages()}function s(c,u){if(typeof c=="string")t.registerLanguage(c,u);else{let d;for(d in c)Object.hasOwn(c,d)&&t.registerLanguage(d,c[d])}}function a(c,u){if(typeof c=="string")t.registerAliases(typeof u=="string"?u:[...u],{languageName:c});else{let d;for(d in c)if(Object.hasOwn(c,d)){const f=c[d];t.registerAliases(typeof f=="string"?f:[...f],{languageName:d})}}}function o(c){return!!t.getLanguage(c)}}class lVe{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],r=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:r}):i.children.push(...r)}openNode(t){const n=this,i=t.split(".").map(function(a,o){return o?a+"_".repeat(o):n.options.classPrefix+a}),r=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:i},children:[]};r.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const cVe={};function Yz(e){const t=e||cVe,n=t.aliases,i=t.detect||!1,r=t.languages||fFe,s=t.plainText,a=t.prefix,o=t.subset;let c="hljs";const u=oVe(r);if(n&&u.registerAlias(n),a){const d=a.indexOf("-");c=d===-1?a:a.slice(0,d)}return function(d,f){B1(d,"element",function(h,p,g){if(h.tagName!=="code"||!g||g.type!=="element"||g.tagName!=="pre")return;const b=uVe(h);if(b===!1||!b&&!i||b&&s&&s.includes(b))return;Array.isArray(h.properties.className)||(h.properties.className=[]),h.properties.className.includes(c)||h.properties.className.unshift(c);const y=H7e(h,{whitespace:"pre"});let O;try{O=b?u.highlight(b,y,{prefix:a}):u.highlightAuto(y,{prefix:a,subset:o})}catch(v){const x=v;if(b&&/Unknown language/.test(x.message)){f.message("Cannot highlight as `"+b+"`, it’s not registered",{ancestors:[g,h],cause:x,place:h.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw x}!b&&O.data&&O.data.language&&h.properties.className.push("language-"+O.data.language),O.children.length>0&&(h.children=O.children)})}}function uVe(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n-1&&s<=t.length){let a=0;for(;;){let o=n[a];if(o===void 0){const c=Zz(t,n[a-1]);o=c===-1?t.length+1:c+1,n[a]=o}if(o>s)return{line:a+1,column:s-(a>0?n[a-1]:0)+1,offset:s};a++}}}function r(s){if(s&&typeof s.line=="number"&&typeof s.column=="number"&&!Number.isNaN(s.line)&&!Number.isNaN(s.column)){for(;n.length1?n[s.line-2]:0)+s.column-1;if(a=55296&&e<=57343}function LVe(e){return e>=56320&&e<=57343}function DVe(e,t){return(e-55296)*1024+9216+t}function _oe(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function Aoe(e){return e>=64976&&e<=65007||MVe.has(e)}var $e;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})($e||($e={}));const $Ve=65536;class QVe{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=$Ve,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:i,col:r,offset:s}=this,a=r+n,o=s+n;return{code:t,startLine:i,endLine:i,startCol:a,endCol:a,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if(LVe(n))return this.pos++,this._addGap(),DVe(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Z.EOF;return this._err($e.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let i=0;i=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Z.EOF;const i=this.html.charCodeAt(n);return i===Z.CARRIAGE_RETURN?Z.LINE_FEED:i}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Z.EOF;let t=this.html.charCodeAt(this.pos);return t===Z.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Z.LINE_FEED):t===Z.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Toe(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===Z.LINE_FEED||t===Z.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){_oe(t)?this._err($e.controlCharacterInInputStream):Aoe(t)&&this._err($e.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const BVe=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),UVe=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function zVe(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=UVe.get(e))!==null&&t!==void 0?t:e}var ms;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(ms||(ms={}));const FVe=32;var cf;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(cf||(cf={}));function OM(e){return e>=ms.ZERO&&e<=ms.NINE}function VVe(e){return e>=ms.UPPER_A&&e<=ms.UPPER_F||e>=ms.LOWER_A&&e<=ms.LOWER_F}function XVe(e){return e>=ms.UPPER_A&&e<=ms.UPPER_Z||e>=ms.LOWER_A&&e<=ms.LOWER_Z||OM(e)}function qVe(e){return e===ms.EQUALS||XVe(e)}var cs;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(cs||(cs={}));var Nu;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Nu||(Nu={}));class HVe{constructor(t,n,i){this.decodeTree=t,this.emitCodePoint=n,this.errors=i,this.state=cs.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Nu.Strict}startEntity(t){this.decodeMode=t,this.state=cs.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case cs.EntityStart:return t.charCodeAt(n)===ms.NUM?(this.state=cs.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=cs.NamedEntity,this.stateNamedEntity(t,n));case cs.NumericStart:return this.stateNumericStart(t,n);case cs.NumericDecimal:return this.stateNumericDecimal(t,n);case cs.NumericHex:return this.stateNumericHex(t,n);case cs.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|FVe)===ms.LOWER_X?(this.state=cs.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=cs.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,i,r){if(n!==i){const s=i-n;this.result=this.result*Math.pow(r,s)+Number.parseInt(t.substr(n,s),r),this.consumed+=s}}stateNumericHex(t,n){const i=n;for(;n>14;for(;n>14,s!==0){if(a===ms.SEMI)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);this.decodeMode!==Nu.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:i}=this,r=(i[n]&cf.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,r,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,i){const{decodeTree:r}=this;return this.emitCodePoint(n===1?r[t]&~cf.VALUE_LENGTH:r[t+1],i),n===3&&this.emitCodePoint(r[t+2],i),i}end(){var t;switch(this.state){case cs.NamedEntity:return this.result!==0&&(this.decodeMode!==Nu.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case cs.NumericDecimal:return this.emitNumericEntity(0,2);case cs.NumericHex:return this.emitNumericEntity(0,3);case cs.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case cs.EntityStart:return 0}}}function YVe(e,t,n,i){const r=(t&cf.BRANCH_LENGTH)>>7,s=t&cf.JUMP_TABLE;if(r===0)return s!==0&&i===s?n:-1;if(s){const c=i-s;return c<0||c>=r?-1:e[n+c]-1}let a=n,o=a+r-1;for(;a<=o;){const c=a+o>>>1,u=e[c];if(ui)o=c-1;else return e[c+r]}return-1}var Ye;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Ye||(Ye={}));var op;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(op||(op={}));var Uo;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Uo||(Uo={}));var ke;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(ke||(ke={}));var _;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(_||(_={}));const GVe=new Map([[ke.A,_.A],[ke.ADDRESS,_.ADDRESS],[ke.ANNOTATION_XML,_.ANNOTATION_XML],[ke.APPLET,_.APPLET],[ke.AREA,_.AREA],[ke.ARTICLE,_.ARTICLE],[ke.ASIDE,_.ASIDE],[ke.B,_.B],[ke.BASE,_.BASE],[ke.BASEFONT,_.BASEFONT],[ke.BGSOUND,_.BGSOUND],[ke.BIG,_.BIG],[ke.BLOCKQUOTE,_.BLOCKQUOTE],[ke.BODY,_.BODY],[ke.BR,_.BR],[ke.BUTTON,_.BUTTON],[ke.CAPTION,_.CAPTION],[ke.CENTER,_.CENTER],[ke.CODE,_.CODE],[ke.COL,_.COL],[ke.COLGROUP,_.COLGROUP],[ke.DD,_.DD],[ke.DESC,_.DESC],[ke.DETAILS,_.DETAILS],[ke.DIALOG,_.DIALOG],[ke.DIR,_.DIR],[ke.DIV,_.DIV],[ke.DL,_.DL],[ke.DT,_.DT],[ke.EM,_.EM],[ke.EMBED,_.EMBED],[ke.FIELDSET,_.FIELDSET],[ke.FIGCAPTION,_.FIGCAPTION],[ke.FIGURE,_.FIGURE],[ke.FONT,_.FONT],[ke.FOOTER,_.FOOTER],[ke.FOREIGN_OBJECT,_.FOREIGN_OBJECT],[ke.FORM,_.FORM],[ke.FRAME,_.FRAME],[ke.FRAMESET,_.FRAMESET],[ke.H1,_.H1],[ke.H2,_.H2],[ke.H3,_.H3],[ke.H4,_.H4],[ke.H5,_.H5],[ke.H6,_.H6],[ke.HEAD,_.HEAD],[ke.HEADER,_.HEADER],[ke.HGROUP,_.HGROUP],[ke.HR,_.HR],[ke.HTML,_.HTML],[ke.I,_.I],[ke.IMG,_.IMG],[ke.IMAGE,_.IMAGE],[ke.INPUT,_.INPUT],[ke.IFRAME,_.IFRAME],[ke.KEYGEN,_.KEYGEN],[ke.LABEL,_.LABEL],[ke.LI,_.LI],[ke.LINK,_.LINK],[ke.LISTING,_.LISTING],[ke.MAIN,_.MAIN],[ke.MALIGNMARK,_.MALIGNMARK],[ke.MARQUEE,_.MARQUEE],[ke.MATH,_.MATH],[ke.MENU,_.MENU],[ke.META,_.META],[ke.MGLYPH,_.MGLYPH],[ke.MI,_.MI],[ke.MO,_.MO],[ke.MN,_.MN],[ke.MS,_.MS],[ke.MTEXT,_.MTEXT],[ke.NAV,_.NAV],[ke.NOBR,_.NOBR],[ke.NOFRAMES,_.NOFRAMES],[ke.NOEMBED,_.NOEMBED],[ke.NOSCRIPT,_.NOSCRIPT],[ke.OBJECT,_.OBJECT],[ke.OL,_.OL],[ke.OPTGROUP,_.OPTGROUP],[ke.OPTION,_.OPTION],[ke.P,_.P],[ke.PARAM,_.PARAM],[ke.PLAINTEXT,_.PLAINTEXT],[ke.PRE,_.PRE],[ke.RB,_.RB],[ke.RP,_.RP],[ke.RT,_.RT],[ke.RTC,_.RTC],[ke.RUBY,_.RUBY],[ke.S,_.S],[ke.SCRIPT,_.SCRIPT],[ke.SEARCH,_.SEARCH],[ke.SECTION,_.SECTION],[ke.SELECT,_.SELECT],[ke.SOURCE,_.SOURCE],[ke.SMALL,_.SMALL],[ke.SPAN,_.SPAN],[ke.STRIKE,_.STRIKE],[ke.STRONG,_.STRONG],[ke.STYLE,_.STYLE],[ke.SUB,_.SUB],[ke.SUMMARY,_.SUMMARY],[ke.SUP,_.SUP],[ke.TABLE,_.TABLE],[ke.TBODY,_.TBODY],[ke.TEMPLATE,_.TEMPLATE],[ke.TEXTAREA,_.TEXTAREA],[ke.TFOOT,_.TFOOT],[ke.TD,_.TD],[ke.TH,_.TH],[ke.THEAD,_.THEAD],[ke.TITLE,_.TITLE],[ke.TR,_.TR],[ke.TRACK,_.TRACK],[ke.TT,_.TT],[ke.U,_.U],[ke.UL,_.UL],[ke.SVG,_.SVG],[ke.VAR,_.VAR],[ke.WBR,_.WBR],[ke.XMP,_.XMP]]);function rb(e){var t;return(t=GVe.get(e))!==null&&t!==void 0?t:_.UNKNOWN}const nt=_,WVe={[Ye.HTML]:new Set([nt.ADDRESS,nt.APPLET,nt.AREA,nt.ARTICLE,nt.ASIDE,nt.BASE,nt.BASEFONT,nt.BGSOUND,nt.BLOCKQUOTE,nt.BODY,nt.BR,nt.BUTTON,nt.CAPTION,nt.CENTER,nt.COL,nt.COLGROUP,nt.DD,nt.DETAILS,nt.DIR,nt.DIV,nt.DL,nt.DT,nt.EMBED,nt.FIELDSET,nt.FIGCAPTION,nt.FIGURE,nt.FOOTER,nt.FORM,nt.FRAME,nt.FRAMESET,nt.H1,nt.H2,nt.H3,nt.H4,nt.H5,nt.H6,nt.HEAD,nt.HEADER,nt.HGROUP,nt.HR,nt.HTML,nt.IFRAME,nt.IMG,nt.INPUT,nt.LI,nt.LINK,nt.LISTING,nt.MAIN,nt.MARQUEE,nt.MENU,nt.META,nt.NAV,nt.NOEMBED,nt.NOFRAMES,nt.NOSCRIPT,nt.OBJECT,nt.OL,nt.P,nt.PARAM,nt.PLAINTEXT,nt.PRE,nt.SCRIPT,nt.SECTION,nt.SELECT,nt.SOURCE,nt.STYLE,nt.SUMMARY,nt.TABLE,nt.TBODY,nt.TD,nt.TEMPLATE,nt.TEXTAREA,nt.TFOOT,nt.TH,nt.THEAD,nt.TITLE,nt.TR,nt.TRACK,nt.UL,nt.WBR,nt.XMP]),[Ye.MATHML]:new Set([nt.MI,nt.MO,nt.MN,nt.MS,nt.MTEXT,nt.ANNOTATION_XML]),[Ye.SVG]:new Set([nt.TITLE,nt.FOREIGN_OBJECT,nt.DESC]),[Ye.XLINK]:new Set,[Ye.XML]:new Set,[Ye.XMLNS]:new Set},yM=new Set([nt.H1,nt.H2,nt.H3,nt.H4,nt.H5,nt.H6]);ke.STYLE,ke.SCRIPT,ke.XMP,ke.IFRAME,ke.NOEMBED,ke.NOFRAMES,ke.PLAINTEXT;var ne;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(ne||(ne={}));const jr={DATA:ne.DATA,RCDATA:ne.RCDATA,RAWTEXT:ne.RAWTEXT,SCRIPT_DATA:ne.SCRIPT_DATA,PLAINTEXT:ne.PLAINTEXT,CDATA_SECTION:ne.CDATA_SECTION};function ZVe(e){return e>=Z.DIGIT_0&&e<=Z.DIGIT_9}function RO(e){return e>=Z.LATIN_CAPITAL_A&&e<=Z.LATIN_CAPITAL_Z}function KVe(e){return e>=Z.LATIN_SMALL_A&&e<=Z.LATIN_SMALL_Z}function Qd(e){return KVe(e)||RO(e)}function Jz(e){return Qd(e)||ZVe(e)}function Mw(e){return e+32}function Coe(e){return e===Z.SPACE||e===Z.LINE_FEED||e===Z.TABULATION||e===Z.FORM_FEED}function eF(e){return Coe(e)||e===Z.SOLIDUS||e===Z.GREATER_THAN_SIGN}function JVe(e){return e===Z.NULL?$e.nullCharacterReference:e>1114111?$e.characterReferenceOutsideUnicodeRange:Toe(e)?$e.surrogateCharacterReference:Aoe(e)?$e.noncharacterCharacterReference:_oe(e)||e===Z.CARRIAGE_RETURN?$e.controlCharacterReference:null}class eXe{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=ne.DATA,this.returnState=ne.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new QVe(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new HVe(BVe,(i,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(i)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err($e.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:i=>{this._err($e.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+i)},validateNumericCharacterReference:i=>{const r=JVe(i);r&&this._err(r,1)}}:void 0)}_err(t,n=0){var i,r;(r=(i=this.handler).onParseError)===null||r===void 0||r.call(i,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,n,i){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||i==null||i()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n0&&this._err($e.endTagWithAttributes),t.selfClosing&&this._err($e.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case En.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case En.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case En.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:En.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=Coe(t)?En.WHITESPACE_CHARACTER:t===Z.NULL?En.NULL_CHARACTER:En.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(En.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=ne.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nu.Attribute:Nu.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===ne.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ne.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ne.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case ne.DATA:{this._stateData(t);break}case ne.RCDATA:{this._stateRcdata(t);break}case ne.RAWTEXT:{this._stateRawtext(t);break}case ne.SCRIPT_DATA:{this._stateScriptData(t);break}case ne.PLAINTEXT:{this._statePlaintext(t);break}case ne.TAG_OPEN:{this._stateTagOpen(t);break}case ne.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case ne.TAG_NAME:{this._stateTagName(t);break}case ne.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case ne.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case ne.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case ne.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case ne.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case ne.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case ne.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case ne.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case ne.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case ne.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case ne.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case ne.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case ne.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case ne.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case ne.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case ne.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case ne.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case ne.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case ne.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case ne.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case ne.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case ne.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case ne.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case ne.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case ne.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case ne.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case ne.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case ne.BOGUS_COMMENT:{this._stateBogusComment(t);break}case ne.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case ne.COMMENT_START:{this._stateCommentStart(t);break}case ne.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case ne.COMMENT:{this._stateComment(t);break}case ne.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case ne.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case ne.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case ne.COMMENT_END:{this._stateCommentEnd(t);break}case ne.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case ne.DOCTYPE:{this._stateDoctype(t);break}case ne.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case ne.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case ne.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case ne.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case ne.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case ne.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case ne.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case ne.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case ne.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case ne.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case ne.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case ne.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case ne.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case ne.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case ne.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case ne.CDATA_SECTION:{this._stateCdataSection(t);break}case ne.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case ne.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case ne.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case ne.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.TAG_OPEN;break}case Z.AMPERSAND:{this._startCharacterReference();break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitCodePoint(t);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case Z.AMPERSAND:{this._startCharacterReference();break}case Z.LESS_THAN_SIGN:{this.state=ne.RCDATA_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.RAWTEXT_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case Z.LESS_THAN_SIGN:{this.state=ne.SCRIPT_DATA_LESS_THAN_SIGN;break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case Z.NULL:{this._err($e.unexpectedNullCharacter),this._emitChars(rr);break}case Z.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(Qd(t))this._createStartTagToken(),this.state=ne.TAG_NAME,this._stateTagName(t);else switch(t){case Z.EXCLAMATION_MARK:{this.state=ne.MARKUP_DECLARATION_OPEN;break}case Z.SOLIDUS:{this.state=ne.END_TAG_OPEN;break}case Z.QUESTION_MARK:{this._err($e.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ne.BOGUS_COMMENT,this._stateBogusComment(t);break}case Z.EOF:{this._err($e.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err($e.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ne.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(Qd(t))this._createEndTagToken(),this.state=ne.TAG_NAME,this._stateTagName(t);else switch(t){case Z.GREATER_THAN_SIGN:{this._err($e.missingEndTagName),this.state=ne.DATA;break}case Z.EOF:{this._err($e.eofBeforeTagName),this._emitChars("");break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this.state=ne.SCRIPT_DATA_ESCAPED,this._emitChars(rr);break}case Z.EOF:{this._err($e.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ne.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===Z.SOLIDUS?this.state=ne.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Qd(t)?(this._emitChars("<"),this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=ne.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){Qd(t)?(this.state=ne.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("");break}case Z.NULL:{this._err($e.unexpectedNullCharacter),this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(rr);break}case Z.EOF:{this._err($e.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===Z.SOLIDUS?(this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ne.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Aa.SCRIPT,!1)&&eF(this.preprocessor.peek(Aa.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const i=this._indexOf(t);this.items[i]=n,i===this.stackTop&&(this.current=n)}insertAfter(t,n,i){const r=this._indexOf(t)+1;this.items.splice(r,0,n),this.tagIDs.splice(r,0,i),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==Ye.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop=0;i--)if(t.has(this.tagIDs[i])&&this.treeAdapter.getNamespaceURI(this.items[i])===n)return i;return-1}clearBackTo(t,n){const i=this._indexOfTagNames(t,n);this.shortenToLength(i+1)}clearBackToTableContext(){this.clearBackTo(sXe,Ye.HTML)}clearBackToTableBodyContext(){this.clearBackTo(rXe,Ye.HTML)}clearBackToTableRowContext(){this.clearBackTo(iXe,Ye.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===_.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===_.HTML}hasInDynamicScope(t,n){for(let i=this.stackTop;i>=0;i--){const r=this.tagIDs[i];switch(this.treeAdapter.getNamespaceURI(this.items[i])){case Ye.HTML:{if(r===t)return!0;if(n.has(r))return!1;break}case Ye.SVG:{if(iF.has(r))return!1;break}case Ye.MATHML:{if(nF.has(r))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,qk)}hasInListItemScope(t){return this.hasInDynamicScope(t,tXe)}hasInButtonScope(t){return this.hasInDynamicScope(t,nXe)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case Ye.HTML:{if(yM.has(n))return!0;if(qk.has(n))return!1;break}case Ye.SVG:{if(iF.has(n))return!1;break}case Ye.MATHML:{if(nF.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Ye.HTML)switch(this.tagIDs[n]){case t:return!0;case _.TABLE:case _.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ye.HTML)switch(this.tagIDs[t]){case _.TBODY:case _.THEAD:case _.TFOOT:return!0;case _.TABLE:case _.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Ye.HTML)switch(this.tagIDs[n]){case t:return!0;case _.OPTION:case _.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&joe.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&tF.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&tF.has(this.currentTagId);)this.pop()}}const UC=3;var yc;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(yc||(yc={}));const rF={type:yc.Marker};class lXe{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const i=[],r=n.length,s=this.treeAdapter.getTagName(t),a=this.treeAdapter.getNamespaceURI(t);for(let o=0;o[a.name,a.value]));let s=0;for(let a=0;ar.get(c.name)===c.value)&&(s+=1,s>=UC&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(rF)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:yc.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const i=this.entries.indexOf(this.bookmark);this.entries.splice(i,0,{type:yc.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(rF);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(i=>i.type===yc.Marker||this.treeAdapter.getTagName(i.element)===t);return n&&n.type===yc.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===yc.Element&&n.element===t)}}const Bd={createDocument(){return{nodeName:"#document",mode:Uo.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const i=e.childNodes.indexOf(n);e.childNodes.splice(i,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,i){const r=e.childNodes.find(s=>s.nodeName==="#documentType");if(r)r.name=t,r.publicId=n,r.systemId=i;else{const s={nodeName:"#documentType",name:t,publicId:n,systemId:i,parentNode:null};Bd.appendChild(e,s)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(Bd.isTextNode(n)){n.value+=t;return}}Bd.appendChild(e,Bd.createTextNode(t))},insertTextBefore(e,t,n){const i=e.childNodes[e.childNodes.indexOf(n)-1];i&&Bd.isTextNode(i)?i.value+=t:Bd.insertBefore(e,Bd.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(i=>i.name));for(let i=0;ie.startsWith(n))}function pXe(e){return e.name===Roe&&e.publicId===null&&(e.systemId===null||e.systemId===cXe)}function mXe(e){if(e.name!==Roe)return Uo.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===uXe)return Uo.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),fXe.has(n))return Uo.QUIRKS;let i=t===null?dXe:Ioe;if(sF(n,i))return Uo.QUIRKS;if(i=t===null?Poe:hXe,sF(n,i))return Uo.LIMITED_QUIRKS}return Uo.NO_QUIRKS}const aF={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},gXe="definitionurl",bXe="definitionURL",OXe=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),yXe=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Ye.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Ye.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Ye.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Ye.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Ye.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Ye.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Ye.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Ye.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Ye.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Ye.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Ye.XMLNS}]]),xXe=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),vXe=new Set([_.B,_.BIG,_.BLOCKQUOTE,_.BODY,_.BR,_.CENTER,_.CODE,_.DD,_.DIV,_.DL,_.DT,_.EM,_.EMBED,_.H1,_.H2,_.H3,_.H4,_.H5,_.H6,_.HEAD,_.HR,_.I,_.IMG,_.LI,_.LISTING,_.MENU,_.META,_.NOBR,_.OL,_.P,_.PRE,_.RUBY,_.S,_.SMALL,_.SPAN,_.STRONG,_.STRIKE,_.SUB,_.SUP,_.TABLE,_.TT,_.U,_.UL,_.VAR]);function wXe(e){const t=e.tagID;return t===_.FONT&&e.attrs.some(({name:i})=>i===op.COLOR||i===op.SIZE||i===op.FACE)||vXe.has(t)}function Moe(e){for(let t=0;t0&&this._setContextModes(t,n)}onItemPop(t,n){var i,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(r=(i=this.treeAdapter).onItemPop)===null||r===void 0||r.call(i,t,this.openElements.current),n){let s,a;this.openElements.stackTop===0&&this.fragmentContext?(s=this.fragmentContext,a=this.fragmentContextID):{current:s,currentTagId:a}=this.openElements,this._setContextModes(s,a)}}_setContextModes(t,n){const i=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===Ye.HTML;this.currentNotInHTML=!i,this.tokenizer.inForeignNode=!i&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,Ye.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=ce.TEXT}switchToPlaintextParsing(){this.insertionMode=ce.TEXT,this.originalInsertionMode=ce.IN_BODY,this.tokenizer.state=jr.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===ke.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Ye.HTML))switch(this.fragmentContextID){case _.TITLE:case _.TEXTAREA:{this.tokenizer.state=jr.RCDATA;break}case _.STYLE:case _.XMP:case _.IFRAME:case _.NOEMBED:case _.NOFRAMES:case _.NOSCRIPT:{this.tokenizer.state=jr.RAWTEXT;break}case _.SCRIPT:{this.tokenizer.state=jr.SCRIPT_DATA;break}case _.PLAINTEXT:{this.tokenizer.state=jr.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",i=t.publicId||"",r=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,i,r),t.location){const a=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));a&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const i=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,i)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const i=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(i??this.document,t)}}_appendElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location)}_insertElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location),this.openElements.push(i,t.tagID)}_insertFakeElement(t,n){const i=this.treeAdapter.createElement(t,Ye.HTML,[]);this._attachElementToTree(i,null),this.openElements.push(i,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,Ye.HTML,t.attrs),i=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,i),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(ke.HTML,Ye.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,_.HTML)}_appendCommentNode(t,n){const i=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,i),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,t.location)}_insertCharacters(t){let n,i;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:i}=this._findFosterParentingLocation(),i?this.treeAdapter.insertTextBefore(n,t.chars,i):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const r=this.treeAdapter.getChildNodes(n),s=i?r.lastIndexOf(i):r.length,a=r[s-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:c,endCol:u,endOffset:d}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:c,endCol:u,endOffset:d})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_adoptNodes(t,n){for(let i=this.treeAdapter.getFirstChild(t);i;i=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(i),this.treeAdapter.appendChild(n,i)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const i=n.location,r=this.treeAdapter.getTagName(t),s=n.type===En.END_TAG&&r===n.tagName?{endTag:{...i},endLine:i.endLine,endCol:i.endCol,endOffset:i.endOffset}:{endLine:i.startLine,endCol:i.startCol,endOffset:i.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,s)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,i;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,i=this.fragmentContextID):{current:n,currentTagId:i}=this.openElements,t.tagID===_.SVG&&this.treeAdapter.getTagName(n)===ke.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===Ye.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===_.MGLYPH||t.tagID===_.MALIGNMARK)&&i!==void 0&&!this._isIntegrationPoint(i,n,Ye.HTML)}_processToken(t){switch(t.type){case En.CHARACTER:{this.onCharacter(t);break}case En.NULL_CHARACTER:{this.onNullCharacter(t);break}case En.COMMENT:{this.onComment(t);break}case En.DOCTYPE:{this.onDoctype(t);break}case En.START_TAG:{this._processStartTag(t);break}case En.END_TAG:{this.onEndTag(t);break}case En.EOF:{this.onEof(t);break}case En.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,i){const r=this.treeAdapter.getNamespaceURI(n),s=this.treeAdapter.getAttrList(n);return TXe(t,r,s,i)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(r=>r.type===yc.Marker||this.openElements.contains(r.element)),i=n===-1?t-1:n-1;for(let r=i;r>=0;r--){const s=this.activeFormattingElements.entries[r];this._insertElement(s.token,this.treeAdapter.getNamespaceURI(s.element)),s.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=ce.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(_.P),this.openElements.popUntilTagNamePopped(_.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case _.TR:{this.insertionMode=ce.IN_ROW;return}case _.TBODY:case _.THEAD:case _.TFOOT:{this.insertionMode=ce.IN_TABLE_BODY;return}case _.CAPTION:{this.insertionMode=ce.IN_CAPTION;return}case _.COLGROUP:{this.insertionMode=ce.IN_COLUMN_GROUP;return}case _.TABLE:{this.insertionMode=ce.IN_TABLE;return}case _.BODY:{this.insertionMode=ce.IN_BODY;return}case _.FRAMESET:{this.insertionMode=ce.IN_FRAMESET;return}case _.SELECT:{this._resetInsertionModeForSelect(t);return}case _.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case _.HTML:{this.insertionMode=this.headElement?ce.AFTER_HEAD:ce.BEFORE_HEAD;return}case _.TD:case _.TH:{if(t>0){this.insertionMode=ce.IN_CELL;return}break}case _.HEAD:{if(t>0){this.insertionMode=ce.IN_HEAD;return}break}}this.insertionMode=ce.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const i=this.openElements.tagIDs[n];if(i===_.TEMPLATE)break;if(i===_.TABLE){this.insertionMode=ce.IN_SELECT_IN_TABLE;return}}this.insertionMode=ce.IN_SELECT}_isElementCausesFosterParenting(t){return Doe.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case _.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===Ye.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case _.TABLE:{const i=this.treeAdapter.getParentNode(n);return i?{parent:i,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const i=this.treeAdapter.getNamespaceURI(t);return WVe[i].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){aHe(this,t);return}switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.IN_BODY:case ce.IN_CAPTION:case ce.IN_CELL:case ce.IN_TEMPLATE:{Qoe(this,t);break}case ce.TEXT:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_TABLE_TEXT:{Xoe(this,t);break}case ce.IN_COLUMN_GROUP:{Hk(this,t);break}case ce.AFTER_BODY:{Yk(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){sHe(this,t);return}switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.TEXT:{this._insertCharacters(t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_COLUMN_GROUP:{Hk(this,t);break}case ce.AFTER_BODY:{Yk(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){xM(this,t);return}switch(this.insertionMode){case ce.INITIAL:case ce.BEFORE_HTML:case ce.BEFORE_HEAD:case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:case ce.IN_BODY:case ce.IN_TABLE:case ce.IN_CAPTION:case ce.IN_COLUMN_GROUP:case ce.IN_TABLE_BODY:case ce.IN_ROW:case ce.IN_CELL:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:case ce.IN_TEMPLATE:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:{xM(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.AFTER_BODY:{DXe(this,t);break}case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{$Xe(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case ce.INITIAL:{QXe(this,t);break}case ce.BEFORE_HEAD:case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:{this._err(t,$e.misplacedDoctype);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,$e.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?oHe(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{BXe(this,t);break}case ce.BEFORE_HEAD:{zXe(this,t);break}case ce.IN_HEAD:{ql(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{XXe(this,t);break}case ce.AFTER_HEAD:{HXe(this,t);break}case ce.IN_BODY:{ea(this,t);break}case ce.IN_TABLE:{m0(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_CAPTION:{Fqe(this,t);break}case ce.IN_COLUMN_GROUP:{M3(this,t);break}case ce.IN_TABLE_BODY:{bA(this,t);break}case ce.IN_ROW:{OA(this,t);break}case ce.IN_CELL:{qqe(this,t);break}case ce.IN_SELECT:{Yoe(this,t);break}case ce.IN_SELECT_IN_TABLE:{Yqe(this,t);break}case ce.IN_TEMPLATE:{Wqe(this,t);break}case ce.AFTER_BODY:{Kqe(this,t);break}case ce.IN_FRAMESET:{Jqe(this,t);break}case ce.AFTER_FRAMESET:{tHe(this,t);break}case ce.AFTER_AFTER_BODY:{iHe(this,t);break}case ce.AFTER_AFTER_FRAMESET:{rHe(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?lHe(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{UXe(this,t);break}case ce.BEFORE_HEAD:{FXe(this,t);break}case ce.IN_HEAD:{VXe(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{qXe(this,t);break}case ce.AFTER_HEAD:{YXe(this,t);break}case ce.IN_BODY:{gA(this,t);break}case ce.TEXT:{Iqe(this,t);break}case ce.IN_TABLE:{_x(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_CAPTION:{Vqe(this,t);break}case ce.IN_COLUMN_GROUP:{Xqe(this,t);break}case ce.IN_TABLE_BODY:{vM(this,t);break}case ce.IN_ROW:{Hoe(this,t);break}case ce.IN_CELL:{Hqe(this,t);break}case ce.IN_SELECT:{Goe(this,t);break}case ce.IN_SELECT_IN_TABLE:{Gqe(this,t);break}case ce.IN_TEMPLATE:{Zqe(this,t);break}case ce.AFTER_BODY:{Zoe(this,t);break}case ce.IN_FRAMESET:{eHe(this,t);break}case ce.AFTER_FRAMESET:{nHe(this,t);break}case ce.AFTER_AFTER_BODY:{aE(this,t);break}}}onEof(t){switch(this.insertionMode){case ce.INITIAL:{tO(this,t);break}case ce.BEFORE_HTML:{my(this,t);break}case ce.BEFORE_HEAD:{gy(this,t);break}case ce.IN_HEAD:{by(this,t);break}case ce.IN_HEAD_NO_SCRIPT:{Oy(this,t);break}case ce.AFTER_HEAD:{yy(this,t);break}case ce.IN_BODY:case ce.IN_TABLE:case ce.IN_CAPTION:case ce.IN_COLUMN_GROUP:case ce.IN_TABLE_BODY:case ce.IN_ROW:case ce.IN_CELL:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:{Foe(this,t);break}case ce.TEXT:{Pqe(this,t);break}case ce.IN_TABLE_TEXT:{nO(this,t);break}case ce.IN_TEMPLATE:{Woe(this,t);break}case ce.AFTER_BODY:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{P3(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===Z.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case ce.IN_HEAD:case ce.IN_HEAD_NO_SCRIPT:case ce.AFTER_HEAD:case ce.TEXT:case ce.IN_COLUMN_GROUP:case ce.IN_SELECT:case ce.IN_SELECT_IN_TABLE:case ce.IN_FRAMESET:case ce.AFTER_FRAMESET:{this._insertCharacters(t);break}case ce.IN_BODY:case ce.IN_CAPTION:case ce.IN_CELL:case ce.IN_TEMPLATE:case ce.AFTER_BODY:case ce.AFTER_AFTER_BODY:case ce.AFTER_AFTER_FRAMESET:{$oe(this,t);break}case ce.IN_TABLE:case ce.IN_TABLE_BODY:case ce.IN_ROW:{zC(this,t);break}case ce.IN_TABLE_TEXT:{Voe(this,t);break}}}};function jXe(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):zoe(e,t),n}function RXe(e,t){let n=null,i=e.openElements.stackTop;for(;i>=0;i--){const r=e.openElements.items[i];if(r===t.element)break;e._isSpecialElement(r,e.openElements.tagIDs[i])&&(n=r)}return n||(e.openElements.shortenToLength(Math.max(i,0)),e.activeFormattingElements.removeEntry(t)),n}function IXe(e,t,n){let i=t,r=e.openElements.getCommonAncestor(t);for(let s=0,a=r;a!==n;s++,a=r){r=e.openElements.getCommonAncestor(a);const o=e.activeFormattingElements.getElementEntry(a),c=o&&s>=NXe;!o||c?(c&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=PXe(e,o),i===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(i),e.treeAdapter.appendChild(a,i),i=a)}return i}function PXe(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),i=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,i),t.element=i,i}function MXe(e,t,n){const i=e.treeAdapter.getTagName(t),r=rb(i);if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const s=e.treeAdapter.getNamespaceURI(t);r===_.TEMPLATE&&s===Ye.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function LXe(e,t,n){const i=e.treeAdapter.getNamespaceURI(n.element),{token:r}=n,s=e.treeAdapter.createElement(r.tagName,i,r.attrs);e._adoptNodes(t,s),e.treeAdapter.appendChild(t,s),e.activeFormattingElements.insertElementAfterBookmark(s,r),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,s,r.tagID)}function I3(e,t){for(let n=0;n=n;i--)e._setEndLocation(e.openElements.items[i],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const i=e.openElements.items[0],r=e.treeAdapter.getNodeSourceCodeLocation(i);if(r&&!r.endTag&&(e._setEndLocation(i,t),e.openElements.stackTop>=1)){const s=e.openElements.items[1],a=e.treeAdapter.getNodeSourceCodeLocation(s);a&&!a.endTag&&e._setEndLocation(s,t)}}}}function QXe(e,t){e._setDocumentType(t);const n=t.forceQuirks?Uo.QUIRKS:mXe(t);pXe(t)||e._err(t,$e.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=ce.BEFORE_HTML}function tO(e,t){e._err(t,$e.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Uo.QUIRKS),e.insertionMode=ce.BEFORE_HTML,e._processToken(t)}function BXe(e,t){t.tagID===_.HTML?(e._insertElement(t,Ye.HTML),e.insertionMode=ce.BEFORE_HEAD):my(e,t)}function UXe(e,t){const n=t.tagID;(n===_.HTML||n===_.HEAD||n===_.BODY||n===_.BR)&&my(e,t)}function my(e,t){e._insertFakeRootElement(),e.insertionMode=ce.BEFORE_HEAD,e._processToken(t)}function zXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.HEAD:{e._insertElement(t,Ye.HTML),e.headElement=e.openElements.current,e.insertionMode=ce.IN_HEAD;break}default:gy(e,t)}}function FXe(e,t){const n=t.tagID;n===_.HEAD||n===_.BODY||n===_.HTML||n===_.BR?gy(e,t):e._err(t,$e.endTagWithoutMatchingOpenElement)}function gy(e,t){e._insertFakeElement(ke.HEAD,_.HEAD),e.headElement=e.openElements.current,e.insertionMode=ce.IN_HEAD,e._processToken(t)}function ql(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:{e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0;break}case _.TITLE:{e._switchToTextParsing(t,jr.RCDATA);break}case _.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,jr.RAWTEXT):(e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_HEAD_NO_SCRIPT);break}case _.NOFRAMES:case _.STYLE:{e._switchToTextParsing(t,jr.RAWTEXT);break}case _.SCRIPT:{e._switchToTextParsing(t,jr.SCRIPT_DATA);break}case _.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=ce.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(ce.IN_TEMPLATE);break}case _.HEAD:{e._err(t,$e.misplacedStartTagForHeadElement);break}default:by(e,t)}}function VXe(e,t){switch(t.tagID){case _.HEAD:{e.openElements.pop(),e.insertionMode=ce.AFTER_HEAD;break}case _.BODY:case _.BR:case _.HTML:{by(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function Xp(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==_.TEMPLATE&&e._err(t,$e.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(_.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,$e.endTagWithoutMatchingOpenElement)}function by(e,t){e.openElements.pop(),e.insertionMode=ce.AFTER_HEAD,e._processToken(t)}function XXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BASEFONT:case _.BGSOUND:case _.HEAD:case _.LINK:case _.META:case _.NOFRAMES:case _.STYLE:{ql(e,t);break}case _.NOSCRIPT:{e._err(t,$e.nestedNoscriptInHead);break}default:Oy(e,t)}}function qXe(e,t){switch(t.tagID){case _.NOSCRIPT:{e.openElements.pop(),e.insertionMode=ce.IN_HEAD;break}case _.BR:{Oy(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function Oy(e,t){const n=t.type===En.EOF?$e.openElementsLeftAfterEof:$e.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=ce.IN_HEAD,e._processToken(t)}function HXe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.BODY:{e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=ce.IN_BODY;break}case _.FRAMESET:{e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_FRAMESET;break}case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:case _.NOFRAMES:case _.SCRIPT:case _.STYLE:case _.TEMPLATE:case _.TITLE:{e._err(t,$e.abandonedHeadElementChild),e.openElements.push(e.headElement,_.HEAD),ql(e,t),e.openElements.remove(e.headElement);break}case _.HEAD:{e._err(t,$e.misplacedStartTagForHeadElement);break}default:yy(e,t)}}function YXe(e,t){switch(t.tagID){case _.BODY:case _.HTML:case _.BR:{yy(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:e._err(t,$e.endTagWithoutMatchingOpenElement)}}function yy(e,t){e._insertFakeElement(ke.BODY,_.BODY),e.insertionMode=ce.IN_BODY,mA(e,t)}function mA(e,t){switch(t.type){case En.CHARACTER:{Qoe(e,t);break}case En.WHITESPACE_CHARACTER:{$oe(e,t);break}case En.COMMENT:{xM(e,t);break}case En.START_TAG:{ea(e,t);break}case En.END_TAG:{gA(e,t);break}case En.EOF:{Foe(e,t);break}}}function $oe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Qoe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function GXe(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function WXe(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function ZXe(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_FRAMESET)}function KXe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML)}function JXe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&yM.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Ye.HTML)}function eqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function tqe(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),n||(e.formElement=e.openElements.current))}function nqe(e,t){e.framesetOk=!1;const n=t.tagID;for(let i=e.openElements.stackTop;i>=0;i--){const r=e.openElements.tagIDs[i];if(n===_.LI&&r===_.LI||(n===_.DD||n===_.DT)&&(r===_.DD||r===_.DT)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.popUntilTagNamePopped(r);break}if(r!==_.ADDRESS&&r!==_.DIV&&r!==_.P&&e._isSpecialElement(e.openElements.items[i],r))break}e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML)}function iqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.tokenizer.state=jr.PLAINTEXT}function rqe(e,t){e.openElements.hasInScope(_.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(_.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.framesetOk=!1}function sqe(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(ke.A);n&&(I3(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function aqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function oqe(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(_.NOBR)&&(I3(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Ye.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function lqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function cqe(e,t){e.treeAdapter.getDocumentMode(e.document)!==Uo.QUIRKS&&e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=ce.IN_TABLE}function Boe(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ye.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Uoe(e){const t=Noe(e,op.TYPE);return t!=null&&t.toLowerCase()===_Xe}function uqe(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ye.HTML),Uoe(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function dqe(e,t){e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0}function fqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._appendElement(t,Ye.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function hqe(e,t){t.tagName=ke.IMG,t.tagID=_.IMG,Boe(e,t)}function pqe(e,t){e._insertElement(t,Ye.HTML),e.skipNextNewLine=!0,e.tokenizer.state=jr.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=ce.TEXT}function mqe(e,t){e.openElements.hasInButtonScope(_.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,jr.RAWTEXT)}function gqe(e,t){e.framesetOk=!1,e._switchToTextParsing(t,jr.RAWTEXT)}function cF(e,t){e._switchToTextParsing(t,jr.RAWTEXT)}function bqe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===ce.IN_TABLE||e.insertionMode===ce.IN_CAPTION||e.insertionMode===ce.IN_TABLE_BODY||e.insertionMode===ce.IN_ROW||e.insertionMode===ce.IN_CELL?ce.IN_SELECT_IN_TABLE:ce.IN_SELECT}function Oqe(e,t){e.openElements.currentTagId===_.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML)}function yqe(e,t){e.openElements.hasInScope(_.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Ye.HTML)}function xqe(e,t){e.openElements.hasInScope(_.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(_.RTC),e._insertElement(t,Ye.HTML)}function vqe(e,t){e._reconstructActiveFormattingElements(),Moe(t),R3(t),t.selfClosing?e._appendElement(t,Ye.MATHML):e._insertElement(t,Ye.MATHML),t.ackSelfClosing=!0}function wqe(e,t){e._reconstructActiveFormattingElements(),Loe(t),R3(t),t.selfClosing?e._appendElement(t,Ye.SVG):e._insertElement(t,Ye.SVG),t.ackSelfClosing=!0}function uF(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ye.HTML)}function ea(e,t){switch(t.tagID){case _.I:case _.S:case _.B:case _.U:case _.EM:case _.TT:case _.BIG:case _.CODE:case _.FONT:case _.SMALL:case _.STRIKE:case _.STRONG:{aqe(e,t);break}case _.A:{sqe(e,t);break}case _.H1:case _.H2:case _.H3:case _.H4:case _.H5:case _.H6:{JXe(e,t);break}case _.P:case _.DL:case _.OL:case _.UL:case _.DIV:case _.DIR:case _.NAV:case _.MAIN:case _.MENU:case _.ASIDE:case _.CENTER:case _.FIGURE:case _.FOOTER:case _.HEADER:case _.HGROUP:case _.DIALOG:case _.DETAILS:case _.ADDRESS:case _.ARTICLE:case _.SEARCH:case _.SECTION:case _.SUMMARY:case _.FIELDSET:case _.BLOCKQUOTE:case _.FIGCAPTION:{KXe(e,t);break}case _.LI:case _.DD:case _.DT:{nqe(e,t);break}case _.BR:case _.IMG:case _.WBR:case _.AREA:case _.EMBED:case _.KEYGEN:{Boe(e,t);break}case _.HR:{fqe(e,t);break}case _.RB:case _.RTC:{yqe(e,t);break}case _.RT:case _.RP:{xqe(e,t);break}case _.PRE:case _.LISTING:{eqe(e,t);break}case _.XMP:{mqe(e,t);break}case _.SVG:{wqe(e,t);break}case _.HTML:{GXe(e,t);break}case _.BASE:case _.LINK:case _.META:case _.STYLE:case _.TITLE:case _.SCRIPT:case _.BGSOUND:case _.BASEFONT:case _.TEMPLATE:{ql(e,t);break}case _.BODY:{WXe(e,t);break}case _.FORM:{tqe(e,t);break}case _.NOBR:{oqe(e,t);break}case _.MATH:{vqe(e,t);break}case _.TABLE:{cqe(e,t);break}case _.INPUT:{uqe(e,t);break}case _.PARAM:case _.TRACK:case _.SOURCE:{dqe(e,t);break}case _.IMAGE:{hqe(e,t);break}case _.BUTTON:{rqe(e,t);break}case _.APPLET:case _.OBJECT:case _.MARQUEE:{lqe(e,t);break}case _.IFRAME:{gqe(e,t);break}case _.SELECT:{bqe(e,t);break}case _.OPTION:case _.OPTGROUP:{Oqe(e,t);break}case _.NOEMBED:case _.NOFRAMES:{cF(e,t);break}case _.FRAMESET:{ZXe(e,t);break}case _.TEXTAREA:{pqe(e,t);break}case _.NOSCRIPT:{e.options.scriptingEnabled?cF(e,t):uF(e,t);break}case _.PLAINTEXT:{iqe(e,t);break}case _.COL:case _.TH:case _.TD:case _.TR:case _.HEAD:case _.FRAME:case _.TBODY:case _.TFOOT:case _.THEAD:case _.CAPTION:case _.COLGROUP:break;default:uF(e,t)}}function Sqe(e,t){if(e.openElements.hasInScope(_.BODY)&&(e.insertionMode=ce.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Eqe(e,t){e.openElements.hasInScope(_.BODY)&&(e.insertionMode=ce.AFTER_BODY,Zoe(e,t))}function kqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function Tqe(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(_.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(_.FORM):n&&e.openElements.remove(n))}function _qe(e){e.openElements.hasInButtonScope(_.P)||e._insertFakeElement(ke.P,_.P),e._closePElement()}function Aqe(e){e.openElements.hasInListItemScope(_.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(_.LI),e.openElements.popUntilTagNamePopped(_.LI))}function Nqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Cqe(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function jqe(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function Rqe(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(ke.BR,_.BR),e.openElements.pop(),e.framesetOk=!1}function zoe(e,t){const n=t.tagName,i=t.tagID;for(let r=e.openElements.stackTop;r>0;r--){const s=e.openElements.items[r],a=e.openElements.tagIDs[r];if(i===a&&(i!==_.UNKNOWN||e.treeAdapter.getTagName(s)===n)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.stackTop>=r&&e.openElements.shortenToLength(r);break}if(e._isSpecialElement(s,a))break}}function gA(e,t){switch(t.tagID){case _.A:case _.B:case _.I:case _.S:case _.U:case _.EM:case _.TT:case _.BIG:case _.CODE:case _.FONT:case _.NOBR:case _.SMALL:case _.STRIKE:case _.STRONG:{I3(e,t);break}case _.P:{_qe(e);break}case _.DL:case _.UL:case _.OL:case _.DIR:case _.DIV:case _.NAV:case _.PRE:case _.MAIN:case _.MENU:case _.ASIDE:case _.BUTTON:case _.CENTER:case _.FIGURE:case _.FOOTER:case _.HEADER:case _.HGROUP:case _.DIALOG:case _.ADDRESS:case _.ARTICLE:case _.DETAILS:case _.SEARCH:case _.SECTION:case _.SUMMARY:case _.LISTING:case _.FIELDSET:case _.BLOCKQUOTE:case _.FIGCAPTION:{kqe(e,t);break}case _.LI:{Aqe(e);break}case _.DD:case _.DT:{Nqe(e,t);break}case _.H1:case _.H2:case _.H3:case _.H4:case _.H5:case _.H6:{Cqe(e);break}case _.BR:{Rqe(e);break}case _.BODY:{Sqe(e,t);break}case _.HTML:{Eqe(e,t);break}case _.FORM:{Tqe(e);break}case _.APPLET:case _.OBJECT:case _.MARQUEE:{jqe(e,t);break}case _.TEMPLATE:{Xp(e,t);break}default:zoe(e,t)}}function Foe(e,t){e.tmplInsertionModeStack.length>0?Woe(e,t):P3(e,t)}function Iqe(e,t){var n;t.tagID===_.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function Pqe(e,t){e._err(t,$e.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function zC(e,t){if(e.openElements.currentTagId!==void 0&&Doe.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=ce.IN_TABLE_TEXT,t.type){case En.CHARACTER:{Xoe(e,t);break}case En.WHITESPACE_CHARACTER:{Voe(e,t);break}}else z1(e,t)}function Mqe(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_CAPTION}function Lqe(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_COLUMN_GROUP}function Dqe(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ke.COLGROUP,_.COLGROUP),e.insertionMode=ce.IN_COLUMN_GROUP,M3(e,t)}function $qe(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ye.HTML),e.insertionMode=ce.IN_TABLE_BODY}function Qqe(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ke.TBODY,_.TBODY),e.insertionMode=ce.IN_TABLE_BODY,bA(e,t)}function Bqe(e,t){e.openElements.hasInTableScope(_.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function Uqe(e,t){Uoe(t)?e._appendElement(t,Ye.HTML):z1(e,t),t.ackSelfClosing=!0}function zqe(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Ye.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function m0(e,t){switch(t.tagID){case _.TD:case _.TH:case _.TR:{Qqe(e,t);break}case _.STYLE:case _.SCRIPT:case _.TEMPLATE:{ql(e,t);break}case _.COL:{Dqe(e,t);break}case _.FORM:{zqe(e,t);break}case _.TABLE:{Bqe(e,t);break}case _.TBODY:case _.TFOOT:case _.THEAD:{$qe(e,t);break}case _.INPUT:{Uqe(e,t);break}case _.CAPTION:{Mqe(e,t);break}case _.COLGROUP:{Lqe(e,t);break}default:z1(e,t)}}function _x(e,t){switch(t.tagID){case _.TABLE:{e.openElements.hasInTableScope(_.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TABLE),e._resetInsertionMode());break}case _.TEMPLATE:{Xp(e,t);break}case _.BODY:case _.CAPTION:case _.COL:case _.COLGROUP:case _.HTML:case _.TBODY:case _.TD:case _.TFOOT:case _.TH:case _.THEAD:case _.TR:break;default:z1(e,t)}}function z1(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,mA(e,t),e.fosterParentingEnabled=n}function Voe(e,t){e.pendingCharacterTokens.push(t)}function Xoe(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function nO(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n0&&e.openElements.currentTagId===_.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===_.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===_.OPTGROUP&&e.openElements.pop();break}case _.OPTION:{e.openElements.currentTagId===_.OPTION&&e.openElements.pop();break}case _.SELECT:{e.openElements.hasInSelectScope(_.SELECT)&&(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode());break}case _.TEMPLATE:{Xp(e,t);break}}}function Yqe(e,t){const n=t.tagID;n===_.CAPTION||n===_.TABLE||n===_.TBODY||n===_.TFOOT||n===_.THEAD||n===_.TR||n===_.TD||n===_.TH?(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Yoe(e,t)}function Gqe(e,t){const n=t.tagID;n===_.CAPTION||n===_.TABLE||n===_.TBODY||n===_.TFOOT||n===_.THEAD||n===_.TR||n===_.TD||n===_.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(_.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Goe(e,t)}function Wqe(e,t){switch(t.tagID){case _.BASE:case _.BASEFONT:case _.BGSOUND:case _.LINK:case _.META:case _.NOFRAMES:case _.SCRIPT:case _.STYLE:case _.TEMPLATE:case _.TITLE:{ql(e,t);break}case _.CAPTION:case _.COLGROUP:case _.TBODY:case _.TFOOT:case _.THEAD:{e.tmplInsertionModeStack[0]=ce.IN_TABLE,e.insertionMode=ce.IN_TABLE,m0(e,t);break}case _.COL:{e.tmplInsertionModeStack[0]=ce.IN_COLUMN_GROUP,e.insertionMode=ce.IN_COLUMN_GROUP,M3(e,t);break}case _.TR:{e.tmplInsertionModeStack[0]=ce.IN_TABLE_BODY,e.insertionMode=ce.IN_TABLE_BODY,bA(e,t);break}case _.TD:case _.TH:{e.tmplInsertionModeStack[0]=ce.IN_ROW,e.insertionMode=ce.IN_ROW,OA(e,t);break}default:e.tmplInsertionModeStack[0]=ce.IN_BODY,e.insertionMode=ce.IN_BODY,ea(e,t)}}function Zqe(e,t){t.tagID===_.TEMPLATE&&Xp(e,t)}function Woe(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(_.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):P3(e,t)}function Kqe(e,t){t.tagID===_.HTML?ea(e,t):Yk(e,t)}function Zoe(e,t){var n;if(t.tagID===_.HTML){if(e.fragmentContext||(e.insertionMode=ce.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===_.HTML){e._setEndLocation(e.openElements.items[0],t);const i=e.openElements.items[1];i&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(i))===null||n===void 0)&&n.endTag)&&e._setEndLocation(i,t)}}else Yk(e,t)}function Yk(e,t){e.insertionMode=ce.IN_BODY,mA(e,t)}function Jqe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.FRAMESET:{e._insertElement(t,Ye.HTML);break}case _.FRAME:{e._appendElement(t,Ye.HTML),t.ackSelfClosing=!0;break}case _.NOFRAMES:{ql(e,t);break}}}function eHe(e,t){t.tagID===_.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==_.FRAMESET&&(e.insertionMode=ce.AFTER_FRAMESET))}function tHe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.NOFRAMES:{ql(e,t);break}}}function nHe(e,t){t.tagID===_.HTML&&(e.insertionMode=ce.AFTER_AFTER_FRAMESET)}function iHe(e,t){t.tagID===_.HTML?ea(e,t):aE(e,t)}function aE(e,t){e.insertionMode=ce.IN_BODY,mA(e,t)}function rHe(e,t){switch(t.tagID){case _.HTML:{ea(e,t);break}case _.NOFRAMES:{ql(e,t);break}}}function sHe(e,t){t.chars=rr,e._insertCharacters(t)}function aHe(e,t){e._insertCharacters(t),e.framesetOk=!1}function Koe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Ye.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function oHe(e,t){if(wXe(t))Koe(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),i=e.treeAdapter.getNamespaceURI(n);i===Ye.MATHML?Moe(t):i===Ye.SVG&&(SXe(t),Loe(t)),R3(t),t.selfClosing?e._appendElement(t,i):e._insertElement(t,i),t.ackSelfClosing=!0}}function lHe(e,t){if(t.tagID===_.P||t.tagID===_.BR){Koe(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const i=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(i)===Ye.HTML){e._endTagOutsideForeignContent(t);break}const r=e.treeAdapter.getTagName(i);if(r.toLowerCase()===t.tagName){t.tagName=r,e.openElements.shortenToLength(n);break}}}ke.AREA,ke.BASE,ke.BASEFONT,ke.BGSOUND,ke.BR,ke.COL,ke.EMBED,ke.FRAME,ke.HR,ke.IMG,ke.INPUT,ke.KEYGEN,ke.LINK,ke.META,ke.PARAM,ke.SOURCE,ke.TRACK,ke.WBR;const cHe=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,uHe=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),dF={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function Joe(e,t){const n=xHe(e),i=pae("type",{handlers:{root:dHe,element:fHe,text:hHe,comment:tle,doctype:pHe,raw:gHe},unknown:bHe}),r={parser:n?new lF(dF):lF.getFragmentParser(void 0,dF),handle(o){i(o,r)},stitches:!1,options:t||{}};i(e,r),sb(r,Wc());const s=n?r.parser.document:r.parser.getFragment(),a=vVe(s,{file:r.options.file});return r.stitches&&B1(a,"comment",function(o,c,u){const d=o;if(d.value.stitch&&u&&c!==void 0){const f=u.children;return f[c]=d.value.stitch,c}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function ele(e,t){let n=-1;if(e)for(;++n4&&(t.parser.tokenizer.state=0);const n={type:En.CHARACTER,chars:e.value,location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function pHe(e,t){const n={type:En.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function mHe(e,t){t.stitches=!0;const n=vHe(e);if("children"in e&&"children"in n){const i=Joe({type:"root",children:e.children},t.options);n.children=i.children}tle({type:"comment",value:{stitch:n}},t)}function tle(e,t){const n=e.value,i={type:En.COMMENT,data:n,location:F1(e)};sb(t,Wc(e)),t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken)}function gHe(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,nle(t,Wc(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(cHe,"<$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function bHe(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))mHe(n,t);else{let i="";throw uHe.has(n.type)&&(i=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+i)}}function sb(e,t){nle(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=jr.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function nle(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function OHe(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===jr.PLAINTEXT)return;sb(t,Wc(e));const i=t.parser.openElements.current;let r="namespaceURI"in i?i.namespaceURI:Uh.html;r===Uh.html&&n==="svg"&&(r=Uh.svg);const s=TVe({...e,children:[]},{space:r===Uh.svg?"svg":"html"}),a={type:En.START_TAG,tagName:n,tagID:rb(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in s?s.attrs:[],location:F1(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function yHe(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&PVe.includes(n)||t.parser.tokenizer.state===jr.PLAINTEXT)return;sb(t,cA(e));const i={type:En.END_TAG,tagName:n,tagID:rb(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:F1(e)};t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===jr.RCDATA||t.parser.tokenizer.state===jr.RAWTEXT||t.parser.tokenizer.state===jr.SCRIPT_DATA)&&(t.parser.tokenizer.state=jr.DATA)}function xHe(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function F1(e){const t=Wc(e)||{line:void 0,column:void 0,offset:void 0},n=cA(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function vHe(e){return"children"in e?h0({...e,children:[]}):h0(e)}function wHe(e){return function(t,n){return Joe(t,{...e,file:n})}}const ile=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function rle(e){if(!e)return!1;try{const t=e.toLowerCase();return ile.some(n=>t.includes(n))}catch{return!1}}function SHe(e){var i;const t=(i=e==null?void 0:e.properties)==null?void 0:i.href;if(!t)return!1;if(rle(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const r=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return ile.some(s=>r.includes(s))}return!1}function EHe({text:e,className:t,allowRawHtml:n=!0}){const[i,r]=m.useState(null),s=(c,u)=>{if(c.src)return c.src;if(u){const d=h=>{var p;if(!h)return null;if(h.type==="source"&&((p=h.properties)!=null&&p.src))return h.properties.src;if(h.children)for(const g of h.children){const b=d(g);if(b)return b}return null},f=d({children:u});if(f)return f}return""},a=c=>{try{const d=new URL(c).pathname.split("/");return d[d.length-1]||"video.mp4"}catch{return"video.mp4"}},o=c=>c?Array.isArray(c)?c.map(u=>(u==null?void 0:u.value)||"").join("")||"video":(c==null?void 0:c.value)||"video":"video";return l.jsxs("div",{className:t?`md ${t}`:"md",children:[l.jsx(_9e,{remarkPlugins:[B7e],rehypePlugins:n?[wHe,Yz]:[Yz],components:{a:({node:c,...u})=>{const d=u.href;if(d&&(rle(d)||SHe(c))){const f=d,h=o(c==null?void 0:c.children);return l.jsxs("div",{className:"video-container",children:[l.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${h}`,onClick:()=>r({src:f,title:h}),children:[l.jsx("video",{src:f,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),l.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]}),l.jsx("div",{className:"video-caption",children:l.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:h})})]})}return l.jsx("a",{...u,target:"_blank",rel:"noopener noreferrer"})},img:({node:c,src:u,alt:d,...f})=>{const h=l.jsx("img",{...f,src:u,alt:d??"",loading:"lazy"});return u?l.jsx(sJ,{src:u,children:l.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${d||"图片"}`,children:[h,l.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]})}):h},video:({node:c,src:u,children:d,...f})=>{const h=s({src:u},d);return h?l.jsx("div",{className:"video-container",children:l.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>r({src:h}),children:[l.jsx("video",{src:h,...f,playsInline:!0,className:"video-thumbnail",children:d}),l.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:l.jsx(np,{})})]})}):l.jsx("video",{src:u,controls:!0,playsInline:!0,className:"video-inline",...f,children:d})}},children:e}),i&&l.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>r(null),children:l.jsxs("div",{className:"video-viewer",onClick:c=>c.stopPropagation(),children:[l.jsxs("div",{className:"video-viewer-header",children:[l.jsx("div",{className:"video-viewer-title",children:i.title||a(i.src)}),l.jsxs("nav",{className:"video-viewer-nav",children:[l.jsx("a",{href:i.src,download:i.title||a(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:l.jsx(b_,{})}),l.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>r(null),children:l.jsx(xa,{})})]})]}),l.jsx("div",{className:"video-viewer-body",children:l.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const qp=m.memo(EHe);function yA({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:i}){return e.skills.length===0&&!e.targetAgent?null:l.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(r=>l.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:r.description,children:[l.jsx(tx,{"aria-hidden":!0}),l.jsxs("span",{children:[t,r.name]}),n?l.jsx("button",{type:"button",onClick:()=>n(r.name),"aria-label":`移除技能 ${r.name}`,children:l.jsx(xa,{})}):null]},r.name)),e.targetAgent?l.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[l.jsx(lJ,{"aria-hidden":!0}),l.jsx("span",{children:e.targetAgent.name}),i?l.jsx("button",{type:"button",onClick:i,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:l.jsx(xa,{})}):null]}):null]})}function L3(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function sle(e){var n,i,r,s;const t=L3(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((i=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:i.toUpperCase())??"VIDEO":t==="image"?((s=(r=e.mimeType)==null?void 0:r.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function ale(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function ole(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?qJ(t,e.uri):""}function kHe({kind:e}){return e==="image"?l.jsx(LD,{}):e==="video"?l.jsx(fJ,{}):e==="pdf"?l.jsx(Gwe,{}):l.jsx(PD,{})}function xA({appName:e,items:t,compact:n=!1,onRemove:i}){const[r,s]=m.useState(null);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const o=L3(a.mimeType),c=ole(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=l.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:o==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[o==="image"&&c?l.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):o==="video"&&c?l.jsxs("div",{className:"media-card-video-container",children:[l.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),l.jsx("span",{className:"media-card-video-play",children:l.jsx(cSe,{})})]}):l.jsx("span",{className:"media-card-icon",children:l.jsx(kHe,{kind:o})}),l.jsxs("span",{className:"media-card-copy",children:[l.jsx("span",{className:"media-card-name",children:a.name??"附件"}),l.jsxs("span",{className:"media-card-meta",children:[l.jsx("span",{className:"media-card-type",children:sle(a)}),a.status==="uploading"?l.jsxs(l.Fragment,{children:[l.jsx(Kn,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":ale(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?l.jsx(np,{className:"media-card-open"}):null]});return l.jsxs(wr.div,{className:`media-card media-card--${o}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[o==="image"&&!u?l.jsx(sJ,{src:c,children:d}):d,i?l.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>i(a.id),children:l.jsx(xa,{})}):null]},a.id)})}),l.jsx(xf,{children:r?l.jsx(THe,{appName:e,item:r,onClose:()=>s(null)}):null})]})}function THe({appName:e,item:t,onClose:n}){const i=m.useMemo(()=>ole(t,e),[e,t]),r=L3(t.mimeType),[s,a]=m.useState(""),[o,c]=m.useState(r==="text"||r==="markdown"),[u,d]=m.useState("");return m.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),m.useEffect(()=>{if(r!=="text"&&r!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(i,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[r,i]),l.jsx(wr.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:l.jsxs(wr.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[l.jsxs("header",{className:"media-viewer-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:t.name??"附件"}),l.jsxs("span",{children:[sle(t),t.sizeBytes?` · ${ale(t.sizeBytes)}`:""]})]}),l.jsxs("nav",{children:[l.jsx("a",{href:i,download:t.name,"aria-label":"下载",children:l.jsx(b_,{})}),l.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:l.jsx(xa,{})})]})]}),l.jsxs("div",{className:`media-viewer-body media-viewer-body--${r}`,children:[r==="image"?l.jsx("img",{src:i,alt:t.name??"图片"}):null,r==="video"?l.jsx("div",{className:"media-viewer-video-wrapper",children:l.jsx("video",{src:i,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,r==="pdf"?l.jsx("iframe",{src:i,title:t.name??"PDF"}):null,o?l.jsxs("div",{className:"media-viewer-loading",children:[l.jsx(Kn,{})," 正在读取文档…"]}):null,!o&&u?l.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!o&&r==="markdown"?l.jsx("div",{className:"media-document",children:l.jsx(qp,{text:s})}):null,!o&&r==="text"?l.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function _He(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),l.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function AHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),l.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),l.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),l.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function D3(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),l.jsxs("g",{className:"video-generate-icon__clapper",children:[l.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),l.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),l.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function NHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),l.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),l.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function CHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),l.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),l.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function jHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),l.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),l.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),l.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function RHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),l.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),l.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function IHe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),l.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),l.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),l.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function lle(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function PHe({definition:e,label:t,done:n,open:i,onToggle:r}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return l.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:r,"aria-expanded":i,children:[l.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:l.jsx(s,{})}),n?l.jsx("span",{className:"builtin-tool-label",children:a}):l.jsx(oi,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),l.jsx(lle,{className:`builtin-tool-chevron${i?" is-open":""}`})]})}const MHe={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:_He},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:IHe},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:AHe},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:D3},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:NHe},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:CHe},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:jHe},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:RHe}};function LHe(e){return MHe[e]}function DHe(e){return l.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}const cle="send_a2ui_json_to_client",$He=28;function QHe(e,t,n){let i=t;for(let r=0;r65535?2:1}return i}function BHe(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function ule(e,t,n,i){const[r,s]=m.useState(()=>t?"":e),a=m.useRef(r),o=m.useRef(e),c=m.useRef(null),u=m.useRef(0),d=m.useRef(n);return o.current=e,d.current=n,m.useEffect(()=>{const f=a.current,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||h||!e.startsWith(f)){c.current!==null&&window.cancelAnimationFrame(c.current),c.current=null,f!==e&&(a.current=e,s(e));return}if(f===e||c.current!==null)return;const p=g=>{const b=o.current,y=a.current;if(!b.startsWith(y)){a.current=b,s(b),c.current=null;return}if(g-u.current<$He){c.current=window.requestAnimationFrame(p);return}const O=b.length-y.length;if(O<=0){c.current=null;return}const v=QHe(b,y.length,BHe(O)),x=b.slice(0,v);a.current=x,u.current=g,s(x),c.current=x===b?null:window.requestAnimationFrame(p)};c.current=window.requestAnimationFrame(p)},[t,e]),m.useLayoutEffect(()=>{var f;(f=d.current)==null||f.call(d)},[r]),m.useEffect(()=>{r===e&&(i==null||i())},[r,i,e]),m.useEffect(()=>()=>{c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)},[]),r}function UHe(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M14.3 5.25a4.6 4.6 0 0 0-5.55 5.55L3.6 15.95a1.8 1.8 0 0 0 0 2.55l1.9 1.9a1.8 1.8 0 0 0 2.55 0l5.15-5.15a4.6 4.6 0 0 0 5.55-5.55l-2.9 2.9-2.45-.55-.55-2.45 2.9-2.9a4.6 4.6 0 0 0-1.45-1.45Z"})})}function zHe(e,t){if(e!=="load_skill"||t==null||typeof t!="object"||Array.isArray(t))return;const n=t.skill_name;if(!(typeof n!="string"||!n.trim()))return`使用 ${n.trim()} 技能`}function dle({text:e,done:t,answerStarted:n=!1,streaming:i=!1,onStreamFrame:r}){const[s,a]=m.useState(!(t||n)),o=m.useRef(!1);m.useEffect(()=>{o.current||a(!(t||n))},[n,t]);const c=()=>{o.current=!0,a(p=>!p)},u=e.replace(/^\s+/,""),d=ule(u,!t||i,r),{ref:f,onScroll:h}=kse(d);return l.jsxs("div",{className:"block-thinking",children:[l.jsxs("button",{className:"think-head",onClick:c,type:"button",children:[l.jsx("span",{className:"think-icon","aria-hidden":"true",children:l.jsx(DHe,{className:`thinking-logo ${t?"":"is-active"}`})}),t?l.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):l.jsx(oi,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),l.jsx(U0,{className:`chev ${s?"open":""}`})]}),l.jsx("div",{className:`think-collapse ${s&&d?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsx("div",{className:"think-body scroll",ref:f,onScroll:h,children:d})})})]})}function fle(){return l.jsx(dle,{text:"",done:!1})}const FHe=m.memo(function({text:t,streaming:n,onStreamFrame:i,onStreamComplete:r}){const s=ule(t,n,i,r);return s?l.jsx("div",{className:"bubble",children:l.jsx(qp,{text:s})}):null});function VHe({name:e,args:t,response:n,done:i}){const[r,s]=m.useState(!1),a=e===cle?"渲染 UI":e,o=LHe(e),c=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),u=c&&c.length>2e3?c.slice(0,2e3)+` +…(已截断)`:c;return l.jsxs(wr.div,{className:`block-tool${o?" block-tool--builtin":""}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[o?l.jsx(PHe,{definition:o,label:zHe(e,t),done:i,open:r,onToggle:()=>s(d=>!d)}):l.jsxs("button",{className:"tool-head tool-head--generic",onClick:()=>s(d=>!d),type:"button","aria-expanded":r,children:[l.jsx("span",{className:"tool-icon tool-icon--generic","aria-hidden":"true",children:l.jsx(UHe,{})}),i?l.jsx("span",{className:"tool-name",children:a}):l.jsx(oi,{className:"tool-name",duration:2.2,spread:15,children:a}),l.jsx(lle,{className:`tool-chevron${r?" is-open":""}`})]}),l.jsx("div",{className:`think-collapse ${r?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsxs("div",{className:"tool-detail",children:[t!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"参数"}),l.jsx("pre",{className:"tool-args",children:JSON.stringify(t,null,2)})]}),u!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"返回"}),l.jsx("pre",{className:"tool-args tool-result",children:u})]})]})})})]})}function XHe({block:e,onDownload:t,onPreview:n}){const[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(null);m.useEffect(()=>()=>{o&&URL.revokeObjectURL(o.url)},[o]);const u=()=>c(null),d=async(p,g)=>{if(t){r(`download:${p}`),a("");try{await t(p,g)}catch(b){a(b instanceof Error?b.message:String(b))}finally{r("")}}},f=async(p,g,b)=>{if(n){r(`preview:${b}`),a("");try{const y=await n(p,g);c({name:b,url:y})}catch(y){a(y instanceof Error?y.message:String(y))}finally{r("")}}},h=e.files.filter(p=>!p.filename.endsWith(".preview.webp"));return l.jsxs("div",{className:"artifact-list",children:[h.map(p=>{const g=`${p.filename.replace(/\.pptx$/i,"")}.preview.webp`,b=e.files.find(y=>y.filename===g);return l.jsxs("div",{className:"artifact-card",children:[l.jsx("span",{className:"artifact-card__icon","aria-hidden":"true",children:l.jsx(PD,{})}),l.jsxs("span",{className:"artifact-card__copy",children:[l.jsx("span",{className:"artifact-card__name",children:p.filename}),l.jsx("span",{className:"artifact-card__hint",children:"PowerPoint 演示文稿"})]}),l.jsxs("span",{className:"artifact-card__actions",children:[b&&l.jsxs("button",{className:"artifact-card__action",type:"button",disabled:!n||i!=="",onClick:()=>void f(b.filename,b.version,p.filename),children:[i===`preview:${p.filename}`?l.jsx(Kn,{className:"spin"}):l.jsx(qwe,{}),"预览"]}),l.jsxs("button",{className:"artifact-card__action artifact-card__action--primary",type:"button",disabled:!t||i!=="",onClick:()=>void d(p.filename,p.version),children:[i===`download:${p.filename}`?l.jsx(Kn,{className:"spin"}):l.jsx(b_,{}),"下载"]})]})]},`${p.filename}:${p.version}`)}),s&&l.jsx("div",{className:"artifact-card__error",children:s}),o&&l.jsxs("div",{className:"artifact-preview",role:"dialog","aria-modal":"true","aria-label":`${o.name} 预览`,children:[l.jsx("button",{className:"artifact-preview__backdrop",type:"button","aria-label":"关闭预览",onClick:u}),l.jsxs("div",{className:"artifact-preview__panel",children:[l.jsxs("div",{className:"artifact-preview__header",children:[l.jsx("span",{children:o.name}),l.jsx("button",{type:"button","aria-label":"关闭预览",onClick:u,children:l.jsx(xa,{})})]}),l.jsx("div",{className:"artifact-preview__canvas",children:l.jsx("img",{src:o.url,alt:`${o.name} 幻灯片预览`})})]})]})]})}function qHe({block:e,onAuth:t}){const[n,i]=m.useState(e.done?"done":"idle"),[r,s]=m.useState(""),a=e.label||"MCP 工具集",o=(()=>{try{return e.authUri?new URL(e.authUri).host:""}catch{return""}})(),c=async()=>{if(t){s(""),i("authorizing");try{await t(e),i("done")}catch(d){s(d instanceof Error?d.message:String(d)),i("idle")}}};return e.done||n==="done"?l.jsxs(wr.div,{className:"auth-card-collapsed",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:[l.jsx(s9,{className:"auth-card-icon auth-card-icon--done"}),l.jsxs("span",{children:["已授权 · ",a]})]}):l.jsxs(wr.div,{className:"auth-card",initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[l.jsxs("div",{className:"auth-card-head",children:[l.jsx(s9,{className:"auth-card-icon"}),l.jsxs("span",{className:"auth-card-title",children:[a," 需要授权"]})]}),l.jsxs("p",{className:"auth-card-desc",children:["工具集 ",l.jsx("code",{className:"auth-card-code",children:a})," 使用 OAuth 保护, 需登录授权后方可调用。",o&&l.jsxs(l.Fragment,{children:[" ","将跳转至 ",l.jsx("code",{className:"auth-card-code",children:o})," 完成登录,"]}),"授权完成后对话自动继续。"]}),l.jsx("button",{className:"auth-card-btn",onClick:c,disabled:n==="authorizing"||!e.authUri,children:n==="authorizing"?l.jsxs(l.Fragment,{children:[l.jsx(Kn,{className:"cw-i spin"})," 等待授权…"]}):l.jsx(l.Fragment,{children:"去授权"})}),!e.authUri&&l.jsx("div",{className:"auth-card-err",children:"未在事件中找到授权地址。"}),r&&l.jsx("div",{className:"auth-card-err",children:r})]})}function vA({blocks:e,appName:t="",streaming:n=!1,onStreamFrame:i,onStreamComplete:r,onAction:s,onAuth:a,onArtifactDownload:o,onArtifactPreview:c}){const u=e.reduce((d,f,h)=>f.kind==="text"?h:d,-1);return l.jsx(l.Fragment,{children:e.map((d,f)=>{switch(d.kind){case"thinking":{const h=e.slice(f+1).some(p=>p.kind==="text"&&!!p.text.trim());return l.jsx(dle,{text:d.text,done:d.done,answerStarted:h,streaming:n,onStreamFrame:i},f)}case"text":{const h=d.text.replace(/^\s+/,"");return h?l.jsx(FHe,{text:h,streaming:n,onStreamFrame:i,onStreamComplete:f===u?r:void 0},f):null}case"attachment":return l.jsx(xA,{appName:t,items:d.files},f);case"artifact":return l.jsx(XHe,{block:d,onDownload:o,onPreview:c},f);case"invocation":return l.jsx(yA,{value:d.value},f);case"tool":return d.name===cle&&d.done?null:l.jsx(VHe,{name:d.name,args:d.args,response:d.response,done:d.done},f);case"agent-transfer":return null;case"auth":return l.jsx(qHe,{block:d,onAuth:a},f);case"a2ui":return Ese(d.messages).filter(h=>h.components[h.rootId]).map(h=>l.jsx(wr.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},transition:{type:"spring",stiffness:380,damping:30},children:l.jsx(W4e,{surface:h,onAction:s})},`${f}-${h.surfaceId}`));default:return null}})})}const HHe=()=>{};function YHe(e){if(e.kind==="message")return{kind:"text",text:e.text};if(e.kind==="thinking")return{kind:"thinking",text:e.text,done:e.status==="done"};if(e.kind==="tool")return{kind:"tool",name:e.name,args:e.args,response:e.response,done:e.status==="done"};throw new Error("不支持的 Skill 对话活动")}function GHe({activities:e}){const t=m.useMemo(()=>e.filter(n=>n.kind!=="status").map(YHe),[e]);return t.length===0?null:l.jsx("div",{className:"skill-conversation","aria-label":"Skill 生成对话","aria-live":"polite",children:l.jsx(vA,{blocks:t,onAction:HHe})})}function fF(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function FC({label:e,value:t,options:n,onChange:i,disabled:r=!1,allowCustom:s=!1,required:a=!1,placeholder:o="请选择",error:c}){const u=m.useId(),d=m.useId(),f=m.useId(),h=m.useRef(null),p=m.useRef(null),g=m.useRef(null),b=m.useRef(null),y=m.useRef([]),O=n.findIndex(L=>L.value===t),v=t.trim().toLocaleLowerCase(),x=s&&v?n.filter(L=>L.value.toLocaleLowerCase().includes(v)||L.label.toLocaleLowerCase().includes(v)):n,[w,E]=m.useState(!1),[S,k]=m.useState(Math.max(0,O)),T=O>=0?n[O]:void 0,A=r||!s&&n.length===0,N=(L=!1)=>{E(!1),L&&window.requestAnimationFrame(()=>{var P,Q;return s?(P=g.current)==null?void 0:P.focus():(Q=p.current)==null?void 0:Q.focus()})},C=L=>{A||x.length!==0&&(k(Math.min(Math.max(L,0),x.length-1)),E(!0))};m.useEffect(()=>{if(!w)return;const L=b.current,P=s?void 0:window.requestAnimationFrame(()=>{var U;(U=y.current[S])==null||U.focus()}),Q=U=>{if(!L)return;const B=L.scrollTop<=0,I=L.scrollTop+L.clientHeight>=L.scrollHeight-1;(L.scrollHeight<=L.clientHeight||U.deltaY<0&&B||U.deltaY>0&&I)&&U.preventDefault(),U.stopPropagation()},j=U=>{var B;U.target instanceof Node&&!((B=h.current)!=null&&B.contains(U.target))&&N()},$=U=>{U.key==="Escape"&&N(!0)};return L==null||L.addEventListener("wheel",Q,{passive:!1}),window.addEventListener("pointerdown",j),window.addEventListener("keydown",$),()=>{P!==void 0&&window.cancelAnimationFrame(P),L==null||L.removeEventListener("wheel",Q),window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",$)}},[S,s,w]);const M=L=>{var Q;if(x.length===0)return;const P=(L+x.length)%x.length;k(P),(Q=y.current[P])==null||Q.focus()};return l.jsxs("div",{ref:h,className:`skill-config-select${w?" is-open":""}`,onBlur:L=>{var P;(!L.relatedTarget||!((P=h.current)!=null&&P.contains(L.relatedTarget)))&&N()},children:[l.jsxs("span",{id:d,className:"skill-config-select__label",children:[e,a?l.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"}):null]}),s?l.jsxs("div",{className:`skill-config-select__trigger is-editable${r?" is-disabled":""}`,"aria-expanded":w,children:[l.jsx("input",{ref:g,value:t,disabled:r,role:"combobox","aria-autocomplete":"list","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,"aria-invalid":!!c,"aria-describedby":c?f:void 0,placeholder:o,onChange:L=>{i(L.target.value),k(0),n.length>0&&E(!0)},onClick:()=>{!w&&x.length>0&&C(0)},onKeyDown:L=>{var P,Q;if(!(L.nativeEvent.isComposing||L.keyCode===229))if(L.key==="ArrowDown")L.preventDefault(),w?(P=y.current[S])==null||P.focus():C(0);else if(L.key==="ArrowUp")L.preventDefault(),w?(Q=y.current[x.length-1])==null||Q.focus():C(x.length-1);else if(L.key==="Enter"&&w){L.preventDefault();const j=x[S];j&&i(j.value),N()}else L.key==="Escape"&&(L.preventDefault(),N())}}),l.jsx("button",{type:"button",className:"skill-config-select__toggle",disabled:r||n.length===0,"aria-label":w?"收起模型选项":"展开模型选项",onClick:()=>{w?N():C(0)},children:l.jsx(fF,{})})]}):l.jsxs("button",{ref:p,type:"button",className:"skill-config-select__trigger",disabled:A,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,onClick:()=>{w?N():C(O>=0?O:0)},onKeyDown:L=>{L.key==="ArrowDown"?(L.preventDefault(),C(O>=0?O:0)):L.key==="ArrowUp"&&(L.preventDefault(),C(O>=0?O:n.length-1))},children:[l.jsx("span",{className:T?void 0:"is-placeholder",title:T==null?void 0:T.label,children:(T==null?void 0:T.label)||(n.length===0?"暂无可用选项":o)}),l.jsx(fF,{})]}),w?l.jsxs("div",{ref:b,id:u,className:"skill-config-select__menu",role:"listbox","aria-labelledby":d,children:[x.length===0?l.jsx("div",{className:"skill-config-select__empty",role:"status",children:"没有匹配项,可直接使用当前模型 ID"}):null,x.map((L,P)=>{const Q=L.value===t;return l.jsx("button",{ref:j=>{y.current[P]=j},type:"button",role:"option","aria-selected":Q,tabIndex:P===S?0:-1,className:`skill-config-select__option${Q?" is-selected":""}`,title:L.label,onFocus:()=>k(P),onClick:()=>{i(L.value),N(!0)},onKeyDown:j=>{j.key==="ArrowDown"?(j.preventDefault(),M(P+1)):j.key==="ArrowUp"?(j.preventDefault(),M(P-1)):j.key==="Home"?(j.preventDefault(),M(0)):j.key==="End"&&(j.preventDefault(),M(n.length-1))},children:L.label},L.value)})]}):null,c?l.jsx("span",{id:f,className:"skill-config-select__error",role:"alert",children:c}):null]})}function ds(e,t){return e instanceof Error?e:typeof e=="string"&&e.trim()?new Error(e.trim()):new Error(t)}function ho({error:e}){var r,s,a,o,c;const t=e,n=(s=(r=t.originalError)==null?void 0:r.message)==null?void 0:s.trim(),i=[typeof t.status=="number"?`HTTP ${t.status}${t.statusText?` ${t.statusText}`:""}`:"",t.code?`错误码:${t.code}`:"",(a=t.originalError)!=null&&a.type?`错误类型:${t.originalError.type}`:"",(o=t.originalError)!=null&&o.repr&&t.originalError.repr!==n?`异常表示:${t.originalError.repr}`:"",(c=t.rawResponse)!=null&&c.trim()?`服务端原始响应: ${t.rawResponse.trim()}`:""].filter(Boolean);return l.jsxs("div",{className:"skill-error-details",children:[l.jsx("div",{className:"skill-error-details__summary",children:e.message}),n?l.jsxs("div",{className:"skill-error-details__original",children:["原始错误:",n]}):null,i.length>0?l.jsxs("details",{children:[l.jsx("summary",{children:"详细信息"}),l.jsx("pre",{children:i.join(` -`)})]}):null]})}const $3=Symbol.for("yaml.alias"),wM=Symbol.for("yaml.document"),Ef=Symbol.for("yaml.map"),fle=Symbol.for("yaml.pair"),Vc=Symbol.for("yaml.scalar"),ab=Symbol.for("yaml.seq"),sl=Symbol.for("yaml.node.type"),ob=e=>!!e&&typeof e=="object"&&e[sl]===$3,V1=e=>!!e&&typeof e=="object"&&e[sl]===wM,X1=e=>!!e&&typeof e=="object"&&e[sl]===Ef,Mr=e=>!!e&&typeof e=="object"&&e[sl]===fle,Fi=e=>!!e&&typeof e=="object"&&e[sl]===Vc,q1=e=>!!e&&typeof e=="object"&&e[sl]===ab;function Rr(e){if(e&&typeof e=="object")switch(e[sl]){case Ef:case ab:return!0}return!1}function Pr(e){if(e&&typeof e=="object")switch(e[sl]){case $3:case Ef:case Vc:case ab:return!0}return!1}const hle=e=>(Fi(e)||Rr(e))&&!!e.anchor,Nh=Symbol("break visit"),GHe=Symbol("skip children"),xy=Symbol("remove node");function lb(e,t){const n=WHe(t);V1(e)?ig(null,e.contents,n,Object.freeze([e]))===xy&&(e.contents=null):ig(null,e,n,Object.freeze([]))}lb.BREAK=Nh;lb.SKIP=GHe;lb.REMOVE=xy;function ig(e,t,n,i){const r=ZHe(e,t,n,i);if(Pr(r)||Mr(r))return KHe(e,i,r),ig(e,r,n,i);if(typeof r!="symbol"){if(Rr(t)){i=Object.freeze(i.concat(t));for(let s=0;se.replace(/[!,[\]{}]/g,t=>JHe[t]);class fa{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},fa.defaultYaml,t),this.tags=Object.assign({},fa.defaultTags,n)}clone(){const t=new fa(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new fa(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:fa.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},fa.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:fa.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},fa.defaultTags),this.atNextDocument=!1);const i=t.trim().split(/[ \t]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;const[s,a]=i;return this.tags[s]=a,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[s]=i;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{const a=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,a),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const a=t.slice(2,-1);return a==="!"||a==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),a)}const[,i,r]=t.match(/^(.*!)([^!]*)$/s);r||n(`The ${t} tag has no suffix`);const s=this.tags[i];if(s)try{return s+decodeURIComponent(r)}catch(a){return n(String(a)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+eYe(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags);let r;if(t&&i.length>0&&Pr(t.contents)){const s={};lb(t.contents,(a,o)=>{Pr(o)&&o.tag&&(s[o.tag]=!0)}),r=Object.keys(s)}else r=[];for(const[s,a]of i)s==="!!"&&a==="tag:yaml.org,2002:"||(!t||r.some(o=>o.startsWith(a)))&&n.push(`%TAG ${s} ${a}`);return n.join(` -`)}}fa.defaultYaml={explicit:!1,version:"1.2"};fa.defaultTags={"!!":"tag:yaml.org,2002:"};function ple(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function mle(e){const t=new Set;return lb(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function gle(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function tYe(e,t){const n=[],i=new Map;let r=null;return{onAnchor:s=>{n.push(s),r??(r=mle(e));const a=gle(t,r);return r.add(a),a},setAnchors:()=>{for(const s of n){const a=i.get(s);if(typeof a=="object"&&a.anchor&&(Fi(a.node)||Rr(a.node)))a.node.anchor=a.anchor;else{const o=new Error("Failed to resolve repeated object (this should not happen)");throw o.source=s,o}}},sourceObjects:i}}function rg(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,s=i.length;ril(i,String(r),n));if(e&&typeof e.toJSON=="function"){if(!n||!hle(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=s=>{i.res=s,delete n.onCreate};const r=e.toJSON(t,n);return n.onCreate&&n.onCreate(r),r}return typeof e=="bigint"&&!(n!=null&&n.keep)?Number(e):e}class Q3{constructor(t){Object.defineProperty(this,sl,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:s}={}){if(!V1(t))throw new TypeError("A document argument is required");const a={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},o=il(this,"",a);if(typeof r=="function")for(const{count:c,res:u}of a.anchors.values())r(u,c);return typeof s=="function"?rg(s,{"":o},"",o):o}}let B3=class extends Q3{constructor(t){super($3),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if((n==null?void 0:n.maxAliasCount)===0)throw new ReferenceError("Alias resolution is disabled");let i;n!=null&&n.aliasResolveCache?i=n.aliasResolveCache:(i=[],lb(t,{Node:(s,a)=>{(ob(a)||hle(a))&&i.push(a)}}),n&&(n.aliasResolveCache=i));let r;for(const s of i){if(s===this)break;s.anchor===this.source&&(r=s)}return r}toJSON(t,n){if(!n)return{source:this.source};const{anchors:i,doc:r,maxAliasCount:s}=n,a=this.resolve(r,n);if(!a){const c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let o=i.get(a);if(o||(il(a,null,n),o=i.get(a)),(o==null?void 0:o.res)===void 0){const c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(s>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=oE(r,a,i)),o.count*o.aliasCount>s)){const c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return o.res}toString(t,n,i){const r=`*${this.source}`;if(t){if(ple(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${r} `}return r}};function oE(e,t,n){if(ob(t)){const i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Rr(t)){let i=0;for(const r of t.items){const s=oE(e,r,n);s>i&&(i=s)}return i}else if(Mr(t)){const i=oE(e,t.key,n),r=oE(e,t.value,n);return Math.max(i,r)}return 1}const ble=e=>!e||typeof e!="function"&&typeof e!="object";class cn extends Q3{constructor(t){super(Vc),this.value=t}toJSON(t,n){return n!=null&&n.keep?this.value:il(this.value,t,n)}toString(){return String(this.value)}}cn.BLOCK_FOLDED="BLOCK_FOLDED";cn.BLOCK_LITERAL="BLOCK_LITERAL";cn.PLAIN="PLAIN";cn.QUOTE_DOUBLE="QUOTE_DOUBLE";cn.QUOTE_SINGLE="QUOTE_SINGLE";const nYe="tag:yaml.org,2002:";function iYe(e,t,n){if(t){const i=n.filter(s=>s.tag===t),r=i.find(s=>!s.format)??i[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return n.find(i=>{var r;return((r=i.identify)==null?void 0:r.call(i,e))&&!i.format})}function Ax(e,t,n){var f,h,p;if(V1(e)&&(e=e.contents),Pr(e))return e;if(Mr(e)){const g=(h=(f=n.schema[Ef]).createNode)==null?void 0:h.call(f,n.schema,null,n);return g.items.push(e),g}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:r,onTagObj:s,schema:a,sourceObjects:o}=n;let c;if(i&&e&&typeof e=="object"){if(c=o.get(e),c)return c.anchor??(c.anchor=r(e)),new B3(c.anchor);c={anchor:null,node:null},o.set(e,c)}t!=null&&t.startsWith("!!")&&(t=nYe+t.slice(2));let u=iYe(e,t,a.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const g=new cn(e);return c&&(c.node=g),g}u=e instanceof Map?a[Ef]:Symbol.iterator in Object(e)?a[ab]:a[Ef]}s&&(s(u),delete n.onTagObj);const d=u!=null&&u.createNode?u.createNode(n.schema,e,n):typeof((p=u==null?void 0:u.nodeClass)==null?void 0:p.from)=="function"?u.nodeClass.from(n.schema,e,n):new cn(e);return t?d.tag=t:u.default||(d.tag=u.tag),c&&(c.node=d),d}function Gk(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){const s=t[r];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){const a=[];a[s]=i,i=a}else i=new Map([[s,i]])}return Ax(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const IO=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class Ole extends Q3{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(i=>Pr(i)||Mr(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(IO(t))this.add(n);else{const[i,...r]=t,s=this.get(i,!0);if(Rr(s))s.addIn(r,n);else if(s===void 0&&this.schema)this.set(i,Gk(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(t){const[n,...i]=t;if(i.length===0)return this.delete(n);const r=this.get(n,!0);if(Rr(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){const[i,...r]=t,s=this.get(i,!0);return r.length===0?!n&&Fi(s)?s.value:s:Rr(s)?s.getIn(r,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!Mr(n))return!1;const i=n.value;return i==null||t&&Fi(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){const[n,...i]=t;if(i.length===0)return this.has(n);const r=this.get(n,!0);return Rr(r)?r.hasIn(i):!1}setIn(t,n){const[i,...r]=t;if(r.length===0)this.set(i,n);else{const s=this.get(i,!0);if(Rr(s))s.setIn(r,n);else if(s===void 0&&this.schema)this.set(i,Gk(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}}const rYe=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Lu(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const zh=(e,t,n)=>e.endsWith(` +`)})]}):null]})}const $3=Symbol.for("yaml.alias"),wM=Symbol.for("yaml.document"),Ef=Symbol.for("yaml.map"),hle=Symbol.for("yaml.pair"),Vc=Symbol.for("yaml.scalar"),ab=Symbol.for("yaml.seq"),sl=Symbol.for("yaml.node.type"),ob=e=>!!e&&typeof e=="object"&&e[sl]===$3,V1=e=>!!e&&typeof e=="object"&&e[sl]===wM,X1=e=>!!e&&typeof e=="object"&&e[sl]===Ef,Mr=e=>!!e&&typeof e=="object"&&e[sl]===hle,Fi=e=>!!e&&typeof e=="object"&&e[sl]===Vc,q1=e=>!!e&&typeof e=="object"&&e[sl]===ab;function Rr(e){if(e&&typeof e=="object")switch(e[sl]){case Ef:case ab:return!0}return!1}function Pr(e){if(e&&typeof e=="object")switch(e[sl]){case $3:case Ef:case Vc:case ab:return!0}return!1}const ple=e=>(Fi(e)||Rr(e))&&!!e.anchor,Nh=Symbol("break visit"),WHe=Symbol("skip children"),xy=Symbol("remove node");function lb(e,t){const n=ZHe(t);V1(e)?ig(null,e.contents,n,Object.freeze([e]))===xy&&(e.contents=null):ig(null,e,n,Object.freeze([]))}lb.BREAK=Nh;lb.SKIP=WHe;lb.REMOVE=xy;function ig(e,t,n,i){const r=KHe(e,t,n,i);if(Pr(r)||Mr(r))return JHe(e,i,r),ig(e,r,n,i);if(typeof r!="symbol"){if(Rr(t)){i=Object.freeze(i.concat(t));for(let s=0;se.replace(/[!,[\]{}]/g,t=>eYe[t]);class fa{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},fa.defaultYaml,t),this.tags=Object.assign({},fa.defaultTags,n)}clone(){const t=new fa(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new fa(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:fa.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},fa.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:fa.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},fa.defaultTags),this.atNextDocument=!1);const i=t.trim().split(/[ \t]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;const[s,a]=i;return this.tags[s]=a,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[s]=i;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{const a=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,a),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const a=t.slice(2,-1);return a==="!"||a==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),a)}const[,i,r]=t.match(/^(.*!)([^!]*)$/s);r||n(`The ${t} tag has no suffix`);const s=this.tags[i];if(s)try{return s+decodeURIComponent(r)}catch(a){return n(String(a)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+tYe(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags);let r;if(t&&i.length>0&&Pr(t.contents)){const s={};lb(t.contents,(a,o)=>{Pr(o)&&o.tag&&(s[o.tag]=!0)}),r=Object.keys(s)}else r=[];for(const[s,a]of i)s==="!!"&&a==="tag:yaml.org,2002:"||(!t||r.some(o=>o.startsWith(a)))&&n.push(`%TAG ${s} ${a}`);return n.join(` +`)}}fa.defaultYaml={explicit:!1,version:"1.2"};fa.defaultTags={"!!":"tag:yaml.org,2002:"};function mle(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function gle(e){const t=new Set;return lb(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function ble(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function nYe(e,t){const n=[],i=new Map;let r=null;return{onAnchor:s=>{n.push(s),r??(r=gle(e));const a=ble(t,r);return r.add(a),a},setAnchors:()=>{for(const s of n){const a=i.get(s);if(typeof a=="object"&&a.anchor&&(Fi(a.node)||Rr(a.node)))a.node.anchor=a.anchor;else{const o=new Error("Failed to resolve repeated object (this should not happen)");throw o.source=s,o}}},sourceObjects:i}}function rg(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,s=i.length;ril(i,String(r),n));if(e&&typeof e.toJSON=="function"){if(!n||!ple(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=s=>{i.res=s,delete n.onCreate};const r=e.toJSON(t,n);return n.onCreate&&n.onCreate(r),r}return typeof e=="bigint"&&!(n!=null&&n.keep)?Number(e):e}class Q3{constructor(t){Object.defineProperty(this,sl,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:s}={}){if(!V1(t))throw new TypeError("A document argument is required");const a={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},o=il(this,"",a);if(typeof r=="function")for(const{count:c,res:u}of a.anchors.values())r(u,c);return typeof s=="function"?rg(s,{"":o},"",o):o}}let B3=class extends Q3{constructor(t){super($3),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if((n==null?void 0:n.maxAliasCount)===0)throw new ReferenceError("Alias resolution is disabled");let i;n!=null&&n.aliasResolveCache?i=n.aliasResolveCache:(i=[],lb(t,{Node:(s,a)=>{(ob(a)||ple(a))&&i.push(a)}}),n&&(n.aliasResolveCache=i));let r;for(const s of i){if(s===this)break;s.anchor===this.source&&(r=s)}return r}toJSON(t,n){if(!n)return{source:this.source};const{anchors:i,doc:r,maxAliasCount:s}=n,a=this.resolve(r,n);if(!a){const c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let o=i.get(a);if(o||(il(a,null,n),o=i.get(a)),(o==null?void 0:o.res)===void 0){const c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(s>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=oE(r,a,i)),o.count*o.aliasCount>s)){const c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return o.res}toString(t,n,i){const r=`*${this.source}`;if(t){if(mle(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${r} `}return r}};function oE(e,t,n){if(ob(t)){const i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Rr(t)){let i=0;for(const r of t.items){const s=oE(e,r,n);s>i&&(i=s)}return i}else if(Mr(t)){const i=oE(e,t.key,n),r=oE(e,t.value,n);return Math.max(i,r)}return 1}const Ole=e=>!e||typeof e!="function"&&typeof e!="object";class cn extends Q3{constructor(t){super(Vc),this.value=t}toJSON(t,n){return n!=null&&n.keep?this.value:il(this.value,t,n)}toString(){return String(this.value)}}cn.BLOCK_FOLDED="BLOCK_FOLDED";cn.BLOCK_LITERAL="BLOCK_LITERAL";cn.PLAIN="PLAIN";cn.QUOTE_DOUBLE="QUOTE_DOUBLE";cn.QUOTE_SINGLE="QUOTE_SINGLE";const iYe="tag:yaml.org,2002:";function rYe(e,t,n){if(t){const i=n.filter(s=>s.tag===t),r=i.find(s=>!s.format)??i[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return n.find(i=>{var r;return((r=i.identify)==null?void 0:r.call(i,e))&&!i.format})}function Ax(e,t,n){var f,h,p;if(V1(e)&&(e=e.contents),Pr(e))return e;if(Mr(e)){const g=(h=(f=n.schema[Ef]).createNode)==null?void 0:h.call(f,n.schema,null,n);return g.items.push(e),g}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:r,onTagObj:s,schema:a,sourceObjects:o}=n;let c;if(i&&e&&typeof e=="object"){if(c=o.get(e),c)return c.anchor??(c.anchor=r(e)),new B3(c.anchor);c={anchor:null,node:null},o.set(e,c)}t!=null&&t.startsWith("!!")&&(t=iYe+t.slice(2));let u=rYe(e,t,a.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const g=new cn(e);return c&&(c.node=g),g}u=e instanceof Map?a[Ef]:Symbol.iterator in Object(e)?a[ab]:a[Ef]}s&&(s(u),delete n.onTagObj);const d=u!=null&&u.createNode?u.createNode(n.schema,e,n):typeof((p=u==null?void 0:u.nodeClass)==null?void 0:p.from)=="function"?u.nodeClass.from(n.schema,e,n):new cn(e);return t?d.tag=t:u.default||(d.tag=u.tag),c&&(c.node=d),d}function Gk(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){const s=t[r];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){const a=[];a[s]=i,i=a}else i=new Map([[s,i]])}return Ax(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const IO=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class yle extends Q3{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(i=>Pr(i)||Mr(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(IO(t))this.add(n);else{const[i,...r]=t,s=this.get(i,!0);if(Rr(s))s.addIn(r,n);else if(s===void 0&&this.schema)this.set(i,Gk(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(t){const[n,...i]=t;if(i.length===0)return this.delete(n);const r=this.get(n,!0);if(Rr(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){const[i,...r]=t,s=this.get(i,!0);return r.length===0?!n&&Fi(s)?s.value:s:Rr(s)?s.getIn(r,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!Mr(n))return!1;const i=n.value;return i==null||t&&Fi(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){const[n,...i]=t;if(i.length===0)return this.has(n);const r=this.get(n,!0);return Rr(r)?r.hasIn(i):!1}setIn(t,n){const[i,...r]=t;if(r.length===0)this.set(i,n);else{const s=this.get(i,!0);if(Rr(s))s.setIn(r,n);else if(s===void 0&&this.schema)this.set(i,Gk(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}}const sYe=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Lu(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const zh=(e,t,n)=>e.endsWith(` `)?Lu(n,t):n.includes(` `)?` -`+Lu(n,t):(e.endsWith(" ")?"":" ")+n,yle="flow",SM="block",lE="quoted";function wA(e,t,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:s=20,onFold:a,onOverflow:o}={}){if(!r||r<0)return e;rr-Math.max(2,s)?u.push(0):f=r-i);let h,p,g=!1,b=-1,y=-1,O=-1;n===SM&&(b=hF(e,b,t.length),b!==-1&&(f=b+c));for(let x;x=e[b+=1];){if(n===lE&&x==="\\"){switch(y=b,e[b+1]){case"x":b+=3;break;case"u":b+=5;break;case"U":b+=9;break;default:b+=1}O=b}if(x===` +`+Lu(n,t):(e.endsWith(" ")?"":" ")+n,xle="flow",SM="block",lE="quoted";function wA(e,t,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:s=20,onFold:a,onOverflow:o}={}){if(!r||r<0)return e;rr-Math.max(2,s)?u.push(0):f=r-i);let h,p,g=!1,b=-1,y=-1,O=-1;n===SM&&(b=hF(e,b,t.length),b!==-1&&(f=b+c));for(let x;x=e[b+=1];){if(n===lE&&x==="\\"){switch(y=b,e[b+1]){case"x":b+=3;break;case"u":b+=5;break;case"U":b+=9;break;default:b+=1}O=b}if(x===` `)n===SM&&(b=hF(e,b,t.length)),f=b+t.length+c,h=void 0;else{if(x===" "&&p&&p!==" "&&p!==` `&&p!==" "){const w=e[b+1];w&&w!==" "&&w!==` `&&w!==" "&&(h=b)}if(b>=f)if(h)u.push(h),f=h+c,h=void 0;else if(n===lE){for(;p===" "||p===" ";)p=x,x=e[b+=1],g=!0;const w=b>O+1?b-2:y-1;if(d[w])return e;u.push(w),d[w]=!0,f=w+c,h=void 0}else g=!0}p=x}if(g&&o&&o(),u.length===0)return e;a&&a();let v=e.slice(0,u[0]);for(let x=0;x({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),EA=e=>/^(%|---|\.\.\.)/m.test(e);function sYe(e,t,n){if(!t||t<0)return!1;const i=t-n,r=e.length;if(r<=i)return!1;for(let s=0,a=0;s({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),EA=e=>/^(%|---|\.\.\.)/m.test(e);function aYe(e,t,n){if(!t||t<0)return!1;const i=t-n,r=e.length;if(r<=i)return!1;for(let s=0,a=0;si)return!0;if(a=s+1,r-a<=i)return!1}return!0}function vy(e,t){const n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;const{implicitKey:i}=t,r=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(EA(e)?" ":"");let a="",o=0;for(let c=0,u=n[c];u;u=n[++c])if(u===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(a+=n.slice(o,c)+"\\ ",c+=1,o=c,u="\\"),u==="\\")switch(n[c+1]){case"u":{a+=n.slice(o,c);const d=n.substr(c+2,4);switch(d){case"0000":a+="\\0";break;case"0007":a+="\\a";break;case"000b":a+="\\v";break;case"001b":a+="\\e";break;case"0085":a+="\\N";break;case"00a0":a+="\\_";break;case"2028":a+="\\L";break;case"2029":a+="\\P";break;default:d.substr(0,2)==="00"?a+="\\x"+d.substr(2):a+=n.substr(c,6)}c+=5,o=c+1}break;case"n":if(i||n[c+2]==='"'||n.length `;let f,h;for(h=n.length;h>0;--h){const E=n[h-1];if(E!==` `&&E!==" "&&E!==" ")break}let p=n.substring(h);const g=p.indexOf(` @@ -568,12 +568,12 @@ ${n}`)+"'";return t.implicitKey?i:wA(i,n,yle,SA(t,!1))}function sg(e,t){const{si `)O=y;else break}let v=n.substring(0,O{S=!0});const T=wA(`${v}${E}${p}`,u,SM,k);if(!S)return`>${w} ${u}${T}`}return n=n.replace(/\n+/g,`$&${u}`),`|${w} -${u}${v}${n}${p}`}function aYe(e,t,n,i){const{type:r,value:s}=e,{actualString:a,implicitKey:o,indent:c,indentStep:u,inFlow:d}=t;if(o&&s.includes(` +${u}${v}${n}${p}`}function oYe(e,t,n,i){const{type:r,value:s}=e,{actualString:a,implicitKey:o,indent:c,indentStep:u,inFlow:d}=t;if(o&&s.includes(` `)||d&&/[[\]{},]/.test(s))return sg(s,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return o||d||!s.includes(` `)?sg(s,t):cE(e,t,n,i);if(!o&&!d&&r!==cn.PLAIN&&s.includes(` `))return cE(e,t,n,i);if(EA(s)){if(c==="")return t.forceBlockIndent=!0,cE(e,t,n,i);if(o&&c===u)return sg(s,t)}const f=s.replace(/\n+/g,`$& -${c}`);if(a){const h=b=>{var y;return b.default&&b.tag!=="tag:yaml.org,2002:str"&&((y=b.test)==null?void 0:y.test(f))},{compat:p,tags:g}=t.doc.schema;if(g.some(h)||p!=null&&p.some(h))return sg(s,t)}return o?f:wA(f,c,yle,SA(t,!1))}function U3(e,t,n,i){const{implicitKey:r,inFlow:s}=t,a=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)});let{type:o}=e;o!==cn.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(a.value)&&(o=cn.QUOTE_DOUBLE);const c=d=>{switch(d){case cn.BLOCK_FOLDED:case cn.BLOCK_LITERAL:return r||s?sg(a.value,t):cE(a,t,n,i);case cn.QUOTE_DOUBLE:return vy(a.value,t);case cn.QUOTE_SINGLE:return EM(a.value,t);case cn.PLAIN:return aYe(a,t,n,i);default:return null}};let u=c(o);if(u===null){const{defaultKeyType:d,defaultStringType:f}=t.options,h=r&&d||f;if(u=c(h),u===null)throw new Error(`Unsupported default string type ${h}`)}return u}function xle(e,t){const n=Object.assign({blockQuote:!0,commentString:rYe,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:i,options:n}}function oYe(e,t){var r;if(t.tag){const s=e.filter(a=>a.tag===t.tag);if(s.length>0)return s.find(a=>a.format===t.format)??s[0]}let n,i;if(Fi(t)){i=t.value;let s=e.filter(a=>{var o;return(o=a.identify)==null?void 0:o.call(a,i)});if(s.length>1){const a=s.filter(o=>o.test);a.length>0&&(s=a)}n=s.find(a=>a.format===t.format)??s.find(a=>!a.format)}else i=t,n=e.find(s=>s.nodeClass&&i instanceof s.nodeClass);if(!n){const s=((r=i==null?void 0:i.constructor)==null?void 0:r.name)??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${s} value`)}return n}function lYe(e,t,{anchors:n,doc:i}){if(!i.directives)return"";const r=[],s=(Fi(e)||Rr(e))&&e.anchor;s&&ple(s)&&(n.add(s),r.push(`&${s}`));const a=e.tag??(t.default?null:t.tag);return a&&r.push(i.directives.tagString(a)),r.join(" ")}function g0(e,t,n,i){var c;if(Mr(e))return e.toString(t,n,i);if(ob(e)){if(t.doc.directives)return e.toString(t);if((c=t.resolvedAliases)!=null&&c.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let r;const s=Pr(e)?e:t.doc.createNode(e,{onTagObj:u=>r=u});r??(r=oYe(t.doc.schema.tags,s));const a=lYe(s,r,t);a.length>0&&(t.indentAtStart=(t.indentAtStart??0)+a.length+1);const o=typeof r.stringify=="function"?r.stringify(s,t,n,i):Fi(s)?U3(s,t,n,i):s.toString(t,n,i);return a?Fi(s)||o[0]==="{"||o[0]==="["?`${a} ${o}`:`${a} -${t.indent}${o}`:o}function cYe({key:e,value:t},n,i,r){const{allNullValues:s,doc:a,indent:o,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:f}}=n;let h=Pr(e)&&e.comment||null;if(f){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(Rr(e)||!Pr(e)&&typeof e=="object"){const k="With simple keys, collection cannot be used as a key value";throw new Error(k)}}let p=!f&&(!e||h&&t==null&&!n.inFlow||Rr(e)||(Fi(e)?e.type===cn.BLOCK_FOLDED||e.type===cn.BLOCK_LITERAL:typeof e=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(f||!s),indent:o+c});let g=!1,b=!1,y=g0(e,n,()=>g=!0,()=>b=!0);if(!p&&!n.inFlow&&y.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(s||t==null)return g&&i&&i(),y===""?"?":p?`? ${y}`:y}else if(s&&!f||t==null&&p)return y=`? ${y}`,h&&!g?y+=zh(y,n.indent,u(h)):b&&r&&r(),y;g&&(h=null),p?(h&&(y+=zh(y,n.indent,u(h))),y=`? ${y} +${c}`);if(a){const h=b=>{var y;return b.default&&b.tag!=="tag:yaml.org,2002:str"&&((y=b.test)==null?void 0:y.test(f))},{compat:p,tags:g}=t.doc.schema;if(g.some(h)||p!=null&&p.some(h))return sg(s,t)}return o?f:wA(f,c,xle,SA(t,!1))}function U3(e,t,n,i){const{implicitKey:r,inFlow:s}=t,a=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)});let{type:o}=e;o!==cn.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(a.value)&&(o=cn.QUOTE_DOUBLE);const c=d=>{switch(d){case cn.BLOCK_FOLDED:case cn.BLOCK_LITERAL:return r||s?sg(a.value,t):cE(a,t,n,i);case cn.QUOTE_DOUBLE:return vy(a.value,t);case cn.QUOTE_SINGLE:return EM(a.value,t);case cn.PLAIN:return oYe(a,t,n,i);default:return null}};let u=c(o);if(u===null){const{defaultKeyType:d,defaultStringType:f}=t.options,h=r&&d||f;if(u=c(h),u===null)throw new Error(`Unsupported default string type ${h}`)}return u}function vle(e,t){const n=Object.assign({blockQuote:!0,commentString:sYe,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:i,options:n}}function lYe(e,t){var r;if(t.tag){const s=e.filter(a=>a.tag===t.tag);if(s.length>0)return s.find(a=>a.format===t.format)??s[0]}let n,i;if(Fi(t)){i=t.value;let s=e.filter(a=>{var o;return(o=a.identify)==null?void 0:o.call(a,i)});if(s.length>1){const a=s.filter(o=>o.test);a.length>0&&(s=a)}n=s.find(a=>a.format===t.format)??s.find(a=>!a.format)}else i=t,n=e.find(s=>s.nodeClass&&i instanceof s.nodeClass);if(!n){const s=((r=i==null?void 0:i.constructor)==null?void 0:r.name)??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${s} value`)}return n}function cYe(e,t,{anchors:n,doc:i}){if(!i.directives)return"";const r=[],s=(Fi(e)||Rr(e))&&e.anchor;s&&mle(s)&&(n.add(s),r.push(`&${s}`));const a=e.tag??(t.default?null:t.tag);return a&&r.push(i.directives.tagString(a)),r.join(" ")}function g0(e,t,n,i){var c;if(Mr(e))return e.toString(t,n,i);if(ob(e)){if(t.doc.directives)return e.toString(t);if((c=t.resolvedAliases)!=null&&c.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let r;const s=Pr(e)?e:t.doc.createNode(e,{onTagObj:u=>r=u});r??(r=lYe(t.doc.schema.tags,s));const a=cYe(s,r,t);a.length>0&&(t.indentAtStart=(t.indentAtStart??0)+a.length+1);const o=typeof r.stringify=="function"?r.stringify(s,t,n,i):Fi(s)?U3(s,t,n,i):s.toString(t,n,i);return a?Fi(s)||o[0]==="{"||o[0]==="["?`${a} ${o}`:`${a} +${t.indent}${o}`:o}function uYe({key:e,value:t},n,i,r){const{allNullValues:s,doc:a,indent:o,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:f}}=n;let h=Pr(e)&&e.comment||null;if(f){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(Rr(e)||!Pr(e)&&typeof e=="object"){const k="With simple keys, collection cannot be used as a key value";throw new Error(k)}}let p=!f&&(!e||h&&t==null&&!n.inFlow||Rr(e)||(Fi(e)?e.type===cn.BLOCK_FOLDED||e.type===cn.BLOCK_LITERAL:typeof e=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(f||!s),indent:o+c});let g=!1,b=!1,y=g0(e,n,()=>g=!0,()=>b=!0);if(!p&&!n.inFlow&&y.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(s||t==null)return g&&i&&i(),y===""?"?":p?`? ${y}`:y}else if(s&&!f||t==null&&p)return y=`? ${y}`,h&&!g?y+=zh(y,n.indent,u(h)):b&&r&&r(),y;g&&(h=null),p?(h&&(y+=zh(y,n.indent,u(h))),y=`? ${y} ${o}:`):(y=`${y}:`,h&&(y+=zh(y,n.indent,u(h))));let O,v,x;Pr(t)?(O=!!t.spaceBefore,v=t.commentBefore,x=t.comment):(O=!1,v=null,x=null,t&&typeof t=="object"&&(t=a.createNode(t))),n.implicitKey=!1,!p&&!h&&Fi(t)&&(n.indentAtStart=y.length+1),b=!1,!d&&c.length>=2&&!n.inFlow&&!p&&q1(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let w=!1;const E=g0(t,n,()=>w=!0,()=>b=!0);let S=" ";if(h||O||v){if(S=O?` `:"",v){const k=u(v);S+=` ${Lu(k,n.indent)}`}E===""&&!n.inFlow?S===` @@ -583,32 +583,32 @@ ${Lu(k,n.indent)}`}E===""&&!n.inFlow?S===` ${n.indent}`}else if(!p&&Rr(t)){const k=E[0],T=E.indexOf(` `),A=T!==-1,N=n.inFlow??t.flow??t.items.length===0;if(A||!N){let C=!1;if(A&&(k==="&"||k==="!")){let M=E.indexOf(" ");k==="&"&&M!==-1&&Me===Lw||typeof e=="symbol"&&e.description===Lw,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new cn(Symbol(Lw)),{addToJSMap:wle}),stringify:()=>Lw},uYe=(e,t)=>(qu.identify(t)||Fi(t)&&(!t.type||t.type===cn.PLAIN)&&qu.identify(t.value))&&(e==null?void 0:e.doc.schema.tags.some(n=>n.tag===qu.tag&&n.default));function wle(e,t,n){const i=Sle(e,n);if(q1(i))for(const r of i.items)VC(e,t,r);else if(Array.isArray(i))for(const r of i)VC(e,t,r);else VC(e,t,i)}function VC(e,t,n){const i=Sle(e,n);if(!X1(i))throw new Error("Merge sources must be maps or map aliases");const r=i.toJSON(null,e,Map);for(const[s,a]of r)t instanceof Map?t.has(s)||t.set(s,a):t instanceof Set?t.add(s):Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{value:a,writable:!0,enumerable:!0,configurable:!0});return t}function Sle(e,t){return e&&ob(t)?t.resolve(e.doc,e):t}function Ele(e,t,{key:n,value:i}){if(Pr(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(uYe(e,n))wle(e,t,i);else{const r=il(n,"",e);if(t instanceof Map)t.set(r,il(i,r,e));else if(t instanceof Set)t.add(r);else{const s=dYe(n,r,e),a=il(i,s,e);s in t?Object.defineProperty(t,s,{value:a,writable:!0,enumerable:!0,configurable:!0}):t[s]=a}}return t}function dYe(e,t,n){if(t===null)return"";if(typeof t!="object")return String(t);if(Pr(e)&&(n!=null&&n.doc)){const i=xle(n.doc,{});i.anchors=new Set;for(const s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;const r=e.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);s.length>40&&(s=s.substring(0,36)+'..."'),vle(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function z3(e,t,n){const i=Ax(e,void 0,n),r=Ax(t,void 0,n);return new Oa(i,r)}class Oa{constructor(t,n=null){Object.defineProperty(this,sl,{value:fle}),this.key=t,this.value=n}clone(t){let{key:n,value:i}=this;return Pr(n)&&(n=n.clone(t)),Pr(i)&&(i=i.clone(t)),new Oa(n,i)}toJSON(t,n){const i=n!=null&&n.mapAsMap?new Map:{};return Ele(n,i,this)}toString(t,n,i){return t!=null&&t.doc?cYe(this,t,n,i):JSON.stringify(this)}}function kle(e,t,n){return(t.inFlow??e.flow?hYe:fYe)(e,t,n)}function fYe({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:a,onComment:o}){const{indent:c,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null});let f=!1;const h=[];for(let g=0;gy=null,()=>f=!0);y&&(O+=zh(O,s,u(y))),f&&y&&(f=!1),h.push(i+O)}let p;if(h.length===0)p=r.start+r.end;else{p=h[0];for(let g=1;ge===Lw||typeof e=="symbol"&&e.description===Lw,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new cn(Symbol(Lw)),{addToJSMap:Sle}),stringify:()=>Lw},dYe=(e,t)=>(qu.identify(t)||Fi(t)&&(!t.type||t.type===cn.PLAIN)&&qu.identify(t.value))&&(e==null?void 0:e.doc.schema.tags.some(n=>n.tag===qu.tag&&n.default));function Sle(e,t,n){const i=Ele(e,n);if(q1(i))for(const r of i.items)VC(e,t,r);else if(Array.isArray(i))for(const r of i)VC(e,t,r);else VC(e,t,i)}function VC(e,t,n){const i=Ele(e,n);if(!X1(i))throw new Error("Merge sources must be maps or map aliases");const r=i.toJSON(null,e,Map);for(const[s,a]of r)t instanceof Map?t.has(s)||t.set(s,a):t instanceof Set?t.add(s):Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{value:a,writable:!0,enumerable:!0,configurable:!0});return t}function Ele(e,t){return e&&ob(t)?t.resolve(e.doc,e):t}function kle(e,t,{key:n,value:i}){if(Pr(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(dYe(e,n))Sle(e,t,i);else{const r=il(n,"",e);if(t instanceof Map)t.set(r,il(i,r,e));else if(t instanceof Set)t.add(r);else{const s=fYe(n,r,e),a=il(i,s,e);s in t?Object.defineProperty(t,s,{value:a,writable:!0,enumerable:!0,configurable:!0}):t[s]=a}}return t}function fYe(e,t,n){if(t===null)return"";if(typeof t!="object")return String(t);if(Pr(e)&&(n!=null&&n.doc)){const i=vle(n.doc,{});i.anchors=new Set;for(const s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;const r=e.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);s.length>40&&(s=s.substring(0,36)+'..."'),wle(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function z3(e,t,n){const i=Ax(e,void 0,n),r=Ax(t,void 0,n);return new Oa(i,r)}class Oa{constructor(t,n=null){Object.defineProperty(this,sl,{value:hle}),this.key=t,this.value=n}clone(t){let{key:n,value:i}=this;return Pr(n)&&(n=n.clone(t)),Pr(i)&&(i=i.clone(t)),new Oa(n,i)}toJSON(t,n){const i=n!=null&&n.mapAsMap?new Map:{};return kle(n,i,this)}toString(t,n,i){return t!=null&&t.doc?uYe(this,t,n,i):JSON.stringify(this)}}function Tle(e,t,n){return(t.inFlow??e.flow?pYe:hYe)(e,t,n)}function hYe({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:a,onComment:o}){const{indent:c,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null});let f=!1;const h=[];for(let g=0;gy=null,()=>f=!0);y&&(O+=zh(O,s,u(y))),f&&y&&(f=!1),h.push(i+O)}let p;if(h.length===0)p=r.start+r.end;else{p=h[0];for(let g=1;gy=null);u||(u=f.length>d||O.includes(` +`+Lu(u(e),c),o&&o()):f&&a&&a(),p}function pYe({items:e},t,{flowChars:n,itemIndent:i}){const{indent:r,indentStep:s,flowCollectionPadding:a,options:{commentString:o}}=t;i+=s;const c=Object.assign({},t,{indent:i,inFlow:!0,type:null});let u=!1,d=0;const f=[];for(let g=0;gy=null);u||(u=f.length>d||O.includes(` `)),g0&&(u||(u=f.reduce((v,x)=>v+x.length+2,2)+(O.length+2)>t.options.lineWidth)),u&&(O+=",")),y&&(O+=zh(O,i,o(y))),f.push(O),d=f.length}const{start:h,end:p}=n;if(f.length===0)return h+p;if(!u){const g=f.reduce((b,y)=>b+y.length+2,2);u=t.options.lineWidth>0&&g>t.options.lineWidth}if(u){let g=h;for(const b of f)g+=b?` ${s}${r}${b}`:` `;return`${g} -${r}${p}`}else return`${h}${a}${f.join(" ")}${a}${p}`}function Wk({indent:e,options:{commentString:t}},n,i,r){if(i&&r&&(i=i.replace(/^\n+/,"")),i){const s=Lu(t(i),e);n.push(s.trimStart())}}function Fh(e,t){const n=Fi(t)?t.value:t;for(const i of e)if(Mr(i)&&(i.key===t||i.key===n||Fi(i.key)&&i.key.value===n))return i}class qo extends Ole{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ef,t),this.items=[]}static from(t,n,i){const{keepUndefined:r,replacer:s}=i,a=new this(t),o=(c,u)=>{if(typeof s=="function")u=s.call(n,c,u);else if(Array.isArray(s)&&!s.includes(c))return;(u!==void 0||r)&&a.items.push(z3(c,u,i))};if(n instanceof Map)for(const[c,u]of n)o(c,u);else if(n&&typeof n=="object")for(const c of Object.keys(n))o(c,n[c]);return typeof t.sortMapEntries=="function"&&a.items.sort(t.sortMapEntries),a}add(t,n){var a;let i;Mr(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Oa(t,t==null?void 0:t.value):i=new Oa(t.key,t.value);const r=Fh(this.items,i.key),s=(a=this.schema)==null?void 0:a.sortMapEntries;if(r){if(!n)throw new Error(`Key ${i.key} already set`);Fi(r.value)&&ble(i.value)?r.value.value=i.value:r.value=i.value}else if(s){const o=this.items.findIndex(c=>s(i,c)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){const n=Fh(this.items,t);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(t,n){const i=Fh(this.items,t),r=i==null?void 0:i.value;return(!n&&Fi(r)?r.value:r)??void 0}has(t){return!!Fh(this.items,t)}set(t,n){this.add(new Oa(t,n),!0)}toJSON(t,n,i){const r=i?new i:n!=null&&n.mapAsMap?new Map:{};n!=null&&n.onCreate&&n.onCreate(r);for(const s of this.items)Ele(n,r,s);return r}toString(t,n,i){if(!t)return JSON.stringify(this);for(const r of this.items)if(!Mr(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),kle(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:n})}}const cb={collection:"map",default:!0,nodeClass:qo,tag:"tag:yaml.org,2002:map",resolve(e,t){return X1(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,n)=>qo.from(e,t,n)};class Ep extends Ole{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(ab,t),this.items=[]}add(t){this.items.push(t)}delete(t){const n=Dw(t);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(t,n){const i=Dw(t);if(typeof i!="number")return;const r=this.items[i];return!n&&Fi(r)?r.value:r}has(t){const n=Dw(t);return typeof n=="number"&&n=0?t:null}const ub={collection:"seq",default:!0,nodeClass:Ep,tag:"tag:yaml.org,2002:seq",resolve(e,t){return q1(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,n)=>Ep.from(e,t,n)},kA={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,n,i){return t=Object.assign({actualString:!0},t),U3(e,t,n,i)}},TA={identify:e=>e==null,createNode:()=>new cn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new cn(null),stringify:({source:e},t)=>typeof e=="string"&&TA.test.test(e)?e:t.options.nullStr},F3={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new cn(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&F3.test.test(e)){const i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};function Hl({format:e,minFractionDigits:t,tag:n,value:i}){if(typeof i=="bigint")return String(i);const r=typeof i=="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let a=s.indexOf(".");a<0&&(a=s.length,s+=".");let o=t-(s.length-a-1);for(;o-- >0;)s+="0"}return s}const Tle={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Hl},_le={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():Hl(e)}},Ale={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new cn(parseFloat(e)),n=e.indexOf(".");return n!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-n-1),t},stringify:Hl},_A=e=>typeof e=="bigint"||Number.isInteger(e),V3=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Nle(e,t,n){const{value:i}=e;return _A(i)&&i>=0?n+i.toString(t):Hl(e)}const Cle={identify:e=>_A(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>V3(e,2,8,n),stringify:e=>Nle(e,8,"0o")},jle={identify:_A,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>V3(e,0,10,n),stringify:Hl},Rle={identify:e=>_A(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>V3(e,2,16,n),stringify:e=>Nle(e,16,"0x")},pYe=[cb,ub,kA,TA,F3,Cle,jle,Rle,Tle,_le,Ale];function pF(e){return typeof e=="bigint"||Number.isInteger(e)}const $w=({value:e})=>JSON.stringify(e),mYe=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:$w},{identify:e=>e==null,createNode:()=>new cn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:$w},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:$w},{identify:pF,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>pF(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:$w}],gYe={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},bYe=[cb,ub].concat(mYe,gYe),X3={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){const n=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r1&&t("Each pair must have its own sequence indicator");const r=i.items[0]||new Oa(new cn(null));if(i.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${i.commentBefore} +${r}${p}`}else return`${h}${a}${f.join(" ")}${a}${p}`}function Wk({indent:e,options:{commentString:t}},n,i,r){if(i&&r&&(i=i.replace(/^\n+/,"")),i){const s=Lu(t(i),e);n.push(s.trimStart())}}function Fh(e,t){const n=Fi(t)?t.value:t;for(const i of e)if(Mr(i)&&(i.key===t||i.key===n||Fi(i.key)&&i.key.value===n))return i}class qo extends yle{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ef,t),this.items=[]}static from(t,n,i){const{keepUndefined:r,replacer:s}=i,a=new this(t),o=(c,u)=>{if(typeof s=="function")u=s.call(n,c,u);else if(Array.isArray(s)&&!s.includes(c))return;(u!==void 0||r)&&a.items.push(z3(c,u,i))};if(n instanceof Map)for(const[c,u]of n)o(c,u);else if(n&&typeof n=="object")for(const c of Object.keys(n))o(c,n[c]);return typeof t.sortMapEntries=="function"&&a.items.sort(t.sortMapEntries),a}add(t,n){var a;let i;Mr(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Oa(t,t==null?void 0:t.value):i=new Oa(t.key,t.value);const r=Fh(this.items,i.key),s=(a=this.schema)==null?void 0:a.sortMapEntries;if(r){if(!n)throw new Error(`Key ${i.key} already set`);Fi(r.value)&&Ole(i.value)?r.value.value=i.value:r.value=i.value}else if(s){const o=this.items.findIndex(c=>s(i,c)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){const n=Fh(this.items,t);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(t,n){const i=Fh(this.items,t),r=i==null?void 0:i.value;return(!n&&Fi(r)?r.value:r)??void 0}has(t){return!!Fh(this.items,t)}set(t,n){this.add(new Oa(t,n),!0)}toJSON(t,n,i){const r=i?new i:n!=null&&n.mapAsMap?new Map:{};n!=null&&n.onCreate&&n.onCreate(r);for(const s of this.items)kle(n,r,s);return r}toString(t,n,i){if(!t)return JSON.stringify(this);for(const r of this.items)if(!Mr(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Tle(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:n})}}const cb={collection:"map",default:!0,nodeClass:qo,tag:"tag:yaml.org,2002:map",resolve(e,t){return X1(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,n)=>qo.from(e,t,n)};class Ep extends yle{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(ab,t),this.items=[]}add(t){this.items.push(t)}delete(t){const n=Dw(t);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(t,n){const i=Dw(t);if(typeof i!="number")return;const r=this.items[i];return!n&&Fi(r)?r.value:r}has(t){const n=Dw(t);return typeof n=="number"&&n=0?t:null}const ub={collection:"seq",default:!0,nodeClass:Ep,tag:"tag:yaml.org,2002:seq",resolve(e,t){return q1(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,n)=>Ep.from(e,t,n)},kA={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,n,i){return t=Object.assign({actualString:!0},t),U3(e,t,n,i)}},TA={identify:e=>e==null,createNode:()=>new cn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new cn(null),stringify:({source:e},t)=>typeof e=="string"&&TA.test.test(e)?e:t.options.nullStr},F3={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new cn(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&F3.test.test(e)){const i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};function Hl({format:e,minFractionDigits:t,tag:n,value:i}){if(typeof i=="bigint")return String(i);const r=typeof i=="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let a=s.indexOf(".");a<0&&(a=s.length,s+=".");let o=t-(s.length-a-1);for(;o-- >0;)s+="0"}return s}const _le={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Hl},Ale={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():Hl(e)}},Nle={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new cn(parseFloat(e)),n=e.indexOf(".");return n!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-n-1),t},stringify:Hl},_A=e=>typeof e=="bigint"||Number.isInteger(e),V3=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Cle(e,t,n){const{value:i}=e;return _A(i)&&i>=0?n+i.toString(t):Hl(e)}const jle={identify:e=>_A(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>V3(e,2,8,n),stringify:e=>Cle(e,8,"0o")},Rle={identify:_A,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>V3(e,0,10,n),stringify:Hl},Ile={identify:e=>_A(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>V3(e,2,16,n),stringify:e=>Cle(e,16,"0x")},mYe=[cb,ub,kA,TA,F3,jle,Rle,Ile,_le,Ale,Nle];function pF(e){return typeof e=="bigint"||Number.isInteger(e)}const $w=({value:e})=>JSON.stringify(e),gYe=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:$w},{identify:e=>e==null,createNode:()=>new cn(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:$w},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:$w},{identify:pF,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>pF(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:$w}],bYe={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},OYe=[cb,ub].concat(gYe,bYe),X3={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){const n=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r1&&t("Each pair must have its own sequence indicator");const r=i.items[0]||new Oa(new cn(null));if(i.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${i.commentBefore} ${r.key.commentBefore}`:i.commentBefore),i.comment){const s=r.value??r.key;s.comment=s.comment?`${i.comment} -${s.comment}`:i.comment}i=r}e.items[n]=Mr(i)?i:new Oa(i)}}else t("Expected a sequence for this tag");return e}function Ple(e,t,n){const{replacer:i}=n,r=new Ep(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let a of t){typeof i=="function"&&(a=i.call(t,String(s++),a));let o,c;if(Array.isArray(a))if(a.length===2)o=a[0],c=a[1];else throw new TypeError(`Expected [key, value] tuple: ${a}`);else if(a&&a instanceof Object){const u=Object.keys(a);if(u.length===1)o=u[0],c=a[o];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else o=a;r.items.push(z3(o,c,n))}return r}const q3={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ile,createNode:Ple};class kg extends Ep{constructor(){super(),this.add=qo.prototype.add.bind(this),this.delete=qo.prototype.delete.bind(this),this.get=qo.prototype.get.bind(this),this.has=qo.prototype.has.bind(this),this.set=qo.prototype.set.bind(this),this.tag=kg.tag}toJSON(t,n){if(!n)return super.toJSON(t);const i=new Map;n!=null&&n.onCreate&&n.onCreate(i);for(const r of this.items){let s,a;if(Mr(r)?(s=il(r.key,"",n),a=il(r.value,s,n)):s=il(r,"",n),i.has(s))throw new Error("Ordered maps must not include duplicate keys");i.set(s,a)}return i}static from(t,n,i){const r=Ple(t,n,i),s=new this;return s.items=r.items,s}}kg.tag="tag:yaml.org,2002:omap";const H3={collection:"seq",identify:e=>e instanceof Map,nodeClass:kg,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const n=Ile(e,t),i=[];for(const{key:r}of n.items)Fi(r)&&(i.includes(r.value)?t(`Ordered maps must not include duplicate keys: ${r.value}`):i.push(r.value));return Object.assign(new kg,n)},createNode:(e,t,n)=>kg.from(e,t,n)};function Mle({value:e,source:t},n){return t&&(e?Lle:Dle).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}const Lle={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new cn(!0),stringify:Mle},Dle={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new cn(!1),stringify:Mle},OYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Hl},yYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():Hl(e)}},xYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new cn(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){const i=e.substring(n+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Hl},H1=e=>typeof e=="bigint"||Number.isInteger(e);function AA(e,t,n,{intAsBigInt:i}){const r=e[0];if((r==="-"||r==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}const a=BigInt(e);return r==="-"?BigInt(-1)*a:a}const s=parseInt(e,n);return r==="-"?-1*s:s}function Y3(e,t,n){const{value:i}=e;if(H1(i)){const r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Hl(e)}const vYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>AA(e,2,2,n),stringify:e=>Y3(e,2,"0b")},wYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>AA(e,1,8,n),stringify:e=>Y3(e,8,"0")},SYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>AA(e,0,10,n),stringify:Hl},EYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>AA(e,2,16,n),stringify:e=>Y3(e,16,"0x")};class Tg extends qo{constructor(t){super(t),this.tag=Tg.tag}add(t){let n;Mr(t)?n=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?n=new Oa(t.key,null):n=new Oa(t,null),Fh(this.items,n.key)||this.items.push(n)}get(t,n){const i=Fh(this.items,t);return!n&&Mr(i)?Fi(i.key)?i.key.value:i.key:i}set(t,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);const i=Fh(this.items,t);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new Oa(t))}toJSON(t,n){return super.toJSON(t,n,Set)}toString(t,n,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),n,i);throw new Error("Set items must all have null values")}static from(t,n,i){const{replacer:r}=i,s=new this(t);if(n&&Symbol.iterator in Object(n))for(let a of n)typeof r=="function"&&(a=r.call(n,a,a)),s.items.push(z3(a,null,i));return s}}Tg.tag="tag:yaml.org,2002:set";const G3={collection:"map",identify:e=>e instanceof Set,nodeClass:Tg,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Tg.from(e,t,n),resolve(e,t){if(X1(e)){if(e.hasAllNullValues(!0))return Object.assign(new Tg,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function W3(e,t){const n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=a=>t?BigInt(a):Number(a),s=i.replace(/_/g,"").split(":").reduce((a,o)=>a*r(60)+r(o),r(0));return n==="-"?r(-1)*s:s}function $le(e){let{value:t}=e,n=a=>a;if(typeof t=="bigint")n=a=>BigInt(a);else if(isNaN(t)||!isFinite(t))return Hl(e);let i="";t<0&&(i="-",t*=n(-1));const r=n(60),s=[t%r];return t<60?s.unshift(0):(t=(t-s[0])/r,s.unshift(t%r),t>=60&&(t=(t-s[0])/r,s.unshift(t))),i+s.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Qle={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>W3(e,n),stringify:$le},Ble={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>W3(e,!1),stringify:$le},NA={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(NA.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,n,i,r,s,a,o]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0;let u=Date.UTC(n,i-1,r,s||0,a||0,o||0,c);const d=t[8];if(d&&d!=="Z"){let f=W3(d,!1);Math.abs(f)<30&&(f*=60),u-=6e4*f}return new Date(u)},stringify:({value:e})=>(e==null?void 0:e.toISOString().replace(/(T00:00:00)?\.000Z$/,""))??""},mF=[cb,ub,kA,TA,Lle,Dle,vYe,wYe,SYe,EYe,OYe,yYe,xYe,X3,qu,H3,q3,G3,Qle,Ble,NA],gF=new Map([["core",pYe],["failsafe",[cb,ub,kA]],["json",bYe],["yaml11",mF],["yaml-1.1",mF]]),bF={binary:X3,bool:F3,float:Ale,floatExp:_le,floatNaN:Tle,floatTime:Ble,int:jle,intHex:Rle,intOct:Cle,intTime:Qle,map:cb,merge:qu,null:TA,omap:H3,pairs:q3,seq:ub,set:G3,timestamp:NA},kYe={"tag:yaml.org,2002:binary":X3,"tag:yaml.org,2002:merge":qu,"tag:yaml.org,2002:omap":H3,"tag:yaml.org,2002:pairs":q3,"tag:yaml.org,2002:set":G3,"tag:yaml.org,2002:timestamp":NA};function XC(e,t,n){const i=gF.get(t);if(i&&!e)return n&&!i.includes(qu)?i.concat(qu):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{const s=Array.from(gF.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(const s of e)r=r.concat(s);else typeof e=="function"&&(r=e(r.slice()));return n&&(r=r.concat(qu)),r.reduce((s,a)=>{const o=typeof a=="string"?bF[a]:a;if(!o){const c=JSON.stringify(a),u=Object.keys(bF).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return s.includes(o)||s.push(o),s},[])}const TYe=(e,t)=>e.keyt.key?1:0;let _Ye=class Ule{constructor({compat:t,customTags:n,merge:i,resolveKnownTags:r,schema:s,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(t)?XC(t,"compat"):t?XC(null,t):null,this.name=typeof s=="string"&&s||"core",this.knownTags=r?kYe:{},this.tags=XC(n,this.name,i),this.toStringOptions=o??null,Object.defineProperty(this,Ef,{value:cb}),Object.defineProperty(this,Vc,{value:kA}),Object.defineProperty(this,ab,{value:ub}),this.sortMapEntries=typeof a=="function"?a:a===!0?TYe:null}clone(){const t=Object.create(Ule.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function AYe(e,t){var c;const n=[];let i=t.directives===!0;if(t.directives!==!1&&e.directives){const u=e.directives.toString(e);u?(n.push(u),i=!0):e.directives.docStart&&(i=!0)}i&&n.push("---");const r=xle(e,t),{commentString:s}=r.options;if(e.commentBefore){n.length!==1&&n.unshift("");const u=s(e.commentBefore);n.unshift(Lu(u,""))}let a=!1,o=null;if(e.contents){if(Pr(e.contents)){if(e.contents.spaceBefore&&i&&n.push(""),e.contents.commentBefore){const f=s(e.contents.commentBefore);n.push(Lu(f,""))}r.forceBlockIndent=!!e.comment,o=e.contents.comment}const u=o?void 0:()=>a=!0;let d=g0(e.contents,r,()=>o=null,u);o&&(d+=zh(d,"",s(o))),(d[0]==="|"||d[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${d}`:n.push(d)}else n.push(g0(e.contents,r));if((c=e.directives)!=null&&c.docEnd)if(e.comment){const u=s(e.comment);u.includes(` +${s.comment}`:i.comment}i=r}e.items[n]=Mr(i)?i:new Oa(i)}}else t("Expected a sequence for this tag");return e}function Mle(e,t,n){const{replacer:i}=n,r=new Ep(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let a of t){typeof i=="function"&&(a=i.call(t,String(s++),a));let o,c;if(Array.isArray(a))if(a.length===2)o=a[0],c=a[1];else throw new TypeError(`Expected [key, value] tuple: ${a}`);else if(a&&a instanceof Object){const u=Object.keys(a);if(u.length===1)o=u[0],c=a[o];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else o=a;r.items.push(z3(o,c,n))}return r}const q3={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ple,createNode:Mle};class kg extends Ep{constructor(){super(),this.add=qo.prototype.add.bind(this),this.delete=qo.prototype.delete.bind(this),this.get=qo.prototype.get.bind(this),this.has=qo.prototype.has.bind(this),this.set=qo.prototype.set.bind(this),this.tag=kg.tag}toJSON(t,n){if(!n)return super.toJSON(t);const i=new Map;n!=null&&n.onCreate&&n.onCreate(i);for(const r of this.items){let s,a;if(Mr(r)?(s=il(r.key,"",n),a=il(r.value,s,n)):s=il(r,"",n),i.has(s))throw new Error("Ordered maps must not include duplicate keys");i.set(s,a)}return i}static from(t,n,i){const r=Mle(t,n,i),s=new this;return s.items=r.items,s}}kg.tag="tag:yaml.org,2002:omap";const H3={collection:"seq",identify:e=>e instanceof Map,nodeClass:kg,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const n=Ple(e,t),i=[];for(const{key:r}of n.items)Fi(r)&&(i.includes(r.value)?t(`Ordered maps must not include duplicate keys: ${r.value}`):i.push(r.value));return Object.assign(new kg,n)},createNode:(e,t,n)=>kg.from(e,t,n)};function Lle({value:e,source:t},n){return t&&(e?Dle:$le).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}const Dle={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new cn(!0),stringify:Lle},$le={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new cn(!1),stringify:Lle},yYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Hl},xYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():Hl(e)}},vYe={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new cn(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){const i=e.substring(n+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Hl},H1=e=>typeof e=="bigint"||Number.isInteger(e);function AA(e,t,n,{intAsBigInt:i}){const r=e[0];if((r==="-"||r==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}const a=BigInt(e);return r==="-"?BigInt(-1)*a:a}const s=parseInt(e,n);return r==="-"?-1*s:s}function Y3(e,t,n){const{value:i}=e;if(H1(i)){const r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Hl(e)}const wYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>AA(e,2,2,n),stringify:e=>Y3(e,2,"0b")},SYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>AA(e,1,8,n),stringify:e=>Y3(e,8,"0")},EYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>AA(e,0,10,n),stringify:Hl},kYe={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>AA(e,2,16,n),stringify:e=>Y3(e,16,"0x")};class Tg extends qo{constructor(t){super(t),this.tag=Tg.tag}add(t){let n;Mr(t)?n=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?n=new Oa(t.key,null):n=new Oa(t,null),Fh(this.items,n.key)||this.items.push(n)}get(t,n){const i=Fh(this.items,t);return!n&&Mr(i)?Fi(i.key)?i.key.value:i.key:i}set(t,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);const i=Fh(this.items,t);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new Oa(t))}toJSON(t,n){return super.toJSON(t,n,Set)}toString(t,n,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),n,i);throw new Error("Set items must all have null values")}static from(t,n,i){const{replacer:r}=i,s=new this(t);if(n&&Symbol.iterator in Object(n))for(let a of n)typeof r=="function"&&(a=r.call(n,a,a)),s.items.push(z3(a,null,i));return s}}Tg.tag="tag:yaml.org,2002:set";const G3={collection:"map",identify:e=>e instanceof Set,nodeClass:Tg,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Tg.from(e,t,n),resolve(e,t){if(X1(e)){if(e.hasAllNullValues(!0))return Object.assign(new Tg,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function W3(e,t){const n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=a=>t?BigInt(a):Number(a),s=i.replace(/_/g,"").split(":").reduce((a,o)=>a*r(60)+r(o),r(0));return n==="-"?r(-1)*s:s}function Qle(e){let{value:t}=e,n=a=>a;if(typeof t=="bigint")n=a=>BigInt(a);else if(isNaN(t)||!isFinite(t))return Hl(e);let i="";t<0&&(i="-",t*=n(-1));const r=n(60),s=[t%r];return t<60?s.unshift(0):(t=(t-s[0])/r,s.unshift(t%r),t>=60&&(t=(t-s[0])/r,s.unshift(t))),i+s.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Ble={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>W3(e,n),stringify:Qle},Ule={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>W3(e,!1),stringify:Qle},NA={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(NA.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,n,i,r,s,a,o]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0;let u=Date.UTC(n,i-1,r,s||0,a||0,o||0,c);const d=t[8];if(d&&d!=="Z"){let f=W3(d,!1);Math.abs(f)<30&&(f*=60),u-=6e4*f}return new Date(u)},stringify:({value:e})=>(e==null?void 0:e.toISOString().replace(/(T00:00:00)?\.000Z$/,""))??""},mF=[cb,ub,kA,TA,Dle,$le,wYe,SYe,EYe,kYe,yYe,xYe,vYe,X3,qu,H3,q3,G3,Ble,Ule,NA],gF=new Map([["core",mYe],["failsafe",[cb,ub,kA]],["json",OYe],["yaml11",mF],["yaml-1.1",mF]]),bF={binary:X3,bool:F3,float:Nle,floatExp:Ale,floatNaN:_le,floatTime:Ule,int:Rle,intHex:Ile,intOct:jle,intTime:Ble,map:cb,merge:qu,null:TA,omap:H3,pairs:q3,seq:ub,set:G3,timestamp:NA},TYe={"tag:yaml.org,2002:binary":X3,"tag:yaml.org,2002:merge":qu,"tag:yaml.org,2002:omap":H3,"tag:yaml.org,2002:pairs":q3,"tag:yaml.org,2002:set":G3,"tag:yaml.org,2002:timestamp":NA};function XC(e,t,n){const i=gF.get(t);if(i&&!e)return n&&!i.includes(qu)?i.concat(qu):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{const s=Array.from(gF.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(const s of e)r=r.concat(s);else typeof e=="function"&&(r=e(r.slice()));return n&&(r=r.concat(qu)),r.reduce((s,a)=>{const o=typeof a=="string"?bF[a]:a;if(!o){const c=JSON.stringify(a),u=Object.keys(bF).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return s.includes(o)||s.push(o),s},[])}const _Ye=(e,t)=>e.keyt.key?1:0;let AYe=class zle{constructor({compat:t,customTags:n,merge:i,resolveKnownTags:r,schema:s,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(t)?XC(t,"compat"):t?XC(null,t):null,this.name=typeof s=="string"&&s||"core",this.knownTags=r?TYe:{},this.tags=XC(n,this.name,i),this.toStringOptions=o??null,Object.defineProperty(this,Ef,{value:cb}),Object.defineProperty(this,Vc,{value:kA}),Object.defineProperty(this,ab,{value:ub}),this.sortMapEntries=typeof a=="function"?a:a===!0?_Ye:null}clone(){const t=Object.create(zle.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function NYe(e,t){var c;const n=[];let i=t.directives===!0;if(t.directives!==!1&&e.directives){const u=e.directives.toString(e);u?(n.push(u),i=!0):e.directives.docStart&&(i=!0)}i&&n.push("---");const r=vle(e,t),{commentString:s}=r.options;if(e.commentBefore){n.length!==1&&n.unshift("");const u=s(e.commentBefore);n.unshift(Lu(u,""))}let a=!1,o=null;if(e.contents){if(Pr(e.contents)){if(e.contents.spaceBefore&&i&&n.push(""),e.contents.commentBefore){const f=s(e.contents.commentBefore);n.push(Lu(f,""))}r.forceBlockIndent=!!e.comment,o=e.contents.comment}const u=o?void 0:()=>a=!0;let d=g0(e.contents,r,()=>o=null,u);o&&(d+=zh(d,"",s(o))),(d[0]==="|"||d[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${d}`:n.push(d)}else n.push(g0(e.contents,r));if((c=e.directives)!=null&&c.docEnd)if(e.comment){const u=s(e.comment);u.includes(` `)?(n.push("..."),n.push(Lu(u,""))):n.push(`... ${u}`)}else n.push("...");else{let u=e.comment;u&&a&&(u=u.replace(/^\n+/,"")),u&&((!a||o)&&n[n.length-1]!==""&&n.push(""),n.push(Lu(s(u),"")))}return n.join(` `)+` -`}class Y1{constructor(t,n,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,sl,{value:wM});let r=null;typeof n=="function"||Array.isArray(n)?r=n:i===void 0&&n&&(i=n,n=void 0);const s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=s;let{version:a}=s;i!=null&&i._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new fa({version:a}),this.setSchema(a,i),this.contents=t===void 0?null:this.createNode(t,r,i)}clone(){const t=Object.create(Y1.prototype,{[sl]:{value:wM}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Pr(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){dm(this.contents)&&this.contents.add(t)}addIn(t,n){dm(this.contents)&&this.contents.addIn(t,n)}createAlias(t,n){if(!t.anchor){const i=mle(this);t.anchor=!n||i.has(n)?gle(n||"a",i):n}return new B3(t.anchor)}createNode(t,n,i){let r;if(typeof n=="function")t=n.call({"":t},"",t),r=n;else if(Array.isArray(n)){const y=v=>typeof v=="number"||v instanceof String||v instanceof Number,O=n.filter(y).map(String);O.length>0&&(n=n.concat(O)),r=n}else i===void 0&&n&&(i=n,n=void 0);const{aliasDuplicateObjects:s,anchorPrefix:a,flow:o,keepUndefined:c,onTagObj:u,tag:d}=i??{},{onAnchor:f,setAnchors:h,sourceObjects:p}=tYe(this,a||"a"),g={aliasDuplicateObjects:s??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:u,replacer:r,schema:this.schema,sourceObjects:p},b=Ax(t,d,g);return o&&Rr(b)&&(b.flow=!0),h(),b}createPair(t,n,i={}){const r=this.createNode(t,null,i),s=this.createNode(n,null,i);return new Oa(r,s)}delete(t){return dm(this.contents)?this.contents.delete(t):!1}deleteIn(t){return IO(t)?this.contents==null?!1:(this.contents=null,!0):dm(this.contents)?this.contents.deleteIn(t):!1}get(t,n){return Rr(this.contents)?this.contents.get(t,n):void 0}getIn(t,n){return IO(t)?!n&&Fi(this.contents)?this.contents.value:this.contents:Rr(this.contents)?this.contents.getIn(t,n):void 0}has(t){return Rr(this.contents)?this.contents.has(t):!1}hasIn(t){return IO(t)?this.contents!==void 0:Rr(this.contents)?this.contents.hasIn(t):!1}set(t,n){this.contents==null?this.contents=Gk(this.schema,[t],n):dm(this.contents)&&this.contents.set(t,n)}setIn(t,n){IO(t)?this.contents=n:this.contents==null?this.contents=Gk(this.schema,Array.from(t),n):dm(this.contents)&&this.contents.setIn(t,n)}setSchema(t,n={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new fa({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new fa({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{const r=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(i)this.schema=new _Ye(Object.assign(i,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:n,mapAsMap:i,maxAliasCount:r,onAnchor:s,reviver:a}={}){const o={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=il(this.contents,n??"",o);if(typeof s=="function")for(const{count:u,res:d}of o.anchors.values())s(d,u);return typeof a=="function"?rg(a,{"":c},"",c):c}toJSON(t,n){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:n})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){const n=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return AYe(this,t)}}function dm(e){if(Rr(e))return!0;throw new Error("Expected a YAML collection as document contents")}class zle extends Error{constructor(t,n,i,r){super(),this.name=t,this.code=i,this.message=r,this.pos=n}}class PO extends zle{constructor(t,n,i){super("YAMLParseError",t,n,i)}}class NYe extends zle{constructor(t,n,i){super("YAMLWarning",t,n,i)}}const OF=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(o=>t.linePos(o));const{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let s=r-1,a=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&a.length>80){const o=Math.min(s-39,a.length-79);a="…"+a.substring(o),s-=o-1}if(a.length>80&&(a=a.substring(0,79)+"…"),i>1&&/^ *$/.test(a.substring(0,s))){let o=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);o.length>80&&(o=o.substring(0,79)+`… +`}class Y1{constructor(t,n,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,sl,{value:wM});let r=null;typeof n=="function"||Array.isArray(n)?r=n:i===void 0&&n&&(i=n,n=void 0);const s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=s;let{version:a}=s;i!=null&&i._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new fa({version:a}),this.setSchema(a,i),this.contents=t===void 0?null:this.createNode(t,r,i)}clone(){const t=Object.create(Y1.prototype,{[sl]:{value:wM}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Pr(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){dm(this.contents)&&this.contents.add(t)}addIn(t,n){dm(this.contents)&&this.contents.addIn(t,n)}createAlias(t,n){if(!t.anchor){const i=gle(this);t.anchor=!n||i.has(n)?ble(n||"a",i):n}return new B3(t.anchor)}createNode(t,n,i){let r;if(typeof n=="function")t=n.call({"":t},"",t),r=n;else if(Array.isArray(n)){const y=v=>typeof v=="number"||v instanceof String||v instanceof Number,O=n.filter(y).map(String);O.length>0&&(n=n.concat(O)),r=n}else i===void 0&&n&&(i=n,n=void 0);const{aliasDuplicateObjects:s,anchorPrefix:a,flow:o,keepUndefined:c,onTagObj:u,tag:d}=i??{},{onAnchor:f,setAnchors:h,sourceObjects:p}=nYe(this,a||"a"),g={aliasDuplicateObjects:s??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:u,replacer:r,schema:this.schema,sourceObjects:p},b=Ax(t,d,g);return o&&Rr(b)&&(b.flow=!0),h(),b}createPair(t,n,i={}){const r=this.createNode(t,null,i),s=this.createNode(n,null,i);return new Oa(r,s)}delete(t){return dm(this.contents)?this.contents.delete(t):!1}deleteIn(t){return IO(t)?this.contents==null?!1:(this.contents=null,!0):dm(this.contents)?this.contents.deleteIn(t):!1}get(t,n){return Rr(this.contents)?this.contents.get(t,n):void 0}getIn(t,n){return IO(t)?!n&&Fi(this.contents)?this.contents.value:this.contents:Rr(this.contents)?this.contents.getIn(t,n):void 0}has(t){return Rr(this.contents)?this.contents.has(t):!1}hasIn(t){return IO(t)?this.contents!==void 0:Rr(this.contents)?this.contents.hasIn(t):!1}set(t,n){this.contents==null?this.contents=Gk(this.schema,[t],n):dm(this.contents)&&this.contents.set(t,n)}setIn(t,n){IO(t)?this.contents=n:this.contents==null?this.contents=Gk(this.schema,Array.from(t),n):dm(this.contents)&&this.contents.setIn(t,n)}setSchema(t,n={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new fa({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new fa({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{const r=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(i)this.schema=new AYe(Object.assign(i,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:n,mapAsMap:i,maxAliasCount:r,onAnchor:s,reviver:a}={}){const o={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=il(this.contents,n??"",o);if(typeof s=="function")for(const{count:u,res:d}of o.anchors.values())s(d,u);return typeof a=="function"?rg(a,{"":c},"",c):c}toJSON(t,n){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:n})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){const n=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return NYe(this,t)}}function dm(e){if(Rr(e))return!0;throw new Error("Expected a YAML collection as document contents")}class Fle extends Error{constructor(t,n,i,r){super(),this.name=t,this.code=i,this.message=r,this.pos=n}}class PO extends Fle{constructor(t,n,i){super("YAMLParseError",t,n,i)}}class CYe extends Fle{constructor(t,n,i){super("YAMLWarning",t,n,i)}}const OF=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(o=>t.linePos(o));const{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let s=r-1,a=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&a.length>80){const o=Math.min(s-39,a.length-79);a="…"+a.substring(o),s-=o-1}if(a.length>80&&(a=a.substring(0,79)+"…"),i>1&&/^ *$/.test(a.substring(0,s))){let o=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);o.length>80&&(o=o.substring(0,79)+`… `),a=o+a}if(/[^ ]/.test(a)){let o=1;const c=n.linePos[1];(c==null?void 0:c.line)===i&&c.col>r&&(o=Math.max(1,Math.min(c.col-r,80-s)));const u=" ".repeat(s)+"^".repeat(o);n.message+=`: ${a} ${u} `}};function b0(e,{flow:t,indicator:n,next:i,offset:r,onError:s,parentIndent:a,startOnNewline:o}){let c=!1,u=o,d=o,f="",h="",p=!1,g=!1,b=null,y=null,O=null,v=null,x=null,w=null,E=null;for(const T of e)switch(g&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&s(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),b&&(u&&T.type!=="comment"&&T.type!=="newline"&&s(b,"TAB_AS_INDENT","Tabs are not allowed as indentation"),b=null),T.type){case"space":!t&&(n!=="doc-start"||(i==null?void 0:i.type)!=="flow-collection")&&T.source.includes(" ")&&(b=T),d=!0;break;case"comment":{d||s(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const A=T.source.substring(1)||" ";f?f+=h+A:f=A,h="",u=!1;break}case"newline":u?f?f+=T.source:(!w||n!=="seq-item-ind")&&(c=!0):h+=T.source,u=!0,p=!0,(y||O)&&(v=T),d=!0;break;case"anchor":y&&s(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&s(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=T,E??(E=T.offset),u=!1,d=!1,g=!0;break;case"tag":{O&&s(T,"MULTIPLE_TAGS","A node can have at most one tag"),O=T,E??(E=T.offset),u=!1,d=!1,g=!0;break}case n:(y||O)&&s(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),w&&s(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${t??"collection"}`),w=T,u=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(t){x&&s(T,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),x=T,u=!1,d=!1;break}default:s(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),u=!1,d=!1}const S=e[e.length-1],k=S?S.offset+S.source.length:r;return g&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),b&&(u&&b.indent<=a||(i==null?void 0:i.type)==="block-map"||(i==null?void 0:i.type)==="block-seq")&&s(b,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:x,found:w,spaceBefore:c,comment:f,hasNewline:p,anchor:y,tag:O,newlineAfterProp:v,end:k,start:E??k}}function Nx(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(` -`))return!0;if(e.end){for(const t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(const t of e.items){for(const n of t.start)if(n.type==="newline")return!0;if(t.sep){for(const n of t.sep)if(n.type==="newline")return!0}if(Nx(t.key)||Nx(t.value))return!0}return!1;default:return!0}}function TM(e,t,n){if((t==null?void 0:t.type)==="flow-collection"){const i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&Nx(t)&&n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Fle(e,t,n){const{uniqueKeys:i}=e.options;if(i===!1)return!1;const r=typeof i=="function"?i:(s,a)=>s===a||Fi(s)&&Fi(a)&&s.value===a.value;return t.some(s=>r(s.key,n))}const yF="All mapping items must start at the same column";function CYe({composeNode:e,composeEmptyNode:t},n,i,r,s){var d;const a=(s==null?void 0:s.nodeClass)??qo,o=new a(n.schema);n.atRoot&&(n.atRoot=!1);let c=i.offset,u=null;for(const f of i.items){const{start:h,key:p,sep:g,value:b}=f,y=b0(h,{indicator:"explicit-key-ind",next:p??(g==null?void 0:g[0]),offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0}),O=!y.found;if(O){if(p&&(p.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&r(c,"BAD_INDENT",yF)),!y.anchor&&!y.tag&&!g){u=y.end,y.comment&&(o.comment?o.comment+=` -`+y.comment:o.comment=y.comment);continue}(y.newlineAfterProp||Nx(p))&&r(p??h[h.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else((d=y.found)==null?void 0:d.indent)!==i.indent&&r(c,"BAD_INDENT",yF);n.atKey=!0;const v=y.end,x=p?e(n,p,y,r):t(n,v,h,null,y,r);n.schema.compat&&TM(i.indent,p,r),n.atKey=!1,Fle(n,o.items,x)&&r(v,"DUPLICATE_KEY","Map keys must be unique");const w=b0(g??[],{indicator:"map-value-ind",next:b,offset:x.range[2],onError:r,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=w.end,w.found){O&&((b==null?void 0:b.type)==="block-map"&&!w.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&y.starte&&(e.type==="block-map"||e.type==="block-seq");function RYe({composeNode:e,composeEmptyNode:t},n,i,r,s){var y;const a=i.start.source==="{",o=a?"flow map":"flow sequence",c=(s==null?void 0:s.nodeClass)??(a?qo:Ep),u=new c(n.schema);u.flow=!0;const d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let f=i.offset+i.start.source.length;for(let O=0;Os===a||Fi(s)&&Fi(a)&&s.value===a.value;return t.some(s=>r(s.key,n))}const yF="All mapping items must start at the same column";function jYe({composeNode:e,composeEmptyNode:t},n,i,r,s){var d;const a=(s==null?void 0:s.nodeClass)??qo,o=new a(n.schema);n.atRoot&&(n.atRoot=!1);let c=i.offset,u=null;for(const f of i.items){const{start:h,key:p,sep:g,value:b}=f,y=b0(h,{indicator:"explicit-key-ind",next:p??(g==null?void 0:g[0]),offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0}),O=!y.found;if(O){if(p&&(p.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&r(c,"BAD_INDENT",yF)),!y.anchor&&!y.tag&&!g){u=y.end,y.comment&&(o.comment?o.comment+=` +`+y.comment:o.comment=y.comment);continue}(y.newlineAfterProp||Nx(p))&&r(p??h[h.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else((d=y.found)==null?void 0:d.indent)!==i.indent&&r(c,"BAD_INDENT",yF);n.atKey=!0;const v=y.end,x=p?e(n,p,y,r):t(n,v,h,null,y,r);n.schema.compat&&TM(i.indent,p,r),n.atKey=!1,Vle(n,o.items,x)&&r(v,"DUPLICATE_KEY","Map keys must be unique");const w=b0(g??[],{indicator:"map-value-ind",next:b,offset:x.range[2],onError:r,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=w.end,w.found){O&&((b==null?void 0:b.type)==="block-map"&&!w.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&y.starte&&(e.type==="block-map"||e.type==="block-seq");function IYe({composeNode:e,composeEmptyNode:t},n,i,r,s){var y;const a=i.start.source==="{",o=a?"flow map":"flow sequence",c=(s==null?void 0:s.nodeClass)??(a?qo:Ep),u=new c(n.schema);u.flow=!0;const d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let f=i.offset+i.start.source.length;for(let O=0;O0){const O=G1(g,b,n.options.strict,r);O.comment&&(u.comment?u.comment+=` -`+O.comment:u.comment=O.comment),u.range=[i.offset,b,O.offset]}else u.range=[i.offset,b,b];return u}function YC(e,t,n,i,r,s){const a=n.type==="block-map"?CYe(e,t,n,i,s):n.type==="block-seq"?jYe(e,t,n,i,s):RYe(e,t,n,i,s),o=a.constructor;return r==="!"||r===o.tagName?(a.tag=o.tagName,a):(r&&(a.tag=r),a)}function IYe(e,t,n,i,r){var h;const s=i.tag,a=s?t.directives.tagName(s.source,p=>r(s,"TAG_RESOLVE_FAILED",p)):null;if(n.type==="block-seq"){const{anchor:p,newlineAfterProp:g}=i,b=p&&s?p.offset>s.offset?p:s:p??s;b&&(!g||g.offsetp.tag===a&&p.collection===o);if(!c){const p=t.schema.knownTags[a];if((p==null?void 0:p.collection)===o)t.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?r(s,"BAD_COLLECTION_TYPE",`${p.tag} used for ${o} collection, but expects ${p.collection??"scalar"}`,!0):r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${a}`,!0),YC(e,t,n,r,a)}const u=YC(e,t,n,r,a,c),d=((h=c.resolve)==null?void 0:h.call(c,u,p=>r(s,"TAG_RESOLVE_FAILED",p),t.options))??u,f=Pr(d)?d:new cn(d);return f.range=u.range,f.tag=a,c!=null&&c.format&&(f.format=c.format),f}function PYe(e,t,n){const i=t.offset,r=MYe(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};const s=r.mode===">"?cn.BLOCK_FOLDED:cn.BLOCK_LITERAL,a=t.source?LYe(t.source):[];let o=a.length;for(let b=a.length-1;b>=0;--b){const y=a[b][1];if(y===""||y==="\r")o=b;else break}if(o===0){const b=r.chomp==="+"&&a.length>0?` +`+N.comment:A.comment=N.comment);const M=new Oa(A,C);if(n.options.keepSourceTokens&&(M.srcToken=v),a){const L=u;Vle(n,L.items,A)&&r(T,"DUPLICATE_KEY","Map keys must be unique"),L.items.push(M)}else{const L=new qo(n.schema);L.flow=!0,L.items.push(M);const P=(C??A).range;L.range=[A.range[0],P[1],P[2]],u.items.push(L)}f=C?C.range[2]:N.end}}const h=a?"}":"]",[p,...g]=i.end;let b=f;if((p==null?void 0:p.source)===h)b=p.offset+p.source.length;else{const O=o[0].toUpperCase()+o.substring(1),v=d?`${O} must end with a ${h}`:`${O} in block collection must be sufficiently indented and end with a ${h}`;r(f,d?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){const O=G1(g,b,n.options.strict,r);O.comment&&(u.comment?u.comment+=` +`+O.comment:u.comment=O.comment),u.range=[i.offset,b,O.offset]}else u.range=[i.offset,b,b];return u}function YC(e,t,n,i,r,s){const a=n.type==="block-map"?jYe(e,t,n,i,s):n.type==="block-seq"?RYe(e,t,n,i,s):IYe(e,t,n,i,s),o=a.constructor;return r==="!"||r===o.tagName?(a.tag=o.tagName,a):(r&&(a.tag=r),a)}function PYe(e,t,n,i,r){var h;const s=i.tag,a=s?t.directives.tagName(s.source,p=>r(s,"TAG_RESOLVE_FAILED",p)):null;if(n.type==="block-seq"){const{anchor:p,newlineAfterProp:g}=i,b=p&&s?p.offset>s.offset?p:s:p??s;b&&(!g||g.offsetp.tag===a&&p.collection===o);if(!c){const p=t.schema.knownTags[a];if((p==null?void 0:p.collection)===o)t.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?r(s,"BAD_COLLECTION_TYPE",`${p.tag} used for ${o} collection, but expects ${p.collection??"scalar"}`,!0):r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${a}`,!0),YC(e,t,n,r,a)}const u=YC(e,t,n,r,a,c),d=((h=c.resolve)==null?void 0:h.call(c,u,p=>r(s,"TAG_RESOLVE_FAILED",p),t.options))??u,f=Pr(d)?d:new cn(d);return f.range=u.range,f.tag=a,c!=null&&c.format&&(f.format=c.format),f}function MYe(e,t,n){const i=t.offset,r=LYe(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};const s=r.mode===">"?cn.BLOCK_FOLDED:cn.BLOCK_LITERAL,a=t.source?DYe(t.source):[];let o=a.length;for(let b=a.length-1;b>=0;--b){const y=a[b][1];if(y===""||y==="\r")o=b;else break}if(o===0){const b=r.chomp==="+"&&a.length>0?` `.repeat(Math.max(1,a.length-1)):"";let y=i+r.length;return t.source&&(y+=t.source.length),{value:b,type:s,comment:r.comment,range:[i,y,y]}}let c=t.indent+r.indent,u=t.offset+r.length,d=0;for(let b=0;bc&&(c=y.length);else{y.length=o;--b)a[b][0].length>c&&(o=b+1);let f="",h="",p=!1;for(let b=0;bc||O[0]===" "?(h===" "?h=` @@ -623,38 +623,38 @@ ${u} `+a[b][0].slice(c);f[f.length-1]!==` `&&(f+=` `);break;default:f+=` -`}const g=i+r.length+t.source.length;return{value:f,type:s,comment:r.comment,range:[i,g,g]}}function MYe({offset:e,props:t},n,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:r}=t[0],s=r[0];let a=0,o="",c=-1;for(let h=1;hn(i+h,p,g);switch(r){case"scalar":o=cn.PLAIN,c=$Ye(s,u);break;case"single-quoted-scalar":o=cn.QUOTE_SINGLE,c=QYe(s,u);break;case"double-quoted-scalar":o=cn.QUOTE_DOUBLE,c=BYe(s,u);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+s.length,i+s.length]}}const d=i+s.length,f=G1(a,d,t,n);return{value:c,type:o,comment:f.comment,range:[i,d,f.offset]}}function $Ye(e,t){let n="";switch(e[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}return n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Vle(e)}function QYe(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Vle(e.slice(1,-1)).replace(/''/g,"'")}function Vle(e){let t,n;try{t=new RegExp(`(.*?)(?n(i+h,p,g);switch(r){case"scalar":o=cn.PLAIN,c=QYe(s,u);break;case"single-quoted-scalar":o=cn.QUOTE_SINGLE,c=BYe(s,u);break;case"double-quoted-scalar":o=cn.QUOTE_DOUBLE,c=UYe(s,u);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+s.length,i+s.length]}}const d=i+s.length,f=G1(a,d,t,n);return{value:c,type:o,comment:f.comment,range:[i,d,f.offset]}}function QYe(e,t){let n="";switch(e[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}return n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Xle(e)}function BYe(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Xle(e.slice(1,-1)).replace(/''/g,"'")}function Xle(e){let t,n;try{t=new RegExp(`(.*?)(?s?e.slice(s,i+1):r)}else n+=r}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),n}function UYe(e,t){let n="",i=e[t+1];for(;(i===" "||i===" "||i===` +`)&&(n+=i>s?e.slice(s,i+1):r)}else n+=r}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),n}function zYe(e,t){let n="",i=e[t+1];for(;(i===" "||i===" "||i===` `||i==="\r")&&!(i==="\r"&&e[t+2]!==` `);)i===` `&&(n+=` -`),t+=1,i=e[t+1];return n||(n=" "),{fold:n,offset:t}}const zYe={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:` -`,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function FYe(e,t,n,i){const r=e.substr(t,n),a=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(a)}catch{const o=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),o}}function Xle(e,t,n,i){const{value:r,type:s,comment:a,range:o}=t.type==="block-scalar"?PYe(e,t,i):DYe(t,e.options.strict,i),c=n?e.directives.tagName(n.source,f=>i(n,"TAG_RESOLVE_FAILED",f)):null;let u;e.options.stringKeys&&e.atKey?u=e.schema[Vc]:c?u=VYe(e.schema,r,c,n,i):t.type==="scalar"?u=XYe(e,r,t,i):u=e.schema[Vc];let d;try{const f=u.resolve(r,h=>i(n??t,"TAG_RESOLVE_FAILED",h),e.options);d=Fi(f)?f:new cn(f)}catch(f){const h=f instanceof Error?f.message:String(f);i(n??t,"TAG_RESOLVE_FAILED",h),d=new cn(r)}return d.range=o,d.source=r,s&&(d.type=s),c&&(d.tag=c),u.format&&(d.format=u.format),a&&(d.comment=a),d}function VYe(e,t,n,i,r){var o;if(n==="!")return e[Vc];const s=[];for(const c of e.tags)if(!c.collection&&c.tag===n)if(c.default&&c.test)s.push(c);else return c;for(const c of s)if((o=c.test)!=null&&o.test(t))return c;const a=e.knownTags[n];return a&&!a.collection?(e.tags.push(Object.assign({},a,{default:!1,test:void 0})),a):(r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Vc])}function XYe({atKey:e,directives:t,schema:n},i,r,s){const a=n.tags.find(o=>{var c;return(o.default===!0||e&&o.default==="key")&&((c=o.test)==null?void 0:c.test(i))})||n[Vc];if(n.compat){const o=n.compat.find(c=>{var u;return c.default&&((u=c.test)==null?void 0:u.test(i))})??n[Vc];if(a.tag!==o.tag){const c=t.tagString(a.tag),u=t.tagString(o.tag),d=`Value may be parsed as either ${c} or ${u}`;s(r,"TAG_RESOLVE_FAILED",d,!0)}}return a}function qYe(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++i];(r==null?void 0:r.type)==="space";)e+=r.source.length,r=t[++i];break}}return e}const HYe={composeNode:qle,composeEmptyNode:Z3};function qle(e,t,n,i){const r=e.atKey,{spaceBefore:s,comment:a,anchor:o,tag:c}=n;let u,d=!0;switch(t.type){case"alias":u=YYe(e,t,i),(o||c)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=Xle(e,t,c,i),o&&(u.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=IYe(HYe,e,t,n,i),o&&(u.anchor=o.source.substring(1))}catch(f){const h=f instanceof Error?f.message:String(f);i(t,"RESOURCE_EXHAUSTION",h)}break;default:{const f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",f),d=!1}}return u??(u=Z3(e,t.offset,void 0,null,n,i)),o&&u.anchor===""&&i(o,"BAD_ALIAS","Anchor cannot be an empty string"),r&&e.options.stringKeys&&(!Fi(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),a&&(t.type==="scalar"&&t.source===""?u.comment=a:u.commentBefore=a),e.options.keepSourceTokens&&d&&(u.srcToken=t),u}function Z3(e,t,n,i,{spaceBefore:r,comment:s,anchor:a,tag:o,end:c},u){const d={type:"scalar",offset:qYe(t,n,i),indent:-1,source:""},f=Xle(e,d,o,u);return a&&(f.anchor=a.source.substring(1),f.anchor===""&&u(a,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(f.spaceBefore=!0),s&&(f.comment=s,f.range[2]=c),f}function YYe({options:e},{offset:t,source:n,end:i},r){const s=new B3(n.substring(1));s.source===""&&r(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const a=t+n.length,o=G1(i,a,e.strict,r);return s.range=[t,a,o.offset],o.comment&&(s.comment=o.comment),s}function GYe(e,t,{offset:n,start:i,value:r,end:s},a){const o=Object.assign({_directives:t},e),c=new Y1(void 0,o),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=b0(i,{indicator:"doc-start",next:r??(s==null?void 0:s[0]),offset:n,onError:a,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!d.hasNewline&&a(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?qle(u,r,d,a):Z3(u,d.end,i,null,d,a);const f=c.contents.range[2],h=G1(s,f,!1,a);return h.comment&&(c.comment=h.comment),c.range=[n,f,h.offset],c}function iO(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];const{offset:t,source:n}=e;return[t,t+(typeof n=="string"?n.length:1)]}function xF(e){var r;let t="",n=!1,i=!1;for(let s=0;si(n,"TAG_RESOLVE_FAILED",f)):null;let u;e.options.stringKeys&&e.atKey?u=e.schema[Vc]:c?u=XYe(e.schema,r,c,n,i):t.type==="scalar"?u=qYe(e,r,t,i):u=e.schema[Vc];let d;try{const f=u.resolve(r,h=>i(n??t,"TAG_RESOLVE_FAILED",h),e.options);d=Fi(f)?f:new cn(f)}catch(f){const h=f instanceof Error?f.message:String(f);i(n??t,"TAG_RESOLVE_FAILED",h),d=new cn(r)}return d.range=o,d.source=r,s&&(d.type=s),c&&(d.tag=c),u.format&&(d.format=u.format),a&&(d.comment=a),d}function XYe(e,t,n,i,r){var o;if(n==="!")return e[Vc];const s=[];for(const c of e.tags)if(!c.collection&&c.tag===n)if(c.default&&c.test)s.push(c);else return c;for(const c of s)if((o=c.test)!=null&&o.test(t))return c;const a=e.knownTags[n];return a&&!a.collection?(e.tags.push(Object.assign({},a,{default:!1,test:void 0})),a):(r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Vc])}function qYe({atKey:e,directives:t,schema:n},i,r,s){const a=n.tags.find(o=>{var c;return(o.default===!0||e&&o.default==="key")&&((c=o.test)==null?void 0:c.test(i))})||n[Vc];if(n.compat){const o=n.compat.find(c=>{var u;return c.default&&((u=c.test)==null?void 0:u.test(i))})??n[Vc];if(a.tag!==o.tag){const c=t.tagString(a.tag),u=t.tagString(o.tag),d=`Value may be parsed as either ${c} or ${u}`;s(r,"TAG_RESOLVE_FAILED",d,!0)}}return a}function HYe(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++i];(r==null?void 0:r.type)==="space";)e+=r.source.length,r=t[++i];break}}return e}const YYe={composeNode:Hle,composeEmptyNode:Z3};function Hle(e,t,n,i){const r=e.atKey,{spaceBefore:s,comment:a,anchor:o,tag:c}=n;let u,d=!0;switch(t.type){case"alias":u=GYe(e,t,i),(o||c)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=qle(e,t,c,i),o&&(u.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=PYe(YYe,e,t,n,i),o&&(u.anchor=o.source.substring(1))}catch(f){const h=f instanceof Error?f.message:String(f);i(t,"RESOURCE_EXHAUSTION",h)}break;default:{const f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",f),d=!1}}return u??(u=Z3(e,t.offset,void 0,null,n,i)),o&&u.anchor===""&&i(o,"BAD_ALIAS","Anchor cannot be an empty string"),r&&e.options.stringKeys&&(!Fi(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),a&&(t.type==="scalar"&&t.source===""?u.comment=a:u.commentBefore=a),e.options.keepSourceTokens&&d&&(u.srcToken=t),u}function Z3(e,t,n,i,{spaceBefore:r,comment:s,anchor:a,tag:o,end:c},u){const d={type:"scalar",offset:HYe(t,n,i),indent:-1,source:""},f=qle(e,d,o,u);return a&&(f.anchor=a.source.substring(1),f.anchor===""&&u(a,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(f.spaceBefore=!0),s&&(f.comment=s,f.range[2]=c),f}function GYe({options:e},{offset:t,source:n,end:i},r){const s=new B3(n.substring(1));s.source===""&&r(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const a=t+n.length,o=G1(i,a,e.strict,r);return s.range=[t,a,o.offset],o.comment&&(s.comment=o.comment),s}function WYe(e,t,{offset:n,start:i,value:r,end:s},a){const o=Object.assign({_directives:t},e),c=new Y1(void 0,o),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=b0(i,{indicator:"doc-start",next:r??(s==null?void 0:s[0]),offset:n,onError:a,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!d.hasNewline&&a(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?Hle(u,r,d,a):Z3(u,d.end,i,null,d,a);const f=c.contents.range[2],h=G1(s,f,!1,a);return h.comment&&(c.comment=h.comment),c.range=[n,f,h.offset],c}function iO(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];const{offset:t,source:n}=e;return[t,t+(typeof n=="string"?n.length:1)]}function xF(e){var r;let t="",n=!1,i=!1;for(let s=0;s{const a=iO(n);s?this.warnings.push(new NYe(a,i,r)):this.errors.push(new PO(a,i,r))},this.directives=new fa({version:t.version||"1.2"}),this.options=t}decorate(t,n){const{comment:i,afterEmptyLine:r}=xF(this.prelude);if(i){const s=t.contents;if(n)t.comment=t.comment?`${t.comment} +`)+(a.substring(1)||" "),n=!0,i=!1;break;case"%":((r=e[s+1])==null?void 0:r[0])!=="#"&&(s+=1),n=!1;break;default:n||(i=!0),n=!1}}return{comment:t,afterEmptyLine:i}}let ZYe=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,i,r,s)=>{const a=iO(n);s?this.warnings.push(new CYe(a,i,r)):this.errors.push(new PO(a,i,r))},this.directives=new fa({version:t.version||"1.2"}),this.options=t}decorate(t,n){const{comment:i,afterEmptyLine:r}=xF(this.prelude);if(i){const s=t.contents;if(n)t.comment=t.comment?`${t.comment} ${i}`:i;else if(r||t.directives.docStart||!s)t.commentBefore=i;else if(Rr(s)&&!s.flow&&s.items.length>0){let a=s.items[0];Mr(a)&&(a=a.key);const o=a.commentBefore;a.commentBefore=o?`${i} ${o}`:i}else{const a=s.commentBefore;s.commentBefore=a?`${i} -${a}`:i}}if(n){for(let s=0;s{const s=iO(t);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",i,r)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{const n=GYe(this.options,this.directives,t,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{const n=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new PO(iO(t),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){const i="Unexpected doc-end without preceding document";this.errors.push(new PO(iO(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;const n=G1(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){const i=this.doc.comment;this.doc.comment=i?`${i} -${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new PO(iO(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){const i=Object.assign({_directives:this.directives},this.options),r=new Y1(void 0,i);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};const Hle="\uFEFF",Yle="",Gle="",_M="";function ZYe(e){switch(e){case Hle:return"byte-order-mark";case Yle:return"doc-mode";case Gle:return"flow-error-end";case _M:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case` +${a}`:i}}if(n){for(let s=0;s{const s=iO(t);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",i,r)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{const n=WYe(this.options,this.directives,t,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{const n=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new PO(iO(t),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){const i="Unexpected doc-end without preceding document";this.errors.push(new PO(iO(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;const n=G1(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){const i=this.doc.comment;this.doc.comment=i?`${i} +${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new PO(iO(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){const i=Object.assign({_directives:this.directives},this.options),r=new Y1(void 0,i);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};const Yle="\uFEFF",Gle="",Wle="",_M="";function KYe(e){switch(e){case Yle:return"byte-order-mark";case Gle:return"doc-mode";case Wle:return"flow-error-end";case _M:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case` `:case`\r `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function Ol(e){switch(e){case void 0:case" ":case` -`:case"\r":case" ":return!0;default:return!1}}const vF=new Set("0123456789ABCDEFabcdef"),KYe=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Qw=new Set(",[]{}"),JYe=new Set(` ,[]{} -\r `),GC=e=>!e||JYe.has(e);class eGe{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,n=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!n;let i=this.next??"stream";for(;i&&(n||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,n=this.buffer[t];for(;n===" "||n===" ";)n=this.buffer[++t];return!n||n==="#"||n===` +`:case"\r":case" ":return!0;default:return!1}}const vF=new Set("0123456789ABCDEFabcdef"),JYe=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Qw=new Set(",[]{}"),eGe=new Set(` ,[]{} +\r `),GC=e=>!e||eGe.has(e);class tGe{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,n=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!n;let i=this.next??"stream";for(;i&&(n||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,n=this.buffer[t];for(;n===" "||n===" ";)n=this.buffer[++t];return!n||n==="#"||n===` `?!0:n==="\r"?this.buffer[t+1]===` `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let n=this.buffer[t];if(this.indentNext>0){let i=0;for(;n===" ";)n=this.buffer[++i+t];if(n==="\r"){const r=this.buffer[i+t+1];if(r===` `||!r&&!this.atEnd)return t+i+1}return n===` `||i>=this.indentNext||!n&&!this.atEnd?t+i:-1}if(n==="-"||n==="."){const i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&Ol(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&tthis.indentValue&&!Ol(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[t,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&Ol(n)){const i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const t=this.getLine();if(t===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(t[n]){case"#":yield*this.pushCount(t.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(GC),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,n,i=-1;do t=yield*this.pushNewline(),t>0?(n=yield*this.pushSpaces(!1),this.indentValue=i=n):n=0,n+=yield*this.pushSpaces(!0);while(t+n>0);const r=this.getLine();if(r===null)return this.setNext("flow");if((i!==-1&&ithis.indentValue&&!Ol(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[t,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&Ol(n)){const i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const t=this.getLine();if(t===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(t[n]){case"#":yield*this.pushCount(t.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(GC),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,n,i=-1;do t=yield*this.pushNewline(),t>0?(n=yield*this.pushSpaces(!1),this.indentValue=i=n):n=0,n+=yield*this.pushSpaces(!0);while(t+n>0);const r=this.getLine();if(r===null)return this.setNext("flow");if((i!==-1&&i"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Ol(n)||n==="#")}*parseBlockScalar(){let t=this.pos-1,n=0,i;e:for(let s=this.pos;i=this.buffer[s];++s)switch(i){case" ":n+=1;break;case` `:t=s,n=0;break;case"\r":{const a=this.buffer[s+1];if(!a&&!this.atEnd)return this.setNext("block-scalar");if(a===` @@ -664,23 +664,23 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus `&&s>=this.pos&&s+1+n>o)t=s;else break}while(!0);return yield _M,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const t=this.flowLevel>0;let n=this.pos-1,i=this.pos-1,r;for(;r=this.buffer[++i];)if(r===":"){const s=this.buffer[i+1];if(Ol(s)||t&&Qw.has(s))break;n=i}else if(Ol(r)){let s=this.buffer[i+1];if(r==="\r"&&(s===` `?(i+=1,r=` `,s=this.buffer[i+1]):n=i),s==="#"||t&&Qw.has(s))break;if(r===` -`){const a=this.continueScalar(i+1);if(a===-1)break;i=Math.max(i,a-2)}}else{if(t&&Qw.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield _M,yield*this.pushToIndex(n+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,n){const i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(n&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(GC),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{const n=this.flowLevel>0,i=this.charAt(1);if(Ol(i)||n&&Qw.has(i)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,n=this.buffer[t];for(;!Ol(n)&&n!==">";)n=this.buffer[++t];return yield*this.pushToIndex(n===">"?t+1:t,!1)}else{let t=this.pos+1,n=this.buffer[t];for(;n;)if(KYe.has(n))n=this.buffer[++t];else if(n==="%"&&vF.has(this.buffer[t+1])&&vF.has(this.buffer[t+2]))n=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){const t=this.buffer[this.pos];return t===` +`){const a=this.continueScalar(i+1);if(a===-1)break;i=Math.max(i,a-2)}}else{if(t&&Qw.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield _M,yield*this.pushToIndex(n+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,n){const i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(n&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(GC),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{const n=this.flowLevel>0,i=this.charAt(1);if(Ol(i)||n&&Qw.has(i)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,n=this.buffer[t];for(;!Ol(n)&&n!==">";)n=this.buffer[++t];return yield*this.pushToIndex(n===">"?t+1:t,!1)}else{let t=this.pos+1,n=this.buffer[t];for(;n;)if(JYe.has(n))n=this.buffer[++t];else if(n==="%"&&vF.has(this.buffer[t+1])&&vF.has(this.buffer[t+2]))n=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){const t=this.buffer[this.pos];return t===` `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===` -`?yield*this.pushCount(2):0}*pushSpaces(t){let n=this.pos-1,i;do i=this.buffer[++n];while(i===" "||t&&i===" ");const r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(t){let n=this.pos,i=this.buffer[n];for(;!t(i);)i=this.buffer[++n];return yield*this.pushToIndex(n,!1)}}class tGe{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let n=0,i=this.lineStarts.length;for(;n>1;this.lineStarts[s]=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;((n=e[++t])==null?void 0:n.type)==="space";);return e.splice(t,e.length)}function Zk(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const t=this.peek(1);if(this.type==="doc-end"&&(t==null?void 0:t.type)!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){const n=t??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{const i=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in i?i.indent:0:n.type==="flow-collection"&&i.type==="document"&&(n.indent=0),n.type==="flow-collection"&&SF(n),i.type){case"document":i.value=n;break;case"block-scalar":i.props.push(n);break;case"block-map":{const r=i.items[i.items.length-1];if(r.value){i.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{const r=i.items[i.items.length-1];r.value?i.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{const r=i.items[i.items.length-1];!r||r.value?i.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){const r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&wF(r.start)===-1&&(n.indent===0||r.start.every(s=>s.type!=="comment"||s.indent0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(t){let n=this.pos,i=this.buffer[n];for(;!t(i);)i=this.buffer[++n];return yield*this.pushToIndex(n,!1)}}class nGe{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let n=0,i=this.lineStarts.length;for(;n>1;this.lineStarts[s]=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;((n=e[++t])==null?void 0:n.type)==="space";);return e.splice(t,e.length)}function Zk(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const t=this.peek(1);if(this.type==="doc-end"&&(t==null?void 0:t.type)!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){const n=t??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{const i=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in i?i.indent:0:n.type==="flow-collection"&&i.type==="document"&&(n.indent=0),n.type==="flow-collection"&&SF(n),i.type){case"document":i.value=n;break;case"block-scalar":i.props.push(n);break;case"block-map":{const r=i.items[i.items.length-1];if(r.value){i.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{const r=i.items[i.items.length-1];r.value?i.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{const r=i.items[i.items.length-1];!r||r.value?i.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){const r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&wF(r.start)===-1&&(n.indent===0||r.start.every(s=>s.type!=="comment"||s.indent=t.indent){const r=!this.onKeyLine&&this.indent===t.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind";let a=[];if(s&&n.sep&&!n.value){const o=[];for(let c=0;ct.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Xd(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(Wle(n.key)&&!Xd(n.sep,"newline")){const o=fm(n.start),c=n.key,u=n.sep;u.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:c,sep:u}]})}else a.length>0?n.sep=n.sep.concat(a,this.sourceToken):n.sep.push(this.sourceToken);else if(Xd(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{const o=fm(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Xd(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);s||n.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Xd(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){var i;const n=t.items[t.items.length-1];switch(this.type){case"newline":if(n.value){const r="end"in n.value?n.value.end:void 0,s=Array.isArray(r)?r[r.length-1]:void 0;(s==null?void 0:s.type)==="comment"?r==null||r.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,t.indent)){const r=t.items[t.items.length-2],s=(i=r==null?void 0:r.value)==null?void 0:i.end;if(Array.isArray(s)){Zk(s,n.start),s.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=t.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;n.value||Xd(n.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>t.indent){const r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){const n=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while((i==null?void 0:i.type)==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?t.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const r=this.flowScalar(this.type);!n||n.value?t.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}const i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{const i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){const r=Bw(i),s=fm(r);SF(t);const a=t.end.splice(1,t.end.length);a.push(this.sourceToken);const o={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:s,key:t,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let n=this.source.indexOf(` +`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){var i;const n=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){const r="end"in n.value?n.value.end:void 0,s=Array.isArray(r)?r[r.length-1]:void 0;(s==null?void 0:s.type)==="comment"?r==null||r.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,t.indent)){const r=t.items[t.items.length-2],s=(i=r==null?void 0:r.value)==null?void 0:i.end;if(Array.isArray(s)){Zk(s,n.start),s.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=t.indent){const r=!this.onKeyLine&&this.indent===t.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind";let a=[];if(s&&n.sep&&!n.value){const o=[];for(let c=0;ct.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Xd(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(Zle(n.key)&&!Xd(n.sep,"newline")){const o=fm(n.start),c=n.key,u=n.sep;u.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:c,sep:u}]})}else a.length>0?n.sep=n.sep.concat(a,this.sourceToken):n.sep.push(this.sourceToken);else if(Xd(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{const o=fm(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?t.items.push({start:a,key:null,sep:[this.sourceToken]}):Xd(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);s||n.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Xd(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){var i;const n=t.items[t.items.length-1];switch(this.type){case"newline":if(n.value){const r="end"in n.value?n.value.end:void 0,s=Array.isArray(r)?r[r.length-1]:void 0;(s==null?void 0:s.type)==="comment"?r==null||r.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,t.indent)){const r=t.items[t.items.length-2],s=(i=r==null?void 0:r.value)==null?void 0:i.end;if(Array.isArray(s)){Zk(s,n.start),s.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=t.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;n.value||Xd(n.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>t.indent){const r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){const n=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while((i==null?void 0:i.type)==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?t.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const r=this.flowScalar(this.type);!n||n.value?t.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}const i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{const i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){const r=Bw(i),s=fm(r);SF(t);const a=t.end.splice(1,t.end.length);a.push(this.sourceToken);const o={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:s,key:t,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let n=this.source.indexOf(` `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(` -`,n)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=Bw(t),i=fm(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=Bw(t),i=fm(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function iGe(e){const t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new tGe||null,prettyErrors:t}}function Zle(e,t={}){const{lineCounter:n,prettyErrors:i}=iGe(t),r=new nGe(n==null?void 0:n.addNewLine),s=new WYe(t);let a=null;for(const o of s.compose(r.parse(e),!0,e.length))if(!a)a=o;else if(a.options.logLevel!=="silent"){a.errors.push(new PO(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(a.errors.forEach(OF(e,n)),a.warnings.forEach(OF(e,n))),a}function rGe(e,t,n){let i;const r=Zle(e,n);if(!r)return null;if(r.warnings.forEach(s=>vle(r.options.logLevel,s)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function Kle(e,t,n){let i=null;if(Array.isArray(t)&&(i=t),e===void 0){const{keepUndefined:r}={};if(!r)return}return V1(e)&&!i?e.toString(n):new Y1(e,i,n).toString(n)}const Jle=1024;let sGe=0,Ho=class{constructor(t,n){this.from=t,this.to=n}};class sn{constructor(t={}){this.id=sGe++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ss.match(t)),n=>{let i=t(n);return i===void 0?null:[this,i]}}}sn.closedBy=new sn({deserialize:e=>e.split(" ")});sn.openedBy=new sn({deserialize:e=>e.split(" ")});sn.group=new sn({deserialize:e=>e.split(" ")});sn.isolate=new sn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});sn.contextHash=new sn({perNode:!0});sn.lookAhead=new sn({perNode:!0});sn.mounted=new sn({perNode:!0});class _g{constructor(t,n,i,r=!1){this.tree=t,this.overlay=n,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[sn.mounted.id]}}const aGe=Object.create(null);class ss{constructor(t,n,i,r=0){this.name=t,this.props=n,this.id=i,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):aGe,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new ss(t.name||"",n,t.id,i);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(sn.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let i in t)for(let r of i.split(" "))n[r]=t[i];return i=>{for(let r=i.prop(sn.group),s=-1;s<(r?r.length:0);s++){let a=n[s<0?i.name:r[s]];if(a)return a}}}}ss.none=new ss("",Object.create(null),0,8);class W1{constructor(t){this.types=t;for(let n=0;n0;for(let c=this.cursor(a|si.IncludeAnonymous);;){let u=!1;if(c.from<=s&&c.to>=r&&(!o&&c.type.isAnonymous||n(c)!==!1)){if(c.firstChild())continue;u=!0}for(;u&&i&&(o||!c.type.isAnonymous)&&i(c),!c.nextSibling();){if(!c.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:e4(ss.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new li(this.type,n,i,r,this.propValues),t.makeTree||((n,i,r)=>new li(ss.none,n,i,r)))}static build(t){return uGe(t)}}li.empty=new li(ss.none,[],[],0);class K3{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new K3(this.buffer,this.index)}}class zf{constructor(t,n,i){this.buffer=t,this.length=n,this.set=i}get type(){return ss.none}toString(){let t=[];for(let n=0;n0));c=a[c+3]);return o}slice(t,n,i){let r=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,c=0;o=t&&nt;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function Cx(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?o.length:-1;t!=u;t+=n){let d=o[t],f=c[t]+a.from,h;if(!(!(s&si.EnterBracketed&&d instanceof li&&(h=_g.get(d))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+d.length)&&!ece(r,i,f,f+d.length))){if(d instanceof zf){if(s&si.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,i-f,r);if(p>-1)return new Cc(new oGe(a,d,t,f),null,p)}else if(s&si.IncludeAnonymous||!d.type.isAnonymous||J3(d)){let p;if(!(s&si.IgnoreMounts)&&(p=_g.get(d))&&!p.overlay)return new Ks(p.tree,f,t,a);let g=new Ks(d,f,t,a);return s&si.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?d.children.length-1:0,n,i,r,s)}}}if(s&si.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,n,i=0){let r;if(!(i&si.IgnoreOverlays)&&(r=_g.get(this._tree))&&r.overlay){let s=t-this.from,a=i&si.EnterBracketed&&r.bracketed;for(let{from:o,to:c}of r.overlay)if((n>0||a?o<=s:o=s:c>s))return new Ks(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function kF(e,t,n,i){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function AM(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class oGe{constructor(t,n,i,r){this.parent=t,this.buffer=n,this.index=i,this.start=r}}class Cc extends tce{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,i){super(),this.context=t,this._parent=n,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t,n-this.context.start,i);return s<0?null:new Cc(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,n,i=0){if(i&si.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new Cc(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Cc(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Cc(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let a=i.buffer[this.index+1];t.push(i.slice(r,s,a)),n.push(0)}return new li(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function nce(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;sn.from||a.to=t){let o=new Ks(a.tree,a.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Cx(o,t,n,!1))}}return r?nce(r):i}class Kk{get name(){return this.type.name}constructor(t,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~si.EnterBracketed,t instanceof Ks)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return t?t instanceof Ks?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],t,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,i=this.mode){return this.buffer?i&si.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&si.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&si.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,i=this.stack.length-1;if(t<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,i,{buffer:r}=this;if(r){if(t>0){if(this.index-1)for(let s=n+t,a=t<0?-1:i._tree.children.length;s!=a;s+=t){let o=i._tree.children[s];if(this.mode&si.IncludeAnonymous||o instanceof zf||!o.type.isAnonymous||J3(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to=0;){for(let a=t;a;a=a._parent)if(a.index==r){if(r==this.index)return a;n=a,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return AM(this._tree,t,r);let a=i[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[r]&&t[r]!=a.name)return!1;r--}}return!0}}function J3(e){return e.children.some(t=>t instanceof zf||!t.type.isAnonymous||J3(t))}function uGe(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=Jle,reused:s=[],minRepeatType:a=i.types.length}=e,o=Array.isArray(n)?new K3(n,n.length):n,c=i.types,u=0,d=0;function f(E,S,k,T,A,N){let{id:C,start:M,end:L,size:P}=o,Q=d,j=u;if(P<0)if(o.next(),P==-1){let X=s[C];k.push(X),T.push(M-E);return}else if(P==-3){u=C;return}else if(P==-4){d=C;return}else throw new RangeError(`Unrecognized record size: ${P}`);let $=c[C],U,B,I=M-E;if(L-M<=r&&(B=y(o.pos-S,A))){let X=new Uint16Array(B.size-B.skip),q=o.pos-B.size,D=X.length;for(;o.pos>q;)D=O(B.start,X,D);U=new zf(X,L-B.start,i),I=B.start-E}else{let X=o.pos-P;o.next();let q=[],D=[],H=C>=a?C:-1,re=0,fe=L;for(;o.pos>X;)H>=0&&o.id==H&&o.size>=0?(o.end<=fe-r&&(g(q,D,M,re,o.end,fe,H,Q,j),re=q.length,fe=o.end),o.next()):N>2500?h(M,X,q,D):f(M,X,q,D,H,N+1);if(H>=0&&re>0&&re-1&&re>0){let Ae=p($,j);U=e4($,q,D,0,q.length,0,L-M,Ae,Ae)}else U=b($,q,D,L-M,Q-L,j)}k.push(U),T.push(I)}function h(E,S,k,T){let A=[],N=0,C=-1;for(;o.pos>S;){let{id:M,start:L,end:P,size:Q}=o;if(Q>4)o.next();else{if(C>-1&&L=0;P-=3)M[Q++]=A[P],M[Q++]=A[P+1]-L,M[Q++]=A[P+2]-L,M[Q++]=Q;k.push(new zf(M,A[2]-L,i)),T.push(L-E)}}function p(E,S){return(k,T,A)=>{let N=0,C=k.length-1,M,L;if(C>=0&&(M=k[C])instanceof li){if(!C&&M.type==E&&M.length==A)return M;(L=M.prop(sn.lookAhead))&&(N=T[C]+M.length+L)}return b(E,k,T,A,N,S)}}function g(E,S,k,T,A,N,C,M,L){let P=[],Q=[];for(;E.length>T;)P.push(E.pop()),Q.push(S.pop()+k-A);E.push(b(i.types[C],P,Q,N-A,M-N,L)),S.push(A-k)}function b(E,S,k,T,A,N,C){if(N){let M=[sn.contextHash,N];C=C?[M].concat(C):[M]}if(A>25){let M=[sn.lookAhead,A];C=C?[M].concat(C):[M]}return new li(E,S,k,T,C)}function y(E,S){let k=o.fork(),T=0,A=0,N=0,C=k.end-r,M={size:0,start:0,skip:0};e:for(let L=k.pos-E;k.pos>L;){let P=k.size;if(k.id==S&&P>=0){M.size=T,M.start=A,M.skip=N,N+=4,T+=4,k.next();continue}let Q=k.pos-P;if(P<0||Q=a?4:0,$=k.start;for(k.next();k.pos>Q;){if(k.size<0)if(k.size==-3||k.size==-4)j+=4;else break e;else k.id>=a&&(j+=4);k.next()}A=$,T+=P,N+=j}return(S<0||T==E)&&(M.size=T,M.start=A,M.skip=N),M.size>4?M:void 0}function O(E,S,k){let{id:T,start:A,end:N,size:C}=o;if(o.next(),C>=0&&T4){let L=o.pos-(C-4);for(;o.pos>L;)k=O(E,S,k)}S[--k]=M,S[--k]=N-E,S[--k]=A-E,S[--k]=T}else C==-3?u=T:C==-4&&(d=T);return k}let v=[],x=[];for(;o.pos>0;)f(e.start||0,e.bufferStart||0,v,x,-1,0);let w=(t=e.length)!==null&&t!==void 0?t:v.length?x[0]+v[0].length:0;return new li(c[e.topID],v.reverse(),x.reverse(),w)}const TF=new WeakMap;function uE(e,t){if(!e.isAnonymous||t instanceof zf||t.type!=e)return 1;let n=TF.get(t);if(n==null){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof li)){n=1;break}n+=uE(e,i)}TF.set(t,n)}return n}function e4(e,t,n,i,r,s,a,o,c){let u=0;for(let g=i;g=d)break;S+=k}if(x==w+1){if(S>d){let k=g[w];p(k.children,k.positions,0,k.children.length,b[w]+v);continue}f.push(g[w])}else{let k=b[x-1]+g[x-1].length-E;f.push(e4(e,g,b,w,x,E,k,null,c))}h.push(E+v-s)}}return p(t,n,i,r,0),(o||c)(f,h,a)}class t4{constructor(){this.map=new WeakMap}setBuffer(t,n,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(n,i)}getBuffer(t,n){let i=this.map.get(t);return i&&i.get(n)}set(t,n){t instanceof Cc?this.setBuffer(t.context.buffer,t.index,n):t instanceof Ks&&this.map.set(t.tree,n)}get(t){return t instanceof Cc?this.getBuffer(t.context.buffer,t.index):t instanceof Ks?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Hu{constructor(t,n,i,r,s=!1,a=!1){this.from=t,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],i=!1){let r=[new Hu(0,t.length,t,0,!1,i)];for(let s of n)s.to>t.length&&r.push(s);return r}static applyChanges(t,n,i=128){if(!n.length)return t;let r=[],s=1,a=t.length?t[0]:null;for(let o=0,c=0,u=0;;o++){let d=o=i)for(;a&&a.from=h.from||f<=h.to||u){let p=Math.max(h.from,c)-u,g=Math.min(h.to,f)-u;h=p>=g?null:new Hu(p,g,h.tree,h.offset+u,o>0,!!d)}if(h&&r.push(h),a.to>f)break;a=snew Ho(r.from,r.to)):[new Ho(0,0)]:[new Ho(0,t.length)],this.createParse(t,n||[],i)}parse(t,n,i){let r=this.startParse(t,n,i);for(;;){let s=r.advance();if(s)return s}}}class dGe{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function ice(e){return(t,n,i,r)=>new hGe(t,e,n,i,r)}class _F{constructor(t,n,i,r,s,a){this.parser=t,this.parse=n,this.overlay=i,this.bracketed=r,this.target=s,this.from=a}}function AF(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class fGe{constructor(t,n,i,r,s,a,o,c){this.parser=t,this.predicate=n,this.mounts=i,this.index=r,this.start=s,this.bracketed=a,this.target=o,this.prev=c,this.depth=0,this.ranges=[]}}const NM=new sn({perNode:!0});class hGe{constructor(t,n,i,r,s){this.nest=n,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new li(i.type,i.children,i.positions,i.length,i.propValues.concat([[NM,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[sn.mounted.id]=new _g(n,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n=this.stoppedAt)o=!1;else if(t.hasNode(r)){if(n){let u=n.mounts.find(d=>d.frag.from<=r.from&&d.frag.to>=r.to&&d.mount.overlay);if(u)for(let d of u.mount.overlay){let f=d.from+u.pos,h=d.to+u.pos;f>=r.from&&h<=r.to&&!n.ranges.some(p=>p.fromf)&&n.ranges.push({from:f,to:h})}}o=!1}else if(i&&(a=pGe(i.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Ho(f.from-r.from,f.to-r.from)):null,!!s.bracketed,r.tree,d.length?d[0].from:r.from)),s.overlay?d.length&&(i={ranges:d,depth:0,prev:i}):o=!1}}else if(n&&(c=n.predicate(r))&&(c===!0&&(c=new Ho(r.from,r.to)),c.from=0&&n.ranges[u].to==c.from?n.ranges[u]={from:n.ranges[u].from,to:c.to}:n.ranges.push(c)}if(o&&r.firstChild())n&&n.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(n&&!--n.depth){let u=jF(this.ranges,n.ranges);u.length&&(AF(u),this.inner.splice(n.index,0,new _F(n.parser,n.parser.startParse(this.input,RF(n.mounts,u),u),n.ranges.map(d=>new Ho(d.from-n.start,d.to-n.start)),n.bracketed,n.target,u[0].from))),n=n.prev}i&&!--i.depth&&(i=i.prev)}}}}function pGe(e,t,n){for(let i of e){if(i.from>=n)break;if(i.to>t)return i.from<=t&&i.to>=n?2:1}return 0}function NF(e,t,n,i,r,s){if(t=t&&n.enter(i,1,si.IgnoreOverlays|si.ExcludeBuffers)))if(n.to<=t)n.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof li)n=n.children[0];else break}return!1}}let gGe=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(n=i.tree.prop(NM))!==null&&n!==void 0?n:i.to,this.inner=new CF(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(NM))!==null&&t!==void 0?t:n.to,this.inner=new CF(n.tree,-n.offset)}}findMounts(t,n){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(i=s.tree)===null||i===void 0?void 0:i.prop(sn.mounted);if(a&&a.parser==n)for(let o=this.fragI;o=s.to)break;c.tree==this.curFrag.tree&&r.push({frag:c,pos:s.from-c.offset,mount:a})}}}return r}};function jF(e,t){let n=null,i=t;for(let r=1,s=0;r=o)break;c.to<=a||(n||(i=n=t.slice()),c.fromo&&n.splice(s+1,0,new Ho(o,c.to))):c.to>o?n[s--]=new Ho(o,c.to):n.splice(s--,1))}}return i}function bGe(e,t,n,i){let r=0,s=0,a=!1,o=!1,c=-1e9,u=[];for(;;){let d=r==e.length?1e9:a?e[r].to:e[r].from,f=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(c,n),p=Math.min(d,f,i);hnew Ho(h.from+i,h.to+i)),f=bGe(t,d,c,u);for(let h=0,p=c;;h++){let g=h==f.length,b=g?u:f[h].from;if(b>p&&n.push(new Hu(p,b,r.tree,-a,s.from>=p||s.openStart,s.to<=b||s.openEnd)),g)break;p=f[h].to}}else n.push(new Hu(c,u,r.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}var IF={};class Jk{constructor(t,n,i,r,s,a,o,c,u,d=0,f){this.p=t,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=a,this.buffer=o,this.bufferBase=c,this.curContext=u,this.lookAhead=d,this.parent=f}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,i=0){let r=t.parser.context;return new Jk(t,[],n,i,i,0,[],0,r?new PF(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let i=t>>19,r=t&65535,{parser:s}=this.p,a=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(r,u)}storeNode(t,n,i,r=4,s=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(n==i)return;if(this.buffer[a-2]>=n){this.buffer[a-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(t,n,i,r);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let o=!1;for(let c=a;c>0&&this.buffer[c-2]>i;c-=4)if(this.buffer[c-1]>=0){o=!0;break}if(o)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,r>4&&(r-=4)}this.buffer[a]=t,this.buffer[a+1]=n,this.buffer[a+2]=i,this.buffer[a+3]=r}}shift(t,n,i,r){if(t&131072)this.pushState(t&65535,this.pos);else if(t&262144)this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4);else{let s=t,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(s,1);!o&&(r>i||n<=a.maxNode)&&(this.reducePos=r),this.pushState(s,o?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=a.maxNode&&this.buffer.push(n,i,r,4)}}apply(t,n,i,r){t&65536?this.reduce(t):this.shift(t,n,i,r)}useNode(t,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let r=this.pos;this.reducePos=this.pos=r+t.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let i=t.buffer.slice(n),r=t.bufferBase+n;for(;t&&r==t.bufferBase;)t=t.parent;return new Jk(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new OGe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(i==0)return!1;if(!(i&65536))return!0;n.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,a;sc&1&&o==a)||r.push(n[s],a)}n=r}let i=[];for(let r=0;r>19,r=n&65535,s=this.stack.length-i*3;if(s<0||t.getGoto(this.stack[s],r,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;n=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),t.allActions(r,a=>{if(!(a&393216))if(a&65536){let o=(a>>19)-s;if(o>1){let c=a&65535,u=this.stack.length-o*3;if(u>=0&&t.getGoto(this.stack[u],c,!1)>=0)return o<<19|65536|c}}else{let o=i(a,s+1);if(o!=null)return o}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class PF{constructor(t,n){this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}}class OGe{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let n=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class eT{constructor(t,n,i){this.stack=t,this.pos=n,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new eT(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new eT(this.stack,this.pos,this.index)}}function MO(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let i=0,r=0;i=92&&a--,a>=34&&a--;let c=a-32;if(c>=46&&(c-=46,o=!0),s+=c,o)break;s*=46}n?n[r++]=s:n=new t(s)}return n}class dE{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const MF=new dE;class yGe{constructor(t,n){this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=MF,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(t,n){let i=this.range,r=this.rangeIndex,s=this.pos+t;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let a=this.ranges[++r];s+=a.from-i.to,i=a}return s}clipPos(t){if(t>=this.range.from&&tt)return Math.max(t,n.from);return this.end}peek(t){let n=this.chunkOff+t,i,r;if(n>=0&&n=this.chunk2Pos&&io.to&&(this.chunk2=this.chunk2.slice(0,o.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(t,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,n){if(n?(this.token=n,n.start=t,n.lookAhead=t+1,n.value=n.extended=-1):this.token=MF,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,n-this.chunkPos);if(t>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,n-this.chunk2Pos);if(t>=this.range.from&&n<=this.range.to)return this.input.read(t,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>t&&(i+=this.input.read(Math.max(r.from,t),Math.min(r.to,n)))}return i}}class Ag{constructor(t,n){this.data=t,this.id=n}token(t,n){let{parser:i}=n.p;rce(this.data,t,n,this.id,i.data,i.tokenPrecTable)}}Ag.prototype.contextual=Ag.prototype.fallback=Ag.prototype.extend=!1;class tT{constructor(t,n,i){this.precTable=n,this.elseToken=i,this.data=typeof t=="string"?MO(t):t}token(t,n){let i=t.pos,r=0;for(;;){let s=t.next<0,a=t.resolveOffset(1,1);if(rce(this.data,t,n,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,a==null)break;t.reset(a,t.token)}r&&(t.reset(i,t.token),t.acceptToken(this.elseToken,r))}}tT.prototype.contextual=Ag.prototype.fallback=Ag.prototype.extend=!1;class Lr{constructor(t,n={}){this.token=t,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function rce(e,t,n,i,r,s){let a=0,o=1<0){let g=e[p];if(c.allows(g)&&(t.token.value==-1||t.token.value==g||xGe(g,t.token.value,r,s))){t.acceptToken(g);break}}let d=t.next,f=0,h=e[a+2];if(t.next<0&&h>f&&e[u+h*3-3]==65535){a=e[u+h*3-1];continue e}for(;f>1,g=u+p+(p<<1),b=e[g],y=e[g+1]||65536;if(d=y)f=p+1;else{a=e[g+2],t.advance();continue e}}break}}function LF(e,t,n){for(let i=t,r;(r=e[i])!=65535;i++)if(r==n)return i-t;return-1}function xGe(e,t,n,i){let r=LF(n,i,t);return r<0||LF(n,i,e)t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}let vGe=class{constructor(t,n){this.fragments=t,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?DF(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?DF(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(tt)return this.nextStart=a,null;if(s instanceof li){if(a==t){if(a=Math.max(this.safeFrom,t)&&(this.trees.push(s),this.start.push(a),this.index.push(0))}else this.index[n]++,this.nextStart=a+s.length}}};class wGe{constructor(t,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new dE)}getActions(t){let n=0,i=null,{parser:r}=t.p,{tokenizers:s}=r,a=r.stateSlot(t.state,3),o=t.curContext?t.curContext.hash:0,c=0;for(let u=0;uf.end+25&&(c=Math.max(f.lookAhead,c)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(t,f.extended,f.end,n)),n=this.addActions(t,f.value,f.end,n),!d.extend&&(i=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return c&&t.setLookAhead(c),!i&&t.pos==this.stream.end&&(i=new dE,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,n=this.addActions(t,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let n=new dE,{pos:i,p:r}=t;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(t,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,t),i),t.value>-1){let{parser:s}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(o>>1)){o&1?t.extended=o>>1:t.value=o>>1;break}}}else t.value=0,t.end=this.stream.clipPos(r+1)}putAction(t,n,i,r){for(let s=0;st.bufferLength*4?new vGe(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&t.length==1){let[a]=t;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;an)i.push(o);else{if(this.advanceStack(o,i,t))continue;{r||(r=[],s=[]),r.push(o);let c=this.tokens.getMainToken(o);s.push(c.value,c.end)}}break}}if(!i.length){let a=r&&kGe(r);if(a)return Za&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Za&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let a=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(a)return Za&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((o,c)=>c.score-o.score);i.length>a;)i.pop();i.some(o=>o.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&u.buffer.length>500)if((o.score-u.score||o.buffer.length-u.buffer.length)>0)i.splice(c--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,o)=>o.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let u=t.curContext&&t.curContext.tracker.strict,d=u?t.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(t.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(sn.contextHash)||0)==d))return t.useNode(f,h),Za&&console.log(a+this.stackID(t)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof li)||f.children.length==0||f.positions[0]>0)break;let p=f.children[0];if(p instanceof li&&f.positions[0]==0)f=p;else break}}let o=s.stateSlot(t.state,4);if(o>0)return t.reduce(o),Za&&console.log(a+this.stackID(t)+` (via always-reduce ${s.getName(o&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let c=this.tokens.getActions(t);for(let u=0;ur?n.push(g):i.push(g)}return!1}advanceFully(t,n){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return $F(t,n),!0}}runRecovery(t,n,i){let r=null,s=!1;for(let a=0;a ":"";if(o.deadEnd&&(s||(s=!0,o.restart(),Za&&console.log(d+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let f=o.split(),h=d;for(let p=0;p<10&&f.forceReduce()&&(Za&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));p++)Za&&(h=this.stackID(f)+" -> ");for(let p of o.recoverByInsert(c))Za&&console.log(d+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,i);this.stream.end>o.pos?(u==o.pos&&(u++,c=0),o.recoverByDelete(c,u),Za&&console.log(d+this.stackID(o)+` (via recover-delete ${this.parser.getName(c)})`),$F(o,i)):(!r||r.scoree;class CA{constructor(t){this.start=t.start,this.shift=t.shift||ZC,this.reduce=t.reduce||ZC,this.reuse=t.reuse||ZC,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class ad extends n4{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let o=0;ot.topRules[o][1]),r=[];for(let o=0;o=0)s(d,c,o[u++]);else{let f=o[u+-d];for(let h=-d;h>0;h--)s(o[u++],c,f);u++}}}this.nodeSet=new W1(n.map((o,c)=>ss.define({name:c>=this.minRepeatTerm?void 0:o,id:c,props:r[c],top:i.indexOf(c)>-1,error:c==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(c)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=Jle;let a=MO(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let o=0;otypeof o=="number"?new Ag(a,o):o),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,i){let r=new SGe(this,t,n,i);for(let s of this.wrappers)r=s(r,t,n,i);return r}getGoto(t,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let a=r[s++],o=a&1,c=r[s++];if(o&&i)return c;for(let u=s+(a>>1);s0}validAction(t,n){return!!this.allActions(t,i=>i==n?!0:null)}allActions(t,n){let i=this.stateSlot(t,4),r=i?n(i):void 0;for(let s=this.stateSlot(t,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=_u(this.data,s+2);else break;r=n(_u(this.data,s+1))}return r}nextStates(t){let n=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=_u(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];n.some((s,a)=>a&1&&s==r)||n.push(this.data[i],r)}}return n}configure(t){let n=Object.assign(Object.create(ad.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=i}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=t.tokenizers.find(s=>s.from==i);return r?r.to:i})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=t.specializers.find(o=>o.from==i.external);if(!s)return i;let a=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=QF(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(t)for(let s of t.split(" ")){let a=n.indexOf(s);a>=0&&(i[a]=!0)}let r=null;for(let s=0;si)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,i)<<1|t}return e.get}let TGe=0,xc=class CM{constructor(t,n,i,r){this.name=t,this.set=n,this.base=i,this.modified=r,this.id=TGe++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let i=typeof t=="string"?t:"?";if(t instanceof CM&&(n=t),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new CM(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(t){let n=new nT(t);return i=>i.modified.indexOf(n)>-1?i:nT.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}},_Ge=0;class nT{constructor(t){this.name=t,this.instances=[],this.id=_Ge++}static get(t,n){if(!n.length)return t;let i=n[0].instances.find(o=>o.base==t&&AGe(n,o.modified));if(i)return i;let r=[],s=new xc(t.name,r,t,n);for(let o of n)o.instances.push(s);let a=NGe(n);for(let o of t.set)if(!o.modified.length)for(let c of a)r.push(nT.get(o,c));return s}}function AGe(e,t){return e.length==t.length&&e.every((n,i)=>n==t[i])}function NGe(e){let t=[[]];for(let n=0;ni.length-n.length)}function xd(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],a=2,o=r;for(let f=0;;){if(o=="..."&&f>0&&f+3==r.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){a=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);o=r.slice(f)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+r);let d=new jx(i,a,c>0?s.slice(0,c):null);t[u]=d.sort(t[u])}}return sce.add(t)}const sce=new sn({combine(e,t){let n,i,r;for(;e||t;){if(!e||t&&e.depth>=t.depth?(r=t,t=t.next):(r=e,e=e.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new jx(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class jx{constructor(t,n,i,r){this.tags=t,this.mode=n,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let a=r;for(let o of s)for(let c of o.set){let u=n[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:i}}function CGe(e,t){let n=null;for(let i of e){let r=i.style(t);r&&(n=n?n+" "+r:r)}return n}function jGe(e,t,n,i=0,r=e.length){let s=new RGe(i,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),i,r,"",s.highlighters),s.flush(r)}class RGe{constructor(t,n,i){this.at=t,this.highlighters=n,this.span=i,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,i,r,s){let{type:a,from:o,to:c}=t;if(o>=i||c<=n)return;a.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(a)));let u=r,d=IGe(t)||jx.empty,f=CGe(s,d.tags);if(f&&(u&&(u+=" "),u+=f,d.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(n,o),u),d.opaque)return;let h=t.tree&&t.tree.prop(sn.mounted);if(h&&h.overlay){let p=t.node.enter(h.overlay[0].from+o,1),g=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),b=t.firstChild();for(let y=0,O=o;;y++){let v=y=x||!t.nextSibling())););if(!v||x>i)break;O=v.to+o,O>n&&(this.highlightRange(p.cursor(),Math.max(n,v.from+o),Math.min(i,O),"",g),this.startSpan(Math.min(i,O),u))}b&&t.parent()}else if(t.firstChild()){h&&(r="");do if(!(t.to<=n)){if(t.from>=i)break;this.highlightRange(t,n,i,r,s),this.startSpan(Math.min(i,t.to),u)}while(t.nextSibling());t.parent()}}}function IGe(e){let t=e.type.prop(sce);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const pt=xc.define,zw=pt(),qd=pt(),BF=pt(qd),UF=pt(qd),Hd=pt(),Fw=pt(Hd),KC=pt(Hd),gc=pt(),ph=pt(gc),fc=pt(),hc=pt(),jM=pt(),rO=pt(jM),Vw=pt(),G={comment:zw,lineComment:pt(zw),blockComment:pt(zw),docComment:pt(zw),name:qd,variableName:pt(qd),typeName:BF,tagName:pt(BF),propertyName:UF,attributeName:pt(UF),className:pt(qd),labelName:pt(qd),namespace:pt(qd),macroName:pt(qd),literal:Hd,string:Fw,docString:pt(Fw),character:pt(Fw),attributeValue:pt(Fw),number:KC,integer:pt(KC),float:pt(KC),bool:pt(Hd),regexp:pt(Hd),escape:pt(Hd),color:pt(Hd),url:pt(Hd),keyword:fc,self:pt(fc),null:pt(fc),atom:pt(fc),unit:pt(fc),modifier:pt(fc),operatorKeyword:pt(fc),controlKeyword:pt(fc),definitionKeyword:pt(fc),moduleKeyword:pt(fc),operator:hc,derefOperator:pt(hc),arithmeticOperator:pt(hc),logicOperator:pt(hc),bitwiseOperator:pt(hc),compareOperator:pt(hc),updateOperator:pt(hc),definitionOperator:pt(hc),typeOperator:pt(hc),controlOperator:pt(hc),punctuation:jM,separator:pt(jM),bracket:rO,angleBracket:pt(rO),squareBracket:pt(rO),paren:pt(rO),brace:pt(rO),content:gc,heading:ph,heading1:pt(ph),heading2:pt(ph),heading3:pt(ph),heading4:pt(ph),heading5:pt(ph),heading6:pt(ph),contentSeparator:pt(gc),list:pt(gc),quote:pt(gc),emphasis:pt(gc),strong:pt(gc),link:pt(gc),monospace:pt(gc),strikethrough:pt(gc),inserted:pt(),deleted:pt(),changed:pt(),invalid:pt(),meta:Vw,documentMeta:pt(Vw),annotation:pt(Vw),processingInstruction:pt(Vw),definition:xc.defineModifier("definition"),constant:xc.defineModifier("constant"),function:xc.defineModifier("function"),standard:xc.defineModifier("standard"),local:xc.defineModifier("local"),special:xc.defineModifier("special")};for(let e in G){let t=G[e];t instanceof xc&&(t.name=e)}ace([{tag:G.link,class:"tok-link"},{tag:G.heading,class:"tok-heading"},{tag:G.emphasis,class:"tok-emphasis"},{tag:G.strong,class:"tok-strong"},{tag:G.keyword,class:"tok-keyword"},{tag:G.atom,class:"tok-atom"},{tag:G.bool,class:"tok-bool"},{tag:G.url,class:"tok-url"},{tag:G.labelName,class:"tok-labelName"},{tag:G.inserted,class:"tok-inserted"},{tag:G.deleted,class:"tok-deleted"},{tag:G.literal,class:"tok-literal"},{tag:G.string,class:"tok-string"},{tag:G.number,class:"tok-number"},{tag:[G.regexp,G.escape,G.special(G.string)],class:"tok-string2"},{tag:G.variableName,class:"tok-variableName"},{tag:G.local(G.variableName),class:"tok-variableName tok-local"},{tag:G.definition(G.variableName),class:"tok-variableName tok-definition"},{tag:G.special(G.variableName),class:"tok-variableName2"},{tag:G.definition(G.propertyName),class:"tok-propertyName tok-definition"},{tag:G.typeName,class:"tok-typeName"},{tag:G.namespace,class:"tok-namespace"},{tag:G.className,class:"tok-className"},{tag:G.macroName,class:"tok-macroName"},{tag:G.propertyName,class:"tok-propertyName"},{tag:G.operator,class:"tok-operator"},{tag:G.comment,class:"tok-comment"},{tag:G.meta,class:"tok-meta"},{tag:G.invalid,class:"tok-invalid"},{tag:G.punctuation,class:"tok-punctuation"}]);const PGe=316,MGe=317,zF=1,LGe=2,DGe=3,$Ge=4,QGe=318,BGe=320,UGe=321,zGe=5,FGe=6,VGe=0,RM=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],oce=125,XGe=59,IM=47,qGe=42,HGe=43,YGe=45,GGe=60,WGe=44,ZGe=63,KGe=46,JGe=91,eWe=new CA({start:!1,shift(e,t){return t==zGe||t==FGe||t==BGe?e:t==UGe},strict:!1}),tWe=new Lr((e,t)=>{let{next:n}=e;(n==oce||n==-1||t.context)&&e.acceptToken(QGe)},{contextual:!0,fallback:!0}),nWe=new Lr((e,t)=>{let{next:n}=e,i;RM.indexOf(n)>-1||n==IM&&((i=e.peek(1))==IM||i==qGe)||n!=oce&&n!=XGe&&n!=-1&&!t.context&&e.acceptToken(PGe)},{contextual:!0}),iWe=new Lr((e,t)=>{e.next==JGe&&!t.context&&e.acceptToken(MGe)},{contextual:!0}),rWe=new Lr((e,t)=>{let{next:n}=e;if(n==HGe||n==YGe){if(e.advance(),n==e.next){e.advance();let i=!t.context&&t.canShift(zF);e.acceptToken(i?zF:LGe)}}else n==ZGe&&e.peek(1)==KGe&&(e.advance(),e.advance(),(e.next<48||e.next>57)&&e.acceptToken(DGe))},{contextual:!0});function JC(e,t){return e>=65&&e<=90||e>=97&&e<=122||e==95||e>=192||!t&&e>=48&&e<=57}const sWe=new Lr((e,t)=>{if(e.next!=GGe||!t.dialectEnabled(VGe)||(e.advance(),e.next==IM))return;let n=0;for(;RM.indexOf(e.next)>-1;)e.advance(),n++;if(JC(e.next,!0)){for(e.advance(),n++;JC(e.next,!1);)e.advance(),n++;for(;RM.indexOf(e.next)>-1;)e.advance(),n++;if(e.next==WGe)return;for(let i=0;;i++){if(i==7){if(!JC(e.next,!0))return;break}if(e.next!="extends".charCodeAt(i))break;e.advance(),n++}}e.acceptToken($Ge,-n)}),aWe=xd({"get set async static":G.modifier,"for while do if else switch try catch finally return throw break continue default case defer":G.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":G.operatorKeyword,"let var const using function class extends":G.definitionKeyword,"import export from":G.moduleKeyword,"with debugger new":G.keyword,TemplateString:G.special(G.string),super:G.atom,BooleanLiteral:G.bool,this:G.self,null:G.null,Star:G.modifier,VariableName:G.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":G.function(G.variableName),VariableDefinition:G.definition(G.variableName),Label:G.labelName,PropertyName:G.propertyName,PrivatePropertyName:G.special(G.propertyName),"CallExpression/MemberExpression/PropertyName":G.function(G.propertyName),"FunctionDeclaration/VariableDefinition":G.function(G.definition(G.variableName)),"ClassDeclaration/VariableDefinition":G.definition(G.className),"NewExpression/VariableName":G.className,PropertyDefinition:G.definition(G.propertyName),PrivatePropertyDefinition:G.definition(G.special(G.propertyName)),UpdateOp:G.updateOperator,"LineComment Hashbang":G.lineComment,BlockComment:G.blockComment,Number:G.number,String:G.string,Escape:G.escape,ArithOp:G.arithmeticOperator,LogicOp:G.logicOperator,BitOp:G.bitwiseOperator,CompareOp:G.compareOperator,RegExp:G.regexp,Equals:G.definitionOperator,Arrow:G.function(G.punctuation),": Spread":G.punctuation,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace,"InterpolationStart InterpolationEnd":G.special(G.brace),".":G.derefOperator,", ;":G.separator,"@":G.meta,TypeName:G.typeName,TypeDefinition:G.definition(G.typeName),"type enum interface implements namespace module declare":G.definitionKeyword,"abstract global Privacy readonly override":G.modifier,"is keyof unique infer asserts":G.operatorKeyword,JSXAttributeValue:G.attributeValue,JSXText:G.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":G.angleBracket,"JSXIdentifier JSXNameSpacedName":G.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":G.attributeName,"JSXBuiltin/JSXIdentifier":G.standard(G.tagName)}),oWe={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},lWe={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},cWe={__proto__:null,"<":193},uWe=ad.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:eWe,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[aWe],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[nWe,iWe,rWe,sWe,2,3,4,5,6,7,8,9,10,11,12,13,14,tWe,new tT("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new tT("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:e=>oWe[e]||-1},{term:343,get:e=>lWe[e]||-1},{term:95,get:e=>cWe[e]||-1}],tokenPrec:15201});let PM=[],lce=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t>1;if(e=lce[i])t=i+1;else return!0;if(t==n)return!1}}function FF(e){return e>=127462&&e<=127487}const VF=8205;function fWe(e,t,n=!0,i=!0){return(n?cce:hWe)(e,t,i)}function cce(e,t,n){if(t==e.length)return t;t&&uce(e.charCodeAt(t))&&dce(e.charCodeAt(t-1))&&t--;let i=ej(e,t);for(t+=XF(i);t=0&&FF(ej(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function hWe(e,t,n){for(;t>1;){let i=cce(e,t-2,n);if(i=56320&&e<57344}function dce(e){return e>=55296&&e<56320}function XF(e){return e<65536?1:2}let ei=class fce{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,i){[t,n]=O0(this,t,n);let r=[];return this.decompose(0,t,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),wc.from(r,this.length-(n-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=O0(this,t,n);let i=[];return this.decompose(t,n,i,0),wc.from(i,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),r=new wy(this),s=new wy(t);for(let a=n,o=n;;){if(r.next(a),s.next(a),a=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(o+=r.value.length,r.done||o>=i)return!0}}iter(t=1){return new wy(this,t)}iterRange(t,n=this.length){return new hce(this,t,n)}iterLines(t,n){let i;if(t==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(t).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new pce(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?fce.empty:t.length<=32?new Nr(t):wc.from(Nr.split(t,[]))}};class Nr extends ei{constructor(t,n=pWe(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,i,r){for(let s=0;;s++){let a=this.text[s],o=r+a.length;if((n?i:o)>=t)return new mWe(r,o,i,a);r=o+1,i++}}decompose(t,n,i,r){let s=t<=0&&n>=this.length?this:new Nr(qF(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),o=fE(s.text,a.text.slice(),0,s.length);if(o.length<=32)i.push(new Nr(o,a.length+s.length));else{let c=o.length>>1;i.push(new Nr(o.slice(0,c)),new Nr(o.slice(c)))}}else i.push(s)}replace(t,n,i){if(!(i instanceof Nr))return super.replace(t,n,i);[t,n]=O0(this,t,n);let r=fE(this.text,fE(i.text,qF(this.text,0,t)),n),s=this.length+i.length-(n-t);return r.length<=32?new Nr(r,s):wc.from(Nr.split(r,[]),s)}sliceString(t,n=this.length,i=` +`,n)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=Bw(t),i=fm(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=Bw(t),i=fm(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function rGe(e){const t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new nGe||null,prettyErrors:t}}function Kle(e,t={}){const{lineCounter:n,prettyErrors:i}=rGe(t),r=new iGe(n==null?void 0:n.addNewLine),s=new ZYe(t);let a=null;for(const o of s.compose(r.parse(e),!0,e.length))if(!a)a=o;else if(a.options.logLevel!=="silent"){a.errors.push(new PO(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(a.errors.forEach(OF(e,n)),a.warnings.forEach(OF(e,n))),a}function sGe(e,t,n){let i;const r=Kle(e,n);if(!r)return null;if(r.warnings.forEach(s=>wle(r.options.logLevel,s)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function Jle(e,t,n){let i=null;if(Array.isArray(t)&&(i=t),e===void 0){const{keepUndefined:r}={};if(!r)return}return V1(e)&&!i?e.toString(n):new Y1(e,i,n).toString(n)}const ece=1024;let aGe=0,Ho=class{constructor(t,n){this.from=t,this.to=n}};class sn{constructor(t={}){this.id=aGe++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ss.match(t)),n=>{let i=t(n);return i===void 0?null:[this,i]}}}sn.closedBy=new sn({deserialize:e=>e.split(" ")});sn.openedBy=new sn({deserialize:e=>e.split(" ")});sn.group=new sn({deserialize:e=>e.split(" ")});sn.isolate=new sn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});sn.contextHash=new sn({perNode:!0});sn.lookAhead=new sn({perNode:!0});sn.mounted=new sn({perNode:!0});class _g{constructor(t,n,i,r=!1){this.tree=t,this.overlay=n,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[sn.mounted.id]}}const oGe=Object.create(null);class ss{constructor(t,n,i,r=0){this.name=t,this.props=n,this.id=i,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):oGe,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new ss(t.name||"",n,t.id,i);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(sn.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let i in t)for(let r of i.split(" "))n[r]=t[i];return i=>{for(let r=i.prop(sn.group),s=-1;s<(r?r.length:0);s++){let a=n[s<0?i.name:r[s]];if(a)return a}}}}ss.none=new ss("",Object.create(null),0,8);class W1{constructor(t){this.types=t;for(let n=0;n0;for(let c=this.cursor(a|si.IncludeAnonymous);;){let u=!1;if(c.from<=s&&c.to>=r&&(!o&&c.type.isAnonymous||n(c)!==!1)){if(c.firstChild())continue;u=!0}for(;u&&i&&(o||!c.type.isAnonymous)&&i(c),!c.nextSibling();){if(!c.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:e4(ss.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new li(this.type,n,i,r,this.propValues),t.makeTree||((n,i,r)=>new li(ss.none,n,i,r)))}static build(t){return dGe(t)}}li.empty=new li(ss.none,[],[],0);class K3{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new K3(this.buffer,this.index)}}class zf{constructor(t,n,i){this.buffer=t,this.length=n,this.set=i}get type(){return ss.none}toString(){let t=[];for(let n=0;n0));c=a[c+3]);return o}slice(t,n,i){let r=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,c=0;o=t&&nt;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function Cx(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?o.length:-1;t!=u;t+=n){let d=o[t],f=c[t]+a.from,h;if(!(!(s&si.EnterBracketed&&d instanceof li&&(h=_g.get(d))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+d.length)&&!tce(r,i,f,f+d.length))){if(d instanceof zf){if(s&si.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,i-f,r);if(p>-1)return new Cc(new lGe(a,d,t,f),null,p)}else if(s&si.IncludeAnonymous||!d.type.isAnonymous||J3(d)){let p;if(!(s&si.IgnoreMounts)&&(p=_g.get(d))&&!p.overlay)return new Ks(p.tree,f,t,a);let g=new Ks(d,f,t,a);return s&si.IncludeAnonymous||!g.type.isAnonymous?g:g.nextChild(n<0?d.children.length-1:0,n,i,r,s)}}}if(s&si.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,n,i=0){let r;if(!(i&si.IgnoreOverlays)&&(r=_g.get(this._tree))&&r.overlay){let s=t-this.from,a=i&si.EnterBracketed&&r.bracketed;for(let{from:o,to:c}of r.overlay)if((n>0||a?o<=s:o=s:c>s))return new Ks(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function kF(e,t,n,i){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function AM(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class lGe{constructor(t,n,i,r){this.parent=t,this.buffer=n,this.index=i,this.start=r}}class Cc extends nce{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,i){super(),this.context=t,this._parent=n,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t,n-this.context.start,i);return s<0?null:new Cc(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,n,i=0){if(i&si.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new Cc(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Cc(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Cc(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let a=i.buffer[this.index+1];t.push(i.slice(r,s,a)),n.push(0)}return new li(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ice(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;sn.from||a.to=t){let o=new Ks(a.tree,a.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Cx(o,t,n,!1))}}return r?ice(r):i}class Kk{get name(){return this.type.name}constructor(t,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~si.EnterBracketed,t instanceof Ks)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return t?t instanceof Ks?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],t,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,i=this.mode){return this.buffer?i&si.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&si.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&si.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,i=this.stack.length-1;if(t<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,i,{buffer:r}=this;if(r){if(t>0){if(this.index-1)for(let s=n+t,a=t<0?-1:i._tree.children.length;s!=a;s+=t){let o=i._tree.children[s];if(this.mode&si.IncludeAnonymous||o instanceof zf||!o.type.isAnonymous||J3(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to=0;){for(let a=t;a;a=a._parent)if(a.index==r){if(r==this.index)return a;n=a,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return AM(this._tree,t,r);let a=i[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[r]&&t[r]!=a.name)return!1;r--}}return!0}}function J3(e){return e.children.some(t=>t instanceof zf||!t.type.isAnonymous||J3(t))}function dGe(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=ece,reused:s=[],minRepeatType:a=i.types.length}=e,o=Array.isArray(n)?new K3(n,n.length):n,c=i.types,u=0,d=0;function f(E,S,k,T,A,N){let{id:C,start:M,end:L,size:P}=o,Q=d,j=u;if(P<0)if(o.next(),P==-1){let X=s[C];k.push(X),T.push(M-E);return}else if(P==-3){u=C;return}else if(P==-4){d=C;return}else throw new RangeError(`Unrecognized record size: ${P}`);let $=c[C],U,B,I=M-E;if(L-M<=r&&(B=y(o.pos-S,A))){let X=new Uint16Array(B.size-B.skip),q=o.pos-B.size,D=X.length;for(;o.pos>q;)D=O(B.start,X,D);U=new zf(X,L-B.start,i),I=B.start-E}else{let X=o.pos-P;o.next();let q=[],D=[],H=C>=a?C:-1,re=0,fe=L;for(;o.pos>X;)H>=0&&o.id==H&&o.size>=0?(o.end<=fe-r&&(g(q,D,M,re,o.end,fe,H,Q,j),re=q.length,fe=o.end),o.next()):N>2500?h(M,X,q,D):f(M,X,q,D,H,N+1);if(H>=0&&re>0&&re-1&&re>0){let Ae=p($,j);U=e4($,q,D,0,q.length,0,L-M,Ae,Ae)}else U=b($,q,D,L-M,Q-L,j)}k.push(U),T.push(I)}function h(E,S,k,T){let A=[],N=0,C=-1;for(;o.pos>S;){let{id:M,start:L,end:P,size:Q}=o;if(Q>4)o.next();else{if(C>-1&&L=0;P-=3)M[Q++]=A[P],M[Q++]=A[P+1]-L,M[Q++]=A[P+2]-L,M[Q++]=Q;k.push(new zf(M,A[2]-L,i)),T.push(L-E)}}function p(E,S){return(k,T,A)=>{let N=0,C=k.length-1,M,L;if(C>=0&&(M=k[C])instanceof li){if(!C&&M.type==E&&M.length==A)return M;(L=M.prop(sn.lookAhead))&&(N=T[C]+M.length+L)}return b(E,k,T,A,N,S)}}function g(E,S,k,T,A,N,C,M,L){let P=[],Q=[];for(;E.length>T;)P.push(E.pop()),Q.push(S.pop()+k-A);E.push(b(i.types[C],P,Q,N-A,M-N,L)),S.push(A-k)}function b(E,S,k,T,A,N,C){if(N){let M=[sn.contextHash,N];C=C?[M].concat(C):[M]}if(A>25){let M=[sn.lookAhead,A];C=C?[M].concat(C):[M]}return new li(E,S,k,T,C)}function y(E,S){let k=o.fork(),T=0,A=0,N=0,C=k.end-r,M={size:0,start:0,skip:0};e:for(let L=k.pos-E;k.pos>L;){let P=k.size;if(k.id==S&&P>=0){M.size=T,M.start=A,M.skip=N,N+=4,T+=4,k.next();continue}let Q=k.pos-P;if(P<0||Q=a?4:0,$=k.start;for(k.next();k.pos>Q;){if(k.size<0)if(k.size==-3||k.size==-4)j+=4;else break e;else k.id>=a&&(j+=4);k.next()}A=$,T+=P,N+=j}return(S<0||T==E)&&(M.size=T,M.start=A,M.skip=N),M.size>4?M:void 0}function O(E,S,k){let{id:T,start:A,end:N,size:C}=o;if(o.next(),C>=0&&T4){let L=o.pos-(C-4);for(;o.pos>L;)k=O(E,S,k)}S[--k]=M,S[--k]=N-E,S[--k]=A-E,S[--k]=T}else C==-3?u=T:C==-4&&(d=T);return k}let v=[],x=[];for(;o.pos>0;)f(e.start||0,e.bufferStart||0,v,x,-1,0);let w=(t=e.length)!==null&&t!==void 0?t:v.length?x[0]+v[0].length:0;return new li(c[e.topID],v.reverse(),x.reverse(),w)}const TF=new WeakMap;function uE(e,t){if(!e.isAnonymous||t instanceof zf||t.type!=e)return 1;let n=TF.get(t);if(n==null){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof li)){n=1;break}n+=uE(e,i)}TF.set(t,n)}return n}function e4(e,t,n,i,r,s,a,o,c){let u=0;for(let g=i;g=d)break;S+=k}if(x==w+1){if(S>d){let k=g[w];p(k.children,k.positions,0,k.children.length,b[w]+v);continue}f.push(g[w])}else{let k=b[x-1]+g[x-1].length-E;f.push(e4(e,g,b,w,x,E,k,null,c))}h.push(E+v-s)}}return p(t,n,i,r,0),(o||c)(f,h,a)}class t4{constructor(){this.map=new WeakMap}setBuffer(t,n,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(n,i)}getBuffer(t,n){let i=this.map.get(t);return i&&i.get(n)}set(t,n){t instanceof Cc?this.setBuffer(t.context.buffer,t.index,n):t instanceof Ks&&this.map.set(t.tree,n)}get(t){return t instanceof Cc?this.getBuffer(t.context.buffer,t.index):t instanceof Ks?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Hu{constructor(t,n,i,r,s=!1,a=!1){this.from=t,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],i=!1){let r=[new Hu(0,t.length,t,0,!1,i)];for(let s of n)s.to>t.length&&r.push(s);return r}static applyChanges(t,n,i=128){if(!n.length)return t;let r=[],s=1,a=t.length?t[0]:null;for(let o=0,c=0,u=0;;o++){let d=o=i)for(;a&&a.from=h.from||f<=h.to||u){let p=Math.max(h.from,c)-u,g=Math.min(h.to,f)-u;h=p>=g?null:new Hu(p,g,h.tree,h.offset+u,o>0,!!d)}if(h&&r.push(h),a.to>f)break;a=snew Ho(r.from,r.to)):[new Ho(0,0)]:[new Ho(0,t.length)],this.createParse(t,n||[],i)}parse(t,n,i){let r=this.startParse(t,n,i);for(;;){let s=r.advance();if(s)return s}}}class fGe{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function rce(e){return(t,n,i,r)=>new pGe(t,e,n,i,r)}class _F{constructor(t,n,i,r,s,a){this.parser=t,this.parse=n,this.overlay=i,this.bracketed=r,this.target=s,this.from=a}}function AF(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class hGe{constructor(t,n,i,r,s,a,o,c){this.parser=t,this.predicate=n,this.mounts=i,this.index=r,this.start=s,this.bracketed=a,this.target=o,this.prev=c,this.depth=0,this.ranges=[]}}const NM=new sn({perNode:!0});class pGe{constructor(t,n,i,r,s){this.nest=n,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new li(i.type,i.children,i.positions,i.length,i.propValues.concat([[NM,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[sn.mounted.id]=new _g(n,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n=this.stoppedAt)o=!1;else if(t.hasNode(r)){if(n){let u=n.mounts.find(d=>d.frag.from<=r.from&&d.frag.to>=r.to&&d.mount.overlay);if(u)for(let d of u.mount.overlay){let f=d.from+u.pos,h=d.to+u.pos;f>=r.from&&h<=r.to&&!n.ranges.some(p=>p.fromf)&&n.ranges.push({from:f,to:h})}}o=!1}else if(i&&(a=mGe(i.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Ho(f.from-r.from,f.to-r.from)):null,!!s.bracketed,r.tree,d.length?d[0].from:r.from)),s.overlay?d.length&&(i={ranges:d,depth:0,prev:i}):o=!1}}else if(n&&(c=n.predicate(r))&&(c===!0&&(c=new Ho(r.from,r.to)),c.from=0&&n.ranges[u].to==c.from?n.ranges[u]={from:n.ranges[u].from,to:c.to}:n.ranges.push(c)}if(o&&r.firstChild())n&&n.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(n&&!--n.depth){let u=jF(this.ranges,n.ranges);u.length&&(AF(u),this.inner.splice(n.index,0,new _F(n.parser,n.parser.startParse(this.input,RF(n.mounts,u),u),n.ranges.map(d=>new Ho(d.from-n.start,d.to-n.start)),n.bracketed,n.target,u[0].from))),n=n.prev}i&&!--i.depth&&(i=i.prev)}}}}function mGe(e,t,n){for(let i of e){if(i.from>=n)break;if(i.to>t)return i.from<=t&&i.to>=n?2:1}return 0}function NF(e,t,n,i,r,s){if(t=t&&n.enter(i,1,si.IgnoreOverlays|si.ExcludeBuffers)))if(n.to<=t)n.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof li)n=n.children[0];else break}return!1}}let bGe=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(n=i.tree.prop(NM))!==null&&n!==void 0?n:i.to,this.inner=new CF(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(NM))!==null&&t!==void 0?t:n.to,this.inner=new CF(n.tree,-n.offset)}}findMounts(t,n){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(i=s.tree)===null||i===void 0?void 0:i.prop(sn.mounted);if(a&&a.parser==n)for(let o=this.fragI;o=s.to)break;c.tree==this.curFrag.tree&&r.push({frag:c,pos:s.from-c.offset,mount:a})}}}return r}};function jF(e,t){let n=null,i=t;for(let r=1,s=0;r=o)break;c.to<=a||(n||(i=n=t.slice()),c.fromo&&n.splice(s+1,0,new Ho(o,c.to))):c.to>o?n[s--]=new Ho(o,c.to):n.splice(s--,1))}}return i}function OGe(e,t,n,i){let r=0,s=0,a=!1,o=!1,c=-1e9,u=[];for(;;){let d=r==e.length?1e9:a?e[r].to:e[r].from,f=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(c,n),p=Math.min(d,f,i);hnew Ho(h.from+i,h.to+i)),f=OGe(t,d,c,u);for(let h=0,p=c;;h++){let g=h==f.length,b=g?u:f[h].from;if(b>p&&n.push(new Hu(p,b,r.tree,-a,s.from>=p||s.openStart,s.to<=b||s.openEnd)),g)break;p=f[h].to}}else n.push(new Hu(c,u,r.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}var IF={};class Jk{constructor(t,n,i,r,s,a,o,c,u,d=0,f){this.p=t,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=a,this.buffer=o,this.bufferBase=c,this.curContext=u,this.lookAhead=d,this.parent=f}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,i=0){let r=t.parser.context;return new Jk(t,[],n,i,i,0,[],0,r?new PF(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let i=t>>19,r=t&65535,{parser:s}=this.p,a=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(r,u)}storeNode(t,n,i,r=4,s=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(n==i)return;if(this.buffer[a-2]>=n){this.buffer[a-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(t,n,i,r);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let o=!1;for(let c=a;c>0&&this.buffer[c-2]>i;c-=4)if(this.buffer[c-1]>=0){o=!0;break}if(o)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,r>4&&(r-=4)}this.buffer[a]=t,this.buffer[a+1]=n,this.buffer[a+2]=i,this.buffer[a+3]=r}}shift(t,n,i,r){if(t&131072)this.pushState(t&65535,this.pos);else if(t&262144)this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4);else{let s=t,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(s,1);!o&&(r>i||n<=a.maxNode)&&(this.reducePos=r),this.pushState(s,o?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=a.maxNode&&this.buffer.push(n,i,r,4)}}apply(t,n,i,r){t&65536?this.reduce(t):this.shift(t,n,i,r)}useNode(t,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let r=this.pos;this.reducePos=this.pos=r+t.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let i=t.buffer.slice(n),r=t.bufferBase+n;for(;t&&r==t.bufferBase;)t=t.parent;return new Jk(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new yGe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(i==0)return!1;if(!(i&65536))return!0;n.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,a;sc&1&&o==a)||r.push(n[s],a)}n=r}let i=[];for(let r=0;r>19,r=n&65535,s=this.stack.length-i*3;if(s<0||t.getGoto(this.stack[s],r,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;n=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),t.allActions(r,a=>{if(!(a&393216))if(a&65536){let o=(a>>19)-s;if(o>1){let c=a&65535,u=this.stack.length-o*3;if(u>=0&&t.getGoto(this.stack[u],c,!1)>=0)return o<<19|65536|c}}else{let o=i(a,s+1);if(o!=null)return o}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class PF{constructor(t,n){this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}}class yGe{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let n=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class eT{constructor(t,n,i){this.stack=t,this.pos=n,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new eT(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new eT(this.stack,this.pos,this.index)}}function MO(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let i=0,r=0;i=92&&a--,a>=34&&a--;let c=a-32;if(c>=46&&(c-=46,o=!0),s+=c,o)break;s*=46}n?n[r++]=s:n=new t(s)}return n}class dE{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const MF=new dE;class xGe{constructor(t,n){this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=MF,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(t,n){let i=this.range,r=this.rangeIndex,s=this.pos+t;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let a=this.ranges[++r];s+=a.from-i.to,i=a}return s}clipPos(t){if(t>=this.range.from&&tt)return Math.max(t,n.from);return this.end}peek(t){let n=this.chunkOff+t,i,r;if(n>=0&&n=this.chunk2Pos&&io.to&&(this.chunk2=this.chunk2.slice(0,o.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(t,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,n){if(n?(this.token=n,n.start=t,n.lookAhead=t+1,n.value=n.extended=-1):this.token=MF,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,n-this.chunkPos);if(t>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,n-this.chunk2Pos);if(t>=this.range.from&&n<=this.range.to)return this.input.read(t,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>t&&(i+=this.input.read(Math.max(r.from,t),Math.min(r.to,n)))}return i}}class Ag{constructor(t,n){this.data=t,this.id=n}token(t,n){let{parser:i}=n.p;sce(this.data,t,n,this.id,i.data,i.tokenPrecTable)}}Ag.prototype.contextual=Ag.prototype.fallback=Ag.prototype.extend=!1;class tT{constructor(t,n,i){this.precTable=n,this.elseToken=i,this.data=typeof t=="string"?MO(t):t}token(t,n){let i=t.pos,r=0;for(;;){let s=t.next<0,a=t.resolveOffset(1,1);if(sce(this.data,t,n,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,a==null)break;t.reset(a,t.token)}r&&(t.reset(i,t.token),t.acceptToken(this.elseToken,r))}}tT.prototype.contextual=Ag.prototype.fallback=Ag.prototype.extend=!1;class Lr{constructor(t,n={}){this.token=t,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function sce(e,t,n,i,r,s){let a=0,o=1<0){let g=e[p];if(c.allows(g)&&(t.token.value==-1||t.token.value==g||vGe(g,t.token.value,r,s))){t.acceptToken(g);break}}let d=t.next,f=0,h=e[a+2];if(t.next<0&&h>f&&e[u+h*3-3]==65535){a=e[u+h*3-1];continue e}for(;f>1,g=u+p+(p<<1),b=e[g],y=e[g+1]||65536;if(d=y)f=p+1;else{a=e[g+2],t.advance();continue e}}break}}function LF(e,t,n){for(let i=t,r;(r=e[i])!=65535;i++)if(r==n)return i-t;return-1}function vGe(e,t,n,i){let r=LF(n,i,t);return r<0||LF(n,i,e)t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}let wGe=class{constructor(t,n){this.fragments=t,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?DF(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?DF(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(tt)return this.nextStart=a,null;if(s instanceof li){if(a==t){if(a=Math.max(this.safeFrom,t)&&(this.trees.push(s),this.start.push(a),this.index.push(0))}else this.index[n]++,this.nextStart=a+s.length}}};class SGe{constructor(t,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new dE)}getActions(t){let n=0,i=null,{parser:r}=t.p,{tokenizers:s}=r,a=r.stateSlot(t.state,3),o=t.curContext?t.curContext.hash:0,c=0;for(let u=0;uf.end+25&&(c=Math.max(f.lookAhead,c)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(t,f.extended,f.end,n)),n=this.addActions(t,f.value,f.end,n),!d.extend&&(i=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return c&&t.setLookAhead(c),!i&&t.pos==this.stream.end&&(i=new dE,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,n=this.addActions(t,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let n=new dE,{pos:i,p:r}=t;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(t,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,t),i),t.value>-1){let{parser:s}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(o>>1)){o&1?t.extended=o>>1:t.value=o>>1;break}}}else t.value=0,t.end=this.stream.clipPos(r+1)}putAction(t,n,i,r){for(let s=0;st.bufferLength*4?new wGe(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&t.length==1){let[a]=t;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;an)i.push(o);else{if(this.advanceStack(o,i,t))continue;{r||(r=[],s=[]),r.push(o);let c=this.tokens.getMainToken(o);s.push(c.value,c.end)}}break}}if(!i.length){let a=r&&TGe(r);if(a)return Za&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Za&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let a=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(a)return Za&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((o,c)=>c.score-o.score);i.length>a;)i.pop();i.some(o=>o.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&u.buffer.length>500)if((o.score-u.score||o.buffer.length-u.buffer.length)>0)i.splice(c--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,o)=>o.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let u=t.curContext&&t.curContext.tracker.strict,d=u?t.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(t.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(sn.contextHash)||0)==d))return t.useNode(f,h),Za&&console.log(a+this.stackID(t)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof li)||f.children.length==0||f.positions[0]>0)break;let p=f.children[0];if(p instanceof li&&f.positions[0]==0)f=p;else break}}let o=s.stateSlot(t.state,4);if(o>0)return t.reduce(o),Za&&console.log(a+this.stackID(t)+` (via always-reduce ${s.getName(o&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let c=this.tokens.getActions(t);for(let u=0;ur?n.push(g):i.push(g)}return!1}advanceFully(t,n){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return $F(t,n),!0}}runRecovery(t,n,i){let r=null,s=!1;for(let a=0;a ":"";if(o.deadEnd&&(s||(s=!0,o.restart(),Za&&console.log(d+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let f=o.split(),h=d;for(let p=0;p<10&&f.forceReduce()&&(Za&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));p++)Za&&(h=this.stackID(f)+" -> ");for(let p of o.recoverByInsert(c))Za&&console.log(d+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,i);this.stream.end>o.pos?(u==o.pos&&(u++,c=0),o.recoverByDelete(c,u),Za&&console.log(d+this.stackID(o)+` (via recover-delete ${this.parser.getName(c)})`),$F(o,i)):(!r||r.scoree;class CA{constructor(t){this.start=t.start,this.shift=t.shift||ZC,this.reduce=t.reduce||ZC,this.reuse=t.reuse||ZC,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class ad extends n4{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let o=0;ot.topRules[o][1]),r=[];for(let o=0;o=0)s(d,c,o[u++]);else{let f=o[u+-d];for(let h=-d;h>0;h--)s(o[u++],c,f);u++}}}this.nodeSet=new W1(n.map((o,c)=>ss.define({name:c>=this.minRepeatTerm?void 0:o,id:c,props:r[c],top:i.indexOf(c)>-1,error:c==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(c)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=ece;let a=MO(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let o=0;otypeof o=="number"?new Ag(a,o):o),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,i){let r=new EGe(this,t,n,i);for(let s of this.wrappers)r=s(r,t,n,i);return r}getGoto(t,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let a=r[s++],o=a&1,c=r[s++];if(o&&i)return c;for(let u=s+(a>>1);s0}validAction(t,n){return!!this.allActions(t,i=>i==n?!0:null)}allActions(t,n){let i=this.stateSlot(t,4),r=i?n(i):void 0;for(let s=this.stateSlot(t,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=_u(this.data,s+2);else break;r=n(_u(this.data,s+1))}return r}nextStates(t){let n=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=_u(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];n.some((s,a)=>a&1&&s==r)||n.push(this.data[i],r)}}return n}configure(t){let n=Object.assign(Object.create(ad.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=i}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=t.tokenizers.find(s=>s.from==i);return r?r.to:i})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=t.specializers.find(o=>o.from==i.external);if(!s)return i;let a=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=QF(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(t)for(let s of t.split(" ")){let a=n.indexOf(s);a>=0&&(i[a]=!0)}let r=null;for(let s=0;si)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,i)<<1|t}return e.get}let _Ge=0,xc=class CM{constructor(t,n,i,r){this.name=t,this.set=n,this.base=i,this.modified=r,this.id=_Ge++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let i=typeof t=="string"?t:"?";if(t instanceof CM&&(n=t),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new CM(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(t){let n=new nT(t);return i=>i.modified.indexOf(n)>-1?i:nT.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}},AGe=0;class nT{constructor(t){this.name=t,this.instances=[],this.id=AGe++}static get(t,n){if(!n.length)return t;let i=n[0].instances.find(o=>o.base==t&&NGe(n,o.modified));if(i)return i;let r=[],s=new xc(t.name,r,t,n);for(let o of n)o.instances.push(s);let a=CGe(n);for(let o of t.set)if(!o.modified.length)for(let c of a)r.push(nT.get(o,c));return s}}function NGe(e,t){return e.length==t.length&&e.every((n,i)=>n==t[i])}function CGe(e){let t=[[]];for(let n=0;ni.length-n.length)}function xd(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],a=2,o=r;for(let f=0;;){if(o=="..."&&f>0&&f+3==r.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){a=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);o=r.slice(f)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+r);let d=new jx(i,a,c>0?s.slice(0,c):null);t[u]=d.sort(t[u])}}return ace.add(t)}const ace=new sn({combine(e,t){let n,i,r;for(;e||t;){if(!e||t&&e.depth>=t.depth?(r=t,t=t.next):(r=e,e=e.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new jx(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class jx{constructor(t,n,i,r){this.tags=t,this.mode=n,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let a=r;for(let o of s)for(let c of o.set){let u=n[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:i}}function jGe(e,t){let n=null;for(let i of e){let r=i.style(t);r&&(n=n?n+" "+r:r)}return n}function RGe(e,t,n,i=0,r=e.length){let s=new IGe(i,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),i,r,"",s.highlighters),s.flush(r)}class IGe{constructor(t,n,i){this.at=t,this.highlighters=n,this.span=i,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,i,r,s){let{type:a,from:o,to:c}=t;if(o>=i||c<=n)return;a.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(a)));let u=r,d=PGe(t)||jx.empty,f=jGe(s,d.tags);if(f&&(u&&(u+=" "),u+=f,d.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(n,o),u),d.opaque)return;let h=t.tree&&t.tree.prop(sn.mounted);if(h&&h.overlay){let p=t.node.enter(h.overlay[0].from+o,1),g=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),b=t.firstChild();for(let y=0,O=o;;y++){let v=y=x||!t.nextSibling())););if(!v||x>i)break;O=v.to+o,O>n&&(this.highlightRange(p.cursor(),Math.max(n,v.from+o),Math.min(i,O),"",g),this.startSpan(Math.min(i,O),u))}b&&t.parent()}else if(t.firstChild()){h&&(r="");do if(!(t.to<=n)){if(t.from>=i)break;this.highlightRange(t,n,i,r,s),this.startSpan(Math.min(i,t.to),u)}while(t.nextSibling());t.parent()}}}function PGe(e){let t=e.type.prop(ace);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const pt=xc.define,zw=pt(),qd=pt(),BF=pt(qd),UF=pt(qd),Hd=pt(),Fw=pt(Hd),KC=pt(Hd),gc=pt(),ph=pt(gc),fc=pt(),hc=pt(),jM=pt(),rO=pt(jM),Vw=pt(),G={comment:zw,lineComment:pt(zw),blockComment:pt(zw),docComment:pt(zw),name:qd,variableName:pt(qd),typeName:BF,tagName:pt(BF),propertyName:UF,attributeName:pt(UF),className:pt(qd),labelName:pt(qd),namespace:pt(qd),macroName:pt(qd),literal:Hd,string:Fw,docString:pt(Fw),character:pt(Fw),attributeValue:pt(Fw),number:KC,integer:pt(KC),float:pt(KC),bool:pt(Hd),regexp:pt(Hd),escape:pt(Hd),color:pt(Hd),url:pt(Hd),keyword:fc,self:pt(fc),null:pt(fc),atom:pt(fc),unit:pt(fc),modifier:pt(fc),operatorKeyword:pt(fc),controlKeyword:pt(fc),definitionKeyword:pt(fc),moduleKeyword:pt(fc),operator:hc,derefOperator:pt(hc),arithmeticOperator:pt(hc),logicOperator:pt(hc),bitwiseOperator:pt(hc),compareOperator:pt(hc),updateOperator:pt(hc),definitionOperator:pt(hc),typeOperator:pt(hc),controlOperator:pt(hc),punctuation:jM,separator:pt(jM),bracket:rO,angleBracket:pt(rO),squareBracket:pt(rO),paren:pt(rO),brace:pt(rO),content:gc,heading:ph,heading1:pt(ph),heading2:pt(ph),heading3:pt(ph),heading4:pt(ph),heading5:pt(ph),heading6:pt(ph),contentSeparator:pt(gc),list:pt(gc),quote:pt(gc),emphasis:pt(gc),strong:pt(gc),link:pt(gc),monospace:pt(gc),strikethrough:pt(gc),inserted:pt(),deleted:pt(),changed:pt(),invalid:pt(),meta:Vw,documentMeta:pt(Vw),annotation:pt(Vw),processingInstruction:pt(Vw),definition:xc.defineModifier("definition"),constant:xc.defineModifier("constant"),function:xc.defineModifier("function"),standard:xc.defineModifier("standard"),local:xc.defineModifier("local"),special:xc.defineModifier("special")};for(let e in G){let t=G[e];t instanceof xc&&(t.name=e)}oce([{tag:G.link,class:"tok-link"},{tag:G.heading,class:"tok-heading"},{tag:G.emphasis,class:"tok-emphasis"},{tag:G.strong,class:"tok-strong"},{tag:G.keyword,class:"tok-keyword"},{tag:G.atom,class:"tok-atom"},{tag:G.bool,class:"tok-bool"},{tag:G.url,class:"tok-url"},{tag:G.labelName,class:"tok-labelName"},{tag:G.inserted,class:"tok-inserted"},{tag:G.deleted,class:"tok-deleted"},{tag:G.literal,class:"tok-literal"},{tag:G.string,class:"tok-string"},{tag:G.number,class:"tok-number"},{tag:[G.regexp,G.escape,G.special(G.string)],class:"tok-string2"},{tag:G.variableName,class:"tok-variableName"},{tag:G.local(G.variableName),class:"tok-variableName tok-local"},{tag:G.definition(G.variableName),class:"tok-variableName tok-definition"},{tag:G.special(G.variableName),class:"tok-variableName2"},{tag:G.definition(G.propertyName),class:"tok-propertyName tok-definition"},{tag:G.typeName,class:"tok-typeName"},{tag:G.namespace,class:"tok-namespace"},{tag:G.className,class:"tok-className"},{tag:G.macroName,class:"tok-macroName"},{tag:G.propertyName,class:"tok-propertyName"},{tag:G.operator,class:"tok-operator"},{tag:G.comment,class:"tok-comment"},{tag:G.meta,class:"tok-meta"},{tag:G.invalid,class:"tok-invalid"},{tag:G.punctuation,class:"tok-punctuation"}]);const MGe=316,LGe=317,zF=1,DGe=2,$Ge=3,QGe=4,BGe=318,UGe=320,zGe=321,FGe=5,VGe=6,XGe=0,RM=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],lce=125,qGe=59,IM=47,HGe=42,YGe=43,GGe=45,WGe=60,ZGe=44,KGe=63,JGe=46,eWe=91,tWe=new CA({start:!1,shift(e,t){return t==FGe||t==VGe||t==UGe?e:t==zGe},strict:!1}),nWe=new Lr((e,t)=>{let{next:n}=e;(n==lce||n==-1||t.context)&&e.acceptToken(BGe)},{contextual:!0,fallback:!0}),iWe=new Lr((e,t)=>{let{next:n}=e,i;RM.indexOf(n)>-1||n==IM&&((i=e.peek(1))==IM||i==HGe)||n!=lce&&n!=qGe&&n!=-1&&!t.context&&e.acceptToken(MGe)},{contextual:!0}),rWe=new Lr((e,t)=>{e.next==eWe&&!t.context&&e.acceptToken(LGe)},{contextual:!0}),sWe=new Lr((e,t)=>{let{next:n}=e;if(n==YGe||n==GGe){if(e.advance(),n==e.next){e.advance();let i=!t.context&&t.canShift(zF);e.acceptToken(i?zF:DGe)}}else n==KGe&&e.peek(1)==JGe&&(e.advance(),e.advance(),(e.next<48||e.next>57)&&e.acceptToken($Ge))},{contextual:!0});function JC(e,t){return e>=65&&e<=90||e>=97&&e<=122||e==95||e>=192||!t&&e>=48&&e<=57}const aWe=new Lr((e,t)=>{if(e.next!=WGe||!t.dialectEnabled(XGe)||(e.advance(),e.next==IM))return;let n=0;for(;RM.indexOf(e.next)>-1;)e.advance(),n++;if(JC(e.next,!0)){for(e.advance(),n++;JC(e.next,!1);)e.advance(),n++;for(;RM.indexOf(e.next)>-1;)e.advance(),n++;if(e.next==ZGe)return;for(let i=0;;i++){if(i==7){if(!JC(e.next,!0))return;break}if(e.next!="extends".charCodeAt(i))break;e.advance(),n++}}e.acceptToken(QGe,-n)}),oWe=xd({"get set async static":G.modifier,"for while do if else switch try catch finally return throw break continue default case defer":G.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":G.operatorKeyword,"let var const using function class extends":G.definitionKeyword,"import export from":G.moduleKeyword,"with debugger new":G.keyword,TemplateString:G.special(G.string),super:G.atom,BooleanLiteral:G.bool,this:G.self,null:G.null,Star:G.modifier,VariableName:G.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":G.function(G.variableName),VariableDefinition:G.definition(G.variableName),Label:G.labelName,PropertyName:G.propertyName,PrivatePropertyName:G.special(G.propertyName),"CallExpression/MemberExpression/PropertyName":G.function(G.propertyName),"FunctionDeclaration/VariableDefinition":G.function(G.definition(G.variableName)),"ClassDeclaration/VariableDefinition":G.definition(G.className),"NewExpression/VariableName":G.className,PropertyDefinition:G.definition(G.propertyName),PrivatePropertyDefinition:G.definition(G.special(G.propertyName)),UpdateOp:G.updateOperator,"LineComment Hashbang":G.lineComment,BlockComment:G.blockComment,Number:G.number,String:G.string,Escape:G.escape,ArithOp:G.arithmeticOperator,LogicOp:G.logicOperator,BitOp:G.bitwiseOperator,CompareOp:G.compareOperator,RegExp:G.regexp,Equals:G.definitionOperator,Arrow:G.function(G.punctuation),": Spread":G.punctuation,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace,"InterpolationStart InterpolationEnd":G.special(G.brace),".":G.derefOperator,", ;":G.separator,"@":G.meta,TypeName:G.typeName,TypeDefinition:G.definition(G.typeName),"type enum interface implements namespace module declare":G.definitionKeyword,"abstract global Privacy readonly override":G.modifier,"is keyof unique infer asserts":G.operatorKeyword,JSXAttributeValue:G.attributeValue,JSXText:G.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":G.angleBracket,"JSXIdentifier JSXNameSpacedName":G.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":G.attributeName,"JSXBuiltin/JSXIdentifier":G.standard(G.tagName)}),lWe={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},cWe={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},uWe={__proto__:null,"<":193},dWe=ad.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:tWe,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[oWe],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[iWe,rWe,sWe,aWe,2,3,4,5,6,7,8,9,10,11,12,13,14,nWe,new tT("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new tT("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:e=>lWe[e]||-1},{term:343,get:e=>cWe[e]||-1},{term:95,get:e=>uWe[e]||-1}],tokenPrec:15201});let PM=[],cce=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t>1;if(e=cce[i])t=i+1;else return!0;if(t==n)return!1}}function FF(e){return e>=127462&&e<=127487}const VF=8205;function hWe(e,t,n=!0,i=!0){return(n?uce:pWe)(e,t,i)}function uce(e,t,n){if(t==e.length)return t;t&&dce(e.charCodeAt(t))&&fce(e.charCodeAt(t-1))&&t--;let i=ej(e,t);for(t+=XF(i);t=0&&FF(ej(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function pWe(e,t,n){for(;t>1;){let i=uce(e,t-2,n);if(i=56320&&e<57344}function fce(e){return e>=55296&&e<56320}function XF(e){return e<65536?1:2}let ei=class hce{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,i){[t,n]=O0(this,t,n);let r=[];return this.decompose(0,t,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),wc.from(r,this.length-(n-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=O0(this,t,n);let i=[];return this.decompose(t,n,i,0),wc.from(i,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),r=new wy(this),s=new wy(t);for(let a=n,o=n;;){if(r.next(a),s.next(a),a=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(o+=r.value.length,r.done||o>=i)return!0}}iter(t=1){return new wy(this,t)}iterRange(t,n=this.length){return new pce(this,t,n)}iterLines(t,n){let i;if(t==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(t).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new mce(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?hce.empty:t.length<=32?new Nr(t):wc.from(Nr.split(t,[]))}};class Nr extends ei{constructor(t,n=mWe(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,i,r){for(let s=0;;s++){let a=this.text[s],o=r+a.length;if((n?i:o)>=t)return new gWe(r,o,i,a);r=o+1,i++}}decompose(t,n,i,r){let s=t<=0&&n>=this.length?this:new Nr(qF(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(r&1){let a=i.pop(),o=fE(s.text,a.text.slice(),0,s.length);if(o.length<=32)i.push(new Nr(o,a.length+s.length));else{let c=o.length>>1;i.push(new Nr(o.slice(0,c)),new Nr(o.slice(c)))}}else i.push(s)}replace(t,n,i){if(!(i instanceof Nr))return super.replace(t,n,i);[t,n]=O0(this,t,n);let r=fE(this.text,fE(i.text,qF(this.text,0,t)),n),s=this.length+i.length-(n-t);return r.length<=32?new Nr(r,s):wc.from(Nr.split(r,[]),s)}sliceString(t,n=this.length,i=` `){[t,n]=O0(this,t,n);let r="";for(let s=0,a=0;s<=n&&at&&a&&(r+=i),ts&&(r+=o.slice(Math.max(0,t-s),n-s)),s=c+1}return r}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let i=[],r=-1;for(let s of t)i.push(s),r+=s.length+1,i.length==32&&(n.push(new Nr(i,r)),i=[],r=-1);return r>-1&&n.push(new Nr(i,r)),n}}class wc extends ei{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,n,i,r){for(let s=0;;s++){let a=this.children[s],o=r+a.length,c=i+a.lines-1;if((n?c:o)>=t)return a.lineInner(t,n,i,r);r=o+1,i=c+1}}decompose(t,n,i,r){for(let s=0,a=0;a<=n&&s=a){let u=r&((a<=t?1:0)|(c>=n?2:0));a>=t&&c<=n&&!u?i.push(o):o.decompose(t-a,n-a,i,u)}a=c+1}}replace(t,n,i){if([t,n]=O0(this,t,n),i.lines=s&&n<=o){let c=a.replace(t-s,n-s,i),u=this.lines-a.lines+c.lines;if(c.lines>4&&c.lines>u>>6){let d=this.children.slice();return d[r]=c,new wc(d,this.length-(n-t)+i.length)}return super.replace(s,o,c)}s=o+1}return super.replace(t,n,i)}sliceString(t,n=this.length,i=` -`){[t,n]=O0(this,t,n);let r="";for(let s=0,a=0;st&&s&&(r+=i),ta&&(r+=o.sliceString(t-a,n-a,i)),a=c+1}return r}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof wc))return 0;let i=0,[r,s,a,o]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==a||s==o)return i;let c=this.children[r],u=t.children[s];if(c!=u)return i+c.scanIdentical(u,n);i+=c.length+1}}static from(t,n=t.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of t)i+=p.lines;if(i<32){let p=[];for(let g of t)g.flatten(p);return new Nr(p,n)}let r=Math.max(32,i>>5),s=r<<1,a=r>>1,o=[],c=0,u=-1,d=[];function f(p){let g;if(p.lines>s&&p instanceof wc)for(let b of p.children)f(b);else p.lines>a&&(c>a||!c)?(h(),o.push(p)):p instanceof Nr&&c&&(g=d[d.length-1])instanceof Nr&&p.lines+g.lines<=32?(c+=p.lines,u+=p.length+1,d[d.length-1]=new Nr(g.text.concat(p.text),g.length+1+p.length)):(c+p.lines>r&&h(),c+=p.lines,u+=p.length+1,d.push(p))}function h(){c!=0&&(o.push(d.length==1?d[0]:wc.from(d,u)),u=-1,c=d.length=0)}for(let p of t)f(p);return h(),o.length==1?o[0]:new wc(o,n)}}ei.empty=new Nr([""],0);function pWe(e){let t=-1;for(let n of e)t+=n.length+1;return t}function fE(e,t,n=0,i=1e9){for(let r=0,s=0,a=!0;s=n&&(c>i&&(o=o.slice(0,i-r)),r0?1:(t instanceof Nr?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],a=s>>1,o=r instanceof Nr?r.text.length:r.children.length;if(a==(n>0?o:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,t==0)return this.lineBreak=!0,this.value=` -`,this;t--}else if(r instanceof Nr){let c=r.text[a+(n<0?-1:0)];if(this.offsets[i]+=n,c.length>Math.max(0,t))return this.value=t==0?c:n>0?c.slice(t):c.slice(0,c.length-t),this;t-=c.length}else{let c=r.children[a+(n<0?-1:0)];t>c.length?(t-=c.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(c),this.offsets.push(n>0?1:(c instanceof Nr?c.text.length:c.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class hce{constructor(t,n,i){this.value="",this.done=!1,this.cursor=new wy(t,n>i?-1:1),this.pos=n>i?t.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(t,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class pce{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:n,lineBreak:i,value:r}=this.inner.next(t);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ei.prototype[Symbol.iterator]=function(){return this.iter()},wy.prototype[Symbol.iterator]=hce.prototype[Symbol.iterator]=pce.prototype[Symbol.iterator]=function(){return this});let mWe=class{constructor(t,n,i,r){this.from=t,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}};function O0(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Os(e,t,n=!0,i=!0){return fWe(e,t,n,i)}function gWe(e){return e>=56320&&e<57344}function bWe(e){return e>=55296&&e<56320}function Pa(e,t){let n=e.charCodeAt(t);if(!bWe(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return gWe(i)?(n-55296<<10)+(i-56320)+65536:n}function i4(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Sc(e){return e<65536?1:2}const MM=/\r\n?|\n/;var Cs=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Cs||(Cs={}));class Qc{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;nt)return s+(t-r);s+=o}else{if(i!=Cs.Simple&&u>=t&&(i==Cs.TrackDel&&rt||i==Cs.TrackBefore&&rt))return null;if(u>t||u==t&&n<0&&!o)return t==r||n<0?s:s+c;s+=c}r=u}if(t>r)throw new RangeError(`Position ${t} is out of range for changeset of length ${r}`);return s}touchesRange(t,n=t){for(let i=0,r=0;i=0&&r<=n&&o>=t)return rn?"cover":!0;r=o}return!1}toString(){let t="";for(let n=0;n=0?":"+r:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qc(t)}static create(t){return new Qc(t)}}class ns extends Qc{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return LM(this,(n,i,r,s,a)=>t=t.replace(r,r+(i-n),a),!1),t}mapDesc(t,n=!1){return DM(this,t,n,!0)}invert(t){let n=this.sections.slice(),i=[];for(let r=0,s=0;r=0){n[r]=o,n[r+1]=a;let c=r>>1;for(;i.length0&&uf(i,n,s.text),s.forward(d),o+=d}let u=t[a++];for(;o>1].toJSON()))}return t}static of(t,n,i){let r=[],s=[],a=0,o=null;function c(d=!1){if(!d&&!r.length)return;ah||f<0||h>n)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${n})`);let g=p?typeof p=="string"?ei.of(p.split(i||MM)):p:ei.empty,b=g.length;if(f==h&&b==0)return;fa&&Hs(r,f-a,-1),Hs(r,h-f,b),uf(s,r,g),a=h}}return u(t),c(!o),o}static empty(t){return new ns(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;ro&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&t==0&&e[r]==0?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function uf(e,t,n){if(n.length==0)return;let i=t.length-2>>1;if(i>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)o=e.sections[a++],c=e.sections[a++];t(r,u,s,d,f),r=u,s=d}}}function DM(e,t,n,i=!1){let r=[],s=i?[]:null,a=new Rx(e),o=new Rx(t);for(let c=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let u=Math.min(a.len,o.len);Hs(r,u,-1),a.forward(u),o.forward(u)}else if(o.ins>=0&&(a.ins<0||c==a.i||a.off==0&&(o.len=0&&c=0){let u=0,d=a.len;for(;d;)if(o.ins==-1){let f=Math.min(d,o.len);u+=f,d-=f,o.forward(f)}else if(o.ins==0&&o.lenc||a.ins>=0&&a.len>c)&&(o||i.length>u),s.forward2(c),a.forward(c)}}}}class Rx{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return n>=t.length?ei.empty:t[n]}textBit(t){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!t?ei.empty:n[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Jd{constructor(t,n,i,r){this.from=t,this.to=n,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}map(t,n=-1){let i,r;return this.empty?i=r=t.mapPos(this.from,n):(i=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Jd(i,r,this.flags,this.goalColumn)}extend(t,n=t,i=0){if(t<=this.anchor&&n>=this.anchor)return Qe.range(t,n,void 0,void 0,i);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return Qe.range(this.anchor,r,void 0,void 0,i)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Qe.range(t.anchor,t.head)}static create(t,n,i,r){return new Jd(t,n,i,r)}}class Qe{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Qe.create(this.ranges.map(i=>i.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Qe(t.ranges.map(n=>Jd.fromJSON(n)),t.main)}static single(t,n=t){return new Qe([Qe.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),n=t.indexOf(i);for(let r=1;rs.head?Qe.range(c,o):Qe.range(o,c))}}return new Qe(t,n)}}function gce(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let r4=0;class yt{constructor(t,n,i,r,s){this.combine=t,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=r4++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new yt(t.combine||(n=>n),t.compareInput||((n,i)=>n===i),t.compare||(t.combine?(n,i)=>n===i:s4),!!t.static,t.enables)}of(t){return new hE([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new hE(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new hE(t,this,2,n)}from(t,n){return n||(n=i=>i),this.compute([t],i=>n(i.field(t)))}}function s4(e,t){return e==t||e.length==t.length&&e.every((n,i)=>n===t[i])}class hE{constructor(t,n,i,r){this.dependencies=t,this.facet=n,this.type=i,this.value=r,this.id=r4++}dynamicSlot(t){var n;let i=this.value,r=this.facet.compareInput,s=this.id,a=t[s]>>1,o=this.type==2,c=!1,u=!1,d=[];for(let f of this.dependencies)f=="doc"?c=!0:f=="selection"?u=!0:((n=t[f.id])!==null&&n!==void 0?n:1)&1||d.push(t[f.id]);return{create(f){return f.values[a]=i(f),1},update(f,h){if(c&&h.docChanged||u&&(h.docChanged||h.selection)||$M(f,d)){let p=i(f);if(o?!HF(p,f.values[a],r):!r(p,f.values[a]))return f.values[a]=p,1}return 0},reconfigure:(f,h)=>{let p,g=h.config.address[s];if(g!=null){let b=rT(h,g);if(this.dependencies.every(y=>y instanceof yt?h.facet(y)===f.facet(y):y instanceof Ms?h.field(y,!1)==f.field(y,!1):!0)||(o?HF(p=i(f),b,r):r(p=i(f),b)))return f.values[a]=b,0}else p=i(f);return f.values[a]=p,1}}}get extension(){return this}}function HF(e,t,n){if(e.length!=t.length)return!1;for(let i=0;ie[c.id]),r=n.map(c=>c.type),s=i.filter(c=>!(c&1)),a=e[t.id]>>1;function o(c){let u=[];for(let d=0;di===r),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(Xw).find(i=>i.field==this);return((n==null?void 0:n.create)||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],a=this.updateF(s,r);return this.compareF(s,a)?0:(i.values[n]=a,1)},reconfigure:(i,r)=>{let s=i.facet(Xw),a=r.facet(Xw),o;return(o=s.find(c=>c.field==this))&&o!=a.find(c=>c.field==this)?(i.values[n]=o.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(t){return[this,Xw.of({field:this,create:t})]}get extension(){return this}}const Ih={lowest:4,low:3,default:2,high:1,highest:0};function sO(e){return t=>new bce(t,e)}const vd={highest:sO(Ih.highest),high:sO(Ih.high),default:sO(Ih.default),low:sO(Ih.low),lowest:sO(Ih.lowest)};class bce{constructor(t,n){this.inner=t,this.prec=n}get extension(){return this}}class jA{of(t){return new QM(this,t)}reconfigure(t){return jA.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class QM{constructor(t,n){this.compartment=t,this.inner=n}get extension(){return this}}class iT{constructor(t,n,i,r,s,a){for(this.base=t,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,i){let r=[],s=Object.create(null),a=new Map;for(let h of yWe(t,n,a))h instanceof Ms?r.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let o=Object.create(null),c=[],u=[];for(let h of r)o[h.id]=u.length<<1,u.push(p=>h.slot(p));let d=i==null?void 0:i.config.facets;for(let h in s){let p=s[h],g=p[0].facet,b=d&&d[h]||[];if(p.every(y=>y.type==0))if(o[g.id]=c.length<<1|1,s4(b,p))c.push(i.facet(g));else{let y=g.combine(p.map(O=>O.value));c.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(o[y.id]=c.length<<1|1,c.push(y.value)):(o[y.id]=u.length<<1,u.push(O=>y.dynamicSlot(O)));o[g.id]=u.length<<1,u.push(y=>OWe(y,g,p))}}let f=u.map(h=>h(o));return new iT(t,a,f,o,c,s)}}function yWe(e,t,n){let i=[[],[],[],[],[]],r=new Map;function s(a,o){let c=r.get(a);if(c!=null){if(c<=o)return;let u=i[c].indexOf(a);u>-1&&i[c].splice(u,1),a instanceof QM&&n.delete(a.compartment)}if(r.set(a,o),Array.isArray(a))for(let u of a)s(u,o);else if(a instanceof QM){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=t.get(a.compartment)||a.inner;n.set(a.compartment,u),s(u,o)}else if(a instanceof bce)s(a.inner,a.prec);else if(a instanceof Ms)i[o].push(a),a.provides&&s(a.provides,o);else if(a instanceof hE)i[o].push(a),a.facet.extensions&&s(a.facet.extensions,Ih.default);else{let u=a.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(u==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,o)}}return s(e,Ih.default),i.reduce((a,o)=>a.concat(o))}function Sy(e,t){if(t&1)return 2;let n=t>>1,i=e.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function rT(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const Oce=yt.define(),BM=yt.define({combine:e=>e.some(t=>t),static:!0}),yce=yt.define({combine:e=>e.length?e[0]:void 0,static:!0}),xce=yt.define(),vce=yt.define(),wce=yt.define(),Sce=yt.define({combine:e=>e.length?e[0]:!1});class Kc{constructor(t,n){this.type=t,this.value=n}static define(){return new xWe}}class xWe{of(t){return new Kc(this,t)}}class vWe{constructor(t){this.map=t}of(t){return new rn(this,t)}}class rn{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new rn(this.type,n)}is(t){return this.type==t}static define(t={}){return new vWe(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let i=[];for(let r of t){let s=r.map(n);s&&i.push(s)}return i}}rn.reconfigure=rn.define();rn.appendConfig=rn.define();class Xr{constructor(t,n,i,r,s,a){this.startState=t,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,i&&gce(i,n.newLength),s.some(o=>o.type==Xr.time)||(this.annotations=s.concat(Xr.time.of(Date.now())))}static create(t,n,i,r,s,a){return new Xr(t,n,i,r,s,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(Xr.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}Xr.time=Kc.define();Xr.userEvent=Kc.define();Xr.addToHistory=Kc.define();Xr.remote=Kc.define();function wWe(e,t){let n=[];for(let i=0,r=0;;){let s,a;if(i=e[i]))s=e[i++],a=e[i++];else if(r=0;r--){let s=i[r](e);s instanceof Xr?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Xr?e=s[0]:e=kce(t,Ng(s),!1)}return e}function EWe(e){let t=e.startState,n=t.facet(wce),i=e;for(let r=n.length-1;r>=0;r--){let s=n[r](e);s&&Object.keys(s).length&&(i=Ece(i,UM(t,s,e.changes.newLength),!0))}return i==e?e:Xr.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}const kWe=[];function Ng(e){return e==null?kWe:Array.isArray(e)?e:[e]}var lr=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(lr||(lr={}));const TWe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let zM;try{zM=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _We(e){if(zM)return zM.test(e);for(let t=0;t"€"&&(n.toUpperCase()!=n.toLowerCase()||TWe.test(n)))return!0}return!1}function AWe(e){return t=>{if(!/\S/.test(t))return lr.Space;if(_We(t))return lr.Word;for(let n=0;n-1)return lr.Word;return lr.Other}}class Bn{constructor(t,n,i,r,s,a){this.config=t,this.doc=n,this.selection=i,this.values=r,this.status=t.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let o=0;or.set(u,c)),n=null),r.set(o.value.compartment,o.value.extension)):o.is(rn.reconfigure)?(n=null,i=o.value):o.is(rn.appendConfig)&&(n=null,i=Ng(i).concat(o.value));let s;n?s=t.startState.values.slice():(n=iT.resolve(i,r,this),s=new Bn(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(c,u)=>u.reconfigure(c,this),null).values);let a=t.startState.facet(BM)?t.newSelection:t.newSelection.asSingle();new Bn(n,t.newDoc,a,s,(o,c)=>c.update(o,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:Qe.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,i=t(n.ranges[0]),r=this.changes(i.changes),s=[i.range],a=Ng(i.effects);for(let o=1;oa.spec.fromJSON(o,c)))}}return Bn.create({doc:t.doc,selection:Qe.fromJSON(t.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(t={}){let n=iT.resolve(t.extensions||[],new Map),i=t.doc instanceof ei?t.doc:ei.of((t.doc||"").split(n.staticFacet(Bn.lineSeparator)||MM)),r=t.selection?t.selection instanceof Qe?t.selection:Qe.single(t.selection.anchor,t.selection.head):Qe.single(0);return gce(r,i.length),n.staticFacet(BM)||(r=r.asSingle()),new Bn(n,i,r,n.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(Bn.tabSize)}get lineBreak(){return this.facet(Bn.lineSeparator)||` -`}get readOnly(){return this.facet(Sce)}phrase(t,...n){for(let i of this.facet(Bn.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),t}languageDataAt(t,n,i=-1){let r=[];for(let s of this.facet(Oce))for(let a of s(this,n,i))Object.prototype.hasOwnProperty.call(a,t)&&r.push(a[t]);return r}charCategorizer(t){let n=this.languageDataAt("wordChars",t);return AWe(n.length?n[0]:"")}wordAt(t){let{text:n,from:i,length:r}=this.doc.lineAt(t),s=this.charCategorizer(t),a=t-i,o=t-i;for(;a>0;){let c=Os(n,a,!1);if(s(n.slice(c,a))!=lr.Word)break;a=c}for(;oe.length?e[0]:4});Bn.lineSeparator=yce;Bn.readOnly=Sce;Bn.phrases=yt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(r=>e[r]==t[r])}});Bn.languageData=Oce;Bn.changeFilter=xce;Bn.transactionFilter=vce;Bn.transactionExtender=wce;jA.reconfigure=rn.define();function Jc(e,t,n={}){let i={};for(let r of e)for(let s of Object.keys(r)){let a=r[s],o=i[s];if(o===void 0)i[s]=a;else if(!(o===a||a===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](o,a);else throw new Error("Config merge conflict for field "+s)}for(let r in t)i[r]===void 0&&(i[r]=t[r]);return i}class Ff{eq(t){return this==t}range(t,n=t){return Ix.create(t,n,this)}}Ff.prototype.startSide=Ff.prototype.endSide=0;Ff.prototype.point=!1;Ff.prototype.mapMode=Cs.TrackDel;function a4(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}class Ix{constructor(t,n,i){this.from=t,this.to=n,this.value=i}static create(t,n,i){return new Ix(t,n,i)}}function FM(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class o4{constructor(t,n,i,r){this.from=t,this.to=n,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(t,n,i,r=0){let s=i?this.to:this.from;for(let a=r,o=s.length;;){if(a==o)return a;let c=a+o>>1,u=s[c]-t||(i?this.value[c].endSide:this.value[c].startSide)-n;if(c==a)return u>=0?a:o;u>=0?o=c:a=c+1}}between(t,n,i,r){for(let s=this.findIndex(n,-1e9,!0),a=this.findIndex(i,1e9,!1,s);sp||h==p&&u.startSide>0&&u.endSide<=0)continue;(p-h||u.endSide-u.startSide)<0||(a<0&&(a=h),u.point&&(o=Math.max(o,p-h)),i.push(u),r.push(h-a),s.push(p-a))}return{mapped:i.length?new o4(r,s,i,o):null,pos:a}}}class jn{constructor(t,n,i,r){this.chunkPos=t,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(t,n,i,r){return new jn(t,n,i,r)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let n of this.chunk)t+=n.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=t,a=t.filter;if(n.length==0&&!a)return this;if(i&&(n=n.slice().sort(FM)),this.isEmpty)return n.length?jn.of(n):this;let o=new Tce(this,null,-1).goto(0),c=0,u=[],d=new od;for(;o.value||c=0){let f=n[c++];d.addInner(f.from,f.to,f.value)||u.push(f)}else o.rangeIndex==1&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||so.to||s=s&&t<=s+a.length&&a.between(s,t-s,n-s,i)===!1)return}this.nextLayer.between(t,n,i)}}iter(t=0){return Px.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return Px.from(t).goto(n)}static compare(t,n,i,r,s=-1){let a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),o=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),c=YF(a,o,i),u=new aO(a,c,s),d=new aO(o,c,s);i.iterGaps((f,h,p)=>GF(u,f,d,h,p,r)),i.empty&&i.length==0&&GF(u,0,d,0,0,r)}static eq(t,n,i=0,r){r==null&&(r=999999999);let s=t.filter(d=>!d.isEmpty&&n.indexOf(d)<0),a=n.filter(d=>!d.isEmpty&&t.indexOf(d)<0);if(s.length!=a.length)return!1;if(!s.length)return!0;let o=YF(s,a),c=new aO(s,o,0).goto(i),u=new aO(a,o,0).goto(i);for(;;){if(c.to!=u.to||!VM(c.active,u.active)||c.point&&(!u.point||!a4(c.point,u.point)))return!1;if(c.to>r)return!0;c.next(),u.next()}}static spans(t,n,i,r,s=-1){let a=new aO(t,null,s).goto(n),o=n,c=a.openStart;for(;;){let u=Math.min(a.to,i);if(a.point){let d=a.activeForPoint(a.to),f=a.pointFromo&&(r.span(o,u,a.active,c),c=a.openEnd(u));if(a.to>i)return c+(a.point&&a.to>i?1:0);o=a.to,a.next()}}static of(t,n=!1){let i=new od;for(let r of t instanceof Ix?[t]:n?NWe(t):t)i.add(r.from,r.to,r.value);return i.finish()}static join(t){if(!t.length)return jn.empty;let n=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let r=t[i];r!=jn.empty;r=r.nextLayer)n=new jn(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}jn.empty=new jn([],[],null,-1);function NWe(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(FM);t=i}return e}jn.empty.nextLayer=jn.empty;class od{finishChunk(t){this.chunks.push(new o4(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,i){this.addInner(t,n,i)||(this.nextLayer||(this.nextLayer=new od)).add(t,n,i)}addInner(t,n,i){let r=t-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-t)),!0)}addChunk(t,n){if((t-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(t);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+t,this.lastTo=n.to[i]+t,!0}finish(){return this.finishInner(jn.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=jn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}}function YF(e,t,n){let i=new Map;for(let s of e)for(let a=0;a=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new Tce(a,n,i,s));return r.length==1?r[0]:new Px(r)}get startSide(){return this.value?this.value.startSide:0}goto(t,n=-1e9){for(let i of this.heap)i.goto(t,n);for(let i=this.heap.length>>1;i>=0;i--)tj(this.heap,i);return this.next(),this}forward(t,n){for(let i of this.heap)i.forward(t,n);for(let i=this.heap.length>>1;i>=0;i--)tj(this.heap,i);(this.to-t||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tj(this.heap,0)}}}function tj(e,t){for(let n=e[t];;){let i=(t<<1)+1;if(i>=e.length)break;let r=e[i];if(i+1=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class aO{constructor(t,n,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Px.from(t,n,i)}goto(t,n=-1e9){return this.cursor.goto(t,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=n,this.openStart=-1,this.next(),this}forward(t,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(t,n)}removeActive(t){qw(this.active,t),qw(this.activeTo,t),qw(this.activeRank,t),this.minActive=WF(this.active,this.activeTo)}addActive(t){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n0;)n++;Hw(this.active,n,i),Hw(this.activeTo,n,r),Hw(this.activeRank,n,s),t&&Hw(t,n,this.cursor.from),this.minActive=WF(this.active,this.activeTo)}next(){let t=this.to,n=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>t){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&qw(i,r)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(t){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)n++;return n}}function GF(e,t,n,i,r,s){e.goto(t),n.goto(i);let a=i+r,o=i,c=i-t,u=!!s.boundChange;for(let d=!1;;){let f=e.to+c-n.to,h=f||e.endSide-n.endSide,p=h<0?e.to+c:n.to,g=Math.min(p,a);if(e.point||n.point?(e.point&&n.point&&a4(e.point,n.point)&&VM(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(o,g,e.point,n.point),d=!1):(d&&s.boundChange(o),g>o&&!VM(e.active,n.active)&&s.compareRange(o,g,e.active,n.active),u&&ga)break;o=p,h<=0&&e.next(),h>=0&&n.next()}}function VM(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;i--)e[i+1]=e[i];e[t]=n}function WF(e,t){let n=-1,i=1e9;for(let r=0;r=t)return r;if(r==e.length)break;s+=e.charCodeAt(r)==9?n-s%n:1,r=Os(e,r)}return i===!0?-1:e.length}const qM="ͼ",ZF=typeof Symbol>"u"?"__"+qM:Symbol.for(qM),HM=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),KF=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Vf{constructor(t,n){this.rules=[];let{finish:i}=n||{};function r(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function s(a,o,c,u){let d=[],f=/^@(\w+)\b/.exec(a[0]),h=f&&f[1]=="keyframes";if(f&&o==null)return c.push(a[0]+";");for(let p in o){let g=o[p];if(/&/.test(p))s(p.split(/,\s*/).map(b=>a.map(y=>b.replace(/&/,y))).reduce((b,y)=>b.concat(y)),g,c);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,d,h)}else g!=null&&d.push(p.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+g+";")}(d.length||h)&&c.push((i&&!f&&!u?a.map(i):a).join(", ")+" {"+d.join(" ")+"}")}for(let a in t)s(r(a),t[a],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let t=KF[ZF]||1;return KF[ZF]=t+1,qM+t.toString(36)}static mount(t,n,i){let r=t[HM],s=i&&i.nonce;r?s&&r.setNonce(s):r=new CWe(t,s),r.mount(Array.isArray(n)?n:[n],t)}}let JF=new Map;class CWe{constructor(t,n){let i=t.ownerDocument||t,r=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&r.CSSStyleSheet){let s=JF.get(i);if(s)return t[HM]=s;this.sheet=new r.CSSStyleSheet,JF.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[HM]=this}mount(t,n){let i=this.sheet,r=0,s=0;for(let a=0;a-1&&(this.modules.splice(c,1),s--,c=-1),c==-1){if(this.modules.splice(s++,0,o),i)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},jWe=typeof navigator<"u"&&/Mac/.test(navigator.platform),RWe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _s=0;_s<10;_s++)Xf[48+_s]=Xf[96+_s]=String(_s);for(var _s=1;_s<=24;_s++)Xf[_s+111]="F"+_s;for(var _s=65;_s<=90;_s++)Xf[_s]=String.fromCharCode(_s+32),Mx[_s]=String.fromCharCode(_s);for(var nj in Xf)Mx.hasOwnProperty(nj)||(Mx[nj]=Xf[nj]);function IWe(e){var t=jWe&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||RWe&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Mx:Xf)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function Ei(){var e=arguments[0];typeof e=="string"&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];typeof r=="string"?e.setAttribute(i,r):r!=null&&(e[i]=r)}t++}for(;t2);var Ot={mac:nV||/Mac/.test(ha.platform),windows:/Win/.test(ha.platform),linux:/Linux|X11/.test(ha.platform),ie:RA,ie_version:Ace?YM.documentMode||6:WM?+WM[1]:GM?+GM[1]:0,gecko:eV,gecko_version:eV?+(/Firefox\/(\d+)/.exec(ha.userAgent)||[0,0])[1]:0,chrome:!!ij,chrome_version:ij?+ij[1]:0,ios:nV,android:/Android\b/.test(ha.userAgent),webkit:tV,webkit_version:tV?+(/\bAppleWebKit\/(\d+)/.exec(ha.userAgent)||[0,0])[1]:0,safari:ZM,safari_version:ZM?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ha.userAgent)||[0,0])[1]:0,tabSize:YM.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function l4(e,t){for(let n in e)n=="class"&&t.class?t.class+=" "+e.class:n=="style"&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const sT=Object.create(null);function c4(e,t,n){if(e==t)return!0;e||(e=sT),t||(t=sT);let i=Object.keys(e),r=Object.keys(t);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||e[s]!==t[s]))return!1;return!0}function PWe(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;t[i]==null&&e.removeAttribute(i)}for(let n in t){let i=t[n];n=="style"?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}function iV(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,r=="style"?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,r=="style"?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function MWe(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new kp(t,n,n,i,t.widget||null,!1)}static replace(t){let n=!!t.block,i,r;if(t.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:a}=Nce(t,n);i=(s?n?-3e8:-1:5e8)-1,r=(a?n?2e8:1:-6e8)+1}return new kp(t,i,r,n,t.widget||null,!0)}static line(t){return new K1(t)}static set(t,n=!1){return jn.of(t,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}zt.none=jn.empty;class Z1 extends zt{constructor(t){let{start:n,end:i}=Nce(t);super(n?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?l4(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||sT}eq(t){return this==t||t instanceof Z1&&this.tagName==t.tagName&&c4(this.attrs,t.attrs)}range(t,n=t){if(t>=n)throw new RangeError("Mark decorations may not be empty");return super.range(t,n)}}Z1.prototype.point=!1;class K1 extends zt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof K1&&this.spec.class==t.spec.class&&c4(this.spec.attributes,t.spec.attributes)}range(t,n=t){if(n!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,n)}}K1.prototype.mapMode=Cs.TrackBefore;K1.prototype.point=!0;class kp extends zt{constructor(t,n,i,r,s,a){super(n,i,s,t),this.block=r,this.isReplace=a,this.mapMode=r?n<=0?Cs.TrackBefore:Cs.TrackAfter:Cs.TrackDel}get type(){return this.startSide!=this.endSide?Is.WidgetRange:this.startSide<=0?Is.WidgetBefore:Is.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof kp&&LWe(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,n=t){if(this.isReplace&&(t>n||t==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,n)}}kp.prototype.point=!0;function Nce(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return n==null&&(n=e.inclusive),i==null&&(i=e.inclusive),{start:n??t,end:i??t}}function LWe(e,t){return e==t||!!(e&&t&&e.compare(t))}function Cg(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}class Lx extends Ff{constructor(t,n,i){super(),this.tagName=t,this.attributes=n,this.rank=i}eq(t){return t==this||t instanceof Lx&&this.tagName==t.tagName&&c4(this.attributes,t.attributes)}static create(t){return new Lx(t.tagName,t.attributes||sT,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return jn.of(t,n)}}Lx.prototype.startSide=Lx.prototype.endSide=-1;function Dx(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function KM(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function Ey(e,t){if(!t.anchorNode)return!1;try{return KM(e,t.anchorNode)}catch{return!1}}function ky(e){return e.nodeType==3?Qx(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Ty(e,t,n,i){return n?rV(e,t,n,i,-1)||rV(e,t,n,i,1):!1}function qf(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function aT(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function rV(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:ld(e))){if(e.nodeName=="DIV")return!1;let s=e.parentNode;if(!s||s.nodeType!=1)return!1;t=qf(e)+(r<0?0:1),e=s}else if(e.nodeType==1){if(e=e.childNodes[t+(r<0?-1:0)],e.nodeType==1&&e.contentEditable=="false")return!1;t=r<0?ld(e):0}else return!1}}function ld(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function $x(e,t){let{left:n,right:i}=e;if(n==i)return e;let r=t?n:i;return{left:r,right:r,top:e.top,bottom:e.bottom}}function DWe(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Cce(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function $We(e,t,n,i,r,s,a,o){let c=e.ownerDocument,u=c.defaultView||window;for(let d=e,f=!1;d&&!f;)if(d.nodeType==1){let h,p=d==c.body,g=1,b=1;if(p)h=DWe(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(f=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let v=d.getBoundingClientRect();({scaleX:g,scaleY:b}=Cce(d,v)),h={left:v.left,right:v.left+d.clientWidth*g,top:v.top,bottom:v.top+d.clientHeight*b}}let y=0,O=0;if(r=="nearest")t.top0&&t.bottom>h.bottom+O&&(O=t.bottom-h.bottom+a)):t.bottom>h.bottom-a&&(O=t.bottom-h.bottom+a,n<0&&t.top-O0&&t.right>h.right+y&&(y=t.right-h.right+s)):t.right>h.right-s&&(y=t.right-h.right+s,n<0&&t.lefth.bottom||t.lefth.right)&&(t={left:Math.max(t.left,h.left),right:Math.min(t.right,h.right),top:Math.max(t.top,h.top),bottom:Math.min(t.bottom,h.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function jce(e,t=!0){let n=e.ownerDocument,i=null,r=null;for(let s=e.parentNode;s&&!(s==n.body||(!t||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),t&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class QWe{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:n,focusNode:i}=t;this.set(n,Math.min(t.anchorOffset,n?ld(n):0),i,Math.min(t.focusOffset,i?ld(i):0))}set(t,n,i,r){this.anchorNode=t,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}let Ch=null;Ot.safari&&Ot.safari_version>=26&&(Ch=!1);function Rce(e){if(e.setActive)return e.setActive();if(Ch)return e.focus(Ch);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(Ch==null?{get preventScroll(){return Ch={preventScroll:!0},!0}}:void 0),!Ch){Ch=!1;for(let n=0;nMath.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Pce(e,t){for(let n=e,i=t;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=ld(n)}else if(n.parentNode&&!aT(n))i=qf(n),n=n.parentNode;else return null}}function Mce(e,t){for(let n=e,i=t;;){if(n.nodeType==3&&i=n){if(o.level==i)return a;(s<0||(r!=0?r<0?o.fromn:t[s].level>o.level))&&(s=a)}}if(s<0)throw new RangeError("Index out of range");return s}}function $ce(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;b-=3)if(pc[b+1]==-p){let y=pc[b+2],O=y&2?r:y&4?y&1?s:r:0;O&&(Ii[f]=Ii[pc[b]]=O),o=b;break}}else{if(pc.length==189)break;pc[o++]=f,pc[o++]=h,pc[o++]=c}else if((g=Ii[f])==2||g==1){let b=g==r;c=b?0:1;for(let y=o-3;y>=0;y-=3){let O=pc[y+2];if(O&2)break;if(b)pc[y+2]|=2;else{if(O&4)break;pc[y+2]|=4}}}}}function HWe(e,t,n,i){for(let r=0,s=i;r<=n.length;r++){let a=r?n[r-1].to:e,o=rc;)g==y&&(g=n[--b].from,y=b?n[b-1].to:e),Ii[--g]=p;c=d}else s=u,c++}}}function eL(e,t,n,i,r,s,a){let o=i%2?2:1;if(i%2==r%2)for(let c=t,u=0;cc&&a.push(new jc(c,b.from,p));let y=b.direction==Tp!=!(p%2);tL(e,y?i+1:i,r,b.inner,b.from,b.to,a),c=b.to}g=b.to}else{if(g==n||(d?Ii[g]!=o:Ii[g]==o))break;g++}h?eL(e,c,g,i+1,r,h,a):ct;){let d=!0,f=!1;if(!u||c>s[u-1].to){let b=Ii[c-1];b!=o&&(d=!1,f=b==16)}let h=!d&&o==1?[]:null,p=d?i:i+1,g=c;e:for(;;)if(u&&g==s[u-1].to){if(f)break e;let b=s[--u];if(!d)for(let y=b.from,O=u;;){if(y==t)break e;if(O&&s[O-1].to==y)y=s[--O].from;else{if(Ii[y-1]==o)break e;break}}if(h)h.push(b);else{b.toIi.length;)Ii[Ii.length]=256;let i=[],r=t==Tp?0:1;return tL(e,r,r,n,0,e.length,i),i}function Qce(e){return[new jc(0,e,0)]}let Bce="";function GWe(e,t,n,i,r){var s;let a=i.head-e.from,o=jc.find(t,a,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),c=t[o],u=c.side(r,n);if(a==u){let h=o+=r?1:-1;if(h<0||h>=t.length)return null;c=t[o=h],a=c.side(!r,n),u=c.side(r,n)}let d=Os(e.text,a,c.forward(r,n));(dc.to)&&(d=u),Bce=e.text.slice(Math.min(a,d),Math.max(a,d));let f=o==(r?t.length-1:0)?null:t[o+(r?1:-1)];return f&&d==u&&f.level+(r?0:1)e.some(t=>t)}),Yce=yt.define({combine:e=>e.some(t=>t)}),Gce=yt.define();class Rg{constructor(t,n,i,r,s,a=!1){this.range=t,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=a}map(t){return t.empty?this:new Rg(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Rg(Qe.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Yw=rn.define({map:(e,t)=>e.map(t)}),Wce=rn.define();function Qa(e,t,n){let i=e.facet(Vce);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const Cu=yt.define({combine:e=>e.length?e[0]:!0});let ZWe=0;const ag=yt.define({combine(e){return e.filter((t,n)=>{for(let i=0;i{let c=[];return a&&c.push(IA.of(u=>{let d=u.plugin(o);return d?a(d):zt.none})),s&&c.push(s(o)),c})}static fromClass(t,n){return Tr.define((i,r)=>new t(i,r),n)}}class rj{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Qa(n.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(n){Qa(t.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Qa(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Zce=yt.define(),h4=yt.define(),IA=yt.define(),Kce=yt.define(),p4=yt.define(),J1=yt.define(),Jce=yt.define();function aV(e,t){let n=e.state.facet(Jce);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(e):s),r=[];return jn.spans(i,t.from,t.to,{point(){},span(s,a,o,c){let u=s-t.from,d=a-t.from,f=r;for(let h=o.length-1;h>=0;h--,c--){let p=o[h].spec.bidiIsolate,g;if(p==null&&(p=WWe(t.text,u,d)),c>0&&f.length&&(g=f[f.length-1]).to==u&&g.direction==p)g.to=d,f=g.inner;else{let b={from:u,to:d,direction:p,inner:[]};f.push(b),f=b.inner}}}}),r}const eue=yt.define();function m4(e){let t=0,n=0,i=0,r=0;for(let s of e.state.facet(eue)){let a=s(e);a&&(a.left!=null&&(t=Math.max(t,a.left)),a.right!=null&&(n=Math.max(n,a.right)),a.top!=null&&(i=Math.max(i,a.top)),a.bottom!=null&&(r=Math.max(r,a.bottom)))}return{left:t,right:n,top:i,bottom:r}}const LO=yt.define();class Yo{constructor(t,n,i,r){this.fromA=t,this.toA=n,this.fromB=i,this.toB=r}join(t){return new Yo(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let n=t.length,i=this;for(;n>0;n--){let r=t[n-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new Yo(s,a,o,c))),this.changedRanges=r}static create(t,n,i){return new oT(t,n,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const KWe=[];class Er{constructor(t,n,i=0){this.dom=t,this.length=n,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return KWe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&PWe(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,n=this.posAtStart){let i=n;for(let r of this.children){if(r==t)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,n,i){return null}domPosFor(t,n){let i=qf(this.dom),r=this.length?t>0:n>0;return new Il(this.parent.dom,i+(r?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof MA)return t;return null}static get(t){return t.cmTile}}class PA extends Er{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let n=this.dom,i=null,r,s=(t==null?void 0:t.node)==n?t:null,a=0;for(let o of this.children){if(o.sync(t),a+=o.length+o.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=o.dom&&(s.written=!0),o.dom.parentNode==n)for(;r&&r!=o.dom;)r=oV(r);else n.insertBefore(o.dom,r);i=o.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=oV(r);this.length=a}}function oV(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class MA extends PA{constructor(t,n){super(n),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let n=Er.get(t);if(n&&this.owns(n))return n;t=t.parentNode}}blockTiles(t){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let a=i.children[r++];if(a instanceof Yu)n.push(r),i=a,r=0;else{let o=s+a.length,c=t(a,s);if(c!==void 0)return c;s=o+a.breakAfter}}}resolveBlock(t,n){let i,r=-1,s,a=-1;if(this.blockTiles((o,c)=>{let u=c+o.length;if(t>=c&&t<=u){if(o.isWidget()&&n>=-1&&n<=1){if(o.flags&32)return!0;o.flags&16&&(i=void 0)}(ct||t==c&&(n>1?o.length:o.covers(-1)))&&(!s||!o.isWidget()&&s.isWidget())&&(s=o,a=t-c)}}),!i&&!s)throw new Error("No tile at position "+t);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:a}}}class Yu extends PA{constructor(t,n){super(t),this.wrapper=n}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let i=new Yu(n||document.createElement(t.tagName),t);return n||(i.flags|=4),i}}class y0 extends PA{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,i){let r=new y0(n||document.createElement("div"),t);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(t,n,i){let r=null,s=-1,a=null,o=-1;function c(d,f){for(let h=0,p=0;h=f&&(g.isComposite()?c(g,f-p):(!a||a.isHidden&&(n>0&&!(a.flags&32)||i&&eZe(a,g)))&&(b>f||g.flags&32)?(a=g,o=f-p):(pr&&(t=r);let s=t,a=t,o=0;t==0&&n<0||t==r&&n>=0?Ot.chrome||Ot.gecko||(t?(s--,o=1):a=0)?0:c.length-1];return Ot.safari&&!o&&u.width==0&&(u=Array.prototype.find.call(c,d=>d.width)||u),i==null?u:$x(u,(o?o>0:n<0)==i)}static of(t,n){let i=new Vh(n||document.createTextNode(t),t);return n||(i.flags|=2),i}}class _p extends Er{constructor(t,n,i,r){super(t,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,n){return this.coordsInWidget(t,n,!1)}coordsInWidget(t,n,i){let r=this.widget.coordsAt(this.dom,t,n);if(r)return r;if(i)return $x(this.dom.getBoundingClientRect(),this.length?t==0:n<=0);{let s=this.dom.getClientRects(),a=null;if(!s.length)return null;let o=this.flags&16?!0:this.flags&32?!1:t>0;for(let c=o?s.length-1:0;a=s[c],!(t>0?c==0:c==s.length-1||a.top0==i)}}class tZe{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,n,i){let{tile:r,index:s,beforeBreak:a,parents:o}=this;for(;t||n>0;)if(r.isComposite())if(a){if(!t)break;i&&i.break(),t--,a=!1}else if(s==r.children.length){if(!t&&!o.length)break;i&&i.leave(r),a=!!r.breakAfter,{tile:r,index:s}=o.pop(),s++}else{let c=r.children[s],u=c.breakAfter;(n>0?c.length<=t:c.length=0;o--){let c=n.marks[o],u=r.lastChild;if(u instanceof La&&u.mark.eq(c.mark))u.dom!=c.dom&&u.setDOM(sj(c.dom)),r=u;else{if(this.cache.reused.get(c)){let f=Er.get(c.dom);f&&f.setDOM(sj(c.dom))}let d=La.of(c.mark,c.dom);r.append(d),r=d}this.cache.reused.set(c,2)}let s=Er.get(t.text);s&&this.cache.reused.set(s,2);let a=new Vh(t.text,t.text.nodeValue);a.flags|=8,this.pos=t.range.toB,r.append(a)}addInlineWidget(t,n,i){let r=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(t.flags&16)&&s.append(this.getBuffer(1)),s.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,n,i){this.flushBuffer(),this.ensureMarks(n,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let n=this.afterWidget||this.lastBlock;n.length+=t,this.pos+=t}addLineStart(t,n){var i;t||(t=tue);let r=y0.start(t,n||((i=this.cache.find(y0))===null||i===void 0?void 0:i.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,n){var i;let r=this.curLine;for(let s=t.length-1;s>=0;s--){let a=t[s],o;if(n>0&&(o=r.lastChild)&&o instanceof La&&o.mark.eq(a))r=o,n--;else{let c=La.of(a,(i=this.cache.find(La,u=>u.mark.eq(a)))===null||i===void 0?void 0:i.dom);r.append(c),r=c,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!lV(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(Ot.ios&&lV(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(aj,0,32)||new _p(aj.toDOM(),0,aj,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to=this.pos){let n=t.rank*102+t.value.rank,i=new nZe(t.from,t.to,t.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);n.append(s),n=s}}return n}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let n=2|(t<0?16:32),i=this.cache.find(lT,void 0,1);return i&&(i.flags=n),i||new lT(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class rZe{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=r;let o=this.textOff=Math.min(t,r.length);return s?null:r.slice(0,o)}let n=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const cT=[_p,y0,Vh,La,lT,Yu,MA];for(let e=0;e[]),this.index=cT.map(()=>0),this.reused=new Map}add(t){let n=t.constructor.bucket,i=this.buckets[n];i.length<6?i.push(t):i[this.index[n]=(this.index[n]+1)%6]=t}find(t,n,i=2){let r=t.bucket,s=this.buckets[r],a=this.index[r];for(let o=0;o{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(t,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,a=0;;){let o=ar){let u=c-r;this.preserve(u,!a,!o),r=c,s+=u}if(!o)break;n&&o.fromA<=n.range.fromA&&o.toA>=n.range.toA?(this.forward(o.fromA,n.range.fromA,n.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(c-o);else{let u=c>0||o{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof La&&r.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?r.length&&(r.length=s=0):a instanceof La&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,n){let i=null,r=this.builder,s=-1,a=jn.spans(this.decorations,t,n,{point:(o,c,u,d,f,h)=>{if(u instanceof kp){if(this.disallowBlockEffectsFor[h]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(c>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=d.length,f>d.length)r.continueWidget(c-o);else{let p=u.widget||(u.block?x0.block:x0.inline),g=oZe(u),b=this.cache.findWidget(p,c-o,g)||_p.of(p,this.view,c-o,g);u.block?(u.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(b)):(r.ensureLine(i),r.addInlineWidget(b,d,f))}i=null}else i=lZe(i,u);c>o&&this.text.skip(c-o)},span:(o,c,u,d)=>{for(let f=o;f-1&&(this.openWidget=a>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=a}forward(t,n,i=1){n-t<=10?this.old.advance(n-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let n=[],i=null;for(let r=t.parentNode;;r=r.parentNode){let s=Er.get(r);if(r==this.view.contentDOM)break;s instanceof La?n.push(s):s!=null&&s.isLine()?i=s:s instanceof Yu||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new y0(r,tue):i||n.push(La.of(new Z1({tagName:r.nodeName.toLowerCase(),attributes:MWe(r)}),r)))}return{line:i,marks:n}}}function lV(e,t){let n=i=>{for(let r of i.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function oZe(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}const tue={class:"cm-line"};function lZe(e,t){let n=t.spec.attributes,i=t.spec.class;return!n&&!i||(e||(e={class:"cm-line"}),n&&l4(n,e),i&&(e.class+=" "+i)),e}function cZe(e){let t=[];for(let n=e.parents.length;n>1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof La&&t.push(i.mark)}return t}function sj(e){let t=Er.get(e);return t&&t.setDOM(e.cloneNode()),e}class x0 extends Yl{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}x0.inline=new x0("span");x0.block=new x0("div");const aj=new class extends Yl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class cV{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=zt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new MA(t,t.contentDOM),this.updateInner([new Yo(0,0,0,t.state.doc.length)],null)}update(t){var n;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:d,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!OZe(t.changes,this.hasComposition)&&!t.selectionSet&&(r=t.state.selection.main.head));let s=r>-1?dZe(this.view,t.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:f}=this.hasComposition;i=new Yo(d,f,t.changes.mapPos(d,-1),t.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Ot.ie||Ot.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,o=this.blockWrappers;this.updateDeco();let c=pZe(a,this.decorations,t.changes);c.length&&(i=Yo.extendWithRanges(i,c));let u=gZe(o,this.blockWrappers,t.changes);return u.length&&(i=Yo.extendWithRanges(i,u)),s&&!i.some(d=>d.fromA<=s.range.fromA&&d.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||t.length){let a=this.tile,o=new aZe(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Er.get(n.text)&&o.cache.reused.set(Er.get(n.text),2),this.tile=o.run(t,n),iL(a,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Ot.chrome||Ot.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ey(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||a))return;let o=this.forceSelection;this.forceSelection=!1;let c=this.view.state.selection.main,u,d;if(c.empty?d=u=this.inlineDOMNearPos(c.anchor,c.assoc||1):(d=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),u=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Ot.gecko&&c.empty&&!this.hasComposition&&uZe(u)){let h=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(h,u.node.childNodes[u.offset]||null)),u=d=new Il(h,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!Ty(u.node,u.offset,f.anchorNode,f.anchorOffset)||!Ty(d.node,d.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,c))&&(this.view.observer.ignore(()=>{Ot.android&&Ot.chrome&&i.contains(f.focusNode)&&bZe(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=Dx(this.view.root);if(h)if(c.empty){if(Ot.gecko){let p=fZe(u.node,u.offset);if(p&&p!=3){let g=(p==1?Pce:Mce)(u.node,u.offset);g&&(u=new Il(g.node,g.offset))}}h.collapse(u.node,u.offset),c.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=c.bidiLevel)}else if(h.extend){h.collapse(u.node,u.offset);try{h.extend(d.node,d.offset)}catch{}}else{let p=document.createRange();c.anchor>c.head&&([u,d]=[d,u]),p.setEnd(d.node,d.offset),p.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(p)}a&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(u,d)),this.impreciseAnchor=u.precise?null:new Il(f.anchorNode,f.anchorOffset),this.impreciseHead=d.precise?null:new Il(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(t,n){return this.hasComposition&&n.empty&&Ty(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,n=t.state.selection.main,i=Dx(t.root),{anchorNode:r,anchorOffset:s}=t.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let a=this.lineAt(n.head,n.assoc);if(!a)return;let o=a.posAtStart;if(n.head==o||n.head==o+a.length)return;let c=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!c||!u||c.bottom>u.top)return;let d=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(d.node,d.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let f=t.observer.selectionRange;t.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(t,n){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(t==i.dom)s=i.dom.childNodes[n];else{let a=ld(t)==0?0:n==0?-1:1;for(;;){let o=t.parentNode;if(o==i.dom)break;a==0&&o.firstChild!=o.lastChild&&(t==o.firstChild?a=-1:a=1),t=o}a<0?s=t:s=t.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Er.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let a=0,o=r;;a++){let c=i.children[a];if(c.dom==s)return o;o+=c.length+c.breakAfter}}else return i.isText()?t==i.dom?r+n:r+(n?i.length:0):r}domAtPos(t,n){let{tile:i,offset:r}=this.tile.resolveBlock(t,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(t,n){let i,r=-1,s=!1,a,o=-1,c=!1;return this.tile.blockTiles((u,d)=>{if(u.isWidget()){if(u.flags&32&&d>=t)return!0;u.flags&16&&(s=!0)}else{let f=d+u.length;if(d<=t&&(i=u,r=t-d,s=f=t&&!a&&(a=u,o=t-d,c=d>t),d>t&&a)return!0}}),!i&&!a?this.domAtPos(t,n):(s&&a?i=null:c&&i&&(a=null),i&&n<0||!a?i.domIn(r,n):a.domIn(o,n))}coordsAt(t,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(t,n);return r.isWidget()?r.widget instanceof oj?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(t,n){let{tile:i}=this.tile.resolveBlock(t,n);return i.isLine()?i:null}coordsForChar(t){let{tile:n,offset:i}=this.tile.resolveBlock(t,1);if(!n.isLine())return null;function r(s,a){if(s.isComposite())for(let o of s.children){if(o.length>=a){let c=r(o,a);if(c)return c}if(a-=o.length,a<0)break}else if(s.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,c=this.view.textDirection==Pi.LTR,u=0,d=(f,h,p)=>{for(let g=0;gr);g++){let b=f.children[g],y=h+b.length,O=b.dom.getBoundingClientRect(),{height:v}=O;if(p&&!g&&(u+=O.top-p.top),b instanceof Yu)y>i&&d(b,h,O);else if(h>=i&&(u>0&&n.push(-u),n.push(v+u),u=0,a)){let x=b.dom.lastChild,w=x?ky(x):[];if(w.length){let E=w[w.length-1],S=c?E.right-O.left:O.right-E.left;S>o&&(o=S,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=y)}}p&&g==f.children.length-1&&(u+=p.bottom-O.bottom),h=y+b.breakAfter}};return d(this.tile,0,null),n}textDirectionAt(t){let{tile:n}=this.tile.resolveBlock(t,1);return getComputedStyle(n.dom).direction=="rtl"?Pi.RTL:Pi.LTR}measureTextSize(){let t=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let o=0,c;for(let u of a.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let d=ky(u.dom);if(d.length!=1)return;o+=d[0].width,c=d[0].height}if(o)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:o/a.length,textHeight:c}}});if(t)return t;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let a=ky(n.firstChild)[0];i=n.getBoundingClientRect().height,r=a&&a.width?a.width/27:7,s=a&&a.height?a.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let t=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],a=s?s.from-1:this.view.state.doc.length;if(a>i){let o=(n.lineBlockAt(a).bottom-n.lineBlockAt(i).top)/this.view.scaleY;t.push(zt.replace({widget:new oj(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!s)break;i=s.to+1}return zt.set(t)}updateDeco(){let t=1,n=this.view.state.facet(IA).map(s=>(this.dynamicDecorationMap[t++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(p4).map((s,a)=>{let o=typeof s=="function";return o&&(i=!0),o?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[t++]=i,n.push(jn.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];ttypeof s=="function"?s(this.view):s)}scrollIntoView(t){if(t.isSnapshot){let u=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=u.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let u of this.view.state.facet(Gce))try{if(u(this.view,t.range,t))return!0}catch(d){Qa(this.view.state,d,"scroll handler")}let{range:n}=t,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=m4(this.view),a={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:o,offsetHeight:c}=this.view.scrollDOM;if($We(this.view.scrollDOM,a,n.head1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(t,1).tile)}destroy(){iL(this.tile)}}function iL(e,t){let n=t==null?void 0:t.get(e);if(n!=1){n==null&&e.destroy();for(let i of e.children)iL(i,t)}}function uZe(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable=="false")&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable=="false")}function nue(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Pce(n.focusNode,n.focusOffset),r=Mce(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let o=Er.get(r.node);if(!o||o.isText()&&o.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let c=Er.get(i.node);!c||c.isText()&&c.text!=i.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=i,!s)return null;let a=t-s.offset;return{from:a,to:a+s.node.nodeValue.length,node:s.node}}function dZe(e,t,n){let i=nue(e,n);if(!i)return null;let{node:r,from:s,to:a}=i,o=r.nodeValue;if(/[\n\r]/.test(o)||e.state.doc.sliceString(i.from,i.to)!=o)return null;let c=t.invertedDesc;return{range:new Yo(c.mapPos(s),c.mapPos(a),s,a),text:r}}function fZe(e,t){return e.nodeType!=1?0:(t&&e.childNodes[t-1].contentEditable=="false"?1:0)|(t{it.from&&(n=!0)}),n}class oj extends Yl{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function yZe(e,t,n=1){let i=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(r.length==0)return Qe.cursor(t);s==0?n=1:s==r.length&&(n=-1);let a=s,o=s;n<0?a=Os(r.text,s,!1):o=Os(r.text,s);let c=i(r.text.slice(a,o));for(;a>0;){let u=Os(r.text,a,!1);if(i(r.text.slice(u,a))!=c)break;a=u}for(;oe.defaultLineHeight*1.5){let o=e.viewState.heightOracle.textHeight,c=Math.floor((r-n.top-(e.defaultLineHeight-o)*.5)/o);s+=c*e.viewState.heightOracle.lineLength}let a=e.state.sliceDoc(n.from,n.to);return n.from+XM(a,s,e.state.tabSize)}function rL(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>t)break;if(!(s.tot)return s;(!r||s.type==Is.Text&&(r.type!=s.type||(n<0?s.fromt)))&&(r=s)}}return r||i}return i}function vZe(e,t,n,i){let r=rL(e,t.head,t.assoc||-1),s=!i||r.type!=Is.Text||!(e.lineWrapping||r.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head);if(s){let a=e.dom.getBoundingClientRect(),o=e.textDirectionAt(r.from),c=e.posAtCoords({x:n==(o==Pi.LTR)?a.right-1:a.left+1,y:(s.top+s.bottom)/2});if(c!=null)return Qe.cursor(c,n?-1:1)}return Qe.cursor(n?r.to:r.from,n?-1:1)}function uV(e,t,n,i){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),a=e.textDirectionAt(r.from);for(let o=t,c=null;;){let u=GWe(r,s,a,o,n),d=Bce;if(!u){if(r.number==(n?e.state.doc.lines:1))return o;d=` -`,r=e.state.doc.line(r.number+(n?1:-1)),s=e.bidiSpans(r),u=e.visualLineSide(r,!n)}if(c){if(!c(d))return o}else{if(!i)return u;c=i(d)}o=u}}function wZe(e,t,n){let i=e.state.charCategorizer(t),r=i(n);return s=>{let a=i(s);return r==lr.Space&&(r=a),r==a}}function SZe(e,t,n,i){let r=t.head,s=n?1:-1;if(r==(n?e.state.doc.length:0))return Qe.cursor(r,t.assoc);let a=t.goalColumn,o,c=e.contentDOM.getBoundingClientRect(),u=e.coordsAtPos(r,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),d=e.documentTop;if(u)a==null&&(a=u.left-c.left),o=s<0?u.top:u.bottom;else{let g=e.viewState.lineBlockAt(r);a==null&&(a=Math.min(c.right-c.left,e.defaultCharacterWidth*(r-g.from))),o=(s<0?g.top:g.bottom)+d}let f=c.left+a,h=e.viewState.heightOracle.textHeight>>1,p=i??h;for(let g=0;;g+=h){let b=o+(p+g)*s,y=sL(e,{x:f,y:b},!1,s);if(n?b>c.bottom:bo:v{if(t>s&&tr(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:Qe.cursor(i,ie.viewState.docHeight)return new Ec(e.state.doc.length,-1);if(u=e.elementAtHeight(c),i==null)break;if(u.type==Is.Text){if(i<0?u.toe.viewport.to)break;let h=e.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(h&&(i<0?h.top<=c+s:h.bottom>=c+s))break}let f=e.viewState.heightOracle.textHeight/2;c=i>0?u.bottom+f:u.top-f}if(e.viewport.from>=u.to||e.viewport.to<=u.from){if(n)return null;if(u.type==Is.Text){let f=xZe(e,r,u,a,o);return new Ec(f,f==u.from?1:-1)}}if(u.type!=Is.Text)return c<(u.top+u.bottom)/2?new Ec(u.from,1):new Ec(u.to,-1);let d=e.docView.lineAt(u.from,2);return(!d||d.length!=u.length)&&(d=e.docView.lineAt(u.from,-2)),new EZe(e,a,o,e.textDirectionAt(u.from)).scanTile(d,u.from)}class EZe{constructor(t,n,i,r){this.view=t,this.x=n,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(a.has(b)){let O=r+Math.floor(Math.random()*g);for(let v=0;v1)){if(v.bottomthis.y)(!u||u.top>v.top)&&(u=v),x=-1;else{let w=v.left>this.x?this.x-v.left:v.right(g+g+b)/3)return this.y=c.bottom-1,this.scan(t,n,!0);if(u&&u.top<(g+b+b)/3)return this.y=u.top+1,this.scan(t,n,!0)}let p=(o?this.dirAt(t[d],1):this.baseDir)==Pi.LTR;return{i:d,after:this.x>(h.left+h.right)/2==p}}scanText(t,n){let i=[];for(let s=0;s{let a=i[s]-n,o=i[s+1]-n;return Qx(t.dom,a,o).getClientRects()});return r.after?new Ec(i[r.i+1],-1):new Ec(i[r.i],1)}scanTile(t,n){if(!t.length)return new Ec(n,1);if(t.children.length==1){let o=t.children[0];if(o.isText())return this.scanText(o,n);if(o.isComposite())return this.scanTile(o,n)}let i=[n];for(let o=0,c=n;o{let c=t.children[o];return c.flags&48?null:(c.dom.nodeType==1?c.dom:Qx(c.dom,0,c.length)).getClientRects()}),s=t.children[r.i],a=i[r.i];return s.isText()?this.scanText(s,a):s.isComposite()?this.scanTile(s,a):r.after?new Ec(i[r.i+1],-1):new Ec(a,1)}}const jm="￿";class kZe{constructor(t,n){this.points=t,this.view=n,this.text="",this.lineSeparator=n.state.facet(Bn.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=jm}readRange(t,n){if(!t)return this;let i=t.parentNode;for(let r=t;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let a=Er.get(r),o=r.nextSibling;if(o==n){a!=null&&a.breakAfter&&!o&&i!=this.view.contentDOM&&this.lineBreak();break}let c=Er.get(o);(a&&c?a.breakAfter:(a?a.breakAfter:aT(r))||aT(o)&&(r.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>s)&&!_Ze(o,n)&&this.lineBreak(),r=o}return this.findPointBefore(i,n),this}readTextNode(t){let n=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,a=1,o;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(o=r.exec(n))&&(s=o.index,a=o[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),a>1)for(let c of this.points)c.node==t&&c.pos>this.text.length&&(c.pos-=a-1);i=s+a}}readNode(t){let n=Er.get(t),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,n){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(t,n){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(TZe(t,i.node,i.offset)?n:0))}}function TZe(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:s,impreciseAnchor:a}=t.docView,o=t.state.selection;if(t.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=rue(t.docView.tile,n,i,0))){let c=s||a?[]:CZe(t),u=new kZe(c,t);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=jZe(c,this.bounds.from)}else{let c=t.observer.selectionRange,u=s&&s.node==c.focusNode&&s.offset==c.focusOffset||!KM(t.contentDOM,c.focusNode)?o.main.head:t.docView.posFromDOM(c.focusNode,c.focusOffset),d=a&&a.node==c.anchorNode&&a.offset==c.anchorOffset||!KM(t.contentDOM,c.anchorNode)?o.main.anchor:t.docView.posFromDOM(c.anchorNode,c.anchorOffset),f=t.viewport;if((Ot.ios||Ot.chrome)&&u!=d&&Math.min(u,d)<=o.main.from&&Math.max(u,d)>=o.main.to&&(f.from>0||f.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(Qe.range(d,u));else if(t.lineWrapping&&d==u&&!(o.main.empty&&o.main.head==u)&&t.inputState.lastTouchTime>Date.now()-100){let h=t.coordsAtPos(u,-1),p=0;h&&(p=t.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=Qe.create([Qe.cursor(u,p)])}else this.newSel=Qe.single(d,u)}}}function rue(e,t,n,i){if(e.isComposite()){let r=-1,s=-1,a=-1,o=-1;for(let c=0,u=i,d=i;cn)return rue(f,t,n,u);if(h>=t&&r==-1&&(r=c,s=u),u>n&&f.dom.parentNode==e.dom){a=c,o=d;break}d=h,u=h+f.breakAfter}return{from:s,to:o<0?i+e.length:o,startDOM:(r?e.children[r-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:a=0?e.children[a].dom:null}}else return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function sue(e,t){let n,{newSel:i}=t,{state:r}=e,s=r.selection.main,a=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:c}=t.bounds,u=s.from,d=null;(a===8||Ot.android&&t.text.length=o&&s.to<=c&&(t.typeOver||f!=t.text)&&f.slice(0,s.from-o)==t.text.slice(0,s.from-o)&&f.slice(s.to-o)==t.text.slice(h=t.text.length-(f.length-(s.to-o)))?n={from:s.from,to:s.to,insert:ei.of(t.text.slice(s.from-o,h).split(jm))}:(p=aue(f,t.text,u-o,d))&&(Ot.chrome&&a==13&&p.toB==p.from+2&&t.text.slice(p.from,p.toB)==jm+jm&&p.toB--,n={from:o+p.from,to:o+p.toA,insert:ei.of(t.text.slice(p.from,p.toB).split(jm))})}else i&&(!e.hasFocus&&r.facet(Cu)||uT(i,s))&&(i=null);if(!n&&!i)return!1;if((Ot.mac||Ot.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=Qe.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:ei.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:r.toText(e.inputState.insertingText)}:Ot.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&e.lineWrapping&&(i&&(i=Qe.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:ei.of([" "])}),n)return g4(e,n,i,a);if(i&&!uT(i,s)){let o=!1,c="select";return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin=="select"&&(o=!0),c=e.inputState.lastSelectionOrigin,c=="select.pointer"&&(i=iue(r.facet(J1).map(u=>u(e)),i))),e.dispatch({selection:i,scrollIntoView:o,userEvent:c}),!0}else return!1}function g4(e,t,n,i=-1){if(Ot.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(Ot.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&e.state.sliceDoc(t.from,r.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&jg(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||i==8&&t.insert.lengthr.head)&&jg(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&jg(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a,o=()=>a||(a=NZe(e,t,n));return e.state.facet(Xce).some(c=>c(e,t.from,t.to,s,o))||e.dispatch(o()),!0}function NZe(e,t,n){let i,r=e.state,s=r.selection.main,a=-1;if(t.from==t.to&&t.froms.to){let c=t.fromf(e)),u,c);t.from==d&&(a=d)}if(a>-1)i={changes:t,selection:Qe.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let c=s.fromt.to?r.sliceDoc(t.to,s.to):"";i=r.replaceSelection(e.state.toText(c+t.insert.sliceString(0,void 0,e.state.lineBreak)+u))}else{let c=r.changes(t),u=n&&n.main.to<=c.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let d=e.state.sliceDoc(t.from,t.to),f,h=n&&nue(e,n.main.head);if(h){let g=t.insert.length-(t.to-t.from);f={from:h.from,to:h.to-g}}else f=e.state.doc.lineAt(s.head);let p=s.to-t.to;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:c,range:u||g.map(c)};let b=g.to-p,y=b-d.length;if(e.state.sliceDoc(y,b)!=d||b>=f.from&&y<=f.to)return{range:g};let O=r.changes({from:y,to:b,insert:t.insert}),v=g.to-s.to;return{changes:O,range:u?Qe.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):g.map(O)}})}else i={changes:c,selection:u&&r.selection.replaceRange(u)}}let o="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,o+=".compose",e.inputState.compositionFirstChange&&(o+=".start",e.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function aue(e,t,n,i){let r=Math.min(e.length,t.length),s=0;for(;s0&&o>0&&e.charCodeAt(a-1)==t.charCodeAt(o-1);)a--,o--;if(i=="end"){let c=Math.max(0,s-Math.min(a,o));n-=a+c-s}if(a=a?s-n:0;s-=c,o=s+(o-a),a=s}else if(o=o?s-n:0;s-=c,a=s+(a-o),o=s}return{from:s,toA:a,toB:o}}function CZe(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new dV(n,i)),(r!=n||s!=i)&&t.push(new dV(r,s))),t}function jZe(e,t){if(e.length==0)return null;let n=e[0].pos,i=e.length==2?e[1].pos:n;return n>-1&&i>-1?Qe.single(n+t,i+t):null}function uT(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class RZe{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Ot.safari&&t.contentDOM.addEventListener("input",()=>null),Ot.gecko&&YZe(t.contentDOM.ownerDocument)}handleEvent(t){!UZe(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,n){let i=this.handlers[t];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(t){let n=PZe(t),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let a=!n[s].handlers.length,o=i[s];o&&a!=!o.handlers.length&&(r.removeEventListener(s,this.handleEvent),o=null),o||r.addEventListener(s,this.handleEvent,{passive:a})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&lue.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),Ot.android&&Ot.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(Ot.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(oue.some(n=>n.keyCode==t.keyCode)&&!t.ctrlKey||MZe.indexOf(t.key)>-1&&t.ctrlKey)){let n={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};return n.shiftKey&&Ot.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&IZe(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&t&&t.from0?!0:Ot.safari&&!Ot.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function IZe(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function fV(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(r){Qa(n.state,r)}}}function PZe(e){let t=Object.create(null);function n(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of e){let r=i.spec,s=r&&r.plugin.domEventHandlers,a=r&&r.plugin.domEventObservers;if(s)for(let o in s){let c=s[o];c&&n(o).handlers.push(fV(i.value,c))}if(a)for(let o in a){let c=a[o];c&&n(o).observers.push(fV(i.value,c))}}for(let i in Ul)n(i).handlers.push(Ul[i]);for(let i in va)n(i).observers.push(va[i]);return t}const oue=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],MZe="dthko",lue=[16,17,18,20,91,92,224,225],Gw=6;function Ww(e){return Math.max(0,e)*.7+8}function LZe(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}class DZe{constructor(t,n,i,r){this.view=t,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=jce(t.contentDOM),this.atoms=t.state.facet(J1).map(a=>a(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=t.state.facet(Bn.allowMultipleSelections)&&$Ze(t,n),this.dragging=BZe(t,n)&&due(n)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&LZe(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let n=0,i=0,r=0,s=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:o}=this.scrollParents.y.getBoundingClientRect());let c=m4(this.view);t.clientX-c.left<=r+Gw?n=-Ww(r-t.clientX):t.clientX+c.right>=a-Gw&&(n=Ww(t.clientX-a)),t.clientY-c.top<=s+Gw?i=-Ww(s-t.clientY):t.clientY+c.bottom>=o-Gw&&(i=Ww(t.clientY-o)),this.setScrollSpeed(n,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,n){this.scrollSpeed={x:t,y:n},t||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:n}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(t||n)&&this.view.win.scrollBy(t,n),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:n}=this,i=iue(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function $Ze(e,t){let n=e.state.facet(Uce);return n.length?n[0](t):Ot.mac?t.metaKey:t.ctrlKey}function QZe(e,t){let n=e.state.facet(zce);return n.length?n[0](t):Ot.mac?!t.altKey:!t.ctrlKey}function BZe(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=Dx(e.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=t.clientX&&a.top<=t.clientY&&a.bottom>=t.clientY)return!0}return!1}function UZe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,i;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Er.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const Ul=Object.create(null),va=Object.create(null),cue=Ot.ie&&Ot.ie_version<15||Ot.ios&&Ot.webkit_version<604;function zZe(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),uue(e,n.value)},50)}function LA(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function uue(e,t){t=LA(e.state,d4,t);let{state:n}=e,i,r=1,s=n.toText(t),a=s.lines==n.selection.ranges.length;if(aL!=null&&n.selection.ranges.every(c=>c.empty)&&aL==s.toString()){let c=-1;i=n.changeByRange(u=>{let d=n.doc.lineAt(u.from);if(d.from==c)return{range:u};c=d.from;let f=n.toText((a?s.line(r++).text:t)+n.lineBreak);return{changes:{from:d.from,insert:f},range:Qe.cursor(u.from+f.length)}})}else a?i=n.changeByRange(c=>{let u=s.line(r++);return{changes:{from:c.from,to:c.to,insert:u.text},range:Qe.cursor(c.from+u.length)}}):i=n.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}va.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,Ot.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};va.wheel=va.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};Ul.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);va.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};va.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};va.touchend=(e,t)=>{e.inputState.touchActive=!1};Ul.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(Fce))if(n=i(e,t),n)break;if(!n&&t.button==0&&(n=VZe(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new DZe(e,t,n,i)),i&&e.observer.ignore(()=>{Rce(e.contentDOM);let s=e.root.activeElement;s&&!s.contains(e.contentDOM)&&s.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),r.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function hV(e,t,n,i){if(i==1)return Qe.cursor(t,n);if(i==2)return yZe(e.state,t,n);{let r=e.docView.lineAt(t,n),s=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:s.from,o=r?r.posAtEnd:s.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(mV+1)%3:1}function VZe(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=due(t),r=e.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,a,o){let c=e.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,d=hV(e,c.pos,c.assoc,i);if(n.pos!=c.pos&&!a){let f=hV(e,n.pos,n.assoc,i),h=Math.min(f.from,d.from),p=Math.max(f.to,d.to);d=h1&&(u=XZe(r,c.pos))?u:o?r.addRange(d):Qe.create([d])}}}function XZe(e,t){for(let n=0;n=t)return Qe.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}Ul.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let s=r.posAtStart,a=s+r.length;(s>=n.to||a<=n.from)&&(n=Qe.undirectionalRange(s,a))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",LA(e.state,f4,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Ul.dragend=e=>(e.inputState.draggedContent=null,!1);function bV(e,t,n,i){if(n=LA(e.state,d4,n),!n)return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,a=i&&s&&QZe(e,t)?{from:s.from,to:s.to}:null,o={from:r,insert:n},c=e.state.changes(a?[a,o]:o);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(r,-1),head:c.mapPos(r,1)},userEvent:a?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Ul.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&bV(e,t,i.filter(a=>a!=null).join(e.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(o.result)||(i[a]=o.result),s()},o.readAsText(n[a])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return bV(e,t,i,!0),!0}return!1};Ul.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=cue?null:t.clipboardData;return n?(uue(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(zZe(e),!1)};function qZe(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}function HZe(e){let t=[],n=[],i=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let r=-1;for(let{from:s}of e.selection.ranges){let a=e.doc.lineAt(s);a.number>r&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),r=a.number}i=!0}return{text:LA(e,f4,t.join(e.lineBreak)),ranges:n,linewise:i}}let aL=null;Ul.copy=Ul.cut=(e,t)=>{if(!Ey(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=HZe(e.state);if(!n&&!r)return!1;aL=r?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=cue?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(qZe(e,n),!1)};const fue=Kc.define();function hue(e,t){let n=[];for(let i of e.facet(qce)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:fue.of(!0)}):null}function pue(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=hue(e.state,t);n?e.dispatch(n):e.update([])}},10)}va.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),pue(e)};va.blur=e=>{e.observer.clearSelectionRange(),pue(e)};va.compositionstart=va.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange==null&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))};va.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Ot.chrome&&Ot.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};va.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};Ul.beforeinput=(e,t)=>{var n,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&e.observer.editContext){let s=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),a=t.getTargetRanges();if(s&&a.length){let o=a[0],c=e.posAtDOM(o.startContainer,o.startOffset),u=e.posAtDOM(o.endContainer,o.endOffset);return g4(e,{from:c,to:u,insert:e.state.toText(s)},null),!0}}let r;if(Ot.chrome&&Ot.android&&(r=oue.find(s=>s.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>s+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Ot.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),Ot.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>va.compositionend(e,t),20),!1};const OV=new Set;function YZe(e){OV.has(e)||(OV.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}const yV=["pre-wrap","normal","pre-line","break-spaces"];let v0=!1;function xV(){v0=!1}class GZe{constructor(t){this.lineWrapping=t,this.doc=ei.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return yV.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let n=!1;for(let i=0;i-1,c=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,c){this.heightSamples={};for(let u=0;u0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>pE&&(v0=!0),this.height=t)}replace(t,n,i){return ya.of(i)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,i,r){let s=this,a=i.doc;for(let o=r.length-1;o>=0;o--){let{fromA:c,toA:u,fromB:d,toB:f}=r[o],h=s.lineAt(c,Bi.ByPosNoHeight,i.setDoc(n),0,0),p=h.to>=u?h:s.lineAt(u,Bi.ByPosNoHeight,i,0,0);for(f+=p.to-u,u=p.to;o>0&&h.from<=r[o-1].toA;)c=r[o-1].fromA,d=r[o-1].fromB,o--,cs*2){let o=t[n-1];o.break?t.splice(--n,1,o.left,null,o.right):t.splice(--n,1,o.left,o.right),i+=1+o.break,r-=o.size}else if(s>r*2){let o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,s-=o.size}else break;else if(r=s&&a(this.lineAt(0,Bi.ByPos,i,r,s))}setMeasuredHeight(t){let n=t.heights[t.index++];n<0?(this.spaceAbove=-n,n=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(t,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class so extends mue{constructor(t,n,i){super(t,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,n){return new Cl(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,i){let r=i[0];return i.length==1&&(r instanceof so||r instanceof Ts&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ts?r=new so(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):ya.of(i)}updateHeight(t,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ts extends ya{constructor(t){super(t,0)}heightMetrics(t,n){let i=t.doc.lineAt(n).number,r=t.doc.lineAt(n+this.length).number,s=r-i+1,a,o=0;if(t.lineWrapping){let c=Math.min(this.height,t.lineHeight*s);a=c/s,this.length>s+1&&(o=(this.height-c)/(this.length-s-1))}else a=this.height/s;return{firstLine:i,lastLine:r,perLine:a,perChar:o}}blockAt(t,n,i,r){let{firstLine:s,lastLine:a,perLine:o,perChar:c}=this.heightMetrics(n,r);if(n.lineWrapping){let u=r+(t0){let s=i[i.length-1];s instanceof Ts?i[i.length-1]=new Ts(s.length+r):i.push(null,new Ts(r-1))}if(t>0){let s=i[0];s instanceof Ts?i[0]=new Ts(t+s.length):i.unshift(new Ts(t-1),null)}return ya.of(i)}decomposeLeft(t,n){n.push(new Ts(t-1),null)}decomposeRight(t,n){n.push(null,new Ts(this.length-t-1))}updateHeight(t,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let a=[],o=Math.max(n,r.from),c=-1;for(r.from>n&&a.push(new Ts(r.from-n-1).updateHeight(t,n));o<=s&&r.more;){let d=t.doc.lineAt(o).length;a.length&&a.push(null);let f=r.heights[r.index++],h=0;f<0&&(h=-f,f=r.heights[r.index++]),c==-1?c=f:Math.abs(f-c)>=pE&&(c=-2);let p=new so(d,f,h);p.outdated=!1,a.push(p),o+=d+1}o<=s&&a.push(null,new Ts(s-o).updateHeight(t,o));let u=ya.of(a);return(c<0||Math.abs(u.height-this.height)>=pE||Math.abs(c-this.heightMetrics(t,n).perLine)>=pE)&&(v0=!0),dT(this,u)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class KZe extends ya{constructor(t,n,i){super(t.length+n+i.length,t.height+i.height,n|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,n,i,r){let s=i+this.left.height;return to))return u;let d=n==Bi.ByPosNoHeight?Bi.ByPosNoHeight:Bi.ByPos;return c?u.join(this.right.lineAt(o,d,i,a,o)):this.left.lineAt(o,d,i,r,s).join(u)}forEachLine(t,n,i,r,s,a){let o=r+this.left.height,c=s+this.left.length+this.break;if(this.break)t=c&&this.right.forEachLine(t,n,i,o,c,a);else{let u=this.lineAt(c,Bi.ByPos,i,r,s);t=t&&u.from<=n&&a(u),n>u.to&&this.right.forEachLine(u.to+1,n,i,o,c,a)}}replace(t,n,i){let r=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(t-r,n-r,i));let s=[];t>0&&this.decomposeLeft(t,s);let a=s.length;for(let o of i)s.push(o);if(t>0&&vV(s,a-1),n=i&&n.push(null)),t>i&&this.right.decomposeLeft(t-i,n)}decomposeRight(t,n){let i=this.left.length,r=i+this.break;if(t>=r)return this.right.decomposeRight(t-r,n);t2*n.size||n.size>2*t.size?ya.of(this.break?[t,null,n]:[t,n]):(this.left=dT(this.left,t),this.right=dT(this.right,n),this.setHeight(t.height+n.height),this.outdated=t.outdated||n.outdated,this.size=t.size+n.size,this.length=t.length+this.break+n.length,this)}updateHeight(t,n=0,i=!1,r){let{left:s,right:a}=this,o=n+s.length+this.break,c=null;return r&&r.from<=n+s.length&&r.more?c=s=s.updateHeight(t,n,i,r):s.updateHeight(t,n,i),r&&r.from<=o+a.length&&r.more?c=a=a.updateHeight(t,o,i,r):a.updateHeight(t,o,i),c?this.balanced(s,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function vV(e,t){let n,i;e[t]==null&&(n=e[t-1])instanceof Ts&&(i=e[t+1])instanceof Ts&&e.splice(t-1,3,new Ts(n.length+1+i.length))}const JZe=5;class b4{constructor(t,n){this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof so?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new so(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(t,n,i){if(t=JZe)&&this.addLineDeco(r,s,a)}else n>t&&this.span(t,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=n,this.writtenTot&&this.nodes.push(new so(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let i=new Ts(n-t);return this.oracle.doc.lineAt(t).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof so)return t;let n=new so(0,-1,0);return this.nodes.push(n),n}addBlock(t){this.enterLine();let n=t.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,n&&n.endSide>0&&(this.covering=t)}addLineDeco(t,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,t),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(t){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof so)&&!this.isCovered?this.nodes.push(new so(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&f.overflow!="visible"){let h=d.getBoundingClientRect();s=Math.max(s,h.left),a=Math.min(a,h.right),o=Math.max(o,h.top),c=Math.min(u==e.parentNode?r.innerHeight:c,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?d.offsetParent:d.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,a)-n.left,top:o-(n.top+t),bottom:Math.max(o,c)-(n.top+t)}}function iKe(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function rKe(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class cj{constructor(t,n,i,r){this.from=t,this.to=n,this.size=i,this.displaySize=r}static same(t,n){if(t.length!=n.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new GZe(i),this.stateDeco=EV(n),this.heightMap=ya.empty().applyChanges(this.stateDeco,ei.empty,this.heightOracle.setDoc(n.doc),[new Yo(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=zt.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!t.some(({from:s,to:a})=>r>=s&&r<=a)){let{from:s,to:a}=this.lineBlockAt(r);t.push(new Zw(s,a))}}return this.viewports=t.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?SV:new O4(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(DO(t,this.scaler))})}update(t,n=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=EV(this.state);let r=t.changedRanges,s=Yo.extendWithRanges(r,eKe(i,this.stateDeco,t?t.changes:ns.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);xV(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=a||v0)&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(n&&(n.range.headc.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,n));let u=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(u||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Yce)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,n=t.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Pi.RTL:Pi.LTR;let a=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",o=n.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let u=0,d=0;if(o.width&&o.height){let{scaleX:E,scaleY:S}=Cce(n,o);(E>.005&&Math.abs(this.scaleX-E)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=E,this.scaleY=S,u|=16,a=c=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(c=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=16);let p=jce(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let g=this.getScrollOffset();this.scrollOffset!=g&&(this.scrollAnchorHeight=-1,this.scrollOffset=g),this.scrolledToBottom=Ice(this.scrollParent||t.win);let b=(this.printing?rKe:nKe)(n,this.paddingTop),y=b.top-this.pixelViewport.top,O=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(c=!0)),!this.inView&&!this.scrollTarget&&!iKe(t.dom))return 0;let x=o.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,u|=16),c){let E=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(E)&&(a=!0),a||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:k,textHeight:T}=t.docView.measureTextSize();a=S>0&&r.refresh(s,S,k,T,Math.max(5,x/k),E),a&&(t.docView.minWidth=0,u|=16)}y>0&&O>0?d=Math.max(y,O):y<0&&O<0&&(d=Math.min(y,O)),xV();for(let S of this.viewports){let k=S.from==this.viewport.from?E:t.docView.measureVisibleLineHeights(S);this.heightMap=(a?ya.empty().applyChanges(this.stateDeco,ei.empty,this.heightOracle,[new Yo(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new WZe(S.from,k))}v0&&(u|=2)}let w=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return w&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),u|=this.updateForViewport()),(u&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,t)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,n){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,c=new Zw(r.lineAt(a-i*1e3,Bi.ByHeight,s,0,0).from,r.lineAt(o+(1-i)*1e3,Bi.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(uc.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(u,Bi.ByPos,s,0,0),h;n.y=="center"?h=(f.top+f.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&u=o+Math.max(10,Math.min(i,250)))&&r>a-2*1e3&&s>1,a=r<<1;if(this.defaultTextDirection!=Pi.LTR&&!i)return[];let o=[],c=(d,f,h,p)=>{if(f-dd&&OO.from>=h.from&&O.to<=h.to&&Math.abs(O.from-d)O.fromv));if(!y){if(fx.from<=f&&x.to>=f)){let x=n.moveToLineBoundary(Qe.cursor(f),!1,!0).head;x>d&&(f=x)}let O=this.gapSize(h,d,f,p),v=i||O<2e6?O:2e6;y=new cj(d,f,O,v)}o.push(y)},u=d=>{if(d.length2e6)for(let S of t)S.from>=d.from&&S.fromd.from&&c(d.from,p,d,f),gn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];jn.spans(n,this.viewport.from,this.viewport.to,{span(s,a){i.push({from:s,to:a})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(n=>n.from<=t&&n.to>=t)||DO(this.heightMap.lineAt(t,Bi.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=t&&n.bottom>=t)||DO(this.heightMap.lineAt(this.scaler.fromDOM(t),Bi.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let n=this.lineBlockAtHeight(t+8);return n.from>=this.viewport.from||this.viewportLines[0].top-t>200?n:this.viewportLines[0]}elementAtHeight(t){return DO(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Zw{constructor(t,n){this.from=t,this.to=n}}function aKe(e,t,n){let i=[],r=e,s=0;return jn.spans(n,e,t,{span(){},point(a,o){a>r&&(i.push({from:r,to:a}),s+=a-r),r=o}},20),r=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let r=0;;r++){let{from:s,to:a}=t[r],o=a-s;if(i<=o)return s+i;i-=o}}function Jw(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}function oKe(e,t){for(let n of e)if(t(n))return n}const SV={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function EV(e){let t=e.facet(IA).filter(i=>typeof i!="function"),n=e.facet(p4).filter(i=>typeof i!="function");return n.length&&t.push(jn.join(n)),t}class O4{constructor(t,n,i){let r=0,s=0,a=0;this.viewports=i.map(({from:o,to:c})=>{let u=n.lineAt(o,Bi.ByPos,t,0,0).top,d=n.lineAt(c,Bi.ByPos,t,0,0).bottom;return r+=d-u,{from:o,to:c,top:u,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let o of this.viewports)o.domTop=a+(o.top-s)*this.scale,a=o.domBottom=o.domTop+(o.bottom-o.top),s=o.bottom}toDOM(t){for(let n=0,i=0,r=0;;n++){let s=nn.from==t.viewports[i].from&&n.to==t.viewports[i].to):!1}}function DO(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new Cl(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(r=>DO(r,t)):e._content)}const eS=yt.define({combine:e=>e.join(" ")}),oL=yt.define({combine:e=>e.indexOf(!0)>-1}),lL=Vf.newName(),gue=Vf.newName(),bue=Vf.newName(),Oue={"&light":"."+gue,"&dark":"."+bue};function cL(e,t,n){return new Vf(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return e;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):e+" "+i}})}const lKe=cL("."+lL,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Oue),cKe={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},uj=Ot.ie&&Ot.ie_version<=11;class uKe{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new QWe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(n=>{for(let i of n)this.queue.push(i);(Ot.ie&&Ot.ie_version<=11||Ot.ios&&t.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ot.android&&t.constructor.EDIT_CONTEXT!==!1&&!(Ot.chrome&&Ot.chrome_version<126)&&(this.editContext=new fKe(t),t.state.facet(Cu)&&(t.contentDOM.editContext=this.editContext.editContext)),uj&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((n,i)=>n!=t[i]))){this.gapIntersection.disconnect();for(let n of t)this.gapIntersection.observe(n);this.gaps=t}}onSelectionChange(t){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Cu)?i.root.activeElement!=this.dom:!Ey(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){n||(this.selectionChanged=!1);return}(Ot.ie&&Ot.ie_version<=11||Ot.android&&Ot.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Ty(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,n=Dx(t.root);if(!n)return!1;let i=Ot.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&dKe(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Ey(this.dom,i);return r&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&jg(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let n=-1,i=-1,r=!1;for(let s of t){let a=this.readMutation(s);a&&(a.typeOver&&(r=!0),n==-1?{from:n,to:i}=a:(n=Math.min(a.from,n),i=Math.max(a.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:t,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Ey(this.dom,this.selectionRange);if(t<0&&!r)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new AZe(this.view,t,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=sue(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!uT(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(t){let n=this.view.docView.tile.nearest(t.target);if(!n||n.isWidget())return null;if(n.markDirty(t.type=="attributes"),t.type=="childList"){let i=kV(n,t.previousSibling||t.target.previousSibling,-1),r=kV(n,t.nextSibling||t.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Cu)!=t.state.facet(Cu)&&(t.view.contentDOM.editContext=t.state.facet(Cu)?this.editContext.editContext:null))}destroy(){var t,n,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function kV(e,t,n){for(;t;){let i=Er.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function TV(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,s=t.endOffset,a=e.docView.domAtPos(e.state.selection.main.anchor,1);return Ty(a.node,a.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function dKe(e,t){if(t.getComposedRanges){let r=t.getComposedRanges(e.root)[0];if(r)return TV(e,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?TV(e,n):null}class fKe{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let n=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let r=t.state.selection.main,{anchor:s,head:a}=r,o=this.toEditorPos(i.updateRangeStart),c=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let u=c-o>i.text.length;o==this.from&&sthis.to&&(c=s);let d=aue(t.state.sliceDoc(o,c),i.text,(u?r.from:r.to)-o,u?"end":null);if(!d){let h=Qe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));uT(h,r)||t.dispatch({selection:h,userEvent:"select"});return}let f={from:d.from+o,to:d.toA+o,insert:ei.of(i.text.slice(d.from,d.toB).split(` -`))};if((Ot.mac||Ot.android)&&f.from==a-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:o,to:c,insert:ei.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);g4(t,f,Qe.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let a=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);a{let r=[];for(let s of i.getTextFormats()){let a=s.underlineStyle,o=s.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(o)){let c=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(c{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=Dx(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,i=!1,r=this.pendingContextChange;return t.changes.iterChanges((s,a,o,c,u)=>{if(i)return;let d=u.length-(a-s);if(r&&a>=r.to)if(r.from==s&&r.to==a&&r.insert.eq(u)){r=this.pendingContextChange=null,n+=d,this.to+=d;return}else r=null,this.revertPending(t.state);if(s+=n,a+=n,a<=this.from)this.from+=d,this.to+=d;else if(sthis.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),u.toString()),this.to+=d}n+=d}),r&&!i&&this.revertPending(t.state),!i}update(t){let n=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class ft{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=t.root||BWe(t.parent)||document,this.viewState=new wV(this,t.state||Bn.create(t)),t.scrollTo&&t.scrollTo.is(Yw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ag).map(r=>new rj(r));for(let r of this.plugins)r.update(this);this.observer=new uKe(this),this.inputState=new RZe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new cV(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let n=t.length==1&&t[0]instanceof Xr?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let h of t){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,o=0,c=null;t.some(h=>h.annotation(fue))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,c=hue(s,a),c||(o=1));let u=this.observer.delayedAndroidKey,d=null;if(u?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Bn.phrases)!=this.state.facet(Bn.phrases))return this.setState(s);r=oT.create(this,s,t),r.flags|=o;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:p}=h.state.selection,{x:g,y:b}=this.state.facet(ft.cursorScrollMargin);f=new Rg(p.empty?p:Qe.cursor(p.head,p.head>p.anchor?-1:1),"nearest","nearest",b,g)}for(let p of h.effects)p.is(Yw)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=fT.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(LO)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(eS)!=r.state.facet(eS)&&(this.viewState.mustMeasureContent=!0),(n||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(nL))try{h(r)}catch(p){Qa(this.state,p,"update listener")}(c||d)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),d&&!sue(this,d)&&u.force&&jg(this.contentDOM,u.key,u.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new wV(this,t),this.plugins=t.facet(ag).map(i=>new rj(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new cV(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(ag),i=t.state.facet(ag);if(n!=i){let r=[];for(let s of i){let a=n.indexOf(s);if(a<0)r.push(new rj(s));else{let o=this.plugins[a];o.mustUpdate=t,r.push(o)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=t;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(Ice(i||this.win))s=-1,a=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,a=p.top}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];c&4||([this.measureRequests,u]=[u,this.measureRequests]);let d=u.map(p=>{try{return p.read(this)}catch(g){return Qa(this.state,g),_V}}),f=oT.create(this,this.state,[]),h=!1;f.flags|=c,n?n.flags|=c:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let p=0;p1||g<-1)&&!(Ot.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+g,i?i.scrollTop+=g:this.win.scrollBy(0,g),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let o of this.state.facet(nL))o(n)}get themeClasses(){return lL+" "+(this.state.facet(oL)?bue:gue)+" "+this.state.facet(eS)}updateAttrs(){let t=AV(this,Zce,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Cu)?"true":"false",class:"cm-content",style:`${Ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),AV(this,h4,n);let i=this.observer.ignore(()=>{let r=iV(this.contentDOM,this.contentAttrs,n),s=iV(this.dom,this.editorAttrs,t);return r||s});return this.editorAttrs=t,this.contentAttrs=n,i}showAnnouncements(t){let n=!0;for(let i of t)for(let r of i.effects)if(r.is(ft.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(LO);let t=this.state.facet(ft.cspNonce);Vf.mount(this.root,this.styleModules.concat(lKe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;ni.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,i){return lj(this,t,uV(this,t,n,i))}moveByGroup(t,n){return lj(this,t,uV(this,t,n,i=>wZe(this,t.head,i)))}visualLineSide(t,n){let i=this.bidiSpans(t),r=this.textDirectionAt(t.from),s=i[n?i.length-1:0];return Qe.cursor(s.side(n,r)+t.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(t,n,i=!0){return vZe(this,t,n,i)}moveVertically(t,n,i){return lj(this,t,SZe(this,t,n,i))}domAtPos(t,n=1){return this.docView.domAtPos(t,n)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){this.readMeasured();let i=sL(this,t,n);return i&&i.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),sL(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let i=this.state.doc.lineAt(t),r=this.bidiSpans(i),s=r[jc.find(r,t-i.from,-1,n)];return this.docView.coordsAt(t,n,s.dir==Pi.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Hce)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>hKe)return Qce(t.length);let n=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||$ce(s.isolates,i=aV(this,t))))return s.order;i||(i=aV(this,t));let r=YWe(t.text,n,i);return this.bidiCache.push(new fT(t.from,t.to,n,i,!0,r)),r}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Ot.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Rce(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){var i,r,s,a;return Yw.of(new Rg(typeof t=="number"?Qe.cursor(t):t,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(a=n.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Yw.of(new Rg(Qe.cursor(i.from),"start","start",i.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Tr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Tr.define(()=>({}),{eventObservers:t})}static theme(t,n){let i=Vf.newName(),r=[eS.of(i),LO.of(cL(`.${i}`,t))];return n&&n.dark&&r.push(oL.of(!0)),r}static baseTheme(t){return vd.lowest(LO.of(cL("."+lL,t,Oue)))}static findFromDOM(t){var n;let i=t.querySelector(".cm-content"),r=i&&Er.get(i)||Er.get(t);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}ft.styleModule=LO;ft.inputHandler=Xce;ft.clipboardInputFilter=d4;ft.clipboardOutputFilter=f4;ft.scrollHandler=Gce;ft.focusChangeEffect=qce;ft.perLineTextDirection=Hce;ft.exceptionSink=Vce;ft.updateListener=nL;ft.editable=Cu;ft.mouseSelectionStyle=Fce;ft.dragMovesSelection=zce;ft.clickAddsSelectionRange=Uce;ft.decorations=IA;ft.blockWrappers=Kce;ft.outerDecorations=p4;ft.atomicRanges=J1;ft.bidiIsolatedRanges=Jce;ft.cursorScrollMargin=yt.define({combine:e=>{let t=5,n=5;for(let i of e)typeof i=="number"?t=n=i:{x:t,y:n}=i;return{x:t,y:n}}});ft.scrollMargins=eue;ft.darkTheme=oL;ft.cspNonce=yt.define({combine:e=>e.length?e[0]:""});ft.contentAttributes=h4;ft.editorAttributes=Zce;ft.lineWrapping=ft.contentAttributes.of({class:"cm-lineWrapping"});ft.announce=rn.define();const hKe=4096,_V={};class fT{constructor(t,n,i,r,s,a){this.from=t,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=a}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let i=[],r=t.length?t[t.length-1].dir:Pi.LTR;for(let s=Math.max(0,t.length-10);s=0;r--){let s=i[r],a=typeof s=="function"?s(e):s;a&&l4(a,n)}return n}const pKe=Ot.mac?"mac":Ot.windows?"win":Ot.linux?"linux":"key";function mKe(e,t){const n=e.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,a,o;for(let c=0;ci.concat(r),[]))),n}function bKe(e,t,n){return xue(yue(e.state),t,e,n)}let ef=null;const OKe=4e3;function yKe(e,t=pKe){let n=Object.create(null),i=Object.create(null),r=(a,o)=>{let c=i[a];if(c==null)i[a]=o;else if(c!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,o,c,u,d)=>{var f,h;let p=n[a]||(n[a]=Object.create(null)),g=o.split(/ (?!$)/).map(O=>mKe(O,t));for(let O=1;O{let w=ef={view:x,prefix:v,scope:a};return setTimeout(()=>{ef==w&&(ef=null)},OKe),!0}]})}let b=g.join(" ");r(b,!1);let y=p[b]||(p[b]={preventDefault:!1,stopPropagation:!1,run:((h=(f=p._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});c&&y.run.push(c),u&&(y.preventDefault=!0),d&&(y.stopPropagation=!0)};for(let a of e){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let u of o){let d=n[u]||(n[u]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=a;for(let h in d)d[h].run.push(p=>f(p,uL))}let c=a[t]||a.key;if(c)for(let u of o)s(u,c,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(u,"Shift-"+c,a.shift,a.preventDefault,a.stopPropagation)}return n}let uL=null;function xue(e,t,n,i){uL=t;let r=IWe(t),s=Pa(r,0),a=Sc(s)==r.length&&r!=" ",o="",c=!1,u=!1,d=!1;ef&&ef.view==n&&ef.scope==i&&(o=ef.prefix+" ",lue.indexOf(t.keyCode)<0&&(u=!0,ef=null));let f=new Set,h=y=>{if(y){for(let O of y.run)if(!f.has(O)&&(f.add(O),O(n)))return y.stopPropagation&&(d=!0),!0;y.preventDefault&&(y.stopPropagation&&(d=!0),u=!0)}return!1},p=e[i],g,b;return p&&(h(p[o+tS(r,t,!a)])?c=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Ot.windows&&t.ctrlKey&&t.altKey)&&!(Ot.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(g=Xf[t.keyCode])&&g!=r?(h(p[o+tS(g,t,!0)])||t.shiftKey&&(b=Mx[t.keyCode])!=r&&b!=g&&h(p[o+tS(b,t,!1)]))&&(c=!0):a&&t.shiftKey&&h(p[o+tS(r,t,!0)])&&(c=!0),!c&&h(p._any)&&(c=!0)),u&&(c=!0),c&&d&&t.stopPropagation(),uL=null,c}class lp{constructor(t,n,i,r,s){this.className=t,this.left=n,this.top=i,this.width=r,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,i){if(i.empty){let r=t.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=vue(t);return[new lp(n,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return xKe(t,n,i)}}function vue(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Pi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function CV(e,t,n,i){let r=e.coordsAtPos(t,n*2);if(!r)return i;let s=e.dom.getBoundingClientRect(),a=(r.top+r.bottom)/2,o=e.posAtCoords({x:s.left+1,y:a}),c=e.posAtCoords({x:s.right-1,y:a});return o==null||c==null?i:{from:Math.max(i.from,Math.min(o,c)),to:Math.min(i.to,Math.max(o,c))}}function xKe(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),s=e.textDirection==Pi.LTR,a=e.contentDOM,o=a.getBoundingClientRect(),c=vue(e),u=a.querySelector(".cm-line"),d=u&&window.getComputedStyle(u),f=o.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),h=o.right-(d?parseInt(d.paddingRight):0),p=rL(e,i,1),g=rL(e,r,-1),b=p.type==Is.Text?p:null,y=g.type==Is.Text?g:null;if(b&&(e.lineWrapping||p.widgetLineBreaks)&&(b=CV(e,i,1,b)),y&&(e.lineWrapping||g.widgetLineBreaks)&&(y=CV(e,r,-1,y)),b&&y&&b.from==y.from&&b.to==y.to)return v(x(n.from,n.to,b));{let E=b?x(n.from,null,b):w(p,!1),S=y?x(null,n.to,y):w(g,!0),k=[];return(b||p).to<(y||g).from-(b&&y?1:0)||p.widgetLineBreaks>1&&E.bottom+e.defaultLineHeight/2M&&P.from=j)break;I>Q&&C(Math.max(B,Q),E==null&&B<=M,Math.min(I,j),S==null&&I>=L,U.dir)}if(Q=$.to+1,Q>=j)break}return N.length==0&&C(M,E==null,L,S==null,e.textDirection),{top:T,bottom:A,horizontal:N}}function w(E,S){let k=o.top+(S?E.top:E.bottom);return{top:k,bottom:k,horizontal:[]}}}function vKe(e,t){return e.constructor==t.constructor&&e.eq(t)}class wKe{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(mE)!=t.state.facet(mE)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,i=t.facet(mE);for(;n!vKe(n,this.drawn[i]))){let n=this.dom.firstChild,i=0;for(let r of t)r.update&&n&&r.constructor&&this.drawn[i].constructor&&r.update(n,this.drawn[i])?(n=n.nextSibling,i++):this.dom.insertBefore(r.draw(),n);for(;n;){let r=n.nextSibling;n.remove(),n=r}this.drawn=t,Ot.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const mE=yt.define();function wue(e){return[Tr.define(t=>new wKe(t,e)),mE.of(e)]}const w0=yt.define({combine(e){return Jc(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function SKe(e={}){return[w0.of(e),EKe,kKe,TKe,Yce.of(!0)]}function Sue(e){return e.startState.facet(w0)!=e.state.facet(w0)}const EKe=wue({above:!0,markers(e){let{state:t}=e,n=t.facet(w0),i=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||n.drawRangeCursor&&!(s&&Ot.ios&&n.iosSelectionHandles)){let a=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=r.empty?r:Qe.cursor(r.head,r.assoc);for(let c of lp.forRange(e,a,o))i.push(c)}}return i},update(e,t){e.transactions.some(i=>i.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Sue(e);return n&&jV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){jV(t.state,e)},class:"cm-cursorLayer"});function jV(e,t){t.style.animationDuration=e.facet(w0).cursorBlinkRate+"ms"}const kKe=wue({above:!1,markers(e){let t=[],{main:n,ranges:i}=e.state.selection;for(let r of i)if(!r.empty)for(let s of lp.forRange(e,"cm-selectionBackground",r))t.push(s);if(Ot.ios&&!n.empty&&e.state.facet(w0).iosSelectionHandles){for(let r of lp.forRange(e,"cm-selectionHandle cm-selectionHandle-start",Qe.cursor(n.from,1)))t.push(r);for(let r of lp.forRange(e,"cm-selectionHandle cm-selectionHandle-end",Qe.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Sue(e)},class:"cm-selectionLayer"}),TKe=vd.highest(ft.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Eue=rn.define({map(e,t){return e==null?null:t.mapPos(e)}}),$O=Ms.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,i)=>i.is(Eue)?i.value:n,e)}}),_Ke=Tr.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field($O);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field($O)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field($O),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field($O)!=e&&this.view.dispatch({effects:Eue.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function AKe(){return[$O,_Ke]}function RV(e,t,n,i,r){t.lastIndex=0;for(let s=e.iterRange(n,i),a=n,o;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)r(a+o.index,o)}function NKe(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class CKe{constructor(t){const{regexp:n,decoration:i,decorate:r,boundary:s,maxLength:a=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,r)this.addMatch=(o,c,u,d)=>r(d,u,u+o[0].length,o,c);else if(typeof i=="function")this.addMatch=(o,c,u,d)=>{let f=i(o,c,u);f&&d(u,u+o[0].length,f)};else if(i)this.addMatch=(o,c,u,d)=>d(u,u+o[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let n=new od,i=n.add.bind(n);for(let{from:r,to:s}of NKe(t,this.maxLength))RV(t.state.doc,this.regexp,r,s,(a,o)=>this.addMatch(o,t,a,i));return n.finish()}updateDeco(t,n){let i=1e9,r=-1;return t.docChanged&&t.changes.iterChanges((s,a,o,c)=>{c>=t.view.viewport.from&&o<=t.view.viewport.to&&(i=Math.min(o,i),r=Math.max(c,r))}),t.viewportMoved||r-i>1e3?this.createDeco(t.view):r>-1?this.updateRange(t.view,n.map(t.changes),i,r):n}updateRange(t,n,i,r){for(let s of t.visibleRanges){let a=Math.max(s.from,i),o=Math.min(s.to,r);if(o>=a){let c=t.state.doc.lineAt(a),u=c.toc.from;a--)if(this.boundary.test(c.text[a-1-c.from])){d=a;break}for(;oh.push(O.range(b,y));if(c==u)for(this.regexp.lastIndex=d-c.from;(p=this.regexp.exec(c.text))&&p.indexthis.addMatch(y,t,b,g));n=n.update({filterFrom:d,filterTo:f,filter:(b,y)=>bf,add:h})}}return n}}const dL=/x/.unicode!=null?"gu":"g",jKe=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,dL),RKe={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let dj=null;function IKe(){var e;if(dj==null&&typeof document<"u"&&document.body){let t=document.body.style;dj=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return dj||!1}const gE=yt.define({combine(e){let t=Jc(e,{render:null,specialChars:jKe,addSpecialChars:null});return(t.replaceTabs=!IKe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,dL)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,dL)),t}});function PKe(e={}){return[gE.of(e),MKe()]}let IV=null;function MKe(){return IV||(IV=Tr.fromClass(class{constructor(e){this.view=e,this.decorations=zt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(gE)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new CKe({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:r}=n.state,s=Pa(t[0],0);if(s==9){let a=r.lineAt(i),o=n.state.tabSize,c=Bl(a.text,o,i-a.from);return zt.replace({widget:new QKe((o-c%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=zt.replace({widget:new $Ke(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(gE);e.startState.facet(gE)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const LKe="•";function DKe(e){return e>=32?LKe:e==10?"␤":String.fromCharCode(9216+e)}class $Ke extends Yl{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=DKe(this.code),i=t.state.phrase("Control character")+" "+(RKe[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class QKe extends Yl{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function BKe(){return zKe}const UKe=zt.line({class:"cm-activeLine"}),zKe=Tr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let r=e.lineBlockAt(i.head);r.from>t&&(n.push(UKe.range(r.from)),t=r.from)}return zt.set(n)}},{decorations:e=>e.decorations});class FKe extends Yl{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?ky(t.firstChild):[];if(!n.length)return null;let i=window.getComputedStyle(t.parentNode),r=$x(n[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function VKe(e){let t=Tr.fromClass(class{constructor(n){this.view=n,this.placeholder=e?zt.set([zt.widget({widget:new FKe(e),side:1}).range(0)]):zt.none}get decorations(){return this.view.state.doc.length?zt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,ft.contentAttributes.of({"aria-placeholder":e})]:t}const fL=2e3;function XKe(e,t,n){let i=Math.min(t.line,n.line),r=Math.max(t.line,n.line),s=[];if(t.off>fL||n.off>fL||t.col<0||n.col<0){let a=Math.min(t.off,n.off),o=Math.max(t.off,n.off);for(let c=i;c<=r;c++){let u=e.doc.line(c);u.length<=o&&s.push(Qe.range(u.from+a,u.to+o))}}else{let a=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let c=i;c<=r;c++){let u=e.doc.line(c),d=XM(u.text,a,e.tabSize,!0);if(d<0)s.push(Qe.cursor(u.to));else{let f=XM(u.text,o,e.tabSize);s.push(Qe.range(u.from+d,u.from+f))}}}return s}function qKe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function PV(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),i=e.state.doc.lineAt(n),r=n-i.from,s=r>fL?-1:r==i.length?qKe(e,t.clientX):Bl(i.text,e.state.tabSize,n-i.from);return{line:i.number,col:s,off:r}}function HKe(e,t){let n=PV(e,t),i=e.state.selection;return n?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(n.line).from),a=r.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},i=i.map(r.changes)}},get(r,s,a){let o=PV(e,r);if(!o)return i;let c=XKe(e.state,n,o);return c.length?a?Qe.create(c.concat(i.ranges)):Qe.create(c):i}}:null}function YKe(e){let t=n=>n.altKey&&n.button==0;return ft.mouseSelectionStyle.of((n,i)=>t(i)?HKe(n,i):null)}const GKe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},WKe={style:"cursor: crosshair"};function ZKe(e={}){let[t,n]=GKe[e.key||"Alt"],i=Tr.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==t||n(r))},keyup(r){(r.keyCode==t||!n(r))&&this.set(!1)},mousemove(r){this.set(n(r))}}});return[i,ft.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?WKe:null})]}const nS="-10000px";class kue{constructor(t,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=t.state.facet(n),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=i(a,s))}update(t,n){var i;let r=t.state.facet(this.facet),s=r.filter(c=>c);if(r===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],o=n?[]:null;for(let c=0;cn[u]=c),n.length=o.length),this.input=r,this.tooltips=s,this.tooltipViews=a,!0}}function KKe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const fj=yt.define({combine:e=>{var t,n,i;return{position:Ot.ios?"absolute":((t=e.find(r=>r.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=e.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||KKe}}}),MV=new WeakMap,y4=Tr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(fj);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new kue(e,x4,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(fj);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=nS,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(e=i.destroy)===null||e===void 0||e.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ot.safari){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=m4(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(fj).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=e,a=[];for(let o=0;o=Math.min(n.bottom,i.bottom)||f.rightMath.min(n.right,i.right)+.1)){d.style.top=nS;continue}let p=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,b=h.right-h.left,y=(t=MV.get(u))!==null&&t!==void 0?t:h.bottom-h.top,O=u.offset||eJe,v=this.view.textDirection==Pi.LTR,x=h.width>i.right-i.left?v?i.left:i.right-h.width:v?Math.max(i.left,Math.min(f.left-(p?14:0)+O.x,i.right-b)):Math.min(Math.max(i.left,f.left-b+(p?14:0)-O.x),i.right-b),w=this.above[o];!c.strictSide&&(w?f.top-y-g-O.yi.bottom)&&w==i.bottom-f.bottom>f.top-i.top&&(w=this.above[o]=!w);let E=(w?f.top-i.top:i.bottom-f.bottom)-g;if(Ex&&T.topS&&(S=w?T.top-y-2-g:T.bottom+g+2);if(this.position=="absolute"?(d.style.top=(S-e.parent.top)/s+"px",LV(d,(x-e.parent.left)/r)):(d.style.top=S/s+"px",LV(d,x/r)),p){let T=f.left+(v?O.x:-O.x)-(x+14-7);p.style.left=T/r+"px"}u.overlap!==!0&&a.push({left:x,top:S,right:k,bottom:S+y}),d.classList.toggle("cm-tooltip-above",w),d.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=nS}},{eventObservers:{scroll(){this.maybeMeasure()}}});function LV(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const JKe=ft.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),eJe={x:0,y:0},x4=yt.define({enables:[y4,JKe]}),hT=yt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class DA{static create(t){return new DA(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new kue(t,hT,(n,i)=>this.createHostedView(n,i),n=>n.dom.remove())}createHostedView(t,n){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let i of this.manager.tooltipViews){let r=i[t];if(r!==void 0){if(n===void 0)n=r;else if(n!==r)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const tJe=x4.compute([hT],e=>{let t=e.facet(hT);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var i;return(i=n.end)!==null&&i!==void 0?i:n.pos})),create:DA.create,above:t[0].above,arrow:t.some(n=>n.arrow)}}),Tue=yt.define();class nJe{constructor(t,n,i,r,s,a){this.view=t,this.source=n,this.field=i,this.locked=r,this.setHover=s,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;ta.bottom||n.xa.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=o&&o.dir==Pi.RTL?-1:1;s=n.x{if(o&&!(Array.isArray(o)&&!o.length)){let c=Array.isArray(o)?o:[o];r&&this.locked.set(c,r),t.dispatch({effects:this.setHover.of(c)})}};if(s&&"then"in s){let o=this.pending={pos:n};s.then(c=>{this.pending==o&&(this.pending=null,a(c))},c=>Qa(t.state,c,"hover tooltip"))}else a(s)}get tooltip(){let t=this.view.plugin(y4),n=t?t.manager.tooltips.findIndex(i=>i.create==DA.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!iJe(s.dom,t)||this.pending){let{pos:a}=r[0]||this.pending,o=(i=(n=r[0])===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!rJe(this.view,a,o,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=i=>{t.removeEventListener("mouseleave",n);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const iS=4;function iJe(e,t){let{left:n,right:i,top:r,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();r=Math.min(o.top,r),s=Math.max(o.bottom,s)}return t.clientX>=n-iS&&t.clientX<=i+iS&&t.clientY>=r-iS&&t.clientY<=s+iS}function rJe(e,t,n,i,r,s){let a=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>i||a.rightr||Math.min(a.bottom,o)=t&&c<=n}function sJe(e,t={}){let n=rn.define(),i=new WeakMap,r=Ms.define({create(){return[]},update(a,o){let c=i.get(a);if(a.length&&(t.hideOnChange&&(o.docChanged||o.selection)?a=[]:c&&c(o)?a=[]:t.hideOn&&(a=a.filter(u=>!t.hideOn(o,u)))),o.docChanged&&a.length){let u=[];for(let d of a){let f=o.changes.mapPos(d.pos,-1,Cs.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),d);h.pos=f,h.end!=null&&(h.end=o.changes.mapPos(h.end)),u.push(h)}}a=u}for(let u of o.effects)u.is(n)&&(a=u.value,c=void 0),(u.is(oJe)&&!u.value||u.value==r)&&(a=[]);return a.length&&c&&i.set(a,c),a},provide:a=>hT.from(a)});const s=Tr.define(a=>new nJe(a,e,r,i,n,t.hoverTime||300));return{active:r,extension:[r,s,Tue.of(s),tJe]}}function aJe(e,t,n,i={}){var r;let s=e.state.facet(Tue).map(a=>e.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=s.find(o=>o.field==i.tooltip.active);a&&(s=[a])}for(let a of s)a.activateHover(e,t,n,(r=i.until)!==null&&r!==void 0?r:()=>!1)}function _ue(e,t){let n=e.plugin(y4);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const oJe=rn.define(),DV=yt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function v4(e,t){let n=e.plugin(Aue),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const Aue=Tr.fromClass(class{constructor(e){this.input=e.state.facet(Bx),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(DV);this.top=new rS(e,!0,t.topContainer),this.bottom=new rS(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(DV);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new rS(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new rS(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Bx);if(n!=this.input){let i=n.filter(c=>c),r=[],s=[],a=[],o=[];for(let c of i){let u=this.specs.indexOf(c),d;u<0?(d=c(e.view),o.push(d)):(d=this.panels[u],d.update&&d.update(e)),r.push(d),(d.top?s:a).push(d)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(a);for(let c of o)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let i of this.panels)i.update&&i.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ft.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class rS{constructor(t,n,i){this.view=t,this.top=n,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=$V(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=$V(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function $V(e){let t=e.nextSibling;return e.remove(),t}const Bx=yt.define({enables:Aue});function lJe(e,t){let n,i=new Promise(a=>n=a),r=a=>cJe(a,t,n);e.state.field(hj,!1)?e.dispatch({effects:Nue.of(r)}):e.dispatch({effects:rn.appendConfig.of(hj.init(()=>[r]))});let s=Cue.of(r);return{close:s,result:i.then(a=>((e.win.queueMicrotask||(c=>e.win.setTimeout(c,10)))(()=>{e.state.field(hj).indexOf(r)>-1&&e.dispatch({effects:s})}),a))}}const hj=Ms.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(Nue)?e=[n.value].concat(e):n.is(Cue)&&(e=e.filter(i=>i!=n.value));return e},provide:e=>Bx.computeN([e],t=>t.field(e))}),Nue=rn.define(),Cue=rn.define();function cJe(e,t,n){let i=t.content?t.content(e,()=>a(null)):null;if(!i){if(i=Ei("form"),t.input){let o=Ei("input",t.input);/^(text|password|number|email|tel|url)$/.test(o.type)&&o.classList.add("cm-textfield"),o.name||(o.name="input"),i.appendChild(Ei("label",(t.label||"")+": ",o))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Ei("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let o=0;o{u.keyCode==27?(u.preventDefault(),a(null)):u.keyCode==13&&(u.preventDefault(),a(c))}),c.addEventListener("submit",u=>{u.preventDefault(),a(c)})}let s=Ei("div",i,Ei("button",{onclick:()=>a(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(s.className=t.class),s.classList.add("cm-dialog");function a(o){s.contains(s.ownerDocument.activeElement)&&e.focus(),n(o)}return{dom:s,top:t.top,mount:()=>{if(t.focus){let o;typeof t.focus=="string"?o=i.querySelector(t.focus):o=i.querySelector("input")||i.querySelector("button"),o&&"select"in o?o.select():o&&"focus"in o&&o.focus()}}}}class cd extends Ff{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}cd.prototype.elementClass="";cd.prototype.toDOM=void 0;cd.prototype.mapMode=Cs.TrackBefore;cd.prototype.startSide=cd.prototype.endSide=-1;cd.prototype.point=!0;const bE=yt.define(),uJe=yt.define(),dJe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>jn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Ay=yt.define();function fJe(e){return[jue(),Ay.of({...dJe,...e})]}const QV=yt.define({combine:e=>e.some(t=>t)});function jue(e){return[hJe]}const hJe=Tr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Ay).map(t=>new UV(e,t)),this.fixed=!e.state.facet(QV);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(QV)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=jn.iter(this.view.state.facet(bE),this.view.viewport.from),i=[],r=this.gutters.map(s=>new pJe(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let a=!0;for(let o of s.type)if(o.type==Is.Text&&a){hL(n,i,o.from);for(let c of r)c.line(this.view,o,i);a=!1}else if(o.widget)for(let c of r)c.widget(this.view,o)}else if(s.type==Is.Text){hL(n,i,s.from);for(let a of r)a.line(this.view,s,i)}else if(s.widget)for(let a of r)a.widget(this.view,s);for(let s of r)s.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Ay),n=e.state.facet(Ay),i=e.docChanged||e.heightChanged||e.viewportChanged||!jn.eq(e.startState.facet(bE),e.state.facet(bE),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let r of this.gutters)r.update(e)&&(i=!0);else{i=!0;let r=[];for(let s of n){let a=t.indexOf(s);a<0?r.push(new UV(this.view,s)):(this.gutters[a].update(e),r.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ft.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,r=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Pi.LTR?{left:i,right:r}:{right:i,left:r}})});function BV(e){return Array.isArray(e)?e:[e]}function hL(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class pJe{constructor(t,n,i){this.gutter=t,this.height=i,this.i=0,this.cursor=jn.iter(t.markers,n.from)}addElement(t,n,i){let{gutter:r}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==r.elements.length){let o=new Rue(t,a,s,i);r.elements.push(o),r.dom.appendChild(o.dom)}else r.elements[this.i].update(t,a,s,i);this.height=n.bottom,this.i++}line(t,n,i){let r=[];hL(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(t,n,r);s&&r.unshift(s);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(t,n,r)}widget(t,n){let i=this.gutter.config.widgetMarker(t,n.widget,n),r=i?[i]:null;for(let s of t.state.facet(uJe)){let a=s(t,n.widget,n);a&&(r||(r=[])).push(a)}r&&this.addElement(t,n,r)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class UV{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=r.clientY;let o=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[i](t,o,r)&&r.preventDefault()});this.markers=BV(n.markers(t)),n.initialSpacer&&(this.spacer=new Rue(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=BV(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],t);r!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[r])}let i=t.view.viewport;return!jn.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Rue{constructor(t,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,i,r)}update(t,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),mJe(this.markers,r)||this.setMarkers(t,r)}setMarkers(t,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,a=0;;){let o=a,c=ss(o,c,u)||a(o,c,u):a}return i}})}});class pj extends cd{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function mj(e,t){return e.state.facet(og).formatNumber(t,e.state)}const OJe=Ay.compute([og],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(gJe)},lineMarker(t,n,i){return i.some(r=>r.toDOM)?null:new pj(mj(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,i)=>{for(let r of t.state.facet(bJe)){let s=r(t,n,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(og)!=t.state.facet(og),initialSpacer(t){return new pj(mj(t,zV(t.state.doc.lines)))},updateSpacer(t,n){let i=mj(n.view,zV(n.view.state.doc.lines));return i==t.number?t:new pj(i)},domEventHandlers:e.facet(og).domEventHandlers,side:"before"}));function yJe(e={}){return[og.of(e),jue(),OJe]}function zV(e){let t=9;for(;t{let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.head).from;r>n&&(n=r,t.push(xJe.range(r)))}return jn.of(t)});function wJe(){return vJe}var gj;const Xh=new sn;function w4(e){return yt.define({combine:e?t=>t.concat(e):void 0})}const S4=new sn;class Go{constructor(t,n,i=[],r=""){this.data=t,this.name=r,Bn.prototype.hasOwnProperty("tree")||Object.defineProperty(Bn.prototype,"tree",{get(){return _i(this)}}),this.parser=n,this.extension=[Hf.of(this),Bn.languageData.of((s,a,o)=>{let c=FV(s,a,o),u=c.type.prop(Xh);if(!u)return[];let d=s.facet(u),f=c.type.prop(S4);if(f){let h=c.resolve(a-c.from,o);for(let p of f)if(p.test(h,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(d)}}return d})].concat(i)}isActiveAt(t,n,i=-1){return FV(t,n,i).type.prop(Xh)==this.data}findRegions(t){let n=t.facet(Hf);if((n==null?void 0:n.data)==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,a)=>{if(s.prop(Xh)==this.data){i.push({from:a,to:a+s.length});return}let o=s.prop(sn.mounted);if(o){if(o.tree.prop(Xh)==this.data){if(o.overlay)for(let c of o.overlay)i.push({from:c.from+a,to:c.to+a});else i.push({from:a,to:a+s.length});return}else if(o.overlay){let c=i.length;if(r(o.tree,o.overlay[0].from+a),i.length>c)return}}for(let c=0;ci.isTop?n:void 0)]}),t.name)}configure(t,n){return new ud(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function _i(e){let t=e.field(Go.state,!1);return t?t.tree:li.empty}class SJe{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-i,n-i)}}let oO=null;class Ux{constructor(t,n,i=[],r,s,a,o,c){this.parser=t,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=a,this.skipped=o,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,n,i){return new Ux(t,n,[],li.empty,0,i,[],null)}startParse(){return this.parser.startParse(new SJe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=li.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let r=Date.now()+t;t=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Hu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=oO;oO=this;try{return t()}finally{oO=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=VV(t,n.from,n.to);return t}changes(t,n){let{fragments:i,tree:r,treeLen:s,viewport:a,skipped:o}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,d,f,h)=>c.push({fromA:u,toA:d,fromB:f,toB:h})),i=Hu.applyChanges(i,c),r=li.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){o=[];for(let u of this.skipped){let d=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);dt.from&&(this.fragments=VV(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends n4{createParse(n,i,r){let s=r[0].from,a=r[r.length-1].to;return{parsedPos:s,advance(){let c=oO;if(c){for(let u of r)c.tempSkipped.push(u);t&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,t]):t)}return this.parsedPos=a,new li(ss.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return oO}}function VV(e,t,n){return Hu.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class S0{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new S0(n)}static init(t){let n=Math.min(3e3,t.doc.length),i=Ux.create(t.facet(Hf).parser,t,{from:0,to:n});return i.work(20,n)||i.takeTree(),new S0(i)}}Go.state=Ms.define({create:S0.init,update(e,t){for(let n of t.effects)if(n.is(Go.setState))return n.value;return t.startState.facet(Hf)!=t.state.facet(Hf)?S0.init(t.state):e.apply(t)}});let Iue=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Iue=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const bj=typeof navigator<"u"&&(!((gj=navigator.scheduling)===null||gj===void 0)&&gj.isInputPending)?()=>navigator.scheduling.isInputPending():null,EJe=Tr.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(Go.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(Go.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Iue(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEndr+1e3,c=s.context.work(()=>bj&&bj()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Go.setState.of(new S0(s.context))})),this.chunkBudget>0&&!(c&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Qa(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Hf=yt.define({combine(e){return e.length?e[0]:null},enables:e=>[Go.state,EJe,ft.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Yf{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class pT{constructor(t,n,i,r,s,a=void 0){this.name=t,this.alias=n,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:i}=t;if(!n){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(i)}return new pT(t.name,(t.alias||[]).concat(t.name).map(r=>r.toLowerCase()),t.extensions||[],t.filename,n,i)}static matchFilename(t,n){for(let r of t)if(r.filename&&r.filename.test(n))return r;let i=/\.([^.]+)$/.exec(n);if(i){for(let r of t)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(t,n,i=!0){n=n.toLowerCase();for(let r of t)if(r.alias.some(s=>s==n))return r;if(i)for(let r of t)for(let s of r.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return r}return null}}const kJe=yt.define(),fb=yt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function mT(e){let t=e.facet(fb);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function zx(e,t){let n="",i=e.tabSize,r=e.facet(fb)[0];if(r==" "){for(;t>=i;)n+=" ",t-=i;r=" "}for(let s=0;s=t?TJe(e,n,t):null}class $A{constructor(t,n={}){this.state=t,this.options=n,this.unit=mT(t)}lineAt(t,n=1){let i=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==t?{text:"",from:t}:(n<0?r-1&&(s+=a-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,n=t.length){return Bl(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:i,from:r}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(r);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const rh=new sn;function TJe(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let a=r;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)i={node:s[a],next:i}}return Pue(i,e,n)}function Pue(e,t,n){for(let i=e;i;i=i.next){let r=AJe(i.node);if(r)return r(k4.create(t,n,i))}return 0}function _Je(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function AJe(e){let t=e.type.prop(rh);if(t)return t;let n=e.firstChild,i;if(n&&(i=n.type.prop(sn.closedBy))){let r=e.lastChild,s=r&&i.indexOf(r.name)>-1;return a=>Mue(a,!0,1,void 0,s&&!_Je(a)?r.from:void 0)}return e.parent==null?NJe:null}function NJe(){return 0}class k4 extends $A{constructor(t,n,i){super(t.state,t.options),this.base=t,this.pos=n,this.context=i}get node(){return this.context.node}static create(t,n,i){return new k4(t,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(CJe(i,t))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return Pue(this.context.next,this.base,this.pos)}}function CJe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function jJe(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let o=n.to;;){let c=t.childAfter(o);if(!c||c==i)return null;if(!c.type.isSkipped){if(c.from>=a)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}o=c.to}}function Ig({closing:e,align:t=!0,units:n=1}){return i=>Mue(i,t,n,e)}function Mue(e,t,n,i,r){let s=e.textAfter,a=s.match(/^\s*/)[0].length,o=i&&s.slice(a,a+i.length)==i||r==e.pos+a,c=t?jJe(e):null;return c?o?e.column(c.from):e.column(c.to):e.baseIndent+(o?0:e.unit*n)}const RJe=e=>e.baseIndent;function Pg({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}const IJe=200;function PJe(){return Bn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+IJe)return e;let s=n.sliceString(r.from,i);if(!t.some(u=>u.test(s)))return e;let{state:a}=e,o=-1,c=[];for(let{head:u}of a.selection.ranges){let d=a.doc.lineAt(u);if(d.from==o)continue;o=d.from;let f=E4(a,d.from);if(f==null)continue;let h=/^\s*/.exec(d.text)[0],p=zx(a,f);h!=p&&c.push({from:d.from,to:d.from+h.length,insert:p})}return c.length?[e,{changes:c,sequential:!0}]:e})}const Lue=yt.define(),wd=new sn;function ev(e){let t=e.firstChild,n=e.lastChild;return t&&t.ton)continue;if(s&&o.from=t&&u.to>n&&(s=u)}}return s}function LJe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function gT(e,t,n){for(let i of e.facet(Lue)){let r=i(e,t,n);if(r)return r}return MJe(e,t,n)}function Due(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const QA=rn.define({map:Due}),tv=rn.define({map:Due});function $ue(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(i=>i.from<=n&&i.to>=n)||t.push(e.lineBlockAt(n));return t}const Ap=Ms.define({create(){return zt.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((i,r)=>e=XV(e,i,r)),e=e.map(t.changes);let n=[];for(let i of t.effects)i.is(QA)&&!DJe(e,i.value.from,i.value.to)?n.push(i.value):i.is(tv)&&(e=e.update({filter:(r,s)=>i.value.from!=r||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(n.length){let{preparePlaceholder:i}=t.state.facet(Uue),r=n.map(s=>(i?zt.replace({widget:new VJe(i(t.state,s))}):qV).range(s.from,s.to));e=e.update({add:r})}return t.selection&&(e=XV(e,t.selection.main.head)),e},provide:e=>ft.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(i,r)=>{n.push(i,r)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n{rt&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(r,s)=>r>=n||s<=t}):e}function bT(e,t,n){var i;let r=null;return(i=e.field(Ap,!1))===null||i===void 0||i.between(t,n,(s,a)=>{(!r||r.from>s)&&(r={from:s,to:a})}),r}function DJe(e,t,n){let i=!1;return e.between(t,t,(r,s)=>{r==t&&s==n&&(i=!0)}),i}function Que(e,t){return e.field(Ap,!1)?t:t.concat(rn.appendConfig.of(zue()))}const $Je=e=>{for(let t of $ue(e)){let n=gT(e.state,t.from,t.to);if(n)return e.dispatch({effects:Que(e.state,[QA.of(n),Bue(e,n)])}),!0}return!1},QJe=e=>{if(!e.state.field(Ap,!1))return!1;let t=[];for(let n of $ue(e)){let i=bT(e.state,n.from,n.to);i&&t.push(tv.of(i),Bue(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Bue(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return ft.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const BJe=e=>{let{state:t}=e,n=[];for(let i=0;i{let t=e.state.field(Ap,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(i,r)=>{n.push(tv.of({from:i,to:r}))}),e.dispatch({effects:n}),!0},zJe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:$Je},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:QJe},{key:"Ctrl-Alt-[",run:BJe},{key:"Ctrl-Alt-]",run:UJe}],FJe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Uue=yt.define({combine(e){return Jc(e,FJe)}});function zue(e){return[Ap,HJe]}function Fue(e,t){let{state:n}=e,i=n.facet(Uue),r=a=>{let o=e.lineBlockAt(e.posAtDOM(a.target)),c=bT(e.state,o.from,o.to);c&&e.dispatch({effects:tv.of(c)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const qV=zt.replace({widget:new class extends Yl{toDOM(e){return Fue(e,null)}}});class VJe extends Yl{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Fue(t,this.value)}}const XJe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Oj extends cd{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function qJe(e={}){let t={...XJe,...e},n=new Oj(t,!0),i=new Oj(t,!1),r=Tr.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(Hf)!=a.state.facet(Hf)||a.startState.field(Ap,!1)!=a.state.field(Ap,!1)||_i(a.startState)!=_i(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new od;for(let c of a.viewportLineBlocks){let u=bT(a.state,c.from,c.to)?i:gT(a.state,c.from,c.to)?n:null;u&&o.add(c.from,c.from,u)}return o.finish()}}),{domEventHandlers:s}=t;return[r,fJe({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(r))===null||o===void 0?void 0:o.markers)||jn.empty},initialSpacer(){return new Oj(t,!1)},domEventHandlers:{...s,click:(a,o,c)=>{if(s.click&&s.click(a,o,c))return!0;let u=bT(a.state,o.from,o.to);if(u)return a.dispatch({effects:tv.of(u)}),!0;let d=gT(a.state,o.from,o.to);return d?(a.dispatch({effects:QA.of(d)}),!0):!1}}}),zue()]}const HJe=ft.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class nv{constructor(t,n){this.specs=t;let i;function r(o){let c=Vf.newName();return(i||(i=Object.create(null)))["."+c]=o,c}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,a=n.scope;this.scope=a instanceof Go?o=>o.prop(Xh)==a.data:a?o=>o==a:void 0,this.style=ace(t.map(o=>({tag:o.tag,class:o.class||r(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=i?new Vf(i):null,this.themeType=n.themeType}static define(t,n){return new nv(t,n||{})}}const pL=yt.define(),Vue=yt.define({combine(e){return e.length?[e[0]]:null}});function yj(e){let t=e.facet(pL);return t.length?t:e.facet(Vue)}function Xue(e,t){let n=[GJe],i;return e instanceof nv&&(e.module&&n.push(ft.styleModule.of(e.module)),i=e.themeType),t!=null&&t.fallback?n.push(Vue.of(e)):i?n.push(pL.computeN([ft.darkTheme],r=>r.facet(ft.darkTheme)==(i=="dark")?[e]:[])):n.push(pL.of(e)),n}class YJe{constructor(t){this.markCache=Object.create(null),this.tree=_i(t.state),this.decorations=this.buildDeco(t,yj(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=_i(t.state),i=yj(t.state),r=i!=yj(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return zt.none;let i=new od;for(let{from:r,to:s}of t.visibleRanges)jGe(this.tree,n,(a,o,c)=>{i.add(a,o,this.markCache[c]||(this.markCache[c]=zt.mark({class:c})))},r,s);return i.finish()}}const GJe=vd.high(Tr.fromClass(YJe,{decorations:e=>e.decorations})),WJe=nv.define([{tag:G.meta,color:"#404740"},{tag:G.link,textDecoration:"underline"},{tag:G.heading,textDecoration:"underline",fontWeight:"bold"},{tag:G.emphasis,fontStyle:"italic"},{tag:G.strong,fontWeight:"bold"},{tag:G.strikethrough,textDecoration:"line-through"},{tag:G.keyword,color:"#708"},{tag:[G.atom,G.bool,G.url,G.contentSeparator,G.labelName],color:"#219"},{tag:[G.literal,G.inserted],color:"#164"},{tag:[G.string,G.deleted],color:"#a11"},{tag:[G.regexp,G.escape,G.special(G.string)],color:"#e40"},{tag:G.definition(G.variableName),color:"#00f"},{tag:G.local(G.variableName),color:"#30a"},{tag:[G.typeName,G.namespace],color:"#085"},{tag:G.className,color:"#167"},{tag:[G.special(G.variableName),G.macroName],color:"#256"},{tag:G.definition(G.propertyName),color:"#00c"},{tag:G.comment,color:"#940"},{tag:G.invalid,color:"#f00"}]),ZJe=ft.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),que=1e4,Hue="()[]{}",Yue=yt.define({combine(e){return Jc(e,{afterCursor:!0,brackets:Hue,maxScanDistance:que,renderMatch:eet})}}),KJe=zt.mark({class:"cm-matchingBracket"}),JJe=zt.mark({class:"cm-nonmatchingBracket"});function eet(e){let t=[],n=e.matched?KJe:JJe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function HV(e){let t=[],n=e.facet(Yue);for(let i of e.selection.ranges){if(!i.empty)continue;let r=Rc(e,i.head,-1,n)||i.head>0&&Rc(e,i.head-1,1,n)||n.afterCursor&&(Rc(e,i.head,1,n)||i.heade.decorations}),net=[tet,ZJe];function iet(e={}){return[Yue.of(e),net]}const Gue=new sn;function mL(e,t,n){let i=e.prop(t<0?sn.openedBy:sn.closedBy);if(i)return i;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function gL(e){let t=e.type.prop(Gue);return t?t(e.node):e}function Rc(e,t,n,i={}){let r=i.maxScanDistance||que,s=i.brackets||Hue,a=_i(e),o=a.resolveInner(t,n);for(let c=o;c;c=c.parent){let u=mL(c.type,n,s);if(u&&c.from0?t>=d.from&&td.from&&t<=d.to))return ret(e,t,n,c,d,u,s)}}return set(e,t,n,a,o.type,r,s)}function ret(e,t,n,i,r,s,a){let o=i.parent,c={from:r.from,to:r.to},u=0,d=o==null?void 0:o.cursor();if(d&&(n<0?d.childBefore(i.from):d.childAfter(i.to)))do if(n<0?d.to<=i.from:d.from>=i.to){if(u==0&&s.indexOf(d.type.name)>-1&&d.from0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let h=0;!d.next().done&&h<=s;){let p=d.value;n<0&&(h+=p.length);let g=t+h*n;for(let b=n>0?0:p.length-1,y=n>0?p.length:-1;b!=y;b+=n){let O=a.indexOf(p[b]);if(!(O<0||i.resolveInner(g+b,1).type!=r))if(O%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:g+b,to:g+b+1},matched:O>>1==c>>1};f--}}n>0&&(h+=p.length)}return d.done?{start:u,matched:!1}:null}const aet=Object.create(null),YV=[ss.none],GV=[],WV=Object.create(null),oet=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])oet[e]=cet(aet,t);function xj(e,t){GV.indexOf(e)>-1||(GV.push(e),console.warn(t))}function cet(e,t){let n=[];for(let o of t.split(" ")){let c=[];for(let u of o.split(".")){let d=e[u]||G[u];d?typeof d=="function"?c.length?c=c.map(d):xj(u,`Modifier ${u} used at start of tag`):c.length?xj(u,`Tag ${u} used as modifier`):c=Array.isArray(d)?d:[d]:xj(u,`Unknown highlighting tag ${u}`)}for(let u of c)n.push(u)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map(o=>o.id),s=WV[r];if(s)return s.id;let a=WV[r]=ss.define({id:YV.length,name:i,props:[xd({[i]:n})]});return YV.push(a),a.id}Pi.RTL,Pi.LTR;class T4{constructor(t,n,i,r){this.state=t,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=_i(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Zue(t,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,i){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function ZV(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function uet(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[n,i]=t.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:uet(t);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:t,validFor:n}:null}}function Wue(e,t){return n=>{for(let i=_i(n.state).resolveInner(n.pos,-1);i;i=i.parent){if(e.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return t(n)}}class KV{constructor(t,n,i,r){this.completion=t,this.source=n,this.match=i,this.score=r}}function cp(e){return e.selection.main.from}function Zue(e,t){var n;let{source:i}=e,r=t&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?e:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const A4=Kc.define();function det(e,t,n,i){let{main:r}=e.selection,s=n-r.from,a=i-r.from;return{...e.changeByRange(o=>{if(o!=r&&n!=i&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,i))return{range:o};let c=e.toText(t);return{changes:{from:o.from+s,to:i==r.from?o.to:o.from+a,insert:c},range:Qe.cursor(o.from+s+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const JV=new WeakMap;function fet(e){if(!Array.isArray(e))return e;let t=JV.get(e);return t||JV.set(e,t=_4(e)),t}const OT=rn.define(),Fx=rn.define();class het{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n=48&&E<=57||E>=97&&E<=122?2:E>=65&&E<=90?1:0:(S=i4(E))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!v||k==1&&y||w==0&&k!=0)&&(n[f]==E||i[f]==E&&(h=!0)?a[f++]=v:a.length&&(O=!1)),w=k,v+=Sc(E)}return f==c&&a[0]==0&&O?this.result(-100+(h?-200:0),a,t):p==c&&g==0?this.ret(-200-t.length+(b==t.length?0:-100),[0,b]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):p==c?this.ret(-900-t.length,[g,b]):f==c?this.result(-100+(h?-200:0)+-700+(O?0:-1100),a,t):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,t)}result(t,n,i){let r=[],s=0;for(let a of n){let o=a+(this.astral?Sc(Pa(i,a)):1);s&&r[s-1]==a?r[s-1]=o:(r[s++]=a,r[s++]=o)}return this.ret(t-i.length,r)}}class pet{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:met,filterStrict:!1,compareCompletions:(t,n)=>(t.sortText||t.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>i=>eX(t(i),n(i)),optionClass:(t,n)=>i=>eX(t(i),n(i)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function eX(e,t){return e?t?e+" "+t:e:t}function met(e,t,n,i,r,s){let a=e.textDirection==Pi.RTL,o=a,c=!1,u="top",d,f,h=t.left-r.left,p=r.right-t.right,g=i.right-i.left,b=i.bottom-i.top;if(o&&h=b||v>t.top?d=n.bottom-t.top:(u="bottom",d=t.bottom-n.top)}let y=(t.bottom-t.top)/s.offsetHeight,O=(t.right-t.left)/s.offsetWidth;return{style:`${u}: ${d/y}px; max-width: ${f/O}px`,class:"cm-completionInfo-"+(c?a?"left-narrow":"right-narrow":o?"left":"right")}}const N4=rn.define();function get(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(n,i,r,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,c=0;for(let u=0;uc&&a.appendChild(document.createTextNode(o.slice(c,d)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(d,f))),h.className="cm-completionMatchedText",c=f}return cn.position-i.position).map(n=>n.render)}function vj(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let r=Math.floor(t/n);return{from:r*n,to:(r+1)*n}}let i=Math.ceil((e-t)/n);return{from:e-i*n,to:e-(i-1)*n}}class bet{constructor(t,n,i){this.view=t,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let r=t.state.field(n),{options:s,selected:a}=r.open,o=t.state.facet(gs);this.optionContent=get(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=vj(s.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",c=>{let{options:u}=t.state.field(n).open;for(let d=c.target,f;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(f=/-(\d+)$/.exec(d.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(t.dispatch({effects:N4.of(d)}),c.preventDefault())}}),this.dom.addEventListener("focusout",c=>{let u=t.state.field(this.stateField,!1);u&&u.tooltip&&t.state.facet(gs).closeOnBlur&&c.relatedTarget!=t.contentDOM&&t.dispatch({effects:Fx.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let i=t.state.field(this.stateField),r=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=r){let{options:s,selected:a,disabled:o}=i.open;(!r.open||r.open.options!=s)&&(this.range=vj(s.length,a,t.state.facet(gs).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),o!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;(n.selected>-1&&n.selected=this.range.to)&&(this.range=vj(n.options.length,n.selected,this.view.state.facet(gs).maxRenderedOptions),this.showOptions(n.options,t.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let a=typeof s=="string"?document.createTextNode(s):s(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Qa(this.view.state,o,"completion info")):(this.addInfoPane(a,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)i.appendChild(t),this.infoDestroy=null;else{let{dom:r,destroy:s}=t;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&yet(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=t.getBoundingClientRect(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom{a.target==r&&a.preventDefault()});let s=null;for(let a=i.from;ai.from||i.from==0))if(s=h,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let p=r.appendChild(document.createElement("completion-section"));p.textContent=h}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+a,d.setAttribute("role","option");let f=this.optionClass(o);f&&(d.className=f);for(let h of this.optionContent){let p=h(o,this.view.state,this.view,c);p&&d.appendChild(p)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew bet(n,e,t)}function yet(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),r=n.height/e.offsetHeight;i.topn.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/r)}function tX(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function xet(e,t){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:f}=d.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(p=>p.name==h)||i.push(typeof f=="string"?{name:h}:f)}},a=t.facet(gs);for(let d of e)if(d.hasResult()){let f=d.result.getMatch;if(d.result.filter===!1)for(let h of d.result.options)s(new KV(h,d.source,f?f(h):[],1e9-n.length));else{let h=t.sliceDoc(d.from,d.to),p,g=a.filterStrict?new pet(h):new het(h);for(let b of d.result.options)if(p=g.match(b.label)){let y=b.displayLabel?f?f(b,p.matched):[]:p.matched,O=p.score+(b.boost||0);if(s(new KV(b,d.source,y,O)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:v}=b.section;r||(r=Object.create(null)),r[v]=Math.max(O,r[v]||-1e9)}}}}if(i){let d=Object.create(null),f=0,h=(p,g)=>(p.rank==="dynamic"&&g.rank==="dynamic"?r[g.name]-r[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(p.nameh.score-f.score||u(f.completion,h.completion))){let f=d.completion;!c||c.label!=f.label||c.detail!=f.detail||c.type!=null&&f.type!=null&&c.type!=f.type||c.apply!=f.apply||c.boost!=f.boost?o.push(d):tX(d.completion)>tX(c)&&(o[o.length-1]=d),c=d.completion}return o}class lg{constructor(t,n,i,r,s,a){this.options=t,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new lg(this.options,nX(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,i,r,s,a){if(r&&!a&&t.some(u=>u.isPending))return r.setDisabled();let o=xet(t,n);if(!o.length)return r&&t.some(u=>u.isPending)?r.setDisabled():null;let c=n.facet(gs).selectOnOpen?0:-1;if(r&&r.selected!=c&&r.selected!=-1){let u=r.options[r.selected].completion;for(let d=0;dd.hasResult()?Math.min(u,d.from):u,1e8),create:_et,above:s.aboveCursor},r?r.timestamp:Date.now(),c,!1)}map(t){return new lg(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new lg(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class yT{constructor(t,n,i){this.active=t,this.id=n,this.open=i}static start(){return new yT(ket,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,i=n.facet(gs),s=(i.override||n.languageDataAt("autocomplete",cp(n)).map(fet)).map(c=>(this.active.find(d=>d.source==c)||new Wo(c,this.active.some(d=>d.state!=0)?1:0)).update(t,i));s.length==this.active.length&&s.every((c,u)=>c==this.active[u])&&(s=this.active);let a=this.open,o=t.effects.some(c=>c.is(C4));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(c=>c.hasResult()&&t.changes.touchesRange(c.from,c.to))||!vet(s,this.active)||o?a=lg.build(s,n,this.id,a,i,o):a&&a.disabled&&!s.some(c=>c.isPending)&&(a=null),!a&&s.every(c=>!c.isPending)&&s.some(c=>c.hasResult())&&(s=s.map(c=>c.hasResult()?new Wo(c.source,0):c));for(let c of t.effects)c.is(N4)&&(a=a&&a.setSelected(c.value,this.id));return s==this.active&&a==this.open?this:new yT(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?wet:Eet}}function vet(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n-1&&(n["aria-activedescendant"]=e+"-"+t),n}const ket=[];function Kue(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(A4);if(i&&t.activateOnCompletion(i))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Wo{constructor(t,n,i=!1){this.source=t,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let i=Kue(t,n),r=this;(i&8||i&16&&this.touches(t))&&(r=new Wo(r.source,0)),i&4&&r.state==0&&(r=new Wo(this.source,1)),r=r.updateFor(t,i);for(let s of t.effects)if(s.is(OT))r=new Wo(r.source,1,s.value);else if(s.is(Fx))r=new Wo(r.source,0);else if(s.is(C4))for(let a of s.value)a.source==r.source&&(r=a);return r}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(cp(t.state))}}class Mg extends Wo{constructor(t,n,i,r,s,a){super(t,3,n),this.limit=i,this.result=r,this.from=s,this.to=a}hasResult(){return!0}updateFor(t,n){var i;if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=cp(t.state);if(o>a||!r||n&2&&(cp(t.startState)==this.from||on.map(t))}}),Ma=Ms.define({create(){return yT.start()},update(e,t){return e.update(t)},provide:e=>[x4.from(e,t=>t.tooltip),ft.contentAttributes.from(e,t=>t.attrs)]});function j4(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(Ma).active.find(r=>r.source==t.source);return i instanceof Mg?(typeof n=="string"?e.dispatch({...det(e.state,n,i.from,i.to),annotations:A4.of(t.completion)}):n(e,t.completion,i.from,i.to),!0):!1}const _et=Oet(Ma,j4);function sS(e,t="option"){return n=>{let i=n.state.field(Ma,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:N4.of(o)}),!0}}const Aet=e=>{let t=e.state.field(Ma,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.state.field(Ma,!1)?(e.dispatch({effects:OT.of(!0)}),!0):!1,Net=e=>{let t=e.state.field(Ma,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Fx.of(null)}),!0)};class Cet{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const jet=50,Ret=1e3,Iet=Tr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ma).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ma),n=e.state.facet(gs);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ma)==t)return;let i=e.transactions.some(s=>{let a=Kue(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;sjet&&Date.now()-a.time>Ret){for(let o of a.context.abortListeners)try{o()}catch(c){Qa(this.view.state,c)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(OT)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ma);for(let n of t.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(gs).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=cp(t),i=new T4(t,n,e.explicit,this.view),r=new Cet(e,i);this.running.push(r),Promise.resolve(e.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Fx.of(null)}),Qa(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(gs).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(gs),i=this.view.state.field(Ma);for(let r=0;ro.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new Wo(s.active.source,0);for(let c of s.updates)o=o.update(c,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:C4.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ma,!1);if(t&&t.tooltip&&this.view.state.facet(gs).closeOnBlur){let n=t.open&&_ue(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fx.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:OT.of(!1)}),20),this.composing=0}}}),Pet=typeof navigator=="object"&&/Win/.test(navigator.platform),Met=vd.highest(ft.domEventHandlers({keydown(e,t){let n=t.state.field(Ma,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Pet&&e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(a=>a.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&j4(t,i),!1}})),Jue=ft.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Let{constructor(t,n,i,r){this.field=t,this.line=n,this.from=i,this.to=r}}class R4{constructor(t,n,i){this.field=t,this.from=n,this.to=i}map(t){let n=t.mapPos(this.from,-1,Cs.TrackDel),i=t.mapPos(this.to,1,Cs.TrackDel);return n==null||i==null?null:new R4(this.field,n,i)}}class I4{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let i=[],r=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let c of this.lines){if(i.length){let u=a,d=/^\t*/.exec(c)[0].length;for(let f=0;fnew R4(c.field,r[c.line]+c.from,r[c.line]+c.to));return{text:i,ranges:o}}static parse(t){let n=[],i=[],r=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,c=s[2]||s[3]||"",u=-1;o===0&&(o=1e9);let d=c.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=u&&h.field++}for(let f of r)if(f.line==i.length&&f.from>s.index){let h=s[2]?3+(s[1]||"").length:2;f.from-=h,f.to-=h}r.push(new Let(u,i.length,s.index,s.index+d.length)),a=a.slice(0,s.index)+c+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,c,u)=>{for(let d of r)d.line==i.length&&d.from>u&&(d.from--,d.to--);return c}),i.push(a)}return new I4(i,r)}}let Det=zt.widget({widget:new class extends Yl{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),$et=zt.mark({class:"cm-snippetField"});class hb{constructor(t,n){this.ranges=t,this.active=n,this.deco=zt.set(t.map(i=>(i.from==i.to?Det:$et).range(i.from,i.to)),!0)}map(t){let n=[];for(let i of this.ranges){let r=i.map(t);if(!r)return null;n.push(r)}return new hb(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(i=>i.field==this.active&&i.from<=n.from&&i.to>=n.to))}}const iv=rn.define({map(e,t){return e&&e.map(t)}}),Qet=rn.define(),Vx=Ms.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(iv))return n.value;if(n.is(Qet)&&e)return new hb(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ft.decorations.from(e,t=>t?t.deco:zt.none)});function P4(e,t){return Qe.create(e.filter(n=>n.field==t).map(n=>Qe.range(n.from,n.to)))}function Bet(e){let t=I4.parse(e);return(n,i,r,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,r),{main:c}=n.state.selection,u={changes:{from:r,to:s==c.from?c.to:s,insert:ei.of(a)},scrollIntoView:!0,annotations:i?[A4.of(i),Xr.userEvent.of("input.complete")]:void 0};if(o.length&&(u.selection=P4(o,0)),o.some(d=>d.field>0)){let d=new hb(o,0),f=u.effects=[iv.of(d)];n.state.field(Vx,!1)===void 0&&f.push(rn.appendConfig.of([Vx,Xet,qet,Jue]))}n.dispatch(n.state.update(u))}}function ede(e){return({state:t,dispatch:n})=>{let i=t.field(Vx,!1);if(!i||e<0&&i.active==0)return!1;let r=i.active+e,s=e>0&&!i.ranges.some(a=>a.field==r+e);return n(t.update({selection:P4(i.ranges,r),effects:iv.of(s?null:new hb(i.ranges,r)),scrollIntoView:!0})),!0}}const Uet=({state:e,dispatch:t})=>e.field(Vx,!1)?(t(e.update({effects:iv.of(null)})),!0):!1,zet=ede(1),Fet=ede(-1),Vet=[{key:"Tab",run:zet,shift:Fet},{key:"Escape",run:Uet}],iX=yt.define({combine(e){return e.length?e[0]:Vet}}),Xet=vd.highest(db.compute([iX],e=>e.facet(iX)));function hr(e,t){return{...t,apply:Bet(e)}}const qet=ft.domEventHandlers({mousedown(e,t){let n=t.state.field(Vx,!1),i;if(!n||(i=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let r=n.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==n.active?!1:(t.dispatch({selection:P4(n.ranges,r.field),effects:iv.of(n.ranges.some(s=>s.field>r.field)?new hb(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Xx={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},qh=rn.define({map(e,t){let n=t.mapPos(e,-1,Cs.TrackAfter);return n??void 0}}),M4=new class extends Ff{};M4.startSide=1;M4.endSide=-1;const tde=Ms.define({create(){return jn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of t.effects)n.is(qh)&&(e=e.update({add:[M4.range(n.value,n.value+1)]}));return e}});function Het(){return[Get,tde]}const Sj="()[]{}<>«»»«[]{}";function nde(e){for(let t=0;t{if((Yet?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||i.length==2&&Sc(Pa(i,0))==1||t!=r.from||n!=r.to)return!1;let s=Ket(e.state,i);return s?(e.dispatch(s),!0):!1}),Wet=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=ide(e,e.selection.main.head).brackets||Xx.brackets,r=null,s=e.changeByRange(a=>{if(a.empty){let o=Jet(e.doc,a.head);for(let c of i)if(c==o&&BA(e.doc,a.head)==nde(Pa(c,0)))return{changes:{from:a.head-c.length,to:a.head+c.length},range:Qe.cursor(a.head-c.length)}}return{range:r=a}});return r||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},Zet=[{key:"Backspace",run:Wet}];function Ket(e,t){let n=ide(e,e.selection.main.head),i=n.brackets||Xx.brackets;for(let r of i){let s=nde(Pa(r,0));if(t==r)return s==r?ntt(e,r,i.indexOf(r+r+r)>-1,n):ett(e,r,s,n.before||Xx.before);if(t==s&&rde(e,e.selection.main.from))return ttt(e,r,s)}return null}function rde(e,t){let n=!1;return e.field(tde).between(0,e.doc.length,i=>{i==t&&(n=!0)}),n}function BA(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Sc(Pa(n,0)))}function Jet(e,t){let n=e.sliceString(t-2,t);return Sc(Pa(n,0))==n.length?n:n.slice(1)}function ett(e,t,n,i){let r=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:qh.of(a.to+t.length),range:Qe.range(a.anchor+t.length,a.head+t.length)};let o=BA(e.doc,a.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:qh.of(a.head+t.length),range:Qe.cursor(a.head+t.length)}:{range:r=a}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ttt(e,t,n){let i=null,r=e.changeByRange(s=>s.empty&&BA(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:Qe.cursor(s.head+n.length)}:i={range:s});return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ntt(e,t,n,i){let r=i.stringPrefixes||Xx.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:qh.of(o.to+t.length),range:Qe.range(o.anchor+t.length,o.head+t.length)};let c=o.head,u=BA(e.doc,c),d;if(u==t){if(rX(e,c))return{changes:{insert:t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)};if(rde(e,c)){let h=n&&e.sliceDoc(c,c+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:c,to:c+h.length,insert:h},range:Qe.cursor(c+h.length)}}}else{if(n&&e.sliceDoc(c-2*t.length,c)==t+t&&(d=sX(e,c-2*t.length,r))>-1&&rX(e,d))return{changes:{insert:t+t+t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)};if(e.charCategorizer(c)(u)!=lr.Word&&sX(e,c,r)>-1&&!itt(e,c,t,r))return{changes:{insert:t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function rX(e,t){let n=_i(e).resolveInner(t+1);return n.parent&&n.from==t}function itt(e,t,n,i){let r=_i(e).resolveInner(t,-1),s=i.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),c=o.indexOf(n);if(!c||c>-1&&i.indexOf(o.slice(0,c))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+c;){if(e.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let u=r.to==t&&r.parent;if(!u)break;r=u}return!1}function sX(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=lr.Word)return t;for(let r of n){let s=t-r.length;if(e.sliceDoc(s,t)==r&&i(e.sliceDoc(s-1,s))!=lr.Word)return s}return-1}function rtt(e={}){return[Met,Ma,gs.of(e),Iet,stt,Jue]}const sde=[{key:"Ctrl-Space",run:wj},{mac:"Alt-`",run:wj},{mac:"Alt-i",run:wj},{key:"Escape",run:Net},{key:"ArrowDown",run:sS(!0)},{key:"ArrowUp",run:sS(!1)},{key:"PageDown",run:sS(!0,"page")},{key:"PageUp",run:sS(!1,"page")},{key:"Enter",run:Aet}],stt=vd.highest(db.computeN([gs],e=>e.facet(gs).defaultKeymap?[sde]:[])),ade=[hr("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),hr("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),hr("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),hr("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),hr("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),hr(`try { +`){[t,n]=O0(this,t,n);let r="";for(let s=0,a=0;st&&s&&(r+=i),ta&&(r+=o.sliceString(t-a,n-a,i)),a=c+1}return r}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof wc))return 0;let i=0,[r,s,a,o]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==a||s==o)return i;let c=this.children[r],u=t.children[s];if(c!=u)return i+c.scanIdentical(u,n);i+=c.length+1}}static from(t,n=t.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of t)i+=p.lines;if(i<32){let p=[];for(let g of t)g.flatten(p);return new Nr(p,n)}let r=Math.max(32,i>>5),s=r<<1,a=r>>1,o=[],c=0,u=-1,d=[];function f(p){let g;if(p.lines>s&&p instanceof wc)for(let b of p.children)f(b);else p.lines>a&&(c>a||!c)?(h(),o.push(p)):p instanceof Nr&&c&&(g=d[d.length-1])instanceof Nr&&p.lines+g.lines<=32?(c+=p.lines,u+=p.length+1,d[d.length-1]=new Nr(g.text.concat(p.text),g.length+1+p.length)):(c+p.lines>r&&h(),c+=p.lines,u+=p.length+1,d.push(p))}function h(){c!=0&&(o.push(d.length==1?d[0]:wc.from(d,u)),u=-1,c=d.length=0)}for(let p of t)f(p);return h(),o.length==1?o[0]:new wc(o,n)}}ei.empty=new Nr([""],0);function mWe(e){let t=-1;for(let n of e)t+=n.length+1;return t}function fE(e,t,n=0,i=1e9){for(let r=0,s=0,a=!0;s=n&&(c>i&&(o=o.slice(0,i-r)),r0?1:(t instanceof Nr?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],a=s>>1,o=r instanceof Nr?r.text.length:r.children.length;if(a==(n>0?o:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,t==0)return this.lineBreak=!0,this.value=` +`,this;t--}else if(r instanceof Nr){let c=r.text[a+(n<0?-1:0)];if(this.offsets[i]+=n,c.length>Math.max(0,t))return this.value=t==0?c:n>0?c.slice(t):c.slice(0,c.length-t),this;t-=c.length}else{let c=r.children[a+(n<0?-1:0)];t>c.length?(t-=c.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(c),this.offsets.push(n>0?1:(c instanceof Nr?c.text.length:c.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class pce{constructor(t,n,i){this.value="",this.done=!1,this.cursor=new wy(t,n>i?-1:1),this.pos=n>i?t.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(t,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class mce{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:n,lineBreak:i,value:r}=this.inner.next(t);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ei.prototype[Symbol.iterator]=function(){return this.iter()},wy.prototype[Symbol.iterator]=pce.prototype[Symbol.iterator]=mce.prototype[Symbol.iterator]=function(){return this});let gWe=class{constructor(t,n,i,r){this.from=t,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}};function O0(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Os(e,t,n=!0,i=!0){return hWe(e,t,n,i)}function bWe(e){return e>=56320&&e<57344}function OWe(e){return e>=55296&&e<56320}function Pa(e,t){let n=e.charCodeAt(t);if(!OWe(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return bWe(i)?(n-55296<<10)+(i-56320)+65536:n}function i4(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Sc(e){return e<65536?1:2}const MM=/\r\n?|\n/;var Cs=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Cs||(Cs={}));class Qc{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;nt)return s+(t-r);s+=o}else{if(i!=Cs.Simple&&u>=t&&(i==Cs.TrackDel&&rt||i==Cs.TrackBefore&&rt))return null;if(u>t||u==t&&n<0&&!o)return t==r||n<0?s:s+c;s+=c}r=u}if(t>r)throw new RangeError(`Position ${t} is out of range for changeset of length ${r}`);return s}touchesRange(t,n=t){for(let i=0,r=0;i=0&&r<=n&&o>=t)return rn?"cover":!0;r=o}return!1}toString(){let t="";for(let n=0;n=0?":"+r:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qc(t)}static create(t){return new Qc(t)}}class ns extends Qc{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return LM(this,(n,i,r,s,a)=>t=t.replace(r,r+(i-n),a),!1),t}mapDesc(t,n=!1){return DM(this,t,n,!0)}invert(t){let n=this.sections.slice(),i=[];for(let r=0,s=0;r=0){n[r]=o,n[r+1]=a;let c=r>>1;for(;i.length0&&uf(i,n,s.text),s.forward(d),o+=d}let u=t[a++];for(;o>1].toJSON()))}return t}static of(t,n,i){let r=[],s=[],a=0,o=null;function c(d=!1){if(!d&&!r.length)return;ah||f<0||h>n)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${n})`);let g=p?typeof p=="string"?ei.of(p.split(i||MM)):p:ei.empty,b=g.length;if(f==h&&b==0)return;fa&&Hs(r,f-a,-1),Hs(r,h-f,b),uf(s,r,g),a=h}}return u(t),c(!o),o}static empty(t){return new ns(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;ro&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&t==0&&e[r]==0?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function uf(e,t,n){if(n.length==0)return;let i=t.length-2>>1;if(i>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)o=e.sections[a++],c=e.sections[a++];t(r,u,s,d,f),r=u,s=d}}}function DM(e,t,n,i=!1){let r=[],s=i?[]:null,a=new Rx(e),o=new Rx(t);for(let c=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let u=Math.min(a.len,o.len);Hs(r,u,-1),a.forward(u),o.forward(u)}else if(o.ins>=0&&(a.ins<0||c==a.i||a.off==0&&(o.len=0&&c=0){let u=0,d=a.len;for(;d;)if(o.ins==-1){let f=Math.min(d,o.len);u+=f,d-=f,o.forward(f)}else if(o.ins==0&&o.lenc||a.ins>=0&&a.len>c)&&(o||i.length>u),s.forward2(c),a.forward(c)}}}}class Rx{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return n>=t.length?ei.empty:t[n]}textBit(t){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!t?ei.empty:n[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Jd{constructor(t,n,i,r){this.from=t,this.to=n,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}map(t,n=-1){let i,r;return this.empty?i=r=t.mapPos(this.from,n):(i=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Jd(i,r,this.flags,this.goalColumn)}extend(t,n=t,i=0){if(t<=this.anchor&&n>=this.anchor)return Qe.range(t,n,void 0,void 0,i);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return Qe.range(this.anchor,r,void 0,void 0,i)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Qe.range(t.anchor,t.head)}static create(t,n,i,r){return new Jd(t,n,i,r)}}class Qe{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Qe.create(this.ranges.map(i=>i.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Qe(t.ranges.map(n=>Jd.fromJSON(n)),t.main)}static single(t,n=t){return new Qe([Qe.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),n=t.indexOf(i);for(let r=1;rs.head?Qe.range(c,o):Qe.range(o,c))}}return new Qe(t,n)}}function bce(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let r4=0;class yt{constructor(t,n,i,r,s){this.combine=t,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=r4++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new yt(t.combine||(n=>n),t.compareInput||((n,i)=>n===i),t.compare||(t.combine?(n,i)=>n===i:s4),!!t.static,t.enables)}of(t){return new hE([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new hE(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new hE(t,this,2,n)}from(t,n){return n||(n=i=>i),this.compute([t],i=>n(i.field(t)))}}function s4(e,t){return e==t||e.length==t.length&&e.every((n,i)=>n===t[i])}class hE{constructor(t,n,i,r){this.dependencies=t,this.facet=n,this.type=i,this.value=r,this.id=r4++}dynamicSlot(t){var n;let i=this.value,r=this.facet.compareInput,s=this.id,a=t[s]>>1,o=this.type==2,c=!1,u=!1,d=[];for(let f of this.dependencies)f=="doc"?c=!0:f=="selection"?u=!0:((n=t[f.id])!==null&&n!==void 0?n:1)&1||d.push(t[f.id]);return{create(f){return f.values[a]=i(f),1},update(f,h){if(c&&h.docChanged||u&&(h.docChanged||h.selection)||$M(f,d)){let p=i(f);if(o?!HF(p,f.values[a],r):!r(p,f.values[a]))return f.values[a]=p,1}return 0},reconfigure:(f,h)=>{let p,g=h.config.address[s];if(g!=null){let b=rT(h,g);if(this.dependencies.every(y=>y instanceof yt?h.facet(y)===f.facet(y):y instanceof Ms?h.field(y,!1)==f.field(y,!1):!0)||(o?HF(p=i(f),b,r):r(p=i(f),b)))return f.values[a]=b,0}else p=i(f);return f.values[a]=p,1}}}get extension(){return this}}function HF(e,t,n){if(e.length!=t.length)return!1;for(let i=0;ie[c.id]),r=n.map(c=>c.type),s=i.filter(c=>!(c&1)),a=e[t.id]>>1;function o(c){let u=[];for(let d=0;di===r),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(Xw).find(i=>i.field==this);return((n==null?void 0:n.create)||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],a=this.updateF(s,r);return this.compareF(s,a)?0:(i.values[n]=a,1)},reconfigure:(i,r)=>{let s=i.facet(Xw),a=r.facet(Xw),o;return(o=s.find(c=>c.field==this))&&o!=a.find(c=>c.field==this)?(i.values[n]=o.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(t){return[this,Xw.of({field:this,create:t})]}get extension(){return this}}const Ih={lowest:4,low:3,default:2,high:1,highest:0};function sO(e){return t=>new Oce(t,e)}const vd={highest:sO(Ih.highest),high:sO(Ih.high),default:sO(Ih.default),low:sO(Ih.low),lowest:sO(Ih.lowest)};class Oce{constructor(t,n){this.inner=t,this.prec=n}get extension(){return this}}class jA{of(t){return new QM(this,t)}reconfigure(t){return jA.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class QM{constructor(t,n){this.compartment=t,this.inner=n}get extension(){return this}}class iT{constructor(t,n,i,r,s,a){for(this.base=t,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,i){let r=[],s=Object.create(null),a=new Map;for(let h of xWe(t,n,a))h instanceof Ms?r.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let o=Object.create(null),c=[],u=[];for(let h of r)o[h.id]=u.length<<1,u.push(p=>h.slot(p));let d=i==null?void 0:i.config.facets;for(let h in s){let p=s[h],g=p[0].facet,b=d&&d[h]||[];if(p.every(y=>y.type==0))if(o[g.id]=c.length<<1|1,s4(b,p))c.push(i.facet(g));else{let y=g.combine(p.map(O=>O.value));c.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(o[y.id]=c.length<<1|1,c.push(y.value)):(o[y.id]=u.length<<1,u.push(O=>y.dynamicSlot(O)));o[g.id]=u.length<<1,u.push(y=>yWe(y,g,p))}}let f=u.map(h=>h(o));return new iT(t,a,f,o,c,s)}}function xWe(e,t,n){let i=[[],[],[],[],[]],r=new Map;function s(a,o){let c=r.get(a);if(c!=null){if(c<=o)return;let u=i[c].indexOf(a);u>-1&&i[c].splice(u,1),a instanceof QM&&n.delete(a.compartment)}if(r.set(a,o),Array.isArray(a))for(let u of a)s(u,o);else if(a instanceof QM){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=t.get(a.compartment)||a.inner;n.set(a.compartment,u),s(u,o)}else if(a instanceof Oce)s(a.inner,a.prec);else if(a instanceof Ms)i[o].push(a),a.provides&&s(a.provides,o);else if(a instanceof hE)i[o].push(a),a.facet.extensions&&s(a.facet.extensions,Ih.default);else{let u=a.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(u==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,o)}}return s(e,Ih.default),i.reduce((a,o)=>a.concat(o))}function Sy(e,t){if(t&1)return 2;let n=t>>1,i=e.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function rT(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const yce=yt.define(),BM=yt.define({combine:e=>e.some(t=>t),static:!0}),xce=yt.define({combine:e=>e.length?e[0]:void 0,static:!0}),vce=yt.define(),wce=yt.define(),Sce=yt.define(),Ece=yt.define({combine:e=>e.length?e[0]:!1});class Kc{constructor(t,n){this.type=t,this.value=n}static define(){return new vWe}}class vWe{of(t){return new Kc(this,t)}}class wWe{constructor(t){this.map=t}of(t){return new rn(this,t)}}class rn{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new rn(this.type,n)}is(t){return this.type==t}static define(t={}){return new wWe(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let i=[];for(let r of t){let s=r.map(n);s&&i.push(s)}return i}}rn.reconfigure=rn.define();rn.appendConfig=rn.define();class Xr{constructor(t,n,i,r,s,a){this.startState=t,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,i&&bce(i,n.newLength),s.some(o=>o.type==Xr.time)||(this.annotations=s.concat(Xr.time.of(Date.now())))}static create(t,n,i,r,s,a){return new Xr(t,n,i,r,s,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(Xr.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}Xr.time=Kc.define();Xr.userEvent=Kc.define();Xr.addToHistory=Kc.define();Xr.remote=Kc.define();function SWe(e,t){let n=[];for(let i=0,r=0;;){let s,a;if(i=e[i]))s=e[i++],a=e[i++];else if(r=0;r--){let s=i[r](e);s instanceof Xr?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Xr?e=s[0]:e=Tce(t,Ng(s),!1)}return e}function kWe(e){let t=e.startState,n=t.facet(Sce),i=e;for(let r=n.length-1;r>=0;r--){let s=n[r](e);s&&Object.keys(s).length&&(i=kce(i,UM(t,s,e.changes.newLength),!0))}return i==e?e:Xr.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}const TWe=[];function Ng(e){return e==null?TWe:Array.isArray(e)?e:[e]}var lr=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(lr||(lr={}));const _We=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let zM;try{zM=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function AWe(e){if(zM)return zM.test(e);for(let t=0;t"€"&&(n.toUpperCase()!=n.toLowerCase()||_We.test(n)))return!0}return!1}function NWe(e){return t=>{if(!/\S/.test(t))return lr.Space;if(AWe(t))return lr.Word;for(let n=0;n-1)return lr.Word;return lr.Other}}class Bn{constructor(t,n,i,r,s,a){this.config=t,this.doc=n,this.selection=i,this.values=r,this.status=t.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let o=0;or.set(u,c)),n=null),r.set(o.value.compartment,o.value.extension)):o.is(rn.reconfigure)?(n=null,i=o.value):o.is(rn.appendConfig)&&(n=null,i=Ng(i).concat(o.value));let s;n?s=t.startState.values.slice():(n=iT.resolve(i,r,this),s=new Bn(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(c,u)=>u.reconfigure(c,this),null).values);let a=t.startState.facet(BM)?t.newSelection:t.newSelection.asSingle();new Bn(n,t.newDoc,a,s,(o,c)=>c.update(o,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:Qe.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,i=t(n.ranges[0]),r=this.changes(i.changes),s=[i.range],a=Ng(i.effects);for(let o=1;oa.spec.fromJSON(o,c)))}}return Bn.create({doc:t.doc,selection:Qe.fromJSON(t.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(t={}){let n=iT.resolve(t.extensions||[],new Map),i=t.doc instanceof ei?t.doc:ei.of((t.doc||"").split(n.staticFacet(Bn.lineSeparator)||MM)),r=t.selection?t.selection instanceof Qe?t.selection:Qe.single(t.selection.anchor,t.selection.head):Qe.single(0);return bce(r,i.length),n.staticFacet(BM)||(r=r.asSingle()),new Bn(n,i,r,n.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(Bn.tabSize)}get lineBreak(){return this.facet(Bn.lineSeparator)||` +`}get readOnly(){return this.facet(Ece)}phrase(t,...n){for(let i of this.facet(Bn.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),t}languageDataAt(t,n,i=-1){let r=[];for(let s of this.facet(yce))for(let a of s(this,n,i))Object.prototype.hasOwnProperty.call(a,t)&&r.push(a[t]);return r}charCategorizer(t){let n=this.languageDataAt("wordChars",t);return NWe(n.length?n[0]:"")}wordAt(t){let{text:n,from:i,length:r}=this.doc.lineAt(t),s=this.charCategorizer(t),a=t-i,o=t-i;for(;a>0;){let c=Os(n,a,!1);if(s(n.slice(c,a))!=lr.Word)break;a=c}for(;oe.length?e[0]:4});Bn.lineSeparator=xce;Bn.readOnly=Ece;Bn.phrases=yt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(r=>e[r]==t[r])}});Bn.languageData=yce;Bn.changeFilter=vce;Bn.transactionFilter=wce;Bn.transactionExtender=Sce;jA.reconfigure=rn.define();function Jc(e,t,n={}){let i={};for(let r of e)for(let s of Object.keys(r)){let a=r[s],o=i[s];if(o===void 0)i[s]=a;else if(!(o===a||a===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](o,a);else throw new Error("Config merge conflict for field "+s)}for(let r in t)i[r]===void 0&&(i[r]=t[r]);return i}class Ff{eq(t){return this==t}range(t,n=t){return Ix.create(t,n,this)}}Ff.prototype.startSide=Ff.prototype.endSide=0;Ff.prototype.point=!1;Ff.prototype.mapMode=Cs.TrackDel;function a4(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}class Ix{constructor(t,n,i){this.from=t,this.to=n,this.value=i}static create(t,n,i){return new Ix(t,n,i)}}function FM(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class o4{constructor(t,n,i,r){this.from=t,this.to=n,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(t,n,i,r=0){let s=i?this.to:this.from;for(let a=r,o=s.length;;){if(a==o)return a;let c=a+o>>1,u=s[c]-t||(i?this.value[c].endSide:this.value[c].startSide)-n;if(c==a)return u>=0?a:o;u>=0?o=c:a=c+1}}between(t,n,i,r){for(let s=this.findIndex(n,-1e9,!0),a=this.findIndex(i,1e9,!1,s);sp||h==p&&u.startSide>0&&u.endSide<=0)continue;(p-h||u.endSide-u.startSide)<0||(a<0&&(a=h),u.point&&(o=Math.max(o,p-h)),i.push(u),r.push(h-a),s.push(p-a))}return{mapped:i.length?new o4(r,s,i,o):null,pos:a}}}class jn{constructor(t,n,i,r){this.chunkPos=t,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(t,n,i,r){return new jn(t,n,i,r)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let n of this.chunk)t+=n.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=t,a=t.filter;if(n.length==0&&!a)return this;if(i&&(n=n.slice().sort(FM)),this.isEmpty)return n.length?jn.of(n):this;let o=new _ce(this,null,-1).goto(0),c=0,u=[],d=new od;for(;o.value||c=0){let f=n[c++];d.addInner(f.from,f.to,f.value)||u.push(f)}else o.rangeIndex==1&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||so.to||s=s&&t<=s+a.length&&a.between(s,t-s,n-s,i)===!1)return}this.nextLayer.between(t,n,i)}}iter(t=0){return Px.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return Px.from(t).goto(n)}static compare(t,n,i,r,s=-1){let a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),o=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),c=YF(a,o,i),u=new aO(a,c,s),d=new aO(o,c,s);i.iterGaps((f,h,p)=>GF(u,f,d,h,p,r)),i.empty&&i.length==0&&GF(u,0,d,0,0,r)}static eq(t,n,i=0,r){r==null&&(r=999999999);let s=t.filter(d=>!d.isEmpty&&n.indexOf(d)<0),a=n.filter(d=>!d.isEmpty&&t.indexOf(d)<0);if(s.length!=a.length)return!1;if(!s.length)return!0;let o=YF(s,a),c=new aO(s,o,0).goto(i),u=new aO(a,o,0).goto(i);for(;;){if(c.to!=u.to||!VM(c.active,u.active)||c.point&&(!u.point||!a4(c.point,u.point)))return!1;if(c.to>r)return!0;c.next(),u.next()}}static spans(t,n,i,r,s=-1){let a=new aO(t,null,s).goto(n),o=n,c=a.openStart;for(;;){let u=Math.min(a.to,i);if(a.point){let d=a.activeForPoint(a.to),f=a.pointFromo&&(r.span(o,u,a.active,c),c=a.openEnd(u));if(a.to>i)return c+(a.point&&a.to>i?1:0);o=a.to,a.next()}}static of(t,n=!1){let i=new od;for(let r of t instanceof Ix?[t]:n?CWe(t):t)i.add(r.from,r.to,r.value);return i.finish()}static join(t){if(!t.length)return jn.empty;let n=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let r=t[i];r!=jn.empty;r=r.nextLayer)n=new jn(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}jn.empty=new jn([],[],null,-1);function CWe(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(FM);t=i}return e}jn.empty.nextLayer=jn.empty;class od{finishChunk(t){this.chunks.push(new o4(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,i){this.addInner(t,n,i)||(this.nextLayer||(this.nextLayer=new od)).add(t,n,i)}addInner(t,n,i){let r=t-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-t)),!0)}addChunk(t,n){if((t-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(t);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+t,this.lastTo=n.to[i]+t,!0}finish(){return this.finishInner(jn.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=jn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}}function YF(e,t,n){let i=new Map;for(let s of e)for(let a=0;a=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new _ce(a,n,i,s));return r.length==1?r[0]:new Px(r)}get startSide(){return this.value?this.value.startSide:0}goto(t,n=-1e9){for(let i of this.heap)i.goto(t,n);for(let i=this.heap.length>>1;i>=0;i--)tj(this.heap,i);return this.next(),this}forward(t,n){for(let i of this.heap)i.forward(t,n);for(let i=this.heap.length>>1;i>=0;i--)tj(this.heap,i);(this.to-t||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tj(this.heap,0)}}}function tj(e,t){for(let n=e[t];;){let i=(t<<1)+1;if(i>=e.length)break;let r=e[i];if(i+1=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class aO{constructor(t,n,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Px.from(t,n,i)}goto(t,n=-1e9){return this.cursor.goto(t,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=n,this.openStart=-1,this.next(),this}forward(t,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(t,n)}removeActive(t){qw(this.active,t),qw(this.activeTo,t),qw(this.activeRank,t),this.minActive=WF(this.active,this.activeTo)}addActive(t){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n0;)n++;Hw(this.active,n,i),Hw(this.activeTo,n,r),Hw(this.activeRank,n,s),t&&Hw(t,n,this.cursor.from),this.minActive=WF(this.active,this.activeTo)}next(){let t=this.to,n=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>t){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&qw(i,r)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(t){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)n++;return n}}function GF(e,t,n,i,r,s){e.goto(t),n.goto(i);let a=i+r,o=i,c=i-t,u=!!s.boundChange;for(let d=!1;;){let f=e.to+c-n.to,h=f||e.endSide-n.endSide,p=h<0?e.to+c:n.to,g=Math.min(p,a);if(e.point||n.point?(e.point&&n.point&&a4(e.point,n.point)&&VM(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(o,g,e.point,n.point),d=!1):(d&&s.boundChange(o),g>o&&!VM(e.active,n.active)&&s.compareRange(o,g,e.active,n.active),u&&ga)break;o=p,h<=0&&e.next(),h>=0&&n.next()}}function VM(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;i--)e[i+1]=e[i];e[t]=n}function WF(e,t){let n=-1,i=1e9;for(let r=0;r=t)return r;if(r==e.length)break;s+=e.charCodeAt(r)==9?n-s%n:1,r=Os(e,r)}return i===!0?-1:e.length}const qM="ͼ",ZF=typeof Symbol>"u"?"__"+qM:Symbol.for(qM),HM=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),KF=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Vf{constructor(t,n){this.rules=[];let{finish:i}=n||{};function r(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function s(a,o,c,u){let d=[],f=/^@(\w+)\b/.exec(a[0]),h=f&&f[1]=="keyframes";if(f&&o==null)return c.push(a[0]+";");for(let p in o){let g=o[p];if(/&/.test(p))s(p.split(/,\s*/).map(b=>a.map(y=>b.replace(/&/,y))).reduce((b,y)=>b.concat(y)),g,c);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,d,h)}else g!=null&&d.push(p.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+g+";")}(d.length||h)&&c.push((i&&!f&&!u?a.map(i):a).join(", ")+" {"+d.join(" ")+"}")}for(let a in t)s(r(a),t[a],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let t=KF[ZF]||1;return KF[ZF]=t+1,qM+t.toString(36)}static mount(t,n,i){let r=t[HM],s=i&&i.nonce;r?s&&r.setNonce(s):r=new jWe(t,s),r.mount(Array.isArray(n)?n:[n],t)}}let JF=new Map;class jWe{constructor(t,n){let i=t.ownerDocument||t,r=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&r.CSSStyleSheet){let s=JF.get(i);if(s)return t[HM]=s;this.sheet=new r.CSSStyleSheet,JF.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[HM]=this}mount(t,n){let i=this.sheet,r=0,s=0;for(let a=0;a-1&&(this.modules.splice(c,1),s--,c=-1),c==-1){if(this.modules.splice(s++,0,o),i)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RWe=typeof navigator<"u"&&/Mac/.test(navigator.platform),IWe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _s=0;_s<10;_s++)Xf[48+_s]=Xf[96+_s]=String(_s);for(var _s=1;_s<=24;_s++)Xf[_s+111]="F"+_s;for(var _s=65;_s<=90;_s++)Xf[_s]=String.fromCharCode(_s+32),Mx[_s]=String.fromCharCode(_s);for(var nj in Xf)Mx.hasOwnProperty(nj)||(Mx[nj]=Xf[nj]);function PWe(e){var t=RWe&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||IWe&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Mx:Xf)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function Ei(){var e=arguments[0];typeof e=="string"&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];typeof r=="string"?e.setAttribute(i,r):r!=null&&(e[i]=r)}t++}for(;t2);var Ot={mac:nV||/Mac/.test(ha.platform),windows:/Win/.test(ha.platform),linux:/Linux|X11/.test(ha.platform),ie:RA,ie_version:Nce?YM.documentMode||6:WM?+WM[1]:GM?+GM[1]:0,gecko:eV,gecko_version:eV?+(/Firefox\/(\d+)/.exec(ha.userAgent)||[0,0])[1]:0,chrome:!!ij,chrome_version:ij?+ij[1]:0,ios:nV,android:/Android\b/.test(ha.userAgent),webkit:tV,webkit_version:tV?+(/\bAppleWebKit\/(\d+)/.exec(ha.userAgent)||[0,0])[1]:0,safari:ZM,safari_version:ZM?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ha.userAgent)||[0,0])[1]:0,tabSize:YM.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function l4(e,t){for(let n in e)n=="class"&&t.class?t.class+=" "+e.class:n=="style"&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const sT=Object.create(null);function c4(e,t,n){if(e==t)return!0;e||(e=sT),t||(t=sT);let i=Object.keys(e),r=Object.keys(t);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||e[s]!==t[s]))return!1;return!0}function MWe(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;t[i]==null&&e.removeAttribute(i)}for(let n in t){let i=t[n];n=="style"?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}function iV(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,r=="style"?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,r=="style"?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function LWe(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new kp(t,n,n,i,t.widget||null,!1)}static replace(t){let n=!!t.block,i,r;if(t.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:a}=Cce(t,n);i=(s?n?-3e8:-1:5e8)-1,r=(a?n?2e8:1:-6e8)+1}return new kp(t,i,r,n,t.widget||null,!0)}static line(t){return new K1(t)}static set(t,n=!1){return jn.of(t,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}zt.none=jn.empty;class Z1 extends zt{constructor(t){let{start:n,end:i}=Cce(t);super(n?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?l4(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||sT}eq(t){return this==t||t instanceof Z1&&this.tagName==t.tagName&&c4(this.attrs,t.attrs)}range(t,n=t){if(t>=n)throw new RangeError("Mark decorations may not be empty");return super.range(t,n)}}Z1.prototype.point=!1;class K1 extends zt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof K1&&this.spec.class==t.spec.class&&c4(this.spec.attributes,t.spec.attributes)}range(t,n=t){if(n!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,n)}}K1.prototype.mapMode=Cs.TrackBefore;K1.prototype.point=!0;class kp extends zt{constructor(t,n,i,r,s,a){super(n,i,s,t),this.block=r,this.isReplace=a,this.mapMode=r?n<=0?Cs.TrackBefore:Cs.TrackAfter:Cs.TrackDel}get type(){return this.startSide!=this.endSide?Is.WidgetRange:this.startSide<=0?Is.WidgetBefore:Is.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof kp&&DWe(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,n=t){if(this.isReplace&&(t>n||t==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,n)}}kp.prototype.point=!0;function Cce(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return n==null&&(n=e.inclusive),i==null&&(i=e.inclusive),{start:n??t,end:i??t}}function DWe(e,t){return e==t||!!(e&&t&&e.compare(t))}function Cg(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}class Lx extends Ff{constructor(t,n,i){super(),this.tagName=t,this.attributes=n,this.rank=i}eq(t){return t==this||t instanceof Lx&&this.tagName==t.tagName&&c4(this.attributes,t.attributes)}static create(t){return new Lx(t.tagName,t.attributes||sT,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,n=!1){return jn.of(t,n)}}Lx.prototype.startSide=Lx.prototype.endSide=-1;function Dx(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function KM(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function Ey(e,t){if(!t.anchorNode)return!1;try{return KM(e,t.anchorNode)}catch{return!1}}function ky(e){return e.nodeType==3?Qx(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Ty(e,t,n,i){return n?rV(e,t,n,i,-1)||rV(e,t,n,i,1):!1}function qf(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function aT(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function rV(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:ld(e))){if(e.nodeName=="DIV")return!1;let s=e.parentNode;if(!s||s.nodeType!=1)return!1;t=qf(e)+(r<0?0:1),e=s}else if(e.nodeType==1){if(e=e.childNodes[t+(r<0?-1:0)],e.nodeType==1&&e.contentEditable=="false")return!1;t=r<0?ld(e):0}else return!1}}function ld(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function $x(e,t){let{left:n,right:i}=e;if(n==i)return e;let r=t?n:i;return{left:r,right:r,top:e.top,bottom:e.bottom}}function $We(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function jce(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function QWe(e,t,n,i,r,s,a,o){let c=e.ownerDocument,u=c.defaultView||window;for(let d=e,f=!1;d&&!f;)if(d.nodeType==1){let h,p=d==c.body,g=1,b=1;if(p)h=$We(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(f=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let v=d.getBoundingClientRect();({scaleX:g,scaleY:b}=jce(d,v)),h={left:v.left,right:v.left+d.clientWidth*g,top:v.top,bottom:v.top+d.clientHeight*b}}let y=0,O=0;if(r=="nearest")t.top0&&t.bottom>h.bottom+O&&(O=t.bottom-h.bottom+a)):t.bottom>h.bottom-a&&(O=t.bottom-h.bottom+a,n<0&&t.top-O0&&t.right>h.right+y&&(y=t.right-h.right+s)):t.right>h.right-s&&(y=t.right-h.right+s,n<0&&t.lefth.bottom||t.lefth.right)&&(t={left:Math.max(t.left,h.left),right:Math.min(t.right,h.right),top:Math.max(t.top,h.top),bottom:Math.min(t.bottom,h.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Rce(e,t=!0){let n=e.ownerDocument,i=null,r=null;for(let s=e.parentNode;s&&!(s==n.body||(!t||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),t&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class BWe{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:n,focusNode:i}=t;this.set(n,Math.min(t.anchorOffset,n?ld(n):0),i,Math.min(t.focusOffset,i?ld(i):0))}set(t,n,i,r){this.anchorNode=t,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}let Ch=null;Ot.safari&&Ot.safari_version>=26&&(Ch=!1);function Ice(e){if(e.setActive)return e.setActive();if(Ch)return e.focus(Ch);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(Ch==null?{get preventScroll(){return Ch={preventScroll:!0},!0}}:void 0),!Ch){Ch=!1;for(let n=0;nMath.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Mce(e,t){for(let n=e,i=t;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=ld(n)}else if(n.parentNode&&!aT(n))i=qf(n),n=n.parentNode;else return null}}function Lce(e,t){for(let n=e,i=t;;){if(n.nodeType==3&&i=n){if(o.level==i)return a;(s<0||(r!=0?r<0?o.fromn:t[s].level>o.level))&&(s=a)}}if(s<0)throw new RangeError("Index out of range");return s}}function Qce(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;b-=3)if(pc[b+1]==-p){let y=pc[b+2],O=y&2?r:y&4?y&1?s:r:0;O&&(Ii[f]=Ii[pc[b]]=O),o=b;break}}else{if(pc.length==189)break;pc[o++]=f,pc[o++]=h,pc[o++]=c}else if((g=Ii[f])==2||g==1){let b=g==r;c=b?0:1;for(let y=o-3;y>=0;y-=3){let O=pc[y+2];if(O&2)break;if(b)pc[y+2]|=2;else{if(O&4)break;pc[y+2]|=4}}}}}function YWe(e,t,n,i){for(let r=0,s=i;r<=n.length;r++){let a=r?n[r-1].to:e,o=rc;)g==y&&(g=n[--b].from,y=b?n[b-1].to:e),Ii[--g]=p;c=d}else s=u,c++}}}function eL(e,t,n,i,r,s,a){let o=i%2?2:1;if(i%2==r%2)for(let c=t,u=0;cc&&a.push(new jc(c,b.from,p));let y=b.direction==Tp!=!(p%2);tL(e,y?i+1:i,r,b.inner,b.from,b.to,a),c=b.to}g=b.to}else{if(g==n||(d?Ii[g]!=o:Ii[g]==o))break;g++}h?eL(e,c,g,i+1,r,h,a):ct;){let d=!0,f=!1;if(!u||c>s[u-1].to){let b=Ii[c-1];b!=o&&(d=!1,f=b==16)}let h=!d&&o==1?[]:null,p=d?i:i+1,g=c;e:for(;;)if(u&&g==s[u-1].to){if(f)break e;let b=s[--u];if(!d)for(let y=b.from,O=u;;){if(y==t)break e;if(O&&s[O-1].to==y)y=s[--O].from;else{if(Ii[y-1]==o)break e;break}}if(h)h.push(b);else{b.toIi.length;)Ii[Ii.length]=256;let i=[],r=t==Tp?0:1;return tL(e,r,r,n,0,e.length,i),i}function Bce(e){return[new jc(0,e,0)]}let Uce="";function WWe(e,t,n,i,r){var s;let a=i.head-e.from,o=jc.find(t,a,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),c=t[o],u=c.side(r,n);if(a==u){let h=o+=r?1:-1;if(h<0||h>=t.length)return null;c=t[o=h],a=c.side(!r,n),u=c.side(r,n)}let d=Os(e.text,a,c.forward(r,n));(dc.to)&&(d=u),Uce=e.text.slice(Math.min(a,d),Math.max(a,d));let f=o==(r?t.length-1:0)?null:t[o+(r?1:-1)];return f&&d==u&&f.level+(r?0:1)e.some(t=>t)}),Gce=yt.define({combine:e=>e.some(t=>t)}),Wce=yt.define();class Rg{constructor(t,n,i,r,s,a=!1){this.range=t,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=a}map(t){return t.empty?this:new Rg(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Rg(Qe.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Yw=rn.define({map:(e,t)=>e.map(t)}),Zce=rn.define();function Qa(e,t,n){let i=e.facet(Xce);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const Cu=yt.define({combine:e=>e.length?e[0]:!0});let KWe=0;const ag=yt.define({combine(e){return e.filter((t,n)=>{for(let i=0;i{let c=[];return a&&c.push(IA.of(u=>{let d=u.plugin(o);return d?a(d):zt.none})),s&&c.push(s(o)),c})}static fromClass(t,n){return Tr.define((i,r)=>new t(i,r),n)}}class rj{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Qa(n.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(n){Qa(t.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Qa(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Kce=yt.define(),h4=yt.define(),IA=yt.define(),Jce=yt.define(),p4=yt.define(),J1=yt.define(),eue=yt.define();function aV(e,t){let n=e.state.facet(eue);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(e):s),r=[];return jn.spans(i,t.from,t.to,{point(){},span(s,a,o,c){let u=s-t.from,d=a-t.from,f=r;for(let h=o.length-1;h>=0;h--,c--){let p=o[h].spec.bidiIsolate,g;if(p==null&&(p=ZWe(t.text,u,d)),c>0&&f.length&&(g=f[f.length-1]).to==u&&g.direction==p)g.to=d,f=g.inner;else{let b={from:u,to:d,direction:p,inner:[]};f.push(b),f=b.inner}}}}),r}const tue=yt.define();function m4(e){let t=0,n=0,i=0,r=0;for(let s of e.state.facet(tue)){let a=s(e);a&&(a.left!=null&&(t=Math.max(t,a.left)),a.right!=null&&(n=Math.max(n,a.right)),a.top!=null&&(i=Math.max(i,a.top)),a.bottom!=null&&(r=Math.max(r,a.bottom)))}return{left:t,right:n,top:i,bottom:r}}const LO=yt.define();class Yo{constructor(t,n,i,r){this.fromA=t,this.toA=n,this.fromB=i,this.toB=r}join(t){return new Yo(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let n=t.length,i=this;for(;n>0;n--){let r=t[n-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new Yo(s,a,o,c))),this.changedRanges=r}static create(t,n,i){return new oT(t,n,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const JWe=[];class Er{constructor(t,n,i=0){this.dom=t,this.length=n,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return JWe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&MWe(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,n=this.posAtStart){let i=n;for(let r of this.children){if(r==t)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,n,i){return null}domPosFor(t,n){let i=qf(this.dom),r=this.length?t>0:n>0;return new Il(this.parent.dom,i+(r?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof MA)return t;return null}static get(t){return t.cmTile}}class PA extends Er{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let n=this.dom,i=null,r,s=(t==null?void 0:t.node)==n?t:null,a=0;for(let o of this.children){if(o.sync(t),a+=o.length+o.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=o.dom&&(s.written=!0),o.dom.parentNode==n)for(;r&&r!=o.dom;)r=oV(r);else n.insertBefore(o.dom,r);i=o.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=oV(r);this.length=a}}function oV(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class MA extends PA{constructor(t,n){super(n),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let n=Er.get(t);if(n&&this.owns(n))return n;t=t.parentNode}}blockTiles(t){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let a=i.children[r++];if(a instanceof Yu)n.push(r),i=a,r=0;else{let o=s+a.length,c=t(a,s);if(c!==void 0)return c;s=o+a.breakAfter}}}resolveBlock(t,n){let i,r=-1,s,a=-1;if(this.blockTiles((o,c)=>{let u=c+o.length;if(t>=c&&t<=u){if(o.isWidget()&&n>=-1&&n<=1){if(o.flags&32)return!0;o.flags&16&&(i=void 0)}(ct||t==c&&(n>1?o.length:o.covers(-1)))&&(!s||!o.isWidget()&&s.isWidget())&&(s=o,a=t-c)}}),!i&&!s)throw new Error("No tile at position "+t);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:a}}}class Yu extends PA{constructor(t,n){super(t),this.wrapper=n}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let i=new Yu(n||document.createElement(t.tagName),t);return n||(i.flags|=4),i}}class y0 extends PA{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,i){let r=new y0(n||document.createElement("div"),t);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(t,n,i){let r=null,s=-1,a=null,o=-1;function c(d,f){for(let h=0,p=0;h=f&&(g.isComposite()?c(g,f-p):(!a||a.isHidden&&(n>0&&!(a.flags&32)||i&&tZe(a,g)))&&(b>f||g.flags&32)?(a=g,o=f-p):(pr&&(t=r);let s=t,a=t,o=0;t==0&&n<0||t==r&&n>=0?Ot.chrome||Ot.gecko||(t?(s--,o=1):a=0)?0:c.length-1];return Ot.safari&&!o&&u.width==0&&(u=Array.prototype.find.call(c,d=>d.width)||u),i==null?u:$x(u,(o?o>0:n<0)==i)}static of(t,n){let i=new Vh(n||document.createTextNode(t),t);return n||(i.flags|=2),i}}class _p extends Er{constructor(t,n,i,r){super(t,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,n){return this.coordsInWidget(t,n,!1)}coordsInWidget(t,n,i){let r=this.widget.coordsAt(this.dom,t,n);if(r)return r;if(i)return $x(this.dom.getBoundingClientRect(),this.length?t==0:n<=0);{let s=this.dom.getClientRects(),a=null;if(!s.length)return null;let o=this.flags&16?!0:this.flags&32?!1:t>0;for(let c=o?s.length-1:0;a=s[c],!(t>0?c==0:c==s.length-1||a.top0==i)}}class nZe{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,n,i){let{tile:r,index:s,beforeBreak:a,parents:o}=this;for(;t||n>0;)if(r.isComposite())if(a){if(!t)break;i&&i.break(),t--,a=!1}else if(s==r.children.length){if(!t&&!o.length)break;i&&i.leave(r),a=!!r.breakAfter,{tile:r,index:s}=o.pop(),s++}else{let c=r.children[s],u=c.breakAfter;(n>0?c.length<=t:c.length=0;o--){let c=n.marks[o],u=r.lastChild;if(u instanceof La&&u.mark.eq(c.mark))u.dom!=c.dom&&u.setDOM(sj(c.dom)),r=u;else{if(this.cache.reused.get(c)){let f=Er.get(c.dom);f&&f.setDOM(sj(c.dom))}let d=La.of(c.mark,c.dom);r.append(d),r=d}this.cache.reused.set(c,2)}let s=Er.get(t.text);s&&this.cache.reused.set(s,2);let a=new Vh(t.text,t.text.nodeValue);a.flags|=8,this.pos=t.range.toB,r.append(a)}addInlineWidget(t,n,i){let r=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(t.flags&16)&&s.append(this.getBuffer(1)),s.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,n,i){this.flushBuffer(),this.ensureMarks(n,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let n=this.afterWidget||this.lastBlock;n.length+=t,this.pos+=t}addLineStart(t,n){var i;t||(t=nue);let r=y0.start(t,n||((i=this.cache.find(y0))===null||i===void 0?void 0:i.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,n){var i;let r=this.curLine;for(let s=t.length-1;s>=0;s--){let a=t[s],o;if(n>0&&(o=r.lastChild)&&o instanceof La&&o.mark.eq(a))r=o,n--;else{let c=La.of(a,(i=this.cache.find(La,u=>u.mark.eq(a)))===null||i===void 0?void 0:i.dom);r.append(c),r=c,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!lV(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(Ot.ios&&lV(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(aj,0,32)||new _p(aj.toDOM(),0,aj,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to=this.pos){let n=t.rank*102+t.value.rank,i=new iZe(t.from,t.to,t.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);n.append(s),n=s}}return n}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let n=2|(t<0?16:32),i=this.cache.find(lT,void 0,1);return i&&(i.flags=n),i||new lT(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class sZe{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=r;let o=this.textOff=Math.min(t,r.length);return s?null:r.slice(0,o)}let n=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const cT=[_p,y0,Vh,La,lT,Yu,MA];for(let e=0;e[]),this.index=cT.map(()=>0),this.reused=new Map}add(t){let n=t.constructor.bucket,i=this.buckets[n];i.length<6?i.push(t):i[this.index[n]=(this.index[n]+1)%6]=t}find(t,n,i=2){let r=t.bucket,s=this.buckets[r],a=this.index[r];for(let o=0;o{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(t,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,a=0;;){let o=ar){let u=c-r;this.preserve(u,!a,!o),r=c,s+=u}if(!o)break;n&&o.fromA<=n.range.fromA&&o.toA>=n.range.toA?(this.forward(o.fromA,n.range.fromA,n.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(c-o);else{let u=c>0||o{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof La&&r.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?r.length&&(r.length=s=0):a instanceof La&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,n){let i=null,r=this.builder,s=-1,a=jn.spans(this.decorations,t,n,{point:(o,c,u,d,f,h)=>{if(u instanceof kp){if(this.disallowBlockEffectsFor[h]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(c>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=d.length,f>d.length)r.continueWidget(c-o);else{let p=u.widget||(u.block?x0.block:x0.inline),g=lZe(u),b=this.cache.findWidget(p,c-o,g)||_p.of(p,this.view,c-o,g);u.block?(u.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(b)):(r.ensureLine(i),r.addInlineWidget(b,d,f))}i=null}else i=cZe(i,u);c>o&&this.text.skip(c-o)},span:(o,c,u,d)=>{for(let f=o;f-1&&(this.openWidget=a>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=a}forward(t,n,i=1){n-t<=10?this.old.advance(n-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let n=[],i=null;for(let r=t.parentNode;;r=r.parentNode){let s=Er.get(r);if(r==this.view.contentDOM)break;s instanceof La?n.push(s):s!=null&&s.isLine()?i=s:s instanceof Yu||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new y0(r,nue):i||n.push(La.of(new Z1({tagName:r.nodeName.toLowerCase(),attributes:LWe(r)}),r)))}return{line:i,marks:n}}}function lV(e,t){let n=i=>{for(let r of i.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function lZe(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}const nue={class:"cm-line"};function cZe(e,t){let n=t.spec.attributes,i=t.spec.class;return!n&&!i||(e||(e={class:"cm-line"}),n&&l4(n,e),i&&(e.class+=" "+i)),e}function uZe(e){let t=[];for(let n=e.parents.length;n>1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof La&&t.push(i.mark)}return t}function sj(e){let t=Er.get(e);return t&&t.setDOM(e.cloneNode()),e}class x0 extends Yl{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}x0.inline=new x0("span");x0.block=new x0("div");const aj=new class extends Yl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class cV{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=zt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new MA(t,t.contentDOM),this.updateInner([new Yo(0,0,0,t.state.doc.length)],null)}update(t){var n;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:d,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!yZe(t.changes,this.hasComposition)&&!t.selectionSet&&(r=t.state.selection.main.head));let s=r>-1?fZe(this.view,t.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:f}=this.hasComposition;i=new Yo(d,f,t.changes.mapPos(d,-1),t.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Ot.ie||Ot.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,o=this.blockWrappers;this.updateDeco();let c=mZe(a,this.decorations,t.changes);c.length&&(i=Yo.extendWithRanges(i,c));let u=bZe(o,this.blockWrappers,t.changes);return u.length&&(i=Yo.extendWithRanges(i,u)),s&&!i.some(d=>d.fromA<=s.range.fromA&&d.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||t.length){let a=this.tile,o=new oZe(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Er.get(n.text)&&o.cache.reused.set(Er.get(n.text),2),this.tile=o.run(t,n),iL(a,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Ot.chrome||Ot.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ey(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||a))return;let o=this.forceSelection;this.forceSelection=!1;let c=this.view.state.selection.main,u,d;if(c.empty?d=u=this.inlineDOMNearPos(c.anchor,c.assoc||1):(d=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),u=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Ot.gecko&&c.empty&&!this.hasComposition&&dZe(u)){let h=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(h,u.node.childNodes[u.offset]||null)),u=d=new Il(h,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!Ty(u.node,u.offset,f.anchorNode,f.anchorOffset)||!Ty(d.node,d.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,c))&&(this.view.observer.ignore(()=>{Ot.android&&Ot.chrome&&i.contains(f.focusNode)&&OZe(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=Dx(this.view.root);if(h)if(c.empty){if(Ot.gecko){let p=hZe(u.node,u.offset);if(p&&p!=3){let g=(p==1?Mce:Lce)(u.node,u.offset);g&&(u=new Il(g.node,g.offset))}}h.collapse(u.node,u.offset),c.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=c.bidiLevel)}else if(h.extend){h.collapse(u.node,u.offset);try{h.extend(d.node,d.offset)}catch{}}else{let p=document.createRange();c.anchor>c.head&&([u,d]=[d,u]),p.setEnd(d.node,d.offset),p.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(p)}a&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(u,d)),this.impreciseAnchor=u.precise?null:new Il(f.anchorNode,f.anchorOffset),this.impreciseHead=d.precise?null:new Il(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(t,n){return this.hasComposition&&n.empty&&Ty(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,n=t.state.selection.main,i=Dx(t.root),{anchorNode:r,anchorOffset:s}=t.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let a=this.lineAt(n.head,n.assoc);if(!a)return;let o=a.posAtStart;if(n.head==o||n.head==o+a.length)return;let c=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!c||!u||c.bottom>u.top)return;let d=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(d.node,d.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let f=t.observer.selectionRange;t.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(t,n){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(t==i.dom)s=i.dom.childNodes[n];else{let a=ld(t)==0?0:n==0?-1:1;for(;;){let o=t.parentNode;if(o==i.dom)break;a==0&&o.firstChild!=o.lastChild&&(t==o.firstChild?a=-1:a=1),t=o}a<0?s=t:s=t.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Er.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let a=0,o=r;;a++){let c=i.children[a];if(c.dom==s)return o;o+=c.length+c.breakAfter}}else return i.isText()?t==i.dom?r+n:r+(n?i.length:0):r}domAtPos(t,n){let{tile:i,offset:r}=this.tile.resolveBlock(t,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(t,n){let i,r=-1,s=!1,a,o=-1,c=!1;return this.tile.blockTiles((u,d)=>{if(u.isWidget()){if(u.flags&32&&d>=t)return!0;u.flags&16&&(s=!0)}else{let f=d+u.length;if(d<=t&&(i=u,r=t-d,s=f=t&&!a&&(a=u,o=t-d,c=d>t),d>t&&a)return!0}}),!i&&!a?this.domAtPos(t,n):(s&&a?i=null:c&&i&&(a=null),i&&n<0||!a?i.domIn(r,n):a.domIn(o,n))}coordsAt(t,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(t,n);return r.isWidget()?r.widget instanceof oj?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(t,n){let{tile:i}=this.tile.resolveBlock(t,n);return i.isLine()?i:null}coordsForChar(t){let{tile:n,offset:i}=this.tile.resolveBlock(t,1);if(!n.isLine())return null;function r(s,a){if(s.isComposite())for(let o of s.children){if(o.length>=a){let c=r(o,a);if(c)return c}if(a-=o.length,a<0)break}else if(s.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,c=this.view.textDirection==Pi.LTR,u=0,d=(f,h,p)=>{for(let g=0;gr);g++){let b=f.children[g],y=h+b.length,O=b.dom.getBoundingClientRect(),{height:v}=O;if(p&&!g&&(u+=O.top-p.top),b instanceof Yu)y>i&&d(b,h,O);else if(h>=i&&(u>0&&n.push(-u),n.push(v+u),u=0,a)){let x=b.dom.lastChild,w=x?ky(x):[];if(w.length){let E=w[w.length-1],S=c?E.right-O.left:O.right-E.left;S>o&&(o=S,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=y)}}p&&g==f.children.length-1&&(u+=p.bottom-O.bottom),h=y+b.breakAfter}};return d(this.tile,0,null),n}textDirectionAt(t){let{tile:n}=this.tile.resolveBlock(t,1);return getComputedStyle(n.dom).direction=="rtl"?Pi.RTL:Pi.LTR}measureTextSize(){let t=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let o=0,c;for(let u of a.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let d=ky(u.dom);if(d.length!=1)return;o+=d[0].width,c=d[0].height}if(o)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:o/a.length,textHeight:c}}});if(t)return t;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let a=ky(n.firstChild)[0];i=n.getBoundingClientRect().height,r=a&&a.width?a.width/27:7,s=a&&a.height?a.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let t=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],a=s?s.from-1:this.view.state.doc.length;if(a>i){let o=(n.lineBlockAt(a).bottom-n.lineBlockAt(i).top)/this.view.scaleY;t.push(zt.replace({widget:new oj(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!s)break;i=s.to+1}return zt.set(t)}updateDeco(){let t=1,n=this.view.state.facet(IA).map(s=>(this.dynamicDecorationMap[t++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(p4).map((s,a)=>{let o=typeof s=="function";return o&&(i=!0),o?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[t++]=i,n.push(jn.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];ttypeof s=="function"?s(this.view):s)}scrollIntoView(t){if(t.isSnapshot){let u=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=u.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let u of this.view.state.facet(Wce))try{if(u(this.view,t.range,t))return!0}catch(d){Qa(this.view.state,d,"scroll handler")}let{range:n}=t,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=m4(this.view),a={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:o,offsetHeight:c}=this.view.scrollDOM;if(QWe(this.view.scrollDOM,a,n.head1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(t,1).tile)}destroy(){iL(this.tile)}}function iL(e,t){let n=t==null?void 0:t.get(e);if(n!=1){n==null&&e.destroy();for(let i of e.children)iL(i,t)}}function dZe(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable=="false")&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable=="false")}function iue(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Mce(n.focusNode,n.focusOffset),r=Lce(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let o=Er.get(r.node);if(!o||o.isText()&&o.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let c=Er.get(i.node);!c||c.isText()&&c.text!=i.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=i,!s)return null;let a=t-s.offset;return{from:a,to:a+s.node.nodeValue.length,node:s.node}}function fZe(e,t,n){let i=iue(e,n);if(!i)return null;let{node:r,from:s,to:a}=i,o=r.nodeValue;if(/[\n\r]/.test(o)||e.state.doc.sliceString(i.from,i.to)!=o)return null;let c=t.invertedDesc;return{range:new Yo(c.mapPos(s),c.mapPos(a),s,a),text:r}}function hZe(e,t){return e.nodeType!=1?0:(t&&e.childNodes[t-1].contentEditable=="false"?1:0)|(t{it.from&&(n=!0)}),n}class oj extends Yl{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function xZe(e,t,n=1){let i=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(r.length==0)return Qe.cursor(t);s==0?n=1:s==r.length&&(n=-1);let a=s,o=s;n<0?a=Os(r.text,s,!1):o=Os(r.text,s);let c=i(r.text.slice(a,o));for(;a>0;){let u=Os(r.text,a,!1);if(i(r.text.slice(u,a))!=c)break;a=u}for(;oe.defaultLineHeight*1.5){let o=e.viewState.heightOracle.textHeight,c=Math.floor((r-n.top-(e.defaultLineHeight-o)*.5)/o);s+=c*e.viewState.heightOracle.lineLength}let a=e.state.sliceDoc(n.from,n.to);return n.from+XM(a,s,e.state.tabSize)}function rL(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>t)break;if(!(s.tot)return s;(!r||s.type==Is.Text&&(r.type!=s.type||(n<0?s.fromt)))&&(r=s)}}return r||i}return i}function wZe(e,t,n,i){let r=rL(e,t.head,t.assoc||-1),s=!i||r.type!=Is.Text||!(e.lineWrapping||r.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head);if(s){let a=e.dom.getBoundingClientRect(),o=e.textDirectionAt(r.from),c=e.posAtCoords({x:n==(o==Pi.LTR)?a.right-1:a.left+1,y:(s.top+s.bottom)/2});if(c!=null)return Qe.cursor(c,n?-1:1)}return Qe.cursor(n?r.to:r.from,n?-1:1)}function uV(e,t,n,i){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),a=e.textDirectionAt(r.from);for(let o=t,c=null;;){let u=WWe(r,s,a,o,n),d=Uce;if(!u){if(r.number==(n?e.state.doc.lines:1))return o;d=` +`,r=e.state.doc.line(r.number+(n?1:-1)),s=e.bidiSpans(r),u=e.visualLineSide(r,!n)}if(c){if(!c(d))return o}else{if(!i)return u;c=i(d)}o=u}}function SZe(e,t,n){let i=e.state.charCategorizer(t),r=i(n);return s=>{let a=i(s);return r==lr.Space&&(r=a),r==a}}function EZe(e,t,n,i){let r=t.head,s=n?1:-1;if(r==(n?e.state.doc.length:0))return Qe.cursor(r,t.assoc);let a=t.goalColumn,o,c=e.contentDOM.getBoundingClientRect(),u=e.coordsAtPos(r,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),d=e.documentTop;if(u)a==null&&(a=u.left-c.left),o=s<0?u.top:u.bottom;else{let g=e.viewState.lineBlockAt(r);a==null&&(a=Math.min(c.right-c.left,e.defaultCharacterWidth*(r-g.from))),o=(s<0?g.top:g.bottom)+d}let f=c.left+a,h=e.viewState.heightOracle.textHeight>>1,p=i??h;for(let g=0;;g+=h){let b=o+(p+g)*s,y=sL(e,{x:f,y:b},!1,s);if(n?b>c.bottom:bo:v{if(t>s&&tr(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:Qe.cursor(i,ie.viewState.docHeight)return new Ec(e.state.doc.length,-1);if(u=e.elementAtHeight(c),i==null)break;if(u.type==Is.Text){if(i<0?u.toe.viewport.to)break;let h=e.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(h&&(i<0?h.top<=c+s:h.bottom>=c+s))break}let f=e.viewState.heightOracle.textHeight/2;c=i>0?u.bottom+f:u.top-f}if(e.viewport.from>=u.to||e.viewport.to<=u.from){if(n)return null;if(u.type==Is.Text){let f=vZe(e,r,u,a,o);return new Ec(f,f==u.from?1:-1)}}if(u.type!=Is.Text)return c<(u.top+u.bottom)/2?new Ec(u.from,1):new Ec(u.to,-1);let d=e.docView.lineAt(u.from,2);return(!d||d.length!=u.length)&&(d=e.docView.lineAt(u.from,-2)),new kZe(e,a,o,e.textDirectionAt(u.from)).scanTile(d,u.from)}class kZe{constructor(t,n,i,r){this.view=t,this.x=n,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(a.has(b)){let O=r+Math.floor(Math.random()*g);for(let v=0;v1)){if(v.bottomthis.y)(!u||u.top>v.top)&&(u=v),x=-1;else{let w=v.left>this.x?this.x-v.left:v.right(g+g+b)/3)return this.y=c.bottom-1,this.scan(t,n,!0);if(u&&u.top<(g+b+b)/3)return this.y=u.top+1,this.scan(t,n,!0)}let p=(o?this.dirAt(t[d],1):this.baseDir)==Pi.LTR;return{i:d,after:this.x>(h.left+h.right)/2==p}}scanText(t,n){let i=[];for(let s=0;s{let a=i[s]-n,o=i[s+1]-n;return Qx(t.dom,a,o).getClientRects()});return r.after?new Ec(i[r.i+1],-1):new Ec(i[r.i],1)}scanTile(t,n){if(!t.length)return new Ec(n,1);if(t.children.length==1){let o=t.children[0];if(o.isText())return this.scanText(o,n);if(o.isComposite())return this.scanTile(o,n)}let i=[n];for(let o=0,c=n;o{let c=t.children[o];return c.flags&48?null:(c.dom.nodeType==1?c.dom:Qx(c.dom,0,c.length)).getClientRects()}),s=t.children[r.i],a=i[r.i];return s.isText()?this.scanText(s,a):s.isComposite()?this.scanTile(s,a):r.after?new Ec(i[r.i+1],-1):new Ec(a,1)}}const jm="￿";class TZe{constructor(t,n){this.points=t,this.view=n,this.text="",this.lineSeparator=n.state.facet(Bn.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=jm}readRange(t,n){if(!t)return this;let i=t.parentNode;for(let r=t;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let a=Er.get(r),o=r.nextSibling;if(o==n){a!=null&&a.breakAfter&&!o&&i!=this.view.contentDOM&&this.lineBreak();break}let c=Er.get(o);(a&&c?a.breakAfter:(a?a.breakAfter:aT(r))||aT(o)&&(r.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>s)&&!AZe(o,n)&&this.lineBreak(),r=o}return this.findPointBefore(i,n),this}readTextNode(t){let n=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,a=1,o;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(o=r.exec(n))&&(s=o.index,a=o[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),a>1)for(let c of this.points)c.node==t&&c.pos>this.text.length&&(c.pos-=a-1);i=s+a}}readNode(t){let n=Er.get(t),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,n){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(t,n){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(_Ze(t,i.node,i.offset)?n:0))}}function _Ze(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:s,impreciseAnchor:a}=t.docView,o=t.state.selection;if(t.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=sue(t.docView.tile,n,i,0))){let c=s||a?[]:jZe(t),u=new TZe(c,t);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=RZe(c,this.bounds.from)}else{let c=t.observer.selectionRange,u=s&&s.node==c.focusNode&&s.offset==c.focusOffset||!KM(t.contentDOM,c.focusNode)?o.main.head:t.docView.posFromDOM(c.focusNode,c.focusOffset),d=a&&a.node==c.anchorNode&&a.offset==c.anchorOffset||!KM(t.contentDOM,c.anchorNode)?o.main.anchor:t.docView.posFromDOM(c.anchorNode,c.anchorOffset),f=t.viewport;if((Ot.ios||Ot.chrome)&&u!=d&&Math.min(u,d)<=o.main.from&&Math.max(u,d)>=o.main.to&&(f.from>0||f.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(Qe.range(d,u));else if(t.lineWrapping&&d==u&&!(o.main.empty&&o.main.head==u)&&t.inputState.lastTouchTime>Date.now()-100){let h=t.coordsAtPos(u,-1),p=0;h&&(p=t.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=Qe.create([Qe.cursor(u,p)])}else this.newSel=Qe.single(d,u)}}}function sue(e,t,n,i){if(e.isComposite()){let r=-1,s=-1,a=-1,o=-1;for(let c=0,u=i,d=i;cn)return sue(f,t,n,u);if(h>=t&&r==-1&&(r=c,s=u),u>n&&f.dom.parentNode==e.dom){a=c,o=d;break}d=h,u=h+f.breakAfter}return{from:s,to:o<0?i+e.length:o,startDOM:(r?e.children[r-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:a=0?e.children[a].dom:null}}else return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function aue(e,t){let n,{newSel:i}=t,{state:r}=e,s=r.selection.main,a=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:c}=t.bounds,u=s.from,d=null;(a===8||Ot.android&&t.text.length=o&&s.to<=c&&(t.typeOver||f!=t.text)&&f.slice(0,s.from-o)==t.text.slice(0,s.from-o)&&f.slice(s.to-o)==t.text.slice(h=t.text.length-(f.length-(s.to-o)))?n={from:s.from,to:s.to,insert:ei.of(t.text.slice(s.from-o,h).split(jm))}:(p=oue(f,t.text,u-o,d))&&(Ot.chrome&&a==13&&p.toB==p.from+2&&t.text.slice(p.from,p.toB)==jm+jm&&p.toB--,n={from:o+p.from,to:o+p.toA,insert:ei.of(t.text.slice(p.from,p.toB).split(jm))})}else i&&(!e.hasFocus&&r.facet(Cu)||uT(i,s))&&(i=null);if(!n&&!i)return!1;if((Ot.mac||Ot.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=Qe.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:ei.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:r.toText(e.inputState.insertingText)}:Ot.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&e.lineWrapping&&(i&&(i=Qe.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:ei.of([" "])}),n)return g4(e,n,i,a);if(i&&!uT(i,s)){let o=!1,c="select";return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin=="select"&&(o=!0),c=e.inputState.lastSelectionOrigin,c=="select.pointer"&&(i=rue(r.facet(J1).map(u=>u(e)),i))),e.dispatch({selection:i,scrollIntoView:o,userEvent:c}),!0}else return!1}function g4(e,t,n,i=-1){if(Ot.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(Ot.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&e.state.sliceDoc(t.from,r.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&jg(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||i==8&&t.insert.lengthr.head)&&jg(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&jg(e.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a,o=()=>a||(a=CZe(e,t,n));return e.state.facet(qce).some(c=>c(e,t.from,t.to,s,o))||e.dispatch(o()),!0}function CZe(e,t,n){let i,r=e.state,s=r.selection.main,a=-1;if(t.from==t.to&&t.froms.to){let c=t.fromf(e)),u,c);t.from==d&&(a=d)}if(a>-1)i={changes:t,selection:Qe.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let c=s.fromt.to?r.sliceDoc(t.to,s.to):"";i=r.replaceSelection(e.state.toText(c+t.insert.sliceString(0,void 0,e.state.lineBreak)+u))}else{let c=r.changes(t),u=n&&n.main.to<=c.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let d=e.state.sliceDoc(t.from,t.to),f,h=n&&iue(e,n.main.head);if(h){let g=t.insert.length-(t.to-t.from);f={from:h.from,to:h.to-g}}else f=e.state.doc.lineAt(s.head);let p=s.to-t.to;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:c,range:u||g.map(c)};let b=g.to-p,y=b-d.length;if(e.state.sliceDoc(y,b)!=d||b>=f.from&&y<=f.to)return{range:g};let O=r.changes({from:y,to:b,insert:t.insert}),v=g.to-s.to;return{changes:O,range:u?Qe.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):g.map(O)}})}else i={changes:c,selection:u&&r.selection.replaceRange(u)}}let o="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,o+=".compose",e.inputState.compositionFirstChange&&(o+=".start",e.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function oue(e,t,n,i){let r=Math.min(e.length,t.length),s=0;for(;s0&&o>0&&e.charCodeAt(a-1)==t.charCodeAt(o-1);)a--,o--;if(i=="end"){let c=Math.max(0,s-Math.min(a,o));n-=a+c-s}if(a=a?s-n:0;s-=c,o=s+(o-a),a=s}else if(o=o?s-n:0;s-=c,a=s+(a-o),o=s}return{from:s,toA:a,toB:o}}function jZe(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new dV(n,i)),(r!=n||s!=i)&&t.push(new dV(r,s))),t}function RZe(e,t){if(e.length==0)return null;let n=e[0].pos,i=e.length==2?e[1].pos:n;return n>-1&&i>-1?Qe.single(n+t,i+t):null}function uT(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class IZe{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Ot.safari&&t.contentDOM.addEventListener("input",()=>null),Ot.gecko&&GZe(t.contentDOM.ownerDocument)}handleEvent(t){!zZe(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,n){let i=this.handlers[t];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(t){let n=MZe(t),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let a=!n[s].handlers.length,o=i[s];o&&a!=!o.handlers.length&&(r.removeEventListener(s,this.handleEvent),o=null),o||r.addEventListener(s,this.handleEvent,{passive:a})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&cue.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),Ot.android&&Ot.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(Ot.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(lue.some(n=>n.keyCode==t.keyCode)&&!t.ctrlKey||LZe.indexOf(t.key)>-1&&t.ctrlKey)){let n={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};return n.shiftKey&&Ot.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&PZe(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&t&&t.from0?!0:Ot.safari&&!Ot.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function PZe(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function fV(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(r){Qa(n.state,r)}}}function MZe(e){let t=Object.create(null);function n(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of e){let r=i.spec,s=r&&r.plugin.domEventHandlers,a=r&&r.plugin.domEventObservers;if(s)for(let o in s){let c=s[o];c&&n(o).handlers.push(fV(i.value,c))}if(a)for(let o in a){let c=a[o];c&&n(o).observers.push(fV(i.value,c))}}for(let i in Ul)n(i).handlers.push(Ul[i]);for(let i in va)n(i).observers.push(va[i]);return t}const lue=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],LZe="dthko",cue=[16,17,18,20,91,92,224,225],Gw=6;function Ww(e){return Math.max(0,e)*.7+8}function DZe(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}class $Ze{constructor(t,n,i,r){this.view=t,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=Rce(t.contentDOM),this.atoms=t.state.facet(J1).map(a=>a(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=t.state.facet(Bn.allowMultipleSelections)&&QZe(t,n),this.dragging=UZe(t,n)&&fue(n)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&DZe(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let n=0,i=0,r=0,s=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:o}=this.scrollParents.y.getBoundingClientRect());let c=m4(this.view);t.clientX-c.left<=r+Gw?n=-Ww(r-t.clientX):t.clientX+c.right>=a-Gw&&(n=Ww(t.clientX-a)),t.clientY-c.top<=s+Gw?i=-Ww(s-t.clientY):t.clientY+c.bottom>=o-Gw&&(i=Ww(t.clientY-o)),this.setScrollSpeed(n,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,n){this.scrollSpeed={x:t,y:n},t||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:n}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(t||n)&&this.view.win.scrollBy(t,n),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:n}=this,i=rue(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function QZe(e,t){let n=e.state.facet(zce);return n.length?n[0](t):Ot.mac?t.metaKey:t.ctrlKey}function BZe(e,t){let n=e.state.facet(Fce);return n.length?n[0](t):Ot.mac?!t.altKey:!t.ctrlKey}function UZe(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=Dx(e.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=t.clientX&&a.top<=t.clientY&&a.bottom>=t.clientY)return!0}return!1}function zZe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,i;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Er.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const Ul=Object.create(null),va=Object.create(null),uue=Ot.ie&&Ot.ie_version<15||Ot.ios&&Ot.webkit_version<604;function FZe(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),due(e,n.value)},50)}function LA(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function due(e,t){t=LA(e.state,d4,t);let{state:n}=e,i,r=1,s=n.toText(t),a=s.lines==n.selection.ranges.length;if(aL!=null&&n.selection.ranges.every(c=>c.empty)&&aL==s.toString()){let c=-1;i=n.changeByRange(u=>{let d=n.doc.lineAt(u.from);if(d.from==c)return{range:u};c=d.from;let f=n.toText((a?s.line(r++).text:t)+n.lineBreak);return{changes:{from:d.from,insert:f},range:Qe.cursor(u.from+f.length)}})}else a?i=n.changeByRange(c=>{let u=s.line(r++);return{changes:{from:c.from,to:c.to,insert:u.text},range:Qe.cursor(c.from+u.length)}}):i=n.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}va.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,Ot.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};va.wheel=va.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};Ul.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);va.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};va.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};va.touchend=(e,t)=>{e.inputState.touchActive=!1};Ul.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(Vce))if(n=i(e,t),n)break;if(!n&&t.button==0&&(n=XZe(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new $Ze(e,t,n,i)),i&&e.observer.ignore(()=>{Ice(e.contentDOM);let s=e.root.activeElement;s&&!s.contains(e.contentDOM)&&s.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),r.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function hV(e,t,n,i){if(i==1)return Qe.cursor(t,n);if(i==2)return xZe(e.state,t,n);{let r=e.docView.lineAt(t,n),s=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:s.from,o=r?r.posAtEnd:s.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(mV+1)%3:1}function XZe(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=fue(t),r=e.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,a,o){let c=e.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,d=hV(e,c.pos,c.assoc,i);if(n.pos!=c.pos&&!a){let f=hV(e,n.pos,n.assoc,i),h=Math.min(f.from,d.from),p=Math.max(f.to,d.to);d=h1&&(u=qZe(r,c.pos))?u:o?r.addRange(d):Qe.create([d])}}}function qZe(e,t){for(let n=0;n=t)return Qe.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}Ul.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let s=r.posAtStart,a=s+r.length;(s>=n.to||a<=n.from)&&(n=Qe.undirectionalRange(s,a))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",LA(e.state,f4,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Ul.dragend=e=>(e.inputState.draggedContent=null,!1);function bV(e,t,n,i){if(n=LA(e.state,d4,n),!n)return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,a=i&&s&&BZe(e,t)?{from:s.from,to:s.to}:null,o={from:r,insert:n},c=e.state.changes(a?[a,o]:o);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(r,-1),head:c.mapPos(r,1)},userEvent:a?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Ul.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&bV(e,t,i.filter(a=>a!=null).join(e.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(o.result)||(i[a]=o.result),s()},o.readAsText(n[a])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return bV(e,t,i,!0),!0}return!1};Ul.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=uue?null:t.clipboardData;return n?(due(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(FZe(e),!1)};function HZe(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}function YZe(e){let t=[],n=[],i=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let r=-1;for(let{from:s}of e.selection.ranges){let a=e.doc.lineAt(s);a.number>r&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),r=a.number}i=!0}return{text:LA(e,f4,t.join(e.lineBreak)),ranges:n,linewise:i}}let aL=null;Ul.copy=Ul.cut=(e,t)=>{if(!Ey(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=YZe(e.state);if(!n&&!r)return!1;aL=r?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=uue?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(HZe(e,n),!1)};const hue=Kc.define();function pue(e,t){let n=[];for(let i of e.facet(Hce)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:hue.of(!0)}):null}function mue(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=pue(e.state,t);n?e.dispatch(n):e.update([])}},10)}va.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),mue(e)};va.blur=e=>{e.observer.clearSelectionRange(),mue(e)};va.compositionstart=va.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange==null&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))};va.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Ot.chrome&&Ot.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};va.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};Ul.beforeinput=(e,t)=>{var n,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&e.observer.editContext){let s=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),a=t.getTargetRanges();if(s&&a.length){let o=a[0],c=e.posAtDOM(o.startContainer,o.startOffset),u=e.posAtDOM(o.endContainer,o.endOffset);return g4(e,{from:c,to:u,insert:e.state.toText(s)},null),!0}}let r;if(Ot.chrome&&Ot.android&&(r=lue.find(s=>s.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>s+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Ot.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),Ot.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>va.compositionend(e,t),20),!1};const OV=new Set;function GZe(e){OV.has(e)||(OV.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}const yV=["pre-wrap","normal","pre-line","break-spaces"];let v0=!1;function xV(){v0=!1}class WZe{constructor(t){this.lineWrapping=t,this.doc=ei.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return yV.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let n=!1;for(let i=0;i-1,c=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,c){this.heightSamples={};for(let u=0;u0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>pE&&(v0=!0),this.height=t)}replace(t,n,i){return ya.of(i)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,i,r){let s=this,a=i.doc;for(let o=r.length-1;o>=0;o--){let{fromA:c,toA:u,fromB:d,toB:f}=r[o],h=s.lineAt(c,Bi.ByPosNoHeight,i.setDoc(n),0,0),p=h.to>=u?h:s.lineAt(u,Bi.ByPosNoHeight,i,0,0);for(f+=p.to-u,u=p.to;o>0&&h.from<=r[o-1].toA;)c=r[o-1].fromA,d=r[o-1].fromB,o--,cs*2){let o=t[n-1];o.break?t.splice(--n,1,o.left,null,o.right):t.splice(--n,1,o.left,o.right),i+=1+o.break,r-=o.size}else if(s>r*2){let o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,s-=o.size}else break;else if(r=s&&a(this.lineAt(0,Bi.ByPos,i,r,s))}setMeasuredHeight(t){let n=t.heights[t.index++];n<0?(this.spaceAbove=-n,n=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(t,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class so extends gue{constructor(t,n,i){super(t,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,n){return new Cl(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,i){let r=i[0];return i.length==1&&(r instanceof so||r instanceof Ts&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ts?r=new so(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):ya.of(i)}updateHeight(t,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ts extends ya{constructor(t){super(t,0)}heightMetrics(t,n){let i=t.doc.lineAt(n).number,r=t.doc.lineAt(n+this.length).number,s=r-i+1,a,o=0;if(t.lineWrapping){let c=Math.min(this.height,t.lineHeight*s);a=c/s,this.length>s+1&&(o=(this.height-c)/(this.length-s-1))}else a=this.height/s;return{firstLine:i,lastLine:r,perLine:a,perChar:o}}blockAt(t,n,i,r){let{firstLine:s,lastLine:a,perLine:o,perChar:c}=this.heightMetrics(n,r);if(n.lineWrapping){let u=r+(t0){let s=i[i.length-1];s instanceof Ts?i[i.length-1]=new Ts(s.length+r):i.push(null,new Ts(r-1))}if(t>0){let s=i[0];s instanceof Ts?i[0]=new Ts(t+s.length):i.unshift(new Ts(t-1),null)}return ya.of(i)}decomposeLeft(t,n){n.push(new Ts(t-1),null)}decomposeRight(t,n){n.push(null,new Ts(this.length-t-1))}updateHeight(t,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let a=[],o=Math.max(n,r.from),c=-1;for(r.from>n&&a.push(new Ts(r.from-n-1).updateHeight(t,n));o<=s&&r.more;){let d=t.doc.lineAt(o).length;a.length&&a.push(null);let f=r.heights[r.index++],h=0;f<0&&(h=-f,f=r.heights[r.index++]),c==-1?c=f:Math.abs(f-c)>=pE&&(c=-2);let p=new so(d,f,h);p.outdated=!1,a.push(p),o+=d+1}o<=s&&a.push(null,new Ts(s-o).updateHeight(t,o));let u=ya.of(a);return(c<0||Math.abs(u.height-this.height)>=pE||Math.abs(c-this.heightMetrics(t,n).perLine)>=pE)&&(v0=!0),dT(this,u)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class JZe extends ya{constructor(t,n,i){super(t.length+n+i.length,t.height+i.height,n|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,n,i,r){let s=i+this.left.height;return to))return u;let d=n==Bi.ByPosNoHeight?Bi.ByPosNoHeight:Bi.ByPos;return c?u.join(this.right.lineAt(o,d,i,a,o)):this.left.lineAt(o,d,i,r,s).join(u)}forEachLine(t,n,i,r,s,a){let o=r+this.left.height,c=s+this.left.length+this.break;if(this.break)t=c&&this.right.forEachLine(t,n,i,o,c,a);else{let u=this.lineAt(c,Bi.ByPos,i,r,s);t=t&&u.from<=n&&a(u),n>u.to&&this.right.forEachLine(u.to+1,n,i,o,c,a)}}replace(t,n,i){let r=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(t-r,n-r,i));let s=[];t>0&&this.decomposeLeft(t,s);let a=s.length;for(let o of i)s.push(o);if(t>0&&vV(s,a-1),n=i&&n.push(null)),t>i&&this.right.decomposeLeft(t-i,n)}decomposeRight(t,n){let i=this.left.length,r=i+this.break;if(t>=r)return this.right.decomposeRight(t-r,n);t2*n.size||n.size>2*t.size?ya.of(this.break?[t,null,n]:[t,n]):(this.left=dT(this.left,t),this.right=dT(this.right,n),this.setHeight(t.height+n.height),this.outdated=t.outdated||n.outdated,this.size=t.size+n.size,this.length=t.length+this.break+n.length,this)}updateHeight(t,n=0,i=!1,r){let{left:s,right:a}=this,o=n+s.length+this.break,c=null;return r&&r.from<=n+s.length&&r.more?c=s=s.updateHeight(t,n,i,r):s.updateHeight(t,n,i),r&&r.from<=o+a.length&&r.more?c=a=a.updateHeight(t,o,i,r):a.updateHeight(t,o,i),c?this.balanced(s,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function vV(e,t){let n,i;e[t]==null&&(n=e[t-1])instanceof Ts&&(i=e[t+1])instanceof Ts&&e.splice(t-1,3,new Ts(n.length+1+i.length))}const eKe=5;class b4{constructor(t,n){this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof so?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new so(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(t,n,i){if(t=eKe)&&this.addLineDeco(r,s,a)}else n>t&&this.span(t,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=n,this.writtenTot&&this.nodes.push(new so(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let i=new Ts(n-t);return this.oracle.doc.lineAt(t).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof so)return t;let n=new so(0,-1,0);return this.nodes.push(n),n}addBlock(t){this.enterLine();let n=t.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,n&&n.endSide>0&&(this.covering=t)}addLineDeco(t,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,t),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(t){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof so)&&!this.isCovered?this.nodes.push(new so(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&f.overflow!="visible"){let h=d.getBoundingClientRect();s=Math.max(s,h.left),a=Math.min(a,h.right),o=Math.max(o,h.top),c=Math.min(u==e.parentNode?r.innerHeight:c,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?d.offsetParent:d.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,a)-n.left,top:o-(n.top+t),bottom:Math.max(o,c)-(n.top+t)}}function rKe(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function sKe(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class cj{constructor(t,n,i,r){this.from=t,this.to=n,this.size=i,this.displaySize=r}static same(t,n){if(t.length!=n.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new WZe(i),this.stateDeco=EV(n),this.heightMap=ya.empty().applyChanges(this.stateDeco,ei.empty,this.heightOracle.setDoc(n.doc),[new Yo(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=zt.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!t.some(({from:s,to:a})=>r>=s&&r<=a)){let{from:s,to:a}=this.lineBlockAt(r);t.push(new Zw(s,a))}}return this.viewports=t.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?SV:new O4(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(DO(t,this.scaler))})}update(t,n=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=EV(this.state);let r=t.changedRanges,s=Yo.extendWithRanges(r,tKe(i,this.stateDeco,t?t.changes:ns.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);xV(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=a||v0)&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(n&&(n.range.headc.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,n));let u=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(u||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Gce)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,n=t.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Pi.RTL:Pi.LTR;let a=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",o=n.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let u=0,d=0;if(o.width&&o.height){let{scaleX:E,scaleY:S}=jce(n,o);(E>.005&&Math.abs(this.scaleX-E)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=E,this.scaleY=S,u|=16,a=c=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(c=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=16);let p=Rce(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let g=this.getScrollOffset();this.scrollOffset!=g&&(this.scrollAnchorHeight=-1,this.scrollOffset=g),this.scrolledToBottom=Pce(this.scrollParent||t.win);let b=(this.printing?sKe:iKe)(n,this.paddingTop),y=b.top-this.pixelViewport.top,O=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(c=!0)),!this.inView&&!this.scrollTarget&&!rKe(t.dom))return 0;let x=o.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,u|=16),c){let E=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(E)&&(a=!0),a||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:k,textHeight:T}=t.docView.measureTextSize();a=S>0&&r.refresh(s,S,k,T,Math.max(5,x/k),E),a&&(t.docView.minWidth=0,u|=16)}y>0&&O>0?d=Math.max(y,O):y<0&&O<0&&(d=Math.min(y,O)),xV();for(let S of this.viewports){let k=S.from==this.viewport.from?E:t.docView.measureVisibleLineHeights(S);this.heightMap=(a?ya.empty().applyChanges(this.stateDeco,ei.empty,this.heightOracle,[new Yo(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new ZZe(S.from,k))}v0&&(u|=2)}let w=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return w&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),u|=this.updateForViewport()),(u&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,t)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,n){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,c=new Zw(r.lineAt(a-i*1e3,Bi.ByHeight,s,0,0).from,r.lineAt(o+(1-i)*1e3,Bi.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(uc.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(u,Bi.ByPos,s,0,0),h;n.y=="center"?h=(f.top+f.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&u=o+Math.max(10,Math.min(i,250)))&&r>a-2*1e3&&s>1,a=r<<1;if(this.defaultTextDirection!=Pi.LTR&&!i)return[];let o=[],c=(d,f,h,p)=>{if(f-dd&&OO.from>=h.from&&O.to<=h.to&&Math.abs(O.from-d)O.fromv));if(!y){if(fx.from<=f&&x.to>=f)){let x=n.moveToLineBoundary(Qe.cursor(f),!1,!0).head;x>d&&(f=x)}let O=this.gapSize(h,d,f,p),v=i||O<2e6?O:2e6;y=new cj(d,f,O,v)}o.push(y)},u=d=>{if(d.length2e6)for(let S of t)S.from>=d.from&&S.fromd.from&&c(d.from,p,d,f),gn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];jn.spans(n,this.viewport.from,this.viewport.to,{span(s,a){i.push({from:s,to:a})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(n=>n.from<=t&&n.to>=t)||DO(this.heightMap.lineAt(t,Bi.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=t&&n.bottom>=t)||DO(this.heightMap.lineAt(this.scaler.fromDOM(t),Bi.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let n=this.lineBlockAtHeight(t+8);return n.from>=this.viewport.from||this.viewportLines[0].top-t>200?n:this.viewportLines[0]}elementAtHeight(t){return DO(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Zw{constructor(t,n){this.from=t,this.to=n}}function oKe(e,t,n){let i=[],r=e,s=0;return jn.spans(n,e,t,{span(){},point(a,o){a>r&&(i.push({from:r,to:a}),s+=a-r),r=o}},20),r=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let r=0;;r++){let{from:s,to:a}=t[r],o=a-s;if(i<=o)return s+i;i-=o}}function Jw(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}function lKe(e,t){for(let n of e)if(t(n))return n}const SV={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function EV(e){let t=e.facet(IA).filter(i=>typeof i!="function"),n=e.facet(p4).filter(i=>typeof i!="function");return n.length&&t.push(jn.join(n)),t}class O4{constructor(t,n,i){let r=0,s=0,a=0;this.viewports=i.map(({from:o,to:c})=>{let u=n.lineAt(o,Bi.ByPos,t,0,0).top,d=n.lineAt(c,Bi.ByPos,t,0,0).bottom;return r+=d-u,{from:o,to:c,top:u,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let o of this.viewports)o.domTop=a+(o.top-s)*this.scale,a=o.domBottom=o.domTop+(o.bottom-o.top),s=o.bottom}toDOM(t){for(let n=0,i=0,r=0;;n++){let s=nn.from==t.viewports[i].from&&n.to==t.viewports[i].to):!1}}function DO(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new Cl(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(r=>DO(r,t)):e._content)}const eS=yt.define({combine:e=>e.join(" ")}),oL=yt.define({combine:e=>e.indexOf(!0)>-1}),lL=Vf.newName(),bue=Vf.newName(),Oue=Vf.newName(),yue={"&light":"."+bue,"&dark":"."+Oue};function cL(e,t,n){return new Vf(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return e;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):e+" "+i}})}const cKe=cL("."+lL,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},yue),uKe={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},uj=Ot.ie&&Ot.ie_version<=11;class dKe{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new BWe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(n=>{for(let i of n)this.queue.push(i);(Ot.ie&&Ot.ie_version<=11||Ot.ios&&t.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ot.android&&t.constructor.EDIT_CONTEXT!==!1&&!(Ot.chrome&&Ot.chrome_version<126)&&(this.editContext=new hKe(t),t.state.facet(Cu)&&(t.contentDOM.editContext=this.editContext.editContext)),uj&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((n,i)=>n!=t[i]))){this.gapIntersection.disconnect();for(let n of t)this.gapIntersection.observe(n);this.gaps=t}}onSelectionChange(t){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Cu)?i.root.activeElement!=this.dom:!Ey(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){n||(this.selectionChanged=!1);return}(Ot.ie&&Ot.ie_version<=11||Ot.android&&Ot.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Ty(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,n=Dx(t.root);if(!n)return!1;let i=Ot.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&fKe(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Ey(this.dom,i);return r&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&jg(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let n=-1,i=-1,r=!1;for(let s of t){let a=this.readMutation(s);a&&(a.typeOver&&(r=!0),n==-1?{from:n,to:i}=a:(n=Math.min(a.from,n),i=Math.max(a.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:t,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Ey(this.dom,this.selectionRange);if(t<0&&!r)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new NZe(this.view,t,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=aue(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!uT(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(t){let n=this.view.docView.tile.nearest(t.target);if(!n||n.isWidget())return null;if(n.markDirty(t.type=="attributes"),t.type=="childList"){let i=kV(n,t.previousSibling||t.target.previousSibling,-1),r=kV(n,t.nextSibling||t.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Cu)!=t.state.facet(Cu)&&(t.view.contentDOM.editContext=t.state.facet(Cu)?this.editContext.editContext:null))}destroy(){var t,n,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function kV(e,t,n){for(;t;){let i=Er.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function TV(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,s=t.endOffset,a=e.docView.domAtPos(e.state.selection.main.anchor,1);return Ty(a.node,a.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function fKe(e,t){if(t.getComposedRanges){let r=t.getComposedRanges(e.root)[0];if(r)return TV(e,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?TV(e,n):null}class hKe{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let n=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let r=t.state.selection.main,{anchor:s,head:a}=r,o=this.toEditorPos(i.updateRangeStart),c=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let u=c-o>i.text.length;o==this.from&&sthis.to&&(c=s);let d=oue(t.state.sliceDoc(o,c),i.text,(u?r.from:r.to)-o,u?"end":null);if(!d){let h=Qe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));uT(h,r)||t.dispatch({selection:h,userEvent:"select"});return}let f={from:d.from+o,to:d.toA+o,insert:ei.of(i.text.slice(d.from,d.toB).split(` +`))};if((Ot.mac||Ot.android)&&f.from==a-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:o,to:c,insert:ei.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);g4(t,f,Qe.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let a=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);a{let r=[];for(let s of i.getTextFormats()){let a=s.underlineStyle,o=s.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(o)){let c=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(c{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=Dx(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,i=!1,r=this.pendingContextChange;return t.changes.iterChanges((s,a,o,c,u)=>{if(i)return;let d=u.length-(a-s);if(r&&a>=r.to)if(r.from==s&&r.to==a&&r.insert.eq(u)){r=this.pendingContextChange=null,n+=d,this.to+=d;return}else r=null,this.revertPending(t.state);if(s+=n,a+=n,a<=this.from)this.from+=d,this.to+=d;else if(sthis.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),u.toString()),this.to+=d}n+=d}),r&&!i&&this.revertPending(t.state),!i}update(t){let n=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class ft{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=t.root||UWe(t.parent)||document,this.viewState=new wV(this,t.state||Bn.create(t)),t.scrollTo&&t.scrollTo.is(Yw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ag).map(r=>new rj(r));for(let r of this.plugins)r.update(this);this.observer=new dKe(this),this.inputState=new IZe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new cV(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let n=t.length==1&&t[0]instanceof Xr?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let h of t){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,o=0,c=null;t.some(h=>h.annotation(hue))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,c=pue(s,a),c||(o=1));let u=this.observer.delayedAndroidKey,d=null;if(u?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Bn.phrases)!=this.state.facet(Bn.phrases))return this.setState(s);r=oT.create(this,s,t),r.flags|=o;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:p}=h.state.selection,{x:g,y:b}=this.state.facet(ft.cursorScrollMargin);f=new Rg(p.empty?p:Qe.cursor(p.head,p.head>p.anchor?-1:1),"nearest","nearest",b,g)}for(let p of h.effects)p.is(Yw)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=fT.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(LO)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(eS)!=r.state.facet(eS)&&(this.viewState.mustMeasureContent=!0),(n||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(nL))try{h(r)}catch(p){Qa(this.state,p,"update listener")}(c||d)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),d&&!aue(this,d)&&u.force&&jg(this.contentDOM,u.key,u.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new wV(this,t),this.plugins=t.facet(ag).map(i=>new rj(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new cV(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(ag),i=t.state.facet(ag);if(n!=i){let r=[];for(let s of i){let a=n.indexOf(s);if(a<0)r.push(new rj(s));else{let o=this.plugins[a];o.mustUpdate=t,r.push(o)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=t;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(Pce(i||this.win))s=-1,a=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,a=p.top}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];c&4||([this.measureRequests,u]=[u,this.measureRequests]);let d=u.map(p=>{try{return p.read(this)}catch(g){return Qa(this.state,g),_V}}),f=oT.create(this,this.state,[]),h=!1;f.flags|=c,n?n.flags|=c:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let p=0;p1||g<-1)&&!(Ot.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+g,i?i.scrollTop+=g:this.win.scrollBy(0,g),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let o of this.state.facet(nL))o(n)}get themeClasses(){return lL+" "+(this.state.facet(oL)?Oue:bue)+" "+this.state.facet(eS)}updateAttrs(){let t=AV(this,Kce,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Cu)?"true":"false",class:"cm-content",style:`${Ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),AV(this,h4,n);let i=this.observer.ignore(()=>{let r=iV(this.contentDOM,this.contentAttrs,n),s=iV(this.dom,this.editorAttrs,t);return r||s});return this.editorAttrs=t,this.contentAttrs=n,i}showAnnouncements(t){let n=!0;for(let i of t)for(let r of i.effects)if(r.is(ft.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(LO);let t=this.state.facet(ft.cspNonce);Vf.mount(this.root,this.styleModules.concat(cKe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;ni.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,i){return lj(this,t,uV(this,t,n,i))}moveByGroup(t,n){return lj(this,t,uV(this,t,n,i=>SZe(this,t.head,i)))}visualLineSide(t,n){let i=this.bidiSpans(t),r=this.textDirectionAt(t.from),s=i[n?i.length-1:0];return Qe.cursor(s.side(n,r)+t.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(t,n,i=!0){return wZe(this,t,n,i)}moveVertically(t,n,i){return lj(this,t,EZe(this,t,n,i))}domAtPos(t,n=1){return this.docView.domAtPos(t,n)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){this.readMeasured();let i=sL(this,t,n);return i&&i.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),sL(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let i=this.state.doc.lineAt(t),r=this.bidiSpans(i),s=r[jc.find(r,t-i.from,-1,n)];return this.docView.coordsAt(t,n,s.dir==Pi.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Yce)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>pKe)return Bce(t.length);let n=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||Qce(s.isolates,i=aV(this,t))))return s.order;i||(i=aV(this,t));let r=GWe(t.text,n,i);return this.bidiCache.push(new fT(t.from,t.to,n,i,!0,r)),r}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Ot.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ice(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){var i,r,s,a;return Yw.of(new Rg(typeof t=="number"?Qe.cursor(t):t,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(a=n.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Yw.of(new Rg(Qe.cursor(i.from),"start","start",i.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Tr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Tr.define(()=>({}),{eventObservers:t})}static theme(t,n){let i=Vf.newName(),r=[eS.of(i),LO.of(cL(`.${i}`,t))];return n&&n.dark&&r.push(oL.of(!0)),r}static baseTheme(t){return vd.lowest(LO.of(cL("."+lL,t,yue)))}static findFromDOM(t){var n;let i=t.querySelector(".cm-content"),r=i&&Er.get(i)||Er.get(t);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}ft.styleModule=LO;ft.inputHandler=qce;ft.clipboardInputFilter=d4;ft.clipboardOutputFilter=f4;ft.scrollHandler=Wce;ft.focusChangeEffect=Hce;ft.perLineTextDirection=Yce;ft.exceptionSink=Xce;ft.updateListener=nL;ft.editable=Cu;ft.mouseSelectionStyle=Vce;ft.dragMovesSelection=Fce;ft.clickAddsSelectionRange=zce;ft.decorations=IA;ft.blockWrappers=Jce;ft.outerDecorations=p4;ft.atomicRanges=J1;ft.bidiIsolatedRanges=eue;ft.cursorScrollMargin=yt.define({combine:e=>{let t=5,n=5;for(let i of e)typeof i=="number"?t=n=i:{x:t,y:n}=i;return{x:t,y:n}}});ft.scrollMargins=tue;ft.darkTheme=oL;ft.cspNonce=yt.define({combine:e=>e.length?e[0]:""});ft.contentAttributes=h4;ft.editorAttributes=Kce;ft.lineWrapping=ft.contentAttributes.of({class:"cm-lineWrapping"});ft.announce=rn.define();const pKe=4096,_V={};class fT{constructor(t,n,i,r,s,a){this.from=t,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=a}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let i=[],r=t.length?t[t.length-1].dir:Pi.LTR;for(let s=Math.max(0,t.length-10);s=0;r--){let s=i[r],a=typeof s=="function"?s(e):s;a&&l4(a,n)}return n}const mKe=Ot.mac?"mac":Ot.windows?"win":Ot.linux?"linux":"key";function gKe(e,t){const n=e.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,a,o;for(let c=0;ci.concat(r),[]))),n}function OKe(e,t,n){return vue(xue(e.state),t,e,n)}let ef=null;const yKe=4e3;function xKe(e,t=mKe){let n=Object.create(null),i=Object.create(null),r=(a,o)=>{let c=i[a];if(c==null)i[a]=o;else if(c!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,o,c,u,d)=>{var f,h;let p=n[a]||(n[a]=Object.create(null)),g=o.split(/ (?!$)/).map(O=>gKe(O,t));for(let O=1;O{let w=ef={view:x,prefix:v,scope:a};return setTimeout(()=>{ef==w&&(ef=null)},yKe),!0}]})}let b=g.join(" ");r(b,!1);let y=p[b]||(p[b]={preventDefault:!1,stopPropagation:!1,run:((h=(f=p._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});c&&y.run.push(c),u&&(y.preventDefault=!0),d&&(y.stopPropagation=!0)};for(let a of e){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let u of o){let d=n[u]||(n[u]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=a;for(let h in d)d[h].run.push(p=>f(p,uL))}let c=a[t]||a.key;if(c)for(let u of o)s(u,c,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(u,"Shift-"+c,a.shift,a.preventDefault,a.stopPropagation)}return n}let uL=null;function vue(e,t,n,i){uL=t;let r=PWe(t),s=Pa(r,0),a=Sc(s)==r.length&&r!=" ",o="",c=!1,u=!1,d=!1;ef&&ef.view==n&&ef.scope==i&&(o=ef.prefix+" ",cue.indexOf(t.keyCode)<0&&(u=!0,ef=null));let f=new Set,h=y=>{if(y){for(let O of y.run)if(!f.has(O)&&(f.add(O),O(n)))return y.stopPropagation&&(d=!0),!0;y.preventDefault&&(y.stopPropagation&&(d=!0),u=!0)}return!1},p=e[i],g,b;return p&&(h(p[o+tS(r,t,!a)])?c=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Ot.windows&&t.ctrlKey&&t.altKey)&&!(Ot.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(g=Xf[t.keyCode])&&g!=r?(h(p[o+tS(g,t,!0)])||t.shiftKey&&(b=Mx[t.keyCode])!=r&&b!=g&&h(p[o+tS(b,t,!1)]))&&(c=!0):a&&t.shiftKey&&h(p[o+tS(r,t,!0)])&&(c=!0),!c&&h(p._any)&&(c=!0)),u&&(c=!0),c&&d&&t.stopPropagation(),uL=null,c}class lp{constructor(t,n,i,r,s){this.className=t,this.left=n,this.top=i,this.width=r,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,i){if(i.empty){let r=t.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=wue(t);return[new lp(n,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return vKe(t,n,i)}}function wue(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Pi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function CV(e,t,n,i){let r=e.coordsAtPos(t,n*2);if(!r)return i;let s=e.dom.getBoundingClientRect(),a=(r.top+r.bottom)/2,o=e.posAtCoords({x:s.left+1,y:a}),c=e.posAtCoords({x:s.right-1,y:a});return o==null||c==null?i:{from:Math.max(i.from,Math.min(o,c)),to:Math.min(i.to,Math.max(o,c))}}function vKe(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),s=e.textDirection==Pi.LTR,a=e.contentDOM,o=a.getBoundingClientRect(),c=wue(e),u=a.querySelector(".cm-line"),d=u&&window.getComputedStyle(u),f=o.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),h=o.right-(d?parseInt(d.paddingRight):0),p=rL(e,i,1),g=rL(e,r,-1),b=p.type==Is.Text?p:null,y=g.type==Is.Text?g:null;if(b&&(e.lineWrapping||p.widgetLineBreaks)&&(b=CV(e,i,1,b)),y&&(e.lineWrapping||g.widgetLineBreaks)&&(y=CV(e,r,-1,y)),b&&y&&b.from==y.from&&b.to==y.to)return v(x(n.from,n.to,b));{let E=b?x(n.from,null,b):w(p,!1),S=y?x(null,n.to,y):w(g,!0),k=[];return(b||p).to<(y||g).from-(b&&y?1:0)||p.widgetLineBreaks>1&&E.bottom+e.defaultLineHeight/2M&&P.from=j)break;I>Q&&C(Math.max(B,Q),E==null&&B<=M,Math.min(I,j),S==null&&I>=L,U.dir)}if(Q=$.to+1,Q>=j)break}return N.length==0&&C(M,E==null,L,S==null,e.textDirection),{top:T,bottom:A,horizontal:N}}function w(E,S){let k=o.top+(S?E.top:E.bottom);return{top:k,bottom:k,horizontal:[]}}}function wKe(e,t){return e.constructor==t.constructor&&e.eq(t)}class SKe{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(mE)!=t.state.facet(mE)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,i=t.facet(mE);for(;n!wKe(n,this.drawn[i]))){let n=this.dom.firstChild,i=0;for(let r of t)r.update&&n&&r.constructor&&this.drawn[i].constructor&&r.update(n,this.drawn[i])?(n=n.nextSibling,i++):this.dom.insertBefore(r.draw(),n);for(;n;){let r=n.nextSibling;n.remove(),n=r}this.drawn=t,Ot.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const mE=yt.define();function Sue(e){return[Tr.define(t=>new SKe(t,e)),mE.of(e)]}const w0=yt.define({combine(e){return Jc(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function EKe(e={}){return[w0.of(e),kKe,TKe,_Ke,Gce.of(!0)]}function Eue(e){return e.startState.facet(w0)!=e.state.facet(w0)}const kKe=Sue({above:!0,markers(e){let{state:t}=e,n=t.facet(w0),i=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||n.drawRangeCursor&&!(s&&Ot.ios&&n.iosSelectionHandles)){let a=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=r.empty?r:Qe.cursor(r.head,r.assoc);for(let c of lp.forRange(e,a,o))i.push(c)}}return i},update(e,t){e.transactions.some(i=>i.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Eue(e);return n&&jV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){jV(t.state,e)},class:"cm-cursorLayer"});function jV(e,t){t.style.animationDuration=e.facet(w0).cursorBlinkRate+"ms"}const TKe=Sue({above:!1,markers(e){let t=[],{main:n,ranges:i}=e.state.selection;for(let r of i)if(!r.empty)for(let s of lp.forRange(e,"cm-selectionBackground",r))t.push(s);if(Ot.ios&&!n.empty&&e.state.facet(w0).iosSelectionHandles){for(let r of lp.forRange(e,"cm-selectionHandle cm-selectionHandle-start",Qe.cursor(n.from,1)))t.push(r);for(let r of lp.forRange(e,"cm-selectionHandle cm-selectionHandle-end",Qe.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Eue(e)},class:"cm-selectionLayer"}),_Ke=vd.highest(ft.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),kue=rn.define({map(e,t){return e==null?null:t.mapPos(e)}}),$O=Ms.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,i)=>i.is(kue)?i.value:n,e)}}),AKe=Tr.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field($O);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field($O)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field($O),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field($O)!=e&&this.view.dispatch({effects:kue.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function NKe(){return[$O,AKe]}function RV(e,t,n,i,r){t.lastIndex=0;for(let s=e.iterRange(n,i),a=n,o;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)r(a+o.index,o)}function CKe(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class jKe{constructor(t){const{regexp:n,decoration:i,decorate:r,boundary:s,maxLength:a=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,r)this.addMatch=(o,c,u,d)=>r(d,u,u+o[0].length,o,c);else if(typeof i=="function")this.addMatch=(o,c,u,d)=>{let f=i(o,c,u);f&&d(u,u+o[0].length,f)};else if(i)this.addMatch=(o,c,u,d)=>d(u,u+o[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let n=new od,i=n.add.bind(n);for(let{from:r,to:s}of CKe(t,this.maxLength))RV(t.state.doc,this.regexp,r,s,(a,o)=>this.addMatch(o,t,a,i));return n.finish()}updateDeco(t,n){let i=1e9,r=-1;return t.docChanged&&t.changes.iterChanges((s,a,o,c)=>{c>=t.view.viewport.from&&o<=t.view.viewport.to&&(i=Math.min(o,i),r=Math.max(c,r))}),t.viewportMoved||r-i>1e3?this.createDeco(t.view):r>-1?this.updateRange(t.view,n.map(t.changes),i,r):n}updateRange(t,n,i,r){for(let s of t.visibleRanges){let a=Math.max(s.from,i),o=Math.min(s.to,r);if(o>=a){let c=t.state.doc.lineAt(a),u=c.toc.from;a--)if(this.boundary.test(c.text[a-1-c.from])){d=a;break}for(;oh.push(O.range(b,y));if(c==u)for(this.regexp.lastIndex=d-c.from;(p=this.regexp.exec(c.text))&&p.indexthis.addMatch(y,t,b,g));n=n.update({filterFrom:d,filterTo:f,filter:(b,y)=>bf,add:h})}}return n}}const dL=/x/.unicode!=null?"gu":"g",RKe=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,dL),IKe={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let dj=null;function PKe(){var e;if(dj==null&&typeof document<"u"&&document.body){let t=document.body.style;dj=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return dj||!1}const gE=yt.define({combine(e){let t=Jc(e,{render:null,specialChars:RKe,addSpecialChars:null});return(t.replaceTabs=!PKe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,dL)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,dL)),t}});function MKe(e={}){return[gE.of(e),LKe()]}let IV=null;function LKe(){return IV||(IV=Tr.fromClass(class{constructor(e){this.view=e,this.decorations=zt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(gE)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new jKe({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:r}=n.state,s=Pa(t[0],0);if(s==9){let a=r.lineAt(i),o=n.state.tabSize,c=Bl(a.text,o,i-a.from);return zt.replace({widget:new BKe((o-c%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=zt.replace({widget:new QKe(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(gE);e.startState.facet(gE)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const DKe="•";function $Ke(e){return e>=32?DKe:e==10?"␤":String.fromCharCode(9216+e)}class QKe extends Yl{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=$Ke(this.code),i=t.state.phrase("Control character")+" "+(IKe[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class BKe extends Yl{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function UKe(){return FKe}const zKe=zt.line({class:"cm-activeLine"}),FKe=Tr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let r=e.lineBlockAt(i.head);r.from>t&&(n.push(zKe.range(r.from)),t=r.from)}return zt.set(n)}},{decorations:e=>e.decorations});class VKe extends Yl{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?ky(t.firstChild):[];if(!n.length)return null;let i=window.getComputedStyle(t.parentNode),r=$x(n[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function XKe(e){let t=Tr.fromClass(class{constructor(n){this.view=n,this.placeholder=e?zt.set([zt.widget({widget:new VKe(e),side:1}).range(0)]):zt.none}get decorations(){return this.view.state.doc.length?zt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,ft.contentAttributes.of({"aria-placeholder":e})]:t}const fL=2e3;function qKe(e,t,n){let i=Math.min(t.line,n.line),r=Math.max(t.line,n.line),s=[];if(t.off>fL||n.off>fL||t.col<0||n.col<0){let a=Math.min(t.off,n.off),o=Math.max(t.off,n.off);for(let c=i;c<=r;c++){let u=e.doc.line(c);u.length<=o&&s.push(Qe.range(u.from+a,u.to+o))}}else{let a=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let c=i;c<=r;c++){let u=e.doc.line(c),d=XM(u.text,a,e.tabSize,!0);if(d<0)s.push(Qe.cursor(u.to));else{let f=XM(u.text,o,e.tabSize);s.push(Qe.range(u.from+d,u.from+f))}}}return s}function HKe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function PV(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),i=e.state.doc.lineAt(n),r=n-i.from,s=r>fL?-1:r==i.length?HKe(e,t.clientX):Bl(i.text,e.state.tabSize,n-i.from);return{line:i.number,col:s,off:r}}function YKe(e,t){let n=PV(e,t),i=e.state.selection;return n?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(n.line).from),a=r.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},i=i.map(r.changes)}},get(r,s,a){let o=PV(e,r);if(!o)return i;let c=qKe(e.state,n,o);return c.length?a?Qe.create(c.concat(i.ranges)):Qe.create(c):i}}:null}function GKe(e){let t=n=>n.altKey&&n.button==0;return ft.mouseSelectionStyle.of((n,i)=>t(i)?YKe(n,i):null)}const WKe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},ZKe={style:"cursor: crosshair"};function KKe(e={}){let[t,n]=WKe[e.key||"Alt"],i=Tr.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==t||n(r))},keyup(r){(r.keyCode==t||!n(r))&&this.set(!1)},mousemove(r){this.set(n(r))}}});return[i,ft.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?ZKe:null})]}const nS="-10000px";class Tue{constructor(t,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=t.state.facet(n),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=i(a,s))}update(t,n){var i;let r=t.state.facet(this.facet),s=r.filter(c=>c);if(r===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],o=n?[]:null;for(let c=0;cn[u]=c),n.length=o.length),this.input=r,this.tooltips=s,this.tooltipViews=a,!0}}function JKe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const fj=yt.define({combine:e=>{var t,n,i;return{position:Ot.ios?"absolute":((t=e.find(r=>r.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=e.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||JKe}}}),MV=new WeakMap,y4=Tr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(fj);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Tue(e,x4,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(fj);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=nS,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(e=i.destroy)===null||e===void 0||e.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ot.safari){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=m4(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(fj).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=e,a=[];for(let o=0;o=Math.min(n.bottom,i.bottom)||f.rightMath.min(n.right,i.right)+.1)){d.style.top=nS;continue}let p=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,b=h.right-h.left,y=(t=MV.get(u))!==null&&t!==void 0?t:h.bottom-h.top,O=u.offset||tJe,v=this.view.textDirection==Pi.LTR,x=h.width>i.right-i.left?v?i.left:i.right-h.width:v?Math.max(i.left,Math.min(f.left-(p?14:0)+O.x,i.right-b)):Math.min(Math.max(i.left,f.left-b+(p?14:0)-O.x),i.right-b),w=this.above[o];!c.strictSide&&(w?f.top-y-g-O.yi.bottom)&&w==i.bottom-f.bottom>f.top-i.top&&(w=this.above[o]=!w);let E=(w?f.top-i.top:i.bottom-f.bottom)-g;if(Ex&&T.topS&&(S=w?T.top-y-2-g:T.bottom+g+2);if(this.position=="absolute"?(d.style.top=(S-e.parent.top)/s+"px",LV(d,(x-e.parent.left)/r)):(d.style.top=S/s+"px",LV(d,x/r)),p){let T=f.left+(v?O.x:-O.x)-(x+14-7);p.style.left=T/r+"px"}u.overlap!==!0&&a.push({left:x,top:S,right:k,bottom:S+y}),d.classList.toggle("cm-tooltip-above",w),d.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=nS}},{eventObservers:{scroll(){this.maybeMeasure()}}});function LV(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const eJe=ft.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),tJe={x:0,y:0},x4=yt.define({enables:[y4,eJe]}),hT=yt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class DA{static create(t){return new DA(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tue(t,hT,(n,i)=>this.createHostedView(n,i),n=>n.dom.remove())}createHostedView(t,n){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let i of this.manager.tooltipViews){let r=i[t];if(r!==void 0){if(n===void 0)n=r;else if(n!==r)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const nJe=x4.compute([hT],e=>{let t=e.facet(hT);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var i;return(i=n.end)!==null&&i!==void 0?i:n.pos})),create:DA.create,above:t[0].above,arrow:t.some(n=>n.arrow)}}),_ue=yt.define();class iJe{constructor(t,n,i,r,s,a){this.view=t,this.source=n,this.field=i,this.locked=r,this.setHover=s,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;ta.bottom||n.xa.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=o&&o.dir==Pi.RTL?-1:1;s=n.x{if(o&&!(Array.isArray(o)&&!o.length)){let c=Array.isArray(o)?o:[o];r&&this.locked.set(c,r),t.dispatch({effects:this.setHover.of(c)})}};if(s&&"then"in s){let o=this.pending={pos:n};s.then(c=>{this.pending==o&&(this.pending=null,a(c))},c=>Qa(t.state,c,"hover tooltip"))}else a(s)}get tooltip(){let t=this.view.plugin(y4),n=t?t.manager.tooltips.findIndex(i=>i.create==DA.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!rJe(s.dom,t)||this.pending){let{pos:a}=r[0]||this.pending,o=(i=(n=r[0])===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!sJe(this.view,a,o,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=i=>{t.removeEventListener("mouseleave",n);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const iS=4;function rJe(e,t){let{left:n,right:i,top:r,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();r=Math.min(o.top,r),s=Math.max(o.bottom,s)}return t.clientX>=n-iS&&t.clientX<=i+iS&&t.clientY>=r-iS&&t.clientY<=s+iS}function sJe(e,t,n,i,r,s){let a=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>i||a.rightr||Math.min(a.bottom,o)=t&&c<=n}function aJe(e,t={}){let n=rn.define(),i=new WeakMap,r=Ms.define({create(){return[]},update(a,o){let c=i.get(a);if(a.length&&(t.hideOnChange&&(o.docChanged||o.selection)?a=[]:c&&c(o)?a=[]:t.hideOn&&(a=a.filter(u=>!t.hideOn(o,u)))),o.docChanged&&a.length){let u=[];for(let d of a){let f=o.changes.mapPos(d.pos,-1,Cs.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),d);h.pos=f,h.end!=null&&(h.end=o.changes.mapPos(h.end)),u.push(h)}}a=u}for(let u of o.effects)u.is(n)&&(a=u.value,c=void 0),(u.is(lJe)&&!u.value||u.value==r)&&(a=[]);return a.length&&c&&i.set(a,c),a},provide:a=>hT.from(a)});const s=Tr.define(a=>new iJe(a,e,r,i,n,t.hoverTime||300));return{active:r,extension:[r,s,_ue.of(s),nJe]}}function oJe(e,t,n,i={}){var r;let s=e.state.facet(_ue).map(a=>e.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=s.find(o=>o.field==i.tooltip.active);a&&(s=[a])}for(let a of s)a.activateHover(e,t,n,(r=i.until)!==null&&r!==void 0?r:()=>!1)}function Aue(e,t){let n=e.plugin(y4);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const lJe=rn.define(),DV=yt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function v4(e,t){let n=e.plugin(Nue),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const Nue=Tr.fromClass(class{constructor(e){this.input=e.state.facet(Bx),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(DV);this.top=new rS(e,!0,t.topContainer),this.bottom=new rS(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(DV);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new rS(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new rS(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Bx);if(n!=this.input){let i=n.filter(c=>c),r=[],s=[],a=[],o=[];for(let c of i){let u=this.specs.indexOf(c),d;u<0?(d=c(e.view),o.push(d)):(d=this.panels[u],d.update&&d.update(e)),r.push(d),(d.top?s:a).push(d)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(a);for(let c of o)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let i of this.panels)i.update&&i.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ft.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class rS{constructor(t,n,i){this.view=t,this.top=n,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=$V(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=$V(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function $V(e){let t=e.nextSibling;return e.remove(),t}const Bx=yt.define({enables:Nue});function cJe(e,t){let n,i=new Promise(a=>n=a),r=a=>uJe(a,t,n);e.state.field(hj,!1)?e.dispatch({effects:Cue.of(r)}):e.dispatch({effects:rn.appendConfig.of(hj.init(()=>[r]))});let s=jue.of(r);return{close:s,result:i.then(a=>((e.win.queueMicrotask||(c=>e.win.setTimeout(c,10)))(()=>{e.state.field(hj).indexOf(r)>-1&&e.dispatch({effects:s})}),a))}}const hj=Ms.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(Cue)?e=[n.value].concat(e):n.is(jue)&&(e=e.filter(i=>i!=n.value));return e},provide:e=>Bx.computeN([e],t=>t.field(e))}),Cue=rn.define(),jue=rn.define();function uJe(e,t,n){let i=t.content?t.content(e,()=>a(null)):null;if(!i){if(i=Ei("form"),t.input){let o=Ei("input",t.input);/^(text|password|number|email|tel|url)$/.test(o.type)&&o.classList.add("cm-textfield"),o.name||(o.name="input"),i.appendChild(Ei("label",(t.label||"")+": ",o))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Ei("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let o=0;o{u.keyCode==27?(u.preventDefault(),a(null)):u.keyCode==13&&(u.preventDefault(),a(c))}),c.addEventListener("submit",u=>{u.preventDefault(),a(c)})}let s=Ei("div",i,Ei("button",{onclick:()=>a(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(s.className=t.class),s.classList.add("cm-dialog");function a(o){s.contains(s.ownerDocument.activeElement)&&e.focus(),n(o)}return{dom:s,top:t.top,mount:()=>{if(t.focus){let o;typeof t.focus=="string"?o=i.querySelector(t.focus):o=i.querySelector("input")||i.querySelector("button"),o&&"select"in o?o.select():o&&"focus"in o&&o.focus()}}}}class cd extends Ff{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}cd.prototype.elementClass="";cd.prototype.toDOM=void 0;cd.prototype.mapMode=Cs.TrackBefore;cd.prototype.startSide=cd.prototype.endSide=-1;cd.prototype.point=!0;const bE=yt.define(),dJe=yt.define(),fJe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>jn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Ay=yt.define();function hJe(e){return[Rue(),Ay.of({...fJe,...e})]}const QV=yt.define({combine:e=>e.some(t=>t)});function Rue(e){return[pJe]}const pJe=Tr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Ay).map(t=>new UV(e,t)),this.fixed=!e.state.facet(QV);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(QV)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=jn.iter(this.view.state.facet(bE),this.view.viewport.from),i=[],r=this.gutters.map(s=>new mJe(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let a=!0;for(let o of s.type)if(o.type==Is.Text&&a){hL(n,i,o.from);for(let c of r)c.line(this.view,o,i);a=!1}else if(o.widget)for(let c of r)c.widget(this.view,o)}else if(s.type==Is.Text){hL(n,i,s.from);for(let a of r)a.line(this.view,s,i)}else if(s.widget)for(let a of r)a.widget(this.view,s);for(let s of r)s.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Ay),n=e.state.facet(Ay),i=e.docChanged||e.heightChanged||e.viewportChanged||!jn.eq(e.startState.facet(bE),e.state.facet(bE),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let r of this.gutters)r.update(e)&&(i=!0);else{i=!0;let r=[];for(let s of n){let a=t.indexOf(s);a<0?r.push(new UV(this.view,s)):(this.gutters[a].update(e),r.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ft.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,r=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Pi.LTR?{left:i,right:r}:{right:i,left:r}})});function BV(e){return Array.isArray(e)?e:[e]}function hL(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class mJe{constructor(t,n,i){this.gutter=t,this.height=i,this.i=0,this.cursor=jn.iter(t.markers,n.from)}addElement(t,n,i){let{gutter:r}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==r.elements.length){let o=new Iue(t,a,s,i);r.elements.push(o),r.dom.appendChild(o.dom)}else r.elements[this.i].update(t,a,s,i);this.height=n.bottom,this.i++}line(t,n,i){let r=[];hL(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(t,n,r);s&&r.unshift(s);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(t,n,r)}widget(t,n){let i=this.gutter.config.widgetMarker(t,n.widget,n),r=i?[i]:null;for(let s of t.state.facet(dJe)){let a=s(t,n.widget,n);a&&(r||(r=[])).push(a)}r&&this.addElement(t,n,r)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class UV{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=r.clientY;let o=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[i](t,o,r)&&r.preventDefault()});this.markers=BV(n.markers(t)),n.initialSpacer&&(this.spacer=new Iue(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=BV(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],t);r!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[r])}let i=t.view.viewport;return!jn.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Iue{constructor(t,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,i,r)}update(t,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),gJe(this.markers,r)||this.setMarkers(t,r)}setMarkers(t,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,a=0;;){let o=a,c=ss(o,c,u)||a(o,c,u):a}return i}})}});class pj extends cd{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function mj(e,t){return e.state.facet(og).formatNumber(t,e.state)}const yJe=Ay.compute([og],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(bJe)},lineMarker(t,n,i){return i.some(r=>r.toDOM)?null:new pj(mj(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,i)=>{for(let r of t.state.facet(OJe)){let s=r(t,n,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(og)!=t.state.facet(og),initialSpacer(t){return new pj(mj(t,zV(t.state.doc.lines)))},updateSpacer(t,n){let i=mj(n.view,zV(n.view.state.doc.lines));return i==t.number?t:new pj(i)},domEventHandlers:e.facet(og).domEventHandlers,side:"before"}));function xJe(e={}){return[og.of(e),Rue(),yJe]}function zV(e){let t=9;for(;t{let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.head).from;r>n&&(n=r,t.push(vJe.range(r)))}return jn.of(t)});function SJe(){return wJe}var gj;const Xh=new sn;function w4(e){return yt.define({combine:e?t=>t.concat(e):void 0})}const S4=new sn;class Go{constructor(t,n,i=[],r=""){this.data=t,this.name=r,Bn.prototype.hasOwnProperty("tree")||Object.defineProperty(Bn.prototype,"tree",{get(){return _i(this)}}),this.parser=n,this.extension=[Hf.of(this),Bn.languageData.of((s,a,o)=>{let c=FV(s,a,o),u=c.type.prop(Xh);if(!u)return[];let d=s.facet(u),f=c.type.prop(S4);if(f){let h=c.resolve(a-c.from,o);for(let p of f)if(p.test(h,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(d)}}return d})].concat(i)}isActiveAt(t,n,i=-1){return FV(t,n,i).type.prop(Xh)==this.data}findRegions(t){let n=t.facet(Hf);if((n==null?void 0:n.data)==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,a)=>{if(s.prop(Xh)==this.data){i.push({from:a,to:a+s.length});return}let o=s.prop(sn.mounted);if(o){if(o.tree.prop(Xh)==this.data){if(o.overlay)for(let c of o.overlay)i.push({from:c.from+a,to:c.to+a});else i.push({from:a,to:a+s.length});return}else if(o.overlay){let c=i.length;if(r(o.tree,o.overlay[0].from+a),i.length>c)return}}for(let c=0;ci.isTop?n:void 0)]}),t.name)}configure(t,n){return new ud(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function _i(e){let t=e.field(Go.state,!1);return t?t.tree:li.empty}class EJe{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-i,n-i)}}let oO=null;class Ux{constructor(t,n,i=[],r,s,a,o,c){this.parser=t,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=a,this.skipped=o,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,n,i){return new Ux(t,n,[],li.empty,0,i,[],null)}startParse(){return this.parser.startParse(new EJe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=li.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let r=Date.now()+t;t=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Hu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=oO;oO=this;try{return t()}finally{oO=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=VV(t,n.from,n.to);return t}changes(t,n){let{fragments:i,tree:r,treeLen:s,viewport:a,skipped:o}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,d,f,h)=>c.push({fromA:u,toA:d,fromB:f,toB:h})),i=Hu.applyChanges(i,c),r=li.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){o=[];for(let u of this.skipped){let d=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);dt.from&&(this.fragments=VV(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends n4{createParse(n,i,r){let s=r[0].from,a=r[r.length-1].to;return{parsedPos:s,advance(){let c=oO;if(c){for(let u of r)c.tempSkipped.push(u);t&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,t]):t)}return this.parsedPos=a,new li(ss.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return oO}}function VV(e,t,n){return Hu.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class S0{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new S0(n)}static init(t){let n=Math.min(3e3,t.doc.length),i=Ux.create(t.facet(Hf).parser,t,{from:0,to:n});return i.work(20,n)||i.takeTree(),new S0(i)}}Go.state=Ms.define({create:S0.init,update(e,t){for(let n of t.effects)if(n.is(Go.setState))return n.value;return t.startState.facet(Hf)!=t.state.facet(Hf)?S0.init(t.state):e.apply(t)}});let Pue=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Pue=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const bj=typeof navigator<"u"&&(!((gj=navigator.scheduling)===null||gj===void 0)&&gj.isInputPending)?()=>navigator.scheduling.isInputPending():null,kJe=Tr.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(Go.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(Go.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Pue(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEndr+1e3,c=s.context.work(()=>bj&&bj()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Go.setState.of(new S0(s.context))})),this.chunkBudget>0&&!(c&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Qa(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Hf=yt.define({combine(e){return e.length?e[0]:null},enables:e=>[Go.state,kJe,ft.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Yf{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class pT{constructor(t,n,i,r,s,a=void 0){this.name=t,this.alias=n,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:i}=t;if(!n){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(i)}return new pT(t.name,(t.alias||[]).concat(t.name).map(r=>r.toLowerCase()),t.extensions||[],t.filename,n,i)}static matchFilename(t,n){for(let r of t)if(r.filename&&r.filename.test(n))return r;let i=/\.([^.]+)$/.exec(n);if(i){for(let r of t)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(t,n,i=!0){n=n.toLowerCase();for(let r of t)if(r.alias.some(s=>s==n))return r;if(i)for(let r of t)for(let s of r.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return r}return null}}const TJe=yt.define(),fb=yt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function mT(e){let t=e.facet(fb);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function zx(e,t){let n="",i=e.tabSize,r=e.facet(fb)[0];if(r==" "){for(;t>=i;)n+=" ",t-=i;r=" "}for(let s=0;s=t?_Je(e,n,t):null}class $A{constructor(t,n={}){this.state=t,this.options=n,this.unit=mT(t)}lineAt(t,n=1){let i=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==t?{text:"",from:t}:(n<0?r-1&&(s+=a-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,n=t.length){return Bl(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:i,from:r}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(r);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const rh=new sn;function _Je(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let a=r;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)i={node:s[a],next:i}}return Mue(i,e,n)}function Mue(e,t,n){for(let i=e;i;i=i.next){let r=NJe(i.node);if(r)return r(k4.create(t,n,i))}return 0}function AJe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function NJe(e){let t=e.type.prop(rh);if(t)return t;let n=e.firstChild,i;if(n&&(i=n.type.prop(sn.closedBy))){let r=e.lastChild,s=r&&i.indexOf(r.name)>-1;return a=>Lue(a,!0,1,void 0,s&&!AJe(a)?r.from:void 0)}return e.parent==null?CJe:null}function CJe(){return 0}class k4 extends $A{constructor(t,n,i){super(t.state,t.options),this.base=t,this.pos=n,this.context=i}get node(){return this.context.node}static create(t,n,i){return new k4(t,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(jJe(i,t))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return Mue(this.context.next,this.base,this.pos)}}function jJe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function RJe(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let o=n.to;;){let c=t.childAfter(o);if(!c||c==i)return null;if(!c.type.isSkipped){if(c.from>=a)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}o=c.to}}function Ig({closing:e,align:t=!0,units:n=1}){return i=>Lue(i,t,n,e)}function Lue(e,t,n,i,r){let s=e.textAfter,a=s.match(/^\s*/)[0].length,o=i&&s.slice(a,a+i.length)==i||r==e.pos+a,c=t?RJe(e):null;return c?o?e.column(c.from):e.column(c.to):e.baseIndent+(o?0:e.unit*n)}const IJe=e=>e.baseIndent;function Pg({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}const PJe=200;function MJe(){return Bn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+PJe)return e;let s=n.sliceString(r.from,i);if(!t.some(u=>u.test(s)))return e;let{state:a}=e,o=-1,c=[];for(let{head:u}of a.selection.ranges){let d=a.doc.lineAt(u);if(d.from==o)continue;o=d.from;let f=E4(a,d.from);if(f==null)continue;let h=/^\s*/.exec(d.text)[0],p=zx(a,f);h!=p&&c.push({from:d.from,to:d.from+h.length,insert:p})}return c.length?[e,{changes:c,sequential:!0}]:e})}const Due=yt.define(),wd=new sn;function ev(e){let t=e.firstChild,n=e.lastChild;return t&&t.ton)continue;if(s&&o.from=t&&u.to>n&&(s=u)}}return s}function DJe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function gT(e,t,n){for(let i of e.facet(Due)){let r=i(e,t,n);if(r)return r}return LJe(e,t,n)}function $ue(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const QA=rn.define({map:$ue}),tv=rn.define({map:$ue});function Que(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(i=>i.from<=n&&i.to>=n)||t.push(e.lineBlockAt(n));return t}const Ap=Ms.define({create(){return zt.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((i,r)=>e=XV(e,i,r)),e=e.map(t.changes);let n=[];for(let i of t.effects)i.is(QA)&&!$Je(e,i.value.from,i.value.to)?n.push(i.value):i.is(tv)&&(e=e.update({filter:(r,s)=>i.value.from!=r||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(n.length){let{preparePlaceholder:i}=t.state.facet(zue),r=n.map(s=>(i?zt.replace({widget:new XJe(i(t.state,s))}):qV).range(s.from,s.to));e=e.update({add:r})}return t.selection&&(e=XV(e,t.selection.main.head)),e},provide:e=>ft.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(i,r)=>{n.push(i,r)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n{rt&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(r,s)=>r>=n||s<=t}):e}function bT(e,t,n){var i;let r=null;return(i=e.field(Ap,!1))===null||i===void 0||i.between(t,n,(s,a)=>{(!r||r.from>s)&&(r={from:s,to:a})}),r}function $Je(e,t,n){let i=!1;return e.between(t,t,(r,s)=>{r==t&&s==n&&(i=!0)}),i}function Bue(e,t){return e.field(Ap,!1)?t:t.concat(rn.appendConfig.of(Fue()))}const QJe=e=>{for(let t of Que(e)){let n=gT(e.state,t.from,t.to);if(n)return e.dispatch({effects:Bue(e.state,[QA.of(n),Uue(e,n)])}),!0}return!1},BJe=e=>{if(!e.state.field(Ap,!1))return!1;let t=[];for(let n of Que(e)){let i=bT(e.state,n.from,n.to);i&&t.push(tv.of(i),Uue(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Uue(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return ft.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const UJe=e=>{let{state:t}=e,n=[];for(let i=0;i{let t=e.state.field(Ap,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(i,r)=>{n.push(tv.of({from:i,to:r}))}),e.dispatch({effects:n}),!0},FJe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:QJe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:BJe},{key:"Ctrl-Alt-[",run:UJe},{key:"Ctrl-Alt-]",run:zJe}],VJe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},zue=yt.define({combine(e){return Jc(e,VJe)}});function Fue(e){return[Ap,YJe]}function Vue(e,t){let{state:n}=e,i=n.facet(zue),r=a=>{let o=e.lineBlockAt(e.posAtDOM(a.target)),c=bT(e.state,o.from,o.to);c&&e.dispatch({effects:tv.of(c)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const qV=zt.replace({widget:new class extends Yl{toDOM(e){return Vue(e,null)}}});class XJe extends Yl{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Vue(t,this.value)}}const qJe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Oj extends cd{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function HJe(e={}){let t={...qJe,...e},n=new Oj(t,!0),i=new Oj(t,!1),r=Tr.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(Hf)!=a.state.facet(Hf)||a.startState.field(Ap,!1)!=a.state.field(Ap,!1)||_i(a.startState)!=_i(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new od;for(let c of a.viewportLineBlocks){let u=bT(a.state,c.from,c.to)?i:gT(a.state,c.from,c.to)?n:null;u&&o.add(c.from,c.from,u)}return o.finish()}}),{domEventHandlers:s}=t;return[r,hJe({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(r))===null||o===void 0?void 0:o.markers)||jn.empty},initialSpacer(){return new Oj(t,!1)},domEventHandlers:{...s,click:(a,o,c)=>{if(s.click&&s.click(a,o,c))return!0;let u=bT(a.state,o.from,o.to);if(u)return a.dispatch({effects:tv.of(u)}),!0;let d=gT(a.state,o.from,o.to);return d?(a.dispatch({effects:QA.of(d)}),!0):!1}}}),Fue()]}const YJe=ft.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class nv{constructor(t,n){this.specs=t;let i;function r(o){let c=Vf.newName();return(i||(i=Object.create(null)))["."+c]=o,c}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,a=n.scope;this.scope=a instanceof Go?o=>o.prop(Xh)==a.data:a?o=>o==a:void 0,this.style=oce(t.map(o=>({tag:o.tag,class:o.class||r(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=i?new Vf(i):null,this.themeType=n.themeType}static define(t,n){return new nv(t,n||{})}}const pL=yt.define(),Xue=yt.define({combine(e){return e.length?[e[0]]:null}});function yj(e){let t=e.facet(pL);return t.length?t:e.facet(Xue)}function que(e,t){let n=[WJe],i;return e instanceof nv&&(e.module&&n.push(ft.styleModule.of(e.module)),i=e.themeType),t!=null&&t.fallback?n.push(Xue.of(e)):i?n.push(pL.computeN([ft.darkTheme],r=>r.facet(ft.darkTheme)==(i=="dark")?[e]:[])):n.push(pL.of(e)),n}class GJe{constructor(t){this.markCache=Object.create(null),this.tree=_i(t.state),this.decorations=this.buildDeco(t,yj(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=_i(t.state),i=yj(t.state),r=i!=yj(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return zt.none;let i=new od;for(let{from:r,to:s}of t.visibleRanges)RGe(this.tree,n,(a,o,c)=>{i.add(a,o,this.markCache[c]||(this.markCache[c]=zt.mark({class:c})))},r,s);return i.finish()}}const WJe=vd.high(Tr.fromClass(GJe,{decorations:e=>e.decorations})),ZJe=nv.define([{tag:G.meta,color:"#404740"},{tag:G.link,textDecoration:"underline"},{tag:G.heading,textDecoration:"underline",fontWeight:"bold"},{tag:G.emphasis,fontStyle:"italic"},{tag:G.strong,fontWeight:"bold"},{tag:G.strikethrough,textDecoration:"line-through"},{tag:G.keyword,color:"#708"},{tag:[G.atom,G.bool,G.url,G.contentSeparator,G.labelName],color:"#219"},{tag:[G.literal,G.inserted],color:"#164"},{tag:[G.string,G.deleted],color:"#a11"},{tag:[G.regexp,G.escape,G.special(G.string)],color:"#e40"},{tag:G.definition(G.variableName),color:"#00f"},{tag:G.local(G.variableName),color:"#30a"},{tag:[G.typeName,G.namespace],color:"#085"},{tag:G.className,color:"#167"},{tag:[G.special(G.variableName),G.macroName],color:"#256"},{tag:G.definition(G.propertyName),color:"#00c"},{tag:G.comment,color:"#940"},{tag:G.invalid,color:"#f00"}]),KJe=ft.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Hue=1e4,Yue="()[]{}",Gue=yt.define({combine(e){return Jc(e,{afterCursor:!0,brackets:Yue,maxScanDistance:Hue,renderMatch:tet})}}),JJe=zt.mark({class:"cm-matchingBracket"}),eet=zt.mark({class:"cm-nonmatchingBracket"});function tet(e){let t=[],n=e.matched?JJe:eet;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function HV(e){let t=[],n=e.facet(Gue);for(let i of e.selection.ranges){if(!i.empty)continue;let r=Rc(e,i.head,-1,n)||i.head>0&&Rc(e,i.head-1,1,n)||n.afterCursor&&(Rc(e,i.head,1,n)||i.heade.decorations}),iet=[net,KJe];function ret(e={}){return[Gue.of(e),iet]}const Wue=new sn;function mL(e,t,n){let i=e.prop(t<0?sn.openedBy:sn.closedBy);if(i)return i;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function gL(e){let t=e.type.prop(Wue);return t?t(e.node):e}function Rc(e,t,n,i={}){let r=i.maxScanDistance||Hue,s=i.brackets||Yue,a=_i(e),o=a.resolveInner(t,n);for(let c=o;c;c=c.parent){let u=mL(c.type,n,s);if(u&&c.from0?t>=d.from&&td.from&&t<=d.to))return set(e,t,n,c,d,u,s)}}return aet(e,t,n,a,o.type,r,s)}function set(e,t,n,i,r,s,a){let o=i.parent,c={from:r.from,to:r.to},u=0,d=o==null?void 0:o.cursor();if(d&&(n<0?d.childBefore(i.from):d.childAfter(i.to)))do if(n<0?d.to<=i.from:d.from>=i.to){if(u==0&&s.indexOf(d.type.name)>-1&&d.from0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let h=0;!d.next().done&&h<=s;){let p=d.value;n<0&&(h+=p.length);let g=t+h*n;for(let b=n>0?0:p.length-1,y=n>0?p.length:-1;b!=y;b+=n){let O=a.indexOf(p[b]);if(!(O<0||i.resolveInner(g+b,1).type!=r))if(O%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:g+b,to:g+b+1},matched:O>>1==c>>1};f--}}n>0&&(h+=p.length)}return d.done?{start:u,matched:!1}:null}const oet=Object.create(null),YV=[ss.none],GV=[],WV=Object.create(null),cet=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])cet[e]=uet(oet,t);function xj(e,t){GV.indexOf(e)>-1||(GV.push(e),console.warn(t))}function uet(e,t){let n=[];for(let o of t.split(" ")){let c=[];for(let u of o.split(".")){let d=e[u]||G[u];d?typeof d=="function"?c.length?c=c.map(d):xj(u,`Modifier ${u} used at start of tag`):c.length?xj(u,`Tag ${u} used as modifier`):c=Array.isArray(d)?d:[d]:xj(u,`Unknown highlighting tag ${u}`)}for(let u of c)n.push(u)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map(o=>o.id),s=WV[r];if(s)return s.id;let a=WV[r]=ss.define({id:YV.length,name:i,props:[xd({[i]:n})]});return YV.push(a),a.id}Pi.RTL,Pi.LTR;class T4{constructor(t,n,i,r){this.state=t,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=_i(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Kue(t,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,i){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function ZV(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function det(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[n,i]=t.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:det(t);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:t,validFor:n}:null}}function Zue(e,t){return n=>{for(let i=_i(n.state).resolveInner(n.pos,-1);i;i=i.parent){if(e.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return t(n)}}class KV{constructor(t,n,i,r){this.completion=t,this.source=n,this.match=i,this.score=r}}function cp(e){return e.selection.main.from}function Kue(e,t){var n;let{source:i}=e,r=t&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?e:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const A4=Kc.define();function fet(e,t,n,i){let{main:r}=e.selection,s=n-r.from,a=i-r.from;return{...e.changeByRange(o=>{if(o!=r&&n!=i&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,i))return{range:o};let c=e.toText(t);return{changes:{from:o.from+s,to:i==r.from?o.to:o.from+a,insert:c},range:Qe.cursor(o.from+s+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const JV=new WeakMap;function het(e){if(!Array.isArray(e))return e;let t=JV.get(e);return t||JV.set(e,t=_4(e)),t}const OT=rn.define(),Fx=rn.define();class pet{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n=48&&E<=57||E>=97&&E<=122?2:E>=65&&E<=90?1:0:(S=i4(E))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!v||k==1&&y||w==0&&k!=0)&&(n[f]==E||i[f]==E&&(h=!0)?a[f++]=v:a.length&&(O=!1)),w=k,v+=Sc(E)}return f==c&&a[0]==0&&O?this.result(-100+(h?-200:0),a,t):p==c&&g==0?this.ret(-200-t.length+(b==t.length?0:-100),[0,b]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):p==c?this.ret(-900-t.length,[g,b]):f==c?this.result(-100+(h?-200:0)+-700+(O?0:-1100),a,t):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,t)}result(t,n,i){let r=[],s=0;for(let a of n){let o=a+(this.astral?Sc(Pa(i,a)):1);s&&r[s-1]==a?r[s-1]=o:(r[s++]=a,r[s++]=o)}return this.ret(t-i.length,r)}}class met{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:get,filterStrict:!1,compareCompletions:(t,n)=>(t.sortText||t.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>i=>eX(t(i),n(i)),optionClass:(t,n)=>i=>eX(t(i),n(i)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function eX(e,t){return e?t?e+" "+t:e:t}function get(e,t,n,i,r,s){let a=e.textDirection==Pi.RTL,o=a,c=!1,u="top",d,f,h=t.left-r.left,p=r.right-t.right,g=i.right-i.left,b=i.bottom-i.top;if(o&&h=b||v>t.top?d=n.bottom-t.top:(u="bottom",d=t.bottom-n.top)}let y=(t.bottom-t.top)/s.offsetHeight,O=(t.right-t.left)/s.offsetWidth;return{style:`${u}: ${d/y}px; max-width: ${f/O}px`,class:"cm-completionInfo-"+(c?a?"left-narrow":"right-narrow":o?"left":"right")}}const N4=rn.define();function bet(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(n,i,r,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,c=0;for(let u=0;uc&&a.appendChild(document.createTextNode(o.slice(c,d)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(d,f))),h.className="cm-completionMatchedText",c=f}return cn.position-i.position).map(n=>n.render)}function vj(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let r=Math.floor(t/n);return{from:r*n,to:(r+1)*n}}let i=Math.ceil((e-t)/n);return{from:e-i*n,to:e-(i-1)*n}}class Oet{constructor(t,n,i){this.view=t,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let r=t.state.field(n),{options:s,selected:a}=r.open,o=t.state.facet(gs);this.optionContent=bet(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=vj(s.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",c=>{let{options:u}=t.state.field(n).open;for(let d=c.target,f;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(f=/-(\d+)$/.exec(d.id))&&+f[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(t.dispatch({effects:N4.of(d)}),c.preventDefault())}}),this.dom.addEventListener("focusout",c=>{let u=t.state.field(this.stateField,!1);u&&u.tooltip&&t.state.facet(gs).closeOnBlur&&c.relatedTarget!=t.contentDOM&&t.dispatch({effects:Fx.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let i=t.state.field(this.stateField),r=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=r){let{options:s,selected:a,disabled:o}=i.open;(!r.open||r.open.options!=s)&&(this.range=vj(s.length,a,t.state.facet(gs).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),o!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;(n.selected>-1&&n.selected=this.range.to)&&(this.range=vj(n.options.length,n.selected,this.view.state.facet(gs).maxRenderedOptions),this.showOptions(n.options,t.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let a=typeof s=="string"?document.createTextNode(s):s(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Qa(this.view.state,o,"completion info")):(this.addInfoPane(a,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)i.appendChild(t),this.infoDestroy=null;else{let{dom:r,destroy:s}=t;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&xet(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=t.getBoundingClientRect(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom{a.target==r&&a.preventDefault()});let s=null;for(let a=i.from;ai.from||i.from==0))if(s=h,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let p=r.appendChild(document.createElement("completion-section"));p.textContent=h}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+a,d.setAttribute("role","option");let f=this.optionClass(o);f&&(d.className=f);for(let h of this.optionContent){let p=h(o,this.view.state,this.view,c);p&&d.appendChild(p)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew Oet(n,e,t)}function xet(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),r=n.height/e.offsetHeight;i.topn.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/r)}function tX(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function vet(e,t){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:f}=d.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(p=>p.name==h)||i.push(typeof f=="string"?{name:h}:f)}},a=t.facet(gs);for(let d of e)if(d.hasResult()){let f=d.result.getMatch;if(d.result.filter===!1)for(let h of d.result.options)s(new KV(h,d.source,f?f(h):[],1e9-n.length));else{let h=t.sliceDoc(d.from,d.to),p,g=a.filterStrict?new met(h):new pet(h);for(let b of d.result.options)if(p=g.match(b.label)){let y=b.displayLabel?f?f(b,p.matched):[]:p.matched,O=p.score+(b.boost||0);if(s(new KV(b,d.source,y,O)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:v}=b.section;r||(r=Object.create(null)),r[v]=Math.max(O,r[v]||-1e9)}}}}if(i){let d=Object.create(null),f=0,h=(p,g)=>(p.rank==="dynamic"&&g.rank==="dynamic"?r[g.name]-r[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(p.nameh.score-f.score||u(f.completion,h.completion))){let f=d.completion;!c||c.label!=f.label||c.detail!=f.detail||c.type!=null&&f.type!=null&&c.type!=f.type||c.apply!=f.apply||c.boost!=f.boost?o.push(d):tX(d.completion)>tX(c)&&(o[o.length-1]=d),c=d.completion}return o}class lg{constructor(t,n,i,r,s,a){this.options=t,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new lg(this.options,nX(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,i,r,s,a){if(r&&!a&&t.some(u=>u.isPending))return r.setDisabled();let o=vet(t,n);if(!o.length)return r&&t.some(u=>u.isPending)?r.setDisabled():null;let c=n.facet(gs).selectOnOpen?0:-1;if(r&&r.selected!=c&&r.selected!=-1){let u=r.options[r.selected].completion;for(let d=0;dd.hasResult()?Math.min(u,d.from):u,1e8),create:Aet,above:s.aboveCursor},r?r.timestamp:Date.now(),c,!1)}map(t){return new lg(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new lg(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class yT{constructor(t,n,i){this.active=t,this.id=n,this.open=i}static start(){return new yT(Tet,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,i=n.facet(gs),s=(i.override||n.languageDataAt("autocomplete",cp(n)).map(het)).map(c=>(this.active.find(d=>d.source==c)||new Wo(c,this.active.some(d=>d.state!=0)?1:0)).update(t,i));s.length==this.active.length&&s.every((c,u)=>c==this.active[u])&&(s=this.active);let a=this.open,o=t.effects.some(c=>c.is(C4));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(c=>c.hasResult()&&t.changes.touchesRange(c.from,c.to))||!wet(s,this.active)||o?a=lg.build(s,n,this.id,a,i,o):a&&a.disabled&&!s.some(c=>c.isPending)&&(a=null),!a&&s.every(c=>!c.isPending)&&s.some(c=>c.hasResult())&&(s=s.map(c=>c.hasResult()?new Wo(c.source,0):c));for(let c of t.effects)c.is(N4)&&(a=a&&a.setSelected(c.value,this.id));return s==this.active&&a==this.open?this:new yT(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Eet:ket}}function wet(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Tet=[];function Jue(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(A4);if(i&&t.activateOnCompletion(i))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Wo{constructor(t,n,i=!1){this.source=t,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let i=Jue(t,n),r=this;(i&8||i&16&&this.touches(t))&&(r=new Wo(r.source,0)),i&4&&r.state==0&&(r=new Wo(this.source,1)),r=r.updateFor(t,i);for(let s of t.effects)if(s.is(OT))r=new Wo(r.source,1,s.value);else if(s.is(Fx))r=new Wo(r.source,0);else if(s.is(C4))for(let a of s.value)a.source==r.source&&(r=a);return r}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(cp(t.state))}}class Mg extends Wo{constructor(t,n,i,r,s,a){super(t,3,n),this.limit=i,this.result=r,this.from=s,this.to=a}hasResult(){return!0}updateFor(t,n){var i;if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=cp(t.state);if(o>a||!r||n&2&&(cp(t.startState)==this.from||on.map(t))}}),Ma=Ms.define({create(){return yT.start()},update(e,t){return e.update(t)},provide:e=>[x4.from(e,t=>t.tooltip),ft.contentAttributes.from(e,t=>t.attrs)]});function j4(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(Ma).active.find(r=>r.source==t.source);return i instanceof Mg?(typeof n=="string"?e.dispatch({...fet(e.state,n,i.from,i.to),annotations:A4.of(t.completion)}):n(e,t.completion,i.from,i.to),!0):!1}const Aet=yet(Ma,j4);function sS(e,t="option"){return n=>{let i=n.state.field(Ma,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:N4.of(o)}),!0}}const Net=e=>{let t=e.state.field(Ma,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.state.field(Ma,!1)?(e.dispatch({effects:OT.of(!0)}),!0):!1,Cet=e=>{let t=e.state.field(Ma,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Fx.of(null)}),!0)};class jet{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ret=50,Iet=1e3,Pet=Tr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ma).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ma),n=e.state.facet(gs);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ma)==t)return;let i=e.transactions.some(s=>{let a=Jue(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;sRet&&Date.now()-a.time>Iet){for(let o of a.context.abortListeners)try{o()}catch(c){Qa(this.view.state,c)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(OT)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ma);for(let n of t.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(gs).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=cp(t),i=new T4(t,n,e.explicit,this.view),r=new jet(e,i);this.running.push(r),Promise.resolve(e.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Fx.of(null)}),Qa(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(gs).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(gs),i=this.view.state.field(Ma);for(let r=0;ro.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new Wo(s.active.source,0);for(let c of s.updates)o=o.update(c,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:C4.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ma,!1);if(t&&t.tooltip&&this.view.state.facet(gs).closeOnBlur){let n=t.open&&Aue(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fx.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:OT.of(!1)}),20),this.composing=0}}}),Met=typeof navigator=="object"&&/Win/.test(navigator.platform),Let=vd.highest(ft.domEventHandlers({keydown(e,t){let n=t.state.field(Ma,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Met&&e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(a=>a.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&j4(t,i),!1}})),ede=ft.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Det{constructor(t,n,i,r){this.field=t,this.line=n,this.from=i,this.to=r}}class R4{constructor(t,n,i){this.field=t,this.from=n,this.to=i}map(t){let n=t.mapPos(this.from,-1,Cs.TrackDel),i=t.mapPos(this.to,1,Cs.TrackDel);return n==null||i==null?null:new R4(this.field,n,i)}}class I4{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let i=[],r=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let c of this.lines){if(i.length){let u=a,d=/^\t*/.exec(c)[0].length;for(let f=0;fnew R4(c.field,r[c.line]+c.from,r[c.line]+c.to));return{text:i,ranges:o}}static parse(t){let n=[],i=[],r=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,c=s[2]||s[3]||"",u=-1;o===0&&(o=1e9);let d=c.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f=u&&h.field++}for(let f of r)if(f.line==i.length&&f.from>s.index){let h=s[2]?3+(s[1]||"").length:2;f.from-=h,f.to-=h}r.push(new Det(u,i.length,s.index,s.index+d.length)),a=a.slice(0,s.index)+c+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,c,u)=>{for(let d of r)d.line==i.length&&d.from>u&&(d.from--,d.to--);return c}),i.push(a)}return new I4(i,r)}}let $et=zt.widget({widget:new class extends Yl{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Qet=zt.mark({class:"cm-snippetField"});class hb{constructor(t,n){this.ranges=t,this.active=n,this.deco=zt.set(t.map(i=>(i.from==i.to?$et:Qet).range(i.from,i.to)),!0)}map(t){let n=[];for(let i of this.ranges){let r=i.map(t);if(!r)return null;n.push(r)}return new hb(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(i=>i.field==this.active&&i.from<=n.from&&i.to>=n.to))}}const iv=rn.define({map(e,t){return e&&e.map(t)}}),Bet=rn.define(),Vx=Ms.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(iv))return n.value;if(n.is(Bet)&&e)return new hb(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ft.decorations.from(e,t=>t?t.deco:zt.none)});function P4(e,t){return Qe.create(e.filter(n=>n.field==t).map(n=>Qe.range(n.from,n.to)))}function Uet(e){let t=I4.parse(e);return(n,i,r,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,r),{main:c}=n.state.selection,u={changes:{from:r,to:s==c.from?c.to:s,insert:ei.of(a)},scrollIntoView:!0,annotations:i?[A4.of(i),Xr.userEvent.of("input.complete")]:void 0};if(o.length&&(u.selection=P4(o,0)),o.some(d=>d.field>0)){let d=new hb(o,0),f=u.effects=[iv.of(d)];n.state.field(Vx,!1)===void 0&&f.push(rn.appendConfig.of([Vx,qet,Het,ede]))}n.dispatch(n.state.update(u))}}function tde(e){return({state:t,dispatch:n})=>{let i=t.field(Vx,!1);if(!i||e<0&&i.active==0)return!1;let r=i.active+e,s=e>0&&!i.ranges.some(a=>a.field==r+e);return n(t.update({selection:P4(i.ranges,r),effects:iv.of(s?null:new hb(i.ranges,r)),scrollIntoView:!0})),!0}}const zet=({state:e,dispatch:t})=>e.field(Vx,!1)?(t(e.update({effects:iv.of(null)})),!0):!1,Fet=tde(1),Vet=tde(-1),Xet=[{key:"Tab",run:Fet,shift:Vet},{key:"Escape",run:zet}],iX=yt.define({combine(e){return e.length?e[0]:Xet}}),qet=vd.highest(db.compute([iX],e=>e.facet(iX)));function hr(e,t){return{...t,apply:Uet(e)}}const Het=ft.domEventHandlers({mousedown(e,t){let n=t.state.field(Vx,!1),i;if(!n||(i=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let r=n.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==n.active?!1:(t.dispatch({selection:P4(n.ranges,r.field),effects:iv.of(n.ranges.some(s=>s.field>r.field)?new hb(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Xx={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},qh=rn.define({map(e,t){let n=t.mapPos(e,-1,Cs.TrackAfter);return n??void 0}}),M4=new class extends Ff{};M4.startSide=1;M4.endSide=-1;const nde=Ms.define({create(){return jn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of t.effects)n.is(qh)&&(e=e.update({add:[M4.range(n.value,n.value+1)]}));return e}});function Yet(){return[Wet,nde]}const Sj="()[]{}<>«»»«[]{}";function ide(e){for(let t=0;t{if((Get?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||i.length==2&&Sc(Pa(i,0))==1||t!=r.from||n!=r.to)return!1;let s=Jet(e.state,i);return s?(e.dispatch(s),!0):!1}),Zet=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=rde(e,e.selection.main.head).brackets||Xx.brackets,r=null,s=e.changeByRange(a=>{if(a.empty){let o=ett(e.doc,a.head);for(let c of i)if(c==o&&BA(e.doc,a.head)==ide(Pa(c,0)))return{changes:{from:a.head-c.length,to:a.head+c.length},range:Qe.cursor(a.head-c.length)}}return{range:r=a}});return r||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},Ket=[{key:"Backspace",run:Zet}];function Jet(e,t){let n=rde(e,e.selection.main.head),i=n.brackets||Xx.brackets;for(let r of i){let s=ide(Pa(r,0));if(t==r)return s==r?itt(e,r,i.indexOf(r+r+r)>-1,n):ttt(e,r,s,n.before||Xx.before);if(t==s&&sde(e,e.selection.main.from))return ntt(e,r,s)}return null}function sde(e,t){let n=!1;return e.field(nde).between(0,e.doc.length,i=>{i==t&&(n=!0)}),n}function BA(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Sc(Pa(n,0)))}function ett(e,t){let n=e.sliceString(t-2,t);return Sc(Pa(n,0))==n.length?n:n.slice(1)}function ttt(e,t,n,i){let r=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:qh.of(a.to+t.length),range:Qe.range(a.anchor+t.length,a.head+t.length)};let o=BA(e.doc,a.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:qh.of(a.head+t.length),range:Qe.cursor(a.head+t.length)}:{range:r=a}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ntt(e,t,n){let i=null,r=e.changeByRange(s=>s.empty&&BA(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:Qe.cursor(s.head+n.length)}:i={range:s});return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function itt(e,t,n,i){let r=i.stringPrefixes||Xx.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:qh.of(o.to+t.length),range:Qe.range(o.anchor+t.length,o.head+t.length)};let c=o.head,u=BA(e.doc,c),d;if(u==t){if(rX(e,c))return{changes:{insert:t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)};if(sde(e,c)){let h=n&&e.sliceDoc(c,c+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:c,to:c+h.length,insert:h},range:Qe.cursor(c+h.length)}}}else{if(n&&e.sliceDoc(c-2*t.length,c)==t+t&&(d=sX(e,c-2*t.length,r))>-1&&rX(e,d))return{changes:{insert:t+t+t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)};if(e.charCategorizer(c)(u)!=lr.Word&&sX(e,c,r)>-1&&!rtt(e,c,t,r))return{changes:{insert:t+t,from:c},effects:qh.of(c+t.length),range:Qe.cursor(c+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function rX(e,t){let n=_i(e).resolveInner(t+1);return n.parent&&n.from==t}function rtt(e,t,n,i){let r=_i(e).resolveInner(t,-1),s=i.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),c=o.indexOf(n);if(!c||c>-1&&i.indexOf(o.slice(0,c))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+c;){if(e.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let u=r.to==t&&r.parent;if(!u)break;r=u}return!1}function sX(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=lr.Word)return t;for(let r of n){let s=t-r.length;if(e.sliceDoc(s,t)==r&&i(e.sliceDoc(s-1,s))!=lr.Word)return s}return-1}function stt(e={}){return[Let,Ma,gs.of(e),Pet,att,ede]}const ade=[{key:"Ctrl-Space",run:wj},{mac:"Alt-`",run:wj},{mac:"Alt-i",run:wj},{key:"Escape",run:Cet},{key:"ArrowDown",run:sS(!0)},{key:"ArrowUp",run:sS(!1)},{key:"PageDown",run:sS(!0,"page")},{key:"PageUp",run:sS(!1,"page")},{key:"Enter",run:Net}],att=vd.highest(db.computeN([gs],e=>e.facet(gs).defaultKeymap?[ade]:[])),ode=[hr("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),hr("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),hr("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),hr("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),hr("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),hr(`try { \${} } catch (\${error}) { \${} @@ -692,27 +692,27 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus constructor(\${params}) { \${} } -}`,{label:"class",detail:"definition",type:"keyword"}),hr('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),hr('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],att=ade.concat([hr("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),hr("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),hr("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),aX=new t4,ode=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function lO(e){return(t,n)=>{let i=t.node.getChild("VariableDefinition");return i&&n(i,e),!0}}const ott=["FunctionDeclaration"],ltt={FunctionDeclaration:lO("function"),ClassDeclaration:lO("class"),ClassExpression:()=>!0,EnumDeclaration:lO("constant"),TypeAliasDeclaration:lO("type"),NamespaceDeclaration:lO("namespace"),VariableDefinition(e,t){e.matchContext(ott)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function lde(e,t){let n=aX.get(t);if(n)return n;let i=[],r=!0;function s(a,o){let c=e.sliceString(a.from,a.to);i.push({label:c,type:o})}return t.cursor(si.IncludeAnonymous).iterate(a=>{if(r)r=!1;else if(a.name){let o=ltt[a.name];if(o&&o(a,s)||ode.has(a.name))return!1}else if(a.to-a.from>8192){for(let o of lde(e,a.node))i.push(o);return!1}}),aX.set(t,i),i}const oX=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,cde=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function ctt(e){let t=_i(e.state).resolveInner(e.pos,-1);if(cde.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&oX.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let i=[];for(let r=t;r;r=r.parent)ode.has(r.name)&&(i=i.concat(lde(e.state.doc,r)));return{options:i,from:n?t.from:e.pos,validFor:oX}}const Bc=ud.define({name:"javascript",parser:uWe.configure({props:[rh.add({IfStatement:Pg({except:/^\s*({|else\b)/}),TryStatement:Pg({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:RJe,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),i=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:i?1:2)*e.unit},Block:Ig({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":Pg({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),wd.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ev,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){var t;let n=(t=e.firstChild)===null||t===void 0?void 0:t.nextSibling,i=e.lastChild;return!n||n.type.isError?null:{from:n.to,to:i.type.isError?e.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),ude={test:e=>/^JSX/.test(e.name),facet:w4({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dde=Bc.configure({dialect:"ts"},"typescript"),fde=Bc.configure({dialect:"jsx",props:[S4.add(e=>e.isTop?[ude]:void 0)]}),hde=Bc.configure({dialect:"jsx ts",props:[S4.add(e=>e.isTop?[ude]:void 0)]},"typescript");let pde=e=>({label:e,type:"keyword"});const mde="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(pde),utt=mde.concat(["declare","implements","private","protected","public"].map(pde));function bL(e={}){let t=e.jsx?e.typescript?hde:fde:e.typescript?dde:Bc,n=e.typescript?att.concat(utt):ade.concat(mde);return new Yf(t,[Bc.data.of({autocomplete:Wue(cde,_4(n))}),Bc.data.of({autocomplete:ctt}),e.jsx?htt:[]])}function dtt(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function lX(e,t,n=e.length){for(let i=t==null?void 0:t.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return e.sliceString(i.from,Math.min(i.to,n));return""}const ftt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),htt=ft.inputHandler.of((e,t,n,i,r)=>{if((ftt?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||i!=">"&&i!="/"||!Bc.isActiveAt(e.state,t,-1))return!1;let s=r(),{state:a}=s,o=a.changeByRange(c=>{var u;let{head:d}=c,f=_i(a).resolveInner(d-1,-1),h;if(f.name=="JSXStartTag"&&(f=f.parent),!(a.doc.sliceString(d-1,d)!=i||f.name=="JSXAttributeValue"&&f.to>d)){if(i==">"&&f.name=="JSXFragmentTag")return{range:c,changes:{from:d,insert:""}};if(i=="/"&&f.name=="JSXStartCloseTag"){let p=f.parent,g=p.parent;if(g&&p.from==d-2&&((h=lX(a.doc,g.firstChild,d))||((u=g.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let b=`${h}>`;return{range:Qe.cursor(d+b.length,-1),changes:{from:d,insert:b}}}}else if(i==">"){let p=dtt(f);if(p&&p.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(d,d+2))&&(h=lX(a.doc,p,d)))return{range:c,changes:{from:d,insert:``}}}}return{range:c}});return o.changes.empty?!1:(e.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),ptt=xd({String:G.string,Number:G.number,"True False":G.bool,PropertyName:G.propertyName,Null:G.null,", :":G.separator,"[ ]":G.squareBracket,"{ }":G.brace}),mtt=ad.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[ptt],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),gtt=ud.define({name:"json",parser:mtt.configure({props:[rh.add({Object:Pg({except:/^\s*\}/}),Array:Pg({except:/^\s*\]/})}),wd.add({"Object Array":ev})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function btt(){return new Yf(gtt)}class xT{static create(t,n,i,r,s){let a=r+(r<<8)+t+(n<<4)|0;return new xT(t,n,i,a,s,[],[])}constructor(t,n,i,r,s,a,o){this.type=t,this.value=n,this.from=i,this.hash=r,this.end=s,this.children=a,this.positions=o,this.hashProp=[[sn.contextHash,r]]}addChild(t,n){t.prop(sn.contextHash)!=this.hash&&(t=new li(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let i=this.children.length-1;return i>=0&&(n=Math.max(n,this.positions[i]+this.children[i].length+this.from)),new li(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(r,s,a)=>new li(ss.none,r,s,a,this.hashProp)})}}var ot;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(ot||(ot={}));class Ott{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class ytt{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Ny(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,i=0){for(let r=n;r=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let i=(e.type==ot.OrderedList?$4:D4)(n,t,!1);return i>0&&(e.type!=ot.BulletList||L4(n,t,!1)<0)&&n.text.charCodeAt(n.pos+i-1)==e.value}const gde={[ot.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Hn(ot.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ol(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[ot.ListItem](e,t,n){return n.indent-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[ot.OrderedList]:cX,[ot.BulletList]:cX,[ot.Document](){return!0}};function ol(e){return e==32||e==9||e==10||e==13}function Ny(e,t=0){for(;tn&&ol(e.charCodeAt(t-1));)t--;return t}function bde(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(kde.SetextHeading)>-1||i<3?-1:1}function yde(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function D4(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ol(e.text.charCodeAt(e.pos+1)))&&(!n||yde(t,ot.BulletList)||e.skipSpace(e.pos+2)=48&&r<=57;){i++;if(i==e.text.length)return-1;r=e.text.charCodeAt(i)}return i==e.pos||i>e.pos+9||r!=46&&r!=41||ie.pos+1||e.next!=49)?-1:i+1-e.pos}function xde(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t6?-1:n}function vde(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t/,Sde=/\?>/,yL=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/,Ede=/\?>/,yL=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(i);if(s)return e.append(Hn(ot.Comment,n,n+1+s[0].length));let a=/^\?[^]*?\?>/.exec(i);if(a)return e.append(Hn(ot.ProcessingInstruction,n,n+1+a[0].length));let o=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return o?e.append(Hn(ot.HTMLTag,n,n+1+o[0].length)):-1},Emphasis(e,t,n){if(t!=95&&t!=42)return-1;let i=n+1;for(;e.char(i)==t;)i++;let r=e.slice(n-1,n),s=e.slice(i,i+1),a=Hx.test(r),o=Hx.test(s),c=/\s|^$/.test(r),u=/\s|^$/.test(s),d=!u&&(!o||c||a),f=!c&&(!a||u||o),h=d&&(t==42||!f||a),p=f&&(t==42||!d||o);return e.append(new ao(t==95?Cde:jde,n,i,(h?1:0)|(p?2:0)))},HardBreak(e,t,n){if(t==92&&e.char(n+1)==10)return e.append(Hn(ot.HardBreak,n,n+2));if(t==32){let i=n+1;for(;e.char(i)==32;)i++;if(e.char(i)==10&&i>=n+2)return e.append(Hn(ot.HardBreak,n,i+1))}return-1},Link(e,t,n){return t==91?e.append(new ao(Ph,n,n+1,1)):-1},Image(e,t,n){return t==33&&e.char(n+1)==91?e.append(new ao(vT,n,n+2,1)):-1},LinkEnd(e,t,n){if(t!=93)return-1;for(let i=e.parts.length-1;i>=0;i--){let r=e.parts[i];if(r instanceof ao&&(r.type==Ph||r.type==vT)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[i]=null,-1;let s=e.takeContent(i),a=e.parts[i]=ktt(e,s,r.type==Ph?ot.Link:ot.Image,r.from,n+1);if(r.type==Ph)for(let o=0;ot?Hn(ot.URL,t+n,s+n):s==e.length?null:!1}}function Ide(e,t,n){let i=e.charCodeAt(t);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=t+1,a=!1;s=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,n){return this.text.slice(t-this.offset,n-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,n,i,r,s){return this.append(new ao(t,n,i,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof ao&&(n.type==Ph||n.type==vT))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i=t;c--){let b=this.parts[c];if(b instanceof ao&&b.side&1&&b.type==r.type&&!(s&&(r.side&1||b.side&2)&&(b.to-b.from+a)%3==0&&((b.to-b.from)%3||a%3))){o=b;break}}if(!o)continue;let u=r.type.resolve,d=[],f=o.from,h=r.to;if(s){let b=Math.min(2,o.to-o.from,a);f=o.to-b,h=r.from+b,u=b==1?"Emphasis":"StrongEmphasis"}o.type.mark&&d.push(this.elt(o.type.mark,f,o.to));for(let b=c+1;b=0;n--){let i=this.parts[n];if(i instanceof ao&&i.type==t&&i.side&1)return n}return null}takeContent(t){let n=this.resolveMarkers(t);return this.parts.length=t,n}getDelimiterAt(t){let n=this.parts[t];return n instanceof ao?n:null}skipSpace(t){return Ny(this.text,t-this.offset)+this.offset}elt(t,n,i,r){return typeof t=="string"?Hn(this.parser.getNodeType(t),n,i,r):new Nde(t,n)}}Q4.linkStart=Ph;Q4.imageStart=vT;function vL(e,t){if(!t.length)return e;if(!e.length)return t;let n=e.slice(),i=0;for(let r of t){for(;i(t?t-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` -`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=t+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=n;if(!i.childAfter(r))return!1}}matches(t){let n=this.cursor.tree;return n&&n.prop(sn.contextHash)==t}takeNodes(t){let n=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=t.absoluteLineStart,a=s,o=t.block.children.length,c=a,u=o;for(;;){if(n.to-i>r){if(n.type.isAnonymous&&n.firstChild())continue;break}let d=Mde(n.from-i,t.ranges);if(n.to-i<=t.ranges[t.rangeI].to)t.addNode(n.tree,d);else{let f=new li(t.parser.nodeSet.types[ot.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(f,n.tree),t.addNode(f,d)}if(n.type.is("Block")&&(Ttt.indexOf(n.type.id)<0?(a=n.to-i,o=t.block.children.length):(a=c,o=u),c=n.to-i,u=t.block.children.length),!n.nextSibling())break}for(;t.block.children.length>o;)t.block.children.pop(),t.block.positions.pop();return a-s}}function Mde(e,t){let n=e;for(let i=1;iaS[e]),Object.keys(aS).map(e=>kde[e]),Object.keys(aS),wtt,gde,Object.keys(kj).map(e=>kj[e]),Object.keys(kj),[]);function Ctt(e,t,n){let i=[];for(let r=e.firstChild,s=t;;r=r.nextSibling){let a=r?r.from:n;if(a>s&&i.push({from:s,to:a}),!r)break;s=r.to}return i}function jtt(e){let{codeParser:t,htmlParser:n}=e;return{wrap:ice((r,s)=>{let a=r.type.id;if(t&&(a==ot.CodeBlock||a==ot.FencedCode)){let o="";if(a==ot.FencedCode){let u=r.node.getChild(ot.CodeInfo);u&&(o=s.read(u.from,u.to))}let c=t(o);if(c)return{parser:c,overlay:u=>u.type.id==ot.CodeText,bracketed:a==ot.FencedCode}}else if(n&&(a==ot.HTMLBlock||a==ot.HTMLTag||a==ot.CommentBlock))return{parser:n,overlay:Ctt(r.node,r.from,r.to)};return null})}}const Rtt={resolve:"Strikethrough",mark:"StrikethroughMark"},Itt={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":G.strikethrough}},{name:"StrikethroughMark",style:G.processingInstruction}],parseInline:[{name:"Strikethrough",parse(e,t,n){if(t!=126||e.char(n+1)!=126||e.char(n+2)==126)return-1;let i=e.slice(n-1,n),r=e.slice(n+2,n+3),s=/\s|^$/.test(i),a=/\s|^$/.test(r),o=Hx.test(i),c=Hx.test(r);return e.addDelimiter(Rtt,n,n+2,!a&&(!c||s||o),!s&&(!o||a||c))},after:"Emphasis"}]};function Cy(e,t,n=0,i,r=0){let s=0,a=!0,o=-1,c=-1,u=!1,d=()=>{i.push(e.elt("TableCell",r+o,r+c,e.parser.parseInline(t.slice(o,c),r+o)))};for(let f=n;f-1)&&s++,a=!1,i&&(o>-1&&d(),i.push(e.elt("TableDelimiter",f+r,f+r+1))),o=c=-1):(u||h!=32&&h!=9)&&(o<0&&(o=f),c=f+1),u=!u&&h==92}return o>-1&&(s++,i&&d()),s}function hX(e,t){for(let n=t;n\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class pX{constructor(){this.rows=null}nextLine(t,n,i){if(this.rows==null){this.rows=!1;let r;if((n.next==45||n.next==58||n.next==124)&&Lde.test(r=n.text.slice(n.pos))){let s=[];Cy(t,i.content,0,s,i.start)==Cy(t,r,0)&&(this.rows=[t.elt("TableHeader",i.start,i.start+i.content.length,s),t.elt("TableDelimiter",t.lineStart+n.pos,t.lineStart+n.text.length)])}}else if(this.rows){let r=[];Cy(t,n.text,n.pos,r,t.lineStart),this.rows.push(t.elt("TableRow",t.lineStart+n.pos,t.lineStart+n.text.length,r))}return!1}finish(t,n){return this.rows?(t.addLeafElement(n,t.elt("Table",n.start,n.start+n.content.length,this.rows)),!0):!1}}const Ptt={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":G.heading}},"TableRow",{name:"TableCell",style:G.content},{name:"TableDelimiter",style:G.processingInstruction}],parseBlock:[{name:"Table",leaf(e,t){return hX(t.content,0)?new pX:null},endLeaf(e,t,n){if(n.parsers.some(r=>r instanceof pX)||!hX(t.text,t.basePos))return!1;let i=e.peekLine();return Lde.test(i)&&Cy(e,t.text,t.basePos)==Cy(e,i,t.basePos)},before:"SetextHeading"}]};class Mtt{nextLine(){return!1}finish(t,n){return t.addLeafElement(n,t.elt("Task",n.start,n.start+n.content.length,[t.elt("TaskMarker",n.start,n.start+3),...t.parser.parseInline(n.content.slice(3),n.start+3)])),!0}}const Ltt={defineNodes:[{name:"Task",block:!0,style:G.list},{name:"TaskMarker",style:G.atom}],parseBlock:[{name:"TaskList",leaf(e,t){return/^\[[ xX]\][ \t]/.test(t.content)&&e.parentType().name=="ListItem"?new Mtt:null},after:"SetextHeading"}]},mX=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,gX=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,Dtt=/[\w-]+\.[\w-]+($|[/:])/,bX=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,OX=/\/[a-zA-Z\d@.]+/gy;function yX(e,t,n,i){let r=0;for(let s=t;s-1)return-1;let i=t+n[0].length;for(;;){let r=e[i-1],s;if(/[?!.,:*_~]/.test(r)||r==")"&&yX(e,t,i,")")>yX(e,t,i,"("))i--;else if(r==";"&&(s=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,i))))i=t+s.index;else break}return i}function xX(e,t){bX.lastIndex=t;let n=bX.exec(e);if(!n)return-1;let i=n[0][n[0].length-1];return i=="_"||i=="-"?-1:t+n[0].length-(i=="."?1:0)}const Qtt={parseInline:[{name:"Autolink",parse(e,t,n){let i=n-e.offset;if(i&&/\w/.test(e.text[i-1]))return-1;mX.lastIndex=i;let r=mX.exec(e.text),s=-1;if(!r)return-1;if(r[1]||r[2]){if(s=$tt(e.text,i+r[0].length),s>-1&&e.hasOpenLink){let a=/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(i,s));s=i+a[0].length}}else r[3]?s=xX(e.text,i):(s=xX(e.text,i+r[0].length),s>-1&&r[0]=="xmpp:"&&(OX.lastIndex=s,r=OX.exec(e.text),r&&(s=r.index+r[0].length)));return s<0?-1:(e.addElement(e.elt("URL",n,s+e.offset)),s+e.offset)}}]},Btt=[Ptt,Ltt,Itt,Qtt];function Dde(e,t,n){return(i,r,s)=>{if(r!=e||i.char(s+1)==e)return-1;let a=[i.elt(n,s,s+1)];for(let o=s+1;o=65&&e<=90||e==95||e>=97&&e<=122||e>=161}let EX=null,kX=null,TX=0;function SL(e,t){let n=e.pos+t;if(TX==n&&kX==e)return EX;let i=e.peek(t),r="";for(;hnt(i);)r+=String.fromCharCode(i),i=e.peek(++t);return kX=e,TX=n,EX=r?r.toLowerCase():i==pnt||i==mnt?void 0:null}const Xde=60,wT=62,U4=47,pnt=63,mnt=33,gnt=45;function _X(e,t){this.name=e,this.parent=t}const bnt=[B4,Ude,$de,Qde,Bde],Ont=new CA({start:null,shift(e,t,n,i){return bnt.indexOf(t)>-1?new _X(SL(i,1)||"",e):e},reduce(e,t){return t==zde&&e?e.parent:e},reuse(e,t,n,i){let r=t.type.id;return r==B4||r==ont?new _X(SL(i,1)||"",e):e},strict:!1}),ynt=new Lr((e,t)=>{if(e.next!=Xde){e.next<0&&t.context&&e.acceptToken(Tj);return}e.advance();let n=e.next==U4;n&&e.advance();let i=SL(e,0);if(i===void 0)return;if(!i)return e.acceptToken(n?tnt:ent);let r=t.context?t.context.name:null;if(n){if(i==r)return e.acceptToken(Ztt);if(r&&fnt[r])return e.acceptToken(Tj,-2);if(t.dialectEnabled(cnt))return e.acceptToken(Ktt);for(let s=t.context;s;s=s.parent)if(s.name==i)return;e.acceptToken(Jtt)}else{if(i=="script")return e.acceptToken($de);if(i=="style")return e.acceptToken(Qde);if(i=="textarea")return e.acceptToken(Bde);if(dnt.hasOwnProperty(i))return e.acceptToken(Ude);r&&SX[r]&&SX[r][i]?e.acceptToken(Tj,-1):e.acceptToken(B4)}},{contextual:!0}),xnt=new Lr(e=>{for(let t=0,n=0;;n++){if(e.next<0){n&&e.acceptToken(wX);break}if(e.next==gnt)t++;else if(e.next==wT&&t>=2){n>=3&&e.acceptToken(wX,-2);break}else t=0;e.advance()}});function vnt(e){for(;e;e=e.parent)if(e.name=="svg"||e.name=="math")return!0;return!1}const wnt=new Lr((e,t)=>{if(e.next==U4&&e.peek(1)==wT){let n=t.dialectEnabled(unt)||vnt(t.context);e.acceptToken(n?Wtt:vX,2)}else e.next==wT&&e.acceptToken(vX,1)});function z4(e,t,n){let i=2+e.length;return new Lr(r=>{for(let s=0,a=0,o=0;;o++){if(r.next<0){o&&r.acceptToken(t);break}if(s==0&&r.next==Xde||s==1&&r.next==U4||s>=2&&sa?r.acceptToken(t,-a):r.acceptToken(n,-(a-2));break}else if((r.next==10||r.next==13)&&o){r.acceptToken(t,1);break}else s=a=0;r.advance()}})}const Snt=z4("script",Vtt,Xtt),Ent=z4("style",qtt,Htt),knt=z4("textarea",Ytt,Gtt),Tnt=xd({"Text RawText IncompleteTag IncompleteCloseTag":G.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":G.angleBracket,TagName:G.tagName,"MismatchedCloseTag/TagName":[G.tagName,G.invalid],AttributeName:G.attributeName,"AttributeValue UnquotedAttributeValue":G.attributeValue,Is:G.definitionOperator,"EntityReference CharacterReference":G.character,Comment:G.blockComment,ProcessingInst:G.processingInstruction,DoctypeDecl:G.documentMeta}),_nt=ad.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",stateData:",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:Ont,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[Tnt],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let u=o.type.id;if(u==rnt)return _j(o,c,n);if(u==snt)return _j(o,c,i);if(u==ant)return _j(o,c,r);if(u==zde&&s.length){let d=o.node,f=d.firstChild,h=f&&AX(f,c),p;if(h){for(let g of s)if(g.tag==h&&(!g.attrs||g.attrs(p||(p=qde(f,c))))){let b=d.lastChild,y=b.type.id==lnt?b.from:d.to;if(y>f.to)return{parser:g.parser,overlay:[{from:f.to,to:y}]}}}}if(a&&u==Fde){let d=o.node,f;if(f=d.firstChild){let h=a[c.read(f.from,f.to)];if(h)for(let p of h){if(p.tagName&&p.tagName!=AX(d.parent,c))continue;let g=d.lastChild;if(g.type.id==wL){let b=g.from+1,y=g.lastChild,O=g.to-(y&&y.isError?0:1);if(O>b)return{parser:p.parser,overlay:[{from:b,to:O}],bracketed:!0}}else if(g.type.id==Vde)return{parser:p.parser,overlay:[{from:g.from,to:g.to}]}}}}return null})}const Ant=145,NX=1,Nnt=146,Cnt=147,Yde=2,jnt=148,Rnt=3,Int=4,Gde=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Pnt=58,Mnt=40,Wde=95,Lnt=91,OE=45,Dnt=46,$nt=35,Qnt=37,Bnt=38,Unt=92,znt=10,Fnt=42;function Yx(e){return e>=65&&e<=90||e>=97&&e<=122||e>=161}function F4(e){return e>=48&&e<=57}function CX(e){return F4(e)||e>=97&&e<=102||e>=65&&e<=70}const Zde=(e,t,n)=>(i,r)=>{for(let s=!1,a=0,o=0;;o++){let{next:c}=i;if(Yx(c)||c==OE||c==Wde||s&&F4(c))!s&&(c!=OE||o>0)&&(s=!0),a===o&&c==OE&&a++,i.advance();else if(c==Unt&&i.peek(1)!=znt){if(i.advance(),CX(i.next)){do i.advance();while(CX(i.next));i.next==32&&i.advance()}else i.next>-1&&i.advance();s=!0}else{s&&i.acceptToken(a==2&&r.canShift(Yde)?t:c==Mnt?n:e);break}}},Vnt=new Lr(Zde(Nnt,Yde,Cnt),{contextual:!0}),Xnt=new Lr(Zde(jnt,Rnt,Int),{contextual:!0}),qnt=new Lr(e=>{if(Gde.includes(e.peek(-1))){let{next:t}=e;(Yx(t)||t==Wde||t==$nt||t==Dnt||t==Fnt||t==Lnt||t==Pnt&&Yx(e.peek(1))||t==OE||t==Bnt)&&e.acceptToken(Ant)}}),Hnt=new Lr(e=>{if(!Gde.includes(e.peek(-1))){let{next:t}=e;if(t==Qnt&&(e.advance(),e.acceptToken(NX)),Yx(t)){do e.advance();while(Yx(e.next)||F4(e.next));e.acceptToken(NX)}}}),Ynt=xd({"AtKeyword import charset namespace keyframes media supports font-feature-values":G.definitionKeyword,"from to selector scope MatchFlag":G.keyword,NamespaceName:G.namespace,KeyframeName:G.labelName,KeyframeRangeName:G.operatorKeyword,TagName:G.tagName,ClassName:G.className,PseudoClassName:G.constant(G.className),IdName:G.labelName,"FeatureName PropertyName":G.propertyName,AttributeName:G.attributeName,NumberLiteral:G.number,KeywordQuery:G.keyword,UnaryQueryOp:G.operatorKeyword,"CallTag ValueName FontName":G.atom,VariableName:G.variableName,Callee:G.operatorKeyword,Unit:G.unit,"UniversalSelector NestingSelector":G.definitionOperator,"MatchOp CompareOp":G.compareOperator,"ChildOp SiblingOp, LogicOp":G.logicOperator,BinOp:G.arithmeticOperator,Important:G.modifier,Comment:G.blockComment,ColorLiteral:G.color,"ParenthesizedContent StringLiteral":G.string,":":G.punctuation,"PseudoOp #":G.derefOperator,"; , |":G.separator,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace}),Gnt={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:152,"url-prefix":152,domain:152,regexp:152},Wnt={__proto__:null,or:104,and:104,not:112,only:112,layer:206},Znt={__proto__:null,selector:118,style:124,layer:202},Knt={__proto__:null,"@import":198,"@media":210,"@charset":214,"@namespace":218,"@keyframes":224,"@supports":236,"@scope":240,"@font-feature-values":246},Jnt={__proto__:null,to:243},eit=ad.deserialize({version:14,states:"MlQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FnO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#EOO'dQdO'#EQO'oQdO'#EXO'oQdO'#E[OOQP'#Fn'#FnO)RQhO'#E}OOQS'#Fm'#FmOOQS'#FQ'#FQQYQdOOO)YQdO'#EbO*iQhO'#EhO)YQdO'#EjO*pQdO'#ElO*{QdO'#EoO)}QhO'#EuO+TQdO'#EwO+`QdO'#EzO+eQaO'#CfO+lQ`O'#E_O+qQ`O'#F{O+|QdO'#F{QOQ`OOP,WO&jO'#CaPOOO)CA])CA]OOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,cQdO,59YO'_QdO,5:jO'dQdO,5:lO'oQdO,5:sO'oQdO,5:uO'oQdO,5:vO'oQdO'#FXO,nQ`O,58}O,vQdO'#E^OOQS,58},58}OOQP'#Cq'#CqOOQO'#D|'#D|OOQP,59Y,59YO,}Q`O,59YO-SQ`O,59YOOQP'#EP'#EPOOQP,5:j,5:jO-XQpO'#ERO-dQdO'#ESO-iQ`O'#ESO-nQpO,5:lO.XQaO,5:sO.oQaO,5:vOOQW'#D^'#D^O/nQhO'#DgO0RQhO,5;iO)}QhO'#DeO0`Q`O'#DnO0eQhO'#DxOOQW'#Ft'#FtOOQS,5;i,5;iO0jQ`O'#DhO0oQ`O'#DkOOQS-E9O-E9OOOQ['#Cv'#CvO0tQdO'#CwO1[QdO'#C}O1rQdO'#DQO2YQ!pO'#DSO4fQ!jO,5:|OOQO'#DX'#DXO-SQ`O'#DWO4vQ!nO'#FqO6|Q`O'#DYO7RQ`O'#DyOOQ['#Fq'#FqO7WQhO'#GOO7fQ`O,5;SO7kQ!bO,5;UOOQS'#En'#EnO7sQ`O,5;WO7xQdO,5;WOOQO'#Eq'#EqO8QQ`O,5;ZO8VQhO,5;aO'oQdO'#DjOOQS,5;c,5;cO0jQ`O,5;cO8_QdO,5;cOOQS'#F`'#F`O8gQdO'#E|O7fQ`O,5;fO8oQdO,5:yO9PQdO'#FZO9^Q`O,5lQhO'#DoOOQW,5:Y,5:YOOQW,5:d,5:dOOQW,5:S,5:SO>vQhO,5:VO?bQ!fO'#FrOOQS'#Fr'#FrOOQS'#FS'#FSO@rQdO,59cOOQ[,59c,59cOAYQdO,59iOOQ[,59i,59iOApQdO,59lOOQ[,59l,59lOOQ[,59n,59nO)YQdO,59pOBWQhO'#EdOOQW'#Ed'#EdOBuQ`O1G0hO4oQhO1G0hOOQ[,59r,59rO)}QhO'#D[OOQ[,59t,59tOBzQ#tO,5:eOCVQhO'#F]OCdQ`O,5vQhO'#DmOI_QhO'#DqOIgQhO'#DsOIlQhO'#FwOOQO'#Fw'#FwOItQ!bO'#DwOOQO'#Fy'#FyOOQO'#Fv'#FvOIyQ`O1G/qOOQS-E9Q-E9QOOQ[1G.}1G.}OOQ[1G/T1G/TOOQ[1G/W1G/WOOQ[1G/[1G/[OJOQdO,5;OOOQS7+&S7+&SOJTQ`O7+&SOJYQhO'#D]OJbQ`O,59vO)}QhO,59vOOQ[1G0P1G0POJjQ`O1G0POJoQhO,5;wOOQO-E9Z-E9ZOOQS7+&^7+&^OJ}QbO'#DSOOQO'#Et'#EtOK]Q`O'#EsOOQO'#Es'#EsOKhQ`O'#F^OKpQdO,5;^OOQS,5;^,5;^OOQ[1G/p1G/pOOQS7+&i7+&iO7fQ`O7+&iOK{Q!fO'#FYO)YQdO'#FYOMSQdO7+&POOQO7+&P7+&POOQO,5:{,5:{OOQO1G1a1G1aOMgQ!bO<vQhO'#DrOOQO,5:],5:]O! hQhO,5:_OGUQhO,5:cOOQW7+%]7+%]OOQO'#Ef'#EfO! pQ`O1G0jOOQS<xAN>xO!#zQ`OAN>xO!$PQaO,5;rOOQO-E9U-E9UO!$ZQdO,5;qOOQO-E9T-E9TOOQW<vQhO'#DuOOQO1G/y1G/yO!%vQ!bO1G/}OJOQdO'#F[O!&OQ`O7+&UOOQW7+&U7+&UO!&WQ!bO1G/cOOQ[7+$|7+$|O!&cQhO7+$|P!&jQ`O'#FTOOQO,5;y,5;yOOQO-E9]-E9]OOQS1G1d1G1dOOQPG24dG24dO!&oQ`OAN>ZO)YQdO1G1[O!&tQ`O7+'jOOQO1G/x1G/xO!&|Q`O,5:aO!$eQhO7+%iOOQO,5;v,5;vOOQO-E9Y-E9YOOQW<Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!o`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$[~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%j~'yh$[~!o`OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%jj)jS$qYOy%jz;'S%j;'S;=`%{<%lO%j~)yWOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d<%lO)v~*hOw~~*kRO;'S)v;'S;=`*t;=`O)v~*wXOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d;=`<%l)v<%lO)v~+gP;=`<%l)vj+oYmYOy%jz!Q%j!Q![,_![!c%j!c!i,_!i#T%j#T#Z,_#Z;'S%j;'S;=`%{<%lO%jj,dY!o`Oy%jz!Q%j!Q![-S![!c%j!c!i-S!i#T%j#T#Z-S#Z;'S%j;'S;=`%{<%lO%jj-XY!o`Oy%jz!Q%j!Q![-w![!c%j!c!i-w!i#T%j#T#Z-w#Z;'S%j;'S;=`%{<%lO%jj.OYuY!o`Oy%jz!Q%j!Q![.n![!c%j!c!i.n!i#T%j#T#Z.n#Z;'S%j;'S;=`%{<%lO%jj.uYuY!o`Oy%jz!Q%j!Q![/e![!c%j!c!i/e!i#T%j#T#Z/e#Z;'S%j;'S;=`%{<%lO%jj/jY!o`Oy%jz!Q%j!Q![0Y![!c%j!c!i0Y!i#T%j#T#Z0Y#Z;'S%j;'S;=`%{<%lO%jj0aYuY!o`Oy%jz!Q%j!Q![1P![!c%j!c!i1P!i#T%j#T#Z1P#Z;'S%j;'S;=`%{<%lO%jj1UY!o`Oy%jz!Q%j!Q![1t![!c%j!c!i1t!i#T%j#T#Z1t#Z;'S%j;'S;=`%{<%lO%jj1{SuY!o`Oy%jz;'S%j;'S;=`%{<%lO%jd2[UOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jd2uS!yS!o`Oy%jz;'S%j;'S;=`%{<%lO%jb3WS^QOy%jz;'S%j;'S;=`%{<%lO%j~3gWOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{<%lO3d~4SRO;'S3d;'S;=`4];=`O3d~4`XOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{;=`<%l3d<%lO3d~5OP;=`<%l3dj5WShYOy%jz;'S%j;'S;=`%{<%lO%j~5iOg~n5pUWQyWOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jj6ZWyW#PQOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj6xU!o`Oy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%jj7cY!o`$gYOy%jz!Q%j!Q![7[![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj8WY!o`Oy%jz{%j{|8v|}%j}!O8v!O!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj8{U!o`Oy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj9fU!o`$gYOy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj:P[!o`$gYOy%jz!O%j!O!P7[!P!Q%j!Q![9x![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj:zS!dYOy%jz;'S%j;'S;=`%{<%lO%jj;]WyWOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj;zU`YOy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%j~VUcYOy%jz![%j![!]>i!];'S%j;'S;=`%{<%lO%jj>pSdY!o`Oy%jz;'S%j;'S;=`%{<%lO%jj?RSnYOy%jz;'S%j;'S;=`%{<%lO%jh?dU!WWOy%jz!_%j!_!`?v!`;'S%j;'S;=`%{<%lO%jh?}S!WW!o`Oy%jz;'S%j;'S;=`%{<%lO%jl@bS!WW!ySOy%jz;'S%j;'S;=`%{<%lO%jj@uV!|Q!WWOy%jz!_%j!_!`?v!`!aA[!a;'S%j;'S;=`%{<%lO%jbAcS!|Q!o`Oy%jz;'S%j;'S;=`%{<%lO%jjArYOy%jz}%j}!OBb!O!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjBgW!o`Oy%jz!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjCW[lY!o`Oy%jz}%j}!OCP!O!Q%j!Q![CP![!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jhDRS!zWOy%jz;'S%j;'S;=`%{<%lO%jjDdSpYOy%jz;'S%j;'S;=`%{<%lO%jnDuSo^Oy%jz;'S%j;'S;=`%{<%lO%jjEWU!zWOy%jz#a%j#a#bEj#b;'S%j;'S;=`%{<%lO%jbEoU!o`Oy%jz#d%j#d#eFR#e;'S%j;'S;=`%{<%lO%jbFWU!o`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!o`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!o`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!o`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!o`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!o`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$pQ!o`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$cUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#PQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[qnt,Hnt,Vnt,Xnt,1,2,3,4,new tT("m~RRYZ[z{a~~g~aO$_~~dP!P!Qg~lO$`~~",28,152)],topRules:{StyleSheet:[0,6],Styles:[1,126]},dynamicPrecedences:{94:1},specialized:[{term:147,get:e=>Gnt[e]||-1},{term:148,get:e=>Wnt[e]||-1},{term:4,get:e=>Znt[e]||-1},{term:28,get:e=>Knt[e]||-1},{term:146,get:e=>Jnt[e]||-1}],tokenPrec:2405});let Aj=null;function Nj(){if(!Aj&&typeof document=="object"&&document.body){let{style:e}=document.body,t=[],n=new Set;for(let i in e)i!="cssText"&&i!="cssFloat"&&typeof e[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())),n.has(i)||(t.push(i),n.add(i)));Aj=t.sort().map(i=>({type:"property",label:i,apply:i+": "}))}return Aj||[]}const jX=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(e=>({type:"class",label:e})),RX=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(e=>({type:"keyword",label:e})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(e=>({type:"constant",label:e}))),tit=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(e=>({type:"type",label:e})),nit=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(e=>({type:"keyword",label:e})),mu=/^(\w[\w-]*|-\w[\w-]*|)$/,iit=/^-(-[\w-]*)?$/;function rit(e,t){var n;if((e.name=="("||e.type.isError)&&(e=e.parent||e),e.name!="ArgList")return!1;let i=(n=e.parent)===null||n===void 0?void 0:n.firstChild;return(i==null?void 0:i.name)!="Callee"?!1:t.sliceString(i.from,i.to)=="var"}const IX=new t4,sit=["Declaration"];function ait(e){for(let t=e;;){if(t.type.isTop)return t;if(!(t=t.parent))return e}}function Kde(e,t,n){if(t.to-t.from>4096){let i=IX.get(t);if(i)return i;let r=[],s=new Set,a=t.cursor(si.IncludeAnonymous);if(a.firstChild())do for(let o of Kde(e,a.node,n))s.has(o.label)||(s.add(o.label),r.push(o));while(a.nextSibling());return IX.set(t,r),r}else{let i=[],r=new Set;return t.cursor().iterate(s=>{var a;if(n(s)&&s.matchContext(sit)&&((a=s.node.nextSibling)===null||a===void 0?void 0:a.name)==":"){let o=e.sliceString(s.from,s.to);r.has(o)||(r.add(o),i.push({label:o,type:"variable"}))}}),i}}const oit=e=>t=>{let{state:n,pos:i}=t,r=_i(n).resolveInner(i,-1),s=r.type.isError&&r.from==r.to-1&&n.doc.sliceString(r.from,r.to)=="-";if(r.name=="PropertyName"||(s||r.name=="TagName")&&/^(Block|Styles)$/.test(r.resolve(r.to).name))return{from:r.from,options:Nj(),validFor:mu};if(r.name=="ValueName")return{from:r.from,options:RX,validFor:mu};if(r.name=="PseudoClassName")return{from:r.from,options:jX,validFor:mu};if(e(r)||(t.explicit||s)&&rit(r,n.doc))return{from:e(r)||s?r.from:i,options:Kde(n.doc,ait(r),e),validFor:iit};if(r.name=="TagName"){for(let{parent:c}=r;c;c=c.parent)if(c.name=="Block")return{from:r.from,options:Nj(),validFor:mu};return{from:r.from,options:tit,validFor:mu}}if(r.name=="AtKeyword")return{from:r.from,options:nit,validFor:mu};if(!t.explicit)return null;let a=r.resolve(i),o=a.childBefore(i);return o&&o.name==":"&&a.name=="PseudoClassSelector"?{from:i,options:jX,validFor:mu}:o&&o.name==":"&&a.name=="Declaration"||a.name=="ArgList"?{from:i,options:RX,validFor:mu}:a.name=="Block"||a.name=="Styles"?{from:i,options:Nj(),validFor:mu}:null},lit=oit(e=>e.name=="VariableName"),ST=ud.define({name:"css",parser:eit.configure({props:[rh.add({Declaration:Pg()}),wd.add({"Block KeyframeList":ev})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function cit(){return new Yf(ST,ST.data.of({autocomplete:lit}))}const uO=["_blank","_self","_top","_parent"],Cj=["ascii","utf-8","utf-16","latin1","latin1"],jj=["get","post","put","delete"],Rj=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ka=["true","false"],$t={},uit={a:{attrs:{href:null,ping:null,type:null,media:null,target:uO,hreflang:null}},abbr:$t,address:$t,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:$t,aside:$t,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:$t,base:{attrs:{href:null,target:uO}},bdi:$t,bdo:$t,blockquote:{attrs:{cite:null}},body:$t,br:$t,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Rj,formmethod:jj,formnovalidate:["novalidate"],formtarget:uO,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:$t,center:$t,cite:$t,code:$t,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:$t,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:$t,div:$t,dl:$t,dt:$t,em:$t,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:$t,figure:$t,footer:$t,form:{attrs:{action:null,name:null,"accept-charset":Cj,autocomplete:["on","off"],enctype:Rj,method:jj,novalidate:["novalidate"],target:uO}},h1:$t,h2:$t,h3:$t,h4:$t,h5:$t,h6:$t,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:$t,hgroup:$t,hr:$t,html:{attrs:{manifest:null}},i:$t,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Rj,formmethod:jj,formnovalidate:["novalidate"],formtarget:uO,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:$t,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:$t,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:$t,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Cj,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:$t,noscript:$t,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:$t,param:{attrs:{name:null,value:null}},pre:$t,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:$t,rt:$t,ruby:$t,samp:$t,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Cj}},section:$t,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:$t,source:{attrs:{src:null,type:null,media:null}},span:$t,strong:$t,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:$t,summary:$t,sup:$t,table:$t,tbody:$t,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:$t,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:$t,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:$t,time:{attrs:{datetime:null}},title:$t,tr:$t,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:$t,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:$t},Jde={accesskey:null,class:null,contenteditable:Ka,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ka,autocorrect:Ka,autocapitalize:Ka,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ka,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ka,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ka,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ka,"aria-hidden":Ka,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ka,"aria-multiselectable":Ka,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ka,"aria-relevant":null,"aria-required":Ka,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},efe="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(e=>"on"+e);for(let e of efe)Jde[e]=null;class Gx{constructor(t,n){this.tags={...uit,...t},this.globalAttrs={...Jde,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Gx.default=new Gx;function k0(e,t,n=e.length){if(!t)return"";let i=t.firstChild,r=i&&i.getChild("TagName");return r?e.sliceString(r.from,Math.min(r.to,n)):""}function T0(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function tfe(e,t,n){let i=n.tags[k0(e,T0(t))];return(i==null?void 0:i.children)||n.allTags}function V4(e,t){let n=[];for(let i=T0(t);i&&!i.type.isTop;i=T0(i.parent)){let r=k0(e,i);if(r&&i.lastChild.name=="CloseTag")break;r&&n.indexOf(r)<0&&(t.name=="EndTag"||t.from>=i.firstChild.to)&&n.push(r)}return n}const nfe=/^[:\-\.\w\u00b7-\uffff]*$/;function PX(e,t,n,i,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">",a=T0(n,n.name=="StartTag"||n.name=="TagName");return{from:i,to:r,options:tfe(e.doc,a,t).map(o=>({label:o,type:"type"})).concat(V4(e.doc,n).map((o,c)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function MX(e,t,n,i){let r=/\s*>/.test(e.sliceDoc(i,i+5))?"":">";return{from:n,to:i,options:V4(e.doc,t).map((s,a)=>({label:s,apply:s+r,type:"type",boost:99-a})),validFor:nfe}}function dit(e,t,n,i){let r=[],s=0;for(let a of tfe(e.doc,n,t))r.push({label:"<"+a,type:"type"});for(let a of V4(e.doc,n))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function fit(e,t,n,i,r){let s=T0(n),a=s?t.tags[k0(e.doc,s)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],c=a&&a.globalAttrs===!1?o:o.length?o.concat(t.globalAttrNames):t.globalAttrNames;return{from:i,to:r,options:c.map(u=>({label:u,type:"property"})),validFor:nfe}}function hit(e,t,n,i,r){var s;let a=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),o=[],c;if(a){let u=e.sliceDoc(a.from,a.to),d=t.globalAttrs[u];if(!d){let f=T0(n),h=f?t.tags[k0(e.doc,f)]:null;d=(h==null?void 0:h.attrs)&&h.attrs[u]}if(d){let f=e.sliceDoc(i,r).toLowerCase(),h='"',p='"';/^['"]/.test(f)?(c=f[0]=='"'?/^[^"]*$/:/^[^']*$/,h="",p=e.sliceDoc(r,r+1)==f[0]?"":f[0],f=f.slice(1),i++):c=/^[^\s<>='"]*$/;for(let g of d)o.push({label:g,apply:h+g+p,type:"constant"})}}return{from:i,to:r,options:o,validFor:c}}function ife(e,t){let{state:n,pos:i}=t,r=_i(n).resolveInner(i,-1),s=r.resolve(i);for(let a=i,o;s==r&&(o=r.childBefore(a));){let c=o.lastChild;if(!c||!c.type.isError||c.fromife(i,r)}const git=Bc.parser.configure({top:"SingleExpression"}),rfe=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:dde.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:fde.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:hde.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:git},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Bc.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:ST.parser}],sfe=[{name:"style",parser:ST.parser.configure({top:"Styles"})}].concat(efe.map(e=>({name:e,parser:Bc.parser}))),afe=ud.define({name:"html",parser:_nt.configure({props:[rh.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].lengthe.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),yE=afe.configure({wrap:Hde(rfe,sfe)});function bit(e={}){let t="",n;e.matchClosingTags===!1&&(t="noMatch"),e.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Hde((e.nestedLanguages||[]).concat(rfe),(e.nestedAttributes||[]).concat(sfe)));let i=n?afe.configure({wrap:n,dialect:t}):t?yE.configure({dialect:t}):yE;return new Yf(i,[yE.data.of({autocomplete:mit(e)}),e.autoCloseTags!==!1?Oit:[],bL().support,cit().support])}const LX=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),Oit=ft.inputHandler.of((e,t,n,i,r)=>{if(e.composing||e.state.readOnly||t!=n||i!=">"&&i!="/"||!yE.isActiveAt(e.state,t,-1))return!1;let s=r(),{state:a}=s,o=a.changeByRange(c=>{var u,d,f;let h=a.doc.sliceString(c.from-1,c.to)==i,{head:p}=c,g=_i(a).resolveInner(p,-1),b;if(h&&i==">"&&g.name=="EndTag"){let y=g.parent;if(((d=(u=y.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=k0(a.doc,y.parent,p))&&!LX.has(b)){let O=p+(a.doc.sliceString(p,p+1)===">"?1:0),v=``;return{range:c,changes:{from:p,to:O,insert:v}}}}else if(h&&i=="/"&&g.name=="IncompleteCloseTag"){let y=g.parent;if(g.from==p-2&&((f=y.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(b=k0(a.doc,y,p))&&!LX.has(b)){let O=p+(a.doc.sliceString(p,p+1)===">"?1:0),v=`${b}>`;return{range:Qe.cursor(p+v.length,-1),changes:{from:p,to:O,insert:v}}}}return{range:c}});return o.changes.empty?!1:(e.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),ofe=w4({commentTokens:{block:{open:""}}}),lfe=new sn,cfe=Ntt.configure({props:[wd.add(e=>!e.is("Block")||e.is("Document")||EL(e)!=null||yit(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),lfe.add(EL),rh.add({Document:()=>null}),Xh.add({Document:ofe})]});function EL(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function yit(e){return e.name=="OrderedList"||e.name=="BulletList"}function xit(e,t){let n=e;for(;;){let i=n.nextSibling,r;if(!i||(r=EL(i.type))!=null&&r<=t)break;n=i}return n.to}const vit=Lue.of((e,t,n)=>{for(let i=_i(e).resolveInner(n,-1);i&&!(i.fromn)return{from:n,to:s}}return null});function X4(e){return new Go(ofe,e,[],"markdown")}const wit=X4(cfe),Sit=cfe.configure([Btt,ztt,Utt,Ftt,{props:[wd.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),ET=X4(Sit);function Eit(e,t){return n=>{if(n&&e){let i=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?i=e(n):i=pT.matchLanguageName(e,n,!0),i instanceof pT)return i.support?i.support.language.parser:Ux.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}let Ij=class{constructor(t,n,i,r,s,a,o){this.node=t,this.from=n,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=a,this.item=o}blank(t,n=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;i.length0;r--)i+=" ";return i+(n?this.spaceAfter:"")}}marker(t,n){let i=this.node.name=="OrderedList"?String(+dfe(this.item,t)[2]+n):"";return this.spaceBefore+i+this.type+this.spaceAfter}};function ufe(e,t){let n=[],i=[];for(let r=e;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&n.push(r)}for(let r=n.length-1;r>=0;r--){let s=n[r],a,o=t.lineAt(s.from),c=s.from-o.from;if(s.name=="Blockquote"&&(a=/^ *>( ?)/.exec(o.text.slice(c))))i.push(new Ij(s,c,c+a[0].length,"",a[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(c)))){let u=a[3],d=a[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),i.push(new Ij(s.parent,c,c+d,a[1],u,a[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(c)))){let u=a[4],d=a[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let f=a[2];a[3]&&(f+=a[3].replace(/[xX]/," ")),i.push(new Ij(s.parent,c,c+d,a[1],u,f,s))}}return i}function dfe(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Pj(e,t,n,i=0){for(let r=-1,s=e;;){if(s.name=="ListItem"){let o=dfe(s,t),c=+o[2];if(r>=0){if(c!=r+1)return;n.push({from:s.from+o[1].length,to:s.from+o[0].length,insert:String(r+2+i)})}r=c}let a=s.nextSibling;if(!a)break;s=a}}function q4(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(fb)!=" ")return e;let i=Bl(e,4,n),r="";for(let s=i;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+e.slice(n)}const kit=(e={})=>({state:t,dispatch:n})=>{let i=_i(t),{doc:r}=t,s=null,a=t.changeByRange(o=>{if(!o.empty||!ET.isActiveAt(t,o.from,-1)&&!ET.isActiveAt(t,o.from,1))return s={range:o};let c=o.from,u=r.lineAt(c),d=ufe(i.resolveInner(c,-1),r);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return s={range:o};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return s={range:o};let h=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&h){let O=f.node.firstChild,v=f.node.getChild("ListItem","ListItem");if(O.to>=c||v&&v.to0&&!/[^\s>]/.test(r.lineAt(u.from-1).text)||e.nonTightLists===!1){let x=d.length>1?d[d.length-2]:null,w,E="";x&&x.item?(w=u.from+x.from,E=x.marker(r,1)):w=u.from+(x?x.to:0);let S=[{from:w,to:c,insert:E}];return f.node.name=="OrderedList"&&Pj(f.item,r,S,-2),x&&x.node.name=="OrderedList"&&Pj(x.item,r,S),{range:Qe.cursor(w+E.length),changes:S}}else{let x=$X(d,t,u);return{range:Qe.cursor(c+x.length+1),changes:{from:u.from,insert:x+t.lineBreak}}}}if(f.node.name=="Blockquote"&&h&&u.from){let O=r.lineAt(u.from-1),v=/>\s*$/.exec(O.text);if(v&&v.index==f.from){let x=t.changes([{from:O.from+v.index,to:O.to},{from:u.from+f.from,to:u.to}]);return{range:o.map(x),changes:x}}}let p=[];f.node.name=="OrderedList"&&Pj(f.item,r,p);let g=f.item&&f.item.from]*/.exec(u.text)[0].length>=f.to)for(let O=0,v=d.length-1;O<=v;O++)b+=O==v&&!g?d[O].marker(r,1):d[O].blank(Ou.from&&/\s/.test(u.text.charAt(y-u.from-1));)y--;return b=q4(b,t),_it(f.node,t.doc)&&(b=$X(d,t,u)+t.lineBreak+b),p.push({from:y,to:c,insert:t.lineBreak+b}),{range:Qe.cursor(y+b.length+1),changes:p}});return s?!1:(n(t.update(a,{scrollIntoView:!0,userEvent:"input"})),!0)},Tit=kit();function DX(e){return e.name=="QuoteMark"||e.name=="ListMark"}function _it(e,t){if(e.name!="OrderedList"&&e.name!="BulletList")return!1;let n=e.firstChild,i=e.getChild("ListItem","ListItem");if(!i)return!1;let r=t.lineAt(n.to),s=t.lineAt(i.from),a=/^[\s>]*$/.test(r.text);return r.number+(a?0:1){let n=_i(e),i=null,r=e.changeByRange(s=>{let a=s.from,{doc:o}=e;if(s.empty&&ET.isActiveAt(e,s.from)){let c=o.lineAt(a),u=ufe(Ait(n,a),o);if(u.length){let d=u[u.length-1],f=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(a-c.from>f&&!/\S/.test(c.text.slice(f,a-c.from)))return{range:Qe.cursor(c.from+f),changes:{from:c.from+f,to:a}};if(a-c.from==f&&(d.item&&c.from<=d.item.from||/^[\s>]*$/.test(c.text.slice(0,d.to)))){let h=c.from+d.from;if(d.item&&d.node.from{var n;let{main:i}=t.state.selection;if(i.empty)return!1;let r=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!ET.isActiveAt(t.state,i.from,1)))return!1;let s=_i(t.state),a=!1;return s.iterate({from:i.from,to:i.to,enter:o=>{(o.from>i.from||Pit.test(o.name))&&(a=!0)},leave:o=>{o.to=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}const Mrt=new Lr((e,t)=>{let n;if(e.next<0)e.acceptToken(Qit);else if(t.context.flags&xE)Lj(e.next)&&e.acceptToken($it,1);else if(((n=e.peek(-1))<0||Lj(n))&&t.canShift(QX)){let i=0;for(;e.next==H4||e.next==zA;)e.advance(),i++;(e.next==Np||e.next==Wx||e.next==Y4)&&e.acceptToken(QX,-i)}else Lj(e.next)&&e.acceptToken(Dit,1)},{contextual:!0}),Lrt=new Lr((e,t)=>{let n=t.context;if(n.flags)return;let i=e.peek(-1);if(i==Np||i==Wx){let r=0,s=0;for(;;){if(e.next==H4)r++;else if(e.next==zA)r+=8-r%8;else break;e.advance(),s++}r!=n.indent&&e.next!=Np&&e.next!=Wx&&e.next!=Y4&&(r[e,t|yfe])),Qrt=new CA({start:Drt,reduce(e,t,n,i){return e.flags&xE&&Prt.has(t)||(t==nrt||t==gfe)&&e.flags&yfe?e.parent:e},shift(e,t,n,i){return t==hfe?new vE(e,$rt(i.read(i.pos,n.pos)),0):t==pfe?e.parent:t==zit||t==qit||t==Git||t==mfe?new vE(e,0,xE):FX.has(t)?new vE(e,0,FX.get(t)|e.flags&xE):e},hash(e){return e.hash}}),Brt=new Lr(e=>{for(let t=0;t<5;t++){if(e.next!="print".charCodeAt(t))return;e.advance()}if(!/\w/.test(String.fromCharCode(e.next)))for(let t=0;;t++){let n=e.peek(t);if(!(n==H4||n==zA)){n!=_rt&&n!=Art&&n!=Np&&n!=Wx&&n!=Y4&&e.acceptToken(Lit);return}}}),Urt=new Lr((e,t)=>{let{flags:n}=t.context,i=n&xu?Ofe:bfe,r=(n&vu)>0,s=!(n&wu),a=(n&Su)>0,o=e.pos;for(;!(e.next<0);)if(a&&e.next==kL)if(e.peek(1)==kL)e.advance(2);else{if(e.pos==o){e.acceptToken(mfe,1);return}break}else if(s&&e.next==zX){if(e.pos==o){e.advance();let c=e.next;c>=0&&(e.advance(),zrt(e,c)),e.acceptToken(Uit);return}break}else if(e.next==zX&&!s&&e.peek(1)>-1)e.advance(2);else if(e.next==i&&(!r||e.peek(1)==i&&e.peek(2)==i)){if(e.pos==o){e.acceptToken(BX,r?3:1);return}break}else if(e.next==Np){if(r)e.advance();else if(e.pos==o){e.acceptToken(BX);return}break}else e.advance();e.pos>o&&e.acceptToken(Bit)});function zrt(e,t){if(t==Nrt)for(let n=0;n<2&&e.next>=48&&e.next<=55;n++)e.advance();else if(t==Crt)for(let n=0;n<2&&Dj(e.next);n++)e.advance();else if(t==Rrt)for(let n=0;n<4&&Dj(e.next);n++)e.advance();else if(t==Irt)for(let n=0;n<8&&Dj(e.next);n++)e.advance();else if(t==jrt&&e.next==kL){for(e.advance();e.next>=0&&e.next!=UX&&e.next!=bfe&&e.next!=Ofe&&e.next!=Np;)e.advance();e.next==UX&&e.advance()}}const Frt=xd({'async "*" "**" FormatConversion FormatSpec':G.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":G.controlKeyword,"in not and or is del":G.operatorKeyword,"from def class global nonlocal lambda":G.definitionKeyword,import:G.moduleKeyword,"with as print":G.keyword,Boolean:G.bool,None:G.null,VariableName:G.variableName,"CallExpression/VariableName":G.function(G.variableName),"FunctionDefinition/VariableName":G.function(G.definition(G.variableName)),"ClassDefinition/VariableName":G.definition(G.className),PropertyName:G.propertyName,"CallExpression/MemberExpression/PropertyName":G.function(G.propertyName),Comment:G.lineComment,Number:G.number,String:G.string,FormatString:G.special(G.string),Escape:G.escape,UpdateOp:G.updateOperator,"ArithOp!":G.arithmeticOperator,BitOp:G.bitwiseOperator,CompareOp:G.compareOperator,AssignOp:G.definitionOperator,Ellipsis:G.punctuation,At:G.meta,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace,".":G.derefOperator,", ;":G.separator}),Vrt={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},Xrt=ad.deserialize({version:14,states:"##jQ`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#EnO0rQdO'#EtO0rQdO'#EwO4VQdO'#EyO4^QdO'#FOO4iQdO'#EzO0rQdO'#FOO1XQdO'#FQO1XQdO'#FVO4nQdO'#F[P4uOdO'#GpPOOO)CBd)CBdOOQS'#Ce'#CeOOQS'#Cf'#CfOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Cl'#ClO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO5TQdO'#DoOOQS,5:Y,5:YO5hQdO'#HdOOQS,5:],5:]O5uQ!fO,5:]O5zQtO,59YO1lQdO,59bO1lQdO,59bO1lQdO,59bO8jQdO,59bO8oQdO,59bO8vQdO,59jO8}QdO'#HTO:TQdO'#HSOOQS'#HS'#HSOOQS'#D['#D[O:lQdO,59aO'vQdO,59aO:zQdO,59aOOQS,59y,59yO;PQdO,5:RO'vQdO,5:ROOQS,5:Q,5:QO;_QdO,5:QO;dQdO,5:XO'vQdO,5:XO'vQdO,5:VOOQS,5:U,5:UO;uQdO,5:UO;zQdO,5:WOOOW'#Fy'#FyOOOOQS'#Ds'#DsOOQS1G/w1G/wOOQS1G.|1G.|O!/[QtO1G.|O!/cQtO1G.|O1lQdO1G.|O!0OQdO1G/UOOQS'#DZ'#DZO0rQdO,59tOOQS1G.{1G.{O!0VQdO1G/eO!0gQdO1G/eO!0oQdO1G/fO'vQdO'#H[O!0tQdO'#H[O!0yQtO1G.{O!1ZQdO,59iO!2aQdO,5=zO!2qQdO,5=zO!2yQdO1G/mO!3OQtO1G/mOOQS1G/l1G/lO!3`QdO,5=uO!4VQdO,5=uO0rQdO1G/qO!4tQdO1G/sO!4yQtO1G/sO!5ZQtO1G/qOOQS1G/p1G/pOOQS1G/r1G/rOOOW-E9w-E9wOOQS1G/{1G/{O!5kQdO'#HxO0rQdO'#HxO!5|QdO,5>cOOOW-E9x-E9xOOQS1G/|1G/|OOQS-E9{-E9{O!6[Q#xO1G2zO!6{QtO1G2zO'vQdO,5kOOQS1G1`1G1`O!8RQdO1G1`OOQS'#DV'#DVO0rQdO,5=qOOQS,5=q,5=qO!8WQdO'#FrO!8cQdO,59oO!8kQdO1G/XO!8uQtO,5=uOOQS1G3`1G3`OOQS,5:m,5:mO!9fQdO'#GtOOQS,5jO!;ZQdO,5>jO1XQdO,5>jO!;lQdO,5>iOOQS-E:R-E:RO!;qQdO1G0lO!;|QdO1G0lO!lO!lO!hO!=VQdO,5>hO!=hQdO'#EpO0rQdO1G0tO!=sQdO1G0tO!=xQgO1G0zO!AvQgO1G0}O!EqQdO,5>oO!E{QdO,5>oO!FTQtO,5>oO0rQdO1G1PO!F_QdO1G1PO4iQdO1G1UO!!vQdO1G1WOOQV,5;a,5;aO!FdQfO,5;aO!FiQgO1G1QO!JjQdO'#GZO4iQdO1G1QO4iQdO1G1QO!JzQdO,5>pO!KXQdO,5>pO1XQdO,5>pOOQV1G1U1G1UO!KaQdO'#FSO!KrQ!fO1G1WO!KzQdO1G1WOOQV1G1]1G1]O4iQdO1G1]O!LPQdO1G1]O!LXQdO'#F^OOQV1G1b1G1bO!#ZQtO1G1bPOOO1G2v1G2vP!L^OSO1G2vOOQS,5=},5=}OOQS'#Dp'#DpO0rQdO,5=}O!LfQdO,5=|O!LyQdO,5=|OOQS1G/u1G/uO!MRQdO,5>PO!McQdO,5>PO!MkQdO,5>PO!NOQdO,5>PO!N`QdO,5>POOQS1G3j1G3jOOQS7+$h7+$hO!8kQdO7+$pO#!RQdO1G.|O#!YQdO1G.|OOQS1G/`1G/`OOQS,5<`,5<`O'vQdO,5<`OOQS7+%P7+%PO#!aQdO7+%POOQS-E9r-E9rOOQS7+%Q7+%QO#!qQdO,5=vO'vQdO,5=vOOQS7+$g7+$gO#!vQdO7+%PO##OQdO7+%QO##TQdO1G3fOOQS7+%X7+%XO##eQdO1G3fO##mQdO7+%XOOQS,5<_,5<_O'vQdO,5<_O##rQdO1G3aOOQS-E9q-E9qO#$iQdO7+%]OOQS7+%_7+%_O#$wQdO1G3aO#%fQdO7+%_O#%kQdO1G3gO#%{QdO1G3gO#&TQdO7+%]O#&YQdO,5>dO#&sQdO,5>dO#&sQdO,5>dOOQS'#Dx'#DxO#'UO&jO'#DzO#'aO`O'#HyOOOW1G3}1G3}O#'fQdO1G3}O#'nQdO1G3}O#'yQ#xO7+(fO#(jQtO1G2UP#)TQdO'#GOOOQS,5nQdO,5sQdO1G4OOOQS-E9y-E9yO#?^QdO1G4OO<[QdO'#H{OOOO'#D{'#D{OOOO'#F|'#F|O#?oO&jO,5:fOOOW,5>e,5>eOOOW7+)i7+)iO#?zQdO7+)iO#@SQdO1G2zO#@mQdO1G2zP'vQdO'#FuO0rQdO<mO#BQQdO,5>mOOQS1G0v1G0vOOQS<rO#KgQdO,5>rO#KrQdO,5>rO#K}QdO,5>qO#L`QdO,5>qOOQS1G1Y1G1YOOQS,5;p,5;pOOQV<VAN>VO$ oQdO<cAN>cO0rQdO1G1|O$!PQtO1G1|P$!ZQdO'#FvOOQS1G2R1G2RP$!hQdO'#F{O$!uQdO7+)jO$#`QdO,5>gOOOO-E9z-E9zOOOW<tO$4{QdO,5>tO1XQdO,5vO$)nQdO,5>vOOQS1G1p1G1pOOQS,5<[,5<[OOQU7+'P7+'PO$+zQdO1G/iO$)nQdO,5wO$8zQdO,5>wOOQS1G1s1G1sOOQS7+'S7+'SP$)nQdO'#GdO$9SQdO1G4bO$9^QdO1G4bO$9fQdO1G4bOOQS7+%T7+%TO$9tQdO1G1tO$:SQtO'#FaO$:ZQdO,5<}OOQS,5<},5<}O$:iQdO1G4cOOQS-E:a-E:aO$)nQdO,5<|O$:pQdO,5<|O$:uQdO7+)|OOQS-E:`-E:`O$;PQdO7+)|O$)nQdO,5S~O%cOS%^OSSOS%]PQ~OPdOVaOfoOhYOopOs!POvqO!PrO!Q{O!T!SO!U!RO!XZO!][O!h`O!r`O!s`O!t`O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#l!QO#o!TO#s!UO#u!VO#z!WO#}hO$P!XO%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~O%]!YO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%j![O%k!]O%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aO~Ok%xXl%xXm%xXn%xXo%xXp%xXs%xXz%xX{%xX!x%xX#g%xX%[%xX%_%xX%z%xXg%xX!T%xX!U%xX%{%xX!W%xX![%xX!Q%xX#[%xXt%xX!m%xX~P%SOfoOhYO!XZO!][O!h`O!r`O!s`O!t`O%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~Oz%wX{%wX#g%wX%[%wX%_%wX%z%wX~Ok!pOl!qOm!oOn!oOo!rOp!sOs!tO!x%wX~P)pOV!zOg!|Oo0cOv0qO!PrO~P'vOV#OOo0cOv0qO!W#PO~P'vOV#SOa#TOo0cOv0qO![#UO~P'vOQ#XO%`#XO%a#ZO~OQ#^OR#[O%`#^O%a#`O~OV%iX_%iXa%iXh%iXk%iXl%iXm%iXn%iXo%iXp%iXs%iXz%iX!X%iX!f%iX%j%iX%k%iX%l%iX%m%iX%n%iX%o%iX%p%iX%q%iX%r%iX%s%iXg%iX!T%iX!U%iX~O&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O{%iX!x%iX#g%iX%[%iX%_%iX%z%iX%{%iX!W%iX![%iX!Q%iX#[%iXt%iX!m%iX~P,eOz#dO{%hX!x%hX#g%hX%[%hX%_%hX%z%hX~Oo0cOv0qO~P'vO#g#gO%[#iO%_#iO~O%uWO~O!T#nO#u!VO#z!WO#}hO~OopO~P'vOV#sOa#tO%uWO{wP~OV#xOo0cOv0qO!Q#yO~P'vO{#{O!x$QO%z#|O#g!yX%[!yX%_!yX~OV#xOo0cOv0qO#g#SX%[#SX%_#SX~P'vOo0cOv0qO#g#WX%[#WX%_#WX~P'vOh$WO%uWO~O!f$YO!r$YO%uWO~OV$eO~P'vO!U$gO#s$hO#u$iO~O{$jO~OV$qO~P'vOS$sO%[$rO%_$rO%c$tO~OV$}Oa$}Og%POo0cOv0qO~P'vOo0cOv0qO{%SO~P'vO&Y%UO~Oa!bOh!iO!X!kO!f!mOVba_bakbalbambanbaobapbasbazba{ba!xba#gba%[ba%_ba%jba%kba%lba%mba%nba%oba%pba%qba%rba%sba%zbagba!Tba!Uba%{ba!Wba![ba!Qba#[batba!mba~On%ZO~Oo%ZO~P'vOo0cO~P'vOk0eOl0fOm0dOn0dOo0mOp0nOs0rOg%wX!T%wX!U%wX%{%wX!W%wX![%wX!Q%wX#[%wX!m%wX~P)pO%{%]Og%vXz%vX!T%vX!U%vX!W%vX{%vX~Og%_Oz%`O!T%dO!U%cO~Og%_O~Oz%gO!T%dO!U%cO!W&SX~O!W%kO~Oz%lO{%nO!T%dO!U%cO![%}X~O![%rO~O![%sO~OQ#XO%`#XO%a%uO~OV%wOo0cOv0qO!PrO~P'vOQ#^OR#[O%`#^O%a%zO~OV!qa_!qaa!qah!qak!qal!qam!qan!qao!qap!qas!qaz!qa{!qa!X!qa!f!qa!x!qa#g!qa%[!qa%_!qa%j!qa%k!qa%l!qa%m!qa%n!qa%o!qa%p!qa%q!qa%r!qa%s!qa%z!qag!qa!T!qa!U!qa%{!qa!W!qa![!qa!Q!qa#[!qat!qa!m!qa~P#yOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P%SOV&OOopOvqO{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P'vOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#g$zX%[$zX%_$zX~P'vO#g#gO%[&TO%_&TO~O!f&UOh&sX%[&sXz&sX#[&sX#g&sX%_&sX#Z&sXg&sX~Oh!iO%[&WO~Okealeameaneaoeapeaseazea{ea!xea#gea%[ea%_ea%zeagea!Tea!Uea%{ea!Wea![ea!Qea#[eatea!mea~P%SOsqazqa{qa#gqa%[qa%_qa%zqa~Ok!pOl!qOm!oOn!oOo!rOp!sO!xqa~PEcO%z&YOz%yX{%yX~O%uWOz%yX{%yX~Oz&]O{wX~O{&_O~Oz%lO#g%}X%[%}X%_%}Xg%}X{%}X![%}X!m%}X%z%}X~OV0lOo0cOv0qO!PrO~P'vO%z#|O#gUa%[Ua%_Ua~Oz&hO#g&PX%[&PX%_&PXn&PX~P%SOz&kO!Q&jO#g#Wa%[#Wa%_#Wa~Oz&lO#[&nO#g&rX%[&rX%_&rXg&rX~O!f$YO!r$YO#Z&qO%uWO~O#Z&qO~Oz&sO#g&tX%[&tX%_&tX~Oz&uO#g&pX%[&pX%_&pX{&pX~O!X&wO%z&xO~Oz&|On&wX~P%SOn'PO~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO%['UO~P'vOt'YO#p'WO#q'XOP#naV#naf#nah#nao#nas#nav#na!P#na!Q#na!T#na!U#na!X#na!]#na!h#na!r#na!s#na!t#na!{#na!}#na#P#na#R#na#T#na#X#na#Z#na#^#na#_#na#a#na#c#na#l#na#o#na#s#na#u#na#z#na#}#na$P#na%X#na%o#na%p#na%t#na%u#na&Z#na&[#na&]#na&^#na&_#na&`#na&a#na&b#na&c#na&d#na&e#na&f#na&g#na&h#na&i#na&j#na%Z#na%_#na~Oz'ZO#[']O{&xX~Oh'_O!X&wO~Oh!iO{$jO!X&wO~O{'eO~P%SO%['hO%_'hO~OS'iO%['hO%_'hO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%k!]O~P!#uO%kWi~P!#uOV!aO_!aOa!bOh!iO!X!kO!f!mO%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%m!_O%n!_O~P!&pO%mWi%nWi~P!&pOa!bOh!iO!X!kO!f!mOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%mWi%nWi%oWi%pWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~OV!aO_!aO%q!aO%r!aO%s!aO~P!)nOVWi_Wi%qWi%rWi%sWi~P!)nO!T%dO!U%cOg&VXz&VX~O%z'kO%{'kO~P,eOz'mOg&UX~Og'oO~Oz'pO{'rO!W&XX~Oo0cOv0qOz'pO{'sO!W&XX~P'vO!W'uO~Om!oOn!oOo!rOp!sOkjisjizji{ji!xji#gji%[ji%_ji%zji~Ol!qO~P!.aOlji~P!.aOk0eOl0fOm0dOn0dOo0mOp0nO~Ot'wO~P!/jOV'|Og'}Oo0cOv0qO~P'vOg'}Oz(OO~Og(QO~O!U(SO~Og(TOz(OO!T%dO!U%cO~P%SOk0eOl0fOm0dOn0dOo0mOp0nOgqa!Tqa!Uqa%{qa!Wqa![qa!Qqa#[qatqa!mqa~PEcOV'|Oo0cOv0qO!W&Sa~P'vOz(WO!W&Sa~O!W(XO~Oz(WO!T%dO!U%cO!W&Sa~P%SOV(]Oo0cOv0qO![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~P'vOz(^O![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~O![(aO~Oz(^O!T%dO!U%cO![%}a~P%SOz(dO!T%dO!U%cO![&Ta~P%SOz(gO{&lX![&lX!m&lX%z&lX~O{(kO![(mO!m(nO%z(jO~OV&OOopOvqO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~P'vOz(pO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~O!f&UOh&sa%[&saz&sa#[&sa#g&sa%_&sa#Z&sag&sa~O%[(uO~OV#sOa#tO%uWO~Oz&]O{wa~OopOvqO~P'vOz(^O#g%}a%[%}a%_%}ag%}a{%}a![%}a!m%}a%z%}a~P%SOz(zO#g%hX%[%hX%_%hX%z%hX~O%z#|O#gUi%[Ui%_Ui~O#g&Pa%[&Pa%_&Pan&Pa~P'vOz(}O#g&Pa%[&Pa%_&Pan&Pa~O%uWO#g&ra%[&ra%_&rag&ra~Oz)SO#g&ra%[&ra%_&rag&ra~Og)VO~OV)WOh$WO%uWO~O#Z)XO~O%uWO#g&ta%[&ta%_&ta~Oz)ZO#g&ta%[&ta%_&ta~Oo0cOv0qO#g&pa%[&pa%_&pa{&pa~P'vOz)^O#g&pa%[&pa%_&pa{&pa~OV)`Oa)`O%uWO~O%z)eO~Ot)hO#j)gOP#hiV#hif#hih#hio#his#hiv#hi!P#hi!Q#hi!T#hi!U#hi!X#hi!]#hi!h#hi!r#hi!s#hi!t#hi!{#hi!}#hi#P#hi#R#hi#T#hi#X#hi#Z#hi#^#hi#_#hi#a#hi#c#hi#l#hi#o#hi#s#hi#u#hi#z#hi#}#hi$P#hi%X#hi%o#hi%p#hi%t#hi%u#hi&Z#hi&[#hi&]#hi&^#hi&_#hi&`#hi&a#hi&b#hi&c#hi&d#hi&e#hi&f#hi&g#hi&h#hi&i#hi&j#hi%Z#hi%_#hi~Ot)iOP#kiV#kif#kih#kio#kis#kiv#ki!P#ki!Q#ki!T#ki!U#ki!X#ki!]#ki!h#ki!r#ki!s#ki!t#ki!{#ki!}#ki#P#ki#R#ki#T#ki#X#ki#Z#ki#^#ki#_#ki#a#ki#c#ki#l#ki#o#ki#s#ki#u#ki#z#ki#}#ki$P#ki%X#ki%o#ki%p#ki%t#ki%u#ki&Z#ki&[#ki&]#ki&^#ki&_#ki&`#ki&a#ki&b#ki&c#ki&d#ki&e#ki&f#ki&g#ki&h#ki&i#ki&j#ki%Z#ki%_#ki~OV)kOn&wa~P'vOz)lOn&wa~Oz)lOn&wa~P%SOn)pO~O%Y)tO~Ot)wO#p'WO#q)vOP#niV#nif#nih#nio#nis#niv#ni!P#ni!Q#ni!T#ni!U#ni!X#ni!]#ni!h#ni!r#ni!s#ni!t#ni!{#ni!}#ni#P#ni#R#ni#T#ni#X#ni#Z#ni#^#ni#_#ni#a#ni#c#ni#l#ni#o#ni#s#ni#u#ni#z#ni#}#ni$P#ni%X#ni%o#ni%p#ni%t#ni%u#ni&Z#ni&[#ni&]#ni&^#ni&_#ni&`#ni&a#ni&b#ni&c#ni&d#ni&e#ni&f#ni&g#ni&h#ni&i#ni&j#ni%Z#ni%_#ni~OV)zOo0cOv0qO{$jO~P'vOo0cOv0qO{&xa~P'vOz*OO{&xa~OV*SOa*TOg*WO%q*UO%uWO~O{$jO&{*YO~Oh'_O~Oh!iO{$jO~O%[*_O~O%[*aO%_*aO~OV$}Oa$}Oo0cOv0qOg&Ua~P'vOz*dOg&Ua~Oo0cOv0qO{*gO!W&Xa~P'vOz*hO!W&Xa~Oo0cOv0qOz*hO{*kO!W&Xa~P'vOo0cOv0qOz*hO!W&Xa~P'vOz*hO{*kO!W&Xa~Om0dOn0dOo0mOp0nOgjikjisjizji!Tji!Uji%{ji!Wji{ji![ji#gji%[ji%_ji!Qji#[jitji!mji%zji~Ol0fO~P!NkOlji~P!NkOV'|Og*pOo0cOv0qO~P'vOn*rO~Og*pOz*tO~Og*uO~OV'|Oo0cOv0qO!W&Si~P'vOz*vO!W&Si~O!W*wO~OV(]Oo0cOv0qO![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~P'vOz*zO!T%dO!U%cO![&Ti~Oz*}O![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~O![+OO~Oa+QOo0cOv0qO![&Ti~P'vOz*zO![&Ti~O![+SO~OV+UOo0cOv0qO{&la![&la!m&la%z&la~P'vOz+VO{&la![&la!m&la%z&la~O!]+YO&n+[O![!nX~O![+^O~O{(kO![+_O~O{(kO![+_O!m+`O~OV&OOopOvqO{%hq!x%hq#g%hq%[%hq%_%hq%z%hq~P'vOz$ri{$ri!x$ri#g$ri%[$ri%_$ri%z$ri~P%SOV&OOopOvqO~P'vOV&OOo0cOv0qO#g%ha%[%ha%_%ha%z%ha~P'vOz+aO#g%ha%[%ha%_%ha%z%ha~Oz$ia#g$ia%[$ia%_$ian$ia~P%SO#g&Pi%[&Pi%_&Pin&Pi~P'vOz+dO#g#Wq%[#Wq%_#Wq~O#[+eOz$va#g$va%[$va%_$vag$va~O%uWO#g&ri%[&ri%_&rig&ri~Oz+gO#g&ri%[&ri%_&rig&ri~OV+iOh$WO%uWO~O%uWO#g&ti%[&ti%_&ti~Oo0cOv0qO#g&pi%[&pi%_&pi{&pi~P'vO{#{Oz#eX!W#eX~Oz+mO!W&uX~O!W+oO~Ot+rO#j)gOP#hqV#hqf#hqh#hqo#hqs#hqv#hq!P#hq!Q#hq!T#hq!U#hq!X#hq!]#hq!h#hq!r#hq!s#hq!t#hq!{#hq!}#hq#P#hq#R#hq#T#hq#X#hq#Z#hq#^#hq#_#hq#a#hq#c#hq#l#hq#o#hq#s#hq#u#hq#z#hq#}#hq$P#hq%X#hq%o#hq%p#hq%t#hq%u#hq&Z#hq&[#hq&]#hq&^#hq&_#hq&`#hq&a#hq&b#hq&c#hq&d#hq&e#hq&f#hq&g#hq&h#hq&i#hq&j#hq%Z#hq%_#hq~On$|az$|a~P%SOV)kOn&wi~P'vOz+yOn&wi~Oz,TO{$jO#[,TO~O#q,VOP#nqV#nqf#nqh#nqo#nqs#nqv#nq!P#nq!Q#nq!T#nq!U#nq!X#nq!]#nq!h#nq!r#nq!s#nq!t#nq!{#nq!}#nq#P#nq#R#nq#T#nq#X#nq#Z#nq#^#nq#_#nq#a#nq#c#nq#l#nq#o#nq#s#nq#u#nq#z#nq#}#nq$P#nq%X#nq%o#nq%p#nq%t#nq%u#nq&Z#nq&[#nq&]#nq&^#nq&_#nq&`#nq&a#nq&b#nq&c#nq&d#nq&e#nq&f#nq&g#nq&h#nq&i#nq&j#nq%Z#nq%_#nq~O#[,WOz%Oa{%Oa~Oo0cOv0qO{&xi~P'vOz,YO{&xi~O{#{O%z,[Og&zXz&zX~O%uWOg&zXz&zX~Oz,`Og&yX~Og,bO~O%Y,eO~O!T%dO!U%cOg&Viz&Vi~OV$}Oa$}Oo0cOv0qOg&Ui~P'vO{,hOz$la!W$la~Oo0cOv0qO{,iOz$la!W$la~P'vOo0cOv0qO{*gO!W&Xi~P'vOz,lO!W&Xi~Oo0cOv0qOz,lO!W&Xi~P'vOz,lO{,oO!W&Xi~Og$hiz$hi!W$hi~P%SOV'|Oo0cOv0qO~P'vOn,qO~OV'|Og,rOo0cOv0qO~P'vOV'|Oo0cOv0qO!W&Sq~P'vOz$gi![$gi#g$gi%[$gi%_$gig$gi{$gi!m$gi%z$gi~P%SOV(]Oo0cOv0qO~P'vOa+QOo0cOv0qO![&Tq~P'vOz,sO![&Tq~O![,tO~OV(]Oo0cOv0qO![%}q#g%}q%[%}q%_%}qg%}q{%}q!m%}q%z%}q~P'vO{,uO~OV+UOo0cOv0qO{&li![&li!m&li%z&li~P'vOz,zO{&li![&li!m&li%z&li~O!]+YO&n+[O![!na~O{(kO![,}O~OV&OOo0cOv0qO#g%hi%[%hi%_%hi%z%hi~P'vOz-OO#g%hi%[%hi%_%hi%z%hi~O%uWO#g&rq%[&rq%_&rqg&rq~Oz-RO#g&rq%[&rq%_&rqg&rq~OV)`Oa)`O%uWO!W&ua~Oz-TO!W&ua~On$|iz$|i~P%SOV)kO~P'vOV)kOn&wq~P'vOt-XOP#myV#myf#myh#myo#mys#myv#my!P#my!Q#my!T#my!U#my!X#my!]#my!h#my!r#my!s#my!t#my!{#my!}#my#P#my#R#my#T#my#X#my#Z#my#^#my#_#my#a#my#c#my#l#my#o#my#s#my#u#my#z#my#}#my$P#my%X#my%o#my%p#my%t#my%u#my&Z#my&[#my&]#my&^#my&_#my&`#my&a#my&b#my&c#my&d#my&e#my&f#my&g#my&h#my&i#my&j#my%Z#my%_#my~O%Z-]O%_-]O~P`O#q-^OP#nyV#nyf#nyh#nyo#nys#nyv#ny!P#ny!Q#ny!T#ny!U#ny!X#ny!]#ny!h#ny!r#ny!s#ny!t#ny!{#ny!}#ny#P#ny#R#ny#T#ny#X#ny#Z#ny#^#ny#_#ny#a#ny#c#ny#l#ny#o#ny#s#ny#u#ny#z#ny#}#ny$P#ny%X#ny%o#ny%p#ny%t#ny%u#ny&Z#ny&[#ny&]#ny&^#ny&_#ny&`#ny&a#ny&b#ny&c#ny&d#ny&e#ny&f#ny&g#ny&h#ny&i#ny&j#ny%Z#ny%_#ny~Oz-aO{$jO#[-aO~Oo0cOv0qO{&xq~P'vOz-dO{&xq~O%z,[Og&zaz&za~O{#{Og&zaz&za~OV*SOa*TO%q*UO%uWOg&ya~Oz-hOg&ya~O$S-lO~OV$}Oa$}Oo0cOv0qO~P'vOo0cOv0qO{-mOz$li!W$li~P'vOo0cOv0qOz$li!W$li~P'vO{-mOz$li!W$li~Oo0cOv0qO{*gO~P'vOo0cOv0qO{*gO!W&Xq~P'vOz-pO!W&Xq~Oo0cOv0qOz-pO!W&Xq~P'vOs-sO!T%dO!U%cOg&Oq!W&Oq![&Oqz&Oq~P!/jOa+QOo0cOv0qO![&Ty~P'vOz$ji![$ji~P%SOa+QOo0cOv0qO~P'vOV+UOo0cOv0qO~P'vOV+UOo0cOv0qO{&lq![&lq!m&lq%z&lq~P'vO{(kO![-xO!m-yO%z-wO~OV&OOo0cOv0qO#g%hq%[%hq%_%hq%z%hq~P'vO%uWO#g&ry%[&ry%_&ryg&ry~OV)`Oa)`O%uWO!W&ui~Ot-}OP#m!RV#m!Rf#m!Rh#m!Ro#m!Rs#m!Rv#m!R!P#m!R!Q#m!R!T#m!R!U#m!R!X#m!R!]#m!R!h#m!R!r#m!R!s#m!R!t#m!R!{#m!R!}#m!R#P#m!R#R#m!R#T#m!R#X#m!R#Z#m!R#^#m!R#_#m!R#a#m!R#c#m!R#l#m!R#o#m!R#s#m!R#u#m!R#z#m!R#}#m!R$P#m!R%X#m!R%o#m!R%p#m!R%t#m!R%u#m!R&Z#m!R&[#m!R&]#m!R&^#m!R&_#m!R&`#m!R&a#m!R&b#m!R&c#m!R&d#m!R&e#m!R&f#m!R&g#m!R&h#m!R&i#m!R&j#m!R%Z#m!R%_#m!R~Oo0cOv0qO{&xy~P'vOV*SOa*TO%q*UO%uWOg&yi~O$S-lO%Z.VO%_.VO~OV.aOh._O!X.^O!].`O!h.YO!s.[O!t.[O%p.XO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O~Oo0cOv0qOz$lq!W$lq~P'vO{.fOz$lq!W$lq~Oo0cOv0qO{*gO!W&Xy~P'vOz.gO!W&Xy~Oo0cOv.kO~P'vOs-sO!T%dO!U%cOg&Oy!W&Oy![&Oyz&Oy~P!/jO{(kO![.nO~O{(kO![.nO!m.oO~OV*SOa*TO%q*UO%uWO~Oh.tO!f.rOz$TX#[$TX%j$TXg$TX~Os$TX{$TX!W$TX![$TX~P$-bO%o.vO%p.vOs$UXz$UX{$UX#[$UX%j$UX!W$UXg$UX![$UX~O!h.xO~Oz.|O#[/OO%j.yOs&|X{&|X!W&|Xg&|X~Oa/RO~P$)zOh.tOs&}Xz&}X{&}X#[&}X%j&}X!W&}Xg&}X![&}X~Os/VO{$jO~Oo0cOv0qOz$ly!W$ly~P'vOo0cOv0qO{*gO!W&X!R~P'vOz/ZO!W&X!R~Og&RXs&RX!T&RX!U&RX!W&RX![&RXz&RX~P!/jOs-sO!T%dO!U%cOg&Qa!W&Qa![&Qaz&Qa~O{(kO![/^O~O!f.rOh$[as$[az$[a{$[a#[$[a%j$[a!W$[ag$[a![$[a~O!h/eO~O%o.vO%p.vOs$Uaz$Ua{$Ua#[$Ua%j$Ua!W$Uag$Ua![$Ua~O%j.yOs$Yaz$Ya{$Ya#[$Ya!W$Yag$Ya![$Ya~Os&|a{&|a!W&|ag&|a~P$)nOz/jOs&|a{&|a!W&|ag&|a~O!W/mO~Og/mO~O{/oO~O![/pO~Oo0cOv0qO{*gO!W&X!Z~P'vO{/sO~O%z/tO~P$-bOz/uO#[/OO%j.yOg'PX~Oz/uOg'PX~Og/wO~O!h/xO~O#[/OOs%Saz%Sa{%Sa%j%Sa!W%Sag%Sa![%Sa~O#[/OO%j.yOs%Waz%Wa{%Wa!W%Wag%Wa~Os&|i{&|i!W&|ig&|i~P$)nOz/zO#[/OO%j.yO!['Oa~Og'Pa~P$)nOz0SOg'Pa~Oa0UO!['Oi~P$)zOz0WO!['Oi~Oz0WO#[/OO%j.yO!['Oi~O#[/OO%j.yOg$biz$bi~O%z0ZO~P$-bO#[/OO%j.yOg%Vaz%Va~Og'Pi~P$)nO{0^O~Oa0UO!['Oq~P$)zOz0`O!['Oq~O#[/OO%j.yOz%Ui![%Ui~Oa0UO~P$)zOa0UO!['Oy~P$)zO#[/OO%j.yOg$ciz$ci~O#[/OO%j.yOz%Uq![%Uq~Oz+aO#g%ha%[%ha%_%ha%z%ha~P%SOV&OOo0cOv0qO~P'vOn0hO~Oo0hO~P'vO{0iO~Ot0jO~P!/jO&]&Z&j&h&i&g&f&d&e&c&b&`&a&_&^&[%u~",goto:"!=j'QPPPPPP'RP'Z*s+[+t,_,y-fP.SP'Z.r.r'ZPPP'Z2[PPPPPP2[5PPP5PP7b7k=sPP=v>h>kPP'Z'ZPP>zPP'Z'ZPP'Z'Z'Z'Z'Z?O?w'ZP?zP@QDXGuGyPG|HWH['ZPPPH_Hk'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RP'RPHqH}IVPI^IdPI^PI^I^PPPI^PKrPK{LVL]KrPI^LfPI^PLmLsPLwM]MzNeLwLwNkNxLwLwLwLw! ^! d! g! l! o! y!!P!!]!!o!!u!#P!#V!#s!#y!$P!$Z!$a!$g!$y!%T!%Z!%a!%k!%q!%w!%}!&T!&Z!&e!&k!&u!&{!'U!'[!'k!'s!'}!(UPPPPPPPPPPP!([!(_!(e!(n!(x!)TPPPPPPPPPPPP!-u!/Z!3^!6oPP!6w!7W!7a!8Y!8P!8c!8i!8l!8o!8r!8z!9jPPPPPPPPPPPPPPPPP!9m!9q!9wP!:]!:a!:m!:v!;S!;j!;m!;p!;v!;|!_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY%oY[%T[]%o]p%Tpq%oq#O%T#O#P&o#P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To&tX&n`OY%TYZ%oZ]%T]^%o^#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc'f[&n`O!_%T!_!`([!`#T%T#T#U(r#U#f%T#f#g(r#g#h(r#h#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(cTmR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(yT!mR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk)aV&n`&[ZOr%Trs)vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk){V&n`Or%Trs*bs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk*iT&n`&^ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To+PZS_&n`OY*xYZ%TZ]*x]^%T^#o*x#o#p+r#p#q*x#q#r+r#r;'S*x;'S;=`,^<%lO*x_+wTS_OY+rZ]+r^;'S+r;'S;=`,W<%lO+r_,ZP;=`<%l+ro,aP;=`<%l*xj,kV%rQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-XT!xY&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-oV%lQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.]V&n`&ZZOw%Twx.rx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.wV&n`Ow%Twx/^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/eT&n`&]ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/{ThZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc0cTgR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk0yXVZ&n`Oz%Tz{1f{!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk1mVaR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk2ZV%oZ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc2wTzR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To3_W%pZ&n`O!_%T!_!`-Q!`!a3w!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Td4OT&{S&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk4fX!fQ&n`O!O%T!O!P5R!P!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5WV&n`O!O%T!O!P5m!P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5tT!rZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti6[a!hX&n`O!Q%T!Q![6T![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S6T#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti7fZ&n`O{%T{|8X|}%T}!O8X!O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8^V&n`O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8z]!hX&n`O!Q%T!Q![8s![!l%T!l!m9s!m#R%T#R#S8s#S#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti9zT!hX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk:bX%qR&n`O!P%T!P!Q:}!Q!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj;UV%sQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti;ro!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!d%T!d!e?q!e!g%T!g!h7a!h!l%T!l!m9s!m!q%T!q!rA]!r!z%T!z!{Bq!{#R%T#R#S>_#S#U%T#U#V?q#V#X%T#X#Y7a#Y#^%T#^#_9s#_#c%T#c#dA]#d#l%T#l#mBq#m#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti=xV&n`O!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti>fc!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S>_#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti?vY&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti@mY!hX&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiAbX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBUX!hX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBv]&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiCv]!hX&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToDvV{_&n`O!_%T!_!`E]!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TcEdT%{R&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkEzT#gZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkFbXmR&n`O!^%T!^!_F}!_!`([!`!a([!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjGUV%mQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkGrV%zZ&n`O!_%T!_!`([!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkH`WmR&n`O!_%T!_!`([!`!aHx!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjIPV%nQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkIoV_Q#}P&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToJ_]&n`&YS%uZO!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoKZP;=`<%lJUoKge&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!tJU!t!uLx!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#gLx#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoMRa&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUkN_V&n`&`ZOr%TrsNts#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkNyV&n`Or%Trs! `s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! gT&n`&bZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! }V&n`&_ZOw%Twx!!dx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!!iV&n`Ow%Twx!#Ox#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!#VT&n`&aZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!#oe&n`&YS%uZOr%Trs!%Qsw%Twx!&px!Q%T!Q![JU![!c%T!c!tJU!t!u!(`!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#g!(`#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!%XV&n`&dZOr%Trs!%ns#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!%sV&n`Or%Trs!&Ys#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&aT&n`&fZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&wV&n`&cZOw%Twx!'^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!'cV&n`Ow%Twx!'xx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!(PT&n`&eZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!(ia&n`&YS%uZOr%Trs!)nsw%Twx!+^x!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!)uV&n`&hZOr%Trs!*[s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*aV&n`Or%Trs!*vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*}T&n`&jZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!+eV&n`&gZOw%Twx!+zx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,PV&n`Ow%Twx!,fx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,mT&n`&iZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!-Vi&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!dJU!d!eLx!e!hJU!h!i!(`!i!}JU!}#R%T#R#SJU#S#T%T#T#UJU#U#VLx#V#YJU#Y#Z!(`#Z#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUo!.}a&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!0ZT!XZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc!0qT!WR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj!1XV%kQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[Brt,Lrt,Mrt,Urt,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:e=>Vrt[e]||-1}],tokenPrec:7668}),VX=new t4,xfe=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function lS(e){return(t,n,i)=>{if(i)return!1;let r=t.node.getChild("VariableName");return r&&n(r,e),!0}}const qrt={FunctionDefinition:lS("function"),ClassDefinition:lS("class"),ForStatement(e,t,n){if(n){for(let i=e.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")t(i,"variable");else if(i.name=="in")break}},ImportStatement(e,t){var n,i;let{node:r}=e,s=((n=r.firstChild)===null||n===void 0?void 0:n.name)=="from";for(let a=r.getChild("import");a;a=a.nextSibling)a.name=="VariableName"&&((i=a.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&t(a,s?"variable":"namespace")},AssignStatement(e,t){for(let n=e.node.firstChild;n;n=n.nextSibling)if(n.name=="VariableName")t(n,"variable");else if(n.name==":"||n.name=="AssignOp")break},ParamList(e,t){for(let n=null,i=e.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!n||!/\*|AssignOp/.test(n.name))&&t(i,"variable"),n=i},CapturePattern:lS("variable"),AsPattern:lS("variable"),__proto__:null};function vfe(e,t){let n=VX.get(t);if(n)return n;let i=[],r=!0;function s(a,o){let c=e.sliceString(a.from,a.to);i.push({label:c,type:o})}return t.cursor(si.IncludeAnonymous).iterate(a=>{if(a.name){let o=qrt[a.name];if(o&&o(a,s,r)||!r&&xfe.has(a.name))return!1;r=!1}else if(a.to-a.from>8192){for(let o of vfe(e,a.node))i.push(o);return!1}}),VX.set(t,i),i}const XX=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,wfe=["String","FormatString","Comment","PropertyName"];function Hrt(e){let t=_i(e.state).resolveInner(e.pos,-1);if(wfe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&XX.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let i=[];for(let r=t;r;r=r.parent)xfe.has(r.name)&&(i=i.concat(vfe(e.state.doc,r)));return{options:i,from:n?t.from:e.pos,validFor:XX}}const Yrt=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(e=>({label:e,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(e=>({label:e,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(e=>({label:e,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(e=>({label:e,type:"function"}))),Grt=[hr("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),hr("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),hr("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),hr("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),hr(`if \${}: +`);i=r<0?n:n.slice(0,r)}return t+i.length>this.to?i.slice(0,this.to-t):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(t,n,i=0){this.block=xT.create(t,i,this.lineStart+n,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(t,n,i=0){this.startContext(this.parser.getNodeType(t),n,i)}addNode(t,n,i){typeof t=="number"&&(t=new li(this.parser.nodeSet.types[t],E0,E0,(i??this.prevLineEnd())-n)),this.block.addChild(t,n-this.block.from)}addElement(t){this.block.addChild(t.toTree(this.parser.nodeSet),t.from-this.block.from)}addLeafElement(t,n){this.addNode(this.buffer.writeElements(vL(n.children,t.marks),-n.from).finish(n.type,n.to-n.from),n.from)}finishContext(){let t=this.stack.pop(),n=this.stack[this.stack.length-1];n.addChild(t.toTree(this.parser.nodeSet),t.from-n.from),this.block=n}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(t){return this.ranges.length>1?_de(this.ranges,0,t.topNode,this.ranges[0].from,this.reusePlaceholders):t}finishLeaf(t){for(let i of t.parsers)if(i.finish(this,t))return;let n=vL(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(n,-t.start).finish(ot.Paragraph,t.content.length),t.start)}elt(t,n,i,r){return typeof t=="string"?Hn(this.parser.getNodeType(t),n,i,r):new Cde(t,n)}get buffer(){return new Nde(this.parser.nodeSet)}}function _de(e,t,n,i,r){let s=e[t].to,a=[],o=[],c=n.from+i;function u(d,f){for(;f?d>=s:d>s;){let h=e[t+1].from-s;i+=h,d+=h,t++,s=e[t].to}}for(let d=n.firstChild;d;d=d.nextSibling){u(d.from+i,!0);let f=d.from+i,h,p=r.get(d.tree);p?h=p:d.to+i>s?(h=_de(e,t,d,i,r),u(d.to+i,!1)):h=d.toTree(),a.push(h),o.push(f-c)}return u(n.to+i,!1),new li(n.type,a,o,n.to+i-c,n.tree?n.tree.propValues:void 0)}class UA extends n4{constructor(t,n,i,r,s,a,o,c,u){super(),this.nodeSet=t,this.blockParsers=n,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=a,this.inlineParsers=o,this.inlineNames=c,this.wrappers=u,this.nodeTypes=Object.create(null);for(let d of t.types)this.nodeTypes[d.name]=d.id}createParse(t,n,i){let r=new ktt(this,t,n,i);for(let s of this.wrappers)r=s(r,t,n,i);return r}configure(t){let n=xL(t);if(!n)return this;let{nodeSet:i,skipContextMarkup:r}=this,s=this.blockParsers.slice(),a=this.leafBlockParsers.slice(),o=this.blockNames.slice(),c=this.inlineParsers.slice(),u=this.inlineNames.slice(),d=this.endLeafBlock.slice(),f=this.wrappers;if(cO(n.defineNodes)){r=Object.assign({},r);let h=i.types.slice(),p;for(let g of n.defineNodes){let{name:b,block:y,composite:O,style:v}=typeof g=="string"?{name:g}:g;if(h.some(E=>E.name==b))continue;O&&(r[h.length]=(E,S,k)=>O(S,k,E.value));let x=h.length,w=O?["Block","BlockContext"]:y?x>=ot.ATXHeading1&&x<=ot.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;h.push(ss.define({id:x,name:b,props:w&&[[sn.group,w]]})),v&&(p||(p={}),Array.isArray(v)||v instanceof xc?p[b]=v:Object.assign(p,v))}i=new W1(h),p&&(i=i.extend(xd(p)))}if(cO(n.props)&&(i=i.extend(...n.props)),cO(n.remove))for(let h of n.remove){let p=this.blockNames.indexOf(h),g=this.inlineNames.indexOf(h);p>-1&&(s[p]=a[p]=void 0),g>-1&&(c[g]=void 0)}if(cO(n.parseBlock))for(let h of n.parseBlock){let p=o.indexOf(h.name);if(p>-1)s[p]=h.parse,a[p]=h.leaf;else{let g=h.before?oS(o,h.before):h.after?oS(o,h.after)+1:o.length-1;s.splice(g,0,h.parse),a.splice(g,0,h.leaf),o.splice(g,0,h.name)}h.endLeaf&&d.push(h.endLeaf)}if(cO(n.parseInline))for(let h of n.parseInline){let p=u.indexOf(h.name);if(p>-1)c[p]=h.parse;else{let g=h.before?oS(u,h.before):h.after?oS(u,h.after)+1:u.length-1;c.splice(g,0,h.parse),u.splice(g,0,h.name)}}return n.wrap&&(f=f.concat(n.wrap)),new UA(i,s,a,o,d,r,c,u,f)}getNodeType(t){let n=this.nodeTypes[t];if(n==null)throw new RangeError(`Unknown node type '${t}'`);return n}parseInline(t,n){let i=new Q4(this,t,n);e:for(let r=n;r=0){r=o;continue e}}r++}return i.resolveMarkers(0)}}function cO(e){return e!=null&&e.length>0}function xL(e){if(!Array.isArray(e))return e;if(e.length==0)return null;let t=xL(e[0]);if(e.length==1)return t;let n=xL(e.slice(1));if(!n||!t)return t||n;let i=(a,o)=>(a||E0).concat(o||E0),r=t.wrap,s=n.wrap;return{props:i(t.props,n.props),defineNodes:i(t.defineNodes,n.defineNodes),parseBlock:i(t.parseBlock,n.parseBlock),parseInline:i(t.parseInline,n.parseInline),remove:i(t.remove,n.remove),wrap:r?s?(a,o,c,u)=>r(s(a,o,c,u),o,c,u):r:s}}function oS(e,t){let n=e.indexOf(t);if(n<0)throw new RangeError(`Position specified relative to unknown parser ${t}`);return n}let Ade=[ss.none];for(let e=1,t;t=ot[e];e++)Ade[e]=ss.define({id:e,name:t,props:e>=ot.Escape?[]:[[sn.group,e in bde?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});const E0=[];class Nde{constructor(t){this.nodeSet=t,this.content=[],this.nodes=[]}write(t,n,i,r=0){return this.content.push(t,n,i,4+r*4),this}writeElements(t,n=0){for(let i of t)i.writeTo(this,n);return this}finish(t,n){return li.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:n})}}let qx=class{constructor(t,n,i,r=E0){this.type=t,this.from=n,this.to=i,this.children=r}writeTo(t,n){let i=t.content.length;t.writeElements(this.children,n),t.content.push(this.type,this.from+n,this.to+n,t.content.length+4-i)}toTree(t){return new Nde(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}};class Cde{constructor(t,n){this.tree=t,this.from=n}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return E0}writeTo(t,n){t.nodes.push(this.tree),t.content.push(t.nodes.length-1,this.from+n,this.to+n,-1)}toTree(){return this.tree}}function Hn(e,t,n,i){return new qx(e,t,n,i)}const jde={resolve:"Emphasis",mark:"EmphasisMark"},Rde={resolve:"Emphasis",mark:"EmphasisMark"},Ph={},vT={};class ao{constructor(t,n,i,r){this.type=t,this.from=n,this.to=i,this.side=r}}const fX="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let Hx=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Hx=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}const kj={Escape(e,t,n){if(t!=92||n==e.end-1)return-1;let i=e.char(n+1);for(let r=0;r]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);if(r)return e.append(Hn(ot.Autolink,n,n+1+r[0].length,[Hn(ot.LinkMark,n,n+1),Hn(ot.URL,n+1,n+r[0].length),Hn(ot.LinkMark,n+r[0].length,n+1+r[0].length)]));let s=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(s)return e.append(Hn(ot.Comment,n,n+1+s[0].length));let a=/^\?[^]*?\?>/.exec(i);if(a)return e.append(Hn(ot.ProcessingInstruction,n,n+1+a[0].length));let o=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return o?e.append(Hn(ot.HTMLTag,n,n+1+o[0].length)):-1},Emphasis(e,t,n){if(t!=95&&t!=42)return-1;let i=n+1;for(;e.char(i)==t;)i++;let r=e.slice(n-1,n),s=e.slice(i,i+1),a=Hx.test(r),o=Hx.test(s),c=/\s|^$/.test(r),u=/\s|^$/.test(s),d=!u&&(!o||c||a),f=!c&&(!a||u||o),h=d&&(t==42||!f||a),p=f&&(t==42||!d||o);return e.append(new ao(t==95?jde:Rde,n,i,(h?1:0)|(p?2:0)))},HardBreak(e,t,n){if(t==92&&e.char(n+1)==10)return e.append(Hn(ot.HardBreak,n,n+2));if(t==32){let i=n+1;for(;e.char(i)==32;)i++;if(e.char(i)==10&&i>=n+2)return e.append(Hn(ot.HardBreak,n,i+1))}return-1},Link(e,t,n){return t==91?e.append(new ao(Ph,n,n+1,1)):-1},Image(e,t,n){return t==33&&e.char(n+1)==91?e.append(new ao(vT,n,n+2,1)):-1},LinkEnd(e,t,n){if(t!=93)return-1;for(let i=e.parts.length-1;i>=0;i--){let r=e.parts[i];if(r instanceof ao&&(r.type==Ph||r.type==vT)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[i]=null,-1;let s=e.takeContent(i),a=e.parts[i]=Ttt(e,s,r.type==Ph?ot.Link:ot.Image,r.from,n+1);if(r.type==Ph)for(let o=0;ot?Hn(ot.URL,t+n,s+n):s==e.length?null:!1}}function Pde(e,t,n){let i=e.charCodeAt(t);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=t+1,a=!1;s=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,n){return this.text.slice(t-this.offset,n-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,n,i,r,s){return this.append(new ao(t,n,i,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof ao&&(n.type==Ph||n.type==vT))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i=t;c--){let b=this.parts[c];if(b instanceof ao&&b.side&1&&b.type==r.type&&!(s&&(r.side&1||b.side&2)&&(b.to-b.from+a)%3==0&&((b.to-b.from)%3||a%3))){o=b;break}}if(!o)continue;let u=r.type.resolve,d=[],f=o.from,h=r.to;if(s){let b=Math.min(2,o.to-o.from,a);f=o.to-b,h=r.from+b,u=b==1?"Emphasis":"StrongEmphasis"}o.type.mark&&d.push(this.elt(o.type.mark,f,o.to));for(let b=c+1;b=0;n--){let i=this.parts[n];if(i instanceof ao&&i.type==t&&i.side&1)return n}return null}takeContent(t){let n=this.resolveMarkers(t);return this.parts.length=t,n}getDelimiterAt(t){let n=this.parts[t];return n instanceof ao?n:null}skipSpace(t){return Ny(this.text,t-this.offset)+this.offset}elt(t,n,i,r){return typeof t=="string"?Hn(this.parser.getNodeType(t),n,i,r):new Cde(t,n)}}Q4.linkStart=Ph;Q4.imageStart=vT;function vL(e,t){if(!t.length)return e;if(!e.length)return t;let n=e.slice(),i=0;for(let r of t){for(;i(t?t-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` +`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=t+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=n;if(!i.childAfter(r))return!1}}matches(t){let n=this.cursor.tree;return n&&n.prop(sn.contextHash)==t}takeNodes(t){let n=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=t.absoluteLineStart,a=s,o=t.block.children.length,c=a,u=o;for(;;){if(n.to-i>r){if(n.type.isAnonymous&&n.firstChild())continue;break}let d=Lde(n.from-i,t.ranges);if(n.to-i<=t.ranges[t.rangeI].to)t.addNode(n.tree,d);else{let f=new li(t.parser.nodeSet.types[ot.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(f,n.tree),t.addNode(f,d)}if(n.type.is("Block")&&(_tt.indexOf(n.type.id)<0?(a=n.to-i,o=t.block.children.length):(a=c,o=u),c=n.to-i,u=t.block.children.length),!n.nextSibling())break}for(;t.block.children.length>o;)t.block.children.pop(),t.block.positions.pop();return a-s}}function Lde(e,t){let n=e;for(let i=1;iaS[e]),Object.keys(aS).map(e=>Tde[e]),Object.keys(aS),Stt,bde,Object.keys(kj).map(e=>kj[e]),Object.keys(kj),[]);function jtt(e,t,n){let i=[];for(let r=e.firstChild,s=t;;r=r.nextSibling){let a=r?r.from:n;if(a>s&&i.push({from:s,to:a}),!r)break;s=r.to}return i}function Rtt(e){let{codeParser:t,htmlParser:n}=e;return{wrap:rce((r,s)=>{let a=r.type.id;if(t&&(a==ot.CodeBlock||a==ot.FencedCode)){let o="";if(a==ot.FencedCode){let u=r.node.getChild(ot.CodeInfo);u&&(o=s.read(u.from,u.to))}let c=t(o);if(c)return{parser:c,overlay:u=>u.type.id==ot.CodeText,bracketed:a==ot.FencedCode}}else if(n&&(a==ot.HTMLBlock||a==ot.HTMLTag||a==ot.CommentBlock))return{parser:n,overlay:jtt(r.node,r.from,r.to)};return null})}}const Itt={resolve:"Strikethrough",mark:"StrikethroughMark"},Ptt={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":G.strikethrough}},{name:"StrikethroughMark",style:G.processingInstruction}],parseInline:[{name:"Strikethrough",parse(e,t,n){if(t!=126||e.char(n+1)!=126||e.char(n+2)==126)return-1;let i=e.slice(n-1,n),r=e.slice(n+2,n+3),s=/\s|^$/.test(i),a=/\s|^$/.test(r),o=Hx.test(i),c=Hx.test(r);return e.addDelimiter(Itt,n,n+2,!a&&(!c||s||o),!s&&(!o||a||c))},after:"Emphasis"}]};function Cy(e,t,n=0,i,r=0){let s=0,a=!0,o=-1,c=-1,u=!1,d=()=>{i.push(e.elt("TableCell",r+o,r+c,e.parser.parseInline(t.slice(o,c),r+o)))};for(let f=n;f-1)&&s++,a=!1,i&&(o>-1&&d(),i.push(e.elt("TableDelimiter",f+r,f+r+1))),o=c=-1):(u||h!=32&&h!=9)&&(o<0&&(o=f),c=f+1),u=!u&&h==92}return o>-1&&(s++,i&&d()),s}function hX(e,t){for(let n=t;n\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class pX{constructor(){this.rows=null}nextLine(t,n,i){if(this.rows==null){this.rows=!1;let r;if((n.next==45||n.next==58||n.next==124)&&Dde.test(r=n.text.slice(n.pos))){let s=[];Cy(t,i.content,0,s,i.start)==Cy(t,r,0)&&(this.rows=[t.elt("TableHeader",i.start,i.start+i.content.length,s),t.elt("TableDelimiter",t.lineStart+n.pos,t.lineStart+n.text.length)])}}else if(this.rows){let r=[];Cy(t,n.text,n.pos,r,t.lineStart),this.rows.push(t.elt("TableRow",t.lineStart+n.pos,t.lineStart+n.text.length,r))}return!1}finish(t,n){return this.rows?(t.addLeafElement(n,t.elt("Table",n.start,n.start+n.content.length,this.rows)),!0):!1}}const Mtt={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":G.heading}},"TableRow",{name:"TableCell",style:G.content},{name:"TableDelimiter",style:G.processingInstruction}],parseBlock:[{name:"Table",leaf(e,t){return hX(t.content,0)?new pX:null},endLeaf(e,t,n){if(n.parsers.some(r=>r instanceof pX)||!hX(t.text,t.basePos))return!1;let i=e.peekLine();return Dde.test(i)&&Cy(e,t.text,t.basePos)==Cy(e,i,t.basePos)},before:"SetextHeading"}]};class Ltt{nextLine(){return!1}finish(t,n){return t.addLeafElement(n,t.elt("Task",n.start,n.start+n.content.length,[t.elt("TaskMarker",n.start,n.start+3),...t.parser.parseInline(n.content.slice(3),n.start+3)])),!0}}const Dtt={defineNodes:[{name:"Task",block:!0,style:G.list},{name:"TaskMarker",style:G.atom}],parseBlock:[{name:"TaskList",leaf(e,t){return/^\[[ xX]\][ \t]/.test(t.content)&&e.parentType().name=="ListItem"?new Ltt:null},after:"SetextHeading"}]},mX=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,gX=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,$tt=/[\w-]+\.[\w-]+($|[/:])/,bX=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,OX=/\/[a-zA-Z\d@.]+/gy;function yX(e,t,n,i){let r=0;for(let s=t;s-1)return-1;let i=t+n[0].length;for(;;){let r=e[i-1],s;if(/[?!.,:*_~]/.test(r)||r==")"&&yX(e,t,i,")")>yX(e,t,i,"("))i--;else if(r==";"&&(s=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,i))))i=t+s.index;else break}return i}function xX(e,t){bX.lastIndex=t;let n=bX.exec(e);if(!n)return-1;let i=n[0][n[0].length-1];return i=="_"||i=="-"?-1:t+n[0].length-(i=="."?1:0)}const Btt={parseInline:[{name:"Autolink",parse(e,t,n){let i=n-e.offset;if(i&&/\w/.test(e.text[i-1]))return-1;mX.lastIndex=i;let r=mX.exec(e.text),s=-1;if(!r)return-1;if(r[1]||r[2]){if(s=Qtt(e.text,i+r[0].length),s>-1&&e.hasOpenLink){let a=/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(i,s));s=i+a[0].length}}else r[3]?s=xX(e.text,i):(s=xX(e.text,i+r[0].length),s>-1&&r[0]=="xmpp:"&&(OX.lastIndex=s,r=OX.exec(e.text),r&&(s=r.index+r[0].length)));return s<0?-1:(e.addElement(e.elt("URL",n,s+e.offset)),s+e.offset)}}]},Utt=[Mtt,Dtt,Ptt,Btt];function $de(e,t,n){return(i,r,s)=>{if(r!=e||i.char(s+1)==e)return-1;let a=[i.elt(n,s,s+1)];for(let o=s+1;o=65&&e<=90||e==95||e>=97&&e<=122||e>=161}let EX=null,kX=null,TX=0;function SL(e,t){let n=e.pos+t;if(TX==n&&kX==e)return EX;let i=e.peek(t),r="";for(;pnt(i);)r+=String.fromCharCode(i),i=e.peek(++t);return kX=e,TX=n,EX=r?r.toLowerCase():i==mnt||i==gnt?void 0:null}const qde=60,wT=62,U4=47,mnt=63,gnt=33,bnt=45;function _X(e,t){this.name=e,this.parent=t}const Ont=[B4,zde,Qde,Bde,Ude],ynt=new CA({start:null,shift(e,t,n,i){return Ont.indexOf(t)>-1?new _X(SL(i,1)||"",e):e},reduce(e,t){return t==Fde&&e?e.parent:e},reuse(e,t,n,i){let r=t.type.id;return r==B4||r==lnt?new _X(SL(i,1)||"",e):e},strict:!1}),xnt=new Lr((e,t)=>{if(e.next!=qde){e.next<0&&t.context&&e.acceptToken(Tj);return}e.advance();let n=e.next==U4;n&&e.advance();let i=SL(e,0);if(i===void 0)return;if(!i)return e.acceptToken(n?nnt:tnt);let r=t.context?t.context.name:null;if(n){if(i==r)return e.acceptToken(Ktt);if(r&&hnt[r])return e.acceptToken(Tj,-2);if(t.dialectEnabled(unt))return e.acceptToken(Jtt);for(let s=t.context;s;s=s.parent)if(s.name==i)return;e.acceptToken(ent)}else{if(i=="script")return e.acceptToken(Qde);if(i=="style")return e.acceptToken(Bde);if(i=="textarea")return e.acceptToken(Ude);if(fnt.hasOwnProperty(i))return e.acceptToken(zde);r&&SX[r]&&SX[r][i]?e.acceptToken(Tj,-1):e.acceptToken(B4)}},{contextual:!0}),vnt=new Lr(e=>{for(let t=0,n=0;;n++){if(e.next<0){n&&e.acceptToken(wX);break}if(e.next==bnt)t++;else if(e.next==wT&&t>=2){n>=3&&e.acceptToken(wX,-2);break}else t=0;e.advance()}});function wnt(e){for(;e;e=e.parent)if(e.name=="svg"||e.name=="math")return!0;return!1}const Snt=new Lr((e,t)=>{if(e.next==U4&&e.peek(1)==wT){let n=t.dialectEnabled(dnt)||wnt(t.context);e.acceptToken(n?Ztt:vX,2)}else e.next==wT&&e.acceptToken(vX,1)});function z4(e,t,n){let i=2+e.length;return new Lr(r=>{for(let s=0,a=0,o=0;;o++){if(r.next<0){o&&r.acceptToken(t);break}if(s==0&&r.next==qde||s==1&&r.next==U4||s>=2&&sa?r.acceptToken(t,-a):r.acceptToken(n,-(a-2));break}else if((r.next==10||r.next==13)&&o){r.acceptToken(t,1);break}else s=a=0;r.advance()}})}const Ent=z4("script",Xtt,qtt),knt=z4("style",Htt,Ytt),Tnt=z4("textarea",Gtt,Wtt),_nt=xd({"Text RawText IncompleteTag IncompleteCloseTag":G.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":G.angleBracket,TagName:G.tagName,"MismatchedCloseTag/TagName":[G.tagName,G.invalid],AttributeName:G.attributeName,"AttributeValue UnquotedAttributeValue":G.attributeValue,Is:G.definitionOperator,"EntityReference CharacterReference":G.character,Comment:G.blockComment,ProcessingInst:G.processingInstruction,DoctypeDecl:G.documentMeta}),Ant=ad.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",stateData:",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:ynt,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[_nt],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let u=o.type.id;if(u==snt)return _j(o,c,n);if(u==ant)return _j(o,c,i);if(u==ont)return _j(o,c,r);if(u==Fde&&s.length){let d=o.node,f=d.firstChild,h=f&&AX(f,c),p;if(h){for(let g of s)if(g.tag==h&&(!g.attrs||g.attrs(p||(p=Hde(f,c))))){let b=d.lastChild,y=b.type.id==cnt?b.from:d.to;if(y>f.to)return{parser:g.parser,overlay:[{from:f.to,to:y}]}}}}if(a&&u==Vde){let d=o.node,f;if(f=d.firstChild){let h=a[c.read(f.from,f.to)];if(h)for(let p of h){if(p.tagName&&p.tagName!=AX(d.parent,c))continue;let g=d.lastChild;if(g.type.id==wL){let b=g.from+1,y=g.lastChild,O=g.to-(y&&y.isError?0:1);if(O>b)return{parser:p.parser,overlay:[{from:b,to:O}],bracketed:!0}}else if(g.type.id==Xde)return{parser:p.parser,overlay:[{from:g.from,to:g.to}]}}}}return null})}const Nnt=145,NX=1,Cnt=146,jnt=147,Gde=2,Rnt=148,Int=3,Pnt=4,Wde=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Mnt=58,Lnt=40,Zde=95,Dnt=91,OE=45,$nt=46,Qnt=35,Bnt=37,Unt=38,znt=92,Fnt=10,Vnt=42;function Yx(e){return e>=65&&e<=90||e>=97&&e<=122||e>=161}function F4(e){return e>=48&&e<=57}function CX(e){return F4(e)||e>=97&&e<=102||e>=65&&e<=70}const Kde=(e,t,n)=>(i,r)=>{for(let s=!1,a=0,o=0;;o++){let{next:c}=i;if(Yx(c)||c==OE||c==Zde||s&&F4(c))!s&&(c!=OE||o>0)&&(s=!0),a===o&&c==OE&&a++,i.advance();else if(c==znt&&i.peek(1)!=Fnt){if(i.advance(),CX(i.next)){do i.advance();while(CX(i.next));i.next==32&&i.advance()}else i.next>-1&&i.advance();s=!0}else{s&&i.acceptToken(a==2&&r.canShift(Gde)?t:c==Lnt?n:e);break}}},Xnt=new Lr(Kde(Cnt,Gde,jnt),{contextual:!0}),qnt=new Lr(Kde(Rnt,Int,Pnt),{contextual:!0}),Hnt=new Lr(e=>{if(Wde.includes(e.peek(-1))){let{next:t}=e;(Yx(t)||t==Zde||t==Qnt||t==$nt||t==Vnt||t==Dnt||t==Mnt&&Yx(e.peek(1))||t==OE||t==Unt)&&e.acceptToken(Nnt)}}),Ynt=new Lr(e=>{if(!Wde.includes(e.peek(-1))){let{next:t}=e;if(t==Bnt&&(e.advance(),e.acceptToken(NX)),Yx(t)){do e.advance();while(Yx(e.next)||F4(e.next));e.acceptToken(NX)}}}),Gnt=xd({"AtKeyword import charset namespace keyframes media supports font-feature-values":G.definitionKeyword,"from to selector scope MatchFlag":G.keyword,NamespaceName:G.namespace,KeyframeName:G.labelName,KeyframeRangeName:G.operatorKeyword,TagName:G.tagName,ClassName:G.className,PseudoClassName:G.constant(G.className),IdName:G.labelName,"FeatureName PropertyName":G.propertyName,AttributeName:G.attributeName,NumberLiteral:G.number,KeywordQuery:G.keyword,UnaryQueryOp:G.operatorKeyword,"CallTag ValueName FontName":G.atom,VariableName:G.variableName,Callee:G.operatorKeyword,Unit:G.unit,"UniversalSelector NestingSelector":G.definitionOperator,"MatchOp CompareOp":G.compareOperator,"ChildOp SiblingOp, LogicOp":G.logicOperator,BinOp:G.arithmeticOperator,Important:G.modifier,Comment:G.blockComment,ColorLiteral:G.color,"ParenthesizedContent StringLiteral":G.string,":":G.punctuation,"PseudoOp #":G.derefOperator,"; , |":G.separator,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace}),Wnt={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:152,"url-prefix":152,domain:152,regexp:152},Znt={__proto__:null,or:104,and:104,not:112,only:112,layer:206},Knt={__proto__:null,selector:118,style:124,layer:202},Jnt={__proto__:null,"@import":198,"@media":210,"@charset":214,"@namespace":218,"@keyframes":224,"@supports":236,"@scope":240,"@font-feature-values":246},eit={__proto__:null,to:243},tit=ad.deserialize({version:14,states:"MlQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FnO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#EOO'dQdO'#EQO'oQdO'#EXO'oQdO'#E[OOQP'#Fn'#FnO)RQhO'#E}OOQS'#Fm'#FmOOQS'#FQ'#FQQYQdOOO)YQdO'#EbO*iQhO'#EhO)YQdO'#EjO*pQdO'#ElO*{QdO'#EoO)}QhO'#EuO+TQdO'#EwO+`QdO'#EzO+eQaO'#CfO+lQ`O'#E_O+qQ`O'#F{O+|QdO'#F{QOQ`OOP,WO&jO'#CaPOOO)CA])CA]OOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,cQdO,59YO'_QdO,5:jO'dQdO,5:lO'oQdO,5:sO'oQdO,5:uO'oQdO,5:vO'oQdO'#FXO,nQ`O,58}O,vQdO'#E^OOQS,58},58}OOQP'#Cq'#CqOOQO'#D|'#D|OOQP,59Y,59YO,}Q`O,59YO-SQ`O,59YOOQP'#EP'#EPOOQP,5:j,5:jO-XQpO'#ERO-dQdO'#ESO-iQ`O'#ESO-nQpO,5:lO.XQaO,5:sO.oQaO,5:vOOQW'#D^'#D^O/nQhO'#DgO0RQhO,5;iO)}QhO'#DeO0`Q`O'#DnO0eQhO'#DxOOQW'#Ft'#FtOOQS,5;i,5;iO0jQ`O'#DhO0oQ`O'#DkOOQS-E9O-E9OOOQ['#Cv'#CvO0tQdO'#CwO1[QdO'#C}O1rQdO'#DQO2YQ!pO'#DSO4fQ!jO,5:|OOQO'#DX'#DXO-SQ`O'#DWO4vQ!nO'#FqO6|Q`O'#DYO7RQ`O'#DyOOQ['#Fq'#FqO7WQhO'#GOO7fQ`O,5;SO7kQ!bO,5;UOOQS'#En'#EnO7sQ`O,5;WO7xQdO,5;WOOQO'#Eq'#EqO8QQ`O,5;ZO8VQhO,5;aO'oQdO'#DjOOQS,5;c,5;cO0jQ`O,5;cO8_QdO,5;cOOQS'#F`'#F`O8gQdO'#E|O7fQ`O,5;fO8oQdO,5:yO9PQdO'#FZO9^Q`O,5lQhO'#DoOOQW,5:Y,5:YOOQW,5:d,5:dOOQW,5:S,5:SO>vQhO,5:VO?bQ!fO'#FrOOQS'#Fr'#FrOOQS'#FS'#FSO@rQdO,59cOOQ[,59c,59cOAYQdO,59iOOQ[,59i,59iOApQdO,59lOOQ[,59l,59lOOQ[,59n,59nO)YQdO,59pOBWQhO'#EdOOQW'#Ed'#EdOBuQ`O1G0hO4oQhO1G0hOOQ[,59r,59rO)}QhO'#D[OOQ[,59t,59tOBzQ#tO,5:eOCVQhO'#F]OCdQ`O,5vQhO'#DmOI_QhO'#DqOIgQhO'#DsOIlQhO'#FwOOQO'#Fw'#FwOItQ!bO'#DwOOQO'#Fy'#FyOOQO'#Fv'#FvOIyQ`O1G/qOOQS-E9Q-E9QOOQ[1G.}1G.}OOQ[1G/T1G/TOOQ[1G/W1G/WOOQ[1G/[1G/[OJOQdO,5;OOOQS7+&S7+&SOJTQ`O7+&SOJYQhO'#D]OJbQ`O,59vO)}QhO,59vOOQ[1G0P1G0POJjQ`O1G0POJoQhO,5;wOOQO-E9Z-E9ZOOQS7+&^7+&^OJ}QbO'#DSOOQO'#Et'#EtOK]Q`O'#EsOOQO'#Es'#EsOKhQ`O'#F^OKpQdO,5;^OOQS,5;^,5;^OOQ[1G/p1G/pOOQS7+&i7+&iO7fQ`O7+&iOK{Q!fO'#FYO)YQdO'#FYOMSQdO7+&POOQO7+&P7+&POOQO,5:{,5:{OOQO1G1a1G1aOMgQ!bO<vQhO'#DrOOQO,5:],5:]O! hQhO,5:_OGUQhO,5:cOOQW7+%]7+%]OOQO'#Ef'#EfO! pQ`O1G0jOOQS<xAN>xO!#zQ`OAN>xO!$PQaO,5;rOOQO-E9U-E9UO!$ZQdO,5;qOOQO-E9T-E9TOOQW<vQhO'#DuOOQO1G/y1G/yO!%vQ!bO1G/}OJOQdO'#F[O!&OQ`O7+&UOOQW7+&U7+&UO!&WQ!bO1G/cOOQ[7+$|7+$|O!&cQhO7+$|P!&jQ`O'#FTOOQO,5;y,5;yOOQO-E9]-E9]OOQS1G1d1G1dOOQPG24dG24dO!&oQ`OAN>ZO)YQdO1G1[O!&tQ`O7+'jOOQO1G/x1G/xO!&|Q`O,5:aO!$eQhO7+%iOOQO,5;v,5;vOOQO-E9Y-E9YOOQW<Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!o`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$[~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%j~'yh$[~!o`OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%jj)jS$qYOy%jz;'S%j;'S;=`%{<%lO%j~)yWOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d<%lO)v~*hOw~~*kRO;'S)v;'S;=`*t;=`O)v~*wXOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d;=`<%l)v<%lO)v~+gP;=`<%l)vj+oYmYOy%jz!Q%j!Q![,_![!c%j!c!i,_!i#T%j#T#Z,_#Z;'S%j;'S;=`%{<%lO%jj,dY!o`Oy%jz!Q%j!Q![-S![!c%j!c!i-S!i#T%j#T#Z-S#Z;'S%j;'S;=`%{<%lO%jj-XY!o`Oy%jz!Q%j!Q![-w![!c%j!c!i-w!i#T%j#T#Z-w#Z;'S%j;'S;=`%{<%lO%jj.OYuY!o`Oy%jz!Q%j!Q![.n![!c%j!c!i.n!i#T%j#T#Z.n#Z;'S%j;'S;=`%{<%lO%jj.uYuY!o`Oy%jz!Q%j!Q![/e![!c%j!c!i/e!i#T%j#T#Z/e#Z;'S%j;'S;=`%{<%lO%jj/jY!o`Oy%jz!Q%j!Q![0Y![!c%j!c!i0Y!i#T%j#T#Z0Y#Z;'S%j;'S;=`%{<%lO%jj0aYuY!o`Oy%jz!Q%j!Q![1P![!c%j!c!i1P!i#T%j#T#Z1P#Z;'S%j;'S;=`%{<%lO%jj1UY!o`Oy%jz!Q%j!Q![1t![!c%j!c!i1t!i#T%j#T#Z1t#Z;'S%j;'S;=`%{<%lO%jj1{SuY!o`Oy%jz;'S%j;'S;=`%{<%lO%jd2[UOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jd2uS!yS!o`Oy%jz;'S%j;'S;=`%{<%lO%jb3WS^QOy%jz;'S%j;'S;=`%{<%lO%j~3gWOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{<%lO3d~4SRO;'S3d;'S;=`4];=`O3d~4`XOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{;=`<%l3d<%lO3d~5OP;=`<%l3dj5WShYOy%jz;'S%j;'S;=`%{<%lO%j~5iOg~n5pUWQyWOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jj6ZWyW#PQOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj6xU!o`Oy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%jj7cY!o`$gYOy%jz!Q%j!Q![7[![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj8WY!o`Oy%jz{%j{|8v|}%j}!O8v!O!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj8{U!o`Oy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj9fU!o`$gYOy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj:P[!o`$gYOy%jz!O%j!O!P7[!P!Q%j!Q![9x![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj:zS!dYOy%jz;'S%j;'S;=`%{<%lO%jj;]WyWOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj;zU`YOy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%j~VUcYOy%jz![%j![!]>i!];'S%j;'S;=`%{<%lO%jj>pSdY!o`Oy%jz;'S%j;'S;=`%{<%lO%jj?RSnYOy%jz;'S%j;'S;=`%{<%lO%jh?dU!WWOy%jz!_%j!_!`?v!`;'S%j;'S;=`%{<%lO%jh?}S!WW!o`Oy%jz;'S%j;'S;=`%{<%lO%jl@bS!WW!ySOy%jz;'S%j;'S;=`%{<%lO%jj@uV!|Q!WWOy%jz!_%j!_!`?v!`!aA[!a;'S%j;'S;=`%{<%lO%jbAcS!|Q!o`Oy%jz;'S%j;'S;=`%{<%lO%jjArYOy%jz}%j}!OBb!O!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjBgW!o`Oy%jz!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjCW[lY!o`Oy%jz}%j}!OCP!O!Q%j!Q![CP![!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jhDRS!zWOy%jz;'S%j;'S;=`%{<%lO%jjDdSpYOy%jz;'S%j;'S;=`%{<%lO%jnDuSo^Oy%jz;'S%j;'S;=`%{<%lO%jjEWU!zWOy%jz#a%j#a#bEj#b;'S%j;'S;=`%{<%lO%jbEoU!o`Oy%jz#d%j#d#eFR#e;'S%j;'S;=`%{<%lO%jbFWU!o`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!o`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!o`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!o`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!o`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!o`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$pQ!o`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$cUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#PQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[Hnt,Ynt,Xnt,qnt,1,2,3,4,new tT("m~RRYZ[z{a~~g~aO$_~~dP!P!Qg~lO$`~~",28,152)],topRules:{StyleSheet:[0,6],Styles:[1,126]},dynamicPrecedences:{94:1},specialized:[{term:147,get:e=>Wnt[e]||-1},{term:148,get:e=>Znt[e]||-1},{term:4,get:e=>Knt[e]||-1},{term:28,get:e=>Jnt[e]||-1},{term:146,get:e=>eit[e]||-1}],tokenPrec:2405});let Aj=null;function Nj(){if(!Aj&&typeof document=="object"&&document.body){let{style:e}=document.body,t=[],n=new Set;for(let i in e)i!="cssText"&&i!="cssFloat"&&typeof e[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())),n.has(i)||(t.push(i),n.add(i)));Aj=t.sort().map(i=>({type:"property",label:i,apply:i+": "}))}return Aj||[]}const jX=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(e=>({type:"class",label:e})),RX=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(e=>({type:"keyword",label:e})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(e=>({type:"constant",label:e}))),nit=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(e=>({type:"type",label:e})),iit=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(e=>({type:"keyword",label:e})),mu=/^(\w[\w-]*|-\w[\w-]*|)$/,rit=/^-(-[\w-]*)?$/;function sit(e,t){var n;if((e.name=="("||e.type.isError)&&(e=e.parent||e),e.name!="ArgList")return!1;let i=(n=e.parent)===null||n===void 0?void 0:n.firstChild;return(i==null?void 0:i.name)!="Callee"?!1:t.sliceString(i.from,i.to)=="var"}const IX=new t4,ait=["Declaration"];function oit(e){for(let t=e;;){if(t.type.isTop)return t;if(!(t=t.parent))return e}}function Jde(e,t,n){if(t.to-t.from>4096){let i=IX.get(t);if(i)return i;let r=[],s=new Set,a=t.cursor(si.IncludeAnonymous);if(a.firstChild())do for(let o of Jde(e,a.node,n))s.has(o.label)||(s.add(o.label),r.push(o));while(a.nextSibling());return IX.set(t,r),r}else{let i=[],r=new Set;return t.cursor().iterate(s=>{var a;if(n(s)&&s.matchContext(ait)&&((a=s.node.nextSibling)===null||a===void 0?void 0:a.name)==":"){let o=e.sliceString(s.from,s.to);r.has(o)||(r.add(o),i.push({label:o,type:"variable"}))}}),i}}const lit=e=>t=>{let{state:n,pos:i}=t,r=_i(n).resolveInner(i,-1),s=r.type.isError&&r.from==r.to-1&&n.doc.sliceString(r.from,r.to)=="-";if(r.name=="PropertyName"||(s||r.name=="TagName")&&/^(Block|Styles)$/.test(r.resolve(r.to).name))return{from:r.from,options:Nj(),validFor:mu};if(r.name=="ValueName")return{from:r.from,options:RX,validFor:mu};if(r.name=="PseudoClassName")return{from:r.from,options:jX,validFor:mu};if(e(r)||(t.explicit||s)&&sit(r,n.doc))return{from:e(r)||s?r.from:i,options:Jde(n.doc,oit(r),e),validFor:rit};if(r.name=="TagName"){for(let{parent:c}=r;c;c=c.parent)if(c.name=="Block")return{from:r.from,options:Nj(),validFor:mu};return{from:r.from,options:nit,validFor:mu}}if(r.name=="AtKeyword")return{from:r.from,options:iit,validFor:mu};if(!t.explicit)return null;let a=r.resolve(i),o=a.childBefore(i);return o&&o.name==":"&&a.name=="PseudoClassSelector"?{from:i,options:jX,validFor:mu}:o&&o.name==":"&&a.name=="Declaration"||a.name=="ArgList"?{from:i,options:RX,validFor:mu}:a.name=="Block"||a.name=="Styles"?{from:i,options:Nj(),validFor:mu}:null},cit=lit(e=>e.name=="VariableName"),ST=ud.define({name:"css",parser:tit.configure({props:[rh.add({Declaration:Pg()}),wd.add({"Block KeyframeList":ev})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function uit(){return new Yf(ST,ST.data.of({autocomplete:cit}))}const uO=["_blank","_self","_top","_parent"],Cj=["ascii","utf-8","utf-16","latin1","latin1"],jj=["get","post","put","delete"],Rj=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ka=["true","false"],$t={},dit={a:{attrs:{href:null,ping:null,type:null,media:null,target:uO,hreflang:null}},abbr:$t,address:$t,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:$t,aside:$t,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:$t,base:{attrs:{href:null,target:uO}},bdi:$t,bdo:$t,blockquote:{attrs:{cite:null}},body:$t,br:$t,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Rj,formmethod:jj,formnovalidate:["novalidate"],formtarget:uO,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:$t,center:$t,cite:$t,code:$t,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:$t,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:$t,div:$t,dl:$t,dt:$t,em:$t,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:$t,figure:$t,footer:$t,form:{attrs:{action:null,name:null,"accept-charset":Cj,autocomplete:["on","off"],enctype:Rj,method:jj,novalidate:["novalidate"],target:uO}},h1:$t,h2:$t,h3:$t,h4:$t,h5:$t,h6:$t,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:$t,hgroup:$t,hr:$t,html:{attrs:{manifest:null}},i:$t,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Rj,formmethod:jj,formnovalidate:["novalidate"],formtarget:uO,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:$t,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:$t,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:$t,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Cj,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:$t,noscript:$t,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:$t,param:{attrs:{name:null,value:null}},pre:$t,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:$t,rt:$t,ruby:$t,samp:$t,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Cj}},section:$t,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:$t,source:{attrs:{src:null,type:null,media:null}},span:$t,strong:$t,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:$t,summary:$t,sup:$t,table:$t,tbody:$t,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:$t,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:$t,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:$t,time:{attrs:{datetime:null}},title:$t,tr:$t,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:$t,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:$t},efe={accesskey:null,class:null,contenteditable:Ka,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ka,autocorrect:Ka,autocapitalize:Ka,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ka,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ka,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ka,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ka,"aria-hidden":Ka,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ka,"aria-multiselectable":Ka,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ka,"aria-relevant":null,"aria-required":Ka,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},tfe="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(e=>"on"+e);for(let e of tfe)efe[e]=null;class Gx{constructor(t,n){this.tags={...dit,...t},this.globalAttrs={...efe,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Gx.default=new Gx;function k0(e,t,n=e.length){if(!t)return"";let i=t.firstChild,r=i&&i.getChild("TagName");return r?e.sliceString(r.from,Math.min(r.to,n)):""}function T0(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function nfe(e,t,n){let i=n.tags[k0(e,T0(t))];return(i==null?void 0:i.children)||n.allTags}function V4(e,t){let n=[];for(let i=T0(t);i&&!i.type.isTop;i=T0(i.parent)){let r=k0(e,i);if(r&&i.lastChild.name=="CloseTag")break;r&&n.indexOf(r)<0&&(t.name=="EndTag"||t.from>=i.firstChild.to)&&n.push(r)}return n}const ife=/^[:\-\.\w\u00b7-\uffff]*$/;function PX(e,t,n,i,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">",a=T0(n,n.name=="StartTag"||n.name=="TagName");return{from:i,to:r,options:nfe(e.doc,a,t).map(o=>({label:o,type:"type"})).concat(V4(e.doc,n).map((o,c)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function MX(e,t,n,i){let r=/\s*>/.test(e.sliceDoc(i,i+5))?"":">";return{from:n,to:i,options:V4(e.doc,t).map((s,a)=>({label:s,apply:s+r,type:"type",boost:99-a})),validFor:ife}}function fit(e,t,n,i){let r=[],s=0;for(let a of nfe(e.doc,n,t))r.push({label:"<"+a,type:"type"});for(let a of V4(e.doc,n))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function hit(e,t,n,i,r){let s=T0(n),a=s?t.tags[k0(e.doc,s)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],c=a&&a.globalAttrs===!1?o:o.length?o.concat(t.globalAttrNames):t.globalAttrNames;return{from:i,to:r,options:c.map(u=>({label:u,type:"property"})),validFor:ife}}function pit(e,t,n,i,r){var s;let a=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),o=[],c;if(a){let u=e.sliceDoc(a.from,a.to),d=t.globalAttrs[u];if(!d){let f=T0(n),h=f?t.tags[k0(e.doc,f)]:null;d=(h==null?void 0:h.attrs)&&h.attrs[u]}if(d){let f=e.sliceDoc(i,r).toLowerCase(),h='"',p='"';/^['"]/.test(f)?(c=f[0]=='"'?/^[^"]*$/:/^[^']*$/,h="",p=e.sliceDoc(r,r+1)==f[0]?"":f[0],f=f.slice(1),i++):c=/^[^\s<>='"]*$/;for(let g of d)o.push({label:g,apply:h+g+p,type:"constant"})}}return{from:i,to:r,options:o,validFor:c}}function rfe(e,t){let{state:n,pos:i}=t,r=_i(n).resolveInner(i,-1),s=r.resolve(i);for(let a=i,o;s==r&&(o=r.childBefore(a));){let c=o.lastChild;if(!c||!c.type.isError||c.fromrfe(i,r)}const bit=Bc.parser.configure({top:"SingleExpression"}),sfe=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:fde.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:hde.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:pde.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:bit},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Bc.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:ST.parser}],afe=[{name:"style",parser:ST.parser.configure({top:"Styles"})}].concat(tfe.map(e=>({name:e,parser:Bc.parser}))),ofe=ud.define({name:"html",parser:Ant.configure({props:[rh.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].lengthe.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),yE=ofe.configure({wrap:Yde(sfe,afe)});function Oit(e={}){let t="",n;e.matchClosingTags===!1&&(t="noMatch"),e.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Yde((e.nestedLanguages||[]).concat(sfe),(e.nestedAttributes||[]).concat(afe)));let i=n?ofe.configure({wrap:n,dialect:t}):t?yE.configure({dialect:t}):yE;return new Yf(i,[yE.data.of({autocomplete:git(e)}),e.autoCloseTags!==!1?yit:[],bL().support,uit().support])}const LX=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),yit=ft.inputHandler.of((e,t,n,i,r)=>{if(e.composing||e.state.readOnly||t!=n||i!=">"&&i!="/"||!yE.isActiveAt(e.state,t,-1))return!1;let s=r(),{state:a}=s,o=a.changeByRange(c=>{var u,d,f;let h=a.doc.sliceString(c.from-1,c.to)==i,{head:p}=c,g=_i(a).resolveInner(p,-1),b;if(h&&i==">"&&g.name=="EndTag"){let y=g.parent;if(((d=(u=y.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=k0(a.doc,y.parent,p))&&!LX.has(b)){let O=p+(a.doc.sliceString(p,p+1)===">"?1:0),v=``;return{range:c,changes:{from:p,to:O,insert:v}}}}else if(h&&i=="/"&&g.name=="IncompleteCloseTag"){let y=g.parent;if(g.from==p-2&&((f=y.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(b=k0(a.doc,y,p))&&!LX.has(b)){let O=p+(a.doc.sliceString(p,p+1)===">"?1:0),v=`${b}>`;return{range:Qe.cursor(p+v.length,-1),changes:{from:p,to:O,insert:v}}}}return{range:c}});return o.changes.empty?!1:(e.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),lfe=w4({commentTokens:{block:{open:""}}}),cfe=new sn,ufe=Ctt.configure({props:[wd.add(e=>!e.is("Block")||e.is("Document")||EL(e)!=null||xit(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),cfe.add(EL),rh.add({Document:()=>null}),Xh.add({Document:lfe})]});function EL(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function xit(e){return e.name=="OrderedList"||e.name=="BulletList"}function vit(e,t){let n=e;for(;;){let i=n.nextSibling,r;if(!i||(r=EL(i.type))!=null&&r<=t)break;n=i}return n.to}const wit=Due.of((e,t,n)=>{for(let i=_i(e).resolveInner(n,-1);i&&!(i.fromn)return{from:n,to:s}}return null});function X4(e){return new Go(lfe,e,[],"markdown")}const Sit=X4(ufe),Eit=ufe.configure([Utt,Ftt,ztt,Vtt,{props:[wd.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),ET=X4(Eit);function kit(e,t){return n=>{if(n&&e){let i=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?i=e(n):i=pT.matchLanguageName(e,n,!0),i instanceof pT)return i.support?i.support.language.parser:Ux.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}let Ij=class{constructor(t,n,i,r,s,a,o){this.node=t,this.from=n,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=a,this.item=o}blank(t,n=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;i.length0;r--)i+=" ";return i+(n?this.spaceAfter:"")}}marker(t,n){let i=this.node.name=="OrderedList"?String(+ffe(this.item,t)[2]+n):"";return this.spaceBefore+i+this.type+this.spaceAfter}};function dfe(e,t){let n=[],i=[];for(let r=e;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&n.push(r)}for(let r=n.length-1;r>=0;r--){let s=n[r],a,o=t.lineAt(s.from),c=s.from-o.from;if(s.name=="Blockquote"&&(a=/^ *>( ?)/.exec(o.text.slice(c))))i.push(new Ij(s,c,c+a[0].length,"",a[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(c)))){let u=a[3],d=a[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),i.push(new Ij(s.parent,c,c+d,a[1],u,a[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(c)))){let u=a[4],d=a[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let f=a[2];a[3]&&(f+=a[3].replace(/[xX]/," ")),i.push(new Ij(s.parent,c,c+d,a[1],u,f,s))}}return i}function ffe(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Pj(e,t,n,i=0){for(let r=-1,s=e;;){if(s.name=="ListItem"){let o=ffe(s,t),c=+o[2];if(r>=0){if(c!=r+1)return;n.push({from:s.from+o[1].length,to:s.from+o[0].length,insert:String(r+2+i)})}r=c}let a=s.nextSibling;if(!a)break;s=a}}function q4(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(fb)!=" ")return e;let i=Bl(e,4,n),r="";for(let s=i;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+e.slice(n)}const Tit=(e={})=>({state:t,dispatch:n})=>{let i=_i(t),{doc:r}=t,s=null,a=t.changeByRange(o=>{if(!o.empty||!ET.isActiveAt(t,o.from,-1)&&!ET.isActiveAt(t,o.from,1))return s={range:o};let c=o.from,u=r.lineAt(c),d=dfe(i.resolveInner(c,-1),r);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return s={range:o};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return s={range:o};let h=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&h){let O=f.node.firstChild,v=f.node.getChild("ListItem","ListItem");if(O.to>=c||v&&v.to0&&!/[^\s>]/.test(r.lineAt(u.from-1).text)||e.nonTightLists===!1){let x=d.length>1?d[d.length-2]:null,w,E="";x&&x.item?(w=u.from+x.from,E=x.marker(r,1)):w=u.from+(x?x.to:0);let S=[{from:w,to:c,insert:E}];return f.node.name=="OrderedList"&&Pj(f.item,r,S,-2),x&&x.node.name=="OrderedList"&&Pj(x.item,r,S),{range:Qe.cursor(w+E.length),changes:S}}else{let x=$X(d,t,u);return{range:Qe.cursor(c+x.length+1),changes:{from:u.from,insert:x+t.lineBreak}}}}if(f.node.name=="Blockquote"&&h&&u.from){let O=r.lineAt(u.from-1),v=/>\s*$/.exec(O.text);if(v&&v.index==f.from){let x=t.changes([{from:O.from+v.index,to:O.to},{from:u.from+f.from,to:u.to}]);return{range:o.map(x),changes:x}}}let p=[];f.node.name=="OrderedList"&&Pj(f.item,r,p);let g=f.item&&f.item.from]*/.exec(u.text)[0].length>=f.to)for(let O=0,v=d.length-1;O<=v;O++)b+=O==v&&!g?d[O].marker(r,1):d[O].blank(Ou.from&&/\s/.test(u.text.charAt(y-u.from-1));)y--;return b=q4(b,t),Ait(f.node,t.doc)&&(b=$X(d,t,u)+t.lineBreak+b),p.push({from:y,to:c,insert:t.lineBreak+b}),{range:Qe.cursor(y+b.length+1),changes:p}});return s?!1:(n(t.update(a,{scrollIntoView:!0,userEvent:"input"})),!0)},_it=Tit();function DX(e){return e.name=="QuoteMark"||e.name=="ListMark"}function Ait(e,t){if(e.name!="OrderedList"&&e.name!="BulletList")return!1;let n=e.firstChild,i=e.getChild("ListItem","ListItem");if(!i)return!1;let r=t.lineAt(n.to),s=t.lineAt(i.from),a=/^[\s>]*$/.test(r.text);return r.number+(a?0:1){let n=_i(e),i=null,r=e.changeByRange(s=>{let a=s.from,{doc:o}=e;if(s.empty&&ET.isActiveAt(e,s.from)){let c=o.lineAt(a),u=dfe(Nit(n,a),o);if(u.length){let d=u[u.length-1],f=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(a-c.from>f&&!/\S/.test(c.text.slice(f,a-c.from)))return{range:Qe.cursor(c.from+f),changes:{from:c.from+f,to:a}};if(a-c.from==f&&(d.item&&c.from<=d.item.from||/^[\s>]*$/.test(c.text.slice(0,d.to)))){let h=c.from+d.from;if(d.item&&d.node.from{var n;let{main:i}=t.state.selection;if(i.empty)return!1;let r=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!ET.isActiveAt(t.state,i.from,1)))return!1;let s=_i(t.state),a=!1;return s.iterate({from:i.from,to:i.to,enter:o=>{(o.from>i.from||Mit.test(o.name))&&(a=!0)},leave:o=>{o.to=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}const Lrt=new Lr((e,t)=>{let n;if(e.next<0)e.acceptToken(Bit);else if(t.context.flags&xE)Lj(e.next)&&e.acceptToken(Qit,1);else if(((n=e.peek(-1))<0||Lj(n))&&t.canShift(QX)){let i=0;for(;e.next==H4||e.next==zA;)e.advance(),i++;(e.next==Np||e.next==Wx||e.next==Y4)&&e.acceptToken(QX,-i)}else Lj(e.next)&&e.acceptToken($it,1)},{contextual:!0}),Drt=new Lr((e,t)=>{let n=t.context;if(n.flags)return;let i=e.peek(-1);if(i==Np||i==Wx){let r=0,s=0;for(;;){if(e.next==H4)r++;else if(e.next==zA)r+=8-r%8;else break;e.advance(),s++}r!=n.indent&&e.next!=Np&&e.next!=Wx&&e.next!=Y4&&(r[e,t|xfe])),Brt=new CA({start:$rt,reduce(e,t,n,i){return e.flags&xE&&Mrt.has(t)||(t==irt||t==bfe)&&e.flags&xfe?e.parent:e},shift(e,t,n,i){return t==pfe?new vE(e,Qrt(i.read(i.pos,n.pos)),0):t==mfe?e.parent:t==Fit||t==Hit||t==Wit||t==gfe?new vE(e,0,xE):FX.has(t)?new vE(e,0,FX.get(t)|e.flags&xE):e},hash(e){return e.hash}}),Urt=new Lr(e=>{for(let t=0;t<5;t++){if(e.next!="print".charCodeAt(t))return;e.advance()}if(!/\w/.test(String.fromCharCode(e.next)))for(let t=0;;t++){let n=e.peek(t);if(!(n==H4||n==zA)){n!=Art&&n!=Nrt&&n!=Np&&n!=Wx&&n!=Y4&&e.acceptToken(Dit);return}}}),zrt=new Lr((e,t)=>{let{flags:n}=t.context,i=n&xu?yfe:Ofe,r=(n&vu)>0,s=!(n&wu),a=(n&Su)>0,o=e.pos;for(;!(e.next<0);)if(a&&e.next==kL)if(e.peek(1)==kL)e.advance(2);else{if(e.pos==o){e.acceptToken(gfe,1);return}break}else if(s&&e.next==zX){if(e.pos==o){e.advance();let c=e.next;c>=0&&(e.advance(),Frt(e,c)),e.acceptToken(zit);return}break}else if(e.next==zX&&!s&&e.peek(1)>-1)e.advance(2);else if(e.next==i&&(!r||e.peek(1)==i&&e.peek(2)==i)){if(e.pos==o){e.acceptToken(BX,r?3:1);return}break}else if(e.next==Np){if(r)e.advance();else if(e.pos==o){e.acceptToken(BX);return}break}else e.advance();e.pos>o&&e.acceptToken(Uit)});function Frt(e,t){if(t==Crt)for(let n=0;n<2&&e.next>=48&&e.next<=55;n++)e.advance();else if(t==jrt)for(let n=0;n<2&&Dj(e.next);n++)e.advance();else if(t==Irt)for(let n=0;n<4&&Dj(e.next);n++)e.advance();else if(t==Prt)for(let n=0;n<8&&Dj(e.next);n++)e.advance();else if(t==Rrt&&e.next==kL){for(e.advance();e.next>=0&&e.next!=UX&&e.next!=Ofe&&e.next!=yfe&&e.next!=Np;)e.advance();e.next==UX&&e.advance()}}const Vrt=xd({'async "*" "**" FormatConversion FormatSpec':G.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":G.controlKeyword,"in not and or is del":G.operatorKeyword,"from def class global nonlocal lambda":G.definitionKeyword,import:G.moduleKeyword,"with as print":G.keyword,Boolean:G.bool,None:G.null,VariableName:G.variableName,"CallExpression/VariableName":G.function(G.variableName),"FunctionDefinition/VariableName":G.function(G.definition(G.variableName)),"ClassDefinition/VariableName":G.definition(G.className),PropertyName:G.propertyName,"CallExpression/MemberExpression/PropertyName":G.function(G.propertyName),Comment:G.lineComment,Number:G.number,String:G.string,FormatString:G.special(G.string),Escape:G.escape,UpdateOp:G.updateOperator,"ArithOp!":G.arithmeticOperator,BitOp:G.bitwiseOperator,CompareOp:G.compareOperator,AssignOp:G.definitionOperator,Ellipsis:G.punctuation,At:G.meta,"( )":G.paren,"[ ]":G.squareBracket,"{ }":G.brace,".":G.derefOperator,", ;":G.separator}),Xrt={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},qrt=ad.deserialize({version:14,states:"##jQ`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#EnO0rQdO'#EtO0rQdO'#EwO4VQdO'#EyO4^QdO'#FOO4iQdO'#EzO0rQdO'#FOO1XQdO'#FQO1XQdO'#FVO4nQdO'#F[P4uOdO'#GpPOOO)CBd)CBdOOQS'#Ce'#CeOOQS'#Cf'#CfOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Cl'#ClO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO5TQdO'#DoOOQS,5:Y,5:YO5hQdO'#HdOOQS,5:],5:]O5uQ!fO,5:]O5zQtO,59YO1lQdO,59bO1lQdO,59bO1lQdO,59bO8jQdO,59bO8oQdO,59bO8vQdO,59jO8}QdO'#HTO:TQdO'#HSOOQS'#HS'#HSOOQS'#D['#D[O:lQdO,59aO'vQdO,59aO:zQdO,59aOOQS,59y,59yO;PQdO,5:RO'vQdO,5:ROOQS,5:Q,5:QO;_QdO,5:QO;dQdO,5:XO'vQdO,5:XO'vQdO,5:VOOQS,5:U,5:UO;uQdO,5:UO;zQdO,5:WOOOW'#Fy'#FyOOOOQS'#Ds'#DsOOQS1G/w1G/wOOQS1G.|1G.|O!/[QtO1G.|O!/cQtO1G.|O1lQdO1G.|O!0OQdO1G/UOOQS'#DZ'#DZO0rQdO,59tOOQS1G.{1G.{O!0VQdO1G/eO!0gQdO1G/eO!0oQdO1G/fO'vQdO'#H[O!0tQdO'#H[O!0yQtO1G.{O!1ZQdO,59iO!2aQdO,5=zO!2qQdO,5=zO!2yQdO1G/mO!3OQtO1G/mOOQS1G/l1G/lO!3`QdO,5=uO!4VQdO,5=uO0rQdO1G/qO!4tQdO1G/sO!4yQtO1G/sO!5ZQtO1G/qOOQS1G/p1G/pOOQS1G/r1G/rOOOW-E9w-E9wOOQS1G/{1G/{O!5kQdO'#HxO0rQdO'#HxO!5|QdO,5>cOOOW-E9x-E9xOOQS1G/|1G/|OOQS-E9{-E9{O!6[Q#xO1G2zO!6{QtO1G2zO'vQdO,5kOOQS1G1`1G1`O!8RQdO1G1`OOQS'#DV'#DVO0rQdO,5=qOOQS,5=q,5=qO!8WQdO'#FrO!8cQdO,59oO!8kQdO1G/XO!8uQtO,5=uOOQS1G3`1G3`OOQS,5:m,5:mO!9fQdO'#GtOOQS,5jO!;ZQdO,5>jO1XQdO,5>jO!;lQdO,5>iOOQS-E:R-E:RO!;qQdO1G0lO!;|QdO1G0lO!lO!lO!hO!=VQdO,5>hO!=hQdO'#EpO0rQdO1G0tO!=sQdO1G0tO!=xQgO1G0zO!AvQgO1G0}O!EqQdO,5>oO!E{QdO,5>oO!FTQtO,5>oO0rQdO1G1PO!F_QdO1G1PO4iQdO1G1UO!!vQdO1G1WOOQV,5;a,5;aO!FdQfO,5;aO!FiQgO1G1QO!JjQdO'#GZO4iQdO1G1QO4iQdO1G1QO!JzQdO,5>pO!KXQdO,5>pO1XQdO,5>pOOQV1G1U1G1UO!KaQdO'#FSO!KrQ!fO1G1WO!KzQdO1G1WOOQV1G1]1G1]O4iQdO1G1]O!LPQdO1G1]O!LXQdO'#F^OOQV1G1b1G1bO!#ZQtO1G1bPOOO1G2v1G2vP!L^OSO1G2vOOQS,5=},5=}OOQS'#Dp'#DpO0rQdO,5=}O!LfQdO,5=|O!LyQdO,5=|OOQS1G/u1G/uO!MRQdO,5>PO!McQdO,5>PO!MkQdO,5>PO!NOQdO,5>PO!N`QdO,5>POOQS1G3j1G3jOOQS7+$h7+$hO!8kQdO7+$pO#!RQdO1G.|O#!YQdO1G.|OOQS1G/`1G/`OOQS,5<`,5<`O'vQdO,5<`OOQS7+%P7+%PO#!aQdO7+%POOQS-E9r-E9rOOQS7+%Q7+%QO#!qQdO,5=vO'vQdO,5=vOOQS7+$g7+$gO#!vQdO7+%PO##OQdO7+%QO##TQdO1G3fOOQS7+%X7+%XO##eQdO1G3fO##mQdO7+%XOOQS,5<_,5<_O'vQdO,5<_O##rQdO1G3aOOQS-E9q-E9qO#$iQdO7+%]OOQS7+%_7+%_O#$wQdO1G3aO#%fQdO7+%_O#%kQdO1G3gO#%{QdO1G3gO#&TQdO7+%]O#&YQdO,5>dO#&sQdO,5>dO#&sQdO,5>dOOQS'#Dx'#DxO#'UO&jO'#DzO#'aO`O'#HyOOOW1G3}1G3}O#'fQdO1G3}O#'nQdO1G3}O#'yQ#xO7+(fO#(jQtO1G2UP#)TQdO'#GOOOQS,5nQdO,5sQdO1G4OOOQS-E9y-E9yO#?^QdO1G4OO<[QdO'#H{OOOO'#D{'#D{OOOO'#F|'#F|O#?oO&jO,5:fOOOW,5>e,5>eOOOW7+)i7+)iO#?zQdO7+)iO#@SQdO1G2zO#@mQdO1G2zP'vQdO'#FuO0rQdO<mO#BQQdO,5>mOOQS1G0v1G0vOOQS<rO#KgQdO,5>rO#KrQdO,5>rO#K}QdO,5>qO#L`QdO,5>qOOQS1G1Y1G1YOOQS,5;p,5;pOOQV<VAN>VO$ oQdO<cAN>cO0rQdO1G1|O$!PQtO1G1|P$!ZQdO'#FvOOQS1G2R1G2RP$!hQdO'#F{O$!uQdO7+)jO$#`QdO,5>gOOOO-E9z-E9zOOOW<tO$4{QdO,5>tO1XQdO,5vO$)nQdO,5>vOOQS1G1p1G1pOOQS,5<[,5<[OOQU7+'P7+'PO$+zQdO1G/iO$)nQdO,5wO$8zQdO,5>wOOQS1G1s1G1sOOQS7+'S7+'SP$)nQdO'#GdO$9SQdO1G4bO$9^QdO1G4bO$9fQdO1G4bOOQS7+%T7+%TO$9tQdO1G1tO$:SQtO'#FaO$:ZQdO,5<}OOQS,5<},5<}O$:iQdO1G4cOOQS-E:a-E:aO$)nQdO,5<|O$:pQdO,5<|O$:uQdO7+)|OOQS-E:`-E:`O$;PQdO7+)|O$)nQdO,5S~O%cOS%^OSSOS%]PQ~OPdOVaOfoOhYOopOs!POvqO!PrO!Q{O!T!SO!U!RO!XZO!][O!h`O!r`O!s`O!t`O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#l!QO#o!TO#s!UO#u!VO#z!WO#}hO$P!XO%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~O%]!YO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%j![O%k!]O%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aO~Ok%xXl%xXm%xXn%xXo%xXp%xXs%xXz%xX{%xX!x%xX#g%xX%[%xX%_%xX%z%xXg%xX!T%xX!U%xX%{%xX!W%xX![%xX!Q%xX#[%xXt%xX!m%xX~P%SOfoOhYO!XZO!][O!h`O!r`O!s`O!t`O%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~Oz%wX{%wX#g%wX%[%wX%_%wX%z%wX~Ok!pOl!qOm!oOn!oOo!rOp!sOs!tO!x%wX~P)pOV!zOg!|Oo0cOv0qO!PrO~P'vOV#OOo0cOv0qO!W#PO~P'vOV#SOa#TOo0cOv0qO![#UO~P'vOQ#XO%`#XO%a#ZO~OQ#^OR#[O%`#^O%a#`O~OV%iX_%iXa%iXh%iXk%iXl%iXm%iXn%iXo%iXp%iXs%iXz%iX!X%iX!f%iX%j%iX%k%iX%l%iX%m%iX%n%iX%o%iX%p%iX%q%iX%r%iX%s%iXg%iX!T%iX!U%iX~O&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O{%iX!x%iX#g%iX%[%iX%_%iX%z%iX%{%iX!W%iX![%iX!Q%iX#[%iXt%iX!m%iX~P,eOz#dO{%hX!x%hX#g%hX%[%hX%_%hX%z%hX~Oo0cOv0qO~P'vO#g#gO%[#iO%_#iO~O%uWO~O!T#nO#u!VO#z!WO#}hO~OopO~P'vOV#sOa#tO%uWO{wP~OV#xOo0cOv0qO!Q#yO~P'vO{#{O!x$QO%z#|O#g!yX%[!yX%_!yX~OV#xOo0cOv0qO#g#SX%[#SX%_#SX~P'vOo0cOv0qO#g#WX%[#WX%_#WX~P'vOh$WO%uWO~O!f$YO!r$YO%uWO~OV$eO~P'vO!U$gO#s$hO#u$iO~O{$jO~OV$qO~P'vOS$sO%[$rO%_$rO%c$tO~OV$}Oa$}Og%POo0cOv0qO~P'vOo0cOv0qO{%SO~P'vO&Y%UO~Oa!bOh!iO!X!kO!f!mOVba_bakbalbambanbaobapbasbazba{ba!xba#gba%[ba%_ba%jba%kba%lba%mba%nba%oba%pba%qba%rba%sba%zbagba!Tba!Uba%{ba!Wba![ba!Qba#[batba!mba~On%ZO~Oo%ZO~P'vOo0cO~P'vOk0eOl0fOm0dOn0dOo0mOp0nOs0rOg%wX!T%wX!U%wX%{%wX!W%wX![%wX!Q%wX#[%wX!m%wX~P)pO%{%]Og%vXz%vX!T%vX!U%vX!W%vX{%vX~Og%_Oz%`O!T%dO!U%cO~Og%_O~Oz%gO!T%dO!U%cO!W&SX~O!W%kO~Oz%lO{%nO!T%dO!U%cO![%}X~O![%rO~O![%sO~OQ#XO%`#XO%a%uO~OV%wOo0cOv0qO!PrO~P'vOQ#^OR#[O%`#^O%a%zO~OV!qa_!qaa!qah!qak!qal!qam!qan!qao!qap!qas!qaz!qa{!qa!X!qa!f!qa!x!qa#g!qa%[!qa%_!qa%j!qa%k!qa%l!qa%m!qa%n!qa%o!qa%p!qa%q!qa%r!qa%s!qa%z!qag!qa!T!qa!U!qa%{!qa!W!qa![!qa!Q!qa#[!qat!qa!m!qa~P#yOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P%SOV&OOopOvqO{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P'vOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#g$zX%[$zX%_$zX~P'vO#g#gO%[&TO%_&TO~O!f&UOh&sX%[&sXz&sX#[&sX#g&sX%_&sX#Z&sXg&sX~Oh!iO%[&WO~Okealeameaneaoeapeaseazea{ea!xea#gea%[ea%_ea%zeagea!Tea!Uea%{ea!Wea![ea!Qea#[eatea!mea~P%SOsqazqa{qa#gqa%[qa%_qa%zqa~Ok!pOl!qOm!oOn!oOo!rOp!sO!xqa~PEcO%z&YOz%yX{%yX~O%uWOz%yX{%yX~Oz&]O{wX~O{&_O~Oz%lO#g%}X%[%}X%_%}Xg%}X{%}X![%}X!m%}X%z%}X~OV0lOo0cOv0qO!PrO~P'vO%z#|O#gUa%[Ua%_Ua~Oz&hO#g&PX%[&PX%_&PXn&PX~P%SOz&kO!Q&jO#g#Wa%[#Wa%_#Wa~Oz&lO#[&nO#g&rX%[&rX%_&rXg&rX~O!f$YO!r$YO#Z&qO%uWO~O#Z&qO~Oz&sO#g&tX%[&tX%_&tX~Oz&uO#g&pX%[&pX%_&pX{&pX~O!X&wO%z&xO~Oz&|On&wX~P%SOn'PO~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO%['UO~P'vOt'YO#p'WO#q'XOP#naV#naf#nah#nao#nas#nav#na!P#na!Q#na!T#na!U#na!X#na!]#na!h#na!r#na!s#na!t#na!{#na!}#na#P#na#R#na#T#na#X#na#Z#na#^#na#_#na#a#na#c#na#l#na#o#na#s#na#u#na#z#na#}#na$P#na%X#na%o#na%p#na%t#na%u#na&Z#na&[#na&]#na&^#na&_#na&`#na&a#na&b#na&c#na&d#na&e#na&f#na&g#na&h#na&i#na&j#na%Z#na%_#na~Oz'ZO#[']O{&xX~Oh'_O!X&wO~Oh!iO{$jO!X&wO~O{'eO~P%SO%['hO%_'hO~OS'iO%['hO%_'hO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%k!]O~P!#uO%kWi~P!#uOV!aO_!aOa!bOh!iO!X!kO!f!mO%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%m!_O%n!_O~P!&pO%mWi%nWi~P!&pOa!bOh!iO!X!kO!f!mOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%mWi%nWi%oWi%pWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~OV!aO_!aO%q!aO%r!aO%s!aO~P!)nOVWi_Wi%qWi%rWi%sWi~P!)nO!T%dO!U%cOg&VXz&VX~O%z'kO%{'kO~P,eOz'mOg&UX~Og'oO~Oz'pO{'rO!W&XX~Oo0cOv0qOz'pO{'sO!W&XX~P'vO!W'uO~Om!oOn!oOo!rOp!sOkjisjizji{ji!xji#gji%[ji%_ji%zji~Ol!qO~P!.aOlji~P!.aOk0eOl0fOm0dOn0dOo0mOp0nO~Ot'wO~P!/jOV'|Og'}Oo0cOv0qO~P'vOg'}Oz(OO~Og(QO~O!U(SO~Og(TOz(OO!T%dO!U%cO~P%SOk0eOl0fOm0dOn0dOo0mOp0nOgqa!Tqa!Uqa%{qa!Wqa![qa!Qqa#[qatqa!mqa~PEcOV'|Oo0cOv0qO!W&Sa~P'vOz(WO!W&Sa~O!W(XO~Oz(WO!T%dO!U%cO!W&Sa~P%SOV(]Oo0cOv0qO![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~P'vOz(^O![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~O![(aO~Oz(^O!T%dO!U%cO![%}a~P%SOz(dO!T%dO!U%cO![&Ta~P%SOz(gO{&lX![&lX!m&lX%z&lX~O{(kO![(mO!m(nO%z(jO~OV&OOopOvqO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~P'vOz(pO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~O!f&UOh&sa%[&saz&sa#[&sa#g&sa%_&sa#Z&sag&sa~O%[(uO~OV#sOa#tO%uWO~Oz&]O{wa~OopOvqO~P'vOz(^O#g%}a%[%}a%_%}ag%}a{%}a![%}a!m%}a%z%}a~P%SOz(zO#g%hX%[%hX%_%hX%z%hX~O%z#|O#gUi%[Ui%_Ui~O#g&Pa%[&Pa%_&Pan&Pa~P'vOz(}O#g&Pa%[&Pa%_&Pan&Pa~O%uWO#g&ra%[&ra%_&rag&ra~Oz)SO#g&ra%[&ra%_&rag&ra~Og)VO~OV)WOh$WO%uWO~O#Z)XO~O%uWO#g&ta%[&ta%_&ta~Oz)ZO#g&ta%[&ta%_&ta~Oo0cOv0qO#g&pa%[&pa%_&pa{&pa~P'vOz)^O#g&pa%[&pa%_&pa{&pa~OV)`Oa)`O%uWO~O%z)eO~Ot)hO#j)gOP#hiV#hif#hih#hio#his#hiv#hi!P#hi!Q#hi!T#hi!U#hi!X#hi!]#hi!h#hi!r#hi!s#hi!t#hi!{#hi!}#hi#P#hi#R#hi#T#hi#X#hi#Z#hi#^#hi#_#hi#a#hi#c#hi#l#hi#o#hi#s#hi#u#hi#z#hi#}#hi$P#hi%X#hi%o#hi%p#hi%t#hi%u#hi&Z#hi&[#hi&]#hi&^#hi&_#hi&`#hi&a#hi&b#hi&c#hi&d#hi&e#hi&f#hi&g#hi&h#hi&i#hi&j#hi%Z#hi%_#hi~Ot)iOP#kiV#kif#kih#kio#kis#kiv#ki!P#ki!Q#ki!T#ki!U#ki!X#ki!]#ki!h#ki!r#ki!s#ki!t#ki!{#ki!}#ki#P#ki#R#ki#T#ki#X#ki#Z#ki#^#ki#_#ki#a#ki#c#ki#l#ki#o#ki#s#ki#u#ki#z#ki#}#ki$P#ki%X#ki%o#ki%p#ki%t#ki%u#ki&Z#ki&[#ki&]#ki&^#ki&_#ki&`#ki&a#ki&b#ki&c#ki&d#ki&e#ki&f#ki&g#ki&h#ki&i#ki&j#ki%Z#ki%_#ki~OV)kOn&wa~P'vOz)lOn&wa~Oz)lOn&wa~P%SOn)pO~O%Y)tO~Ot)wO#p'WO#q)vOP#niV#nif#nih#nio#nis#niv#ni!P#ni!Q#ni!T#ni!U#ni!X#ni!]#ni!h#ni!r#ni!s#ni!t#ni!{#ni!}#ni#P#ni#R#ni#T#ni#X#ni#Z#ni#^#ni#_#ni#a#ni#c#ni#l#ni#o#ni#s#ni#u#ni#z#ni#}#ni$P#ni%X#ni%o#ni%p#ni%t#ni%u#ni&Z#ni&[#ni&]#ni&^#ni&_#ni&`#ni&a#ni&b#ni&c#ni&d#ni&e#ni&f#ni&g#ni&h#ni&i#ni&j#ni%Z#ni%_#ni~OV)zOo0cOv0qO{$jO~P'vOo0cOv0qO{&xa~P'vOz*OO{&xa~OV*SOa*TOg*WO%q*UO%uWO~O{$jO&{*YO~Oh'_O~Oh!iO{$jO~O%[*_O~O%[*aO%_*aO~OV$}Oa$}Oo0cOv0qOg&Ua~P'vOz*dOg&Ua~Oo0cOv0qO{*gO!W&Xa~P'vOz*hO!W&Xa~Oo0cOv0qOz*hO{*kO!W&Xa~P'vOo0cOv0qOz*hO!W&Xa~P'vOz*hO{*kO!W&Xa~Om0dOn0dOo0mOp0nOgjikjisjizji!Tji!Uji%{ji!Wji{ji![ji#gji%[ji%_ji!Qji#[jitji!mji%zji~Ol0fO~P!NkOlji~P!NkOV'|Og*pOo0cOv0qO~P'vOn*rO~Og*pOz*tO~Og*uO~OV'|Oo0cOv0qO!W&Si~P'vOz*vO!W&Si~O!W*wO~OV(]Oo0cOv0qO![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~P'vOz*zO!T%dO!U%cO![&Ti~Oz*}O![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~O![+OO~Oa+QOo0cOv0qO![&Ti~P'vOz*zO![&Ti~O![+SO~OV+UOo0cOv0qO{&la![&la!m&la%z&la~P'vOz+VO{&la![&la!m&la%z&la~O!]+YO&n+[O![!nX~O![+^O~O{(kO![+_O~O{(kO![+_O!m+`O~OV&OOopOvqO{%hq!x%hq#g%hq%[%hq%_%hq%z%hq~P'vOz$ri{$ri!x$ri#g$ri%[$ri%_$ri%z$ri~P%SOV&OOopOvqO~P'vOV&OOo0cOv0qO#g%ha%[%ha%_%ha%z%ha~P'vOz+aO#g%ha%[%ha%_%ha%z%ha~Oz$ia#g$ia%[$ia%_$ian$ia~P%SO#g&Pi%[&Pi%_&Pin&Pi~P'vOz+dO#g#Wq%[#Wq%_#Wq~O#[+eOz$va#g$va%[$va%_$vag$va~O%uWO#g&ri%[&ri%_&rig&ri~Oz+gO#g&ri%[&ri%_&rig&ri~OV+iOh$WO%uWO~O%uWO#g&ti%[&ti%_&ti~Oo0cOv0qO#g&pi%[&pi%_&pi{&pi~P'vO{#{Oz#eX!W#eX~Oz+mO!W&uX~O!W+oO~Ot+rO#j)gOP#hqV#hqf#hqh#hqo#hqs#hqv#hq!P#hq!Q#hq!T#hq!U#hq!X#hq!]#hq!h#hq!r#hq!s#hq!t#hq!{#hq!}#hq#P#hq#R#hq#T#hq#X#hq#Z#hq#^#hq#_#hq#a#hq#c#hq#l#hq#o#hq#s#hq#u#hq#z#hq#}#hq$P#hq%X#hq%o#hq%p#hq%t#hq%u#hq&Z#hq&[#hq&]#hq&^#hq&_#hq&`#hq&a#hq&b#hq&c#hq&d#hq&e#hq&f#hq&g#hq&h#hq&i#hq&j#hq%Z#hq%_#hq~On$|az$|a~P%SOV)kOn&wi~P'vOz+yOn&wi~Oz,TO{$jO#[,TO~O#q,VOP#nqV#nqf#nqh#nqo#nqs#nqv#nq!P#nq!Q#nq!T#nq!U#nq!X#nq!]#nq!h#nq!r#nq!s#nq!t#nq!{#nq!}#nq#P#nq#R#nq#T#nq#X#nq#Z#nq#^#nq#_#nq#a#nq#c#nq#l#nq#o#nq#s#nq#u#nq#z#nq#}#nq$P#nq%X#nq%o#nq%p#nq%t#nq%u#nq&Z#nq&[#nq&]#nq&^#nq&_#nq&`#nq&a#nq&b#nq&c#nq&d#nq&e#nq&f#nq&g#nq&h#nq&i#nq&j#nq%Z#nq%_#nq~O#[,WOz%Oa{%Oa~Oo0cOv0qO{&xi~P'vOz,YO{&xi~O{#{O%z,[Og&zXz&zX~O%uWOg&zXz&zX~Oz,`Og&yX~Og,bO~O%Y,eO~O!T%dO!U%cOg&Viz&Vi~OV$}Oa$}Oo0cOv0qOg&Ui~P'vO{,hOz$la!W$la~Oo0cOv0qO{,iOz$la!W$la~P'vOo0cOv0qO{*gO!W&Xi~P'vOz,lO!W&Xi~Oo0cOv0qOz,lO!W&Xi~P'vOz,lO{,oO!W&Xi~Og$hiz$hi!W$hi~P%SOV'|Oo0cOv0qO~P'vOn,qO~OV'|Og,rOo0cOv0qO~P'vOV'|Oo0cOv0qO!W&Sq~P'vOz$gi![$gi#g$gi%[$gi%_$gig$gi{$gi!m$gi%z$gi~P%SOV(]Oo0cOv0qO~P'vOa+QOo0cOv0qO![&Tq~P'vOz,sO![&Tq~O![,tO~OV(]Oo0cOv0qO![%}q#g%}q%[%}q%_%}qg%}q{%}q!m%}q%z%}q~P'vO{,uO~OV+UOo0cOv0qO{&li![&li!m&li%z&li~P'vOz,zO{&li![&li!m&li%z&li~O!]+YO&n+[O![!na~O{(kO![,}O~OV&OOo0cOv0qO#g%hi%[%hi%_%hi%z%hi~P'vOz-OO#g%hi%[%hi%_%hi%z%hi~O%uWO#g&rq%[&rq%_&rqg&rq~Oz-RO#g&rq%[&rq%_&rqg&rq~OV)`Oa)`O%uWO!W&ua~Oz-TO!W&ua~On$|iz$|i~P%SOV)kO~P'vOV)kOn&wq~P'vOt-XOP#myV#myf#myh#myo#mys#myv#my!P#my!Q#my!T#my!U#my!X#my!]#my!h#my!r#my!s#my!t#my!{#my!}#my#P#my#R#my#T#my#X#my#Z#my#^#my#_#my#a#my#c#my#l#my#o#my#s#my#u#my#z#my#}#my$P#my%X#my%o#my%p#my%t#my%u#my&Z#my&[#my&]#my&^#my&_#my&`#my&a#my&b#my&c#my&d#my&e#my&f#my&g#my&h#my&i#my&j#my%Z#my%_#my~O%Z-]O%_-]O~P`O#q-^OP#nyV#nyf#nyh#nyo#nys#nyv#ny!P#ny!Q#ny!T#ny!U#ny!X#ny!]#ny!h#ny!r#ny!s#ny!t#ny!{#ny!}#ny#P#ny#R#ny#T#ny#X#ny#Z#ny#^#ny#_#ny#a#ny#c#ny#l#ny#o#ny#s#ny#u#ny#z#ny#}#ny$P#ny%X#ny%o#ny%p#ny%t#ny%u#ny&Z#ny&[#ny&]#ny&^#ny&_#ny&`#ny&a#ny&b#ny&c#ny&d#ny&e#ny&f#ny&g#ny&h#ny&i#ny&j#ny%Z#ny%_#ny~Oz-aO{$jO#[-aO~Oo0cOv0qO{&xq~P'vOz-dO{&xq~O%z,[Og&zaz&za~O{#{Og&zaz&za~OV*SOa*TO%q*UO%uWOg&ya~Oz-hOg&ya~O$S-lO~OV$}Oa$}Oo0cOv0qO~P'vOo0cOv0qO{-mOz$li!W$li~P'vOo0cOv0qOz$li!W$li~P'vO{-mOz$li!W$li~Oo0cOv0qO{*gO~P'vOo0cOv0qO{*gO!W&Xq~P'vOz-pO!W&Xq~Oo0cOv0qOz-pO!W&Xq~P'vOs-sO!T%dO!U%cOg&Oq!W&Oq![&Oqz&Oq~P!/jOa+QOo0cOv0qO![&Ty~P'vOz$ji![$ji~P%SOa+QOo0cOv0qO~P'vOV+UOo0cOv0qO~P'vOV+UOo0cOv0qO{&lq![&lq!m&lq%z&lq~P'vO{(kO![-xO!m-yO%z-wO~OV&OOo0cOv0qO#g%hq%[%hq%_%hq%z%hq~P'vO%uWO#g&ry%[&ry%_&ryg&ry~OV)`Oa)`O%uWO!W&ui~Ot-}OP#m!RV#m!Rf#m!Rh#m!Ro#m!Rs#m!Rv#m!R!P#m!R!Q#m!R!T#m!R!U#m!R!X#m!R!]#m!R!h#m!R!r#m!R!s#m!R!t#m!R!{#m!R!}#m!R#P#m!R#R#m!R#T#m!R#X#m!R#Z#m!R#^#m!R#_#m!R#a#m!R#c#m!R#l#m!R#o#m!R#s#m!R#u#m!R#z#m!R#}#m!R$P#m!R%X#m!R%o#m!R%p#m!R%t#m!R%u#m!R&Z#m!R&[#m!R&]#m!R&^#m!R&_#m!R&`#m!R&a#m!R&b#m!R&c#m!R&d#m!R&e#m!R&f#m!R&g#m!R&h#m!R&i#m!R&j#m!R%Z#m!R%_#m!R~Oo0cOv0qO{&xy~P'vOV*SOa*TO%q*UO%uWOg&yi~O$S-lO%Z.VO%_.VO~OV.aOh._O!X.^O!].`O!h.YO!s.[O!t.[O%p.XO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O~Oo0cOv0qOz$lq!W$lq~P'vO{.fOz$lq!W$lq~Oo0cOv0qO{*gO!W&Xy~P'vOz.gO!W&Xy~Oo0cOv.kO~P'vOs-sO!T%dO!U%cOg&Oy!W&Oy![&Oyz&Oy~P!/jO{(kO![.nO~O{(kO![.nO!m.oO~OV*SOa*TO%q*UO%uWO~Oh.tO!f.rOz$TX#[$TX%j$TXg$TX~Os$TX{$TX!W$TX![$TX~P$-bO%o.vO%p.vOs$UXz$UX{$UX#[$UX%j$UX!W$UXg$UX![$UX~O!h.xO~Oz.|O#[/OO%j.yOs&|X{&|X!W&|Xg&|X~Oa/RO~P$)zOh.tOs&}Xz&}X{&}X#[&}X%j&}X!W&}Xg&}X![&}X~Os/VO{$jO~Oo0cOv0qOz$ly!W$ly~P'vOo0cOv0qO{*gO!W&X!R~P'vOz/ZO!W&X!R~Og&RXs&RX!T&RX!U&RX!W&RX![&RXz&RX~P!/jOs-sO!T%dO!U%cOg&Qa!W&Qa![&Qaz&Qa~O{(kO![/^O~O!f.rOh$[as$[az$[a{$[a#[$[a%j$[a!W$[ag$[a![$[a~O!h/eO~O%o.vO%p.vOs$Uaz$Ua{$Ua#[$Ua%j$Ua!W$Uag$Ua![$Ua~O%j.yOs$Yaz$Ya{$Ya#[$Ya!W$Yag$Ya![$Ya~Os&|a{&|a!W&|ag&|a~P$)nOz/jOs&|a{&|a!W&|ag&|a~O!W/mO~Og/mO~O{/oO~O![/pO~Oo0cOv0qO{*gO!W&X!Z~P'vO{/sO~O%z/tO~P$-bOz/uO#[/OO%j.yOg'PX~Oz/uOg'PX~Og/wO~O!h/xO~O#[/OOs%Saz%Sa{%Sa%j%Sa!W%Sag%Sa![%Sa~O#[/OO%j.yOs%Waz%Wa{%Wa!W%Wag%Wa~Os&|i{&|i!W&|ig&|i~P$)nOz/zO#[/OO%j.yO!['Oa~Og'Pa~P$)nOz0SOg'Pa~Oa0UO!['Oi~P$)zOz0WO!['Oi~Oz0WO#[/OO%j.yO!['Oi~O#[/OO%j.yOg$biz$bi~O%z0ZO~P$-bO#[/OO%j.yOg%Vaz%Va~Og'Pi~P$)nO{0^O~Oa0UO!['Oq~P$)zOz0`O!['Oq~O#[/OO%j.yOz%Ui![%Ui~Oa0UO~P$)zOa0UO!['Oy~P$)zO#[/OO%j.yOg$ciz$ci~O#[/OO%j.yOz%Uq![%Uq~Oz+aO#g%ha%[%ha%_%ha%z%ha~P%SOV&OOo0cOv0qO~P'vOn0hO~Oo0hO~P'vO{0iO~Ot0jO~P!/jO&]&Z&j&h&i&g&f&d&e&c&b&`&a&_&^&[%u~",goto:"!=j'QPPPPPP'RP'Z*s+[+t,_,y-fP.SP'Z.r.r'ZPPP'Z2[PPPPPP2[5PPP5PP7b7k=sPP=v>h>kPP'Z'ZPP>zPP'Z'ZPP'Z'Z'Z'Z'Z?O?w'ZP?zP@QDXGuGyPG|HWH['ZPPPH_Hk'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RP'RPHqH}IVPI^IdPI^PI^I^PPPI^PKrPK{LVL]KrPI^LfPI^PLmLsPLwM]MzNeLwLwNkNxLwLwLwLw! ^! d! g! l! o! y!!P!!]!!o!!u!#P!#V!#s!#y!$P!$Z!$a!$g!$y!%T!%Z!%a!%k!%q!%w!%}!&T!&Z!&e!&k!&u!&{!'U!'[!'k!'s!'}!(UPPPPPPPPPPP!([!(_!(e!(n!(x!)TPPPPPPPPPPPP!-u!/Z!3^!6oPP!6w!7W!7a!8Y!8P!8c!8i!8l!8o!8r!8z!9jPPPPPPPPPPPPPPPPP!9m!9q!9wP!:]!:a!:m!:v!;S!;j!;m!;p!;v!;|!_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY%oY[%T[]%o]p%Tpq%oq#O%T#O#P&o#P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To&tX&n`OY%TYZ%oZ]%T]^%o^#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc'f[&n`O!_%T!_!`([!`#T%T#T#U(r#U#f%T#f#g(r#g#h(r#h#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(cTmR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(yT!mR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk)aV&n`&[ZOr%Trs)vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk){V&n`Or%Trs*bs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk*iT&n`&^ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To+PZS_&n`OY*xYZ%TZ]*x]^%T^#o*x#o#p+r#p#q*x#q#r+r#r;'S*x;'S;=`,^<%lO*x_+wTS_OY+rZ]+r^;'S+r;'S;=`,W<%lO+r_,ZP;=`<%l+ro,aP;=`<%l*xj,kV%rQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-XT!xY&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-oV%lQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.]V&n`&ZZOw%Twx.rx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.wV&n`Ow%Twx/^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/eT&n`&]ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/{ThZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc0cTgR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk0yXVZ&n`Oz%Tz{1f{!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk1mVaR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk2ZV%oZ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc2wTzR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To3_W%pZ&n`O!_%T!_!`-Q!`!a3w!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Td4OT&{S&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk4fX!fQ&n`O!O%T!O!P5R!P!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5WV&n`O!O%T!O!P5m!P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5tT!rZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti6[a!hX&n`O!Q%T!Q![6T![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S6T#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti7fZ&n`O{%T{|8X|}%T}!O8X!O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8^V&n`O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8z]!hX&n`O!Q%T!Q![8s![!l%T!l!m9s!m#R%T#R#S8s#S#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti9zT!hX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk:bX%qR&n`O!P%T!P!Q:}!Q!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj;UV%sQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti;ro!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!d%T!d!e?q!e!g%T!g!h7a!h!l%T!l!m9s!m!q%T!q!rA]!r!z%T!z!{Bq!{#R%T#R#S>_#S#U%T#U#V?q#V#X%T#X#Y7a#Y#^%T#^#_9s#_#c%T#c#dA]#d#l%T#l#mBq#m#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti=xV&n`O!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti>fc!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S>_#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti?vY&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti@mY!hX&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiAbX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBUX!hX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBv]&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiCv]!hX&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToDvV{_&n`O!_%T!_!`E]!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TcEdT%{R&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkEzT#gZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkFbXmR&n`O!^%T!^!_F}!_!`([!`!a([!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjGUV%mQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkGrV%zZ&n`O!_%T!_!`([!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkH`WmR&n`O!_%T!_!`([!`!aHx!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjIPV%nQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkIoV_Q#}P&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToJ_]&n`&YS%uZO!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoKZP;=`<%lJUoKge&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!tJU!t!uLx!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#gLx#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoMRa&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUkN_V&n`&`ZOr%TrsNts#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkNyV&n`Or%Trs! `s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! gT&n`&bZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! }V&n`&_ZOw%Twx!!dx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!!iV&n`Ow%Twx!#Ox#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!#VT&n`&aZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!#oe&n`&YS%uZOr%Trs!%Qsw%Twx!&px!Q%T!Q![JU![!c%T!c!tJU!t!u!(`!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#g!(`#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!%XV&n`&dZOr%Trs!%ns#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!%sV&n`Or%Trs!&Ys#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&aT&n`&fZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&wV&n`&cZOw%Twx!'^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!'cV&n`Ow%Twx!'xx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!(PT&n`&eZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!(ia&n`&YS%uZOr%Trs!)nsw%Twx!+^x!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!)uV&n`&hZOr%Trs!*[s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*aV&n`Or%Trs!*vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*}T&n`&jZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!+eV&n`&gZOw%Twx!+zx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,PV&n`Ow%Twx!,fx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,mT&n`&iZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!-Vi&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!dJU!d!eLx!e!hJU!h!i!(`!i!}JU!}#R%T#R#SJU#S#T%T#T#UJU#U#VLx#V#YJU#Y#Z!(`#Z#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUo!.}a&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!0ZT!XZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc!0qT!WR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj!1XV%kQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[Urt,Drt,Lrt,zrt,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:e=>Xrt[e]||-1}],tokenPrec:7668}),VX=new t4,vfe=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function lS(e){return(t,n,i)=>{if(i)return!1;let r=t.node.getChild("VariableName");return r&&n(r,e),!0}}const Hrt={FunctionDefinition:lS("function"),ClassDefinition:lS("class"),ForStatement(e,t,n){if(n){for(let i=e.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")t(i,"variable");else if(i.name=="in")break}},ImportStatement(e,t){var n,i;let{node:r}=e,s=((n=r.firstChild)===null||n===void 0?void 0:n.name)=="from";for(let a=r.getChild("import");a;a=a.nextSibling)a.name=="VariableName"&&((i=a.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&t(a,s?"variable":"namespace")},AssignStatement(e,t){for(let n=e.node.firstChild;n;n=n.nextSibling)if(n.name=="VariableName")t(n,"variable");else if(n.name==":"||n.name=="AssignOp")break},ParamList(e,t){for(let n=null,i=e.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!n||!/\*|AssignOp/.test(n.name))&&t(i,"variable"),n=i},CapturePattern:lS("variable"),AsPattern:lS("variable"),__proto__:null};function wfe(e,t){let n=VX.get(t);if(n)return n;let i=[],r=!0;function s(a,o){let c=e.sliceString(a.from,a.to);i.push({label:c,type:o})}return t.cursor(si.IncludeAnonymous).iterate(a=>{if(a.name){let o=Hrt[a.name];if(o&&o(a,s,r)||!r&&vfe.has(a.name))return!1;r=!1}else if(a.to-a.from>8192){for(let o of wfe(e,a.node))i.push(o);return!1}}),VX.set(t,i),i}const XX=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Sfe=["String","FormatString","Comment","PropertyName"];function Yrt(e){let t=_i(e.state).resolveInner(e.pos,-1);if(Sfe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&XX.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let i=[];for(let r=t;r;r=r.parent)vfe.has(r.name)&&(i=i.concat(wfe(e.state.doc,r)));return{options:i,from:n?t.from:e.pos,validFor:XX}}const Grt=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(e=>({label:e,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(e=>({label:e,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(e=>({label:e,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(e=>({label:e,type:"function"}))),Wrt=[hr("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),hr("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),hr("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),hr("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),hr(`if \${}: -`,{label:"if",detail:"block",type:"keyword"}),hr("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),hr("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),hr("import ${module}",{label:"import",detail:"statement",type:"keyword"}),hr("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],Wrt=Wue(wfe,_4(Yrt.concat(Grt)));function $j(e){let{node:t,pos:n}=e,i=e.lineIndent(n,-1),r=null;for(;;){let s=t.childBefore(n);if(s)if(s.name=="Comment")n=s.from;else if(s.name=="Body"||s.name=="MatchBody")e.baseIndentFor(s)+e.unit<=i&&(r=s),t=s;else if(s.name=="MatchClause")t=s;else if(s.type.is("Statement"))t=s;else break;else break}return r}function Qj(e,t){let n=e.baseIndentFor(t),i=e.lineAt(e.pos,-1),r=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&e.node.ton?null:n+e.unit}const Bj=ud.define({name:"python",parser:Xrt.configure({props:[rh.add({Body:e=>{var t;let n=/^\s*(#|$)/.test(e.textAfter)&&$j(e)||e.node;return(t=Qj(e,n))!==null&&t!==void 0?t:e.continue()},MatchBody:e=>{var t;let n=$j(e);return(t=Qj(e,n||e.node))!==null&&t!==void 0?t:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),"ForStatement WhileStatement":e=>/^\s*else:/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except[ :]|finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),MatchStatement:e=>/^\s*case /.test(e.textAfter)?e.baseIndent+e.unit:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Ig({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Ig({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Ig({closing:"]"}),MemberExpression:e=>e.baseIndent+e.unit,"String FormatString":()=>null,Script:e=>{var t;let n=$j(e);return(t=n&&Qj(e,n))!==null&&t!==void 0?t:e.continue()}}),wd.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":ev,Body:(e,t)=>({from:e.from+1,to:e.to-(e.to==t.doc.length?0:1)}),"String FormatString":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function Zrt(){return new Yf(Bj,[Bj.data.of({autocomplete:Hrt}),Bj.data.of({autocomplete:Wrt})])}const Rm=63,qX=64,Krt=1,Jrt=2,Sfe=3,est=4,Efe=5,tst=6,nst=7,kfe=65,ist=66,rst=8,sst=9,ast=10,ost=11,lst=12,Tfe=13,cst=19,ust=20,dst=29,fst=33,hst=34,pst=47,mst=0,G4=1,TL=2,Zx=3,_L=4;class Mh{constructor(t,n,i){this.parent=t,this.depth=n,this.type=i,this.hash=(t?t.hash+t.hash<<8:0)+n+(n<<4)+i}}Mh.top=new Mh(null,-1,mst);function jy(e,t){for(let n=0,i=t-e.pos-1;;i--,n++){let r=e.peek(i);if(dd(r)||r==-1)return n}}function AL(e){return e==32||e==9}function dd(e){return e==10||e==13}function _fe(e){return AL(e)||dd(e)}function Hh(e){return e<0||_fe(e)}const gst=new CA({start:Mh.top,reduce(e,t){return e.type==Zx&&(t==ust||t==hst)?e.parent:e},shift(e,t,n,i){if(t==Sfe)return new Mh(e,jy(i,i.pos),G4);if(t==kfe||t==Efe)return new Mh(e,jy(i,i.pos),TL);if(t==Rm)return e.parent;if(t==cst||t==fst)return new Mh(e,0,Zx);if(t==Tfe&&e.type==_L)return e.parent;if(t==pst){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Mh(e,e.depth+ +r[0],_L)}return e},hash(e){return e.hash}});function _0(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&Hh(e.peek(n+3))}const bst=new Lr((e,t)=>{if(e.next==-1&&t.canShift(qX))return e.acceptToken(qX);let n=e.peek(-1);if((dd(n)||n<0)&&t.context.type!=Zx){if(_0(e,45))if(t.canShift(Rm))e.acceptToken(Rm);else return e.acceptToken(Krt,3);if(_0(e,46))if(t.canShift(Rm))e.acceptToken(Rm);else return e.acceptToken(Jrt,3);let i=0;for(;e.next==32;)i++,e.advance();(i{if(t.context.type==Zx){e.next==63&&(e.advance(),Hh(e.next)&&e.acceptToken(nst));return}if(e.next==45)e.advance(),Hh(e.next)&&e.acceptToken(t.context.type==G4&&t.context.depth==jy(e,e.pos-1)?est:Sfe);else if(e.next==63)e.advance(),Hh(e.next)&&e.acceptToken(t.context.type==TL&&t.context.depth==jy(e,e.pos-1)?tst:Efe);else{let n=e.pos;for(;;)if(AL(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)Afe(e);else if(e.next==38)NL(e);else if(e.next==42){NL(e);break}else if(e.next==39||e.next==34){if(W4(e,!0))break;return}else if(e.next==91||e.next==123){if(!xst(e))return;break}else{Nfe(e,!0,!1,0);break}for(;AL(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(dst))return;let i=e.peek(1);Hh(i)&&e.acceptTokenTo(t.context.type==TL&&t.context.depth==jy(e,n)?ist:kfe,n)}}},{contextual:!0});function yst(e){return e>32&&e<127&&e!=34&&e!=37&&e!=44&&e!=60&&e!=62&&e!=92&&e!=94&&e!=96&&e!=123&&e!=124&&e!=125}function HX(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function YX(e,t){return e.next==37?(e.advance(),HX(e.next)&&e.advance(),HX(e.next)&&e.advance(),!0):yst(e.next)||t&&e.next==44?(e.advance(),!0):!1}function Afe(e){if(e.advance(),e.next==60){for(e.advance();;)if(!YX(e,!0)){e.next==62&&e.advance();break}}else for(;YX(e,!1););}function NL(e){for(e.advance();!Hh(e.next)&&kT(e.next)!="f";)e.advance()}function W4(e,t){let n=e.next,i=!1,r=e.pos;for(e.advance();;){let s=e.next;if(s<0)break;if(e.advance(),s==n)if(s==39)if(e.next==39)e.advance();else break;else break;else if(s==92&&n==34)e.next>=0&&e.advance();else if(dd(s)){if(t)return!1;i=!0}else if(t&&e.pos>=r+1024)return!1}return!i}function xst(e){for(let t=[],n=e.pos+1024;;)if(e.next==91||e.next==123)t.push(e.next),e.advance();else if(e.next==39||e.next==34){if(!W4(e,!0))return!1}else if(e.next==93||e.next==125){if(t[t.length-1]!=e.next-2)return!1;if(t.pop(),e.advance(),!t.length)return!0}else{if(e.next<0||e.pos>n||dd(e.next))return!1;e.advance()}}const vst="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function kT(e){return e<33?"u":e>125?"s":vst[e-33]}function Uj(e,t){let n=kT(e);return n!="u"&&!(t&&n=="f")}function Nfe(e,t,n,i){if(kT(e.next)=="s"||(e.next==63||e.next==58||e.next==45)&&Uj(e.peek(1),n))e.advance();else return!1;let r=e.pos;for(;;){let s=e.next,a=0,o=i+1;for(;_fe(s);){if(dd(s)){if(t)return!1;o=0}else o++;s=e.peek(++a)}if(!(s>=0&&(s==58?Uj(e.peek(a+1),n):s==35?e.peek(a-1)!=32:Uj(s,n)))||!n&&o<=i||o==0&&!n&&(_0(e,45,a)||_0(e,46,a)))break;if(t&&kT(s)=="f")return!1;for(let u=a;u>=0;u--)e.advance();if(t&&e.pos>r+1024)return!1}return!0}const wst=new Lr((e,t)=>{if(e.next==33)Afe(e),e.acceptToken(lst);else if(e.next==38||e.next==42){let n=e.next==38?ast:ost;NL(e),e.acceptToken(n)}else e.next==39||e.next==34?(W4(e,!1),e.acceptToken(sst)):Nfe(e,!1,t.context.type==Zx,t.context.depth)&&e.acceptToken(rst)}),Sst=new Lr((e,t)=>{let n=t.context.type==_L?t.context.depth:-1,i=e.pos;e:for(;;){let r=0,s=e.next;for(;s==32;)s=e.peek(++r);if(!r&&(_0(e,45,r)||_0(e,46,r))||!dd(s)&&(n<0&&(n=Math.max(t.context.depth+1,r)),rYAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:gst,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Est],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[bst,Ost,wst,Sst,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Tst=ud.define({name:"yaml",parser:kst.configure({props:[rh.add({Stream:e=>{for(let t=e.node.resolve(e.pos,-1);t&&t.to>=e.pos;t=t.parent){if(t.name=="BlockLiteralContent"&&t.frome.pos)return null}}return null},FlowMapping:Ig({closing:"}"}),FlowSequence:Ig({closing:"]"})}),wd.add({"FlowMapping FlowSequence":ev,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function _st(){return new Yf(Tst)}function CL(){return CL=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=K4(e.state,n.from);return i.line?Cst(e):i.block?Rst(e):!1};function Z4(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=e(t,n);return r?(i(n.update(r)),!0):!1}}const Cst=Z4(Mst,0),jst=Z4(Cfe,0),Rst=Z4((e,t)=>Cfe(e,t,Pst(t)),0);function K4(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const dO=50;function Ist(e,{open:t,close:n},i,r){let s=e.sliceDoc(i-dO,i),a=e.sliceDoc(r,r+dO),o=/\s*$/.exec(s)[0].length,c=/^\s*/.exec(a)[0].length,u=s.length-o;if(s.slice(u-t.length,u)==t&&a.slice(c,c+n.length)==n)return{open:{pos:i-o,margin:o&&1},close:{pos:r+c,margin:c&&1}};let d,f;r-i<=2*dO?d=f=e.sliceDoc(i,r):(d=e.sliceDoc(i,i+dO),f=e.sliceDoc(r-dO,r));let h=/^\s*/.exec(d)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-n.length;return d.slice(h,h+t.length)==t&&f.slice(g,g+n.length)==n?{open:{pos:i+h+t.length,margin:/\s/.test(d.charAt(h+t.length))?1:0},close:{pos:r-p-n.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function Pst(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}function Cfe(e,t,n=t.selection.ranges){let i=n.map(s=>K4(t,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,a)=>Ist(t,i[a],s.from,s.to));if(e!=2&&!r.every(s=>s))return{changes:t.changes(n.map((s,a)=>r[a]?[]:[{from:s.from,insert:i[a].open+" "},{from:s.to,insert:" "+i[a].close}]))};if(e!=1&&r.some(s=>s)){let s=[];for(let a=0,o;ar&&(s==a||a>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,p=h==f.length,g=f.text.slice(h,h+u.length)==u?h:-1;hs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:o,token:c,indent:u,empty:d,single:f}of i)(f||!d)&&s.push({from:o.from+u,insert:c+" "});let a=t.changes(s);return{changes:a,selection:t.selection.map(a,1)}}else if(e!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:a,comment:o,token:c}of i)if(o>=0){let u=a.from+o,d=u+c.length;a.text[d-a.from]==" "&&d++,s.push({from:u,to:d})}return{changes:s}}return null}const jL=Kc.define(),Lst=Kc.define(),Dst=yt.define(),jfe=yt.define({combine(e){return Jc(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(i,r)=>t(i,r)||n(i,r)})}}),Rfe=Ms.define({create(){return Ic.empty},update(e,t){let n=t.state.facet(jfe),i=t.annotation(jL);if(i){let c=Ba.fromTransaction(t,i.selection),u=i.side,d=u==0?e.undone:e.done;return c?d=TT(d,d.length,n.minDepth,c):d=Mfe(d,t.startState.selection),new Ic(u==0?i.rest:d,u==0?d:i.rest)}let r=t.annotation(Lst);if((r=="full"||r=="before")&&(e=e.isolate()),t.annotation(Xr.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let s=Ba.fromTransaction(t),a=t.annotation(Xr.time),o=t.annotation(Xr.userEvent);return s?e=e.addChanges(s,a,o,n,t):t.selection&&(e=e.addSelection(t.startState.selection,a,o,n.newGroupDelay)),(r=="full"||r=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new Ic(e.done.map(Ba.fromJSON),e.undone.map(Ba.fromJSON))}});function $st(e={}){return[Rfe,jfe.of(e),ft.domEventHandlers({beforeinput(t,n){let i=t.inputType=="historyUndo"?Ife:t.inputType=="historyRedo"?RL:null;return i?(t.preventDefault(),i(n)):!1}})]}function FA(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(Rfe,!1);if(!r)return!1;let s=r.pop(e,n,t);return s?(i(s),!0):!1}}const Ife=FA(0,!1),RL=FA(1,!1),Qst=FA(0,!0),Bst=FA(1,!0);class Ba{constructor(t,n,i,r,s){this.changes=t,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(t){return new Ba(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new Ba(t.changes&&ns.fromJSON(t.changes),[],t.mapped&&Qc.fromJSON(t.mapped),t.startSelection&&Qe.fromJSON(t.startSelection),t.selectionsAfter.map(Qe.fromJSON))}static fromTransaction(t,n){let i=Zo;for(let r of t.startState.facet(Dst)){let s=r(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new Ba(t.changes.invert(t.startState.doc),i,void 0,n||t.startState.selection,Zo)}static selection(t){return new Ba(void 0,Zo,void 0,void 0,t)}}function TT(e,t,n,i){let r=t+1>n+20?t-n-1:0,s=e.slice(r,t);return s.push(i),s}function Ust(e,t){let n=[],i=!1;return e.iterChangedRanges((r,s)=>n.push(r,s)),t.iterChangedRanges((r,s,a,o)=>{for(let c=0;c=u&&a<=d&&(i=!0)}}),i}function zst(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,i)=>n.empty!=t.ranges[i].empty).length===0}function Pfe(e,t){return e.length?t.length?e.concat(t):e:t}const Zo=[],Fst=200;function Mfe(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Fst));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),TT(e,e.length-1,1e9,n.setSelAfter(i)))}else return[Ba.selection([t])]}function Vst(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function zj(e,t){if(!e.length)return e;let n=e.length,i=Zo;for(;n;){let r=Xst(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=e.slice(0,n);return s[n-1]=r,s}else t=r.mapped,n--,i=r.selectionsAfter}return i.length?[Ba.selection(i)]:Zo}function Xst(e,t,n){let i=Pfe(e.selectionsAfter.length?e.selectionsAfter.map(o=>o.map(t)):Zo,n);if(!e.changes)return Ba.selection(i);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),a=e.mapped?e.mapped.composeDesc(s):s;return new Ba(r,rn.mapEffects(e.effects,t),a,e.startSelection.map(s),i)}const qst=/^(input\.type|delete)($|\.)/;class Ic{constructor(t,n,i=0,r=void 0){this.done=t,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Ic(this.done,this.undone):this}addChanges(t,n,i,r,s){let a=this.done,o=a[a.length-1];return o&&o.changes&&!o.changes.empty&&t.changes&&(!i||qst.test(i))&&(!o.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):VA(n,t))}function ta(e){return e.textDirectionAt(e.state.selection.main.head)==Pi.LTR}const Dfe=e=>Lfe(e,!ta(e)),$fe=e=>Lfe(e,ta(e));function Qfe(e,t){return Wl(e,n=>n.empty?e.moveByGroup(n,t):VA(n,t))}const Yst=e=>Qfe(e,!ta(e)),Gst=e=>Qfe(e,ta(e));function Wst(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function XA(e,t,n){let i=_i(e).resolveInner(t.head),r=n?sn.closedBy:sn.openedBy;for(let c=t.head;;){let u=n?i.childAfter(c):i.childBefore(c);if(!u)break;Wst(e,u,r)?i=u:c=n?u.to:u.from}let s=i.type.prop(r),a,o;return s&&(a=n?Rc(e,i.from,1):Rc(e,i.to,-1))&&a.matched?o=n?a.end.to:a.end.from:o=n?i.to:i.from,Qe.cursor(o,n?-1:1)}const Zst=e=>Wl(e,t=>XA(e.state,t,!ta(e))),Kst=e=>Wl(e,t=>XA(e.state,t,ta(e)));function Bfe(e,t){return Wl(e,n=>{if(!n.empty)return VA(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}const Ufe=e=>Bfe(e,!1),zfe=e=>Bfe(e,!0);function Ffe(e){let t=e.scrollDOM.clientHeighta.empty?e.moveVertically(a,t,n.height):VA(a,t));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let a=e.coordsAtPos(i.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),c=o.top+n.marginTop,u=o.bottom-n.marginBottom;a&&a.top>c&&a.bottomVfe(e,!1),IL=e=>Vfe(e,!0);function sh(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&t.head!=i.from+s&&(r=Qe.cursor(i.from+s))}return r}const Jst=e=>Wl(e,t=>sh(e,t,!0)),eat=e=>Wl(e,t=>sh(e,t,!1)),tat=e=>Wl(e,t=>sh(e,t,!ta(e))),nat=e=>Wl(e,t=>sh(e,t,ta(e))),iat=e=>Wl(e,t=>Qe.cursor(e.lineBlockAt(t.head).from,1)),rat=e=>Wl(e,t=>Qe.cursor(e.lineBlockAt(t.head).to,-1));function sat(e,t,n){let i=!1,r=pb(e.selection,s=>{let a=Rc(e,s.head,-1)||Rc(e,s.head,1)||s.head>0&&Rc(e,s.head-1,1)||s.headsat(e,t);function ll(e,t,n){let i=pb(e.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=t&&(r=Qe.range(r.head,r.anchor));let s=n(r);return Qe.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(e.state.selection)?!1:(e.dispatch(Gl(e.state,i)),!0)}function Xfe(e,t){return ll(e,t,n=>e.moveByChar(n,t))}const qfe=e=>Xfe(e,!ta(e)),Hfe=e=>Xfe(e,ta(e));function Yfe(e,t){return ll(e,t,n=>e.moveByGroup(n,t))}const oat=e=>Yfe(e,!ta(e)),lat=e=>Yfe(e,ta(e)),cat=e=>{let t=!ta(e);return ll(e,t,n=>XA(e.state,n,t))},uat=e=>{let t=ta(e);return ll(e,t,n=>XA(e.state,n,t))};function Gfe(e,t){return ll(e,t,n=>e.moveVertically(n,t))}const Wfe=e=>Gfe(e,!1),Zfe=e=>Gfe(e,!0);function Kfe(e,t){return ll(e,t,n=>e.moveVertically(n,t,Ffe(e).height))}const WX=e=>Kfe(e,!1),ZX=e=>Kfe(e,!0),dat=e=>ll(e,!0,t=>sh(e,t,!0)),fat=e=>ll(e,!1,t=>sh(e,t,!1)),hat=e=>{let t=!ta(e);return ll(e,t,n=>sh(e,n,t))},pat=e=>{let t=ta(e);return ll(e,t,n=>sh(e,n,t))},mat=e=>ll(e,!1,t=>Qe.cursor(e.lineBlockAt(t.head).from)),gat=e=>ll(e,!0,t=>Qe.cursor(e.lineBlockAt(t.head).to)),KX=({state:e,dispatch:t})=>(t(Gl(e,{anchor:0})),!0),JX=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.doc.length})),!0),eq=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.selection.main.anchor,head:0})),!0),tq=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),bat=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Oat=({state:e,dispatch:t})=>{let n=qA(e).map(({from:i,to:r})=>Qe.range(i,Math.min(r+1,e.doc.length)));return t(e.update({selection:Qe.create(n),userEvent:"select"})),!0},yat=({state:e,dispatch:t})=>{let n=pb(e.selection,i=>{let r=_i(e),s=r.resolveStack(i.from,1);if(i.empty){let a=r.resolveStack(i.from,-1);a.node.from>=s.node.from&&a.node.to<=s.node.to&&(s=a)}for(let a=s;a;a=a.next){let{node:o}=a;if((o.from=i.to||o.to>i.to&&o.from<=i.from)&&a.next)return Qe.range(o.to,o.from)}return i});return n.eq(e.selection)?!1:(t(Gl(e,n)),!0)};function Jfe(e,t){let{state:n}=e,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let a=n.doc.lineAt(s.head);if(t?a.to0)for(let o=s;;){let c=e.moveVertically(o,t);if(c.heada.to){r.some(u=>u.head==c.head)||r.push(c);break}else{if(c.head==o.head)break;o=c}}}return r.length==i.ranges.length?!1:(e.dispatch(Gl(n,Qe.create(r,r.length-1))),!0)}const xat=e=>Jfe(e,!1),vat=e=>Jfe(e,!0),wat=({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=Qe.create([n.main]):n.main.empty||(i=Qe.create([Qe.cursor(n.main.head)])),i?(t(Gl(e,i)),!0):!1};function rv(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange(s=>{let{from:a,to:o}=s;if(a==o){let c=t(s);ca&&(n="delete.forward",c=cS(e,c,!0)),a=Math.min(a,c),o=Math.max(o,c)}else a=cS(e,a,!1),o=cS(e,o,!0);return a==o?{range:s}:{changes:{from:a,to:o},range:Qe.cursor(a,ar(e)))i.between(t,t,(r,s)=>{rt&&(t=n?s:r)});return t}const ehe=(e,t,n)=>rv(e,i=>{let r=i.from,{state:s}=e,a=s.doc.lineAt(r),o,c;if(n&&!t&&r>a.from&&rehe(e,!1,!0),the=e=>ehe(e,!0,!1),nhe=(e,t)=>rv(e,n=>{let i=n.head,{state:r}=e,s=r.doc.lineAt(i),a=r.charCategorizer(i);for(let o=null;;){if(i==(t?s.to:s.from)){i==n.head&&s.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let c=Os(s.text,i-s.from,t)+s.from,u=s.text.slice(Math.min(i,c)-s.from,Math.max(i,c)-s.from),d=a(u);if(o!=null&&d!=o)break;(u!=" "||i!=n.head)&&(o=d),i=c}return i}),ihe=e=>nhe(e,!1),Sat=e=>nhe(e,!0),Eat=e=>rv(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headrv(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Tat=e=>rv(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ei.of(["",""])},range:Qe.cursor(i.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Aat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{if(!i.empty||i.from==0||i.from==e.doc.length)return{range:i};let r=i.from,s=e.doc.lineAt(r),a=r==s.from?r-1:Os(s.text,r-s.from,!1)+s.from,o=r==s.to?r+1:Os(s.text,r-s.from,!0)+s.from;return{changes:{from:a,to:o,insert:e.doc.slice(r,o).append(e.doc.slice(a,r))},range:Qe.cursor(o)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function qA(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),s=e.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=e.doc.lineAt(i.to-1)),n>=r.number){let a=t[t.length-1];a.to=s.to,a.ranges.push(i)}else t.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return t}function rhe(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let s of qA(e)){if(n?s.to==e.doc.length:s.from==0)continue;let a=e.doc.lineAt(n?s.to+1:s.from-1),o=a.length+1;if(n){i.push({from:s.to,to:a.to},{from:s.from,insert:a.text+e.lineBreak});for(let c of s.ranges)r.push(Qe.range(Math.min(e.doc.length,c.anchor+o),Math.min(e.doc.length,c.head+o)))}else{i.push({from:a.from,to:s.from},{from:s.to,insert:e.lineBreak+a.text});for(let c of s.ranges)r.push(Qe.range(c.anchor-o,c.head-o))}}return i.length?(t(e.update({changes:i,scrollIntoView:!0,selection:Qe.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Nat=({state:e,dispatch:t})=>rhe(e,t,!1),Cat=({state:e,dispatch:t})=>rhe(e,t,!0);function she(e,t,n){if(e.readOnly)return!1;let i=[];for(let s of qA(e))n?i.push({from:s.from,insert:e.doc.slice(s.from,s.to)+e.lineBreak}):i.push({from:s.to,insert:e.lineBreak+e.doc.slice(s.from,s.to)});let r=e.changes(i);return t(e.update({changes:r,selection:e.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const jat=({state:e,dispatch:t})=>she(e,t,!1),Rat=({state:e,dispatch:t})=>she(e,t,!0),Iat=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(qA(t).map(({from:r,to:s})=>(r>0?r--:s{let s;if(e.lineWrapping){let a=e.lineBlockAt(r.head),o=e.coordsAtPos(r.head,r.assoc||1);o&&(s=a.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(r,!0,s)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Pat(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=_i(e).resolveInner(t),i=n.childBefore(t),r=n.childAfter(t),s;return i&&r&&i.to<=t&&r.from>=t&&(s=i.type.prop(sn.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const nq=ahe(!1),Mat=ahe(!0);function ahe(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{let{from:s,to:a}=r,o=t.doc.lineAt(s),c=!e&&s==a&&Pat(t,s);e&&(s=a=(a<=o.to?o:t.doc.lineAt(a)).to);let u=new $A(t,{simulateBreak:s,simulateDoubleBreak:!!c}),d=E4(u,s);for(d==null&&(d=Bl(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));ao.from&&s{let r=[];for(let a=i.from;a<=i.to;){let o=e.doc.lineAt(a);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),a=o.to+1}let s=e.changes(r);return{changes:r,range:Qe.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Lat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new $A(e,{overrideIndentation:s=>{let a=n[s];return a??-1}}),r=J4(e,(s,a,o)=>{let c=E4(i,s.from);if(c==null)return;/\S/.test(s.text)||(c=0);let u=/^\s*/.exec(s.text)[0],d=zx(e,c);(u!=d||o.frome.readOnly?!1:(t(e.update(J4(e,(n,i)=>{i.push({from:n.from,insert:e.facet(fb)})}),{userEvent:"input.indent"})),!0),lhe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(J4(e,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=Bl(r,e.tabSize),a=0,o=zx(e,Math.max(0,s-mT(e)));for(;a(e.setTabFocusMode(),!0),$at=[{key:"Ctrl-b",run:Dfe,shift:qfe,preventDefault:!0},{key:"Ctrl-f",run:$fe,shift:Hfe},{key:"Ctrl-p",run:Ufe,shift:Wfe},{key:"Ctrl-n",run:zfe,shift:Zfe},{key:"Ctrl-a",run:iat,shift:mat},{key:"Ctrl-e",run:rat,shift:gat},{key:"Ctrl-d",run:the},{key:"Ctrl-h",run:PL},{key:"Ctrl-k",run:Eat},{key:"Ctrl-Alt-h",run:ihe},{key:"Ctrl-o",run:_at},{key:"Ctrl-t",run:Aat},{key:"Ctrl-v",run:IL}],Qat=[{key:"ArrowLeft",run:Dfe,shift:qfe,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Yst,shift:oat,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:tat,shift:hat,preventDefault:!0},{key:"ArrowRight",run:$fe,shift:Hfe,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Gst,shift:lat,preventDefault:!0},{mac:"Cmd-ArrowRight",run:nat,shift:pat,preventDefault:!0},{key:"ArrowUp",run:Ufe,shift:Wfe,preventDefault:!0},{mac:"Cmd-ArrowUp",run:KX,shift:eq},{mac:"Ctrl-ArrowUp",run:GX,shift:WX},{key:"ArrowDown",run:zfe,shift:Zfe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:JX,shift:tq},{mac:"Ctrl-ArrowDown",run:IL,shift:ZX},{key:"PageUp",run:GX,shift:WX},{key:"PageDown",run:IL,shift:ZX},{key:"Home",run:eat,shift:fat,preventDefault:!0},{key:"Mod-Home",run:KX,shift:eq},{key:"End",run:Jst,shift:dat,preventDefault:!0},{key:"Mod-End",run:JX,shift:tq},{key:"Enter",run:nq,shift:nq},{key:"Mod-a",run:bat},{key:"Backspace",run:PL,shift:PL,preventDefault:!0},{key:"Delete",run:the,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ihe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Sat,preventDefault:!0},{mac:"Mod-Backspace",run:kat,preventDefault:!0},{mac:"Mod-Delete",run:Tat,preventDefault:!0}].concat($at.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Bat=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Zst,shift:cat},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Kst,shift:uat},{key:"Alt-ArrowUp",run:Nat},{key:"Shift-Alt-ArrowUp",run:jat},{key:"Alt-ArrowDown",run:Cat},{key:"Shift-Alt-ArrowDown",run:Rat},{key:"Mod-Alt-ArrowUp",run:xat},{key:"Mod-Alt-ArrowDown",run:vat},{key:"Escape",run:wat},{key:"Mod-Enter",run:Mat},{key:"Alt-l",mac:"Ctrl-l",run:Oat},{key:"Mod-i",run:yat,preventDefault:!0},{key:"Mod-[",run:lhe},{key:"Mod-]",run:ohe},{key:"Mod-Alt-\\",run:Lat},{key:"Shift-Mod-k",run:Iat},{key:"Shift-Mod-\\",run:aat},{key:"Mod-/",run:Nst},{key:"Alt-A",run:jst},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Dat}].concat(Qat),Uat={key:"Tab",run:ohe,shift:lhe},iq=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class A0{constructor(t,n,i=0,r=t.length,s,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,r),this.bufferStart=i,this.normalize=s?o=>s(iq(o)):iq,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Pa(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=i4(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=Sc(t);let r=this.normalize(n);if(r.length)for(let s=0,a=i,o=!0;;s++){let c=r.charCodeAt(s),u=this.match(c,a,o,this.bufferPos+this.bufferStart,s==r.length-1);if(u)return this.value=u,this;if(s==r.length-1)break;o&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let i=this.curLineStart+n.index,r=i+n[0].length;if(this.matchPos=_T(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,precise:!0,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||r.to<=n){let o=new Lg(n,t.sliceString(n,i));return Fj.set(t,o),o}if(r.from==n&&r.to==i)return r;let{text:s,from:a}=r;return a>n&&(s=t.sliceString(n,a)+s,a=n),r.to=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let i=this.flat.from+n.index,r=i+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,precise:!0,match:n},this.matchPos=_T(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Lg.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(uhe.prototype[Symbol.iterator]=dhe.prototype[Symbol.iterator]=function(){return this});function zat(e){try{return new RegExp(e,eQ),!0}catch{return!1}}function _T(e,t){if(t>=e.length)return t;let n=e.lineAt(t),i;for(;t=56320&&i<57344;)t++;return t}const Fat=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:i,result:r}=lJe(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return r.then(s=>{let a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){e.dispatch({effects:i});return}let o=t.doc.lineAt(t.selection.main.head),[,c,u,d,f]=a,h=d?+d.slice(1):0,p=u?+u:o.number;if(u&&f){let y=p/100;c&&(y=y*(c=="-"?-1:1)+o.number/t.doc.lines),p=Math.round(t.doc.lines*y)}else u&&c&&(p=p*(c=="-"?-1:1)+o.number);let g=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),b=Qe.cursor(g.from+Math.max(0,Math.min(h,g.length)));e.dispatch({effects:[i,ft.scrollIntoView(b.from,{y:"center"})],selection:b})}),!0},Vat={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Xat=yt.define({combine(e){return Jc(e,Vat,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function qat(e){return[Zat,Wat]}const Hat=zt.mark({class:"cm-selectionMatch"}),Yat=zt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function rq(e,t,n,i){return(n==0||e(t.sliceDoc(n-1,n))!=lr.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=lr.Word)}function Gat(e,t,n,i){return e(t.sliceDoc(n,n+1))==lr.Word&&e(t.sliceDoc(i-1,i))==lr.Word}const Wat=Tr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Xat),{state:n}=e,i=n.selection;if(i.ranges.length>1)return zt.none;let r=i.main,s,a=null;if(r.empty){if(!t.highlightWordAroundCursor)return zt.none;let c=n.wordAt(r.head);if(!c)return zt.none;a=n.charCategorizer(r.head),s=n.sliceDoc(c.from,c.to)}else{let c=r.to-r.from;if(c200)return zt.none;if(t.wholeWords){if(s=n.sliceDoc(r.from,r.to),a=n.charCategorizer(r.head),!(rq(a,n,r.from,r.to)&&Gat(a,n,r.from,r.to)))return zt.none}else if(s=n.sliceDoc(r.from,r.to),!s)return zt.none}let o=[];for(let c of e.visibleRanges){let u=new A0(n.doc,s,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!a||rq(a,n,d,f))&&(r.empty&&d<=r.from&&f>=r.to?o.push(Yat.range(d,f)):(d>=r.to||f<=r.from)&&o.push(Hat.range(d,f)),o.length>t.maxMatches))return zt.none}}return zt.set(o)}},{decorations:e=>e.decorations}),Zat=ft.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Kat=({state:e,dispatch:t})=>{let{selection:n}=e,i=Qe.create(n.ranges.map(r=>e.wordAt(r.head)||Qe.cursor(r.head)),n.mainIndex);return i.eq(n)?!1:(t(e.update({selection:i})),!0)};function Jat(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let a=!1,o=new A0(e.doc,t,i[i.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new A0(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(c=>c.from==o.value.from))continue;if(s){let c=e.wordAt(o.value.from);if(!c||c.from!=o.value.from||c.to!=o.value.to)continue}return o.value}}const eot=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(s=>s.from===s.to))return Kat({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(s=>e.sliceDoc(s.from,s.to)!=i))return!1;let r=Jat(e,i);return r?(t(e.update({selection:e.selection.addRange(Qe.range(r.from,r.to),!1),effects:ft.scrollIntoView(r.to)})),!0):!1},mb=yt.define({combine(e){return Jc(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new pot(t),scrollToMatch:t=>ft.scrollIntoView(t)})}});class fhe{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||zat(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,i)=>i=="n"?` -`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new aot(this):new iot(this)}getCursor(t,n=0,i){let r=t.doc?t:Bn.create({doc:t});return i==null&&(i=r.doc.length),this.regexp?Pm(this,r,n,i):Im(this,r,n,i)}}class hhe{constructor(t){this.spec=t}}function tot(e,t,n){return(i,r,s,a)=>{if(n&&!n(i,r,s,a))return!1;let o=i>=a&&r<=a+s.length?s.slice(i-a,r-a):t.doc.sliceString(i,r);return e(o,t,i,r)}}function Im(e,t,n,i){let r;return e.wholeWord&&(r=not(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(r=tot(e.test,t,r)),new A0(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:s=>s.toLowerCase(),r)}function not(e,t){return(n,i,r,s)=>((s>n||s+r.length=n)return null;r.push(i.value)}return r}highlight(t,n,i,r){let s=Im(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function rot(e,t,n){return(i,r,s)=>(!n||n(i,r,s))&&e(s[0],t,i,r)}function Pm(e,t,n,i){let r;return e.wholeWord&&(r=sot(t.charCategorizer(t.selection.main.head))),e.test&&(r=rot(e.test,t,r)),new uhe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:r},n,i)}function AT(e,t){return e.slice(Os(e,t,!1),t)}function NT(e,t){return e.slice(t,Os(e,t))}function sot(e){return(t,n,i)=>!i[0].length||(e(AT(i.input,i.index))!=lr.Word||e(NT(i.input,i.index))!=lr.Word)&&(e(NT(i.input,i.index+i[0].length))!=lr.Word||e(AT(i.input,i.index+i[0].length))!=lr.Word)}class aot extends hhe{nextMatch(t,n,i){let r=Pm(this.spec,t,i,t.doc.length).next();return r.done&&(r=Pm(this.spec,t,0,n).next()),r.done?null:r.value}prevMatchInRange(t,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),a=Pm(this.spec,t,s,i),o=null;for(;!a.next().done;)o=a.value;if(o&&(s==n||o.from>s+10))return o;if(s==n)return null}}prevMatch(t,n,i){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s=n)return null;r.push(i.value)}return r}highlight(t,n,i,r){let s=Pm(this.spec,t,Math.max(0,n-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Kx=rn.define(),tQ=rn.define(),kf=Ms.define({create(e){return new Vj(ML(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Kx)?e=new Vj(n.value.create(),e.panel):n.is(tQ)&&(e=new Vj(e.query,n.value?nQ:null));return e},provide:e=>Bx.from(e,t=>t.panel)});class Vj{constructor(t,n){this.query=t,this.panel=n}}const oot=zt.mark({class:"cm-searchMatch"}),lot=zt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),cot=Tr.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(kf))}update(e){let t=e.state.field(kf);(t!=e.startState.field(kf)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return zt.none;let{view:n}=this,i=new od;for(let r=0,s=n.visibleRanges,a=s.length;rs[r+1].from-2*250;)c=s[++r].to;e.highlight(n.state,o,c,(u,d)=>{let f=n.state.selection.ranges.some(h=>h.from==u&&h.to==d);i.add(u,d,f?lot:oot)})}return i.finish()}},{decorations:e=>e.decorations});function sv(e){return t=>{let n=t.state.field(kf,!1);return n&&n.query.spec.valid?e(t,n):ghe(t)}}const CT=sv((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let r=Qe.single(i.from,i.to),s=e.state.facet(mb);return e.dispatch({selection:r,effects:[iQ(e,i),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),mhe(e),!0}),jT=sv((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,r=t.prevMatch(n,i,i);if(!r)return!1;let s=Qe.single(r.from,r.to),a=e.state.facet(mb);return e.dispatch({selection:s,effects:[iQ(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),mhe(e),!0}),uot=sv((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Qe.create(n.map(i=>Qe.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),dot=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],a=0;for(let o=new A0(e.doc,e.sliceDoc(i,r));!o.next().done;){if(s.length>1e3)return!1;o.value.from==i&&(a=s.length),s.push(Qe.range(o.value.from,o.value.to))}return t(e.update({selection:Qe.create(s,a),userEvent:"select.search.matches"})),!0},sq=sv((e,{query:t})=>{let{state:n}=e,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=t.nextMatch(n,i,i);if(!s)return!1;let a=s,o=[],c,u,d=[];a.precise?a.from==i&&a.to==r&&(u=n.toText(t.getReplacement(a)),o.push({from:a.from,to:a.to,insert:u}),a=t.nextMatch(n,a.from,a.to),d.push(ft.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+"."))):a=t.nextMatch(n,a.from,a.to);let f=e.state.changes(o);return a&&(c=Qe.single(a.from,a.to).map(f),d.push(iQ(e,a)),d.push(n.facet(mb).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),fot=sv((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:s,to:a,precise:o}=r;o&&n.push({from:s,to:a,insert:t.getReplacement(r)})}if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:ft.announce.of(i),userEvent:"input.replace.all"}),!0});function nQ(e){return e.state.facet(mb).createPanel(e)}function ML(e,t){var n,i,r,s,a;let o=e.selection.main,c=o.empty||o.to>o.from+100?"":e.sliceDoc(o.from,o.to);if(t&&!c)return t;let u=e.facet(mb);return new fhe({search:((n=t==null?void 0:t.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(i=t==null?void 0:t.caseSensitive)!==null&&i!==void 0?i:u.caseSensitive,literal:(r=t==null?void 0:t.literal)!==null&&r!==void 0?r:u.literal,regexp:(s=t==null?void 0:t.regexp)!==null&&s!==void 0?s:u.regexp,wholeWord:(a=t==null?void 0:t.wholeWord)!==null&&a!==void 0?a:u.wholeWord})}function phe(e){let t=v4(e,nQ);return t&&t.dom.querySelector("[main-field]")}function mhe(e){let t=phe(e);t&&t==e.root.activeElement&&t.select()}const ghe=e=>{let t=e.state.field(kf,!1);if(t&&t.panel){let n=phe(e);if(n&&n!=e.root.activeElement){let i=ML(e.state,t.query.spec);i.valid&&e.dispatch({effects:Kx.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[tQ.of(!0),t?Kx.of(ML(e.state,t.query.spec)):rn.appendConfig.of(got)]});return!0},bhe=e=>{let t=e.state.field(kf,!1);if(!t||!t.panel)return!1;let n=v4(e,nQ);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:tQ.of(!1)}),!0},hot=[{key:"Mod-f",run:ghe,scope:"editor search-panel"},{key:"F3",run:CT,shift:jT,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:CT,shift:jT,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:bhe,scope:"editor search-panel"},{key:"Mod-Shift-l",run:dot},{key:"Mod-Alt-g",run:Fat},{key:"Mod-d",run:eot,preventDefault:!0}];class pot{constructor(t){this.view=t;let n=this.query=t.state.field(kf).query.spec;this.commit=this.commit.bind(this),this.searchField=Ei("input",{value:n.search,placeholder:Ja(t,"Find"),"aria-label":Ja(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ei("input",{value:n.replace,placeholder:Ja(t,"Replace"),"aria-label":Ja(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ei("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Ei("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Ei("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,a){return Ei("button",{class:"cm-button",name:r,onclick:s,type:"button"},a)}this.dom=Ei("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>CT(t),[Ja(t,"next")]),i("prev",()=>jT(t),[Ja(t,"previous")]),i("select",()=>uot(t),[Ja(t,"all")]),Ei("label",null,[this.caseField,Ja(t,"match case")]),Ei("label",null,[this.reField,Ja(t,"regexp")]),Ei("label",null,[this.wordField,Ja(t,"by word")]),...t.state.readOnly?[]:[Ei("br"),this.replaceField,i("replace",()=>sq(t),[Ja(t,"replace")]),i("replaceAll",()=>fot(t),[Ja(t,"replace all")])],Ei("button",{name:"close",onclick:()=>bhe(t),"aria-label":Ja(t,"close"),type:"button"},["×"])])}commit(){let t=new fhe({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Kx.of(t)}))}keydown(t){bKe(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?jT:CT)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),sq(this.view))}update(t){for(let n of t.transactions)for(let i of n.effects)i.is(Kx)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mb).top}}function Ja(e,t){return e.state.phrase(t)}const uS=30,dS=/[\s\.,:;?!]/;function iQ(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,s=Math.max(i.from,t-uS),a=Math.min(r,n+uS),o=e.state.sliceDoc(s,a);if(s!=i.from){for(let c=0;co.length-uS;c--)if(!dS.test(o[c-1])&&dS.test(o[c])){o=o.slice(0,c);break}}return ft.announce.of(`${e.state.phrase("current match")}. ${o} ${e.state.phrase("on line")} ${i.number}.`)}const mot=ft.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),got=[kf,vd.low(cot),mot];class aq{constructor(t,n,i){this.from=t,this.to=n,this.diagnostic=i}}class Lh{constructor(t,n,i){this.diagnostics=t,this.panel=n,this.selected=i}static init(t,n,i){let r=i.facet(Jx).markerFilter;r&&(t=r(t,i));let s=t.slice().sort((p,g)=>p.from-g.from||p.to-g.to),a=new od,o=[],c=0,u=i.doc.iter(),d=0,f=i.doc.length;for(let p=0;;){let g=p==s.length?null:s[p];if(!g&&!o.length)break;let b,y;if(o.length)b=c,y=o.reduce((x,w)=>Math.min(x,w.to),g&&g.from>b?g.from:1e8);else{if(b=g.from,b>f)break;y=g.to,o.push(g),p++}for(;px.from||x.to==b))o.push(x),p++,y=Math.min(x.to,y);else{y=Math.min(x.from,y);break}}y=Math.min(y,f);let O=!1;if(o.some(x=>x.from==b&&(x.to==y||y==f))&&(O=b==y,!O&&y-b<10)){let x=b-(d+u.value.length);x>0&&(u.next(x),d=b);for(let w=b;;){if(w>=y){O=!0;break}if(!u.lineBreak&&d+u.value.length>w)break;w=d+u.value.length,d+=u.value.length,u.next()}}let v=Not(o);if(O)a.add(b,b,zt.widget({widget:new kot(v),diagnostics:o.slice()}));else{let x=o.reduce((w,E)=>E.markClass?w+" "+E.markClass:w,"");a.add(b,y,zt.mark({class:"cm-lintRange cm-lintRange-"+v+x,diagnostics:o.slice(),inclusiveEnd:o.some(w=>w.to>y)}))}if(c=y,c==f)break;for(let x=0;x{if(!(t&&a.diagnostics.indexOf(t)<0))if(!i)i=new aq(r,s,t||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new aq(i.from,s,i.diagnostic)}}),i}function bot(e,t){let n=t.pos,i=t.end||n,r=e.state.facet(Jx).hideOn(e,n,i);if(r!=null)return r;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(a=>a.is(Ohe))||e.changes.touchesRange(s.from,Math.max(s.to,i)))}function Oot(e,t){return e.field(mo,!1)?t:t.concat(rn.appendConfig.of(Cot))}const Ohe=rn.define(),rQ=rn.define(),yhe=rn.define(),mo=Ms.define({create(){return new Lh(zt.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,r=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);i=Gf(n,e.selected.diagnostic,s)||Gf(n,null,s)}!n.size&&r&&t.state.facet(Jx).autoPanel&&(r=null),e=new Lh(n,r,i)}for(let n of t.effects)if(n.is(Ohe)){let i=t.state.facet(Jx).autoPanel?n.value.length?e1.open:null:e.panel;e=Lh.init(n.value,i,t.state)}else n.is(rQ)?e=new Lh(e.diagnostics,n.value?e1.open:null,e.selected):n.is(yhe)&&(e=new Lh(e.diagnostics,e.panel,n.value));return e},provide:e=>[Bx.from(e,t=>t.panel),ft.decorations.from(e,t=>t.diagnostics)]}),yot=zt.mark({class:"cm-lintRange cm-lintRange-active"});function xot(e,t,n){let{diagnostics:i}=e.state.field(mo),r,s=-1,a=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(tvhe(e,n,!1)))}const wot=e=>{let t=e.state.field(mo,!1);(!t||!t.panel)&&e.dispatch({effects:Oot(e.state,[rQ.of(!0)])});let n=v4(e,e1.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},oq=e=>{let t=e.state.field(mo,!1);return!t||!t.panel?!1:(e.dispatch({effects:rQ.of(!1)}),!0)},Sot=e=>{let t=e.state.field(mo,!1);if(!t)return!1;let n=e.state.selection.main,i=Gf(t.diagnostics,null,n.to+1);return!i&&(i=Gf(t.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),aJe(e,i.from,1,{tooltip:whe,until:r=>r.docChanged||r.newSelection.main.headi.to}),!0)},Eot=[{key:"Mod-Shift-m",run:wot,preventDefault:!0},{key:"F8",run:Sot}],Jx=yt.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Jc(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lq,tooltipFilter:lq,needsRefresh:(t,n)=>t?n?i=>t(i)||n(i):t:n,hideOn:(t,n)=>t?n?(i,r,s)=>t(i,r,s)||n(i,r,s):t:n,autoPanel:(t,n)=>t||n})}}});function lq(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function xhe(e){let t=[];if(e)e:for(let{name:n}of e){for(let i=0;is.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function vhe(e,t,n){var i;let r=n?xhe(t.actions):[];return Ei("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Ei("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((s,a)=>{let o=!1,c=p=>{if(p.preventDefault(),o)return;o=!0;let g=Gf(e.state.field(mo).diagnostics,t);g&&s.apply(e,g.from,g.to)},{name:u}=s,d=r[a]?u.indexOf(r[a]):-1,f=d<0?u:[u.slice(0,d),Ei("u",u.slice(d,d+1)),u.slice(d+1)],h=s.markClass?" "+s.markClass:"";return Ei("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${r[a]})"`}.`},f)}),t.source&&Ei("div",{class:"cm-diagnosticSource"},t.source))}class kot extends Yl{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Ei("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cq{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=vhe(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class e1{constructor(t){this.view=t,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)oq(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],a=xhe(s.actions);for(let o=0;o{for(let s=0;soq(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(mo).selected;if(!t)return-1;for(let n=0;n{for(let d of u.diagnostics){if(a.has(d))continue;a.add(d);let f=-1,h;for(let p=i;pi&&(this.items.splice(i,f-i),r=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:c})=>{let u=c.height/this.list.offsetHeight;o.topc.bottom&&(this.list.scrollTop+=(o.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let t=this.list.firstChild;function n(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)n();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(mo),i=Gf(n.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:yhe.of(i)})}static open(t){return new e1(t)}}function Tot(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function fS(e){return Tot(``,'width="6" height="3"')}const _ot=ft.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fS("#f11")},".cm-lintRange-warning":{backgroundImage:fS("orange")},".cm-lintRange-info":{backgroundImage:fS("#999")},".cm-lintRange-hint":{backgroundImage:fS("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Aot(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function Not(e){let t="hint",n=1;for(let i of e){let r=Aot(i.severity);r>n&&(n=r,t=i.severity)}return t}const whe=sJe(xot,{hideOn:bot}),Cot=[mo,ft.decorations.compute([mo],e=>{let{selected:t,panel:n}=e.field(mo);return!t||!n||t.from==t.to?zt.none:zt.set([yot.range(t.from,t.to)])}),whe,_ot];var uq=function(t){t===void 0&&(t={});var n=t,i=n.crosshairCursor,r=i===void 0?!1:i,s=[];t.closeBracketsKeymap!==!1&&(s=s.concat(Zet)),t.defaultKeymap!==!1&&(s=s.concat(Bat)),t.searchKeymap!==!1&&(s=s.concat(hot)),t.historyKeymap!==!1&&(s=s.concat(Hst)),t.foldKeymap!==!1&&(s=s.concat(zJe)),t.completionKeymap!==!1&&(s=s.concat(sde)),t.lintKeymap!==!1&&(s=s.concat(Eot));var a=[];return t.lineNumbers!==!1&&a.push(yJe()),t.highlightActiveLineGutter!==!1&&a.push(wJe()),t.highlightSpecialChars!==!1&&a.push(PKe()),t.history!==!1&&a.push($st()),t.foldGutter!==!1&&a.push(qJe()),t.drawSelection!==!1&&a.push(SKe()),t.dropCursor!==!1&&a.push(AKe()),t.allowMultipleSelections!==!1&&a.push(Bn.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&a.push(PJe()),t.syntaxHighlighting!==!1&&a.push(Xue(WJe,{fallback:!0})),t.bracketMatching!==!1&&a.push(iet()),t.closeBrackets!==!1&&a.push(Het()),t.autocompletion!==!1&&a.push(rtt()),t.rectangularSelection!==!1&&a.push(YKe()),r!==!1&&a.push(ZKe()),t.highlightActiveLine!==!1&&a.push(BKe()),t.highlightSelectionMatches!==!1&&a.push(qat()),t.tabSize&&typeof t.tabSize=="number"&&a.push(fb.of(" ".repeat(t.tabSize))),a.concat([db.of(s.flat())]).filter(Boolean)};const jot="#e5c07b",dq="#e06c75",Rot="#56b6c2",Iot="#ffffff",wE="#abb2bf",LL="#7d8799",Pot="#61afef",Mot="#98c379",fq="#d19a66",Lot="#c678dd",Dot="#21252b",hq="#2c313a",pq="#282c34",Xj="#353a42",$ot="#3E4451",mq="#528bff",Qot=ft.theme({"&":{color:wE,backgroundColor:pq},".cm-content":{caretColor:mq},".cm-cursor, .cm-dropCursor":{borderLeftColor:mq},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$ot},".cm-panels":{backgroundColor:Dot,color:wE},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:pq,color:LL,border:"none"},".cm-activeLineGutter":{backgroundColor:hq},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Xj},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Xj,borderBottomColor:Xj},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hq,color:wE}}},{dark:!0}),Bot=nv.define([{tag:G.keyword,color:Lot},{tag:[G.name,G.deleted,G.character,G.propertyName,G.macroName],color:dq},{tag:[G.function(G.variableName),G.labelName],color:Pot},{tag:[G.color,G.constant(G.name),G.standard(G.name)],color:fq},{tag:[G.definition(G.name),G.separator],color:wE},{tag:[G.typeName,G.className,G.number,G.changed,G.annotation,G.modifier,G.self,G.namespace],color:jot},{tag:[G.operator,G.operatorKeyword,G.url,G.escape,G.regexp,G.link,G.special(G.string)],color:Rot},{tag:[G.meta,G.comment],color:LL},{tag:G.strong,fontWeight:"bold"},{tag:G.emphasis,fontStyle:"italic"},{tag:G.strikethrough,textDecoration:"line-through"},{tag:G.link,color:LL,textDecoration:"underline"},{tag:G.heading,fontWeight:"bold",color:dq},{tag:[G.atom,G.bool,G.special(G.variableName)],color:fq},{tag:[G.processingInstruction,G.string,G.inserted],color:Mot},{tag:G.invalid,color:Iot}]),Uot=[Qot,Xue(Bot)];var zot=ft.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Fot=function(t){t===void 0&&(t={});var n=t,i=n.indentWithTab,r=i===void 0?!0:i,s=n.editable,a=s===void 0?!0:s,o=n.readOnly,c=o===void 0?!1:o,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,h=f===void 0?"":f,p=n.basicSetup,g=p===void 0?!0:p,b=[];switch(r&&b.unshift(db.of([Uat])),g&&(typeof g=="boolean"?b.unshift(uq()):b.unshift(uq(g))),h&&b.unshift(VKe(h)),d){case"light":b.push(zot);break;case"dark":b.push(Uot);break;case"none":break;default:b.push(d);break}return a===!1&&b.push(ft.editable.of(!1)),c&&b.push(Bn.readOnly.of(!0)),[...b]},Vot=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class Xot{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class gq{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var qj=null,qot=()=>typeof window>"u"?new gq:(qj||(qj=new gq),qj),Hot=ft.theme({"& .cm-scroller":{height:"100% !important"}}),bq=null,Hj=null;function Yot(e,t,n,i,r,s){if(!e&&!t&&!n&&!i&&!r&&!s)return null;var a=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:s});return a===bq||(bq=a,Hj=ft.theme({"&":{height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:s}})),Hj}var Oq=Kc.define(),Got=200,Wot=[];function Zot(e){var t=e.value,n=e.selection,i=e.onChange,r=e.onStatistics,s=e.onCreateEditor,a=e.onUpdate,o=e.extensions,c=o===void 0?Wot:o,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,h=e.height,p=h===void 0?null:h,g=e.minHeight,b=g===void 0?null:g,y=e.maxHeight,O=y===void 0?null:y,v=e.width,x=v===void 0?null:v,w=e.minWidth,E=w===void 0?null:w,S=e.maxWidth,k=S===void 0?null:S,T=e.placeholder,A=T===void 0?"":T,N=e.editable,C=N===void 0?!0:N,M=e.readOnly,L=M===void 0?!1:M,P=e.indentWithTab,Q=P===void 0?!0:P,j=e.basicSetup,$=j===void 0?!0:j,U=e.root,B=e.initialState,I=m.useState(),X=I[0],q=I[1],D=m.useState(),H=D[0],re=D[1],fe=m.useState(),Ae=fe[0],J=fe[1],ie=m.useState(()=>({current:null}))[0],ue=m.useState(()=>({current:null}))[0],ye=Yot(p,b,O,x,E,k),Se=ft.updateListener.of(me=>{if(me.docChanged&&typeof i=="function"&&!me.transactions.some(Oe=>Oe.annotation(Oq))){ie.current?ie.current.reset():(ie.current=new Xot(()=>{if(ue.current){var Oe=ue.current;ue.current=null,Oe()}ie.current=null},Got),qot().add(ie.current));var oe=me.state.doc,Ne=oe.toString();i(Ne,me)}r&&r(Vot(me))}),Re=Fot({theme:f,editable:C,readOnly:L,placeholder:A,indentWithTab:Q,basicSetup:$}),Ee=[Se,...ye?[ye]:[],Hot,...Re];return a&&typeof a=="function"&&Ee.push(ft.updateListener.of(a)),Ee=Ee.concat(c),m.useLayoutEffect(()=>{if(X&&!Ae){var me={doc:t,selection:n,extensions:Ee},oe=B?Bn.fromJSON(B.json,me,B.fields):Bn.create(me);if(J(oe),!H){var Ne=new ft({state:oe,parent:X,root:U});re(Ne),s&&s(Ne,oe)}}return()=>{H&&(J(void 0),re(void 0))}},[X,Ae]),m.useEffect(()=>{e.container&&q(e.container)},[e.container]),m.useEffect(()=>()=>{H&&(H.destroy(),re(void 0)),ie.current&&(ie.current.cancel(),ie.current=null)},[H]),m.useEffect(()=>{u&&H&&H.focus()},[u,H]),m.useEffect(()=>{H&&H.dispatch({effects:rn.reconfigure.of(Ee)})},[f,c,p,b,O,x,E,k,A,C,L,Q,$,i,a]),m.useEffect(()=>{if(t!==void 0){var me=H?H.state.doc.toString():"";if(H&&t!==me){var oe=ie.current&&!ie.current.isDone,Ne=()=>{H&&t!==H.state.doc.toString()&&H.dispatch({changes:{from:0,to:H.state.doc.toString().length,insert:t||""},annotations:[Oq.of(!0)]})};oe?ue.current=Ne:Ne()}}},[t,H]),{state:Ae,setState:J,view:H,setView:re,container:X,setContainer:q}}var Kot=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],She=m.forwardRef((e,t)=>{var n=e.className,i=e.value,r=i===void 0?"":i,s=e.selection,a=e.extensions,o=a===void 0?[]:a,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,h=e.autoFocus,p=e.theme,g=p===void 0?"light":p,b=e.height,y=e.minHeight,O=e.maxHeight,v=e.width,x=e.minWidth,w=e.maxWidth,E=e.basicSetup,S=e.placeholder,k=e.indentWithTab,T=e.editable,A=e.readOnly,N=e.root,C=e.initialState,M=Ast(e,Kot),L=m.useRef(null),P=Zot({root:N,value:r,autoFocus:h,theme:g,height:b,minHeight:y,maxHeight:O,width:v,minWidth:x,maxWidth:w,basicSetup:E,placeholder:S,indentWithTab:k,editable:T,readOnly:A,selection:s,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:o,initialState:C}),Q=P.state,j=P.view,$=P.container,U=P.setContainer;m.useImperativeHandle(t,()=>({editor:L.current,state:Q,view:j}),[L,$,Q,j]);var B=m.useCallback(X=>{L.current=X,U(X)},[U]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var I=typeof g=="string"?"cm-theme-"+g:"cm-theme";return l.jsx("div",CL({ref:B,className:""+I+(n?" "+n:"")},M))});She.displayName="CodeMirror";function Jot(e){const t=e.toLowerCase(),n=t.split("/").pop()??t,i=n.includes(".")?n.split(".").pop():"";return i==="py"||i==="pyi"?[Zrt()]:["ts","tsx","mts","cts"].includes(i??"")?[bL({typescript:!0,jsx:i==="tsx"})]:["js","jsx","mjs","cjs"].includes(i??"")?[bL({jsx:i==="jsx"})]:i==="json"||i==="jsonc"?[btt()]:i==="yaml"||i==="yml"?[_st()]:["md","markdown"].includes(i??"")?[jit()]:[]}function sQ({value:e,path:t,onChange:n,readOnly:i=!1}){const r=m.useMemo(()=>Jot(t),[t]);return l.jsx(She,{value:e,height:"100%",theme:"light",extensions:r,editable:!i,onChange:n,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,highlightActiveLineGutter:!0,autocompletion:!1}})}const Ehe=Object.freeze(Object.defineProperty({__proto__:null,default:sQ},Symbol.toStringTag,{value:"Module"}));function elt(e){var s;const t=e.split(/\r?\n/);if(((s=t[0])==null?void 0:s.trim())!=="---")return{body:e,frontmatter:[]};const n=t.findIndex((a,o)=>o>0&&a.trim()==="---");if(n<0)return{body:e,frontmatter:[]};const i=Zle(t.slice(1,n).join(` +`,{label:"if",detail:"block",type:"keyword"}),hr("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),hr("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),hr("import ${module}",{label:"import",detail:"statement",type:"keyword"}),hr("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],Zrt=Zue(Sfe,_4(Grt.concat(Wrt)));function $j(e){let{node:t,pos:n}=e,i=e.lineIndent(n,-1),r=null;for(;;){let s=t.childBefore(n);if(s)if(s.name=="Comment")n=s.from;else if(s.name=="Body"||s.name=="MatchBody")e.baseIndentFor(s)+e.unit<=i&&(r=s),t=s;else if(s.name=="MatchClause")t=s;else if(s.type.is("Statement"))t=s;else break;else break}return r}function Qj(e,t){let n=e.baseIndentFor(t),i=e.lineAt(e.pos,-1),r=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&e.node.ton?null:n+e.unit}const Bj=ud.define({name:"python",parser:qrt.configure({props:[rh.add({Body:e=>{var t;let n=/^\s*(#|$)/.test(e.textAfter)&&$j(e)||e.node;return(t=Qj(e,n))!==null&&t!==void 0?t:e.continue()},MatchBody:e=>{var t;let n=$j(e);return(t=Qj(e,n||e.node))!==null&&t!==void 0?t:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),"ForStatement WhileStatement":e=>/^\s*else:/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except[ :]|finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),MatchStatement:e=>/^\s*case /.test(e.textAfter)?e.baseIndent+e.unit:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Ig({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Ig({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Ig({closing:"]"}),MemberExpression:e=>e.baseIndent+e.unit,"String FormatString":()=>null,Script:e=>{var t;let n=$j(e);return(t=n&&Qj(e,n))!==null&&t!==void 0?t:e.continue()}}),wd.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":ev,Body:(e,t)=>({from:e.from+1,to:e.to-(e.to==t.doc.length?0:1)}),"String FormatString":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function Krt(){return new Yf(Bj,[Bj.data.of({autocomplete:Yrt}),Bj.data.of({autocomplete:Zrt})])}const Rm=63,qX=64,Jrt=1,est=2,Efe=3,tst=4,kfe=5,nst=6,ist=7,Tfe=65,rst=66,sst=8,ast=9,ost=10,lst=11,cst=12,_fe=13,ust=19,dst=20,fst=29,hst=33,pst=34,mst=47,gst=0,G4=1,TL=2,Zx=3,_L=4;class Mh{constructor(t,n,i){this.parent=t,this.depth=n,this.type=i,this.hash=(t?t.hash+t.hash<<8:0)+n+(n<<4)+i}}Mh.top=new Mh(null,-1,gst);function jy(e,t){for(let n=0,i=t-e.pos-1;;i--,n++){let r=e.peek(i);if(dd(r)||r==-1)return n}}function AL(e){return e==32||e==9}function dd(e){return e==10||e==13}function Afe(e){return AL(e)||dd(e)}function Hh(e){return e<0||Afe(e)}const bst=new CA({start:Mh.top,reduce(e,t){return e.type==Zx&&(t==dst||t==pst)?e.parent:e},shift(e,t,n,i){if(t==Efe)return new Mh(e,jy(i,i.pos),G4);if(t==Tfe||t==kfe)return new Mh(e,jy(i,i.pos),TL);if(t==Rm)return e.parent;if(t==ust||t==hst)return new Mh(e,0,Zx);if(t==_fe&&e.type==_L)return e.parent;if(t==mst){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Mh(e,e.depth+ +r[0],_L)}return e},hash(e){return e.hash}});function _0(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&Hh(e.peek(n+3))}const Ost=new Lr((e,t)=>{if(e.next==-1&&t.canShift(qX))return e.acceptToken(qX);let n=e.peek(-1);if((dd(n)||n<0)&&t.context.type!=Zx){if(_0(e,45))if(t.canShift(Rm))e.acceptToken(Rm);else return e.acceptToken(Jrt,3);if(_0(e,46))if(t.canShift(Rm))e.acceptToken(Rm);else return e.acceptToken(est,3);let i=0;for(;e.next==32;)i++,e.advance();(i{if(t.context.type==Zx){e.next==63&&(e.advance(),Hh(e.next)&&e.acceptToken(ist));return}if(e.next==45)e.advance(),Hh(e.next)&&e.acceptToken(t.context.type==G4&&t.context.depth==jy(e,e.pos-1)?tst:Efe);else if(e.next==63)e.advance(),Hh(e.next)&&e.acceptToken(t.context.type==TL&&t.context.depth==jy(e,e.pos-1)?nst:kfe);else{let n=e.pos;for(;;)if(AL(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)Nfe(e);else if(e.next==38)NL(e);else if(e.next==42){NL(e);break}else if(e.next==39||e.next==34){if(W4(e,!0))break;return}else if(e.next==91||e.next==123){if(!vst(e))return;break}else{Cfe(e,!0,!1,0);break}for(;AL(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(fst))return;let i=e.peek(1);Hh(i)&&e.acceptTokenTo(t.context.type==TL&&t.context.depth==jy(e,n)?rst:Tfe,n)}}},{contextual:!0});function xst(e){return e>32&&e<127&&e!=34&&e!=37&&e!=44&&e!=60&&e!=62&&e!=92&&e!=94&&e!=96&&e!=123&&e!=124&&e!=125}function HX(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function YX(e,t){return e.next==37?(e.advance(),HX(e.next)&&e.advance(),HX(e.next)&&e.advance(),!0):xst(e.next)||t&&e.next==44?(e.advance(),!0):!1}function Nfe(e){if(e.advance(),e.next==60){for(e.advance();;)if(!YX(e,!0)){e.next==62&&e.advance();break}}else for(;YX(e,!1););}function NL(e){for(e.advance();!Hh(e.next)&&kT(e.next)!="f";)e.advance()}function W4(e,t){let n=e.next,i=!1,r=e.pos;for(e.advance();;){let s=e.next;if(s<0)break;if(e.advance(),s==n)if(s==39)if(e.next==39)e.advance();else break;else break;else if(s==92&&n==34)e.next>=0&&e.advance();else if(dd(s)){if(t)return!1;i=!0}else if(t&&e.pos>=r+1024)return!1}return!i}function vst(e){for(let t=[],n=e.pos+1024;;)if(e.next==91||e.next==123)t.push(e.next),e.advance();else if(e.next==39||e.next==34){if(!W4(e,!0))return!1}else if(e.next==93||e.next==125){if(t[t.length-1]!=e.next-2)return!1;if(t.pop(),e.advance(),!t.length)return!0}else{if(e.next<0||e.pos>n||dd(e.next))return!1;e.advance()}}const wst="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function kT(e){return e<33?"u":e>125?"s":wst[e-33]}function Uj(e,t){let n=kT(e);return n!="u"&&!(t&&n=="f")}function Cfe(e,t,n,i){if(kT(e.next)=="s"||(e.next==63||e.next==58||e.next==45)&&Uj(e.peek(1),n))e.advance();else return!1;let r=e.pos;for(;;){let s=e.next,a=0,o=i+1;for(;Afe(s);){if(dd(s)){if(t)return!1;o=0}else o++;s=e.peek(++a)}if(!(s>=0&&(s==58?Uj(e.peek(a+1),n):s==35?e.peek(a-1)!=32:Uj(s,n)))||!n&&o<=i||o==0&&!n&&(_0(e,45,a)||_0(e,46,a)))break;if(t&&kT(s)=="f")return!1;for(let u=a;u>=0;u--)e.advance();if(t&&e.pos>r+1024)return!1}return!0}const Sst=new Lr((e,t)=>{if(e.next==33)Nfe(e),e.acceptToken(cst);else if(e.next==38||e.next==42){let n=e.next==38?ost:lst;NL(e),e.acceptToken(n)}else e.next==39||e.next==34?(W4(e,!1),e.acceptToken(ast)):Cfe(e,!1,t.context.type==Zx,t.context.depth)&&e.acceptToken(sst)}),Est=new Lr((e,t)=>{let n=t.context.type==_L?t.context.depth:-1,i=e.pos;e:for(;;){let r=0,s=e.next;for(;s==32;)s=e.peek(++r);if(!r&&(_0(e,45,r)||_0(e,46,r))||!dd(s)&&(n<0&&(n=Math.max(t.context.depth+1,r)),rYAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:bst,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[kst],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Ost,yst,Sst,Est,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),_st=ud.define({name:"yaml",parser:Tst.configure({props:[rh.add({Stream:e=>{for(let t=e.node.resolve(e.pos,-1);t&&t.to>=e.pos;t=t.parent){if(t.name=="BlockLiteralContent"&&t.frome.pos)return null}}return null},FlowMapping:Ig({closing:"}"}),FlowSequence:Ig({closing:"]"})}),wd.add({"FlowMapping FlowSequence":ev,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Ast(){return new Yf(_st)}function CL(){return CL=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=K4(e.state,n.from);return i.line?jst(e):i.block?Ist(e):!1};function Z4(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=e(t,n);return r?(i(n.update(r)),!0):!1}}const jst=Z4(Lst,0),Rst=Z4(jfe,0),Ist=Z4((e,t)=>jfe(e,t,Mst(t)),0);function K4(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const dO=50;function Pst(e,{open:t,close:n},i,r){let s=e.sliceDoc(i-dO,i),a=e.sliceDoc(r,r+dO),o=/\s*$/.exec(s)[0].length,c=/^\s*/.exec(a)[0].length,u=s.length-o;if(s.slice(u-t.length,u)==t&&a.slice(c,c+n.length)==n)return{open:{pos:i-o,margin:o&&1},close:{pos:r+c,margin:c&&1}};let d,f;r-i<=2*dO?d=f=e.sliceDoc(i,r):(d=e.sliceDoc(i,i+dO),f=e.sliceDoc(r-dO,r));let h=/^\s*/.exec(d)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-n.length;return d.slice(h,h+t.length)==t&&f.slice(g,g+n.length)==n?{open:{pos:i+h+t.length,margin:/\s/.test(d.charAt(h+t.length))?1:0},close:{pos:r-p-n.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function Mst(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}function jfe(e,t,n=t.selection.ranges){let i=n.map(s=>K4(t,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,a)=>Pst(t,i[a],s.from,s.to));if(e!=2&&!r.every(s=>s))return{changes:t.changes(n.map((s,a)=>r[a]?[]:[{from:s.from,insert:i[a].open+" "},{from:s.to,insert:" "+i[a].close}]))};if(e!=1&&r.some(s=>s)){let s=[];for(let a=0,o;ar&&(s==a||a>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,p=h==f.length,g=f.text.slice(h,h+u.length)==u?h:-1;hs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:o,token:c,indent:u,empty:d,single:f}of i)(f||!d)&&s.push({from:o.from+u,insert:c+" "});let a=t.changes(s);return{changes:a,selection:t.selection.map(a,1)}}else if(e!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:a,comment:o,token:c}of i)if(o>=0){let u=a.from+o,d=u+c.length;a.text[d-a.from]==" "&&d++,s.push({from:u,to:d})}return{changes:s}}return null}const jL=Kc.define(),Dst=Kc.define(),$st=yt.define(),Rfe=yt.define({combine(e){return Jc(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(i,r)=>t(i,r)||n(i,r)})}}),Ife=Ms.define({create(){return Ic.empty},update(e,t){let n=t.state.facet(Rfe),i=t.annotation(jL);if(i){let c=Ba.fromTransaction(t,i.selection),u=i.side,d=u==0?e.undone:e.done;return c?d=TT(d,d.length,n.minDepth,c):d=Lfe(d,t.startState.selection),new Ic(u==0?i.rest:d,u==0?d:i.rest)}let r=t.annotation(Dst);if((r=="full"||r=="before")&&(e=e.isolate()),t.annotation(Xr.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let s=Ba.fromTransaction(t),a=t.annotation(Xr.time),o=t.annotation(Xr.userEvent);return s?e=e.addChanges(s,a,o,n,t):t.selection&&(e=e.addSelection(t.startState.selection,a,o,n.newGroupDelay)),(r=="full"||r=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new Ic(e.done.map(Ba.fromJSON),e.undone.map(Ba.fromJSON))}});function Qst(e={}){return[Ife,Rfe.of(e),ft.domEventHandlers({beforeinput(t,n){let i=t.inputType=="historyUndo"?Pfe:t.inputType=="historyRedo"?RL:null;return i?(t.preventDefault(),i(n)):!1}})]}function FA(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(Ife,!1);if(!r)return!1;let s=r.pop(e,n,t);return s?(i(s),!0):!1}}const Pfe=FA(0,!1),RL=FA(1,!1),Bst=FA(0,!0),Ust=FA(1,!0);class Ba{constructor(t,n,i,r,s){this.changes=t,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(t){return new Ba(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new Ba(t.changes&&ns.fromJSON(t.changes),[],t.mapped&&Qc.fromJSON(t.mapped),t.startSelection&&Qe.fromJSON(t.startSelection),t.selectionsAfter.map(Qe.fromJSON))}static fromTransaction(t,n){let i=Zo;for(let r of t.startState.facet($st)){let s=r(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new Ba(t.changes.invert(t.startState.doc),i,void 0,n||t.startState.selection,Zo)}static selection(t){return new Ba(void 0,Zo,void 0,void 0,t)}}function TT(e,t,n,i){let r=t+1>n+20?t-n-1:0,s=e.slice(r,t);return s.push(i),s}function zst(e,t){let n=[],i=!1;return e.iterChangedRanges((r,s)=>n.push(r,s)),t.iterChangedRanges((r,s,a,o)=>{for(let c=0;c=u&&a<=d&&(i=!0)}}),i}function Fst(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,i)=>n.empty!=t.ranges[i].empty).length===0}function Mfe(e,t){return e.length?t.length?e.concat(t):e:t}const Zo=[],Vst=200;function Lfe(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Vst));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),TT(e,e.length-1,1e9,n.setSelAfter(i)))}else return[Ba.selection([t])]}function Xst(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function zj(e,t){if(!e.length)return e;let n=e.length,i=Zo;for(;n;){let r=qst(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=e.slice(0,n);return s[n-1]=r,s}else t=r.mapped,n--,i=r.selectionsAfter}return i.length?[Ba.selection(i)]:Zo}function qst(e,t,n){let i=Mfe(e.selectionsAfter.length?e.selectionsAfter.map(o=>o.map(t)):Zo,n);if(!e.changes)return Ba.selection(i);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),a=e.mapped?e.mapped.composeDesc(s):s;return new Ba(r,rn.mapEffects(e.effects,t),a,e.startSelection.map(s),i)}const Hst=/^(input\.type|delete)($|\.)/;class Ic{constructor(t,n,i=0,r=void 0){this.done=t,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Ic(this.done,this.undone):this}addChanges(t,n,i,r,s){let a=this.done,o=a[a.length-1];return o&&o.changes&&!o.changes.empty&&t.changes&&(!i||Hst.test(i))&&(!o.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):VA(n,t))}function ta(e){return e.textDirectionAt(e.state.selection.main.head)==Pi.LTR}const $fe=e=>Dfe(e,!ta(e)),Qfe=e=>Dfe(e,ta(e));function Bfe(e,t){return Wl(e,n=>n.empty?e.moveByGroup(n,t):VA(n,t))}const Gst=e=>Bfe(e,!ta(e)),Wst=e=>Bfe(e,ta(e));function Zst(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function XA(e,t,n){let i=_i(e).resolveInner(t.head),r=n?sn.closedBy:sn.openedBy;for(let c=t.head;;){let u=n?i.childAfter(c):i.childBefore(c);if(!u)break;Zst(e,u,r)?i=u:c=n?u.to:u.from}let s=i.type.prop(r),a,o;return s&&(a=n?Rc(e,i.from,1):Rc(e,i.to,-1))&&a.matched?o=n?a.end.to:a.end.from:o=n?i.to:i.from,Qe.cursor(o,n?-1:1)}const Kst=e=>Wl(e,t=>XA(e.state,t,!ta(e))),Jst=e=>Wl(e,t=>XA(e.state,t,ta(e)));function Ufe(e,t){return Wl(e,n=>{if(!n.empty)return VA(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}const zfe=e=>Ufe(e,!1),Ffe=e=>Ufe(e,!0);function Vfe(e){let t=e.scrollDOM.clientHeighta.empty?e.moveVertically(a,t,n.height):VA(a,t));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let a=e.coordsAtPos(i.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),c=o.top+n.marginTop,u=o.bottom-n.marginBottom;a&&a.top>c&&a.bottomXfe(e,!1),IL=e=>Xfe(e,!0);function sh(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&t.head!=i.from+s&&(r=Qe.cursor(i.from+s))}return r}const eat=e=>Wl(e,t=>sh(e,t,!0)),tat=e=>Wl(e,t=>sh(e,t,!1)),nat=e=>Wl(e,t=>sh(e,t,!ta(e))),iat=e=>Wl(e,t=>sh(e,t,ta(e))),rat=e=>Wl(e,t=>Qe.cursor(e.lineBlockAt(t.head).from,1)),sat=e=>Wl(e,t=>Qe.cursor(e.lineBlockAt(t.head).to,-1));function aat(e,t,n){let i=!1,r=pb(e.selection,s=>{let a=Rc(e,s.head,-1)||Rc(e,s.head,1)||s.head>0&&Rc(e,s.head-1,1)||s.headaat(e,t);function ll(e,t,n){let i=pb(e.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=t&&(r=Qe.range(r.head,r.anchor));let s=n(r);return Qe.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(e.state.selection)?!1:(e.dispatch(Gl(e.state,i)),!0)}function qfe(e,t){return ll(e,t,n=>e.moveByChar(n,t))}const Hfe=e=>qfe(e,!ta(e)),Yfe=e=>qfe(e,ta(e));function Gfe(e,t){return ll(e,t,n=>e.moveByGroup(n,t))}const lat=e=>Gfe(e,!ta(e)),cat=e=>Gfe(e,ta(e)),uat=e=>{let t=!ta(e);return ll(e,t,n=>XA(e.state,n,t))},dat=e=>{let t=ta(e);return ll(e,t,n=>XA(e.state,n,t))};function Wfe(e,t){return ll(e,t,n=>e.moveVertically(n,t))}const Zfe=e=>Wfe(e,!1),Kfe=e=>Wfe(e,!0);function Jfe(e,t){return ll(e,t,n=>e.moveVertically(n,t,Vfe(e).height))}const WX=e=>Jfe(e,!1),ZX=e=>Jfe(e,!0),fat=e=>ll(e,!0,t=>sh(e,t,!0)),hat=e=>ll(e,!1,t=>sh(e,t,!1)),pat=e=>{let t=!ta(e);return ll(e,t,n=>sh(e,n,t))},mat=e=>{let t=ta(e);return ll(e,t,n=>sh(e,n,t))},gat=e=>ll(e,!1,t=>Qe.cursor(e.lineBlockAt(t.head).from)),bat=e=>ll(e,!0,t=>Qe.cursor(e.lineBlockAt(t.head).to)),KX=({state:e,dispatch:t})=>(t(Gl(e,{anchor:0})),!0),JX=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.doc.length})),!0),eq=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.selection.main.anchor,head:0})),!0),tq=({state:e,dispatch:t})=>(t(Gl(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Oat=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),yat=({state:e,dispatch:t})=>{let n=qA(e).map(({from:i,to:r})=>Qe.range(i,Math.min(r+1,e.doc.length)));return t(e.update({selection:Qe.create(n),userEvent:"select"})),!0},xat=({state:e,dispatch:t})=>{let n=pb(e.selection,i=>{let r=_i(e),s=r.resolveStack(i.from,1);if(i.empty){let a=r.resolveStack(i.from,-1);a.node.from>=s.node.from&&a.node.to<=s.node.to&&(s=a)}for(let a=s;a;a=a.next){let{node:o}=a;if((o.from=i.to||o.to>i.to&&o.from<=i.from)&&a.next)return Qe.range(o.to,o.from)}return i});return n.eq(e.selection)?!1:(t(Gl(e,n)),!0)};function ehe(e,t){let{state:n}=e,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let a=n.doc.lineAt(s.head);if(t?a.to0)for(let o=s;;){let c=e.moveVertically(o,t);if(c.heada.to){r.some(u=>u.head==c.head)||r.push(c);break}else{if(c.head==o.head)break;o=c}}}return r.length==i.ranges.length?!1:(e.dispatch(Gl(n,Qe.create(r,r.length-1))),!0)}const vat=e=>ehe(e,!1),wat=e=>ehe(e,!0),Sat=({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=Qe.create([n.main]):n.main.empty||(i=Qe.create([Qe.cursor(n.main.head)])),i?(t(Gl(e,i)),!0):!1};function rv(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange(s=>{let{from:a,to:o}=s;if(a==o){let c=t(s);ca&&(n="delete.forward",c=cS(e,c,!0)),a=Math.min(a,c),o=Math.max(o,c)}else a=cS(e,a,!1),o=cS(e,o,!0);return a==o?{range:s}:{changes:{from:a,to:o},range:Qe.cursor(a,ar(e)))i.between(t,t,(r,s)=>{rt&&(t=n?s:r)});return t}const the=(e,t,n)=>rv(e,i=>{let r=i.from,{state:s}=e,a=s.doc.lineAt(r),o,c;if(n&&!t&&r>a.from&&rthe(e,!1,!0),nhe=e=>the(e,!0,!1),ihe=(e,t)=>rv(e,n=>{let i=n.head,{state:r}=e,s=r.doc.lineAt(i),a=r.charCategorizer(i);for(let o=null;;){if(i==(t?s.to:s.from)){i==n.head&&s.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let c=Os(s.text,i-s.from,t)+s.from,u=s.text.slice(Math.min(i,c)-s.from,Math.max(i,c)-s.from),d=a(u);if(o!=null&&d!=o)break;(u!=" "||i!=n.head)&&(o=d),i=c}return i}),rhe=e=>ihe(e,!1),Eat=e=>ihe(e,!0),kat=e=>rv(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headrv(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),_at=e=>rv(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ei.of(["",""])},range:Qe.cursor(i.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Nat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{if(!i.empty||i.from==0||i.from==e.doc.length)return{range:i};let r=i.from,s=e.doc.lineAt(r),a=r==s.from?r-1:Os(s.text,r-s.from,!1)+s.from,o=r==s.to?r+1:Os(s.text,r-s.from,!0)+s.from;return{changes:{from:a,to:o,insert:e.doc.slice(r,o).append(e.doc.slice(a,r))},range:Qe.cursor(o)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function qA(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),s=e.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=e.doc.lineAt(i.to-1)),n>=r.number){let a=t[t.length-1];a.to=s.to,a.ranges.push(i)}else t.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return t}function she(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let s of qA(e)){if(n?s.to==e.doc.length:s.from==0)continue;let a=e.doc.lineAt(n?s.to+1:s.from-1),o=a.length+1;if(n){i.push({from:s.to,to:a.to},{from:s.from,insert:a.text+e.lineBreak});for(let c of s.ranges)r.push(Qe.range(Math.min(e.doc.length,c.anchor+o),Math.min(e.doc.length,c.head+o)))}else{i.push({from:a.from,to:s.from},{from:s.to,insert:e.lineBreak+a.text});for(let c of s.ranges)r.push(Qe.range(c.anchor-o,c.head-o))}}return i.length?(t(e.update({changes:i,scrollIntoView:!0,selection:Qe.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Cat=({state:e,dispatch:t})=>she(e,t,!1),jat=({state:e,dispatch:t})=>she(e,t,!0);function ahe(e,t,n){if(e.readOnly)return!1;let i=[];for(let s of qA(e))n?i.push({from:s.from,insert:e.doc.slice(s.from,s.to)+e.lineBreak}):i.push({from:s.to,insert:e.lineBreak+e.doc.slice(s.from,s.to)});let r=e.changes(i);return t(e.update({changes:r,selection:e.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Rat=({state:e,dispatch:t})=>ahe(e,t,!1),Iat=({state:e,dispatch:t})=>ahe(e,t,!0),Pat=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(qA(t).map(({from:r,to:s})=>(r>0?r--:s{let s;if(e.lineWrapping){let a=e.lineBlockAt(r.head),o=e.coordsAtPos(r.head,r.assoc||1);o&&(s=a.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(r,!0,s)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Mat(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=_i(e).resolveInner(t),i=n.childBefore(t),r=n.childAfter(t),s;return i&&r&&i.to<=t&&r.from>=t&&(s=i.type.prop(sn.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const nq=ohe(!1),Lat=ohe(!0);function ohe(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{let{from:s,to:a}=r,o=t.doc.lineAt(s),c=!e&&s==a&&Mat(t,s);e&&(s=a=(a<=o.to?o:t.doc.lineAt(a)).to);let u=new $A(t,{simulateBreak:s,simulateDoubleBreak:!!c}),d=E4(u,s);for(d==null&&(d=Bl(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));ao.from&&s{let r=[];for(let a=i.from;a<=i.to;){let o=e.doc.lineAt(a);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),a=o.to+1}let s=e.changes(r);return{changes:r,range:Qe.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Dat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new $A(e,{overrideIndentation:s=>{let a=n[s];return a??-1}}),r=J4(e,(s,a,o)=>{let c=E4(i,s.from);if(c==null)return;/\S/.test(s.text)||(c=0);let u=/^\s*/.exec(s.text)[0],d=zx(e,c);(u!=d||o.frome.readOnly?!1:(t(e.update(J4(e,(n,i)=>{i.push({from:n.from,insert:e.facet(fb)})}),{userEvent:"input.indent"})),!0),che=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(J4(e,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=Bl(r,e.tabSize),a=0,o=zx(e,Math.max(0,s-mT(e)));for(;a(e.setTabFocusMode(),!0),Qat=[{key:"Ctrl-b",run:$fe,shift:Hfe,preventDefault:!0},{key:"Ctrl-f",run:Qfe,shift:Yfe},{key:"Ctrl-p",run:zfe,shift:Zfe},{key:"Ctrl-n",run:Ffe,shift:Kfe},{key:"Ctrl-a",run:rat,shift:gat},{key:"Ctrl-e",run:sat,shift:bat},{key:"Ctrl-d",run:nhe},{key:"Ctrl-h",run:PL},{key:"Ctrl-k",run:kat},{key:"Ctrl-Alt-h",run:rhe},{key:"Ctrl-o",run:Aat},{key:"Ctrl-t",run:Nat},{key:"Ctrl-v",run:IL}],Bat=[{key:"ArrowLeft",run:$fe,shift:Hfe,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Gst,shift:lat,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:nat,shift:pat,preventDefault:!0},{key:"ArrowRight",run:Qfe,shift:Yfe,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Wst,shift:cat,preventDefault:!0},{mac:"Cmd-ArrowRight",run:iat,shift:mat,preventDefault:!0},{key:"ArrowUp",run:zfe,shift:Zfe,preventDefault:!0},{mac:"Cmd-ArrowUp",run:KX,shift:eq},{mac:"Ctrl-ArrowUp",run:GX,shift:WX},{key:"ArrowDown",run:Ffe,shift:Kfe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:JX,shift:tq},{mac:"Ctrl-ArrowDown",run:IL,shift:ZX},{key:"PageUp",run:GX,shift:WX},{key:"PageDown",run:IL,shift:ZX},{key:"Home",run:tat,shift:hat,preventDefault:!0},{key:"Mod-Home",run:KX,shift:eq},{key:"End",run:eat,shift:fat,preventDefault:!0},{key:"Mod-End",run:JX,shift:tq},{key:"Enter",run:nq,shift:nq},{key:"Mod-a",run:Oat},{key:"Backspace",run:PL,shift:PL,preventDefault:!0},{key:"Delete",run:nhe,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rhe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Eat,preventDefault:!0},{mac:"Mod-Backspace",run:Tat,preventDefault:!0},{mac:"Mod-Delete",run:_at,preventDefault:!0}].concat(Qat.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Uat=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Kst,shift:uat},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Jst,shift:dat},{key:"Alt-ArrowUp",run:Cat},{key:"Shift-Alt-ArrowUp",run:Rat},{key:"Alt-ArrowDown",run:jat},{key:"Shift-Alt-ArrowDown",run:Iat},{key:"Mod-Alt-ArrowUp",run:vat},{key:"Mod-Alt-ArrowDown",run:wat},{key:"Escape",run:Sat},{key:"Mod-Enter",run:Lat},{key:"Alt-l",mac:"Ctrl-l",run:yat},{key:"Mod-i",run:xat,preventDefault:!0},{key:"Mod-[",run:che},{key:"Mod-]",run:lhe},{key:"Mod-Alt-\\",run:Dat},{key:"Shift-Mod-k",run:Pat},{key:"Shift-Mod-\\",run:oat},{key:"Mod-/",run:Cst},{key:"Alt-A",run:Rst},{key:"Ctrl-m",mac:"Shift-Alt-m",run:$at}].concat(Bat),zat={key:"Tab",run:lhe,shift:che},iq=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class A0{constructor(t,n,i=0,r=t.length,s,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,r),this.bufferStart=i,this.normalize=s?o=>s(iq(o)):iq,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Pa(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=i4(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=Sc(t);let r=this.normalize(n);if(r.length)for(let s=0,a=i,o=!0;;s++){let c=r.charCodeAt(s),u=this.match(c,a,o,this.bufferPos+this.bufferStart,s==r.length-1);if(u)return this.value=u,this;if(s==r.length-1)break;o&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let i=this.curLineStart+n.index,r=i+n[0].length;if(this.matchPos=_T(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,precise:!0,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||r.to<=n){let o=new Lg(n,t.sliceString(n,i));return Fj.set(t,o),o}if(r.from==n&&r.to==i)return r;let{text:s,from:a}=r;return a>n&&(s=t.sliceString(n,a)+s,a=n),r.to=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let i=this.flat.from+n.index,r=i+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,precise:!0,match:n},this.matchPos=_T(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Lg.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(dhe.prototype[Symbol.iterator]=fhe.prototype[Symbol.iterator]=function(){return this});function Fat(e){try{return new RegExp(e,eQ),!0}catch{return!1}}function _T(e,t){if(t>=e.length)return t;let n=e.lineAt(t),i;for(;t=56320&&i<57344;)t++;return t}const Vat=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:i,result:r}=cJe(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return r.then(s=>{let a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){e.dispatch({effects:i});return}let o=t.doc.lineAt(t.selection.main.head),[,c,u,d,f]=a,h=d?+d.slice(1):0,p=u?+u:o.number;if(u&&f){let y=p/100;c&&(y=y*(c=="-"?-1:1)+o.number/t.doc.lines),p=Math.round(t.doc.lines*y)}else u&&c&&(p=p*(c=="-"?-1:1)+o.number);let g=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),b=Qe.cursor(g.from+Math.max(0,Math.min(h,g.length)));e.dispatch({effects:[i,ft.scrollIntoView(b.from,{y:"center"})],selection:b})}),!0},Xat={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},qat=yt.define({combine(e){return Jc(e,Xat,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Hat(e){return[Kat,Zat]}const Yat=zt.mark({class:"cm-selectionMatch"}),Gat=zt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function rq(e,t,n,i){return(n==0||e(t.sliceDoc(n-1,n))!=lr.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=lr.Word)}function Wat(e,t,n,i){return e(t.sliceDoc(n,n+1))==lr.Word&&e(t.sliceDoc(i-1,i))==lr.Word}const Zat=Tr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(qat),{state:n}=e,i=n.selection;if(i.ranges.length>1)return zt.none;let r=i.main,s,a=null;if(r.empty){if(!t.highlightWordAroundCursor)return zt.none;let c=n.wordAt(r.head);if(!c)return zt.none;a=n.charCategorizer(r.head),s=n.sliceDoc(c.from,c.to)}else{let c=r.to-r.from;if(c200)return zt.none;if(t.wholeWords){if(s=n.sliceDoc(r.from,r.to),a=n.charCategorizer(r.head),!(rq(a,n,r.from,r.to)&&Wat(a,n,r.from,r.to)))return zt.none}else if(s=n.sliceDoc(r.from,r.to),!s)return zt.none}let o=[];for(let c of e.visibleRanges){let u=new A0(n.doc,s,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!a||rq(a,n,d,f))&&(r.empty&&d<=r.from&&f>=r.to?o.push(Gat.range(d,f)):(d>=r.to||f<=r.from)&&o.push(Yat.range(d,f)),o.length>t.maxMatches))return zt.none}}return zt.set(o)}},{decorations:e=>e.decorations}),Kat=ft.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Jat=({state:e,dispatch:t})=>{let{selection:n}=e,i=Qe.create(n.ranges.map(r=>e.wordAt(r.head)||Qe.cursor(r.head)),n.mainIndex);return i.eq(n)?!1:(t(e.update({selection:i})),!0)};function eot(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let a=!1,o=new A0(e.doc,t,i[i.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new A0(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(c=>c.from==o.value.from))continue;if(s){let c=e.wordAt(o.value.from);if(!c||c.from!=o.value.from||c.to!=o.value.to)continue}return o.value}}const tot=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(s=>s.from===s.to))return Jat({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(s=>e.sliceDoc(s.from,s.to)!=i))return!1;let r=eot(e,i);return r?(t(e.update({selection:e.selection.addRange(Qe.range(r.from,r.to),!1),effects:ft.scrollIntoView(r.to)})),!0):!1},mb=yt.define({combine(e){return Jc(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new mot(t),scrollToMatch:t=>ft.scrollIntoView(t)})}});class hhe{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||Fat(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,i)=>i=="n"?` +`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new oot(this):new rot(this)}getCursor(t,n=0,i){let r=t.doc?t:Bn.create({doc:t});return i==null&&(i=r.doc.length),this.regexp?Pm(this,r,n,i):Im(this,r,n,i)}}class phe{constructor(t){this.spec=t}}function not(e,t,n){return(i,r,s,a)=>{if(n&&!n(i,r,s,a))return!1;let o=i>=a&&r<=a+s.length?s.slice(i-a,r-a):t.doc.sliceString(i,r);return e(o,t,i,r)}}function Im(e,t,n,i){let r;return e.wholeWord&&(r=iot(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(r=not(e.test,t,r)),new A0(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:s=>s.toLowerCase(),r)}function iot(e,t){return(n,i,r,s)=>((s>n||s+r.length=n)return null;r.push(i.value)}return r}highlight(t,n,i,r){let s=Im(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function sot(e,t,n){return(i,r,s)=>(!n||n(i,r,s))&&e(s[0],t,i,r)}function Pm(e,t,n,i){let r;return e.wholeWord&&(r=aot(t.charCategorizer(t.selection.main.head))),e.test&&(r=sot(e.test,t,r)),new dhe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:r},n,i)}function AT(e,t){return e.slice(Os(e,t,!1),t)}function NT(e,t){return e.slice(t,Os(e,t))}function aot(e){return(t,n,i)=>!i[0].length||(e(AT(i.input,i.index))!=lr.Word||e(NT(i.input,i.index))!=lr.Word)&&(e(NT(i.input,i.index+i[0].length))!=lr.Word||e(AT(i.input,i.index+i[0].length))!=lr.Word)}class oot extends phe{nextMatch(t,n,i){let r=Pm(this.spec,t,i,t.doc.length).next();return r.done&&(r=Pm(this.spec,t,0,n).next()),r.done?null:r.value}prevMatchInRange(t,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),a=Pm(this.spec,t,s,i),o=null;for(;!a.next().done;)o=a.value;if(o&&(s==n||o.from>s+10))return o;if(s==n)return null}}prevMatch(t,n,i){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s=n)return null;r.push(i.value)}return r}highlight(t,n,i,r){let s=Pm(this.spec,t,Math.max(0,n-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Kx=rn.define(),tQ=rn.define(),kf=Ms.define({create(e){return new Vj(ML(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Kx)?e=new Vj(n.value.create(),e.panel):n.is(tQ)&&(e=new Vj(e.query,n.value?nQ:null));return e},provide:e=>Bx.from(e,t=>t.panel)});class Vj{constructor(t,n){this.query=t,this.panel=n}}const lot=zt.mark({class:"cm-searchMatch"}),cot=zt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),uot=Tr.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(kf))}update(e){let t=e.state.field(kf);(t!=e.startState.field(kf)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return zt.none;let{view:n}=this,i=new od;for(let r=0,s=n.visibleRanges,a=s.length;rs[r+1].from-2*250;)c=s[++r].to;e.highlight(n.state,o,c,(u,d)=>{let f=n.state.selection.ranges.some(h=>h.from==u&&h.to==d);i.add(u,d,f?cot:lot)})}return i.finish()}},{decorations:e=>e.decorations});function sv(e){return t=>{let n=t.state.field(kf,!1);return n&&n.query.spec.valid?e(t,n):bhe(t)}}const CT=sv((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let r=Qe.single(i.from,i.to),s=e.state.facet(mb);return e.dispatch({selection:r,effects:[iQ(e,i),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),ghe(e),!0}),jT=sv((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,r=t.prevMatch(n,i,i);if(!r)return!1;let s=Qe.single(r.from,r.to),a=e.state.facet(mb);return e.dispatch({selection:s,effects:[iQ(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),ghe(e),!0}),dot=sv((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Qe.create(n.map(i=>Qe.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),fot=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],a=0;for(let o=new A0(e.doc,e.sliceDoc(i,r));!o.next().done;){if(s.length>1e3)return!1;o.value.from==i&&(a=s.length),s.push(Qe.range(o.value.from,o.value.to))}return t(e.update({selection:Qe.create(s,a),userEvent:"select.search.matches"})),!0},sq=sv((e,{query:t})=>{let{state:n}=e,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=t.nextMatch(n,i,i);if(!s)return!1;let a=s,o=[],c,u,d=[];a.precise?a.from==i&&a.to==r&&(u=n.toText(t.getReplacement(a)),o.push({from:a.from,to:a.to,insert:u}),a=t.nextMatch(n,a.from,a.to),d.push(ft.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+"."))):a=t.nextMatch(n,a.from,a.to);let f=e.state.changes(o);return a&&(c=Qe.single(a.from,a.to).map(f),d.push(iQ(e,a)),d.push(n.facet(mb).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),hot=sv((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:s,to:a,precise:o}=r;o&&n.push({from:s,to:a,insert:t.getReplacement(r)})}if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:ft.announce.of(i),userEvent:"input.replace.all"}),!0});function nQ(e){return e.state.facet(mb).createPanel(e)}function ML(e,t){var n,i,r,s,a;let o=e.selection.main,c=o.empty||o.to>o.from+100?"":e.sliceDoc(o.from,o.to);if(t&&!c)return t;let u=e.facet(mb);return new hhe({search:((n=t==null?void 0:t.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(i=t==null?void 0:t.caseSensitive)!==null&&i!==void 0?i:u.caseSensitive,literal:(r=t==null?void 0:t.literal)!==null&&r!==void 0?r:u.literal,regexp:(s=t==null?void 0:t.regexp)!==null&&s!==void 0?s:u.regexp,wholeWord:(a=t==null?void 0:t.wholeWord)!==null&&a!==void 0?a:u.wholeWord})}function mhe(e){let t=v4(e,nQ);return t&&t.dom.querySelector("[main-field]")}function ghe(e){let t=mhe(e);t&&t==e.root.activeElement&&t.select()}const bhe=e=>{let t=e.state.field(kf,!1);if(t&&t.panel){let n=mhe(e);if(n&&n!=e.root.activeElement){let i=ML(e.state,t.query.spec);i.valid&&e.dispatch({effects:Kx.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[tQ.of(!0),t?Kx.of(ML(e.state,t.query.spec)):rn.appendConfig.of(bot)]});return!0},Ohe=e=>{let t=e.state.field(kf,!1);if(!t||!t.panel)return!1;let n=v4(e,nQ);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:tQ.of(!1)}),!0},pot=[{key:"Mod-f",run:bhe,scope:"editor search-panel"},{key:"F3",run:CT,shift:jT,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:CT,shift:jT,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Ohe,scope:"editor search-panel"},{key:"Mod-Shift-l",run:fot},{key:"Mod-Alt-g",run:Vat},{key:"Mod-d",run:tot,preventDefault:!0}];class mot{constructor(t){this.view=t;let n=this.query=t.state.field(kf).query.spec;this.commit=this.commit.bind(this),this.searchField=Ei("input",{value:n.search,placeholder:Ja(t,"Find"),"aria-label":Ja(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ei("input",{value:n.replace,placeholder:Ja(t,"Replace"),"aria-label":Ja(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ei("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Ei("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Ei("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,a){return Ei("button",{class:"cm-button",name:r,onclick:s,type:"button"},a)}this.dom=Ei("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>CT(t),[Ja(t,"next")]),i("prev",()=>jT(t),[Ja(t,"previous")]),i("select",()=>dot(t),[Ja(t,"all")]),Ei("label",null,[this.caseField,Ja(t,"match case")]),Ei("label",null,[this.reField,Ja(t,"regexp")]),Ei("label",null,[this.wordField,Ja(t,"by word")]),...t.state.readOnly?[]:[Ei("br"),this.replaceField,i("replace",()=>sq(t),[Ja(t,"replace")]),i("replaceAll",()=>hot(t),[Ja(t,"replace all")])],Ei("button",{name:"close",onclick:()=>Ohe(t),"aria-label":Ja(t,"close"),type:"button"},["×"])])}commit(){let t=new hhe({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Kx.of(t)}))}keydown(t){OKe(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?jT:CT)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),sq(this.view))}update(t){for(let n of t.transactions)for(let i of n.effects)i.is(Kx)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mb).top}}function Ja(e,t){return e.state.phrase(t)}const uS=30,dS=/[\s\.,:;?!]/;function iQ(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,s=Math.max(i.from,t-uS),a=Math.min(r,n+uS),o=e.state.sliceDoc(s,a);if(s!=i.from){for(let c=0;co.length-uS;c--)if(!dS.test(o[c-1])&&dS.test(o[c])){o=o.slice(0,c);break}}return ft.announce.of(`${e.state.phrase("current match")}. ${o} ${e.state.phrase("on line")} ${i.number}.`)}const got=ft.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),bot=[kf,vd.low(uot),got];class aq{constructor(t,n,i){this.from=t,this.to=n,this.diagnostic=i}}class Lh{constructor(t,n,i){this.diagnostics=t,this.panel=n,this.selected=i}static init(t,n,i){let r=i.facet(Jx).markerFilter;r&&(t=r(t,i));let s=t.slice().sort((p,g)=>p.from-g.from||p.to-g.to),a=new od,o=[],c=0,u=i.doc.iter(),d=0,f=i.doc.length;for(let p=0;;){let g=p==s.length?null:s[p];if(!g&&!o.length)break;let b,y;if(o.length)b=c,y=o.reduce((x,w)=>Math.min(x,w.to),g&&g.from>b?g.from:1e8);else{if(b=g.from,b>f)break;y=g.to,o.push(g),p++}for(;px.from||x.to==b))o.push(x),p++,y=Math.min(x.to,y);else{y=Math.min(x.from,y);break}}y=Math.min(y,f);let O=!1;if(o.some(x=>x.from==b&&(x.to==y||y==f))&&(O=b==y,!O&&y-b<10)){let x=b-(d+u.value.length);x>0&&(u.next(x),d=b);for(let w=b;;){if(w>=y){O=!0;break}if(!u.lineBreak&&d+u.value.length>w)break;w=d+u.value.length,d+=u.value.length,u.next()}}let v=Cot(o);if(O)a.add(b,b,zt.widget({widget:new Tot(v),diagnostics:o.slice()}));else{let x=o.reduce((w,E)=>E.markClass?w+" "+E.markClass:w,"");a.add(b,y,zt.mark({class:"cm-lintRange cm-lintRange-"+v+x,diagnostics:o.slice(),inclusiveEnd:o.some(w=>w.to>y)}))}if(c=y,c==f)break;for(let x=0;x{if(!(t&&a.diagnostics.indexOf(t)<0))if(!i)i=new aq(r,s,t||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new aq(i.from,s,i.diagnostic)}}),i}function Oot(e,t){let n=t.pos,i=t.end||n,r=e.state.facet(Jx).hideOn(e,n,i);if(r!=null)return r;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(a=>a.is(yhe))||e.changes.touchesRange(s.from,Math.max(s.to,i)))}function yot(e,t){return e.field(mo,!1)?t:t.concat(rn.appendConfig.of(jot))}const yhe=rn.define(),rQ=rn.define(),xhe=rn.define(),mo=Ms.define({create(){return new Lh(zt.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,r=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);i=Gf(n,e.selected.diagnostic,s)||Gf(n,null,s)}!n.size&&r&&t.state.facet(Jx).autoPanel&&(r=null),e=new Lh(n,r,i)}for(let n of t.effects)if(n.is(yhe)){let i=t.state.facet(Jx).autoPanel?n.value.length?e1.open:null:e.panel;e=Lh.init(n.value,i,t.state)}else n.is(rQ)?e=new Lh(e.diagnostics,n.value?e1.open:null,e.selected):n.is(xhe)&&(e=new Lh(e.diagnostics,e.panel,n.value));return e},provide:e=>[Bx.from(e,t=>t.panel),ft.decorations.from(e,t=>t.diagnostics)]}),xot=zt.mark({class:"cm-lintRange cm-lintRange-active"});function vot(e,t,n){let{diagnostics:i}=e.state.field(mo),r,s=-1,a=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(twhe(e,n,!1)))}const Sot=e=>{let t=e.state.field(mo,!1);(!t||!t.panel)&&e.dispatch({effects:yot(e.state,[rQ.of(!0)])});let n=v4(e,e1.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},oq=e=>{let t=e.state.field(mo,!1);return!t||!t.panel?!1:(e.dispatch({effects:rQ.of(!1)}),!0)},Eot=e=>{let t=e.state.field(mo,!1);if(!t)return!1;let n=e.state.selection.main,i=Gf(t.diagnostics,null,n.to+1);return!i&&(i=Gf(t.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),oJe(e,i.from,1,{tooltip:She,until:r=>r.docChanged||r.newSelection.main.headi.to}),!0)},kot=[{key:"Mod-Shift-m",run:Sot,preventDefault:!0},{key:"F8",run:Eot}],Jx=yt.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Jc(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lq,tooltipFilter:lq,needsRefresh:(t,n)=>t?n?i=>t(i)||n(i):t:n,hideOn:(t,n)=>t?n?(i,r,s)=>t(i,r,s)||n(i,r,s):t:n,autoPanel:(t,n)=>t||n})}}});function lq(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function vhe(e){let t=[];if(e)e:for(let{name:n}of e){for(let i=0;is.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function whe(e,t,n){var i;let r=n?vhe(t.actions):[];return Ei("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Ei("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((s,a)=>{let o=!1,c=p=>{if(p.preventDefault(),o)return;o=!0;let g=Gf(e.state.field(mo).diagnostics,t);g&&s.apply(e,g.from,g.to)},{name:u}=s,d=r[a]?u.indexOf(r[a]):-1,f=d<0?u:[u.slice(0,d),Ei("u",u.slice(d,d+1)),u.slice(d+1)],h=s.markClass?" "+s.markClass:"";return Ei("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${r[a]})"`}.`},f)}),t.source&&Ei("div",{class:"cm-diagnosticSource"},t.source))}class Tot extends Yl{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Ei("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cq{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=whe(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class e1{constructor(t){this.view=t,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)oq(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],a=vhe(s.actions);for(let o=0;o{for(let s=0;soq(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(mo).selected;if(!t)return-1;for(let n=0;n{for(let d of u.diagnostics){if(a.has(d))continue;a.add(d);let f=-1,h;for(let p=i;pi&&(this.items.splice(i,f-i),r=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:c})=>{let u=c.height/this.list.offsetHeight;o.topc.bottom&&(this.list.scrollTop+=(o.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let t=this.list.firstChild;function n(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)n();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(mo),i=Gf(n.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:xhe.of(i)})}static open(t){return new e1(t)}}function _ot(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function fS(e){return _ot(``,'width="6" height="3"')}const Aot=ft.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fS("#f11")},".cm-lintRange-warning":{backgroundImage:fS("orange")},".cm-lintRange-info":{backgroundImage:fS("#999")},".cm-lintRange-hint":{backgroundImage:fS("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Not(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function Cot(e){let t="hint",n=1;for(let i of e){let r=Not(i.severity);r>n&&(n=r,t=i.severity)}return t}const She=aJe(vot,{hideOn:Oot}),jot=[mo,ft.decorations.compute([mo],e=>{let{selected:t,panel:n}=e.field(mo);return!t||!n||t.from==t.to?zt.none:zt.set([xot.range(t.from,t.to)])}),She,Aot];var uq=function(t){t===void 0&&(t={});var n=t,i=n.crosshairCursor,r=i===void 0?!1:i,s=[];t.closeBracketsKeymap!==!1&&(s=s.concat(Ket)),t.defaultKeymap!==!1&&(s=s.concat(Uat)),t.searchKeymap!==!1&&(s=s.concat(pot)),t.historyKeymap!==!1&&(s=s.concat(Yst)),t.foldKeymap!==!1&&(s=s.concat(FJe)),t.completionKeymap!==!1&&(s=s.concat(ade)),t.lintKeymap!==!1&&(s=s.concat(kot));var a=[];return t.lineNumbers!==!1&&a.push(xJe()),t.highlightActiveLineGutter!==!1&&a.push(SJe()),t.highlightSpecialChars!==!1&&a.push(MKe()),t.history!==!1&&a.push(Qst()),t.foldGutter!==!1&&a.push(HJe()),t.drawSelection!==!1&&a.push(EKe()),t.dropCursor!==!1&&a.push(NKe()),t.allowMultipleSelections!==!1&&a.push(Bn.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&a.push(MJe()),t.syntaxHighlighting!==!1&&a.push(que(ZJe,{fallback:!0})),t.bracketMatching!==!1&&a.push(ret()),t.closeBrackets!==!1&&a.push(Yet()),t.autocompletion!==!1&&a.push(stt()),t.rectangularSelection!==!1&&a.push(GKe()),r!==!1&&a.push(KKe()),t.highlightActiveLine!==!1&&a.push(UKe()),t.highlightSelectionMatches!==!1&&a.push(Hat()),t.tabSize&&typeof t.tabSize=="number"&&a.push(fb.of(" ".repeat(t.tabSize))),a.concat([db.of(s.flat())]).filter(Boolean)};const Rot="#e5c07b",dq="#e06c75",Iot="#56b6c2",Pot="#ffffff",wE="#abb2bf",LL="#7d8799",Mot="#61afef",Lot="#98c379",fq="#d19a66",Dot="#c678dd",$ot="#21252b",hq="#2c313a",pq="#282c34",Xj="#353a42",Qot="#3E4451",mq="#528bff",Bot=ft.theme({"&":{color:wE,backgroundColor:pq},".cm-content":{caretColor:mq},".cm-cursor, .cm-dropCursor":{borderLeftColor:mq},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Qot},".cm-panels":{backgroundColor:$ot,color:wE},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:pq,color:LL,border:"none"},".cm-activeLineGutter":{backgroundColor:hq},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Xj},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Xj,borderBottomColor:Xj},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hq,color:wE}}},{dark:!0}),Uot=nv.define([{tag:G.keyword,color:Dot},{tag:[G.name,G.deleted,G.character,G.propertyName,G.macroName],color:dq},{tag:[G.function(G.variableName),G.labelName],color:Mot},{tag:[G.color,G.constant(G.name),G.standard(G.name)],color:fq},{tag:[G.definition(G.name),G.separator],color:wE},{tag:[G.typeName,G.className,G.number,G.changed,G.annotation,G.modifier,G.self,G.namespace],color:Rot},{tag:[G.operator,G.operatorKeyword,G.url,G.escape,G.regexp,G.link,G.special(G.string)],color:Iot},{tag:[G.meta,G.comment],color:LL},{tag:G.strong,fontWeight:"bold"},{tag:G.emphasis,fontStyle:"italic"},{tag:G.strikethrough,textDecoration:"line-through"},{tag:G.link,color:LL,textDecoration:"underline"},{tag:G.heading,fontWeight:"bold",color:dq},{tag:[G.atom,G.bool,G.special(G.variableName)],color:fq},{tag:[G.processingInstruction,G.string,G.inserted],color:Lot},{tag:G.invalid,color:Pot}]),zot=[Bot,que(Uot)];var Fot=ft.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Vot=function(t){t===void 0&&(t={});var n=t,i=n.indentWithTab,r=i===void 0?!0:i,s=n.editable,a=s===void 0?!0:s,o=n.readOnly,c=o===void 0?!1:o,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,h=f===void 0?"":f,p=n.basicSetup,g=p===void 0?!0:p,b=[];switch(r&&b.unshift(db.of([zat])),g&&(typeof g=="boolean"?b.unshift(uq()):b.unshift(uq(g))),h&&b.unshift(XKe(h)),d){case"light":b.push(Fot);break;case"dark":b.push(zot);break;case"none":break;default:b.push(d);break}return a===!1&&b.push(ft.editable.of(!1)),c&&b.push(Bn.readOnly.of(!0)),[...b]},Xot=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class qot{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class gq{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var qj=null,Hot=()=>typeof window>"u"?new gq:(qj||(qj=new gq),qj),Yot=ft.theme({"& .cm-scroller":{height:"100% !important"}}),bq=null,Hj=null;function Got(e,t,n,i,r,s){if(!e&&!t&&!n&&!i&&!r&&!s)return null;var a=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:s});return a===bq||(bq=a,Hj=ft.theme({"&":{height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:s}})),Hj}var Oq=Kc.define(),Wot=200,Zot=[];function Kot(e){var t=e.value,n=e.selection,i=e.onChange,r=e.onStatistics,s=e.onCreateEditor,a=e.onUpdate,o=e.extensions,c=o===void 0?Zot:o,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,h=e.height,p=h===void 0?null:h,g=e.minHeight,b=g===void 0?null:g,y=e.maxHeight,O=y===void 0?null:y,v=e.width,x=v===void 0?null:v,w=e.minWidth,E=w===void 0?null:w,S=e.maxWidth,k=S===void 0?null:S,T=e.placeholder,A=T===void 0?"":T,N=e.editable,C=N===void 0?!0:N,M=e.readOnly,L=M===void 0?!1:M,P=e.indentWithTab,Q=P===void 0?!0:P,j=e.basicSetup,$=j===void 0?!0:j,U=e.root,B=e.initialState,I=m.useState(),X=I[0],q=I[1],D=m.useState(),H=D[0],re=D[1],fe=m.useState(),Ae=fe[0],J=fe[1],ie=m.useState(()=>({current:null}))[0],ue=m.useState(()=>({current:null}))[0],ye=Got(p,b,O,x,E,k),Se=ft.updateListener.of(me=>{if(me.docChanged&&typeof i=="function"&&!me.transactions.some(Oe=>Oe.annotation(Oq))){ie.current?ie.current.reset():(ie.current=new qot(()=>{if(ue.current){var Oe=ue.current;ue.current=null,Oe()}ie.current=null},Wot),Hot().add(ie.current));var oe=me.state.doc,Ne=oe.toString();i(Ne,me)}r&&r(Xot(me))}),Re=Vot({theme:f,editable:C,readOnly:L,placeholder:A,indentWithTab:Q,basicSetup:$}),Ee=[Se,...ye?[ye]:[],Yot,...Re];return a&&typeof a=="function"&&Ee.push(ft.updateListener.of(a)),Ee=Ee.concat(c),m.useLayoutEffect(()=>{if(X&&!Ae){var me={doc:t,selection:n,extensions:Ee},oe=B?Bn.fromJSON(B.json,me,B.fields):Bn.create(me);if(J(oe),!H){var Ne=new ft({state:oe,parent:X,root:U});re(Ne),s&&s(Ne,oe)}}return()=>{H&&(J(void 0),re(void 0))}},[X,Ae]),m.useEffect(()=>{e.container&&q(e.container)},[e.container]),m.useEffect(()=>()=>{H&&(H.destroy(),re(void 0)),ie.current&&(ie.current.cancel(),ie.current=null)},[H]),m.useEffect(()=>{u&&H&&H.focus()},[u,H]),m.useEffect(()=>{H&&H.dispatch({effects:rn.reconfigure.of(Ee)})},[f,c,p,b,O,x,E,k,A,C,L,Q,$,i,a]),m.useEffect(()=>{if(t!==void 0){var me=H?H.state.doc.toString():"";if(H&&t!==me){var oe=ie.current&&!ie.current.isDone,Ne=()=>{H&&t!==H.state.doc.toString()&&H.dispatch({changes:{from:0,to:H.state.doc.toString().length,insert:t||""},annotations:[Oq.of(!0)]})};oe?ue.current=Ne:Ne()}}},[t,H]),{state:Ae,setState:J,view:H,setView:re,container:X,setContainer:q}}var Jot=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ehe=m.forwardRef((e,t)=>{var n=e.className,i=e.value,r=i===void 0?"":i,s=e.selection,a=e.extensions,o=a===void 0?[]:a,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,h=e.autoFocus,p=e.theme,g=p===void 0?"light":p,b=e.height,y=e.minHeight,O=e.maxHeight,v=e.width,x=e.minWidth,w=e.maxWidth,E=e.basicSetup,S=e.placeholder,k=e.indentWithTab,T=e.editable,A=e.readOnly,N=e.root,C=e.initialState,M=Nst(e,Jot),L=m.useRef(null),P=Kot({root:N,value:r,autoFocus:h,theme:g,height:b,minHeight:y,maxHeight:O,width:v,minWidth:x,maxWidth:w,basicSetup:E,placeholder:S,indentWithTab:k,editable:T,readOnly:A,selection:s,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:o,initialState:C}),Q=P.state,j=P.view,$=P.container,U=P.setContainer;m.useImperativeHandle(t,()=>({editor:L.current,state:Q,view:j}),[L,$,Q,j]);var B=m.useCallback(X=>{L.current=X,U(X)},[U]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var I=typeof g=="string"?"cm-theme-"+g:"cm-theme";return l.jsx("div",CL({ref:B,className:""+I+(n?" "+n:"")},M))});Ehe.displayName="CodeMirror";function elt(e){const t=e.toLowerCase(),n=t.split("/").pop()??t,i=n.includes(".")?n.split(".").pop():"";return i==="py"||i==="pyi"?[Krt()]:["ts","tsx","mts","cts"].includes(i??"")?[bL({typescript:!0,jsx:i==="tsx"})]:["js","jsx","mjs","cjs"].includes(i??"")?[bL({jsx:i==="jsx"})]:i==="json"||i==="jsonc"?[Ott()]:i==="yaml"||i==="yml"?[Ast()]:["md","markdown"].includes(i??"")?[Rit()]:[]}function sQ({value:e,path:t,onChange:n,readOnly:i=!1}){const r=m.useMemo(()=>elt(t),[t]);return l.jsx(Ehe,{value:e,height:"100%",theme:"light",extensions:r,editable:!i,onChange:n,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,highlightActiveLineGutter:!0,autocompletion:!1}})}const khe=Object.freeze(Object.defineProperty({__proto__:null,default:sQ},Symbol.toStringTag,{value:"Module"}));function tlt(e){var s;const t=e.split(/\r?\n/);if(((s=t[0])==null?void 0:s.trim())!=="---")return{body:e,frontmatter:[]};const n=t.findIndex((a,o)=>o>0&&a.trim()==="---");if(n<0)return{body:e,frontmatter:[]};const i=Kle(t.slice(1,n).join(` `));if(i.errors.length>0)return{body:e,frontmatter:[]};const r=i.toJS();return!r||typeof r!="object"||Array.isArray(r)?{body:e,frontmatter:[]}:{body:t.slice(n+1).join(` -`).replace(/^\s*\n/,""),frontmatter:Object.entries(r).map(([a,o])=>({key:a,value:typeof o=="string"?o:Kle(o).trim()}))}}function tlt(){return l.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M2.75 5.5h5l1.5 1.75h8v7.25a1.75 1.75 0 0 1-1.75 1.75h-11a1.75 1.75 0 0 1-1.75-1.75v-9Z"})})}function nlt(){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[l.jsx("path",{d:"M5 2.75h6l4 4v10.5H5z"}),l.jsx("path",{d:"M11 2.75v4h4"})]})}function ilt(e){const t={children:[]};for(const i of e){let r=t;const s=i.path.split("/").filter(Boolean);s.forEach((a,o)=>{let c=r.children.find(u=>u.name===a);if(!c){const u=s.slice(0,o+1).join("/");c={name:a,path:u,children:[]},r.children.push(c)}o===s.length-1&&(c.file=i),r=c})}const n=i=>{i.sort((r,s)=>+!!r.file-+!!s.file||r.name.localeCompare(s.name)),i.forEach(r=>n(r.children))};return n(t.children),t.children}function khe({nodes:e,depth:t,activePath:n,onSelect:i}){return e.map(r=>l.jsxs("div",{children:[r.file?l.jsxs("button",{type:"button",className:`skill-file-tree__row${r.path===n?" is-active":""}`,style:{paddingLeft:`${12+t*16}px`},onClick:()=>i(r.file),title:r.path,children:[l.jsx(nlt,{}),l.jsx("span",{children:r.name}),l.jsxs("small",{children:[r.file.size.toLocaleString()," B"]})]}):l.jsxs("div",{className:"skill-file-tree__row is-folder",style:{paddingLeft:`${12+t*16}px`},title:r.path,children:[l.jsx(tlt,{}),l.jsx("span",{children:r.name})]}),r.children.length>0?l.jsx(khe,{nodes:r.children,depth:t+1,activePath:n,onSelect:i}):null]},r.path))}function rlt(e){if(e.content===void 0)return;if(e.content.startsWith("data:")){const i=document.createElement("a");i.href=e.content,i.download=e.path.split("/").pop()||"skill-file",i.click();return}const t=URL.createObjectURL(new Blob([e.content])),n=document.createElement("a");n.href=t,n.download=e.path.split("/").pop()||"skill-file",n.click(),URL.revokeObjectURL(t)}function The({files:e}){var f;const t=m.useMemo(()=>ilt(e),[e]),[n,i]=m.useState(((f=e[0])==null?void 0:f.path)||""),[r,s]=m.useState("preview"),a=e.find(h=>h.path===n)||e[0],o=(a==null?void 0:a.path.toLowerCase())||"",c=o.endsWith(".md")||o.endsWith(".markdown"),u=/\.(png|jpe?g|gif|webp|svg)$/.test(o),d=m.useMemo(()=>elt(c&&(a==null?void 0:a.content)!==void 0?a.content:""),[a==null?void 0:a.content,c]);return l.jsxs("div",{className:"skill-file-browser",children:[l.jsx("aside",{className:"skill-file-tree","aria-label":"Skill 文件树",children:l.jsx(khe,{nodes:t,depth:0,activePath:(a==null?void 0:a.path)||"",onSelect:h=>i(h.path)})}),l.jsx("section",{className:"skill-file-preview",children:a?l.jsxs(l.Fragment,{children:[l.jsxs("header",{children:[l.jsx("span",{title:a.path,children:a.path}),l.jsxs("div",{children:[c?l.jsx("button",{type:"button",onClick:()=>s(h=>h==="preview"?"source":"preview"),children:r==="preview"?"查看源码":"查看预览"}):null,l.jsx("button",{type:"button",disabled:a.content===void 0,onClick:()=>rlt(a),children:"下载"})]})]}),l.jsx("div",{className:"skill-file-preview__body",children:a.kind==="binary"||a.content===void 0?l.jsxs("div",{className:"skill-file-preview__binary",children:[l.jsx("strong",{children:"二进制文件"}),l.jsxs("span",{children:[a.size.toLocaleString()," 字节"]}),l.jsx("span",{children:"当前接口仅返回文件元数据,可单独下载原文件。"})]}):u?l.jsx("img",{src:a.content.startsWith("data:")?a.content:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a.content)}`,alt:a.path}):c&&r==="preview"?l.jsxs("div",{className:"skill-file-preview__markdown",children:[d.frontmatter.length>0?l.jsx("dl",{className:"skill-file-preview__frontmatter","aria-label":"Skill 元数据",children:d.frontmatter.map(h=>l.jsxs("div",{children:[l.jsx("dt",{children:h.key}),l.jsx("dd",{children:h.value})]},h.key))}):null,l.jsx(qp,{text:d.body,allowRawHtml:!1,className:"skill-file-preview__markdown-body"})]}):l.jsx(sQ,{value:a.content,path:a.path,readOnly:!0,onChange:()=>{}})})]}):l.jsx("div",{className:"skill-file-preview__binary",children:"暂无文件"})})]})}const slt=1200,alt=3,_he=2,olt=/SKILL\.md|frontmatter|Skill name|description|根目录|目录名|UTF-8|文本文件|文件数|符号链接|敏感凭证/i,Ahe={concise:"简洁实用",strict:"严谨稳健",tutorial:"教程友好",automation:"自动化优先"},llt=[...Object.entries(Ahe).map(([e,t])=>({value:e,label:t})),{value:"custom",label:"自定义"}];function yq(e,t){var n;return{id:`group-${Date.now()}-${e}`,model:((n=t.models[e%Math.max(1,t.models.length)])==null?void 0:n.id)||"",style:"concise",customStyle:""}}function clt(e){return e?e.state==="ready"?"Skill 已生成并通过格式校验":e.state==="failed"?"生成失败":e.state==="cancelled"?"已停止":e.stage==="validating"?"正在校验 Skill 格式":e.stage==="packaging"?"正在整理文件":"正在生成 Skill":"正在准备 Dev Sandbox"}function Yj(e){var t;return e.state==="failed"&&((t=e.validation)==null?void 0:t.valid)===!1&&e.validation.errors.some(n=>olt.test(n))}function xq(e){var n;return["只修复下面列出的 Skill 格式错误,不要改变原有用途和内容范围。","修复后重新检查目录结构、SKILL.md frontmatter 和所有文本文件。",(((n=e.validation)==null?void 0:n.errors.join(` +`).replace(/^\s*\n/,""),frontmatter:Object.entries(r).map(([a,o])=>({key:a,value:typeof o=="string"?o:Jle(o).trim()}))}}function nlt(){return l.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M2.75 5.5h5l1.5 1.75h8v7.25a1.75 1.75 0 0 1-1.75 1.75h-11a1.75 1.75 0 0 1-1.75-1.75v-9Z"})})}function ilt(){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[l.jsx("path",{d:"M5 2.75h6l4 4v10.5H5z"}),l.jsx("path",{d:"M11 2.75v4h4"})]})}function rlt(e){const t={children:[]};for(const i of e){let r=t;const s=i.path.split("/").filter(Boolean);s.forEach((a,o)=>{let c=r.children.find(u=>u.name===a);if(!c){const u=s.slice(0,o+1).join("/");c={name:a,path:u,children:[]},r.children.push(c)}o===s.length-1&&(c.file=i),r=c})}const n=i=>{i.sort((r,s)=>+!!r.file-+!!s.file||r.name.localeCompare(s.name)),i.forEach(r=>n(r.children))};return n(t.children),t.children}function The({nodes:e,depth:t,activePath:n,onSelect:i}){return e.map(r=>l.jsxs("div",{children:[r.file?l.jsxs("button",{type:"button",className:`skill-file-tree__row${r.path===n?" is-active":""}`,style:{paddingLeft:`${12+t*16}px`},onClick:()=>i(r.file),title:r.path,children:[l.jsx(ilt,{}),l.jsx("span",{children:r.name}),l.jsxs("small",{children:[r.file.size.toLocaleString()," B"]})]}):l.jsxs("div",{className:"skill-file-tree__row is-folder",style:{paddingLeft:`${12+t*16}px`},title:r.path,children:[l.jsx(nlt,{}),l.jsx("span",{children:r.name})]}),r.children.length>0?l.jsx(The,{nodes:r.children,depth:t+1,activePath:n,onSelect:i}):null]},r.path))}function slt(e){if(e.content===void 0)return;if(e.content.startsWith("data:")){const i=document.createElement("a");i.href=e.content,i.download=e.path.split("/").pop()||"skill-file",i.click();return}const t=URL.createObjectURL(new Blob([e.content])),n=document.createElement("a");n.href=t,n.download=e.path.split("/").pop()||"skill-file",n.click(),URL.revokeObjectURL(t)}function _he({files:e}){var f;const t=m.useMemo(()=>rlt(e),[e]),[n,i]=m.useState(((f=e[0])==null?void 0:f.path)||""),[r,s]=m.useState("preview"),a=e.find(h=>h.path===n)||e[0],o=(a==null?void 0:a.path.toLowerCase())||"",c=o.endsWith(".md")||o.endsWith(".markdown"),u=/\.(png|jpe?g|gif|webp|svg)$/.test(o),d=m.useMemo(()=>tlt(c&&(a==null?void 0:a.content)!==void 0?a.content:""),[a==null?void 0:a.content,c]);return l.jsxs("div",{className:"skill-file-browser",children:[l.jsx("aside",{className:"skill-file-tree","aria-label":"Skill 文件树",children:l.jsx(The,{nodes:t,depth:0,activePath:(a==null?void 0:a.path)||"",onSelect:h=>i(h.path)})}),l.jsx("section",{className:"skill-file-preview",children:a?l.jsxs(l.Fragment,{children:[l.jsxs("header",{children:[l.jsx("span",{title:a.path,children:a.path}),l.jsxs("div",{children:[c?l.jsx("button",{type:"button",onClick:()=>s(h=>h==="preview"?"source":"preview"),children:r==="preview"?"查看源码":"查看预览"}):null,l.jsx("button",{type:"button",disabled:a.content===void 0,onClick:()=>slt(a),children:"下载"})]})]}),l.jsx("div",{className:"skill-file-preview__body",children:a.kind==="binary"||a.content===void 0?l.jsxs("div",{className:"skill-file-preview__binary",children:[l.jsx("strong",{children:"二进制文件"}),l.jsxs("span",{children:[a.size.toLocaleString()," 字节"]}),l.jsx("span",{children:"当前接口仅返回文件元数据,可单独下载原文件。"})]}):u?l.jsx("img",{src:a.content.startsWith("data:")?a.content:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a.content)}`,alt:a.path}):c&&r==="preview"?l.jsxs("div",{className:"skill-file-preview__markdown",children:[d.frontmatter.length>0?l.jsx("dl",{className:"skill-file-preview__frontmatter","aria-label":"Skill 元数据",children:d.frontmatter.map(h=>l.jsxs("div",{children:[l.jsx("dt",{children:h.key}),l.jsx("dd",{children:h.value})]},h.key))}):null,l.jsx(qp,{text:d.body,allowRawHtml:!1,className:"skill-file-preview__markdown-body"})]}):l.jsx(sQ,{value:a.content,path:a.path,readOnly:!0,onChange:()=>{}})})]}):l.jsx("div",{className:"skill-file-preview__binary",children:"暂无文件"})})]})}const alt=1200,olt=3,Ahe=2,llt=/SKILL\.md|frontmatter|Skill name|description|根目录|目录名|UTF-8|文本文件|文件数|符号链接|敏感凭证/i,Nhe={concise:"简洁实用",strict:"严谨稳健",tutorial:"教程友好",automation:"自动化优先"},clt=[...Object.entries(Nhe).map(([e,t])=>({value:e,label:t})),{value:"custom",label:"自定义"}];function yq(e,t){var n;return{id:`group-${Date.now()}-${e}`,model:((n=t.models[e%Math.max(1,t.models.length)])==null?void 0:n.id)||"",style:"concise",customStyle:""}}function ult(e){return e?e.state==="ready"?"Skill 已生成并通过格式校验":e.state==="failed"?"生成失败":e.state==="cancelled"?"已停止":e.stage==="validating"?"正在校验 Skill 格式":e.stage==="packaging"?"正在整理文件":"正在生成 Skill":"正在准备 Dev Sandbox"}function Yj(e){var t;return e.state==="failed"&&((t=e.validation)==null?void 0:t.valid)===!1&&e.validation.errors.some(n=>llt.test(n))}function xq(e){var n;return["只修复下面列出的 Skill 格式错误,不要改变原有用途和内容范围。","修复后重新检查目录结构、SKILL.md frontmatter 和所有文本文件。",(((n=e.validation)==null?void 0:n.errors.join(` `))||e.error||"Skill 格式校验未通过").slice(0,2e3)].join(` -`)}function ult(e){var t;return e.repairing||((t=e.task)==null?void 0:t.state)==="running"&&e.repairMode?e.repairMode==="manual"?"正在再次修复":`正在自动修复(${Math.max(1,e.repairAttempts||1)}/${_he})`:clt(e.task)}function vq(){return l.jsxs("svg",{className:"skill-generation__spinner",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"10",r:"7"}),l.jsx("path",{d:"M10 3a7 7 0 0 1 7 7"})]})}function dlt(e,t=Date.now()){if(!(e!=null&&e.expiresAt))return"Session 最长保留 1 小时";const n=Math.max(0,new Date(e.expiresAt).getTime()-t),i=Math.floor(n/6e4),r=Math.floor(n%6e4/1e3);return`剩余 ${i}:${String(r).padStart(2,"0")}`}function flt(e){return e?e.length>64?"Skill 名称不能超过 64 个字符":/^[a-z0-9-]+$/.test(e)?"":"Skill 名称只能包含小写字母、数字和连字符":""}function wq(e){return e?e.length>128?"模型 ID 不能超过 128 个字符":/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(e)?"":"模型 ID 只能包含字母、数字、点、下划线、连字符、斜杠和冒号":""}function Gj(e){return`${e.region||""}:${e.id}`}function hlt(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function plt({operation:e,cloudProvider:t,space:n,availableSpaces:i=[],spacesLoading:r=!1,initialIntent:s="",source:a,onBack:o,onPublished:c}){var W,K,ae,pe;const[u,d]=m.useState(null),[f,h]=m.useState(null),[p,g]=m.useState(s),[b,y]=m.useState(""),[O,v]=m.useState([]),[x,w]=m.useState([]),[E,S]=m.useState(""),[k,T]=m.useState(!1),[A,N]=m.useState(""),[C,M]=m.useState(""),[L,P]=m.useState(null),[Q,j]=m.useState(""),[$,U]=m.useState(""),[B,I]=m.useState(n?Gj(n):""),[X,q]=m.useState(Date.now()),D=m.useRef([]);m.useEffect(()=>{const z=new AbortController;return aA(z.signal).then(ve=>{d(ve),v([yq(0,ve)])}).catch(ve=>{z.signal.aborted||h(ds(ve,"读取 Dev Sandbox 配置失败"))}),()=>z.abort()},[]),m.useEffect(()=>{D.current=x},[x]),m.useEffect(()=>{const z=window.setInterval(()=>q(Date.now()),1e3);return()=>window.clearInterval(z)},[]),m.useEffect(()=>{const z=ve=>{D.current.some(Be=>{var Je;return((Je=Be.task)==null?void 0:Je.state)==="running"||Be.repairing})&&ve.preventDefault()};return window.addEventListener("beforeunload",z),()=>{var ve;window.removeEventListener("beforeunload",z);for(const Be of D.current)(ve=Be.task)!=null&&ve.jobId&&Q4e(Be.task.jobId).catch(()=>{})}},[]),m.useEffect(()=>{if(!x.some(Je=>{var kt;return((kt=Je.task)==null?void 0:kt.state)==="running"||Je.repairing}))return;let z=!1,ve;const Be=async()=>{const Je=D.current,kt=await Promise.all(Je.map(async Mt=>{var Tt;if(((Tt=Mt.task)==null?void 0:Tt.state)!=="running")return Mt;try{const dt=await L4e(Mt.task.jobId);if(Yj(dt)&&(Mt.repairAttempts||0)<_he){const lt=(Mt.repairAttempts||0)+1;w(Ge=>Ge.map(vt=>vt.id===Mt.id?{...vt,task:dt,repairing:!0,repairMode:"auto",repairAttempts:lt,repairError:void 0}:vt));try{const Ge=await wC({jobId:dt.jobId,intent:xq(dt),expectedRevision:dt.revision});return{...Mt,task:Ge,artifact:void 0,repairing:!1,repairMode:"auto",repairAttempts:lt,repairError:void 0,error:void 0,pollError:void 0}}catch(Ge){return{...Mt,task:dt,repairing:!1,repairMode:void 0,repairAttempts:lt,repairError:ds(Ge,"自动修复格式错误失败"),pollError:void 0}}}let ge=Mt.artifact;return dt.state==="ready"&&(ge=await vC(dt.jobId,dt.revision)),{...Mt,task:dt,artifact:ge,repairing:!1,repairMode:dt.state==="running"?Mt.repairMode:void 0,repairError:void 0,error:void 0,pollError:void 0}}catch(dt){return{...Mt,pollError:ds(dt,"读取候选方案状态失败,正在重试")}}}));z||(w(kt),ve=window.setTimeout(()=>void Be(),slt))};return Be(),()=>{z=!0,ve!==void 0&&window.clearTimeout(ve)}},[x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"||z.repairing})]);const H=x.find(z=>z.id===E)||x[0],re=e==="create"&&!n,fe=i.find(z=>Gj(z)===B)??null,Ae=n??fe,J=i.map(z=>({value:Gj(z),label:`${z.name.trim()||"未命名 Skill Space"} · ${td(z.region||"cn-beijing",t)}`})),ie=flt(b),ue=!!(u!=null&&u.enabled&&p.trim()&&!ie&&O.length>0&&O.every(z=>z.model.trim()&&!wq(z.model.trim()))),ye=(z,ve)=>{v(Be=>Be.map(Je=>Je.id===z?{...Je,...ve}:Je))},Se=async z=>{const ve={...z,model:z.model.trim()},Be=z.style==="custom"?z.customStyle.trim():z.style;try{const Je=await M4e({operation:e,intent:p.trim(),model:ve.model,style:Be,name:b.trim()||void 0,source:a});return{id:z.id,config:ve,task:Je}}catch(Je){return{id:z.id,config:ve,error:ds(Je,"创建候选方案失败")}}},Re=async()=>{if(!ue)return;T(!0),P(null);const z=O.map(Be=>({id:Be.id,config:Be}));w(z),S(O[0].id);const ve=await Promise.all(O.map(Se));w(ve)},Ee=async z=>{w(Be=>Be.map(Je=>Je.id===z.id?{...Je,error:void 0}:Je));const ve=await Se(z.config);w(Be=>Be.map(Je=>Je.id===z.id?ve:Je))},me=async()=>{if(!(!(H!=null&&H.task)||!A.trim()||H.task.state!=="ready")){M("refine"),P(null);try{const z=await wC({jobId:H.task.jobId,intent:A.trim(),expectedRevision:H.task.revision});w(ve=>ve.map(Be=>Be.id===H.id?{...Be,task:z,artifact:void 0}:Be)),N("")}catch(z){P(ds(z,"继续调整失败"))}finally{M("")}}},oe=async()=>{if(!(!(H!=null&&H.task)||!Yj(H.task))){M("refine"),P(null),w(z=>z.map(ve=>ve.id===H.id?{...ve,repairing:!0,repairMode:"manual",repairError:void 0}:ve));try{const z=await wC({jobId:H.task.jobId,intent:xq(H.task),expectedRevision:H.task.revision});w(ve=>ve.map(Be=>Be.id===H.id?{...Be,task:z,artifact:void 0,repairing:!1,repairMode:"manual",repairError:void 0}:Be))}catch(z){w(ve=>ve.map(Be=>Be.id===H.id?{...Be,repairing:!1,repairMode:void 0,repairError:ds(z,"再次修复格式错误失败")}:Be))}finally{M("")}}},Ne=async()=>{if(!(!(H!=null&&H.task)||H.task.state!=="ready"||$)){M("publish"),P(null);try{if(!Ae)throw new Error("请选择上传的 Skill Space");const z=H.artifact||await vC(H.task.jobId,H.task.revision),ve=(a==null?void 0:a.region)||Ae.region||"";if(!BD(ve))throw new Error("当前 Skill 地域不受支持");await $4e({jobId:H.task.jobId,expectedRevision:H.task.revision,expectedArtifactSha256:z.sha256,disposition:e==="optimize"?"update-source":"create-new",skillSpaceIds:[Ae.id],projectName:(a==null?void 0:a.projectName)||Ae.projectName,region:ve,onProgress:Be=>j(Be.message)}),U(H.id),c()}catch(z){P(ds(z,"上传 Skill 失败"))}finally{M(""),j("")}}},Oe=async()=>{if(!(!(H!=null&&H.task)||H.task.state!=="ready")){M("download");try{const z=H.artifact||await vC(H.task.jobId,H.task.revision);await B4e(H.task.jobId,H.task.revision,z.sha256)}catch(z){P(ds(z,"下载失败"))}finally{M("")}}},Ve=async()=>{x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"})&&!window.confirm("离开后将停止并释放正在运行的 Dev Sandbox,确定离开吗?")||(await Promise.allSettled(x.flatMap(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"?[D4e({jobId:z.task.jobId,expectedRevision:z.task.revision})]:[]})),o())},We=e==="create"?"创建技能":`优化 ${(a==null?void 0:a.name)||"技能"}`,De=z=>{var ve;return((ve=u==null?void 0:u.models.find(Be=>Be.id===z))==null?void 0:ve.label)||z},mt=z=>z.config.style==="custom"?z.config.customStyle.trim()||"自定义风格":Ahe[z.config.style],at=z=>z.error||z.repairError?"失败":ult(z),Rt=z=>!z.error&&!z.repairError&&(z.repairing||!z.task||z.task.state==="running"),qe=x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="ready"});return l.jsxs("section",{className:"skill-generation",children:[l.jsxs("header",{className:"skill-generation__header",children:[l.jsx("button",{type:"button",className:"skillcenter-back",onClick:()=>void Ve(),"aria-label":"返回技能空间",children:l.jsx(hlt,{})}),l.jsxs("div",{children:[l.jsx("h1",{children:We}),l.jsx("p",{children:(n==null?void 0:n.name)||"主页技能生成"})]}),x.length>0?l.jsx("span",{className:"skill-generation__ttl",children:dlt(H==null?void 0:H.task,X)}):null]}),k?l.jsxs("div",{className:"skill-generation__workspace",children:[l.jsx("div",{className:"skill-generation__candidate-tabs",role:"tablist","aria-label":"候选方案",children:x.map(z=>l.jsxs("button",{type:"button",role:"tab","aria-selected":(H==null?void 0:H.id)===z.id,className:(H==null?void 0:H.id)===z.id?"is-active":"",onClick:()=>S(z.id),children:[l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"风格"}),l.jsx("strong",{children:mt(z)})]}),l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"模型"}),l.jsx("strong",{children:De(z.config.model)})]}),l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"进度"}),l.jsxs("strong",{children:[Rt(z)?l.jsx(vq,{}):null,at(z)]})]})]},z.id))}),H?l.jsxs("div",{className:"skill-generation__candidate",children:[l.jsxs("section",{className:"skill-generation__activity",children:[l.jsx("header",{children:l.jsxs("div",{className:"skill-generation__candidate-summary",children:[l.jsxs("div",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"风格"}),l.jsx("strong",{children:mt(H)})]}),l.jsxs("div",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"模型"}),l.jsx("strong",{children:De(H.config.model)})]}),l.jsxs("div",{className:"skill-generation__summary-row","aria-live":"polite",children:[l.jsx("span",{children:"进度"}),l.jsxs("strong",{children:[Rt(H)?l.jsx(vq,{}):null,Rt(H)?l.jsx(oi,{children:at(H)}):at(H)]})]})]})}),H.task?l.jsx(YHe,{activities:H.task.activities}):null,H.pollError?l.jsx("div",{className:"skill-inline-notice",children:l.jsx(ho,{error:H.pollError})}):null,H.repairError?l.jsx("div",{className:"skill-inline-notice",children:l.jsx(ho,{error:H.repairError})}):null,H.error?l.jsxs("div",{className:"skill-inline-error",children:[l.jsx(ho,{error:H.error}),l.jsx("button",{type:"button",onClick:()=>void Ee(H),children:"重试此方案"})]}):null,(W=H.task)!=null&&W.validation&&!H.task.validation.valid&&!H.repairing&&H.task.state==="failed"?l.jsxs("div",{className:"skill-validation-errors",children:[l.jsx("strong",{children:"格式校验未通过"}),H.task.validation.errors.map(z=>l.jsx("p",{children:z},z)),Yj(H.task)?l.jsx("button",{type:"button",disabled:!!C,onClick:()=>void oe(),children:"再次修复"}):null]}):null]}),l.jsxs("section",{className:"skill-generation__files",children:[l.jsxs("header",{children:[l.jsx("h2",{children:"文件"}),((K=H.task)==null?void 0:K.state)==="ready"?l.jsx("button",{type:"button",onClick:()=>void Oe(),disabled:!!C,children:"下载 ZIP"}):null]}),H.artifact?l.jsx(The,{files:H.artifact.files}):l.jsx("div",{className:"skill-generation__files-empty",children:((ae=H.task)==null?void 0:ae.state)==="ready"?"正在读取文件…":"生成过程中会在这里显示完整文件树"})]}),((pe=H.task)==null?void 0:pe.state)==="ready"?l.jsxs("div",{className:"skill-generation__ready-actions",children:[re?l.jsx("div",{className:"skill-generation__publish-target",children:l.jsx(FC,{label:"上传到 Skill Space",value:B,options:J,onChange:I,disabled:r,placeholder:r?"正在加载 Skill Space":"选择 Skill Space"})}):null,l.jsxs("footer",{className:"skill-generation__followup",children:[l.jsx("textarea",{value:A,onChange:z=>N(z.target.value),placeholder:"继续调整这个候选方案"}),l.jsx("button",{type:"button",className:"skill-button",disabled:!A.trim()||!!C,onClick:()=>void me(),children:"继续调整"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!!C||!!$||!Ae,onClick:()=>void Ne(),children:C==="publish"?Q||"上传中…":e==="optimize"?"覆盖原 Skill":re?"上传到 Skill Space":"上传到当前空间"})]})]}):null,L?l.jsx("div",{className:"skill-inline-error skill-generation__action-error",children:l.jsx(ho,{error:L})}):null]}):null,!qe&&x.every(z=>z.error)?l.jsx("div",{className:"skill-inline-error",children:"所有方案均创建失败,可分别重试。"}):null]}):l.jsxs("div",{className:"skill-generation__setup",children:[l.jsx("div",{className:"skill-generation__section-head is-basic",children:l.jsx("div",{children:l.jsx("strong",{children:"基本信息"})})}),l.jsxs("label",{children:[l.jsxs("span",{children:["目标",l.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"})]}),l.jsx("textarea",{required:!0,value:p,onChange:z=>g(z.target.value),placeholder:e==="create"?"描述希望这个 Skill 完成什么任务":"描述希望如何优化当前 Skill"})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Skill 名称"}),l.jsx("input",{value:b,onChange:z=>y(z.target.value),placeholder:"留空时自动生成","aria-invalid":!!ie,"aria-describedby":"skill-name-help"}),ie?l.jsx("span",{id:"skill-name-help",className:"skill-generation__field-error",role:"alert",children:ie}):l.jsx("span",{id:"skill-name-help",className:"skill-generation__field-help",children:"仅支持小写字母、数字和连字符;留空时自动生成。"})]}),l.jsx("div",{className:"skill-generation__section-head",children:l.jsxs("div",{children:[l.jsx("strong",{children:e==="create"?"生成方案":"优化方案"}),l.jsx("span",{children:e==="create"?"按不同方案并行生成多个技能,您可以选择最佳结果":"按不同方案并行优化当前技能,您可以选择最佳结果"})]})}),l.jsxs("div",{className:"skill-generation__groups",children:[O.map((z,ve)=>l.jsxs("article",{className:"skill-generation__group",children:[l.jsxs("header",{children:[l.jsxs("strong",{children:["方案 ",ve+1]}),O.length>1?l.jsx("button",{type:"button",onClick:()=>v(Be=>Be.filter(Je=>Je.id!==z.id)),children:"移除"}):null]}),l.jsx(FC,{label:"模型",required:!0,value:z.model,options:(u==null?void 0:u.models.map(Be=>({value:Be.id,label:Be.label})))||[],onChange:Be=>ye(z.id,{model:Be}),allowCustom:!0,placeholder:"选择或输入模型 ID",error:wq(z.model.trim())}),l.jsx(FC,{label:"风格",required:!0,value:z.style,options:llt,onChange:Be=>ye(z.id,{style:Be})}),z.style==="custom"?l.jsxs("label",{children:[l.jsx("span",{children:"自定义风格"}),l.jsx("textarea",{value:z.customStyle,onChange:Be=>ye(z.id,{customStyle:Be.target.value}),placeholder:"描述表达方式、严谨程度或输出偏好"})]}):null]},z.id)),u&&O.lengthv(z=>[...z,yq(z.length,u)]),children:"添加配置"}):null]}),f?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:f})}):null,u&&!u.enabled?l.jsx("div",{className:"skill-inline-notice",children:"管理员未配置"}):null,l.jsx("div",{className:"skill-generation__setup-actions",children:l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!ue,onClick:()=>void Re(),children:"生成"})})]})]})}function aQ({title:e,children:t,onClose:n,className:i=""}){const r=m.useRef(null);return m.useEffect(()=>{var a;(a=r.current)==null||a.focus();const s=o=>o.key==="Escape"&&n();return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),l.jsx("div",{className:"skill-dialog-backdrop",onMouseDown:n,children:l.jsxs("section",{className:`skill-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-label":e,onMouseDown:s=>s.stopPropagation(),children:[l.jsxs("header",{children:[l.jsx("h2",{children:e}),l.jsx("button",{ref:r,type:"button",onClick:n,"aria-label":"关闭",children:"关闭"})]}),t]})})}function mlt({region:e,onClose:t,onCreated:n}){const[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null),f=async()=>{if(i.trim()){c(!0),d(null);try{n(await TPe({name:i.trim(),description:s.trim()||void 0,region:e}))}catch(h){d(ds(h,"创建 Skill 空间失败"))}finally{c(!1)}}};return l.jsxs(aQ,{title:"新建 Skill 空间",onClose:t,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:i,maxLength:128,onChange:h=>r(h.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:s,maxLength:1024,onChange:h=>a(h.target.value)})]}),u?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:u})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!i.trim()||o,onClick:()=>void f(),children:o?"创建中…":"创建"})]})]})}function glt({space:e,region:t,onClose:n,onUpdated:i}){const[r,s]=m.useState(e.name),[a,o]=m.useState(e.description||""),[c,u]=m.useState(!1),[d,f]=m.useState(null),h=async()=>{if(r.trim()){u(!0),f(null);try{const p=await _Pe({spaceId:e.id,name:r.trim(),description:a.trim()||void 0,region:t});i({...e,...p,skillCount:e.skillCount})}catch(p){f(ds(p,"更新 Skill 空间失败"))}finally{u(!1)}}};return l.jsxs(aQ,{title:"编辑 Skill 空间",onClose:n,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:r,maxLength:128,onChange:p=>s(p.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:a,maxLength:1024,onChange:p=>o(p.target.value)})]}),d?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:d})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!r.trim()||c,onClick:()=>void h(),children:c?"保存中…":"保存"})]})]})}function blt({space:e,region:t,onClose:n,onUploaded:i}){const[r,s]=m.useState(null),[a,o]=m.useState(null),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[h,p]=m.useState(null),[g,b]=m.useState(!1),y=m.useRef(0),O=m.useRef(null),v=async w=>{const E=y.current+1;if(y.current=E,s(w),o(null),p(null),u(!!w),!!w)try{const S=await CPe(w);y.current===E&&o({name:S.name,fileCount:S.files.length})}catch(S){y.current===E&&p(ds(S,"Skill ZIP 格式校验失败"))}finally{y.current===E&&u(!1)}},x=async()=>{if(!(!r||!a)){f(!0),p(null);try{await NPe({spaceId:e.id,region:t,project:e.projectName,file:r}),i()}catch(w){p(ds(w,"上传 Skill 失败"))}finally{f(!1)}}};return l.jsxs(aQ,{title:`上传到 ${e.name}`,className:"skill-upload-dialog",onClose:n,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsx("input",{ref:O,className:"skill-upload-dialog__input",type:"file",accept:".zip,application/zip",onChange:w=>{var E;return void v(((E=w.target.files)==null?void 0:E[0])||null)}}),l.jsxs("button",{type:"button",className:`skill-upload-dropzone${g?" is-dragging":""}`,onClick:()=>{var w;return(w=O.current)==null?void 0:w.click()},onDragEnter:w=>{w.preventDefault(),b(!0)},onDragOver:w=>{w.preventDefault(),w.dataTransfer.dropEffect="copy",b(!0)},onDragLeave:w=>{w.currentTarget.contains(w.relatedTarget)||b(!1)},onDrop:w=>{var E;w.preventDefault(),b(!1),v(((E=w.dataTransfer.files)==null?void 0:E[0])||null)},children:[l.jsx("strong",{children:r?r.name:"拖拽 Skill ZIP 到这里"}),l.jsx("span",{children:r?`${r.size.toLocaleString()} 字节`:"或点击选择本地文件"})]}),l.jsx("p",{children:"ZIP 根目录需要包含 SKILL.md,也可以只包含一层包装目录。选择后仅检查格式,不会自动上传。"}),c?l.jsx("div",{className:"skill-inline-notice",children:"正在检查文件格式…"}):null,a?l.jsxs("div",{className:"skill-inline-notice",children:["格式检查通过:",a.name,",共 ",a.fileCount," 个文件"]}):null,h?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:h})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!r||!a||c||d,onClick:()=>void x(),children:d?"上传中…":"上传"})]})]})}const Olt=12,Sq=12;function RT({disabled:e,placement:t="top",children:n}){const i=m.useId();return l.jsxs("span",{className:`skillcenter-disabled-action${e?" is-disabled":""} is-${t}`,tabIndex:e?0:void 0,"aria-describedby":e?i:void 0,children:[n,e?l.jsx("span",{id:i,className:"skillcenter-disabled-tooltip",role:"tooltip",children:"管理员未配置 Dev Sandbox"}):null]})}const ylt={active:"可用",available:"可用",creating:"创建中",disabled:"已停用",enabled:"已启用",failed:"异常",inactive:"未启用",pending:"等待中",published:"已发布",ready:"就绪",released:"已发布",running:"运行中",success:"正常",unavailable:"不可用",unreleased:"未发布",updating:"更新中"};function DL(e){return ylt[(e||"").trim().toLowerCase()]||"未知"}function Eq(e){const t=(e||"").toLowerCase();return["active","available","enabled","published","ready","released","success"].includes(t)||t==="running"?"is-positive":["creating","pending","updating"].includes(t)?"is-progress":["failed","unavailable"].includes(t)?"is-danger":"is-muted"}function kq(e){if(!e)return"";const t=e.trim(),n=Number(t),i=/^\d+(?:\.\d+)?$/.test(t)?new Date(n<1e12?n*1e3:n):new Date(t);return Number.isNaN(i.getTime())?e:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(i)}function Tq(e){if(!e)return 0;const t=e.trim(),n=Number(t),i=/^\d+(?:\.\d+)?$/.test(t)?new Date(n<1e12?n*1e3:n):new Date(t);return Number.isNaN(i.getTime())?0:i.getTime()}function Sl(e){return`${e.region||"default"}:${e.projectName||"default"}:${e.id}`}function xlt(e,t){const n=new Map(e.map(i=>[Sl(i),i]));for(const i of t)n.set(Sl(i),i);return[...n.values()].sort((i,r)=>Tq(r.updatedAt)-Tq(i.updatedAt))}function vlt(e){const t=e.replace(/\r\n/g,` +`)}function dlt(e){var t;return e.repairing||((t=e.task)==null?void 0:t.state)==="running"&&e.repairMode?e.repairMode==="manual"?"正在再次修复":`正在自动修复(${Math.max(1,e.repairAttempts||1)}/${Ahe})`:ult(e.task)}function vq(){return l.jsxs("svg",{className:"skill-generation__spinner",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"10",r:"7"}),l.jsx("path",{d:"M10 3a7 7 0 0 1 7 7"})]})}function flt(e,t=Date.now()){if(!(e!=null&&e.expiresAt))return"Session 最长保留 1 小时";const n=Math.max(0,new Date(e.expiresAt).getTime()-t),i=Math.floor(n/6e4),r=Math.floor(n%6e4/1e3);return`剩余 ${i}:${String(r).padStart(2,"0")}`}function hlt(e){return e?e.length>64?"Skill 名称不能超过 64 个字符":/^[a-z0-9-]+$/.test(e)?"":"Skill 名称只能包含小写字母、数字和连字符":""}function wq(e){return e?e.length>128?"模型 ID 不能超过 128 个字符":/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(e)?"":"模型 ID 只能包含字母、数字、点、下划线、连字符、斜杠和冒号":""}function Gj(e){return`${e.region||""}:${e.id}`}function plt(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function mlt({operation:e,cloudProvider:t,space:n,availableSpaces:i=[],spacesLoading:r=!1,initialIntent:s="",source:a,onBack:o,onPublished:c}){var W,K,ae,pe;const[u,d]=m.useState(null),[f,h]=m.useState(null),[p,g]=m.useState(s),[b,y]=m.useState(""),[O,v]=m.useState([]),[x,w]=m.useState([]),[E,S]=m.useState(""),[k,T]=m.useState(!1),[A,N]=m.useState(""),[C,M]=m.useState(""),[L,P]=m.useState(null),[Q,j]=m.useState(""),[$,U]=m.useState(""),[B,I]=m.useState(n?Gj(n):""),[X,q]=m.useState(Date.now()),D=m.useRef([]);m.useEffect(()=>{const z=new AbortController;return aA(z.signal).then(ve=>{d(ve),v([yq(0,ve)])}).catch(ve=>{z.signal.aborted||h(ds(ve,"读取 Dev Sandbox 配置失败"))}),()=>z.abort()},[]),m.useEffect(()=>{D.current=x},[x]),m.useEffect(()=>{const z=window.setInterval(()=>q(Date.now()),1e3);return()=>window.clearInterval(z)},[]),m.useEffect(()=>{const z=ve=>{D.current.some(Be=>{var Je;return((Je=Be.task)==null?void 0:Je.state)==="running"||Be.repairing})&&ve.preventDefault()};return window.addEventListener("beforeunload",z),()=>{var ve;window.removeEventListener("beforeunload",z);for(const Be of D.current)(ve=Be.task)!=null&&ve.jobId&&B4e(Be.task.jobId).catch(()=>{})}},[]),m.useEffect(()=>{if(!x.some(Je=>{var kt;return((kt=Je.task)==null?void 0:kt.state)==="running"||Je.repairing}))return;let z=!1,ve;const Be=async()=>{const Je=D.current,kt=await Promise.all(Je.map(async Mt=>{var Tt;if(((Tt=Mt.task)==null?void 0:Tt.state)!=="running")return Mt;try{const dt=await D4e(Mt.task.jobId);if(Yj(dt)&&(Mt.repairAttempts||0)Ge.map(vt=>vt.id===Mt.id?{...vt,task:dt,repairing:!0,repairMode:"auto",repairAttempts:lt,repairError:void 0}:vt));try{const Ge=await wC({jobId:dt.jobId,intent:xq(dt),expectedRevision:dt.revision});return{...Mt,task:Ge,artifact:void 0,repairing:!1,repairMode:"auto",repairAttempts:lt,repairError:void 0,error:void 0,pollError:void 0}}catch(Ge){return{...Mt,task:dt,repairing:!1,repairMode:void 0,repairAttempts:lt,repairError:ds(Ge,"自动修复格式错误失败"),pollError:void 0}}}let ge=Mt.artifact;return dt.state==="ready"&&(ge=await vC(dt.jobId,dt.revision)),{...Mt,task:dt,artifact:ge,repairing:!1,repairMode:dt.state==="running"?Mt.repairMode:void 0,repairError:void 0,error:void 0,pollError:void 0}}catch(dt){return{...Mt,pollError:ds(dt,"读取候选方案状态失败,正在重试")}}}));z||(w(kt),ve=window.setTimeout(()=>void Be(),alt))};return Be(),()=>{z=!0,ve!==void 0&&window.clearTimeout(ve)}},[x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"||z.repairing})]);const H=x.find(z=>z.id===E)||x[0],re=e==="create"&&!n,fe=i.find(z=>Gj(z)===B)??null,Ae=n??fe,J=i.map(z=>({value:Gj(z),label:`${z.name.trim()||"未命名 Skill Space"} · ${td(z.region||"cn-beijing",t)}`})),ie=hlt(b),ue=!!(u!=null&&u.enabled&&p.trim()&&!ie&&O.length>0&&O.every(z=>z.model.trim()&&!wq(z.model.trim()))),ye=(z,ve)=>{v(Be=>Be.map(Je=>Je.id===z?{...Je,...ve}:Je))},Se=async z=>{const ve={...z,model:z.model.trim()},Be=z.style==="custom"?z.customStyle.trim():z.style;try{const Je=await L4e({operation:e,intent:p.trim(),model:ve.model,style:Be,name:b.trim()||void 0,source:a});return{id:z.id,config:ve,task:Je}}catch(Je){return{id:z.id,config:ve,error:ds(Je,"创建候选方案失败")}}},Re=async()=>{if(!ue)return;T(!0),P(null);const z=O.map(Be=>({id:Be.id,config:Be}));w(z),S(O[0].id);const ve=await Promise.all(O.map(Se));w(ve)},Ee=async z=>{w(Be=>Be.map(Je=>Je.id===z.id?{...Je,error:void 0}:Je));const ve=await Se(z.config);w(Be=>Be.map(Je=>Je.id===z.id?ve:Je))},me=async()=>{if(!(!(H!=null&&H.task)||!A.trim()||H.task.state!=="ready")){M("refine"),P(null);try{const z=await wC({jobId:H.task.jobId,intent:A.trim(),expectedRevision:H.task.revision});w(ve=>ve.map(Be=>Be.id===H.id?{...Be,task:z,artifact:void 0}:Be)),N("")}catch(z){P(ds(z,"继续调整失败"))}finally{M("")}}},oe=async()=>{if(!(!(H!=null&&H.task)||!Yj(H.task))){M("refine"),P(null),w(z=>z.map(ve=>ve.id===H.id?{...ve,repairing:!0,repairMode:"manual",repairError:void 0}:ve));try{const z=await wC({jobId:H.task.jobId,intent:xq(H.task),expectedRevision:H.task.revision});w(ve=>ve.map(Be=>Be.id===H.id?{...Be,task:z,artifact:void 0,repairing:!1,repairMode:"manual",repairError:void 0}:Be))}catch(z){w(ve=>ve.map(Be=>Be.id===H.id?{...Be,repairing:!1,repairMode:void 0,repairError:ds(z,"再次修复格式错误失败")}:Be))}finally{M("")}}},Ne=async()=>{if(!(!(H!=null&&H.task)||H.task.state!=="ready"||$)){M("publish"),P(null);try{if(!Ae)throw new Error("请选择上传的 Skill Space");const z=H.artifact||await vC(H.task.jobId,H.task.revision),ve=(a==null?void 0:a.region)||Ae.region||"";if(!BD(ve))throw new Error("当前 Skill 地域不受支持");await Q4e({jobId:H.task.jobId,expectedRevision:H.task.revision,expectedArtifactSha256:z.sha256,disposition:e==="optimize"?"update-source":"create-new",skillSpaceIds:[Ae.id],projectName:(a==null?void 0:a.projectName)||Ae.projectName,region:ve,onProgress:Be=>j(Be.message)}),U(H.id),c()}catch(z){P(ds(z,"上传 Skill 失败"))}finally{M(""),j("")}}},Oe=async()=>{if(!(!(H!=null&&H.task)||H.task.state!=="ready")){M("download");try{const z=H.artifact||await vC(H.task.jobId,H.task.revision);await U4e(H.task.jobId,H.task.revision,z.sha256)}catch(z){P(ds(z,"下载失败"))}finally{M("")}}},Ve=async()=>{x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"})&&!window.confirm("离开后将停止并释放正在运行的 Dev Sandbox,确定离开吗?")||(await Promise.allSettled(x.flatMap(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="running"?[$4e({jobId:z.task.jobId,expectedRevision:z.task.revision})]:[]})),o())},We=e==="create"?"创建技能":`优化 ${(a==null?void 0:a.name)||"技能"}`,De=z=>{var ve;return((ve=u==null?void 0:u.models.find(Be=>Be.id===z))==null?void 0:ve.label)||z},mt=z=>z.config.style==="custom"?z.config.customStyle.trim()||"自定义风格":Nhe[z.config.style],at=z=>z.error||z.repairError?"失败":dlt(z),Rt=z=>!z.error&&!z.repairError&&(z.repairing||!z.task||z.task.state==="running"),qe=x.some(z=>{var ve;return((ve=z.task)==null?void 0:ve.state)==="ready"});return l.jsxs("section",{className:"skill-generation",children:[l.jsxs("header",{className:"skill-generation__header",children:[l.jsx("button",{type:"button",className:"skillcenter-back",onClick:()=>void Ve(),"aria-label":"返回技能空间",children:l.jsx(plt,{})}),l.jsxs("div",{children:[l.jsx("h1",{children:We}),l.jsx("p",{children:(n==null?void 0:n.name)||"主页技能生成"})]}),x.length>0?l.jsx("span",{className:"skill-generation__ttl",children:flt(H==null?void 0:H.task,X)}):null]}),k?l.jsxs("div",{className:"skill-generation__workspace",children:[l.jsx("div",{className:"skill-generation__candidate-tabs",role:"tablist","aria-label":"候选方案",children:x.map(z=>l.jsxs("button",{type:"button",role:"tab","aria-selected":(H==null?void 0:H.id)===z.id,className:(H==null?void 0:H.id)===z.id?"is-active":"",onClick:()=>S(z.id),children:[l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"风格"}),l.jsx("strong",{children:mt(z)})]}),l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"模型"}),l.jsx("strong",{children:De(z.config.model)})]}),l.jsxs("span",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"进度"}),l.jsxs("strong",{children:[Rt(z)?l.jsx(vq,{}):null,at(z)]})]})]},z.id))}),H?l.jsxs("div",{className:"skill-generation__candidate",children:[l.jsxs("section",{className:"skill-generation__activity",children:[l.jsx("header",{children:l.jsxs("div",{className:"skill-generation__candidate-summary",children:[l.jsxs("div",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"风格"}),l.jsx("strong",{children:mt(H)})]}),l.jsxs("div",{className:"skill-generation__summary-row",children:[l.jsx("span",{children:"模型"}),l.jsx("strong",{children:De(H.config.model)})]}),l.jsxs("div",{className:"skill-generation__summary-row","aria-live":"polite",children:[l.jsx("span",{children:"进度"}),l.jsxs("strong",{children:[Rt(H)?l.jsx(vq,{}):null,Rt(H)?l.jsx(oi,{children:at(H)}):at(H)]})]})]})}),H.task?l.jsx(GHe,{activities:H.task.activities}):null,H.pollError?l.jsx("div",{className:"skill-inline-notice",children:l.jsx(ho,{error:H.pollError})}):null,H.repairError?l.jsx("div",{className:"skill-inline-notice",children:l.jsx(ho,{error:H.repairError})}):null,H.error?l.jsxs("div",{className:"skill-inline-error",children:[l.jsx(ho,{error:H.error}),l.jsx("button",{type:"button",onClick:()=>void Ee(H),children:"重试此方案"})]}):null,(W=H.task)!=null&&W.validation&&!H.task.validation.valid&&!H.repairing&&H.task.state==="failed"?l.jsxs("div",{className:"skill-validation-errors",children:[l.jsx("strong",{children:"格式校验未通过"}),H.task.validation.errors.map(z=>l.jsx("p",{children:z},z)),Yj(H.task)?l.jsx("button",{type:"button",disabled:!!C,onClick:()=>void oe(),children:"再次修复"}):null]}):null]}),l.jsxs("section",{className:"skill-generation__files",children:[l.jsxs("header",{children:[l.jsx("h2",{children:"文件"}),((K=H.task)==null?void 0:K.state)==="ready"?l.jsx("button",{type:"button",onClick:()=>void Oe(),disabled:!!C,children:"下载 ZIP"}):null]}),H.artifact?l.jsx(_he,{files:H.artifact.files}):l.jsx("div",{className:"skill-generation__files-empty",children:((ae=H.task)==null?void 0:ae.state)==="ready"?"正在读取文件…":"生成过程中会在这里显示完整文件树"})]}),((pe=H.task)==null?void 0:pe.state)==="ready"?l.jsxs("div",{className:"skill-generation__ready-actions",children:[re?l.jsx("div",{className:"skill-generation__publish-target",children:l.jsx(FC,{label:"上传到 Skill Space",value:B,options:J,onChange:I,disabled:r,placeholder:r?"正在加载 Skill Space":"选择 Skill Space"})}):null,l.jsxs("footer",{className:"skill-generation__followup",children:[l.jsx("textarea",{value:A,onChange:z=>N(z.target.value),placeholder:"继续调整这个候选方案"}),l.jsx("button",{type:"button",className:"skill-button",disabled:!A.trim()||!!C,onClick:()=>void me(),children:"继续调整"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!!C||!!$||!Ae,onClick:()=>void Ne(),children:C==="publish"?Q||"上传中…":e==="optimize"?"覆盖原 Skill":re?"上传到 Skill Space":"上传到当前空间"})]})]}):null,L?l.jsx("div",{className:"skill-inline-error skill-generation__action-error",children:l.jsx(ho,{error:L})}):null]}):null,!qe&&x.every(z=>z.error)?l.jsx("div",{className:"skill-inline-error",children:"所有方案均创建失败,可分别重试。"}):null]}):l.jsxs("div",{className:"skill-generation__setup",children:[l.jsx("div",{className:"skill-generation__section-head is-basic",children:l.jsx("div",{children:l.jsx("strong",{children:"基本信息"})})}),l.jsxs("label",{children:[l.jsxs("span",{children:["目标",l.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"})]}),l.jsx("textarea",{required:!0,value:p,onChange:z=>g(z.target.value),placeholder:e==="create"?"描述希望这个 Skill 完成什么任务":"描述希望如何优化当前 Skill"})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Skill 名称"}),l.jsx("input",{value:b,onChange:z=>y(z.target.value),placeholder:"留空时自动生成","aria-invalid":!!ie,"aria-describedby":"skill-name-help"}),ie?l.jsx("span",{id:"skill-name-help",className:"skill-generation__field-error",role:"alert",children:ie}):l.jsx("span",{id:"skill-name-help",className:"skill-generation__field-help",children:"仅支持小写字母、数字和连字符;留空时自动生成。"})]}),l.jsx("div",{className:"skill-generation__section-head",children:l.jsxs("div",{children:[l.jsx("strong",{children:e==="create"?"生成方案":"优化方案"}),l.jsx("span",{children:e==="create"?"按不同方案并行生成多个技能,您可以选择最佳结果":"按不同方案并行优化当前技能,您可以选择最佳结果"})]})}),l.jsxs("div",{className:"skill-generation__groups",children:[O.map((z,ve)=>l.jsxs("article",{className:"skill-generation__group",children:[l.jsxs("header",{children:[l.jsxs("strong",{children:["方案 ",ve+1]}),O.length>1?l.jsx("button",{type:"button",onClick:()=>v(Be=>Be.filter(Je=>Je.id!==z.id)),children:"移除"}):null]}),l.jsx(FC,{label:"模型",required:!0,value:z.model,options:(u==null?void 0:u.models.map(Be=>({value:Be.id,label:Be.label})))||[],onChange:Be=>ye(z.id,{model:Be}),allowCustom:!0,placeholder:"选择或输入模型 ID",error:wq(z.model.trim())}),l.jsx(FC,{label:"风格",required:!0,value:z.style,options:clt,onChange:Be=>ye(z.id,{style:Be})}),z.style==="custom"?l.jsxs("label",{children:[l.jsx("span",{children:"自定义风格"}),l.jsx("textarea",{value:z.customStyle,onChange:Be=>ye(z.id,{customStyle:Be.target.value}),placeholder:"描述表达方式、严谨程度或输出偏好"})]}):null]},z.id)),u&&O.lengthv(z=>[...z,yq(z.length,u)]),children:"添加配置"}):null]}),f?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:f})}):null,u&&!u.enabled?l.jsx("div",{className:"skill-inline-notice",children:"管理员未配置"}):null,l.jsx("div",{className:"skill-generation__setup-actions",children:l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!ue,onClick:()=>void Re(),children:"生成"})})]})]})}function aQ({title:e,children:t,onClose:n,className:i=""}){const r=m.useRef(null);return m.useEffect(()=>{var a;(a=r.current)==null||a.focus();const s=o=>o.key==="Escape"&&n();return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),l.jsx("div",{className:"skill-dialog-backdrop",onMouseDown:n,children:l.jsxs("section",{className:`skill-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-label":e,onMouseDown:s=>s.stopPropagation(),children:[l.jsxs("header",{children:[l.jsx("h2",{children:e}),l.jsx("button",{ref:r,type:"button",onClick:n,"aria-label":"关闭",children:"关闭"})]}),t]})})}function glt({region:e,onClose:t,onCreated:n}){const[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null),f=async()=>{if(i.trim()){c(!0),d(null);try{n(await _Pe({name:i.trim(),description:s.trim()||void 0,region:e}))}catch(h){d(ds(h,"创建 Skill 空间失败"))}finally{c(!1)}}};return l.jsxs(aQ,{title:"新建 Skill 空间",onClose:t,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:i,maxLength:128,onChange:h=>r(h.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:s,maxLength:1024,onChange:h=>a(h.target.value)})]}),u?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:u})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!i.trim()||o,onClick:()=>void f(),children:o?"创建中…":"创建"})]})]})}function blt({space:e,region:t,onClose:n,onUpdated:i}){const[r,s]=m.useState(e.name),[a,o]=m.useState(e.description||""),[c,u]=m.useState(!1),[d,f]=m.useState(null),h=async()=>{if(r.trim()){u(!0),f(null);try{const p=await APe({spaceId:e.id,name:r.trim(),description:a.trim()||void 0,region:t});i({...e,...p,skillCount:e.skillCount})}catch(p){f(ds(p,"更新 Skill 空间失败"))}finally{u(!1)}}};return l.jsxs(aQ,{title:"编辑 Skill 空间",onClose:n,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsxs("label",{children:[l.jsx("span",{children:"名称"}),l.jsx("input",{autoFocus:!0,value:r,maxLength:128,onChange:p=>s(p.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述(可选)"}),l.jsx("textarea",{value:a,maxLength:1024,onChange:p=>o(p.target.value)})]}),d?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:d})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!r.trim()||c,onClick:()=>void h(),children:c?"保存中…":"保存"})]})]})}function Olt({space:e,region:t,onClose:n,onUploaded:i}){const[r,s]=m.useState(null),[a,o]=m.useState(null),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[h,p]=m.useState(null),[g,b]=m.useState(!1),y=m.useRef(0),O=m.useRef(null),v=async w=>{const E=y.current+1;if(y.current=E,s(w),o(null),p(null),u(!!w),!!w)try{const S=await jPe(w);y.current===E&&o({name:S.name,fileCount:S.files.length})}catch(S){y.current===E&&p(ds(S,"Skill ZIP 格式校验失败"))}finally{y.current===E&&u(!1)}},x=async()=>{if(!(!r||!a)){f(!0),p(null);try{await CPe({spaceId:e.id,region:t,project:e.projectName,file:r}),i()}catch(w){p(ds(w,"上传 Skill 失败"))}finally{f(!1)}}};return l.jsxs(aQ,{title:`上传到 ${e.name}`,className:"skill-upload-dialog",onClose:n,children:[l.jsxs("div",{className:"skill-dialog__body",children:[l.jsx("input",{ref:O,className:"skill-upload-dialog__input",type:"file",accept:".zip,application/zip",onChange:w=>{var E;return void v(((E=w.target.files)==null?void 0:E[0])||null)}}),l.jsxs("button",{type:"button",className:`skill-upload-dropzone${g?" is-dragging":""}`,onClick:()=>{var w;return(w=O.current)==null?void 0:w.click()},onDragEnter:w=>{w.preventDefault(),b(!0)},onDragOver:w=>{w.preventDefault(),w.dataTransfer.dropEffect="copy",b(!0)},onDragLeave:w=>{w.currentTarget.contains(w.relatedTarget)||b(!1)},onDrop:w=>{var E;w.preventDefault(),b(!1),v(((E=w.dataTransfer.files)==null?void 0:E[0])||null)},children:[l.jsx("strong",{children:r?r.name:"拖拽 Skill ZIP 到这里"}),l.jsx("span",{children:r?`${r.size.toLocaleString()} 字节`:"或点击选择本地文件"})]}),l.jsx("p",{children:"ZIP 根目录需要包含 SKILL.md,也可以只包含一层包装目录。选择后仅检查格式,不会自动上传。"}),c?l.jsx("div",{className:"skill-inline-notice",children:"正在检查文件格式…"}):null,a?l.jsxs("div",{className:"skill-inline-notice",children:["格式检查通过:",a.name,",共 ",a.fileCount," 个文件"]}):null,h?l.jsx("div",{className:"skill-inline-error",children:l.jsx(ho,{error:h})}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"skill-button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"skill-button skill-button--primary",disabled:!r||!a||c||d,onClick:()=>void x(),children:d?"上传中…":"上传"})]})]})}const ylt=12,Sq=12;function RT({disabled:e,placement:t="top",children:n}){const i=m.useId();return l.jsxs("span",{className:`skillcenter-disabled-action${e?" is-disabled":""} is-${t}`,tabIndex:e?0:void 0,"aria-describedby":e?i:void 0,children:[n,e?l.jsx("span",{id:i,className:"skillcenter-disabled-tooltip",role:"tooltip",children:"管理员未配置 Dev Sandbox"}):null]})}const xlt={active:"可用",available:"可用",creating:"创建中",disabled:"已停用",enabled:"已启用",failed:"异常",inactive:"未启用",pending:"等待中",published:"已发布",ready:"就绪",released:"已发布",running:"运行中",success:"正常",unavailable:"不可用",unreleased:"未发布",updating:"更新中"};function DL(e){return xlt[(e||"").trim().toLowerCase()]||"未知"}function Eq(e){const t=(e||"").toLowerCase();return["active","available","enabled","published","ready","released","success"].includes(t)||t==="running"?"is-positive":["creating","pending","updating"].includes(t)?"is-progress":["failed","unavailable"].includes(t)?"is-danger":"is-muted"}function kq(e){if(!e)return"";const t=e.trim(),n=Number(t),i=/^\d+(?:\.\d+)?$/.test(t)?new Date(n<1e12?n*1e3:n):new Date(t);return Number.isNaN(i.getTime())?e:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(i)}function Tq(e){if(!e)return 0;const t=e.trim(),n=Number(t),i=/^\d+(?:\.\d+)?$/.test(t)?new Date(n<1e12?n*1e3:n):new Date(t);return Number.isNaN(i.getTime())?0:i.getTime()}function Sl(e){return`${e.region||"default"}:${e.projectName||"default"}:${e.id}`}function vlt(e,t){const n=new Map(e.map(i=>[Sl(i),i]));for(const i of t)n.set(Sl(i),i);return[...n.values()].sort((i,r)=>Tq(r.updatedAt)-Tq(i.updatedAt))}function wlt(e){const t=e.replace(/\r\n/g,` `);if(!t.startsWith(`--- `))return e;const n=t.indexOf(` --- -`,4);return n>=0?t.slice(n+5).trimStart():e}function Nhe(e){const t=(e||"").trim();return!t||[">",">-","|","|-"].includes(t)?"暂无描述":t}function wlt(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m7.5 7.5 9 9m0-9-9 9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function _q(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Aq(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}function Slt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nq({direction:e}){return l.jsx("svg",{className:"icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:e==="left"?"m11.7 5.5-4.2 4.5 4.2 4.5":"m8.3 5.5 4.2 4.5-4.2 4.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function Che(){return l.jsx("span",{className:"skillcenter-loading-mark","aria-hidden":!0})}function Elt({page:e,total:t,pageSize:n,onPage:i}){const r=Math.max(1,Math.ceil(t/n));return l.jsxs("footer",{className:"skillcenter-pager",children:[l.jsxs("span",{children:["共 ",t," 项"]}),l.jsxs("div",{className:"skillcenter-pager-actions",children:[l.jsx("button",{type:"button",onClick:()=>i(e-1),disabled:e<=1,"aria-label":"上一页",children:l.jsx(Nq,{direction:"left"})}),l.jsxs("span",{children:[e," / ",r]}),l.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:e>=r,"aria-label":"下一页",children:l.jsx(Nq,{direction:"right"})})]})]})}function klt({children:e}){return l.jsx("div",{className:"skillcenter-empty",children:e})}function Wj({kind:e,title:t,description:n,error:i,action:r}){return l.jsx("div",{className:`skillcenter-page-state is-${e}`,role:e==="error"?"alert":"status",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Title,{children:t}),n?l.jsx(Oi.Description,{children:n}):null,i?l.jsx(ho,{error:i}):null,r?l.jsx(Oi.ActionRow,{children:l.jsx(zu,{color:"secondary",size:"lg",onClick:r.onClick,children:r.label})}):null]})})}function Cq({errors:e,cloudProvider:t,fullPage:n=!1,onRetry:i}){return l.jsxs("div",{className:`skillcenter-space-errors${n?" is-full-page":""}`,role:"alert",children:[l.jsxs("div",{className:"skillcenter-space-errors__content",children:[l.jsx("strong",{children:n?"无法加载技能空间":"部分技能空间加载失败"}),e.map(({region:r,error:s})=>l.jsxs("section",{children:[l.jsx("span",{children:td(r,t)}),l.jsx(ho,{error:s})]},r))]}),l.jsx("button",{type:"button",onClick:i,children:"重新加载"})]})}function Tlt({skill:e,space:t,region:n,cloudProvider:i,detail:r,files:s,loading:a,error:o,canOptimize:c,onOptimize:u,onDownload:d,onClose:f}){return m.useEffect(()=>{const h=p=>{p.key==="Escape"&&f()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f]),l.jsx("div",{className:"skill-detail-backdrop",role:"presentation",onMouseDown:f,children:l.jsxs("section",{className:"skill-detail-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-detail-title",onMouseDown:h=>h.stopPropagation(),children:[l.jsxs("header",{className:"skill-detail-head",children:[l.jsx("div",{className:"skill-detail-heading",children:l.jsxs("div",{children:[l.jsx("h2",{id:"skill-detail-title",children:(r==null?void 0:r.name)||e.skillName}),l.jsx("p",{children:Nhe((r==null?void 0:r.description)||e.skillDescription)})]})}),l.jsxs("div",{className:"skill-detail-actions",children:[l.jsx("button",{type:"button",onClick:d,disabled:s.length===0,children:"下载 ZIP"}),l.jsx(RT,{disabled:!c,placement:"bottom",children:l.jsx("button",{type:"button",onClick:u,disabled:!c,children:"优化"})}),l.jsx("button",{type:"button",className:"skill-detail-close",onClick:f,"aria-label":"关闭技能详情",children:l.jsx(wlt,{})})]})]}),l.jsxs("dl",{className:"skill-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"技能 ID"}),l.jsx("dd",{title:e.skillId,children:e.skillId})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"版本"}),l.jsx("dd",{children:(r==null?void 0:r.version)||e.version||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:DL(e.skillStatus)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能空间"}),l.jsx("dd",{title:t.name,children:t.name})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"地域"}),l.jsx("dd",{children:td(n,i)})]})]}),l.jsxs("div",{className:"skill-detail-content skill-detail-content--files",children:[l.jsx("div",{className:"skill-detail-content-title",children:"完整文件"}),a?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(Che,{}),"正在读取技能内容…"]}):o?l.jsx("div",{className:"skillcenter-error",children:l.jsx(ho,{error:o})}):s.length>0?l.jsx(The,{files:s.map(h=>h.path.endsWith("SKILL.md")&&h.content?{...h,content:vlt(h.content)}:h)}):l.jsx(klt,{children:"该技能暂无 SKILL.md 内容"})]})]})})}function _lt({space:e,canUseSandbox:t,onUpload:n,onSandbox:i,onClose:r}){return m.useEffect(()=>{const s=a=>{a.key==="Escape"&&r()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[r]),l.jsx("div",{className:"skill-dialog-backdrop",role:"presentation",onMouseDown:r,children:l.jsxs("section",{className:"skill-dialog skill-add-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-add-dialog-title",onMouseDown:s=>s.stopPropagation(),children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("h2",{id:"skill-add-dialog-title",children:"添加技能"}),l.jsx("p",{title:e.name,children:e.name})]}),l.jsx("button",{type:"button",onClick:r,children:"取消"})]}),l.jsxs("div",{className:"skill-add-dialog__options",children:[l.jsxs("button",{type:"button",onClick:n,children:[l.jsx("strong",{children:"本地上传"}),l.jsx("span",{children:"选择 ZIP 文件,校验通过后上传到技能空间"})]}),l.jsx(RT,{disabled:!t,placement:"inside",children:l.jsxs("button",{type:"button",disabled:!t,onClick:i,children:[l.jsx("strong",{children:"自动创建"}),l.jsx("span",{children:"选择模型和风格,通过对话生成技能"})]})})]})]})})}function Alt({cloudProvider:e="volcengine",active:t=!0,activationRevision:n=0,initialWorkspace:i=null,onInitialWorkspaceConsumed:r,onPageTitleChange:s}){var Ft;const a=m.useMemo(()=>v1(e).map(Ce=>Ce.value),[e]),[o,c]=m.useState([]),[u,d]=m.useState({}),[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState((i==null?void 0:i.space)??null),[O,v]=m.useState([]),[x,w]=m.useState(1),[E,S]=m.useState(0),[k,T]=m.useState(!1),[A,N]=m.useState(null),[C,M]=m.useState(""),[L,P]=m.useState(null),[Q,j]=m.useState(null),[$,U]=m.useState([]),[B,I]=m.useState(!1),[X,q]=m.useState(null),[D,H]=m.useState(null),[re,fe]=m.useState(!1),[Ae,J]=m.useState(null),[ie,ue]=m.useState(null),[ye,Se]=m.useState(null),[Re,Ee]=m.useState(0),[me,oe]=m.useState(0),[Ne,Oe]=m.useState(""),[Ve,We]=m.useState(""),[De,mt]=m.useState(null),[at,Rt]=m.useState(i),qe=m.useRef(0),W=m.useRef(0),K=m.useRef(!1),ae=m.useRef(null),pe=m.useRef(null),z=m.useRef(null),ve=m.useDeferredValue(p),Be=m.useDeferredValue(C),kt=(at&&(b||at.selectPublishSpace)?at.operation==="create"?"创建技能":`优化 ${((Ft=at.source)==null?void 0:Ft.name)||"技能"}`:"")||(b==null?void 0:b.name)||"技能库";m.useEffect(()=>{t&&(s==null||s(kt))},[t,s,kt]),m.useEffect(()=>{i&&(r==null||r())},[i,r]);const Mt=m.useMemo(()=>{const Ce=ve.trim().toLocaleLowerCase();return Ce?o.filter(et=>`${et.name} ${et.description||""} ${et.projectName||""}`.toLocaleLowerCase().includes(Ce)):o},[ve,o]),Tt=m.useMemo(()=>{const Ce=Be.trim().toLocaleLowerCase();return Ce?O.filter(et=>`${et.skillName} ${et.skillDescription||""}`.toLocaleLowerCase().includes(Ce)):O},[Be,O]),dt=(b==null?void 0:b.region)||Qi(e),ge=m.useMemo(()=>a.flatMap(Ce=>{var wt;const et=(wt=u[Ce])==null?void 0:wt.error;return et?[{region:Ce,error:et}]:[]}),[u,a]),lt=a.some(Ce=>{const et=u[Ce];return!!(et&&!et.done&&!et.error)}),Ge=ge.length===a.length;m.useEffect(()=>{const Ce=new AbortController;return aA(Ce.signal).then(H).catch(()=>H({enabled:!1,reason:"管理员未配置",operations:["create","optimize"],models:[],styles:{}})),()=>Ce.abort()},[]);const vt=m.useCallback(async(Ce,et)=>{var st;if(K.current||Ce.length===0)return;K.current=!0,h(!0),et&&((st=ae.current)==null||st.abort(),c([]),d(Object.fromEntries(Ce.map(({region:At})=>[At,{nextPage:1,loadedCount:0,done:!1,error:null}]))));const wt=new AbortController;ae.current=wt;const yn=++W.current,on=await Promise.allSettled(Ce.map(async({region:At,page:Ut})=>({region:At,page:Ut,result:await kPe({region:At,page:Ut,pageSize:Olt,signal:wt.signal})})));if(W.current!==yn)return;const hi=on.map((At,Ut)=>{const kn=Ce[Ut];return At.status==="rejected"?{request:kn,error:ds(At.reason,"读取技能空间失败,请稍后重试"),items:[],totalCount:0}:{request:kn,error:null,items:(At.value.result.items||[]).map(wn=>({...wn,region:wn.region||At.value.region})),totalCount:At.value.result.totalCount||0}}),Pe=hi.flatMap(At=>At.items);d(At=>{const Ut={...At};return hi.forEach(({request:kn,error:wn,items:Ai,totalCount:Gn})=>{const xn=Ut[kn.region]||{nextPage:kn.page,loadedCount:0,done:!1,error:null};if(wn){Ut[kn.region]={...xn,error:wn};return}const de=xn.loadedCount+Ai.length;Ut[kn.region]={nextPage:kn.page+1,loadedCount:de,done:Ai.length===0||de>=Gn,error:null}}),Ut}),c(At=>xlt(et?[]:At,Pe)),y(At=>At&&(Pe.find(Ut=>Sl(Ut)===Sl(At))||At)),K.current=!1,h(!1)},[]),_t=m.useCallback(()=>{if(K.current)return;const Ce=a.flatMap(et=>{const wt=u[et];return wt&&!wt.done&&!wt.error?[{region:et,page:wt.nextPage}]:[]});vt(Ce,!1)},[vt,u,a]);m.useEffect(()=>{Ie(),y(null),v([]),w(1)},[e]),m.useEffect(()=>{if(t)return vt(a.map(Ce=>({region:Ce,page:1})),!0),()=>{var Ce;W.current+=1,(Ce=ae.current)==null||Ce.abort(),K.current=!1}},[t,n,vt,a,Re]),m.useEffect(()=>{const Ce=z.current,et=pe.current;if(!Ce||!et||!lt||f)return;const wt=new IntersectionObserver(([yn])=>{yn.isIntersecting&&_t()},{root:et,rootMargin:"240px 0px",threshold:.01});return wt.observe(Ce),()=>wt.disconnect()},[lt,_t,f]);const Bt=()=>{const Ce=pe.current;!Ce||!lt||f||Ce.scrollHeight-Ce.scrollTop-Ce.clientHeight<=240&&_t()};m.useEffect(()=>{if(!b){v([]),S(0);return}let Ce=!0;return T(!0),N(null),PPe(b.id,{region:dt,page:x,pageSize:Sq,project:b.projectName}).then(et=>{Ce&&(v(et.items||[]),S(et.totalCount||0))}).catch(et=>{Ce&&(v([]),S(0),N(ds(et,"读取技能失败,请稍后重试")))}).finally(()=>{Ce&&T(!1)}),()=>{Ce=!1}},[dt,b,x,me]);const je=Ce=>{Ie(),y(Ce),w(1),M("")},Ze=()=>{Ie(),y(null),v([]),S(0),w(1),M(""),mt(null)},Ie=()=>{qe.current+=1,P(null),j(null),U([]),q(null),I(!1)},Wt=async Ce=>{if(!b)return;const et=qe.current+1;qe.current=et,P(Ce),j(null),q(null),I(!0);try{const[wt,yn]=await Promise.all([MPe(b.id,Ce.skillId,Ce.version,dt,b.projectName),RPe({spaceId:b.id,skillId:Ce.skillId,version:Ce.version,region:dt})]);qe.current===et&&(j(wt),U(yn))}catch(wt){qe.current===et&&q(ds(wt,"读取技能详情失败,请稍后重试"))}finally{qe.current===et&&I(!1)}},dn=Ce=>{if(b)return{kind:"skill-center",skillId:Ce.skillId,version:Ce.version,region:dt,projectName:b.projectName,skillSpaceId:b.id,skillSpaceName:b.name,name:Ce.skillName,description:Ce.skillDescription}},Qt=Ce=>{const et=dn(Ce);!et||!(D!=null&&D.enabled)||(Ie(),Rt({operation:"optimize",source:et}))},Yt=async Ce=>{if(!(!b||!window.confirm(`确定删除整个 Skill“${Ce.skillName}”吗?此操作会影响所有引用它的空间。`))){Oe(Ce.skillId),mt(null);try{await jPe({spaceId:b.id,skillId:Ce.skillId,region:dt}),oe(et=>et+1),Ee(et=>et+1)}catch(et){mt(ds(et,"删除 Skill 失败"))}finally{Oe("")}}},Jt=async Ce=>{if(!window.confirm(`确定删除 Skill 空间“${Ce.name}”吗?请先确认空间中的技能已删除。`))return;const et=Sl(Ce);We(et),mt(null);try{await APe({spaceId:Ce.id,region:Ce.region||Qi(e)}),b&&Sl(b)===et&&Ze(),Ee(wt=>wt+1)}catch(wt){mt(ds(wt,"删除 Skill 空间失败"))}finally{We("")}};return at&&(b||at.selectPublishSpace)?l.jsx(plt,{operation:at.operation,cloudProvider:e,space:b??void 0,availableSpaces:o,spacesLoading:f,initialIntent:at.initialIntent,source:at.source,onBack:()=>Rt(null),onPublished:()=>{oe(Ce=>Ce+1),Ee(Ce=>Ce+1)}}):l.jsxs("section",{className:`skillcenter${b?" is-space":" my-agents-page"}`,children:[b?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:"skillcenter-page-header",children:[l.jsxs("div",{className:"skillcenter-page-heading skillcenter-page-heading--back",children:[l.jsx("button",{type:"button",className:"skillcenter-back",onClick:Ze,"aria-label":"返回技能空间",children:l.jsx(Slt,{})}),l.jsxs("div",{children:[l.jsx("h1",{title:b.name,children:b.name}),l.jsx("p",{children:b.description||"管理空间中的技能并创建新的版本"})]})]}),l.jsxs("label",{className:"skillcenter-search",children:[l.jsx(_q,{}),l.jsx("input",{type:"search","aria-label":"搜索技能",value:C,onChange:Ce=>M(Ce.target.value),placeholder:"搜索技能"})]})]}),l.jsxs("div",{className:"skillcenter-toolbar",children:[l.jsxs("div",{className:"skillcenter-detail-facts",children:[l.jsxs("div",{children:[l.jsx("span",{children:"技能数量"}),l.jsx("strong",{children:E})]}),l.jsxs("div",{children:[l.jsx("span",{children:"更新时间"}),l.jsx("strong",{children:b.updatedAt?kq(b.updatedAt):"—"})]})]}),l.jsxs("div",{className:"skillcenter-toolbar-actions",children:[l.jsx("button",{type:"button",className:"skillcenter-secondary-action",onClick:()=>Se(b),children:"本地上传"}),l.jsx(RT,{disabled:!(D!=null&&D.enabled),children:l.jsxs("button",{type:"button",className:"skillcenter-primary-action",disabled:!(D!=null&&D.enabled),onClick:()=>Rt({operation:"create"}),children:[l.jsx(Aq,{}),l.jsx("span",{children:"创建技能"})]})})]})]}),De?l.jsx("div",{className:"skillcenter-inline-error",role:"alert",children:l.jsx(ho,{error:De})}):null,l.jsxs("section",{className:"skillcenter-results","aria-label":`${b.name}中的技能`,children:[k&&O.length===0?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(Che,{}),"正在加载技能"]}):A&&O.length===0?l.jsx(Wj,{kind:"error",title:"无法加载技能",error:A,action:{label:"重新加载",onClick:()=>oe(Ce=>Ce+1)}}):Tt.length===0?l.jsx(Wj,{kind:"empty",title:C.trim()?"没有匹配的技能":"暂无技能",description:C.trim()?"请尝试搜索其他名称":"本地上传 Skill,或自动创建",action:C.trim()?void 0:{label:"本地上传",onClick:()=>Se(b)}}):l.jsx("div",{className:"skillcenter-table-wrap",children:l.jsxs("table",{className:"skillcenter-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"技能"}),l.jsx("th",{scope:"col",children:"状态"}),l.jsx("th",{scope:"col",className:"skillcenter-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:Tt.map(Ce=>l.jsxs("tr",{children:[l.jsx("td",{className:"skillcenter-table__skill",children:l.jsxs("button",{type:"button",onClick:()=>void Wt(Ce),children:[l.jsxs("span",{className:"skillcenter-table__title-row",children:[l.jsx("strong",{title:Ce.skillName,children:Ce.skillName}),Ce.version?l.jsx("span",{className:"skillcenter-table__version-badge",children:Ce.version}):null]}),l.jsx("span",{className:"skillcenter-table__description",children:Nhe(Ce.skillDescription)})]})}),l.jsx("td",{children:l.jsx("span",{className:`skillcenter-status ${Eq(Ce.skillStatus)}`,children:DL(Ce.skillStatus)})}),l.jsx("td",{children:l.jsxs("div",{className:"skillcenter-table__actions",children:[l.jsx("button",{type:"button",onClick:()=>void Wt(Ce),children:"查看"}),l.jsx(RT,{disabled:!(D!=null&&D.enabled),children:l.jsx("button",{type:"button",disabled:!(D!=null&&D.enabled),onClick:()=>Qt(Ce),children:"优化"})}),l.jsx("button",{type:"button",className:"is-danger",disabled:Ne===Ce.skillId,onClick:()=>void Yt(Ce),children:Ne===Ce.skillId?"删除中…":"删除"})]})})]},`${Ce.skillId}:${Ce.version}`))})]})}),!C.trim()&&!k&&!A&&E>0?l.jsx(Elt,{page:x,total:E,pageSize:Sq,onPage:w}):null]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"my-agent-type-bar skillcenter-list-toolbar library-resource-toolbar",children:[l.jsxs("button",{type:"button",className:"my-agent-create-primary",onClick:()=>fe(!0),children:[l.jsx(Aq,{}),l.jsx("span",{children:"新建空间"})]}),l.jsxs("label",{className:"my-agent-search",children:[l.jsx(_q,{}),l.jsx("input",{type:"search","aria-label":"搜索技能空间",value:p,onChange:Ce=>g(Ce.target.value),placeholder:"搜索技能空间"})]})]}),De?l.jsx("div",{className:"skillcenter-inline-error",role:"alert",children:l.jsx(ho,{error:De})}):null,l.jsxs("section",{className:"my-agent-results",ref:pe,"aria-label":"技能空间列表",onScroll:Bt,children:[ge.length>0&&!Ge?l.jsx(Cq,{errors:ge,cloudProvider:e,onRetry:()=>Ee(Ce=>Ce+1)}):null,f&&o.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载技能空间"})]}):Ge&&o.length===0?l.jsx(Cq,{errors:ge,cloudProvider:e,fullPage:!0,onRetry:()=>Ee(Ce=>Ce+1)}):Mt.length===0?l.jsx(Wj,{kind:"empty",title:p.trim()?"没有匹配的技能空间":"暂无技能空间",description:p.trim()?"请尝试搜索其他名称":"新建一个空间,开始管理和创建技能",action:p.trim()?void 0:{label:"新建空间",onClick:()=>fe(!0)}}):l.jsx(l.Fragment,{children:l.jsx("div",{className:"my-agent-grid",children:Mt.map(Ce=>{const et=Sl(Ce);return l.jsx(hse,{className:"skillcenter-space-card",title:Ce.name,status:l.jsx("span",{className:`skillcenter-status ${Eq(Ce.status)}`,children:DL(Ce.status)}),description:Ce.description||"暂无描述",metadata:[{label:"技能数量",value:Ce.skillCount??0},{label:"更新时间",value:Ce.updatedAt?kq(Ce.updatedAt):"—"}],secondaryAction:{label:"添加技能",onClick:()=>ue(Ce)},primaryAction:{label:"查看详情",onClick:()=>je(Ce)},menuLabel:`更多空间操作:${Ce.name}`,menuAriaLabel:`${Ce.name}空间操作`,menuActions:[{label:"编辑空间",onClick:()=>J(Ce)},{label:"删除空间",danger:!0,disabled:Ve===et,onClick:()=>void Jt(Ce)}]},et)})})}),!Ge&&o.length>0?l.jsx("div",{className:"my-agent-load-more",ref:z,"aria-live":"polite",children:f?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多技能空间"})]}):lt?l.jsx("span",{children:"继续下滑加载更多"}):ge.length>0?l.jsx("span",{children:"部分技能空间加载失败"}):l.jsx("span",{children:"已加载全部技能空间"})}):null]})]}),L&&b&&l.jsx(Tlt,{skill:L,space:b,region:dt,cloudProvider:e,detail:Q,files:$,loading:B,error:X,canOptimize:(D==null?void 0:D.enabled)===!0,onOptimize:()=>Qt(L),onDownload:()=>void IPe({spaceId:b.id,skillId:L.skillId,version:L.version,region:dt,fallbackName:L.skillName}).catch(Ce=>q(ds(Ce,"下载 Skill 失败"))),onClose:Ie}),re?l.jsx(mlt,{region:Qi(e),onClose:()=>fe(!1),onCreated:Ce=>{fe(!1),Ee(et=>et+1),y({...Ce,region:Ce.region||Qi(e)})}}):null,Ae?l.jsx(glt,{space:Ae,region:Ae.region||Qi(e),onClose:()=>J(null),onUpdated:Ce=>{const et={...Ce,region:Ce.region||Ae.region||Qi(e)};J(null),y(wt=>wt&&Sl(wt)===Sl(et)?et:wt),c(wt=>wt.map(yn=>Sl(yn)===Sl(et)?et:yn)),Ee(wt=>wt+1)}}):null,ie?l.jsx(_lt,{space:ie,canUseSandbox:(D==null?void 0:D.enabled)===!0,onClose:()=>ue(null),onUpload:()=>{Se(ie),ue(null)},onSandbox:()=>{const Ce=ie;ue(null),je(Ce),Rt({operation:"create"})}}):null,ye?l.jsx(blt,{space:ye,region:ye.region||Qi(e),onClose:()=>Se(null),onUploaded:()=>{Se(null),oe(Ce=>Ce+1),Ee(Ce=>Ce+1)}}):null]})}const mh=[{id:"skills",label:"技能库"},{id:"knowledge",label:"知识库"},{id:"artifacts",label:"产物"}];function Nlt({cloudProvider:e,activeTab:t,onTabChange:n,onPageTitleChange:i,skillInitialWorkspace:r=null,onSkillInitialWorkspaceConsumed:s,artifactSources:a=[],artifactUserId:o="",onArtifactActivate:c,onArtifactSourceOpen:u}){const[d,f]=m.useState("技能库"),[h,p]=m.useState(()=>new Set(["skills",t])),[g,b]=m.useState({skills:0,knowledge:0,artifacts:0}),y=m.useRef(c),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(""),k=m.useMemo(()=>{const L=dMe(a);return{key:JSON.stringify(L),candidates:L}},[a]),T=m.useRef(k);T.current.key!==k.key&&(T.current=k);const A=T.current.candidates;m.useEffect(()=>{y.current=c},[c]),m.useEffect(()=>{p(L=>{if(L.has(t))return L;const P=new Set(L);return P.add(t),P})},[t]),m.useEffect(()=>{var P;const L=t==="skills"?d:((P=mh.find(Q=>Q.id===t))==null?void 0:P.label)||"库";i==null||i(L)},[t,i,d]),m.useEffect(()=>{var L;t==="artifacts"&&((L=y.current)==null||L.call(y))},[t,g.artifacts]);const N=m.useCallback(async()=>{w(!0),S("");try{v(await xMe(A))}catch(L){S(L instanceof Error?L.message:String(L))}finally{w(!1)}},[A]);m.useEffect(()=>{t==="artifacts"&&N()},[t,g.artifacts,N]);const C=L=>{p(P=>{if(P.has(L))return P;const Q=new Set(P);return Q.add(L),Q}),b(P=>({...P,[L]:P[L]+1})),n(L)},M=(L,P)=>{var U;if(!["ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;L.preventDefault();const Q=mh.findIndex(B=>B.id===P),j=L.key==="Home"?0:L.key==="End"?mh.length-1:(Q+(L.key==="ArrowRight"?1:-1)+mh.length)%mh.length,$=mh[j];C($.id),(U=document.getElementById(`library-${$.id}-tab`))==null||U.focus()};return l.jsxs("section",{className:"library-view","aria-label":"库",children:[l.jsxs("header",{className:"library-view__header",children:[l.jsx("h1",{children:"库"}),l.jsx("p",{children:"管理您的资源和产物"})]}),l.jsx("nav",{className:"aw-agent-tabs library-tabs","aria-label":"库分类",role:"tablist",children:mh.map(L=>l.jsx("button",{type:"button",id:`library-${L.id}-tab`,className:t===L.id?"is-active":"",role:"tab","aria-selected":t===L.id,"aria-controls":`library-${L.id}-panel`,tabIndex:t===L.id?0:-1,onClick:()=>C(L.id),onKeyDown:P=>M(P,L.id),children:L.label},L.id))}),l.jsxs("div",{className:"library-panels",children:[h.has("skills")?l.jsx("div",{id:"library-skills-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-skills-tab",hidden:t!=="skills",children:l.jsx(Alt,{cloudProvider:e,active:t==="skills",activationRevision:g.skills,onPageTitleChange:f,initialWorkspace:r,onInitialWorkspaceConsumed:s})}):null,h.has("knowledge")?l.jsx("div",{id:"library-knowledge-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-knowledge-tab",hidden:t!=="knowledge",children:l.jsx(v4e,{cloudProvider:e,active:t==="knowledge",activationRevision:g.knowledge})}):null,h.has("artifacts")?l.jsx("div",{id:"library-artifacts-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-artifacts-tab",hidden:t!=="artifacts",children:l.jsx(bMe,{items:O,userId:o,active:t==="artifacts",activationRevision:g.artifacts,loading:x,error:E,onRetry:()=>void N(),onEdit:vMe,onDelete:wMe,onDownload:SMe,onOpenSource:u?L=>u(L.appName,L.sessionId):void 0})}):null]})]})}const jhe="veadk_agentkit_connections",Clt=3e3,jq=6e4;function Al(){try{const e=localStorage.getItem(jhe);return(e?JSON.parse(e):[]).filter(n=>!n.runtimeId||!!n.region)}catch{return[]}}function HA(e){try{localStorage.setItem(jhe,JSON.stringify(e))}catch{}}function Ll(e,t){return`agentkit:${e}:${t}`}function Rhe(e){try{return new URL(e).host}catch{return e}}function gb(e){wJ();for(const t of e)if(!(t.runtimeId&&!t.region))for(const n of t.apps)vJ(Ll(t.id,n),t.runtimeId?{app:n,runtimeId:t.runtimeId,region:t.region}:{app:n,base:t.base,apiKey:t.apiKey})}function Ihe(e,t,n,i,r,s){const a={id:`rt_${e}`,name:t||e,runtimeId:e,region:n,apps:i,appLabels:r,currentVersion:s},o=Al(),c=o.findIndex(u=>u.runtimeId===e);return c===-1?o.push(a):o[c]=a,HA(o),gb(o),a}async function jlt(e,t,n,i,r){let s=null,a=n||"cn-beijing",o=null;for(const f of Jf(n))try{const h=await JD(e,f,{retryProbe:!0});if(h&&h.length>0){s=h,a=f;break}}catch(h){if(h instanceof z0)throw IT(e),h;if(h instanceof ga&&h.unsupported){o=h;continue}throw h}if(!s||s.length===0)throw IT(e),o||new ga("该 Runtime 暂不支持连接,请确认服务已正常运行。",!0,!0);const c=(r==null?void 0:r.trim())||s[0],u=Object.fromEntries(s.map(f=>[f,f===s[0]?c:f])),d=Ihe(e,t,a,s,u,i);return Ll(d.id,s[0])}function Rlt(e){return new Promise(t=>window.setTimeout(t,e))}async function SE(e,t,n,i,r={}){const s=Date.now();for(;;)try{return await jlt(e,t,n,i,r.agentName)}catch(a){const o=Date.now()-s;if(!r.waitForReady||!(a instanceof ga)||!a.retryable||o>=jq)throw a;const c=Math.min(Clt,jq-o);await Rlt(c)}}async function Phe(e,t,n,i){const r=t.trim().replace(/\/+$/,""),s=await v_(r,n.trim()),a={id:Date.now().toString(36),name:e.trim()||Rhe(r),base:r,apiKey:n.trim(),apps:s,appLabels:i&&s.length>0?{[s[0]]:i}:void 0},o=[...Al().filter(c=>c.base!==r),a];return HA(o),gb(o),a}function Ilt(e){const t=Al().filter(n=>n.id!==e);return HA(t),gb(t),t}function IT(e){const t=Al().filter(n=>n.runtimeId!==e);return HA(t),gb(t),t}function Mhe(e,t){const n=e.map(r=>({id:r,label:r,app:r,remote:!1})),i=t.flatMap(r=>r.apps.map(s=>{var o;const a=((o=r.appLabels)==null?void 0:o[s])??s;return{id:Ll(r.id,s),label:a,app:s,remote:!0,host:r.runtimeId?r.name:Rhe(r.base??""),runtimeId:r.runtimeId,region:r.region,currentVersion:r.currentVersion}}));return[...n,...i]}const Rq=Object.freeze(Object.defineProperty({__proto__:null,addConnection:Phe,addRuntimeConnection:Ihe,buildAgentEntries:Mhe,connectRuntime:SE,loadConnections:Al,registerConnections:gb,remoteAppId:Ll,removeConnection:Ilt,removeRuntimeConnection:IT},Symbol.toStringTag,{value:"Module"}));function Plt({onAdded:e,onCancel:t}){const[n,i]=m.useState(""),[r,s]=m.useState(""),[a,o]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=n.trim().length>0&&r.trim().length>0&&!c;async function p(){if(h){u(!0),f("");try{const g=await Phe(a,n,r,a);if(g.apps.length===0){f("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。"),u(!1);return}e(Ll(g.id,g.apps[0]))}catch(g){f(`连接失败:${String(g)}。请检查 URL、API Key,以及该网关是否允许跨域。`),u(!1)}}}return l.jsx("div",{className:"addagent",children:l.jsxs("div",{className:"addagent-card",children:[l.jsx("h2",{className:"addagent-title",children:"添加 AgentKit 智能体"}),l.jsx("p",{className:"addagent-sub",children:"填入 AgentKit 部署的访问地址与 API Key,将通过 ADK 协议连接,连接成功后其 Agent 会出现在左上角的下拉中。"}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"访问地址 URL"}),l.jsx("input",{className:"addagent-input",value:n,onChange:g=>i(g.target.value),placeholder:"https://xxxxx.apigateway-cn-beijing.volceapi.com",autoFocus:!0})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"API Key"}),l.jsx("input",{className:"addagent-input",type:"password",value:r,onChange:g=>s(g.target.value),placeholder:"以 Authorization: Bearer 方式连接"})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"显示名称(可选)"}),l.jsx("input",{className:"addagent-input",value:a,onChange:g=>o(g.target.value),placeholder:"默认取 URL 的主机名"})]}),d&&l.jsx("div",{className:"addagent-error",children:d}),l.jsxs("div",{className:"addagent-actions",children:[l.jsx("button",{className:"addagent-btn addagent-btn--ghost",onClick:t,disabled:c,children:"取消"}),l.jsxs("button",{className:"addagent-btn addagent-btn--primary",onClick:p,disabled:!h,children:[c?l.jsx(Kn,{className:"icon spin"}):null,c?"连接中…":"连接并添加"]})]})]})})}const Mlt=[{id:"case-1",itemKey:"case-1",kind:"good",input:"总结本周客户反馈,并按优先级归类。",output:"覆盖主要问题,给出清晰的优先级与下一步动作。",referenceOutput:"覆盖主要问题,给出清晰的优先级与下一步动作。",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T09:12:00+08:00",evaluationSetId:"",evaluationSetName:"示例 good case",workspaceId:"",tag:"总结",source:"auto",score:.92,reason:"任务完整覆盖了用户目标,输出结构清晰,并给出了可执行的下一步动作。"},{id:"case-2",itemKey:"case-2",kind:"good",input:"查询最新公开资料并附上来源。",output:"调用搜索工具,结论与引用一一对应。",referenceOutput:"调用搜索工具,结论与引用一一对应。",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T08:47:00+08:00",evaluationSetId:"",evaluationSetName:"示例 good case",workspaceId:"",tag:"工具调用",source:"user"},{id:"case-3",itemKey:"case-3",kind:"bad",input:"在信息不足时直接给出确定结论。",output:"应明确说明未知,并主动询问缺失信息。",referenceOutput:"",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T07:35:00+08:00",evaluationSetId:"",evaluationSetName:"示例 bad case",workspaceId:"",tag:"幻觉",source:"auto",score:.28,reason:"信息不足时仍给出了确定结论,缺少必要的澄清步骤与不确定性说明。"},{id:"case-4",itemKey:"case-4",kind:"bad",input:"连续重复调用相同工具获取同一结果。",output:"复用已有结果,避免无意义的重复调用。",referenceOutput:"",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T06:58:00+08:00",evaluationSetId:"",evaluationSetName:"示例 bad case",workspaceId:"",tag:"效率",source:"user"}],Llt=[{id:"eval-regression",name:"核心能力回归",agentIds:[],caseSet:"核心回归集",evaluator:"综合质量评估器",metrics:["回答质量","工具调用"],concurrency:"4",history:[{id:"run-1",createdAt:"今天 10:32",score:88,status:"completed"},{id:"run-2",createdAt:"昨天 16:08",score:84,status:"completed"}]},{id:"eval-safety",name:"安全与幻觉检查",agentIds:[],caseSet:"安全边界集",evaluator:"事实一致性评估器",metrics:["事实准确性","拒答合理性"],concurrency:"2",history:[{id:"run-3",createdAt:"7 月 25 日 14:20",score:91,status:"completed"}]}],Iq=[{id:"basic",label:"基本信息"},{id:"usage",label:"用量统计"},{id:"evaluations",label:"评测集"},{id:"optimizations",label:"优化项"},{id:"integrations",label:"接入方法"}],Dlt=20,$lt=new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1});function Qlt(e){const t=Date.parse(e);return Number.isNaN(t)?"暂未提供":$lt.format(t)}const fO=[{id:"api-server",label:"API Server"},{id:"a2a",label:"A2A"}];function Zj(e,t){return e?`${e.replace(/\/+$/,"")}${t}`:""}function Blt(e,t){const n=e.trim();if(!n||!t)return n;try{const i=new URL(n),r=i.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(!["localhost","127.0.0.1","::1"].includes(r))return n;const s=new URL(t);return i.protocol=s.protocol,i.hostname=s.hostname,i.port=s.port,i.toString()}catch{return n}}function Pq(e){return e==="key_auth"?"API Key":e==="custom_jwt"?"OAuth / JWT":e==="none"?"无需鉴权":"暂无"}function $L(e){return JSON.stringify(e)}function Lhe(e){return e==="key_auth"?`API_KEY = "" +`,4);return n>=0?t.slice(n+5).trimStart():e}function Che(e){const t=(e||"").trim();return!t||[">",">-","|","|-"].includes(t)?"暂无描述":t}function Slt(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m7.5 7.5 9 9m0-9-9 9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function _q(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Aq(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}function Elt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nq({direction:e}){return l.jsx("svg",{className:"icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:e==="left"?"m11.7 5.5-4.2 4.5 4.2 4.5":"m8.3 5.5 4.2 4.5-4.2 4.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function jhe(){return l.jsx("span",{className:"skillcenter-loading-mark","aria-hidden":!0})}function klt({page:e,total:t,pageSize:n,onPage:i}){const r=Math.max(1,Math.ceil(t/n));return l.jsxs("footer",{className:"skillcenter-pager",children:[l.jsxs("span",{children:["共 ",t," 项"]}),l.jsxs("div",{className:"skillcenter-pager-actions",children:[l.jsx("button",{type:"button",onClick:()=>i(e-1),disabled:e<=1,"aria-label":"上一页",children:l.jsx(Nq,{direction:"left"})}),l.jsxs("span",{children:[e," / ",r]}),l.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:e>=r,"aria-label":"下一页",children:l.jsx(Nq,{direction:"right"})})]})]})}function Tlt({children:e}){return l.jsx("div",{className:"skillcenter-empty",children:e})}function Wj({kind:e,title:t,description:n,error:i,action:r}){return l.jsx("div",{className:`skillcenter-page-state is-${e}`,role:e==="error"?"alert":"status",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Title,{children:t}),n?l.jsx(Oi.Description,{children:n}):null,i?l.jsx(ho,{error:i}):null,r?l.jsx(Oi.ActionRow,{children:l.jsx(zu,{color:"secondary",size:"lg",onClick:r.onClick,children:r.label})}):null]})})}function Cq({errors:e,cloudProvider:t,fullPage:n=!1,onRetry:i}){return l.jsxs("div",{className:`skillcenter-space-errors${n?" is-full-page":""}`,role:"alert",children:[l.jsxs("div",{className:"skillcenter-space-errors__content",children:[l.jsx("strong",{children:n?"无法加载技能空间":"部分技能空间加载失败"}),e.map(({region:r,error:s})=>l.jsxs("section",{children:[l.jsx("span",{children:td(r,t)}),l.jsx(ho,{error:s})]},r))]}),l.jsx("button",{type:"button",onClick:i,children:"重新加载"})]})}function _lt({skill:e,space:t,region:n,cloudProvider:i,detail:r,files:s,loading:a,error:o,canOptimize:c,onOptimize:u,onDownload:d,onClose:f}){return m.useEffect(()=>{const h=p=>{p.key==="Escape"&&f()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f]),l.jsx("div",{className:"skill-detail-backdrop",role:"presentation",onMouseDown:f,children:l.jsxs("section",{className:"skill-detail-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-detail-title",onMouseDown:h=>h.stopPropagation(),children:[l.jsxs("header",{className:"skill-detail-head",children:[l.jsx("div",{className:"skill-detail-heading",children:l.jsxs("div",{children:[l.jsx("h2",{id:"skill-detail-title",children:(r==null?void 0:r.name)||e.skillName}),l.jsx("p",{children:Che((r==null?void 0:r.description)||e.skillDescription)})]})}),l.jsxs("div",{className:"skill-detail-actions",children:[l.jsx("button",{type:"button",onClick:d,disabled:s.length===0,children:"下载 ZIP"}),l.jsx(RT,{disabled:!c,placement:"bottom",children:l.jsx("button",{type:"button",onClick:u,disabled:!c,children:"优化"})}),l.jsx("button",{type:"button",className:"skill-detail-close",onClick:f,"aria-label":"关闭技能详情",children:l.jsx(Slt,{})})]})]}),l.jsxs("dl",{className:"skill-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"技能 ID"}),l.jsx("dd",{title:e.skillId,children:e.skillId})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"版本"}),l.jsx("dd",{children:(r==null?void 0:r.version)||e.version||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:DL(e.skillStatus)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能空间"}),l.jsx("dd",{title:t.name,children:t.name})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"地域"}),l.jsx("dd",{children:td(n,i)})]})]}),l.jsxs("div",{className:"skill-detail-content skill-detail-content--files",children:[l.jsx("div",{className:"skill-detail-content-title",children:"完整文件"}),a?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(jhe,{}),"正在读取技能内容…"]}):o?l.jsx("div",{className:"skillcenter-error",children:l.jsx(ho,{error:o})}):s.length>0?l.jsx(_he,{files:s.map(h=>h.path.endsWith("SKILL.md")&&h.content?{...h,content:wlt(h.content)}:h)}):l.jsx(Tlt,{children:"该技能暂无 SKILL.md 内容"})]})]})})}function Alt({space:e,canUseSandbox:t,onUpload:n,onSandbox:i,onClose:r}){return m.useEffect(()=>{const s=a=>{a.key==="Escape"&&r()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[r]),l.jsx("div",{className:"skill-dialog-backdrop",role:"presentation",onMouseDown:r,children:l.jsxs("section",{className:"skill-dialog skill-add-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-add-dialog-title",onMouseDown:s=>s.stopPropagation(),children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("h2",{id:"skill-add-dialog-title",children:"添加技能"}),l.jsx("p",{title:e.name,children:e.name})]}),l.jsx("button",{type:"button",onClick:r,children:"取消"})]}),l.jsxs("div",{className:"skill-add-dialog__options",children:[l.jsxs("button",{type:"button",onClick:n,children:[l.jsx("strong",{children:"本地上传"}),l.jsx("span",{children:"选择 ZIP 文件,校验通过后上传到技能空间"})]}),l.jsx(RT,{disabled:!t,placement:"inside",children:l.jsxs("button",{type:"button",disabled:!t,onClick:i,children:[l.jsx("strong",{children:"自动创建"}),l.jsx("span",{children:"选择模型和风格,通过对话生成技能"})]})})]})]})})}function Nlt({cloudProvider:e="volcengine",active:t=!0,activationRevision:n=0,initialWorkspace:i=null,onInitialWorkspaceConsumed:r,onPageTitleChange:s}){var Ft;const a=m.useMemo(()=>v1(e).map(Ce=>Ce.value),[e]),[o,c]=m.useState([]),[u,d]=m.useState({}),[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState((i==null?void 0:i.space)??null),[O,v]=m.useState([]),[x,w]=m.useState(1),[E,S]=m.useState(0),[k,T]=m.useState(!1),[A,N]=m.useState(null),[C,M]=m.useState(""),[L,P]=m.useState(null),[Q,j]=m.useState(null),[$,U]=m.useState([]),[B,I]=m.useState(!1),[X,q]=m.useState(null),[D,H]=m.useState(null),[re,fe]=m.useState(!1),[Ae,J]=m.useState(null),[ie,ue]=m.useState(null),[ye,Se]=m.useState(null),[Re,Ee]=m.useState(0),[me,oe]=m.useState(0),[Ne,Oe]=m.useState(""),[Ve,We]=m.useState(""),[De,mt]=m.useState(null),[at,Rt]=m.useState(i),qe=m.useRef(0),W=m.useRef(0),K=m.useRef(!1),ae=m.useRef(null),pe=m.useRef(null),z=m.useRef(null),ve=m.useDeferredValue(p),Be=m.useDeferredValue(C),kt=(at&&(b||at.selectPublishSpace)?at.operation==="create"?"创建技能":`优化 ${((Ft=at.source)==null?void 0:Ft.name)||"技能"}`:"")||(b==null?void 0:b.name)||"技能库";m.useEffect(()=>{t&&(s==null||s(kt))},[t,s,kt]),m.useEffect(()=>{i&&(r==null||r())},[i,r]);const Mt=m.useMemo(()=>{const Ce=ve.trim().toLocaleLowerCase();return Ce?o.filter(et=>`${et.name} ${et.description||""} ${et.projectName||""}`.toLocaleLowerCase().includes(Ce)):o},[ve,o]),Tt=m.useMemo(()=>{const Ce=Be.trim().toLocaleLowerCase();return Ce?O.filter(et=>`${et.skillName} ${et.skillDescription||""}`.toLocaleLowerCase().includes(Ce)):O},[Be,O]),dt=(b==null?void 0:b.region)||Qi(e),ge=m.useMemo(()=>a.flatMap(Ce=>{var wt;const et=(wt=u[Ce])==null?void 0:wt.error;return et?[{region:Ce,error:et}]:[]}),[u,a]),lt=a.some(Ce=>{const et=u[Ce];return!!(et&&!et.done&&!et.error)}),Ge=ge.length===a.length;m.useEffect(()=>{const Ce=new AbortController;return aA(Ce.signal).then(H).catch(()=>H({enabled:!1,reason:"管理员未配置",operations:["create","optimize"],models:[],styles:{}})),()=>Ce.abort()},[]);const vt=m.useCallback(async(Ce,et)=>{var st;if(K.current||Ce.length===0)return;K.current=!0,h(!0),et&&((st=ae.current)==null||st.abort(),c([]),d(Object.fromEntries(Ce.map(({region:At})=>[At,{nextPage:1,loadedCount:0,done:!1,error:null}]))));const wt=new AbortController;ae.current=wt;const yn=++W.current,on=await Promise.allSettled(Ce.map(async({region:At,page:Ut})=>({region:At,page:Ut,result:await TPe({region:At,page:Ut,pageSize:ylt,signal:wt.signal})})));if(W.current!==yn)return;const hi=on.map((At,Ut)=>{const kn=Ce[Ut];return At.status==="rejected"?{request:kn,error:ds(At.reason,"读取技能空间失败,请稍后重试"),items:[],totalCount:0}:{request:kn,error:null,items:(At.value.result.items||[]).map(wn=>({...wn,region:wn.region||At.value.region})),totalCount:At.value.result.totalCount||0}}),Pe=hi.flatMap(At=>At.items);d(At=>{const Ut={...At};return hi.forEach(({request:kn,error:wn,items:Ai,totalCount:Gn})=>{const xn=Ut[kn.region]||{nextPage:kn.page,loadedCount:0,done:!1,error:null};if(wn){Ut[kn.region]={...xn,error:wn};return}const de=xn.loadedCount+Ai.length;Ut[kn.region]={nextPage:kn.page+1,loadedCount:de,done:Ai.length===0||de>=Gn,error:null}}),Ut}),c(At=>vlt(et?[]:At,Pe)),y(At=>At&&(Pe.find(Ut=>Sl(Ut)===Sl(At))||At)),K.current=!1,h(!1)},[]),_t=m.useCallback(()=>{if(K.current)return;const Ce=a.flatMap(et=>{const wt=u[et];return wt&&!wt.done&&!wt.error?[{region:et,page:wt.nextPage}]:[]});vt(Ce,!1)},[vt,u,a]);m.useEffect(()=>{Ie(),y(null),v([]),w(1)},[e]),m.useEffect(()=>{if(t)return vt(a.map(Ce=>({region:Ce,page:1})),!0),()=>{var Ce;W.current+=1,(Ce=ae.current)==null||Ce.abort(),K.current=!1}},[t,n,vt,a,Re]),m.useEffect(()=>{const Ce=z.current,et=pe.current;if(!Ce||!et||!lt||f)return;const wt=new IntersectionObserver(([yn])=>{yn.isIntersecting&&_t()},{root:et,rootMargin:"240px 0px",threshold:.01});return wt.observe(Ce),()=>wt.disconnect()},[lt,_t,f]);const Bt=()=>{const Ce=pe.current;!Ce||!lt||f||Ce.scrollHeight-Ce.scrollTop-Ce.clientHeight<=240&&_t()};m.useEffect(()=>{if(!b){v([]),S(0);return}let Ce=!0;return T(!0),N(null),MPe(b.id,{region:dt,page:x,pageSize:Sq,project:b.projectName}).then(et=>{Ce&&(v(et.items||[]),S(et.totalCount||0))}).catch(et=>{Ce&&(v([]),S(0),N(ds(et,"读取技能失败,请稍后重试")))}).finally(()=>{Ce&&T(!1)}),()=>{Ce=!1}},[dt,b,x,me]);const je=Ce=>{Ie(),y(Ce),w(1),M("")},Ze=()=>{Ie(),y(null),v([]),S(0),w(1),M(""),mt(null)},Ie=()=>{qe.current+=1,P(null),j(null),U([]),q(null),I(!1)},Wt=async Ce=>{if(!b)return;const et=qe.current+1;qe.current=et,P(Ce),j(null),q(null),I(!0);try{const[wt,yn]=await Promise.all([LPe(b.id,Ce.skillId,Ce.version,dt,b.projectName),IPe({spaceId:b.id,skillId:Ce.skillId,version:Ce.version,region:dt})]);qe.current===et&&(j(wt),U(yn))}catch(wt){qe.current===et&&q(ds(wt,"读取技能详情失败,请稍后重试"))}finally{qe.current===et&&I(!1)}},dn=Ce=>{if(b)return{kind:"skill-center",skillId:Ce.skillId,version:Ce.version,region:dt,projectName:b.projectName,skillSpaceId:b.id,skillSpaceName:b.name,name:Ce.skillName,description:Ce.skillDescription}},Qt=Ce=>{const et=dn(Ce);!et||!(D!=null&&D.enabled)||(Ie(),Rt({operation:"optimize",source:et}))},Yt=async Ce=>{if(!(!b||!window.confirm(`确定删除整个 Skill“${Ce.skillName}”吗?此操作会影响所有引用它的空间。`))){Oe(Ce.skillId),mt(null);try{await RPe({spaceId:b.id,skillId:Ce.skillId,region:dt}),oe(et=>et+1),Ee(et=>et+1)}catch(et){mt(ds(et,"删除 Skill 失败"))}finally{Oe("")}}},Jt=async Ce=>{if(!window.confirm(`确定删除 Skill 空间“${Ce.name}”吗?请先确认空间中的技能已删除。`))return;const et=Sl(Ce);We(et),mt(null);try{await NPe({spaceId:Ce.id,region:Ce.region||Qi(e)}),b&&Sl(b)===et&&Ze(),Ee(wt=>wt+1)}catch(wt){mt(ds(wt,"删除 Skill 空间失败"))}finally{We("")}};return at&&(b||at.selectPublishSpace)?l.jsx(mlt,{operation:at.operation,cloudProvider:e,space:b??void 0,availableSpaces:o,spacesLoading:f,initialIntent:at.initialIntent,source:at.source,onBack:()=>Rt(null),onPublished:()=>{oe(Ce=>Ce+1),Ee(Ce=>Ce+1)}}):l.jsxs("section",{className:`skillcenter${b?" is-space":" my-agents-page"}`,children:[b?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:"skillcenter-page-header",children:[l.jsxs("div",{className:"skillcenter-page-heading skillcenter-page-heading--back",children:[l.jsx("button",{type:"button",className:"skillcenter-back",onClick:Ze,"aria-label":"返回技能空间",children:l.jsx(Elt,{})}),l.jsxs("div",{children:[l.jsx("h1",{title:b.name,children:b.name}),l.jsx("p",{children:b.description||"管理空间中的技能并创建新的版本"})]})]}),l.jsxs("label",{className:"skillcenter-search",children:[l.jsx(_q,{}),l.jsx("input",{type:"search","aria-label":"搜索技能",value:C,onChange:Ce=>M(Ce.target.value),placeholder:"搜索技能"})]})]}),l.jsxs("div",{className:"skillcenter-toolbar",children:[l.jsxs("div",{className:"skillcenter-detail-facts",children:[l.jsxs("div",{children:[l.jsx("span",{children:"技能数量"}),l.jsx("strong",{children:E})]}),l.jsxs("div",{children:[l.jsx("span",{children:"更新时间"}),l.jsx("strong",{children:b.updatedAt?kq(b.updatedAt):"—"})]})]}),l.jsxs("div",{className:"skillcenter-toolbar-actions",children:[l.jsx("button",{type:"button",className:"skillcenter-secondary-action",onClick:()=>Se(b),children:"本地上传"}),l.jsx(RT,{disabled:!(D!=null&&D.enabled),children:l.jsxs("button",{type:"button",className:"skillcenter-primary-action",disabled:!(D!=null&&D.enabled),onClick:()=>Rt({operation:"create"}),children:[l.jsx(Aq,{}),l.jsx("span",{children:"创建技能"})]})})]})]}),De?l.jsx("div",{className:"skillcenter-inline-error",role:"alert",children:l.jsx(ho,{error:De})}):null,l.jsxs("section",{className:"skillcenter-results","aria-label":`${b.name}中的技能`,children:[k&&O.length===0?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(jhe,{}),"正在加载技能"]}):A&&O.length===0?l.jsx(Wj,{kind:"error",title:"无法加载技能",error:A,action:{label:"重新加载",onClick:()=>oe(Ce=>Ce+1)}}):Tt.length===0?l.jsx(Wj,{kind:"empty",title:C.trim()?"没有匹配的技能":"暂无技能",description:C.trim()?"请尝试搜索其他名称":"本地上传 Skill,或自动创建",action:C.trim()?void 0:{label:"本地上传",onClick:()=>Se(b)}}):l.jsx("div",{className:"skillcenter-table-wrap",children:l.jsxs("table",{className:"skillcenter-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"技能"}),l.jsx("th",{scope:"col",children:"状态"}),l.jsx("th",{scope:"col",className:"skillcenter-table__actions-heading",children:"操作"})]})}),l.jsx("tbody",{children:Tt.map(Ce=>l.jsxs("tr",{children:[l.jsx("td",{className:"skillcenter-table__skill",children:l.jsxs("button",{type:"button",onClick:()=>void Wt(Ce),children:[l.jsxs("span",{className:"skillcenter-table__title-row",children:[l.jsx("strong",{title:Ce.skillName,children:Ce.skillName}),Ce.version?l.jsx("span",{className:"skillcenter-table__version-badge",children:Ce.version}):null]}),l.jsx("span",{className:"skillcenter-table__description",children:Che(Ce.skillDescription)})]})}),l.jsx("td",{children:l.jsx("span",{className:`skillcenter-status ${Eq(Ce.skillStatus)}`,children:DL(Ce.skillStatus)})}),l.jsx("td",{children:l.jsxs("div",{className:"skillcenter-table__actions",children:[l.jsx("button",{type:"button",onClick:()=>void Wt(Ce),children:"查看"}),l.jsx(RT,{disabled:!(D!=null&&D.enabled),children:l.jsx("button",{type:"button",disabled:!(D!=null&&D.enabled),onClick:()=>Qt(Ce),children:"优化"})}),l.jsx("button",{type:"button",className:"is-danger",disabled:Ne===Ce.skillId,onClick:()=>void Yt(Ce),children:Ne===Ce.skillId?"删除中…":"删除"})]})})]},`${Ce.skillId}:${Ce.version}`))})]})}),!C.trim()&&!k&&!A&&E>0?l.jsx(klt,{page:x,total:E,pageSize:Sq,onPage:w}):null]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"my-agent-type-bar skillcenter-list-toolbar library-resource-toolbar",children:[l.jsxs("button",{type:"button",className:"my-agent-create-primary",onClick:()=>fe(!0),children:[l.jsx(Aq,{}),l.jsx("span",{children:"新建空间"})]}),l.jsxs("label",{className:"my-agent-search",children:[l.jsx(_q,{}),l.jsx("input",{type:"search","aria-label":"搜索技能空间",value:p,onChange:Ce=>g(Ce.target.value),placeholder:"搜索技能空间"})]})]}),De?l.jsx("div",{className:"skillcenter-inline-error",role:"alert",children:l.jsx(ho,{error:De})}):null,l.jsxs("section",{className:"my-agent-results",ref:pe,"aria-label":"技能空间列表",onScroll:Bt,children:[ge.length>0&&!Ge?l.jsx(Cq,{errors:ge,cloudProvider:e,onRetry:()=>Ee(Ce=>Ce+1)}):null,f&&o.length===0?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载技能空间"})]}):Ge&&o.length===0?l.jsx(Cq,{errors:ge,cloudProvider:e,fullPage:!0,onRetry:()=>Ee(Ce=>Ce+1)}):Mt.length===0?l.jsx(Wj,{kind:"empty",title:p.trim()?"没有匹配的技能空间":"暂无技能空间",description:p.trim()?"请尝试搜索其他名称":"新建一个空间,开始管理和创建技能",action:p.trim()?void 0:{label:"新建空间",onClick:()=>fe(!0)}}):l.jsx(l.Fragment,{children:l.jsx("div",{className:"my-agent-grid",children:Mt.map(Ce=>{const et=Sl(Ce);return l.jsx(pse,{className:"skillcenter-space-card",title:Ce.name,status:l.jsx("span",{className:`skillcenter-status ${Eq(Ce.status)}`,children:DL(Ce.status)}),description:Ce.description||"暂无描述",metadata:[{label:"技能数量",value:Ce.skillCount??0},{label:"更新时间",value:Ce.updatedAt?kq(Ce.updatedAt):"—"}],secondaryAction:{label:"添加技能",onClick:()=>ue(Ce)},primaryAction:{label:"查看详情",onClick:()=>je(Ce)},menuLabel:`更多空间操作:${Ce.name}`,menuAriaLabel:`${Ce.name}空间操作`,menuActions:[{label:"编辑空间",onClick:()=>J(Ce)},{label:"删除空间",danger:!0,disabled:Ve===et,onClick:()=>void Jt(Ce)}]},et)})})}),!Ge&&o.length>0?l.jsx("div",{className:"my-agent-load-more",ref:z,"aria-live":"polite",children:f?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多技能空间"})]}):lt?l.jsx("span",{children:"继续下滑加载更多"}):ge.length>0?l.jsx("span",{children:"部分技能空间加载失败"}):l.jsx("span",{children:"已加载全部技能空间"})}):null]})]}),L&&b&&l.jsx(_lt,{skill:L,space:b,region:dt,cloudProvider:e,detail:Q,files:$,loading:B,error:X,canOptimize:(D==null?void 0:D.enabled)===!0,onOptimize:()=>Qt(L),onDownload:()=>void PPe({spaceId:b.id,skillId:L.skillId,version:L.version,region:dt,fallbackName:L.skillName}).catch(Ce=>q(ds(Ce,"下载 Skill 失败"))),onClose:Ie}),re?l.jsx(glt,{region:Qi(e),onClose:()=>fe(!1),onCreated:Ce=>{fe(!1),Ee(et=>et+1),y({...Ce,region:Ce.region||Qi(e)})}}):null,Ae?l.jsx(blt,{space:Ae,region:Ae.region||Qi(e),onClose:()=>J(null),onUpdated:Ce=>{const et={...Ce,region:Ce.region||Ae.region||Qi(e)};J(null),y(wt=>wt&&Sl(wt)===Sl(et)?et:wt),c(wt=>wt.map(yn=>Sl(yn)===Sl(et)?et:yn)),Ee(wt=>wt+1)}}):null,ie?l.jsx(Alt,{space:ie,canUseSandbox:(D==null?void 0:D.enabled)===!0,onClose:()=>ue(null),onUpload:()=>{Se(ie),ue(null)},onSandbox:()=>{const Ce=ie;ue(null),je(Ce),Rt({operation:"create"})}}):null,ye?l.jsx(Olt,{space:ye,region:ye.region||Qi(e),onClose:()=>Se(null),onUploaded:()=>{Se(null),oe(Ce=>Ce+1),Ee(Ce=>Ce+1)}}):null]})}const mh=[{id:"skills",label:"技能库"},{id:"knowledge",label:"知识库"},{id:"artifacts",label:"产物"}];function Clt({cloudProvider:e,activeTab:t,onTabChange:n,onPageTitleChange:i,skillInitialWorkspace:r=null,onSkillInitialWorkspaceConsumed:s,artifactSources:a=[],artifactUserId:o="",onArtifactActivate:c,onArtifactSourceOpen:u}){const[d,f]=m.useState("技能库"),[h,p]=m.useState(()=>new Set(["skills",t])),[g,b]=m.useState({skills:0,knowledge:0,artifacts:0}),y=m.useRef(c),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(""),k=m.useMemo(()=>{const L=fMe(a);return{key:JSON.stringify(L),candidates:L}},[a]),T=m.useRef(k);T.current.key!==k.key&&(T.current=k);const A=T.current.candidates;m.useEffect(()=>{y.current=c},[c]),m.useEffect(()=>{p(L=>{if(L.has(t))return L;const P=new Set(L);return P.add(t),P})},[t]),m.useEffect(()=>{var P;const L=t==="skills"?d:((P=mh.find(Q=>Q.id===t))==null?void 0:P.label)||"库";i==null||i(L)},[t,i,d]),m.useEffect(()=>{var L;t==="artifacts"&&((L=y.current)==null||L.call(y))},[t,g.artifacts]);const N=m.useCallback(async()=>{w(!0),S("");try{v(await vMe(A))}catch(L){S(L instanceof Error?L.message:String(L))}finally{w(!1)}},[A]);m.useEffect(()=>{t==="artifacts"&&N()},[t,g.artifacts,N]);const C=L=>{p(P=>{if(P.has(L))return P;const Q=new Set(P);return Q.add(L),Q}),b(P=>({...P,[L]:P[L]+1})),n(L)},M=(L,P)=>{var U;if(!["ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;L.preventDefault();const Q=mh.findIndex(B=>B.id===P),j=L.key==="Home"?0:L.key==="End"?mh.length-1:(Q+(L.key==="ArrowRight"?1:-1)+mh.length)%mh.length,$=mh[j];C($.id),(U=document.getElementById(`library-${$.id}-tab`))==null||U.focus()};return l.jsxs("section",{className:"library-view","aria-label":"库",children:[l.jsxs("header",{className:"library-view__header",children:[l.jsx("h1",{children:"库"}),l.jsx("p",{children:"管理您的资源和产物"})]}),l.jsx("nav",{className:"aw-agent-tabs library-tabs","aria-label":"库分类",role:"tablist",children:mh.map(L=>l.jsx("button",{type:"button",id:`library-${L.id}-tab`,className:t===L.id?"is-active":"",role:"tab","aria-selected":t===L.id,"aria-controls":`library-${L.id}-panel`,tabIndex:t===L.id?0:-1,onClick:()=>C(L.id),onKeyDown:P=>M(P,L.id),children:L.label},L.id))}),l.jsxs("div",{className:"library-panels",children:[h.has("skills")?l.jsx("div",{id:"library-skills-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-skills-tab",hidden:t!=="skills",children:l.jsx(Nlt,{cloudProvider:e,active:t==="skills",activationRevision:g.skills,onPageTitleChange:f,initialWorkspace:r,onInitialWorkspaceConsumed:s})}):null,h.has("knowledge")?l.jsx("div",{id:"library-knowledge-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-knowledge-tab",hidden:t!=="knowledge",children:l.jsx(w4e,{cloudProvider:e,active:t==="knowledge",activationRevision:g.knowledge})}):null,h.has("artifacts")?l.jsx("div",{id:"library-artifacts-panel",className:"library-panel",role:"tabpanel","aria-labelledby":"library-artifacts-tab",hidden:t!=="artifacts",children:l.jsx(OMe,{items:O,userId:o,active:t==="artifacts",activationRevision:g.artifacts,loading:x,error:E,onRetry:()=>void N(),onEdit:wMe,onDelete:SMe,onDownload:EMe,onOpenSource:u?L=>u(L.appName,L.sessionId):void 0})}):null]})]})}const Rhe="veadk_agentkit_connections",jlt=3e3,jq=6e4;function Al(){try{const e=localStorage.getItem(Rhe);return(e?JSON.parse(e):[]).filter(n=>!n.runtimeId||!!n.region)}catch{return[]}}function HA(e){try{localStorage.setItem(Rhe,JSON.stringify(e))}catch{}}function Ll(e,t){return`agentkit:${e}:${t}`}function Ihe(e){try{return new URL(e).host}catch{return e}}function gb(e){SJ();for(const t of e)if(!(t.runtimeId&&!t.region))for(const n of t.apps)wJ(Ll(t.id,n),t.runtimeId?{app:n,runtimeId:t.runtimeId,region:t.region}:{app:n,base:t.base,apiKey:t.apiKey})}function Phe(e,t,n,i,r,s){const a={id:`rt_${e}`,name:t||e,runtimeId:e,region:n,apps:i,appLabels:r,currentVersion:s},o=Al(),c=o.findIndex(u=>u.runtimeId===e);return c===-1?o.push(a):o[c]=a,HA(o),gb(o),a}async function Rlt(e,t,n,i,r){let s=null,a=n||"cn-beijing",o=null;for(const f of Jf(n))try{const h=await JD(e,f,{retryProbe:!0});if(h&&h.length>0){s=h,a=f;break}}catch(h){if(h instanceof z0)throw IT(e),h;if(h instanceof ga&&h.unsupported){o=h;continue}throw h}if(!s||s.length===0)throw IT(e),o||new ga("该 Runtime 暂不支持连接,请确认服务已正常运行。",!0,!0);const c=(r==null?void 0:r.trim())||s[0],u=Object.fromEntries(s.map(f=>[f,f===s[0]?c:f])),d=Phe(e,t,a,s,u,i);return Ll(d.id,s[0])}function Ilt(e){return new Promise(t=>window.setTimeout(t,e))}async function SE(e,t,n,i,r={}){const s=Date.now();for(;;)try{return await Rlt(e,t,n,i,r.agentName)}catch(a){const o=Date.now()-s;if(!r.waitForReady||!(a instanceof ga)||!a.retryable||o>=jq)throw a;const c=Math.min(jlt,jq-o);await Ilt(c)}}async function Mhe(e,t,n,i){const r=t.trim().replace(/\/+$/,""),s=await v_(r,n.trim()),a={id:Date.now().toString(36),name:e.trim()||Ihe(r),base:r,apiKey:n.trim(),apps:s,appLabels:i&&s.length>0?{[s[0]]:i}:void 0},o=[...Al().filter(c=>c.base!==r),a];return HA(o),gb(o),a}function Plt(e){const t=Al().filter(n=>n.id!==e);return HA(t),gb(t),t}function IT(e){const t=Al().filter(n=>n.runtimeId!==e);return HA(t),gb(t),t}function Lhe(e,t){const n=e.map(r=>({id:r,label:r,app:r,remote:!1})),i=t.flatMap(r=>r.apps.map(s=>{var o;const a=((o=r.appLabels)==null?void 0:o[s])??s;return{id:Ll(r.id,s),label:a,app:s,remote:!0,host:r.runtimeId?r.name:Ihe(r.base??""),runtimeId:r.runtimeId,region:r.region,currentVersion:r.currentVersion}}));return[...n,...i]}const Rq=Object.freeze(Object.defineProperty({__proto__:null,addConnection:Mhe,addRuntimeConnection:Phe,buildAgentEntries:Lhe,connectRuntime:SE,loadConnections:Al,registerConnections:gb,remoteAppId:Ll,removeConnection:Plt,removeRuntimeConnection:IT},Symbol.toStringTag,{value:"Module"}));function Mlt({onAdded:e,onCancel:t}){const[n,i]=m.useState(""),[r,s]=m.useState(""),[a,o]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=n.trim().length>0&&r.trim().length>0&&!c;async function p(){if(h){u(!0),f("");try{const g=await Mhe(a,n,r,a);if(g.apps.length===0){f("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。"),u(!1);return}e(Ll(g.id,g.apps[0]))}catch(g){f(`连接失败:${String(g)}。请检查 URL、API Key,以及该网关是否允许跨域。`),u(!1)}}}return l.jsx("div",{className:"addagent",children:l.jsxs("div",{className:"addagent-card",children:[l.jsx("h2",{className:"addagent-title",children:"添加 AgentKit 智能体"}),l.jsx("p",{className:"addagent-sub",children:"填入 AgentKit 部署的访问地址与 API Key,将通过 ADK 协议连接,连接成功后其 Agent 会出现在左上角的下拉中。"}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"访问地址 URL"}),l.jsx("input",{className:"addagent-input",value:n,onChange:g=>i(g.target.value),placeholder:"https://xxxxx.apigateway-cn-beijing.volceapi.com",autoFocus:!0})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"API Key"}),l.jsx("input",{className:"addagent-input",type:"password",value:r,onChange:g=>s(g.target.value),placeholder:"以 Authorization: Bearer 方式连接"})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"显示名称(可选)"}),l.jsx("input",{className:"addagent-input",value:a,onChange:g=>o(g.target.value),placeholder:"默认取 URL 的主机名"})]}),d&&l.jsx("div",{className:"addagent-error",children:d}),l.jsxs("div",{className:"addagent-actions",children:[l.jsx("button",{className:"addagent-btn addagent-btn--ghost",onClick:t,disabled:c,children:"取消"}),l.jsxs("button",{className:"addagent-btn addagent-btn--primary",onClick:p,disabled:!h,children:[c?l.jsx(Kn,{className:"icon spin"}):null,c?"连接中…":"连接并添加"]})]})]})})}const Llt=[{id:"case-1",itemKey:"case-1",kind:"good",input:"总结本周客户反馈,并按优先级归类。",output:"覆盖主要问题,给出清晰的优先级与下一步动作。",referenceOutput:"覆盖主要问题,给出清晰的优先级与下一步动作。",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T09:12:00+08:00",evaluationSetId:"",evaluationSetName:"示例 good case",workspaceId:"",tag:"总结",source:"auto",score:.92,reason:"任务完整覆盖了用户目标,输出结构清晰,并给出了可执行的下一步动作。"},{id:"case-2",itemKey:"case-2",kind:"good",input:"查询最新公开资料并附上来源。",output:"调用搜索工具,结论与引用一一对应。",referenceOutput:"调用搜索工具,结论与引用一一对应。",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T08:47:00+08:00",evaluationSetId:"",evaluationSetName:"示例 good case",workspaceId:"",tag:"工具调用",source:"user"},{id:"case-3",itemKey:"case-3",kind:"bad",input:"在信息不足时直接给出确定结论。",output:"应明确说明未知,并主动询问缺失信息。",referenceOutput:"",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T07:35:00+08:00",evaluationSetId:"",evaluationSetName:"示例 bad case",workspaceId:"",tag:"幻觉",source:"auto",score:.28,reason:"信息不足时仍给出了确定结论,缺少必要的澄清步骤与不确定性说明。"},{id:"case-4",itemKey:"case-4",kind:"bad",input:"连续重复调用相同工具获取同一结果。",output:"复用已有结果,避免无意义的重复调用。",referenceOutput:"",comment:"",agentName:"示例 Agent",sessionId:"",messageId:"",runtimeId:"",invocationId:"",userId:"",createdAt:"2026-08-05T06:58:00+08:00",evaluationSetId:"",evaluationSetName:"示例 bad case",workspaceId:"",tag:"效率",source:"user"}],Dlt=[{id:"eval-regression",name:"核心能力回归",agentIds:[],caseSet:"核心回归集",evaluator:"综合质量评估器",metrics:["回答质量","工具调用"],concurrency:"4",history:[{id:"run-1",createdAt:"今天 10:32",score:88,status:"completed"},{id:"run-2",createdAt:"昨天 16:08",score:84,status:"completed"}]},{id:"eval-safety",name:"安全与幻觉检查",agentIds:[],caseSet:"安全边界集",evaluator:"事实一致性评估器",metrics:["事实准确性","拒答合理性"],concurrency:"2",history:[{id:"run-3",createdAt:"7 月 25 日 14:20",score:91,status:"completed"}]}],Iq=[{id:"basic",label:"基本信息"},{id:"usage",label:"用量统计"},{id:"evaluations",label:"评测集"},{id:"optimizations",label:"优化项"},{id:"integrations",label:"接入方法"}],$lt=20,Qlt=new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1});function Blt(e){const t=Date.parse(e);return Number.isNaN(t)?"暂未提供":Qlt.format(t)}const fO=[{id:"api-server",label:"API Server"},{id:"a2a",label:"A2A"}];function Zj(e,t){return e?`${e.replace(/\/+$/,"")}${t}`:""}function Ult(e,t){const n=e.trim();if(!n||!t)return n;try{const i=new URL(n),r=i.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(!["localhost","127.0.0.1","::1"].includes(r))return n;const s=new URL(t);return i.protocol=s.protocol,i.hostname=s.hostname,i.port=s.port,i.toString()}catch{return n}}function Pq(e){return e==="key_auth"?"API Key":e==="custom_jwt"?"OAuth / JWT":e==="none"?"无需鉴权":"暂无"}function $L(e){return JSON.stringify(e)}function Dhe(e){return e==="key_auth"?`API_KEY = "" HEADERS = {"Authorization": f"Bearer {API_KEY}"}`:e==="custom_jwt"?`ACCESS_TOKEN = "" HEADERS = {"Authorization": f"Bearer {ACCESS_TOKEN}"}`:e==="none"?"HEADERS = {}":`AUTH_TOKEN = "" -HEADERS = {"Authorization": f"Bearer {AUTH_TOKEN}"}`}function Ult(e,t,n){const i=e.replace(/\/+$/,"");return`\`\`\`python +HEADERS = {"Authorization": f"Bearer {AUTH_TOKEN}"}`}function zlt(e,t,n){const i=e.replace(/\/+$/,"");return`\`\`\`python import uuid import requests @@ -721,7 +721,7 @@ BASE_URL = ${$L(i)} APP_NAME = ${$L(t)} USER_ID = "demo-user" SESSION_ID = str(uuid.uuid4()) -${Lhe(n)} +${Dhe(n)} session_response = requests.post( f"{BASE_URL}/apps/{APP_NAME}/users/{USER_ID}/sessions/{SESSION_ID}", @@ -751,13 +751,13 @@ with requests.post( for line in response.iter_lines(): if line: print(line.decode("utf-8")) -\`\`\``}function zlt(e,t){return`\`\`\`python +\`\`\``}function Flt(e,t){return`\`\`\`python import uuid import requests AGENT_URL = ${$L(e)} -${Lhe(t)} +${Dhe(t)} response = requests.post( AGENT_URL, @@ -778,11 +778,11 @@ response = requests.post( ) response.raise_for_status() print(response.json()) -\`\`\``}function Flt({visible:e}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M2.8 12s3.3-5.4 9.2-5.4 9.2 5.4 9.2 5.4-3.3 5.4-9.2 5.4S2.8 12 2.8 12Z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2.4"}),!e&&l.jsx("path",{d:"m4.2 4.2 15.6 15.6"})]})}function Mq({available:e,authType:t,value:n,visible:i,loading:r,error:s,onToggle:a}){return e?t==="none"?"无需 API Key":t==="custom_jwt"?"使用 OAuth / JWT":t!=="key_auth"?"暂无":l.jsxs("span",{className:"aw-integration-secret",children:[l.jsx("span",{className:"aw-integration-secret-value","aria-live":"polite",children:i&&n?n:"****"}),l.jsx("button",{type:"button",className:"aw-integration-secret-toggle","aria-label":i?"隐藏 API Key":"显示 API Key",title:i?"隐藏 API Key":"显示 API Key",disabled:r,onClick:a,children:r?l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}):l.jsx(Flt,{visible:i})}),s&&l.jsx("span",{className:"aw-integration-secret-error",role:"alert",children:s})]}):"暂无"}function Lq({protocol:e,title:t,available:n,fields:i,example:r}){return l.jsxs("section",{className:`aw-integration-panel${n&&r?" has-example":""}`,id:`integration-${e}-panel`,role:"tabpanel","aria-labelledby":`integration-${e}-tab`,children:[l.jsx("header",{children:l.jsx("h3",{children:t})}),l.jsx("dl",{children:i.map(s=>l.jsxs("div",{children:[l.jsx("dt",{children:s.label}),l.jsx("dd",{children:s.value||"暂无"})]},s.label))}),n&&r&&l.jsxs("section",{className:"aw-integration-example",children:[l.jsx("h4",{children:"Python 示例"}),l.jsx(qp,{text:r,className:"aw-integration-example-code",allowRawHtml:!1})]})]})}function Dhe(e){const t=e.tools??[],n=Qp.filter(r=>r.toolNames.some(s=>t.includes(s))),i=new Set(n.flatMap(r=>r.toolNames));return{...el(),modelSource:void 0,name:e.name,description:e.description,instruction:e.instruction||el().instruction,agentType:e.type,modelName:e.model,tools:t.filter(r=>!i.has(r)),builtinTools:n.map(r=>r.id),skills:(e.skills??[]).map(r=>r.name),subAgents:(e.children??[]).map(Dhe)}}function Vlt(e,t){var n;return e!=null&&e.draft?e.draft:e!=null&&e.graph?Dhe(e.graph):{...el(),modelSource:void 0,name:(e==null?void 0:e.name)||t,description:(e==null?void 0:e.description)||"暂无描述",agentType:(e==null?void 0:e.type)??"llm",modelName:e==null?void 0:e.model,tools:(e==null?void 0:e.tools)??[],skills:((n=e==null?void 0:e.skills)==null?void 0:n.map(i=>i.name))??[]}}function $he(e){return e?1+e.children.reduce((t,n)=>t+$he(n),0):1}function Qhe(e){return 1+e.subAgents.reduce((t,n)=>t+Qhe(n),0)}function QL(e){if(!e)return 0;const t=Number(e);if(Number.isFinite(t))return t<1e12?t*1e3:t;const n=Date.parse(e);return Number.isFinite(n)?n:0}function Xlt(e){const t=QL(e);return t?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"时间未知"}function qlt(e){return typeof e.score!="number"||!Number.isFinite(e.score)?"—":`${Math.round(e.score*100)} 分`}function Hlt(e){return e==="high"?"高":e==="medium"?"中":"低"}const Ylt={agent_structure:"Agent 结构",prompt:"提示词",tool:"工具",knowledge:"知识库",memory:"记忆",workflow:"工作流",other:"其他"};function Glt(e){var t;return e.module==="other"?((t=e.customModule)==null?void 0:t.trim())||"其他":Ylt[e.module]}function Wlt(e,t){return e.find(n=>n.kind===t)}function Dq(e){return e.items.map(t=>({...t,tag:t.kind==="good"?"Good case":"Bad case"})).sort((t,n)=>QL(n.createdAt)-QL(t.createdAt))}function Zlt(e){const t=n=>[n.name,n.description,n.agentType??"llm",n.modelName??"",n.tools??[],n.builtinTools??[],(n.customTools??[]).map(i=>i.name),(n.mcpTools??[]).map(i=>i.name),n.skills??[],(n.selectedSkills??[]).map(i=>i.name),(n.subAgents??[]).map(t)];return JSON.stringify(t(e))}const QO=[{phase:"prepare",label:"准备部署",description:"校验配置并创建部署任务"},{phase:"build",label:"构建镜像",description:"生成运行环境与智能体代码"},{phase:"deploy",label:"部署服务",description:"创建并启动 AgentKit Runtime"},{phase:"publish",label:"发布服务",description:"等待服务就绪并生成访问地址"},{phase:"complete",label:"部署完成",description:"智能体已可以正常使用"}],Klt={phase:"evaluation",label:"创建评测集",description:"自动创建 Good Case 和 Bad Case 评测集"};function Jlt(e){return{phase:"update",label:"更新实例配置",description:`将 Runtime 实例数调整为 ${e.min}~${e.max}`}}const ect=QO.findIndex(e=>e.phase==="build");function Bhe(e){const t=e.instanceRange?[...QO.slice(0,-1),Jlt(e.instanceRange),QO[QO.length-1]]:QO;return e.createEvaluationSets?[...t.slice(0,-1),Klt,t[t.length-1]]:t}function Uhe(e){const t=Bhe(e);if(e.status==="success")return t.length-1;const n=e.phase??{准备部署:"prepare",构建镜像:"build",部署:"deploy",发布:"publish",创建评测集:"evaluation",部署完成:"complete"}[e.label],i=t.findIndex(r=>r.phase===n);return i<0?0:i}function tct(e){if(!e)return"";try{return new Intl.DateTimeFormat("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(new Date(e))}catch{return""}}function nct({task:e}){const t=e.buildLog,n=m.useRef(null),i=(t==null?void 0:t.status)!=="complete"&&(e.status==="running"||e.status==="error")&&Uhe(e)===ect,[r,s]=m.useState(i),[a,o]=m.useState(!1),c=!!(t!=null&&t.text||t!=null&&t.error),u=(t==null?void 0:t.text)||(t==null?void 0:t.error)||"",d=u.split(` +\`\`\``}function Vlt({visible:e}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M2.8 12s3.3-5.4 9.2-5.4 9.2 5.4 9.2 5.4-3.3 5.4-9.2 5.4S2.8 12 2.8 12Z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2.4"}),!e&&l.jsx("path",{d:"m4.2 4.2 15.6 15.6"})]})}function Mq({available:e,authType:t,value:n,visible:i,loading:r,error:s,onToggle:a}){return e?t==="none"?"无需 API Key":t==="custom_jwt"?"使用 OAuth / JWT":t!=="key_auth"?"暂无":l.jsxs("span",{className:"aw-integration-secret",children:[l.jsx("span",{className:"aw-integration-secret-value","aria-live":"polite",children:i&&n?n:"****"}),l.jsx("button",{type:"button",className:"aw-integration-secret-toggle","aria-label":i?"隐藏 API Key":"显示 API Key",title:i?"隐藏 API Key":"显示 API Key",disabled:r,onClick:a,children:r?l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}):l.jsx(Vlt,{visible:i})}),s&&l.jsx("span",{className:"aw-integration-secret-error",role:"alert",children:s})]}):"暂无"}function Lq({protocol:e,title:t,available:n,fields:i,example:r}){return l.jsxs("section",{className:`aw-integration-panel${n&&r?" has-example":""}`,id:`integration-${e}-panel`,role:"tabpanel","aria-labelledby":`integration-${e}-tab`,children:[l.jsx("header",{children:l.jsx("h3",{children:t})}),l.jsx("dl",{children:i.map(s=>l.jsxs("div",{children:[l.jsx("dt",{children:s.label}),l.jsx("dd",{children:s.value||"暂无"})]},s.label))}),n&&r&&l.jsxs("section",{className:"aw-integration-example",children:[l.jsx("h4",{children:"Python 示例"}),l.jsx(qp,{text:r,className:"aw-integration-example-code",allowRawHtml:!1})]})]})}function $he(e){const t=e.tools??[],n=Qp.filter(r=>r.toolNames.some(s=>t.includes(s))),i=new Set(n.flatMap(r=>r.toolNames));return{...el(),modelSource:void 0,name:e.name,description:e.description,instruction:e.instruction||el().instruction,agentType:e.type,modelName:e.model,tools:t.filter(r=>!i.has(r)),builtinTools:n.map(r=>r.id),skills:(e.skills??[]).map(r=>r.name),subAgents:(e.children??[]).map($he)}}function Xlt(e,t){var n;return e!=null&&e.draft?e.draft:e!=null&&e.graph?$he(e.graph):{...el(),modelSource:void 0,name:(e==null?void 0:e.name)||t,description:(e==null?void 0:e.description)||"暂无描述",agentType:(e==null?void 0:e.type)??"llm",modelName:e==null?void 0:e.model,tools:(e==null?void 0:e.tools)??[],skills:((n=e==null?void 0:e.skills)==null?void 0:n.map(i=>i.name))??[]}}function Qhe(e){return e?1+e.children.reduce((t,n)=>t+Qhe(n),0):1}function Bhe(e){return 1+e.subAgents.reduce((t,n)=>t+Bhe(n),0)}function QL(e){if(!e)return 0;const t=Number(e);if(Number.isFinite(t))return t<1e12?t*1e3:t;const n=Date.parse(e);return Number.isFinite(n)?n:0}function qlt(e){const t=QL(e);return t?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"时间未知"}function Hlt(e){return typeof e.score!="number"||!Number.isFinite(e.score)?"—":`${Math.round(e.score*100)} 分`}function Ylt(e){return e==="high"?"高":e==="medium"?"中":"低"}const Glt={agent_structure:"Agent 结构",prompt:"提示词",tool:"工具",knowledge:"知识库",memory:"记忆",workflow:"工作流",other:"其他"};function Wlt(e){var t;return e.module==="other"?((t=e.customModule)==null?void 0:t.trim())||"其他":Glt[e.module]}function Zlt(e,t){return e.find(n=>n.kind===t)}function Dq(e){return e.items.map(t=>({...t,tag:t.kind==="good"?"Good case":"Bad case"})).sort((t,n)=>QL(n.createdAt)-QL(t.createdAt))}function Klt(e){const t=n=>[n.name,n.description,n.agentType??"llm",n.modelName??"",n.tools??[],n.builtinTools??[],(n.customTools??[]).map(i=>i.name),(n.mcpTools??[]).map(i=>i.name),n.skills??[],(n.selectedSkills??[]).map(i=>i.name),(n.subAgents??[]).map(t)];return JSON.stringify(t(e))}const QO=[{phase:"prepare",label:"准备部署",description:"校验配置并创建部署任务"},{phase:"build",label:"构建镜像",description:"生成运行环境与智能体代码"},{phase:"deploy",label:"部署服务",description:"创建并启动 AgentKit Runtime"},{phase:"publish",label:"发布服务",description:"等待服务就绪并生成访问地址"},{phase:"complete",label:"部署完成",description:"智能体已可以正常使用"}],Jlt={phase:"evaluation",label:"创建评测集",description:"自动创建 Good Case 和 Bad Case 评测集"};function ect(e){return{phase:"update",label:"更新实例配置",description:`将 Runtime 实例数调整为 ${e.min}~${e.max}`}}const tct=QO.findIndex(e=>e.phase==="build");function Uhe(e){const t=e.instanceRange?[...QO.slice(0,-1),ect(e.instanceRange),QO[QO.length-1]]:QO;return e.createEvaluationSets?[...t.slice(0,-1),Jlt,t[t.length-1]]:t}function zhe(e){const t=Uhe(e);if(e.status==="success")return t.length-1;const n=e.phase??{准备部署:"prepare",构建镜像:"build",部署:"deploy",发布:"publish",创建评测集:"evaluation",部署完成:"complete"}[e.label],i=t.findIndex(r=>r.phase===n);return i<0?0:i}function nct(e){if(!e)return"";try{return new Intl.DateTimeFormat("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(new Date(e))}catch{return""}}function ict({task:e}){const t=e.buildLog,n=m.useRef(null),i=(t==null?void 0:t.status)!=="complete"&&(e.status==="running"||e.status==="error")&&zhe(e)===tct,[r,s]=m.useState(i),[a,o]=m.useState(!1),c=!!(t!=null&&t.text||t!=null&&t.error),u=(t==null?void 0:t.text)||(t==null?void 0:t.error)||"",d=u.split(` `),f=r?u:d.slice(-36).join(` -`),h=(t==null?void 0:t.pendingMessage)||"正在等待构建日志…";if(m.useEffect(()=>{t&&s(i)},[e.id,t==null?void 0:t.status,i]),m.useEffect(()=>{if(!r||!c)return;const v=n.current;v&&(v.scrollTop=v.scrollHeight)},[r,c,f]),!t||!t.text&&t.status!=="error"&&!t.pendingMessage)return null;const p=tct(t.updatedAt),g=t.status==="complete"?"已同步":t.status==="error"?"读取失败":"同步中",b=t.omittedEarly?"已省略早期日志":t.snapshotTruncated?"仅显示最近的构建日志":t.truncated?"已省略部分日志":"",y=[g,t.lineCount?`${t.lineCount} 行`:"",b,p].filter(Boolean).join(" · ");async function O(){try{await navigator.clipboard.writeText(u),o(!0),window.setTimeout(()=>o(!1),1500)}catch{o(!1)}}return l.jsxs("section",{className:`aw-deploy-log is-${t.status}${r?"":" is-collapsed"}`,"aria-label":"构建日志",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"构建日志"}),l.jsx("span",{children:y})]}),l.jsxs("div",{className:"aw-deploy-log-actions",children:[c&&l.jsx("button",{type:"button",onClick:()=>s(v=>!v),children:r?"收起":"展开"}),c&&l.jsxs("button",{type:"button",onClick:()=>void O(),"aria-label":a?"已复制构建日志":"复制构建日志",title:a?"已复制":"复制构建日志",children:[a?l.jsx(Hc,{"aria-hidden":!0}):l.jsx(g_,{"aria-hidden":!0}),l.jsx("span",{children:a?"已复制":"复制"})]})]})]}),r&&(c?l.jsx("pre",{ref:n,children:f}):l.jsx("div",{className:"aw-deploy-log-empty",children:h}))]})}function ict({task:e,onReturnToEdit:t}){const n=Bhe(e),i=Uhe(e),r=e.status==="success"?100:Math.max(6,Math.min(100,e.pct??6)),s=e.status==="running"?"正在部署":e.status==="success"?"部署完成":e.status==="error"?"部署失败":"部署已取消";return l.jsxs("section",{className:`aw-deploy-progress-card is-${e.status}`,"aria-live":"polite",children:[l.jsxs("div",{className:"aw-deploy-progress-head",children:[l.jsxs("div",{children:[l.jsx("span",{className:"aw-deploy-progress-icon","aria-hidden":!0,children:e.status==="running"?l.jsx(Kn,{className:"spin"}):e.status==="success"?l.jsx(Uwe,{}):e.status==="error"?l.jsx(cJ,{}):l.jsx(n9,{})}),l.jsxs("div",{children:[l.jsx("h3",{children:s}),l.jsx("p",{children:e.runtimeName})]})]}),l.jsx("strong",{children:e.status==="running"?`${Math.round(r)}%`:e.label})]}),l.jsx("div",{className:"aw-deploy-progress-track",role:"progressbar","aria-label":"部署进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:l.jsx("span",{style:{width:`${r}%`}})}),l.jsx("ol",{className:"aw-deploy-steps",children:n.map((a,o)=>{const c=e.status==="success"||onew Set),[Qt,Yt]=m.useState(()=>new Set),[Jt,Ft]=m.useState(!1),[Ce,et]=m.useState(""),[wt,yn]=m.useState(null),[on,hi]=m.useState([]),[Pe,st]=m.useState([]),[At,Ut]=m.useState(!1),[kn,wn]=m.useState(""),[Ai,Gn]=m.useState(""),[xn,de]=m.useState(0),[Le,ut]=m.useState([]),[gt,ln]=m.useState(!1),[Sn,In]=m.useState(""),[Ni,Pn]=m.useState(0),[Vt,Ji]=m.useState(null),[fn,pi]=m.useState(1),[ti,vi]=m.useState(!1),[en,Ci]=m.useState(""),[xs,ni]=m.useState(0),[Ls,er]=m.useState(!1),[Ya,mr]=m.useState(()=>new Set),[gr,ul]=m.useState(!1),[Sa,as]=m.useState(""),[Mn,vs]=m.useState(""),[Zl,Gr]=m.useState(()=>new Set),tr=m.useRef(!1),No=m.useRef(""),Dr=m.useRef(null),os=m.useRef(0),na=m.useRef(0),Co=m.useRef(0),[br,ia]=m.useState(Llt),[ji,Kl]=m.useState("");m.useEffect(()=>{e.length!==0&&ia(Y=>Y.map((he,be)=>be===0&&he.agentIds.length===0?{...he,agentIds:e.slice(0,2).map(Ue=>Ue.id)}:he))},[e]);const Ke=m.useMemo(()=>{const Y=new Map;for(const he of e)he.runtimeId&&Y.set(he.runtimeId,he);return Y},[e]),Ds=m.useMemo(()=>{var he;const Y=new Map;for(const be of t){const Ue=(he=be.deploymentTarget)==null?void 0:he.runtimeId;if(!Ue||!Ke.has(Ue))continue;const xt=Y.get(Ue);(!xt||be.updatedAt>xt.updatedAt)&&Y.set(Ue,be)}return Y},[Ke,t]),Ea=m.useMemo(()=>{const Y=new Map;for(const he of f){if(!he.runtimeId)continue;const be=Y.get(he.runtimeId);(!be||he.startedAt>be.startedAt)&&Y.set(he.runtimeId,he)}return Y},[f]),nu=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return Y?e.filter(he=>{const be=he.runtimeId?Ds.get(he.runtimeId):void 0,Ue=he.runtimeId?Ea.get(he.runtimeId):void 0;return[he.label,he.app,he.host??"",(be==null?void 0:be.draft.name)??"",(be==null?void 0:be.draft.description)??"",(Ue==null?void 0:Ue.runtimeName)??""].join(" ").toLowerCase().includes(Y)}):e},[e,Ea,ve,Ds]),$s=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return t.filter(he=>{var Ue;const be=(Ue=he.deploymentTarget)==null?void 0:Ue.runtimeId;return be&&Ke.has(be)?!1:Y?`${he.draft.name} ${he.draft.description}`.toLowerCase().includes(Y):!0})},[Ke,t,ve]),Jl=m.useMemo(()=>t.filter(Y=>{var be;const he=(be=Y.deploymentTarget)==null?void 0:be.runtimeId;return!he||!Ke.has(he)}).length,[Ke,t]),ec=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return Y?br.filter(he=>he.name.toLowerCase().includes(Y)):br},[br,ve]),le=e.find(Y=>Y.id===$),gn=t.find(Y=>Y.id===B),Wn=h?f.find(Y=>Y.id===h):void 0,Vi=le!=null&&le.runtimeId?Ds.get(le.runtimeId):void 0,Ln=O?K:$&&r===$?i:null,Tn=(Ln==null?void 0:Ln.appName)||(le==null?void 0:le.runtimeApp)||(le==null?void 0:le.app)||"",ra=c&&(le!=null&&le.runtimeId)?Iq:Iq.filter(Y=>Y.id!=="usage"),Qs=JSON.stringify([(le==null?void 0:le.runtimeId)??"",(le==null?void 0:le.region)??"cn-beijing",Tn,fn]),dr=(Vt==null?void 0:Vt.requestKey)===Qs?Vt.value:null,ws=`${(le==null?void 0:le.region)??"cn-beijing"}:${(le==null?void 0:le.runtimeId)??""}`,ls=(Re==null?void 0:Re.requestKey)===ws?Re.value:"",te=(D==null?void 0:D.requestKey)===ws?D:null,Me=!!((yv=te==null?void 0:te.apiApps)!=null&&yv.length),ee=!!(te!=null&&te.a2a),_e=((xv=te==null?void 0:te.apiApps)==null?void 0:xv[0])??Tn,tt=(X==null?void 0:X.endpoint)??"",Ct=Blt(((Eb=te==null?void 0:te.a2a)==null?void 0:Eb.endpoint)??"",tt),He=JSON.stringify([(le==null?void 0:le.runtimeId)??"",(le==null?void 0:le.region)??"",Tn]),ht=(De==null?void 0:De.requestKey)===He?De.value:null;m.useEffect(()=>{const Y=os.current+1;os.current=Y,mt(null),W("");const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"";if(!o||!he||!be){Rt(!1);return}const Ue=new AbortController;return Rt(!0),hee({runtimeId:he,region:be,appName:Tn,signal:Ue.signal}).then(xt=>{var Xt,Ri;if(Y===os.current){if(xt.runtime.runtimeId!==he||xt.runtime.region!==be||Tn&&((Xt=xt.agent)==null?void 0:Xt.appName)!==Tn||xt.canUpdate&&!((Ri=xt.agent)!=null&&Ri.appName)){W("Runtime 更新能力响应与当前选择不匹配。");return}mt({requestKey:He,value:xt})}}).catch(xt=>{Y!==os.current||Ue.signal.aborted||W(xt instanceof Error?xt.message:"检查 Runtime 更新能力失败。")}).finally(()=>{Y===os.current&&!Ue.signal.aborted&&Rt(!1)}),()=>Ue.abort()},[o,le==null?void 0:le.region,le==null?void 0:le.runtimeId,Tn,He]);const Pt=m.useMemo(()=>{const Y=new Map(e.map((be,Ue)=>[be.id,Ue])),he=new Map(n.map((be,Ue)=>[be,Ue]));return[...nu].sort((be,Ue)=>{const xt=be.runtimeId?Ea.get(be.runtimeId):void 0,Xt=Ue.runtimeId?Ea.get(Ue.runtimeId):void 0,Ri=(xt==null?void 0:xt.status)==="running"?xt.startedAt:0,nc=(Xt==null?void 0:Xt.status)==="running"?Xt.startedAt:0;if(Ri!==nc)return nc-Ri;const gi=he.get(be.id),ic=he.get(Ue.id);return gi!=null&&ic!=null?gi-ic:gi!=null?-1:ic!=null?1:(Y.get(be.id)??0)-(Y.get(Ue.id)??0)})},[n,e,nu,Ea]),jt=(le==null?void 0:le.label)||(Ln==null?void 0:Ln.name)||(gn==null?void 0:gn.draft.name)||(Wn==null?void 0:Wn.agentName)||((vv=Wn==null?void 0:Wn.agentDraft)==null?void 0:vv.name)||"未选择智能体",bn=br.find(Y=>Y.id===ji),Xi=Pt.filter(Y=>Y.canDelete===!0),Ss=Pt.filter(Y=>Wt.has(Y.id)&&Y.canDelete===!0),Dn=$s.filter(Y=>Qt.has(Y.id)),Wr=Xi.length+$s.length,sa=Ss.length+Dn.length,qi=m.useMemo(()=>(Wn==null?void 0:Wn.agentDraft)??(gn==null?void 0:gn.draft)??(Vi==null?void 0:Vi.draft)??Vlt(Ln,Tn||(le==null?void 0:le.label)||"agent"),[Ln,Tn,le==null?void 0:le.label,Vi==null?void 0:Vi.draft,gn==null?void 0:gn.draft,Wn==null?void 0:Wn.agentDraft]),Xe=gn?a?"":"当前账号没有新建 Agent 的权限。":o?le!=null&&le.runtimeId?le.region?at?"正在检查 Runtime 更新能力…":qe||(ht?ht.canUpdate?(Zp=ht.agent)!=null&&Zp.appName?"":"Runtime 更新能力响应缺少智能体信息。":ht.reason||"当前 Runtime 不支持原地更新。":"尚未完成 Runtime 更新能力检查。"):"Runtime 缺少地域信息,无法更新。":"仅支持更新已部署的云端智能体。":"当前账号没有管理 Agent 的权限。",_n="aw-update-disabled-reason",dl=ht!=null&&ht.agent?{runtimeId:ht.runtime.runtimeId,name:ht.runtime.name,region:ht.runtime.region,appName:ht.agent.appName,currentVersion:ht.runtime.currentVersion}:Vi==null?void 0:Vi.deploymentTarget,fl=m.useMemo(()=>{if(Ln)return Ln.tools;const Y=(qi.builtinTools??[]).map(he=>{var be;return((be=Qp.find(Ue=>Ue.id===he))==null?void 0:be.label)??he});return Array.from(new Set([...qi.tools,...Y,...(qi.customTools??[]).map(he=>he.name),...(qi.mcpTools??[]).map(he=>he.name)].filter(Boolean)))},[qi,Ln]),mi=m.useMemo(()=>Ln?Ln.skillsPreviewSupported?Ln.skills.map(Y=>Y.name):null:Array.from(new Set([...(qi.selectedSkills??[]).map(Y=>Y.name),...qi.skills].filter(Boolean))),[qi,Ln]),Zn=m.useMemo(()=>{if(Wn)return Wn;if(gn)return f.filter(Y=>{var he,be;return((he=Y.agentDraft)==null?void 0:he.name)===gn.draft.name||Y.agentName===gn.draft.name||!!((be=gn.deploymentTarget)!=null&&be.runtimeId)&&Y.runtimeId===gn.deploymentTarget.runtimeId}).sort((Y,he)=>he.startedAt-Y.startedAt)[0];if(le)return f.filter(Y=>!!le.runtimeId&&Y.runtimeId===le.runtimeId||Y.agentName===le.label).sort((Y,he)=>he.startedAt-Y.startedAt)[0]},[f,le,gn,Wn]),cv=!!(h&&Zn&&Zn.id===h),yb=!!(Zn&&(Zn.status!=="success"||cv)),uv=(Zn==null?void 0:Zn.status)==="running",tc=Zn!=null&&Zn.draftId?t.find(Y=>Y.id===Zn.draftId)??(Zn.agentDraft?{id:Zn.draftId,draft:Zn.agentDraft,updatedAt:Zn.startedAt}:void 0):void 0,dv=m.useMemo(()=>Zlt(qi),[qi]),hl=(le==null?void 0:le.currentVersion)??(X==null?void 0:X.currentVersion)??null,sN=hl??(Wn==null?void 0:Wn.startedAt)??"unknown",$n=Ln?`runtime:${(le==null?void 0:le.runtimeId)??Ln.name}:v${sN}:${dv}`:`draft:${(Wn==null?void 0:Wn.id)??(gn==null?void 0:gn.id)??(le==null?void 0:le.id)??jt}:${dv}`;m.useEffect(()=>{Q==="usage"&&!c&&j("basic")},[c,Q]),m.useEffect(()=>{if(!h)return;const Y=f.find(be=>be.id===h),he=Y!=null&&Y.runtimeId?Ke.get(Y.runtimeId):void 0;if(he){I(""),U(he.id),j("basic");return}U(""),I(""),j("basic")},[Ke,f,h]),m.useEffect(()=>{if(!p){No.current="";return}const Y=`${p}:${g}:${b}:${c}`;No.current!==Y&&e.some(he=>he.id===p)&&(No.current=Y,I(""),U(p),j(g==="usage"&&!c?"basic":g),g==="evaluations"&&(kt(b),Tt("")))},[e,c,p,g,b]),m.useEffect(()=>{for(const Y of Pt.slice(0,8)){if(!Y.runtimeId)continue;const he=Y.region??"cn-beijing";mee(Y.runtimeId,he),ZJ(Y.runtimeId,he,Y.runtimeApp??""),Ok(Y.runtimeId,he,Y.runtimeApp??"").then(be=>{const Ue=be.appName||Y.app;Ue&&nP({runtimeId:Y.runtimeId??"",region:he,appName:Ue,pageSize:100})}).catch(()=>{})}},[Pt]),m.useEffect(()=>{!(le!=null&&le.runtimeId)||!Tn||nP({runtimeId:le.runtimeId,region:le.region??"cn-beijing",appName:Tn,pageSize:100})},[Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=(le==null?void 0:le.runtimeApp)??"",xt=he?WJ(he,be,Ue):null;if(ae(xt),z(!!xt||!O||!he),!(!O||!he))return Ok(he,be,Ue,{force:!0}).then(Xt=>{Y||ae(Xt)}).catch(()=>{!Y&&!xt&&ae(null)}).finally(()=>{Y||z(!0)}),()=>{Y=!0}},[O,le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeApp,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing";if(ut([]),In(""),Q!=="optimizations"||!he){ln(!1);return}if(O&&!Tn){ln(!pe);return}return ln(!0),DJ({runtimeId:he,region:be,appName:Tn}).then(Ue=>{Y||ut(Ue.groups)}).catch(Ue=>{Y||In(Ue instanceof Error?Ue.message:String(Ue))}).finally(()=>{Y||ln(!1)}),()=>{Y=!0}},[pe,O,Ni,Q,Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{pi(1)},[le==null?void 0:le.runtimeId,Tn]),m.useEffect(()=>{const Y=Co.current+1;Co.current=Y;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=Tn;if(Ci(""),Q!=="usage"||!he){vi(!1);return}if(!Ue){vi(O&&!pe);return}const xt=new AbortController;return vi(!0),cee({runtimeId:he,region:be,appName:Ue,page:fn,pageSize:Dlt,signal:xt.signal}).then(Xt=>{if(Y===Co.current){if(Xt.runtimeId!==he||Xt.appName!==Ue||Xt.page!==fn){Ci("用量响应与当前 Agent 不匹配,请重试。");return}Ji({requestKey:Qs,value:Xt})}}).catch(Xt=>{Y!==Co.current||xt.signal.aborted||Ci(Xt instanceof Error?Xt.message:"加载 Agent 用量失败。")}).finally(()=>{Y===Co.current&&vi(!1)}),()=>{xt.abort()}},[fn,xs,Qs,pe,O,Q,Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{na.current+=1,Ee(null),oe(!1),Oe(!1),We(""),Se("api-server")},[ws,Q]);function fv(){na.current+=1,Ee(null),oe(!1),Oe(!1),We("")}function hv(Y){Y!==ye&&(fv(),Se(Y))}async function pv(){if(me){fv();return}const Y=(le==null?void 0:le.runtimeId)??"",he=(le==null?void 0:le.region)??"cn-beijing";if(!Y)return;const be=na.current+1;na.current=be,Oe(!0),We("");try{const Ue=await dee(Y,he);if(be!==na.current)return;Ee({requestKey:ws,value:Ue}),oe(!0)}catch(Ue){if(be!==na.current)return;Ee(null),oe(!1),We(Ue instanceof Error?Ue.message:"读取 Runtime API Key 失败。")}finally{be===na.current&&Oe(!1)}}m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=he?pee(he,be):null;if(q(Ue),!!he)return e$(he,be,{force:!0}).then(xt=>{Y||q(xt)}).catch(()=>{!Y&&!Ue&&q(null)}),()=>{Y=!0}},[le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=`${be}:${he}`;if(J(""),Q!=="integrations"||!he){fe(!1),he||H(null);return}fe(!0);const xt=JD(he,be,{retryProbe:!0}).catch(Xt=>{if(Xt instanceof ga&&Xt.unsupported)return null;throw Xt});return Promise.all([xt,uee(he,be,{retryProbe:!0})]).then(([Xt,Ri])=>{Y||H({requestKey:Ue,apiApps:Xt,a2a:Ri})}).catch(Xt=>{Y||(H(null),J(Xt instanceof Error?Xt.message:"探测集成方式失败。"))}).finally(()=>{Y||fe(!1)}),()=>{Y=!0}},[ie,Q,le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=he&&Tn?$J({runtimeId:he,region:be,appName:Tn,pageSize:100}):null;if(hi(Ue?Dq(Ue):[]),st((Ue==null?void 0:Ue.sets)??[]),wn(""),Gn((Ue==null?void 0:Ue.unsupportedMessage)??""),Q!=="evaluations"||!he){Ut(!1);return}if(O&&!Tn){Ut(!pe);return}return Ut(!Ue),w_({runtimeId:he,region:be,appName:Tn,pageSize:100},{force:!0}).then(xt=>{Y||(st(xt.sets),hi(Dq(xt)),Gn(xt.unsupportedMessage??""))}).catch(xt=>{Y||(wn(xt instanceof Error?xt.message:String(xt)),Gn(""))}).finally(()=>{Y||Ut(!1)}),()=>{Y=!0}},[pe,O,xn,Q,Tn,Ln==null?void 0:Ln.appName,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{const Y=new Set(on.map(he=>he.id));mr(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be}),Gr(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be}),Mn&&!Y.has(Mn)&&vs("")},[on,Mn]),m.useEffect(()=>{er(!1),mr(new Set),Gr(new Set),as(""),vs("")},[le==null?void 0:le.runtimeId]),m.useEffect(()=>{const Y=new Set(Pt.filter(he=>he.canDelete===!0).map(he=>he.id));dn(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be})},[Pt]),m.useEffect(()=>{const Y=new Set($s.map(he=>he.id));Yt(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be})},[$s]);const Sd=m.useMemo(()=>!y||!(le!=null&&le.runtimeId)||y.runtimeId!==le.runtimeId||Tn&&y.agentName&&y.agentName!==Tn?null:{...y,tag:y.kind==="good"?"Good case":"Bad case"},[y,le==null?void 0:le.runtimeId,Tn]),Gp=m.useMemo(()=>le!=null&&le.runtimeId?Sd?[Sd,...on.filter(Y=>Y.id!==Sd.id&&(!Y.messageId||Y.messageId!==Sd.messageId))]:on:Mlt,[on,Sd,le==null?void 0:le.runtimeId]),pl=Gp.filter(Y=>{if(Y.kind!==Je||(Y.source==="auto"?"auto":"user")!==dt)return!1;const be=Mt.trim().toLowerCase();return be?[Y.input,Y.output,Y.referenceOutput,Y.comment,Y.tag??"",Y.sessionId,Y.messageId,Y.userId,Y.evaluationSetName].join(" ").toLowerCase().includes(be):!0}),xb=pl.filter(Y=>Ya.has(Y.id)),Ed=!!(le!=null&&le.runtimeId),vb=Y=>{kt(Y),Tt(""),as("");const he=Gp.find(be=>be.kind===Y);vs((he==null?void 0:he.id)??""),window.setTimeout(()=>{var be;(be=Dr.current)==null||be.scrollIntoView({behavior:"smooth",block:"start"})},0)},aN=Y=>{as(""),mr(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be})},mv=()=>{as(""),mr(new Set(pl.map(Y=>Y.id)))},oN=()=>{as(""),mr(new Set),er(!1)},Wp=Y=>{Gr(he=>{const be=new Set(he);return be.has(Y)?be.delete(Y):be.add(Y),be})},lN=Y=>{vs(Y.id),as(""),!(!Y.sessionId||!Y.messageId)&&(T==null||T(Y))},wb=async Y=>{if(!(le!=null&&le.runtimeId)||!Tn||gr||Y.length===0)return;const he=Y.length===1?"确定删除这条反馈案例?原始聊天记录不会被删除。":`确定删除选中的 ${Y.length} 条反馈案例?原始聊天记录不会被删除。`;if(!window.confirm(he))return;const be=Y.map(xt=>xt.id),Ue=new Set(be);ul(!0),as("");try{await UJ({runtimeId:le.runtimeId,region:le.region??"cn-beijing",appName:Tn,itemIds:be});const xt=new Map;for(const Xt of Y)xt.set(Xt.kind,(xt.get(Xt.kind)??0)+1);hi(Xt=>Xt.filter(Ri=>!Ue.has(Ri.id))),st(Xt=>Xt.map(Ri=>({...Ri,itemCount:Math.max(0,Ri.itemCount-(xt.get(Ri.kind)??0))}))),mr(Xt=>new Set([...Xt].filter(Ri=>!Ue.has(Ri)))),Gr(Xt=>new Set([...Xt].filter(Ri=>!Ue.has(Ri)))),Mn&&Ue.has(Mn)&&vs(""),Y.length>1&&er(!1),A==null||A(Y)}catch(xt){as(xt instanceof Error?xt.message:String(xt))}finally{ul(!1)}},gv=Y=>{ia(he=>he.map(be=>be.id===Y.id?Y:be))},iu=()=>{const Y=new Set(e.map(Ue=>Ue.id)),he=n.filter(Ue=>Y.has(Ue)),be=new Set(he);return[...he,...e.filter(Ue=>!be.has(Ue.id)).map(Ue=>Ue.id)]},bv=(Y,he,be)=>{if(!x||Y===he)return;const Ue=iu().filter(Ri=>Ri!==Y),xt=Ue.indexOf(he),Xt=xt<0?Ue.length:be==="after"?xt+1:xt;Ue.splice(Xt,0,Y),x(Ue)},ru=(Y,he)=>{if(!lt||lt===he)return;const be=Y.currentTarget.getBoundingClientRect();_t(he),je(Y.clientY>be.top+be.height/2?"after":"before")},ah=(Y,he)=>{if(!x)return;const be=iu(),Ue=be.indexOf(Y),xt=Math.max(0,Math.min(be.length-1,Ue+he));Ue<0||Ue===xt||(be.splice(Ue,1),be.splice(xt,0,Y),x(be))},cN=Y=>{Y.canDelete===!0&&(et(""),dn(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be}))},jo=Y=>{et(""),Yt(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be})},uN=()=>{et(""),dn(new Set(Xi.map(Y=>Y.id))),Yt(new Set($s.map(Y=>Y.id)))},vn=()=>{et(""),dn(new Set),Yt(new Set),Ie(!1)},dN=()=>{if(sa===0||Jt)return;const Y=Ss.length,he=Dn.length;et(""),yn({kind:"selection",title:Y===1&&he===0?"删除 Agent?":Y===0&&he===1?"删除草稿?":"删除所选项目?",description:Y===1&&he===0?`"${Ss[0].label}" 对应的云端 Runtime 将被永久删除,此操作不可撤销。`:Y===0&&he===1?`"${Dn[0].draft.name||"未命名 Agent"}" 将从本地草稿中删除。`:`将删除选中的 ${sa} 个项目。${Y>0?`${Y} 个云端 Runtime 将被永久删除,此操作不可撤销。`:"草稿删除后无法恢复。"}`,confirmLabel:Y===0&&he===1?"删除草稿":"删除所选",agents:Ss,drafts:Dn})},fN=async()=>{if(!(!wt||Jt)){Ft(!0),et("");try{if(wt.kind==="selection"){const{agents:Y,drafts:he}=wt;if(Y.length>0){if(!w)throw new Error("当前页面不支持删除已部署 Agent。");await w(Y)}he.length>0&&(E==null||E(he)),dn(new Set),Yt(new Set),Ie(!1),Y.some(be=>be.id===$)&&U(""),he.some(be=>be.id===B)&&I("")}else if(wt.kind==="agent"){if(!w)throw new Error("当前页面不支持删除已部署 Agent。");await w([wt.agent]),$===wt.agent.id&&U("")}else{if(!E)throw new Error("当前页面不支持删除草稿。");E([wt.draft]),B===wt.draft.id&&I("")}yn(null)}catch(Y){et(Y instanceof Error?Y.message:String(Y))}finally{Ft(!1)}}},hN=Y=>{!w||Y.canDelete!==!0||Jt||(et(""),yn({kind:"agent",title:"删除 Agent?",description:`"${Y.label}" 对应的云端 Runtime 将被永久删除,此操作不可撤销。`,confirmLabel:"删除 Agent",agent:Y}))},nr=Y=>{if(!E||Jt)return;const he=Y.draft.name||"未命名 Agent";et(""),yn({kind:"draft",title:"删除草稿?",description:`"${he}" 将从本地草稿中删除。`,confirmLabel:"删除草稿",draft:Y})},Ov=()=>{const Y=`eval-${Date.now()}`,he={id:Y,name:`新评测组 ${br.length+1}`,agentIds:[],caseSet:"核心回归集",evaluator:"综合质量评估器",metrics:["回答质量"],concurrency:"4",history:[]};ia(be=>[he,...be]),Kl(Y)},Sb=Y=>{gv({...Y,history:[{id:`run-${Date.now()}`,createdAt:"刚刚",score:86+Y.history.length%7,status:"completed"},...Y.history]})};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`aw-root${O?" is-detail-only":""}`,children:[l.jsxs("nav",{className:"aw-view-tabs","aria-label":"智能体工作台",children:[l.jsx("button",{type:"button",className:L==="library"?"is-active":"","aria-pressed":L==="library",onClick:()=>{P("library"),Be("")},children:"智能体库"}),l.jsx("button",{type:"button",className:L==="evaluation"?"is-active":"","aria-pressed":L==="evaluation",onClick:()=>{P("evaluation"),Be("")},children:"评测"})]}),l.jsxs("div",{className:"aw-workspace-frame",children:[l.jsxs("div",{className:"aw-workspace","aria-hidden":L==="evaluation"||void 0,ref:Y=>{Y==null||Y.toggleAttribute("inert",L==="evaluation")},children:[l.jsxs("aside",{className:"aw-sidebar","aria-label":L==="library"?"智能体列表":"评测组列表",children:[l.jsxs("label",{className:"aw-search",children:[l.jsx(hk,{"aria-hidden":!0}),l.jsx("input",{value:ve,onChange:Y=>Be(Y.currentTarget.value),placeholder:L==="library"?"搜索智能体":"搜索评测组","aria-label":L==="library"?"搜索智能体":"搜索评测组"})]}),l.jsxs("button",{type:"button",className:"aw-create-card",onClick:L==="library"?N:Ov,disabled:L==="library"&&!a,children:[l.jsx(Gs,{"aria-hidden":!0}),l.jsx("span",{children:L==="library"?"新建 Agent":"新建评测组"})]}),L==="library"&&(w||E)&&l.jsx("div",{className:`aw-selection-toolbar${Ze?" is-active":""}`,children:Ze?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"aw-selection-count",children:["已选 ",sa," 个"]}),l.jsx("button",{type:"button",onClick:uN,disabled:Wr===0||Jt,children:"全选"}),l.jsx("button",{type:"button",className:"aw-selection-danger",onClick:()=>void dN(),disabled:sa===0||Jt,children:Jt?"删除中…":"删除所选"}),l.jsx("button",{type:"button",onClick:vn,disabled:Jt,children:"取消"})]}):l.jsx("button",{type:"button",onClick:()=>{et(""),Ie(!0)},disabled:Wr===0,children:"选择"})}),L==="library"&&Ce&&l.jsx("div",{className:"aw-delete-error",role:"alert",children:Ce}),l.jsx("div",{className:"aw-agent-list",children:L==="evaluation"?ec.length===0?l.jsx("div",{className:"aw-list-empty",children:"没有匹配的评测组"}):ec.map(Y=>l.jsxs("button",{type:"button",className:`aw-agent-item${Y.id===ji?" is-active":""}`,onClick:()=>Kl(Y.id),children:[l.jsxs("span",{className:"aw-agent-copy aw-eval-group-copy",children:[l.jsx("strong",{children:Y.name}),l.jsxs("small",{children:[Y.agentIds.length," 个智能体 · ",Y.history.length," 次运行"]})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)):u&&Pt.length===0&&$s.length===0?l.jsx("div",{className:"aw-list-empty",children:"正在读取云端智能体…"}):d&&Pt.length===0&&$s.length===0?l.jsxs("div",{className:"aw-list-empty aw-list-error",children:[l.jsx("span",{children:d}),v&&l.jsx("button",{type:"button",onClick:v,children:"重试"})]}):Pt.length===0&&$s.length===0?l.jsx("div",{className:"aw-list-empty",children:"没有匹配的智能体"}):l.jsxs(l.Fragment,{children:[$s.map(Y=>{const he=f.filter(Ue=>{var xt,Xt;return((xt=Ue.agentDraft)==null?void 0:xt.name)===Y.draft.name||Ue.agentName===Y.draft.name||!!((Xt=Y.deploymentTarget)!=null&&Xt.runtimeId)&&Ue.runtimeId===Y.deploymentTarget.runtimeId}).sort((Ue,xt)=>xt.startedAt-Ue.startedAt)[0],be=Qt.has(Y.id);return l.jsxs("button",{type:"button",className:["aw-agent-item",Ze?"is-selecting":"",be?"is-selected-for-delete":"",Y.id===B?"is-active":""].filter(Boolean).join(" "),"aria-pressed":Ze?be:void 0,onClick:()=>{if(Ze){jo(Y);return}U(""),I(Y.id),j("basic")},children:[Ze&&l.jsx("span",{className:`aw-select-marker${be?" is-checked":""}`,"aria-hidden":"true"}),l.jsxs("span",{className:"aw-agent-copy",children:[l.jsxs("span",{className:"aw-agent-name-row",children:[l.jsx("strong",{children:Y.draft.name||"未命名 Agent"}),l.jsx("span",{className:`aw-draft-badge${(he==null?void 0:he.status)==="running"?" is-deploying":""}`,children:(he==null?void 0:he.status)==="running"?"部署中":"草稿"})]}),l.jsx("small",{children:Y.deploymentTarget?"待更新":"尚未发布"})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)}),Pt.map(Y=>{const he=Y.runtimeId?Ea.get(Y.runtimeId):void 0,be=Y.runtimeId?Ds.get(Y.runtimeId):void 0,Ue=Wt.has(Y.id),xt=Y.canDelete===!0,Xt=(he==null?void 0:he.status)==="running"?{label:"部署中",className:" is-deploying"}:(he==null?void 0:he.status)==="error"?{label:"失败",className:" is-error"}:(he==null?void 0:he.status)==="cancelled"?{label:"已取消",className:" is-muted"}:be?{label:"待更新",className:""}:null,Ri=(he==null?void 0:he.status)==="running"?"正在更新部署":be?"待更新":Y.remote?Y.host||"远程智能体":"本地智能体",nc=["aw-agent-item","aw-agent-item--sortable",Y.id===$?"is-active":"",Ze?"is-selecting":"",Ue?"is-selected-for-delete":"",Ze&&!xt?"is-selection-disabled":"",Y.id===lt?"is-dragging":"",Y.id===vt&&Y.id!==lt?`is-drop-target is-drop-${Bt}`:""].filter(Boolean).join(" ");return l.jsxs("button",{type:"button",draggable:!!x&&!Ze,className:nc,"aria-pressed":Ze?Ue:void 0,"aria-keyshortcuts":x?"Alt+ArrowUp Alt+ArrowDown":void 0,onDragStart:gi=>{x&&(tr.current=!0,Ge(Y.id),gi.dataTransfer.effectAllowed="move",gi.dataTransfer.setData("text/plain",Y.id))},onDragEnter:gi=>{ru(gi,Y.id)},onDragOver:gi=>{!lt||lt===Y.id||(gi.preventDefault(),gi.dataTransfer.dropEffect="move",ru(gi,Y.id))},onDragLeave:gi=>{const ic=gi.relatedTarget;ic instanceof Node&&gi.currentTarget.contains(ic)||vt===Y.id&&_t("")},onDrop:gi=>{gi.preventDefault();const ic=gi.dataTransfer.getData("text/plain")||lt;bv(ic,Y.id,Bt),Ge(""),_t(""),je("before")},onDragEnd:()=>{Ge(""),_t(""),je("before"),window.setTimeout(()=>{tr.current=!1},0)},onKeyDown:gi=>{gi.altKey&&(gi.key==="ArrowUp"?(gi.preventDefault(),ah(Y.id,-1)):gi.key==="ArrowDown"&&(gi.preventDefault(),ah(Y.id,1)))},onClick:gi=>{if(Ze){gi.preventDefault(),cN(Y);return}if(tr.current){gi.preventDefault(),tr.current=!1;return}I(""),U(Y.id),j("basic"),S(Y.id)},children:[Ze&&l.jsx("span",{className:`aw-select-marker${Ue?" is-checked":""}`,"aria-hidden":"true"}),l.jsxs("span",{className:"aw-agent-copy",children:[l.jsxs("span",{className:"aw-agent-name-row",children:[l.jsx("strong",{children:Y.label}),Y.currentVersion!=null&&l.jsxs("span",{className:"aw-version-badge",children:["v",Y.currentVersion]}),Xt&&l.jsx("span",{className:`aw-draft-badge${Xt.className}`,children:Xt.label})]}),l.jsx("small",{children:Ri})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)})]})}),l.jsxs("div",{className:"aw-list-count",children:["共 ",L==="library"?e.length+Jl:br.length," 个"]})]}),L==="evaluation"&&bn?l.jsx(lct,{group:bn,agents:e,cases:Gp,onChange:gv,onRun:Sb}):L==="evaluation"?l.jsx("main",{className:"aw-main aw-empty-selection",children:l.jsx("p",{children:"未选择评测组"})}):!le&&!gn&&!Wn?l.jsx("main",{className:"aw-main aw-empty-selection",children:l.jsx("p",{children:"未选择智能体"})}):l.jsxs("main",{className:`aw-main${uv?" is-deploying":""}`,children:[le&&!Ln&&s&&l.jsx("div",{className:"aw-detail-loading",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"aw-detail-loading-card",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:"正在加载智能体"}),l.jsx("small",{children:"正在读取配置与运行信息…"})]})]})}),Q==="integrations"&&re&&l.jsx("div",{className:"aw-detail-loading",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"aw-detail-loading-card",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:"正在探测接入方式"}),l.jsx("small",{children:"正在确认 API Server 与 A2A…"})]})]})}),l.jsxs("div",{className:"aw-agent-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"aw-agent-title-row",children:[l.jsx("h2",{children:jt}),hl!=null&&l.jsxs("span",{children:["v",hl]}),gn&&l.jsx("span",{children:"草稿"}),Vi&&l.jsx("span",{children:"待更新"}),!le&&!gn&&Wn&&l.jsx("span",{children:Wn.label})]}),l.jsx("p",{children:qi.description||(s||O&&!pe?"正在读取智能体信息…":"暂无描述")})]}),(gn||Vi||(le==null?void 0:le.canDelete))&&l.jsxs("div",{className:"aw-head-actions",children:[(gn||Vi)&&l.jsxs("button",{type:"button",className:"aw-head-delete aw-head-delete--draft",onClick:()=>{const Y=gn??Vi;Y&&nr(Y)},disabled:Jt,"aria-label":"删除草稿",title:"删除草稿",children:[l.jsx(If,{"aria-hidden":!0}),l.jsx("span",{children:"删除草稿"})]}),(le==null?void 0:le.canDelete)&&l.jsxs("button",{type:"button",className:"aw-head-delete",onClick:()=>void hN(le),disabled:Jt,"aria-label":"删除 Agent",title:"删除 Agent",children:[l.jsx(If,{"aria-hidden":!0}),l.jsx("span",{children:Jt?"删除中…":"删除 Agent"})]})]})]}),Zn&&yb&&l.jsx("div",{className:`aw-detail-deployment${uv?" is-running":""}`,children:l.jsx(ict,{task:Zn,onReturnToEdit:tc&&M?()=>M(tc):void 0})}),l.jsx("nav",{className:"aw-agent-tabs","aria-label":"智能体详情",role:"tablist",children:ra.map(Y=>l.jsx("button",{type:"button",id:`agent-${Y.id}-tab`,className:Q===Y.id?"is-active":"",role:"tab","aria-selected":Q===Y.id,"aria-controls":`agent-${Y.id}-panel`,tabIndex:Q===Y.id?0:-1,onClick:()=>j(Y.id),onKeyDown:he=>{var Xt;if(!["ArrowLeft","ArrowRight","Home","End"].includes(he.key))return;he.preventDefault();const be=ra.findIndex(Ri=>Ri.id===Y.id),Ue=he.key==="Home"?0:he.key==="End"?ra.length-1:(be+(he.key==="ArrowRight"?1:-1)+ra.length)%ra.length,xt=ra[Ue];j(xt.id),(Xt=document.getElementById(`agent-${xt.id}-tab`))==null||Xt.focus()},children:Y.label},Y.id))}),l.jsxs("div",{className:"aw-content",id:`agent-${Q}-panel`,role:"tabpanel","aria-labelledby":`agent-${Q}-tab`,children:[Q==="basic"&&l.jsxs("div",{className:"aw-basic-stack",children:[l.jsxs("section",{className:"aw-deployment-panel aw-settings-card",children:[l.jsx("div",{className:"aw-section-head",children:l.jsxs("div",{children:[l.jsx("h3",{children:"部署配置"}),l.jsx("p",{children:"配置目标环境与网络访问方式。"})]})}),l.jsxs("dl",{className:"aw-readonly-config",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"运行状态"}),l.jsxs("dd",{className:(X==null?void 0:X.status.toLowerCase())==="ready"?"is-ready":void 0,children:[(X==null?void 0:X.status.toLowerCase())==="ready"&&l.jsx("span",{className:"aw-status-dot"}),(X==null?void 0:X.status)||"读取中…"]})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"部署区域"}),l.jsx("dd",{children:(X==null?void 0:X.region)||(le==null?void 0:le.region)||(Zn==null?void 0:Zn.region)||"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"网络访问"}),l.jsx("dd",{children:X!=null&&X.networkTypes.length?X.networkTypes.join(" / "):"暂未提供"})]})]})]}),l.jsxs("section",{className:"aw-canvas-card",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"执行流程"})}),l.jsx("div",{className:"aw-canvas",children:l.jsx(px,{draft:qi,direction:"horizontal",selectedPath:[],onSelect:()=>{},onAdd:()=>{},onInsert:()=>{},onDelete:()=>{},readOnly:!0,interactivePreview:!0},$n)})]}),l.jsxs("section",{className:"aw-details-card",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"详细信息"})}),l.jsxs("dl",{className:"aw-facts",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:(Ln==null?void 0:Ln.model)||qi.modelName||"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"智能体数量"}),l.jsx("dd",{children:Ln!=null&&Ln.graph?$he(Ln.graph):Qhe(qi)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"工具"}),l.jsx("dd",{className:"aw-fact-badges",children:fl.length?fl.map(Y=>l.jsx("span",{children:Y},Y)):"暂无"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能"}),l.jsx("dd",{className:"aw-fact-badges",children:mi===null?"暂不支持预览":mi.length?mi.map(Y=>l.jsx("span",{children:Y},Y)):"暂无"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:hl!=null?`v${hl}`:"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:gn?"草稿":(Zn==null?void 0:Zn.status)==="error"?"部署失败":(Zn==null?void 0:Zn.status)==="cancelled"?"已取消":Vi?"待更新":l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"aw-status-dot"}),"可用"]})})]})]})]})]}),Q==="usage"&&(le==null?void 0:le.runtimeId)&&l.jsxs("section",{className:"aw-usage","aria-busy":ti,children:[l.jsx("div",{className:"aw-usage-intro",children:l.jsx("h3",{children:"使用概览"})}),ti&&!dr&&l.jsx("div",{className:"aw-usage-state",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载用量统计"})}),en&&l.jsxs("div",{className:"aw-usage-state is-error",role:"alert",children:[l.jsx("span",{children:en}),l.jsx("button",{type:"button",onClick:()=>ni(Y=>Y+1),children:"重试"})]}),!ti&&!en&&!dr&&!Tn&&l.jsx("div",{className:"aw-usage-state",children:"当前 Runtime 未返回可用的 Agent 应用名称,暂时无法读取用量。"}),dr&&l.jsxs(l.Fragment,{children:[l.jsxs("dl",{className:"aw-usage-summary","aria-label":"Agent 用量摘要",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"总调用次数"}),l.jsx("dd",{children:dr.totalInvocations.toLocaleString("zh-CN")})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"使用用户数"}),l.jsx("dd",{children:dr.totalUsers.toLocaleString("zh-CN")})]})]}),l.jsxs("div",{className:"aw-usage-users-head",children:[l.jsx("h3",{children:"用户明细"}),ti&&l.jsx(oi,{as:"span",role:"status","aria-live":"polite",children:"正在刷新"})]}),dr.users.length===0?l.jsx("div",{className:"aw-usage-state",children:"暂无使用记录。用户成功调用后将在这里显示。"}):l.jsx("div",{className:"aw-usage-table-wrap",children:l.jsxs("table",{className:"aw-usage-table",children:[l.jsx("caption",{children:"当前 Agent 的使用用户列表"}),l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"用户"}),l.jsx("th",{scope:"col",children:"调用次数"}),l.jsx("th",{scope:"col",children:"最近使用"})]})}),l.jsx("tbody",{children:dr.users.map(Y=>l.jsxs("tr",{children:[l.jsxs("td",{children:[l.jsx("strong",{children:Y.displayName||Y.userId||"未知用户"}),Y.displayName&&Y.userId&&l.jsx("small",{title:Y.userId,children:Y.userId})]}),l.jsx("td",{children:Y.invocationCount.toLocaleString("zh-CN")}),l.jsx("td",{children:l.jsx("time",{dateTime:Y.lastUsedAt,children:Qlt(Y.lastUsedAt)})})]},Y.userId))})]})}),dr.totalPages>1&&l.jsxs("nav",{className:"aw-usage-pagination","aria-label":"用量用户列表分页",children:[l.jsx("button",{type:"button",disabled:ti||dr.page<=1,onClick:()=>pi(Y=>Math.max(1,Y-1)),children:"上一页"}),l.jsxs("span",{"aria-live":"polite",children:["第 ",dr.page," / ",dr.totalPages," 页"]}),l.jsx("button",{type:"button",disabled:ti||dr.page>=dr.totalPages,onClick:()=>pi(Y=>Y+1),children:"下一页"})]})]})]}),Q==="integrations"&&l.jsxs("div",{className:"aw-integration-stack",children:[l.jsxs("div",{className:"aw-integration-intro",children:[l.jsx("h3",{children:"接入方式"}),l.jsx("p",{children:"仅展示当前 Runtime 可确认的公开协议与地址。"})]}),Ae&&l.jsxs("div",{className:"aw-integration-error",role:"alert",children:[l.jsx("span",{children:Ae}),l.jsx("button",{type:"button",onClick:()=>ue(Y=>Y+1),children:"重试"})]}),!Ae&&l.jsxs("div",{className:"aw-integration-body",children:[l.jsxs("div",{className:`aw-integration-protocol-tabs${ye==="a2a"?" is-a2a":""}`,role:"tablist","aria-label":"接入协议",children:[l.jsx("span",{className:"aw-integration-protocol-slider","aria-hidden":"true"}),fO.map((Y,he)=>l.jsx("button",{type:"button",id:`integration-${Y.id}-tab`,role:"tab","aria-selected":ye===Y.id,"aria-controls":`integration-${Y.id}-panel`,tabIndex:ye===Y.id?0:-1,onClick:()=>hv(Y.id),onKeyDown:be=>{var Xt;if(!["ArrowLeft","ArrowRight","Home","End"].includes(be.key))return;be.preventDefault();const Ue=be.key==="Home"?0:be.key==="End"?fO.length-1:(he+(be.key==="ArrowRight"?1:-1)+fO.length)%fO.length,xt=fO[Ue];hv(xt.id),(Xt=document.getElementById(`integration-${xt.id}-tab`))==null||Xt.focus()},children:Y.label},Y.id))]}),ye==="api-server"?l.jsx(Lq,{protocol:"api-server",title:"API Server",available:Me,fields:[{label:"Agent",value:Me?((kb=te==null?void 0:te.apiApps)==null?void 0:kb.join("、"))??"":""},{label:"发现接口",value:Me?Zj(tt,"/list-apps"):""},{label:"调用接口",value:Me?Zj(tt,"/run_sse"):""},{label:"鉴权方式",value:Me?Pq(X==null?void 0:X.authType):""},{label:"API Key",value:l.jsx(Mq,{available:Me,authType:X==null?void 0:X.authType,value:ls,visible:me&&!!ls,loading:Ne,error:Ve,onToggle:()=>void pv()})}],example:Me?Ult(tt,_e,X==null?void 0:X.authType):""}):l.jsx(Lq,{protocol:"a2a",title:"A2A",available:ee,fields:[{label:"Agent",value:((wv=te==null?void 0:te.a2a)==null?void 0:wv.name)??""},{label:"Agent Card",value:ee?Zj(tt,"/.well-known/agent-card.json"):""},{label:"调用地址",value:Ct},{label:"鉴权方式",value:ee?Pq(X==null?void 0:X.authType):""},{label:"API Key",value:l.jsx(Mq,{available:ee,authType:X==null?void 0:X.authType,value:ls,visible:me&&!!ls,loading:Ne,error:Ve,onToggle:()=>void pv()})}],example:ee?zlt(Ct,X==null?void 0:X.authType):""})]})]}),Q==="evaluations"&&l.jsxs("section",{className:"aw-cases",children:[(le==null?void 0:le.runtimeId)&&l.jsx("div",{className:"aw-case-summary",children:["good","bad"].map(Y=>{const he=Wlt(Pe,Y),be=Gp.filter(xt=>xt.kind===Y).length,Ue=Sd?be:(he==null?void 0:he.itemCount)??be;return l.jsxs("button",{type:"button",onClick:()=>vb(Y),children:[l.jsx("strong",{children:Ue}),l.jsx("span",{children:Y==="good"?"Good cases":"Bad cases"})]},Y)})}),l.jsxs("div",{className:"aw-case-filter-bar",children:[l.jsxs("div",{className:"aw-case-filter-stack",children:[l.jsx("div",{className:"aw-case-filters","aria-label":"案例结果筛选",children:["good","bad"].map(Y=>l.jsx("button",{type:"button",className:Je===Y?"is-active":"","aria-pressed":Je===Y,onClick:()=>kt(Y),children:Y==="good"?"Good case":"Bad case"},Y))}),l.jsx("div",{className:"aw-case-source-filters","aria-label":"回流方式筛选",children:["auto","user"].map(Y=>l.jsx("button",{type:"button",className:dt===Y?"is-active":"","aria-pressed":dt===Y,onClick:()=>ge(Y),children:Y==="auto"?"自动回流":"手动回流"},Y))})]}),l.jsxs("label",{className:"aw-case-search",children:[l.jsx(hk,{"aria-hidden":!0}),l.jsx("input",{type:"search",value:Mt,onChange:Y=>Tt(Y.currentTarget.value),placeholder:"搜索用户输入、期望行为或标签","aria-label":"搜索评测案例"})]})]}),Ed&&l.jsx("div",{className:`aw-case-toolbar${Ls?" is-active":""}`,children:Ls?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"aw-selection-count",children:["已选 ",xb.length," 条"]}),l.jsx("button",{type:"button",onClick:mv,disabled:pl.length===0||gr,children:"全选当前"}),l.jsx("button",{type:"button",className:"aw-selection-danger",onClick:()=>void wb(xb),disabled:xb.length===0||gr,children:gr?"删除中…":"删除所选"}),l.jsx("button",{type:"button",onClick:oN,disabled:gr,children:"取消"})]}):l.jsx("button",{type:"button",onClick:()=>{as(""),er(!0)},disabled:pl.length===0||gr,children:"选择案例"})}),Sa&&l.jsx("div",{className:"aw-delete-error",role:"alert",children:Sa}),l.jsx("div",{ref:Dr,children:l.jsx(oct,{cases:pl,loading:At&&pl.length===0,error:kn,notice:Ai,runtimeBacked:!!(le!=null&&le.runtimeId),selectionMode:Ls,selectedCaseIds:Ya,focusedCaseId:Mn,expandedCaseIds:Zl,deleting:gr,canDelete:Ed,onOpenCase:lN,onToggleCase:aN,onToggleExpanded:Wp,onDeleteCase:Y=>void wb([Y]),onRetry:()=>de(Y=>Y+1)})})]}),Q==="optimizations"&&l.jsxs("section",{className:"aw-optimizations",children:[l.jsxs("div",{className:"aw-optimization-intro",children:[l.jsx("h3",{children:"优化项"}),l.jsx("p",{children:"根据评测结果汇总需要优先处理的改进建议。"})]}),gt?l.jsxs("div",{className:"aw-optimization-state",role:"status",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsx("span",{children:"正在读取优化项"})]}):Sn?l.jsxs("div",{className:"aw-optimization-state is-error",role:"alert",children:[l.jsx("span",{children:Sn}),l.jsx("button",{type:"button",onClick:()=>Pn(Y=>Y+1),children:"重试"})]}):Le.length>0?l.jsx(sct,{groups:Le}):l.jsx("div",{className:"aw-optimization-state",children:"暂无优化项,自动评测完成后会在这里生成建议。"})]})]}),Q==="basic"&&(le||gn)&&l.jsxs("div",{className:"aw-basic-actions",children:[le&&l.jsxs("button",{type:"button",className:"aw-talk studio-update-action",onClick:()=>k==null?void 0:k(le),children:[l.jsx(nSe,{"aria-hidden":!0}),l.jsx("span",{children:"去对话"})]}),l.jsxs("span",{className:`aw-update-wrap${Xe?" is-disabled":""}`,tabIndex:Xe?0:void 0,"aria-describedby":Xe?_n:void 0,children:[l.jsx("button",{type:"button",className:"aw-update studio-update-action",disabled:!!Xe,"aria-busy":at||void 0,"aria-describedby":Xe?_n:void 0,onClick:()=>{var Y;return gn?M==null?void 0:M(gn):Vi?M==null?void 0:M({...Vi,deploymentTarget:dl}):ht?C(((Y=ht.agent)==null?void 0:Y.draft)??qi,ht):void 0},children:at?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"loading-gap-spinner aw-update-spinner","aria-hidden":"true"}),l.jsx("span",{children:"检测中"})]}):gn||Vi?"继续编辑":"更新"}),Xe&&l.jsx("span",{id:_n,className:"aw-update-disabled-reason",role:"tooltip",children:Xe})]})]})]})]}),L==="evaluation"&&l.jsx("div",{className:"aw-evaluation-glass",role:"status",children:l.jsx("span",{children:"敬请期待"})})]})]}),wt&&l.jsx(Mf,{variant:"danger",title:wt.title,description:wt.description,confirmLabel:Jt?"删除中...":wt.confirmLabel,closeLabel:"关闭删除确认",busy:Jt,onCancel:()=>yn(null),onConfirm:()=>void fN()})]})}function sct({groups:e}){return l.jsx("div",{className:"aw-optimization-table-wrap",children:l.jsxs("table",{className:"aw-optimization-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"修复优先级"}),l.jsx("th",{scope:"col",children:"建议优化模块"}),l.jsx("th",{scope:"col",children:"优化建议和理由"})]})}),l.jsx("tbody",{children:e.map(t=>l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:`aw-priority is-${t.priority}`,children:Hlt(t.priority)})}),l.jsx("td",{children:l.jsx("span",{className:"aw-optimization-module",children:Glt(t)})}),l.jsx("td",{children:l.jsx("ul",{className:"aw-optimization-list",children:t.items.map(n=>l.jsxs("li",{children:[l.jsx("strong",{children:n.suggestion}),l.jsx("p",{children:n.reason})]},`${n.suggestion}:${n.reason}`))})})]},`${t.priority}:${t.module}:${t.customModule??""}`))})]})})}function act(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4.5 7h15"}),l.jsx("path",{d:"M9 7V4.8h6V7"}),l.jsx("path",{d:"m6.5 7 .8 12h9.4l.8-12"}),l.jsx("path",{d:"M10 10.5v5M14 10.5v5"})]})}function oct({cases:e,loading:t=!1,error:n="",notice:i="",runtimeBacked:r=!1,selectionMode:s=!1,selectedCaseIds:a,focusedCaseId:o="",expandedCaseIds:c,deleting:u=!1,canDelete:d=!1,onOpenCase:f,onToggleCase:h,onToggleExpanded:p,onDeleteCase:g,onRetry:b}){return l.jsxs("div",{className:"aw-case-table",children:[l.jsxs("div",{className:"aw-case-row aw-case-row-head",children:[l.jsx("span",{children:"用户输入"}),l.jsx("span",{children:"Agent 输出"}),l.jsx("span",{children:"评分"}),l.jsx("span",{children:"评分理由"}),l.jsx("span",{className:"aw-case-action-head",children:"操作"})]}),t?l.jsx("div",{className:"aw-case-empty",children:"正在读取 AgentKit 评测集…"}):n?l.jsxs("div",{className:"aw-case-empty aw-case-error",children:[l.jsx("span",{children:n}),b&&l.jsx("button",{type:"button",onClick:b,children:"重试"})]}):i?l.jsx("div",{className:"aw-case-empty",children:i}):e.length===0?l.jsx("div",{className:"aw-case-empty",children:r?"暂无用户反馈案例":"没有匹配的案例"}):e.map(y=>{var T,A;const O=y.id.startsWith("local:"),v=(a==null?void 0:a.has(y.id))??!1,x=(c==null?void 0:c.has(y.id))??!1,E=y.output.length+y.referenceOutput.length>220||(((T=y.reason)==null?void 0:T.length)??0)>120,S=d&&!O,k=!!(y.comment&&y.comment.trim()!==((A=y.reason)==null?void 0:A.trim()));return l.jsxs("div",{className:["aw-case-row",o===y.id?"is-focused":"",s?"is-selecting":"",v?"is-selected-for-delete":""].filter(Boolean).join(" "),role:"row",tabIndex:0,"aria-selected":s?v:void 0,onClick:()=>{if(s){S&&(h==null||h(y));return}f==null||f(y)},onKeyDown:N=>{N.target===N.currentTarget&&(N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),s?S&&(h==null||h(y)):f==null||f(y)))},children:[l.jsxs("div",{className:"aw-case-text aw-case-cell","data-label":"用户输入",children:[l.jsxs("span",{className:"aw-case-title-line",children:[s&&S&&l.jsx("span",{className:`aw-select-marker${v?" is-checked":""}`,"aria-hidden":"true"}),l.jsx("strong",{title:y.input,children:y.input||"无用户输入"})]}),k&&l.jsxs("small",{title:y.comment,children:["备注:",y.comment]}),l.jsx("small",{className:"aw-case-time",children:Xlt(y.createdAt)}),(y.userId||y.sessionId)&&l.jsx("small",{title:[y.userId,y.sessionId].filter(Boolean).join(" · "),children:[y.userId,y.sessionId].filter(Boolean).join(" · ")})]}),l.jsxs("div",{className:`aw-case-output aw-case-cell${x?" is-expanded":""}`,"data-label":"Agent 输出",children:[l.jsx("p",{className:"aw-case-output-preview",title:y.output,children:y.output||"无可见回复"}),y.referenceOutput&&l.jsxs("small",{className:"aw-case-output-preview",title:y.referenceOutput,children:["Reference: ",y.referenceOutput]}),E&&l.jsx("button",{type:"button",className:"aw-case-expand",onClick:N=>{N.stopPropagation(),p==null||p(y.id)},children:x?"收起":"展开"})]}),l.jsx("div",{className:"aw-case-score aw-case-cell","data-label":"评分",children:qlt(y)}),l.jsx("div",{className:`aw-case-reason aw-case-cell${x?" is-expanded":""}`,"data-label":"评分理由",children:l.jsx("p",{title:y.reason||void 0,children:y.reason||"—"})}),l.jsx("div",{className:"aw-case-actions aw-case-cell","data-label":"操作",children:S&&l.jsx("button",{type:"button",className:"aw-case-delete",onClick:N=>{N.stopPropagation(),g==null||g(y)},disabled:u,title:"删除反馈案例","aria-label":"删除反馈案例",children:l.jsx(act,{})})})]},y.id)})]})}function lct({group:e,agents:t,cases:n,onChange:i,onRun:r}){const[s,a]=m.useState("config"),o=e.agentIds.map(f=>t.find(h=>h.id===f)).filter(f=>!!f),c=["回答质量","事实准确性","工具调用","响应效率"];m.useEffect(()=>a("config"),[e.id]);const u=f=>{i({...e,agentIds:e.agentIds.includes(f)?e.agentIds.filter(h=>h!==f):[...e.agentIds,f]})},d=f=>{i({...e,metrics:e.metrics.includes(f)?e.metrics.filter(h=>h!==f):[...e.metrics,f]})};return l.jsxs("main",{className:"aw-main",children:[l.jsxs("div",{className:"aw-eval-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"aw-agent-title-row",children:[l.jsx("h2",{children:e.name}),l.jsx("span",{children:"评测组"})]}),l.jsxs("p",{children:[o.length," 个参评智能体 · ",e.caseSet," · ",e.history.length," 次运行"]})]}),l.jsxs("button",{type:"button",className:"aw-run",onClick:()=>r(e),disabled:!0,children:[l.jsx(Wwe,{"aria-hidden":!0}),"开始评测"]})]}),l.jsxs("nav",{className:"aw-agent-tabs","aria-label":"评测组详情",children:[l.jsx("button",{type:"button",className:s==="config"?"is-active":"","aria-pressed":s==="config",onClick:()=>a("config"),disabled:!0,children:"评测配置"}),l.jsx("button",{type:"button",className:s==="history"?"is-active":"","aria-pressed":s==="history",onClick:()=>a("history"),disabled:!0,children:"历史结果"})]}),l.jsx("div",{className:"aw-content",children:s==="config"?l.jsxs("div",{className:"aw-eval-setup",children:[l.jsxs("section",{className:"aw-eval-block",children:[l.jsxs("div",{className:"aw-card-head",children:[l.jsx("strong",{children:"参评智能体"}),l.jsxs("span",{children:["已选择 ",o.length," 个"]})]}),l.jsx("div",{className:"aw-eval-agent-grid",children:t.map(f=>l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:e.agentIds.includes(f.id),onChange:()=>u(f.id)}),l.jsxs("span",{children:[l.jsx("strong",{children:f.label}),l.jsx("small",{children:f.remote?"远程":"本地"})]})]},f.id))})]}),l.jsxs("div",{className:"aw-eval-setting-grid",children:[l.jsxs("section",{className:"aw-eval-block",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"评测资源"})}),l.jsxs("div",{className:"aw-eval-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"评测集"}),l.jsxs("select",{value:e.caseSet,onChange:f=>i({...e,caseSet:f.currentTarget.value}),children:[l.jsx("option",{children:"核心回归集"}),l.jsx("option",{children:"安全边界集"}),l.jsx("option",{children:"工具调用集"})]}),l.jsxs("small",{children:[n.length," 条案例"]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"评估器"}),l.jsxs("select",{value:e.evaluator,onChange:f=>i({...e,evaluator:f.currentTarget.value}),children:[l.jsx("option",{children:"综合质量评估器"}),l.jsx("option",{children:"事实一致性评估器"}),l.jsx("option",{children:"工具调用评估器"})]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"并发数"}),l.jsxs("select",{value:e.concurrency,onChange:f=>i({...e,concurrency:f.currentTarget.value}),children:[l.jsx("option",{value:"2",children:"2"}),l.jsx("option",{value:"4",children:"4"}),l.jsx("option",{value:"8",children:"8"})]})]})]})]}),l.jsxs("section",{className:"aw-eval-block",children:[l.jsxs("div",{className:"aw-card-head",children:[l.jsx("strong",{children:"评测指标"}),l.jsxs("span",{children:["已选择 ",e.metrics.length," 项"]})]}),l.jsx("div",{className:"aw-metric-list",children:c.map(f=>l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:e.metrics.includes(f),onChange:()=>d(f)}),l.jsx("span",{children:f})]},f))})]})]})]}):l.jsxs("section",{className:"aw-eval-history",children:[l.jsx("div",{className:"aw-section-head",children:l.jsxs("div",{children:[l.jsx("h3",{children:"历史结果"}),l.jsx("p",{children:"查看该评测组历次运行的总体表现。"})]})}),e.history.length===0?l.jsxs("div",{className:"aw-results-empty",children:[l.jsx("strong",{children:"暂无历史结果"}),l.jsx("span",{children:"完成首次评测后,结果会出现在这里。"})]}):l.jsx("div",{className:"aw-history-list",children:e.history.map((f,h)=>l.jsxs("button",{type:"button",children:[l.jsxs("span",{children:[l.jsxs("strong",{children:["评测运行 #",e.history.length-h]}),l.jsxs("small",{children:[f.createdAt," · ",o.length," 个智能体"]})]}),l.jsxs("span",{className:"aw-history-score",children:[l.jsx("strong",{children:f.score}),l.jsx("small",{children:"综合得分"})]}),l.jsxs("span",{className:"aw-complete",children:[l.jsx(Hc,{}),"已完成"]}),l.jsx(ay,{"aria-hidden":!0})]},f.id))})]})})]})}const ca="/web/sandbox/sessions",$q="/web/sandbox/codex-project-handoff",Qq=3e4,Kj=33e4,cct=6e4,uct=6e5,hO=15e3,ku=6e4,dct=33e4,Bq=3e4,fct=60*60,Uq=40;function YA(e){switch(e.trim().toLowerCase()){case"ready":return"就绪";case"wakeable":return"可唤醒";case"creating":return"创建中";case"starting":case"initializing":return"启动中";case"pending":return"等待中";case"running":return"运行中";case"failed":case"error":return"异常";case"stopped":return"已停止";case"expired":return"已过期";case"deleting":return"删除中";case"deleted":return"已删除";default:return"未知状态"}}function sr(e){const t=new Headers(e);return t.has("Accept")||t.set("Accept","application/json"),t}async function ar(e,t){const n=await e.text().catch(()=>"");let i={};try{i=JSON.parse(n)}catch{const c=`${t}(HTTP ${e.status})`;return new Error(n?`${c}:${n}`:c)}const r=i.detail,s=r&&typeof r=="object"&&"message"in r?r.message:r??i.error??i.message,a=typeof s=="string"?s:s==null?"":JSON.stringify(s),o=`${t}(HTTP ${e.status})`;return new Error(a?`${o}:${a}`:o)}async function zq(e,t){const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{throw new Error(`${t} Studio 服务响应异常,请刷新后重试。`)}}function gh(e,t="codex"){if(!e.sessionId||!e.status)throw new Error("AgentKit 沙箱返回了无效的 Session 信息。");return{resourceType:"session",id:e.sessionId,toolName:t,userSessionId:e.userSessionId??"",displayName:e.displayName??"",status:e.status,createdAt:e.createdAt??"",expireAt:e.expireAt??"",persistent:e.persistent!==!1,toolType:e.toolType??"",createdBy:e.createdBy??"",threadId:e.threadId??"",cwd:e.cwd??"",workspaceLocked:e.workspaceLocked===!0,busy:e.busy===!0,...typeof e.model=="string"?{model:e.model}:{},permissions:GA(e.permissions)}}function Fq(e,t="codex"){if(!e.snapshotId||!e.status)throw new Error("AgentKit 沙箱返回了无效的 Snapshot 信息。");return{resourceType:"snapshot",id:e.snapshotId,snapshotId:e.snapshotId,sourceSessionId:e.sessionId??"",toolName:t,userSessionId:e.userSessionId??"",displayName:e.displayName??"",status:e.status,snapshotStatus:e.snapshotStatus??"Unknown",reason:e.reason??"",createdAt:e.createdAt??"",createdBy:e.createdBy??""}}const pO={approvalPolicy:"on-request",approvalsReviewer:"user",sandboxMode:"workspace-write",networkAccess:!1};function GA(e){if(!e||typeof e!="object")return{...pO};const t=e,n=t.approvalPolicy,i=t.approvalsReviewer,r=t.sandboxMode;return{approvalPolicy:n==="untrusted"||n==="on-request"||n==="never"?n:pO.approvalPolicy,approvalsReviewer:i==="user"||i==="auto_review"?i:pO.approvalsReviewer,sandboxMode:r==="read-only"||r==="workspace-write"||r==="danger-full-access"?r:pO.sandboxMode,networkAccess:typeof t.networkAccess=="boolean"?t.networkAccess:pO.networkAccess}}function Vq(e){if(!e||typeof e!="object")throw new Error("Sandbox 返回了无效设置。");const t=e;return{threadId:typeof t.threadId=="string"?t.threadId:"",cwd:typeof t.cwd=="string"?t.cwd:"",...typeof t.model=="string"?{model:t.model}:{},workspaceLocked:t.workspaceLocked===!0,busy:t.busy===!0,permissions:GA(t.permissions)}}function Xs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function hct(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id))return{id:t.id,displayName:typeof t.displayName=="string"?t.displayName:t.id,description:typeof t.description=="string"?t.description:"",isDefault:t.isDefault===!0}}function pct(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id||typeof t.name!="string"||!t.name))return{id:t.id,name:t.name,description:typeof t.description=="string"?t.description:""}}function zhe(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id))return{id:t.id,...typeof t.name=="string"&&t.name?{name:t.name}:{},preview:typeof t.preview=="string"?t.preview:"",cwd:typeof t.cwd=="string"?t.cwd:"",modelProvider:typeof t.modelProvider=="string"?t.modelProvider:"",createdAt:typeof t.createdAt=="number"&&Number.isFinite(t.createdAt)?t.createdAt:0,updatedAt:typeof t.updatedAt=="number"&&Number.isFinite(t.updatedAt)?t.updatedAt:0,status:typeof t.status=="string"?t.status:"unknown"}}function hm(e){const t=Xs(e),n=zhe(t==null?void 0:t.thread);if(!t||!n||typeof t.threadId!="string"||!Array.isArray(t.messages))throw new Error("Sandbox 返回了无效 Thread 快照。");const i=t.messages.flatMap(r=>{const s=Xs(r);if(!s||typeof s.id!="string"||s.role!=="user"&&s.role!=="assistant"||typeof s.content!="string"||typeof s.timestamp!="number")return[];const a=Array.isArray(s.skillNames)?s.skillNames.filter(c=>typeof c=="string"&&!!c):[],o=Array.isArray(s.images)?s.images.flatMap(c=>{const u=Xs(c);return!u||typeof u.mimeType!="string"||!u.mimeType.startsWith("image/")||typeof u.data!="string"||!u.data?[]:[{mimeType:u.mimeType,data:u.data,...typeof u.name=="string"&&u.name?{name:u.name}:{},...typeof u.alt=="string"&&u.alt?{alt:u.alt}:{}}]}):[];return[{id:s.id,role:s.role,content:s.content,timestamp:s.timestamp,...a.length?{skillNames:a}:{},...o.length?{images:o}:{}}]});return{thread:n,threadId:t.threadId,messages:i,...typeof t.model=="string"?{model:t.model}:{},...typeof t.cwd=="string"?{cwd:t.cwd}:{},workspaceLocked:t.workspaceLocked===!0,permissions:GA(t.permissions)}}function BL(e){if(!e||typeof e!="object")return;const t=e;if(![t.totalTokens,t.inputTokens,t.cachedInputTokens,t.outputTokens,t.reasoningOutputTokens].some(i=>typeof i!="number"||!Number.isFinite(i)||i<0))return{totalTokens:Math.trunc(t.totalTokens),inputTokens:Math.trunc(t.inputTokens),cachedInputTokens:Math.trunc(t.cachedInputTokens),outputTokens:Math.trunc(t.outputTokens),reasoningOutputTokens:Math.trunc(t.reasoningOutputTokens)}}function mct(e){const t=BL(e.usage);if(!t||typeof e.turnId!="string")return;const n=BL(e.threadTotal),i=e.modelContextWindow;return{turnId:e.turnId,usage:t,...n?{threadTotal:n}:{},...typeof i=="number"&&Number.isFinite(i)&&i>=0?{modelContextWindow:Math.trunc(i)}:{}}}function gct(e){return typeof e.id!="string"||e.kind!=="command"&&e.kind!=="file"||typeof e.method!="string"?null:{id:e.id,kind:e.kind,method:e.method,...typeof e.reason=="string"?{reason:e.reason}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.grantRoot=="string"?{grantRoot:e.grantRoot}:{},...e.changes!==void 0?{changes:e.changes}:{},...typeof e.threadId=="string"?{threadId:e.threadId}:{},...typeof e.turnId=="string"?{turnId:e.turnId}:{},...typeof e.itemId=="string"?{itemId:e.itemId}:{}}}async function bct(e,t={}){if(!e.body)throw new Error("沙箱对话服务未返回内容。");const n=e.body.getReader(),i=new TextDecoder;let r="",s="";const a=[],o=new Map;let c;function u(){var p;(p=t.onBlocks)==null||p.call(t,a.map(g=>({...g})))}function d(p){s+=p;const g=a[a.length-1];(g==null?void 0:g.kind)==="text"?g.text+=p:a.push({kind:"text",text:p}),u()}function f(p){if(typeof p.id!="string"||p.kind!=="thinking"&&p.kind!=="tool"||p.status!=="running"&&p.status!=="done")return;const g=p.status==="done";let b;if(p.kind==="thinking"){if(typeof p.text!="string"||!p.text)return;b={kind:"thinking",text:p.text,done:g}}else{if(typeof p.name!="string"||!p.name)return;b={kind:"tool",name:p.name,args:p.args,response:p.response,done:g}}const y=o.get(p.id);y===void 0?(o.set(p.id,a.length),a.push(b)):a[y]=b,u()}function h(p){var O,v,x;let g="message";const b=[];for(const w of p.split(/\r?\n/))w.startsWith("event:")&&(g=w.slice(6).trim()),w.startsWith("data:")&&b.push(w.slice(5).trimStart());if(b.length===0)return;let y;try{y=JSON.parse(b.join(` -`))}catch{throw new Error("沙箱对话服务返回了无法解析的响应。")}if(g==="error")throw new Error(typeof y.message=="string"&&y.message?y.message:"沙箱对话失败,请稍后重试。");if(g==="activity"&&f(y),g==="approval"){const w=gct(y);w&&((O=t.onApproval)==null||O.call(t,w))}if(g==="usage"){const w=mct(y);w&&(c=w,(v=t.onUsage)==null||v.call(t,w))}g==="approval_resolved"&&typeof y.approvalId=="string"&&((x=t.onApprovalResolved)==null||x.call(t,y.approvalId)),g==="delta"&&typeof y.text=="string"&&d(y.text),g==="done"&&!s&&typeof y.text=="string"&&d(y.text)}for(;;){const{done:p,value:g}=await n.read();r+=i.decode(g,{stream:!p});const b=r.split(/\r?\n\r?\n/);if(r=b.pop()??"",b.forEach(h),p)break}if(r.trim()&&h(r),a.length===0)throw new Error("沙箱未返回有效回复,请重试。");return{text:s,blocks:a,...c?{usage:c}:{}}}async function eo(e,t,{method:n="GET",body:i,options:r={},fallback:s}){if(!e)throw new Error("缺少要操作的 AgentKit Session。");const a=await ri(`${ca}/${encodeURIComponent(e)}/${t}`,{method:n,headers:sr(i===void 0?void 0:{"Content-Type":"application/json"}),...i===void 0?{}:{body:JSON.stringify(i)},signal:r.signal},ku);if(!a.ok)throw await ar(a,s);return a.json()}const Kt={async listSessions(e={}){const t=await ri(ca,{method:"GET",headers:sr(),signal:e.signal},Qq);if(!t.ok)throw await ar(t,"无法读取 Codex 智能体,请稍后重试。");const n=await t.json();if(!Array.isArray(n.sessions))throw new Error("AgentKit 沙箱返回了无效的 Session 列表。");if(n.snapshots!==void 0&&!Array.isArray(n.snapshots))throw new Error("AgentKit 沙箱返回了无效的 Snapshot 列表。");return[...n.sessions.map(i=>gh(i)),...(n.snapshots??[]).map(i=>Fq(i))]},async startSession(e={}){var n;const t=await ri(ca,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({displayName:((n=e.displayName)==null?void 0:n.trim())??"",persistent:e.persistent??!0}),signal:e.signal},Kj);if(!t.ok)throw await ar(t,"无法启动 AgentKit 沙箱,请稍后重试。");return gh(await t.json())},async listAgentSessions(e,t={}){const n=await ri(`/web/${e}/sessions`,{method:"GET",headers:sr(),signal:t.signal},Qq);if(!n.ok)throw await ar(n,`无法读取 ${e} 智能体,请稍后重试。`);const i=await n.json();if(!Array.isArray(i.sessions))throw new Error(`AgentKit 返回了无效的 ${e} Session 列表。`);if(i.snapshots!==void 0&&!Array.isArray(i.snapshots))throw new Error(`AgentKit 返回了无效的 ${e} Snapshot 列表。`);return[...i.sessions.map(r=>gh(r,e)),...(i.snapshots??[]).map(r=>Fq(r,e))]},async startAgentSession(e,t={}){var i;const n=await ri(`/web/${e}/sessions`,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({displayName:((i=t.displayName)==null?void 0:i.trim())??"",persistent:t.persistent??!0}),signal:t.signal},Kj);if(!n.ok)throw await ar(n,`无法创建 ${e} 智能体,请稍后重试。`);return gh(await n.json(),e)},async openAgentSession(e,t,n={}){if(!t)throw new Error("缺少要打开的 AgentKit Session。");const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}/open`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,`无法打开 ${e} 智能体。`);const r=await i.json();if(typeof r.webuiUrl!="string"||!r.webuiUrl.startsWith("/"))throw new Error(`${e} 智能体返回了无效的主页面地址。`);return{session:gh(r,e),kind:e,webuiUrl:vo(r.webuiUrl)}},async launchAgentTerminal(e,t,n={}){if(!t)throw new Error("缺少要打开 Terminal 的 AgentKit Session。");const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}/terminal`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,`无法打开 ${e} Terminal。`);const r=await i.json();return{url:Fhe(r.url,`${e} Terminal`),...typeof r.shellSessionId=="string"?{shellSessionId:r.shellSessionId}:{}}},async deleteAgentSession(e,t,n={}){if(!t)return;const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}`,{method:"DELETE",headers:sr(),signal:n.signal},hO);if(!i.ok&&i.status!==404)throw await ar(i,`无法删除 ${e} 智能体。`)},async resumeSnapshot(e,t,n={}){if(!t)throw new Error("缺少要唤醒的 AgentKit Snapshot。");const i=e==="codex"?"/web/sandbox":`/web/${e}`,r=await ri(`${i}/snapshots/${encodeURIComponent(t)}/resume`,{method:"POST",headers:sr(),signal:n.signal},Kj);if(!r.ok)throw await ar(r,"无法从快照唤醒智能体,请稍后重试。");return gh(await r.json(),e)},async deleteSnapshot(e,t,n={}){if(!t)return;const i=e==="codex"?"/web/sandbox":`/web/${e}`,r=await ri(`${i}/snapshots/${encodeURIComponent(t)}`,{method:"DELETE",headers:sr(),signal:n.signal},hO);if(!r.ok&&r.status!==404)throw await ar(r,"无法删除智能体快照。")},async connectSession(e,t={}){if(!e)throw new Error("缺少要连接的 AgentKit Session。");const n=await ri(`${ca}/${encodeURIComponent(e)}/connect`,{method:"POST",headers:sr({"Content-Type":"application/json"}),signal:t.signal},cct);if(!n.ok)throw await ar(n,"无法连接 Codex 智能体,请稍后重试。");const i=gh(await n.json());if(i.status.toLowerCase()!=="ready")throw new Error(`AgentKit Session 尚未就绪,当前状态:${i.status}。`);return i},async sendMessage(e,t={}){var i;if(!e.sessionId||!e.text.trim())throw new Error("内置智能体会话缺少有效的消息内容。");const n=await ri(`${ca}/${encodeURIComponent(e.sessionId)}/messages`,{method:"POST",headers:sr({Accept:"text/event-stream","Content-Type":"application/json"}),body:JSON.stringify({message:e.text,...(i=e.skillIds)!=null&&i.length?{skillIds:e.skillIds}:{}}),signal:t.signal},uct);if(!n.ok)throw await ar(n,"沙箱对话失败,请稍后重试。");return bct(n,t)},async getStatus(e,t={}){const n=await eo(e,"status",{options:t,fallback:"无法读取 Codex 状态。"}),i=Vq(n),r=Xs(n),s=BL(r==null?void 0:r.threadTotal),a=r==null?void 0:r.modelContextWindow;return{...i,...s?{threadTotal:s}:{},...typeof a=="number"&&Number.isFinite(a)&&a>=0?{modelContextWindow:Math.trunc(a)}:{}}},async getEndpoint(e,t={}){const n=Xs(await eo(e,"endpoint",{options:t,fallback:"无法读取 Sandbox Endpoint。"}));if(typeof(n==null?void 0:n.endpoint)!="string"||!n.endpoint.trim())throw new Error("Sandbox 返回了无效 Endpoint。");return{endpoint:n.endpoint,sessionId:typeof n.sessionId=="string"?n.sessionId:e,...typeof n.expireAt=="string"?{expireAt:n.expireAt}:{}}},async createCodexProjectHandoffPairing(e={}){const t=await ri(`${$q}/pairings`,{method:"POST",headers:sr({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify({ttlSeconds:fct}),signal:e.signal},Bq);if(!t.ok)throw await ar(t,"无法生成 Codex 云端接力配对码。");const n=Xs(await zq(t,"无法生成 Codex 云端接力配对码。"));if(typeof(n==null?void 0:n.pairingCode)!="string"||!n.pairingCode.trim()||typeof n.expireAt!="string"||!n.expireAt.trim())throw new Error("Studio 返回了无效的 Codex 云端接力配对码。");const i=typeof n.studioUrl=="string"&&n.studioUrl.trim()?n.studioUrl.trim():window.location.origin;return{pairingCode:n.pairingCode,expireAt:n.expireAt,studioUrl:i}},async getCodexProjectHandoffStatus(e,t={}){const n=await ri(`${$q}/pairings/${encodeURIComponent(e)}`,{headers:sr({Accept:"application/json"}),signal:t.signal},Bq);if(!n.ok)throw await ar(n,"无法读取端云接力状态。");const i=Xs(await zq(n,"无法读取端云接力状态。")),r=new Set(["issued","creating","session-created","continuing","running","completed","failed"]);if(typeof(i==null?void 0:i.state)!="string"||!r.has(i.state)||typeof i.expireAt!="string"||!i.expireAt.trim())throw new Error("Studio 返回了无效的端云接力状态。");return{state:i.state,expireAt:i.expireAt,...typeof i.projectName=="string"?{projectName:i.projectName}:{},...typeof i.agentName=="string"?{agentName:i.agentName}:{},...typeof i.sessionId=="string"?{sessionId:i.sessionId}:{},...typeof i.error=="string"?{error:i.error}:{},...i.failedStage==="creating-session"||i.failedStage==="uploading-project"||i.failedStage==="restoring-project"||i.failedStage==="continuing-task"?{failedStage:i.failedStage}:{}}},async listModels(e,t={}){const n=Xs(await eo(e,"models",{options:t,fallback:"无法读取 Codex 模型列表。"}));if(!Array.isArray(n==null?void 0:n.models))throw new Error("Sandbox 返回了无效模型列表。");return n.models.flatMap(i=>{const r=hct(i);return r?[r]:[]})},async setModel(e,t,n={}){const i=Xs(await eo(e,"model",{method:"PUT",body:{model:t},options:n,fallback:"无法切换 Codex 模型。"}));if(typeof(i==null?void 0:i.model)!="string"||!i.model)throw new Error("Sandbox 返回了无效模型。");return i.model},async listSkills(e,t=!1,n={}){const r=Xs(await eo(e,`skills${t?"?force_reload=true":""}`,{options:n,fallback:"无法读取 Codex Skills。"}));if(!Array.isArray(r==null?void 0:r.skills))throw new Error("Sandbox 返回了无效 Skill 列表。");return r.skills.flatMap(s=>{const a=pct(s);return a?[a]:[]})},async listThreads(e,t={},n={}){const i=new URLSearchParams;t.cursor&&i.set("cursor",t.cursor),t.search&&i.set("search",t.search),t.archived&&i.set("archived","true");const r=i.size?`?${i}`:"",s=Xs(await eo(e,`threads${r}`,{options:n,fallback:"无法读取 Codex Thread 列表。"}));if(!Array.isArray(s==null?void 0:s.threads))throw new Error("Sandbox 返回了无效 Thread 列表。");return{threads:s.threads.flatMap(a=>{const o=zhe(a);return o?[o]:[]}),...typeof s.nextCursor=="string"?{nextCursor:s.nextCursor}:{}}},async newThread(e,t={}){return hm(await eo(e,"threads/new",{method:"POST",options:t,fallback:"无法创建新的 Codex Thread。"}))},async readThread(e,t,n={}){if(!t)throw new Error("缺少要读取的 Codex Thread。");return hm(await eo(e,`threads/${encodeURIComponent(t)}`,{options:n,fallback:"无法读取 Codex 历史消息。"}))},async resumeThread(e,t,n={}){return hm(await eo(e,"threads/resume",{method:"POST",body:{threadId:t},options:n,fallback:"无法恢复 Codex Thread。"}))},async forkThread(e,t={}){return hm(await eo(e,"threads/fork",{method:"POST",options:t,fallback:"无法分叉 Codex Thread。"}))},async archiveThread(e,t,n={}){const i=Xs(await eo(e,"threads/archive",{method:"POST",body:{threadId:t},options:n,fallback:"无法归档 Codex Thread。"}));if((i==null?void 0:i.archived)!==!0)throw new Error("Sandbox 返回了无效归档结果。");return{archived:!0,...i.thread?{snapshot:hm(i)}:{}}},async deleteThread(e,t,n={}){const i=Xs(await eo(e,"threads/delete",{method:"POST",body:{threadId:t},options:n,fallback:"无法删除 Codex Thread。"}));if((i==null?void 0:i.deleted)!==!0)throw new Error("Sandbox 返回了无效删除结果。");return{deleted:!0,...i.thread?{snapshot:hm(i)}:{}}},async compactThread(e,t={}){await eo(e,"threads/compact",{method:"POST",options:t,fallback:"无法压缩 Codex Thread。"})},async getSettings(e,t={}){const n=await ri(`${ca}/${encodeURIComponent(e)}/settings`,{method:"GET",headers:sr(),signal:t.signal},ku);if(!n.ok)throw await ar(n,"无法读取 Codex 权限与工作空间。");return Vq(await n.json())},async updatePermissions(e,t,n={}){const i=await ri(`${ca}/${encodeURIComponent(e)}/permissions`,{method:"PUT",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify(t),signal:n.signal},ku);if(!i.ok)throw await ar(i,"无法更新 Codex 权限。");const r=await i.json();return GA(r.permissions)},async updateWorkspace(e,t,n={}){const i=await ri(`${ca}/${encodeURIComponent(e)}/workspace`,{method:"PUT",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({cwd:t}),signal:n.signal},ku);if(!i.ok)throw await ar(i,"无法更新 Codex 工作空间。");const r=await i.json();if(typeof r.cwd!="string"||!r.cwd)throw new Error("Sandbox 返回了无效工作目录。");return r.cwd},async listDirectories(e,t,n={}){const i=new URLSearchParams({path:t}),r=await ri(`${ca}/${encodeURIComponent(e)}/directories?${i}`,{method:"GET",headers:sr(),signal:n.signal},ku);if(!r.ok)throw await ar(r,"无法读取 Sandbox 目录。");const s=await r.json();if(typeof s.path!="string"||!Array.isArray(s.directories)||s.directories.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error("Sandbox 返回了无效目录列表。");return{path:s.path,...typeof s.parent=="string"?{parent:s.parent}:{},directories:s.directories}},async resolveApproval(e,t,n,i={}){const r=await ri(`${ca}/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({decision:n}),signal:i.signal},ku);if(!r.ok)throw await ar(r,"无法提交 Codex 审批决定。")},async launchTerminal(e,t={}){return Xq(e,"terminal",t)},async launchBrowser(e,t={}){return Xq(e,"browser",t)},async uploadFile(e,t,n={}){const i=new FormData;i.set("file",t,t.name);const r=await ri(`${ca}/${encodeURIComponent(e)}/files`,{method:"POST",headers:sr(),body:i,signal:n.signal},dct);if(!r.ok)throw await ar(r,"无法上传文件到 Sandbox。");const s=await r.json();if(typeof s.id!="string"||typeof s.path!="string"||typeof s.name!="string"||typeof s.mimeType!="string"||typeof s.sizeBytes!="number")throw new Error("Sandbox 返回了无效上传结果。");return s},async closeSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}/disconnect`,{method:"POST",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法断开 Codex 智能体连接。")},async interruptSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}/interrupt`,{method:"POST",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法停止 Codex 任务。")},async deleteSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}`,{method:"DELETE",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法删除 Codex 智能体。")}};async function Xq(e,t,n){const i=await ri(`${ca}/${encodeURIComponent(e)}/${t}`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,t==="terminal"?"无法打开 Sandbox Terminal。":"无法打开 Sandbox Browser。");const r=await i.json();return{url:Fhe(r.url,"Sandbox 工具"),...typeof r.shellSessionId=="string"?{shellSessionId:r.shellSessionId}:{}}}function Fhe(e,t){if(typeof e!="string")throw new Error(`${t} 返回了无效地址。`);if(e.startsWith("/"))return vo(e);let n;try{n=new URL(e)}catch{throw new Error(`${t} 返回了无效地址。`)}const i=n.protocol==="http:"&&window.location.protocol==="http:";if(n.protocol!=="https:"&&!i)throw new Error(`${t} 返回了不安全的地址。`);return n.toString()}function cg(e,t,n){const i=e instanceof Error?`${e.name}: ${e.message}`:String(e||"未知错误");return[`${t}失败`,`详细信息:${i}`,n?`请求:${n}`:""].filter(Boolean).join(` -`)}function Oct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M8.4 18.4H7.2a4.2 4.2 0 0 1-.65-8.35A5.7 5.7 0 0 1 17.3 8.2a4.6 4.6 0 0 1-.4 9.2h-3.2"}),l.jsx("path",{d:"m7.8 12.3 2 2-2 2M12.2 16.3h3.2"})]})}function yct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M18.9 6.25A8.4 8.4 0 1 0 19.6 16"}),l.jsx("path",{d:"M19 6.2c.1 2.1-.65 3.75-2.25 4.95-1.2.9-2.75 1.25-4.2.9"}),l.jsx("circle",{cx:"10.6",cy:"12.8",r:"2.45"}),l.jsx("path",{d:"m5.25 18.6 3.65-3.9M14.8 17.9c1.9-.45 3.55-1.65 4.65-3.35"})]})}function xct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6.2 20c.55-2.15.75-4.1.75-6.7V9.8A5.35 5.35 0 0 1 12.35 4c3.35 0 5.65 2.35 5.65 5.65v4.6c0 2.35.35 4.25 1.15 5.75"}),l.jsx("path",{d:"M8.05 10.2c1.35-.6 2.2-1.65 2.55-3.15.45 1.55 1.35 2.55 2.7 3.05.1-1 .4-1.95.85-2.75.45 1.25 1.2 2.2 2.15 2.75"}),l.jsx("path",{d:"M9.3 12.65h.01M14.9 12.65h.01M10.8 15.55c.8.5 1.65.5 2.45 0"}),l.jsx("path",{d:"M8.45 19.85c.95-.85 1.45-1.95 1.5-3.25M15.1 16.65c.05 1.2.55 2.3 1.55 3.2"})]})}function vct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5.2 17.2V8.1a3 3 0 0 1 3-3h7.6a3 3 0 0 1 3 3v9.1"}),l.jsx("path",{d:"M7.4 17.2h9.2M9 19.9h6"}),l.jsx("path",{d:"M9.1 9.25h5.8M9.1 12h3.1"}),l.jsx("path",{d:"m14.1 12.4 2 2.1M16.2 12.4l-2.1 2.1"})]})}function t1({kind:e,...t}){return e==="codex"?l.jsx(Oct,{...t}):e==="deepseek-harness"?l.jsx(vct,{...t}):e==="openclaw"?l.jsx(yct,{...t}):l.jsx(xct,{...t})}const Jj=[{id:"general",label:"通用智能体"},{id:"codex",label:"Codex 智能体"},{id:"deepseek-harness",label:"DeepSeek Harness"},{id:"openclaw",label:"OpenClaw 智能体"},{id:"hermes",label:"Hermes 智能体"}],wct=24,Sct=3e4,ug=new Map,Dg=new Map,Ect=new Set;function hS(e){if(!e){ug.clear(),Dg.clear();return}const t=new Set(e);if(t.size!==0){for(const[n,i]of Dg)i.page.runtimes.some(r=>t.has(r.runtimeId))&&Dg.delete(n);ug.clear()}}function kct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function eR(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function Tct(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M2.75 5.25h8.75m0 0-2-2m2 2-2 2M13.25 10.75H4.5m0 0 2 2m-2-2 2-2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function _ct({type:e}){return e==="general"?l.jsx(Pf,{}):l.jsx(t1,{kind:e})}function oQ(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(t).replace(/\//g,"-")}function Act(e,t=Date.now()){const n=Date.parse(e);if(!Number.isFinite(n)||n-t<6e4)return"即将清空";const i=Math.ceil((n-t)/6e4),r=Math.floor(i/60),s=i%60;return`${r} 小时 ${s} 分钟`}function qq(e){var t;return{id:e.runtimeId,name:e.name,description:((t=e.description)==null?void 0:t.trim())||"暂无描述",createdAt:oQ(e.createdAt??""),specificationLabel:"创建人",specification:e.author||"—",isMine:e.isMine,runtime:{runtimeId:e.runtimeId,region:e.region,currentVersion:e.currentVersion,canDelete:e.canDelete}}}function Nct(e){return{id:e.id,name:e.displayName||`${e.toolName} 智能体`,description:YA(e.status),createdAt:oQ(e.createdAt),specificationLabel:"创建人",specification:e.createdBy||"—",sandbox:e}}function Cct(e){var t;return{id:e.id,name:e.draft.name||"未命名 Agent",description:((t=e.draft.description)==null?void 0:t.trim())||"暂无描述",createdAt:oQ(new Date(e.updatedAt).toISOString()),specificationLabel:"存储位置",specification:"当前浏览器",draft:e}}async function jct(e,t,n){const i=`${e}:all:${t}`,r=Dg.get(i);if(r&&r.expiresAt>Date.now())return n(r.page.runtimes.map(qq)),r.page.nextToken;r&&Dg.delete(i);let s=ug.get(i);s||(s=S_({scope:e,region:"all",pageSize:wct,nextToken:t}),ug.set(i,s),s.then(()=>ug.delete(i),()=>ug.delete(i)));const a=await s;return Dg.set(i,{page:a,expiresAt:Date.now()+Sct}),n(a.runtimes.map(qq)),a.nextToken}function Rct({agent:e,cloudProvider:t,onUse:n,onViewDetails:i,connecting:r,connected:s,showOwnership:a,deploymentTask:o,nowMs:c,onViewDeploymentTask:u,onEditDraft:d,onDeleteDraft:f}){var y,O,v,x;const h=(y=e.sandbox)==null?void 0:y.status.toLowerCase(),p=((O=e.sandbox)==null?void 0:O.resourceType)==="snapshot",g=!!(e.runtime||h==="ready"||h==="wakeable"),b=((v=e.sandbox)==null?void 0:v.resourceType)==="snapshot"?e.sandbox.sourceSessionId||e.sandbox.snapshotId:(x=e.sandbox)==null?void 0:x.id;return l.jsxs("article",{className:"my-agent-card",children:[l.jsxs("div",{className:"my-agent-card-content",children:[l.jsxs("div",{className:"my-agent-card-title",children:[l.jsxs("div",{className:"my-agent-card-title-copy",children:[l.jsx("h3",{children:e.name}),e.sandbox?l.jsx("span",{className:"my-agent-session-id",title:b,children:b}):null]}),e.draft?l.jsx("span",{className:"my-agent-draft-badge",children:o?"部署中":"草稿"}):e.sandbox?l.jsx("span",{className:"my-agent-status-label","data-ready":e.sandbox.status.toLowerCase()==="ready"||void 0,"data-wakeable":p||void 0,children:e.description}):e.runtime?l.jsxs("div",{className:"my-agent-card-badges",children:[o?l.jsx("span",{className:"my-agent-deploying-badge",children:"部署中"}):null,l.jsx("span",{className:"my-agent-region-badge",children:td(e.runtime.region,t)}),a&&e.isMine?l.jsx("span",{className:"runtime-owner-badge",children:"我创建的"}):null]}):null]}),e.sandbox?null:l.jsx("p",{className:"my-agent-description",children:e.description}),l.jsxs("dl",{className:"my-agent-meta",children:[l.jsxs("div",{className:"my-agent-created-at",children:[l.jsx("dt",{children:e.draft?"更新时间":"创建时间"}),l.jsx("dd",{children:e.createdAt})]}),l.jsxs("div",{className:"my-agent-region",children:[l.jsx("dt",{children:e.specificationLabel}),l.jsx("dd",{children:e.specification})]}),e.sandbox?l.jsxs("div",{className:`my-agent-expiry${e.sandbox.resourceType==="session"&&e.sandbox.persistent?"":" is-expiring"}`,children:[l.jsx("dt",{children:"剩余时间"}),l.jsx("dd",{children:e.sandbox.resourceType==="snapshot"?"可唤醒":e.sandbox.persistent?"永不过期":Act(e.sandbox.expireAt,c)})]}):null]})]}),l.jsx("footer",{className:"my-agent-actions",children:e.draft?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"my-agent-details","aria-label":o?`查看 ${e.name} 部署进度`:`编辑草稿 ${e.name}`,onClick:()=>o?u==null?void 0:u(o):d==null?void 0:d(e.draft),children:o?"查看进度":"编辑"}),l.jsx("button",{type:"button",className:"my-agent-delete","aria-label":`删除草稿 ${e.name}`,onClick:()=>f==null?void 0:f(e.draft),children:"删除"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"my-agent-details",disabled:!g,"aria-label":o?`查看 ${e.name} 部署进度`:`查看 ${e.name} 详情`,onClick:()=>o?u==null?void 0:u(o):i==null?void 0:i(e),children:o?"查看进度":"查看详情"}),l.jsx("button",{type:"button",className:`my-agent-use${s?" is-connected":""}`,disabled:!g||r||s,"aria-busy":r||void 0,"aria-label":s?`${e.name} 已连接`:p?`唤醒 ${e.name}`:`使用 ${e.name}`,onClick:()=>void(n==null?void 0:n(e)),children:r?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-use-spinner","aria-hidden":"true"}),l.jsx("span",{children:p?"唤醒中":"连接中"})]}):s?"已连接":p?"唤醒":"使用"})]})})]})}function Ict({cloudProvider:e,canCreate:t,runtimeScope:n,onCreateAgent:i,onOpenCodexProjectUpload:r,onUseAgent:s,onViewAgentDetails:a,onCreateSandboxAgent:o,onUseSandboxAgent:c,onViewSandboxAgentDetails:u,sandboxRefreshKey:d=0,connectedRuntimeId:f="",hiddenRuntimeIds:h=Ect,drafts:p=[],deploymentTasks:g=[],draftDeploymentTaskIds:b={},onViewDeploymentTask:y,onEditDraft:O,onDeleteDraft:v}){const x=m.useRef(null),w=m.useRef(null),E=m.useRef(0),S=m.useRef(0),k=m.useRef(null),[T,A]=m.useState("general"),[N,C]=m.useState(""),[M,L]=m.useState([]),[P,Q]=m.useState(""),[j,$]=m.useState(!0),[U,B]=m.useState(""),[I,X]=m.useState([]),[q,D]=m.useState(!1),[H,re]=m.useState(""),[fe,Ae]=m.useState(""),[J,ie]=m.useState(null),[ue,ye]=m.useState(()=>Date.now()),Se=I.some(ae=>{var pe;return((pe=ae.sandbox)==null?void 0:pe.resourceType)==="session"&&ae.sandbox.persistent===!1});m.useEffect(()=>{if(!Se)return;ye(Date.now());const ae=window.setInterval(()=>ye(Date.now()),6e4);return()=>window.clearInterval(ae)},[Se]);const Re=m.useMemo(()=>p.map(Cct),[p]),Ee=m.useMemo(()=>{const ae=new Map,pe=new Map;for(const z of g){if(z.status!=="running"||(ae.set(z.id,z),!z.runtimeId))continue;const ve=pe.get(z.runtimeId);(!ve||z.startedAt>ve.startedAt)&&pe.set(z.runtimeId,z)}return{byId:ae,byRuntimeId:pe}},[g]),me=m.useCallback(ae=>{var z;if(ae.draft){const ve=b[ae.draft.id];return ve?Ee.byId.get(ve):void 0}const pe=(z=ae.runtime)==null?void 0:z.runtimeId;return pe?Ee.byRuntimeId.get(pe):void 0},[Ee,b]),oe=m.useCallback((ae,pe)=>{const z=++E.current;return $(!0),B(""),jct(n,ae,ve=>{E.current===z&&L(Be=>pe?ve:[...Be,...ve])}).then(ve=>{E.current===z&&Q(ve)}).catch(ve=>{E.current===z&&B(cg(ve,"加载通用智能体","GET /web/runtimes"))}).finally(()=>{E.current===z&&$(!1)})},[n]);m.useEffect(()=>{if(T==="general")return L([]),Q(""),oe("",!0),()=>{E.current+=1}},[T,oe]);const Ne=m.useCallback(async ae=>{var ve,Be;(ve=k.current)==null||ve.abort();const pe=new AbortController;k.current=pe;const z=++S.current;D(!0),re(""),X([]);try{const Je=ae==="codex"?await Kt.listSessions({signal:pe.signal}):await Kt.listAgentSessions(ae,{signal:pe.signal});if(S.current!==z)return;X(Je.map(Nct))}catch(Je){if((Je==null?void 0:Je.name)==="AbortError"||S.current!==z)return;re(cg(Je,`加载 ${((Be=Jj.find(kt=>kt.id===ae))==null?void 0:Be.label)??ae}`,`GET /web/${ae==="codex"?"sandbox":ae}/sessions`))}finally{k.current===pe&&(k.current=null),S.current===z&&D(!1)}},[]);function Oe(ae){var pe;ae!==T&&(ae==="general"?(E.current+=1,L([]),Q(""),B(""),$(!0)):((pe=k.current)==null||pe.abort(),k.current=null,S.current+=1,X([]),re(""),D(!0)),A(ae))}m.useEffect(()=>{var ae;if(T==="general"){(ae=k.current)==null||ae.abort(),k.current=null,S.current+=1;return}return Ne(T),()=>{var pe;(pe=k.current)==null||pe.abort(),k.current=null,S.current+=1}},[T,Ne,d]),m.useEffect(()=>{const ae=w.current,pe=x.current;if(!ae||!pe||T!=="general"||!P||j)return;const z=new IntersectionObserver(([ve])=>{ve.isIntersecting&&oe(P,!1)},{root:pe,rootMargin:"240px 0px",threshold:.01});return z.observe(ae),()=>z.disconnect()},[T,oe,j,P]);const Ve=m.useCallback(async ae=>{if(!fe){Ae(ae.id);try{await new Promise(pe=>requestAnimationFrame(()=>pe())),ae.sandbox?await c(ae.sandbox):await s(ae)}finally{Ae("")}}},[fe,s,c]),We=m.useMemo(()=>{const ae=N.trim().toLocaleLowerCase(),pe=T==="general"?[...Re,...M]:I,z=ae?pe.filter(Je=>Je.name.toLocaleLowerCase().includes(ae)):pe;if(T!=="general")return z;const ve=h.size>0?z.filter(Je=>!Je.runtime||!h.has(Je.runtime.runtimeId)):z,Be=ve.findIndex(Je=>{var kt;return((kt=Je.runtime)==null?void 0:kt.runtimeId)===f});return Be<=0?ve:[ve[Be],...ve.slice(0,Be),...ve.slice(Be+1)]},[T,f,Re,h,N,M,I]),De=Jj.find(ae=>ae.id===T),mt=(De==null?void 0:De.label)??"智能体",at=T==="general"?j&&M.length===0&&Re.length===0:q&&I.length===0,Rt=!at&&We.length===0,qe=t?T==="general"?()=>i(Qi(e)):()=>o(T):void 0,W=T==="codex"&&t&&!!r,K=t?void 0:"当前账号没有创建智能体权限";return l.jsxs("div",{className:"my-agents-page",children:[l.jsxs("header",{className:"my-agents-header",children:[l.jsxs("div",{className:"my-agents-heading",children:[l.jsx("div",{className:"my-agents-title-row",children:l.jsx("h1",{children:"智能体"})}),l.jsx("p",{children:n==="all"?"在此处浏览所有智能体":"在此处浏览您的所有智能体"})]}),l.jsxs("label",{className:"my-agent-search",children:[l.jsx(kct,{}),l.jsx("input",{type:"search","aria-label":"搜索智能体",value:N,onChange:ae=>C(ae.target.value),placeholder:"搜索所有类型智能体名称"})]})]}),l.jsxs("div",{className:"my-agent-type-bar",children:[l.jsx("nav",{className:"my-agent-type-pills","aria-label":"智能体类型",children:Jj.map(ae=>l.jsx("button",{type:"button",className:`my-agent-type-pill${T===ae.id?" is-active":""}`,"aria-pressed":T===ae.id,onClick:()=>Oe(ae.id),children:ae.label},ae.id))}),l.jsxs("div",{className:"my-agent-type-actions",children:[W?l.jsxs("button",{type:"button",className:"my-agent-create-secondary",onClick:r,children:[l.jsx(Tct,{}),l.jsx("span",{children:"接力"})]}):null,l.jsxs("button",{type:"button",className:"my-agent-create-primary",disabled:!qe,title:K,onClick:()=>qe==null?void 0:qe(),children:[l.jsx(eR,{}),l.jsx("span",{children:"创建智能体"})]})]})]}),l.jsxs("section",{className:"my-agent-results",ref:x,"aria-label":`${mt}列表`,children:[at?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载智能体"})]}):(T==="general"?U:H)&&We.length===0?l.jsxs("div",{className:"my-agent-empty",role:"alert",children:[l.jsx("p",{children:T==="general"?U:H}),l.jsx("button",{type:"button",onClick:()=>{T==="general"?oe("",!0):Ne(T)},children:"重新加载"})]}):Rt?N.trim()?l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(jwe,{})}),l.jsx(Oi.Title,{children:"没有匹配的智能体"}),l.jsx(Oi.Description,{children:"请尝试搜索其他名称"})]})}):T!=="general"?l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(_ct,{type:T})}),l.jsxs(Oi.Title,{className:"my-agent-sandbox-empty-title",children:["暂无 ",mt]}),t?l.jsx(Oi.ActionRow,{children:l.jsxs(zu,{color:"primary",size:"lg",onClick:()=>o(T),children:[l.jsx(eR,{}),"创建智能体"]})}):null]})}):l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(Pf,{})}),l.jsx(Oi.Title,{children:"暂无通用智能体"}),l.jsx(Oi.Description,{children:"创建一个通用智能体,开始构建和对话"}),t?l.jsx(Oi.ActionRow,{children:l.jsxs(zu,{color:"primary",size:"lg",onClick:()=>i(Qi(e)),children:[l.jsx(eR,{}),"创建智能体"]})}):null]})}):l.jsxs(l.Fragment,{children:[T==="general"&&U?l.jsxs("div",{className:"my-agent-inline-error",role:"alert",children:[l.jsx("span",{children:U}),l.jsx("button",{type:"button",onClick:()=>void oe("",!0),children:"重新加载"})]}):null,l.jsx("div",{className:"my-agent-grid",children:We.map(ae=>{var pe;return l.jsx(Rct,{agent:ae,cloudProvider:e,deploymentTask:me(ae),nowMs:ue,onViewDeploymentTask:y,onUse:Ve,onViewDetails:z=>{z.sandbox?u(z.sandbox):a(z)},connecting:ae.id===fe,connected:((pe=ae.runtime)==null?void 0:pe.runtimeId)===f,showOwnership:n==="all",onEditDraft:O,onDeleteDraft:ie},ae.id)})})]}),T==="general"&&!U&&!at&&(We.length>0||!!P)&&l.jsx("div",{className:"my-agent-load-more",ref:w,"aria-live":"polite",children:j?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多智能体"})]}):P?l.jsx("span",{children:"继续下滑加载更多"}):l.jsx("span",{children:"已加载全部智能体"})})]}),J?l.jsx(Mf,{title:"删除草稿?",description:`删除后将无法恢复“${J.draft.name||"未命名 Agent"}”。`,confirmLabel:"删除草稿",variant:"danger",onCancel:()=>ie(null),onConfirm:()=>{v==null||v(J),ie(null)}}):null]})}function Pct(e){return e==="127.0.0.1"}const Mct={id:"coding-agents",kind:"coding-agent",category:"development",icon:"coding-agents",name:"配置 Coding Agents",badge:"本地",badgeTone:"success",description:"将 VeADK 和 AgentKit 内置 Skills 全局配置到 Trae、Claude Code 或 Codex。"},Lct={id:"feishu",kind:"feishu",category:"channels",icon:"feishu",name:"飞书机器人",badge:"Beta",description:"创建飞书机器人,并将消息直接接入 AgentKit Runtime。"},Dct="https://api.github.com",$ct=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,Hq=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/,Qct=/^[A-Za-z0-9._/-]+$/;function Bct(e,t,n){return e===401||e===403?"GitHub Token 无效或没有仓库写入权限":e===404?"仓库、分支或文件不存在,或 Token 无权访问":e===422?"GitHub 拒绝了提交,请检查分支和文件状态":String((t==null?void 0:t.message)||"").split(n).join("***").trim().slice(0,240)||`GitHub 请求失败(HTTP ${e})`}async function bh(e,t){const n={Accept:"application/vnd.github+json",Authorization:`Bearer ${t.token}`,"X-GitHub-Api-Version":"2022-11-28"};t.body&&(n["Content-Type"]="application/json");let i;try{i=await fetch(`${Dct}${e}`,{method:t.method||"GET",headers:n,body:t.body?JSON.stringify(t.body):void 0,signal:t.signal})}catch(s){throw t.signal.aborted?s:new Error("连接 GitHub 失败,请检查网络后重试")}const r=await i.json().catch(()=>null);if(!t.expected.includes(i.status))throw new Error(Bct(i.status,r,t.token));return{status:i.status,payload:r}}function tR(e){return e.split("/").map(encodeURIComponent).join("/")}function Uct(e){const t=new TextEncoder().encode(e);let n="";const i=32768;for(let r=0;r({...h,path:lQ(h.path,"")})),s=AbortSignal.any([t,AbortSignal.timeout(6e4)]),a=`/repos/${n}`;await bh(`${a}`,{token:e.token,expected:[200],signal:s});const c=(f=(await bh(`${a}/git/ref/heads/${tR(i)}`,{token:e.token,expected:[200],signal:s})).payload.object)==null?void 0:f.sha;if(!c)throw new Error("目标分支缺少有效 Git SHA");const u=zct(e.branchPrefix);await bh(`${a}/git/refs`,{token:e.token,expected:[201],signal:s,method:"POST",body:{ref:`refs/heads/${u}`,sha:c}});let d=!0;try{for(const p of r){const g=tR(p.path),b=await bh(`${a}/contents/${g}?ref=${encodeURIComponent(i)}`,{token:e.token,expected:[200,404],signal:s});if(p.mustBeNew&&b.status===200)throw new Error(`目标仓库中已存在 ${p.path},未覆盖现有文件`);if(b.status===200&&!b.payload.sha)throw new Error(`目标路径 ${p.path} 不是可更新的文件`);await bh(`${a}/contents/${g}`,{token:e.token,expected:[200,201],signal:s,method:"PUT",body:{message:p.commitMessage,content:Uct(p.content),branch:u,...b.payload.sha?{sha:b.payload.sha}:{}}})}const h=await bh(`${a}/pulls`,{token:e.token,expected:[201],signal:s,method:"POST",body:{title:e.title,head:u,base:i,body:e.description}});if(!h.payload.number||!h.payload.html_url)throw new Error("GitHub 未返回有效的 Pull Request");return d=!1,{number:h.payload.number,url:h.payload.html_url,branch:u}}finally{d&&await bh(`${a}/git/refs/heads/${tR(u)}`,{token:e.token,expected:[204],signal:AbortSignal.timeout(15e3),method:"DELETE"}).catch(()=>{})}}const uQ={name:"repository",label:"GitHub Repo",placeholder:"owner/repository",help:"支持 owner/repository 或完整 github.com URL",required:!0},dQ={name:"baseBranch",label:"目标分支",placeholder:"main",help:"留空时使用 main,PR 将以此分支为 base",required:!1},Xhe={name:"runtimeName",label:"Runtime 名称",placeholder:"support-agent",help:"用于 AgentKit 发布配置",required:!0},qhe={name:"runtimeId",label:"Runtime ID",placeholder:"rt-xxxxxxxx",help:"持续更新的目标 AgentKit Runtime",required:!0};function fQ(e={}){return{repository:"",baseBranch:"main",projectPath:".",runtimeName:"",runtimeId:"",sandboxToolId:"",modelName:"",modelBaseUrl:"https://ark.cn-beijing.volces.com/api/coding/v3",region:"cn-beijing",token:"",...e}}function hQ(e){return{repository:e.repository.trim(),baseBranch:e.baseBranch.trim()||"main",region:e.region,token:e.token.trim()}}const Fct=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,Vct=/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;function Xct(e){if(!Fct.test(e.sandboxToolId))throw new Error("Sandbox Tool ID 格式不正确");if(!Vct.test(e.modelName))throw new Error("模型名称格式不正确");let t;try{t=new URL(e.modelBaseUrl)}catch{throw new Error("模型 API 地址必须是安全的 HTTPS URL")}if(t.protocol!=="https:"||!t.hostname||t.username||t.password||t.search||t.hash)throw new Error("模型 API 地址必须是安全的 HTTPS URL")}function qct(e){Xct(e);const t=String.raw`name: PR Automated Review +`),h=(t==null?void 0:t.pendingMessage)||"正在等待构建日志…";if(m.useEffect(()=>{t&&s(i)},[e.id,t==null?void 0:t.status,i]),m.useEffect(()=>{if(!r||!c)return;const v=n.current;v&&(v.scrollTop=v.scrollHeight)},[r,c,f]),!t||!t.text&&t.status!=="error"&&!t.pendingMessage)return null;const p=nct(t.updatedAt),g=t.status==="complete"?"已同步":t.status==="error"?"读取失败":"同步中",b=t.omittedEarly?"已省略早期日志":t.snapshotTruncated?"仅显示最近的构建日志":t.truncated?"已省略部分日志":"",y=[g,t.lineCount?`${t.lineCount} 行`:"",b,p].filter(Boolean).join(" · ");async function O(){try{await navigator.clipboard.writeText(u),o(!0),window.setTimeout(()=>o(!1),1500)}catch{o(!1)}}return l.jsxs("section",{className:`aw-deploy-log is-${t.status}${r?"":" is-collapsed"}`,"aria-label":"构建日志",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"构建日志"}),l.jsx("span",{children:y})]}),l.jsxs("div",{className:"aw-deploy-log-actions",children:[c&&l.jsx("button",{type:"button",onClick:()=>s(v=>!v),children:r?"收起":"展开"}),c&&l.jsxs("button",{type:"button",onClick:()=>void O(),"aria-label":a?"已复制构建日志":"复制构建日志",title:a?"已复制":"复制构建日志",children:[a?l.jsx(Hc,{"aria-hidden":!0}):l.jsx(g_,{"aria-hidden":!0}),l.jsx("span",{children:a?"已复制":"复制"})]})]})]}),r&&(c?l.jsx("pre",{ref:n,children:f}):l.jsx("div",{className:"aw-deploy-log-empty",children:h}))]})}function rct({task:e,onReturnToEdit:t}){const n=Uhe(e),i=zhe(e),r=e.status==="success"?100:Math.max(6,Math.min(100,e.pct??6)),s=e.status==="running"?"正在部署":e.status==="success"?"部署完成":e.status==="error"?"部署失败":"部署已取消";return l.jsxs("section",{className:`aw-deploy-progress-card is-${e.status}`,"aria-live":"polite",children:[l.jsxs("div",{className:"aw-deploy-progress-head",children:[l.jsxs("div",{children:[l.jsx("span",{className:"aw-deploy-progress-icon","aria-hidden":!0,children:e.status==="running"?l.jsx(Kn,{className:"spin"}):e.status==="success"?l.jsx(zwe,{}):e.status==="error"?l.jsx(uJ,{}):l.jsx(n9,{})}),l.jsxs("div",{children:[l.jsx("h3",{children:s}),l.jsx("p",{children:e.runtimeName})]})]}),l.jsx("strong",{children:e.status==="running"?`${Math.round(r)}%`:e.label})]}),l.jsx("div",{className:"aw-deploy-progress-track",role:"progressbar","aria-label":"部署进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:l.jsx("span",{style:{width:`${r}%`}})}),l.jsx("ol",{className:"aw-deploy-steps",children:n.map((a,o)=>{const c=e.status==="success"||onew Set),[Qt,Yt]=m.useState(()=>new Set),[Jt,Ft]=m.useState(!1),[Ce,et]=m.useState(""),[wt,yn]=m.useState(null),[on,hi]=m.useState([]),[Pe,st]=m.useState([]),[At,Ut]=m.useState(!1),[kn,wn]=m.useState(""),[Ai,Gn]=m.useState(""),[xn,de]=m.useState(0),[Le,ut]=m.useState([]),[gt,ln]=m.useState(!1),[Sn,In]=m.useState(""),[Ni,Pn]=m.useState(0),[Vt,Ji]=m.useState(null),[fn,pi]=m.useState(1),[ti,vi]=m.useState(!1),[en,Ci]=m.useState(""),[xs,ni]=m.useState(0),[Ls,er]=m.useState(!1),[Ya,mr]=m.useState(()=>new Set),[gr,ul]=m.useState(!1),[Sa,as]=m.useState(""),[Mn,vs]=m.useState(""),[Zl,Gr]=m.useState(()=>new Set),tr=m.useRef(!1),No=m.useRef(""),Dr=m.useRef(null),os=m.useRef(0),na=m.useRef(0),Co=m.useRef(0),[br,ia]=m.useState(Dlt),[ji,Kl]=m.useState("");m.useEffect(()=>{e.length!==0&&ia(Y=>Y.map((he,be)=>be===0&&he.agentIds.length===0?{...he,agentIds:e.slice(0,2).map(Ue=>Ue.id)}:he))},[e]);const Ke=m.useMemo(()=>{const Y=new Map;for(const he of e)he.runtimeId&&Y.set(he.runtimeId,he);return Y},[e]),Ds=m.useMemo(()=>{var he;const Y=new Map;for(const be of t){const Ue=(he=be.deploymentTarget)==null?void 0:he.runtimeId;if(!Ue||!Ke.has(Ue))continue;const xt=Y.get(Ue);(!xt||be.updatedAt>xt.updatedAt)&&Y.set(Ue,be)}return Y},[Ke,t]),Ea=m.useMemo(()=>{const Y=new Map;for(const he of f){if(!he.runtimeId)continue;const be=Y.get(he.runtimeId);(!be||he.startedAt>be.startedAt)&&Y.set(he.runtimeId,he)}return Y},[f]),nu=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return Y?e.filter(he=>{const be=he.runtimeId?Ds.get(he.runtimeId):void 0,Ue=he.runtimeId?Ea.get(he.runtimeId):void 0;return[he.label,he.app,he.host??"",(be==null?void 0:be.draft.name)??"",(be==null?void 0:be.draft.description)??"",(Ue==null?void 0:Ue.runtimeName)??""].join(" ").toLowerCase().includes(Y)}):e},[e,Ea,ve,Ds]),$s=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return t.filter(he=>{var Ue;const be=(Ue=he.deploymentTarget)==null?void 0:Ue.runtimeId;return be&&Ke.has(be)?!1:Y?`${he.draft.name} ${he.draft.description}`.toLowerCase().includes(Y):!0})},[Ke,t,ve]),Jl=m.useMemo(()=>t.filter(Y=>{var be;const he=(be=Y.deploymentTarget)==null?void 0:be.runtimeId;return!he||!Ke.has(he)}).length,[Ke,t]),ec=m.useMemo(()=>{const Y=ve.trim().toLowerCase();return Y?br.filter(he=>he.name.toLowerCase().includes(Y)):br},[br,ve]),le=e.find(Y=>Y.id===$),gn=t.find(Y=>Y.id===B),Wn=h?f.find(Y=>Y.id===h):void 0,Vi=le!=null&&le.runtimeId?Ds.get(le.runtimeId):void 0,Ln=O?K:$&&r===$?i:null,Tn=(Ln==null?void 0:Ln.appName)||(le==null?void 0:le.runtimeApp)||(le==null?void 0:le.app)||"",ra=c&&(le!=null&&le.runtimeId)?Iq:Iq.filter(Y=>Y.id!=="usage"),Qs=JSON.stringify([(le==null?void 0:le.runtimeId)??"",(le==null?void 0:le.region)??"cn-beijing",Tn,fn]),dr=(Vt==null?void 0:Vt.requestKey)===Qs?Vt.value:null,ws=`${(le==null?void 0:le.region)??"cn-beijing"}:${(le==null?void 0:le.runtimeId)??""}`,ls=(Re==null?void 0:Re.requestKey)===ws?Re.value:"",te=(D==null?void 0:D.requestKey)===ws?D:null,Me=!!((yv=te==null?void 0:te.apiApps)!=null&&yv.length),ee=!!(te!=null&&te.a2a),_e=((xv=te==null?void 0:te.apiApps)==null?void 0:xv[0])??Tn,tt=(X==null?void 0:X.endpoint)??"",Ct=Ult(((Eb=te==null?void 0:te.a2a)==null?void 0:Eb.endpoint)??"",tt),He=JSON.stringify([(le==null?void 0:le.runtimeId)??"",(le==null?void 0:le.region)??"",Tn]),ht=(De==null?void 0:De.requestKey)===He?De.value:null;m.useEffect(()=>{const Y=os.current+1;os.current=Y,mt(null),W("");const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"";if(!o||!he||!be){Rt(!1);return}const Ue=new AbortController;return Rt(!0),pee({runtimeId:he,region:be,appName:Tn,signal:Ue.signal}).then(xt=>{var Xt,Ri;if(Y===os.current){if(xt.runtime.runtimeId!==he||xt.runtime.region!==be||Tn&&((Xt=xt.agent)==null?void 0:Xt.appName)!==Tn||xt.canUpdate&&!((Ri=xt.agent)!=null&&Ri.appName)){W("Runtime 更新能力响应与当前选择不匹配。");return}mt({requestKey:He,value:xt})}}).catch(xt=>{Y!==os.current||Ue.signal.aborted||W(xt instanceof Error?xt.message:"检查 Runtime 更新能力失败。")}).finally(()=>{Y===os.current&&!Ue.signal.aborted&&Rt(!1)}),()=>Ue.abort()},[o,le==null?void 0:le.region,le==null?void 0:le.runtimeId,Tn,He]);const Pt=m.useMemo(()=>{const Y=new Map(e.map((be,Ue)=>[be.id,Ue])),he=new Map(n.map((be,Ue)=>[be,Ue]));return[...nu].sort((be,Ue)=>{const xt=be.runtimeId?Ea.get(be.runtimeId):void 0,Xt=Ue.runtimeId?Ea.get(Ue.runtimeId):void 0,Ri=(xt==null?void 0:xt.status)==="running"?xt.startedAt:0,nc=(Xt==null?void 0:Xt.status)==="running"?Xt.startedAt:0;if(Ri!==nc)return nc-Ri;const gi=he.get(be.id),ic=he.get(Ue.id);return gi!=null&&ic!=null?gi-ic:gi!=null?-1:ic!=null?1:(Y.get(be.id)??0)-(Y.get(Ue.id)??0)})},[n,e,nu,Ea]),jt=(le==null?void 0:le.label)||(Ln==null?void 0:Ln.name)||(gn==null?void 0:gn.draft.name)||(Wn==null?void 0:Wn.agentName)||((vv=Wn==null?void 0:Wn.agentDraft)==null?void 0:vv.name)||"未选择智能体",bn=br.find(Y=>Y.id===ji),Xi=Pt.filter(Y=>Y.canDelete===!0),Ss=Pt.filter(Y=>Wt.has(Y.id)&&Y.canDelete===!0),Dn=$s.filter(Y=>Qt.has(Y.id)),Wr=Xi.length+$s.length,sa=Ss.length+Dn.length,qi=m.useMemo(()=>(Wn==null?void 0:Wn.agentDraft)??(gn==null?void 0:gn.draft)??(Vi==null?void 0:Vi.draft)??Xlt(Ln,Tn||(le==null?void 0:le.label)||"agent"),[Ln,Tn,le==null?void 0:le.label,Vi==null?void 0:Vi.draft,gn==null?void 0:gn.draft,Wn==null?void 0:Wn.agentDraft]),Xe=gn?a?"":"当前账号没有新建 Agent 的权限。":o?le!=null&&le.runtimeId?le.region?at?"正在检查 Runtime 更新能力…":qe||(ht?ht.canUpdate?(Zp=ht.agent)!=null&&Zp.appName?"":"Runtime 更新能力响应缺少智能体信息。":ht.reason||"当前 Runtime 不支持原地更新。":"尚未完成 Runtime 更新能力检查。"):"Runtime 缺少地域信息,无法更新。":"仅支持更新已部署的云端智能体。":"当前账号没有管理 Agent 的权限。",_n="aw-update-disabled-reason",dl=ht!=null&&ht.agent?{runtimeId:ht.runtime.runtimeId,name:ht.runtime.name,region:ht.runtime.region,appName:ht.agent.appName,currentVersion:ht.runtime.currentVersion}:Vi==null?void 0:Vi.deploymentTarget,fl=m.useMemo(()=>{if(Ln)return Ln.tools;const Y=(qi.builtinTools??[]).map(he=>{var be;return((be=Qp.find(Ue=>Ue.id===he))==null?void 0:be.label)??he});return Array.from(new Set([...qi.tools,...Y,...(qi.customTools??[]).map(he=>he.name),...(qi.mcpTools??[]).map(he=>he.name)].filter(Boolean)))},[qi,Ln]),mi=m.useMemo(()=>Ln?Ln.skillsPreviewSupported?Ln.skills.map(Y=>Y.name):null:Array.from(new Set([...(qi.selectedSkills??[]).map(Y=>Y.name),...qi.skills].filter(Boolean))),[qi,Ln]),Zn=m.useMemo(()=>{if(Wn)return Wn;if(gn)return f.filter(Y=>{var he,be;return((he=Y.agentDraft)==null?void 0:he.name)===gn.draft.name||Y.agentName===gn.draft.name||!!((be=gn.deploymentTarget)!=null&&be.runtimeId)&&Y.runtimeId===gn.deploymentTarget.runtimeId}).sort((Y,he)=>he.startedAt-Y.startedAt)[0];if(le)return f.filter(Y=>!!le.runtimeId&&Y.runtimeId===le.runtimeId||Y.agentName===le.label).sort((Y,he)=>he.startedAt-Y.startedAt)[0]},[f,le,gn,Wn]),cv=!!(h&&Zn&&Zn.id===h),yb=!!(Zn&&(Zn.status!=="success"||cv)),uv=(Zn==null?void 0:Zn.status)==="running",tc=Zn!=null&&Zn.draftId?t.find(Y=>Y.id===Zn.draftId)??(Zn.agentDraft?{id:Zn.draftId,draft:Zn.agentDraft,updatedAt:Zn.startedAt}:void 0):void 0,dv=m.useMemo(()=>Klt(qi),[qi]),hl=(le==null?void 0:le.currentVersion)??(X==null?void 0:X.currentVersion)??null,sN=hl??(Wn==null?void 0:Wn.startedAt)??"unknown",$n=Ln?`runtime:${(le==null?void 0:le.runtimeId)??Ln.name}:v${sN}:${dv}`:`draft:${(Wn==null?void 0:Wn.id)??(gn==null?void 0:gn.id)??(le==null?void 0:le.id)??jt}:${dv}`;m.useEffect(()=>{Q==="usage"&&!c&&j("basic")},[c,Q]),m.useEffect(()=>{if(!h)return;const Y=f.find(be=>be.id===h),he=Y!=null&&Y.runtimeId?Ke.get(Y.runtimeId):void 0;if(he){I(""),U(he.id),j("basic");return}U(""),I(""),j("basic")},[Ke,f,h]),m.useEffect(()=>{if(!p){No.current="";return}const Y=`${p}:${g}:${b}:${c}`;No.current!==Y&&e.some(he=>he.id===p)&&(No.current=Y,I(""),U(p),j(g==="usage"&&!c?"basic":g),g==="evaluations"&&(kt(b),Tt("")))},[e,c,p,g,b]),m.useEffect(()=>{for(const Y of Pt.slice(0,8)){if(!Y.runtimeId)continue;const he=Y.region??"cn-beijing";gee(Y.runtimeId,he),KJ(Y.runtimeId,he,Y.runtimeApp??""),Ok(Y.runtimeId,he,Y.runtimeApp??"").then(be=>{const Ue=be.appName||Y.app;Ue&&nP({runtimeId:Y.runtimeId??"",region:he,appName:Ue,pageSize:100})}).catch(()=>{})}},[Pt]),m.useEffect(()=>{!(le!=null&&le.runtimeId)||!Tn||nP({runtimeId:le.runtimeId,region:le.region??"cn-beijing",appName:Tn,pageSize:100})},[Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=(le==null?void 0:le.runtimeApp)??"",xt=he?ZJ(he,be,Ue):null;if(ae(xt),z(!!xt||!O||!he),!(!O||!he))return Ok(he,be,Ue,{force:!0}).then(Xt=>{Y||ae(Xt)}).catch(()=>{!Y&&!xt&&ae(null)}).finally(()=>{Y||z(!0)}),()=>{Y=!0}},[O,le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeApp,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing";if(ut([]),In(""),Q!=="optimizations"||!he){ln(!1);return}if(O&&!Tn){ln(!pe);return}return ln(!0),$J({runtimeId:he,region:be,appName:Tn}).then(Ue=>{Y||ut(Ue.groups)}).catch(Ue=>{Y||In(Ue instanceof Error?Ue.message:String(Ue))}).finally(()=>{Y||ln(!1)}),()=>{Y=!0}},[pe,O,Ni,Q,Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{pi(1)},[le==null?void 0:le.runtimeId,Tn]),m.useEffect(()=>{const Y=Co.current+1;Co.current=Y;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=Tn;if(Ci(""),Q!=="usage"||!he){vi(!1);return}if(!Ue){vi(O&&!pe);return}const xt=new AbortController;return vi(!0),uee({runtimeId:he,region:be,appName:Ue,page:fn,pageSize:$lt,signal:xt.signal}).then(Xt=>{if(Y===Co.current){if(Xt.runtimeId!==he||Xt.appName!==Ue||Xt.page!==fn){Ci("用量响应与当前 Agent 不匹配,请重试。");return}Ji({requestKey:Qs,value:Xt})}}).catch(Xt=>{Y!==Co.current||xt.signal.aborted||Ci(Xt instanceof Error?Xt.message:"加载 Agent 用量失败。")}).finally(()=>{Y===Co.current&&vi(!1)}),()=>{xt.abort()}},[fn,xs,Qs,pe,O,Q,Tn,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{na.current+=1,Ee(null),oe(!1),Oe(!1),We(""),Se("api-server")},[ws,Q]);function fv(){na.current+=1,Ee(null),oe(!1),Oe(!1),We("")}function hv(Y){Y!==ye&&(fv(),Se(Y))}async function pv(){if(me){fv();return}const Y=(le==null?void 0:le.runtimeId)??"",he=(le==null?void 0:le.region)??"cn-beijing";if(!Y)return;const be=na.current+1;na.current=be,Oe(!0),We("");try{const Ue=await fee(Y,he);if(be!==na.current)return;Ee({requestKey:ws,value:Ue}),oe(!0)}catch(Ue){if(be!==na.current)return;Ee(null),oe(!1),We(Ue instanceof Error?Ue.message:"读取 Runtime API Key 失败。")}finally{be===na.current&&Oe(!1)}}m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=he?mee(he,be):null;if(q(Ue),!!he)return e$(he,be,{force:!0}).then(xt=>{Y||q(xt)}).catch(()=>{!Y&&!Ue&&q(null)}),()=>{Y=!0}},[le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=`${be}:${he}`;if(J(""),Q!=="integrations"||!he){fe(!1),he||H(null);return}fe(!0);const xt=JD(he,be,{retryProbe:!0}).catch(Xt=>{if(Xt instanceof ga&&Xt.unsupported)return null;throw Xt});return Promise.all([xt,dee(he,be,{retryProbe:!0})]).then(([Xt,Ri])=>{Y||H({requestKey:Ue,apiApps:Xt,a2a:Ri})}).catch(Xt=>{Y||(H(null),J(Xt instanceof Error?Xt.message:"探测集成方式失败。"))}).finally(()=>{Y||fe(!1)}),()=>{Y=!0}},[ie,Q,le==null?void 0:le.currentVersion,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{let Y=!1;const he=(le==null?void 0:le.runtimeId)??"",be=(le==null?void 0:le.region)??"cn-beijing",Ue=he&&Tn?QJ({runtimeId:he,region:be,appName:Tn,pageSize:100}):null;if(hi(Ue?Dq(Ue):[]),st((Ue==null?void 0:Ue.sets)??[]),wn(""),Gn((Ue==null?void 0:Ue.unsupportedMessage)??""),Q!=="evaluations"||!he){Ut(!1);return}if(O&&!Tn){Ut(!pe);return}return Ut(!Ue),w_({runtimeId:he,region:be,appName:Tn,pageSize:100},{force:!0}).then(xt=>{Y||(st(xt.sets),hi(Dq(xt)),Gn(xt.unsupportedMessage??""))}).catch(xt=>{Y||(wn(xt instanceof Error?xt.message:String(xt)),Gn(""))}).finally(()=>{Y||Ut(!1)}),()=>{Y=!0}},[pe,O,xn,Q,Tn,Ln==null?void 0:Ln.appName,le==null?void 0:le.region,le==null?void 0:le.runtimeId]),m.useEffect(()=>{const Y=new Set(on.map(he=>he.id));mr(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be}),Gr(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be}),Mn&&!Y.has(Mn)&&vs("")},[on,Mn]),m.useEffect(()=>{er(!1),mr(new Set),Gr(new Set),as(""),vs("")},[le==null?void 0:le.runtimeId]),m.useEffect(()=>{const Y=new Set(Pt.filter(he=>he.canDelete===!0).map(he=>he.id));dn(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be})},[Pt]),m.useEffect(()=>{const Y=new Set($s.map(he=>he.id));Yt(he=>{const be=new Set([...he].filter(Ue=>Y.has(Ue)));return be.size===he.size?he:be})},[$s]);const Sd=m.useMemo(()=>!y||!(le!=null&&le.runtimeId)||y.runtimeId!==le.runtimeId||Tn&&y.agentName&&y.agentName!==Tn?null:{...y,tag:y.kind==="good"?"Good case":"Bad case"},[y,le==null?void 0:le.runtimeId,Tn]),Gp=m.useMemo(()=>le!=null&&le.runtimeId?Sd?[Sd,...on.filter(Y=>Y.id!==Sd.id&&(!Y.messageId||Y.messageId!==Sd.messageId))]:on:Llt,[on,Sd,le==null?void 0:le.runtimeId]),pl=Gp.filter(Y=>{if(Y.kind!==Je||(Y.source==="auto"?"auto":"user")!==dt)return!1;const be=Mt.trim().toLowerCase();return be?[Y.input,Y.output,Y.referenceOutput,Y.comment,Y.tag??"",Y.sessionId,Y.messageId,Y.userId,Y.evaluationSetName].join(" ").toLowerCase().includes(be):!0}),xb=pl.filter(Y=>Ya.has(Y.id)),Ed=!!(le!=null&&le.runtimeId),vb=Y=>{kt(Y),Tt(""),as("");const he=Gp.find(be=>be.kind===Y);vs((he==null?void 0:he.id)??""),window.setTimeout(()=>{var be;(be=Dr.current)==null||be.scrollIntoView({behavior:"smooth",block:"start"})},0)},aN=Y=>{as(""),mr(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be})},mv=()=>{as(""),mr(new Set(pl.map(Y=>Y.id)))},oN=()=>{as(""),mr(new Set),er(!1)},Wp=Y=>{Gr(he=>{const be=new Set(he);return be.has(Y)?be.delete(Y):be.add(Y),be})},lN=Y=>{vs(Y.id),as(""),!(!Y.sessionId||!Y.messageId)&&(T==null||T(Y))},wb=async Y=>{if(!(le!=null&&le.runtimeId)||!Tn||gr||Y.length===0)return;const he=Y.length===1?"确定删除这条反馈案例?原始聊天记录不会被删除。":`确定删除选中的 ${Y.length} 条反馈案例?原始聊天记录不会被删除。`;if(!window.confirm(he))return;const be=Y.map(xt=>xt.id),Ue=new Set(be);ul(!0),as("");try{await zJ({runtimeId:le.runtimeId,region:le.region??"cn-beijing",appName:Tn,itemIds:be});const xt=new Map;for(const Xt of Y)xt.set(Xt.kind,(xt.get(Xt.kind)??0)+1);hi(Xt=>Xt.filter(Ri=>!Ue.has(Ri.id))),st(Xt=>Xt.map(Ri=>({...Ri,itemCount:Math.max(0,Ri.itemCount-(xt.get(Ri.kind)??0))}))),mr(Xt=>new Set([...Xt].filter(Ri=>!Ue.has(Ri)))),Gr(Xt=>new Set([...Xt].filter(Ri=>!Ue.has(Ri)))),Mn&&Ue.has(Mn)&&vs(""),Y.length>1&&er(!1),A==null||A(Y)}catch(xt){as(xt instanceof Error?xt.message:String(xt))}finally{ul(!1)}},gv=Y=>{ia(he=>he.map(be=>be.id===Y.id?Y:be))},iu=()=>{const Y=new Set(e.map(Ue=>Ue.id)),he=n.filter(Ue=>Y.has(Ue)),be=new Set(he);return[...he,...e.filter(Ue=>!be.has(Ue.id)).map(Ue=>Ue.id)]},bv=(Y,he,be)=>{if(!x||Y===he)return;const Ue=iu().filter(Ri=>Ri!==Y),xt=Ue.indexOf(he),Xt=xt<0?Ue.length:be==="after"?xt+1:xt;Ue.splice(Xt,0,Y),x(Ue)},ru=(Y,he)=>{if(!lt||lt===he)return;const be=Y.currentTarget.getBoundingClientRect();_t(he),je(Y.clientY>be.top+be.height/2?"after":"before")},ah=(Y,he)=>{if(!x)return;const be=iu(),Ue=be.indexOf(Y),xt=Math.max(0,Math.min(be.length-1,Ue+he));Ue<0||Ue===xt||(be.splice(Ue,1),be.splice(xt,0,Y),x(be))},cN=Y=>{Y.canDelete===!0&&(et(""),dn(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be}))},jo=Y=>{et(""),Yt(he=>{const be=new Set(he);return be.has(Y.id)?be.delete(Y.id):be.add(Y.id),be})},uN=()=>{et(""),dn(new Set(Xi.map(Y=>Y.id))),Yt(new Set($s.map(Y=>Y.id)))},vn=()=>{et(""),dn(new Set),Yt(new Set),Ie(!1)},dN=()=>{if(sa===0||Jt)return;const Y=Ss.length,he=Dn.length;et(""),yn({kind:"selection",title:Y===1&&he===0?"删除 Agent?":Y===0&&he===1?"删除草稿?":"删除所选项目?",description:Y===1&&he===0?`"${Ss[0].label}" 对应的云端 Runtime 将被永久删除,此操作不可撤销。`:Y===0&&he===1?`"${Dn[0].draft.name||"未命名 Agent"}" 将从本地草稿中删除。`:`将删除选中的 ${sa} 个项目。${Y>0?`${Y} 个云端 Runtime 将被永久删除,此操作不可撤销。`:"草稿删除后无法恢复。"}`,confirmLabel:Y===0&&he===1?"删除草稿":"删除所选",agents:Ss,drafts:Dn})},fN=async()=>{if(!(!wt||Jt)){Ft(!0),et("");try{if(wt.kind==="selection"){const{agents:Y,drafts:he}=wt;if(Y.length>0){if(!w)throw new Error("当前页面不支持删除已部署 Agent。");await w(Y)}he.length>0&&(E==null||E(he)),dn(new Set),Yt(new Set),Ie(!1),Y.some(be=>be.id===$)&&U(""),he.some(be=>be.id===B)&&I("")}else if(wt.kind==="agent"){if(!w)throw new Error("当前页面不支持删除已部署 Agent。");await w([wt.agent]),$===wt.agent.id&&U("")}else{if(!E)throw new Error("当前页面不支持删除草稿。");E([wt.draft]),B===wt.draft.id&&I("")}yn(null)}catch(Y){et(Y instanceof Error?Y.message:String(Y))}finally{Ft(!1)}}},hN=Y=>{!w||Y.canDelete!==!0||Jt||(et(""),yn({kind:"agent",title:"删除 Agent?",description:`"${Y.label}" 对应的云端 Runtime 将被永久删除,此操作不可撤销。`,confirmLabel:"删除 Agent",agent:Y}))},nr=Y=>{if(!E||Jt)return;const he=Y.draft.name||"未命名 Agent";et(""),yn({kind:"draft",title:"删除草稿?",description:`"${he}" 将从本地草稿中删除。`,confirmLabel:"删除草稿",draft:Y})},Ov=()=>{const Y=`eval-${Date.now()}`,he={id:Y,name:`新评测组 ${br.length+1}`,agentIds:[],caseSet:"核心回归集",evaluator:"综合质量评估器",metrics:["回答质量"],concurrency:"4",history:[]};ia(be=>[he,...be]),Kl(Y)},Sb=Y=>{gv({...Y,history:[{id:`run-${Date.now()}`,createdAt:"刚刚",score:86+Y.history.length%7,status:"completed"},...Y.history]})};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`aw-root${O?" is-detail-only":""}`,children:[l.jsxs("nav",{className:"aw-view-tabs","aria-label":"智能体工作台",children:[l.jsx("button",{type:"button",className:L==="library"?"is-active":"","aria-pressed":L==="library",onClick:()=>{P("library"),Be("")},children:"智能体库"}),l.jsx("button",{type:"button",className:L==="evaluation"?"is-active":"","aria-pressed":L==="evaluation",onClick:()=>{P("evaluation"),Be("")},children:"评测"})]}),l.jsxs("div",{className:"aw-workspace-frame",children:[l.jsxs("div",{className:"aw-workspace","aria-hidden":L==="evaluation"||void 0,ref:Y=>{Y==null||Y.toggleAttribute("inert",L==="evaluation")},children:[l.jsxs("aside",{className:"aw-sidebar","aria-label":L==="library"?"智能体列表":"评测组列表",children:[l.jsxs("label",{className:"aw-search",children:[l.jsx(hk,{"aria-hidden":!0}),l.jsx("input",{value:ve,onChange:Y=>Be(Y.currentTarget.value),placeholder:L==="library"?"搜索智能体":"搜索评测组","aria-label":L==="library"?"搜索智能体":"搜索评测组"})]}),l.jsxs("button",{type:"button",className:"aw-create-card",onClick:L==="library"?N:Ov,disabled:L==="library"&&!a,children:[l.jsx(Gs,{"aria-hidden":!0}),l.jsx("span",{children:L==="library"?"新建 Agent":"新建评测组"})]}),L==="library"&&(w||E)&&l.jsx("div",{className:`aw-selection-toolbar${Ze?" is-active":""}`,children:Ze?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"aw-selection-count",children:["已选 ",sa," 个"]}),l.jsx("button",{type:"button",onClick:uN,disabled:Wr===0||Jt,children:"全选"}),l.jsx("button",{type:"button",className:"aw-selection-danger",onClick:()=>void dN(),disabled:sa===0||Jt,children:Jt?"删除中…":"删除所选"}),l.jsx("button",{type:"button",onClick:vn,disabled:Jt,children:"取消"})]}):l.jsx("button",{type:"button",onClick:()=>{et(""),Ie(!0)},disabled:Wr===0,children:"选择"})}),L==="library"&&Ce&&l.jsx("div",{className:"aw-delete-error",role:"alert",children:Ce}),l.jsx("div",{className:"aw-agent-list",children:L==="evaluation"?ec.length===0?l.jsx("div",{className:"aw-list-empty",children:"没有匹配的评测组"}):ec.map(Y=>l.jsxs("button",{type:"button",className:`aw-agent-item${Y.id===ji?" is-active":""}`,onClick:()=>Kl(Y.id),children:[l.jsxs("span",{className:"aw-agent-copy aw-eval-group-copy",children:[l.jsx("strong",{children:Y.name}),l.jsxs("small",{children:[Y.agentIds.length," 个智能体 · ",Y.history.length," 次运行"]})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)):u&&Pt.length===0&&$s.length===0?l.jsx("div",{className:"aw-list-empty",children:"正在读取云端智能体…"}):d&&Pt.length===0&&$s.length===0?l.jsxs("div",{className:"aw-list-empty aw-list-error",children:[l.jsx("span",{children:d}),v&&l.jsx("button",{type:"button",onClick:v,children:"重试"})]}):Pt.length===0&&$s.length===0?l.jsx("div",{className:"aw-list-empty",children:"没有匹配的智能体"}):l.jsxs(l.Fragment,{children:[$s.map(Y=>{const he=f.filter(Ue=>{var xt,Xt;return((xt=Ue.agentDraft)==null?void 0:xt.name)===Y.draft.name||Ue.agentName===Y.draft.name||!!((Xt=Y.deploymentTarget)!=null&&Xt.runtimeId)&&Ue.runtimeId===Y.deploymentTarget.runtimeId}).sort((Ue,xt)=>xt.startedAt-Ue.startedAt)[0],be=Qt.has(Y.id);return l.jsxs("button",{type:"button",className:["aw-agent-item",Ze?"is-selecting":"",be?"is-selected-for-delete":"",Y.id===B?"is-active":""].filter(Boolean).join(" "),"aria-pressed":Ze?be:void 0,onClick:()=>{if(Ze){jo(Y);return}U(""),I(Y.id),j("basic")},children:[Ze&&l.jsx("span",{className:`aw-select-marker${be?" is-checked":""}`,"aria-hidden":"true"}),l.jsxs("span",{className:"aw-agent-copy",children:[l.jsxs("span",{className:"aw-agent-name-row",children:[l.jsx("strong",{children:Y.draft.name||"未命名 Agent"}),l.jsx("span",{className:`aw-draft-badge${(he==null?void 0:he.status)==="running"?" is-deploying":""}`,children:(he==null?void 0:he.status)==="running"?"部署中":"草稿"})]}),l.jsx("small",{children:Y.deploymentTarget?"待更新":"尚未发布"})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)}),Pt.map(Y=>{const he=Y.runtimeId?Ea.get(Y.runtimeId):void 0,be=Y.runtimeId?Ds.get(Y.runtimeId):void 0,Ue=Wt.has(Y.id),xt=Y.canDelete===!0,Xt=(he==null?void 0:he.status)==="running"?{label:"部署中",className:" is-deploying"}:(he==null?void 0:he.status)==="error"?{label:"失败",className:" is-error"}:(he==null?void 0:he.status)==="cancelled"?{label:"已取消",className:" is-muted"}:be?{label:"待更新",className:""}:null,Ri=(he==null?void 0:he.status)==="running"?"正在更新部署":be?"待更新":Y.remote?Y.host||"远程智能体":"本地智能体",nc=["aw-agent-item","aw-agent-item--sortable",Y.id===$?"is-active":"",Ze?"is-selecting":"",Ue?"is-selected-for-delete":"",Ze&&!xt?"is-selection-disabled":"",Y.id===lt?"is-dragging":"",Y.id===vt&&Y.id!==lt?`is-drop-target is-drop-${Bt}`:""].filter(Boolean).join(" ");return l.jsxs("button",{type:"button",draggable:!!x&&!Ze,className:nc,"aria-pressed":Ze?Ue:void 0,"aria-keyshortcuts":x?"Alt+ArrowUp Alt+ArrowDown":void 0,onDragStart:gi=>{x&&(tr.current=!0,Ge(Y.id),gi.dataTransfer.effectAllowed="move",gi.dataTransfer.setData("text/plain",Y.id))},onDragEnter:gi=>{ru(gi,Y.id)},onDragOver:gi=>{!lt||lt===Y.id||(gi.preventDefault(),gi.dataTransfer.dropEffect="move",ru(gi,Y.id))},onDragLeave:gi=>{const ic=gi.relatedTarget;ic instanceof Node&&gi.currentTarget.contains(ic)||vt===Y.id&&_t("")},onDrop:gi=>{gi.preventDefault();const ic=gi.dataTransfer.getData("text/plain")||lt;bv(ic,Y.id,Bt),Ge(""),_t(""),je("before")},onDragEnd:()=>{Ge(""),_t(""),je("before"),window.setTimeout(()=>{tr.current=!1},0)},onKeyDown:gi=>{gi.altKey&&(gi.key==="ArrowUp"?(gi.preventDefault(),ah(Y.id,-1)):gi.key==="ArrowDown"&&(gi.preventDefault(),ah(Y.id,1)))},onClick:gi=>{if(Ze){gi.preventDefault(),cN(Y);return}if(tr.current){gi.preventDefault(),tr.current=!1;return}I(""),U(Y.id),j("basic"),S(Y.id)},children:[Ze&&l.jsx("span",{className:`aw-select-marker${Ue?" is-checked":""}`,"aria-hidden":"true"}),l.jsxs("span",{className:"aw-agent-copy",children:[l.jsxs("span",{className:"aw-agent-name-row",children:[l.jsx("strong",{children:Y.label}),Y.currentVersion!=null&&l.jsxs("span",{className:"aw-version-badge",children:["v",Y.currentVersion]}),Xt&&l.jsx("span",{className:`aw-draft-badge${Xt.className}`,children:Xt.label})]}),l.jsx("small",{children:Ri})]}),l.jsx(ay,{"aria-hidden":!0})]},Y.id)})]})}),l.jsxs("div",{className:"aw-list-count",children:["共 ",L==="library"?e.length+Jl:br.length," 个"]})]}),L==="evaluation"&&bn?l.jsx(cct,{group:bn,agents:e,cases:Gp,onChange:gv,onRun:Sb}):L==="evaluation"?l.jsx("main",{className:"aw-main aw-empty-selection",children:l.jsx("p",{children:"未选择评测组"})}):!le&&!gn&&!Wn?l.jsx("main",{className:"aw-main aw-empty-selection",children:l.jsx("p",{children:"未选择智能体"})}):l.jsxs("main",{className:`aw-main${uv?" is-deploying":""}`,children:[le&&!Ln&&s&&l.jsx("div",{className:"aw-detail-loading",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"aw-detail-loading-card",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:"正在加载智能体"}),l.jsx("small",{children:"正在读取配置与运行信息…"})]})]})}),Q==="integrations"&&re&&l.jsx("div",{className:"aw-detail-loading",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"aw-detail-loading-card",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:"正在探测接入方式"}),l.jsx("small",{children:"正在确认 API Server 与 A2A…"})]})]})}),l.jsxs("div",{className:"aw-agent-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"aw-agent-title-row",children:[l.jsx("h2",{children:jt}),hl!=null&&l.jsxs("span",{children:["v",hl]}),gn&&l.jsx("span",{children:"草稿"}),Vi&&l.jsx("span",{children:"待更新"}),!le&&!gn&&Wn&&l.jsx("span",{children:Wn.label})]}),l.jsx("p",{children:qi.description||(s||O&&!pe?"正在读取智能体信息…":"暂无描述")})]}),(gn||Vi||(le==null?void 0:le.canDelete))&&l.jsxs("div",{className:"aw-head-actions",children:[(gn||Vi)&&l.jsxs("button",{type:"button",className:"aw-head-delete aw-head-delete--draft",onClick:()=>{const Y=gn??Vi;Y&&nr(Y)},disabled:Jt,"aria-label":"删除草稿",title:"删除草稿",children:[l.jsx(If,{"aria-hidden":!0}),l.jsx("span",{children:"删除草稿"})]}),(le==null?void 0:le.canDelete)&&l.jsxs("button",{type:"button",className:"aw-head-delete",onClick:()=>void hN(le),disabled:Jt,"aria-label":"删除 Agent",title:"删除 Agent",children:[l.jsx(If,{"aria-hidden":!0}),l.jsx("span",{children:Jt?"删除中…":"删除 Agent"})]})]})]}),Zn&&yb&&l.jsx("div",{className:`aw-detail-deployment${uv?" is-running":""}`,children:l.jsx(rct,{task:Zn,onReturnToEdit:tc&&M?()=>M(tc):void 0})}),l.jsx("nav",{className:"aw-agent-tabs","aria-label":"智能体详情",role:"tablist",children:ra.map(Y=>l.jsx("button",{type:"button",id:`agent-${Y.id}-tab`,className:Q===Y.id?"is-active":"",role:"tab","aria-selected":Q===Y.id,"aria-controls":`agent-${Y.id}-panel`,tabIndex:Q===Y.id?0:-1,onClick:()=>j(Y.id),onKeyDown:he=>{var Xt;if(!["ArrowLeft","ArrowRight","Home","End"].includes(he.key))return;he.preventDefault();const be=ra.findIndex(Ri=>Ri.id===Y.id),Ue=he.key==="Home"?0:he.key==="End"?ra.length-1:(be+(he.key==="ArrowRight"?1:-1)+ra.length)%ra.length,xt=ra[Ue];j(xt.id),(Xt=document.getElementById(`agent-${xt.id}-tab`))==null||Xt.focus()},children:Y.label},Y.id))}),l.jsxs("div",{className:"aw-content",id:`agent-${Q}-panel`,role:"tabpanel","aria-labelledby":`agent-${Q}-tab`,children:[Q==="basic"&&l.jsxs("div",{className:"aw-basic-stack",children:[l.jsxs("section",{className:"aw-deployment-panel aw-settings-card",children:[l.jsx("div",{className:"aw-section-head",children:l.jsxs("div",{children:[l.jsx("h3",{children:"部署配置"}),l.jsx("p",{children:"配置目标环境与网络访问方式。"})]})}),l.jsxs("dl",{className:"aw-readonly-config",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"运行状态"}),l.jsxs("dd",{className:(X==null?void 0:X.status.toLowerCase())==="ready"?"is-ready":void 0,children:[(X==null?void 0:X.status.toLowerCase())==="ready"&&l.jsx("span",{className:"aw-status-dot"}),(X==null?void 0:X.status)||"读取中…"]})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"部署区域"}),l.jsx("dd",{children:(X==null?void 0:X.region)||(le==null?void 0:le.region)||(Zn==null?void 0:Zn.region)||"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"网络访问"}),l.jsx("dd",{children:X!=null&&X.networkTypes.length?X.networkTypes.join(" / "):"暂未提供"})]})]})]}),l.jsxs("section",{className:"aw-canvas-card",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"执行流程"})}),l.jsx("div",{className:"aw-canvas",children:l.jsx(px,{draft:qi,direction:"horizontal",selectedPath:[],onSelect:()=>{},onAdd:()=>{},onInsert:()=>{},onDelete:()=>{},readOnly:!0,interactivePreview:!0},$n)})]}),l.jsxs("section",{className:"aw-details-card",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"详细信息"})}),l.jsxs("dl",{className:"aw-facts",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:(Ln==null?void 0:Ln.model)||qi.modelName||"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"智能体数量"}),l.jsx("dd",{children:Ln!=null&&Ln.graph?Qhe(Ln.graph):Bhe(qi)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"工具"}),l.jsx("dd",{className:"aw-fact-badges",children:fl.length?fl.map(Y=>l.jsx("span",{children:Y},Y)):"暂无"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能"}),l.jsx("dd",{className:"aw-fact-badges",children:mi===null?"暂不支持预览":mi.length?mi.map(Y=>l.jsx("span",{children:Y},Y)):"暂无"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:hl!=null?`v${hl}`:"暂未提供"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:gn?"草稿":(Zn==null?void 0:Zn.status)==="error"?"部署失败":(Zn==null?void 0:Zn.status)==="cancelled"?"已取消":Vi?"待更新":l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"aw-status-dot"}),"可用"]})})]})]})]})]}),Q==="usage"&&(le==null?void 0:le.runtimeId)&&l.jsxs("section",{className:"aw-usage","aria-busy":ti,children:[l.jsx("div",{className:"aw-usage-intro",children:l.jsx("h3",{children:"使用概览"})}),ti&&!dr&&l.jsx("div",{className:"aw-usage-state",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载用量统计"})}),en&&l.jsxs("div",{className:"aw-usage-state is-error",role:"alert",children:[l.jsx("span",{children:en}),l.jsx("button",{type:"button",onClick:()=>ni(Y=>Y+1),children:"重试"})]}),!ti&&!en&&!dr&&!Tn&&l.jsx("div",{className:"aw-usage-state",children:"当前 Runtime 未返回可用的 Agent 应用名称,暂时无法读取用量。"}),dr&&l.jsxs(l.Fragment,{children:[l.jsxs("dl",{className:"aw-usage-summary","aria-label":"Agent 用量摘要",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"总调用次数"}),l.jsx("dd",{children:dr.totalInvocations.toLocaleString("zh-CN")})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"使用用户数"}),l.jsx("dd",{children:dr.totalUsers.toLocaleString("zh-CN")})]})]}),l.jsxs("div",{className:"aw-usage-users-head",children:[l.jsx("h3",{children:"用户明细"}),ti&&l.jsx(oi,{as:"span",role:"status","aria-live":"polite",children:"正在刷新"})]}),dr.users.length===0?l.jsx("div",{className:"aw-usage-state",children:"暂无使用记录。用户成功调用后将在这里显示。"}):l.jsx("div",{className:"aw-usage-table-wrap",children:l.jsxs("table",{className:"aw-usage-table",children:[l.jsx("caption",{children:"当前 Agent 的使用用户列表"}),l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"用户"}),l.jsx("th",{scope:"col",children:"调用次数"}),l.jsx("th",{scope:"col",children:"最近使用"})]})}),l.jsx("tbody",{children:dr.users.map(Y=>l.jsxs("tr",{children:[l.jsxs("td",{children:[l.jsx("strong",{children:Y.displayName||Y.userId||"未知用户"}),Y.displayName&&Y.userId&&l.jsx("small",{title:Y.userId,children:Y.userId})]}),l.jsx("td",{children:Y.invocationCount.toLocaleString("zh-CN")}),l.jsx("td",{children:l.jsx("time",{dateTime:Y.lastUsedAt,children:Blt(Y.lastUsedAt)})})]},Y.userId))})]})}),dr.totalPages>1&&l.jsxs("nav",{className:"aw-usage-pagination","aria-label":"用量用户列表分页",children:[l.jsx("button",{type:"button",disabled:ti||dr.page<=1,onClick:()=>pi(Y=>Math.max(1,Y-1)),children:"上一页"}),l.jsxs("span",{"aria-live":"polite",children:["第 ",dr.page," / ",dr.totalPages," 页"]}),l.jsx("button",{type:"button",disabled:ti||dr.page>=dr.totalPages,onClick:()=>pi(Y=>Y+1),children:"下一页"})]})]})]}),Q==="integrations"&&l.jsxs("div",{className:"aw-integration-stack",children:[l.jsxs("div",{className:"aw-integration-intro",children:[l.jsx("h3",{children:"接入方式"}),l.jsx("p",{children:"仅展示当前 Runtime 可确认的公开协议与地址。"})]}),Ae&&l.jsxs("div",{className:"aw-integration-error",role:"alert",children:[l.jsx("span",{children:Ae}),l.jsx("button",{type:"button",onClick:()=>ue(Y=>Y+1),children:"重试"})]}),!Ae&&l.jsxs("div",{className:"aw-integration-body",children:[l.jsxs("div",{className:`aw-integration-protocol-tabs${ye==="a2a"?" is-a2a":""}`,role:"tablist","aria-label":"接入协议",children:[l.jsx("span",{className:"aw-integration-protocol-slider","aria-hidden":"true"}),fO.map((Y,he)=>l.jsx("button",{type:"button",id:`integration-${Y.id}-tab`,role:"tab","aria-selected":ye===Y.id,"aria-controls":`integration-${Y.id}-panel`,tabIndex:ye===Y.id?0:-1,onClick:()=>hv(Y.id),onKeyDown:be=>{var Xt;if(!["ArrowLeft","ArrowRight","Home","End"].includes(be.key))return;be.preventDefault();const Ue=be.key==="Home"?0:be.key==="End"?fO.length-1:(he+(be.key==="ArrowRight"?1:-1)+fO.length)%fO.length,xt=fO[Ue];hv(xt.id),(Xt=document.getElementById(`integration-${xt.id}-tab`))==null||Xt.focus()},children:Y.label},Y.id))]}),ye==="api-server"?l.jsx(Lq,{protocol:"api-server",title:"API Server",available:Me,fields:[{label:"Agent",value:Me?((kb=te==null?void 0:te.apiApps)==null?void 0:kb.join("、"))??"":""},{label:"发现接口",value:Me?Zj(tt,"/list-apps"):""},{label:"调用接口",value:Me?Zj(tt,"/run_sse"):""},{label:"鉴权方式",value:Me?Pq(X==null?void 0:X.authType):""},{label:"API Key",value:l.jsx(Mq,{available:Me,authType:X==null?void 0:X.authType,value:ls,visible:me&&!!ls,loading:Ne,error:Ve,onToggle:()=>void pv()})}],example:Me?zlt(tt,_e,X==null?void 0:X.authType):""}):l.jsx(Lq,{protocol:"a2a",title:"A2A",available:ee,fields:[{label:"Agent",value:((wv=te==null?void 0:te.a2a)==null?void 0:wv.name)??""},{label:"Agent Card",value:ee?Zj(tt,"/.well-known/agent-card.json"):""},{label:"调用地址",value:Ct},{label:"鉴权方式",value:ee?Pq(X==null?void 0:X.authType):""},{label:"API Key",value:l.jsx(Mq,{available:ee,authType:X==null?void 0:X.authType,value:ls,visible:me&&!!ls,loading:Ne,error:Ve,onToggle:()=>void pv()})}],example:ee?Flt(Ct,X==null?void 0:X.authType):""})]})]}),Q==="evaluations"&&l.jsxs("section",{className:"aw-cases",children:[(le==null?void 0:le.runtimeId)&&l.jsx("div",{className:"aw-case-summary",children:["good","bad"].map(Y=>{const he=Zlt(Pe,Y),be=Gp.filter(xt=>xt.kind===Y).length,Ue=Sd?be:(he==null?void 0:he.itemCount)??be;return l.jsxs("button",{type:"button",onClick:()=>vb(Y),children:[l.jsx("strong",{children:Ue}),l.jsx("span",{children:Y==="good"?"Good cases":"Bad cases"})]},Y)})}),l.jsxs("div",{className:"aw-case-filter-bar",children:[l.jsxs("div",{className:"aw-case-filter-stack",children:[l.jsx("div",{className:"aw-case-filters","aria-label":"案例结果筛选",children:["good","bad"].map(Y=>l.jsx("button",{type:"button",className:Je===Y?"is-active":"","aria-pressed":Je===Y,onClick:()=>kt(Y),children:Y==="good"?"Good case":"Bad case"},Y))}),l.jsx("div",{className:"aw-case-source-filters","aria-label":"回流方式筛选",children:["auto","user"].map(Y=>l.jsx("button",{type:"button",className:dt===Y?"is-active":"","aria-pressed":dt===Y,onClick:()=>ge(Y),children:Y==="auto"?"自动回流":"手动回流"},Y))})]}),l.jsxs("label",{className:"aw-case-search",children:[l.jsx(hk,{"aria-hidden":!0}),l.jsx("input",{type:"search",value:Mt,onChange:Y=>Tt(Y.currentTarget.value),placeholder:"搜索用户输入、期望行为或标签","aria-label":"搜索评测案例"})]})]}),Ed&&l.jsx("div",{className:`aw-case-toolbar${Ls?" is-active":""}`,children:Ls?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"aw-selection-count",children:["已选 ",xb.length," 条"]}),l.jsx("button",{type:"button",onClick:mv,disabled:pl.length===0||gr,children:"全选当前"}),l.jsx("button",{type:"button",className:"aw-selection-danger",onClick:()=>void wb(xb),disabled:xb.length===0||gr,children:gr?"删除中…":"删除所选"}),l.jsx("button",{type:"button",onClick:oN,disabled:gr,children:"取消"})]}):l.jsx("button",{type:"button",onClick:()=>{as(""),er(!0)},disabled:pl.length===0||gr,children:"选择案例"})}),Sa&&l.jsx("div",{className:"aw-delete-error",role:"alert",children:Sa}),l.jsx("div",{ref:Dr,children:l.jsx(lct,{cases:pl,loading:At&&pl.length===0,error:kn,notice:Ai,runtimeBacked:!!(le!=null&&le.runtimeId),selectionMode:Ls,selectedCaseIds:Ya,focusedCaseId:Mn,expandedCaseIds:Zl,deleting:gr,canDelete:Ed,onOpenCase:lN,onToggleCase:aN,onToggleExpanded:Wp,onDeleteCase:Y=>void wb([Y]),onRetry:()=>de(Y=>Y+1)})})]}),Q==="optimizations"&&l.jsxs("section",{className:"aw-optimizations",children:[l.jsxs("div",{className:"aw-optimization-intro",children:[l.jsx("h3",{children:"优化项"}),l.jsx("p",{children:"根据评测结果汇总需要优先处理的改进建议。"})]}),gt?l.jsxs("div",{className:"aw-optimization-state",role:"status",children:[l.jsx("span",{className:"loading-gap-spinner","aria-hidden":"true"}),l.jsx("span",{children:"正在读取优化项"})]}):Sn?l.jsxs("div",{className:"aw-optimization-state is-error",role:"alert",children:[l.jsx("span",{children:Sn}),l.jsx("button",{type:"button",onClick:()=>Pn(Y=>Y+1),children:"重试"})]}):Le.length>0?l.jsx(act,{groups:Le}):l.jsx("div",{className:"aw-optimization-state",children:"暂无优化项,自动评测完成后会在这里生成建议。"})]})]}),Q==="basic"&&(le||gn)&&l.jsxs("div",{className:"aw-basic-actions",children:[le&&l.jsxs("button",{type:"button",className:"aw-talk studio-update-action",onClick:()=>k==null?void 0:k(le),children:[l.jsx(iSe,{"aria-hidden":!0}),l.jsx("span",{children:"去对话"})]}),l.jsxs("span",{className:`aw-update-wrap${Xe?" is-disabled":""}`,tabIndex:Xe?0:void 0,"aria-describedby":Xe?_n:void 0,children:[l.jsx("button",{type:"button",className:"aw-update studio-update-action",disabled:!!Xe,"aria-busy":at||void 0,"aria-describedby":Xe?_n:void 0,onClick:()=>{var Y;return gn?M==null?void 0:M(gn):Vi?M==null?void 0:M({...Vi,deploymentTarget:dl}):ht?C(((Y=ht.agent)==null?void 0:Y.draft)??qi,ht):void 0},children:at?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"loading-gap-spinner aw-update-spinner","aria-hidden":"true"}),l.jsx("span",{children:"检测中"})]}):gn||Vi?"继续编辑":"更新"}),Xe&&l.jsx("span",{id:_n,className:"aw-update-disabled-reason",role:"tooltip",children:Xe})]})]})]})]}),L==="evaluation"&&l.jsx("div",{className:"aw-evaluation-glass",role:"status",children:l.jsx("span",{children:"敬请期待"})})]})]}),wt&&l.jsx(Mf,{variant:"danger",title:wt.title,description:wt.description,confirmLabel:Jt?"删除中...":wt.confirmLabel,closeLabel:"关闭删除确认",busy:Jt,onCancel:()=>yn(null),onConfirm:()=>void fN()})]})}function act({groups:e}){return l.jsx("div",{className:"aw-optimization-table-wrap",children:l.jsxs("table",{className:"aw-optimization-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",children:"修复优先级"}),l.jsx("th",{scope:"col",children:"建议优化模块"}),l.jsx("th",{scope:"col",children:"优化建议和理由"})]})}),l.jsx("tbody",{children:e.map(t=>l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:`aw-priority is-${t.priority}`,children:Ylt(t.priority)})}),l.jsx("td",{children:l.jsx("span",{className:"aw-optimization-module",children:Wlt(t)})}),l.jsx("td",{children:l.jsx("ul",{className:"aw-optimization-list",children:t.items.map(n=>l.jsxs("li",{children:[l.jsx("strong",{children:n.suggestion}),l.jsx("p",{children:n.reason})]},`${n.suggestion}:${n.reason}`))})})]},`${t.priority}:${t.module}:${t.customModule??""}`))})]})})}function oct(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4.5 7h15"}),l.jsx("path",{d:"M9 7V4.8h6V7"}),l.jsx("path",{d:"m6.5 7 .8 12h9.4l.8-12"}),l.jsx("path",{d:"M10 10.5v5M14 10.5v5"})]})}function lct({cases:e,loading:t=!1,error:n="",notice:i="",runtimeBacked:r=!1,selectionMode:s=!1,selectedCaseIds:a,focusedCaseId:o="",expandedCaseIds:c,deleting:u=!1,canDelete:d=!1,onOpenCase:f,onToggleCase:h,onToggleExpanded:p,onDeleteCase:g,onRetry:b}){return l.jsxs("div",{className:"aw-case-table",children:[l.jsxs("div",{className:"aw-case-row aw-case-row-head",children:[l.jsx("span",{children:"用户输入"}),l.jsx("span",{children:"Agent 输出"}),l.jsx("span",{children:"评分"}),l.jsx("span",{children:"评分理由"}),l.jsx("span",{className:"aw-case-action-head",children:"操作"})]}),t?l.jsx("div",{className:"aw-case-empty",children:"正在读取 AgentKit 评测集…"}):n?l.jsxs("div",{className:"aw-case-empty aw-case-error",children:[l.jsx("span",{children:n}),b&&l.jsx("button",{type:"button",onClick:b,children:"重试"})]}):i?l.jsx("div",{className:"aw-case-empty",children:i}):e.length===0?l.jsx("div",{className:"aw-case-empty",children:r?"暂无用户反馈案例":"没有匹配的案例"}):e.map(y=>{var T,A;const O=y.id.startsWith("local:"),v=(a==null?void 0:a.has(y.id))??!1,x=(c==null?void 0:c.has(y.id))??!1,E=y.output.length+y.referenceOutput.length>220||(((T=y.reason)==null?void 0:T.length)??0)>120,S=d&&!O,k=!!(y.comment&&y.comment.trim()!==((A=y.reason)==null?void 0:A.trim()));return l.jsxs("div",{className:["aw-case-row",o===y.id?"is-focused":"",s?"is-selecting":"",v?"is-selected-for-delete":""].filter(Boolean).join(" "),role:"row",tabIndex:0,"aria-selected":s?v:void 0,onClick:()=>{if(s){S&&(h==null||h(y));return}f==null||f(y)},onKeyDown:N=>{N.target===N.currentTarget&&(N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),s?S&&(h==null||h(y)):f==null||f(y)))},children:[l.jsxs("div",{className:"aw-case-text aw-case-cell","data-label":"用户输入",children:[l.jsxs("span",{className:"aw-case-title-line",children:[s&&S&&l.jsx("span",{className:`aw-select-marker${v?" is-checked":""}`,"aria-hidden":"true"}),l.jsx("strong",{title:y.input,children:y.input||"无用户输入"})]}),k&&l.jsxs("small",{title:y.comment,children:["备注:",y.comment]}),l.jsx("small",{className:"aw-case-time",children:qlt(y.createdAt)}),(y.userId||y.sessionId)&&l.jsx("small",{title:[y.userId,y.sessionId].filter(Boolean).join(" · "),children:[y.userId,y.sessionId].filter(Boolean).join(" · ")})]}),l.jsxs("div",{className:`aw-case-output aw-case-cell${x?" is-expanded":""}`,"data-label":"Agent 输出",children:[l.jsx("p",{className:"aw-case-output-preview",title:y.output,children:y.output||"无可见回复"}),y.referenceOutput&&l.jsxs("small",{className:"aw-case-output-preview",title:y.referenceOutput,children:["Reference: ",y.referenceOutput]}),E&&l.jsx("button",{type:"button",className:"aw-case-expand",onClick:N=>{N.stopPropagation(),p==null||p(y.id)},children:x?"收起":"展开"})]}),l.jsx("div",{className:"aw-case-score aw-case-cell","data-label":"评分",children:Hlt(y)}),l.jsx("div",{className:`aw-case-reason aw-case-cell${x?" is-expanded":""}`,"data-label":"评分理由",children:l.jsx("p",{title:y.reason||void 0,children:y.reason||"—"})}),l.jsx("div",{className:"aw-case-actions aw-case-cell","data-label":"操作",children:S&&l.jsx("button",{type:"button",className:"aw-case-delete",onClick:N=>{N.stopPropagation(),g==null||g(y)},disabled:u,title:"删除反馈案例","aria-label":"删除反馈案例",children:l.jsx(oct,{})})})]},y.id)})]})}function cct({group:e,agents:t,cases:n,onChange:i,onRun:r}){const[s,a]=m.useState("config"),o=e.agentIds.map(f=>t.find(h=>h.id===f)).filter(f=>!!f),c=["回答质量","事实准确性","工具调用","响应效率"];m.useEffect(()=>a("config"),[e.id]);const u=f=>{i({...e,agentIds:e.agentIds.includes(f)?e.agentIds.filter(h=>h!==f):[...e.agentIds,f]})},d=f=>{i({...e,metrics:e.metrics.includes(f)?e.metrics.filter(h=>h!==f):[...e.metrics,f]})};return l.jsxs("main",{className:"aw-main",children:[l.jsxs("div",{className:"aw-eval-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"aw-agent-title-row",children:[l.jsx("h2",{children:e.name}),l.jsx("span",{children:"评测组"})]}),l.jsxs("p",{children:[o.length," 个参评智能体 · ",e.caseSet," · ",e.history.length," 次运行"]})]}),l.jsxs("button",{type:"button",className:"aw-run",onClick:()=>r(e),disabled:!0,children:[l.jsx(Zwe,{"aria-hidden":!0}),"开始评测"]})]}),l.jsxs("nav",{className:"aw-agent-tabs","aria-label":"评测组详情",children:[l.jsx("button",{type:"button",className:s==="config"?"is-active":"","aria-pressed":s==="config",onClick:()=>a("config"),disabled:!0,children:"评测配置"}),l.jsx("button",{type:"button",className:s==="history"?"is-active":"","aria-pressed":s==="history",onClick:()=>a("history"),disabled:!0,children:"历史结果"})]}),l.jsx("div",{className:"aw-content",children:s==="config"?l.jsxs("div",{className:"aw-eval-setup",children:[l.jsxs("section",{className:"aw-eval-block",children:[l.jsxs("div",{className:"aw-card-head",children:[l.jsx("strong",{children:"参评智能体"}),l.jsxs("span",{children:["已选择 ",o.length," 个"]})]}),l.jsx("div",{className:"aw-eval-agent-grid",children:t.map(f=>l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:e.agentIds.includes(f.id),onChange:()=>u(f.id)}),l.jsxs("span",{children:[l.jsx("strong",{children:f.label}),l.jsx("small",{children:f.remote?"远程":"本地"})]})]},f.id))})]}),l.jsxs("div",{className:"aw-eval-setting-grid",children:[l.jsxs("section",{className:"aw-eval-block",children:[l.jsx("div",{className:"aw-card-head",children:l.jsx("strong",{children:"评测资源"})}),l.jsxs("div",{className:"aw-eval-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"评测集"}),l.jsxs("select",{value:e.caseSet,onChange:f=>i({...e,caseSet:f.currentTarget.value}),children:[l.jsx("option",{children:"核心回归集"}),l.jsx("option",{children:"安全边界集"}),l.jsx("option",{children:"工具调用集"})]}),l.jsxs("small",{children:[n.length," 条案例"]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"评估器"}),l.jsxs("select",{value:e.evaluator,onChange:f=>i({...e,evaluator:f.currentTarget.value}),children:[l.jsx("option",{children:"综合质量评估器"}),l.jsx("option",{children:"事实一致性评估器"}),l.jsx("option",{children:"工具调用评估器"})]})]}),l.jsxs("label",{children:[l.jsx("span",{children:"并发数"}),l.jsxs("select",{value:e.concurrency,onChange:f=>i({...e,concurrency:f.currentTarget.value}),children:[l.jsx("option",{value:"2",children:"2"}),l.jsx("option",{value:"4",children:"4"}),l.jsx("option",{value:"8",children:"8"})]})]})]})]}),l.jsxs("section",{className:"aw-eval-block",children:[l.jsxs("div",{className:"aw-card-head",children:[l.jsx("strong",{children:"评测指标"}),l.jsxs("span",{children:["已选择 ",e.metrics.length," 项"]})]}),l.jsx("div",{className:"aw-metric-list",children:c.map(f=>l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:e.metrics.includes(f),onChange:()=>d(f)}),l.jsx("span",{children:f})]},f))})]})]})]}):l.jsxs("section",{className:"aw-eval-history",children:[l.jsx("div",{className:"aw-section-head",children:l.jsxs("div",{children:[l.jsx("h3",{children:"历史结果"}),l.jsx("p",{children:"查看该评测组历次运行的总体表现。"})]})}),e.history.length===0?l.jsxs("div",{className:"aw-results-empty",children:[l.jsx("strong",{children:"暂无历史结果"}),l.jsx("span",{children:"完成首次评测后,结果会出现在这里。"})]}):l.jsx("div",{className:"aw-history-list",children:e.history.map((f,h)=>l.jsxs("button",{type:"button",children:[l.jsxs("span",{children:[l.jsxs("strong",{children:["评测运行 #",e.history.length-h]}),l.jsxs("small",{children:[f.createdAt," · ",o.length," 个智能体"]})]}),l.jsxs("span",{className:"aw-history-score",children:[l.jsx("strong",{children:f.score}),l.jsx("small",{children:"综合得分"})]}),l.jsxs("span",{className:"aw-complete",children:[l.jsx(Hc,{}),"已完成"]}),l.jsx(ay,{"aria-hidden":!0})]},f.id))})]})})]})}const ca="/web/sandbox/sessions",$q="/web/sandbox/codex-project-handoff",Qq=3e4,Kj=33e4,uct=6e4,dct=6e5,hO=15e3,ku=6e4,fct=33e4,Bq=3e4,hct=60*60,Uq=40;function YA(e){switch(e.trim().toLowerCase()){case"ready":return"就绪";case"wakeable":return"可唤醒";case"creating":return"创建中";case"starting":case"initializing":return"启动中";case"pending":return"等待中";case"running":return"运行中";case"failed":case"error":return"异常";case"stopped":return"已停止";case"expired":return"已过期";case"deleting":return"删除中";case"deleted":return"已删除";default:return"未知状态"}}function sr(e){const t=new Headers(e);return t.has("Accept")||t.set("Accept","application/json"),t}async function ar(e,t){const n=await e.text().catch(()=>"");let i={};try{i=JSON.parse(n)}catch{const c=`${t}(HTTP ${e.status})`;return new Error(n?`${c}:${n}`:c)}const r=i.detail,s=r&&typeof r=="object"&&"message"in r?r.message:r??i.error??i.message,a=typeof s=="string"?s:s==null?"":JSON.stringify(s),o=`${t}(HTTP ${e.status})`;return new Error(a?`${o}:${a}`:o)}async function zq(e,t){const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{throw new Error(`${t} Studio 服务响应异常,请刷新后重试。`)}}function gh(e,t="codex"){if(!e.sessionId||!e.status)throw new Error("AgentKit 沙箱返回了无效的 Session 信息。");return{resourceType:"session",id:e.sessionId,toolName:t,userSessionId:e.userSessionId??"",displayName:e.displayName??"",status:e.status,createdAt:e.createdAt??"",expireAt:e.expireAt??"",persistent:e.persistent!==!1,toolType:e.toolType??"",createdBy:e.createdBy??"",threadId:e.threadId??"",cwd:e.cwd??"",workspaceLocked:e.workspaceLocked===!0,busy:e.busy===!0,...typeof e.model=="string"?{model:e.model}:{},permissions:GA(e.permissions)}}function Fq(e,t="codex"){if(!e.snapshotId||!e.status)throw new Error("AgentKit 沙箱返回了无效的 Snapshot 信息。");return{resourceType:"snapshot",id:e.snapshotId,snapshotId:e.snapshotId,sourceSessionId:e.sessionId??"",toolName:t,userSessionId:e.userSessionId??"",displayName:e.displayName??"",status:e.status,snapshotStatus:e.snapshotStatus??"Unknown",reason:e.reason??"",createdAt:e.createdAt??"",createdBy:e.createdBy??""}}function Vq(e,t){if(!(t!=null&&t.autoResumeSnapshots))return e;const n=new URLSearchParams({autoResumeSnapshots:"true"});return`${e}?${n.toString()}`}const pO={approvalPolicy:"on-request",approvalsReviewer:"user",sandboxMode:"workspace-write",networkAccess:!1};function GA(e){if(!e||typeof e!="object")return{...pO};const t=e,n=t.approvalPolicy,i=t.approvalsReviewer,r=t.sandboxMode;return{approvalPolicy:n==="untrusted"||n==="on-request"||n==="never"?n:pO.approvalPolicy,approvalsReviewer:i==="user"||i==="auto_review"?i:pO.approvalsReviewer,sandboxMode:r==="read-only"||r==="workspace-write"||r==="danger-full-access"?r:pO.sandboxMode,networkAccess:typeof t.networkAccess=="boolean"?t.networkAccess:pO.networkAccess}}function Xq(e){if(!e||typeof e!="object")throw new Error("Sandbox 返回了无效设置。");const t=e;return{threadId:typeof t.threadId=="string"?t.threadId:"",cwd:typeof t.cwd=="string"?t.cwd:"",...typeof t.model=="string"?{model:t.model}:{},workspaceLocked:t.workspaceLocked===!0,busy:t.busy===!0,permissions:GA(t.permissions)}}function Xs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function pct(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id))return{id:t.id,displayName:typeof t.displayName=="string"?t.displayName:t.id,description:typeof t.description=="string"?t.description:"",isDefault:t.isDefault===!0}}function mct(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id||typeof t.name!="string"||!t.name))return{id:t.id,name:t.name,description:typeof t.description=="string"?t.description:""}}function Fhe(e){const t=Xs(e);if(!(!t||typeof t.id!="string"||!t.id))return{id:t.id,...typeof t.name=="string"&&t.name?{name:t.name}:{},preview:typeof t.preview=="string"?t.preview:"",cwd:typeof t.cwd=="string"?t.cwd:"",modelProvider:typeof t.modelProvider=="string"?t.modelProvider:"",createdAt:typeof t.createdAt=="number"&&Number.isFinite(t.createdAt)?t.createdAt:0,updatedAt:typeof t.updatedAt=="number"&&Number.isFinite(t.updatedAt)?t.updatedAt:0,status:typeof t.status=="string"?t.status:"unknown"}}function hm(e){const t=Xs(e),n=Fhe(t==null?void 0:t.thread);if(!t||!n||typeof t.threadId!="string"||!Array.isArray(t.messages))throw new Error("Sandbox 返回了无效 Thread 快照。");const i=t.messages.flatMap(r=>{const s=Xs(r);if(!s||typeof s.id!="string"||s.role!=="user"&&s.role!=="assistant"||typeof s.content!="string"||typeof s.timestamp!="number")return[];const a=Array.isArray(s.skillNames)?s.skillNames.filter(c=>typeof c=="string"&&!!c):[],o=Array.isArray(s.images)?s.images.flatMap(c=>{const u=Xs(c);return!u||typeof u.mimeType!="string"||!u.mimeType.startsWith("image/")||typeof u.data!="string"||!u.data?[]:[{mimeType:u.mimeType,data:u.data,...typeof u.name=="string"&&u.name?{name:u.name}:{},...typeof u.alt=="string"&&u.alt?{alt:u.alt}:{}}]}):[];return[{id:s.id,role:s.role,content:s.content,timestamp:s.timestamp,...a.length?{skillNames:a}:{},...o.length?{images:o}:{}}]});return{thread:n,threadId:t.threadId,messages:i,...typeof t.model=="string"?{model:t.model}:{},...typeof t.cwd=="string"?{cwd:t.cwd}:{},workspaceLocked:t.workspaceLocked===!0,permissions:GA(t.permissions)}}function BL(e){if(!e||typeof e!="object")return;const t=e;if(![t.totalTokens,t.inputTokens,t.cachedInputTokens,t.outputTokens,t.reasoningOutputTokens].some(i=>typeof i!="number"||!Number.isFinite(i)||i<0))return{totalTokens:Math.trunc(t.totalTokens),inputTokens:Math.trunc(t.inputTokens),cachedInputTokens:Math.trunc(t.cachedInputTokens),outputTokens:Math.trunc(t.outputTokens),reasoningOutputTokens:Math.trunc(t.reasoningOutputTokens)}}function gct(e){const t=BL(e.usage);if(!t||typeof e.turnId!="string")return;const n=BL(e.threadTotal),i=e.modelContextWindow;return{turnId:e.turnId,usage:t,...n?{threadTotal:n}:{},...typeof i=="number"&&Number.isFinite(i)&&i>=0?{modelContextWindow:Math.trunc(i)}:{}}}function bct(e){return typeof e.id!="string"||e.kind!=="command"&&e.kind!=="file"||typeof e.method!="string"?null:{id:e.id,kind:e.kind,method:e.method,...typeof e.reason=="string"?{reason:e.reason}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.grantRoot=="string"?{grantRoot:e.grantRoot}:{},...e.changes!==void 0?{changes:e.changes}:{},...typeof e.threadId=="string"?{threadId:e.threadId}:{},...typeof e.turnId=="string"?{turnId:e.turnId}:{},...typeof e.itemId=="string"?{itemId:e.itemId}:{}}}async function Oct(e,t={}){if(!e.body)throw new Error("沙箱对话服务未返回内容。");const n=e.body.getReader(),i=new TextDecoder;let r="",s="";const a=[],o=new Map;let c;function u(){var p;(p=t.onBlocks)==null||p.call(t,a.map(g=>({...g})))}function d(p){s+=p;const g=a[a.length-1];(g==null?void 0:g.kind)==="text"?g.text+=p:a.push({kind:"text",text:p}),u()}function f(p){if(typeof p.id!="string"||p.kind!=="thinking"&&p.kind!=="tool"||p.status!=="running"&&p.status!=="done")return;const g=p.status==="done";let b;if(p.kind==="thinking"){if(typeof p.text!="string"||!p.text)return;b={kind:"thinking",text:p.text,done:g}}else{if(typeof p.name!="string"||!p.name)return;b={kind:"tool",name:p.name,args:p.args,response:p.response,done:g}}const y=o.get(p.id);y===void 0?(o.set(p.id,a.length),a.push(b)):a[y]=b,u()}function h(p){var O,v,x;let g="message";const b=[];for(const w of p.split(/\r?\n/))w.startsWith("event:")&&(g=w.slice(6).trim()),w.startsWith("data:")&&b.push(w.slice(5).trimStart());if(b.length===0)return;let y;try{y=JSON.parse(b.join(` +`))}catch{throw new Error("沙箱对话服务返回了无法解析的响应。")}if(g==="error")throw new Error(typeof y.message=="string"&&y.message?y.message:"沙箱对话失败,请稍后重试。");if(g==="activity"&&f(y),g==="approval"){const w=bct(y);w&&((O=t.onApproval)==null||O.call(t,w))}if(g==="usage"){const w=gct(y);w&&(c=w,(v=t.onUsage)==null||v.call(t,w))}g==="approval_resolved"&&typeof y.approvalId=="string"&&((x=t.onApprovalResolved)==null||x.call(t,y.approvalId)),g==="delta"&&typeof y.text=="string"&&d(y.text),g==="done"&&!s&&typeof y.text=="string"&&d(y.text)}for(;;){const{done:p,value:g}=await n.read();r+=i.decode(g,{stream:!p});const b=r.split(/\r?\n\r?\n/);if(r=b.pop()??"",b.forEach(h),p)break}if(r.trim()&&h(r),a.length===0)throw new Error("沙箱未返回有效回复,请重试。");return{text:s,blocks:a,...c?{usage:c}:{}}}async function eo(e,t,{method:n="GET",body:i,options:r={},fallback:s}){if(!e)throw new Error("缺少要操作的 AgentKit Session。");const a=await ri(`${ca}/${encodeURIComponent(e)}/${t}`,{method:n,headers:sr(i===void 0?void 0:{"Content-Type":"application/json"}),...i===void 0?{}:{body:JSON.stringify(i)},signal:r.signal},ku);if(!a.ok)throw await ar(a,s);return a.json()}const Kt={async listSessions(e={}){const t=await ri(Vq(ca,e),{method:"GET",headers:sr(),signal:e.signal},Qq);if(!t.ok)throw await ar(t,"无法读取 Codex 智能体,请稍后重试。");const n=await t.json();if(!Array.isArray(n.sessions))throw new Error("AgentKit 沙箱返回了无效的 Session 列表。");if(n.snapshots!==void 0&&!Array.isArray(n.snapshots))throw new Error("AgentKit 沙箱返回了无效的 Snapshot 列表。");return[...n.sessions.map(i=>gh(i)),...(n.snapshots??[]).map(i=>Fq(i))]},async startSession(e={}){var n;const t=await ri(ca,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({displayName:((n=e.displayName)==null?void 0:n.trim())??"",persistent:e.persistent??!0}),signal:e.signal},Kj);if(!t.ok)throw await ar(t,"无法启动 AgentKit 沙箱,请稍后重试。");return gh(await t.json())},async listAgentSessions(e,t={}){const n=await ri(Vq(`/web/${e}/sessions`,t),{method:"GET",headers:sr(),signal:t.signal},Qq);if(!n.ok)throw await ar(n,`无法读取 ${e} 智能体,请稍后重试。`);const i=await n.json();if(!Array.isArray(i.sessions))throw new Error(`AgentKit 返回了无效的 ${e} Session 列表。`);if(i.snapshots!==void 0&&!Array.isArray(i.snapshots))throw new Error(`AgentKit 返回了无效的 ${e} Snapshot 列表。`);return[...i.sessions.map(r=>gh(r,e)),...(i.snapshots??[]).map(r=>Fq(r,e))]},async startAgentSession(e,t={}){var i;const n=await ri(`/web/${e}/sessions`,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({displayName:((i=t.displayName)==null?void 0:i.trim())??"",persistent:t.persistent??!0}),signal:t.signal},Kj);if(!n.ok)throw await ar(n,`无法创建 ${e} 智能体,请稍后重试。`);return gh(await n.json(),e)},async openAgentSession(e,t,n={}){if(!t)throw new Error("缺少要打开的 AgentKit Session。");const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}/open`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,`无法打开 ${e} 智能体。`);const r=await i.json();if(typeof r.webuiUrl!="string"||!r.webuiUrl.startsWith("/"))throw new Error(`${e} 智能体返回了无效的主页面地址。`);return{session:gh(r,e),kind:e,webuiUrl:vo(r.webuiUrl)}},async launchAgentTerminal(e,t,n={}){if(!t)throw new Error("缺少要打开 Terminal 的 AgentKit Session。");const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}/terminal`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,`无法打开 ${e} Terminal。`);const r=await i.json();return{url:Vhe(r.url,`${e} Terminal`),...typeof r.shellSessionId=="string"?{shellSessionId:r.shellSessionId}:{}}},async deleteAgentSession(e,t,n={}){if(!t)return;const i=await ri(`/web/${e}/sessions/${encodeURIComponent(t)}`,{method:"DELETE",headers:sr(),signal:n.signal},hO);if(!i.ok&&i.status!==404)throw await ar(i,`无法删除 ${e} 智能体。`)},async resumeSnapshot(e,t,n={}){if(!t)throw new Error("缺少要唤醒的 AgentKit Snapshot。");const i=e==="codex"?"/web/sandbox":`/web/${e}`,r=await ri(`${i}/snapshots/${encodeURIComponent(t)}/resume`,{method:"POST",headers:sr(),signal:n.signal},Kj);if(!r.ok)throw await ar(r,"无法从快照唤醒智能体,请稍后重试。");return gh(await r.json(),e)},async deleteSnapshot(e,t,n={}){if(!t)return;const i=e==="codex"?"/web/sandbox":`/web/${e}`,r=await ri(`${i}/snapshots/${encodeURIComponent(t)}`,{method:"DELETE",headers:sr(),signal:n.signal},hO);if(!r.ok&&r.status!==404)throw await ar(r,"无法删除智能体快照。")},async connectSession(e,t={}){if(!e)throw new Error("缺少要连接的 AgentKit Session。");const n=await ri(`${ca}/${encodeURIComponent(e)}/connect`,{method:"POST",headers:sr({"Content-Type":"application/json"}),signal:t.signal},uct);if(!n.ok)throw await ar(n,"无法连接 Codex 智能体,请稍后重试。");const i=gh(await n.json());if(i.status.toLowerCase()!=="ready")throw new Error(`AgentKit Session 尚未就绪,当前状态:${i.status}。`);return i},async sendMessage(e,t={}){var i;if(!e.sessionId||!e.text.trim())throw new Error("内置智能体会话缺少有效的消息内容。");const n=await ri(`${ca}/${encodeURIComponent(e.sessionId)}/messages`,{method:"POST",headers:sr({Accept:"text/event-stream","Content-Type":"application/json"}),body:JSON.stringify({message:e.text,...(i=e.skillIds)!=null&&i.length?{skillIds:e.skillIds}:{}}),signal:t.signal},dct);if(!n.ok)throw await ar(n,"沙箱对话失败,请稍后重试。");return Oct(n,t)},async getStatus(e,t={}){const n=await eo(e,"status",{options:t,fallback:"无法读取 Codex 状态。"}),i=Xq(n),r=Xs(n),s=BL(r==null?void 0:r.threadTotal),a=r==null?void 0:r.modelContextWindow;return{...i,...s?{threadTotal:s}:{},...typeof a=="number"&&Number.isFinite(a)&&a>=0?{modelContextWindow:Math.trunc(a)}:{}}},async getEndpoint(e,t={}){const n=Xs(await eo(e,"endpoint",{options:t,fallback:"无法读取 Sandbox Endpoint。"}));if(typeof(n==null?void 0:n.endpoint)!="string"||!n.endpoint.trim())throw new Error("Sandbox 返回了无效 Endpoint。");return{endpoint:n.endpoint,sessionId:typeof n.sessionId=="string"?n.sessionId:e,...typeof n.expireAt=="string"?{expireAt:n.expireAt}:{}}},async createCodexProjectHandoffPairing(e={}){const t=await ri(`${$q}/pairings`,{method:"POST",headers:sr({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify({ttlSeconds:hct}),signal:e.signal},Bq);if(!t.ok)throw await ar(t,"无法生成 Codex 云端接力配对码。");const n=Xs(await zq(t,"无法生成 Codex 云端接力配对码。"));if(typeof(n==null?void 0:n.pairingCode)!="string"||!n.pairingCode.trim()||typeof n.expireAt!="string"||!n.expireAt.trim())throw new Error("Studio 返回了无效的 Codex 云端接力配对码。");const i=typeof n.studioUrl=="string"&&n.studioUrl.trim()?n.studioUrl.trim():window.location.origin;return{pairingCode:n.pairingCode,expireAt:n.expireAt,studioUrl:i}},async getCodexProjectHandoffStatus(e,t={}){const n=await ri(`${$q}/pairings/${encodeURIComponent(e)}`,{headers:sr({Accept:"application/json"}),signal:t.signal},Bq);if(!n.ok)throw await ar(n,"无法读取端云接力状态。");const i=Xs(await zq(n,"无法读取端云接力状态。")),r=new Set(["issued","creating","session-created","continuing","running","completed","failed"]);if(typeof(i==null?void 0:i.state)!="string"||!r.has(i.state)||typeof i.expireAt!="string"||!i.expireAt.trim())throw new Error("Studio 返回了无效的端云接力状态。");return{state:i.state,expireAt:i.expireAt,...typeof i.projectName=="string"?{projectName:i.projectName}:{},...typeof i.agentName=="string"?{agentName:i.agentName}:{},...typeof i.sessionId=="string"?{sessionId:i.sessionId}:{},...typeof i.error=="string"?{error:i.error}:{},...i.failedStage==="creating-session"||i.failedStage==="uploading-project"||i.failedStage==="restoring-project"||i.failedStage==="continuing-task"?{failedStage:i.failedStage}:{}}},async listModels(e,t={}){const n=Xs(await eo(e,"models",{options:t,fallback:"无法读取 Codex 模型列表。"}));if(!Array.isArray(n==null?void 0:n.models))throw new Error("Sandbox 返回了无效模型列表。");return n.models.flatMap(i=>{const r=pct(i);return r?[r]:[]})},async setModel(e,t,n={}){const i=Xs(await eo(e,"model",{method:"PUT",body:{model:t},options:n,fallback:"无法切换 Codex 模型。"}));if(typeof(i==null?void 0:i.model)!="string"||!i.model)throw new Error("Sandbox 返回了无效模型。");return i.model},async listSkills(e,t=!1,n={}){const r=Xs(await eo(e,`skills${t?"?force_reload=true":""}`,{options:n,fallback:"无法读取 Codex Skills。"}));if(!Array.isArray(r==null?void 0:r.skills))throw new Error("Sandbox 返回了无效 Skill 列表。");return r.skills.flatMap(s=>{const a=mct(s);return a?[a]:[]})},async listThreads(e,t={},n={}){const i=new URLSearchParams;t.cursor&&i.set("cursor",t.cursor),t.search&&i.set("search",t.search),t.archived&&i.set("archived","true");const r=i.size?`?${i}`:"",s=Xs(await eo(e,`threads${r}`,{options:n,fallback:"无法读取 Codex Thread 列表。"}));if(!Array.isArray(s==null?void 0:s.threads))throw new Error("Sandbox 返回了无效 Thread 列表。");return{threads:s.threads.flatMap(a=>{const o=Fhe(a);return o?[o]:[]}),...typeof s.nextCursor=="string"?{nextCursor:s.nextCursor}:{}}},async newThread(e,t={}){return hm(await eo(e,"threads/new",{method:"POST",options:t,fallback:"无法创建新的 Codex Thread。"}))},async readThread(e,t,n={}){if(!t)throw new Error("缺少要读取的 Codex Thread。");return hm(await eo(e,`threads/${encodeURIComponent(t)}`,{options:n,fallback:"无法读取 Codex 历史消息。"}))},async resumeThread(e,t,n={}){return hm(await eo(e,"threads/resume",{method:"POST",body:{threadId:t},options:n,fallback:"无法恢复 Codex Thread。"}))},async forkThread(e,t={}){return hm(await eo(e,"threads/fork",{method:"POST",options:t,fallback:"无法分叉 Codex Thread。"}))},async archiveThread(e,t,n={}){const i=Xs(await eo(e,"threads/archive",{method:"POST",body:{threadId:t},options:n,fallback:"无法归档 Codex Thread。"}));if((i==null?void 0:i.archived)!==!0)throw new Error("Sandbox 返回了无效归档结果。");return{archived:!0,...i.thread?{snapshot:hm(i)}:{}}},async deleteThread(e,t,n={}){const i=Xs(await eo(e,"threads/delete",{method:"POST",body:{threadId:t},options:n,fallback:"无法删除 Codex Thread。"}));if((i==null?void 0:i.deleted)!==!0)throw new Error("Sandbox 返回了无效删除结果。");return{deleted:!0,...i.thread?{snapshot:hm(i)}:{}}},async compactThread(e,t={}){await eo(e,"threads/compact",{method:"POST",options:t,fallback:"无法压缩 Codex Thread。"})},async getSettings(e,t={}){const n=await ri(`${ca}/${encodeURIComponent(e)}/settings`,{method:"GET",headers:sr(),signal:t.signal},ku);if(!n.ok)throw await ar(n,"无法读取 Codex 权限与工作空间。");return Xq(await n.json())},async updatePermissions(e,t,n={}){const i=await ri(`${ca}/${encodeURIComponent(e)}/permissions`,{method:"PUT",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify(t),signal:n.signal},ku);if(!i.ok)throw await ar(i,"无法更新 Codex 权限。");const r=await i.json();return GA(r.permissions)},async updateWorkspace(e,t,n={}){const i=await ri(`${ca}/${encodeURIComponent(e)}/workspace`,{method:"PUT",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({cwd:t}),signal:n.signal},ku);if(!i.ok)throw await ar(i,"无法更新 Codex 工作空间。");const r=await i.json();if(typeof r.cwd!="string"||!r.cwd)throw new Error("Sandbox 返回了无效工作目录。");return r.cwd},async listDirectories(e,t,n={}){const i=new URLSearchParams({path:t}),r=await ri(`${ca}/${encodeURIComponent(e)}/directories?${i}`,{method:"GET",headers:sr(),signal:n.signal},ku);if(!r.ok)throw await ar(r,"无法读取 Sandbox 目录。");const s=await r.json();if(typeof s.path!="string"||!Array.isArray(s.directories)||s.directories.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error("Sandbox 返回了无效目录列表。");return{path:s.path,...typeof s.parent=="string"?{parent:s.parent}:{},directories:s.directories}},async resolveApproval(e,t,n,i={}){const r=await ri(`${ca}/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",headers:sr({"Content-Type":"application/json"}),body:JSON.stringify({decision:n}),signal:i.signal},ku);if(!r.ok)throw await ar(r,"无法提交 Codex 审批决定。")},async launchTerminal(e,t={}){return qq(e,"terminal",t)},async launchBrowser(e,t={}){return qq(e,"browser",t)},async uploadFile(e,t,n={}){const i=new FormData;i.set("file",t,t.name);const r=await ri(`${ca}/${encodeURIComponent(e)}/files`,{method:"POST",headers:sr(),body:i,signal:n.signal},fct);if(!r.ok)throw await ar(r,"无法上传文件到 Sandbox。");const s=await r.json();if(typeof s.id!="string"||typeof s.path!="string"||typeof s.name!="string"||typeof s.mimeType!="string"||typeof s.sizeBytes!="number")throw new Error("Sandbox 返回了无效上传结果。");return s},async closeSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}/disconnect`,{method:"POST",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法断开 Codex 智能体连接。")},async interruptSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}/interrupt`,{method:"POST",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法停止 Codex 任务。")},async deleteSession(e,t={}){if(!e)return;const n=await ri(`${ca}/${encodeURIComponent(e)}`,{method:"DELETE",headers:sr(),signal:t.signal},hO);if(!n.ok&&n.status!==404)throw await ar(n,"无法删除 Codex 智能体。")}};async function qq(e,t,n){const i=await ri(`${ca}/${encodeURIComponent(e)}/${t}`,{method:"POST",headers:sr(),signal:n.signal},ku);if(!i.ok)throw await ar(i,t==="terminal"?"无法打开 Sandbox Terminal。":"无法打开 Sandbox Browser。");const r=await i.json();return{url:Vhe(r.url,"Sandbox 工具"),...typeof r.shellSessionId=="string"?{shellSessionId:r.shellSessionId}:{}}}function Vhe(e,t){if(typeof e!="string")throw new Error(`${t} 返回了无效地址。`);if(e.startsWith("/"))return vo(e);let n;try{n=new URL(e)}catch{throw new Error(`${t} 返回了无效地址。`)}const i=n.protocol==="http:"&&window.location.protocol==="http:";if(n.protocol!=="https:"&&!i)throw new Error(`${t} 返回了不安全的地址。`);return n.toString()}function cg(e,t,n){const i=e instanceof Error?`${e.name}: ${e.message}`:String(e||"未知错误");return[`${t}失败`,`详细信息:${i}`,n?`请求:${n}`:""].filter(Boolean).join(` +`)}function yct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M8.4 18.4H7.2a4.2 4.2 0 0 1-.65-8.35A5.7 5.7 0 0 1 17.3 8.2a4.6 4.6 0 0 1-.4 9.2h-3.2"}),l.jsx("path",{d:"m7.8 12.3 2 2-2 2M12.2 16.3h3.2"})]})}function xct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M18.9 6.25A8.4 8.4 0 1 0 19.6 16"}),l.jsx("path",{d:"M19 6.2c.1 2.1-.65 3.75-2.25 4.95-1.2.9-2.75 1.25-4.2.9"}),l.jsx("circle",{cx:"10.6",cy:"12.8",r:"2.45"}),l.jsx("path",{d:"m5.25 18.6 3.65-3.9M14.8 17.9c1.9-.45 3.55-1.65 4.65-3.35"})]})}function vct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6.2 20c.55-2.15.75-4.1.75-6.7V9.8A5.35 5.35 0 0 1 12.35 4c3.35 0 5.65 2.35 5.65 5.65v4.6c0 2.35.35 4.25 1.15 5.75"}),l.jsx("path",{d:"M8.05 10.2c1.35-.6 2.2-1.65 2.55-3.15.45 1.55 1.35 2.55 2.7 3.05.1-1 .4-1.95.85-2.75.45 1.25 1.2 2.2 2.15 2.75"}),l.jsx("path",{d:"M9.3 12.65h.01M14.9 12.65h.01M10.8 15.55c.8.5 1.65.5 2.45 0"}),l.jsx("path",{d:"M8.45 19.85c.95-.85 1.45-1.95 1.5-3.25M15.1 16.65c.05 1.2.55 2.3 1.55 3.2"})]})}function wct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M5.2 17.2V8.1a3 3 0 0 1 3-3h7.6a3 3 0 0 1 3 3v9.1"}),l.jsx("path",{d:"M7.4 17.2h9.2M9 19.9h6"}),l.jsx("path",{d:"M9.1 9.25h5.8M9.1 12h3.1"}),l.jsx("path",{d:"m14.1 12.4 2 2.1M16.2 12.4l-2.1 2.1"})]})}function t1({kind:e,...t}){return e==="codex"?l.jsx(yct,{...t}):e==="deepseek-harness"?l.jsx(wct,{...t}):e==="openclaw"?l.jsx(xct,{...t}):l.jsx(vct,{...t})}const Jj=[{id:"general",label:"通用智能体"},{id:"codex",label:"Codex 智能体"},{id:"deepseek-harness",label:"DeepSeek Harness"},{id:"openclaw",label:"OpenClaw 智能体"},{id:"hermes",label:"Hermes 智能体"}],Sct=24,Ect=3e4,ug=new Map,Dg=new Map,kct=new Set;function hS(e){if(!e){ug.clear(),Dg.clear();return}const t=new Set(e);if(t.size!==0){for(const[n,i]of Dg)i.page.runtimes.some(r=>t.has(r.runtimeId))&&Dg.delete(n);ug.clear()}}function Tct(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function eR(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function _ct(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M2.75 5.25h8.75m0 0-2-2m2 2-2 2M13.25 10.75H4.5m0 0 2 2m-2-2 2-2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Act({type:e}){return e==="general"?l.jsx(Pf,{}):l.jsx(t1,{kind:e})}function oQ(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(t).replace(/\//g,"-")}function Nct(e,t=Date.now()){const n=Date.parse(e);if(!Number.isFinite(n)||n-t<6e4)return"即将清空";const i=Math.ceil((n-t)/6e4),r=Math.floor(i/60),s=i%60;return`${r} 小时 ${s} 分钟`}function Hq(e){var t;return{id:e.runtimeId,name:e.name,description:((t=e.description)==null?void 0:t.trim())||"暂无描述",createdAt:oQ(e.createdAt??""),specificationLabel:"创建人",specification:e.author||"—",isMine:e.isMine,runtime:{runtimeId:e.runtimeId,region:e.region,currentVersion:e.currentVersion,canDelete:e.canDelete}}}function Cct(e){return{id:e.id,name:e.displayName||`${e.toolName} 智能体`,description:YA(e.status),createdAt:oQ(e.createdAt),specificationLabel:"创建人",specification:e.createdBy||"—",sandbox:e}}function jct(e){var t;return{id:e.id,name:e.draft.name||"未命名 Agent",description:((t=e.draft.description)==null?void 0:t.trim())||"暂无描述",createdAt:oQ(new Date(e.updatedAt).toISOString()),specificationLabel:"存储位置",specification:"当前浏览器",draft:e}}async function Rct(e,t,n){const i=`${e}:all:${t}`,r=Dg.get(i);if(r&&r.expiresAt>Date.now())return n(r.page.runtimes.map(Hq)),r.page.nextToken;r&&Dg.delete(i);let s=ug.get(i);s||(s=S_({scope:e,region:"all",pageSize:Sct,nextToken:t}),ug.set(i,s),s.then(()=>ug.delete(i),()=>ug.delete(i)));const a=await s;return Dg.set(i,{page:a,expiresAt:Date.now()+Ect}),n(a.runtimes.map(Hq)),a.nextToken}function Ict({agent:e,cloudProvider:t,onUse:n,onViewDetails:i,connecting:r,connected:s,showOwnership:a,deploymentTask:o,nowMs:c,onViewDeploymentTask:u,onEditDraft:d,onDeleteDraft:f}){var y,O,v,x;const h=(y=e.sandbox)==null?void 0:y.status.toLowerCase(),p=((O=e.sandbox)==null?void 0:O.resourceType)==="snapshot",g=!!(e.runtime||h==="ready"||h==="wakeable"),b=((v=e.sandbox)==null?void 0:v.resourceType)==="snapshot"?e.sandbox.sourceSessionId||e.sandbox.snapshotId:(x=e.sandbox)==null?void 0:x.id;return l.jsxs("article",{className:"my-agent-card",children:[l.jsxs("div",{className:"my-agent-card-content",children:[l.jsxs("div",{className:"my-agent-card-title",children:[l.jsxs("div",{className:"my-agent-card-title-copy",children:[l.jsx("h3",{children:e.name}),e.sandbox?l.jsx("span",{className:"my-agent-session-id",title:b,children:b}):null]}),e.draft?l.jsx("span",{className:"my-agent-draft-badge",children:o?"部署中":"草稿"}):e.sandbox?l.jsx("span",{className:"my-agent-status-label","data-ready":e.sandbox.status.toLowerCase()==="ready"||void 0,"data-wakeable":p||void 0,children:e.description}):e.runtime?l.jsxs("div",{className:"my-agent-card-badges",children:[o?l.jsx("span",{className:"my-agent-deploying-badge",children:"部署中"}):null,l.jsx("span",{className:"my-agent-region-badge",children:td(e.runtime.region,t)}),a&&e.isMine?l.jsx("span",{className:"runtime-owner-badge",children:"我创建的"}):null]}):null]}),e.sandbox?null:l.jsx("p",{className:"my-agent-description",children:e.description}),l.jsxs("dl",{className:"my-agent-meta",children:[l.jsxs("div",{className:"my-agent-created-at",children:[l.jsx("dt",{children:e.draft?"更新时间":"创建时间"}),l.jsx("dd",{children:e.createdAt})]}),l.jsxs("div",{className:"my-agent-region",children:[l.jsx("dt",{children:e.specificationLabel}),l.jsx("dd",{children:e.specification})]}),e.sandbox?l.jsxs("div",{className:`my-agent-expiry${e.sandbox.resourceType==="session"&&e.sandbox.persistent?"":" is-expiring"}`,children:[l.jsx("dt",{children:"剩余时间"}),l.jsx("dd",{children:e.sandbox.resourceType==="snapshot"?"可唤醒":e.sandbox.persistent?"永不过期":Nct(e.sandbox.expireAt,c)})]}):null]})]}),l.jsx("footer",{className:"my-agent-actions",children:e.draft?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"my-agent-details","aria-label":o?`查看 ${e.name} 部署进度`:`编辑草稿 ${e.name}`,onClick:()=>o?u==null?void 0:u(o):d==null?void 0:d(e.draft),children:o?"查看进度":"编辑"}),l.jsx("button",{type:"button",className:"my-agent-delete","aria-label":`删除草稿 ${e.name}`,onClick:()=>f==null?void 0:f(e.draft),children:"删除"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"my-agent-details",disabled:!g,"aria-label":o?`查看 ${e.name} 部署进度`:`查看 ${e.name} 详情`,onClick:()=>o?u==null?void 0:u(o):i==null?void 0:i(e),children:o?"查看进度":"查看详情"}),l.jsx("button",{type:"button",className:`my-agent-use${s?" is-connected":""}`,disabled:!g||r||s,"aria-busy":r||void 0,"aria-label":s?`${e.name} 已连接`:p?`唤醒 ${e.name}`:`使用 ${e.name}`,onClick:()=>void(n==null?void 0:n(e)),children:r?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-use-spinner","aria-hidden":"true"}),l.jsx("span",{children:p?"唤醒中":"连接中"})]}):s?"已连接":p?"唤醒":"使用"})]})})]})}function Pct({cloudProvider:e,canCreate:t,runtimeScope:n,onCreateAgent:i,onOpenCodexProjectUpload:r,onUseAgent:s,onViewAgentDetails:a,onCreateSandboxAgent:o,onUseSandboxAgent:c,onViewSandboxAgentDetails:u,sandboxRefreshKey:d=0,connectedRuntimeId:f="",hiddenRuntimeIds:h=kct,drafts:p=[],deploymentTasks:g=[],draftDeploymentTaskIds:b={},onViewDeploymentTask:y,onEditDraft:O,onDeleteDraft:v}){const x=m.useRef(null),w=m.useRef(null),E=m.useRef(0),S=m.useRef(0),k=m.useRef(null),[T,A]=m.useState("general"),[N,C]=m.useState(""),[M,L]=m.useState([]),[P,Q]=m.useState(""),[j,$]=m.useState(!0),[U,B]=m.useState(""),[I,X]=m.useState([]),[q,D]=m.useState(!1),[H,re]=m.useState(""),[fe,Ae]=m.useState(""),[J,ie]=m.useState(null),[ue,ye]=m.useState(()=>Date.now()),Se=I.some(ae=>{var pe;return((pe=ae.sandbox)==null?void 0:pe.resourceType)==="session"&&ae.sandbox.persistent===!1});m.useEffect(()=>{if(!Se)return;ye(Date.now());const ae=window.setInterval(()=>ye(Date.now()),6e4);return()=>window.clearInterval(ae)},[Se]);const Re=m.useMemo(()=>p.map(jct),[p]),Ee=m.useMemo(()=>{const ae=new Map,pe=new Map;for(const z of g){if(z.status!=="running"||(ae.set(z.id,z),!z.runtimeId))continue;const ve=pe.get(z.runtimeId);(!ve||z.startedAt>ve.startedAt)&&pe.set(z.runtimeId,z)}return{byId:ae,byRuntimeId:pe}},[g]),me=m.useCallback(ae=>{var z;if(ae.draft){const ve=b[ae.draft.id];return ve?Ee.byId.get(ve):void 0}const pe=(z=ae.runtime)==null?void 0:z.runtimeId;return pe?Ee.byRuntimeId.get(pe):void 0},[Ee,b]),oe=m.useCallback((ae,pe)=>{const z=++E.current;return $(!0),B(""),Rct(n,ae,ve=>{E.current===z&&L(Be=>pe?ve:[...Be,...ve])}).then(ve=>{E.current===z&&Q(ve)}).catch(ve=>{E.current===z&&B(cg(ve,"加载通用智能体","GET /web/runtimes"))}).finally(()=>{E.current===z&&$(!1)})},[n]);m.useEffect(()=>{if(T==="general")return L([]),Q(""),oe("",!0),()=>{E.current+=1}},[T,oe]);const Ne=m.useCallback(async ae=>{var ve,Be;(ve=k.current)==null||ve.abort();const pe=new AbortController;k.current=pe;const z=++S.current;D(!0),re(""),X([]);try{const Je=ae==="codex"?await Kt.listSessions({signal:pe.signal,autoResumeSnapshots:!0}):await Kt.listAgentSessions(ae,{signal:pe.signal,autoResumeSnapshots:!0});if(S.current!==z)return;X(Je.map(Cct))}catch(Je){if((Je==null?void 0:Je.name)==="AbortError"||S.current!==z)return;re(cg(Je,`加载 ${((Be=Jj.find(kt=>kt.id===ae))==null?void 0:Be.label)??ae}`,`GET /web/${ae==="codex"?"sandbox":ae}/sessions`))}finally{k.current===pe&&(k.current=null),S.current===z&&D(!1)}},[]);function Oe(ae){var pe;ae!==T&&(ae==="general"?(E.current+=1,L([]),Q(""),B(""),$(!0)):((pe=k.current)==null||pe.abort(),k.current=null,S.current+=1,X([]),re(""),D(!0)),A(ae))}m.useEffect(()=>{var ae;if(T==="general"){(ae=k.current)==null||ae.abort(),k.current=null,S.current+=1;return}return Ne(T),()=>{var pe;(pe=k.current)==null||pe.abort(),k.current=null,S.current+=1}},[T,Ne,d]),m.useEffect(()=>{const ae=w.current,pe=x.current;if(!ae||!pe||T!=="general"||!P||j)return;const z=new IntersectionObserver(([ve])=>{ve.isIntersecting&&oe(P,!1)},{root:pe,rootMargin:"240px 0px",threshold:.01});return z.observe(ae),()=>z.disconnect()},[T,oe,j,P]);const Ve=m.useCallback(async ae=>{if(!fe){Ae(ae.id);try{await new Promise(pe=>requestAnimationFrame(()=>pe())),ae.sandbox?await c(ae.sandbox):await s(ae)}finally{Ae("")}}},[fe,s,c]),We=m.useMemo(()=>{const ae=N.trim().toLocaleLowerCase(),pe=T==="general"?[...Re,...M]:I,z=ae?pe.filter(Je=>Je.name.toLocaleLowerCase().includes(ae)):pe;if(T!=="general")return z;const ve=h.size>0?z.filter(Je=>!Je.runtime||!h.has(Je.runtime.runtimeId)):z,Be=ve.findIndex(Je=>{var kt;return((kt=Je.runtime)==null?void 0:kt.runtimeId)===f});return Be<=0?ve:[ve[Be],...ve.slice(0,Be),...ve.slice(Be+1)]},[T,f,Re,h,N,M,I]),De=Jj.find(ae=>ae.id===T),mt=(De==null?void 0:De.label)??"智能体",at=T==="general"?j&&M.length===0&&Re.length===0:q&&I.length===0,Rt=!at&&We.length===0,qe=t?T==="general"?()=>i(Qi(e)):()=>o(T):void 0,W=T==="codex"&&t&&!!r,K=t?void 0:"当前账号没有创建智能体权限";return l.jsxs("div",{className:"my-agents-page",children:[l.jsxs("header",{className:"my-agents-header",children:[l.jsxs("div",{className:"my-agents-heading",children:[l.jsx("div",{className:"my-agents-title-row",children:l.jsx("h1",{children:"智能体"})}),l.jsx("p",{children:n==="all"?"在此处浏览所有智能体":"在此处浏览您的所有智能体"})]}),l.jsxs("label",{className:"my-agent-search",children:[l.jsx(Tct,{}),l.jsx("input",{type:"search","aria-label":"搜索智能体",value:N,onChange:ae=>C(ae.target.value),placeholder:"搜索所有类型智能体名称"})]})]}),l.jsxs("div",{className:"my-agent-type-bar",children:[l.jsx("nav",{className:"my-agent-type-pills","aria-label":"智能体类型",children:Jj.map(ae=>l.jsx("button",{type:"button",className:`my-agent-type-pill${T===ae.id?" is-active":""}`,"aria-pressed":T===ae.id,onClick:()=>Oe(ae.id),children:ae.label},ae.id))}),l.jsxs("div",{className:"my-agent-type-actions",children:[W?l.jsxs("button",{type:"button",className:"my-agent-create-secondary",onClick:r,children:[l.jsx(_ct,{}),l.jsx("span",{children:"接力"})]}):null,l.jsxs("button",{type:"button",className:"my-agent-create-primary",disabled:!qe,title:K,onClick:()=>qe==null?void 0:qe(),children:[l.jsx(eR,{}),l.jsx("span",{children:"创建智能体"})]})]})]}),l.jsxs("section",{className:"my-agent-results",ref:x,"aria-label":`${mt}列表`,children:[at?l.jsxs("div",{className:"my-agent-initial-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载智能体"})]}):(T==="general"?U:H)&&We.length===0?l.jsxs("div",{className:"my-agent-empty",role:"alert",children:[l.jsx("p",{children:T==="general"?U:H}),l.jsx("button",{type:"button",onClick:()=>{T==="general"?oe("",!0):Ne(T)},children:"重新加载"})]}):Rt?N.trim()?l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(Rwe,{})}),l.jsx(Oi.Title,{children:"没有匹配的智能体"}),l.jsx(Oi.Description,{children:"请尝试搜索其他名称"})]})}):T!=="general"?l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(Act,{type:T})}),l.jsxs(Oi.Title,{className:"my-agent-sandbox-empty-title",children:["暂无 ",mt]}),t?l.jsx(Oi.ActionRow,{children:l.jsxs(zu,{color:"primary",size:"lg",onClick:()=>o(T),children:[l.jsx(eR,{}),"创建智能体"]})}):null]})}):l.jsx("div",{className:"my-agent-empty-message",children:l.jsxs(Oi,{fill:"none",children:[l.jsx(Oi.Icon,{children:l.jsx(Pf,{})}),l.jsx(Oi.Title,{children:"暂无通用智能体"}),l.jsx(Oi.Description,{children:"创建一个通用智能体,开始构建和对话"}),t?l.jsx(Oi.ActionRow,{children:l.jsxs(zu,{color:"primary",size:"lg",onClick:()=>i(Qi(e)),children:[l.jsx(eR,{}),"创建智能体"]})}):null]})}):l.jsxs(l.Fragment,{children:[T==="general"&&U?l.jsxs("div",{className:"my-agent-inline-error",role:"alert",children:[l.jsx("span",{children:U}),l.jsx("button",{type:"button",onClick:()=>void oe("",!0),children:"重新加载"})]}):null,l.jsx("div",{className:"my-agent-grid",children:We.map(ae=>{var pe;return l.jsx(Ict,{agent:ae,cloudProvider:e,deploymentTask:me(ae),nowMs:ue,onViewDeploymentTask:y,onUse:Ve,onViewDetails:z=>{z.sandbox?u(z.sandbox):a(z)},connecting:ae.id===fe,connected:((pe=ae.runtime)==null?void 0:pe.runtimeId)===f,showOwnership:n==="all",onEditDraft:O,onDeleteDraft:ie},ae.id)})})]}),T==="general"&&!U&&!at&&(We.length>0||!!P)&&l.jsx("div",{className:"my-agent-load-more",ref:w,"aria-live":"polite",children:j?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),l.jsx("span",{children:"正在加载更多智能体"})]}):P?l.jsx("span",{children:"继续下滑加载更多"}):l.jsx("span",{children:"已加载全部智能体"})})]}),J?l.jsx(Mf,{title:"删除草稿?",description:`删除后将无法恢复“${J.draft.name||"未命名 Agent"}”。`,confirmLabel:"删除草稿",variant:"danger",onCancel:()=>ie(null),onConfirm:()=>{v==null||v(J),ie(null)}}):null]})}function Mct(e){return e==="127.0.0.1"}const Lct={id:"coding-agents",kind:"coding-agent",category:"development",icon:"coding-agents",name:"配置 Coding Agents",badge:"本地",badgeTone:"success",description:"将 VeADK 和 AgentKit 内置 Skills 全局配置到 Trae、Claude Code 或 Codex。"},Dct={id:"feishu",kind:"feishu",category:"channels",icon:"feishu",name:"飞书机器人",badge:"Beta",description:"创建飞书机器人,并将消息直接接入 AgentKit Runtime。"},$ct="https://api.github.com",Qct=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,Yq=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/,Bct=/^[A-Za-z0-9._/-]+$/;function Uct(e,t,n){return e===401||e===403?"GitHub Token 无效或没有仓库写入权限":e===404?"仓库、分支或文件不存在,或 Token 无权访问":e===422?"GitHub 拒绝了提交,请检查分支和文件状态":String((t==null?void 0:t.message)||"").split(n).join("***").trim().slice(0,240)||`GitHub 请求失败(HTTP ${e})`}async function bh(e,t){const n={Accept:"application/vnd.github+json",Authorization:`Bearer ${t.token}`,"X-GitHub-Api-Version":"2022-11-28"};t.body&&(n["Content-Type"]="application/json");let i;try{i=await fetch(`${$ct}${e}`,{method:t.method||"GET",headers:n,body:t.body?JSON.stringify(t.body):void 0,signal:t.signal})}catch(s){throw t.signal.aborted?s:new Error("连接 GitHub 失败,请检查网络后重试")}const r=await i.json().catch(()=>null);if(!t.expected.includes(i.status))throw new Error(Uct(i.status,r,t.token));return{status:i.status,payload:r}}function tR(e){return e.split("/").map(encodeURIComponent).join("/")}function zct(e){const t=new TextEncoder().encode(e);let n="";const i=32768;for(let r=0;r({...h,path:lQ(h.path,"")})),s=AbortSignal.any([t,AbortSignal.timeout(6e4)]),a=`/repos/${n}`;await bh(`${a}`,{token:e.token,expected:[200],signal:s});const c=(f=(await bh(`${a}/git/ref/heads/${tR(i)}`,{token:e.token,expected:[200],signal:s})).payload.object)==null?void 0:f.sha;if(!c)throw new Error("目标分支缺少有效 Git SHA");const u=Fct(e.branchPrefix);await bh(`${a}/git/refs`,{token:e.token,expected:[201],signal:s,method:"POST",body:{ref:`refs/heads/${u}`,sha:c}});let d=!0;try{for(const p of r){const g=tR(p.path),b=await bh(`${a}/contents/${g}?ref=${encodeURIComponent(i)}`,{token:e.token,expected:[200,404],signal:s});if(p.mustBeNew&&b.status===200)throw new Error(`目标仓库中已存在 ${p.path},未覆盖现有文件`);if(b.status===200&&!b.payload.sha)throw new Error(`目标路径 ${p.path} 不是可更新的文件`);await bh(`${a}/contents/${g}`,{token:e.token,expected:[200,201],signal:s,method:"PUT",body:{message:p.commitMessage,content:zct(p.content),branch:u,...b.payload.sha?{sha:b.payload.sha}:{}}})}const h=await bh(`${a}/pulls`,{token:e.token,expected:[201],signal:s,method:"POST",body:{title:e.title,head:u,base:i,body:e.description}});if(!h.payload.number||!h.payload.html_url)throw new Error("GitHub 未返回有效的 Pull Request");return d=!1,{number:h.payload.number,url:h.payload.html_url,branch:u}}finally{d&&await bh(`${a}/git/refs/heads/${tR(u)}`,{token:e.token,expected:[204],signal:AbortSignal.timeout(15e3),method:"DELETE"}).catch(()=>{})}}const uQ={name:"repository",label:"GitHub Repo",placeholder:"owner/repository",help:"支持 owner/repository 或完整 github.com URL",required:!0},dQ={name:"baseBranch",label:"目标分支",placeholder:"main",help:"留空时使用 main,PR 将以此分支为 base",required:!1},qhe={name:"runtimeName",label:"Runtime 名称",placeholder:"support-agent",help:"用于 AgentKit 发布配置",required:!0},Hhe={name:"runtimeId",label:"Runtime ID",placeholder:"rt-xxxxxxxx",help:"持续更新的目标 AgentKit Runtime",required:!0};function fQ(e={}){return{repository:"",baseBranch:"main",projectPath:".",runtimeName:"",runtimeId:"",sandboxToolId:"",modelName:"",modelBaseUrl:"https://ark.cn-beijing.volces.com/api/coding/v3",region:"cn-beijing",token:"",...e}}function hQ(e){return{repository:e.repository.trim(),baseBranch:e.baseBranch.trim()||"main",region:e.region,token:e.token.trim()}}const Vct=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,Xct=/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;function qct(e){if(!Vct.test(e.sandboxToolId))throw new Error("Sandbox Tool ID 格式不正确");if(!Xct.test(e.modelName))throw new Error("模型名称格式不正确");let t;try{t=new URL(e.modelBaseUrl)}catch{throw new Error("模型 API 地址必须是安全的 HTTPS URL")}if(t.protocol!=="https:"||!t.hostname||t.username||t.password||t.search||t.hash)throw new Error("模型 API 地址必须是安全的 HTTPS URL")}function Hct(e){qct(e);const t=String.raw`name: PR Automated Review "on": pull_request: @@ -866,7 +866,7 @@ jobs: gh pr review "__GH__ github.event.pull_request.number }}" \ --comment \ --body-file review-body.md -`,n={__GH__:"${{",__REGION__:JSON.stringify(e.region),__SANDBOX_TOOL_ID__:JSON.stringify(e.sandboxToolId),__MODEL_NAME__:JSON.stringify(e.modelName),__MODEL_BASE_URL__:JSON.stringify(e.modelBaseUrl)};return Object.entries(n).reduce((i,[r,s])=>i.split(r).join(s),t)}const Hct={id:"review",kind:"github",category:"development",icon:"github",name:"PR 自动评审",description:"在隔离 Sandbox 中评审代码变更,并将结果发布到 Pull Request。",title:"PR 自动评审",subtitle:"在隔离 Sandbox 中检查代码变更并把结果发布到 Pull Request",panel:"工作流仅评审同仓库的非草稿 PR;fork PR 不会读取仓库 Secrets。",submitLabel:"添加评审并提交 PR",fields:[uQ,dQ,{name:"sandboxToolId",label:"Sandbox Tool ID",placeholder:"tool-xxxxxxxx",help:"用于运行每次评审的 AgentKit CodeEnv",required:!0},{name:"modelName",label:"评审模型",placeholder:"doubao-seed-code-preview",help:"注入 Sandbox 的代码评审模型名称",required:!0},{name:"modelBaseUrl",label:"模型 API 地址",placeholder:"https://ark.cn-beijing.volces.com/api/coding/v3",help:"必须使用 OpenAI 兼容的 HTTPS 地址",required:!0}],initialValues:fQ(),regionHelp:"必须与 Sandbox Tool 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","CODEX_MODEL_API_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e);return cQ({...n,files:[{path:".github/workflows/codex-pr-review.yml",content:qct({sandboxToolId:e.sandboxToolId.trim(),modelName:e.modelName.trim(),modelBaseUrl:e.modelBaseUrl.trim(),region:n.region}),commitMessage:"chore: configure PR automated review"}],branchPrefix:"chore/pr-automated-review",title:"chore: 配置 PR 自动评审",description:"新增 GitHub Actions 工作流,在隔离 Sandbox 中评审同仓库 PR,并将结果发布为 GitHub Review。合并前请配置工作流所需 Secrets。"},t)}},Yct=/^[A-Za-z0-9_-]+$/,Hhe=4,PT=64,MT=6,Yq="agent-runtime";function Yhe(e){const t=e.trim();if(!t)return Yq;let n=t.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,PT);return n?(n.lengthPT?"Runtime 名称长度须为 4-64 个字符":null:"Runtime 名称只能包含英文字母、数字、下划线和连字符":"Runtime 名称为必填项"}const Kct=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;function Jct(e){const t=pQ(e.runtimeName);if(t)throw new Error(t);if(!Kct.test(e.runtimeId))throw new Error("Runtime ID 格式不正确")}function Ghe(e){Jct(e);const t=`name: Publish to AgentKit Runtime +`,n={__GH__:"${{",__REGION__:JSON.stringify(e.region),__SANDBOX_TOOL_ID__:JSON.stringify(e.sandboxToolId),__MODEL_NAME__:JSON.stringify(e.modelName),__MODEL_BASE_URL__:JSON.stringify(e.modelBaseUrl)};return Object.entries(n).reduce((i,[r,s])=>i.split(r).join(s),t)}const Yct={id:"review",kind:"github",category:"development",icon:"github",name:"PR 自动评审",description:"在隔离 Sandbox 中评审代码变更,并将结果发布到 Pull Request。",title:"PR 自动评审",subtitle:"在隔离 Sandbox 中检查代码变更并把结果发布到 Pull Request",panel:"工作流仅评审同仓库的非草稿 PR;fork PR 不会读取仓库 Secrets。",submitLabel:"添加评审并提交 PR",fields:[uQ,dQ,{name:"sandboxToolId",label:"Sandbox Tool ID",placeholder:"tool-xxxxxxxx",help:"用于运行每次评审的 AgentKit CodeEnv",required:!0},{name:"modelName",label:"评审模型",placeholder:"doubao-seed-code-preview",help:"注入 Sandbox 的代码评审模型名称",required:!0},{name:"modelBaseUrl",label:"模型 API 地址",placeholder:"https://ark.cn-beijing.volces.com/api/coding/v3",help:"必须使用 OpenAI 兼容的 HTTPS 地址",required:!0}],initialValues:fQ(),regionHelp:"必须与 Sandbox Tool 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","CODEX_MODEL_API_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e);return cQ({...n,files:[{path:".github/workflows/codex-pr-review.yml",content:Hct({sandboxToolId:e.sandboxToolId.trim(),modelName:e.modelName.trim(),modelBaseUrl:e.modelBaseUrl.trim(),region:n.region}),commitMessage:"chore: configure PR automated review"}],branchPrefix:"chore/pr-automated-review",title:"chore: 配置 PR 自动评审",description:"新增 GitHub Actions 工作流,在隔离 Sandbox 中评审同仓库 PR,并将结果发布为 GitHub Review。合并前请配置工作流所需 Secrets。"},t)}},Gct=/^[A-Za-z0-9_-]+$/,Yhe=4,PT=64,MT=6,Gq="agent-runtime";function Ghe(e){const t=e.trim();if(!t)return Gq;let n=t.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,PT);return n?(n.lengthPT?"Runtime 名称长度须为 4-64 个字符":null:"Runtime 名称只能包含英文字母、数字、下划线和连字符":"Runtime 名称为必填项"}const Jct=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;function eut(e){const t=pQ(e.runtimeName);if(t)throw new Error(t);if(!Jct.test(e.runtimeId))throw new Error("Runtime ID 格式不正确")}function Whe(e){eut(e);const t=`name: Publish to AgentKit Runtime on: push: @@ -962,7 +962,7 @@ jobs: if not result.success: raise SystemExit(f"AgentKit publish failed: {result.error}") PY -`,n={__BASE_BRANCH__:JSON.stringify(e.baseBranch),__PROJECT_PATH__:JSON.stringify(e.projectPath),__RUNTIME_NAME__:JSON.stringify(e.runtimeName),__RUNTIME_ID__:JSON.stringify(e.runtimeId),__REGION__:JSON.stringify(e.region),__CONCURRENCY_GROUP__:JSON.stringify(`agentkit-runtime-${e.runtimeId}`)};return Object.entries(n).reduce((i,[r,s])=>i.split(r).join(s),t)}const eut={id:"delivery",kind:"github",category:"development",icon:"github",name:"AgentKit Runtime 持续交付",description:"为您的仓库添加持续交付到 AgentKit Runtime 的自动化工作流。",title:"AgentKit Runtime 持续交付",subtitle:"用 Pull Request 把持续发布配置安全地加入代码仓库",panel:"提交后将在目标仓库创建发布分支,并发起包含 GitHub Actions 工作流的 PR。",submitLabel:"确定并提交 PR",fields:[uQ,dQ,{name:"projectPath",label:"Agent 项目目录",placeholder:".",help:"留空时使用仓库根目录;目录内需包含挂载完整 Studio App Server 的 app.py",required:!1},Xhe,qhe],initialValues:fQ(),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e),i=lQ(e.projectPath,".");return cQ({...n,files:[{path:".github/workflows/publish-agentkit.yml",content:Ghe({baseBranch:n.baseBranch,projectPath:i,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:n.region}),commitMessage:"feat: publish Agent to AgentKit Runtime"}],branchPrefix:"feat/agentkit-release",title:"feat: 持续发布到 AgentKit Runtime",description:"新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 Volcengine Secrets。"},t)}};function tut(e,t){return e==="."?t:`${e}/${t}`}function nut(e){return`.github/workflows/publish-agentkit-${e.replace(/[^A-Za-z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()||"root"}.yml`}function iut(e){return Object.fromEntries(Object.entries({"app.py":`"""__PROJECT_NAME__ — a VeADK agent with the full Studio App Server.""" +`,n={__BASE_BRANCH__:JSON.stringify(e.baseBranch),__PROJECT_PATH__:JSON.stringify(e.projectPath),__RUNTIME_NAME__:JSON.stringify(e.runtimeName),__RUNTIME_ID__:JSON.stringify(e.runtimeId),__REGION__:JSON.stringify(e.region),__CONCURRENCY_GROUP__:JSON.stringify(`agentkit-runtime-${e.runtimeId}`)};return Object.entries(n).reduce((i,[r,s])=>i.split(r).join(s),t)}const tut={id:"delivery",kind:"github",category:"development",icon:"github",name:"AgentKit Runtime 持续交付",description:"为您的仓库添加持续交付到 AgentKit Runtime 的自动化工作流。",title:"AgentKit Runtime 持续交付",subtitle:"用 Pull Request 把持续发布配置安全地加入代码仓库",panel:"提交后将在目标仓库创建发布分支,并发起包含 GitHub Actions 工作流的 PR。",submitLabel:"确定并提交 PR",fields:[uQ,dQ,{name:"projectPath",label:"Agent 项目目录",placeholder:".",help:"留空时使用仓库根目录;目录内需包含挂载完整 Studio App Server 的 app.py",required:!1},qhe,Hhe],initialValues:fQ(),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e),i=lQ(e.projectPath,".");return cQ({...n,files:[{path:".github/workflows/publish-agentkit.yml",content:Whe({baseBranch:n.baseBranch,projectPath:i,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:n.region}),commitMessage:"feat: publish Agent to AgentKit Runtime"}],branchPrefix:"feat/agentkit-release",title:"feat: 持续发布到 AgentKit Runtime",description:"新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 Volcengine Secrets。"},t)}};function nut(e,t){return e==="."?t:`${e}/${t}`}function iut(e){return`.github/workflows/publish-agentkit-${e.replace(/[^A-Za-z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()||"root"}.yml`}function rut(e){return Object.fromEntries(Object.entries({"app.py":`"""__PROJECT_NAME__ — a VeADK agent with the full Studio App Server.""" from assistant import root_agent from veadk.integrations.agentkit import create_agentkit_app, run_agentkit_app @@ -1070,36 +1070,36 @@ __pycache__/ Dockerfile .dockerignore README.md -`}).map(([n,i])=>[n,i.split("__PROJECT_NAME__").join(e)]))}const rut={id:"template",kind:"github",category:"development",icon:"github",name:"模板项目导入",description:"在您的仓库中创建一个可持续交付到 AgentKit Runtime 的最简智能体",title:"模板项目导入",subtitle:"把可直接启动 Studio 的 basic Agent 和持续交付配置加入仓库",panel:"提交后将创建一个 PR,同时导入 basic 项目和 AgentKit Runtime 发布工作流。",submitLabel:"导入模板并提交 PR",fields:[uQ,dQ,{name:"projectPath",label:"Agent 项目目录",placeholder:"agentkit-basic-agent",help:"将在此目录新增 basic 项目;app.py 挂载完整 Studio App Server,并作为服务入口启动",required:!0},Xhe,qhe],initialValues:fQ({projectPath:"agentkit-basic-agent"}),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e),i=Vhe(n.repository),r=lQ(e.projectPath,"agentkit-basic-agent"),s=r==="."?i.split("/").slice(-1)[0]||"agentkit-basic-agent":r.split("/").slice(-1)[0]||"agentkit-basic-agent",a=Object.entries(iut(s)).map(([o,c])=>({path:tut(r,o),content:c,commitMessage:"feat: import AgentKit basic template",mustBeNew:!0}));return a.push({path:nut(r),content:Ghe({baseBranch:n.baseBranch,projectPath:r,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:n.region}),commitMessage:"feat: add AgentKit Runtime delivery",mustBeNew:!0}),cQ({...n,repository:i,files:a,branchPrefix:"feat/agentkit-basic-template",title:"feat: 导入 AgentKit basic 模板",description:"导入带有 AgentKit Studio App Server 的 basic Agent 项目,并添加持续发布到 AgentKit Runtime 的工作流。合并前请配置 Volcengine Secrets。"},t)}},Gq=[{id:"development",label:"研发"},{id:"channels",label:"消息渠道"}],Whe=[Mct,rut,eut,Hct,Lct],sut=new Map(Whe.map(e=>[e.id,e]));function Zhe(e){const t=sut.get(e);if(!t)throw new Error(`Unknown automation: ${e}`);return t}function aut(e){const t=Zhe(e);if(t.kind!=="github")throw new Error(`Automation is not backed by GitHub: ${e}`);return t}const mQ="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2048%2048'%3e%3cimage%20width='48'%20height='48'%20href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAAH7UlEQVRoBdVZWWwbVRQ9492Onc1xTfaWLukq9oSqLKnYBZRSNgn6AagsAgmJRfzxg4SEEDtiER8IBKKAChK0FS1tKYWW0lZQKKV0gxCVJm3ikDiO17EdzrUzSdw4jj1OpeQqNzO237vvnHfvu/e9GWVwcBBDYue1mrqE2kI1UqeSJAnmIHUzNUCNUmGiKtQy6oPUR6geqnw/FSVOUH9R36KupfaDHnBQn6MGqEnqVJcEAfZTBbNL4b+lZPI1VbwwnaSfYO8z8N+TVMd0Qj6EVdbs3eIBP29cVFkL00kk+wSEwHAamgh9bDAJSQWTITZFnF+85J1tBPyOUC9OqqnsVdTIRkVBi70Msy125uriHJ8XAXFRfzKBTQM+rO0/hc54cSQE8iyzAx/XLcEltjIU44uCQijOaHvPfxIv97TjWCzEcMo7+sZ4TGa+2V6KT2rPQ73ZptsPBZE30fVrymvxTvUCtDoqYC0ijhMk/3MkgDd62xFheOqVggjIIAbOVaujEh/ULsaNzioUsxhVAv/A34GD0YBubxZMQJupWpMNr58zHytcHth1ekICsDcRx4u+fxBK6vOCbgKyEIXEK975WOmaoZuErKv1QR8ORQd0eUE3Ac0TNSYrXvI24fZSLxwGfebiDKW3e08gln9J0oYvKoMNG6kmiRdmzMOtTi8sOsJJJfANA93oiseGbeZ7k1EHZAKCEcApu4wCxUsSz3rm4HQiim3B/wpOsBJA2yP/4cZIJYIBFcGwCjWeSKEwm4wosZtR7rKizGXJQJZRB1TuttftAprnAbOrM9rl9UHqwg+s1o+eOow/GNN5CaPOklSgdKq4us+Ji7pt6Dw1AF9vBOGImjJht5lRVWFDY7UL58/3wOt2YPEcN2xWVpPRe6EQC+y9rwINPNKsuRaYX5cXhIxGkks+Y7V+6vQRdLBi5yx1bGwicFebivj+ARgOhZGMJMFyQyWpoV2GRIa2ZXOX2bDyqnPxzEPNKC+1Zj957eDBTbz34PXAwvoMfBN+kGV8Bxf00VgQz/vaEB6nSCnRQVj2h2DZG4TyZwQWlSils3m8RDDEhk2uaqlHaYklVb3Ha42dh4B3eMzZ//eEmMc0kGL3cEU9WksqU4XvzAYKZ9n6fQCOz3thORCGkhgCf2bDMz4bjQpW39yE65Y1QO5FxiUgP+76E3hzI7D1VyBcwP5NTFcZzXjaPRMNZmvGPkfA23YMwLHRD0Mf3ZwTgaBIi8GgYMGsSjx2z3kEP9Jp5E5rOeoqQH75C3htPfDpD4CskXxFvHC5vQKPVjSwPqQfcKTAfxuA/Ws/lBAXwEhUTGjWSAL3r1qYykSju+UkIFbZDx09wPvb0iH1W9uEYw03MHAV3ltew1CqgDkyCNtWgt/cnwY/3GriG5n9hbMrccNljRmzLz0nJCCNJBsEwsCH24E3NgDr96brhfyWS2Sm3EYLVsOL0i0DsG8h+LDkqcLExHhfc9siVDDrjJ59sZJRyHKZFRKybiSkTtIjR08CrXwEdtGcXL2A4+192LOuDeatfqg6wMvsL5lbhWuWysIdO995E9BgSkh19THX7wQOtANXLgKWLQSaarUWI9dNP7bjo68OY9uef6GqhcW8ZkViX2a/nBWYQ4+RggmIBfFGnHgOcD0c7wD2HgOW0xuXk0xN5SDaOwL4cnsb1m05joPHejKK0hgEOb4Q8Muba3H1pXUwZZl96aqLgHSU2RCbEe6/9hzh875OYPdhYF5NDLt/Oohd+46gNxBjm2zzJhZyi/RyV5TggdsvRJnTOm5j3QQ0i9ra6OHj1u9+B/YdNcLXVQdDmYNPy9oZ971IcIPHjUHadVrHHFfZNphtTtx508W4eJEHsg7Gk6IJaIZlDEn3EdUEl7sBg4la2MtqkYgNIOz/F9FgF6IhX6p5mozcjgbGasw/xWCCs7IeN7U24b4VddwZj26jjTZynTQCmknxSBqIETanh7ceWEpmpIiokT7E6JFosBvxaD/iJCeNDQYzTFYnzHY3SsobmfM9eOyucjTO0KyOf510AqOHkl2kiMlSQoAlsPLAk4hHSCaIJMMqmUgfYBQeggxGK4xmOxprXHh8lYK51em+E/0/qwQyBh8iY+Q52pjlOZD8XFcFPHELcGlT3stlbBaymtOROTReBoZJ+0DjZ9pv4SFq9fL0YWqcjJl1+AwP8OSGS+amq6y4P/fyyWqvoC9lDAG7ainPEJcBs7xMBGOLbU6bGQTMJHAnDUlG2biPFZevEM4GCZl9sSsnPgG+bAHfa+l8vZJxpNSo+oPp/c4XP6bPBN0kog2qtdFz1WzIkfXmZuAKVm6JewlbvZKVgGZMilMPwW9ngdr5B3CEG7iEbCY5ffl6RgPtYDGdybS4ogW4YDbgLefTD5s2kv5rTgKaWdlKi1fau4BDJ3jM5I70NDd0J7grzfZEUMg5CM5Tmg4TiW3ZtVYxTKpcgM2iWS7+mhcBbRiZ/TBTd4jPjtSEVF3AxxdUPgkxTrUUMTcBykKUmLZwhQlYPhWBeCBV5DRjk3QtiEC2McUDsjPVCEhWEQ8Umk2y2c7nOyEwrV/ySdbdQo3nw3aKtRHM3wiBtVQu02knISJ+SQh8Q32TyqTJJ6xTXyQzyzb2LeoBWQOy5pjwcDf1YSqzNIooLex99kTCppsq4N+l+oUArylhoku9sb+O18VU8c5UEiZu7KGyrKKTmgr7/wGxhy03aZIycwAAAABJRU5ErkJggg=='%20/%3e%3c/svg%3e";function Khe(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91 .58 .11 .79-.25.79-.56v-2.02c-3.2.7-3.88-1.36-3.88-1.36-.52-1.33-1.28-1.69-1.28-1.69-1.05-.72.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.71 1.26 3.37.96.1-.75.4-1.26.73-1.55-2.56-.29-5.25-1.28-5.25-5.7 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.47.11-3.06 0 0 .97-.31 3.16 1.18A10.98 10.98 0 0 1 12 6.11c.98 0 1.96.13 2.87.39 2.19-1.49 3.16-1.18 3.16-1.18.63 1.59.23 2.77.11 3.06.74.81 1.19 1.84 1.19 3.1 0 4.43-2.7 5.4-5.27 5.69.42.36.78 1.06.78 2.14v3.04c0 .31.21.67.8.56A11.51 11.51 0 0 0 23.5 12C23.5 5.65 18.35.5 12 .5Z"})})}function Wq(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function out(e){return l.jsxs("svg",{viewBox:"0 0 36 36",fill:"none","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",fill:"currentColor",opacity:"0.1"}),l.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("path",{d:"m9.2 11.2-2.8 2.7 2.8 2.7M12.1 17.4h4.3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("circle",{cx:"26.5",cy:"12",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("circle",{cx:"27",cy:"26.5",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("path",{d:"M21.5 12h2M19.3 21l5.6 3.8M27 15v8.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function lut({onOpen:e}){var u;const[t,n]=m.useState("development"),[i,r]=m.useState(""),s=m.useDeferredValue(i),a=m.useMemo(()=>{const d=s.trim().toLocaleLowerCase();return Whe.filter(f=>f.category===t).filter(f=>!d||`${f.name} ${f.description}`.toLocaleLowerCase().includes(d))},[t,s]),o=(u=Gq.find(d=>d.id===t))==null?void 0:u.label,c=Pct(window.location.hostname);return l.jsxs("div",{className:"applications-page",children:[l.jsxs("header",{className:"applications-header",children:[l.jsxs("div",{children:[l.jsx("h1",{children:"自动化"}),l.jsx("p",{children:"连接研发工具,为智能体扩展自动化工作流"})]}),l.jsxs("label",{className:"applications-search",children:[l.jsx(Wq,{}),l.jsx("input",{type:"search","aria-label":"搜索自动化",value:i,onChange:d=>r(d.target.value),placeholder:"搜索自动化"})]})]}),l.jsx("nav",{className:"applications-categories","aria-label":"自动化分类",children:Gq.map(d=>l.jsx("button",{type:"button",className:t===d.id?"is-active":"","aria-pressed":t===d.id,onClick:()=>n(d.id),children:d.label},d.id))}),l.jsx("section",{className:"applications-results","aria-label":`${o}自动化列表`,children:a.length?l.jsx("div",{className:"applications-grid",children:a.map(d=>{const f=d.id==="coding-agents"&&!c,h=f?"coding-agents-local-only-tooltip":void 0;return l.jsxs("div",{className:`application-card-wrap${f?" is-disabled":""}`,tabIndex:f?0:void 0,"aria-describedby":h,children:[l.jsxs("button",{type:"button",className:"application-card",onClick:()=>e(d.id),"aria-label":`打开${d.name}`,disabled:f,children:[d.icon==="feishu"?l.jsx("img",{className:"application-card-icon application-card-brand-icon",src:mQ,alt:"","aria-hidden":"true"}):d.icon==="coding-agents"?l.jsx(out,{className:"application-card-icon"}):l.jsx(Khe,{className:"application-card-icon"}),l.jsxs("div",{className:"application-card-copy",children:[l.jsxs("div",{className:"application-card-title",children:[l.jsx("h2",{children:d.name}),d.badge?l.jsx("span",{className:`application-card-badge is-${d.badgeTone||"default"}`,children:d.badge}):null]}),l.jsx("p",{children:d.description})]})]}),f?l.jsx("span",{id:h,className:"application-card-tooltip",role:"tooltip",children:"仅本地部署可用"}):null]},d.id)})}):l.jsxs("div",{className:"applications-empty",role:"status",children:[l.jsx(Wq,{}),l.jsx("h2",{children:"没有匹配的自动化"}),l.jsx("p",{children:"请尝试搜索其他名称"})]})})]})}const cut={volcengine:"https://console.volcengine.com",byteplus:"https://console.byteplus.com"};function n1(e){return e.trim()}function gQ(e){return cut[e]}function uut(e){const t=n1(e);if(!t)return null;let n=t;try{n=new URL(t.includes("://")?t:`https://${t}`).hostname}catch{return null}const i=n.match(/^(.+)\.tos-([a-z0-9-]+)\.(?:volces|bytepluses)\.com$/i);return i?{bucket:i[1],region:i[2]}:null}function dut(e,t){const n=uut(t);if(!n)return null;const i=new URLSearchParams({id:n.bucket,region:n.region,type:"objects"});return`${gQ(e)}/tos/bucket/setting?${i.toString()}`}function fut(e,t,n){const i=n1(t),r=n1(n);return!i||!r?null:`${gQ(e)}/agentkit/region:agentkit+${encodeURIComponent(i)}/builtintools/${encodeURIComponent(r)}/detail`}function hut(e,t,n){const i=n1(t),r=n1(n);return!i||!r?null:`${gQ(e)}/identity/region:identity+${encodeURIComponent(i)}/user-pools/${encodeURIComponent(r)}/info`}function nR({href:e,label:t,children:n}){return e?l.jsxs("a",{className:"system-info-resource-link",href:e,target:"_blank",rel:"noreferrer","aria-label":t,title:t,children:[l.jsx("span",{children:n}),l.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"M7.75 5.25h-2.5a1.5 1.5 0 0 0-1.5 1.5v8a1.5 1.5 0 0 0 1.5 1.5h8a1.5 1.5 0 0 0 1.5-1.5v-2.5"}),l.jsx("path",{d:"M10.25 3.75h6v6M16 4 9 11"})]})]}):l.jsx("span",{children:n})}function put(e){return e instanceof Error&&e.message.includes("Volcengine credentials not found")}function mut({version:e,localMode:t,role:n,provider:i,region:r}){const s=n==="admin",[a,o]=m.useState(""),[c,u]=m.useState([]),[d,f]=m.useState([]),[h,p]=m.useState(!0),[g,b]=m.useState(""),[y,O]=m.useState(!0),[v,x]=m.useState(""),[w,E]=m.useState(0),[S,k]=m.useState(0);return m.useEffect(()=>{if(!s){o(""),u([]),p(!1),b("");return}const T=new AbortController;return p(!0),b(""),nee(T.signal).then(A=>{o(A.storage.tosAddress),u(A.sandboxTools)}).catch(A=>{(A==null?void 0:A.name)!=="AbortError"&&b(A instanceof Error?A.message:String(A))}).finally(()=>{T.signal.aborted||p(!1)}),()=>T.abort()},[s,w]),m.useEffect(()=>{if(!s){f([]),O(!1),x("");return}const T=new AbortController;return O(!0),x(""),KD(T.signal).then(A=>{f(A.filter(N=>N.isCurrent))}).catch(A=>{if((A==null?void 0:A.name)!=="AbortError"){if(t&&put(A)){f([]);return}x(A instanceof Error?A.message:String(A))}}).finally(()=>{T.signal.aborted||O(!1)}),()=>T.abort()},[s,t,S]),l.jsxs("div",{className:"system-info-page",children:[l.jsxs("header",{className:"system-info-page-header",children:[l.jsx("h1",{children:"系统信息"}),l.jsx("p",{children:"查看当前 Studio 版本及关联的基础资源"})]}),l.jsxs("div",{className:"system-info-scroll",children:[l.jsxs("section",{className:"system-info-section","aria-labelledby":"studio-info-title",children:[l.jsx("h2",{id:"studio-info-title",children:"通用"}),l.jsx("dl",{className:"system-info-summary",children:l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:e||"—"})]})})]}),s?l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"system-info-section","aria-labelledby":"storage-info-title",children:[l.jsx("h2",{id:"storage-info-title",children:"存储"}),h?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载存储信息"})}):g?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:g}),l.jsx("button",{type:"button",onClick:()=>E(T=>T+1),children:"重新加载"})]}):l.jsx("dl",{className:"system-info-summary",children:l.jsxs("div",{className:"system-info-resource-row",children:[l.jsx("dt",{children:"TOS 地址"}),l.jsx("dd",{className:`system-info-resource-value${a?"":" is-empty"}`,children:l.jsx(nR,{href:dut(i,a),label:"在云控制台中打开 TOS 存储桶",children:a||"未配置"})})]})})]}),l.jsxs("section",{className:"system-info-section","aria-labelledby":"sandbox-tool-title",children:[l.jsx("h2",{id:"sandbox-tool-title",children:"沙箱信息"}),h?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载沙箱信息"})}):g?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:g}),l.jsx("button",{type:"button",onClick:()=>E(T=>T+1),children:"重新加载"})]}):l.jsx("div",{className:"system-info-tool-list",children:c.map(T=>l.jsx("dl",{className:"system-info-tool",children:l.jsxs("div",{className:"system-info-resource-row",children:[l.jsxs("dt",{className:"system-info-tool-label",children:[l.jsx("span",{children:T.label}),T.snapshot?l.jsx("span",{className:"system-info-tool-badge",children:"快照版"}):null]}),l.jsx("dd",{className:`system-info-resource-value${T.toolId?"":" is-empty"}`,children:l.jsx(nR,{href:fut(i,r,T.toolId),label:`在云控制台中打开${T.label}`,children:T.toolId||"未配置"})})]})},T.kind))})]}),l.jsxs("section",{className:"system-info-section","aria-labelledby":"user-pool-title",children:[l.jsx("h2",{id:"user-pool-title",children:"用户池"}),y?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载用户池"})}):v?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:v}),l.jsx("button",{type:"button",onClick:()=>k(T=>T+1),children:"重新加载"})]}):d.length>0?l.jsx("div",{className:"system-info-pool-list",children:d.map(T=>l.jsxs("dl",{className:"system-info-pool",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"名称"}),l.jsx("dd",{className:"system-info-resource-value",children:l.jsx(nR,{href:hut(i,T.region||r,T.uid),label:`在云控制台中打开用户池${T.name?`“${T.name}”`:""}`,children:T.name||"未命名用户池"})})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"ID"}),l.jsx("dd",{children:T.uid||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"域名"}),l.jsx("dd",{children:T.domain||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"区域"}),l.jsx("dd",{children:T.region||"—"})]})]},T.uid))}):l.jsx("p",{className:"system-info-empty",children:t?"本地模式未配置用户池":"当前 Studio 未配置用户池"})]})]}):null]})]})}function gut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function but({hidden:e,...t}){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("path",{d:"M2.5 10s2.6-4 7.5-4 7.5 4 7.5 4-2.6 4-7.5 4-7.5-4-7.5-4Z"}),l.jsx("circle",{cx:"10",cy:"10",r:"1.8"}),e?l.jsx("path",{d:"m4 4 12 12"}):null]})}function Zq(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Out(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function yut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function iR(e,t,n){const i=t.trim();if(!i)return n?"此项不能为空":"";if(e==="repository"&&!/^(?:https:\/\/github\.com\/)?[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:\.git)?$/.test(i))return"请输入 owner/repository 或完整 GitHub Repo URL";if(e==="baseBranch"&&(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(i)||i.includes("..")))return"目标分支格式不正确";if(e==="projectPath"&&(i.startsWith("/")||i.split("/").includes("..")))return"请输入仓库内的相对目录";if(e==="runtimeName")return pQ(i)??"";if(e==="runtimeId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(i))return"Runtime ID 格式不正确";if(e==="sandboxToolId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(i))return"Sandbox Tool ID 格式不正确";if(e==="modelName"&&!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(i))return"模型名称格式不正确";if(e==="modelBaseUrl")try{const r=new URL(i);if(r.protocol!=="https:"||r.username||r.password||r.search||r.hash)return"请输入不含凭据、查询参数或锚点的 HTTPS 地址"}catch{return"请输入有效的 HTTPS 地址"}return""}function xut({automation:e,onBack:t}){const n=aut(e),[i,r]=m.useState(()=>({...n.initialValues})),[s,a]=m.useState({}),[o,c]=m.useState(""),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(!1),[b,y]=m.useState(null),O=m.useRef(null);m.useEffect(()=>()=>{var k;return(k=O.current)==null?void 0:k.abort()},[]);const v=(k,T)=>{r(A=>({...A,[k]:T})),s[k]&&a(A=>({...A,[k]:""}))},x=k=>{var N;const T=k==="token"||((N=n.fields.find(C=>C.name===k))==null?void 0:N.required)===!0,A=iR(k,i[k],T);a(C=>({...C,[k]:A}))},w=async k=>{var C;k.preventDefault();const T={};for(const M of n.fields){const L=iR(M.name,i[M.name],M.required);L&&(T[M.name]=L)}const A=iR("token",i.token,!0);if(A&&(T.token=A),a(T),Object.keys(T).length)return;(C=O.current)==null||C.abort();const N=new AbortController;O.current=N,d(!0),c(""),y(null);try{const M=await n.submit(i,N.signal);if(O.current!==N)return;y(M),r(L=>({...L,token:""}))}catch(M){if(N.signal.aborted||O.current!==N)return;c(M instanceof Error?M.message:String(M))}finally{O.current===N&&(O.current=null,d(!1))}},E=k=>{k.key==="Enter"&&(k.nativeEvent.isComposing||k.nativeEvent.keyCode===229)&&k.preventDefault()},S=k=>{const{name:T,label:A,placeholder:N,help:C,required:M}=k;return l.jsxs("div",{className:"github-field",children:[l.jsxs("label",{htmlFor:`github-${T}`,children:[l.jsx("span",{children:A}),l.jsx("span",{className:`github-field-requirement${M?" is-required":""}`,children:M?"必填":"可选"})]}),l.jsx("input",{id:`github-${T}`,value:i[T],onChange:L=>v(T,L.target.value),onBlur:()=>x(T),placeholder:N,required:M,"aria-invalid":!!s[T],"aria-describedby":`github-${T}-help${s[T]?` github-${T}-error`:""}`}),l.jsx("span",{id:`github-${T}-help`,className:"github-field-help",children:C}),s[T]?l.jsx("span",{id:`github-${T}-error`,className:"github-field-error",role:"alert",children:s[T]}):null]},T)};return l.jsxs("div",{className:"github-integration-page",children:[l.jsxs("header",{className:"github-integration-header",children:[l.jsx("button",{type:"button",className:"github-back",onClick:t,"aria-label":"返回自动化列表",children:l.jsx(gut,{})}),l.jsx(Khe,{className:"github-integration-logo"}),l.jsxs("div",{children:[l.jsx("h1",{children:n.title}),l.jsx("p",{children:n.subtitle})]})]}),l.jsx("div",{className:"github-integration-layout",children:l.jsxs("section",{id:`github-panel-${e}`,className:"github-section-panel",children:[l.jsx("div",{className:"github-panel-heading",children:l.jsx("p",{children:n.panel})}),l.jsxs("form",{className:"github-release-form",onSubmit:w,onKeyDown:E,noValidate:!0,children:[l.jsxs("div",{className:"github-field-grid",children:[n.fields.map(S),l.jsxs("div",{className:"github-field",children:[l.jsxs("label",{id:"github-region-label",children:[l.jsx("span",{children:"地域"}),l.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),l.jsxs("div",{className:"pp-network-region github-region-picker",onKeyDown:k=>{k.key==="Escape"&&g(!1)},children:[l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-labelledby":"github-region-label","aria-haspopup":"listbox","aria-expanded":p,onClick:()=>g(k=>!k),children:[l.jsx("span",{children:i.region==="cn-shanghai"?"华东 2(上海)":"华北 2(北京)"}),l.jsx(Out,{className:`pp-region-chevron${p?" is-open":""}`})]}),p?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>g(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"地域",children:[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}].map(k=>{const T=k.value===i.region;return l.jsxs("button",{type:"button",role:"option","aria-selected":T,className:`pp-region-option${T?" is-selected":""}`,onClick:()=>{v("region",k.value),g(!1)},children:[l.jsx("span",{children:k.label}),T?l.jsx(yut,{}):null]},k.value)})})]}):null]}),l.jsx("span",{className:"github-field-help",children:n.regionHelp})]})]}),l.jsxs("div",{className:"github-field github-token-field",children:[l.jsxs("div",{className:"github-token-label-row",children:[l.jsxs("label",{htmlFor:"github-token",children:[l.jsx("span",{children:"GitHub Token"}),l.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),l.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new?name=VeADK%20Studio&description=Create%20a%20GitHub%20automation%20pull%20request&contents=write&pull_requests=write",target:"_blank",rel:"noreferrer",children:["获取 Token",l.jsx(Zq,{})]})]}),l.jsxs("div",{className:"github-token-input",children:[l.jsx("input",{id:"github-token",type:f?"text":"password",value:i.token,onChange:k=>v("token",k.target.value),onBlur:()=>x("token"),autoComplete:"off",required:!0,placeholder:"需要仓库 Contents 与 Pull requests 写权限","aria-invalid":!!s.token,"aria-describedby":`github-token-help${s.token?" github-token-error":""}`}),l.jsx("button",{type:"button",onClick:()=>h(k=>!k),"aria-label":f?"隐藏 Token":"显示 Token",title:f?"隐藏 Token":"显示 Token",children:l.jsx(but,{hidden:f})})]}),l.jsx("span",{id:"github-token-help",className:"github-field-help",children:"Token 仅用于本次提交,不会保存在浏览器或写入 PR"}),s.token?l.jsx("span",{id:"github-token-error",className:"github-field-error",role:"alert",children:s.token}):null]}),o?l.jsx("div",{className:"github-submit-message is-error",role:"alert",children:o}):null,b?l.jsxs("div",{className:"github-submit-message is-success",role:"status",children:[l.jsxs("span",{children:["PR #",b.number," 已创建"]}),l.jsxs("a",{href:b.url,target:"_blank",rel:"noreferrer",children:["在 GitHub 查看",l.jsx(Zq,{})]})]}):null,l.jsxs("div",{className:"github-form-actions",children:[l.jsxs("div",{className:"github-secrets-note",children:[l.jsx("strong",{children:"合并 PR 前,请在仓库的 GitHub Actions Secrets 中配置:"}),n.secrets.map(k=>l.jsx("span",{children:k},k))]}),l.jsx("button",{type:"submit",disabled:u,children:u?"提交 PR 中…":n.submitLabel})]})]})]})})]})}const vut=1050062,Kq="1.0",wut="https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/5/collect.js";class Sut{constructor(){Or(this,"enabled",!1);Or(this,"initialized",!1);Or(this,"pending",[]);Or(this,"userUniqueId","");Or(this,"initPromise")}init(t){return this.enabled=t.enabled,this.enabled?this.initPromise?this.initPromise:(this.initPromise=Promise.resolve().then(()=>{const n=this.bootstrapCollector();n("init",{app_id:vut,channel:"cn",disable_auto_pv:1}),this.userUniqueId&&n("config",{user_unique_id:this.userUniqueId}),n("config",{_staging_flag:t.environment==="prod"?0:1}),n("start"),this.initialized=!0;const i=this.pending;this.pending=[];for(const[r,s]of i)this.collect(r,s)}),this.initPromise):(this.pending=[],Promise.resolve())}identify(t){this.userUniqueId=t,this.initialized&&this.collect("config",{user_unique_id:t})}emit(t,n){if(this.enabled){if(this.initialized){this.collect(t,n);return}this.pending=[...this.pending.slice(-49),[t,n]]}}bootstrapCollector(){if(window.collectEvent)return window.collectEvent;window.LogAnalyticsObject="collectEvent";const t=function(){var r;(r=t.q)==null||r.push(arguments)};t.q=[],t.l=Date.now(),window.collectEvent=t;const n=document.createElement("script");return n.async=!0,n.src=wut,n.onerror=()=>{this.enabled=!1,t.q=[],console.warn("[telemetry] TEA SDK script failed to load")},document.head.appendChild(n),t}collect(t,n){var i;(i=window.collectEvent)==null||i.call(window,t,n)}}function Eut(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e).trim();return/^[A-Za-z0-9_.:-]{1,64}$/.test(t)?t:void 0}function gu(e,t){return t===void 0?{errorKind:e}:{errorKind:e,errorCode:t}}function Ra(e,t={}){const n=e!==null&&typeof e=="object"?e:{},i=Eut(n.code),r=typeof n.name=="string"?n.name:"";if(r==="RuntimeProbeError")return gu("runtime_probe_error",i);if(r==="AbortError")return gu("abort",i);if(r==="RuntimeAccessDeniedError"||r==="AuthError")return gu("auth",i);if(t.phase==="build")return gu("build_failed",i);if(r==="TimeoutError")return gu("timeout",i);if(r==="NetworkError"||r==="TypeError")return gu("network",i);if(r==="ValidationError")return gu("validation",i);if(r==="ServerError")return gu("server",i);const s=typeof n.status=="number"&&Number.isInteger(n.status)?n.status:void 0;if(s===void 0||s<400||s>599)return gu("unknown",i);const a=String(s);return s===401||s===403?{errorKind:"auth",errorCode:a}:s===400||s===409||s===422?{errorKind:"validation",errorCode:a}:s>=500?{errorKind:"server",errorCode:a}:{errorKind:"unknown",errorCode:a}}const kut=["schema_version","event_id","operation_id","user_pool_id","studio_deploy_id","vefaas_application_id","vefaas_function_id","studio_region","studio_project","studio_version","environment","cloud_provider","account_id","user_role","user_source","page_instance_id"],Tut={studio_entry_viewed:["auth_state"],studio_session_started:["agents_source"],studio_agent_deploy:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","deploy_region","runtime_network_type","feishu_enabled","runtime_id","duration_ms","failed_phase","error_kind","error_code"],studio_sandbox_create:["status","sandbox_kind","sandbox_source","sandbox_id","duration_ms","error_kind","error_code"],studio_agent_debug:["status","agent_id","variant_type","debug_run_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_connect:["status","target_id","agent_kind","connect_source","runtime_region","runtime_is_mine","sandbox_status","duration_ms","error_kind","error_code"],studio_agent_message:["status","agent_id","agent_kind","message_source","session_state","session_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_source_download:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","duration_ms","file_count","zip_size_bytes","error_kind","error_code"]};function _ut(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function Jq(e,t){const n=new Set([...kut,...Tut[e]]),i={};for(const[r,s]of Object.entries(t))!n.has(r)||!_ut(s)||(i[r]=typeof s=="string"?s.slice(0,256):s);return i}function Aut(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function Nut(){return typeof performance<"u"?performance.now():Date.now()}function pm(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class Cut{constructor(t){Or(this,"sink");Or(this,"createId");Or(this,"now");Or(this,"pageInstanceId");Or(this,"context");Or(this,"identity");Or(this,"entryViewed",!1);Or(this,"sessionStarted",!1);this.sink=t.sink,this.createId=t.createId??Aut,this.now=t.now??Nut,this.pageInstanceId=this.createId()}setContext(t){var n;this.context={...t,accountId:((n=t.accountId)==null?void 0:n.trim())??""}}identify(t){var i,r,s;const n=t.userUniqueId.trim();n&&(this.identity&&this.identity.userUniqueId!==n&&(this.pageInstanceId=this.createId(),this.sessionStarted=!1),this.identity={...t,userUniqueId:n,accountId:((i=t.accountId)==null?void 0:i.trim())??""},(s=(r=this.sink).identify)==null||s.call(r,n))}trackStudioSessionStarted(t){this.sessionStarted||!this.context||!this.identity||(this.sessionStarted=!0,this.emit("studio_session_started",{agents_source:t.agentsSource}))}trackStudioEntryViewed(t){if(this.entryViewed||!this.context)return;this.entryViewed=!0;const n=Jq("studio_entry_viewed",pm({schema_version:Kq,event_id:this.createId(),user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.context.accountId,page_instance_id:this.pageInstanceId,auth_state:t.authState}));this.sink.emit("studio_entry_viewed",n)}beginAgentDeploy(t){return this.beginOperation("studio_agent_deploy",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted,deploy_region:t.deployRegion,runtime_network_type:t.runtimeNetworkType,feishu_enabled:t.feishuEnabled},n=>({runtime_id:n.runtimeId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginSandboxCreate(t){return this.beginOperation("studio_sandbox_create",{sandbox_kind:t.sandboxKind,sandbox_source:t.sandboxSource},n=>({sandbox_id:n.sandboxId}),n=>({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentDebug(t){return this.beginOperation("studio_agent_debug",{agent_id:t.agentId,variant_type:t.variantType},n=>({debug_run_id:n.debugRunId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentConnect(t){return this.beginOperation("studio_agent_connect",{target_id:t.targetId,agent_kind:t.agentKind,connect_source:t.connectSource},n=>pm({runtime_region:n.runtimeRegion,runtime_is_mine:n.runtimeIsMine,sandbox_status:n.sandboxStatus}),n=>pm({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentMessage(t){return this.beginOperation("studio_agent_message",pm({agent_id:t.agentId,agent_kind:t.agentKind,message_source:t.messageSource,session_state:t.sessionState,session_id:t.sessionId}),n=>({session_id:n.sessionId}),n=>pm({session_id:n.sessionId,failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentSourceDownload(t){return this.beginOperation("studio_agent_source_download",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted},n=>({file_count:n.fileCount,zip_size_bytes:n.zipSizeBytes}),n=>({file_count:n.fileCount,error_kind:n.errorKind,error_code:n.errorCode}))}beginOperation(t,n,i,r){const s=this.createId(),a=this.now(),o=!!(this.context&&this.identity);let c=!1;o&&this.emit(t,{...n,status:"started"},s);const u=(d,f)=>{c||(c=!0,o&&this.emit(t,{...n,...f,status:d,duration_ms:Math.max(0,this.now()-a)},s))};return{operationId:s,succeed:d=>u("succeeded",i(d)),fail:d=>u("failed",r(d))}}emit(t,n,i){if(!this.context||!this.identity)return;const r=Jq(t,pm({schema_version:Kq,event_id:this.createId(),operation_id:i,user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.identity.accountId,user_role:this.identity.userRole,user_source:this.identity.userSource,page_instance_id:this.pageInstanceId,...n}));this.sink.emit(t,r)}}const Jhe=new Sut,eu=new Cut({sink:Jhe});function jut(e){return Jhe.init(e)}function Rut(e){eu.setContext(e)}function Iut(e){eu.identify(e)}function Put(e){eu.trackStudioEntryViewed(e)}function Mut(e){eu.trackStudioSessionStarted(e)}function epe(e){return eu.beginAgentDeploy(e)}function Lut(e){return eu.beginSandboxCreate(e)}function Dut(e){return eu.beginAgentDebug(e)}function rR(e){return eu.beginAgentConnect(e)}function eH(e){return eu.beginAgentMessage(e)}function $ut(e){return eu.beginAgentSourceDownload(e)}const Qut=/^[A-Za-z_][A-Za-z0-9_]*$/;function i1(e){return e.trim().length===0?"名称为必填项":e==="user"?"user 是 Google ADK 保留名称,请使用其他名称":Qut.test(e)?null:"名称须以英文字母或下划线开头,且只能包含英文字母、数字和下划线"}function But(e){const t=new Set,n=new Set,i=r=>{i1(r.name)===null&&(t.has(r.name)?n.add(r.name):t.add(r.name)),r.subAgents.forEach(i)};return i(e),n}function Uut(e){return{...el(),name:e,description:"一个通过飞书接收消息并提供帮助的智能助手。",instruction:"你是一个通过飞书为用户提供帮助的智能助手。准确理解用户问题,给出简洁、可靠的回答;信息不足时先提问澄清,不要臆造事实。",deployment:{feishuEnabled:!0}}}async function zut(e){const t=Uut(e.agentName),n=await t$(t);return w1(n.name,n.files,{region:e.region,projectName:"default"},{taskId:e.taskId,sessionStorage:"in-memory",minInstance:1,maxInstance:1,description:t.description,im:{feishu:{enabled:!0}},envs:[{key:"FEISHU_APP_ID",value:e.appId},{key:"FEISHU_APP_SECRET",value:e.appSecret}],onStage:e.onStage})}const yl=[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}],tpe=[{phase:"prepare",label:"生成智能体"},{phase:"build",label:"构建镜像"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}];function Fut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Vut(e){return l.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 7 4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function tH(e){return l.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4 9.2 3.1 3.1L14 5.8",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function qut(e){if(!e||e==="upload")return 0;const t=tpe.findIndex(n=>n.phase===e);return t<0?0:t}function sR(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}function Hut({onBack:e}){var J;const[t,n]=m.useState("feishu_assistant"),[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState("cn-beijing"),[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState(""),[O,v]=m.useState(""),[x,w]=m.useState("idle"),[E,S]=m.useState(null),[k,T]=m.useState(""),[A,N]=m.useState(null),C=m.useRef(null),M=m.useRef(null),L=m.useRef([]),P=m.useRef(0),Q=m.useRef(null),j=m.useRef(null),$=m.useRef("prepare"),U=m.useRef(!1),B=m.useRef(!0),I=["preparing","running","cancelling"].includes(x);m.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),m.useEffect(()=>{var ye;if(!f)return;(ye=L.current[P.current])==null||ye.focus();const ie=Se=>{Se.target instanceof Node&&C.current&&!C.current.contains(Se.target)&&h(!1)},ue=Se=>{var Re;Se.key==="Escape"&&(h(!1),(Re=M.current)==null||Re.focus())};return window.addEventListener("pointerdown",ie),window.addEventListener("keydown",ue),()=>{window.removeEventListener("pointerdown",ie),window.removeEventListener("keydown",ue)}},[f]);const X=ie=>{ie.key==="Enter"&&(ie.nativeEvent.isComposing||ie.nativeEvent.keyCode===229)&&ie.preventDefault()},q=()=>{const ie=i1(t.trim())??"",ue=i.trim()?"":"请输入飞书 App ID",ye=s.trim()?"":"请输入飞书 App Secret";return g(ie),y(ue),v(ye),!ie&&!ue&&!ye},D=async ie=>{if(ie.preventDefault(),!q()||I)return;const ue=crypto.randomUUID();Q.current=ue,$.current="prepare",U.current=!1,w("preparing"),S(null),T(""),N(null);const ye=epe({agentId:String(t.trim()),deployAction:"create",deploySource:"feishu_automation",createMode:"feishu_template",aiAssisted:0,deployRegion:String(u),runtimeNetworkType:"public",feishuEnabled:1});j.current=ye;try{const Se=await zut({agentName:t.trim(),appId:i.trim(),appSecret:s.trim(),region:u,taskId:ue,onStage:Re=>{$.current=Re.phase||"deploy",!(!B.current||U.current)&&(w("running"),S(Re))}});if(U.current){ye.fail({failedPhase:sR($.current),errorKind:"abort"});return}if(ye.succeed({runtimeId:String(Se.runtimeId||"")}),!B.current)return;N(Se),a(""),c(!1),w("succeeded")}catch(Se){if(ye.fail({failedPhase:sR($.current),...U.current?{errorKind:"abort"}:Ra(Se,{phase:$.current})}),!B.current||U.current)return;w("failed"),T(Se instanceof Error?Se.message:String(Se))}finally{Q.current===ue&&(Q.current=null),j.current===ye&&(j.current=null)}},H=async()=>{var ue;const ie=Q.current;if(!(!ie||x!=="running")&&window.confirm("取消部署将停止任务并清理已创建的 Runtime,确定继续吗?")){U.current=!0,w("cancelling"),T("");try{await iee(ie),(ue=j.current)==null||ue.fail({failedPhase:sR($.current),errorKind:"abort"}),B.current&&w("cancelled")}catch(ye){if(U.current=!1,!B.current)return;w("failed"),T(ye instanceof Error?ye.message:String(ye))}}},re=qut((E==null?void 0:E.phase)??null),fe=!!(t.trim()&&i.trim()&&s.trim()&&!I),Ae=yl.find(ie=>ie.value===u);return l.jsxs("div",{className:"feishu-integration-page",children:[l.jsxs("header",{className:"feishu-integration-header",children:[l.jsx("button",{type:"button",className:"feishu-back",onClick:e,"aria-label":"返回自动化列表",disabled:I,children:l.jsx(Fut,{})}),l.jsx("img",{className:"feishu-integration-logo",src:mQ,alt:"","aria-hidden":"true"}),l.jsxs("div",{children:[l.jsx("h1",{children:"飞书机器人"}),l.jsx("p",{children:"创建一个由 AgentKit Runtime 驱动的飞书智能体"})]})]}),l.jsx("div",{className:"feishu-integration-layout",children:l.jsxs("section",{className:"feishu-section-panel",children:[l.jsx("p",{className:"feishu-panel-description",children:"填写已发布飞书应用的凭据,Studio 将生成 basic 智能体、创建独立 Runtime,并启用飞书消息长连接。"}),l.jsxs("form",{className:"feishu-form",onSubmit:D,onKeyDown:X,noValidate:!0,children:[l.jsxs("div",{className:"feishu-field-grid",children:[l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-agent-name",children:"智能体名称"}),l.jsx("input",{id:"feishu-agent-name",value:t,maxLength:64,disabled:I,onChange:ie=>{n(ie.target.value),p&&g("")},onBlur:()=>g(i1(t.trim())??""),"aria-invalid":!!p,"aria-describedby":`feishu-agent-name-help${p?" feishu-agent-name-error":""}`}),l.jsx("span",{id:"feishu-agent-name-help",className:"feishu-field-help",children:"将作为新 Runtime 中的根智能体名称"}),p?l.jsx("span",{id:"feishu-agent-name-error",className:"feishu-field-error",role:"alert",children:p}):null]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{id:"feishu-region-label",children:"部署地域"}),l.jsxs("div",{className:"feishu-region-picker",ref:C,children:[l.jsxs("button",{ref:M,type:"button",className:"feishu-region-trigger",disabled:I,"aria-haspopup":"listbox","aria-expanded":f,"aria-labelledby":"feishu-region-label feishu-region-value",onClick:()=>{P.current=yl.findIndex(ie=>ie.value===u),h(ie=>!ie)},onKeyDown:ie=>{ie.key!=="ArrowDown"&&ie.key!=="ArrowUp"||(ie.preventDefault(),P.current=ie.key==="ArrowUp"?yl.length-1:yl.findIndex(ue=>ue.value===u),h(!0))},children:[l.jsx("span",{id:"feishu-region-value",children:Ae.label}),l.jsx(Vut,{})]}),f?l.jsx("div",{className:"feishu-region-menu",role:"listbox","aria-label":"部署地域",onKeyDown:ie=>{var Se;const ue=L.current.findIndex(Re=>Re===document.activeElement);let ye=null;ie.key==="ArrowDown"?ye=(ue+1)%yl.length:ie.key==="ArrowUp"?ye=(ue-1+yl.length)%yl.length:ie.key==="Home"?ye=0:ie.key==="End"?ye=yl.length-1:ie.key==="Tab"&&h(!1),ye!==null&&(ie.preventDefault(),(Se=L.current[ye])==null||Se.focus())},children:yl.map(ie=>l.jsx("button",{ref:ue=>{const ye=yl.findIndex(Se=>Se.value===ie.value);L.current[ye]=ue},type:"button",role:"option","aria-selected":u===ie.value,className:`feishu-region-option${u===ie.value?" is-selected":""}`,onClick:()=>{var ue;d(ie.value),h(!1),(ue=M.current)==null||ue.focus()},children:ie.label},ie.value))}):null]}),l.jsx("span",{className:"feishu-field-help",children:"Runtime 与构建产物将创建在该地域"})]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-app-id",children:"飞书 App ID"}),l.jsx("input",{id:"feishu-app-id",value:i,maxLength:128,autoComplete:"off",disabled:I,placeholder:"cli_xxxxxxxxxxxxxxxx",onChange:ie=>{r(ie.target.value),b&&y("")},onBlur:()=>y(i.trim()?"":"请输入飞书 App ID"),"aria-invalid":!!b,"aria-describedby":`feishu-app-id-help${b?" feishu-app-id-error":""}`}),l.jsx("span",{id:"feishu-app-id-help",className:"feishu-field-help",children:"来自飞书开放平台的应用凭证"}),b?l.jsx("span",{id:"feishu-app-id-error",className:"feishu-field-error",role:"alert",children:b}):null]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-app-secret",children:"飞书 App Secret"}),l.jsxs("div",{className:"feishu-secret-input",children:[l.jsx("input",{id:"feishu-app-secret",type:o?"text":"password",value:s,maxLength:256,autoComplete:"off",disabled:I,placeholder:"请输入 App Secret",onChange:ie=>{a(ie.target.value),O&&v("")},onBlur:()=>v(s.trim()?"":"请输入飞书 App Secret"),"aria-invalid":!!O,"aria-describedby":`feishu-app-secret-help${O?" feishu-app-secret-error":""}`}),l.jsx("button",{type:"button",disabled:I,onClick:()=>c(ie=>!ie),"aria-label":o?"隐藏 App Secret":"显示 App Secret",children:o?"隐藏":"显示"})]}),l.jsx("span",{id:"feishu-app-secret-help",className:"feishu-field-help",children:"仅写入新 Runtime 的环境变量"}),O?l.jsx("span",{id:"feishu-app-secret-error",className:"feishu-field-error",role:"alert",children:O}):null]})]}),x!=="idle"?l.jsxs("div",{className:`feishu-deployment-status is-${x}`,role:x==="failed"?"alert":"status",children:[l.jsxs("div",{className:"feishu-deployment-heading",children:[x==="preparing"?l.jsx(oi,{as:"strong",children:"正在生成 basic 智能体"}):null,x==="running"?l.jsx(oi,{as:"strong",children:(E==null?void 0:E.message)||"正在创建 Runtime"}):null,x==="cancelling"?l.jsx(oi,{as:"strong",children:"正在取消部署"}):null,x==="succeeded"?l.jsxs("strong",{children:[l.jsx(tH,{}),"飞书机器人 Runtime 已创建"]}):null,x==="cancelled"?l.jsx("strong",{children:"部署已取消"}):null,x==="failed"?l.jsx("strong",{children:"创建失败"}):null]}),x==="preparing"||x==="running"||x==="cancelling"?l.jsx("ol",{className:"feishu-deployment-steps",children:tpe.map((ie,ue)=>{const ye=x==="running"&&ueie.value===(A.region||u)))==null?void 0:J.label)||A.region}),A.consoleUrl?l.jsxs("a",{href:A.consoleUrl,target:"_blank",rel:"noreferrer",children:["打开 Runtime 控制台",l.jsx(Xut,{})]}):null]}):null]}):null,l.jsxs("div",{className:"feishu-form-actions",children:[l.jsxs("div",{className:"feishu-secrets-note",children:[l.jsx("strong",{children:"凭据处理"}),l.jsx("span",{children:"App Secret 仅用于本次部署,不会写入生成源码或浏览器存储。"})]}),l.jsxs("div",{className:"feishu-action-buttons",children:[x==="running"?l.jsx("button",{type:"button",className:"feishu-cancel",onClick:()=>void H(),children:"取消部署"}):null,l.jsx("button",{type:"submit",className:"feishu-submit",disabled:!fe,children:I?"正在创建…":"创建飞书机器人 Runtime"})]})]})]})]})})]})}async function bQ(e,t,n,i=_o){var s;const r=await ri(e,{...t,headers:{accept:"application/json",...t.headers},signal:n},i);if(!r.ok){let a="";try{a=((s=(await r.json()).detail)==null?void 0:s.trim())||""}catch{}throw new Error(a||`请求失败 (${r.status})`)}return r.json()}function Yut(e){return bQ("/web/coding-agents/capabilities",{method:"GET"},e,DD)}function Gut(e,t){return bQ(`/web/coding-agents/skills/${encodeURIComponent(e)}/preview`,{method:"GET"},t)}function Wut(e,t){return bQ("/web/coding-agents/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},t)}const Zut="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='16'%20height='16'%20rx='3.692'%20fill='%231A1B1D'/%3e%3cpath%20d='M13.235%205.829V4.332H2.758v5.987h1.496v1.496h8.981V5.828Zm-1.497%204.49H4.254V5.83h7.484v4.49Z'%20fill='%2332F08C'/%3e%3cpath%20d='M6.937%206.993%205.88%208.051%206.937%209.11%207.995%208.05%206.937%206.993ZM9.931%206.992%208.873%208.05%209.931%209.11%2010.99%208.05%209.93%206.992Z'%20fill='%2332F08C'/%3e%3c/svg%3e";function Kut(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m4 4 8 8m0-8-8 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function nH(){return l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[l.jsx("path",{d:"M4 1.8h5l3 3V14H4z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),l.jsx("path",{d:"M9 1.8V5h3M6 8h4M6 10.5h4",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}function iH(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M1.8 4.5h4l1.2-1.3h2.2l1.2 1.3h3.8v8H1.8z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function Jut(e){return e instanceof DOMException&&e.name==="AbortError"}function edt(e){return e instanceof Error&&e.message?e.message:"读取 Skill 文件失败"}function tdt(e){return e<1024?`${e} B`:`${(e/1024).toFixed(e<10*1024?1:0)} KB`}function ndt(e){const t=e.split("/");return t[t.length-1]??e}function idt(e){const t=new Map;for(const n of e){const i=n.path.split("/"),r=i.length>1?i.slice(0,-1).join("/"):"";t.set(r,[...t.get(r)??[],n])}return Array.from(t,([n,i])=>({directory:n,files:i})).sort((n,i)=>n.directory?i.directory?n.directory.localeCompare(i.directory):1:-1)}function rdt({skill:e,onClose:t}){const n=m.useRef(null),i=m.useRef(null),r=m.useId(),s=m.useId(),[a,o]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(!0),[h,p]=m.useState(""),[g,b]=m.useState(0);m.useEffect(()=>{i.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const v=n.current;return v&&!v.open&&v.showModal(),()=>{var x;v!=null&&v.open&&v.close(),(x=i.current)==null||x.focus()}},[]),m.useEffect(()=>{const v=new AbortController;return f(!0),p(""),o(null),u(""),Gut(e.id,v.signal).then(x=>{if(v.signal.aborted)return;o(x);const w=x.files.find(E=>E.path==="SKILL.md")??x.files[0];u((w==null?void 0:w.path)??"")}).catch(x=>{!v.signal.aborted&&!Jut(x)&&p(edt(x))}).finally(()=>{v.signal.aborted||f(!1)}),()=>v.abort()},[g,e.id]);const y=m.useMemo(()=>idt((a==null?void 0:a.files)??[]),[a]),O=(a==null?void 0:a.files.find(v=>v.path===c))??null;return l.jsxs("dialog",{ref:n,className:"coding-agents-preview-dialog","aria-labelledby":r,"aria-describedby":s,onCancel:v=>{v.preventDefault(),t()},onMouseDown:v=>{const x=v.currentTarget.getBoundingClientRect();(v.clientXx.right||v.clientYx.bottom)&&t()},children:[l.jsxs("header",{className:"coding-agents-preview-header",children:[l.jsx("span",{className:"coding-agents-preview-mark",children:l.jsx(iH,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:r,children:e.name}),l.jsx("p",{id:s,children:"只读浏览随 Studio 提供的 Skill 文件"})]}),l.jsx("button",{type:"button",autoFocus:!0,"aria-label":"关闭文件预览",onClick:t,children:l.jsx(Kut,{})})]}),d?l.jsxs("div",{className:"coding-agents-preview-state",children:[l.jsx("i",{}),"正在读取文件…"]}):h?l.jsxs("div",{className:"coding-agents-preview-state is-error",role:"alert",children:[l.jsx("span",{children:h}),l.jsx("button",{type:"button",onClick:()=>b(v=>v+1),children:"重试"})]}):l.jsxs("div",{className:"coding-agents-preview-layout",children:[l.jsxs("nav",{className:"coding-agents-preview-tree","aria-label":`${e.name} 文件`,children:[l.jsxs("div",{className:"coding-agents-preview-tree-title",children:[l.jsx("span",{children:"文件"}),l.jsx("small",{children:(a==null?void 0:a.files.length)??0})]}),l.jsx("div",{className:"coding-agents-preview-tree-scroll",children:y.map(v=>v.directory?l.jsxs("details",{open:!0,children:[l.jsxs("summary",{children:[l.jsx(iH,{}),l.jsx("span",{children:v.directory})]}),l.jsx("div",{children:v.files.map(x=>l.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[l.jsx(nH,{}),l.jsx("span",{children:ndt(x.path)})]},x.path))})]},v.directory):v.files.map(x=>l.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[l.jsx(nH,{}),l.jsx("span",{children:x.path})]},x.path)))})]}),l.jsx("section",{className:"coding-agents-preview-file","aria-label":"文件内容",children:O?l.jsxs(l.Fragment,{children:[l.jsxs("header",{children:[l.jsx("strong",{children:O.path}),l.jsx("span",{children:tdt(O.size)})]}),O.previewable&&O.content!==null?l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:O.content})}):l.jsx("div",{className:"coding-agents-preview-unavailable",children:"此文件不是可预览的 UTF-8 文本。"})]}):l.jsx("div",{className:"coding-agents-preview-unavailable",children:"没有可预览的文件。"})})]})]})}function sdt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function adt(e){return l.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"16",height:"16",rx:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("path",{d:"m8.5 11-2.4 2.4 2.4 2.4M11 16.5h3.8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("circle",{cx:"24.5",cy:"10.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("circle",{cx:"24.5",cy:"24.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("path",{d:"M19.5 10.5H22M18.2 19l4.3 3.7M24.5 13v9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function odt(e){return l.jsx("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:l.jsxs("g",{stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",children:[l.jsx("path",{d:"M16 4.5v7M16 20.5v7"}),l.jsx("path",{d:"m9.3 6.3 3.5 6.1M19.2 19.6l3.5 6.1"}),l.jsx("path",{d:"m5.9 11.1 6.2 3.5M19.9 17.4l6.2 3.5"}),l.jsx("path",{d:"M4.7 16h7M20.3 16h7"}),l.jsx("path",{d:"m5.9 20.9 6.2-3.5M19.9 14.6l6.2-3.5"}),l.jsx("path",{d:"m9.3 25.7 3.5-6.1M19.2 12.4l3.5-6.1"})]})})}function ldt(e){return l.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M15.8 4.2c2.4 0 4.5 1.2 5.7 3.1 2.2-.3 4.5.8 5.6 2.9 1.1 2 .8 4.4-.5 6.1 1.2 1.8 1.3 4.3.1 6.2-1.2 2-3.4 3-5.6 2.6-1.3 1.8-3.5 2.9-5.8 2.7-2.2-.2-4.1-1.5-5.1-3.4-2.2.1-4.4-1-5.4-3.1-1-2-.6-4.4.8-6.1-1.1-1.9-1.1-4.3.2-6.1 1.3-1.9 3.6-2.7 5.7-2.2 1.1-1.7 2.6-2.7 4.3-2.7Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),l.jsx("path",{d:"m10.7 12.2 3.1 3.8-3.1 3.8M17.1 20h4.3",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function rH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.4 8.2 3 3L12.8 5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function cdt(e){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M2.8 6.3h14.4v8.3a1.6 1.6 0 0 1-1.6 1.6H4.4a1.6 1.6 0 0 1-1.6-1.6V6.3Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),l.jsx("path",{d:"M2.8 6.3V5.1a1.4 1.4 0 0 1 1.4-1.4h3.4l1.5 1.6h6.5a1.6 1.6 0 0 1 1.6 1.6",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})]})}function udt({agentId:e}){return e==="trae"?l.jsx("img",{src:Zut,alt:"","aria-hidden":"true"}):e==="claude-code"?l.jsx(odt,{}):l.jsx(ldt,{})}function sH(e){return e instanceof DOMException&&e.name==="AbortError"}function aH(e,t){return e instanceof Error&&e.message?e.message:t}function ddt({onBack:e}){var N;const[t,n]=m.useState(null),[i,r]=m.useState(!0),[s,a]=m.useState(""),[o,c]=m.useState(0),[u,d]=m.useState(new Set),[f,h]=m.useState(new Set),[p,g]=m.useState(null),[b,y]=m.useState(!1),[O,v]=m.useState(null),x=m.useRef(null);m.useEffect(()=>{const C=new AbortController;return r(!0),a(""),Yut(C.signal).then(M=>{if(C.signal.aborted)return;n(M);const L=M.agents.filter(P=>P.available);d(P=>{const Q=L.filter(j=>P.has(j.id));return new Set((Q.length?Q:L.slice(0,1)).map(j=>j.id))}),h(P=>{const Q=M.skills.filter(j=>P.has(j.id));return new Set((Q.length?Q:M.skills).map(j=>j.id))})}).catch(M=>{!sH(M)&&!C.signal.aborted&&(n(null),a(aH(M,"检测本机客户端失败")))}).finally(()=>{C.signal.aborted||r(!1)}),()=>C.abort()},[o]),m.useEffect(()=>()=>{var C;return(C=x.current)==null?void 0:C.abort()},[]);const w=m.useMemo(()=>(t==null?void 0:t.agents.filter(C=>C.available&&u.has(C.id)))||[],[t,u]),E=m.useMemo(()=>(t==null?void 0:t.skills.filter(C=>f.has(C.id)))||[],[t,f]),S=!!(!b&&w.length&&E.length),k=(C,M)=>{!M||b||(v(null),d(L=>{const P=new Set(L);return P.has(C)?P.delete(C):P.add(C),P}))},T=C=>{b||(v(null),h(M=>{const L=new Set(M);return L.has(C)?L.delete(C):L.add(C),L}))},A=async()=>{var M;if(!S)return;(M=x.current)==null||M.abort();const C=new AbortController;x.current=C,y(!0),v(null);try{const L=await Wut({agents:w.map(Q=>Q.id),skills:E.map(Q=>Q.id)},C.signal);if(C.signal.aborted)return;const P=L.installations;v({tone:"success",message:`已为 ${w.length} 个客户端配置 ${E.length} 个 Skill`,details:P.map(Q=>`${Q.agentName} · ${Q.skill} → ${Q.displayPath}`)})}catch(L){!sH(L)&&!C.signal.aborted&&v({tone:"error",message:aH(L,"配置失败,请检查用户目录权限后重试")})}finally{x.current===C&&(x.current=null),C.signal.aborted||y(!1)}};return l.jsxs("section",{className:"coding-agents-page",children:[l.jsxs("header",{className:"coding-agents-header",children:[l.jsx("button",{type:"button",className:"coding-agents-back",onClick:e,disabled:b,"aria-label":"返回自动化列表",children:l.jsx(sdt,{})}),l.jsx(adt,{className:"coding-agents-logo"}),l.jsxs("div",{children:[l.jsx("h1",{children:"配置 Coding Agents"}),l.jsx("p",{children:"把随 Studio 提供的 AgentKit Skills 全局安装到本地编码客户端。"})]})]}),l.jsx("div",{className:"coding-agents-scroll",children:l.jsxs("div",{className:"coding-agents-content",children:[l.jsxs("section",{className:"coding-agents-section","aria-label":"选择 Coding Agent",children:[l.jsxs("div",{className:"coding-agents-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"1"}),l.jsx("h2",{children:"本机客户端"})]}),l.jsx("button",{type:"button",onClick:()=>c(C=>C+1),disabled:i||b,children:"重新检测"})]}),i?l.jsxs("div",{className:"coding-agents-inline-state",children:[l.jsx("i",{}),"正在检测本机客户端…"]}):s?l.jsxs("div",{className:"coding-agents-error-row",role:"alert",children:[l.jsx("span",{children:s}),l.jsx("button",{type:"button",onClick:()=>c(C=>C+1),children:"重试"})]}):l.jsx("div",{className:"coding-agents-agent-grid",children:t==null?void 0:t.agents.map(C=>l.jsxs("button",{type:"button",className:`coding-agents-agent ${u.has(C.id)?"is-selected":""}`,"aria-pressed":u.has(C.id),disabled:!C.available||b,onClick:()=>k(C.id,C.available),title:C.available?C.name:C.reason,children:[l.jsx("span",{className:`coding-agents-agent-mark is-${C.id}`,children:l.jsx(udt,{agentId:C.id})}),l.jsxs("span",{className:"coding-agents-agent-copy",children:[l.jsx("strong",{children:C.name}),l.jsx("small",{children:C.available?C.version||"已检测到客户端":C.reason})]}),l.jsx("span",{className:`coding-agents-status ${C.available?"is-ready":""}`,children:C.available?"可用":"未检测到"}),l.jsx("span",{className:"coding-agents-check",children:l.jsx(rH,{})})]},C.id))})]}),l.jsxs("section",{className:"coding-agents-section","aria-label":"选择内置 Skill",children:[l.jsx("div",{className:"coding-agents-section-heading",children:l.jsxs("div",{children:[l.jsx("span",{children:"2"}),l.jsx("h2",{children:"内置 Skills"})]})}),l.jsx("div",{className:"coding-agents-skill-list",children:t==null?void 0:t.skills.map(C=>l.jsxs("div",{className:`coding-agents-skill ${f.has(C.id)?"is-selected":""}`,children:[l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:f.has(C.id),onChange:()=>T(C.id),disabled:b}),l.jsx("span",{className:"coding-agents-skill-check","aria-hidden":"true",children:l.jsx(rH,{})}),l.jsxs("span",{children:[l.jsx("strong",{children:C.name}),l.jsx("small",{children:C.description})]})]}),l.jsx("button",{type:"button",onClick:()=>g(C),children:"查看文件"})]},C.id))}),l.jsxs("div",{className:"coding-agents-global","aria-label":"全局安装目录",children:[l.jsxs("div",{className:"coding-agents-global-heading",children:[l.jsx(cdt,{}),l.jsxs("div",{children:[l.jsx("strong",{children:"全局安装"}),l.jsx("span",{children:"配置后可在本机其他项目中使用"})]})]}),w.length?l.jsx("dl",{children:w.map(C=>l.jsxs("div",{children:[l.jsx("dt",{children:C.name}),l.jsx("dd",{children:C.globalSkillsPath})]},C.id))}):l.jsx("p",{children:"选择客户端后显示对应安装目录。"})]})]}),O?l.jsxs("div",{className:`coding-agents-result is-${O.tone}`,role:O.tone==="error"?"alert":"status",children:[l.jsx("strong",{children:O.message}),(N=O.details)!=null&&N.length?l.jsx("ul",{children:O.details.map(C=>l.jsx("li",{children:C},C))}):null]}):null,l.jsxs("div",{className:"coding-agents-actions",children:[l.jsx("span",{children:w.length?`已选择 ${w.length} 个客户端、${E.length} 个 Skill`:"请先选择客户端"}),l.jsx("button",{type:"button",onClick:()=>void A(),disabled:!S,children:b?"正在配置…":"配置"})]})]})}),p?l.jsx(rdt,{skill:p,onClose:()=>g(null)}):null]})}function oH(e){return e.replace(/\s+/g," ").trim()}function fdt(e,t){const n=oH(e)||"AgentKit Studio";if(t.kind==="home")return n;const i=oH(t.title);return i?t.kind==="conversation"?i:`${n} - ${i}`:n}const hdt="/web/video",pdt=18e4;async function bb(e,t={},n=_o){return fetch(vo(`${hdt}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function npe(e,t){const n=await e.text().catch(()=>"");let i="";try{const r=JSON.parse(n),s=r.detail??r.error;i=typeof s=="string"?s:""}catch{i=n.trim().slice(0,500)}return new Error(i||`${t}(HTTP ${e.status})`)}async function av(e,t){if(!e.ok)throw await npe(e,t);const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{const i=e.headers.get("content-type")||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(${i})`)}}async function mdt(e){return av(await bb("/capabilities",{signal:e,headers:{Accept:"application/json"}}),"加载视频模型能力失败")}async function gdt(e,t,n){const i=new FormData;return i.set("file",e),i.set("role",t),av(await bb("/assets",{method:"POST",body:i,signal:n},kr),`上传${e.name}失败`)}async function bdt(e,t){return av(await bb("/prompts/enhance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t},pdt),"提示词优化失败")}async function Odt(e,t){return av(await bb("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t},kr),"创建视频生成任务失败")}async function ydt(e,t){return av(await bb(`/tasks/${encodeURIComponent(e)}`,{signal:t,headers:{Accept:"application/json"}}),"查询视频生成任务失败")}async function xdt(e,t){const n=await bb(`/tasks/${encodeURIComponent(e)}/download`,{signal:t,headers:{Accept:"video/*"}},kr);if(!n.ok)throw await npe(n,"下载生成视频失败");return n.blob()}function vdt(e){return e.startsWith("/")?vo(e):e}function OQ(e){return e.isComposing||e.keyCode===229}function wdt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 11.5 5.5-5.5 5.5 5.5M12 6v12"})})}function Sdt(e){return l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...e,children:l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.75",fill:"currentColor"})})}const El=[{value:"agent",label:"Agent",description:"与当前选择的 Agent 对话"},{value:"temporary",label:"内置智能体",description:"使用平台提供的智能体"}],lH=[{label:"Codex 智能体",kind:"codex",value:"temporary",description:"在沙箱中执行任务"},{label:"DeepSeek Harness",kind:"deepseek-harness",value:"deepseek-harness",description:"打开 DeepSeek Harness 工作区"}],Edt=[{label:"ArkClaw",kind:"openclaw"},{label:"Hermes 智能体",kind:"hermes"}];function cH({mode:e}){return e==="temporary"?l.jsxs("svg",{className:"new-chat-mode__temporary-icon",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"m10 2.8 6.1 3.45v7.5L10 17.2l-6.1-3.45v-7.5L10 2.8Z"}),l.jsx("path",{d:"m3.9 6.25 6.1 3.5 6.1-3.5M10 9.75v7.45"})]}):l.jsx(Pf,{className:"new-chat-mode__agent-icon"})}function kdt(){return l.jsx("svg",{className:"new-chat-mode__nested-chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m4.5 3 3 3-3 3"})})}function uH(e){const t=El.findIndex(n=>n.value===e);return t>=0?t:El.findIndex(n=>n.value==="temporary")}function Tdt({value:e,onChange:t,disabled:n=!1,temporaryEnabled:i,deepseekHarnessEnabled:r}){const[s,a]=m.useState(!1),[o,c]=m.useState(!1),[u,d]=m.useState(()=>uH(e)),f=m.useRef(null),h=m.useRef(null),p=e==="agent"?El[0]:El[1],g=lH.find(k=>k.value===e),b=(g==null?void 0:g.label)??p.label;function y(k){return k.value==="temporary"?i===!0||r===!0?!0:i===!1&&r===!1?!1:void 0:!0}function O(k){return k==="temporary"?i:k==="deepseek-harness"?r:!1}function v(k){return y(k)!==!0}function x(k){const T=y(k);return T===void 0?"正在检查配置":T?k.description:"管理员未配置"}m.useEffect(()=>{if(!s)return;const k=T=>{var A;(A=f.current)!=null&&A.contains(T.target)||(a(!1),c(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[s]);function w(k){let T=u;do T=(T+k+El.length)%El.length;while(v(El[T]));d(T),c(El[T].value==="temporary")}function E(k){var T;if(!v(k)){if(k.value==="temporary"){c(!0);return}t(k.value),a(!1),c(!1),(T=h.current)==null||T.focus()}}function S(k){O(k)===!0&&(t(k),a(!1),c(!1))}return l.jsxs("div",{className:"new-chat-mode",ref:f,children:[l.jsxs("button",{ref:h,type:"button",className:"new-chat-mode__trigger","aria-label":"选择新会话模式","aria-haspopup":"listbox","aria-expanded":s,disabled:n,onClick:()=>{d(uH(e)),a(k=>(k&&c(!1),!k))},onKeyDown:k=>{k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),s?w(k.key==="ArrowDown"?1:-1):a(!0)):s&&(k.key==="Enter"||k.key===" ")?(k.preventDefault(),E(El[u])):s&&k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1))},children:[l.jsx("span",{className:"new-chat-mode__icon",children:l.jsx(cH,{mode:p.value})}),l.jsx("span",{className:"new-chat-mode__current",title:b,children:b}),l.jsx("svg",{className:"new-chat-mode__chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m3 4.5 3 3 3-3"})})]}),s?l.jsxs("div",{className:"new-chat-mode__menus",children:[l.jsx("div",{className:"new-chat-mode__menu",role:"listbox","aria-label":"新会话模式",tabIndex:-1,onKeyDown:k=>{var T;k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),w(k.key==="ArrowDown"?1:-1)):k.key==="Enter"?(k.preventDefault(),E(El[u])):k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1),(T=h.current)==null||T.focus())},children:El.map((k,T)=>{const A=k.value==="temporary";return l.jsxs("button",{type:"button",role:"option","aria-selected":p.value===k.value,"aria-haspopup":A?"menu":void 0,"aria-expanded":A?o:void 0,"aria-disabled":v(k),disabled:v(k),className:`new-chat-mode__option${T===u?" is-active":""}`,onMouseEnter:()=>{d(T),c(k.value==="temporary")},onClick:()=>E(k),children:[l.jsx("span",{className:"new-chat-mode__option-icon",children:l.jsx(cH,{mode:k.value})}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k.label}),l.jsx("span",{children:x(k)})]}),A?l.jsx(kdt,{}):e===k.value?l.jsx("svg",{className:"new-chat-mode__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})}):null]},k.value)})}),o?l.jsxs("div",{className:"new-chat-mode__submenu",role:"menu","aria-label":"内置智能体",children:[lH.map(k=>{const T=O(k.value);return l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",disabled:T!==!0,onClick:()=>S(k.value),children:[l.jsx(t1,{kind:k.kind,className:"new-chat-mode__builtin-icon"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k.label}),l.jsx("span",{children:T===void 0?"正在检查配置":T?k.description:"管理员未配置"})]})]},k.value)}),Edt.map(({label:k,kind:T})=>l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",disabled:!0,children:[l.jsx(t1,{kind:T,className:"new-chat-mode__builtin-icon"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k}),l.jsx("span",{children:"暂不可用"})]})]},k))]}):null]}):null]})}const mm=[{id:"general",label:"通用智能体"},{id:"codex",label:"Codex 智能体"},{id:"deepseek-harness",label:"DeepSeek Harness"},{id:"openclaw",label:"OpenClaw 智能体"},{id:"hermes",label:"Hermes 智能体"}],_dt=15,Adt=15e3,Ndt=120,Cdt=180;function dH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5.75 3.75 4.25 4.25-4.25 4.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function jdt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function aR({type:e,className:t="new-chat-agent-picker__type-icon"}){return e==="general"?l.jsx(Pf,{className:t}):l.jsx(t1,{kind:e,className:t})}function Rdt({selectedAgentName:e="",selectedRuntimeId:t="",runtimeScope:n,disabled:i=!1,onSelectRuntime:r,onSelectSandboxSession:s}){var me;const[a,o]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.useState(0),[h,p]=m.useState(0),[g,b]=m.useState("types"),[y,O]=m.useState(!1),[v,x]=m.useState([]),[w,E]=m.useState([]),[S,k]=m.useState(null),[T,A]=m.useState(""),[N,C]=m.useState(!1),[M,L]=m.useState(""),[P,Q]=m.useState(""),j=m.useRef(null),$=m.useRef(null),U=m.useRef(null),B=m.useRef(0),I=m.useRef(null),X=m.useRef(null),q=m.useRef(null),D=((me=mm.find(oe=>oe.id===c))==null?void 0:me.label)??"智能体",H=m.useCallback((oe=!1)=>{var Ne;X.current!==null&&(window.clearTimeout(X.current),X.current=null),q.current!==null&&(window.clearTimeout(q.current),q.current=null),o(!1),u(null),b("types"),O(!1),oe&&((Ne=$.current)==null||Ne.focus())},[]),re=m.useCallback(async(oe="",Ne=!1)=>{const Oe=++B.current;let Ve;C(!0),L("");try{const We=await Promise.race([S_({scope:n,region:"all",pageSize:_dt,nextToken:oe}),new Promise((De,mt)=>{Ve=window.setTimeout(()=>{mt(new Error("加载智能体超时(15 秒),请检查网络或 Runtime 服务后重试"))},Adt)})]);if(B.current!==Oe)return;x(De=>{const mt=Ne?We.runtimes:[...De,...We.runtimes];return mt.filter((at,Rt)=>mt.findIndex(qe=>qe.runtimeId===at.runtimeId)===Rt)}),A(We.nextToken),p(0)}catch(We){if(B.current!==Oe)return;L(cg(We,"加载通用智能体","GET /web/runtimes"))}finally{window.clearTimeout(Ve),B.current===Oe&&C(!1)}},[n]),fe=m.useCallback(async oe=>{var Ve,We;(Ve=I.current)==null||Ve.abort();const Ne=new AbortController;I.current=Ne;const Oe=++B.current;C(!0),L(""),E([]);try{const De=oe==="codex"?await Kt.listSessions({signal:Ne.signal}):await Kt.listAgentSessions(oe,{signal:Ne.signal});if(B.current!==Oe)return;E(De),k(oe),p(0)}catch(De){if((De==null?void 0:De.name)==="AbortError"||B.current!==Oe)return;L(cg(De,`加载 ${((We=mm.find(mt=>mt.id===oe))==null?void 0:We.label)??oe}`,`GET /web/${oe==="codex"?"sandbox":oe}/sessions`)),k(oe)}finally{I.current===Ne&&(I.current=null),B.current===Oe&&C(!1)}},[]);m.useEffect(()=>{!a||c!=="general"||v.length>0||N||M||re("",!0)},[c,M,re,N,a,v.length]),m.useEffect(()=>{!a||c===null||c==="general"||S===c||fe(c)},[c,fe,S,a]),m.useEffect(()=>{if(!a)return;const oe=Ne=>{var Oe;(Oe=j.current)!=null&&Oe.contains(Ne.target)||H()};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[H,a]),m.useEffect(()=>()=>{var oe;B.current+=1,(oe=I.current)==null||oe.abort(),X.current!==null&&window.clearTimeout(X.current),q.current!==null&&window.clearTimeout(q.current)},[]);function Ae(oe,Ne=!1){X.current!==null&&(window.clearTimeout(X.current),X.current=null),q.current!==null&&(window.clearTimeout(q.current),q.current=null),o(!0),u(Ne?"general":null),f(0),b("types"),O(Ne),oe&&requestAnimationFrame(()=>{var Oe;return(Oe=U.current)==null?void 0:Oe.focus()})}function J(){i||a||X.current!==null||(X.current=window.setTimeout(()=>{X.current=null,Ae(!1)},Ndt))}function ie(){q.current!==null&&(window.clearTimeout(q.current),q.current=null)}function ue(){X.current!==null&&(window.clearTimeout(X.current),X.current=null),!(!a||q.current!==null)&&(q.current=window.setTimeout(()=>{q.current=null,H()},Cdt))}function ye(oe){var Ve;const Ne=(oe+mm.length)%mm.length,Oe=mm[Ne].id;Oe!==c&&(B.current+=1,(Ve=I.current)==null||Ve.abort(),I.current=null,C(!1),L("")),f(Ne),u(Oe),p(0)}async function Se(oe){if(!P){Q(oe.runtimeId),L("");try{await r(oe),H(!0)}catch(Ne){L(cg(Ne,"连接通用智能体"))}finally{Q("")}}}async function Re(oe){if(!P){Q(oe.id),L("");try{await s(oe),H(!0)}catch(Ne){L(cg(Ne,`打开 ${D}`))}finally{Q("")}}}function Ee(oe){if(oe.key==="Escape"){oe.preventDefault(),H(!0);return}if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft","Enter"].includes(oe.key)&&O(!0),g==="types"){oe.key==="ArrowDown"||oe.key==="ArrowUp"?(oe.preventDefault(),ye(d+(oe.key==="ArrowDown"?1:-1))):(oe.key==="ArrowRight"||oe.key==="Enter")&&(oe.preventDefault(),c===null&&ye(d),b("runtimes"));return}if(oe.key==="ArrowLeft")oe.preventDefault(),b("types");else if((c==="general"?v:w).length>0&&(oe.key==="ArrowDown"||oe.key==="ArrowUp")){oe.preventDefault();const Ne=oe.key==="ArrowDown"?1:-1,Oe=c==="general"?v.length:w.length;p(Ve=>(Ve+Ne+Oe)%Oe)}else oe.key==="Enter"&&c==="general"&&v[h]?(oe.preventDefault(),Se(v[h])):oe.key==="Enter"&&c!=="general"&&w[h]&&(oe.preventDefault(),Re(w[h]))}return l.jsxs("div",{className:"new-chat-agent-picker",ref:j,onPointerEnter:oe=>{oe.pointerType==="mouse"&&ie()},onPointerLeave:oe=>{oe.pointerType==="mouse"&&ue()},children:[l.jsxs("button",{ref:$,type:"button",className:"new-chat-agent-picker__trigger","aria-label":"选择智能体","aria-haspopup":"menu","aria-expanded":a,disabled:i,onPointerEnter:oe=>{oe.pointerType==="mouse"&&J()},onClick:()=>a?H():Ae(!0),onKeyDown:oe=>{oe.key==="ArrowDown"||oe.key==="ArrowUp"?(oe.preventDefault(),a||Ae(!0,!0)):oe.key==="Escape"&&a&&(oe.preventDefault(),H(!0))},children:[l.jsx("span",{title:e||"选择智能体",children:e||"选择智能体"}),l.jsx(dH,{className:"new-chat-agent-picker__trigger-chevron"})]}),a?l.jsxs("div",{ref:U,className:"new-chat-agent-picker__menus",tabIndex:-1,onKeyDown:Ee,onPointerMove:oe=>{oe.pointerType==="mouse"&&O(!1)},children:[l.jsx("div",{className:"new-chat-agent-picker__menu",role:"menu","aria-label":"智能体类型",children:mm.map((oe,Ne)=>l.jsxs("button",{type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":c===oe.id,className:`new-chat-agent-picker__type${y&&g==="types"&&d===Ne?" is-keyboard-active":""}`,onMouseEnter:()=>ye(Ne),onClick:()=>{ye(Ne),b("runtimes")},children:[l.jsx(aR,{type:oe.id}),l.jsx("span",{children:oe.label}),l.jsx(dH,{className:"new-chat-agent-picker__nested-chevron"})]},oe.id))}),c!==null?l.jsx("div",{className:"new-chat-agent-picker__submenu",role:"listbox","aria-label":`${D}列表`,children:c!=="general"&&N&&w.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner","aria-hidden":"true"}),"正在加载智能体"]}):c!=="general"&&M&&w.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:M}),l.jsx("button",{type:"button",onClick:()=>void fe(c),children:"重新加载"})]}):c!=="general"&&w.length===0?l.jsxs(Oi,{className:"new-chat-agent-picker__empty",fill:"none",children:[l.jsx(Oi.Icon,{size:"sm",children:l.jsx(aR,{type:c,className:"new-chat-agent-picker__empty-agent-icon"})}),l.jsx(Oi.Title,{children:l.jsxs("span",{className:"new-chat-agent-picker__empty-title",children:["暂无 ",D]})}),l.jsx(Oi.Description,{children:"请前往智能体页创建"})]}):c!=="general"?l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:w.map((oe,Ne)=>{const Oe=P===oe.id,Ve=oe.resourceType==="snapshot";return l.jsxs("button",{type:"button",role:"option","aria-selected":!1,"aria-busy":Oe||void 0,className:`new-chat-agent-picker__runtime${y&&g==="runtimes"&&h===Ne?" is-keyboard-active":""}`,disabled:!!P,title:`${oe.displayName||D} · ${oe.id}`,onMouseEnter:()=>p(Ne),onClick:()=>void Re(oe),children:[l.jsx(aR,{type:c,className:"new-chat-agent-picker__runtime-icon"}),l.jsx("span",{children:oe.displayName||D}),l.jsx("small",{children:Oe?Ve?"正在唤醒":"正在打开":YA(oe.status)})]},oe.id)})}):N&&v.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner","aria-hidden":"true"}),"正在加载智能体"]}):M&&v.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:M}),l.jsx("button",{type:"button",onClick:()=>void re("",!0),children:"重新加载"})]}):v.length===0?l.jsxs(Oi,{className:"new-chat-agent-picker__empty",fill:"none",children:[l.jsx(Oi.Icon,{size:"sm",children:l.jsx(Pf,{})}),l.jsx(Oi.Title,{children:l.jsx("span",{className:"new-chat-agent-picker__empty-title",children:"暂无通用智能体"})}),l.jsx(Oi.Description,{children:"请前往智能体页创建"})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:v.map((oe,Ne)=>{const Oe=P===oe.runtimeId,Ve=oe.runtimeId===t;return l.jsxs("button",{type:"button",role:"option","aria-selected":Ve,"aria-busy":Oe||void 0,className:`new-chat-agent-picker__runtime${y&&g==="runtimes"&&h===Ne?" is-keyboard-active":""}`,disabled:!!P,title:oe.name,onMouseEnter:()=>p(Ne),onClick:()=>void Se(oe),children:[l.jsx(Pf,{className:"new-chat-agent-picker__runtime-icon"}),l.jsx("span",{children:oe.name}),Oe?l.jsx("small",{children:"正在连接"}):Ve?l.jsx(jdt,{className:"new-chat-agent-picker__check"}):null]},oe.runtimeId)})}),M?l.jsx("div",{className:"new-chat-agent-picker__inline-error",role:"alert",children:M}):null,T?l.jsx("button",{type:"button",className:"new-chat-agent-picker__load-more",disabled:N||!!P,onClick:()=>void re(T),children:N?"加载中":"加载更多"}):null]})}):null]}):null]})}const Idt=120,Pdt=180;function Mdt(){return l.jsx("svg",{className:"new-chat-compact-select__chevron",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m4.75 6.25 3.25 3.5 3.25-3.5"})})}function Ldt(){return l.jsx("svg",{className:"new-chat-compact-select__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5"})})}function Cp({label:e,hideLabel:t=!1,value:n,options:i,onChange:r,placeholder:s,loading:a=!1,error:o="",disabled:c=!1,searchable:u=!1,onRetry:d}){const[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState(0),O=m.useRef(null),v=m.useRef(null),x=m.useRef(null),w=m.useRef(!1),E=m.useRef(null),S=m.useRef(null),k=i.find(B=>B.value===n),T=p.trim().toLocaleLowerCase(),A=m.useMemo(()=>T?i.filter(B=>`${B.label} ${B.description||""}`.toLocaleLowerCase().includes(T)):i,[T,i]),N=m.useCallback((B=!1)=>{var I;E.current!==null&&(window.clearTimeout(E.current),E.current=null),S.current!==null&&(window.clearTimeout(S.current),S.current=null),w.current=!1,h(!1),g(""),B&&((I=v.current)==null||I.focus())},[]);m.useEffect(()=>{if(!f)return;const B=I=>{var X;(X=O.current)!=null&&X.contains(I.target)||N()};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[N,f]),m.useEffect(()=>{!f||!u||!w.current||(w.current=!1,requestAnimationFrame(()=>{var B;return(B=x.current)==null?void 0:B.focus()}))},[f,u]),m.useEffect(()=>()=>{E.current!==null&&window.clearTimeout(E.current),S.current!==null&&window.clearTimeout(S.current)},[]);function C(B){E.current!==null&&(window.clearTimeout(E.current),E.current=null),S.current!==null&&(window.clearTimeout(S.current),S.current=null),w.current=B,g(""),y(Math.max(0,i.findIndex(I=>I.value===n))),h(!0)}function M(){c||f||E.current!==null||(E.current=window.setTimeout(()=>{E.current=null,C(!1)},Idt))}function L(){S.current!==null&&(window.clearTimeout(S.current),S.current=null)}function P(){E.current!==null&&(window.clearTimeout(E.current),E.current=null),!(!f||S.current!==null)&&(S.current=window.setTimeout(()=>{S.current=null,N()},Pdt))}function Q(B){const I=A[B];I&&(r(I.value),N(!0))}function j(B){if(B.key==="Escape"&&f){B.preventDefault(),N(!0);return}if(B.key==="Home"&&f&&A.length>0){B.preventDefault(),y(0);return}if(B.key==="End"&&f&&A.length>0){B.preventDefault(),y(A.length-1);return}if(B.key!=="ArrowDown"&&B.key!=="ArrowUp"){f&&B.key==="Enter"&&A[b]&&(B.preventDefault(),Q(b));return}if(B.preventDefault(),!f){C(!0);return}const I=B.key==="ArrowDown"?1:-1;y(X=>(X+I+A.length)%Math.max(1,A.length))}const $=a&&i.length===0,U=$?"加载中…":(k==null?void 0:k.label)||s;return l.jsxs("div",{className:"new-chat-compact-select",ref:O,onKeyDown:j,onPointerEnter:B=>{B.pointerType==="mouse"&&L()},onPointerLeave:B=>{B.pointerType==="mouse"&&P()},children:[l.jsxs("button",{ref:v,type:"button",className:"new-chat-compact-select__trigger","aria-label":`${e}:${U}`,"aria-haspopup":"listbox","aria-expanded":f,disabled:c,onPointerEnter:B=>{B.pointerType==="mouse"&&M()},onClick:()=>f?N():C(!0),children:[t?null:l.jsx("span",{className:"new-chat-compact-select__label",children:e}),$?l.jsx("span",{className:"new-chat-compact-select__spinner","aria-hidden":"true"}):l.jsx("span",{className:`new-chat-compact-select__value${k?"":" is-placeholder"}`,children:U}),$?null:l.jsx(Mdt,{})]}),f?l.jsxs("div",{className:"new-chat-compact-select__menu",children:[u&&i.length>0?l.jsxs("label",{className:"new-chat-compact-select__search",children:[l.jsxs("span",{className:"sr-only",children:["搜索",e]}),l.jsx("input",{ref:x,value:p,placeholder:`搜索${e}`,onChange:B=>{g(B.currentTarget.value),y(0)}})]}):null,l.jsx("div",{className:"new-chat-compact-select__list",role:"listbox","aria-label":e,children:a&&i.length===0?l.jsx("div",{className:"new-chat-compact-select__status",role:"status",children:"正在加载…"}):o?l.jsxs("div",{className:"new-chat-compact-select__status is-error",role:"alert",children:[l.jsx("span",{children:o}),d?l.jsx("button",{type:"button",onClick:d,children:"重试"}):null]}):A.length===0?l.jsx("div",{className:"new-chat-compact-select__status",children:p?"没有匹配项":"暂无可选项"}):A.map((B,I)=>l.jsxs("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":B.value===n,className:`new-chat-compact-select__option${I===b?" is-active":""}`,onMouseEnter:()=>y(I),onClick:()=>Q(I),children:[l.jsxs("span",{className:"new-chat-compact-select__option-copy",children:[l.jsx("strong",{children:B.label}),B.description?l.jsx("small",{children:B.description}):null]}),B.value===n?l.jsx(Ldt,{}):null]},B.value))})]}):null]})}const Ld=[{value:"create",label:"技能生成"},{value:"optimize",label:"技能优化"}],Ddt=120,$dt=180;function Qdt(){return l.jsx("svg",{className:"new-chat-skill-picker__chevron",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m4.75 6.25 3.25 3.5 3.25-3.5"})})}function Bdt(){return l.jsx("svg",{className:"new-chat-skill-picker__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5"})})}function Udt({value:e,onChange:t,disabled:n=!1}){const[i,r]=m.useState(!1),[s,a]=m.useState(()=>Math.max(0,Ld.findIndex(x=>x.value===e))),o=m.useRef(null),c=m.useRef(null),u=m.useRef(null),d=m.useRef(null),f=Ld.find(x=>x.value===e)??Ld[0],h=m.useCallback((x=!1)=>{var w;u.current!==null&&(window.clearTimeout(u.current),u.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),r(!1),x&&((w=c.current)==null||w.focus())},[]);m.useEffect(()=>{if(!i)return;const x=w=>{var E;(E=o.current)!=null&&E.contains(w.target)||h()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[h,i]),m.useEffect(()=>()=>{u.current!==null&&window.clearTimeout(u.current),d.current!==null&&window.clearTimeout(d.current)},[]);function p(){u.current!==null&&(window.clearTimeout(u.current),u.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Math.max(0,Ld.findIndex(x=>x.value===e))),r(!0)}function g(){n||i||u.current!==null||(u.current=window.setTimeout(()=>{u.current=null,p()},Ddt))}function b(){d.current!==null&&(window.clearTimeout(d.current),d.current=null)}function y(){u.current!==null&&(window.clearTimeout(u.current),u.current=null),!(!i||d.current!==null)&&(d.current=window.setTimeout(()=>{d.current=null,h()},$dt))}function O(x){const w=Ld[x];w&&(t(w.value),a(x),h(!0))}function v(x){if(x.key==="Escape"&&i){x.preventDefault(),h(!0);return}if(x.key!=="ArrowDown"&&x.key!=="ArrowUp"){i&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),O(s));return}if(x.preventDefault(),!i){p();return}const w=x.key==="ArrowDown"?1:-1;a(E=>(E+w+Ld.length)%Ld.length)}return l.jsxs("div",{className:"new-chat-skill-picker",ref:o,onPointerEnter:x=>{x.pointerType==="mouse"&&b()},onPointerLeave:x=>{x.pointerType==="mouse"&&y()},children:[l.jsxs("button",{ref:c,type:"button",className:"new-chat-skill-picker__trigger","aria-label":"选择技能定制方式","aria-haspopup":"listbox","aria-expanded":i,disabled:n,onPointerEnter:x=>{x.pointerType==="mouse"&&g()},onClick:()=>{i?h():p()},onKeyDown:v,children:[l.jsx("span",{children:f.label}),l.jsx(Qdt,{})]}),i?l.jsx("div",{className:"new-chat-skill-picker__menu",role:"listbox","aria-label":"技能定制方式",tabIndex:-1,onKeyDown:v,children:Ld.map((x,w)=>l.jsxs("button",{type:"button",role:"option","aria-selected":x.value===e,className:`new-chat-skill-picker__option${w===s?" is-active":""}`,onMouseEnter:()=>a(w),onClick:()=>O(w),children:[l.jsx("span",{children:x.label}),x.value===e?l.jsx(Bdt,{}):null]},x.value))}):null]})}const zdt=120,Fdt=180;function fH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5.75 3.75 4.25 4.25-4.25 4.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Vdt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function oR(e){return e.name.trim()||"未命名 Skill Space"}function Xdt({spaces:e,skills:t,activeSpaceId:n,selectedSpaceId:i,selectedSkillId:r,selectedSkillLabel:s,spacesLoading:a=!1,skillsLoading:o=!1,spacesError:c="",skillsError:u="",disabled:d=!1,onActivateSpace:f,onSelect:h,onRetrySpaces:p,onRetrySkills:g}){const[b,y]=m.useState(!1),[O,v]=m.useState(0),[x,w]=m.useState(0),[E,S]=m.useState("spaces"),[k,T]=m.useState(!1),[A,N]=m.useState("below"),[C,M]=m.useState(286),L=m.useRef(null),P=m.useRef(null),Q=m.useRef(null),j=m.useRef(null),$=m.useRef(null),U=e.find(ue=>ue.id===n)??null,B=U?oR(U):"Skill Space",I=s||"选择 Skill",X=m.useCallback((ue=!1)=>{var ye;j.current!==null&&(window.clearTimeout(j.current),j.current=null),$.current!==null&&(window.clearTimeout($.current),$.current=null),y(!1),S("spaces"),T(!1),f(""),ue&&((ye=P.current)==null||ye.focus())},[f]);m.useEffect(()=>{if(!b)return;const ue=ye=>{var Se;(Se=L.current)!=null&&Se.contains(ye.target)||X()};return document.addEventListener("mousedown",ue),()=>document.removeEventListener("mousedown",ue)},[X,b]),m.useEffect(()=>{d&&b&&X()},[X,d,b]);const q=m.useCallback(()=>{const ue=P.current;if(!ue)return;const ye=ue.getBoundingClientRect(),Se=12,Re=7,Ee=window.innerHeight-ye.bottom-Re-Se,me=ye.top-Re-Se,oe=Ee>=220||Ee>=me?"below":"above",Ne=oe==="below"?Ee:me;N(oe),M(Math.max(120,Math.floor(Ne)))},[]);m.useLayoutEffect(()=>{if(b)return q(),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[b,q]),m.useEffect(()=>()=>{j.current!==null&&window.clearTimeout(j.current),$.current!==null&&window.clearTimeout($.current)},[]);function D(ue){if(e.length===0)return;const ye=(ue+e.length)%e.length,Se=e[ye];v(ye),w(0),Se.id!==n&&f(Se.id)}function H(ue,ye=!1){j.current!==null&&(window.clearTimeout(j.current),j.current=null),$.current!==null&&(window.clearTimeout($.current),$.current=null);const Se=e.findIndex(Ee=>Ee.id===i),Re=Se>=0?Se:0;v(Re),w(0),S("spaces"),T(ye),y(!0),ye&&e[Re]?f(e[Re].id):f(""),ue&&requestAnimationFrame(()=>{var Ee;return(Ee=Q.current)==null?void 0:Ee.focus()})}function re(){d||b||j.current!==null||(j.current=window.setTimeout(()=>{j.current=null,H(!1)},zdt))}function fe(){$.current!==null&&(window.clearTimeout($.current),$.current=null)}function Ae(){j.current!==null&&(window.clearTimeout(j.current),j.current=null),!(!b||$.current!==null)&&($.current=window.setTimeout(()=>{$.current=null,X()},Fdt))}function J(ue){U&&(h(U,ue),X(!0))}function ie(ue){if(ue.key==="Escape"){ue.preventDefault(),X(!0);return}if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft","Enter"].includes(ue.key)&&T(!0),E==="spaces"){ue.key==="ArrowDown"||ue.key==="ArrowUp"?(ue.preventDefault(),D(O+(ue.key==="ArrowDown"?1:-1))):(ue.key==="ArrowRight"||ue.key==="Enter")&&(ue.preventDefault(),U||D(O),S("skills"));return}if(ue.key==="ArrowLeft")ue.preventDefault(),S("spaces");else if(t.length>0&&(ue.key==="ArrowDown"||ue.key==="ArrowUp")){ue.preventDefault();const ye=ue.key==="ArrowDown"?1:-1;w(Se=>(Se+ye+t.length)%t.length)}else ue.key==="Enter"&&t[x]&&(ue.preventDefault(),J(t[x]))}return l.jsxs("div",{className:"new-chat-skill-target-picker",ref:L,onPointerEnter:ue=>{ue.pointerType==="mouse"&&fe()},onPointerLeave:ue=>{ue.pointerType==="mouse"&&Ae()},children:[l.jsxs("button",{ref:P,type:"button",className:"new-chat-agent-picker__trigger new-chat-skill-target-picker__trigger","aria-label":`选择 Skill:${I}`,"aria-haspopup":"menu","aria-expanded":b,disabled:d,onPointerEnter:ue=>{ue.pointerType==="mouse"&&re()},onClick:()=>b?X():H(!0),onKeyDown:ue=>{ue.key==="ArrowDown"||ue.key==="ArrowUp"?(ue.preventDefault(),b||H(!0,!0)):ue.key==="Escape"&&b&&(ue.preventDefault(),X(!0))},children:[l.jsx("span",{title:I,children:I}),l.jsx(fH,{className:"new-chat-agent-picker__trigger-chevron"})]}),b?l.jsxs("div",{ref:Q,className:`new-chat-agent-picker__menus new-chat-skill-target-picker__menus is-${A}`,style:{"--new-chat-skill-menu-max-height":`${C}px`},tabIndex:-1,onKeyDown:ie,onPointerMove:ue=>{ue.pointerType==="mouse"&&T(!1)},children:[l.jsx("div",{className:"new-chat-agent-picker__menu",role:"menu","aria-label":"Skill Space",children:a&&e.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner new-chat-skill-target-picker__spinner","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:"正在加载 Skill Space"})]}):c&&e.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:c}),l.jsx("button",{type:"button",onClick:p,children:"重新加载"})]}):e.length===0?l.jsx("div",{className:"new-chat-skill-target-picker__empty",children:"暂无 Skill Space"}):e.map((ue,ye)=>l.jsxs("button",{type:"button",role:"menuitem","aria-haspopup":"listbox","aria-expanded":n===ue.id,className:`new-chat-agent-picker__type new-chat-skill-target-picker__space${n===ue.id?" is-previewed":""}${k&&E==="spaces"&&O===ye?" is-keyboard-active":""}`,title:oR(ue),onMouseEnter:()=>D(ye),onClick:()=>{D(ye),S("skills")},children:[l.jsx("span",{children:oR(ue)}),l.jsx(fH,{className:"new-chat-agent-picker__nested-chevron"})]},ue.id))}),U?l.jsx("div",{className:"new-chat-agent-picker__submenu new-chat-skill-target-picker__submenu",role:"listbox","aria-label":`${B} Skill 列表`,children:o&&t.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner new-chat-skill-target-picker__spinner","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:"正在加载 Skill"})]}):u&&t.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:u}),l.jsx("button",{type:"button",onClick:g,children:"重新加载"})]}):t.length===0?l.jsx("div",{className:"new-chat-skill-target-picker__empty",children:"暂无 Skill"}):l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:t.map((ue,ye)=>{const Se=U.id===i&&ue.skillId===r;return l.jsxs("button",{type:"button",role:"option","aria-selected":Se,className:`new-chat-agent-picker__runtime new-chat-skill-target-picker__skill${k&&E==="skills"&&x===ye?" is-keyboard-active":""}`,title:ue.skillDescription||ue.skillName||ue.skillId,onMouseEnter:()=>w(ye),onClick:()=>J(ue),children:[l.jsx("span",{children:ue.skillName||ue.skillId}),ue.skillDescription?l.jsx("small",{children:ue.skillDescription}):null,Se?l.jsx(Vdt,{className:"new-chat-agent-picker__check"}):null]},ue.skillId)})})}):null]}):null]})}const hH={concise:"简洁实用",strict:"严谨稳健",tutorial:"教程友好",automation:"自动化优先"};function lR(e,t){return e instanceof Error&&e.message?e.message:t}function qdt({action:e,onActionChange:t,optimizationSource:n=null,onOptimizationSourceChange:i,disabled:r=!1}){const[s,a]=m.useState(null),[o,c]=m.useState(!1),[u,d]=m.useState(""),[f,h]=m.useState(0),[p,g]=m.useState("concise"),[b,y]=m.useState(""),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(""),[k,T]=m.useState(0),[A,N]=m.useState(""),[C,M]=m.useState([]),[L,P]=m.useState(!1),[Q,j]=m.useState(""),[$,U]=m.useState(0);m.useEffect(()=>{if(e!=="create"||s)return;const q=new AbortController;return c(!0),d(""),aA(q.signal).then(D=>{a(D),y(H=>{var re;return H||((re=D.models[0])==null?void 0:re.id)||""}),!D.enabled&&D.reason&&d(D.reason)}).catch(D=>{q.signal.aborted||d(lR(D,"模型配置加载失败"))}).finally(()=>{q.signal.aborted||c(!1)}),()=>q.abort()},[e,s,f]),m.useEffect(()=>{if(e!=="optimize"||O.length>0)return;let q=!1;return w(!0),S(""),A$().then(D=>{q||v(D)}).catch(D=>{q||S(lR(D,"Skill Space 加载失败"))}).finally(()=>{q||w(!1)}),()=>{q=!0}},[e,O.length,k]);const B=O.find(q=>q.id===A);m.useEffect(()=>{if(e!=="optimize"||!B){M([]),j(""),P(!1);return}let q=!1;return M([]),P(!0),j(""),N$(B.id,B.region).then(D=>{q||M(D)}).catch(D=>{q||j(lR(D,"Skill 加载失败"))}).finally(()=>{q||P(!1)}),()=>{q=!0}},[e,B,$]);const I=m.useMemo(()=>Object.keys(s?s.styles:hH).map(D=>({value:D,label:hH[D]||D})),[s]),X=m.useMemo(()=>(s==null?void 0:s.models.map(q=>({value:q.id,label:q.label})))||[],[s]);return l.jsxs("div",{className:`new-chat-skill-controls is-${e}`,"aria-label":"技能定制配置",children:[l.jsx(Udt,{value:e,onChange:t,disabled:r}),e==="create"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-skill-controls__style",children:l.jsx(Cp,{label:"风格",value:p,options:I,onChange:g,placeholder:"选择风格",disabled:r})}),l.jsx("div",{className:"new-chat-skill-controls__model",children:l.jsx(Cp,{label:"模型",hideLabel:!0,value:b,options:X,onChange:y,placeholder:"选择模型",loading:o,error:u,disabled:r,onRetry:()=>{a(null),h(q=>q+1)}})})]}):l.jsx(Xdt,{spaces:O,skills:C,activeSpaceId:A,selectedSpaceId:(n==null?void 0:n.space.id)||"",selectedSkillId:(n==null?void 0:n.skill.skillId)||"",selectedSkillLabel:(n==null?void 0:n.skill.skillName)||(n==null?void 0:n.skill.skillId)||"",spacesLoading:x,skillsLoading:L,spacesError:E,skillsError:Q,disabled:r,onActivateSpace:N,onSelect:(q,D)=>{i==null||i({space:q,skill:D})},onRetrySpaces:()=>{v([]),T(q=>q+1)},onRetrySkills:()=>{M([]),U(q=>q+1)}})]})}const pH=[{value:"auto",label:"自动识别"},{value:"text_to_video",label:"文生视频"},{value:"reference_to_video",label:"参考素材生视频"},{value:"video_editing",label:"视频编辑"},{value:"video_extension",label:"视频续写"},{value:"first_last_frame",label:"首尾帧生成"}],Hdt=[{value:"21:9",label:"21:9"},{value:"16:9",label:"16:9"},{value:"4:3",label:"4:3"},{value:"1:1",label:"1:1"},{value:"3:4",label:"3:4"},{value:"9:16",label:"9:16"}],Ydt=[{value:"480p",label:"480p"},{value:"720p",label:"720p"}],Gdt={taskMode:"auto",aspectRatio:"16:9",resolution:"720p",durationSeconds:8,referenceImage:null,referenceVideo:null,firstFrame:null,lastFrame:null};function ipe({kind:e,...t}){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:e==="image"?l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"4",width:"17",height:"16",rx:"2.5"}),l.jsx("circle",{cx:"9",cy:"9.25",r:"1.5"}),l.jsx("path",{d:"m5.75 17 4.1-4.1a1.25 1.25 0 0 1 1.77 0l1.35 1.35 1.55-1.55a1.25 1.25 0 0 1 1.77 0L19 15.4"})]}):l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"5",width:"12.5",height:"14",rx:"2.5"}),l.jsx("path",{d:"m16 9.5 3.1-1.75a.9.9 0 0 1 1.35.78v6.94a.9.9 0 0 1-1.35.78L16 14.5"}),l.jsx("path",{d:"m9 9.5 3.5 2.5L9 14.5Z"})]})})}function rpe(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4.5 4.5 7 7m0-7-7 7"})})}function Wdt({asset:e,onChange:t,disabled:n=!1,unavailableReason:i="",kind:r,label:s}){const a=m.useId(),[o,c]=m.useState("");m.useEffect(()=>{if(!e){c("");return}const d=URL.createObjectURL(e);return c(d),()=>URL.revokeObjectURL(d)},[e]);function u(d){var h;const f=((h=d.currentTarget.files)==null?void 0:h[0])??null;f&&t(f),d.currentTarget.value=""}return l.jsxs("div",{className:`new-chat-inline-video${e?" has-preview":""}${n?" is-disabled":""}`,children:[l.jsx("input",{id:a,className:"new-chat-inline-video__input",type:"file",accept:`${r}/*`,disabled:n,required:!0,"aria-label":`上传${s}`,onChange:u}),l.jsx("label",{className:"new-chat-inline-video__tile",htmlFor:a,title:i||(e?`更换${s}:${e.name}`:`上传${s}`),children:o&&r==="image"?l.jsx("img",{src:o,alt:""}):o?l.jsx("video",{src:o,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):l.jsxs(l.Fragment,{children:[l.jsx(ipe,{kind:r}),l.jsx("span",{children:s})]})}),e?l.jsx("button",{className:"new-chat-inline-video__remove",type:"button","aria-label":`移除${s} ${e.name}`,disabled:n,onClick:()=>t(null),children:l.jsx(rpe,{})}):null]})}function Zdt(){return l.jsx("span",{className:"new-chat-video-model-spinner",role:"status","aria-label":"正在加载增强模型"})}function cR({label:e,helper:t,accept:n,asset:i,onChange:r,disabled:s,kind:a}){const o=m.useId();function c(u){var f;const d=((f=u.currentTarget.files)==null?void 0:f[0])??null;d&&r(d),u.currentTarget.value=""}return l.jsxs("div",{className:`new-chat-video-asset${s?" is-disabled":""}`,children:[l.jsx("input",{id:o,className:"new-chat-video-asset__input",type:"file",accept:n,disabled:s,onChange:c}),l.jsxs("label",{className:"new-chat-video-asset__label",htmlFor:o,children:[l.jsx("span",{className:"new-chat-video-asset__icon",children:l.jsx(ipe,{kind:a})}),l.jsxs("span",{className:"new-chat-video-asset__copy",children:[l.jsxs("span",{className:"new-chat-video-asset__title",children:[e,l.jsx("small",{children:"可选"})]}),l.jsx("span",{className:`new-chat-video-asset__value${i?" is-selected":""}`,title:i==null?void 0:i.name,children:(i==null?void 0:i.name)||t})]}),l.jsx("span",{className:"new-chat-video-asset__action",children:i?"更换":"添加"})]}),i?l.jsx("button",{className:"new-chat-video-asset__remove",type:"button","aria-label":`移除${e} ${i.name}`,disabled:s,onClick:()=>r(null),children:l.jsx(rpe,{})}):null]})}function Kdt({config:e,onChange:t,enhancerModel:n,assetStorageAvailable:i,assetStorageUnavailableReason:r="",modelsLoading:s=!1,modelsError:a="",disabled:o=!1}){const c=cwe();function u(g,b){t({...e,[g]:b})}const d=e.taskMode==="first_last_frame",f=e.taskMode==="video_editing",h=e.taskMode==="video_extension",p=o||!i;return l.jsxs(wr.section,{className:"new-chat-video-controls","aria-label":"视频创作配置",initial:c?!1:{opacity:0,y:-12,scaleY:.96},animate:{opacity:1,y:0,scaleY:1},exit:c?{opacity:0}:{opacity:0,y:-8,scaleY:.98},transition:{duration:c?0:.2,ease:[.22,1,.36,1]},children:[l.jsxs("div",{className:"new-chat-video-controls__parameters",children:[l.jsx("div",{className:"new-chat-video-controls__field",children:l.jsx(Cp,{label:"比例",value:e.aspectRatio,options:Hdt,placeholder:"选择比例",disabled:o,onChange:g=>u("aspectRatio",g)})}),l.jsx("div",{className:"new-chat-video-controls__field",children:l.jsx(Cp,{label:"清晰度",value:e.resolution,options:Ydt,placeholder:"选择清晰度",disabled:o,onChange:g=>u("resolution",g)})}),l.jsxs("label",{className:`new-chat-video-duration${o?" is-disabled":""}`,children:[l.jsxs("span",{className:"new-chat-video-duration__header",children:[l.jsx("span",{children:"时长"}),l.jsxs("output",{children:[e.durationSeconds,"s"]})]}),l.jsx("input",{type:"range",min:"4",max:"30",step:"1",value:e.durationSeconds,disabled:o,"aria-label":`视频时长:${e.durationSeconds} 秒`,onChange:g=>u("durationSeconds",Number(g.currentTarget.value))})]})]}),l.jsx("div",{className:`new-chat-video-controls__assets${d||f||h?" is-single":""}`,children:d?l.jsx(cR,{label:"尾帧",helper:"添加视频结束画面",accept:"image/*",asset:e.lastFrame,disabled:p,kind:"image",onChange:g=>u("lastFrame",g)}):l.jsxs(l.Fragment,{children:[l.jsx(cR,{label:f||h?"辅助图片":"参考图片",helper:f||h?"用于补充画面参考":"支持常见图片格式",accept:"image/*",asset:e.referenceImage,disabled:p,kind:"image",onChange:g=>u("referenceImage",g)}),f||h?null:l.jsx(cR,{label:"参考视频",helper:"支持常见视频格式",accept:"video/*",asset:e.referenceVideo,disabled:p,kind:"video",onChange:g=>u("referenceVideo",g)})]})}),!i&&r?l.jsx("p",{className:"new-chat-video-controls__storage-unavailable",role:"status",children:r}):null,l.jsx("p",{className:"new-chat-video-controls__model-hint",title:a||void 0,children:s?l.jsx(Zdt,{}):n?l.jsxs(l.Fragment,{children:["使用 ",n," 模型进行意图识别和提示词增强"]}):"增强模型不可用"})]})}function Jdt({className:e=""}){return l.jsxs("span",{className:`${e} new-chat-workspace-tabs__skill-icon`,"aria-hidden":"true",children:[l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-triangle"}),l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-circle"}),l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-square"})]})}const uR=[{value:"agent",label:"智能体",icon:Pf},{value:"skill",label:"技能定制",icon:Jdt},{value:"video",label:"视频创作",icon:D3}];function eft({value:e,onChange:t,disabled:n=!1,skillCustomizationEnabled:i=!1}){const r=m.useRef([]),s=i?uR:uR.filter(c=>c.value!=="skill");function a(c){var d;const u=s[c];!u||n||(t(u.value),(d=r.current[c])==null||d.focus())}function o(c,u){let d=null;c.key==="ArrowRight"&&(d=(u+1)%s.length),c.key==="ArrowLeft"&&(d=(u-1+s.length)%s.length),c.key==="Home"&&(d=0),c.key==="End"&&(d=uR.length-1),d!==null&&(c.preventDefault(),a(d))}return l.jsx("div",{className:"new-chat-workspace-tabs",role:"tablist","aria-label":"新会话模式",children:s.map((c,u)=>{const d=c.icon,f=e===c.value;return l.jsxs("button",{ref:h=>{r.current[u]=h},id:`new-chat-workspace-tab-${c.value}`,type:"button",role:"tab","aria-controls":"new-chat-workspace-panel","aria-selected":f,tabIndex:f?0:-1,className:`new-chat-workspace-tabs__tab${f?" is-active":""}`,disabled:n,onClick:()=>t(c.value),onKeyDown:h=>o(h,u),children:[f?l.jsx(wr.span,{className:"new-chat-workspace-tabs__slider",layoutId:"new-chat-workspace-active-pill",initial:!1,transition:{layout:{duration:.24,ease:[.22,1,.36,1]}},"aria-hidden":"true"}):null,l.jsx(d,{className:"new-chat-workspace-tabs__icon"}),l.jsx("span",{className:"new-chat-workspace-tabs__label",children:c.label})]},c.value)})})}const tft={auto:"视频生成",text_to_video:"文生视频",reference_to_video:"参考素材生视频",video_editing:"视频编辑",video_extension:"视频续写",first_last_frame:"首尾帧生成"};function spe(e){return e?tft[e]:"视频生成"}function nft({prompt:e,config:t,enhancerModel:n,generationModel:i}){return{localId:crypto.randomUUID(),remoteTaskId:"",runId:1,status:"optimizing",requestedPrompt:e,optimizedPrompt:"",requestedMode:t.taskMode,resolvedMode:null,config:{...t},enhancerModel:n,generationModel:i,assetIds:[],output:null,errorStage:null,error:""}}function mH(e,t){return t.type==="optimization_succeeded"?{...e,status:"generating",optimizedPrompt:t.optimizedPrompt,resolvedMode:t.resolvedMode,enhancerModel:t.enhancerModel,errorStage:null,error:""}:t.type==="assets_uploaded"?{...e,assetIds:t.assetIds}:t.type==="generation_started"?{...e,status:"generating",remoteTaskId:t.remoteTaskId,generationModel:t.generationModel,errorStage:null,error:""}:t.type==="generation_succeeded"?{...e,status:"success",output:t.output,errorStage:null,error:""}:t.type==="failed"?{...e,status:"error",errorStage:t.stage,error:t.error}:{...e,runId:e.runId+1,status:t.stage==="optimization"?"optimizing":"generating",remoteTaskId:"",optimizedPrompt:t.stage==="optimization"?"":e.optimizedPrompt,resolvedMode:t.stage==="optimization"?null:e.resolvedMode,output:null,errorStage:null,error:""}}function ift(e){const t=spe(e.resolvedMode),n=e.status==="error"&&e.errorStage==="optimization",i=e.status==="error"&&e.errorStage==="generation",r=!!e.optimizedPrompt&&!n;return[{id:"optimization",label:n?"提示词优化失败":r?"提示词优化完成":"提示词优化中",status:n?"failed":r?"done":"active"},{id:"generation",label:e.status==="success"?`${t}已完成`:i?`${t}失败`:e.status==="generating"?`${t}进行中`:"等待视频生成",status:e.status==="success"?"done":i?"failed":e.status==="generating"?"active":"pending"}]}function ape(e){return(e==null?void 0:e.status)==="optimizing"||(e==null?void 0:e.status)==="generating"}const ope={ppt:["ppt_generate"],image:["image_generate"],video:["video_generate"]},rft={ppt:[],image:[],video:["video_task_query"]},sft=[{pattern:/(?:^|[-_.])glm[-_.]?5[-_.]?2(?:[-_.]|$)/,tokens:1024e3},{pattern:/(?:^|[-_.])deepseek[-_.]?v4(?:[-_.]|$)/,tokens:1024e3}],aft=[{pattern:/doubao[-_.]seed[-_.]evolving(?:[-_.]|$)/,tokens:1024e3},{pattern:/doubao[-_.]seed[-_.]translation(?:[-_.]|$)/,tokens:4e3},{pattern:/doubao[-_.]seed[-_.]character(?:[-_.]|$)/,tokens:128e3},{pattern:/doubao[-_.]1[-_.]?5[-_.]pro[-_.]32k[-_.]character(?:[-_.]|$)/,tokens:32e3},{pattern:/doubao[-_.]1[-_.]?5[-_.]pro[-_.]32k(?:[-_.]|$)/,tokens:128e3},{pattern:/doubao[-_.]1[-_.]?5[-_.](?:lite[-_.]32k|vision[-_.]pro[-_.]32k)(?:[-_.]|$)/,tokens:32e3},{pattern:/doubao[-_.]seed[-_.]2[-_.][01](?:[-_.]|$)/,tokens:256e3},{pattern:/doubao[-_.]seed[-_.](?:1[-_.][68]|code[-_.]preview)(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])glm[-_.]?4[-_.]?7(?:[-_.]|$)/,tokens:2e5}],oft=[{pattern:/dola[-_.]seed[-_.]2[-_.]1(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])seed[-_.]2[-_.]0(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])seed[-_.]1[-_.][68](?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])glm[-_.]?4[-_.]?7(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])deepseek[-_.]?v3[-_.]?2(?:[-_.]|$)/,tokens:128e3},{pattern:/(?:^|[-_.])gpt[-_.]?oss[-_.]?120b(?:[-_.]|$)/,tokens:128e3}];function lft(e){const t=e.match(/(?:^|[-_.])(\d+(?:\.\d+)?)(k|m)(?:[-_.]|$)/i);if(!t)return null;const n=Number(t[1]);return!Number.isFinite(n)||n<=0?null:Math.round(n*(t[2].toLowerCase()==="m"?1e6:1e3))}function cft(e,t){const n=e.trim().toLowerCase().split("/").pop()??"";if(!n)return null;const i=t==="byteplus"?oft:aft;for(const r of[...i,...sft])if(r.pattern.test(n))return r.tokens;return lft(n)}const Dh=new Intl.NumberFormat("zh-CN");function gH(e){return e>=1e3?`${Number((e/1e3).toFixed(1))}K`:Dh.format(e)}function dR(e){return e>=1e3?`${Number((e/1e3).toFixed(1))}K`:`${Dh.format(e)} Token`}function bH(e){return`${Number(e.toFixed(2))}%`}const OH={system:"系统与工具",input:"输入与历史",output:"输出与思考",remaining:"剩余"};function uft({cloudProvider:e,modelName:t,usage:n,systemTokenEstimate:i}){const r=m.useId(),s=cft(t,e),a=s?EEe({usage:n,contextWindow:s,estimatedSystemTokens:i}):null,o=(a==null?void 0:a.usedTokens)??n.current.totalTokenCount,c=s?o/s*100:null,u=c===null?null:Math.round(c),d=c!==null&&c>0&&c<1?"<1":String(u??0),f=c===null?0:Math.min(100,Math.max(0,c)),h=100-f,p=t.trim()||"模型信息未提供",g=i===null?"提示词(含系统)":OH.input,b=a?Math.max(0,a.usedTokens-a.contextWindow):0,y=i===null?"系统与工具占用未知":`系统与工具约 ${Dh.format((a==null?void 0:a.systemTokens)??0)} Token`,O=a?`上下文已使用 ${d}%,${y},${g} ${Dh.format(a.inputTokens)} Token,输出与思考 ${Dh.format(a.outputTokens)} Token,剩余 ${Dh.format(a.remainingTokens)} Token`:`${p},上下文窗口未知,会话累计使用 ${Dh.format(n.cumulative.totalTokenCount)} Token`,v=a?kEe(a):[],x=a?[{kind:"system",tokens:a.systemTokens},{kind:"input",tokens:a.inputTokens},{kind:"output",tokens:a.outputTokens},{kind:"remaining",tokens:a.remainingTokens}]:[];return l.jsxs("div",{className:"token-usage-indicator",tabIndex:0,role:s===null?"status":"meter","aria-label":O,"aria-describedby":r,"aria-valuemin":s===null?void 0:0,"aria-valuemax":s??void 0,"aria-valuenow":s===null?void 0:Math.min(o,s),children:[l.jsxs("svg",{className:"token-usage-ring",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{className:"token-usage-ring__track",cx:"10",cy:"10",r:"7"}),l.jsx("circle",{className:"token-usage-ring__value",cx:"10",cy:"10",r:"7",pathLength:"100",style:{strokeDasharray:`${f} ${100-f}`}})]}),l.jsxs("div",{id:r,className:"token-usage-tooltip",role:"tooltip",children:[a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"token-usage-tooltip__header",children:[l.jsx("strong",{children:"上下文构成"}),l.jsxs("span",{children:[d,"% 已用"]})]}),l.jsxs("div",{className:"token-context-breakdown",children:[l.jsx("div",{className:"token-context-grid",role:"img","aria-label":"100 格上下文构成图,每格代表上下文窗口的百分之一",children:v.map(w=>l.jsx("span",{className:"token-context-cell","aria-hidden":"true",children:w.slices.map(E=>l.jsx("span",{className:`token-context-cell__slice is-${E.kind}`,style:{width:`${E.share*100}%`}},E.kind))},w.index))}),l.jsx("dl",{className:"token-context-legend",children:x.map(w=>l.jsxs("div",{children:[l.jsxs("dt",{children:[l.jsx("span",{className:`token-context-swatch is-${w.kind}`,"aria-hidden":"true"}),w.kind==="input"?g:OH[w.kind],w.kind==="system"&&i!==null?l.jsx("em",{children:"估算"}):null]}),l.jsx("dd",{children:w.kind==="system"&&i===null?"未知":`${w.kind==="system"?"≈":""}${gH(w.tokens)}`})]},w.kind))})]}),l.jsxs("div",{className:"token-context-summary",children:[l.jsxs("div",{children:[l.jsx("strong",{children:bH(f)})," 已用,剩余"," ",l.jsx("strong",{children:bH(h)})]}),l.jsxs("div",{children:[l.jsx("strong",{children:dR(a.usedTokens)})," 已用,剩余"," ",l.jsx("strong",{children:dR(a.remainingTokens)}),",总计"," ",l.jsx("strong",{children:dR(a.contextWindow)})]})]}),b>0?l.jsxs("div",{className:"token-usage-tooltip__overflow",children:["已超出上下文 ",gH(b)," Token"]}):null]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"token-usage-tooltip__title",children:"上下文用量"}),l.jsx("div",{className:"token-usage-tooltip__unknown",children:t.trim()?"暂未收录该模型的上下文窗口":"当前 Runtime 未提供模型信息"})]}),l.jsx("div",{className:"token-usage-tooltip__model",title:p,children:p})]})]})}const yH=[{value:"ppt",label:"PPT",icon:rSe,prompts:["复盘【季度】经营表现,提炼指标差距、原因与行动建议","汇报【项目名称】进展:里程碑、风险、预算和资源诉求","为【客户行业】输出解决方案:痛点、架构、实施路径与收益","分析【行业主题】趋势,给出竞争格局、机会与战略建议"]},{value:"image",label:"图片生成",icon:LD,prompts:["为【品牌或产品】设计【高级科技】风格的发布会主视觉","生成【产品名称】电商海报,突出【核心卖点】与品牌色","呈现【产品或空间】在【使用场景】中的写实概念效果图","围绕【传播主题】制作简洁专业的企业社媒配图"]},{value:"video",label:"视频生成",icon:D3,prompts:["制作【品牌名称】30 秒宣传片,突出【品牌价值】","为【产品名称】制作 45 秒发布视频:痛点、功能、场景与行动号召","制作【培训主题】企业培训视频,讲清【关键操作或规范】","生成【活动名称】20 秒预热视频,包含亮点、时间地点和报名信息"]}];function dft({cloudProvider:e,sessionId:t,sessionInitializing:n=!1,appName:i,agentName:r,value:s,onChange:a,onSubmit:o,onStop:c,onVideoSubmit:u,videoTask:d=null,onOpenVideoTask:f,disabled:h,busy:p,showMeta:g,attachments:b,skills:y,agents:O,invocation:v,capabilitiesLoading:x=!1,modelName:w,tokenUsage:E,systemTokenEstimate:S,allowAttachments:k=!0,onInvocationChange:T,onAddFiles:A,onRemoveAttachment:N,newChatMode:C="agent",newChatWorkspaceMode:M="agent",newChatSkillAction:L="create",newChatSkillTarget:P=null,skillCustomizationEnabled:Q=!1,newChatTask:j=null,newChatLayout:$=!1,showWorkspaceTabs:U=!1,showModeSelector:B=!1,onWorkspaceModeChange:I,onSkillActionChange:X,onSkillTargetChange:q,onModeChange:D,onTaskChange:H,temporaryEnabled:re,deepseekHarnessEnabled:fe,harnessEnabled:Ae=!1,builtinTools:J=[],showAgentPicker:ie=!1,agentPickerDisabled:ue=!1,selectedRuntimeId:ye="",runtimeScope:Se="mine",onSelectRuntime:Re,onSelectSandboxSession:Ee}){var hi;const me=m.useRef(null),oe=m.useRef(null),Ne=m.useRef(null),Oe=m.useRef(null),[Ve,We]=m.useState(!1),[De,mt]=m.useState(null),[at,Rt]=m.useState(0),[qe,W]=m.useState(!1),[K,ae]=m.useState(Gdt),[pe,z]=m.useState(null),[ve,Be]=m.useState(!1),[Je,kt]=m.useState("");m.useEffect(()=>{if(!$||M!=="video")return;const Pe=new AbortController;return Be(!0),kt(""),mdt(Pe.signal).then(st=>{Pe.signal.aborted||z(st)}).catch(st=>{Pe.signal.aborted||(z(null),kt(st instanceof Error?st.message:String(st)))}).finally(()=>{Pe.signal.aborted||Be(!1)}),()=>Pe.abort()},[e,$,M]),m.useEffect(()=>{!(pe!=null&&pe.supportedModes.length)||K.taskMode==="auto"||pe.supportedModes.includes(K.taskMode)||ae(Pe=>({...Pe,taskMode:pe.supportedModes[0]}))},[K.taskMode,pe]);async function Mt(){if(t)try{await navigator.clipboard.writeText(t),W(!0),setTimeout(()=>W(!1),1500)}catch{W(!1)}}m.useLayoutEffect(()=>{const Pe=me.current;Pe&&(Pe.style.height="auto",Pe.style.height=`${Math.min(Pe.scrollHeight,200)}px`)},[s]);const Tt=b.some(Pe=>Pe.status!=="ready"),dt=$&&M==="video",ge=dt?K.taskMode==="first_last_frame"?{asset:K.firstFrame,kind:"image",label:"首帧"}:K.taskMode==="video_editing"||K.taskMode==="video_extension"?{asset:K.referenceVideo,kind:"video",label:K.taskMode==="video_editing"?"待编辑视频":"基础视频"}:null:null,lt=ape(d),Ge=dt&&!!d&&!s.trim(),vt=p&&!!c,_t=dt?lt||Ge||!h&&!p&&!Tt&&(!ge||!!ge.asset)&&!!pe&&s.trim().length>0:!h&&!p&&!Tt&&(s.trim().length>0||b.length>0);function Bt(){if(dt){if(lt||Ge){f==null||f();return}pe&&s.trim()&&(u==null||u(s.trim(),K,pe));return}o()}const je=M==="skill"?L==="optimize"?"描述你想优化的技能…":"描述你想生成的技能…":M==="video"?"描述你想创作的视频…":`向 ${r} 发消息…`,Ze=h&&M==="agent"?"请先选择智能体":h&&M==="skill"&&L==="optimize"&&!P?"请先选择需要优化的 Skill":je,Ie=(De==null?void 0:De.query.toLocaleLowerCase())??"",Wt=(De==null?void 0:De.kind)==="skill"?y.filter(Pe=>!v.skills.some(st=>st.name===Pe.name)).filter(Pe=>`${Pe.name} ${Pe.description}`.toLocaleLowerCase().includes(Ie)).map(Pe=>({kind:"skill",value:Pe})):(De==null?void 0:De.kind)==="agent"?O.filter(Pe=>`${Pe.name} ${Pe.description}`.toLocaleLowerCase().includes(Ie)).map(Pe=>({kind:"agent",value:Pe})):[];function dn(Pe){var st;We(!1),mt(null),(st=Pe.current)==null||st.click()}function Qt(Pe){H==null||H(Pe.value),We(!1),mt(null),requestAnimationFrame(()=>{var st,At;(st=me.current)==null||st.focus(),(At=me.current)==null||At.setSelectionRange(s.length,s.length)})}function Yt(Pe){a(Pe),We(!1),mt(null),requestAnimationFrame(()=>{var Ut,kn,wn;(Ut=me.current)==null||Ut.focus();const st=Pe.indexOf("【"),At=Pe.indexOf("】",st+1);st>=0&&At>st?(kn=me.current)==null||kn.setSelectionRange(st+1,At):(wn=me.current)==null||wn.setSelectionRange(Pe.length,Pe.length)})}function Jt(){H==null||H(null),a(""),We(!1),mt(null),requestAnimationFrame(()=>{var Pe,st;(Pe=me.current)==null||Pe.focus(),(st=me.current)==null||st.setSelectionRange(0,0)})}const Ft=yH.find(Pe=>Pe.value===j),Ce=yH.filter(Pe=>ope[Pe.value].every(st=>J.includes(st)));function et(Pe,st){const At=Pe.slice(0,st),Ut=/(^|\s)([/@])([^\s/@]*)$/.exec(At);if(!Ut){mt(null);return}const kn=Ut[2].length+Ut[3].length,wn={kind:Ut[2]==="/"?"skill":"agent",query:Ut[3],start:st-kn,end:st},Ai=!De||De.kind!==wn.kind||De.query!==wn.query||De.start!==wn.start||De.end!==wn.end;mt(wn),Ai&&Rt(0),We(!1)}function wt(Pe){if(!De)return;const st=s.slice(0,De.start)+s.slice(De.end);a(st),Pe.kind==="skill"?T({...v,skills:[...v.skills,Pe.value]}):T({skills:[],targetAgent:Pe.value});const At=De.start;mt(null),requestAnimationFrame(()=>{var Ut,kn;(Ut=me.current)==null||Ut.focus(),(kn=me.current)==null||kn.setSelectionRange(At,At)})}function yn(){if(v.targetAgent){T({skills:[]});return}v.skills.length>0&&T({...v,skills:v.skills.slice(0,-1)})}function on(Pe){const st=Pe.target.files?Array.from(Pe.target.files):[];st.length&&A(st),Pe.target.value=""}return l.jsxs("div",{className:`composer${$?" composer--new-chat":""}${Ft?` composer--has-task composer--task-${Ft.value}`:""}`,children:[l.jsx(yA,{value:v,onRemoveSkill:Pe=>T({...v,skills:v.skills.filter(st=>st.name!==Pe)}),onRemoveAgent:()=>T({skills:[]})}),b.length>0&&l.jsx(xA,{appName:i,compact:!0,items:b,onRemove:N}),$&&U&&I?l.jsx(eft,{value:M,onChange:I,disabled:p,skillCustomizationEnabled:Q}):null,l.jsxs("div",{id:$&&U?"new-chat-workspace-panel":void 0,className:"composer-box",role:$&&U?"tabpanel":void 0,"aria-labelledby":$&&U?`new-chat-workspace-tab-${M}`:void 0,children:[De?l.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":De.kind==="skill"?"可用技能":"可用子 Agent",children:[l.jsxs("div",{className:"composer-command-head",children:[De.kind==="skill"?l.jsx(tx,{}):l.jsx(oJ,{}),l.jsx("span",{children:De.kind==="skill"?"调用技能":"使用子 Agent"}),l.jsx("kbd",{children:De.kind==="skill"?"/":"@"})]}),x?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Kn,{className:"spin"})," 正在读取 Agent 能力…"]}):Wt.length===0?l.jsx("div",{className:"composer-command-empty",children:De.kind==="skill"?"当前 Agent 没有匹配技能":"当前 Agent 没有匹配子 Agent"}):l.jsx("div",{className:"composer-command-list",children:Wt.map((Pe,st)=>l.jsxs("button",{type:"button",role:"option","aria-selected":st===at,className:`composer-command-item${st===at?" is-active":""}`,onMouseDown:At=>{At.preventDefault(),wt(Pe)},onMouseEnter:()=>Rt(st),children:[l.jsx("span",{className:`composer-command-icon composer-command-icon--${Pe.kind}`,children:Pe.kind==="skill"?l.jsx(tx,{}):l.jsx(lJ,{})}),l.jsxs("span",{className:"composer-command-copy",children:[l.jsxs("strong",{children:[Pe.kind==="skill"?"/":"@",Pe.value.name]}),l.jsx("span",{children:Pe.value.description||(Pe.kind==="skill"?"加载并执行该技能":"将本轮交给该 Agent")})]}),l.jsx("kbd",{children:st===at?"↵":Pe.kind==="skill"?"技能":"Agent"})]},`${Pe.kind}-${Pe.value.name}`))})]}):null,l.jsxs("div",{className:"composer-menu-wrap",children:[l.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:h||!k,onClick:()=>{mt(null),We(Pe=>!Pe)},children:l.jsx(Gs,{className:"icon"})}),Ve&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>We(!1)}),l.jsxs("div",{className:"composer-menu",role:"menu",children:[l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(oe),children:[l.jsx(LD,{className:"icon"}),"上传图片"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(Ne),children:[l.jsx(PD,{className:"icon"}),"上传文档或 PDF"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(Oe),children:[l.jsx(dJ,{className:"icon"}),"上传视频"]})]})]})]}),M==="agent"&&ie&&Re&&Ee?l.jsx(Rdt,{selectedAgentName:i?r:"",selectedRuntimeId:ye,runtimeScope:Se,disabled:ue,onSelectRuntime:Re,onSelectSandboxSession:Ee}):null,$&&M==="skill"&&X?l.jsx(qdt,{action:L,onActionChange:X,optimizationSource:P,onOptimizationSourceChange:q,disabled:p}):null,$&&M==="video"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-video-task-mode",children:l.jsx(Cp,{label:"任务模式",hideLabel:!0,value:K.taskMode,options:(hi=pe==null?void 0:pe.supportedModes)!=null&&hi.length?pH.filter(Pe=>Pe.value==="auto"||pe.supportedModes.includes(Pe.value)):pH,onChange:Pe=>ae(st=>({...st,taskMode:Pe})),placeholder:"选择任务模式",disabled:p||lt||ve||!pe})}),l.jsx("div",{className:"new-chat-video-generation-model",title:Je||(pe==null?void 0:pe.generationModel),children:ve?l.jsx(Kn,{className:"icon spin",role:"status","aria-label":"正在加载生成模型"}):l.jsx("strong",{children:(pe==null?void 0:pe.generationModel)||"模型不可用"})})]}):null,B&&D?l.jsx(Tdt,{value:C,onChange:D,disabled:p,temporaryEnabled:re,deepseekHarnessEnabled:fe}):null,$&&M==="agent"&&C==="agent"&&Ft&&H?l.jsxs("button",{type:"button",className:`new-chat-task-chip new-chat-task-chip--${Ft.value}`,"aria-label":`取消${Ft.label}任务`,disabled:p,onClick:Jt,children:[l.jsxs("span",{className:"new-chat-task-chip__icon","aria-hidden":"true",children:[l.jsx(Ft.icon,{className:"new-chat-task-chip__task-icon"}),l.jsx(xa,{className:"new-chat-task-chip__remove-icon"})]}),l.jsx("span",{children:Ft.label})]}):null,l.jsxs("div",{className:`composer-input-stack${ge?" has-inline-asset":""}`,children:[ge?l.jsx(Wdt,{asset:ge.asset,kind:ge.kind,label:ge.label,disabled:p||lt||!((pe==null?void 0:pe.assetStorageAvailable)??!1),unavailableReason:(pe==null?void 0:pe.assetStorageUnavailableReason)||"",onChange:Pe=>ae(st=>st.taskMode==="first_last_frame"?{...st,firstFrame:Pe}:{...st,referenceVideo:Pe})}):null,l.jsx("textarea",{ref:me,className:"comp-input scroll",rows:$?4:1,value:s,disabled:h,placeholder:Ze,"aria-expanded":!!De,onChange:Pe=>{a(Pe.target.value),et(Pe.target.value,Pe.target.selectionStart)},onSelect:Pe=>{et(Pe.currentTarget.value,Pe.currentTarget.selectionStart)},onBlur:()=>setTimeout(()=>mt(null),0),onKeyDown:Pe=>{if(!OQ(Pe.nativeEvent)){if(De){if(Pe.key==="ArrowDown"&&Wt.length>0){Pe.preventDefault(),Rt(st=>(st+1)%Wt.length);return}if(Pe.key==="ArrowUp"&&Wt.length>0){Pe.preventDefault(),Rt(st=>(st-1+Wt.length)%Wt.length);return}if((Pe.key==="Enter"||Pe.key==="Tab")&&Wt[at]){Pe.preventDefault(),wt(Wt[at]);return}if(Pe.key==="Escape"){Pe.preventDefault(),mt(null);return}}if(Pe.key==="Backspace"&&!s&&Pe.currentTarget.selectionStart===0&&Pe.currentTarget.selectionEnd===0){yn();return}Pe.key==="Enter"&&!Pe.shiftKey&&(Pe.preventDefault(),_t&&Bt())}}}),$&&s.length===0?l.jsx("span",{className:"composer-placeholder-reveal","aria-hidden":"true",children:Ze},Ze):null]}),l.jsxs("div",{className:"composer-submit-actions",children:[t&&i&&M==="agent"?l.jsx(uft,{cloudProvider:e,modelName:w,usage:E,systemTokenEstimate:S}):null,l.jsx(wr.button,{type:"button",className:"comp-send",disabled:vt?!1:!_t,onClick:vt?c:Bt,"aria-label":vt?"停止生成":lt||Ge?"查看视频生成进度":"发送",title:vt?"停止生成":Je||void 0,whileTap:vt||_t?{scale:.9}:void 0,transition:{type:"spring",stiffness:600,damping:22},children:vt?l.jsx(Sdt,{className:"icon"}):p||lt?l.jsx(Kn,{className:"icon spin"}):l.jsx(wdt,{className:"icon"})})]})]}),l.jsx(xf,{initial:!1,children:$&&U&&M==="video"?l.jsx(Kdt,{config:K,onChange:ae,enhancerModel:(pe==null?void 0:pe.enhancerModel)||"",assetStorageAvailable:(pe==null?void 0:pe.assetStorageAvailable)??!1,assetStorageUnavailableReason:(pe==null?void 0:pe.assetStorageUnavailableReason)||"",modelsLoading:ve,modelsError:Je,disabled:p||lt},"new-chat-video-controls"):null}),$&&M==="agent"&&C==="agent"&&Ae&&!Ft?l.jsx("div",{className:"task-shortcuts","aria-label":"选择任务类型",children:Ce.map(Pe=>{const st=Pe.icon;return l.jsxs("button",{type:"button",className:"task-shortcut",disabled:h||p,onClick:()=>Qt(Pe),children:[l.jsx(st,{}),l.jsx("span",{children:Pe.label})]},Pe.value)})}):null,$&&M==="agent"&&C==="agent"&&Ft?l.jsx("div",{className:"prompt-suggestions","aria-label":`${Ft.label}企业提示词`,children:Ft.prompts.map(Pe=>{const st=Ft.icon;return l.jsxs("button",{type:"button",className:"prompt-suggestion",disabled:h||p,onClick:()=>Yt(Pe),children:[l.jsx(st,{}),l.jsx("span",{children:Pe})]},Pe)})}):null,g&&l.jsxs("div",{className:"composer-meta",children:[l.jsxs("span",{className:"composer-session-line",children:["会话 ID:",l.jsx("span",{className:"composer-session-id",title:t||void 0,"aria-live":"polite",children:n?"初始化中":t||"—"}),t&&l.jsx("button",{type:"button",className:"composer-session-copy",title:qe?"已复制":"复制会话 ID","aria-label":qe?"已复制会话 ID":"复制会话 ID",onClick:()=>void Mt(),children:qe?l.jsx(Hc,{}):l.jsx(g_,{})})]}),l.jsx("span",{className:"composer-meta-separator","aria-hidden":!0,children:"|"}),l.jsx("span",{children:"回答仅供参考"})]}),l.jsx("input",{ref:oe,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:on}),l.jsx("input",{ref:Ne,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:on}),l.jsx("input",{ref:Oe,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:on})]})}function fft({title:e,sub:t,cards:n,footer:i}){return l.jsxs("div",{className:"stk",children:[l.jsxs("div",{className:"stk-head",children:[l.jsx("h1",{className:"stk-title",children:e}),t&&l.jsx("p",{className:"stk-sub",children:t})]}),l.jsx("div",{className:"stk-list",children:n.map((r,s)=>l.jsxs(wr.button,{type:"button",className:`stk-card ${r.disabled?"stk-card-disabled":""}`,onClick:r.disabled?void 0:r.onClick,disabled:r.disabled,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut",delay:s*.04},children:[l.jsx("span",{className:"stk-card-icon",children:l.jsx(r.icon,{})}),l.jsxs("span",{className:"stk-card-text",children:[l.jsx("span",{className:"stk-card-title",children:r.title}),l.jsx("span",{className:"stk-card-desc",children:r.desc})]}),r.status&&l.jsx("span",{className:"stk-card-status",children:r.status}),l.jsx(U0,{className:"stk-card-arrow"})]},r.key))}),i&&l.jsx("div",{className:"stk-footer",children:i})]})}const hft="modulepreload",pft=function(e){return"/"+e},xH={},$g=function(t,n,i){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=pft(c),c in xH)return;xH[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":hft,u||(f.as="script"),f.crossOrigin="",f.href=c,o&&f.setAttribute("nonce",o),document.head.appendChild(f),u)return new Promise((h,p)=>{f.addEventListener("load",h),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})},mft="_Container_1tuad_1",gft="_Checkbox_1tuad_22",bft="_CheckMark_1tuad_92",Oft="_Label_1tuad_162",pS={Container:mft,Checkbox:gft,CheckMark:bft,Label:Oft},yQ=({className:e,label:t,id:n,disabled:i,orientation:r="left",...s})=>{const a=m.useId(),o=n??a;return l.jsxs("div",{"data-disabled":i?"":void 0,"data-has-label":t?"":void 0,"data-orientation":r,className:Ps(e,pS.Container),children:[l.jsx(M5e,{className:pS.Checkbox,id:o,disabled:i,...s,children:l.jsx(D5e,{className:pS.CheckMark})}),t&&l.jsx("label",{htmlFor:o,className:pS.Label,onMouseDown:c=>{!c.defaultPrevented&&c.detail>1&&c.preventDefault()},children:t})]})},yft="_RadioGroup_onrfm_1",xft="_RadioLabel_onrfm_9",vft="_RadioIndicatorWrapper_onrfm_26",wft="_RadioItem_onrfm_43",Sft="_RadioIndicator_onrfm_26",BO={RadioGroup:yft,RadioLabel:xft,RadioIndicatorWrapper:vft,RadioItem:wft,RadioIndicator:Sft},lpe=m.createContext(null),Eft=()=>{const e=m.use(lpe);if(!e)throw new Error("RadioGroup components must be wrapped in ");return e},UO=({onChange:e,children:t,className:n,direction:i="row",disabled:r=!1,...s})=>{const a=m.useMemo(()=>({disabled:r,direction:i}),[r,i]);return l.jsx(lpe,{value:a,children:l.jsx(U$e,{className:Ps(BO.RadioGroup,n),"data-direction":i,onValueChange:e,disabled:r,...s,children:t})})},kft=({value:e,disabled:t=!1,required:n,children:i,className:r,block:s=!1,...a})=>{const{disabled:o}=Eft(),c=o||t,u=m.useId(),d=`${e}-${u}`;return l.jsx("div",{className:"flex",...a,children:l.jsxs("label",{htmlFor:d,className:Ps(BO.RadioLabel,r),"data-disabled":c?"":void 0,"data-block":s?"":void 0,onMouseDown:f=>{!f.defaultPrevented&&f.detail>1&&f.preventDefault()},children:[l.jsx("div",{className:BO.RadioIndicatorWrapper,children:l.jsx(X$e,{id:d,value:e,disabled:c,required:n,className:BO.RadioItem,children:l.jsx(H$e,{className:BO.RadioIndicator})})}),i]})})};UO.Item=kft;function WA(e,t){return t[e.key]??e.defaultValue??""}function cpe(e){const t=new Map,n={};for(const i of e){for(const r of i.env){const s=t.get(r.key);(!s||r.required&&!s.required)&&t.set(r.key,r)}i.enableFlag&&(t.set(i.enableFlag,{key:i.enableFlag,required:!0}),n[i.enableFlag]="true")}return{specs:[...t.values()],fixedValues:n}}function Tft(e,t){return cpe([{env:e}]).specs.map(i=>({...i,value:i.serverManaged?i.placeholder||"由服务端注入":WA(i,t)}))}function upe(e,t){const n=new Map;for(const i of e){if(i.serverManaged)continue;const r=WA(i,t);r.trim()&&n.set(i.key,r)}return[...n].map(([i,r])=>({key:i,value:r}))}function vH(e,t){return e.find(n=>n.required&&!n.serverManaged&&!WA(n,t).trim())}function xQ(e,t){if(e.format!=="json")return;const n=WA(e,t).trim();if(n)try{JSON.parse(n);return}catch{return"JSON 格式不正确"}}function dpe(e,t){for(const n of e){const i=xQ(n,t);if(i)return{spec:n,error:i}}}function _ft({className:e,...t}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.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"}),l.jsx("path",{d:"M12 6.5c.4 2.4 1 3 3.4 3.4-2.4.4-3 1-3.4 3.4-.4-2.4-1-3-3.4-3.4 2.4-.4 3-1 3.4-3.4Z"})]})}const Mm={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:_ft},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:Zwe},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:hSe},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:mJ},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:O_}},Aft=[Mm.llm,Mm.sequential,Mm.parallel,Mm.loop,Mm.a2a];function fpe(e){return Mm[e??"llm"]}const hpe=e=>e==="sequential"||e==="parallel"||e==="loop",ZA=e=>e==="a2a";function r1(e){return e.trimEnd().replace(/[。.]+$/,"")}function up(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(i=>i==null?void 0:i.toLocaleLowerCase().includes(n)):!0}const ppe=new Set(["local","sqlite","mysql","postgresql"]),mpe=new Set(["local","opensearch","redis","viking","openviking","mem0"]),gpe=new Set(["opensearch","viking","context_search","openviking"]),bpe=new Set(["apmplus","cozeloop","tls"]),Ope=new Set(["web_search","parallel_web_search","link_reader","web_scraper","image_generate","image_edit","video_generate","text_to_speech","run_code","vesearch"]),Nft=new Set(["llm","sequential","parallel","loop","a2a"]);function nn(e,t=""){return typeof e=="string"?e:t}function lo(e){return e===!0}function Ry(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Cft(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}function ype(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"?{name:nn(t.name),description:nn(t.description)}:null).filter(t=>!!t&&!!t.name.trim()):[]}function Qg(e,t,n){return typeof e=="string"&&t.has(e)?e:n}function xpe(e){return typeof e=="string"&&Nft.has(e)?e:"llm"}function vpe(e){return e==="byteplus"?"byteplus":"volcengine"}function wpe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):3}function Spe(e){const t=e&&typeof e=="object"?e:{};return{enabled:lo(t.enabled),registrySpaceId:nn(t.registrySpaceId),registryTopK:nn(t.registryTopK),registryRegion:nn(t.registryRegion),registryEndpoint:nn(t.registryEndpoint)}}function Epe(e,t="volcengine"){return Array.isArray(e)?e.map(n=>{const i=n&&typeof n=="object"?n:{},r=vpe(i.cloudProvider??t),s=i.memory&&typeof i.memory=="object"?i.memory:{},a=Spe(i.a2aRegistry),o=xpe(i.agentType),c=a.enabled&&o==="llm"?"a2a":o;return{...el(r),cloudProvider:r,name:nn(i.name),description:nn(i.description),instruction:nn(i.instruction),agentType:c,maxIterations:wpe(i.maxIterations),a2aUrl:nn(i.a2aUrl),modelName:nn(i.modelName),modelSource:i.modelSource==="custom"||i.modelSource==="ark"?i.modelSource:void 0,modelProvider:nn(i.modelProvider),modelApiBase:nn(i.modelApiBase),builtinTools:Ry(i.builtinTools).filter(u=>Ope.has(u)),customTools:ype(i.customTools),memory:{shortTerm:lo(s.shortTerm),longTerm:lo(s.longTerm)},shortTermBackend:Qg(i.shortTermBackend,ppe,"local"),longTermBackend:Qg(i.longTermBackend,mpe,"local"),autoSaveSession:lo(i.autoSaveSession),knowledgebase:lo(i.knowledgebase),knowledgebaseBackend:Qg(i.knowledgebaseBackend,gpe,wf),knowledgebaseIndex:nn(i.knowledgebaseIndex),tracing:lo(i.tracing),tracingExporters:Ry(i.tracingExporters).filter(u=>bpe.has(u)),a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,subAgents:Epe(i.subAgents,r),selectedSkills:kpe(i)}}):[]}function kpe(e){if(!Array.isArray(e.selectedSkills))return[];const t=[];for(const n of e.selectedSkills){const i=n&&typeof n=="object"?n:{},r=nn(i.source),s=r==="local"||r==="skillspace"||r==="skillhub"?r:"skillhub",a=nn(i.name)||nn(i.slug)||nn(i.skillName)||nn(i.skillId)||"skill",o=nn(i.folder)||a,c=nn(i.description);if(s==="skillhub"){const f=nn(i.slug);if(!f)continue;t.push({source:s,folder:o,name:a,description:c,slug:f,namespace:nn(i.namespace)||"public"});continue}if(s==="local"){const h=(Array.isArray(i.localFiles)?i.localFiles:[]).map(p=>{const g=p&&typeof p=="object"?p:{},b=nn(g.path),y=nn(g.content);return b?{path:b,content:y}:null}).filter(p=>p!==null);if(h.length===0)continue;t.push({source:s,folder:o,name:a,description:c,localFiles:h});continue}const u=nn(i.skillSpaceId),d=nn(i.skillId);!u||!d||t.push({source:s,folder:o,name:a,description:c,skillSpaceId:u,skillSpaceName:nn(i.skillSpaceName),skillId:d,version:nn(i.version)})}return t}function jft(e){const t=e&&typeof e=="object"?e:{},n=t.memory&&typeof t.memory=="object"?t.memory:{},i=t.deployment&&typeof t.deployment=="object"?t.deployment:{},r=Cft(i.envValues),s=Spe(t.a2aRegistry),a=xpe(t.agentType),o=s.enabled&&a==="llm"?"a2a":a,c=vpe(t.cloudProvider),u=Array.isArray(t.mcpTools)?t.mcpTools.map(d=>{const f=d&&typeof d=="object"?d:{},h=f.transport==="stdio"?"stdio":"http";return{name:nn(f.name),transport:h,url:nn(f.url),authToken:nn(f.authToken),authTokenEnv:nn(f.authTokenEnv),command:nn(f.command),args:Ry(f.args)}}).filter(d=>d.transport==="http"?!!d.url:!!d.command):[];return{...el(c),cloudProvider:c,name:nn(t.name)||"my_agent",description:nn(t.description),instruction:nn(t.instruction)||"You are a helpful assistant.",agentType:o,maxIterations:wpe(t.maxIterations),a2aUrl:nn(t.a2aUrl),modelName:nn(t.modelName),modelSource:t.modelSource==="custom"||t.modelSource==="ark"?t.modelSource:void 0,modelProvider:nn(t.modelProvider),modelApiBase:nn(t.modelApiBase),builtinTools:Ry(t.builtinTools).filter(d=>Ope.has(d)),customTools:ype(t.customTools),mcpTools:u,a2aRegistry:o==="a2a"?{...s,enabled:!0}:s,memory:{shortTerm:lo(n.shortTerm),longTerm:lo(n.longTerm)},shortTermBackend:Qg(t.shortTermBackend,ppe,"local"),longTermBackend:Qg(t.longTermBackend,mpe,"local"),autoSaveSession:lo(t.autoSaveSession),knowledgebase:lo(t.knowledgebase),knowledgebaseBackend:Qg(t.knowledgebaseBackend,gpe,wf),knowledgebaseIndex:nn(t.knowledgebaseIndex),tracing:lo(t.tracing),tracingExporters:Ry(t.tracingExporters).filter(d=>bpe.has(d)),deployment:{feishuEnabled:lo(i.feishuEnabled),runtimeName:nn(i.runtimeName),runtimeNameCustomized:lo(i.runtimeNameCustomized)||!!nn(i.runtimeName).trim(),modelApiKeyId:nn(i.modelApiKeyId),modelApiKeyName:nn(i.modelApiKeyName),...Object.keys(r).length>0?{envValues:r}:{}},subAgents:Epe(t.subAgents,c),selectedSkills:kpe(t)}}function Tpe(e,t=e.cloudProvider??"volcengine"){const n=e.cloudProvider??t,i=new Set(Vne(n).map(r=>r.id));return{...e,builtinTools:(e.builtinTools??[]).filter(r=>i.has(r)),tracing:!1,tracingExporters:[],memory:{shortTerm:!1,longTerm:!1},shortTermBackend:"local",longTermBackend:"local",autoSaveSession:!1,knowledgebase:!1,knowledgebaseBackend:wf,knowledgebaseIndex:"",subAgents:e.subAgents.map(r=>Tpe(r,n))}}const Rft=/^[A-Za-z_][A-Za-z0-9_]*$/,vQ=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function wH(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Ift(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function _pe(e){var n,i,r;const t=(n=e.authTokenEnv)==null?void 0:n.trim();return t&&Rft.test(t)?t:((r=(i=e.authToken)==null?void 0:i.trim().match(vQ))==null?void 0:r[1])??""}function Pft(e){if(e.authToken)return e.authToken;const t=_pe(e);return t?`\${${t}}`:""}function Mft(e,t){if(!t){const i={...e};return delete i.authToken,delete i.authTokenEnv,i}const n=t.trim().match(vQ);if(n){const i={...e,authTokenEnv:n[1]};return delete i.authToken,i}return{...e,authToken:t}}function Lft(e){if(!e.trim())return!1;try{return!new URL(e).pathname.replace(/\/+$/,"").endsWith("/mcp")}catch{return!1}}function KA(e){const t=new Set,n={},i=r=>{var u;const s=wH(r.name,"AGENT"),a=(u=r.mcpTools)==null?void 0:u.map((d,f)=>{var O,v;const h=((O=d.authToken)==null?void 0:O.trim())??"",p=((v=h.match(vQ))==null?void 0:v[1])??"";let b=_pe(d);if(!b&&h){const x=wH(d.name,`TOOL_${f+1}`);b=Ift(`MCP_${s}_${x}_AUTH_TOKEN`,t)}b&&t.add(b),b&&h&&!p&&(n[b]=h);const y={...d};return delete y.authToken,b?y.authTokenEnv=b:delete y.authTokenEnv,y}),o=r.subAgents.map(i),c=r.workflow?{...r.workflow,nodes:r.workflow.nodes.map(d=>({...d,agent:i(d.agent)}))}:void 0;return{...r,subAgents:o,...a?{mcpTools:a}:{},...c?{workflow:c}:{}}};return{draft:i(e),envValues:n}}function Ape(e){var n,i,r,s,a,o,c,u,d,f,h,p,g,b,y,O,v,x,w,E,S,k,T,A,N,C,M,L,P,Q,j,$,U,B,I,X;const t={agentType:e.agentType??"llm"};if(e.agentType==="a2a"){if((n=e.a2aRegistry)!=null&&n.enabled){const q={enabled:!0};(i=e.a2aRegistry.registrySpaceId)!=null&&i.trim()&&(q.registrySpaceId=e.a2aRegistry.registrySpaceId.trim()),q.registryTopK=((r=e.a2aRegistry.registryTopK)==null?void 0:r.trim())||Pl.topK,q.registryRegion=((s=e.a2aRegistry.registryRegion)==null?void 0:s.trim())||Pl.region,q.registryEndpoint=((a=e.a2aRegistry.registryEndpoint)==null?void 0:a.trim())||Pl.endpoint,t.a2aRegistry=q}return t}if(t.name=e.name,t.description=e.description,t.instruction=e.instruction,e.agentType==="loop"&&(t.maxIterations=e.maxIterations??3),(o=e.modelName)!=null&&o.trim()&&(t.modelName=e.modelName.trim()),e.modelSource&&(t.modelSource=e.modelSource),e.modelSource!=="ark"&&((c=e.modelProvider)!=null&&c.trim()&&(t.modelProvider=e.modelProvider.trim()),(u=e.modelApiBase)!=null&&u.trim()&&(t.modelApiBase=e.modelApiBase.trim())),(d=e.builtinTools)!=null&&d.length&&(t.builtinTools=[...e.builtinTools]),(f=e.customTools)!=null&&f.length&&(t.customTools=e.customTools.map(q=>({name:q.name,description:q.description}))),(h=e.mcpTools)!=null&&h.length&&(t.mcpTools=e.mcpTools.map(q=>{var H,re,fe,Ae;const D={name:q.name,transport:q.transport};return(H=q.url)!=null&&H.trim()&&(D.url=q.url.trim()),(re=q.authTokenEnv)!=null&&re.trim()&&(D.authTokenEnv=q.authTokenEnv.trim()),(fe=q.command)!=null&&fe.trim()&&(D.command=q.command.trim()),(Ae=q.args)!=null&&Ae.length&&(D.args=q.args),D})),((p=e.memory)!=null&&p.shortTerm||(g=e.memory)!=null&&g.longTerm)&&(t.memory={shortTerm:!!e.memory.shortTerm,longTerm:!!e.memory.longTerm},e.memory.shortTerm&&(t.shortTermBackend=e.shortTermBackend||"local"),e.memory.longTerm&&(t.longTermBackend=e.longTermBackend||"local",t.autoSaveSession=!!e.autoSaveSession)),e.knowledgebase&&(t.knowledgebase=!0,t.knowledgebaseBackend=e.knowledgebaseBackend||"viking",(b=e.knowledgebaseIndex)!=null&&b.trim()&&(t.knowledgebaseIndex=e.knowledgebaseIndex.trim())),e.tracing&&((y=e.tracingExporters)!=null&&y.length)&&(t.tracing=!0,t.tracingExporters=[...e.tracingExporters]),(O=e.deployment)!=null&&O.feishuEnabled||(x=(v=e.deployment)==null?void 0:v.runtimeName)!=null&&x.trim()||(w=e.deployment)!=null&&w.runtimeNameCustomized||(S=(E=e.deployment)==null?void 0:E.modelApiKeyId)!=null&&S.trim()||(T=(k=e.deployment)==null?void 0:k.modelApiKeyName)!=null&&T.trim()||Object.keys(((A=e.deployment)==null?void 0:A.envValues)??{}).length>0){const q={feishuEnabled:!!((N=e.deployment)!=null&&N.feishuEnabled)};(M=(C=e.deployment)==null?void 0:C.runtimeName)!=null&&M.trim()&&(q.runtimeName=e.deployment.runtimeName.trim()),(L=e.deployment)!=null&&L.runtimeNameCustomized&&(q.runtimeNameCustomized=!0),(Q=(P=e.deployment)==null?void 0:P.modelApiKeyId)!=null&&Q.trim()&&(q.modelApiKeyId=e.deployment.modelApiKeyId.trim()),($=(j=e.deployment)==null?void 0:j.modelApiKeyName)!=null&&$.trim()&&(q.modelApiKeyName=e.deployment.modelApiKeyName.trim()),Object.keys(((U=e.deployment)==null?void 0:U.envValues)??{}).length>0&&(q.envValues={...(B=e.deployment)==null?void 0:B.envValues}),t.deployment=q}return(I=e.selectedSkills)!=null&&I.length&&(t.selectedSkills=e.selectedSkills.map(q=>{const D={source:q.source,name:q.name,folder:q.folder};return q.description&&(D.description=q.description),q.source==="skillhub"?(D.slug=q.slug,D.namespace=q.namespace??"public"):q.source==="local"?D.localFiles=q.localFiles??[]:(D.skillSpaceId=q.skillSpaceId,D.skillSpaceName=q.skillSpaceName,D.skillId=q.skillId,q.version&&(D.version=q.version)),D})),(X=e.subAgents)!=null&&X.length&&(t.subAgents=e.subAgents.map(Ape)),t}function Dft(e){var r;const t=KA(e),n={...((r=t.draft.deployment)==null?void 0:r.envValues)??{},...t.envValues},i={...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}};return`# VeADK Agent 结构配置 +`}).map(([n,i])=>[n,i.split("__PROJECT_NAME__").join(e)]))}const sut={id:"template",kind:"github",category:"development",icon:"github",name:"模板项目导入",description:"在您的仓库中创建一个可持续交付到 AgentKit Runtime 的最简智能体",title:"模板项目导入",subtitle:"把可直接启动 Studio 的 basic Agent 和持续交付配置加入仓库",panel:"提交后将创建一个 PR,同时导入 basic 项目和 AgentKit Runtime 发布工作流。",submitLabel:"导入模板并提交 PR",fields:[uQ,dQ,{name:"projectPath",label:"Agent 项目目录",placeholder:"agentkit-basic-agent",help:"将在此目录新增 basic 项目;app.py 挂载完整 Studio App Server,并作为服务入口启动",required:!0},qhe,Hhe],initialValues:fQ({projectPath:"agentkit-basic-agent"}),regionHelp:"必须与目标 Runtime 所在地域一致",secrets:["VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)","VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)"],submit(e,t){const n=hQ(e),i=Xhe(n.repository),r=lQ(e.projectPath,"agentkit-basic-agent"),s=r==="."?i.split("/").slice(-1)[0]||"agentkit-basic-agent":r.split("/").slice(-1)[0]||"agentkit-basic-agent",a=Object.entries(rut(s)).map(([o,c])=>({path:nut(r,o),content:c,commitMessage:"feat: import AgentKit basic template",mustBeNew:!0}));return a.push({path:iut(r),content:Whe({baseBranch:n.baseBranch,projectPath:r,runtimeName:e.runtimeName.trim(),runtimeId:e.runtimeId.trim(),region:n.region}),commitMessage:"feat: add AgentKit Runtime delivery",mustBeNew:!0}),cQ({...n,repository:i,files:a,branchPrefix:"feat/agentkit-basic-template",title:"feat: 导入 AgentKit basic 模板",description:"导入带有 AgentKit Studio App Server 的 basic Agent 项目,并添加持续发布到 AgentKit Runtime 的工作流。合并前请配置 Volcengine Secrets。"},t)}},Wq=[{id:"development",label:"研发"},{id:"channels",label:"消息渠道"}],Zhe=[Lct,sut,tut,Yct,Dct],aut=new Map(Zhe.map(e=>[e.id,e]));function Khe(e){const t=aut.get(e);if(!t)throw new Error(`Unknown automation: ${e}`);return t}function out(e){const t=Khe(e);if(t.kind!=="github")throw new Error(`Automation is not backed by GitHub: ${e}`);return t}const mQ="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2048%2048'%3e%3cimage%20width='48'%20height='48'%20href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAAH7UlEQVRoBdVZWWwbVRQ9492Onc1xTfaWLukq9oSqLKnYBZRSNgn6AagsAgmJRfzxg4SEEDtiER8IBKKAChK0FS1tKYWW0lZQKKV0gxCVJm3ikDiO17EdzrUzSdw4jj1OpeQqNzO237vvnHfvu/e9GWVwcBBDYue1mrqE2kI1UqeSJAnmIHUzNUCNUmGiKtQy6oPUR6geqnw/FSVOUH9R36KupfaDHnBQn6MGqEnqVJcEAfZTBbNL4b+lZPI1VbwwnaSfYO8z8N+TVMd0Qj6EVdbs3eIBP29cVFkL00kk+wSEwHAamgh9bDAJSQWTITZFnF+85J1tBPyOUC9OqqnsVdTIRkVBi70Msy125uriHJ8XAXFRfzKBTQM+rO0/hc54cSQE8iyzAx/XLcEltjIU44uCQijOaHvPfxIv97TjWCzEcMo7+sZ4TGa+2V6KT2rPQ73ZptsPBZE30fVrymvxTvUCtDoqYC0ijhMk/3MkgDd62xFheOqVggjIIAbOVaujEh/ULsaNzioUsxhVAv/A34GD0YBubxZMQJupWpMNr58zHytcHth1ekICsDcRx4u+fxBK6vOCbgKyEIXEK975WOmaoZuErKv1QR8ORQd0eUE3Ac0TNSYrXvI24fZSLxwGfebiDKW3e08gln9J0oYvKoMNG6kmiRdmzMOtTi8sOsJJJfANA93oiseGbeZ7k1EHZAKCEcApu4wCxUsSz3rm4HQiim3B/wpOsBJA2yP/4cZIJYIBFcGwCjWeSKEwm4wosZtR7rKizGXJQJZRB1TuttftAprnAbOrM9rl9UHqwg+s1o+eOow/GNN5CaPOklSgdKq4us+Ji7pt6Dw1AF9vBOGImjJht5lRVWFDY7UL58/3wOt2YPEcN2xWVpPRe6EQC+y9rwINPNKsuRaYX5cXhIxGkks+Y7V+6vQRdLBi5yx1bGwicFebivj+ARgOhZGMJMFyQyWpoV2GRIa2ZXOX2bDyqnPxzEPNKC+1Zj957eDBTbz34PXAwvoMfBN+kGV8Bxf00VgQz/vaEB6nSCnRQVj2h2DZG4TyZwQWlSils3m8RDDEhk2uaqlHaYklVb3Ha42dh4B3eMzZ//eEmMc0kGL3cEU9WksqU4XvzAYKZ9n6fQCOz3thORCGkhgCf2bDMz4bjQpW39yE65Y1QO5FxiUgP+76E3hzI7D1VyBcwP5NTFcZzXjaPRMNZmvGPkfA23YMwLHRD0Mf3ZwTgaBIi8GgYMGsSjx2z3kEP9Jp5E5rOeoqQH75C3htPfDpD4CskXxFvHC5vQKPVjSwPqQfcKTAfxuA/Ws/lBAXwEhUTGjWSAL3r1qYykSju+UkIFbZDx09wPvb0iH1W9uEYw03MHAV3ltew1CqgDkyCNtWgt/cnwY/3GriG5n9hbMrccNljRmzLz0nJCCNJBsEwsCH24E3NgDr96brhfyWS2Sm3EYLVsOL0i0DsG8h+LDkqcLExHhfc9siVDDrjJ59sZJRyHKZFRKybiSkTtIjR08CrXwEdtGcXL2A4+192LOuDeatfqg6wMvsL5lbhWuWysIdO995E9BgSkh19THX7wQOtANXLgKWLQSaarUWI9dNP7bjo68OY9uef6GqhcW8ZkViX2a/nBWYQ4+RggmIBfFGnHgOcD0c7wD2HgOW0xuXk0xN5SDaOwL4cnsb1m05joPHejKK0hgEOb4Q8Muba3H1pXUwZZl96aqLgHSU2RCbEe6/9hzh875OYPdhYF5NDLt/Oohd+46gNxBjm2zzJhZyi/RyV5TggdsvRJnTOm5j3QQ0i9ra6OHj1u9+B/YdNcLXVQdDmYNPy9oZ971IcIPHjUHadVrHHFfZNphtTtx508W4eJEHsg7Gk6IJaIZlDEn3EdUEl7sBg4la2MtqkYgNIOz/F9FgF6IhX6p5mozcjgbGasw/xWCCs7IeN7U24b4VddwZj26jjTZynTQCmknxSBqIETanh7ceWEpmpIiokT7E6JFosBvxaD/iJCeNDQYzTFYnzHY3SsobmfM9eOyucjTO0KyOf510AqOHkl2kiMlSQoAlsPLAk4hHSCaIJMMqmUgfYBQeggxGK4xmOxprXHh8lYK51em+E/0/qwQyBh8iY+Q52pjlOZD8XFcFPHELcGlT3stlbBaymtOROTReBoZJ+0DjZ9pv4SFq9fL0YWqcjJl1+AwP8OSGS+amq6y4P/fyyWqvoC9lDAG7ainPEJcBs7xMBGOLbU6bGQTMJHAnDUlG2biPFZevEM4GCZl9sSsnPgG+bAHfa+l8vZJxpNSo+oPp/c4XP6bPBN0kog2qtdFz1WzIkfXmZuAKVm6JewlbvZKVgGZMilMPwW9ngdr5B3CEG7iEbCY5ffl6RgPtYDGdybS4ogW4YDbgLefTD5s2kv5rTgKaWdlKi1fau4BDJ3jM5I70NDd0J7grzfZEUMg5CM5Tmg4TiW3ZtVYxTKpcgM2iWS7+mhcBbRiZ/TBTd4jPjtSEVF3AxxdUPgkxTrUUMTcBykKUmLZwhQlYPhWBeCBV5DRjk3QtiEC2McUDsjPVCEhWEQ8Umk2y2c7nOyEwrV/ySdbdQo3nw3aKtRHM3wiBtVQu02knISJ+SQh8Q32TyqTJJ6xTXyQzyzb2LeoBWQOy5pjwcDf1YSqzNIooLex99kTCppsq4N+l+oUArylhoku9sb+O18VU8c5UEiZu7KGyrKKTmgr7/wGxhy03aZIycwAAAABJRU5ErkJggg=='%20/%3e%3c/svg%3e";function Jhe(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91 .58 .11 .79-.25.79-.56v-2.02c-3.2.7-3.88-1.36-3.88-1.36-.52-1.33-1.28-1.69-1.28-1.69-1.05-.72.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.71 1.26 3.37.96.1-.75.4-1.26.73-1.55-2.56-.29-5.25-1.28-5.25-5.7 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.47.11-3.06 0 0 .97-.31 3.16 1.18A10.98 10.98 0 0 1 12 6.11c.98 0 1.96.13 2.87.39 2.19-1.49 3.16-1.18 3.16-1.18.63 1.59.23 2.77.11 3.06.74.81 1.19 1.84 1.19 3.1 0 4.43-2.7 5.4-5.27 5.69.42.36.78 1.06.78 2.14v3.04c0 .31.21.67.8.56A11.51 11.51 0 0 0 23.5 12C23.5 5.65 18.35.5 12 .5Z"})})}function Zq(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.2",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.4 15.4 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function lut(e){return l.jsxs("svg",{viewBox:"0 0 36 36",fill:"none","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",fill:"currentColor",opacity:"0.1"}),l.jsx("rect",{x:"3.5",y:"5",width:"18",height:"18",rx:"5",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("path",{d:"m9.2 11.2-2.8 2.7 2.8 2.7M12.1 17.4h4.3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("circle",{cx:"26.5",cy:"12",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("circle",{cx:"27",cy:"26.5",r:"3",fill:"hsl(var(--background))",stroke:"currentColor",strokeWidth:"1.6"}),l.jsx("path",{d:"M21.5 12h2M19.3 21l5.6 3.8M27 15v8.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function cut({onOpen:e}){var u;const[t,n]=m.useState("development"),[i,r]=m.useState(""),s=m.useDeferredValue(i),a=m.useMemo(()=>{const d=s.trim().toLocaleLowerCase();return Zhe.filter(f=>f.category===t).filter(f=>!d||`${f.name} ${f.description}`.toLocaleLowerCase().includes(d))},[t,s]),o=(u=Wq.find(d=>d.id===t))==null?void 0:u.label,c=Mct(window.location.hostname);return l.jsxs("div",{className:"applications-page",children:[l.jsxs("header",{className:"applications-header",children:[l.jsxs("div",{children:[l.jsx("h1",{children:"自动化"}),l.jsx("p",{children:"连接研发工具,为智能体扩展自动化工作流"})]}),l.jsxs("label",{className:"applications-search",children:[l.jsx(Zq,{}),l.jsx("input",{type:"search","aria-label":"搜索自动化",value:i,onChange:d=>r(d.target.value),placeholder:"搜索自动化"})]})]}),l.jsx("nav",{className:"applications-categories","aria-label":"自动化分类",children:Wq.map(d=>l.jsx("button",{type:"button",className:t===d.id?"is-active":"","aria-pressed":t===d.id,onClick:()=>n(d.id),children:d.label},d.id))}),l.jsx("section",{className:"applications-results","aria-label":`${o}自动化列表`,children:a.length?l.jsx("div",{className:"applications-grid",children:a.map(d=>{const f=d.id==="coding-agents"&&!c,h=f?"coding-agents-local-only-tooltip":void 0;return l.jsxs("div",{className:`application-card-wrap${f?" is-disabled":""}`,tabIndex:f?0:void 0,"aria-describedby":h,children:[l.jsxs("button",{type:"button",className:"application-card",onClick:()=>e(d.id),"aria-label":`打开${d.name}`,disabled:f,children:[d.icon==="feishu"?l.jsx("img",{className:"application-card-icon application-card-brand-icon",src:mQ,alt:"","aria-hidden":"true"}):d.icon==="coding-agents"?l.jsx(lut,{className:"application-card-icon"}):l.jsx(Jhe,{className:"application-card-icon"}),l.jsxs("div",{className:"application-card-copy",children:[l.jsxs("div",{className:"application-card-title",children:[l.jsx("h2",{children:d.name}),d.badge?l.jsx("span",{className:`application-card-badge is-${d.badgeTone||"default"}`,children:d.badge}):null]}),l.jsx("p",{children:d.description})]})]}),f?l.jsx("span",{id:h,className:"application-card-tooltip",role:"tooltip",children:"仅本地部署可用"}):null]},d.id)})}):l.jsxs("div",{className:"applications-empty",role:"status",children:[l.jsx(Zq,{}),l.jsx("h2",{children:"没有匹配的自动化"}),l.jsx("p",{children:"请尝试搜索其他名称"})]})})]})}const uut={volcengine:"https://console.volcengine.com",byteplus:"https://console.byteplus.com"};function n1(e){return e.trim()}function gQ(e){return uut[e]}function dut(e){const t=n1(e);if(!t)return null;let n=t;try{n=new URL(t.includes("://")?t:`https://${t}`).hostname}catch{return null}const i=n.match(/^(.+)\.tos-([a-z0-9-]+)\.(?:volces|bytepluses)\.com$/i);return i?{bucket:i[1],region:i[2]}:null}function fut(e,t){const n=dut(t);if(!n)return null;const i=new URLSearchParams({id:n.bucket,region:n.region,type:"objects"});return`${gQ(e)}/tos/bucket/setting?${i.toString()}`}function hut(e,t,n){const i=n1(t),r=n1(n);return!i||!r?null:`${gQ(e)}/agentkit/region:agentkit+${encodeURIComponent(i)}/builtintools/${encodeURIComponent(r)}/detail`}function put(e,t,n){const i=n1(t),r=n1(n);return!i||!r?null:`${gQ(e)}/identity/region:identity+${encodeURIComponent(i)}/user-pools/${encodeURIComponent(r)}/info`}function nR({href:e,label:t,children:n}){return e?l.jsxs("a",{className:"system-info-resource-link",href:e,target:"_blank",rel:"noreferrer","aria-label":t,title:t,children:[l.jsx("span",{children:n}),l.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"M7.75 5.25h-2.5a1.5 1.5 0 0 0-1.5 1.5v8a1.5 1.5 0 0 0 1.5 1.5h8a1.5 1.5 0 0 0 1.5-1.5v-2.5"}),l.jsx("path",{d:"M10.25 3.75h6v6M16 4 9 11"})]})]}):l.jsx("span",{children:n})}function mut(e){return e instanceof Error&&e.message.includes("Volcengine credentials not found")}function gut({version:e,localMode:t,role:n,provider:i,region:r}){const s=n==="admin",[a,o]=m.useState(""),[c,u]=m.useState([]),[d,f]=m.useState([]),[h,p]=m.useState(!0),[g,b]=m.useState(""),[y,O]=m.useState(!0),[v,x]=m.useState(""),[w,E]=m.useState(0),[S,k]=m.useState(0);return m.useEffect(()=>{if(!s){o(""),u([]),p(!1),b("");return}const T=new AbortController;return p(!0),b(""),iee(T.signal).then(A=>{o(A.storage.tosAddress),u(A.sandboxTools)}).catch(A=>{(A==null?void 0:A.name)!=="AbortError"&&b(A instanceof Error?A.message:String(A))}).finally(()=>{T.signal.aborted||p(!1)}),()=>T.abort()},[s,w]),m.useEffect(()=>{if(!s){f([]),O(!1),x("");return}const T=new AbortController;return O(!0),x(""),KD(T.signal).then(A=>{f(A.filter(N=>N.isCurrent))}).catch(A=>{if((A==null?void 0:A.name)!=="AbortError"){if(t&&mut(A)){f([]);return}x(A instanceof Error?A.message:String(A))}}).finally(()=>{T.signal.aborted||O(!1)}),()=>T.abort()},[s,t,S]),l.jsxs("div",{className:"system-info-page",children:[l.jsxs("header",{className:"system-info-page-header",children:[l.jsx("h1",{children:"系统信息"}),l.jsx("p",{children:"查看当前 Studio 版本及关联的基础资源"})]}),l.jsxs("div",{className:"system-info-scroll",children:[l.jsxs("section",{className:"system-info-section","aria-labelledby":"studio-info-title",children:[l.jsx("h2",{id:"studio-info-title",children:"通用"}),l.jsx("dl",{className:"system-info-summary",children:l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:e||"—"})]})})]}),s?l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"system-info-section","aria-labelledby":"storage-info-title",children:[l.jsx("h2",{id:"storage-info-title",children:"存储"}),h?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载存储信息"})}):g?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:g}),l.jsx("button",{type:"button",onClick:()=>E(T=>T+1),children:"重新加载"})]}):l.jsx("dl",{className:"system-info-summary",children:l.jsxs("div",{className:"system-info-resource-row",children:[l.jsx("dt",{children:"TOS 地址"}),l.jsx("dd",{className:`system-info-resource-value${a?"":" is-empty"}`,children:l.jsx(nR,{href:fut(i,a),label:"在云控制台中打开 TOS 存储桶",children:a||"未配置"})})]})})]}),l.jsxs("section",{className:"system-info-section","aria-labelledby":"sandbox-tool-title",children:[l.jsx("h2",{id:"sandbox-tool-title",children:"沙箱信息"}),h?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载沙箱信息"})}):g?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:g}),l.jsx("button",{type:"button",onClick:()=>E(T=>T+1),children:"重新加载"})]}):l.jsx("div",{className:"system-info-tool-list",children:c.map(T=>l.jsx("dl",{className:"system-info-tool",children:l.jsxs("div",{className:"system-info-resource-row",children:[l.jsxs("dt",{className:"system-info-tool-label",children:[l.jsx("span",{children:T.label}),T.snapshot?l.jsx("span",{className:"system-info-tool-badge",children:"快照版"}):null]}),l.jsx("dd",{className:`system-info-resource-value${T.toolId?"":" is-empty"}`,children:l.jsx(nR,{href:hut(i,r,T.toolId),label:`在云控制台中打开${T.label}`,children:T.toolId||"未配置"})})]})},T.kind))})]}),l.jsxs("section",{className:"system-info-section","aria-labelledby":"user-pool-title",children:[l.jsx("h2",{id:"user-pool-title",children:"用户池"}),y?l.jsx("div",{className:"system-info-loading",role:"status","aria-live":"polite",children:l.jsx(oi,{as:"span",children:"正在加载用户池"})}):v?l.jsxs("div",{className:"system-info-error",role:"alert",children:[l.jsx("p",{children:v}),l.jsx("button",{type:"button",onClick:()=>k(T=>T+1),children:"重新加载"})]}):d.length>0?l.jsx("div",{className:"system-info-pool-list",children:d.map(T=>l.jsxs("dl",{className:"system-info-pool",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"名称"}),l.jsx("dd",{className:"system-info-resource-value",children:l.jsx(nR,{href:put(i,T.region||r,T.uid),label:`在云控制台中打开用户池${T.name?`“${T.name}”`:""}`,children:T.name||"未命名用户池"})})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"ID"}),l.jsx("dd",{children:T.uid||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"域名"}),l.jsx("dd",{children:T.domain||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"区域"}),l.jsx("dd",{children:T.region||"—"})]})]},T.uid))}):l.jsx("p",{className:"system-info-empty",children:t?"本地模式未配置用户池":"当前 Studio 未配置用户池"})]})]}):null]})]})}function but(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Out({hidden:e,...t}){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("path",{d:"M2.5 10s2.6-4 7.5-4 7.5 4 7.5 4-2.6 4-7.5 4-7.5-4-7.5-4Z"}),l.jsx("circle",{cx:"10",cy:"10",r:"1.8"}),e?l.jsx("path",{d:"m4 4 12 12"}):null]})}function Kq(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function yut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function xut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function iR(e,t,n){const i=t.trim();if(!i)return n?"此项不能为空":"";if(e==="repository"&&!/^(?:https:\/\/github\.com\/)?[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:\.git)?$/.test(i))return"请输入 owner/repository 或完整 GitHub Repo URL";if(e==="baseBranch"&&(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(i)||i.includes("..")))return"目标分支格式不正确";if(e==="projectPath"&&(i.startsWith("/")||i.split("/").includes("..")))return"请输入仓库内的相对目录";if(e==="runtimeName")return pQ(i)??"";if(e==="runtimeId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(i))return"Runtime ID 格式不正确";if(e==="sandboxToolId"&&!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(i))return"Sandbox Tool ID 格式不正确";if(e==="modelName"&&!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(i))return"模型名称格式不正确";if(e==="modelBaseUrl")try{const r=new URL(i);if(r.protocol!=="https:"||r.username||r.password||r.search||r.hash)return"请输入不含凭据、查询参数或锚点的 HTTPS 地址"}catch{return"请输入有效的 HTTPS 地址"}return""}function vut({automation:e,onBack:t}){const n=out(e),[i,r]=m.useState(()=>({...n.initialValues})),[s,a]=m.useState({}),[o,c]=m.useState(""),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(!1),[b,y]=m.useState(null),O=m.useRef(null);m.useEffect(()=>()=>{var k;return(k=O.current)==null?void 0:k.abort()},[]);const v=(k,T)=>{r(A=>({...A,[k]:T})),s[k]&&a(A=>({...A,[k]:""}))},x=k=>{var N;const T=k==="token"||((N=n.fields.find(C=>C.name===k))==null?void 0:N.required)===!0,A=iR(k,i[k],T);a(C=>({...C,[k]:A}))},w=async k=>{var C;k.preventDefault();const T={};for(const M of n.fields){const L=iR(M.name,i[M.name],M.required);L&&(T[M.name]=L)}const A=iR("token",i.token,!0);if(A&&(T.token=A),a(T),Object.keys(T).length)return;(C=O.current)==null||C.abort();const N=new AbortController;O.current=N,d(!0),c(""),y(null);try{const M=await n.submit(i,N.signal);if(O.current!==N)return;y(M),r(L=>({...L,token:""}))}catch(M){if(N.signal.aborted||O.current!==N)return;c(M instanceof Error?M.message:String(M))}finally{O.current===N&&(O.current=null,d(!1))}},E=k=>{k.key==="Enter"&&(k.nativeEvent.isComposing||k.nativeEvent.keyCode===229)&&k.preventDefault()},S=k=>{const{name:T,label:A,placeholder:N,help:C,required:M}=k;return l.jsxs("div",{className:"github-field",children:[l.jsxs("label",{htmlFor:`github-${T}`,children:[l.jsx("span",{children:A}),l.jsx("span",{className:`github-field-requirement${M?" is-required":""}`,children:M?"必填":"可选"})]}),l.jsx("input",{id:`github-${T}`,value:i[T],onChange:L=>v(T,L.target.value),onBlur:()=>x(T),placeholder:N,required:M,"aria-invalid":!!s[T],"aria-describedby":`github-${T}-help${s[T]?` github-${T}-error`:""}`}),l.jsx("span",{id:`github-${T}-help`,className:"github-field-help",children:C}),s[T]?l.jsx("span",{id:`github-${T}-error`,className:"github-field-error",role:"alert",children:s[T]}):null]},T)};return l.jsxs("div",{className:"github-integration-page",children:[l.jsxs("header",{className:"github-integration-header",children:[l.jsx("button",{type:"button",className:"github-back",onClick:t,"aria-label":"返回自动化列表",children:l.jsx(but,{})}),l.jsx(Jhe,{className:"github-integration-logo"}),l.jsxs("div",{children:[l.jsx("h1",{children:n.title}),l.jsx("p",{children:n.subtitle})]})]}),l.jsx("div",{className:"github-integration-layout",children:l.jsxs("section",{id:`github-panel-${e}`,className:"github-section-panel",children:[l.jsx("div",{className:"github-panel-heading",children:l.jsx("p",{children:n.panel})}),l.jsxs("form",{className:"github-release-form",onSubmit:w,onKeyDown:E,noValidate:!0,children:[l.jsxs("div",{className:"github-field-grid",children:[n.fields.map(S),l.jsxs("div",{className:"github-field",children:[l.jsxs("label",{id:"github-region-label",children:[l.jsx("span",{children:"地域"}),l.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),l.jsxs("div",{className:"pp-network-region github-region-picker",onKeyDown:k=>{k.key==="Escape"&&g(!1)},children:[l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-labelledby":"github-region-label","aria-haspopup":"listbox","aria-expanded":p,onClick:()=>g(k=>!k),children:[l.jsx("span",{children:i.region==="cn-shanghai"?"华东 2(上海)":"华北 2(北京)"}),l.jsx(yut,{className:`pp-region-chevron${p?" is-open":""}`})]}),p?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>g(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"地域",children:[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}].map(k=>{const T=k.value===i.region;return l.jsxs("button",{type:"button",role:"option","aria-selected":T,className:`pp-region-option${T?" is-selected":""}`,onClick:()=>{v("region",k.value),g(!1)},children:[l.jsx("span",{children:k.label}),T?l.jsx(xut,{}):null]},k.value)})})]}):null]}),l.jsx("span",{className:"github-field-help",children:n.regionHelp})]})]}),l.jsxs("div",{className:"github-field github-token-field",children:[l.jsxs("div",{className:"github-token-label-row",children:[l.jsxs("label",{htmlFor:"github-token",children:[l.jsx("span",{children:"GitHub Token"}),l.jsx("span",{className:"github-field-requirement is-required",children:"必填"})]}),l.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new?name=VeADK%20Studio&description=Create%20a%20GitHub%20automation%20pull%20request&contents=write&pull_requests=write",target:"_blank",rel:"noreferrer",children:["获取 Token",l.jsx(Kq,{})]})]}),l.jsxs("div",{className:"github-token-input",children:[l.jsx("input",{id:"github-token",type:f?"text":"password",value:i.token,onChange:k=>v("token",k.target.value),onBlur:()=>x("token"),autoComplete:"off",required:!0,placeholder:"需要仓库 Contents 与 Pull requests 写权限","aria-invalid":!!s.token,"aria-describedby":`github-token-help${s.token?" github-token-error":""}`}),l.jsx("button",{type:"button",onClick:()=>h(k=>!k),"aria-label":f?"隐藏 Token":"显示 Token",title:f?"隐藏 Token":"显示 Token",children:l.jsx(Out,{hidden:f})})]}),l.jsx("span",{id:"github-token-help",className:"github-field-help",children:"Token 仅用于本次提交,不会保存在浏览器或写入 PR"}),s.token?l.jsx("span",{id:"github-token-error",className:"github-field-error",role:"alert",children:s.token}):null]}),o?l.jsx("div",{className:"github-submit-message is-error",role:"alert",children:o}):null,b?l.jsxs("div",{className:"github-submit-message is-success",role:"status",children:[l.jsxs("span",{children:["PR #",b.number," 已创建"]}),l.jsxs("a",{href:b.url,target:"_blank",rel:"noreferrer",children:["在 GitHub 查看",l.jsx(Kq,{})]})]}):null,l.jsxs("div",{className:"github-form-actions",children:[l.jsxs("div",{className:"github-secrets-note",children:[l.jsx("strong",{children:"合并 PR 前,请在仓库的 GitHub Actions Secrets 中配置:"}),n.secrets.map(k=>l.jsx("span",{children:k},k))]}),l.jsx("button",{type:"submit",disabled:u,children:u?"提交 PR 中…":n.submitLabel})]})]})]})})]})}const wut=1050062,Jq="1.0",Sut="https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/5/collect.js";class Eut{constructor(){Or(this,"enabled",!1);Or(this,"initialized",!1);Or(this,"pending",[]);Or(this,"userUniqueId","");Or(this,"initPromise")}init(t){return this.enabled=t.enabled,this.enabled?this.initPromise?this.initPromise:(this.initPromise=Promise.resolve().then(()=>{const n=this.bootstrapCollector();n("init",{app_id:wut,channel:"cn",disable_auto_pv:1}),this.userUniqueId&&n("config",{user_unique_id:this.userUniqueId}),n("config",{_staging_flag:t.environment==="prod"?0:1}),n("start"),this.initialized=!0;const i=this.pending;this.pending=[];for(const[r,s]of i)this.collect(r,s)}),this.initPromise):(this.pending=[],Promise.resolve())}identify(t){this.userUniqueId=t,this.initialized&&this.collect("config",{user_unique_id:t})}emit(t,n){if(this.enabled){if(this.initialized){this.collect(t,n);return}this.pending=[...this.pending.slice(-49),[t,n]]}}bootstrapCollector(){if(window.collectEvent)return window.collectEvent;window.LogAnalyticsObject="collectEvent";const t=function(){var r;(r=t.q)==null||r.push(arguments)};t.q=[],t.l=Date.now(),window.collectEvent=t;const n=document.createElement("script");return n.async=!0,n.src=Sut,n.onerror=()=>{this.enabled=!1,t.q=[],console.warn("[telemetry] TEA SDK script failed to load")},document.head.appendChild(n),t}collect(t,n){var i;(i=window.collectEvent)==null||i.call(window,t,n)}}function kut(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e).trim();return/^[A-Za-z0-9_.:-]{1,64}$/.test(t)?t:void 0}function gu(e,t){return t===void 0?{errorKind:e}:{errorKind:e,errorCode:t}}function Ra(e,t={}){const n=e!==null&&typeof e=="object"?e:{},i=kut(n.code),r=typeof n.name=="string"?n.name:"";if(r==="RuntimeProbeError")return gu("runtime_probe_error",i);if(r==="AbortError")return gu("abort",i);if(r==="RuntimeAccessDeniedError"||r==="AuthError")return gu("auth",i);if(t.phase==="build")return gu("build_failed",i);if(r==="TimeoutError")return gu("timeout",i);if(r==="NetworkError"||r==="TypeError")return gu("network",i);if(r==="ValidationError")return gu("validation",i);if(r==="ServerError")return gu("server",i);const s=typeof n.status=="number"&&Number.isInteger(n.status)?n.status:void 0;if(s===void 0||s<400||s>599)return gu("unknown",i);const a=String(s);return s===401||s===403?{errorKind:"auth",errorCode:a}:s===400||s===409||s===422?{errorKind:"validation",errorCode:a}:s>=500?{errorKind:"server",errorCode:a}:{errorKind:"unknown",errorCode:a}}const Tut=["schema_version","event_id","operation_id","user_pool_id","studio_deploy_id","vefaas_application_id","vefaas_function_id","studio_region","studio_project","studio_version","environment","cloud_provider","account_id","user_role","user_source","page_instance_id"],_ut={studio_entry_viewed:["auth_state"],studio_session_started:["agents_source"],studio_agent_deploy:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","deploy_region","runtime_network_type","feishu_enabled","runtime_id","duration_ms","failed_phase","error_kind","error_code"],studio_sandbox_create:["status","sandbox_kind","sandbox_source","sandbox_id","duration_ms","error_kind","error_code"],studio_agent_debug:["status","agent_id","variant_type","debug_run_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_connect:["status","target_id","agent_kind","connect_source","runtime_region","runtime_is_mine","sandbox_status","duration_ms","error_kind","error_code"],studio_agent_message:["status","agent_id","agent_kind","message_source","session_state","session_id","duration_ms","failed_phase","error_kind","error_code"],studio_agent_source_download:["status","agent_id","deploy_action","deploy_source","create_mode","ai_assisted","duration_ms","file_count","zip_size_bytes","error_kind","error_code"]};function Aut(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function eH(e,t){const n=new Set([...Tut,..._ut[e]]),i={};for(const[r,s]of Object.entries(t))!n.has(r)||!Aut(s)||(i[r]=typeof s=="string"?s.slice(0,256):s);return i}function Nut(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function Cut(){return typeof performance<"u"?performance.now():Date.now()}function pm(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class jut{constructor(t){Or(this,"sink");Or(this,"createId");Or(this,"now");Or(this,"pageInstanceId");Or(this,"context");Or(this,"identity");Or(this,"entryViewed",!1);Or(this,"sessionStarted",!1);this.sink=t.sink,this.createId=t.createId??Nut,this.now=t.now??Cut,this.pageInstanceId=this.createId()}setContext(t){var n;this.context={...t,accountId:((n=t.accountId)==null?void 0:n.trim())??""}}identify(t){var i,r,s;const n=t.userUniqueId.trim();n&&(this.identity&&this.identity.userUniqueId!==n&&(this.pageInstanceId=this.createId(),this.sessionStarted=!1),this.identity={...t,userUniqueId:n,accountId:((i=t.accountId)==null?void 0:i.trim())??""},(s=(r=this.sink).identify)==null||s.call(r,n))}trackStudioSessionStarted(t){this.sessionStarted||!this.context||!this.identity||(this.sessionStarted=!0,this.emit("studio_session_started",{agents_source:t.agentsSource}))}trackStudioEntryViewed(t){if(this.entryViewed||!this.context)return;this.entryViewed=!0;const n=eH("studio_entry_viewed",pm({schema_version:Jq,event_id:this.createId(),user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.context.accountId,page_instance_id:this.pageInstanceId,auth_state:t.authState}));this.sink.emit("studio_entry_viewed",n)}beginAgentDeploy(t){return this.beginOperation("studio_agent_deploy",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted,deploy_region:t.deployRegion,runtime_network_type:t.runtimeNetworkType,feishu_enabled:t.feishuEnabled},n=>({runtime_id:n.runtimeId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginSandboxCreate(t){return this.beginOperation("studio_sandbox_create",{sandbox_kind:t.sandboxKind,sandbox_source:t.sandboxSource},n=>({sandbox_id:n.sandboxId}),n=>({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentDebug(t){return this.beginOperation("studio_agent_debug",{agent_id:t.agentId,variant_type:t.variantType},n=>({debug_run_id:n.debugRunId}),n=>({failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentConnect(t){return this.beginOperation("studio_agent_connect",{target_id:t.targetId,agent_kind:t.agentKind,connect_source:t.connectSource},n=>pm({runtime_region:n.runtimeRegion,runtime_is_mine:n.runtimeIsMine,sandbox_status:n.sandboxStatus}),n=>pm({error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentMessage(t){return this.beginOperation("studio_agent_message",pm({agent_id:t.agentId,agent_kind:t.agentKind,message_source:t.messageSource,session_state:t.sessionState,session_id:t.sessionId}),n=>({session_id:n.sessionId}),n=>pm({session_id:n.sessionId,failed_phase:n.failedPhase,error_kind:n.errorKind,error_code:n.errorCode}))}beginAgentSourceDownload(t){return this.beginOperation("studio_agent_source_download",{agent_id:t.agentId,deploy_action:t.deployAction,deploy_source:t.deploySource,create_mode:t.createMode,ai_assisted:t.aiAssisted},n=>({file_count:n.fileCount,zip_size_bytes:n.zipSizeBytes}),n=>({file_count:n.fileCount,error_kind:n.errorKind,error_code:n.errorCode}))}beginOperation(t,n,i,r){const s=this.createId(),a=this.now(),o=!!(this.context&&this.identity);let c=!1;o&&this.emit(t,{...n,status:"started"},s);const u=(d,f)=>{c||(c=!0,o&&this.emit(t,{...n,...f,status:d,duration_ms:Math.max(0,this.now()-a)},s))};return{operationId:s,succeed:d=>u("succeeded",i(d)),fail:d=>u("failed",r(d))}}emit(t,n,i){if(!this.context||!this.identity)return;const r=eH(t,pm({schema_version:Jq,event_id:this.createId(),operation_id:i,user_pool_id:this.context.userPoolId,studio_deploy_id:this.context.studioDeployId,vefaas_application_id:this.context.applicationId,vefaas_function_id:this.context.functionId,studio_region:this.context.studioRegion,studio_project:this.context.studioProject,studio_version:this.context.studioVersion,environment:this.context.environment,cloud_provider:this.context.cloudProvider,account_id:this.identity.accountId,user_role:this.identity.userRole,user_source:this.identity.userSource,page_instance_id:this.pageInstanceId,...n}));this.sink.emit(t,r)}}const epe=new Eut,eu=new jut({sink:epe});function Rut(e){return epe.init(e)}function Iut(e){eu.setContext(e)}function Put(e){eu.identify(e)}function Mut(e){eu.trackStudioEntryViewed(e)}function Lut(e){eu.trackStudioSessionStarted(e)}function tpe(e){return eu.beginAgentDeploy(e)}function Dut(e){return eu.beginSandboxCreate(e)}function $ut(e){return eu.beginAgentDebug(e)}function rR(e){return eu.beginAgentConnect(e)}function tH(e){return eu.beginAgentMessage(e)}function Qut(e){return eu.beginAgentSourceDownload(e)}const But=/^[A-Za-z_][A-Za-z0-9_]*$/;function i1(e){return e.trim().length===0?"名称为必填项":e==="user"?"user 是 Google ADK 保留名称,请使用其他名称":But.test(e)?null:"名称须以英文字母或下划线开头,且只能包含英文字母、数字和下划线"}function Uut(e){const t=new Set,n=new Set,i=r=>{i1(r.name)===null&&(t.has(r.name)?n.add(r.name):t.add(r.name)),r.subAgents.forEach(i)};return i(e),n}function zut(e){return{...el(),name:e,description:"一个通过飞书接收消息并提供帮助的智能助手。",instruction:"你是一个通过飞书为用户提供帮助的智能助手。准确理解用户问题,给出简洁、可靠的回答;信息不足时先提问澄清,不要臆造事实。",deployment:{feishuEnabled:!0}}}async function Fut(e){const t=zut(e.agentName),n=await t$(t);return w1(n.name,n.files,{region:e.region,projectName:"default"},{taskId:e.taskId,sessionStorage:"in-memory",minInstance:1,maxInstance:1,description:t.description,im:{feishu:{enabled:!0}},envs:[{key:"FEISHU_APP_ID",value:e.appId},{key:"FEISHU_APP_SECRET",value:e.appSecret}],onStage:e.onStage})}const yl=[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}],npe=[{phase:"prepare",label:"生成智能体"},{phase:"build",label:"构建镜像"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}];function Vut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xut(e){return l.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 7 4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function nH(e){return l.jsx("svg",{viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4 9.2 3.1 3.1L14 5.8",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function qut(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"M6.5 4H4.8A1.8 1.8 0 0 0 3 5.8v5.4A1.8 1.8 0 0 0 4.8 13h5.4a1.8 1.8 0 0 0 1.8-1.8V9.5M9 3h4v4M12.5 3.5 7.2 8.8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Hut(e){if(!e||e==="upload")return 0;const t=npe.findIndex(n=>n.phase===e);return t<0?0:t}function sR(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}function Yut({onBack:e}){var J;const[t,n]=m.useState("feishu_assistant"),[i,r]=m.useState(""),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState("cn-beijing"),[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState(""),[O,v]=m.useState(""),[x,w]=m.useState("idle"),[E,S]=m.useState(null),[k,T]=m.useState(""),[A,N]=m.useState(null),C=m.useRef(null),M=m.useRef(null),L=m.useRef([]),P=m.useRef(0),Q=m.useRef(null),j=m.useRef(null),$=m.useRef("prepare"),U=m.useRef(!1),B=m.useRef(!0),I=["preparing","running","cancelling"].includes(x);m.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),m.useEffect(()=>{var ye;if(!f)return;(ye=L.current[P.current])==null||ye.focus();const ie=Se=>{Se.target instanceof Node&&C.current&&!C.current.contains(Se.target)&&h(!1)},ue=Se=>{var Re;Se.key==="Escape"&&(h(!1),(Re=M.current)==null||Re.focus())};return window.addEventListener("pointerdown",ie),window.addEventListener("keydown",ue),()=>{window.removeEventListener("pointerdown",ie),window.removeEventListener("keydown",ue)}},[f]);const X=ie=>{ie.key==="Enter"&&(ie.nativeEvent.isComposing||ie.nativeEvent.keyCode===229)&&ie.preventDefault()},q=()=>{const ie=i1(t.trim())??"",ue=i.trim()?"":"请输入飞书 App ID",ye=s.trim()?"":"请输入飞书 App Secret";return g(ie),y(ue),v(ye),!ie&&!ue&&!ye},D=async ie=>{if(ie.preventDefault(),!q()||I)return;const ue=crypto.randomUUID();Q.current=ue,$.current="prepare",U.current=!1,w("preparing"),S(null),T(""),N(null);const ye=tpe({agentId:String(t.trim()),deployAction:"create",deploySource:"feishu_automation",createMode:"feishu_template",aiAssisted:0,deployRegion:String(u),runtimeNetworkType:"public",feishuEnabled:1});j.current=ye;try{const Se=await Fut({agentName:t.trim(),appId:i.trim(),appSecret:s.trim(),region:u,taskId:ue,onStage:Re=>{$.current=Re.phase||"deploy",!(!B.current||U.current)&&(w("running"),S(Re))}});if(U.current){ye.fail({failedPhase:sR($.current),errorKind:"abort"});return}if(ye.succeed({runtimeId:String(Se.runtimeId||"")}),!B.current)return;N(Se),a(""),c(!1),w("succeeded")}catch(Se){if(ye.fail({failedPhase:sR($.current),...U.current?{errorKind:"abort"}:Ra(Se,{phase:$.current})}),!B.current||U.current)return;w("failed"),T(Se instanceof Error?Se.message:String(Se))}finally{Q.current===ue&&(Q.current=null),j.current===ye&&(j.current=null)}},H=async()=>{var ue;const ie=Q.current;if(!(!ie||x!=="running")&&window.confirm("取消部署将停止任务并清理已创建的 Runtime,确定继续吗?")){U.current=!0,w("cancelling"),T("");try{await ree(ie),(ue=j.current)==null||ue.fail({failedPhase:sR($.current),errorKind:"abort"}),B.current&&w("cancelled")}catch(ye){if(U.current=!1,!B.current)return;w("failed"),T(ye instanceof Error?ye.message:String(ye))}}},re=Hut((E==null?void 0:E.phase)??null),fe=!!(t.trim()&&i.trim()&&s.trim()&&!I),Ae=yl.find(ie=>ie.value===u);return l.jsxs("div",{className:"feishu-integration-page",children:[l.jsxs("header",{className:"feishu-integration-header",children:[l.jsx("button",{type:"button",className:"feishu-back",onClick:e,"aria-label":"返回自动化列表",disabled:I,children:l.jsx(Vut,{})}),l.jsx("img",{className:"feishu-integration-logo",src:mQ,alt:"","aria-hidden":"true"}),l.jsxs("div",{children:[l.jsx("h1",{children:"飞书机器人"}),l.jsx("p",{children:"创建一个由 AgentKit Runtime 驱动的飞书智能体"})]})]}),l.jsx("div",{className:"feishu-integration-layout",children:l.jsxs("section",{className:"feishu-section-panel",children:[l.jsx("p",{className:"feishu-panel-description",children:"填写已发布飞书应用的凭据,Studio 将生成 basic 智能体、创建独立 Runtime,并启用飞书消息长连接。"}),l.jsxs("form",{className:"feishu-form",onSubmit:D,onKeyDown:X,noValidate:!0,children:[l.jsxs("div",{className:"feishu-field-grid",children:[l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-agent-name",children:"智能体名称"}),l.jsx("input",{id:"feishu-agent-name",value:t,maxLength:64,disabled:I,onChange:ie=>{n(ie.target.value),p&&g("")},onBlur:()=>g(i1(t.trim())??""),"aria-invalid":!!p,"aria-describedby":`feishu-agent-name-help${p?" feishu-agent-name-error":""}`}),l.jsx("span",{id:"feishu-agent-name-help",className:"feishu-field-help",children:"将作为新 Runtime 中的根智能体名称"}),p?l.jsx("span",{id:"feishu-agent-name-error",className:"feishu-field-error",role:"alert",children:p}):null]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{id:"feishu-region-label",children:"部署地域"}),l.jsxs("div",{className:"feishu-region-picker",ref:C,children:[l.jsxs("button",{ref:M,type:"button",className:"feishu-region-trigger",disabled:I,"aria-haspopup":"listbox","aria-expanded":f,"aria-labelledby":"feishu-region-label feishu-region-value",onClick:()=>{P.current=yl.findIndex(ie=>ie.value===u),h(ie=>!ie)},onKeyDown:ie=>{ie.key!=="ArrowDown"&&ie.key!=="ArrowUp"||(ie.preventDefault(),P.current=ie.key==="ArrowUp"?yl.length-1:yl.findIndex(ue=>ue.value===u),h(!0))},children:[l.jsx("span",{id:"feishu-region-value",children:Ae.label}),l.jsx(Xut,{})]}),f?l.jsx("div",{className:"feishu-region-menu",role:"listbox","aria-label":"部署地域",onKeyDown:ie=>{var Se;const ue=L.current.findIndex(Re=>Re===document.activeElement);let ye=null;ie.key==="ArrowDown"?ye=(ue+1)%yl.length:ie.key==="ArrowUp"?ye=(ue-1+yl.length)%yl.length:ie.key==="Home"?ye=0:ie.key==="End"?ye=yl.length-1:ie.key==="Tab"&&h(!1),ye!==null&&(ie.preventDefault(),(Se=L.current[ye])==null||Se.focus())},children:yl.map(ie=>l.jsx("button",{ref:ue=>{const ye=yl.findIndex(Se=>Se.value===ie.value);L.current[ye]=ue},type:"button",role:"option","aria-selected":u===ie.value,className:`feishu-region-option${u===ie.value?" is-selected":""}`,onClick:()=>{var ue;d(ie.value),h(!1),(ue=M.current)==null||ue.focus()},children:ie.label},ie.value))}):null]}),l.jsx("span",{className:"feishu-field-help",children:"Runtime 与构建产物将创建在该地域"})]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-app-id",children:"飞书 App ID"}),l.jsx("input",{id:"feishu-app-id",value:i,maxLength:128,autoComplete:"off",disabled:I,placeholder:"cli_xxxxxxxxxxxxxxxx",onChange:ie=>{r(ie.target.value),b&&y("")},onBlur:()=>y(i.trim()?"":"请输入飞书 App ID"),"aria-invalid":!!b,"aria-describedby":`feishu-app-id-help${b?" feishu-app-id-error":""}`}),l.jsx("span",{id:"feishu-app-id-help",className:"feishu-field-help",children:"来自飞书开放平台的应用凭证"}),b?l.jsx("span",{id:"feishu-app-id-error",className:"feishu-field-error",role:"alert",children:b}):null]}),l.jsxs("div",{className:"feishu-field",children:[l.jsx("label",{htmlFor:"feishu-app-secret",children:"飞书 App Secret"}),l.jsxs("div",{className:"feishu-secret-input",children:[l.jsx("input",{id:"feishu-app-secret",type:o?"text":"password",value:s,maxLength:256,autoComplete:"off",disabled:I,placeholder:"请输入 App Secret",onChange:ie=>{a(ie.target.value),O&&v("")},onBlur:()=>v(s.trim()?"":"请输入飞书 App Secret"),"aria-invalid":!!O,"aria-describedby":`feishu-app-secret-help${O?" feishu-app-secret-error":""}`}),l.jsx("button",{type:"button",disabled:I,onClick:()=>c(ie=>!ie),"aria-label":o?"隐藏 App Secret":"显示 App Secret",children:o?"隐藏":"显示"})]}),l.jsx("span",{id:"feishu-app-secret-help",className:"feishu-field-help",children:"仅写入新 Runtime 的环境变量"}),O?l.jsx("span",{id:"feishu-app-secret-error",className:"feishu-field-error",role:"alert",children:O}):null]})]}),x!=="idle"?l.jsxs("div",{className:`feishu-deployment-status is-${x}`,role:x==="failed"?"alert":"status",children:[l.jsxs("div",{className:"feishu-deployment-heading",children:[x==="preparing"?l.jsx(oi,{as:"strong",children:"正在生成 basic 智能体"}):null,x==="running"?l.jsx(oi,{as:"strong",children:(E==null?void 0:E.message)||"正在创建 Runtime"}):null,x==="cancelling"?l.jsx(oi,{as:"strong",children:"正在取消部署"}):null,x==="succeeded"?l.jsxs("strong",{children:[l.jsx(nH,{}),"飞书机器人 Runtime 已创建"]}):null,x==="cancelled"?l.jsx("strong",{children:"部署已取消"}):null,x==="failed"?l.jsx("strong",{children:"创建失败"}):null]}),x==="preparing"||x==="running"||x==="cancelling"?l.jsx("ol",{className:"feishu-deployment-steps",children:npe.map((ie,ue)=>{const ye=x==="running"&&ueie.value===(A.region||u)))==null?void 0:J.label)||A.region}),A.consoleUrl?l.jsxs("a",{href:A.consoleUrl,target:"_blank",rel:"noreferrer",children:["打开 Runtime 控制台",l.jsx(qut,{})]}):null]}):null]}):null,l.jsxs("div",{className:"feishu-form-actions",children:[l.jsxs("div",{className:"feishu-secrets-note",children:[l.jsx("strong",{children:"凭据处理"}),l.jsx("span",{children:"App Secret 仅用于本次部署,不会写入生成源码或浏览器存储。"})]}),l.jsxs("div",{className:"feishu-action-buttons",children:[x==="running"?l.jsx("button",{type:"button",className:"feishu-cancel",onClick:()=>void H(),children:"取消部署"}):null,l.jsx("button",{type:"submit",className:"feishu-submit",disabled:!fe,children:I?"正在创建…":"创建飞书机器人 Runtime"})]})]})]})]})})]})}async function bQ(e,t,n,i=_o){var s;const r=await ri(e,{...t,headers:{accept:"application/json",...t.headers},signal:n},i);if(!r.ok){let a="";try{a=((s=(await r.json()).detail)==null?void 0:s.trim())||""}catch{}throw new Error(a||`请求失败 (${r.status})`)}return r.json()}function Gut(e){return bQ("/web/coding-agents/capabilities",{method:"GET"},e,DD)}function Wut(e,t){return bQ(`/web/coding-agents/skills/${encodeURIComponent(e)}/preview`,{method:"GET"},t)}function Zut(e,t){return bQ("/web/coding-agents/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},t)}const Kut="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='16'%20height='16'%20rx='3.692'%20fill='%231A1B1D'/%3e%3cpath%20d='M13.235%205.829V4.332H2.758v5.987h1.496v1.496h8.981V5.828Zm-1.497%204.49H4.254V5.83h7.484v4.49Z'%20fill='%2332F08C'/%3e%3cpath%20d='M6.937%206.993%205.88%208.051%206.937%209.11%207.995%208.05%206.937%206.993ZM9.931%206.992%208.873%208.05%209.931%209.11%2010.99%208.05%209.93%206.992Z'%20fill='%2332F08C'/%3e%3c/svg%3e";function Jut(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m4 4 8 8m0-8-8 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function iH(){return l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[l.jsx("path",{d:"M4 1.8h5l3 3V14H4z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),l.jsx("path",{d:"M9 1.8V5h3M6 8h4M6 10.5h4",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}function rH(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M1.8 4.5h4l1.2-1.3h2.2l1.2 1.3h3.8v8H1.8z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function edt(e){return e instanceof DOMException&&e.name==="AbortError"}function tdt(e){return e instanceof Error&&e.message?e.message:"读取 Skill 文件失败"}function ndt(e){return e<1024?`${e} B`:`${(e/1024).toFixed(e<10*1024?1:0)} KB`}function idt(e){const t=e.split("/");return t[t.length-1]??e}function rdt(e){const t=new Map;for(const n of e){const i=n.path.split("/"),r=i.length>1?i.slice(0,-1).join("/"):"";t.set(r,[...t.get(r)??[],n])}return Array.from(t,([n,i])=>({directory:n,files:i})).sort((n,i)=>n.directory?i.directory?n.directory.localeCompare(i.directory):1:-1)}function sdt({skill:e,onClose:t}){const n=m.useRef(null),i=m.useRef(null),r=m.useId(),s=m.useId(),[a,o]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(!0),[h,p]=m.useState(""),[g,b]=m.useState(0);m.useEffect(()=>{i.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const v=n.current;return v&&!v.open&&v.showModal(),()=>{var x;v!=null&&v.open&&v.close(),(x=i.current)==null||x.focus()}},[]),m.useEffect(()=>{const v=new AbortController;return f(!0),p(""),o(null),u(""),Wut(e.id,v.signal).then(x=>{if(v.signal.aborted)return;o(x);const w=x.files.find(E=>E.path==="SKILL.md")??x.files[0];u((w==null?void 0:w.path)??"")}).catch(x=>{!v.signal.aborted&&!edt(x)&&p(tdt(x))}).finally(()=>{v.signal.aborted||f(!1)}),()=>v.abort()},[g,e.id]);const y=m.useMemo(()=>rdt((a==null?void 0:a.files)??[]),[a]),O=(a==null?void 0:a.files.find(v=>v.path===c))??null;return l.jsxs("dialog",{ref:n,className:"coding-agents-preview-dialog","aria-labelledby":r,"aria-describedby":s,onCancel:v=>{v.preventDefault(),t()},onMouseDown:v=>{const x=v.currentTarget.getBoundingClientRect();(v.clientXx.right||v.clientYx.bottom)&&t()},children:[l.jsxs("header",{className:"coding-agents-preview-header",children:[l.jsx("span",{className:"coding-agents-preview-mark",children:l.jsx(rH,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:r,children:e.name}),l.jsx("p",{id:s,children:"只读浏览随 Studio 提供的 Skill 文件"})]}),l.jsx("button",{type:"button",autoFocus:!0,"aria-label":"关闭文件预览",onClick:t,children:l.jsx(Jut,{})})]}),d?l.jsxs("div",{className:"coding-agents-preview-state",children:[l.jsx("i",{}),"正在读取文件…"]}):h?l.jsxs("div",{className:"coding-agents-preview-state is-error",role:"alert",children:[l.jsx("span",{children:h}),l.jsx("button",{type:"button",onClick:()=>b(v=>v+1),children:"重试"})]}):l.jsxs("div",{className:"coding-agents-preview-layout",children:[l.jsxs("nav",{className:"coding-agents-preview-tree","aria-label":`${e.name} 文件`,children:[l.jsxs("div",{className:"coding-agents-preview-tree-title",children:[l.jsx("span",{children:"文件"}),l.jsx("small",{children:(a==null?void 0:a.files.length)??0})]}),l.jsx("div",{className:"coding-agents-preview-tree-scroll",children:y.map(v=>v.directory?l.jsxs("details",{open:!0,children:[l.jsxs("summary",{children:[l.jsx(rH,{}),l.jsx("span",{children:v.directory})]}),l.jsx("div",{children:v.files.map(x=>l.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[l.jsx(iH,{}),l.jsx("span",{children:idt(x.path)})]},x.path))})]},v.directory):v.files.map(x=>l.jsxs("button",{type:"button",className:c===x.path?"is-selected":"","aria-current":c===x.path?"true":void 0,onClick:()=>u(x.path),children:[l.jsx(iH,{}),l.jsx("span",{children:x.path})]},x.path)))})]}),l.jsx("section",{className:"coding-agents-preview-file","aria-label":"文件内容",children:O?l.jsxs(l.Fragment,{children:[l.jsxs("header",{children:[l.jsx("strong",{children:O.path}),l.jsx("span",{children:ndt(O.size)})]}),O.previewable&&O.content!==null?l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:O.content})}):l.jsx("div",{className:"coding-agents-preview-unavailable",children:"此文件不是可预览的 UTF-8 文本。"})]}):l.jsx("div",{className:"coding-agents-preview-unavailable",children:"没有可预览的文件。"})})]})]})}function adt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9.8 3.5-4.5 4.5 4.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function odt(e){return l.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"16",height:"16",rx:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("path",{d:"m8.5 11-2.4 2.4 2.4 2.4M11 16.5h3.8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("circle",{cx:"24.5",cy:"10.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("circle",{cx:"24.5",cy:"24.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("path",{d:"M19.5 10.5H22M18.2 19l4.3 3.7M24.5 13v9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function ldt(e){return l.jsx("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:l.jsxs("g",{stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",children:[l.jsx("path",{d:"M16 4.5v7M16 20.5v7"}),l.jsx("path",{d:"m9.3 6.3 3.5 6.1M19.2 19.6l3.5 6.1"}),l.jsx("path",{d:"m5.9 11.1 6.2 3.5M19.9 17.4l6.2 3.5"}),l.jsx("path",{d:"M4.7 16h7M20.3 16h7"}),l.jsx("path",{d:"m5.9 20.9 6.2-3.5M19.9 14.6l6.2-3.5"}),l.jsx("path",{d:"m9.3 25.7 3.5-6.1M19.2 12.4l3.5-6.1"})]})})}function cdt(e){return l.jsxs("svg",{viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M15.8 4.2c2.4 0 4.5 1.2 5.7 3.1 2.2-.3 4.5.8 5.6 2.9 1.1 2 .8 4.4-.5 6.1 1.2 1.8 1.3 4.3.1 6.2-1.2 2-3.4 3-5.6 2.6-1.3 1.8-3.5 2.9-5.8 2.7-2.2-.2-4.1-1.5-5.1-3.4-2.2.1-4.4-1-5.4-3.1-1-2-.6-4.4.8-6.1-1.1-1.9-1.1-4.3.2-6.1 1.3-1.9 3.6-2.7 5.7-2.2 1.1-1.7 2.6-2.7 4.3-2.7Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),l.jsx("path",{d:"m10.7 12.2 3.1 3.8-3.1 3.8M17.1 20h4.3",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function sH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.4 8.2 3 3L12.8 5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function udt(e){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M2.8 6.3h14.4v8.3a1.6 1.6 0 0 1-1.6 1.6H4.4a1.6 1.6 0 0 1-1.6-1.6V6.3Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),l.jsx("path",{d:"M2.8 6.3V5.1a1.4 1.4 0 0 1 1.4-1.4h3.4l1.5 1.6h6.5a1.6 1.6 0 0 1 1.6 1.6",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})]})}function ddt({agentId:e}){return e==="trae"?l.jsx("img",{src:Kut,alt:"","aria-hidden":"true"}):e==="claude-code"?l.jsx(ldt,{}):l.jsx(cdt,{})}function aH(e){return e instanceof DOMException&&e.name==="AbortError"}function oH(e,t){return e instanceof Error&&e.message?e.message:t}function fdt({onBack:e}){var N;const[t,n]=m.useState(null),[i,r]=m.useState(!0),[s,a]=m.useState(""),[o,c]=m.useState(0),[u,d]=m.useState(new Set),[f,h]=m.useState(new Set),[p,g]=m.useState(null),[b,y]=m.useState(!1),[O,v]=m.useState(null),x=m.useRef(null);m.useEffect(()=>{const C=new AbortController;return r(!0),a(""),Gut(C.signal).then(M=>{if(C.signal.aborted)return;n(M);const L=M.agents.filter(P=>P.available);d(P=>{const Q=L.filter(j=>P.has(j.id));return new Set((Q.length?Q:L.slice(0,1)).map(j=>j.id))}),h(P=>{const Q=M.skills.filter(j=>P.has(j.id));return new Set((Q.length?Q:M.skills).map(j=>j.id))})}).catch(M=>{!aH(M)&&!C.signal.aborted&&(n(null),a(oH(M,"检测本机客户端失败")))}).finally(()=>{C.signal.aborted||r(!1)}),()=>C.abort()},[o]),m.useEffect(()=>()=>{var C;return(C=x.current)==null?void 0:C.abort()},[]);const w=m.useMemo(()=>(t==null?void 0:t.agents.filter(C=>C.available&&u.has(C.id)))||[],[t,u]),E=m.useMemo(()=>(t==null?void 0:t.skills.filter(C=>f.has(C.id)))||[],[t,f]),S=!!(!b&&w.length&&E.length),k=(C,M)=>{!M||b||(v(null),d(L=>{const P=new Set(L);return P.has(C)?P.delete(C):P.add(C),P}))},T=C=>{b||(v(null),h(M=>{const L=new Set(M);return L.has(C)?L.delete(C):L.add(C),L}))},A=async()=>{var M;if(!S)return;(M=x.current)==null||M.abort();const C=new AbortController;x.current=C,y(!0),v(null);try{const L=await Zut({agents:w.map(Q=>Q.id),skills:E.map(Q=>Q.id)},C.signal);if(C.signal.aborted)return;const P=L.installations;v({tone:"success",message:`已为 ${w.length} 个客户端配置 ${E.length} 个 Skill`,details:P.map(Q=>`${Q.agentName} · ${Q.skill} → ${Q.displayPath}`)})}catch(L){!aH(L)&&!C.signal.aborted&&v({tone:"error",message:oH(L,"配置失败,请检查用户目录权限后重试")})}finally{x.current===C&&(x.current=null),C.signal.aborted||y(!1)}};return l.jsxs("section",{className:"coding-agents-page",children:[l.jsxs("header",{className:"coding-agents-header",children:[l.jsx("button",{type:"button",className:"coding-agents-back",onClick:e,disabled:b,"aria-label":"返回自动化列表",children:l.jsx(adt,{})}),l.jsx(odt,{className:"coding-agents-logo"}),l.jsxs("div",{children:[l.jsx("h1",{children:"配置 Coding Agents"}),l.jsx("p",{children:"把随 Studio 提供的 AgentKit Skills 全局安装到本地编码客户端。"})]})]}),l.jsx("div",{className:"coding-agents-scroll",children:l.jsxs("div",{className:"coding-agents-content",children:[l.jsxs("section",{className:"coding-agents-section","aria-label":"选择 Coding Agent",children:[l.jsxs("div",{className:"coding-agents-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"1"}),l.jsx("h2",{children:"本机客户端"})]}),l.jsx("button",{type:"button",onClick:()=>c(C=>C+1),disabled:i||b,children:"重新检测"})]}),i?l.jsxs("div",{className:"coding-agents-inline-state",children:[l.jsx("i",{}),"正在检测本机客户端…"]}):s?l.jsxs("div",{className:"coding-agents-error-row",role:"alert",children:[l.jsx("span",{children:s}),l.jsx("button",{type:"button",onClick:()=>c(C=>C+1),children:"重试"})]}):l.jsx("div",{className:"coding-agents-agent-grid",children:t==null?void 0:t.agents.map(C=>l.jsxs("button",{type:"button",className:`coding-agents-agent ${u.has(C.id)?"is-selected":""}`,"aria-pressed":u.has(C.id),disabled:!C.available||b,onClick:()=>k(C.id,C.available),title:C.available?C.name:C.reason,children:[l.jsx("span",{className:`coding-agents-agent-mark is-${C.id}`,children:l.jsx(ddt,{agentId:C.id})}),l.jsxs("span",{className:"coding-agents-agent-copy",children:[l.jsx("strong",{children:C.name}),l.jsx("small",{children:C.available?C.version||"已检测到客户端":C.reason})]}),l.jsx("span",{className:`coding-agents-status ${C.available?"is-ready":""}`,children:C.available?"可用":"未检测到"}),l.jsx("span",{className:"coding-agents-check",children:l.jsx(sH,{})})]},C.id))})]}),l.jsxs("section",{className:"coding-agents-section","aria-label":"选择内置 Skill",children:[l.jsx("div",{className:"coding-agents-section-heading",children:l.jsxs("div",{children:[l.jsx("span",{children:"2"}),l.jsx("h2",{children:"内置 Skills"})]})}),l.jsx("div",{className:"coding-agents-skill-list",children:t==null?void 0:t.skills.map(C=>l.jsxs("div",{className:`coding-agents-skill ${f.has(C.id)?"is-selected":""}`,children:[l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:f.has(C.id),onChange:()=>T(C.id),disabled:b}),l.jsx("span",{className:"coding-agents-skill-check","aria-hidden":"true",children:l.jsx(sH,{})}),l.jsxs("span",{children:[l.jsx("strong",{children:C.name}),l.jsx("small",{children:C.description})]})]}),l.jsx("button",{type:"button",onClick:()=>g(C),children:"查看文件"})]},C.id))}),l.jsxs("div",{className:"coding-agents-global","aria-label":"全局安装目录",children:[l.jsxs("div",{className:"coding-agents-global-heading",children:[l.jsx(udt,{}),l.jsxs("div",{children:[l.jsx("strong",{children:"全局安装"}),l.jsx("span",{children:"配置后可在本机其他项目中使用"})]})]}),w.length?l.jsx("dl",{children:w.map(C=>l.jsxs("div",{children:[l.jsx("dt",{children:C.name}),l.jsx("dd",{children:C.globalSkillsPath})]},C.id))}):l.jsx("p",{children:"选择客户端后显示对应安装目录。"})]})]}),O?l.jsxs("div",{className:`coding-agents-result is-${O.tone}`,role:O.tone==="error"?"alert":"status",children:[l.jsx("strong",{children:O.message}),(N=O.details)!=null&&N.length?l.jsx("ul",{children:O.details.map(C=>l.jsx("li",{children:C},C))}):null]}):null,l.jsxs("div",{className:"coding-agents-actions",children:[l.jsx("span",{children:w.length?`已选择 ${w.length} 个客户端、${E.length} 个 Skill`:"请先选择客户端"}),l.jsx("button",{type:"button",onClick:()=>void A(),disabled:!S,children:b?"正在配置…":"配置"})]})]})}),p?l.jsx(sdt,{skill:p,onClose:()=>g(null)}):null]})}function lH(e){return e.replace(/\s+/g," ").trim()}function hdt(e,t){const n=lH(e)||"AgentKit Studio";if(t.kind==="home")return n;const i=lH(t.title);return i?t.kind==="conversation"?i:`${n} - ${i}`:n}const pdt="/web/video",mdt=18e4;async function bb(e,t={},n=_o){return fetch(vo(`${pdt}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}async function ipe(e,t){const n=await e.text().catch(()=>"");let i="";try{const r=JSON.parse(n),s=r.detail??r.error;i=typeof s=="string"?s:""}catch{i=n.trim().slice(0,500)}return new Error(i||`${t}(HTTP ${e.status})`)}async function av(e,t){if(!e.ok)throw await ipe(e,t);const n=await e.text().catch(()=>"");try{return JSON.parse(n)}catch{const i=e.headers.get("content-type")||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(${i})`)}}async function gdt(e){return av(await bb("/capabilities",{signal:e,headers:{Accept:"application/json"}}),"加载视频模型能力失败")}async function bdt(e,t,n){const i=new FormData;return i.set("file",e),i.set("role",t),av(await bb("/assets",{method:"POST",body:i,signal:n},kr),`上传${e.name}失败`)}async function Odt(e,t){return av(await bb("/prompts/enhance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t},mdt),"提示词优化失败")}async function ydt(e,t){return av(await bb("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t},kr),"创建视频生成任务失败")}async function xdt(e,t){return av(await bb(`/tasks/${encodeURIComponent(e)}`,{signal:t,headers:{Accept:"application/json"}}),"查询视频生成任务失败")}async function vdt(e,t){const n=await bb(`/tasks/${encodeURIComponent(e)}/download`,{signal:t,headers:{Accept:"video/*"}},kr);if(!n.ok)throw await ipe(n,"下载生成视频失败");return n.blob()}function wdt(e){return e.startsWith("/")?vo(e):e}function OQ(e){return e.isComposing||e.keyCode===229}function Sdt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 11.5 5.5-5.5 5.5 5.5M12 6v12"})})}function Edt(e){return l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...e,children:l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.75",fill:"currentColor"})})}const El=[{value:"agent",label:"Agent",description:"与当前选择的 Agent 对话"},{value:"temporary",label:"内置智能体",description:"使用平台提供的智能体"}],cH=[{label:"Codex 智能体",kind:"codex",value:"temporary",description:"在沙箱中执行任务"},{label:"DeepSeek Harness",kind:"deepseek-harness",value:"deepseek-harness",description:"打开 DeepSeek Harness 工作区"}],kdt=[{label:"ArkClaw",kind:"openclaw"},{label:"Hermes 智能体",kind:"hermes"}];function uH({mode:e}){return e==="temporary"?l.jsxs("svg",{className:"new-chat-mode__temporary-icon",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"m10 2.8 6.1 3.45v7.5L10 17.2l-6.1-3.45v-7.5L10 2.8Z"}),l.jsx("path",{d:"m3.9 6.25 6.1 3.5 6.1-3.5M10 9.75v7.45"})]}):l.jsx(Pf,{className:"new-chat-mode__agent-icon"})}function Tdt(){return l.jsx("svg",{className:"new-chat-mode__nested-chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m4.5 3 3 3-3 3"})})}function dH(e){const t=El.findIndex(n=>n.value===e);return t>=0?t:El.findIndex(n=>n.value==="temporary")}function _dt({value:e,onChange:t,disabled:n=!1,temporaryEnabled:i,deepseekHarnessEnabled:r}){const[s,a]=m.useState(!1),[o,c]=m.useState(!1),[u,d]=m.useState(()=>dH(e)),f=m.useRef(null),h=m.useRef(null),p=e==="agent"?El[0]:El[1],g=cH.find(k=>k.value===e),b=(g==null?void 0:g.label)??p.label;function y(k){return k.value==="temporary"?i===!0||r===!0?!0:i===!1&&r===!1?!1:void 0:!0}function O(k){return k==="temporary"?i:k==="deepseek-harness"?r:!1}function v(k){return y(k)!==!0}function x(k){const T=y(k);return T===void 0?"正在检查配置":T?k.description:"管理员未配置"}m.useEffect(()=>{if(!s)return;const k=T=>{var A;(A=f.current)!=null&&A.contains(T.target)||(a(!1),c(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[s]);function w(k){let T=u;do T=(T+k+El.length)%El.length;while(v(El[T]));d(T),c(El[T].value==="temporary")}function E(k){var T;if(!v(k)){if(k.value==="temporary"){c(!0);return}t(k.value),a(!1),c(!1),(T=h.current)==null||T.focus()}}function S(k){O(k)===!0&&(t(k),a(!1),c(!1))}return l.jsxs("div",{className:"new-chat-mode",ref:f,children:[l.jsxs("button",{ref:h,type:"button",className:"new-chat-mode__trigger","aria-label":"选择新会话模式","aria-haspopup":"listbox","aria-expanded":s,disabled:n,onClick:()=>{d(dH(e)),a(k=>(k&&c(!1),!k))},onKeyDown:k=>{k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),s?w(k.key==="ArrowDown"?1:-1):a(!0)):s&&(k.key==="Enter"||k.key===" ")?(k.preventDefault(),E(El[u])):s&&k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1))},children:[l.jsx("span",{className:"new-chat-mode__icon",children:l.jsx(uH,{mode:p.value})}),l.jsx("span",{className:"new-chat-mode__current",title:b,children:b}),l.jsx("svg",{className:"new-chat-mode__chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m3 4.5 3 3 3-3"})})]}),s?l.jsxs("div",{className:"new-chat-mode__menus",children:[l.jsx("div",{className:"new-chat-mode__menu",role:"listbox","aria-label":"新会话模式",tabIndex:-1,onKeyDown:k=>{var T;k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),w(k.key==="ArrowDown"?1:-1)):k.key==="Enter"?(k.preventDefault(),E(El[u])):k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1),(T=h.current)==null||T.focus())},children:El.map((k,T)=>{const A=k.value==="temporary";return l.jsxs("button",{type:"button",role:"option","aria-selected":p.value===k.value,"aria-haspopup":A?"menu":void 0,"aria-expanded":A?o:void 0,"aria-disabled":v(k),disabled:v(k),className:`new-chat-mode__option${T===u?" is-active":""}`,onMouseEnter:()=>{d(T),c(k.value==="temporary")},onClick:()=>E(k),children:[l.jsx("span",{className:"new-chat-mode__option-icon",children:l.jsx(uH,{mode:k.value})}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k.label}),l.jsx("span",{children:x(k)})]}),A?l.jsx(Tdt,{}):e===k.value?l.jsx("svg",{className:"new-chat-mode__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})}):null]},k.value)})}),o?l.jsxs("div",{className:"new-chat-mode__submenu",role:"menu","aria-label":"内置智能体",children:[cH.map(k=>{const T=O(k.value);return l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",disabled:T!==!0,onClick:()=>S(k.value),children:[l.jsx(t1,{kind:k.kind,className:"new-chat-mode__builtin-icon"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k.label}),l.jsx("span",{children:T===void 0?"正在检查配置":T?k.description:"管理员未配置"})]})]},k.value)}),kdt.map(({label:k,kind:T})=>l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",disabled:!0,children:[l.jsx(t1,{kind:T,className:"new-chat-mode__builtin-icon"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k}),l.jsx("span",{children:"暂不可用"})]})]},k))]}):null]}):null]})}const mm=[{id:"general",label:"通用智能体"},{id:"codex",label:"Codex 智能体"},{id:"deepseek-harness",label:"DeepSeek Harness"},{id:"openclaw",label:"OpenClaw 智能体"},{id:"hermes",label:"Hermes 智能体"}],Adt=15,Ndt=15e3,Cdt=120,jdt=180;function fH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5.75 3.75 4.25 4.25-4.25 4.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rdt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function aR({type:e,className:t="new-chat-agent-picker__type-icon"}){return e==="general"?l.jsx(Pf,{className:t}):l.jsx(t1,{kind:e,className:t})}function Idt({selectedAgentName:e="",selectedRuntimeId:t="",runtimeScope:n,disabled:i=!1,onSelectRuntime:r,onSelectSandboxSession:s}){var me;const[a,o]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.useState(0),[h,p]=m.useState(0),[g,b]=m.useState("types"),[y,O]=m.useState(!1),[v,x]=m.useState([]),[w,E]=m.useState([]),[S,k]=m.useState(null),[T,A]=m.useState(""),[N,C]=m.useState(!1),[M,L]=m.useState(""),[P,Q]=m.useState(""),j=m.useRef(null),$=m.useRef(null),U=m.useRef(null),B=m.useRef(0),I=m.useRef(null),X=m.useRef(null),q=m.useRef(null),D=((me=mm.find(oe=>oe.id===c))==null?void 0:me.label)??"智能体",H=m.useCallback((oe=!1)=>{var Ne;X.current!==null&&(window.clearTimeout(X.current),X.current=null),q.current!==null&&(window.clearTimeout(q.current),q.current=null),o(!1),u(null),b("types"),O(!1),oe&&((Ne=$.current)==null||Ne.focus())},[]),re=m.useCallback(async(oe="",Ne=!1)=>{const Oe=++B.current;let Ve;C(!0),L("");try{const We=await Promise.race([S_({scope:n,region:"all",pageSize:Adt,nextToken:oe}),new Promise((De,mt)=>{Ve=window.setTimeout(()=>{mt(new Error("加载智能体超时(15 秒),请检查网络或 Runtime 服务后重试"))},Ndt)})]);if(B.current!==Oe)return;x(De=>{const mt=Ne?We.runtimes:[...De,...We.runtimes];return mt.filter((at,Rt)=>mt.findIndex(qe=>qe.runtimeId===at.runtimeId)===Rt)}),A(We.nextToken),p(0)}catch(We){if(B.current!==Oe)return;L(cg(We,"加载通用智能体","GET /web/runtimes"))}finally{window.clearTimeout(Ve),B.current===Oe&&C(!1)}},[n]),fe=m.useCallback(async oe=>{var Ve,We;(Ve=I.current)==null||Ve.abort();const Ne=new AbortController;I.current=Ne;const Oe=++B.current;C(!0),L(""),E([]);try{const De=oe==="codex"?await Kt.listSessions({signal:Ne.signal,autoResumeSnapshots:!0}):await Kt.listAgentSessions(oe,{signal:Ne.signal,autoResumeSnapshots:!0});if(B.current!==Oe)return;E(De),k(oe),p(0)}catch(De){if((De==null?void 0:De.name)==="AbortError"||B.current!==Oe)return;L(cg(De,`加载 ${((We=mm.find(mt=>mt.id===oe))==null?void 0:We.label)??oe}`,`GET /web/${oe==="codex"?"sandbox":oe}/sessions`)),k(oe)}finally{I.current===Ne&&(I.current=null),B.current===Oe&&C(!1)}},[]);m.useEffect(()=>{!a||c!=="general"||v.length>0||N||M||re("",!0)},[c,M,re,N,a,v.length]),m.useEffect(()=>{!a||c===null||c==="general"||S===c||fe(c)},[c,fe,S,a]),m.useEffect(()=>{if(!a)return;const oe=Ne=>{var Oe;(Oe=j.current)!=null&&Oe.contains(Ne.target)||H()};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[H,a]),m.useEffect(()=>()=>{var oe;B.current+=1,(oe=I.current)==null||oe.abort(),X.current!==null&&window.clearTimeout(X.current),q.current!==null&&window.clearTimeout(q.current)},[]);function Ae(oe,Ne=!1){X.current!==null&&(window.clearTimeout(X.current),X.current=null),q.current!==null&&(window.clearTimeout(q.current),q.current=null),o(!0),u(Ne?"general":null),f(0),b("types"),O(Ne),oe&&requestAnimationFrame(()=>{var Oe;return(Oe=U.current)==null?void 0:Oe.focus()})}function J(){i||a||X.current!==null||(X.current=window.setTimeout(()=>{X.current=null,Ae(!1)},Cdt))}function ie(){q.current!==null&&(window.clearTimeout(q.current),q.current=null)}function ue(){X.current!==null&&(window.clearTimeout(X.current),X.current=null),!(!a||q.current!==null)&&(q.current=window.setTimeout(()=>{q.current=null,H()},jdt))}function ye(oe){var Ve;const Ne=(oe+mm.length)%mm.length,Oe=mm[Ne].id;Oe!==c&&(B.current+=1,(Ve=I.current)==null||Ve.abort(),I.current=null,C(!1),L("")),f(Ne),u(Oe),p(0)}async function Se(oe){if(!P){Q(oe.runtimeId),L("");try{await r(oe),H(!0)}catch(Ne){L(cg(Ne,"连接通用智能体"))}finally{Q("")}}}async function Re(oe){if(!P){Q(oe.id),L("");try{await s(oe),H(!0)}catch(Ne){L(cg(Ne,`打开 ${D}`))}finally{Q("")}}}function Ee(oe){if(oe.key==="Escape"){oe.preventDefault(),H(!0);return}if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft","Enter"].includes(oe.key)&&O(!0),g==="types"){oe.key==="ArrowDown"||oe.key==="ArrowUp"?(oe.preventDefault(),ye(d+(oe.key==="ArrowDown"?1:-1))):(oe.key==="ArrowRight"||oe.key==="Enter")&&(oe.preventDefault(),c===null&&ye(d),b("runtimes"));return}if(oe.key==="ArrowLeft")oe.preventDefault(),b("types");else if((c==="general"?v:w).length>0&&(oe.key==="ArrowDown"||oe.key==="ArrowUp")){oe.preventDefault();const Ne=oe.key==="ArrowDown"?1:-1,Oe=c==="general"?v.length:w.length;p(Ve=>(Ve+Ne+Oe)%Oe)}else oe.key==="Enter"&&c==="general"&&v[h]?(oe.preventDefault(),Se(v[h])):oe.key==="Enter"&&c!=="general"&&w[h]&&(oe.preventDefault(),Re(w[h]))}return l.jsxs("div",{className:"new-chat-agent-picker",ref:j,onPointerEnter:oe=>{oe.pointerType==="mouse"&&ie()},onPointerLeave:oe=>{oe.pointerType==="mouse"&&ue()},children:[l.jsxs("button",{ref:$,type:"button",className:"new-chat-agent-picker__trigger","aria-label":"选择智能体","aria-haspopup":"menu","aria-expanded":a,disabled:i,onPointerEnter:oe=>{oe.pointerType==="mouse"&&J()},onClick:()=>a?H():Ae(!0),onKeyDown:oe=>{oe.key==="ArrowDown"||oe.key==="ArrowUp"?(oe.preventDefault(),a||Ae(!0,!0)):oe.key==="Escape"&&a&&(oe.preventDefault(),H(!0))},children:[l.jsx("span",{title:e||"选择智能体",children:e||"选择智能体"}),l.jsx(fH,{className:"new-chat-agent-picker__trigger-chevron"})]}),a?l.jsxs("div",{ref:U,className:"new-chat-agent-picker__menus",tabIndex:-1,onKeyDown:Ee,onPointerMove:oe=>{oe.pointerType==="mouse"&&O(!1)},children:[l.jsx("div",{className:"new-chat-agent-picker__menu",role:"menu","aria-label":"智能体类型",children:mm.map((oe,Ne)=>l.jsxs("button",{type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":c===oe.id,className:`new-chat-agent-picker__type${y&&g==="types"&&d===Ne?" is-keyboard-active":""}`,onMouseEnter:()=>ye(Ne),onClick:()=>{ye(Ne),b("runtimes")},children:[l.jsx(aR,{type:oe.id}),l.jsx("span",{children:oe.label}),l.jsx(fH,{className:"new-chat-agent-picker__nested-chevron"})]},oe.id))}),c!==null?l.jsx("div",{className:"new-chat-agent-picker__submenu",role:"listbox","aria-label":`${D}列表`,children:c!=="general"&&N&&w.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner","aria-hidden":"true"}),"正在加载智能体"]}):c!=="general"&&M&&w.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:M}),l.jsx("button",{type:"button",onClick:()=>void fe(c),children:"重新加载"})]}):c!=="general"&&w.length===0?l.jsxs(Oi,{className:"new-chat-agent-picker__empty",fill:"none",children:[l.jsx(Oi.Icon,{size:"sm",children:l.jsx(aR,{type:c,className:"new-chat-agent-picker__empty-agent-icon"})}),l.jsx(Oi.Title,{children:l.jsxs("span",{className:"new-chat-agent-picker__empty-title",children:["暂无 ",D]})}),l.jsx(Oi.Description,{children:"请前往智能体页创建"})]}):c!=="general"?l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:w.map((oe,Ne)=>{const Oe=P===oe.id,Ve=oe.resourceType==="snapshot";return l.jsxs("button",{type:"button",role:"option","aria-selected":!1,"aria-busy":Oe||void 0,className:`new-chat-agent-picker__runtime${y&&g==="runtimes"&&h===Ne?" is-keyboard-active":""}`,disabled:!!P,title:`${oe.displayName||D} · ${oe.id}`,onMouseEnter:()=>p(Ne),onClick:()=>void Re(oe),children:[l.jsx(aR,{type:c,className:"new-chat-agent-picker__runtime-icon"}),l.jsx("span",{children:oe.displayName||D}),l.jsx("small",{children:Oe?Ve?"正在唤醒":"正在打开":YA(oe.status)})]},oe.id)})}):N&&v.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner","aria-hidden":"true"}),"正在加载智能体"]}):M&&v.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:M}),l.jsx("button",{type:"button",onClick:()=>void re("",!0),children:"重新加载"})]}):v.length===0?l.jsxs(Oi,{className:"new-chat-agent-picker__empty",fill:"none",children:[l.jsx(Oi.Icon,{size:"sm",children:l.jsx(Pf,{})}),l.jsx(Oi.Title,{children:l.jsx("span",{className:"new-chat-agent-picker__empty-title",children:"暂无通用智能体"})}),l.jsx(Oi.Description,{children:"请前往智能体页创建"})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:v.map((oe,Ne)=>{const Oe=P===oe.runtimeId,Ve=oe.runtimeId===t;return l.jsxs("button",{type:"button",role:"option","aria-selected":Ve,"aria-busy":Oe||void 0,className:`new-chat-agent-picker__runtime${y&&g==="runtimes"&&h===Ne?" is-keyboard-active":""}`,disabled:!!P,title:oe.name,onMouseEnter:()=>p(Ne),onClick:()=>void Se(oe),children:[l.jsx(Pf,{className:"new-chat-agent-picker__runtime-icon"}),l.jsx("span",{children:oe.name}),Oe?l.jsx("small",{children:"正在连接"}):Ve?l.jsx(Rdt,{className:"new-chat-agent-picker__check"}):null]},oe.runtimeId)})}),M?l.jsx("div",{className:"new-chat-agent-picker__inline-error",role:"alert",children:M}):null,T?l.jsx("button",{type:"button",className:"new-chat-agent-picker__load-more",disabled:N||!!P,onClick:()=>void re(T),children:N?"加载中":"加载更多"}):null]})}):null]}):null]})}const Pdt=120,Mdt=180;function Ldt(){return l.jsx("svg",{className:"new-chat-compact-select__chevron",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m4.75 6.25 3.25 3.5 3.25-3.5"})})}function Ddt(){return l.jsx("svg",{className:"new-chat-compact-select__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5"})})}function Cp({label:e,hideLabel:t=!1,value:n,options:i,onChange:r,placeholder:s,loading:a=!1,error:o="",disabled:c=!1,searchable:u=!1,onRetry:d}){const[f,h]=m.useState(!1),[p,g]=m.useState(""),[b,y]=m.useState(0),O=m.useRef(null),v=m.useRef(null),x=m.useRef(null),w=m.useRef(!1),E=m.useRef(null),S=m.useRef(null),k=i.find(B=>B.value===n),T=p.trim().toLocaleLowerCase(),A=m.useMemo(()=>T?i.filter(B=>`${B.label} ${B.description||""}`.toLocaleLowerCase().includes(T)):i,[T,i]),N=m.useCallback((B=!1)=>{var I;E.current!==null&&(window.clearTimeout(E.current),E.current=null),S.current!==null&&(window.clearTimeout(S.current),S.current=null),w.current=!1,h(!1),g(""),B&&((I=v.current)==null||I.focus())},[]);m.useEffect(()=>{if(!f)return;const B=I=>{var X;(X=O.current)!=null&&X.contains(I.target)||N()};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[N,f]),m.useEffect(()=>{!f||!u||!w.current||(w.current=!1,requestAnimationFrame(()=>{var B;return(B=x.current)==null?void 0:B.focus()}))},[f,u]),m.useEffect(()=>()=>{E.current!==null&&window.clearTimeout(E.current),S.current!==null&&window.clearTimeout(S.current)},[]);function C(B){E.current!==null&&(window.clearTimeout(E.current),E.current=null),S.current!==null&&(window.clearTimeout(S.current),S.current=null),w.current=B,g(""),y(Math.max(0,i.findIndex(I=>I.value===n))),h(!0)}function M(){c||f||E.current!==null||(E.current=window.setTimeout(()=>{E.current=null,C(!1)},Pdt))}function L(){S.current!==null&&(window.clearTimeout(S.current),S.current=null)}function P(){E.current!==null&&(window.clearTimeout(E.current),E.current=null),!(!f||S.current!==null)&&(S.current=window.setTimeout(()=>{S.current=null,N()},Mdt))}function Q(B){const I=A[B];I&&(r(I.value),N(!0))}function j(B){if(B.key==="Escape"&&f){B.preventDefault(),N(!0);return}if(B.key==="Home"&&f&&A.length>0){B.preventDefault(),y(0);return}if(B.key==="End"&&f&&A.length>0){B.preventDefault(),y(A.length-1);return}if(B.key!=="ArrowDown"&&B.key!=="ArrowUp"){f&&B.key==="Enter"&&A[b]&&(B.preventDefault(),Q(b));return}if(B.preventDefault(),!f){C(!0);return}const I=B.key==="ArrowDown"?1:-1;y(X=>(X+I+A.length)%Math.max(1,A.length))}const $=a&&i.length===0,U=$?"加载中…":(k==null?void 0:k.label)||s;return l.jsxs("div",{className:"new-chat-compact-select",ref:O,onKeyDown:j,onPointerEnter:B=>{B.pointerType==="mouse"&&L()},onPointerLeave:B=>{B.pointerType==="mouse"&&P()},children:[l.jsxs("button",{ref:v,type:"button",className:"new-chat-compact-select__trigger","aria-label":`${e}:${U}`,"aria-haspopup":"listbox","aria-expanded":f,disabled:c,onPointerEnter:B=>{B.pointerType==="mouse"&&M()},onClick:()=>f?N():C(!0),children:[t?null:l.jsx("span",{className:"new-chat-compact-select__label",children:e}),$?l.jsx("span",{className:"new-chat-compact-select__spinner","aria-hidden":"true"}):l.jsx("span",{className:`new-chat-compact-select__value${k?"":" is-placeholder"}`,children:U}),$?null:l.jsx(Ldt,{})]}),f?l.jsxs("div",{className:"new-chat-compact-select__menu",children:[u&&i.length>0?l.jsxs("label",{className:"new-chat-compact-select__search",children:[l.jsxs("span",{className:"sr-only",children:["搜索",e]}),l.jsx("input",{ref:x,value:p,placeholder:`搜索${e}`,onChange:B=>{g(B.currentTarget.value),y(0)}})]}):null,l.jsx("div",{className:"new-chat-compact-select__list",role:"listbox","aria-label":e,children:a&&i.length===0?l.jsx("div",{className:"new-chat-compact-select__status",role:"status",children:"正在加载…"}):o?l.jsxs("div",{className:"new-chat-compact-select__status is-error",role:"alert",children:[l.jsx("span",{children:o}),d?l.jsx("button",{type:"button",onClick:d,children:"重试"}):null]}):A.length===0?l.jsx("div",{className:"new-chat-compact-select__status",children:p?"没有匹配项":"暂无可选项"}):A.map((B,I)=>l.jsxs("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":B.value===n,className:`new-chat-compact-select__option${I===b?" is-active":""}`,onMouseEnter:()=>y(I),onClick:()=>Q(I),children:[l.jsxs("span",{className:"new-chat-compact-select__option-copy",children:[l.jsx("strong",{children:B.label}),B.description?l.jsx("small",{children:B.description}):null]}),B.value===n?l.jsx(Ddt,{}):null]},B.value))})]}):null]})}const Ld=[{value:"create",label:"技能生成"},{value:"optimize",label:"技能优化"}],$dt=120,Qdt=180;function Bdt(){return l.jsx("svg",{className:"new-chat-skill-picker__chevron",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m4.75 6.25 3.25 3.5 3.25-3.5"})})}function Udt(){return l.jsx("svg",{className:"new-chat-skill-picker__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5"})})}function zdt({value:e,onChange:t,disabled:n=!1}){const[i,r]=m.useState(!1),[s,a]=m.useState(()=>Math.max(0,Ld.findIndex(x=>x.value===e))),o=m.useRef(null),c=m.useRef(null),u=m.useRef(null),d=m.useRef(null),f=Ld.find(x=>x.value===e)??Ld[0],h=m.useCallback((x=!1)=>{var w;u.current!==null&&(window.clearTimeout(u.current),u.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),r(!1),x&&((w=c.current)==null||w.focus())},[]);m.useEffect(()=>{if(!i)return;const x=w=>{var E;(E=o.current)!=null&&E.contains(w.target)||h()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[h,i]),m.useEffect(()=>()=>{u.current!==null&&window.clearTimeout(u.current),d.current!==null&&window.clearTimeout(d.current)},[]);function p(){u.current!==null&&(window.clearTimeout(u.current),u.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Math.max(0,Ld.findIndex(x=>x.value===e))),r(!0)}function g(){n||i||u.current!==null||(u.current=window.setTimeout(()=>{u.current=null,p()},$dt))}function b(){d.current!==null&&(window.clearTimeout(d.current),d.current=null)}function y(){u.current!==null&&(window.clearTimeout(u.current),u.current=null),!(!i||d.current!==null)&&(d.current=window.setTimeout(()=>{d.current=null,h()},Qdt))}function O(x){const w=Ld[x];w&&(t(w.value),a(x),h(!0))}function v(x){if(x.key==="Escape"&&i){x.preventDefault(),h(!0);return}if(x.key!=="ArrowDown"&&x.key!=="ArrowUp"){i&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),O(s));return}if(x.preventDefault(),!i){p();return}const w=x.key==="ArrowDown"?1:-1;a(E=>(E+w+Ld.length)%Ld.length)}return l.jsxs("div",{className:"new-chat-skill-picker",ref:o,onPointerEnter:x=>{x.pointerType==="mouse"&&b()},onPointerLeave:x=>{x.pointerType==="mouse"&&y()},children:[l.jsxs("button",{ref:c,type:"button",className:"new-chat-skill-picker__trigger","aria-label":"选择技能定制方式","aria-haspopup":"listbox","aria-expanded":i,disabled:n,onPointerEnter:x=>{x.pointerType==="mouse"&&g()},onClick:()=>{i?h():p()},onKeyDown:v,children:[l.jsx("span",{children:f.label}),l.jsx(Bdt,{})]}),i?l.jsx("div",{className:"new-chat-skill-picker__menu",role:"listbox","aria-label":"技能定制方式",tabIndex:-1,onKeyDown:v,children:Ld.map((x,w)=>l.jsxs("button",{type:"button",role:"option","aria-selected":x.value===e,className:`new-chat-skill-picker__option${w===s?" is-active":""}`,onMouseEnter:()=>a(w),onClick:()=>O(w),children:[l.jsx("span",{children:x.label}),x.value===e?l.jsx(Udt,{}):null]},x.value))}):null]})}const Fdt=120,Vdt=180;function hH(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5.75 3.75 4.25 4.25-4.25 4.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xdt(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:l.jsx("path",{d:"m3.25 8.25 3 3 6.5-6.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function oR(e){return e.name.trim()||"未命名 Skill Space"}function qdt({spaces:e,skills:t,activeSpaceId:n,selectedSpaceId:i,selectedSkillId:r,selectedSkillLabel:s,spacesLoading:a=!1,skillsLoading:o=!1,spacesError:c="",skillsError:u="",disabled:d=!1,onActivateSpace:f,onSelect:h,onRetrySpaces:p,onRetrySkills:g}){const[b,y]=m.useState(!1),[O,v]=m.useState(0),[x,w]=m.useState(0),[E,S]=m.useState("spaces"),[k,T]=m.useState(!1),[A,N]=m.useState("below"),[C,M]=m.useState(286),L=m.useRef(null),P=m.useRef(null),Q=m.useRef(null),j=m.useRef(null),$=m.useRef(null),U=e.find(ue=>ue.id===n)??null,B=U?oR(U):"Skill Space",I=s||"选择 Skill",X=m.useCallback((ue=!1)=>{var ye;j.current!==null&&(window.clearTimeout(j.current),j.current=null),$.current!==null&&(window.clearTimeout($.current),$.current=null),y(!1),S("spaces"),T(!1),f(""),ue&&((ye=P.current)==null||ye.focus())},[f]);m.useEffect(()=>{if(!b)return;const ue=ye=>{var Se;(Se=L.current)!=null&&Se.contains(ye.target)||X()};return document.addEventListener("mousedown",ue),()=>document.removeEventListener("mousedown",ue)},[X,b]),m.useEffect(()=>{d&&b&&X()},[X,d,b]);const q=m.useCallback(()=>{const ue=P.current;if(!ue)return;const ye=ue.getBoundingClientRect(),Se=12,Re=7,Ee=window.innerHeight-ye.bottom-Re-Se,me=ye.top-Re-Se,oe=Ee>=220||Ee>=me?"below":"above",Ne=oe==="below"?Ee:me;N(oe),M(Math.max(120,Math.floor(Ne)))},[]);m.useLayoutEffect(()=>{if(b)return q(),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[b,q]),m.useEffect(()=>()=>{j.current!==null&&window.clearTimeout(j.current),$.current!==null&&window.clearTimeout($.current)},[]);function D(ue){if(e.length===0)return;const ye=(ue+e.length)%e.length,Se=e[ye];v(ye),w(0),Se.id!==n&&f(Se.id)}function H(ue,ye=!1){j.current!==null&&(window.clearTimeout(j.current),j.current=null),$.current!==null&&(window.clearTimeout($.current),$.current=null);const Se=e.findIndex(Ee=>Ee.id===i),Re=Se>=0?Se:0;v(Re),w(0),S("spaces"),T(ye),y(!0),ye&&e[Re]?f(e[Re].id):f(""),ue&&requestAnimationFrame(()=>{var Ee;return(Ee=Q.current)==null?void 0:Ee.focus()})}function re(){d||b||j.current!==null||(j.current=window.setTimeout(()=>{j.current=null,H(!1)},Fdt))}function fe(){$.current!==null&&(window.clearTimeout($.current),$.current=null)}function Ae(){j.current!==null&&(window.clearTimeout(j.current),j.current=null),!(!b||$.current!==null)&&($.current=window.setTimeout(()=>{$.current=null,X()},Vdt))}function J(ue){U&&(h(U,ue),X(!0))}function ie(ue){if(ue.key==="Escape"){ue.preventDefault(),X(!0);return}if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft","Enter"].includes(ue.key)&&T(!0),E==="spaces"){ue.key==="ArrowDown"||ue.key==="ArrowUp"?(ue.preventDefault(),D(O+(ue.key==="ArrowDown"?1:-1))):(ue.key==="ArrowRight"||ue.key==="Enter")&&(ue.preventDefault(),U||D(O),S("skills"));return}if(ue.key==="ArrowLeft")ue.preventDefault(),S("spaces");else if(t.length>0&&(ue.key==="ArrowDown"||ue.key==="ArrowUp")){ue.preventDefault();const ye=ue.key==="ArrowDown"?1:-1;w(Se=>(Se+ye+t.length)%t.length)}else ue.key==="Enter"&&t[x]&&(ue.preventDefault(),J(t[x]))}return l.jsxs("div",{className:"new-chat-skill-target-picker",ref:L,onPointerEnter:ue=>{ue.pointerType==="mouse"&&fe()},onPointerLeave:ue=>{ue.pointerType==="mouse"&&Ae()},children:[l.jsxs("button",{ref:P,type:"button",className:"new-chat-agent-picker__trigger new-chat-skill-target-picker__trigger","aria-label":`选择 Skill:${I}`,"aria-haspopup":"menu","aria-expanded":b,disabled:d,onPointerEnter:ue=>{ue.pointerType==="mouse"&&re()},onClick:()=>b?X():H(!0),onKeyDown:ue=>{ue.key==="ArrowDown"||ue.key==="ArrowUp"?(ue.preventDefault(),b||H(!0,!0)):ue.key==="Escape"&&b&&(ue.preventDefault(),X(!0))},children:[l.jsx("span",{title:I,children:I}),l.jsx(hH,{className:"new-chat-agent-picker__trigger-chevron"})]}),b?l.jsxs("div",{ref:Q,className:`new-chat-agent-picker__menus new-chat-skill-target-picker__menus is-${A}`,style:{"--new-chat-skill-menu-max-height":`${C}px`},tabIndex:-1,onKeyDown:ie,onPointerMove:ue=>{ue.pointerType==="mouse"&&T(!1)},children:[l.jsx("div",{className:"new-chat-agent-picker__menu",role:"menu","aria-label":"Skill Space",children:a&&e.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner new-chat-skill-target-picker__spinner","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:"正在加载 Skill Space"})]}):c&&e.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:c}),l.jsx("button",{type:"button",onClick:p,children:"重新加载"})]}):e.length===0?l.jsx("div",{className:"new-chat-skill-target-picker__empty",children:"暂无 Skill Space"}):e.map((ue,ye)=>l.jsxs("button",{type:"button",role:"menuitem","aria-haspopup":"listbox","aria-expanded":n===ue.id,className:`new-chat-agent-picker__type new-chat-skill-target-picker__space${n===ue.id?" is-previewed":""}${k&&E==="spaces"&&O===ye?" is-keyboard-active":""}`,title:oR(ue),onMouseEnter:()=>D(ye),onClick:()=>{D(ye),S("skills")},children:[l.jsx("span",{children:oR(ue)}),l.jsx(hH,{className:"new-chat-agent-picker__nested-chevron"})]},ue.id))}),U?l.jsx("div",{className:"new-chat-agent-picker__submenu new-chat-skill-target-picker__submenu",role:"listbox","aria-label":`${B} Skill 列表`,children:o&&t.length===0?l.jsxs("div",{className:"new-chat-agent-picker__status",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"new-chat-agent-picker__spinner new-chat-skill-target-picker__spinner","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:"正在加载 Skill"})]}):u&&t.length===0?l.jsxs("div",{className:"new-chat-agent-picker__error",role:"alert",children:[l.jsx("span",{children:u}),l.jsx("button",{type:"button",onClick:g,children:"重新加载"})]}):t.length===0?l.jsx("div",{className:"new-chat-skill-target-picker__empty",children:"暂无 Skill"}):l.jsx("div",{className:"new-chat-agent-picker__runtime-list",children:t.map((ue,ye)=>{const Se=U.id===i&&ue.skillId===r;return l.jsxs("button",{type:"button",role:"option","aria-selected":Se,className:`new-chat-agent-picker__runtime new-chat-skill-target-picker__skill${k&&E==="skills"&&x===ye?" is-keyboard-active":""}`,title:ue.skillDescription||ue.skillName||ue.skillId,onMouseEnter:()=>w(ye),onClick:()=>J(ue),children:[l.jsx("span",{children:ue.skillName||ue.skillId}),ue.skillDescription?l.jsx("small",{children:ue.skillDescription}):null,Se?l.jsx(Xdt,{className:"new-chat-agent-picker__check"}):null]},ue.skillId)})})}):null]}):null]})}const pH={concise:"简洁实用",strict:"严谨稳健",tutorial:"教程友好",automation:"自动化优先"};function lR(e,t){return e instanceof Error&&e.message?e.message:t}function Hdt({action:e,onActionChange:t,optimizationSource:n=null,onOptimizationSourceChange:i,disabled:r=!1}){const[s,a]=m.useState(null),[o,c]=m.useState(!1),[u,d]=m.useState(""),[f,h]=m.useState(0),[p,g]=m.useState("concise"),[b,y]=m.useState(""),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(""),[k,T]=m.useState(0),[A,N]=m.useState(""),[C,M]=m.useState([]),[L,P]=m.useState(!1),[Q,j]=m.useState(""),[$,U]=m.useState(0);m.useEffect(()=>{if(e!=="create"||s)return;const q=new AbortController;return c(!0),d(""),aA(q.signal).then(D=>{a(D),y(H=>{var re;return H||((re=D.models[0])==null?void 0:re.id)||""}),!D.enabled&&D.reason&&d(D.reason)}).catch(D=>{q.signal.aborted||d(lR(D,"模型配置加载失败"))}).finally(()=>{q.signal.aborted||c(!1)}),()=>q.abort()},[e,s,f]),m.useEffect(()=>{if(e!=="optimize"||O.length>0)return;let q=!1;return w(!0),S(""),A$().then(D=>{q||v(D)}).catch(D=>{q||S(lR(D,"Skill Space 加载失败"))}).finally(()=>{q||w(!1)}),()=>{q=!0}},[e,O.length,k]);const B=O.find(q=>q.id===A);m.useEffect(()=>{if(e!=="optimize"||!B){M([]),j(""),P(!1);return}let q=!1;return M([]),P(!0),j(""),N$(B.id,B.region).then(D=>{q||M(D)}).catch(D=>{q||j(lR(D,"Skill 加载失败"))}).finally(()=>{q||P(!1)}),()=>{q=!0}},[e,B,$]);const I=m.useMemo(()=>Object.keys(s?s.styles:pH).map(D=>({value:D,label:pH[D]||D})),[s]),X=m.useMemo(()=>(s==null?void 0:s.models.map(q=>({value:q.id,label:q.label})))||[],[s]);return l.jsxs("div",{className:`new-chat-skill-controls is-${e}`,"aria-label":"技能定制配置",children:[l.jsx(zdt,{value:e,onChange:t,disabled:r}),e==="create"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-skill-controls__style",children:l.jsx(Cp,{label:"风格",value:p,options:I,onChange:g,placeholder:"选择风格",disabled:r})}),l.jsx("div",{className:"new-chat-skill-controls__model",children:l.jsx(Cp,{label:"模型",hideLabel:!0,value:b,options:X,onChange:y,placeholder:"选择模型",loading:o,error:u,disabled:r,onRetry:()=>{a(null),h(q=>q+1)}})})]}):l.jsx(qdt,{spaces:O,skills:C,activeSpaceId:A,selectedSpaceId:(n==null?void 0:n.space.id)||"",selectedSkillId:(n==null?void 0:n.skill.skillId)||"",selectedSkillLabel:(n==null?void 0:n.skill.skillName)||(n==null?void 0:n.skill.skillId)||"",spacesLoading:x,skillsLoading:L,spacesError:E,skillsError:Q,disabled:r,onActivateSpace:N,onSelect:(q,D)=>{i==null||i({space:q,skill:D})},onRetrySpaces:()=>{v([]),T(q=>q+1)},onRetrySkills:()=>{M([]),U(q=>q+1)}})]})}const mH=[{value:"auto",label:"自动识别"},{value:"text_to_video",label:"文生视频"},{value:"reference_to_video",label:"参考素材生视频"},{value:"video_editing",label:"视频编辑"},{value:"video_extension",label:"视频续写"},{value:"first_last_frame",label:"首尾帧生成"}],Ydt=[{value:"21:9",label:"21:9"},{value:"16:9",label:"16:9"},{value:"4:3",label:"4:3"},{value:"1:1",label:"1:1"},{value:"3:4",label:"3:4"},{value:"9:16",label:"9:16"}],Gdt=[{value:"480p",label:"480p"},{value:"720p",label:"720p"}],Wdt={taskMode:"auto",aspectRatio:"16:9",resolution:"720p",durationSeconds:8,referenceImage:null,referenceVideo:null,firstFrame:null,lastFrame:null};function rpe({kind:e,...t}){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:e==="image"?l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"4",width:"17",height:"16",rx:"2.5"}),l.jsx("circle",{cx:"9",cy:"9.25",r:"1.5"}),l.jsx("path",{d:"m5.75 17 4.1-4.1a1.25 1.25 0 0 1 1.77 0l1.35 1.35 1.55-1.55a1.25 1.25 0 0 1 1.77 0L19 15.4"})]}):l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"5",width:"12.5",height:"14",rx:"2.5"}),l.jsx("path",{d:"m16 9.5 3.1-1.75a.9.9 0 0 1 1.35.78v6.94a.9.9 0 0 1-1.35.78L16 14.5"}),l.jsx("path",{d:"m9 9.5 3.5 2.5L9 14.5Z"})]})})}function spe(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m4.5 4.5 7 7m0-7-7 7"})})}function Zdt({asset:e,onChange:t,disabled:n=!1,unavailableReason:i="",kind:r,label:s}){const a=m.useId(),[o,c]=m.useState("");m.useEffect(()=>{if(!e){c("");return}const d=URL.createObjectURL(e);return c(d),()=>URL.revokeObjectURL(d)},[e]);function u(d){var h;const f=((h=d.currentTarget.files)==null?void 0:h[0])??null;f&&t(f),d.currentTarget.value=""}return l.jsxs("div",{className:`new-chat-inline-video${e?" has-preview":""}${n?" is-disabled":""}`,children:[l.jsx("input",{id:a,className:"new-chat-inline-video__input",type:"file",accept:`${r}/*`,disabled:n,required:!0,"aria-label":`上传${s}`,onChange:u}),l.jsx("label",{className:"new-chat-inline-video__tile",htmlFor:a,title:i||(e?`更换${s}:${e.name}`:`上传${s}`),children:o&&r==="image"?l.jsx("img",{src:o,alt:""}):o?l.jsx("video",{src:o,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):l.jsxs(l.Fragment,{children:[l.jsx(rpe,{kind:r}),l.jsx("span",{children:s})]})}),e?l.jsx("button",{className:"new-chat-inline-video__remove",type:"button","aria-label":`移除${s} ${e.name}`,disabled:n,onClick:()=>t(null),children:l.jsx(spe,{})}):null]})}function Kdt(){return l.jsx("span",{className:"new-chat-video-model-spinner",role:"status","aria-label":"正在加载增强模型"})}function cR({label:e,helper:t,accept:n,asset:i,onChange:r,disabled:s,kind:a}){const o=m.useId();function c(u){var f;const d=((f=u.currentTarget.files)==null?void 0:f[0])??null;d&&r(d),u.currentTarget.value=""}return l.jsxs("div",{className:`new-chat-video-asset${s?" is-disabled":""}`,children:[l.jsx("input",{id:o,className:"new-chat-video-asset__input",type:"file",accept:n,disabled:s,onChange:c}),l.jsxs("label",{className:"new-chat-video-asset__label",htmlFor:o,children:[l.jsx("span",{className:"new-chat-video-asset__icon",children:l.jsx(rpe,{kind:a})}),l.jsxs("span",{className:"new-chat-video-asset__copy",children:[l.jsxs("span",{className:"new-chat-video-asset__title",children:[e,l.jsx("small",{children:"可选"})]}),l.jsx("span",{className:`new-chat-video-asset__value${i?" is-selected":""}`,title:i==null?void 0:i.name,children:(i==null?void 0:i.name)||t})]}),l.jsx("span",{className:"new-chat-video-asset__action",children:i?"更换":"添加"})]}),i?l.jsx("button",{className:"new-chat-video-asset__remove",type:"button","aria-label":`移除${e} ${i.name}`,disabled:s,onClick:()=>r(null),children:l.jsx(spe,{})}):null]})}function Jdt({config:e,onChange:t,enhancerModel:n,assetStorageAvailable:i,assetStorageUnavailableReason:r="",modelsLoading:s=!1,modelsError:a="",disabled:o=!1}){const c=uwe();function u(g,b){t({...e,[g]:b})}const d=e.taskMode==="first_last_frame",f=e.taskMode==="video_editing",h=e.taskMode==="video_extension",p=o||!i;return l.jsxs(wr.section,{className:"new-chat-video-controls","aria-label":"视频创作配置",initial:c?!1:{opacity:0,y:-12,scaleY:.96},animate:{opacity:1,y:0,scaleY:1},exit:c?{opacity:0}:{opacity:0,y:-8,scaleY:.98},transition:{duration:c?0:.2,ease:[.22,1,.36,1]},children:[l.jsxs("div",{className:"new-chat-video-controls__parameters",children:[l.jsx("div",{className:"new-chat-video-controls__field",children:l.jsx(Cp,{label:"比例",value:e.aspectRatio,options:Ydt,placeholder:"选择比例",disabled:o,onChange:g=>u("aspectRatio",g)})}),l.jsx("div",{className:"new-chat-video-controls__field",children:l.jsx(Cp,{label:"清晰度",value:e.resolution,options:Gdt,placeholder:"选择清晰度",disabled:o,onChange:g=>u("resolution",g)})}),l.jsxs("label",{className:`new-chat-video-duration${o?" is-disabled":""}`,children:[l.jsxs("span",{className:"new-chat-video-duration__header",children:[l.jsx("span",{children:"时长"}),l.jsxs("output",{children:[e.durationSeconds,"s"]})]}),l.jsx("input",{type:"range",min:"4",max:"30",step:"1",value:e.durationSeconds,disabled:o,"aria-label":`视频时长:${e.durationSeconds} 秒`,onChange:g=>u("durationSeconds",Number(g.currentTarget.value))})]})]}),l.jsx("div",{className:`new-chat-video-controls__assets${d||f||h?" is-single":""}`,children:d?l.jsx(cR,{label:"尾帧",helper:"添加视频结束画面",accept:"image/*",asset:e.lastFrame,disabled:p,kind:"image",onChange:g=>u("lastFrame",g)}):l.jsxs(l.Fragment,{children:[l.jsx(cR,{label:f||h?"辅助图片":"参考图片",helper:f||h?"用于补充画面参考":"支持常见图片格式",accept:"image/*",asset:e.referenceImage,disabled:p,kind:"image",onChange:g=>u("referenceImage",g)}),f||h?null:l.jsx(cR,{label:"参考视频",helper:"支持常见视频格式",accept:"video/*",asset:e.referenceVideo,disabled:p,kind:"video",onChange:g=>u("referenceVideo",g)})]})}),!i&&r?l.jsx("p",{className:"new-chat-video-controls__storage-unavailable",role:"status",children:r}):null,l.jsx("p",{className:"new-chat-video-controls__model-hint",title:a||void 0,children:s?l.jsx(Kdt,{}):n?l.jsxs(l.Fragment,{children:["使用 ",n," 模型进行意图识别和提示词增强"]}):"增强模型不可用"})]})}function eft({className:e=""}){return l.jsxs("span",{className:`${e} new-chat-workspace-tabs__skill-icon`,"aria-hidden":"true",children:[l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-triangle"}),l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-circle"}),l.jsx(Q2,{className:"new-chat-workspace-tabs__skill-shape is-square"})]})}const uR=[{value:"agent",label:"智能体",icon:Pf},{value:"skill",label:"技能定制",icon:eft},{value:"video",label:"视频创作",icon:D3}];function tft({value:e,onChange:t,disabled:n=!1,skillCustomizationEnabled:i=!1}){const r=m.useRef([]),s=i?uR:uR.filter(c=>c.value!=="skill");function a(c){var d;const u=s[c];!u||n||(t(u.value),(d=r.current[c])==null||d.focus())}function o(c,u){let d=null;c.key==="ArrowRight"&&(d=(u+1)%s.length),c.key==="ArrowLeft"&&(d=(u-1+s.length)%s.length),c.key==="Home"&&(d=0),c.key==="End"&&(d=uR.length-1),d!==null&&(c.preventDefault(),a(d))}return l.jsx("div",{className:"new-chat-workspace-tabs",role:"tablist","aria-label":"新会话模式",children:s.map((c,u)=>{const d=c.icon,f=e===c.value;return l.jsxs("button",{ref:h=>{r.current[u]=h},id:`new-chat-workspace-tab-${c.value}`,type:"button",role:"tab","aria-controls":"new-chat-workspace-panel","aria-selected":f,tabIndex:f?0:-1,className:`new-chat-workspace-tabs__tab${f?" is-active":""}`,disabled:n,onClick:()=>t(c.value),onKeyDown:h=>o(h,u),children:[f?l.jsx(wr.span,{className:"new-chat-workspace-tabs__slider",layoutId:"new-chat-workspace-active-pill",initial:!1,transition:{layout:{duration:.24,ease:[.22,1,.36,1]}},"aria-hidden":"true"}):null,l.jsx(d,{className:"new-chat-workspace-tabs__icon"}),l.jsx("span",{className:"new-chat-workspace-tabs__label",children:c.label})]},c.value)})})}const nft={auto:"视频生成",text_to_video:"文生视频",reference_to_video:"参考素材生视频",video_editing:"视频编辑",video_extension:"视频续写",first_last_frame:"首尾帧生成"};function ape(e){return e?nft[e]:"视频生成"}function ift({prompt:e,config:t,enhancerModel:n,generationModel:i}){return{localId:crypto.randomUUID(),remoteTaskId:"",runId:1,status:"optimizing",requestedPrompt:e,optimizedPrompt:"",requestedMode:t.taskMode,resolvedMode:null,config:{...t},enhancerModel:n,generationModel:i,assetIds:[],output:null,errorStage:null,error:""}}function gH(e,t){return t.type==="optimization_succeeded"?{...e,status:"generating",optimizedPrompt:t.optimizedPrompt,resolvedMode:t.resolvedMode,enhancerModel:t.enhancerModel,errorStage:null,error:""}:t.type==="assets_uploaded"?{...e,assetIds:t.assetIds}:t.type==="generation_started"?{...e,status:"generating",remoteTaskId:t.remoteTaskId,generationModel:t.generationModel,errorStage:null,error:""}:t.type==="generation_succeeded"?{...e,status:"success",output:t.output,errorStage:null,error:""}:t.type==="failed"?{...e,status:"error",errorStage:t.stage,error:t.error}:{...e,runId:e.runId+1,status:t.stage==="optimization"?"optimizing":"generating",remoteTaskId:"",optimizedPrompt:t.stage==="optimization"?"":e.optimizedPrompt,resolvedMode:t.stage==="optimization"?null:e.resolvedMode,output:null,errorStage:null,error:""}}function rft(e){const t=ape(e.resolvedMode),n=e.status==="error"&&e.errorStage==="optimization",i=e.status==="error"&&e.errorStage==="generation",r=!!e.optimizedPrompt&&!n;return[{id:"optimization",label:n?"提示词优化失败":r?"提示词优化完成":"提示词优化中",status:n?"failed":r?"done":"active"},{id:"generation",label:e.status==="success"?`${t}已完成`:i?`${t}失败`:e.status==="generating"?`${t}进行中`:"等待视频生成",status:e.status==="success"?"done":i?"failed":e.status==="generating"?"active":"pending"}]}function ope(e){return(e==null?void 0:e.status)==="optimizing"||(e==null?void 0:e.status)==="generating"}const lpe={ppt:["ppt_generate"],image:["image_generate"],video:["video_generate"]},sft={ppt:[],image:[],video:["video_task_query"]},aft=[{pattern:/(?:^|[-_.])glm[-_.]?5[-_.]?2(?:[-_.]|$)/,tokens:1024e3},{pattern:/(?:^|[-_.])deepseek[-_.]?v4(?:[-_.]|$)/,tokens:1024e3}],oft=[{pattern:/doubao[-_.]seed[-_.]evolving(?:[-_.]|$)/,tokens:1024e3},{pattern:/doubao[-_.]seed[-_.]translation(?:[-_.]|$)/,tokens:4e3},{pattern:/doubao[-_.]seed[-_.]character(?:[-_.]|$)/,tokens:128e3},{pattern:/doubao[-_.]1[-_.]?5[-_.]pro[-_.]32k[-_.]character(?:[-_.]|$)/,tokens:32e3},{pattern:/doubao[-_.]1[-_.]?5[-_.]pro[-_.]32k(?:[-_.]|$)/,tokens:128e3},{pattern:/doubao[-_.]1[-_.]?5[-_.](?:lite[-_.]32k|vision[-_.]pro[-_.]32k)(?:[-_.]|$)/,tokens:32e3},{pattern:/doubao[-_.]seed[-_.]2[-_.][01](?:[-_.]|$)/,tokens:256e3},{pattern:/doubao[-_.]seed[-_.](?:1[-_.][68]|code[-_.]preview)(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])glm[-_.]?4[-_.]?7(?:[-_.]|$)/,tokens:2e5}],lft=[{pattern:/dola[-_.]seed[-_.]2[-_.]1(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])seed[-_.]2[-_.]0(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])seed[-_.]1[-_.][68](?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])glm[-_.]?4[-_.]?7(?:[-_.]|$)/,tokens:256e3},{pattern:/(?:^|[-_.])deepseek[-_.]?v3[-_.]?2(?:[-_.]|$)/,tokens:128e3},{pattern:/(?:^|[-_.])gpt[-_.]?oss[-_.]?120b(?:[-_.]|$)/,tokens:128e3}];function cft(e){const t=e.match(/(?:^|[-_.])(\d+(?:\.\d+)?)(k|m)(?:[-_.]|$)/i);if(!t)return null;const n=Number(t[1]);return!Number.isFinite(n)||n<=0?null:Math.round(n*(t[2].toLowerCase()==="m"?1e6:1e3))}function uft(e,t){const n=e.trim().toLowerCase().split("/").pop()??"";if(!n)return null;const i=t==="byteplus"?lft:oft;for(const r of[...i,...aft])if(r.pattern.test(n))return r.tokens;return cft(n)}const Dh=new Intl.NumberFormat("zh-CN");function bH(e){return e>=1e3?`${Number((e/1e3).toFixed(1))}K`:Dh.format(e)}function dR(e){return e>=1e3?`${Number((e/1e3).toFixed(1))}K`:`${Dh.format(e)} Token`}function OH(e){return`${Number(e.toFixed(2))}%`}const yH={system:"系统与工具",input:"输入与历史",output:"输出与思考",remaining:"剩余"};function dft({cloudProvider:e,modelName:t,usage:n,systemTokenEstimate:i}){const r=m.useId(),s=uft(t,e),a=s?kEe({usage:n,contextWindow:s,estimatedSystemTokens:i}):null,o=(a==null?void 0:a.usedTokens)??n.current.totalTokenCount,c=s?o/s*100:null,u=c===null?null:Math.round(c),d=c!==null&&c>0&&c<1?"<1":String(u??0),f=c===null?0:Math.min(100,Math.max(0,c)),h=100-f,p=t.trim()||"模型信息未提供",g=i===null?"提示词(含系统)":yH.input,b=a?Math.max(0,a.usedTokens-a.contextWindow):0,y=i===null?"系统与工具占用未知":`系统与工具约 ${Dh.format((a==null?void 0:a.systemTokens)??0)} Token`,O=a?`上下文已使用 ${d}%,${y},${g} ${Dh.format(a.inputTokens)} Token,输出与思考 ${Dh.format(a.outputTokens)} Token,剩余 ${Dh.format(a.remainingTokens)} Token`:`${p},上下文窗口未知,会话累计使用 ${Dh.format(n.cumulative.totalTokenCount)} Token`,v=a?TEe(a):[],x=a?[{kind:"system",tokens:a.systemTokens},{kind:"input",tokens:a.inputTokens},{kind:"output",tokens:a.outputTokens},{kind:"remaining",tokens:a.remainingTokens}]:[];return l.jsxs("div",{className:"token-usage-indicator",tabIndex:0,role:s===null?"status":"meter","aria-label":O,"aria-describedby":r,"aria-valuemin":s===null?void 0:0,"aria-valuemax":s??void 0,"aria-valuenow":s===null?void 0:Math.min(o,s),children:[l.jsxs("svg",{className:"token-usage-ring",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{className:"token-usage-ring__track",cx:"10",cy:"10",r:"7"}),l.jsx("circle",{className:"token-usage-ring__value",cx:"10",cy:"10",r:"7",pathLength:"100",style:{strokeDasharray:`${f} ${100-f}`}})]}),l.jsxs("div",{id:r,className:"token-usage-tooltip",role:"tooltip",children:[a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"token-usage-tooltip__header",children:[l.jsx("strong",{children:"上下文构成"}),l.jsxs("span",{children:[d,"% 已用"]})]}),l.jsxs("div",{className:"token-context-breakdown",children:[l.jsx("div",{className:"token-context-grid",role:"img","aria-label":"100 格上下文构成图,每格代表上下文窗口的百分之一",children:v.map(w=>l.jsx("span",{className:"token-context-cell","aria-hidden":"true",children:w.slices.map(E=>l.jsx("span",{className:`token-context-cell__slice is-${E.kind}`,style:{width:`${E.share*100}%`}},E.kind))},w.index))}),l.jsx("dl",{className:"token-context-legend",children:x.map(w=>l.jsxs("div",{children:[l.jsxs("dt",{children:[l.jsx("span",{className:`token-context-swatch is-${w.kind}`,"aria-hidden":"true"}),w.kind==="input"?g:yH[w.kind],w.kind==="system"&&i!==null?l.jsx("em",{children:"估算"}):null]}),l.jsx("dd",{children:w.kind==="system"&&i===null?"未知":`${w.kind==="system"?"≈":""}${bH(w.tokens)}`})]},w.kind))})]}),l.jsxs("div",{className:"token-context-summary",children:[l.jsxs("div",{children:[l.jsx("strong",{children:OH(f)})," 已用,剩余"," ",l.jsx("strong",{children:OH(h)})]}),l.jsxs("div",{children:[l.jsx("strong",{children:dR(a.usedTokens)})," 已用,剩余"," ",l.jsx("strong",{children:dR(a.remainingTokens)}),",总计"," ",l.jsx("strong",{children:dR(a.contextWindow)})]})]}),b>0?l.jsxs("div",{className:"token-usage-tooltip__overflow",children:["已超出上下文 ",bH(b)," Token"]}):null]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"token-usage-tooltip__title",children:"上下文用量"}),l.jsx("div",{className:"token-usage-tooltip__unknown",children:t.trim()?"暂未收录该模型的上下文窗口":"当前 Runtime 未提供模型信息"})]}),l.jsx("div",{className:"token-usage-tooltip__model",title:p,children:p})]})]})}const xH=[{value:"ppt",label:"PPT",icon:sSe,prompts:["复盘【季度】经营表现,提炼指标差距、原因与行动建议","汇报【项目名称】进展:里程碑、风险、预算和资源诉求","为【客户行业】输出解决方案:痛点、架构、实施路径与收益","分析【行业主题】趋势,给出竞争格局、机会与战略建议"]},{value:"image",label:"图片生成",icon:LD,prompts:["为【品牌或产品】设计【高级科技】风格的发布会主视觉","生成【产品名称】电商海报,突出【核心卖点】与品牌色","呈现【产品或空间】在【使用场景】中的写实概念效果图","围绕【传播主题】制作简洁专业的企业社媒配图"]},{value:"video",label:"视频生成",icon:D3,prompts:["制作【品牌名称】30 秒宣传片,突出【品牌价值】","为【产品名称】制作 45 秒发布视频:痛点、功能、场景与行动号召","制作【培训主题】企业培训视频,讲清【关键操作或规范】","生成【活动名称】20 秒预热视频,包含亮点、时间地点和报名信息"]}];function fft({cloudProvider:e,sessionId:t,sessionInitializing:n=!1,appName:i,agentName:r,value:s,onChange:a,onSubmit:o,onStop:c,onVideoSubmit:u,videoTask:d=null,onOpenVideoTask:f,disabled:h,busy:p,showMeta:g,attachments:b,skills:y,agents:O,invocation:v,capabilitiesLoading:x=!1,modelName:w,tokenUsage:E,systemTokenEstimate:S,allowAttachments:k=!0,onInvocationChange:T,onAddFiles:A,onRemoveAttachment:N,newChatMode:C="agent",newChatWorkspaceMode:M="agent",newChatSkillAction:L="create",newChatSkillTarget:P=null,skillCustomizationEnabled:Q=!1,newChatTask:j=null,newChatLayout:$=!1,showWorkspaceTabs:U=!1,showModeSelector:B=!1,onWorkspaceModeChange:I,onSkillActionChange:X,onSkillTargetChange:q,onModeChange:D,onTaskChange:H,temporaryEnabled:re,deepseekHarnessEnabled:fe,harnessEnabled:Ae=!1,builtinTools:J=[],showAgentPicker:ie=!1,agentPickerDisabled:ue=!1,selectedRuntimeId:ye="",runtimeScope:Se="mine",onSelectRuntime:Re,onSelectSandboxSession:Ee}){var hi;const me=m.useRef(null),oe=m.useRef(null),Ne=m.useRef(null),Oe=m.useRef(null),[Ve,We]=m.useState(!1),[De,mt]=m.useState(null),[at,Rt]=m.useState(0),[qe,W]=m.useState(!1),[K,ae]=m.useState(Wdt),[pe,z]=m.useState(null),[ve,Be]=m.useState(!1),[Je,kt]=m.useState("");m.useEffect(()=>{if(!$||M!=="video")return;const Pe=new AbortController;return Be(!0),kt(""),gdt(Pe.signal).then(st=>{Pe.signal.aborted||z(st)}).catch(st=>{Pe.signal.aborted||(z(null),kt(st instanceof Error?st.message:String(st)))}).finally(()=>{Pe.signal.aborted||Be(!1)}),()=>Pe.abort()},[e,$,M]),m.useEffect(()=>{!(pe!=null&&pe.supportedModes.length)||K.taskMode==="auto"||pe.supportedModes.includes(K.taskMode)||ae(Pe=>({...Pe,taskMode:pe.supportedModes[0]}))},[K.taskMode,pe]);async function Mt(){if(t)try{await navigator.clipboard.writeText(t),W(!0),setTimeout(()=>W(!1),1500)}catch{W(!1)}}m.useLayoutEffect(()=>{const Pe=me.current;Pe&&(Pe.style.height="auto",Pe.style.height=`${Math.min(Pe.scrollHeight,200)}px`)},[s]);const Tt=b.some(Pe=>Pe.status!=="ready"),dt=$&&M==="video",ge=dt?K.taskMode==="first_last_frame"?{asset:K.firstFrame,kind:"image",label:"首帧"}:K.taskMode==="video_editing"||K.taskMode==="video_extension"?{asset:K.referenceVideo,kind:"video",label:K.taskMode==="video_editing"?"待编辑视频":"基础视频"}:null:null,lt=ope(d),Ge=dt&&!!d&&!s.trim(),vt=p&&!!c,_t=dt?lt||Ge||!h&&!p&&!Tt&&(!ge||!!ge.asset)&&!!pe&&s.trim().length>0:!h&&!p&&!Tt&&(s.trim().length>0||b.length>0);function Bt(){if(dt){if(lt||Ge){f==null||f();return}pe&&s.trim()&&(u==null||u(s.trim(),K,pe));return}o()}const je=M==="skill"?L==="optimize"?"描述你想优化的技能…":"描述你想生成的技能…":M==="video"?"描述你想创作的视频…":`向 ${r} 发消息…`,Ze=h&&M==="agent"?"请先选择智能体":h&&M==="skill"&&L==="optimize"&&!P?"请先选择需要优化的 Skill":je,Ie=(De==null?void 0:De.query.toLocaleLowerCase())??"",Wt=(De==null?void 0:De.kind)==="skill"?y.filter(Pe=>!v.skills.some(st=>st.name===Pe.name)).filter(Pe=>`${Pe.name} ${Pe.description}`.toLocaleLowerCase().includes(Ie)).map(Pe=>({kind:"skill",value:Pe})):(De==null?void 0:De.kind)==="agent"?O.filter(Pe=>`${Pe.name} ${Pe.description}`.toLocaleLowerCase().includes(Ie)).map(Pe=>({kind:"agent",value:Pe})):[];function dn(Pe){var st;We(!1),mt(null),(st=Pe.current)==null||st.click()}function Qt(Pe){H==null||H(Pe.value),We(!1),mt(null),requestAnimationFrame(()=>{var st,At;(st=me.current)==null||st.focus(),(At=me.current)==null||At.setSelectionRange(s.length,s.length)})}function Yt(Pe){a(Pe),We(!1),mt(null),requestAnimationFrame(()=>{var Ut,kn,wn;(Ut=me.current)==null||Ut.focus();const st=Pe.indexOf("【"),At=Pe.indexOf("】",st+1);st>=0&&At>st?(kn=me.current)==null||kn.setSelectionRange(st+1,At):(wn=me.current)==null||wn.setSelectionRange(Pe.length,Pe.length)})}function Jt(){H==null||H(null),a(""),We(!1),mt(null),requestAnimationFrame(()=>{var Pe,st;(Pe=me.current)==null||Pe.focus(),(st=me.current)==null||st.setSelectionRange(0,0)})}const Ft=xH.find(Pe=>Pe.value===j),Ce=xH.filter(Pe=>lpe[Pe.value].every(st=>J.includes(st)));function et(Pe,st){const At=Pe.slice(0,st),Ut=/(^|\s)([/@])([^\s/@]*)$/.exec(At);if(!Ut){mt(null);return}const kn=Ut[2].length+Ut[3].length,wn={kind:Ut[2]==="/"?"skill":"agent",query:Ut[3],start:st-kn,end:st},Ai=!De||De.kind!==wn.kind||De.query!==wn.query||De.start!==wn.start||De.end!==wn.end;mt(wn),Ai&&Rt(0),We(!1)}function wt(Pe){if(!De)return;const st=s.slice(0,De.start)+s.slice(De.end);a(st),Pe.kind==="skill"?T({...v,skills:[...v.skills,Pe.value]}):T({skills:[],targetAgent:Pe.value});const At=De.start;mt(null),requestAnimationFrame(()=>{var Ut,kn;(Ut=me.current)==null||Ut.focus(),(kn=me.current)==null||kn.setSelectionRange(At,At)})}function yn(){if(v.targetAgent){T({skills:[]});return}v.skills.length>0&&T({...v,skills:v.skills.slice(0,-1)})}function on(Pe){const st=Pe.target.files?Array.from(Pe.target.files):[];st.length&&A(st),Pe.target.value=""}return l.jsxs("div",{className:`composer${$?" composer--new-chat":""}${Ft?` composer--has-task composer--task-${Ft.value}`:""}`,children:[l.jsx(yA,{value:v,onRemoveSkill:Pe=>T({...v,skills:v.skills.filter(st=>st.name!==Pe)}),onRemoveAgent:()=>T({skills:[]})}),b.length>0&&l.jsx(xA,{appName:i,compact:!0,items:b,onRemove:N}),$&&U&&I?l.jsx(tft,{value:M,onChange:I,disabled:p,skillCustomizationEnabled:Q}):null,l.jsxs("div",{id:$&&U?"new-chat-workspace-panel":void 0,className:"composer-box",role:$&&U?"tabpanel":void 0,"aria-labelledby":$&&U?`new-chat-workspace-tab-${M}`:void 0,children:[De?l.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":De.kind==="skill"?"可用技能":"可用子 Agent",children:[l.jsxs("div",{className:"composer-command-head",children:[De.kind==="skill"?l.jsx(tx,{}):l.jsx(lJ,{}),l.jsx("span",{children:De.kind==="skill"?"调用技能":"使用子 Agent"}),l.jsx("kbd",{children:De.kind==="skill"?"/":"@"})]}),x?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Kn,{className:"spin"})," 正在读取 Agent 能力…"]}):Wt.length===0?l.jsx("div",{className:"composer-command-empty",children:De.kind==="skill"?"当前 Agent 没有匹配技能":"当前 Agent 没有匹配子 Agent"}):l.jsx("div",{className:"composer-command-list",children:Wt.map((Pe,st)=>l.jsxs("button",{type:"button",role:"option","aria-selected":st===at,className:`composer-command-item${st===at?" is-active":""}`,onMouseDown:At=>{At.preventDefault(),wt(Pe)},onMouseEnter:()=>Rt(st),children:[l.jsx("span",{className:`composer-command-icon composer-command-icon--${Pe.kind}`,children:Pe.kind==="skill"?l.jsx(tx,{}):l.jsx(cJ,{})}),l.jsxs("span",{className:"composer-command-copy",children:[l.jsxs("strong",{children:[Pe.kind==="skill"?"/":"@",Pe.value.name]}),l.jsx("span",{children:Pe.value.description||(Pe.kind==="skill"?"加载并执行该技能":"将本轮交给该 Agent")})]}),l.jsx("kbd",{children:st===at?"↵":Pe.kind==="skill"?"技能":"Agent"})]},`${Pe.kind}-${Pe.value.name}`))})]}):null,l.jsxs("div",{className:"composer-menu-wrap",children:[l.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:h||!k,onClick:()=>{mt(null),We(Pe=>!Pe)},children:l.jsx(Gs,{className:"icon"})}),Ve&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>We(!1)}),l.jsxs("div",{className:"composer-menu",role:"menu",children:[l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(oe),children:[l.jsx(LD,{className:"icon"}),"上传图片"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(Ne),children:[l.jsx(PD,{className:"icon"}),"上传文档或 PDF"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>dn(Oe),children:[l.jsx(fJ,{className:"icon"}),"上传视频"]})]})]})]}),M==="agent"&&ie&&Re&&Ee?l.jsx(Idt,{selectedAgentName:i?r:"",selectedRuntimeId:ye,runtimeScope:Se,disabled:ue,onSelectRuntime:Re,onSelectSandboxSession:Ee}):null,$&&M==="skill"&&X?l.jsx(Hdt,{action:L,onActionChange:X,optimizationSource:P,onOptimizationSourceChange:q,disabled:p}):null,$&&M==="video"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"new-chat-video-task-mode",children:l.jsx(Cp,{label:"任务模式",hideLabel:!0,value:K.taskMode,options:(hi=pe==null?void 0:pe.supportedModes)!=null&&hi.length?mH.filter(Pe=>Pe.value==="auto"||pe.supportedModes.includes(Pe.value)):mH,onChange:Pe=>ae(st=>({...st,taskMode:Pe})),placeholder:"选择任务模式",disabled:p||lt||ve||!pe})}),l.jsx("div",{className:"new-chat-video-generation-model",title:Je||(pe==null?void 0:pe.generationModel),children:ve?l.jsx(Kn,{className:"icon spin",role:"status","aria-label":"正在加载生成模型"}):l.jsx("strong",{children:(pe==null?void 0:pe.generationModel)||"模型不可用"})})]}):null,B&&D?l.jsx(_dt,{value:C,onChange:D,disabled:p,temporaryEnabled:re,deepseekHarnessEnabled:fe}):null,$&&M==="agent"&&C==="agent"&&Ft&&H?l.jsxs("button",{type:"button",className:`new-chat-task-chip new-chat-task-chip--${Ft.value}`,"aria-label":`取消${Ft.label}任务`,disabled:p,onClick:Jt,children:[l.jsxs("span",{className:"new-chat-task-chip__icon","aria-hidden":"true",children:[l.jsx(Ft.icon,{className:"new-chat-task-chip__task-icon"}),l.jsx(xa,{className:"new-chat-task-chip__remove-icon"})]}),l.jsx("span",{children:Ft.label})]}):null,l.jsxs("div",{className:`composer-input-stack${ge?" has-inline-asset":""}`,children:[ge?l.jsx(Zdt,{asset:ge.asset,kind:ge.kind,label:ge.label,disabled:p||lt||!((pe==null?void 0:pe.assetStorageAvailable)??!1),unavailableReason:(pe==null?void 0:pe.assetStorageUnavailableReason)||"",onChange:Pe=>ae(st=>st.taskMode==="first_last_frame"?{...st,firstFrame:Pe}:{...st,referenceVideo:Pe})}):null,l.jsx("textarea",{ref:me,className:"comp-input scroll",rows:$?4:1,value:s,disabled:h,placeholder:Ze,"aria-expanded":!!De,onChange:Pe=>{a(Pe.target.value),et(Pe.target.value,Pe.target.selectionStart)},onSelect:Pe=>{et(Pe.currentTarget.value,Pe.currentTarget.selectionStart)},onBlur:()=>setTimeout(()=>mt(null),0),onKeyDown:Pe=>{if(!OQ(Pe.nativeEvent)){if(De){if(Pe.key==="ArrowDown"&&Wt.length>0){Pe.preventDefault(),Rt(st=>(st+1)%Wt.length);return}if(Pe.key==="ArrowUp"&&Wt.length>0){Pe.preventDefault(),Rt(st=>(st-1+Wt.length)%Wt.length);return}if((Pe.key==="Enter"||Pe.key==="Tab")&&Wt[at]){Pe.preventDefault(),wt(Wt[at]);return}if(Pe.key==="Escape"){Pe.preventDefault(),mt(null);return}}if(Pe.key==="Backspace"&&!s&&Pe.currentTarget.selectionStart===0&&Pe.currentTarget.selectionEnd===0){yn();return}Pe.key==="Enter"&&!Pe.shiftKey&&(Pe.preventDefault(),_t&&Bt())}}}),$&&s.length===0?l.jsx("span",{className:"composer-placeholder-reveal","aria-hidden":"true",children:Ze},Ze):null]}),l.jsxs("div",{className:"composer-submit-actions",children:[t&&i&&M==="agent"?l.jsx(dft,{cloudProvider:e,modelName:w,usage:E,systemTokenEstimate:S}):null,l.jsx(wr.button,{type:"button",className:"comp-send",disabled:vt?!1:!_t,onClick:vt?c:Bt,"aria-label":vt?"停止生成":lt||Ge?"查看视频生成进度":"发送",title:vt?"停止生成":Je||void 0,whileTap:vt||_t?{scale:.9}:void 0,transition:{type:"spring",stiffness:600,damping:22},children:vt?l.jsx(Edt,{className:"icon"}):p||lt?l.jsx(Kn,{className:"icon spin"}):l.jsx(Sdt,{className:"icon"})})]})]}),l.jsx(xf,{initial:!1,children:$&&U&&M==="video"?l.jsx(Jdt,{config:K,onChange:ae,enhancerModel:(pe==null?void 0:pe.enhancerModel)||"",assetStorageAvailable:(pe==null?void 0:pe.assetStorageAvailable)??!1,assetStorageUnavailableReason:(pe==null?void 0:pe.assetStorageUnavailableReason)||"",modelsLoading:ve,modelsError:Je,disabled:p||lt},"new-chat-video-controls"):null}),$&&M==="agent"&&C==="agent"&&Ae&&!Ft?l.jsx("div",{className:"task-shortcuts","aria-label":"选择任务类型",children:Ce.map(Pe=>{const st=Pe.icon;return l.jsxs("button",{type:"button",className:"task-shortcut",disabled:h||p,onClick:()=>Qt(Pe),children:[l.jsx(st,{}),l.jsx("span",{children:Pe.label})]},Pe.value)})}):null,$&&M==="agent"&&C==="agent"&&Ft?l.jsx("div",{className:"prompt-suggestions","aria-label":`${Ft.label}企业提示词`,children:Ft.prompts.map(Pe=>{const st=Ft.icon;return l.jsxs("button",{type:"button",className:"prompt-suggestion",disabled:h||p,onClick:()=>Yt(Pe),children:[l.jsx(st,{}),l.jsx("span",{children:Pe})]},Pe)})}):null,g&&l.jsxs("div",{className:"composer-meta",children:[l.jsxs("span",{className:"composer-session-line",children:["会话 ID:",l.jsx("span",{className:"composer-session-id",title:t||void 0,"aria-live":"polite",children:n?"初始化中":t||"—"}),t&&l.jsx("button",{type:"button",className:"composer-session-copy",title:qe?"已复制":"复制会话 ID","aria-label":qe?"已复制会话 ID":"复制会话 ID",onClick:()=>void Mt(),children:qe?l.jsx(Hc,{}):l.jsx(g_,{})})]}),l.jsx("span",{className:"composer-meta-separator","aria-hidden":!0,children:"|"}),l.jsx("span",{children:"回答仅供参考"})]}),l.jsx("input",{ref:oe,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:on}),l.jsx("input",{ref:Ne,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:on}),l.jsx("input",{ref:Oe,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:on})]})}function hft({title:e,sub:t,cards:n,footer:i}){return l.jsxs("div",{className:"stk",children:[l.jsxs("div",{className:"stk-head",children:[l.jsx("h1",{className:"stk-title",children:e}),t&&l.jsx("p",{className:"stk-sub",children:t})]}),l.jsx("div",{className:"stk-list",children:n.map((r,s)=>l.jsxs(wr.button,{type:"button",className:`stk-card ${r.disabled?"stk-card-disabled":""}`,onClick:r.disabled?void 0:r.onClick,disabled:r.disabled,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut",delay:s*.04},children:[l.jsx("span",{className:"stk-card-icon",children:l.jsx(r.icon,{})}),l.jsxs("span",{className:"stk-card-text",children:[l.jsx("span",{className:"stk-card-title",children:r.title}),l.jsx("span",{className:"stk-card-desc",children:r.desc})]}),r.status&&l.jsx("span",{className:"stk-card-status",children:r.status}),l.jsx(U0,{className:"stk-card-arrow"})]},r.key))}),i&&l.jsx("div",{className:"stk-footer",children:i})]})}const pft="modulepreload",mft=function(e){return"/"+e},vH={},$g=function(t,n,i){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=mft(c),c in vH)return;vH[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":pft,u||(f.as="script"),f.crossOrigin="",f.href=c,o&&f.setAttribute("nonce",o),document.head.appendChild(f),u)return new Promise((h,p)=>{f.addEventListener("load",h),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})},gft="_Container_1tuad_1",bft="_Checkbox_1tuad_22",Oft="_CheckMark_1tuad_92",yft="_Label_1tuad_162",pS={Container:gft,Checkbox:bft,CheckMark:Oft,Label:yft},yQ=({className:e,label:t,id:n,disabled:i,orientation:r="left",...s})=>{const a=m.useId(),o=n??a;return l.jsxs("div",{"data-disabled":i?"":void 0,"data-has-label":t?"":void 0,"data-orientation":r,className:Ps(e,pS.Container),children:[l.jsx(L5e,{className:pS.Checkbox,id:o,disabled:i,...s,children:l.jsx($5e,{className:pS.CheckMark})}),t&&l.jsx("label",{htmlFor:o,className:pS.Label,onMouseDown:c=>{!c.defaultPrevented&&c.detail>1&&c.preventDefault()},children:t})]})},xft="_RadioGroup_onrfm_1",vft="_RadioLabel_onrfm_9",wft="_RadioIndicatorWrapper_onrfm_26",Sft="_RadioItem_onrfm_43",Eft="_RadioIndicator_onrfm_26",BO={RadioGroup:xft,RadioLabel:vft,RadioIndicatorWrapper:wft,RadioItem:Sft,RadioIndicator:Eft},cpe=m.createContext(null),kft=()=>{const e=m.use(cpe);if(!e)throw new Error("RadioGroup components must be wrapped in ");return e},UO=({onChange:e,children:t,className:n,direction:i="row",disabled:r=!1,...s})=>{const a=m.useMemo(()=>({disabled:r,direction:i}),[r,i]);return l.jsx(cpe,{value:a,children:l.jsx(z$e,{className:Ps(BO.RadioGroup,n),"data-direction":i,onValueChange:e,disabled:r,...s,children:t})})},Tft=({value:e,disabled:t=!1,required:n,children:i,className:r,block:s=!1,...a})=>{const{disabled:o}=kft(),c=o||t,u=m.useId(),d=`${e}-${u}`;return l.jsx("div",{className:"flex",...a,children:l.jsxs("label",{htmlFor:d,className:Ps(BO.RadioLabel,r),"data-disabled":c?"":void 0,"data-block":s?"":void 0,onMouseDown:f=>{!f.defaultPrevented&&f.detail>1&&f.preventDefault()},children:[l.jsx("div",{className:BO.RadioIndicatorWrapper,children:l.jsx(q$e,{id:d,value:e,disabled:c,required:n,className:BO.RadioItem,children:l.jsx(Y$e,{className:BO.RadioIndicator})})}),i]})})};UO.Item=Tft;function WA(e,t){return t[e.key]??e.defaultValue??""}function upe(e){const t=new Map,n={};for(const i of e){for(const r of i.env){const s=t.get(r.key);(!s||r.required&&!s.required)&&t.set(r.key,r)}i.enableFlag&&(t.set(i.enableFlag,{key:i.enableFlag,required:!0}),n[i.enableFlag]="true")}return{specs:[...t.values()],fixedValues:n}}function _ft(e,t){return upe([{env:e}]).specs.map(i=>({...i,value:i.serverManaged?i.placeholder||"由服务端注入":WA(i,t)}))}function dpe(e,t){const n=new Map;for(const i of e){if(i.serverManaged)continue;const r=WA(i,t);r.trim()&&n.set(i.key,r)}return[...n].map(([i,r])=>({key:i,value:r}))}function wH(e,t){return e.find(n=>n.required&&!n.serverManaged&&!WA(n,t).trim())}function xQ(e,t){if(e.format!=="json")return;const n=WA(e,t).trim();if(n)try{JSON.parse(n);return}catch{return"JSON 格式不正确"}}function fpe(e,t){for(const n of e){const i=xQ(n,t);if(i)return{spec:n,error:i}}}function Aft({className:e,...t}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.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"}),l.jsx("path",{d:"M12 6.5c.4 2.4 1 3 3.4 3.4-2.4.4-3 1-3.4 3.4-.4-2.4-1-3-3.4-3.4 2.4-.4 3-1 3.4-3.4Z"})]})}const Mm={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:Aft},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:Kwe},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:pSe},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:gJ},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:O_}},Nft=[Mm.llm,Mm.sequential,Mm.parallel,Mm.loop,Mm.a2a];function hpe(e){return Mm[e??"llm"]}const ppe=e=>e==="sequential"||e==="parallel"||e==="loop",ZA=e=>e==="a2a";function r1(e){return e.trimEnd().replace(/[。.]+$/,"")}function up(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(i=>i==null?void 0:i.toLocaleLowerCase().includes(n)):!0}const mpe=new Set(["local","sqlite","mysql","postgresql"]),gpe=new Set(["local","opensearch","redis","viking","openviking","mem0"]),bpe=new Set(["opensearch","viking","context_search","openviking"]),Ope=new Set(["apmplus","cozeloop","tls"]),ype=new Set(["web_search","parallel_web_search","link_reader","web_scraper","image_generate","image_edit","video_generate","text_to_speech","run_code","vesearch"]),Cft=new Set(["llm","sequential","parallel","loop","a2a"]);function nn(e,t=""){return typeof e=="string"?e:t}function lo(e){return e===!0}function Ry(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function jft(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}function xpe(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"?{name:nn(t.name),description:nn(t.description)}:null).filter(t=>!!t&&!!t.name.trim()):[]}function Qg(e,t,n){return typeof e=="string"&&t.has(e)?e:n}function vpe(e){return typeof e=="string"&&Cft.has(e)?e:"llm"}function wpe(e){return e==="byteplus"?"byteplus":"volcengine"}function Spe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):3}function Epe(e){const t=e&&typeof e=="object"?e:{};return{enabled:lo(t.enabled),registrySpaceId:nn(t.registrySpaceId),registryTopK:nn(t.registryTopK),registryRegion:nn(t.registryRegion),registryEndpoint:nn(t.registryEndpoint)}}function kpe(e,t="volcengine"){return Array.isArray(e)?e.map(n=>{const i=n&&typeof n=="object"?n:{},r=wpe(i.cloudProvider??t),s=i.memory&&typeof i.memory=="object"?i.memory:{},a=Epe(i.a2aRegistry),o=vpe(i.agentType),c=a.enabled&&o==="llm"?"a2a":o;return{...el(r),cloudProvider:r,name:nn(i.name),description:nn(i.description),instruction:nn(i.instruction),agentType:c,maxIterations:Spe(i.maxIterations),a2aUrl:nn(i.a2aUrl),modelName:nn(i.modelName),modelSource:i.modelSource==="custom"||i.modelSource==="ark"?i.modelSource:void 0,modelProvider:nn(i.modelProvider),modelApiBase:nn(i.modelApiBase),builtinTools:Ry(i.builtinTools).filter(u=>ype.has(u)),customTools:xpe(i.customTools),memory:{shortTerm:lo(s.shortTerm),longTerm:lo(s.longTerm)},shortTermBackend:Qg(i.shortTermBackend,mpe,"local"),longTermBackend:Qg(i.longTermBackend,gpe,"local"),autoSaveSession:lo(i.autoSaveSession),knowledgebase:lo(i.knowledgebase),knowledgebaseBackend:Qg(i.knowledgebaseBackend,bpe,wf),knowledgebaseIndex:nn(i.knowledgebaseIndex),tracing:lo(i.tracing),tracingExporters:Ry(i.tracingExporters).filter(u=>Ope.has(u)),a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,subAgents:kpe(i.subAgents,r),selectedSkills:Tpe(i)}}):[]}function Tpe(e){if(!Array.isArray(e.selectedSkills))return[];const t=[];for(const n of e.selectedSkills){const i=n&&typeof n=="object"?n:{},r=nn(i.source),s=r==="local"||r==="skillspace"||r==="skillhub"?r:"skillhub",a=nn(i.name)||nn(i.slug)||nn(i.skillName)||nn(i.skillId)||"skill",o=nn(i.folder)||a,c=nn(i.description);if(s==="skillhub"){const f=nn(i.slug);if(!f)continue;t.push({source:s,folder:o,name:a,description:c,slug:f,namespace:nn(i.namespace)||"public"});continue}if(s==="local"){const h=(Array.isArray(i.localFiles)?i.localFiles:[]).map(p=>{const g=p&&typeof p=="object"?p:{},b=nn(g.path),y=nn(g.content);return b?{path:b,content:y}:null}).filter(p=>p!==null);if(h.length===0)continue;t.push({source:s,folder:o,name:a,description:c,localFiles:h});continue}const u=nn(i.skillSpaceId),d=nn(i.skillId);!u||!d||t.push({source:s,folder:o,name:a,description:c,skillSpaceId:u,skillSpaceName:nn(i.skillSpaceName),skillId:d,version:nn(i.version)})}return t}function Rft(e){const t=e&&typeof e=="object"?e:{},n=t.memory&&typeof t.memory=="object"?t.memory:{},i=t.deployment&&typeof t.deployment=="object"?t.deployment:{},r=jft(i.envValues),s=Epe(t.a2aRegistry),a=vpe(t.agentType),o=s.enabled&&a==="llm"?"a2a":a,c=wpe(t.cloudProvider),u=Array.isArray(t.mcpTools)?t.mcpTools.map(d=>{const f=d&&typeof d=="object"?d:{},h=f.transport==="stdio"?"stdio":"http";return{name:nn(f.name),transport:h,url:nn(f.url),authToken:nn(f.authToken),authTokenEnv:nn(f.authTokenEnv),command:nn(f.command),args:Ry(f.args)}}).filter(d=>d.transport==="http"?!!d.url:!!d.command):[];return{...el(c),cloudProvider:c,name:nn(t.name)||"my_agent",description:nn(t.description),instruction:nn(t.instruction)||"You are a helpful assistant.",agentType:o,maxIterations:Spe(t.maxIterations),a2aUrl:nn(t.a2aUrl),modelName:nn(t.modelName),modelSource:t.modelSource==="custom"||t.modelSource==="ark"?t.modelSource:void 0,modelProvider:nn(t.modelProvider),modelApiBase:nn(t.modelApiBase),builtinTools:Ry(t.builtinTools).filter(d=>ype.has(d)),customTools:xpe(t.customTools),mcpTools:u,a2aRegistry:o==="a2a"?{...s,enabled:!0}:s,memory:{shortTerm:lo(n.shortTerm),longTerm:lo(n.longTerm)},shortTermBackend:Qg(t.shortTermBackend,mpe,"local"),longTermBackend:Qg(t.longTermBackend,gpe,"local"),autoSaveSession:lo(t.autoSaveSession),knowledgebase:lo(t.knowledgebase),knowledgebaseBackend:Qg(t.knowledgebaseBackend,bpe,wf),knowledgebaseIndex:nn(t.knowledgebaseIndex),tracing:lo(t.tracing),tracingExporters:Ry(t.tracingExporters).filter(d=>Ope.has(d)),deployment:{feishuEnabled:lo(i.feishuEnabled),runtimeName:nn(i.runtimeName),runtimeNameCustomized:lo(i.runtimeNameCustomized)||!!nn(i.runtimeName).trim(),modelApiKeyId:nn(i.modelApiKeyId),modelApiKeyName:nn(i.modelApiKeyName),...Object.keys(r).length>0?{envValues:r}:{}},subAgents:kpe(t.subAgents,c),selectedSkills:Tpe(t)}}function _pe(e,t=e.cloudProvider??"volcengine"){const n=e.cloudProvider??t,i=new Set(Xne(n).map(r=>r.id));return{...e,builtinTools:(e.builtinTools??[]).filter(r=>i.has(r)),tracing:!1,tracingExporters:[],memory:{shortTerm:!1,longTerm:!1},shortTermBackend:"local",longTermBackend:"local",autoSaveSession:!1,knowledgebase:!1,knowledgebaseBackend:wf,knowledgebaseIndex:"",subAgents:e.subAgents.map(r=>_pe(r,n))}}const Ift=/^[A-Za-z_][A-Za-z0-9_]*$/,vQ=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function SH(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Pft(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function Ape(e){var n,i,r;const t=(n=e.authTokenEnv)==null?void 0:n.trim();return t&&Ift.test(t)?t:((r=(i=e.authToken)==null?void 0:i.trim().match(vQ))==null?void 0:r[1])??""}function Mft(e){if(e.authToken)return e.authToken;const t=Ape(e);return t?`\${${t}}`:""}function Lft(e,t){if(!t){const i={...e};return delete i.authToken,delete i.authTokenEnv,i}const n=t.trim().match(vQ);if(n){const i={...e,authTokenEnv:n[1]};return delete i.authToken,i}return{...e,authToken:t}}function Dft(e){if(!e.trim())return!1;try{return!new URL(e).pathname.replace(/\/+$/,"").endsWith("/mcp")}catch{return!1}}function KA(e){const t=new Set,n={},i=r=>{var u;const s=SH(r.name,"AGENT"),a=(u=r.mcpTools)==null?void 0:u.map((d,f)=>{var O,v;const h=((O=d.authToken)==null?void 0:O.trim())??"",p=((v=h.match(vQ))==null?void 0:v[1])??"";let b=Ape(d);if(!b&&h){const x=SH(d.name,`TOOL_${f+1}`);b=Pft(`MCP_${s}_${x}_AUTH_TOKEN`,t)}b&&t.add(b),b&&h&&!p&&(n[b]=h);const y={...d};return delete y.authToken,b?y.authTokenEnv=b:delete y.authTokenEnv,y}),o=r.subAgents.map(i),c=r.workflow?{...r.workflow,nodes:r.workflow.nodes.map(d=>({...d,agent:i(d.agent)}))}:void 0;return{...r,subAgents:o,...a?{mcpTools:a}:{},...c?{workflow:c}:{}}};return{draft:i(e),envValues:n}}function Npe(e){var n,i,r,s,a,o,c,u,d,f,h,p,g,b,y,O,v,x,w,E,S,k,T,A,N,C,M,L,P,Q,j,$,U,B,I,X;const t={agentType:e.agentType??"llm"};if(e.agentType==="a2a"){if((n=e.a2aRegistry)!=null&&n.enabled){const q={enabled:!0};(i=e.a2aRegistry.registrySpaceId)!=null&&i.trim()&&(q.registrySpaceId=e.a2aRegistry.registrySpaceId.trim()),q.registryTopK=((r=e.a2aRegistry.registryTopK)==null?void 0:r.trim())||Pl.topK,q.registryRegion=((s=e.a2aRegistry.registryRegion)==null?void 0:s.trim())||Pl.region,q.registryEndpoint=((a=e.a2aRegistry.registryEndpoint)==null?void 0:a.trim())||Pl.endpoint,t.a2aRegistry=q}return t}if(t.name=e.name,t.description=e.description,t.instruction=e.instruction,e.agentType==="loop"&&(t.maxIterations=e.maxIterations??3),(o=e.modelName)!=null&&o.trim()&&(t.modelName=e.modelName.trim()),e.modelSource&&(t.modelSource=e.modelSource),e.modelSource!=="ark"&&((c=e.modelProvider)!=null&&c.trim()&&(t.modelProvider=e.modelProvider.trim()),(u=e.modelApiBase)!=null&&u.trim()&&(t.modelApiBase=e.modelApiBase.trim())),(d=e.builtinTools)!=null&&d.length&&(t.builtinTools=[...e.builtinTools]),(f=e.customTools)!=null&&f.length&&(t.customTools=e.customTools.map(q=>({name:q.name,description:q.description}))),(h=e.mcpTools)!=null&&h.length&&(t.mcpTools=e.mcpTools.map(q=>{var H,re,fe,Ae;const D={name:q.name,transport:q.transport};return(H=q.url)!=null&&H.trim()&&(D.url=q.url.trim()),(re=q.authTokenEnv)!=null&&re.trim()&&(D.authTokenEnv=q.authTokenEnv.trim()),(fe=q.command)!=null&&fe.trim()&&(D.command=q.command.trim()),(Ae=q.args)!=null&&Ae.length&&(D.args=q.args),D})),((p=e.memory)!=null&&p.shortTerm||(g=e.memory)!=null&&g.longTerm)&&(t.memory={shortTerm:!!e.memory.shortTerm,longTerm:!!e.memory.longTerm},e.memory.shortTerm&&(t.shortTermBackend=e.shortTermBackend||"local"),e.memory.longTerm&&(t.longTermBackend=e.longTermBackend||"local",t.autoSaveSession=!!e.autoSaveSession)),e.knowledgebase&&(t.knowledgebase=!0,t.knowledgebaseBackend=e.knowledgebaseBackend||"viking",(b=e.knowledgebaseIndex)!=null&&b.trim()&&(t.knowledgebaseIndex=e.knowledgebaseIndex.trim())),e.tracing&&((y=e.tracingExporters)!=null&&y.length)&&(t.tracing=!0,t.tracingExporters=[...e.tracingExporters]),(O=e.deployment)!=null&&O.feishuEnabled||(x=(v=e.deployment)==null?void 0:v.runtimeName)!=null&&x.trim()||(w=e.deployment)!=null&&w.runtimeNameCustomized||(S=(E=e.deployment)==null?void 0:E.modelApiKeyId)!=null&&S.trim()||(T=(k=e.deployment)==null?void 0:k.modelApiKeyName)!=null&&T.trim()||Object.keys(((A=e.deployment)==null?void 0:A.envValues)??{}).length>0){const q={feishuEnabled:!!((N=e.deployment)!=null&&N.feishuEnabled)};(M=(C=e.deployment)==null?void 0:C.runtimeName)!=null&&M.trim()&&(q.runtimeName=e.deployment.runtimeName.trim()),(L=e.deployment)!=null&&L.runtimeNameCustomized&&(q.runtimeNameCustomized=!0),(Q=(P=e.deployment)==null?void 0:P.modelApiKeyId)!=null&&Q.trim()&&(q.modelApiKeyId=e.deployment.modelApiKeyId.trim()),($=(j=e.deployment)==null?void 0:j.modelApiKeyName)!=null&&$.trim()&&(q.modelApiKeyName=e.deployment.modelApiKeyName.trim()),Object.keys(((U=e.deployment)==null?void 0:U.envValues)??{}).length>0&&(q.envValues={...(B=e.deployment)==null?void 0:B.envValues}),t.deployment=q}return(I=e.selectedSkills)!=null&&I.length&&(t.selectedSkills=e.selectedSkills.map(q=>{const D={source:q.source,name:q.name,folder:q.folder};return q.description&&(D.description=q.description),q.source==="skillhub"?(D.slug=q.slug,D.namespace=q.namespace??"public"):q.source==="local"?D.localFiles=q.localFiles??[]:(D.skillSpaceId=q.skillSpaceId,D.skillSpaceName=q.skillSpaceName,D.skillId=q.skillId,q.version&&(D.version=q.version)),D})),(X=e.subAgents)!=null&&X.length&&(t.subAgents=e.subAgents.map(Npe)),t}function $ft(e){var r;const t=KA(e),n={...((r=t.draft.deployment)==null?void 0:r.envValues)??{},...t.envValues},i={...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}};return`# VeADK Agent 结构配置 # 可在「创建 Agent」页通过「导入 YAML」重新载入。 -`+Kle(Ape(i))}function $ft(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function fR(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function Npe(e,t){const n=e==null?void 0:e.trim();if(!n)return!1;try{const i=new URL(n),r=new URL(t),s=i.pathname.replace(/\/+$/,""),a=r.pathname.replace(/\/+$/,"");return i.protocol==="https:"&&i.username===""&&i.password===""&&i.search===""&&i.hash===""&&i.hostname.toLowerCase()===r.hostname.toLowerCase()&&i.port===r.port&&s===a}catch{return!1}}function Cpe(e,t){const n=[],i=new Set,r=s=>{var a,o,c;if(s.agentType==="llm"&&s.modelSource!=="ark"&&(s.modelSource==="custom"||(a=s.modelApiBase)!=null&&a.trim()&&!Npe(s.modelApiBase,t))){const u=$ft(s.name,"AGENT"),d=((o=s.modelProvider)==null?void 0:o.trim())??"",f=((c=s.modelApiBase)==null?void 0:c.trim())??"",h=d?fR(`CUSTOM_MODEL_${u}_PROVIDER`,i):void 0;h&&i.add(h);const p=f?fR(`CUSTOM_MODEL_${u}_API_BASE`,i):void 0;p&&i.add(p);const g=fR(`CUSTOM_MODEL_${u}_API_KEY`,i);i.add(g),n.push({providerKey:h,apiBaseKey:p,apiKeyKey:g,provider:d,apiBase:f,label:`${s.name.trim()||"自定义模型"} 模型 API Key`})}s.subAgents.forEach(r)};return r(e),n}function jpe(e,t){return Cpe(e,t).map(({apiKeyKey:n,label:i})=>({key:n,label:i}))}const Rpe="MODEL_AGENT_API_KEY_ID",Ipe="MODEL_AGENT_API_KEY_NAME";function SH(e){return e==="MODEL_AGENT_API_KEY"||e===Rpe||e===Ipe}function Ob(e,t){var i,r,s;if(e.modelSource==="ark"||e.modelSource==="custom")return e.modelSource;if((r=(i=e.deployment)==null?void 0:i.modelApiKeyId)!=null&&r.trim())return"ark";const n=(s=e.modelApiBase)==null?void 0:s.trim();return!n||Npe(n,Dl(t))?"ark":"custom"}function Qft(e,t){var h,p,g,b;const n=new Map(t.map(({key:y,value:O})=>[y,O.trim()])),i=((p=(h=e.deployment)==null?void 0:h.modelApiKeyId)==null?void 0:p.trim())??"",r=((b=(g=e.deployment)==null?void 0:g.modelApiKeyName)==null?void 0:b.trim())??"",s=n.get(Rpe)??"",a=n.get(Ipe)??"",o=i||s,c=i?r||(s===i?a:""):s?a:r||a,u=!!o&&e.modelSource!=="custom",d=y=>{var x,w;const O=y.cloudProvider??e.cloudProvider??"volcengine",v=(x=y.modelProvider)!=null&&x.trim()||(w=y.modelApiBase)!=null&&w.trim()?Ob(y,O):"custom";return{...y,modelSource:y.modelSource==="ark"||y.modelSource==="custom"?y.modelSource:y.agentType==="llm"?u?"ark":v:y.modelSource,subAgents:y.subAgents.map(d),...y.workflow?{workflow:{...y.workflow,nodes:y.workflow.nodes.map(E=>({...E,agent:d(E.agent)}))}}:{}}},f=d(e);return{...f,deployment:{...f.deployment??{feishuEnabled:!1},modelApiKeyId:o,modelApiKeyName:c}}}function Ppe(e,t){const n=e.cloudProvider??t,i=Ob(e,n);return{...e,cloudProvider:n,modelSource:i,modelProvider:i==="ark"?"":e.modelProvider,modelApiBase:i==="ark"?"":e.modelApiBase,subAgents:e.subAgents.map(r=>Ppe(r,n))}}function Oh(e,t){return e[t]|e[t+1]<<8}function gm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}async function Bft(e){const t=new DecompressionStream("deflate-raw"),n=new Blob([new Uint8Array(e)]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}async function Mpe(e,t={}){let i=-1;for(let u=e.length-22;u>=0&&u>e.length-65557;u--)if(gm(e,u)===101010256){i=u;break}if(i<0)throw new Error("无效的 zip:找不到 EOCD");const r=Oh(e,i+10);if(t.maxEntries!==void 0&&r>t.maxEntries)throw new Error(`zip 文件数不能超过 ${t.maxEntries} 个`);let s=gm(e,i+16);const a=new TextDecoder("utf-8"),o=[];let c=0;for(let u=0;ut.maxUncompressedBytes)throw new Error("zip 解压后的内容过大");const v=Oh(e,y+26),x=Oh(e,y+28),w=y+30+v+x,E=e.subarray(w,w+f);let S;if(d===0)S=E;else if(d===8)S=await Bft(E);else{s+=46+p+g+b;continue}o.push({name:O,text:a.decode(S)}),s+=46+p+g+b}return o}const Uft="/harness/skills/findskill";async function zft(e,t="public"){const n=e.trim(),i=new URLSearchParams({query:n,page_number:"1",page_size:"20"}),r=`${Uft}?${i.toString()}`,s=await fetch(r,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(!s.ok)throw new Error(`搜索失败 (${s.status})`);return((await s.json()).items??[]).map(o=>({source:"skillhub",id:o.slug??o.name??"",slug:o.slug??"",name:o.name??o.slug??"",description:o.description??"",namespace:t,sourceRepo:o.sourceRepo,downloadCount:o.downloadCount,version:o.version}))}function Fft({selected:e,onChange:t}){const[n,i]=m.useState(""),[r,s]=m.useState([]),[a,o]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.useState(!1),h=b=>e.some(y=>y.source==="skillhub"&&y.slug===b),p=b=>{b.slug&&(h(b.slug)?t(e.filter(y=>!(y.source==="skillhub"&&y.slug===b.slug))):t([...e,{source:"skillhub",slug:b.slug,name:b.name,folder:b.slug.split("/").pop()||b.name,namespace:b.namespace||"public",description:b.description}]))},g=async b=>{o(!0),u(null),f(!0);try{const y=await zft(b);s(y)}catch(y){u(y instanceof Error?y.message:"搜索失败,请稍后重试。"),s([])}finally{o(!1)}};return m.useEffect(()=>{const b=n.trim();if(!b){s([]),f(!1),u(null);return}const y=setTimeout(()=>g(b),300);return()=>clearTimeout(y)},[n]),l.jsxs("div",{className:"cw-skillhub",children:[l.jsxs("div",{className:"cw-skill-searchrow",children:[l.jsxs("div",{className:"cw-skill-searchbox",children:[l.jsx(hk,{className:"cw-i cw-skill-searchicon","aria-hidden":!0}),l.jsx("input",{className:"cw-input cw-skill-input",value:n,placeholder:"搜索火山 Find Skill 技能广场,例如 数据分析、PDF…",onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),n.trim()&&g(n))}})]}),l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft",onClick:()=>n.trim()&&g(n),disabled:!n.trim()||a,children:[a?l.jsx(Kn,{className:"cw-i cw-spin"}):l.jsx(hk,{className:"cw-i"}),"搜索"]})]}),c&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:c})]}),a&&r.length===0?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在搜索…"]}):r.length>0?l.jsx("div",{className:"cw-skill-results",children:r.map(b=>{const y=h(b.slug||"");return l.jsxs("button",{type:"button",className:`cw-skill-result ${y?"is-on":""}`,onClick:()=>p(b),"aria-pressed":y,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:y?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:b.name}),b.description&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(b.description)}),b.sourceRepo&&l.jsx("span",{className:"cw-skill-result-repo",children:b.sourceRepo})]})]},b.id||b.slug)})}):d&&!c?l.jsx("p",{className:"cw-empty-line",children:"没有找到匹配的技能,换个关键词试试。"}):!d&&l.jsx("p",{className:"cw-empty-line",children:"输入关键词搜索火山 Find Skill 技能广场,所选技能会在生成项目时下载到 skills/ 目录。"})]})}const UL=/(^|\/)skill\.md$/i;function Vft(e){const t=(e??"").replace(/\r\n?/g,` +`+Jle(Npe(i))}function Qft(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function fR(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function Cpe(e,t){const n=e==null?void 0:e.trim();if(!n)return!1;try{const i=new URL(n),r=new URL(t),s=i.pathname.replace(/\/+$/,""),a=r.pathname.replace(/\/+$/,"");return i.protocol==="https:"&&i.username===""&&i.password===""&&i.search===""&&i.hash===""&&i.hostname.toLowerCase()===r.hostname.toLowerCase()&&i.port===r.port&&s===a}catch{return!1}}function jpe(e,t){const n=[],i=new Set,r=s=>{var a,o,c;if(s.agentType==="llm"&&s.modelSource!=="ark"&&(s.modelSource==="custom"||(a=s.modelApiBase)!=null&&a.trim()&&!Cpe(s.modelApiBase,t))){const u=Qft(s.name,"AGENT"),d=((o=s.modelProvider)==null?void 0:o.trim())??"",f=((c=s.modelApiBase)==null?void 0:c.trim())??"",h=d?fR(`CUSTOM_MODEL_${u}_PROVIDER`,i):void 0;h&&i.add(h);const p=f?fR(`CUSTOM_MODEL_${u}_API_BASE`,i):void 0;p&&i.add(p);const g=fR(`CUSTOM_MODEL_${u}_API_KEY`,i);i.add(g),n.push({providerKey:h,apiBaseKey:p,apiKeyKey:g,provider:d,apiBase:f,label:`${s.name.trim()||"自定义模型"} 模型 API Key`})}s.subAgents.forEach(r)};return r(e),n}function Rpe(e,t){return jpe(e,t).map(({apiKeyKey:n,label:i})=>({key:n,label:i}))}const Ipe="MODEL_AGENT_API_KEY_ID",Ppe="MODEL_AGENT_API_KEY_NAME";function EH(e){return e==="MODEL_AGENT_API_KEY"||e===Ipe||e===Ppe}function Ob(e,t){var i,r,s;if(e.modelSource==="ark"||e.modelSource==="custom")return e.modelSource;if((r=(i=e.deployment)==null?void 0:i.modelApiKeyId)!=null&&r.trim())return"ark";const n=(s=e.modelApiBase)==null?void 0:s.trim();return!n||Cpe(n,Dl(t))?"ark":"custom"}function Bft(e,t){var h,p,g,b;const n=new Map(t.map(({key:y,value:O})=>[y,O.trim()])),i=((p=(h=e.deployment)==null?void 0:h.modelApiKeyId)==null?void 0:p.trim())??"",r=((b=(g=e.deployment)==null?void 0:g.modelApiKeyName)==null?void 0:b.trim())??"",s=n.get(Ipe)??"",a=n.get(Ppe)??"",o=i||s,c=i?r||(s===i?a:""):s?a:r||a,u=!!o&&e.modelSource!=="custom",d=y=>{var x,w;const O=y.cloudProvider??e.cloudProvider??"volcengine",v=(x=y.modelProvider)!=null&&x.trim()||(w=y.modelApiBase)!=null&&w.trim()?Ob(y,O):"custom";return{...y,modelSource:y.modelSource==="ark"||y.modelSource==="custom"?y.modelSource:y.agentType==="llm"?u?"ark":v:y.modelSource,subAgents:y.subAgents.map(d),...y.workflow?{workflow:{...y.workflow,nodes:y.workflow.nodes.map(E=>({...E,agent:d(E.agent)}))}}:{}}},f=d(e);return{...f,deployment:{...f.deployment??{feishuEnabled:!1},modelApiKeyId:o,modelApiKeyName:c}}}function Mpe(e,t){const n=e.cloudProvider??t,i=Ob(e,n);return{...e,cloudProvider:n,modelSource:i,modelProvider:i==="ark"?"":e.modelProvider,modelApiBase:i==="ark"?"":e.modelApiBase,subAgents:e.subAgents.map(r=>Mpe(r,n))}}function Oh(e,t){return e[t]|e[t+1]<<8}function gm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}async function Uft(e){const t=new DecompressionStream("deflate-raw"),n=new Blob([new Uint8Array(e)]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}async function Lpe(e,t={}){let i=-1;for(let u=e.length-22;u>=0&&u>e.length-65557;u--)if(gm(e,u)===101010256){i=u;break}if(i<0)throw new Error("无效的 zip:找不到 EOCD");const r=Oh(e,i+10);if(t.maxEntries!==void 0&&r>t.maxEntries)throw new Error(`zip 文件数不能超过 ${t.maxEntries} 个`);let s=gm(e,i+16);const a=new TextDecoder("utf-8"),o=[];let c=0;for(let u=0;ut.maxUncompressedBytes)throw new Error("zip 解压后的内容过大");const v=Oh(e,y+26),x=Oh(e,y+28),w=y+30+v+x,E=e.subarray(w,w+f);let S;if(d===0)S=E;else if(d===8)S=await Uft(E);else{s+=46+p+g+b;continue}o.push({name:O,text:a.decode(S)}),s+=46+p+g+b}return o}const zft="/harness/skills/findskill";async function Fft(e,t="public"){const n=e.trim(),i=new URLSearchParams({query:n,page_number:"1",page_size:"20"}),r=`${zft}?${i.toString()}`,s=await fetch(r,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(!s.ok)throw new Error(`搜索失败 (${s.status})`);return((await s.json()).items??[]).map(o=>({source:"skillhub",id:o.slug??o.name??"",slug:o.slug??"",name:o.name??o.slug??"",description:o.description??"",namespace:t,sourceRepo:o.sourceRepo,downloadCount:o.downloadCount,version:o.version}))}function Vft({selected:e,onChange:t}){const[n,i]=m.useState(""),[r,s]=m.useState([]),[a,o]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.useState(!1),h=b=>e.some(y=>y.source==="skillhub"&&y.slug===b),p=b=>{b.slug&&(h(b.slug)?t(e.filter(y=>!(y.source==="skillhub"&&y.slug===b.slug))):t([...e,{source:"skillhub",slug:b.slug,name:b.name,folder:b.slug.split("/").pop()||b.name,namespace:b.namespace||"public",description:b.description}]))},g=async b=>{o(!0),u(null),f(!0);try{const y=await Fft(b);s(y)}catch(y){u(y instanceof Error?y.message:"搜索失败,请稍后重试。"),s([])}finally{o(!1)}};return m.useEffect(()=>{const b=n.trim();if(!b){s([]),f(!1),u(null);return}const y=setTimeout(()=>g(b),300);return()=>clearTimeout(y)},[n]),l.jsxs("div",{className:"cw-skillhub",children:[l.jsxs("div",{className:"cw-skill-searchrow",children:[l.jsxs("div",{className:"cw-skill-searchbox",children:[l.jsx(hk,{className:"cw-i cw-skill-searchicon","aria-hidden":!0}),l.jsx("input",{className:"cw-input cw-skill-input",value:n,placeholder:"搜索火山 Find Skill 技能广场,例如 数据分析、PDF…",onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),n.trim()&&g(n))}})]}),l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft",onClick:()=>n.trim()&&g(n),disabled:!n.trim()||a,children:[a?l.jsx(Kn,{className:"cw-i cw-spin"}):l.jsx(hk,{className:"cw-i"}),"搜索"]})]}),c&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:c})]}),a&&r.length===0?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在搜索…"]}):r.length>0?l.jsx("div",{className:"cw-skill-results",children:r.map(b=>{const y=h(b.slug||"");return l.jsxs("button",{type:"button",className:`cw-skill-result ${y?"is-on":""}`,onClick:()=>p(b),"aria-pressed":y,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:y?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:b.name}),b.description&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(b.description)}),b.sourceRepo&&l.jsx("span",{className:"cw-skill-result-repo",children:b.sourceRepo})]})]},b.id||b.slug)})}):d&&!c?l.jsx("p",{className:"cw-empty-line",children:"没有找到匹配的技能,换个关键词试试。"}):!d&&l.jsx("p",{className:"cw-empty-line",children:"输入关键词搜索火山 Find Skill 技能广场,所选技能会在生成项目时下载到 skills/ 目录。"})]})}const UL=/(^|\/)skill\.md$/i;function Xft(e){const t=(e??"").replace(/\r\n?/g,` `).split(` -`);if(!t.length||t[0].trim()!=="---")return{name:"",description:""};let n=-1;for(let r=1;r=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))}function qft(...e){var t;for(const n of e){const i=(t=n.trim().replace(/\\/g,"/").split("/").filter(Boolean).pop())==null?void 0:t.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");if(i)return i.slice(0,64)}return"local-skill"}function Hft(e,t){return t.trim()||e}function Lpe(e){const t=e.map(i=>({path:i.path.replace(/\\/g,"/").replace(/^\.\//,""),text:i.text})).filter(i=>i.path.length>0&&!i.path.endsWith("/")),n=new Set(t.map(i=>i.path.split("/")[0]));if(n.size===1&&t.every(i=>i.path.includes("/"))){const i=[...n][0]+"/";return t.map(r=>({path:r.path.slice(i.length),text:r.text}))}return t}function Yft(e){const t=new Map,n=new Set;for(const i of e)if(UL.test("/"+i.path)){const r=i.path.split("/");n.add(r.slice(0,-1).join("/"))}for(const i of e){const r=i.path.split("/");let s="";for(let u=r.length-1;u>=0;u--){const d=r.slice(0,u).join("/");if(n.has(d)){s=d;break}}const a=UL.test("/"+i.path);if(!s&&!a&&!n.has("")||!n.has(s)&&!a)continue;const o=s?i.path.slice(s.length+1):i.path,c=t.get(s)||[];c.push({path:o,text:i.text}),t.set(s,c)}return t}function Gft(e,t,n){const i=`${n}${e?"/"+e:""}`,r=t.find(c=>UL.test("/"+c.path));if(!r)return{hit:null,error:`${i} 缺少 SKILL.md`};const s=Vft(r.text),a=qft(s.name,e,n.replace(/\.[^.]+$/,"")),o=[];for(const c of t){if(c.path.split("/").some(f=>f===".."))return{hit:null,error:`${i} 包含非法路径(..):${c.path}`};const d=`skills/${a}/${c.path}`;if(!d.startsWith(`skills/${a}/`))return{hit:null,error:`${i} 包含非法路径:${c.path}`};o.push({path:d,content:c.text})}return{hit:{source:"local",id:`local:${a}:${t.length}`,name:Hft(a,s.name),description:s.description||"本地 Skill",folder:a,localFiles:o},error:null}}async function Wft(e){const t=new Uint8Array(await e.arrayBuffer()),i=(await Mpe(t)).map(r=>({path:r.name,text:r.text}));return Dpe(Lpe(i),e.name)}async function Zft(e,t=new Map){const n=[];for(let i=0;ie.file(t,n))}async function Jft(e){const t=e.createReader(),n=[];for(;;){const i=await new Promise((r,s)=>t.readEntries(r,s));if(i.length===0)return n;n.push(...i)}}async function $pe(e,t=""){const n=t?`${t}/${e.name}`:e.name;if(e.isFile)return[{file:await Kft(e),path:n}];if(!e.isDirectory)return[];const i=await Jft(e);return(await Promise.all(i.map(r=>$pe(r,n)))).flat()}function eht({selected:e,onChange:t}){const[n,i]=m.useState([]),[r,s]=m.useState([]),[a,o]=m.useState(!1),[c,u]=m.useState(!1),d=m.useRef(0),f=x=>e.some(w=>w.source==="local"&&w.folder===x),h=x=>{x.localFiles&&(f(x.folder||x.name)?t(e.filter(w=>!(w.source==="local"&&w.folder===(x.folder||x.name)))):t([...e,{source:"local",folder:x.folder||x.name,name:x.name,description:x.description,localFiles:x.localFiles}]))},p=m.useRef([]),g=m.useRef(e);m.useEffect(()=>{p.current=r},[r]),m.useEffect(()=>{g.current=e},[e]);const b=x=>{const w=new Set([...p.current.map(T=>T.folder||T.name),...g.current.filter(T=>T.source==="local").map(T=>T.folder)]),E=[],S=[];for(const T of x.hits){const A=T.folder||T.name;if(w.has(A)){E.push(T.name);continue}w.add(A),S.push(T)}s(T=>[...T,...S]);const k=[...x.errors];if(E.length>0&&k.push(`已跳过重复技能:${E.join("、")}`),i(k),S.length===1&&x.errors.length===0&&E.length===0){const T=S[0];T.localFiles&&t([...g.current,{source:"local",folder:T.folder||T.name,name:T.name,description:T.description,localFiles:T.localFiles}])}},y=x=>{x.preventDefault(),d.current+=1,u(!0)},O=x=>{x.preventDefault(),d.current=Math.max(0,d.current-1),d.current===0&&u(!1)},v=async x=>{if(x.preventDefault(),d.current=0,u(!1),a)return;const w=Array.from(x.dataTransfer.items).map(E=>{var S;return(S=E.webkitGetAsEntry)==null?void 0:S.call(E)}).filter(E=>E!==null);if(w.length===0){i(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}o(!0);try{const E=(await Promise.all(w.map(T=>$pe(T)))).flat(),S=w.some(T=>T.isDirectory);if(!S&&E.length===1&&E[0].file.name.toLowerCase().endsWith(".zip")){b(await Wft(E[0].file));return}if(!S){i(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}const k=new Map(E.map(({file:T,path:A})=>[T,A]));b(await Zft(E.map(({file:T})=>T),k))}catch(E){i([`读取失败:${E instanceof Error?E.message:String(E)}`])}finally{o(!1)}};return l.jsxs("div",{className:"cw-local",children:[l.jsxs("div",{className:`cw-local-dropzone ${c?"is-dragging":""}`,role:"group","aria-label":"拖入文件夹或 ZIP,自动识别 Skill",onDragEnter:y,onDragOver:x=>x.preventDefault(),onDragLeave:O,onDrop:x=>void v(x),children:[l.jsx(MD,{className:"cw-local-drop-icon","aria-hidden":!0}),l.jsx("p",{className:"cw-local-drop-hint",children:"拖入文件夹或 ZIP,自动识别 Skill"})]}),l.jsx("p",{className:"cw-local-hint",children:"每个技能需包含 SKILL.md。支持包含多个技能的目录。"}),a&&l.jsx("p",{className:"cw-empty-line",children:"正在读取文件…"}),n.length>0&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:n.join(";")})]}),r.length>0&&l.jsx("div",{className:"cw-skill-results",children:r.map(x=>{var E;const w=f(x.folder||x.name);return l.jsxs("button",{type:"button",className:`cw-skill-result ${w?"is-on":""}`,onClick:()=>h(x),"aria-pressed":w,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:w?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:x.name}),x.description&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(x.description)}),l.jsxs("span",{className:"cw-skill-result-repo",children:["本地 · ",((E=x.localFiles)==null?void 0:E.length)??0," 个文件"]})]})]},x.id)})})]})}function tht({selected:e,onChange:t,cloudProvider:n="volcengine"}){const[i,r]=m.useState([]),[s,a]=m.useState([]),[o,c]=m.useState(""),[u,d]=m.useState(!0),[f,h]=m.useState(!1),[p,g]=m.useState(null);m.useEffect(()=>{let x=!1;return(async()=>{d(!0),g(null);try{const w=await A$();x||(r(w),w.length>0&&c(w[0].id))}catch(w){x||g(w instanceof Error?w.message:"加载失败")}finally{x||d(!1)}})(),()=>{x=!0}},[]),m.useEffect(()=>{if(!o){a([]);return}const x=i.find(E=>E.id===o);let w=!1;return(async()=>{h(!0),g(null);try{const E=await N$(o,x==null?void 0:x.region);w||a(E)}catch(E){w||g(E instanceof Error?E.message:"加载失败")}finally{w||h(!1)}})(),()=>{w=!0}},[o,i]);const b=i.find(x=>x.id===o),y=b?DPe(b.id,b.region,n):"",O=(x,w)=>e.some(E=>E.source==="skillspace"&&E.skillId===x&&(E.version||"")===w),v=x=>{if(b)if(O(x.skillId,x.version))t(e.filter(w=>!(w.source==="skillspace"&&w.skillId===x.skillId&&(w.version||"")===x.version)));else{const w=LPe(b,x);t([...e,{source:"skillspace",folder:w.folder||x.skillName,name:w.name,description:w.description,skillSpaceId:w.skillSpaceId,skillSpaceName:w.skillSpaceName,skillSpaceRegion:w.skillSpaceRegion,skillId:w.skillId,version:w.version}])}};return l.jsx("div",{className:"cw-skillspace",children:u?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在加载 AgentKit Skills 中心…"]}):p?l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:p})]}):i.length===0?l.jsx("p",{className:"cw-empty-line",children:"此账号下没有 AgentKit Skills 中心。"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-skillspace-header",children:[l.jsx("select",{className:"cw-input cw-skillspace-select",value:o,onChange:x=>c(x.target.value),"aria-label":"选择 AgentKit Skills 中心",children:i.map(x=>l.jsxs("option",{value:x.id,children:[x.name||x.id,x.description?` — ${r1(x.description)}`:""]},x.id))}),b&&l.jsxs(l.Fragment,{children:[b.region&&l.jsx("span",{className:"cw-skillspace-region-label",title:b.region,children:td(b.region,n)}),y&&l.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"cw-button cw-button-secondary cw-skillspace-console-link",title:"在火山引擎控制台打开","aria-label":"在火山引擎控制台打开",children:l.jsx(e0,{className:"cw-i cw-i-sm"})})]})]}),f?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在加载技能列表…"]}):s.length===0?l.jsx("p",{className:"cw-empty-line",children:"此 AgentKit Skills 中心暂无技能。"}):l.jsx("div",{className:"cw-skill-results",children:s.map(x=>{const w=O(x.skillId,x.version);return l.jsxs("button",{type:"button",className:`cw-skill-result ${w?"is-on":""}`,onClick:()=>v(x),"aria-pressed":w,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:w?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsxs("span",{className:"cw-skill-result-name",children:[x.skillName,x.version&&l.jsxs("span",{className:"cw-skill-result-version",children:[" ","v",x.version]})]}),x.skillDescription&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(x.skillDescription)}),l.jsxs("span",{className:"cw-skill-result-repo",children:[l.jsx(zwe,{className:"cw-i cw-i-sm"})," ",(b==null?void 0:b.name)||o]})]})]},`${x.skillId}/${x.version}`)})})]})})}async function nht(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 AgentKit 智能体中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit 智能体中心");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function iht(e={}){const t=new URLSearchParams({page_size:String(e.pageSize??100),project:e.project||"default"});return e.region&&t.set("region",e.region),(await nht(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function rht(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 知识库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 知识库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function sht(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await rht(`/web/viking-knowledgebases${n?`?${n}`:""}`)).items||[]}const aht=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function oht(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function fr(e,t){e.push(t&255,t>>>8&255)}function to(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}const EH=2048,hR=20,kH=0;function lht(e){const t=new TextEncoder,n=[],i=[];let r=0;for(const p of e){const g=t.encode(p.path),b=t.encode(p.content),y=oht(b),O=b.length,v=[];to(v,67324752),fr(v,hR),fr(v,EH),fr(v,kH),fr(v,0),fr(v,0),to(v,y),to(v,O),to(v,O),fr(v,g.length),fr(v,0);const x=Uint8Array.from(v);n.push(x,g,b),i.push({nameBytes:g,dataBytes:b,crc:y,size:O,offset:r}),r+=x.length+g.length+b.length}const s=r,a=[];let o=0;for(const p of i){const g=[];to(g,33639248),fr(g,hR),fr(g,hR),fr(g,EH),fr(g,kH),fr(g,0),fr(g,0),to(g,p.crc),to(g,p.size),to(g,p.size),fr(g,p.nameBytes.length),fr(g,0),fr(g,0),fr(g,0),fr(g,0),to(g,0),to(g,p.offset);const b=Uint8Array.from(g);a.push(b,p.nameBytes),o+=b.length+p.nameBytes.length}const c=[];to(c,101010256),fr(c,0),fr(c,0),fr(c,i.length),fr(c,i.length),to(c,o),to(c,s),fr(c,0);const u=[...n,...a,Uint8Array.from(c)],d=u.reduce((p,g)=>p+g.length,0),f=new Uint8Array(d);let h=0;for(const p of u)f.set(p,h),h+=p.length;return new Blob([f],{type:"application/zip"})}const cht=m.lazy(()=>$g(()=>Promise.resolve().then(()=>Ehe),void 0));function uht(e){const t={name:"",children:new Map};for(const n of e){const i=n.path.split("/").filter(Boolean);let r=t;i.forEach((s,a)=>{let o=r.children.get(s);o||(o={name:s,children:new Map},r.children.set(s,o)),a===i.length-1&&(o.path=n.path),r=o})}return t}function dht(e){return[...e.children.values()].sort((t,n)=>{const i=t.children.size>0&&t.path===void 0,r=n.children.size>0&&n.path===void 0;return i!==r?i?-1:1:t.name.localeCompare(n.name)})}function Qpe({project:e,open:t,onClose:n,onChange:i}){var g;const[r,s]=m.useState(((g=e.files[0])==null?void 0:g.path)??null),[a,o]=m.useState(new Set),c=m.useRef(null),u=m.useMemo(()=>uht(e.files),[e.files]),d=e.files.find(b=>b.path===r)??null;if(m.useEffect(()=>{var O;if(!t)return;const b=document.body.style.overflow;document.body.style.overflow="hidden",(O=c.current)==null||O.focus();const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>{document.body.style.overflow=b,window.removeEventListener("keydown",y)}},[n,t]),m.useEffect(()=>{d||e.files.length===0||s(e.files[0].path)},[e.files,d]),!t)return null;function f(b){o(y=>{const O=new Set(y);return O.has(b)?O.delete(b):O.add(b),O})}function h(b,y,O){return dht(b).map(v=>{const x=O?`${O}/${v.name}`:v.name;if(!(v.children.size>0&&v.path===void 0)&&v.path)return l.jsxs("button",{type:"button",className:`code-browser-file${r===v.path?" is-active":""}`,style:{paddingLeft:`${12+y*16}px`},onClick:()=>s(v.path??null),title:v.path,children:[l.jsx(r9,{"aria-hidden":"true"}),l.jsx("span",{children:v.name})]},x);const E=a.has(x);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+y*16}px`},onClick:()=>f(x),"aria-expanded":!E,children:[l.jsx(U0,{className:E?"":"is-open","aria-hidden":"true"}),l.jsx(fJ,{"aria-hidden":"true"}),l.jsx("span",{children:v.name})]}),!E&&h(v,y+1,x)]},x)})}function p(b){d&&i({...e,files:e.files.map(y=>y.path===d.path?{...y,content:b}:y)})}return zi.createPortal(l.jsx("div",{className:"code-browser-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"code-browser-title",children:[l.jsxs("header",{className:"code-browser-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon","aria-hidden":"true",children:l.jsx(uJ,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"code-browser-title",children:"项目代码"}),l.jsx("p",{children:e.name||"Agent 项目"})]})]}),l.jsx("button",{ref:c,type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭代码浏览器",children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"code-browser-workspace",children:[l.jsxs("aside",{className:"code-browser-sidebar","aria-label":"项目文件",children:[l.jsxs("div",{className:"code-browser-sidebar-head",children:["文件 ",l.jsx("span",{children:e.files.length})]}),l.jsx("div",{className:"code-browser-tree",children:e.files.length>0?h(u,0,""):l.jsx("div",{className:"code-browser-empty",children:"暂无项目文件"})})]}),l.jsxs("main",{className:"code-browser-main",children:[l.jsxs("div",{className:"code-browser-path",children:[l.jsx(r9,{"aria-hidden":"true"}),l.jsx("span",{children:(d==null?void 0:d.path)??"未选择文件"})]}),l.jsx("div",{className:"code-browser-editor",children:d?l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:l.jsx(cht,{value:d.content,path:d.path,onChange:p})}):l.jsx("div",{className:"code-browser-empty",children:"从左侧选择文件以查看代码"})})]})]})]})}),document.body)}function fht({project:e,onChange:t,className:n="",label:i="查看源码"}){const[r,s]=m.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:i,children:[l.jsx(uJ,{"aria-hidden":"true"}),l.jsx("span",{children:i})]}),l.jsx(Qpe,{project:e,open:r,onClose:()=>s(!1),onChange:t})]})}function LT({message:e,className:t="",onRetry:n,retryLabel:i="重试部署",defaultExpanded:r=!0}){const[s,a]=m.useState(r),[o,c]=m.useState(!1),[u,d]=m.useState(!1),f=async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch{c(!1)}},h=async()=>{if(!(!n||u)){d(!0);try{await n()}finally{d(!1)}}};return l.jsxs("div",{className:`deploy-error-message${s?" is-expanded":""}${t?` ${t}`:""}`,role:"alert",children:[l.jsx("p",{className:"deploy-error-message-text",children:e}),l.jsxs("div",{className:"deploy-error-message-actions",children:[n&&l.jsxs("button",{type:"button",className:"deploy-error-retry",disabled:u,onClick:()=>void h(),children:[u?l.jsx(Kn,{className:"spin"}):l.jsx(dSe,{}),u?"重试中…":i]}),l.jsx("button",{type:"button",title:s?"收起错误信息":"展开完整错误信息","aria-label":s?"收起错误信息":"展开完整错误信息",onClick:()=>a(p=>!p),children:s?l.jsx(iSe,{}):l.jsx(np,{})}),l.jsx("button",{type:"button",title:o?"已复制":"复制完整错误信息","aria-label":o?"已复制":"复制完整错误信息",onClick:()=>void f(),children:o?l.jsx(Hc,{}):l.jsx(g_,{})})]})]})}function hht(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 9.5 5 5 5-5"})})}function pht(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 12.5 3.5 3.5 7.5-8"})})}function JA({ariaLabel:e,value:t,valueLabel:n,placeholder:i,options:r,disabled:s=!1,searchValue:a,searchPlaceholder:o="搜索资源名称",loading:c=!1,hasMore:u=!1,emptyMessage:d="暂无可用选项",onSearchChange:f,onLoadMore:h,onChange:p}){const g=m.useId(),b=m.useRef(null),y=m.useRef(null),O=m.useRef(null),v=m.useRef(null),x=m.useRef([]),[w,E]=m.useState(!1),[S,k]=m.useState(0),T=r.find(Q=>Q.value===t),A=(T==null?void 0:T.label)??(t?n:void 0),N=a!==void 0&&!!f,C=()=>{E(!1),N&&a&&(f==null||f(""))};m.useEffect(()=>{if(!w)return;const Q=j=>{j.target instanceof Node&&b.current&&!b.current.contains(j.target)&&C()};return window.addEventListener("pointerdown",Q),()=>window.removeEventListener("pointerdown",Q)},[w,f,a,N]),m.useEffect(()=>{var Q,j;if(w){if(N){(Q=O.current)==null||Q.focus();return}(j=x.current[S])==null||j.focus()}},[w,N]),m.useEffect(()=>{var Q;!w||N&&document.activeElement===O.current||(Q=x.current[S])==null||Q.focus()},[S,w,N]),m.useEffect(()=>{k(Q=>Math.min(Q,Math.max(0,r.length-1)))},[r.length]),m.useEffect(()=>{if(!w||!u||c||!h)return;const Q=window.requestAnimationFrame(()=>{const j=v.current;j&&j.scrollHeight<=j.clientHeight+1&&h()});return()=>window.cancelAnimationFrame(Q)},[u,c,h,w,r.length]);const M=(Q=1)=>{const j=r.findIndex(U=>U.value===t),$=j>=0?j:Q===1?0:Math.max(0,r.length-1);k($),E(!0)},L=Q=>{r.length!==0&&k((Q+r.length)%r.length)},P=Q=>{var j;p(Q.value),C(),(j=y.current)==null||j.focus()};return l.jsxs("div",{className:"pp-deployment-select",ref:b,onKeyDown:Q=>{var $,U;const j=Q.target===O.current;if(Q.key==="Escape"&&w){Q.preventDefault(),C(),($=y.current)==null||$.focus();return}if(Q.key==="Tab"){C();return}if(j){Q.key==="ArrowDown"&&r.length>0&&(Q.preventDefault(),k(0),(U=x.current[0])==null||U.focus());return}Q.key==="ArrowDown"?(Q.preventDefault(),w?L(S+1):M(1)):Q.key==="ArrowUp"?(Q.preventDefault(),w?L(S-1):M(-1)):w&&Q.key==="Home"?(Q.preventDefault(),k(0)):w&&Q.key==="End"&&(Q.preventDefault(),k(Math.max(0,r.length-1)))},children:[l.jsxs("button",{ref:y,type:"button",className:"pp-deployment-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?g:void 0,disabled:s,onClick:()=>{w?C():M()},children:[l.jsx("span",{className:A?void 0:"is-placeholder",children:A??i}),l.jsx(hht,{className:`pp-deployment-select-chevron${w?" is-open":""}`})]}),w&&l.jsxs("div",{className:"pp-deployment-select-menu",children:[N&&l.jsx("div",{className:"pp-deployment-select-search",children:l.jsx("input",{ref:O,type:"search",value:a,"aria-label":`搜索${e}`,placeholder:o,autoComplete:"off",onChange:Q=>f==null?void 0:f(Q.currentTarget.value)})}),l.jsx("div",{id:g,ref:v,className:"pp-deployment-select-options",role:"listbox","aria-label":e,"aria-busy":c||void 0,onScroll:Q=>{if(!u||c||!h)return;const j=Q.currentTarget;j.scrollHeight-j.scrollTop-j.clientHeight<=24&&h()},children:r.map((Q,j)=>{const $=Q.value===t;return l.jsxs("button",{ref:U=>{x.current[j]=U},type:"button",role:"option","aria-selected":$,tabIndex:j===S?0:-1,className:`pp-deployment-select-option${$?" is-selected":""}`,title:Q.description,onFocus:()=>k(j),onClick:()=>P(Q),children:[l.jsxs("span",{className:"pp-deployment-select-copy",children:[l.jsxs("span",{className:"pp-deployment-select-name",children:[Q.label,Q.badge&&l.jsx("span",{className:"pp-deployment-select-badge",children:Q.badge})]}),Q.description&&l.jsx("small",{children:Q.description})]}),$&&l.jsx(pht,{})]},Q.value)})}),c&&l.jsx("div",{className:"pp-deployment-select-state","aria-live":"polite",children:"正在加载更多资源…"}),!c&&r.length===0&&l.jsx("div",{className:"pp-deployment-select-state",children:d})]})]})}const mht=[{value:"auto",label:"自动创建",description:"部署时自动创建所需资源",badge:"推荐"},{value:"create",label:"指定名称",description:"使用指定名称创建或复用资源"},{value:"existing",label:"选择已有",description:"从当前账号的已有资源中选择"}],ght={tos:{mode:"auto"},cr:{mode:"auto"},codePipeline:{mode:"auto"}};function bm(e){const[t,n]=m.useState([]),[i,r]=m.useState(""),[s,a]=m.useState(1),[o,c]=m.useState(0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(null),[b,y]=m.useState(""),[O,v]=m.useState(""),[x,w]=m.useState(""),[E,S]=m.useState(0),k=m.useRef(!1),T=m.useRef(null),A=e?JSON.stringify(e):"",N=e?JSON.stringify({...e,search:O}):"";m.useEffect(()=>{const Q=window.setTimeout(()=>{v(b.trim())},250);return()=>window.clearTimeout(Q)},[b]),m.useEffect(()=>{y(""),v("")},[A]);const C=m.useCallback((Q,j)=>{var B;if(!N)return;(B=T.current)==null||B.abort();const $=new AbortController;T.current=$;const U=JSON.parse(N);j&&n([]),k.current=!0,h(!0),g(null),tee({...U,pageNumber:Q,pageSize:100},$.signal).then(I=>{n(X=>{if(j)return I.items;const q=new Set(X.map(D=>`${D.id}\0${D.name}`));return[...X,...I.items.filter(D=>!q.has(`${D.id}\0${D.name}`))]}),r(I.serviceRegion),a(I.pageNumber),c(I.totalCount),d(I.hasMore),w(N)}).catch(I=>{I instanceof DOMException&&I.name==="AbortError"||(w(N),g(I instanceof Error?I.message:String(I)))}).finally(()=>{T.current===$&&(T.current=null,k.current=!1,h(!1))})},[N]);m.useEffect(()=>{var Q;if(!N){(Q=T.current)==null||Q.abort(),T.current=null,k.current=!1,n([]),r(""),a(1),c(0),d(!1),w(""),h(!1),g(null);return}return C(1,!0),()=>{var j;return(j=T.current)==null?void 0:j.abort()}},[C,N,E]);const M=!!N&&x===N&&b.trim()===O,L=m.useCallback(()=>{w(""),S(Q=>Q+1)},[]),P=m.useCallback(()=>{!M||k.current||!u||C(s+1,!1)},[u,C,s,M]);return{items:t,serviceRegion:i,totalCount:o,hasMore:M?u:!1,loading:!!N&&(!M||f),error:p,search:b,setSearch:y,reload:L,loadMore:P}}function bht(e,t){return e.map(n=>({value:n[t],label:n.name,description:[n.status,n.region,n.id].filter(Boolean).join(" · ")}))}function Om({ariaLabel:e,value:t,valueLabel:n,state:i,disabled:r,valueField:s="id",onChange:a}){const o=m.useMemo(()=>bht(i.items,s),[i.items,s]);return l.jsxs("div",{className:"pp-resource-picker",children:[l.jsx(JA,{ariaLabel:e,value:t,valueLabel:n,placeholder:i.loading?"正在加载…":"请选择已有资源",options:o,disabled:r||!!i.error,searchValue:i.search,searchPlaceholder:"搜索资源名称",loading:i.loading,hasMore:i.hasMore,emptyMessage:i.search.trim()?"未找到匹配资源":"暂无可用资源",onSearchChange:i.setSearch,onLoadMore:i.loadMore,onChange:c=>{const u=i.items.find(d=>d[s]===c);u&&a(u)}}),i.error?l.jsxs("div",{className:"pp-resource-error",role:"alert",children:[l.jsx("span",{children:i.error}),l.jsx("button",{type:"button",onClick:i.reload,children:"重试"})]}):i.loading&&i.items.length===0?l.jsx("span",{className:"pp-resource-status","aria-live":"polite",children:i.search.trim()?"正在搜索云资源…":"正在加载云资源…"}):i.items.length===0?l.jsx("span",{className:"pp-resource-status",children:i.search.trim()?"未找到匹配资源。":"暂无可用资源。"}):i.serviceRegion?l.jsxs("span",{className:"pp-resource-status",children:["实际服务区域:",i.serviceRegion," · 已加载 ",i.items.length,i.totalCount>0?`/${i.totalCount}`:""]}):null]})}function pR({resource:e,value:t,disabled:n,onChange:i}){return l.jsxs("label",{className:"pp-resource-field pp-resource-mode",children:[l.jsx("span",{children:"配置方式"}),l.jsx(JA,{ariaLabel:`${e}配置方式`,value:t,placeholder:"请选择配置方式",options:mht,disabled:n,onChange:r=>i(r)})]})}function ym({label:e,value:t,placeholder:n,disabled:i,onChange:r}){return l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:e}),l.jsx("input",{value:t,placeholder:n,disabled:i,autoComplete:"off",onChange:s=>r(s.currentTarget.value)})]})}function mR({items:e,note:t}){return l.jsxs("div",{className:"pp-resource-auto-names",children:[l.jsx("span",{children:"自动创建名称"}),l.jsx("dl",{children:e.map(n=>l.jsxs("div",{children:[l.jsx("dt",{children:n.label}),l.jsx("dd",{title:n.name,children:n.name})]},n.label))}),t&&l.jsx("small",{children:t})]})}function Oht(e){var t,n,i,r,s,a,o,c;return e.tos.mode!=="auto"&&!((t=e.tos.bucket)!=null&&t.trim())?"请填写或选择 TOS 存储桶。":e.cr.mode!=="auto"&&(!((n=e.cr.instance)!=null&&n.trim())||!((i=e.cr.namespace)!=null&&i.trim())||!((r=e.cr.repository)!=null&&r.trim()))?"请完整填写或选择 CR 实例、命名空间和镜像仓库。":e.codePipeline.mode!=="auto"&&(!((s=e.codePipeline.workspaceName)!=null&&s.trim())||!((a=e.codePipeline.pipelineName)!=null&&a.trim()))?"请完整填写或选择 CodePipeline Workspace 和 Pipeline。":e.codePipeline.mode==="existing"&&(!((o=e.codePipeline.workspaceId)!=null&&o.trim())||!((c=e.codePipeline.pipelineId)!=null&&c.trim()))?"请选择已有的 CodePipeline Workspace 和兼容 Pipeline。":null}function yht({value:e,agentName:t,runtimeName:n,region:i,disabled:r,validationError:s,onChange:a}){const o=t.trim()||"agentkit-app",c=n.trim()||o,u=i&&i!=="cn-beijing"?`agentkit-platform-{账号 ID}-${i.startsWith("cn-")?i.slice(3):i}`:"agentkit-platform-{账号 ID}",d=bm(e.tos.mode==="existing"?{kind:"tos-bucket",region:i}:null),f=bm(e.cr.mode==="existing"?{kind:"cr-registry",region:i}:null),h=bm(e.cr.mode==="existing"&&e.cr.instance?{kind:"cr-namespace",region:i,registry:e.cr.instance}:null),p=bm(e.cr.mode==="existing"&&e.cr.instance&&e.cr.namespace?{kind:"cr-repository",region:i,registry:e.cr.instance,namespace:e.cr.namespace}:null),g=bm(e.codePipeline.mode==="existing"?{kind:"cp-workspace",region:i}:null),b=bm(e.codePipeline.mode==="existing"&&e.codePipeline.workspaceId?{kind:"cp-pipeline",region:i,workspaceId:e.codePipeline.workspaceId}:null),y=O=>a({...e,...O});return l.jsxs("div",{className:"pp-resource-list",children:[l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"TOS 存储桶"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"TOS 存储桶",value:e.tos.mode,disabled:r,onChange:O=>y({tos:{mode:O}})}),e.tos.mode==="create"&&l.jsx(ym,{label:"存储桶名称",value:e.tos.bucket??"",placeholder:"输入存储桶名称",disabled:r,onChange:O=>y({tos:{...e.tos,bucket:O}})}),e.tos.mode==="existing"&&l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"已有存储桶"}),l.jsx(Om,{ariaLabel:"已有 TOS 存储桶",value:e.tos.bucket??"",valueLabel:e.tos.bucket,state:d,disabled:r,onChange:O=>y({tos:{...e.tos,bucket:O.name}})})]}),e.tos.mode==="auto"&&l.jsx(mR,{items:[{label:"存储桶",name:u}],note:"账号 ID 在部署时按当前云账号解析。"})]})]}),l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"容器镜像仓库(CR)"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"CR",value:e.cr.mode,disabled:r,onChange:O=>y({cr:{mode:O}})}),e.cr.mode==="create"&&l.jsxs("div",{className:"pp-resource-fields pp-resource-fields-three",children:[l.jsx(ym,{label:"实例名称",value:e.cr.instance??"",placeholder:"CR 实例",disabled:r,onChange:O=>y({cr:{...e.cr,instance:O}})}),l.jsx(ym,{label:"命名空间",value:e.cr.namespace??"",placeholder:"命名空间",disabled:r,onChange:O=>y({cr:{...e.cr,namespace:O}})}),l.jsx(ym,{label:"镜像仓库",value:e.cr.repository??"",placeholder:"镜像仓库",disabled:r,onChange:O=>y({cr:{...e.cr,repository:O}})})]}),e.cr.mode==="existing"&&l.jsxs("div",{className:"pp-resource-fields pp-resource-fields-three",children:[l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"CR 实例"}),l.jsx(Om,{ariaLabel:"已有 CR 实例",value:e.cr.instance??"",valueLabel:e.cr.instance,state:f,disabled:r,valueField:"name",onChange:O=>y({cr:{mode:"existing",instance:O.name}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"命名空间"}),l.jsx(Om,{ariaLabel:"已有 CR 命名空间",value:e.cr.namespace??"",valueLabel:e.cr.namespace,state:h,disabled:r||!e.cr.instance,valueField:"name",onChange:O=>y({cr:{...e.cr,namespace:O.name,repository:void 0}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"镜像仓库"}),l.jsx(Om,{ariaLabel:"已有 CR 镜像仓库",value:e.cr.repository??"",valueLabel:e.cr.repository,state:p,disabled:r||!e.cr.namespace,valueField:"name",onChange:O=>y({cr:{...e.cr,repository:O.name}})})]})]}),e.cr.mode==="auto"&&l.jsx(mR,{items:[{label:"CR 实例",name:"agentkit-platform-{账号 ID}"},{label:"命名空间",name:"agentkit"},{label:"镜像仓库",name:`${o}-{4 位随机字符}`}],note:"账号 ID 在部署时解析,镜像仓库的随机字符在部署时生成。"})]})]}),l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"CodePipeline"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"CodePipeline",value:e.codePipeline.mode,disabled:r,onChange:O=>y({codePipeline:{mode:O}})}),e.codePipeline.mode==="create"&&l.jsxs("div",{className:"pp-resource-fields",children:[l.jsx(ym,{label:"Workspace 名称",value:e.codePipeline.workspaceName??"",placeholder:"Workspace 名称",disabled:r,onChange:O=>y({codePipeline:{...e.codePipeline,workspaceName:O}})}),l.jsx(ym,{label:"Pipeline 名称",value:e.codePipeline.pipelineName??"",placeholder:"Pipeline 名称",disabled:r,onChange:O=>y({codePipeline:{...e.codePipeline,pipelineName:O}})})]}),e.codePipeline.mode==="existing"&&l.jsxs("div",{className:"pp-resource-fields",children:[l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"Workspace"}),l.jsx(Om,{ariaLabel:"已有 CodePipeline Workspace",value:e.codePipeline.workspaceId??"",valueLabel:e.codePipeline.workspaceName,state:g,disabled:r,onChange:O=>y({codePipeline:{mode:"existing",workspaceId:O.id,workspaceName:O.name}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"兼容 Pipeline"}),l.jsx(Om,{ariaLabel:"已有 AgentKit CodePipeline",value:e.codePipeline.pipelineId??"",valueLabel:e.codePipeline.pipelineName,state:b,disabled:r||!e.codePipeline.workspaceId,onChange:O=>y({codePipeline:{...e.codePipeline,pipelineId:O.id,pipelineName:O.name}})})]})]}),e.codePipeline.mode==="auto"&&l.jsx(mR,{items:[{label:"Workspace",name:"agentkit-cli-workspace"},{label:"Pipeline",name:c}],note:"Pipeline 与 Runtime 名称一致。"})]})]}),s&&l.jsx("p",{className:"pp-resource-validation",role:"alert",children:s})]})}const xht=5e4;function vht(e,t){if(!e)return t;if(!t||e.endsWith(t))return e;if(t.startsWith(e))return t;const n=e.split(` +`);if(!t.length||t[0].trim()!=="---")return{name:"",description:""};let n=-1;for(let r=1;r=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))}function Hft(...e){var t;for(const n of e){const i=(t=n.trim().replace(/\\/g,"/").split("/").filter(Boolean).pop())==null?void 0:t.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");if(i)return i.slice(0,64)}return"local-skill"}function Yft(e,t){return t.trim()||e}function Dpe(e){const t=e.map(i=>({path:i.path.replace(/\\/g,"/").replace(/^\.\//,""),text:i.text})).filter(i=>i.path.length>0&&!i.path.endsWith("/")),n=new Set(t.map(i=>i.path.split("/")[0]));if(n.size===1&&t.every(i=>i.path.includes("/"))){const i=[...n][0]+"/";return t.map(r=>({path:r.path.slice(i.length),text:r.text}))}return t}function Gft(e){const t=new Map,n=new Set;for(const i of e)if(UL.test("/"+i.path)){const r=i.path.split("/");n.add(r.slice(0,-1).join("/"))}for(const i of e){const r=i.path.split("/");let s="";for(let u=r.length-1;u>=0;u--){const d=r.slice(0,u).join("/");if(n.has(d)){s=d;break}}const a=UL.test("/"+i.path);if(!s&&!a&&!n.has("")||!n.has(s)&&!a)continue;const o=s?i.path.slice(s.length+1):i.path,c=t.get(s)||[];c.push({path:o,text:i.text}),t.set(s,c)}return t}function Wft(e,t,n){const i=`${n}${e?"/"+e:""}`,r=t.find(c=>UL.test("/"+c.path));if(!r)return{hit:null,error:`${i} 缺少 SKILL.md`};const s=Xft(r.text),a=Hft(s.name,e,n.replace(/\.[^.]+$/,"")),o=[];for(const c of t){if(c.path.split("/").some(f=>f===".."))return{hit:null,error:`${i} 包含非法路径(..):${c.path}`};const d=`skills/${a}/${c.path}`;if(!d.startsWith(`skills/${a}/`))return{hit:null,error:`${i} 包含非法路径:${c.path}`};o.push({path:d,content:c.text})}return{hit:{source:"local",id:`local:${a}:${t.length}`,name:Yft(a,s.name),description:s.description||"本地 Skill",folder:a,localFiles:o},error:null}}async function Zft(e){const t=new Uint8Array(await e.arrayBuffer()),i=(await Lpe(t)).map(r=>({path:r.name,text:r.text}));return $pe(Dpe(i),e.name)}async function Kft(e,t=new Map){const n=[];for(let i=0;ie.file(t,n))}async function eht(e){const t=e.createReader(),n=[];for(;;){const i=await new Promise((r,s)=>t.readEntries(r,s));if(i.length===0)return n;n.push(...i)}}async function Qpe(e,t=""){const n=t?`${t}/${e.name}`:e.name;if(e.isFile)return[{file:await Jft(e),path:n}];if(!e.isDirectory)return[];const i=await eht(e);return(await Promise.all(i.map(r=>Qpe(r,n)))).flat()}function tht({selected:e,onChange:t}){const[n,i]=m.useState([]),[r,s]=m.useState([]),[a,o]=m.useState(!1),[c,u]=m.useState(!1),d=m.useRef(0),f=x=>e.some(w=>w.source==="local"&&w.folder===x),h=x=>{x.localFiles&&(f(x.folder||x.name)?t(e.filter(w=>!(w.source==="local"&&w.folder===(x.folder||x.name)))):t([...e,{source:"local",folder:x.folder||x.name,name:x.name,description:x.description,localFiles:x.localFiles}]))},p=m.useRef([]),g=m.useRef(e);m.useEffect(()=>{p.current=r},[r]),m.useEffect(()=>{g.current=e},[e]);const b=x=>{const w=new Set([...p.current.map(T=>T.folder||T.name),...g.current.filter(T=>T.source==="local").map(T=>T.folder)]),E=[],S=[];for(const T of x.hits){const A=T.folder||T.name;if(w.has(A)){E.push(T.name);continue}w.add(A),S.push(T)}s(T=>[...T,...S]);const k=[...x.errors];if(E.length>0&&k.push(`已跳过重复技能:${E.join("、")}`),i(k),S.length===1&&x.errors.length===0&&E.length===0){const T=S[0];T.localFiles&&t([...g.current,{source:"local",folder:T.folder||T.name,name:T.name,description:T.description,localFiles:T.localFiles}])}},y=x=>{x.preventDefault(),d.current+=1,u(!0)},O=x=>{x.preventDefault(),d.current=Math.max(0,d.current-1),d.current===0&&u(!1)},v=async x=>{if(x.preventDefault(),d.current=0,u(!1),a)return;const w=Array.from(x.dataTransfer.items).map(E=>{var S;return(S=E.webkitGetAsEntry)==null?void 0:S.call(E)}).filter(E=>E!==null);if(w.length===0){i(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}o(!0);try{const E=(await Promise.all(w.map(T=>Qpe(T)))).flat(),S=w.some(T=>T.isDirectory);if(!S&&E.length===1&&E[0].file.name.toLowerCase().endsWith(".zip")){b(await Zft(E[0].file));return}if(!S){i(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}const k=new Map(E.map(({file:T,path:A})=>[T,A]));b(await Kft(E.map(({file:T})=>T),k))}catch(E){i([`读取失败:${E instanceof Error?E.message:String(E)}`])}finally{o(!1)}};return l.jsxs("div",{className:"cw-local",children:[l.jsxs("div",{className:`cw-local-dropzone ${c?"is-dragging":""}`,role:"group","aria-label":"拖入文件夹或 ZIP,自动识别 Skill",onDragEnter:y,onDragOver:x=>x.preventDefault(),onDragLeave:O,onDrop:x=>void v(x),children:[l.jsx(MD,{className:"cw-local-drop-icon","aria-hidden":!0}),l.jsx("p",{className:"cw-local-drop-hint",children:"拖入文件夹或 ZIP,自动识别 Skill"})]}),l.jsx("p",{className:"cw-local-hint",children:"每个技能需包含 SKILL.md。支持包含多个技能的目录。"}),a&&l.jsx("p",{className:"cw-empty-line",children:"正在读取文件…"}),n.length>0&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:n.join(";")})]}),r.length>0&&l.jsx("div",{className:"cw-skill-results",children:r.map(x=>{var E;const w=f(x.folder||x.name);return l.jsxs("button",{type:"button",className:`cw-skill-result ${w?"is-on":""}`,onClick:()=>h(x),"aria-pressed":w,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:w?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:x.name}),x.description&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(x.description)}),l.jsxs("span",{className:"cw-skill-result-repo",children:["本地 · ",((E=x.localFiles)==null?void 0:E.length)??0," 个文件"]})]})]},x.id)})})]})}function nht({selected:e,onChange:t,cloudProvider:n="volcengine"}){const[i,r]=m.useState([]),[s,a]=m.useState([]),[o,c]=m.useState(""),[u,d]=m.useState(!0),[f,h]=m.useState(!1),[p,g]=m.useState(null);m.useEffect(()=>{let x=!1;return(async()=>{d(!0),g(null);try{const w=await A$();x||(r(w),w.length>0&&c(w[0].id))}catch(w){x||g(w instanceof Error?w.message:"加载失败")}finally{x||d(!1)}})(),()=>{x=!0}},[]),m.useEffect(()=>{if(!o){a([]);return}const x=i.find(E=>E.id===o);let w=!1;return(async()=>{h(!0),g(null);try{const E=await N$(o,x==null?void 0:x.region);w||a(E)}catch(E){w||g(E instanceof Error?E.message:"加载失败")}finally{w||h(!1)}})(),()=>{w=!0}},[o,i]);const b=i.find(x=>x.id===o),y=b?$Pe(b.id,b.region,n):"",O=(x,w)=>e.some(E=>E.source==="skillspace"&&E.skillId===x&&(E.version||"")===w),v=x=>{if(b)if(O(x.skillId,x.version))t(e.filter(w=>!(w.source==="skillspace"&&w.skillId===x.skillId&&(w.version||"")===x.version)));else{const w=DPe(b,x);t([...e,{source:"skillspace",folder:w.folder||x.skillName,name:w.name,description:w.description,skillSpaceId:w.skillSpaceId,skillSpaceName:w.skillSpaceName,skillSpaceRegion:w.skillSpaceRegion,skillId:w.skillId,version:w.version}])}};return l.jsx("div",{className:"cw-skillspace",children:u?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在加载 AgentKit Skills 中心…"]}):p?l.jsxs("div",{className:"cw-banner",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:p})]}):i.length===0?l.jsx("p",{className:"cw-empty-line",children:"此账号下没有 AgentKit Skills 中心。"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-skillspace-header",children:[l.jsx("select",{className:"cw-input cw-skillspace-select",value:o,onChange:x=>c(x.target.value),"aria-label":"选择 AgentKit Skills 中心",children:i.map(x=>l.jsxs("option",{value:x.id,children:[x.name||x.id,x.description?` — ${r1(x.description)}`:""]},x.id))}),b&&l.jsxs(l.Fragment,{children:[b.region&&l.jsx("span",{className:"cw-skillspace-region-label",title:b.region,children:td(b.region,n)}),y&&l.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"cw-button cw-button-secondary cw-skillspace-console-link",title:"在火山引擎控制台打开","aria-label":"在火山引擎控制台打开",children:l.jsx(e0,{className:"cw-i cw-i-sm"})})]})]}),f?l.jsxs("p",{className:"cw-empty-line cw-skill-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"})," 正在加载技能列表…"]}):s.length===0?l.jsx("p",{className:"cw-empty-line",children:"此 AgentKit Skills 中心暂无技能。"}):l.jsx("div",{className:"cw-skill-results",children:s.map(x=>{const w=O(x.skillId,x.version);return l.jsxs("button",{type:"button",className:`cw-skill-result ${w?"is-on":""}`,onClick:()=>v(x),"aria-pressed":w,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:w?l.jsx(Hc,{className:"cw-i cw-i-sm"}):l.jsx(Gs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsxs("span",{className:"cw-skill-result-name",children:[x.skillName,x.version&&l.jsxs("span",{className:"cw-skill-result-version",children:[" ","v",x.version]})]}),x.skillDescription&&l.jsx("span",{className:"cw-skill-result-desc",children:r1(x.skillDescription)}),l.jsxs("span",{className:"cw-skill-result-repo",children:[l.jsx(Fwe,{className:"cw-i cw-i-sm"})," ",(b==null?void 0:b.name)||o]})]})]},`${x.skillId}/${x.version}`)})})]})})}async function iht(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 AgentKit 智能体中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit 智能体中心");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function rht(e={}){const t=new URLSearchParams({page_size:String(e.pageSize??100),project:e.project||"default"});return e.region&&t.set("region",e.region),(await iht(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function sht(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ao(void 0,_o)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 知识库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 知识库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function aht(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await sht(`/web/viking-knowledgebases${n?`?${n}`:""}`)).items||[]}const oht=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function lht(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function fr(e,t){e.push(t&255,t>>>8&255)}function to(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}const kH=2048,hR=20,TH=0;function cht(e){const t=new TextEncoder,n=[],i=[];let r=0;for(const p of e){const g=t.encode(p.path),b=t.encode(p.content),y=lht(b),O=b.length,v=[];to(v,67324752),fr(v,hR),fr(v,kH),fr(v,TH),fr(v,0),fr(v,0),to(v,y),to(v,O),to(v,O),fr(v,g.length),fr(v,0);const x=Uint8Array.from(v);n.push(x,g,b),i.push({nameBytes:g,dataBytes:b,crc:y,size:O,offset:r}),r+=x.length+g.length+b.length}const s=r,a=[];let o=0;for(const p of i){const g=[];to(g,33639248),fr(g,hR),fr(g,hR),fr(g,kH),fr(g,TH),fr(g,0),fr(g,0),to(g,p.crc),to(g,p.size),to(g,p.size),fr(g,p.nameBytes.length),fr(g,0),fr(g,0),fr(g,0),fr(g,0),to(g,0),to(g,p.offset);const b=Uint8Array.from(g);a.push(b,p.nameBytes),o+=b.length+p.nameBytes.length}const c=[];to(c,101010256),fr(c,0),fr(c,0),fr(c,i.length),fr(c,i.length),to(c,o),to(c,s),fr(c,0);const u=[...n,...a,Uint8Array.from(c)],d=u.reduce((p,g)=>p+g.length,0),f=new Uint8Array(d);let h=0;for(const p of u)f.set(p,h),h+=p.length;return new Blob([f],{type:"application/zip"})}const uht=m.lazy(()=>$g(()=>Promise.resolve().then(()=>khe),void 0));function dht(e){const t={name:"",children:new Map};for(const n of e){const i=n.path.split("/").filter(Boolean);let r=t;i.forEach((s,a)=>{let o=r.children.get(s);o||(o={name:s,children:new Map},r.children.set(s,o)),a===i.length-1&&(o.path=n.path),r=o})}return t}function fht(e){return[...e.children.values()].sort((t,n)=>{const i=t.children.size>0&&t.path===void 0,r=n.children.size>0&&n.path===void 0;return i!==r?i?-1:1:t.name.localeCompare(n.name)})}function Bpe({project:e,open:t,onClose:n,onChange:i}){var g;const[r,s]=m.useState(((g=e.files[0])==null?void 0:g.path)??null),[a,o]=m.useState(new Set),c=m.useRef(null),u=m.useMemo(()=>dht(e.files),[e.files]),d=e.files.find(b=>b.path===r)??null;if(m.useEffect(()=>{var O;if(!t)return;const b=document.body.style.overflow;document.body.style.overflow="hidden",(O=c.current)==null||O.focus();const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>{document.body.style.overflow=b,window.removeEventListener("keydown",y)}},[n,t]),m.useEffect(()=>{d||e.files.length===0||s(e.files[0].path)},[e.files,d]),!t)return null;function f(b){o(y=>{const O=new Set(y);return O.has(b)?O.delete(b):O.add(b),O})}function h(b,y,O){return fht(b).map(v=>{const x=O?`${O}/${v.name}`:v.name;if(!(v.children.size>0&&v.path===void 0)&&v.path)return l.jsxs("button",{type:"button",className:`code-browser-file${r===v.path?" is-active":""}`,style:{paddingLeft:`${12+y*16}px`},onClick:()=>s(v.path??null),title:v.path,children:[l.jsx(r9,{"aria-hidden":"true"}),l.jsx("span",{children:v.name})]},x);const E=a.has(x);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+y*16}px`},onClick:()=>f(x),"aria-expanded":!E,children:[l.jsx(U0,{className:E?"":"is-open","aria-hidden":"true"}),l.jsx(hJ,{"aria-hidden":"true"}),l.jsx("span",{children:v.name})]}),!E&&h(v,y+1,x)]},x)})}function p(b){d&&i({...e,files:e.files.map(y=>y.path===d.path?{...y,content:b}:y)})}return zi.createPortal(l.jsx("div",{className:"code-browser-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"code-browser-title",children:[l.jsxs("header",{className:"code-browser-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon","aria-hidden":"true",children:l.jsx(dJ,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"code-browser-title",children:"项目代码"}),l.jsx("p",{children:e.name||"Agent 项目"})]})]}),l.jsx("button",{ref:c,type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭代码浏览器",children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"code-browser-workspace",children:[l.jsxs("aside",{className:"code-browser-sidebar","aria-label":"项目文件",children:[l.jsxs("div",{className:"code-browser-sidebar-head",children:["文件 ",l.jsx("span",{children:e.files.length})]}),l.jsx("div",{className:"code-browser-tree",children:e.files.length>0?h(u,0,""):l.jsx("div",{className:"code-browser-empty",children:"暂无项目文件"})})]}),l.jsxs("main",{className:"code-browser-main",children:[l.jsxs("div",{className:"code-browser-path",children:[l.jsx(r9,{"aria-hidden":"true"}),l.jsx("span",{children:(d==null?void 0:d.path)??"未选择文件"})]}),l.jsx("div",{className:"code-browser-editor",children:d?l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:l.jsx(uht,{value:d.content,path:d.path,onChange:p})}):l.jsx("div",{className:"code-browser-empty",children:"从左侧选择文件以查看代码"})})]})]})]})}),document.body)}function hht({project:e,onChange:t,className:n="",label:i="查看源码"}){const[r,s]=m.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:i,children:[l.jsx(dJ,{"aria-hidden":"true"}),l.jsx("span",{children:i})]}),l.jsx(Bpe,{project:e,open:r,onClose:()=>s(!1),onChange:t})]})}function LT({message:e,className:t="",onRetry:n,retryLabel:i="重试部署",defaultExpanded:r=!0}){const[s,a]=m.useState(r),[o,c]=m.useState(!1),[u,d]=m.useState(!1),f=async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch{c(!1)}},h=async()=>{if(!(!n||u)){d(!0);try{await n()}finally{d(!1)}}};return l.jsxs("div",{className:`deploy-error-message${s?" is-expanded":""}${t?` ${t}`:""}`,role:"alert",children:[l.jsx("p",{className:"deploy-error-message-text",children:e}),l.jsxs("div",{className:"deploy-error-message-actions",children:[n&&l.jsxs("button",{type:"button",className:"deploy-error-retry",disabled:u,onClick:()=>void h(),children:[u?l.jsx(Kn,{className:"spin"}):l.jsx(fSe,{}),u?"重试中…":i]}),l.jsx("button",{type:"button",title:s?"收起错误信息":"展开完整错误信息","aria-label":s?"收起错误信息":"展开完整错误信息",onClick:()=>a(p=>!p),children:s?l.jsx(rSe,{}):l.jsx(np,{})}),l.jsx("button",{type:"button",title:o?"已复制":"复制完整错误信息","aria-label":o?"已复制":"复制完整错误信息",onClick:()=>void f(),children:o?l.jsx(Hc,{}):l.jsx(g_,{})})]})]})}function pht(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 9.5 5 5 5-5"})})}function mht(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 12.5 3.5 3.5 7.5-8"})})}function JA({ariaLabel:e,value:t,valueLabel:n,placeholder:i,options:r,disabled:s=!1,searchValue:a,searchPlaceholder:o="搜索资源名称",loading:c=!1,hasMore:u=!1,emptyMessage:d="暂无可用选项",onSearchChange:f,onLoadMore:h,onChange:p}){const g=m.useId(),b=m.useRef(null),y=m.useRef(null),O=m.useRef(null),v=m.useRef(null),x=m.useRef([]),[w,E]=m.useState(!1),[S,k]=m.useState(0),T=r.find(Q=>Q.value===t),A=(T==null?void 0:T.label)??(t?n:void 0),N=a!==void 0&&!!f,C=()=>{E(!1),N&&a&&(f==null||f(""))};m.useEffect(()=>{if(!w)return;const Q=j=>{j.target instanceof Node&&b.current&&!b.current.contains(j.target)&&C()};return window.addEventListener("pointerdown",Q),()=>window.removeEventListener("pointerdown",Q)},[w,f,a,N]),m.useEffect(()=>{var Q,j;if(w){if(N){(Q=O.current)==null||Q.focus();return}(j=x.current[S])==null||j.focus()}},[w,N]),m.useEffect(()=>{var Q;!w||N&&document.activeElement===O.current||(Q=x.current[S])==null||Q.focus()},[S,w,N]),m.useEffect(()=>{k(Q=>Math.min(Q,Math.max(0,r.length-1)))},[r.length]),m.useEffect(()=>{if(!w||!u||c||!h)return;const Q=window.requestAnimationFrame(()=>{const j=v.current;j&&j.scrollHeight<=j.clientHeight+1&&h()});return()=>window.cancelAnimationFrame(Q)},[u,c,h,w,r.length]);const M=(Q=1)=>{const j=r.findIndex(U=>U.value===t),$=j>=0?j:Q===1?0:Math.max(0,r.length-1);k($),E(!0)},L=Q=>{r.length!==0&&k((Q+r.length)%r.length)},P=Q=>{var j;p(Q.value),C(),(j=y.current)==null||j.focus()};return l.jsxs("div",{className:"pp-deployment-select",ref:b,onKeyDown:Q=>{var $,U;const j=Q.target===O.current;if(Q.key==="Escape"&&w){Q.preventDefault(),C(),($=y.current)==null||$.focus();return}if(Q.key==="Tab"){C();return}if(j){Q.key==="ArrowDown"&&r.length>0&&(Q.preventDefault(),k(0),(U=x.current[0])==null||U.focus());return}Q.key==="ArrowDown"?(Q.preventDefault(),w?L(S+1):M(1)):Q.key==="ArrowUp"?(Q.preventDefault(),w?L(S-1):M(-1)):w&&Q.key==="Home"?(Q.preventDefault(),k(0)):w&&Q.key==="End"&&(Q.preventDefault(),k(Math.max(0,r.length-1)))},children:[l.jsxs("button",{ref:y,type:"button",className:"pp-deployment-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?g:void 0,disabled:s,onClick:()=>{w?C():M()},children:[l.jsx("span",{className:A?void 0:"is-placeholder",children:A??i}),l.jsx(pht,{className:`pp-deployment-select-chevron${w?" is-open":""}`})]}),w&&l.jsxs("div",{className:"pp-deployment-select-menu",children:[N&&l.jsx("div",{className:"pp-deployment-select-search",children:l.jsx("input",{ref:O,type:"search",value:a,"aria-label":`搜索${e}`,placeholder:o,autoComplete:"off",onChange:Q=>f==null?void 0:f(Q.currentTarget.value)})}),l.jsx("div",{id:g,ref:v,className:"pp-deployment-select-options",role:"listbox","aria-label":e,"aria-busy":c||void 0,onScroll:Q=>{if(!u||c||!h)return;const j=Q.currentTarget;j.scrollHeight-j.scrollTop-j.clientHeight<=24&&h()},children:r.map((Q,j)=>{const $=Q.value===t;return l.jsxs("button",{ref:U=>{x.current[j]=U},type:"button",role:"option","aria-selected":$,tabIndex:j===S?0:-1,className:`pp-deployment-select-option${$?" is-selected":""}`,title:Q.description,onFocus:()=>k(j),onClick:()=>P(Q),children:[l.jsxs("span",{className:"pp-deployment-select-copy",children:[l.jsxs("span",{className:"pp-deployment-select-name",children:[Q.label,Q.badge&&l.jsx("span",{className:"pp-deployment-select-badge",children:Q.badge})]}),Q.description&&l.jsx("small",{children:Q.description})]}),$&&l.jsx(mht,{})]},Q.value)})}),c&&l.jsx("div",{className:"pp-deployment-select-state","aria-live":"polite",children:"正在加载更多资源…"}),!c&&r.length===0&&l.jsx("div",{className:"pp-deployment-select-state",children:d})]})]})}const ght=[{value:"auto",label:"自动创建",description:"部署时自动创建所需资源",badge:"推荐"},{value:"create",label:"指定名称",description:"使用指定名称创建或复用资源"},{value:"existing",label:"选择已有",description:"从当前账号的已有资源中选择"}],bht={tos:{mode:"auto"},cr:{mode:"auto"},codePipeline:{mode:"auto"}};function bm(e){const[t,n]=m.useState([]),[i,r]=m.useState(""),[s,a]=m.useState(1),[o,c]=m.useState(0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,g]=m.useState(null),[b,y]=m.useState(""),[O,v]=m.useState(""),[x,w]=m.useState(""),[E,S]=m.useState(0),k=m.useRef(!1),T=m.useRef(null),A=e?JSON.stringify(e):"",N=e?JSON.stringify({...e,search:O}):"";m.useEffect(()=>{const Q=window.setTimeout(()=>{v(b.trim())},250);return()=>window.clearTimeout(Q)},[b]),m.useEffect(()=>{y(""),v("")},[A]);const C=m.useCallback((Q,j)=>{var B;if(!N)return;(B=T.current)==null||B.abort();const $=new AbortController;T.current=$;const U=JSON.parse(N);j&&n([]),k.current=!0,h(!0),g(null),nee({...U,pageNumber:Q,pageSize:100},$.signal).then(I=>{n(X=>{if(j)return I.items;const q=new Set(X.map(D=>`${D.id}\0${D.name}`));return[...X,...I.items.filter(D=>!q.has(`${D.id}\0${D.name}`))]}),r(I.serviceRegion),a(I.pageNumber),c(I.totalCount),d(I.hasMore),w(N)}).catch(I=>{I instanceof DOMException&&I.name==="AbortError"||(w(N),g(I instanceof Error?I.message:String(I)))}).finally(()=>{T.current===$&&(T.current=null,k.current=!1,h(!1))})},[N]);m.useEffect(()=>{var Q;if(!N){(Q=T.current)==null||Q.abort(),T.current=null,k.current=!1,n([]),r(""),a(1),c(0),d(!1),w(""),h(!1),g(null);return}return C(1,!0),()=>{var j;return(j=T.current)==null?void 0:j.abort()}},[C,N,E]);const M=!!N&&x===N&&b.trim()===O,L=m.useCallback(()=>{w(""),S(Q=>Q+1)},[]),P=m.useCallback(()=>{!M||k.current||!u||C(s+1,!1)},[u,C,s,M]);return{items:t,serviceRegion:i,totalCount:o,hasMore:M?u:!1,loading:!!N&&(!M||f),error:p,search:b,setSearch:y,reload:L,loadMore:P}}function Oht(e,t){return e.map(n=>({value:n[t],label:n.name,description:[n.status,n.region,n.id].filter(Boolean).join(" · ")}))}function Om({ariaLabel:e,value:t,valueLabel:n,state:i,disabled:r,valueField:s="id",onChange:a}){const o=m.useMemo(()=>Oht(i.items,s),[i.items,s]);return l.jsxs("div",{className:"pp-resource-picker",children:[l.jsx(JA,{ariaLabel:e,value:t,valueLabel:n,placeholder:i.loading?"正在加载…":"请选择已有资源",options:o,disabled:r||!!i.error,searchValue:i.search,searchPlaceholder:"搜索资源名称",loading:i.loading,hasMore:i.hasMore,emptyMessage:i.search.trim()?"未找到匹配资源":"暂无可用资源",onSearchChange:i.setSearch,onLoadMore:i.loadMore,onChange:c=>{const u=i.items.find(d=>d[s]===c);u&&a(u)}}),i.error?l.jsxs("div",{className:"pp-resource-error",role:"alert",children:[l.jsx("span",{children:i.error}),l.jsx("button",{type:"button",onClick:i.reload,children:"重试"})]}):i.loading&&i.items.length===0?l.jsx("span",{className:"pp-resource-status","aria-live":"polite",children:i.search.trim()?"正在搜索云资源…":"正在加载云资源…"}):i.items.length===0?l.jsx("span",{className:"pp-resource-status",children:i.search.trim()?"未找到匹配资源。":"暂无可用资源。"}):i.serviceRegion?l.jsxs("span",{className:"pp-resource-status",children:["实际服务区域:",i.serviceRegion," · 已加载 ",i.items.length,i.totalCount>0?`/${i.totalCount}`:""]}):null]})}function pR({resource:e,value:t,disabled:n,onChange:i}){return l.jsxs("label",{className:"pp-resource-field pp-resource-mode",children:[l.jsx("span",{children:"配置方式"}),l.jsx(JA,{ariaLabel:`${e}配置方式`,value:t,placeholder:"请选择配置方式",options:ght,disabled:n,onChange:r=>i(r)})]})}function ym({label:e,value:t,placeholder:n,disabled:i,onChange:r}){return l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:e}),l.jsx("input",{value:t,placeholder:n,disabled:i,autoComplete:"off",onChange:s=>r(s.currentTarget.value)})]})}function mR({items:e,note:t}){return l.jsxs("div",{className:"pp-resource-auto-names",children:[l.jsx("span",{children:"自动创建名称"}),l.jsx("dl",{children:e.map(n=>l.jsxs("div",{children:[l.jsx("dt",{children:n.label}),l.jsx("dd",{title:n.name,children:n.name})]},n.label))}),t&&l.jsx("small",{children:t})]})}function yht(e){var t,n,i,r,s,a,o,c;return e.tos.mode!=="auto"&&!((t=e.tos.bucket)!=null&&t.trim())?"请填写或选择 TOS 存储桶。":e.cr.mode!=="auto"&&(!((n=e.cr.instance)!=null&&n.trim())||!((i=e.cr.namespace)!=null&&i.trim())||!((r=e.cr.repository)!=null&&r.trim()))?"请完整填写或选择 CR 实例、命名空间和镜像仓库。":e.codePipeline.mode!=="auto"&&(!((s=e.codePipeline.workspaceName)!=null&&s.trim())||!((a=e.codePipeline.pipelineName)!=null&&a.trim()))?"请完整填写或选择 CodePipeline Workspace 和 Pipeline。":e.codePipeline.mode==="existing"&&(!((o=e.codePipeline.workspaceId)!=null&&o.trim())||!((c=e.codePipeline.pipelineId)!=null&&c.trim()))?"请选择已有的 CodePipeline Workspace 和兼容 Pipeline。":null}function xht({value:e,agentName:t,runtimeName:n,region:i,disabled:r,validationError:s,onChange:a}){const o=t.trim()||"agentkit-app",c=n.trim()||o,u=i&&i!=="cn-beijing"?`agentkit-platform-{账号 ID}-${i.startsWith("cn-")?i.slice(3):i}`:"agentkit-platform-{账号 ID}",d=bm(e.tos.mode==="existing"?{kind:"tos-bucket",region:i}:null),f=bm(e.cr.mode==="existing"?{kind:"cr-registry",region:i}:null),h=bm(e.cr.mode==="existing"&&e.cr.instance?{kind:"cr-namespace",region:i,registry:e.cr.instance}:null),p=bm(e.cr.mode==="existing"&&e.cr.instance&&e.cr.namespace?{kind:"cr-repository",region:i,registry:e.cr.instance,namespace:e.cr.namespace}:null),g=bm(e.codePipeline.mode==="existing"?{kind:"cp-workspace",region:i}:null),b=bm(e.codePipeline.mode==="existing"&&e.codePipeline.workspaceId?{kind:"cp-pipeline",region:i,workspaceId:e.codePipeline.workspaceId}:null),y=O=>a({...e,...O});return l.jsxs("div",{className:"pp-resource-list",children:[l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"TOS 存储桶"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"TOS 存储桶",value:e.tos.mode,disabled:r,onChange:O=>y({tos:{mode:O}})}),e.tos.mode==="create"&&l.jsx(ym,{label:"存储桶名称",value:e.tos.bucket??"",placeholder:"输入存储桶名称",disabled:r,onChange:O=>y({tos:{...e.tos,bucket:O}})}),e.tos.mode==="existing"&&l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"已有存储桶"}),l.jsx(Om,{ariaLabel:"已有 TOS 存储桶",value:e.tos.bucket??"",valueLabel:e.tos.bucket,state:d,disabled:r,onChange:O=>y({tos:{...e.tos,bucket:O.name}})})]}),e.tos.mode==="auto"&&l.jsx(mR,{items:[{label:"存储桶",name:u}],note:"账号 ID 在部署时按当前云账号解析。"})]})]}),l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"容器镜像仓库(CR)"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"CR",value:e.cr.mode,disabled:r,onChange:O=>y({cr:{mode:O}})}),e.cr.mode==="create"&&l.jsxs("div",{className:"pp-resource-fields pp-resource-fields-three",children:[l.jsx(ym,{label:"实例名称",value:e.cr.instance??"",placeholder:"CR 实例",disabled:r,onChange:O=>y({cr:{...e.cr,instance:O}})}),l.jsx(ym,{label:"命名空间",value:e.cr.namespace??"",placeholder:"命名空间",disabled:r,onChange:O=>y({cr:{...e.cr,namespace:O}})}),l.jsx(ym,{label:"镜像仓库",value:e.cr.repository??"",placeholder:"镜像仓库",disabled:r,onChange:O=>y({cr:{...e.cr,repository:O}})})]}),e.cr.mode==="existing"&&l.jsxs("div",{className:"pp-resource-fields pp-resource-fields-three",children:[l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"CR 实例"}),l.jsx(Om,{ariaLabel:"已有 CR 实例",value:e.cr.instance??"",valueLabel:e.cr.instance,state:f,disabled:r,valueField:"name",onChange:O=>y({cr:{mode:"existing",instance:O.name}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"命名空间"}),l.jsx(Om,{ariaLabel:"已有 CR 命名空间",value:e.cr.namespace??"",valueLabel:e.cr.namespace,state:h,disabled:r||!e.cr.instance,valueField:"name",onChange:O=>y({cr:{...e.cr,namespace:O.name,repository:void 0}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"镜像仓库"}),l.jsx(Om,{ariaLabel:"已有 CR 镜像仓库",value:e.cr.repository??"",valueLabel:e.cr.repository,state:p,disabled:r||!e.cr.namespace,valueField:"name",onChange:O=>y({cr:{...e.cr,repository:O.name}})})]})]}),e.cr.mode==="auto"&&l.jsx(mR,{items:[{label:"CR 实例",name:"agentkit-platform-{账号 ID}"},{label:"命名空间",name:"agentkit"},{label:"镜像仓库",name:`${o}-{4 位随机字符}`}],note:"账号 ID 在部署时解析,镜像仓库的随机字符在部署时生成。"})]})]}),l.jsxs("div",{className:"pp-resource-item",children:[l.jsx("div",{className:"pp-resource-name",children:"CodePipeline"}),l.jsxs("div",{className:"pp-resource-grid",children:[l.jsx(pR,{resource:"CodePipeline",value:e.codePipeline.mode,disabled:r,onChange:O=>y({codePipeline:{mode:O}})}),e.codePipeline.mode==="create"&&l.jsxs("div",{className:"pp-resource-fields",children:[l.jsx(ym,{label:"Workspace 名称",value:e.codePipeline.workspaceName??"",placeholder:"Workspace 名称",disabled:r,onChange:O=>y({codePipeline:{...e.codePipeline,workspaceName:O}})}),l.jsx(ym,{label:"Pipeline 名称",value:e.codePipeline.pipelineName??"",placeholder:"Pipeline 名称",disabled:r,onChange:O=>y({codePipeline:{...e.codePipeline,pipelineName:O}})})]}),e.codePipeline.mode==="existing"&&l.jsxs("div",{className:"pp-resource-fields",children:[l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"Workspace"}),l.jsx(Om,{ariaLabel:"已有 CodePipeline Workspace",value:e.codePipeline.workspaceId??"",valueLabel:e.codePipeline.workspaceName,state:g,disabled:r,onChange:O=>y({codePipeline:{mode:"existing",workspaceId:O.id,workspaceName:O.name}})})]}),l.jsxs("label",{className:"pp-resource-field",children:[l.jsx("span",{children:"兼容 Pipeline"}),l.jsx(Om,{ariaLabel:"已有 AgentKit CodePipeline",value:e.codePipeline.pipelineId??"",valueLabel:e.codePipeline.pipelineName,state:b,disabled:r||!e.codePipeline.workspaceId,onChange:O=>y({codePipeline:{...e.codePipeline,pipelineId:O.id,pipelineName:O.name}})})]})]}),e.codePipeline.mode==="auto"&&l.jsx(mR,{items:[{label:"Workspace",name:"agentkit-cli-workspace"},{label:"Pipeline",name:c}],note:"Pipeline 与 Runtime 名称一致。"})]})]}),s&&l.jsx("p",{className:"pp-resource-validation",role:"alert",children:s})]})}const vht=5e4;function wht(e,t){if(!e)return t;if(!t||e.endsWith(t))return e;if(t.startsWith(e))return t;const n=e.split(` `),i=t.split(` `),r=Math.min(n.length,i.length,260);for(let s=r;s>0;s-=1){const a=n.slice(-s).join(` `),o=i.slice(0,s).join(` `);if(a===o){const c=i.slice(s).join(` `);return c?`${e} ${c}`:e}}return`${e} -${t}`}function wht(e,t){if(e.length<=t)return{text:e,omitted:!1};let n=e.slice(-t);const i=n.indexOf(` -`);return i>=0&&(n=n.slice(i+1)),{text:n,omitted:!0}}function TH(e,t,n=xht){const i=vht((e==null?void 0:e.text)??"",t.text??""),r=wht(i,n),s=r.text?r.text.split(` -`).length:0,a=!!(t.snapshotTruncated||t.truncated),o=!!(e!=null&&e.omittedEarly||r.omitted);return{...t,text:r.text,lineCount:s,truncated:!!(e!=null&&e.truncated||t.truncated||o),omittedEarly:o,snapshotTruncated:!!(e!=null&&e.snapshotTruncated||a)}}Fa.registerLanguage("python",Gae);Fa.registerLanguage("typescript",ooe);Fa.registerLanguage("javascript",Fae);Fa.registerLanguage("json",Vae);Fa.registerLanguage("yaml",loe);Fa.registerLanguage("markdown",Yae);Fa.registerLanguage("bash",Dae);Fa.registerLanguage("ini",$ae);Fa.registerLanguage("dockerfile",J7e);Fa.registerLanguage("makefile",Hae);function _H(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}const Sht=m.lazy(()=>$g(()=>Promise.resolve().then(()=>Ehe),void 0)),Dd=()=>{};function Eht({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M2.75 12s3.35-5.25 9.25-5.25S21.25 12 21.25 12 17.9 17.25 12 17.25 2.75 12 2.75 12Z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2.5"})]})}function kht({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M3 3l18 18"}),l.jsx("path",{d:"M9.7 6.95A9.7 9.7 0 0 1 12 6.68c5.9 0 9.25 5.32 9.25 5.32a16 16 0 0 1-2.28 2.85"}),l.jsx("path",{d:"M14.35 14.55A3.25 3.25 0 0 1 9.5 10.2"}),l.jsx("path",{d:"M6.25 8.12A16.4 16.4 0 0 0 2.75 12S6.1 17.32 12 17.32c.8 0 1.55-.1 2.25-.27"})]})}const gR={status:"hidden",apiKeyId:"",value:"",error:""};function Tht({open:e,isUpdate:t,onCancel:n,onConfirm:i}){const r=m.useRef(null);return m.useEffect(()=>{var o;if(!e)return;const s=document.body.style.overflow;document.body.style.overflow="hidden",(o=r.current)==null||o.focus();const a=c=>{c.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>{document.body.style.overflow=s,window.removeEventListener("keydown",a)}},[n,e]),e?zi.createPortal(l.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:s=>{s.target===s.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog pp-confirm-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"pp-confirm-title","aria-describedby":"pp-confirm-description",children:[l.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:l.jsx(pSe,{})}),l.jsx("h2",{id:"pp-confirm-title",children:t?"确认更新":"确认部署"})]}),l.jsx("button",{type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭部署确认",children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"pp-confirm-body",children:l.jsx("p",{id:"pp-confirm-description",children:t?"将更新并发布到当前云端 Runtime,过程可能需要几分钟。确定继续吗?":"将创建新的云端 Runtime,部署过程可能需要几分钟。确定继续吗?"})}),l.jsxs("footer",{className:"pp-confirm-actions",children:[l.jsx("button",{ref:r,type:"button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:i,children:t?"确定更新":"确定部署"})]})]})}),document.body):null}function _ht({value:e,disabled:t,onChange:n}){const[i,r]=m.useState([]),[s,a]=m.useState(!0),[o,c]=m.useState(null),[u,d]=m.useState(0);m.useEffect(()=>{const p=new AbortController;return a(!0),c(null),KD(p.signal).then(g=>r(g)).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||(r([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{p.signal.aborted||a(!1)}),()=>p.abort()},[u]);const f=m.useMemo(()=>[...i].sort((p,g)=>Number(g.isCurrent)-Number(p.isCurrent)).map(p=>({value:p.uid,label:p.name.trim()||"未命名用户池",description:p.domain||p.uid,badge:p.isCurrent?"当前用户池":void 0})),[i]),h=i.find(p=>p.uid===e);return l.jsxs("div",{className:"pp-user-pool-picker",children:[l.jsx(JA,{ariaLabel:"部署用户池",value:e,placeholder:s?"正在加载用户池…":"请选择用户池",options:f,disabled:t||s||!!o,onChange:n}),o?l.jsxs("div",{className:"pp-user-pool-error",role:"alert",children:[l.jsx("span",{children:o}),l.jsx("button",{type:"button",onClick:()=>d(p=>p+1),children:"重试"})]}):s?l.jsxs("span",{className:"pp-user-pool-status","aria-live":"polite",children:[l.jsx(Kn,{"aria-hidden":"true",className:"pp-user-pool-spinner"}),"正在加载 Identity 用户池…"]}):i.length===0?l.jsx("span",{className:"pp-user-pool-status",children:"当前账号下暂无 Identity 用户池。"}):h!=null&&h.isCurrent?l.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime。"}):h?l.jsx("div",{className:"pp-user-pool-error",role:"alert",children:l.jsx("span",{children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime。"})}):l.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 使用的用户池已在列表中标注。"})]})}const Aht=[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],Nht={py:"python",pyi:"python",ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",md:"markdown",markdown:"markdown",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",cfg:"ini",conf:"ini",env:"ini",txt:"plaintext"},AH={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function NH(e){return e.replace(/&/g,"&").replace(//g,">")}function Cht(e){const n=(e.split("/").pop()??e).toLowerCase();if(AH[n])return AH[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const i=n.lastIndexOf(".");if(i===-1)return null;const r=n.slice(i+1);return Nht[r]??null}function jht(e,t){try{const n=Cht(t);return n&&Fa.getLanguage(n)?Fa.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?Fa.highlightAuto(e).value:NH(e)}catch{return NH(e)}}const Rht=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],Iht=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}],Pht={phase:"update",label:"更新实例配置"},Mht={phase:"evaluation",label:"创建评测集"};function Lht(e){return e?!e.memory.shortTerm||(e.shortTermBackend||"local")==="local":!1}function Dht(e,t){const n=Number(e),i=Number(t);return!e.trim()||!t.trim()||!Number.isSafeInteger(n)||!Number.isSafeInteger(i)||n<1||i<1?{valid:!1,error:"实例数必须为大于 0 的整数。"}:n>i?{valid:!1,error:"最小实例数不能大于最大实例数。"}:{valid:!0,min:n,max:i}}function $ht(e){const t={name:"",children:new Map};for(const n of e){const i=n.path.split("/").filter(Boolean);let r=t;i.forEach((s,a)=>{let o=r.children.get(s);o||(o={name:s,children:new Map},r.children.set(s,o)),a===i.length-1&&(o.path=n.path),r=o})}return t}function Qht(e){return[...e.children.values()].sort((t,n)=>{const i=t.children.size>0&&t.path===void 0,r=n.children.size>0&&n.path===void 0;return i!==r?i?-1:1:t.name.localeCompare(n.name)})}function Bht(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function Uht({left:e,right:t}){const[n,i]=m.useState(null);return m.useLayoutEffect(()=>{const r=document.getElementById("veadk-page-header-left"),s=document.getElementById("veadk-page-header-actions");r&&s&&i({left:r,right:s})},[]),n?l.jsxs(l.Fragment,{children:[zi.createPortal(e,n.left),zi.createPortal(t,n.right)]}):l.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function wQ({project:e,embedded:t=!1,deployDisabledReason:n,agentDraft:i,agentName:r,agentCount:s,releaseConfiguration:a,onChange:o,onDeploy:c,onAgentAdded:u,onDeploymentComplete:d,deploymentActionLabel:f="部署",deploymentActionTargetId:h,deploymentRuntimeId:p,deploymentRuntimeName:g,deploymentRuntimeNameCustomized:b=!1,onDeploymentRuntimeNameChange:y,onDeploymentStarted:O,onDeploymentTaskChange:v,feishuEnabled:x=!1,onFeishuEnabledChange:w,deploymentEnv:E=[],requiredSecretEnv:S=[],requiredSecretEnvValues:k,onRequiredSecretEnvChange:T,deploymentEnvValues:A={},onDeploymentEnvChange:N,network:C,onNetworkChange:M,cloudProvider:L="volcengine",deployRegion:P=Qi(L),onDeployRegionChange:Q,deploymentTelemetry:j={source:"unknown",createMode:"unknown",aiAssisted:!1},onBack:$,backLabel:U="返回配置",onExportYaml:B,deploymentPrimaryPane:I,deployDisabled:X=!1}){var dr,ws,ls,te,Me;const q=typeof o=="function",D=!!p,H=Lht(i),re=(r==null?void 0:r.trim())||(i==null?void 0:i.name)||e.name,fe=m.useMemo(()=>Wct(re),[re]),[Ae,J]=m.useState(null),ie=D?g??re:b?g??"":Ae??fe,ue=D?null:pQ(ie),[ye,Se]=m.useState(null),[Re,Ee]=m.useState(!1),me=`${P}\0${ie.trim()}`,oe=m.useRef(me);oe.current=me;const Ne=(ye==null?void 0:ye.key)===me?ye.message:null,Oe=ue??Ne,Ve=((ws=(dr=i==null?void 0:i.deployment)==null?void 0:dr.modelApiKeyId)==null?void 0:ws.trim())??"",[We,De]=m.useState(((te=(ls=e==null?void 0:e.files)==null?void 0:ls[0])==null?void 0:te.path)??null);m.useEffect(()=>{J(null),Se(null)},[re]);const[mt,at]=m.useState(new Set),[Rt,qe]=m.useState(!1),[W,K]=m.useState(""),[ae,pe]=m.useState(!1),[z,ve]=m.useState(!1),[Be,Je]=m.useState(!1),[kt,Mt]=m.useState(!1),[Tt,dt]=m.useState(null),[ge,lt]=m.useState(null),[Ge,vt]=m.useState({}),[_t,Bt]=m.useState(null),[je,Ze]=m.useState(!1),[Ie,Wt]=m.useState([]),[dn,Qt]=m.useState(gR),Yt=m.useRef(null),Jt=m.useRef(Ve);Jt.current=Ve;const[Ft,Ce]=m.useState({}),et=k??Ft,[wt,yn]=m.useState(null),[on,hi]=m.useState(ght),[Pe,st]=m.useState(null),[At,Ut]=m.useState(!1),kn=m.useId(),wn=m.useId(),Ai=m.useId(),Gn=m.useId(),[xn,de]=m.useState("api_key"),[Le,ut]=m.useState(""),gt=v1(L),ln=td(P,L),[Sn,In]=m.useState("1"),[Ni,Pn]=m.useState(H?"1":"5"),[Vt,Ji]=m.useState(!0),fn=L!=="byteplus",pi=fn&&Vt,[ti,vi]=m.useState(null),en=m.useRef(!0),Ci=S.map(ee=>`${ee.key}:${ee.label}`).join("|"),xs=m.useRef(P),ni=Dht(Sn,Ni),Ls=!D&&ni.valid&&(ni.min!==1||ni.max!==5),er=I?Iht:Rht,Ya=Ls?[...er,Pht]:er,mr=pi?[...Ya,Mht]:Ya;function gr(){var ee;(ee=Yt.current)==null||ee.abort(),Yt.current=null,Qt(gR)}async function ul(){var tt;const ee=Jt.current;if(!ee){Qt({status:"error",apiKeyId:"",value:"",error:"请先在模型配置中选择 API Key。"});return}(tt=Yt.current)==null||tt.abort();const _e=new AbortController;Yt.current=_e,Qt({status:"loading",apiKeyId:ee,value:"",error:""});try{const Ct=await EJ(ee,_e.signal);if(_e.signal.aborted||Jt.current!==ee)return;Qt({status:"visible",apiKeyId:ee,value:Ct.value,error:""})}catch(Ct){if(_e.signal.aborted)return;Qt({status:"error",apiKeyId:ee,value:"",error:Ct instanceof Error?Ct.message:"加载 API Key 失败,请重试。"})}finally{Yt.current===_e&&(Yt.current=null)}}m.useEffect(()=>{gr()},[Ve]),m.useEffect(()=>(window.addEventListener("pagehide",gr),()=>{window.removeEventListener("pagehide",gr),gr()}),[]),m.useEffect(()=>{const ee=new Set(S.map(_e=>_e.key));k===void 0&&Ce(_e=>Object.fromEntries(Object.entries(_e).filter(([tt])=>ee.has(tt)))),yn(_e=>_e&&ee.has(_e)?_e:null)},[Ci,k]),m.useEffect(()=>{!Q||D||gt.some(ee=>ee.value===P)||Q(Qi(L))},[L,P,gt,D,Q]),m.useEffect(()=>{if(!h){vi(null);return}vi(document.getElementById(h))},[h]);const Sa=ee=>l.jsxs("div",{className:`pp-network-region${At?" is-open":""}`,onKeyDown:_e=>{_e.key==="Escape"&&Ut(!1)},children:[ee&&l.jsx("span",{children:"发布区域"}),l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":At,"aria-describedby":D?kn:void 0,disabled:ae||D||!Q,onClick:()=>Ut(_e=>!_e),children:[l.jsx("span",{children:ln}),l.jsx(Bwe,{className:`pp-region-chevron${At?" is-open":""}`})]}),At&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>Ut(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:gt.map(_e=>{const tt=_e.value===P;return l.jsxs("button",{type:"button",role:"option","aria-selected":tt,className:`pp-region-option${tt?" is-selected":""}`,onClick:()=>{Q==null||Q(_e.value),Ut(!1)},children:[l.jsx("span",{children:_e.label}),tt&&l.jsx(Hc,{"aria-hidden":"true"})]},_e.value)})})]}),D&&l.jsx("span",{id:kn,className:"pp-region-help",children:"更新时沿用现有 Runtime 的部署区域,无法修改。"})]});m.useEffect(()=>(en.current=!0,()=>{en.current=!1}),[]),m.useEffect(()=>{In("1"),Pn(H?"1":"5")},[H]),m.useEffect(()=>{xs.current!==P&&(xs.current=P,hi(ee=>({tos:ee.tos.mode==="existing"?{mode:"existing"}:ee.tos,cr:ee.cr.mode==="existing"?{mode:"existing"}:ee.cr,codePipeline:ee.codePipeline.mode==="existing"?{mode:"existing"}:ee.codePipeline})),st(null))},[P]),m.useEffect(()=>{if(!Be)return;const ee=document.body.style.overflow;document.body.style.overflow="hidden";const _e=tt=>{tt.key==="Escape"&&Je(!1)};return window.addEventListener("keydown",_e),()=>{document.body.style.overflow=ee,window.removeEventListener("keydown",_e)}},[Be]);const as=m.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:$ht(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return l.jsx("div",{className:"pp-error",children:"项目数据无效"});const Mn=e.files.find(ee=>ee.path===We)??null,vs=(C==null?void 0:C.mode)??"public",Zl=()=>({agentId:String((r==null?void 0:r.trim())||e.name||"unknown"),deployAction:p?"update":"create",deploySource:j.source,createMode:j.createMode,aiAssisted:j.aiAssisted?1:0,deployRegion:String(P),runtimeNetworkType:vs,feishuEnabled:x?1:0}),Gr=new Set(S.map(ee=>ee.key)),tr=Tft(x?[...E,...Zb]:E,A).filter(ee=>!Gr.has(ee.key)),No=tr.length+S.length+Ie.length,Dr=dn.apiKeyId===Ve?dn:gR,os=Dr.status==="visible",na=Ve?Dr.status==="loading"?"正在显示 API Key":os?"隐藏 API Key":Dr.status==="error"?"重试显示 API Key":"显示 API Key":"请先选择 API Key";function Co(ee){at(_e=>{const tt=new Set(_e);return tt.has(ee)?tt.delete(ee):tt.add(ee),tt})}function br(ee,_e){o&&(o({...e,files:ee}),_e!==void 0&&De(_e))}function ia(ee){Mn&&br(e.files.map(_e=>_e.path===Mn.path?{..._e,content:ee}:_e))}function ji(){const ee=W.trim();if(qe(!1),K(""),!!ee){if(e.files.some(_e=>_e.path===ee)){De(ee);return}br([...e.files,{path:ee,content:""}],ee)}}function Kl(){if(!Mn)return;const ee=window.prompt("重命名文件",Mn.path),_e=ee==null?void 0:ee.trim();!_e||_e===Mn.path||e.files.some(tt=>tt.path===_e)||br(e.files.map(tt=>tt.path===Mn.path?{...tt,path:_e}:tt),_e)}function Ke(){var _e;if(!Mn)return;const ee=e.files.filter(tt=>tt.path!==Mn.path);br(ee,((_e=ee[0])==null?void 0:_e.path)??null)}function Ds(ee,_e){Wt(tt=>tt.map(Ct=>Ct.id===ee?{...Ct,..._e}:Ct))}function Ea(ee){Wt(_e=>_e.filter(tt=>tt.id!==ee))}function nu(){Wt(ee=>[...ee,Bht()])}function $s(ee){M&&M(ee==="public"?void 0:{...C??{mode:ee},mode:ee})}function Jl(ee){M==null||M({...C??{mode:"private"},...ee})}function ec(){var Ct,He,ht,Pt;const ee=new Map(Ie.map(jt=>({key:jt.key.trim(),value:jt.value})).filter(jt=>jt.key.length>0).map(jt=>[jt.key,jt.value])),_e=x?[...E,...Zb]:E;for(const jt of upe(_e,A))ee.set(jt.key,jt.value);for(const jt of S){const bn=et[jt.key]??"";bn.trim()&&ee.set(jt.key,bn)}const tt=jt=>jt.agentType==="llm"&&Ob(jt,L)==="ark"||jt.subAgents.some(tt);if(i&&tt(i)){const jt=(He=(Ct=i.deployment)==null?void 0:Ct.modelApiKeyId)==null?void 0:He.trim(),bn=(Pt=(ht=i.deployment)==null?void 0:ht.modelApiKeyName)==null?void 0:Pt.trim();jt&&ee.set("MODEL_AGENT_API_KEY_ID",jt),bn&&ee.set("MODEL_AGENT_API_KEY_NAME",bn)}return[...ee].map(([jt,bn])=>({key:jt,value:bn}))}async function le(){if(!(!w||ae||kt)){dt(null),Mt(!0);try{await w(!x)}catch(ee){en.current&&dt(`更新飞书配置失败:${ee instanceof Error?ee.message:String(ee)}`)}finally{en.current&&Mt(!1)}}}async function gn(){var Ct;if(!c||ae||Re||X)return;if(Oe){dt(Oe);return}if(!D){const He=Oht(on);if(He){st(He),dt(He);return}}if(st(null),!ni.valid){dt(ni.error);return}if(!D&&xn==="user_pool"&&!Le){dt("请选择用于 Runtime 鉴权的用户池。");return}if(vs!=="public"&&!((Ct=C==null?void 0:C.vpcId)!=null&&Ct.trim())){dt("使用 VPC 网络时,请填写 VPC ID。");return}const ee=S.find(He=>!(et[He.key]??"").trim());if(ee){yn(ee.key),dt(`请填写 ${ee.label},用于访问对应的自定义模型地址。`);return}yn(null);const _e=vH(E,A);if(_e){const He=E.find(ht=>ht.key===_e.key);dt(`请返回配置页填写 ${(He==null?void 0:He.comment)||(He==null?void 0:He.key)}(${He==null?void 0:He.key})。`);return}const tt=dpe(E,A);if(tt){dt(`${tt.spec.comment||tt.spec.key}:${tt.error}`);return}if(x){const He=vH(Zb,A);if(He){const ht=Zb.find(Pt=>Pt.key===He.key);dt(`启用飞书后,请填写${(ht==null?void 0:ht.comment)||(ht==null?void 0:ht.key)}。`);return}}if(!D){const He=ie.trim(),ht=`${P}\0${He}`;Ee(!0),dt(null);try{const Pt=await eee(He,P);if(!en.current||oe.current!==ht)return;if(!Pt.available){const jt="Runtime 名称已存在,请修改后重试。";Se({key:ht,message:jt}),dt(jt);return}Se(null)}catch(Pt){if(!en.current)return;dt(Pt instanceof Error?Pt.message:String(Pt));return}finally{en.current&&Ee(!1)}}ve(!0)}async function Wn(){var qi;if(!c||ae)return;if(Oe){ve(!1),dt(Oe);return}if(!ni.valid){ve(!1),dt(ni.error);return}ve(!1);const ee=ec();en.current&&(dt(null),lt(null),vt({}),Bt(null),pe(!0));const _e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tt=(r==null?void 0:r.trim())||(i==null?void 0:i.name)||e.name,Ct=ie.trim();let He=Ct;const ht=Date.now(),Pt=epe(Zl()),jt={id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"running",phase:"prepare",label:"准备部署",agentDraft:i,instanceRange:Ls?{min:ni.min,max:ni.max}:void 0,createEvaluationSets:pi};v==null||v(jt),O==null||O(jt);let bn,Xi=jt.phase??"prepare";const Ss=Xe=>bn?{...bn,status:Xe,updatedAt:Date.now()}:void 0,Dn=Xe=>{const _n=Ss(Xe);return _n?{buildLog:_n}:{}},Wr=()=>({source:"code-pipeline",status:"running",text:"",lineCount:0,truncated:!1,updatedAt:Date.now(),pendingMessage:"正在等待构建日志…"}),sa=Xe=>{if(Xi!=="build")return;const _n=["","----- 构建失败 -----",Xe].join(` -`);return bn=TH(bn,{source:"code-pipeline",status:"error",text:_n,lineCount:_n.split(` -`).length,truncated:!1,updatedAt:Date.now()}),bn};try{const Xe=await c(e,_n=>{var dl;_n.runtimeName&&(He=_n.runtimeName),Xi=_n.phase,_n.buildLog?bn=TH(bn,_n.buildLog):_n.phase==="build"&&!bn&&(bn=Wr()),en.current&&(vt(fl=>({...fl,[_n.phase]:_n})),Bt(_n.phase)),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"running",phase:_n.phase,label:((dl=mr.find(fl=>fl.phase===_n.phase))==null?void 0:dl.label)??_n.phase,message:_n.message,pct:_n.pct,...bn?{buildLog:bn}:{}})},{taskId:_e,runtimeName:Ct,sessionStorage:H?"in-memory":"persistent",minInstance:ni.min,maxInstance:ni.max,...D?{}:{authentication:xn==="user_pool"?{type:"user_pool",userPoolUid:Le}:{type:"api_key"}},createEvaluationSets:pi,...x?{im:{feishu:{enabled:!0}}}:{},envs:ee,...D?{}:{resources:on}});en.current&&(lt(Xe),Bt(null)),Pt.succeed({runtimeId:String(Xe.runtimeId||p||"")}),v==null||v({id:_e,agentName:Xe.agentName||tt,runtimeName:Xe.runtimeName||He,runtimeId:Xe.runtimeId||p,region:Xe.region||P,startedAt:ht,status:"success",phase:"complete",label:"部署完成",message:(qi=Xe.warnings)==null?void 0:qi.join(";"),...Dn("complete")});try{await(d==null?void 0:d(Xe))}catch(_n){if(!(_n instanceof ga))throw _n;v==null||v({id:_e,agentName:Xe.agentName||tt,runtimeName:Xe.runtimeName||He,runtimeId:Xe.runtimeId||p,region:Xe.region||P,startedAt:ht,status:"success",phase:"complete",label:"部署完成,暂未连接",message:_n.message,...Dn("complete")})}}catch(Xe){const _n=Xe instanceof Error?Xe.message:String(Xe);if(Xe instanceof DOMException&&Xe.name==="AbortError"){Pt.fail({failedPhase:_H(Xi),...Ra(Xe,{phase:Xi})}),en.current&&(dt(null),Bt(null)),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。",...Dn("complete")});return}en.current&&dt(_n);const dl=sa(_n);Pt.fail({failedPhase:_H(Xi),...Ra(Xe,{phase:Xi})}),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"error",phase:Xi,label:"部署失败",message:_n,...dl?{buildLog:dl}:Dn("complete"),retry:gn})}finally{en.current&&pe(!1)}}function Vi(){ve(!1)}async function Ln(){if(!(!ge||je)){Ze(!0),dt(null);try{const{addConnection:ee,addRuntimeConnection:_e,remoteAppId:tt,loadConnections:Ct}=await $g(async()=>{const{addConnection:Pt,addRuntimeConnection:jt,remoteAppId:bn,loadConnections:Xi}=await Promise.resolve().then(()=>Rq);return{addConnection:Pt,addRuntimeConnection:jt,remoteAppId:bn,loadConnections:Xi}},void 0),{probeRuntimeApps:He}=await $g(async()=>{const{probeRuntimeApps:Pt}=await Promise.resolve().then(()=>OEe);return{probeRuntimeApps:Pt}},void 0);let ht;if(ge.runtimeId){const Pt=ge.region??P,jt=await He(ge.runtimeId,Pt,{retryProbe:!0})??[];ht=_e(ge.runtimeId,ge.runtimeName,Pt,jt,jt.length>0?{[jt[0]]:ge.agentName}:void 0,ge.version)}else ht=await ee(ge.agentName,ge.url,ge.apikey,"");if(ht.apps.length===0)dt("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const Pt={[ht.apps[0]]:ge.agentName},jt={...ht,appLabels:{...ht.appLabels??{},...Pt}},Xi=Ct().map(Dn=>Dn.id===ht.id?jt:Dn);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(Xi));const{registerConnections:Ss}=await $g(async()=>{const{registerConnections:Dn}=await Promise.resolve().then(()=>Rq);return{registerConnections:Dn}},void 0);if(Ss(Xi),u){const Dn=tt(ht.id,ht.apps[0]);u(Dn,ge.agentName)}else alert(`🎉 Agent "${ge.agentName}" 已添加到左上角下拉列表!`)}}catch(ee){dt(`添加 Agent 失败:${ee instanceof Error?ee.message:String(ee)}`)}finally{Ze(!1)}}}function Tn(){const ee=Zl(),_e=$ut({agentId:ee.agentId,deployAction:ee.deployAction,deploySource:ee.deploySource,createMode:ee.createMode,aiAssisted:ee.aiAssisted});try{const tt=lht(e.files),Ct=URL.createObjectURL(tt),He=document.createElement("a");He.href=Ct,He.download=`${e.name||"project"}.zip`,document.body.appendChild(He),He.click(),document.body.removeChild(He),URL.revokeObjectURL(Ct),_e.succeed({fileCount:e.files.length,zipSizeBytes:tt.size})}catch(tt){throw _e.fail({fileCount:e.files.length,...Ra(tt)}),tt}}const ra=l.jsxs("div",{className:`pp-artifact-actions${t?" is-rail":""}`,"aria-label":"发布产物操作",children:[B&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:B,children:[l.jsx(qwe,{className:"pp-ic"}),"导出 YAML"]}),q&&o&&l.jsx(fht,{project:e,onChange:o,className:"pp-artifact-source",label:"查看源代码"}),e.files.length>0&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:Tn,children:[l.jsx(b_,{className:"pp-ic"}),"下载源代码"]})]});function Qs(ee,_e,tt){return Qht(ee).map(Ct=>{const He=tt?`${tt}/${Ct.name}`:Ct.name,ht=Ct.path!==void 0,Pt={paddingLeft:8+_e*14};if(ht){const bn=Ct.path===We;return l.jsxs("button",{type:"button",className:`pp-row pp-file${bn?" pp-active":""}`,style:Pt,onClick:()=>De(Ct.path),title:Ct.path,children:[l.jsx(Gwe,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:Ct.name})]},He)}const jt=mt.has(He);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"pp-row pp-folder",style:Pt,onClick:()=>Co(He),children:[l.jsx(U0,{className:`pp-ic pp-chevron${jt?"":" pp-open"}`}),l.jsx(fJ,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:Ct.name})]}),!jt&&Qs(Ct,_e+1,He)]},He)})}return l.jsxs("div",{className:`pp-root${c?" is-deploy":""}${t?" is-embedded":""}${I?" has-primary-pane":""}`,children:[c&&!t&&l.jsx(Uht,{left:l.jsxs("div",{className:"pp-toolbar-left",children:[$&&l.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:$,children:[l.jsx(aJ,{className:"pp-ic"}),U]}),l.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",r||e.name||"未命名 Agent",s&&s>1?` 等 ${s} 个智能体`:""]})]}),right:null}),l.jsxs("div",{className:"pp-body",children:[c&&!I&&l.jsx("section",{className:"pp-release-overview","aria-label":"发布概览",children:l.jsxs("div",{className:`pp-release-preview${t?" is-embedded":""}`,children:[l.jsxs("div",{className:"pp-flow-thumbnail",children:[i&&l.jsx(px,{draft:i,direction:"horizontal",selectedPath:[],onSelect:Dd,onAdd:Dd,onInsert:Dd,onDelete:Dd,readOnly:!0,interactivePreview:!0}),l.jsx("button",{type:"button",className:"pp-flow-expand",onClick:()=>Je(!0),"aria-label":"放大查看执行流程",title:"放大查看",children:l.jsx(np,{"aria-hidden":!0})})]}),t&&ra,!t&&l.jsxs("div",{className:"pp-release-info",children:[l.jsx("div",{className:"pp-release-card-head",children:"Agent 概览"}),l.jsxs("div",{className:"pp-release-info-body",children:[l.jsxs("div",{className:"pp-release-info-main",children:[l.jsx("h2",{children:r||e.name||"未命名 Agent"}),(i==null?void 0:i.description)&&l.jsx("p",{className:"pp-release-description",title:i.description,children:i.description}),l.jsxs("dl",{className:"pp-release-facts",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Agent 数量"}),l.jsx("dd",{children:s??1})]}),a&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:a.modelName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"描述"}),l.jsx("dd",{className:"pp-release-fact-long",children:a.description})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"系统提示词"}),l.jsx("dd",{className:"pp-release-fact-long pp-release-prompt",children:a.instruction})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"优化选项"}),l.jsx("dd",{children:a.optimizations.length>0?a.optimizations.join("、"):"未启用"})]})]})]})]}),ra]})]})]})}),l.jsxs("div",{className:"pp-files-area",children:[l.jsxs("div",{className:"pp-sidebar",children:[l.jsxs("div",{className:"pp-sidebar-head",children:[l.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),q&&l.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{qe(!0),K("")},children:l.jsx(Hwe,{className:"pp-ic"})})]}),l.jsxs("div",{className:"pp-tree",children:[Rt&&l.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:W,onChange:ee=>K(ee.target.value),onBlur:ji,onKeyDown:ee=>{ee.key==="Enter"&&ji(),ee.key==="Escape"&&(qe(!1),K(""))}}),e.files.length===0&&!Rt?l.jsx("div",{className:"pp-empty",children:"暂无文件"}):Qs(as,0,"")]})]}),l.jsxs("div",{className:"pp-main",children:[l.jsxs("div",{className:"pp-main-head",children:[l.jsx("span",{className:"pp-path",title:Mn==null?void 0:Mn.path,children:(Mn==null?void 0:Mn.path)??"未选择文件"}),l.jsx("div",{className:"pp-actions",children:q&&Mn&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Kl,children:l.jsx(oSe,{className:"pp-ic"})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Ke,children:l.jsx(If,{className:"pp-ic"})})]})})]}),l.jsx("div",{className:"pp-content",children:Mn==null?l.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):q?l.jsx("div",{className:"pp-codemirror",children:l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:l.jsx(Sht,{value:Mn.content,path:Mn.path,onChange:ia})})}):l.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:jht(Mn.content,Mn.path)}})})]})]}),c&&l.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[l.jsx("div",{className:"pp-config-head",children:l.jsx("div",{className:"pp-config-title",children:"部署配置"})}),l.jsxs("div",{className:"pp-config-scroll",children:[I,!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("label",{className:"pp-config-label",htmlFor:wn,children:"Runtime 名称"}),l.jsxs("div",{className:"pp-runtime-name-field",children:[l.jsx("input",{id:wn,className:"pp-runtime-name-input",value:ie,disabled:ae||Re||D,maxLength:64,autoComplete:"off","aria-label":"Runtime 名称","aria-invalid":!!Oe,"aria-describedby":`${Ai}${Oe?` ${Gn}`:""}`,onChange:ee=>{const _e=ee.currentTarget.value;Se(null),dt(null),y?y(_e):J(_e)}}),l.jsx("p",{id:Ai,className:"pp-config-note",children:D?"更新时保持现有 Runtime 名称不变。":"默认根据 Root Agent 名称生成,并添加随机后缀避免重名;支持 4-64 位字母、数字、连字符和下划线"}),Oe&&l.jsx("p",{id:Gn,className:"pp-runtime-name-error",role:"alert",children:Oe})]})]}),!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"发布区域"}),Sa(!1)]}),!I&&l.jsxs("section",{className:"pp-config-section pp-auth-section",children:[l.jsx("div",{className:"pp-config-label",children:"访问鉴权"}),D?l.jsx("p",{className:"pp-config-note pp-auth-preserved-note",children:"更新时保持现有 Runtime 的鉴权方式不变。"}):l.jsxs("div",{className:"pp-auth-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"鉴权方式"}),l.jsx(JA,{ariaLabel:"部署鉴权方式",value:xn,placeholder:"请选择鉴权方式",options:Aht,disabled:ae,onChange:ee=>{dt(null),de(ee)}})]}),xn==="user_pool"&&l.jsxs("label",{children:[l.jsx("span",{children:"用户池"}),l.jsx(_ht,{value:Le,disabled:ae,onChange:ee=>{dt(null),ut(ee)}})]})]})]}),!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"消息渠道"}),l.jsx("div",{className:`pp-channel-card${x?" is-flipped":""}`,children:l.jsxs("div",{className:"pp-channel-card-inner",children:[l.jsxs("button",{type:"button",className:"pp-channel-card-face pp-channel-card-front","aria-pressed":x,"aria-hidden":x,tabIndex:x?-1:0,onClick:()=>void le(),disabled:x||ae||Re||kt||!w,children:[l.jsx("span",{className:"pp-channel-logo",children:l.jsx("img",{src:mQ,alt:""})}),l.jsxs("span",{className:"pp-channel-card-copy",children:[l.jsx("strong",{children:"飞书"}),l.jsx("small",{children:kt?"正在启用并更新配置…":"接收消息并通过飞书机器人回复"})]})]}),l.jsxs("div",{className:"pp-channel-card-face pp-channel-card-back","aria-hidden":!x,children:[l.jsxs("div",{className:"pp-channel-card-head",children:[l.jsx("strong",{children:"飞书配置"}),l.jsx("button",{type:"button",className:"pp-channel-remove",tabIndex:x?0:-1,onClick:()=>void le(),disabled:!x||ae||kt||!w,children:kt?"取消中…":"取消"})]}),l.jsx("div",{className:"pp-channel-fields",children:Zb.map(ee=>l.jsxs("label",{children:[l.jsxs("span",{children:[ee.comment||ee.key,ee.required&&l.jsx("small",{children:"必填"})]}),l.jsx("input",{type:ee.key.includes("SECRET")?"password":"text",value:A[ee.key]??"",placeholder:ee.placeholder,tabIndex:x?0:-1,disabled:!x||ae||!N,autoComplete:"off",onChange:_e=>N==null?void 0:N(ee.key,_e.currentTarget.value)})]},ee.key))})]})]})})]}),!D&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"实例设置"}),l.jsxs("div",{className:"pp-instance-fields",children:[l.jsxs("label",{htmlFor:"runtime-min-instance",children:[l.jsx("span",{children:"最小实例数"}),l.jsx("input",{id:"runtime-min-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Sn,disabled:ae,"aria-invalid":!ni.valid,onChange:ee=>In(ee.currentTarget.value)})]}),l.jsxs("label",{htmlFor:"runtime-max-instance",children:[l.jsx("span",{children:"最大实例数"}),l.jsx("input",{id:"runtime-max-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Ni,disabled:ae,"aria-invalid":!ni.valid,onChange:ee=>Pn(ee.currentTarget.value)})]})]}),H&&l.jsx("p",{className:"pp-instance-note",role:"note",children:"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}),!ni.valid&&l.jsx("p",{className:"pp-instance-error",role:"alert",children:ni.error})]}),l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"网络"}),I&&Sa(!0),D&&l.jsx("p",{className:"pp-config-note",children:"现有 Runtime 的区域与网络模式保持不变。"}),l.jsxs("div",{className:"pp-network-layout",children:[l.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(ee=>l.jsxs("label",{className:"pp-network-option",children:[l.jsx("input",{type:"radio",name:"deployment-network-mode",value:ee,checked:vs===ee,onChange:()=>$s(ee),disabled:ae||D||!M}),l.jsx("span",{children:ee==="public"?"公网":ee==="private"?"VPC":"公网 + VPC"})]},ee))}),vs!=="public"&&l.jsxs("div",{className:"pp-network-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"VPC ID"}),l.jsx("input",{value:(C==null?void 0:C.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:ae||D,onChange:ee=>Jl({vpcId:ee.target.value})})]}),l.jsxs("label",{children:[l.jsxs("span",{children:["子网 ID ",l.jsx("small",{children:"可选,多个用逗号分隔"})]}),l.jsx("input",{value:(C==null?void 0:C.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:ae||D,onChange:ee=>Jl({subnetIds:ee.target.value})})]}),l.jsxs("label",{className:"pp-network-check",children:[l.jsx("input",{type:"checkbox",checked:!!(C!=null&&C.enableSharedInternetAccess),disabled:ae||D,onChange:ee=>Jl({enableSharedInternetAccess:ee.target.checked})}),"VPC 内共享公网出口"]})]})]})]}),fn&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"评测集"}),l.jsxs("label",{className:"pp-evaluation-set-option",children:[l.jsx("input",{type:"checkbox",checked:Vt,disabled:ae,onChange:ee=>Ji(ee.currentTarget.checked)}),l.jsxs("span",{children:[l.jsx("strong",{children:"自动创建评测集"}),l.jsx("small",{children:"部署成功后,自动创建 Good Case 和 Bad Case 评测集。"})]})]})]}),!D&&l.jsxs("section",{className:"pp-config-section pp-resource-section",children:[l.jsx("div",{className:"pp-config-label",children:"资源配置"}),l.jsx(yht,{value:on,agentName:r||e.name||"agentkit-app",runtimeName:ie,region:P,disabled:ae,validationError:Pe,onChange:ee=>{hi(ee),st(null)}})]}),l.jsxs("section",{className:"pp-config-section pp-env-section",children:[l.jsx("div",{className:"pp-env-head",children:l.jsxs("div",{children:[l.jsxs("div",{className:"pp-config-label",children:["环境变量",l.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[No," 项"]})]}),l.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]})}),l.jsxs("button",{type:"button",className:"pp-env-add",onClick:nu,disabled:ae,children:[l.jsx(Gs,{className:"pp-ic"}),"添加变量"]}),(tr.length>0||S.length>0||Ie.length>0)&&l.jsxs("div",{className:"pp-env-table",children:[tr.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"组件自动生成"}),l.jsxs("small",{children:[tr.length," 项"]})]}),tr.map(ee=>{const _e=ee.readOnly||ee.key.startsWith("ENABLE_"),tt=ee.serverManaged&&ee.key==="MODEL_AGENT_API_KEY",Ct=tt?os?Dr.value:"由所选 API Key 注入":ee.value,He=xQ(ee,A),ht=ee.multiline||ee.format==="json";return l.jsxs("div",{className:`pp-env-row pp-env-row-derived${ht?" is-multiline":""}`,children:[l.jsxs("div",{className:"pp-env-key-fixed pp-env-key-cell","aria-label":`${ee.key} 环境变量名`,"aria-disabled":ae,children:[l.jsx("span",{title:ee.key,children:ee.key}),(ee.help||ee.comment)&&l.jsxs("span",{className:"pp-env-help",tabIndex:0,"data-help":ee.help||ee.comment,"aria-label":`${ee.key}说明:${ee.help||ee.comment}`,children:["?",l.jsx("span",{className:"pp-env-help-popover",role:"tooltip",children:ee.help||ee.comment})]}),ee.link&&l.jsx("a",{className:"pp-env-link",href:ee.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${ee.link.label}`,"aria-label":`${ee.key}:打开 OpenViking ${ee.link.label}`,children:l.jsx(e0,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"pp-env-value-wrap",children:[ht?l.jsx("textarea",{className:"pp-env-value pp-env-json-value",value:ee.value,placeholder:ee.required?"必填,尚未填写":"可选,尚未填写",readOnly:_e,disabled:ae||!_e&&!N,autoComplete:"off",spellCheck:!1,"aria-invalid":!!He,"aria-label":`${ee.key} 环境变量值`,onChange:Pt=>N==null?void 0:N(ee.key,Pt.currentTarget.value)}):l.jsxs("div",{className:tt?"pp-env-secret-control":void 0,children:[l.jsx("input",{className:"pp-env-value",type:tt?"text":ee.secret?"password":"text",value:Ct,placeholder:ee.required?"必填,尚未填写":"可选,尚未填写",readOnly:_e,disabled:ae||!_e&&!N,autoComplete:ee.secret?"new-password":"off",spellCheck:ee.secret?!1:void 0,"aria-invalid":!!He,"aria-label":`${ee.key} 环境变量值`,onChange:Pt=>N==null?void 0:N(ee.key,Pt.currentTarget.value)}),tt&&l.jsx("button",{type:"button",className:"pp-env-secret-toggle","aria-label":na,title:na,"aria-pressed":os,disabled:Dr.status==="loading"||!Ve,onClick:()=>{os?gr():ul()},children:Dr.status==="loading"?l.jsx(Kn,{className:"pp-env-secret-spinner","aria-hidden":"true"}):os?l.jsx(kht,{}):l.jsx(Eht,{})})]}),He&&l.jsx("span",{className:"pp-env-error",children:He}),tt&&Dr.status==="error"&&l.jsx("span",{className:"pp-env-reveal-error",role:"alert",children:Dr.error})]}),l.jsx("span",{className:"pp-env-source",children:_e?"自动":"同步"})]},ee.key)})]}),S.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"自定义模型凭据"}),l.jsxs("small",{children:[S.length," 项"]})]}),S.map(ee=>{const _e=wt===ee.key,tt=`${ee.key.toLowerCase()}-error`;return l.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[l.jsx("label",{className:"pp-env-key-fixed pp-env-key-cell",htmlFor:ee.key,title:ee.label,children:l.jsx("span",{children:ee.key})}),l.jsxs("div",{className:"pp-env-value-wrap",children:[l.jsx("input",{id:ee.key,className:"pp-env-value",type:"password",value:et[ee.key]??"",placeholder:"必填,仅用于本次发布",disabled:ae,autoComplete:"new-password",spellCheck:!1,"aria-invalid":_e,"aria-describedby":_e?tt:void 0,"aria-label":ee.label,onChange:Ct=>{const He=Ct.currentTarget.value;T?T(ee.key,He):Ce(ht=>({...ht,[ee.key]:He})),_e&&He.trim()&&(yn(null),dt(null))}}),_e&&l.jsx("span",{id:tt,className:"pp-env-error",role:"alert",children:"请填写此模型地址对应的 API Key。"})]}),l.jsx("span",{className:"pp-env-source",children:"本次发布"})]},ee.key)})]}),Ie.length>0&&l.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[l.jsx("span",{children:"自定义变量"}),l.jsxs("small",{children:[Ie.length," 项"]})]}),Ie.map(ee=>l.jsxs("div",{className:"pp-env-row",children:[l.jsx("input",{value:ee.key,placeholder:"名称",disabled:ae,autoComplete:"off",onChange:_e=>Ds(ee.id,{key:_e.currentTarget.value})}),l.jsx("input",{type:"text",value:ee.value,placeholder:"值",disabled:ae,autoComplete:"off",onChange:_e=>Ds(ee.id,{value:_e.currentTarget.value})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:ae,onClick:()=>Ea(ee.id),children:l.jsx(xa,{className:"pp-ic"})})]},ee.id))]})]}),(ae||ge||Object.keys(Ge).length>0)&&l.jsxs("section",{className:"pp-config-section pp-progress-section",children:[l.jsx("div",{className:"pp-config-label",children:"部署进度"}),l.jsx("ol",{className:"pp-steps",children:mr.map((ee,_e)=>{const tt=_t?mr.findIndex(Pt=>Pt.phase===_t):-1,Ct=!!Tt&&(tt===-1?_e===0:_e===tt);let He;ge?He="done":Ct?He="failed":tt===-1?He=ae?"active":"pending":_eee.phase===_t))==null?void 0:Me.label)??_t}阶段):`:""}${Tt}`,onRetry:gn,retryLabel:D?"重试更新":"重试部署"}),ge&&l.jsxs("section",{className:"pp-deploy-result",children:[l.jsx("div",{className:"pp-deploy-result-header",children:D?"更新成功":"部署成功"}),l.jsxs("div",{className:"pp-deploy-result-body",children:[ge.warnings&&ge.warnings.length>0&&l.jsx("div",{className:"pp-deploy-result-warning",role:"status",children:ge.warnings.map(ee=>l.jsx("span",{children:ee},ee))}),ge.region&&l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"区域"}),l.jsx("code",{children:td(ge.region,L)})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Agent 名称"}),l.jsx("code",{children:ge.agentName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Runtime 名称"}),l.jsx("code",{children:ge.runtimeName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"API 端点"}),l.jsx("code",{className:"pp-deploy-result-url",children:ge.url})]})]}),l.jsxs("div",{className:"pp-deploy-result-actions",children:[l.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Ln,disabled:je,children:[je?l.jsx(Kn,{className:"pp-ic spin"}):l.jsx(pJ,{className:"pp-ic"}),je?"连接中…":"立即对话"]}),ge.consoleUrl&&l.jsxs("a",{href:ge.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[l.jsx(e0,{className:"pp-ic"}),"控制台"]})]})]})]}),l.jsx("div",{className:`pp-config-actions${ti?" is-external":""}`,children:ti?zi.createPortal(l.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:gn,disabled:ae||Re||kt||X||!!n||!!Oe,title:n||Oe||void 0,children:ae?`${f}中…`:Re?"正在检查名称…":Tt?`重试${f}`:f}),ti):l.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:gn,disabled:ae||Re||kt||X||!!n||!!Oe,title:n||Oe||void 0,children:ae?`${f}中…`:Re?"正在检查名称…":Tt?`重试${f}`:f})})]})]}),Be&&i&&zi.createPortal(l.jsx("div",{className:"pp-flow-backdrop",onMouseDown:ee=>{ee.target===ee.currentTarget&&Je(!1)},children:l.jsxs("section",{className:"pp-flow-dialog",role:"dialog","aria-modal":"true","aria-label":"执行流程预览",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"执行流程"}),l.jsx("span",{children:"只读预览,可缩放与拖动画布"})]}),l.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":"关闭执行流程预览",children:l.jsx(xa,{"aria-hidden":!0})})]}),l.jsx("div",{className:"pp-flow-dialog-canvas",children:l.jsx(px,{draft:i,direction:"horizontal",selectedPath:[],onSelect:Dd,onAdd:Dd,onInsert:Dd,onDelete:Dd,readOnly:!0,interactivePreview:!0})})]})}),document.body),l.jsx(Tht,{open:z,isUpdate:D,onCancel:Vi,onConfirm:()=>void Wn()})]})}const CH=["#6366f1","#0ea5e9","#10b981","#f59e0b","#f43f5e","#a855f7","#14b8a6","#f472b6"];function bR(e){let t=0;for(let n=0;n>>0;return CH[t%CH.length]}function zht(e){const t=new Map;e.forEach(u=>t.set(u.span_id,u));const n=new Map,i=[];for(const u of e)u.parent_span_id!=null&&t.has(u.parent_span_id)?(n.get(u.parent_span_id)??n.set(u.parent_span_id,[]).get(u.parent_span_id)).push(u):i.push(u);const r=(u,d)=>u.start_time-d.start_time,s=(u,d)=>({span:u,depth:d,children:(n.get(u.span_id)??[]).sort(r).map(f=>s(f,d+1))}),a=i.sort(r).map(u=>s(u,0)),o=e.length?Math.min(...e.map(u=>u.start_time)):0,c=e.length?Math.max(...e.map(u=>u.end_time)):1;return{rootNodes:a,min:o,total:c-o||1}}function Fht(e,t){const n=[],i=r=>{n.push(r),t.has(r.span.span_id)||r.children.forEach(i)};return e.forEach(i),n}function jH(e){const t=e/1e6;return t>=1e3?`${(t/1e3).toFixed(2)} s`:`${t.toFixed(t<10?2:1)} ms`}const Vht=e=>e.replace(/^(gen_ai|a2ui|adk)\./,"");function RH(e){return Object.entries(e.attributes).filter(([,t])=>t!=null&&typeof t!="object").map(([t,n])=>{const i=String(n);return{key:Vht(t),value:i,long:i.length>80||i.includes(` -`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function Bpe({appName:e,testRunId:t,sessionId:n,endTimeMs:i,onClose:r,title:s="调用链路观测"}){const[a,o]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(new Set),[h,p]=m.useState(null);m.useEffect(()=>{o(null),u("");let E;if(t)E=yee(t,n);else if(e)E=bk(e,n,i);else{u("缺少调用链路来源");return}E.then(S=>{o(S),p(S.length?S.reduce((k,T)=>k.start_time<=T.start_time?k:T).span_id:null)}).catch(S=>u(S instanceof Error?S.message:String(S)))},[e,i,n,t]);const{rootNodes:g,min:b,total:y}=m.useMemo(()=>zht(a??[]),[a]),O=m.useMemo(()=>Fht(g,d),[g,d]),v=(a==null?void 0:a.find(E=>E.span_id===h))??null,x=y/1e6,w=E=>f(S=>{const k=new Set(S);return k.has(E)?k.delete(E):k.add(E),k});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim",onClick:r}),l.jsxs("aside",{className:"drawer drawer--trace",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"drawer-title",children:s}),l.jsx("div",{className:"drawer-sub",children:a?`${a.length} 个调用 · ${x.toFixed(1)} ms`:"加载中"})]}),l.jsx("button",{className:"drawer-close",onClick:r,"aria-label":"关闭",children:l.jsx(xa,{className:"icon"})})]}),a==null&&!c&&l.jsxs("div",{className:"drawer-loading",children:[l.jsx(Kn,{className:"icon spin"})," 加载调用链路…"]}),c&&l.jsx("div",{className:"error",children:c}),a&&a.length===0&&l.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),O.length>0&&l.jsxs("div",{className:"trace-split",children:[l.jsx("div",{className:"trace-tree scroll",children:O.map(E=>{const S=E.span,k=(S.start_time-b)/y*100,T=Math.max((S.end_time-S.start_time)/y*100,.6),A=E.children.length>0;return l.jsxs("button",{className:`trace-row ${h===S.span_id?"active":""}`,onClick:()=>p(S.span_id),children:[l.jsxs("span",{className:"trace-label",style:{paddingLeft:E.depth*14},children:[l.jsx("span",{className:`trace-caret ${A?"":"hidden"} ${d.has(S.span_id)?"":"open"}`,onClick:N=>{N.stopPropagation(),A&&w(S.span_id)},children:l.jsx(U0,{className:"chev"})}),l.jsx("span",{className:"trace-dot",style:{background:bR(S.name)}}),l.jsx("span",{className:"trace-name",title:S.name,children:S.name})]}),l.jsx("span",{className:"trace-dur",children:jH(S.end_time-S.start_time)}),l.jsx("span",{className:"trace-track",children:l.jsx("span",{className:"trace-bar",style:{left:`${k}%`,width:`${T}%`,background:bR(S.name)}})})]},S.span_id)})}),l.jsx("div",{className:"trace-detail scroll",children:v?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"td-title",children:v.name}),l.jsxs("div",{className:"td-dur",children:[l.jsx("span",{className:"td-dot",style:{background:bR(v.name)}}),jH(v.end_time-v.start_time)]}),l.jsx("div",{className:"td-section",children:"属性"}),l.jsx("div",{className:"td-props",children:RH(v).filter(E=>!E.long).map(E=>l.jsxs("div",{className:"td-prop",children:[l.jsx("span",{className:"td-key",children:E.key}),l.jsx("span",{className:"td-val",children:E.value})]},E.key))}),RH(v).filter(E=>E.long).map(E=>l.jsxs("div",{className:"td-block",children:[l.jsx("div",{className:"td-section",children:E.key}),l.jsx("pre",{className:"td-pre",children:E.value})]},E.key))]}):l.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}const Xht=m.lazy(()=>$g(()=>import("./MarkdownPromptEditor-Cfdarq4r.js"),__vite__mapDeps([0,1]))),zL="veadk.generatedAgentTestRuns",IH=4;function SQ(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(zL)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}catch{return[]}}function Upe(e){if(typeof window>"u")return;const t=Array.from(new Set(e)).slice(-20);try{t.length?window.sessionStorage.setItem(zL,JSON.stringify(t)):window.sessionStorage.removeItem(zL)}catch{}}function qht(e){Upe([...SQ(),e])}function mO(e){Upe(SQ().filter(t=>t!==e))}function Hht(e,t,n="text/plain"){const i=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(i)}const Yht=[{id:"type",label:"Agent 类型",hint:"选择 Agent 类型",icon:fSe,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:hd,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:Vwe},{id:"tools",label:"工具",hint:"可调用的能力",icon:mSe},{id:"skills",label:"技能",hint:"声明式技能",icon:tx},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:$S},{id:"memory",label:"记忆",hint:"短期与长期记忆",icon:hJ},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:Qwe},{id:"review",label:"完成",hint:"预览并创建",icon:uSe}];function Ght({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M9 7.15v9.7a1.15 1.15 0 0 0 1.78.96l7.2-4.85a1.15 1.15 0 0 0 0-1.92l-7.2-4.85A1.15 1.15 0 0 0 9 7.15Z"}),l.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),l.jsx("path",{d:"M3 10v4",opacity:"0.45"}),l.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function PH({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4.75 7.25h14.5"}),l.jsx("path",{d:"M9.1 4.75h5.8l.75 2.5h-7.3l.75-2.5Z"}),l.jsx("path",{d:"m6.75 7.25.75 12h9l.75-12"}),l.jsx("path",{d:"M10 10.25v5.75M14 10.25v5.75"})]})}function EQ({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5"})})}function kQ({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),l.jsx("path",{d:"M4.5 4.75v3.5H8"}),l.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),l.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const Wht={llm:"智能体",sequential:"分步协作",parallel:"同时处理",loop:"循环执行",a2a:"远程智能体"},MH={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},zpe="REGISTRY_SPACE_ID",Zht=Fne.filter(e=>e.key!==zpe);function Fpe(e,t){var i,r,s;if(!(e!=null&&e.enabled))return{};const n={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(n.REGISTRY_TOP_K=((i=e.registryTopK)==null?void 0:i.trim())||Pl.topK,n.REGISTRY_REGION=((r=e.registryRegion)==null?void 0:r.trim())||Pl.region,n.REGISTRY_ENDPOINT=((s=e.registryEndpoint)==null?void 0:s.trim())||Pl.endpoint):(n.REGISTRY_TOP_K=e.registryTopK??"",n.REGISTRY_REGION=e.registryRegion??"",n.REGISTRY_ENDPOINT=e.registryEndpoint??""),n}function mS(e,t){return t!=="byteplus"?e:e.map(n=>n.key==="MODEL_EMBEDDING_NAME"?{...n,placeholder:eEe(t)}:n.key==="MODEL_EMBEDDING_API_BASE"?{...n,placeholder:Dl(t)}:n.key==="MODEL_IMAGE_NAME"?{...n,placeholder:nEe(t)}:n.key==="MODEL_EDIT_NAME"?{...n,placeholder:iEe(t)}:n.key==="MODEL_VIDEO_NAME"?{...n,placeholder:rEe(t)}:n.key==="MODEL_IMAGE_API_BASE"||n.key==="MODEL_EDIT_API_BASE"||n.key==="MODEL_VIDEO_API_BASE"?{...n,placeholder:Dl(t)}:n)}function Kht({items:e,selected:t,onToggle:n,scrollRows:i}){return l.jsx("div",{className:`cw-checklist ${i?"cw-checklist-tools":""}`,style:i?{"--cw-checklist-max-height":`${i*40+(i-1)*8}px`}:void 0,children:e.map(r=>{const s=t.includes(r.id);return l.jsx(yQ,{id:`cw-check-${r.id}`,className:`cw-check ${s?"is-on":""}`,checked:s,onCheckedChange:a=>{a!==s&&n(r.id)},label:l.jsx("span",{className:"cw-check-text",children:l.jsx("span",{className:"cw-check-title",children:r.label})})},r.id)})})}function OR({options:e,value:t,onChange:n}){return l.jsx("div",{className:"cw-segmented",children:e.map(i=>{var s;const r=(t??((s=e[0])==null?void 0:s.id))===i.id;return l.jsx("button",{type:"button",className:`cw-seg ${r?"is-on":""}`,onClick:()=>n(i.id),"aria-pressed":r,children:l.jsx("span",{className:"cw-seg-title",children:i.label})},i.id)})})}function Jht(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function gO({env:e,values:t,onChange:n,renderAfterField:i}){return e.length===0?l.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):l.jsx("div",{className:"cw-env-fields",children:e.map(r=>{const s=t[r.key]??r.defaultValue??"",a=xQ(r,t),o=`cw-env-${r.key}`;return l.jsxs(m.Fragment,{children:[l.jsxs("label",{className:"cw-env-field",htmlFor:o,children:[l.jsxs("span",{className:"cw-env-field-head",children:[l.jsxs("span",{className:"cw-env-field-title",children:[l.jsxs("span",{className:"cw-env-field-label",children:[r.comment||r.key,r.required&&l.jsx("span",{className:"cw-req",children:"*"})]}),r.help&&l.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":r.help,"aria-label":`${r.comment||r.key}说明:${r.help}`,children:["?",l.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:r.help})]}),r.link&&l.jsx("a",{className:"cw-env-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${r.link.label}`,"aria-label":`打开 OpenViking ${r.link.label}`,onClick:c=>c.stopPropagation(),children:l.jsx(e0,{"aria-hidden":"true"})})]}),r.comment&&l.jsx("code",{title:r.key,children:r.key})]}),r.multiline||r.format==="json"?l.jsx("textarea",{id:o,className:"cw-input cw-env-textarea",value:s,placeholder:r.placeholder||"请输入参数值",autoComplete:"off",spellCheck:!1,"aria-invalid":!!a,onChange:c=>n(r.key,c.currentTarget.value)}):l.jsx("input",{id:o,className:"cw-input",type:Jht(r.key)?"password":"text",value:s,placeholder:r.placeholder||"请输入参数值",autoComplete:"off","aria-invalid":!!a,onChange:c=>n(r.key,c.currentTarget.value)}),a&&l.jsx("span",{className:"cw-env-error",children:a})]}),i==null?void 0:i(r)]},r.key)})})}const yR="默认值:留空;生成项目时使用 Agent 名自动生成,例如 my_agent_kb。未配置 DATABASE_OPENVIKING_TARGET_URI 时,默认 URI 拼接为 viking://user/{知识库归属 ID,未填则 default}/resources/{资源索引}/;如果填写了 DATABASE_OPENVIKING_TARGET_URI,则直接使用该完整 URI。";function ept({value:e,onChange:t}){const n="cw-openviking-knowledge-index";return l.jsxs("label",{className:"cw-env-field",htmlFor:n,children:[l.jsx("span",{className:"cw-env-field-head",children:l.jsxs("span",{className:"cw-env-field-title",children:[l.jsx("span",{className:"cw-env-field-label",children:"OpenViking 资源索引"}),l.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":yR,"aria-label":`OpenViking 资源索引说明:${yR}`,children:["?",l.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:yR})]})]})}),l.jsx("input",{id:n,className:"cw-input",value:e,placeholder:"",autoComplete:"off",onChange:i=>t(i.currentTarget.value)})]})}function xR(e){return e.name.trim()||"未命名智能体中心"}function vR(e){const t=e.name.trim()||e.id||"未命名知识库",n=[e.sourceLabel,e.projectName].filter(Boolean);return n.length?`${t} · ${n.join(" · ")}`:t}function tpt(e){return e.available?"已开通":e.lifecycleStatus==="Retiring"?"即将下线":e.activationState&&e.activationState!=="Available"?"未开通":"暂不可用"}function npt(e){return e.available||e.lifecycleStatus==="Retiring"}function LH({selectedLabel:e,placeholder:t,disabled:n,triggerAriaLabel:i,menuAriaLabel:r,searchAriaLabel:s,searchValue:a,searchPlaceholder:o,onSearchChange:c,empty:u,emptyLabel:d,triggerClassName:f="",optionsClassName:h="",renderOptions:p}){const[g,b]=m.useState(!1),y=m.useRef(null),O=m.useRef(null),v=m.useRef(null),x=m.useId(),[w,E]=m.useState(null);m.useEffect(()=>{if(!g)return;const T=N=>{var M;const C=N.target;C instanceof Node&&y.current&&!y.current.contains(C)&&!((M=v.current)!=null&&M.contains(C))&&b(!1)},A=N=>{var C;N.key==="Escape"&&(b(!1),(C=O.current)==null||C.focus())};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",A),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",A)}},[g]),m.useEffect(()=>{if(!g){E(null);return}const T=()=>{const A=O.current;if(!A)return;const N=A.getBoundingClientRect(),C=12,M=6,L=window.innerHeight-N.bottom-C-M,P=N.top-C-M,Q=L<300&&P>L,j=Math.max(96,Q?P:L),$=Math.min(N.width,window.innerWidth-C*2),U=Math.min(Math.max(C,N.left),window.innerWidth-C-$);E({...Q?{bottom:window.innerHeight-N.top+M}:{top:N.bottom+M},left:U,width:$,maxHeight:j,opensUp:Q})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[g]);const S=()=>b(!1),k=T=>{var M,L;if(!["ArrowDown","ArrowUp","Home","End"].includes(T.key))return;const A=Array.from(((M=v.current)==null?void 0:M.querySelectorAll('[role="option"]:not(:disabled)'))??[]);if(!A.length)return;T.preventDefault();const N=A.findIndex(P=>P===document.activeElement),C=T.key==="Home"?0:T.key==="End"?A.length-1:T.key==="ArrowUp"?N<=0?A.length-1:N-1:N<0||N===A.length-1?0:N+1;(L=A[C])==null||L.focus()};return l.jsxs("div",{className:`cw-a2a-space-select-wrap cw-catalog-select${g?" is-open":""}`,ref:y,children:[l.jsxs("button",{ref:O,type:"button",className:`cw-a2a-space-trigger ${f}`.trim(),disabled:n,"aria-haspopup":"listbox","aria-controls":g?x:void 0,"aria-expanded":g,"aria-label":i,title:e,onClick:()=>{g||c(""),b(T=>!T)},children:[l.jsx("span",{className:t?"is-placeholder":void 0,children:e}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),g&&w&&zi.createPortal(l.jsxs("div",{ref:v,className:`cw-a2a-space-menu cw-catalog-menu cw-catalog-menu-portal${w.opensUp?" is-up":""}`,style:{top:w.top,bottom:w.bottom,left:w.left,width:w.width,maxHeight:w.maxHeight},onKeyDown:k,children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:a,autoFocus:!0,autoComplete:"off","aria-label":s,placeholder:o,onChange:T=>c(T.currentTarget.value)})}),l.jsxs("div",{id:x,className:`cw-picker-options cw-catalog-options ${h}`.trim(),role:"listbox","aria-label":r,children:[p(S),u&&l.jsx("div",{className:"cw-picker-empty",children:d})]})]}),document.body)]})}function ipt({value:e,cloudProvider:t,apiKeyId:n,apiKeyName:i,onApiKeyChange:r,onChange:s}){const[a,o]=m.useState([]),[c,u]=m.useState(!1),[d,f]=m.useState([]),[h,p]=m.useState(null),[g,b]=m.useState(!1),[y,O]=m.useState(null),[v,x]=m.useState(0),[w,E]=m.useState(0),[S,k]=m.useState(""),[T,A]=m.useState("");m.useEffect(()=>{const D=new AbortController;return u(!0),O(null),SJ(D.signal,v>0).then(H=>{if(D.signal.aborted)return;o(H.keys);const re=H.keys.find(fe=>fe.id===n)??H.keys.find(fe=>fe.name===i)??H.keys.find(fe=>fe.id===H.defaultKeyId)??H.keys[0];re&&r(re)}).catch(H=>{D.signal.aborted||O(H instanceof Error?H.message:"加载 Ark API Key 失败")}).finally(()=>{D.signal.aborted||u(!1)}),()=>D.abort()},[t,v]),m.useEffect(()=>{if(!n){f([]);return}const D=new AbortController;return b(!0),O(null),p(null),kJ({signal:D.signal,apiKeyId:n,refresh:v>0||w>0}).then(H=>{D.signal.aborted||(f(H.models),p(n))}).catch(H=>{D.signal.aborted||O(H instanceof Error?H.message:"加载模型列表失败")}).finally(()=>{D.signal.aborted||b(!1)}),()=>D.abort()},[n,t,w,v]);const N=e.trim(),C=h===n,M=C?d:[],L=a.find(D=>D.id===n),P=L?L.name:n?"当前 API Key":c?"正在加载 API Key…":a.length===0?"暂无可用 API Key":"请选择 API Key",Q=m.useMemo(()=>a.filter(D=>up(S,[D.name])),[S,a]),j=M.find(D=>D.id===N),$=g&&!C?"正在刷新模型列表…":j?`${j.displayName} (${j.id})`:N||"请选择模型",U=m.useMemo(()=>M.filter(D=>up(T,[D.displayName,D.id,D.name,D.vendorName,D.activationState,D.lifecycleStatus])),[T,M]),B=!!(N&&!j&&up(T,[N])),I=M.filter(D=>D.available).length,X=t==="byteplus"?"BytePlus ModelArk":"火山方舟",q=JSe(t);return l.jsxs("div",{className:"cw-a2a-space-picker cw-model-picker",children:[l.jsxs("div",{className:"cw-model-picker-stack",children:[l.jsxs("div",{className:"cw-model-picker-field",children:[l.jsx("span",{className:"cw-model-picker-label",children:"API Key"}),l.jsx(LH,{selectedLabel:P,placeholder:!n,disabled:c,triggerAriaLabel:"选择 API Key",menuAriaLabel:"API Key 列表",searchAriaLabel:"搜索 API Key",searchValue:S,searchPlaceholder:"搜索 API Key 名称",onSearchChange:k,empty:Q.length===0,emptyLabel:"未找到匹配的 API Key",optionsClassName:"cw-model-key-options",renderOptions:D=>Q.map(H=>{const re=H.id===n;return l.jsx("button",{type:"button",role:"option","aria-selected":re,className:`cw-a2a-space-option cw-model-key-option ${re?"is-selected":""}`,title:H.name,onClick:()=>{E(fe=>fe+1),r(H),D()},children:l.jsx("span",{children:H.name})},H.id)})})]}),l.jsxs("div",{className:"cw-model-picker-field",children:[l.jsx("span",{className:"cw-model-picker-label",children:"模型"}),l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsx(LH,{selectedLabel:$,placeholder:!N,disabled:g,triggerAriaLabel:`选择${X}模型`,menuAriaLabel:`${X}模型`,searchAriaLabel:"搜索模型",searchValue:T,searchPlaceholder:"搜索名称、Model ID 或服务商",onSearchChange:A,empty:!B&&U.length===0,emptyLabel:"未找到匹配的模型",triggerClassName:"cw-model-trigger",optionsClassName:"cw-model-options",renderOptions:D=>l.jsxs(l.Fragment,{children:[B&&l.jsxs("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option cw-model-option is-selected",onClick:()=>{s(N),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:"当前配置"}),l.jsx("small",{children:N})]}),l.jsx("span",{className:"cw-model-status is-unknown",children:"状态未知"})]}),U.map(H=>{const re=H.id===N,fe=npt(H);return!fe&&H.activationState!=="Available"?l.jsxs("button",{type:"button",role:"option","aria-selected":!1,className:"cw-a2a-space-option cw-model-option is-activation-link",title:`前往${X}开通 ${H.displayName}`,onClick:()=>{window.open(q,"_blank","noopener,noreferrer"),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:H.displayName}),l.jsxs("small",{children:[H.id,H.vendorName?` · ${H.vendorName}`:""]})]}),l.jsx("span",{className:"cw-model-status is-unavailable",children:"未开通,去开通"})]},H.id):l.jsxs("button",{type:"button",role:"option","aria-selected":re,disabled:!fe,className:`cw-a2a-space-option cw-model-option ${re?"is-selected":""}`,title:`${H.displayName} (${H.id})`,onClick:()=>{s(H.id),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:H.displayName}),l.jsxs("small",{children:[H.id,H.vendorName?` · ${H.vendorName}`:""]})]}),l.jsx("span",{className:`cw-model-status ${H.available?"is-available":H.lifecycleStatus==="Retiring"?"is-retiring":"is-unavailable"}`,children:tpt(H)})]},H.id)})]})}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新 API Key 和模型列表","aria-label":"刷新 API Key 和模型列表",disabled:g||c,onClick:()=>x(D=>D+1),children:g||c?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]})]})]}),y?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",role:"alert",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:y})]}):g?l.jsxs("span",{className:"cw-help cw-a2a-space-status","aria-live":"polite",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载模型列表…"]}):M.length===0?l.jsx("span",{className:"cw-help",children:"当前账号下暂无可配置模型。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",M.length," 个模型,其中 ",I," 个已开通。"]})]})}function rpt({value:e,region:t,invalid:n,onChange:i}){const r=t.trim()||Pl.region,[s,a]=m.useState([]),[o,c]=m.useState(!1),[u,d]=m.useState(null),[f,h]=m.useState(0),[p,g]=m.useState(!1),[b,y]=m.useState(""),O=m.useRef(null);m.useEffect(()=>{let A=!1;return c(!0),d(null),iht({region:r}).then(N=>{A||a(N)}).catch(N=>{A||(a([]),d(N instanceof Error?N.message:"加载失败"))}).finally(()=>{A||c(!1)}),()=>{A=!0}},[r,f]);const v=!e||s.some(A=>A.id===e.trim()),x=s.find(A=>A.id===e.trim()),w=x?xR(x):e&&!v?"已选择的智能体中心":"请选择智能体中心",E=o&&s.length===0,S=m.useMemo(()=>s.filter(A=>up(b,[xR(A),A.id,A.projectName])),[b,s]),k=!!(e&&!v&&up(b,["已选择的智能体中心",e]));m.useEffect(()=>{if(!p)return;const A=C=>{const M=C.target;M instanceof Node&&O.current&&!O.current.contains(M)&&g(!1)},N=C=>{C.key==="Escape"&&g(!1)};return window.addEventListener("pointerdown",A),window.addEventListener("keydown",N),()=>{window.removeEventListener("pointerdown",A),window.removeEventListener("keydown",N)}},[p]);const T=A=>{i(A),g(!1)};return l.jsxs("div",{className:`cw-a2a-space-picker${p?" is-open":""}`,ref:O,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:E,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{y(""),g(A=>!A)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:w}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),p&&l.jsxs("div",{className:"cw-a2a-space-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:b,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:A=>y(A.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[k&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>T(e),children:"已选择的智能体中心"}),S.map(A=>{const N=xR(A),C=A.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":C,className:`cw-a2a-space-option ${C?"is-selected":""}`,title:`${N} (${A.id})`,onClick:()=>T(A.id),children:N},A.id)}),!k&&S.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:o,onClick:()=>h(A=>A+1),children:o?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]}),u?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:u})]}):o?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):s.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",s.length," 个智能体中心,列表仅展示中心名称。"]})]})}function spt({value:e,onChange:t}){const[n,i]=m.useState([]),[r,s]=m.useState(!1),[a,o]=m.useState(null),[c,u]=m.useState(0),[d,f]=m.useState(!1),[h,p]=m.useState(""),g=m.useRef(null);m.useEffect(()=>{let S=!1;return s(!0),o(null),sht().then(k=>{S||i(k)}).catch(k=>{S||(i([]),o(k instanceof Error?k.message:"加载失败"))}).finally(()=>{S||s(!1)}),()=>{S=!0}},[c]);const b=!e||n.some(S=>S.id===e.trim()),y=n.find(S=>S.id===e.trim()),O=y?vR(y):e&&!b?e:"请选择 VikingDB 知识库",v=r&&n.length===0,x=m.useMemo(()=>n.filter(S=>up(h,[vR(S),S.id,S.description,S.projectName,S.resourceId,S.agentkitKnowledgeId,S.providerKnowledgeId,S.sourceLabel])),[n,h]),w=!!(e&&!b&&up(h,[e]));m.useEffect(()=>{if(!d)return;const S=T=>{const A=T.target;A instanceof Node&&g.current&&!g.current.contains(A)&&f(!1)},k=T=>{T.key==="Escape"&&f(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",k),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",k)}},[d]);const E=S=>{t(S),f(!1)};return r&&n.length===0?l.jsxs("span",{className:"cw-viking-kb-inline-status",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载…"]}):l.jsxs("div",{className:`cw-a2a-space-picker cw-viking-kb-picker${d?" is-open":""}`,ref:g,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:v,"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"选择 VikingDB 知识库",onClick:()=>{p(""),f(S=>!S)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:O}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),d&&l.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:h,autoFocus:!0,autoComplete:"off","aria-label":"搜索 VikingDB 知识库",placeholder:"搜索名称或 ID",onChange:S=>p(S.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"VikingDB 知识库",children:[w&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>E({id:e,name:e,description:"",projectName:"",region:"",sourceKind:"knowledge",sourceLabel:"Knowledge Engine",resourceId:""}),children:e}),x.map(S=>{const k=vR(S),T=S.id===e,A=[S.id,S.resourceId,S.agentkitKnowledgeId,S.providerKnowledgeId].filter(Boolean).join(" / ");return l.jsx("button",{type:"button",role:"option","aria-selected":T,className:`cw-a2a-space-option ${T?"is-selected":""}`,title:A?`${k} (${A})`:k,onClick:()=>E(S),children:k},S.id)}),!w&&x.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的知识库"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:"刷新知识库列表","aria-label":"刷新知识库列表",disabled:r,onClick:()=>u(S=>S+1),children:r?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]}),a?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:a})]}):n.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 VikingDB 知识库。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",n.length," 个知识库,选择的知识库会用于当前 Agent。"]})]})}function apt({tools:e,onChange:t}){const n=(s,a)=>t(e.map((o,c)=>c===s?{...o,...a}:o)),i=s=>t(e.filter((a,o)=>o!==s)),r=()=>t([...e,{name:"",transport:"http",url:""}]);return l.jsxs("div",{className:"cw-mcp",children:[e.length>0&&l.jsx("div",{className:"cw-mcp-list",children:l.jsx(xf,{initial:!1,children:e.map((s,a)=>l.jsxs(wr.div,{className:"cw-mcp-row",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.16},children:[l.jsxs("div",{className:"cw-mcp-rowhead",children:[l.jsxs("div",{className:"cw-mcp-transport",children:[l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":s.transport==="http",children:l.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":s.transport==="stdio",children:l.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>i(a),"aria-label":"移除 MCP 工具",children:l.jsx(If,{className:"cw-i cw-i-sm"})})]}),l.jsx("input",{className:"cw-input",value:s.name,placeholder:"名称(用于命名,可留空)",onChange:o=>n(a,{name:o.target.value})}),s.transport==="http"?l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:s.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:o=>n(a,{url:o.target.value})}),Lft(s.url??"")&&l.jsxs("p",{className:"cw-mcp-warning",children:[l.jsx(hd,{"aria-hidden":"true"}),l.jsx("span",{children:"当前地址不是以 /mcp 结尾,请确认它是实际的 MCP Endpoint。Studio 会保留该地址,不会自动补充路径。"})]}),l.jsx("input",{className:"cw-input",value:Pft(s),placeholder:"Bearer Token(可选)",onChange:o=>t(e.map((c,u)=>u===a?Mft(c,o.target.value):c))})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:s.command??"",placeholder:"启动命令,例如 npx",onChange:o=>n(a,{command:o.target.value})}),l.jsx("input",{className:"cw-input",value:(s.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:o=>n(a,{args:o.target.value.split(/\s+/).filter(Boolean)})}),l.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),l.jsxs("button",{type:"button",className:"cw-add-sub",onClick:r,children:[l.jsx(Gs,{className:"cw-i"}),"添加 MCP 工具"]})]})}function Vpe({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M5.5 7.5h10.75a2 2 0 0 1 2 2v7.75a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V9.5a2 2 0 0 1 2-2Z"}),l.jsx("path",{d:"M7 4.75h9.5a2 2 0 0 1 2 2",opacity:".58"}),l.jsx("path",{d:"m11 10.25.72 1.48 1.63.24-1.18 1.15.28 1.62-1.45-.77-1.45.77.28-1.62-1.18-1.15 1.63-.24.72-1.48Z"}),l.jsx("path",{d:"M19.25 11.25h1.5M20 10.5V12",opacity:".72"})]})}function opt({s:e,onRemove:t}){let n=tx,i="火山 Find Skill 技能广场";return e.source==="local"?(n=MD,i="本地"):e.source==="skillspace"&&(n=Vpe,i="AgentKit Skills 中心"),l.jsxs(wr.div,{className:"cw-selected-skill-row",layout:!0,initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16},children:[l.jsx("span",{className:"cw-selected-skill-icon","aria-hidden":!0,children:l.jsx(n,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-selected-skill-meta",children:[l.jsx("span",{className:"cw-selected-skill-name",children:e.name}),l.jsxs("span",{className:"cw-selected-skill-detail",children:[i,e.description?` · ${r1(e.description)}`:""]})]}),l.jsx("button",{type:"button",className:"cw-selected-skill-remove",onClick:t,"aria-label":`移除 ${e.name}`,title:`移除 ${e.name}`,children:l.jsx(xa,{className:"cw-i cw-i-sm"})})]},`${e.source}:${e.folder}:${e.skillId||e.slug||""}:${e.version||""}`)}const wR=[{id:"local",label:"本地文件",icon:MD},{id:"skillspace",label:"AgentKit Skills 中心",icon:Vpe},{id:"skillhub",label:"火山 Find Skill 技能广场",icon:O_}];function lpt({selected:e,onChange:t,cloudProvider:n}){const[i,r]=m.useState("local"),[s,a]=m.useState(!1),o=wR.findIndex(u=>u.id===i),c=u=>t(e.filter(d=>SR(d)!==u));return m.useEffect(()=>{if(!s)return;const u=d=>{d.key==="Escape"&&a(!1)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]),l.jsxs("div",{className:"cw-skillspane",children:[l.jsxs("button",{type:"button",className:"cw-skill-add","aria-haspopup":"dialog",onClick:()=>a(!0),children:[l.jsx("span",{className:"cw-skill-add-icon","aria-hidden":!0,children:l.jsx(Gs,{className:"cw-i"})}),l.jsx("span",{children:"添加 Skill"})]}),e.length>0&&l.jsxs("div",{className:"cw-skill-selected",children:[l.jsxs("span",{className:"cw-skill-selected-label",children:["已加入技能 · ",e.length]}),l.jsx("div",{className:"cw-selected-skill-list",children:l.jsx(xf,{initial:!1,children:e.map(u=>l.jsx(opt,{s:u,onRemove:()=>c(SR(u))},SR(u)))})})]}),l.jsx(xf,{children:s&&l.jsx(wr.div,{className:"cw-skill-dialog-backdrop",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},onMouseDown:u=>{u.target===u.currentTarget&&a(!1)},children:l.jsxs(wr.div,{className:"cw-skill-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"cw-skill-dialog-title",initial:{opacity:0,y:10,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.99},transition:{duration:.18,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-skill-dialog-head",children:[l.jsx("h3",{id:"cw-skill-dialog-title",children:"添加 Skill"}),l.jsx("button",{type:"button",className:"cw-skill-dialog-close","aria-label":"关闭添加 Skill",onClick:()=>a(!1),children:l.jsx(xa,{className:"cw-i"})})]}),l.jsxs("div",{className:"cw-skill-dialog-body",children:[l.jsxs("div",{className:"cw-skill-sourcetabs",role:"tablist",style:{"--cw-skill-tab-slider-width":`calc((100% - 16px) / ${wR.length})`,"--cw-active-skill-tab-offset":`calc(${o*100}% + ${o*4}px)`},children:[l.jsx("span",{className:"cw-skill-tab-slider","aria-hidden":!0}),wR.map(({id:u,label:d,icon:f})=>l.jsxs("button",{type:"button",role:"tab",id:`cw-skill-tab-${u}`,"aria-controls":"cw-skill-tabpanel","aria-selected":i===u,className:`cw-skill-pickertab ${i===u?"is-on":""}`,onClick:()=>r(u),children:[l.jsx(f,{className:"cw-i cw-i-sm"}),d]},u))]}),l.jsxs("div",{id:"cw-skill-tabpanel",className:"cw-skill-tabbody",role:"tabpanel","aria-labelledby":`cw-skill-tab-${i}`,children:[i==="skillhub"&&l.jsx(Fft,{selected:e,onChange:t}),i==="local"&&l.jsx(eht,{selected:e,onChange:t}),i==="skillspace"&&l.jsx(tht,{selected:e,onChange:t,cloudProvider:n})]})]})]})})})]})}function SR(e){return e.source==="skillhub"?`hub:${e.namespace}/${e.slug}`:e.source==="local"?`local:${e.folder}`:`ss:${e.skillSpaceId}/${e.skillId}/${e.version||""}`}function gS({checked:e,onChange:t,title:n,desc:i,showDescription:r=!1}){return l.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[l.jsxs("span",{className:"cw-toggle-text",children:[l.jsx("span",{className:"cw-toggle-title",children:n}),r&&l.jsx("span",{className:"cw-toggle-help",children:i})]}),l.jsx("span",{className:"cw-switch","aria-hidden":!0,children:l.jsx(wr.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}function cpt(e,t){var i;let n=e;for(const r of t)if(n=(i=n.subAgents)==null?void 0:i[r],!n)return!1;return!0}function bS(e,t){let n=e;for(const i of t)n=n.subAgents[i];return n}function ov(e,t,n){if(t.length===0)return n(e);const[i,...r]=t,s=e.subAgents.slice();return s[i]=ov(s[i],r,n),{...e,subAgents:s}}function upt(e,t,n="volcengine"){return ov(e,t,i=>({...i,subAgents:[...i.subAgents,el(n)]}))}function dpt(e,t,n,i="volcengine"){return ov(e,t,r=>{const s=r.subAgents.slice();return s.splice(n,0,el(i)),{...r,subAgents:s}})}function fpt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),i=t[t.length-1];return ov(e,n,r=>({...r,subAgents:r.subAgents.filter((s,a)=>a!==i)}))}const FL=e=>!ZA(e.agentType),DH=3;function hpt(e,t,n=!1){var r;if(ZA(e.agentType))return n?"远程 Agent 只能作为子 Agent":(r=e.a2aRegistry)!=null&&r.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const i=i1(e.name);return i||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":hpe(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function Xpe(e,t,n=[]){const i=[],r=ZA(e.agentType),s=hpt(e,t,n.length===0);return s&&i.push({path:n,name:r?"远程 Agent":e.name.trim()||"未命名",typeLabel:fpe(e.agentType).label,problem:s}),FL(e)&&e.subAgents.forEach((a,o)=>i.push(...Xpe(a,t,[...n,o]))),i}function ppt(e){return`${e.typeLabel}至少需要添加一个子 Agent 后才能调试或发布。`}function qpe(e){return 1+e.subAgents.reduce((t,n)=>t+qpe(n),0)}function Hpe(e){const t=KA(e),n=[],i={...t.envValues},r=t.draft.cloudProvider??"volcengine";let s=!1;for(const c of Cpe(t.draft,Dl(r))){const u=[{key:c.apiKeyKey,required:!0,comment:c.label}];c.providerKey&&(u.push({key:c.providerKey,required:!0}),i[c.providerKey]=c.provider),c.apiBaseKey&&(u.push({key:c.apiBaseKey,required:!0}),i[c.apiBaseKey]=c.apiBase),n.push({env:u})}const a=c=>{var u,d,f,h;c.agentType==="llm"&&Ob(c,r)==="ark"&&(s=!0);for(const p of c.builtinTools??[]){const g=Qp.find(b=>b.id===p);g&&n.push({env:mS(g.env,r)})}for(const p of c.mcpTools??[])p.authTokenEnv&&n.push({env:[{key:p.authTokenEnv,required:!1,comment:`${p.name.trim()||"MCP"} Bearer Token`}]});if((u=c.a2aRegistry)!=null&&u.enabled&&(n.push({env:Fne}),Object.assign(i,Fpe(c.a2aRegistry,{includeDefaults:!0}))),c.memory.shortTerm&&n.push({env:mS(((d=RP.find(p=>p.id===(c.shortTermBackend??"local")))==null?void 0:d.env)??[],r)}),c.memory.longTerm&&n.push({env:mS(((f=IP.find(p=>p.id===(c.longTermBackend??"local")))==null?void 0:f.env)??[],r)}),c.knowledgebase&&n.push({env:mS(((h=PP.find(p=>p.id===(c.knowledgebaseBackend??wf)))==null?void 0:h.env)??[],r)}),c.tracing)for(const p of c.tracingExporters??[]){const g=xPe.find(b=>b.id===p);g&&n.push({env:g.env,enableFlag:g.enableFlag})}c.subAgents.forEach(a)};a(t.draft),s&&(n.push({env:[{key:"MODEL_AGENT_PROVIDER",required:!0},{key:"MODEL_AGENT_API_BASE",required:!0},{key:"MODEL_AGENT_API_KEY",required:!0,comment:"Ark API Key",placeholder:"由所选 API Key 注入",secret:!0,readOnly:!0,serverManaged:!0}]}),i.MODEL_AGENT_PROVIDER="openai",i.MODEL_AGENT_API_BASE=Dl(r));const o=cpe(n);return{specs:o.specs,fixedValues:{...o.fixedValues,...i}}}function mpt(e,t){const n=i=>(i??"").trim().replace(/\/+$/,"");return n(e)===n(t)}function gpt(e,t,n){const i=(e??"").trim();return!i||i===t0(t)?!0:i===t0(n)?!1:n==="byteplus"&&i.includes("doubao-")}function $h(e,t){const n=e.cloudProvider??"volcengine",i=Ob(e,n),r=e.subAgents.map(u=>$h(u,t)),s=i==="ark"&&gpt(e.modelName,n,t)?t0(t):e.modelName,o=mpt(e.modelApiBase,Dl(n))||t==="byteplus"&&(e.modelApiBase??"").includes("volces.com")?Dl(t):e.modelApiBase;return e.cloudProvider!==t||s!==e.modelName||o!==e.modelApiBase||r.some((u,d)=>u!==e.subAgents[d])?{...e,cloudProvider:t,modelName:s,modelApiBase:o,subAgents:r}:e}function bpt(e,t){var o;const n=$h(e,t),i=jpe(n,Dl(t)),r=new Set(i.map(({key:c})=>c)),s=((o=n.deployment)==null?void 0:o.envValues)??{},a=Object.fromEntries(Object.entries(s).filter(([c,u])=>r.has(c)&&!!u.trim()));return Object.keys(a).length===0?{draft:n,customModelSecretValues:a}:{draft:{...n,deployment:{...n.deployment??{feishuEnabled:!1},envValues:Object.fromEntries(Object.entries(s).filter(([c])=>!r.has(c)))}},customModelSecretValues:a}}function Ype(e){var i,r,s;const t=KA(e).draft;return{...Ppe(t,t.cloudProvider??"volcengine"),deployment:{feishuEnabled:!!((i=e.deployment)!=null&&i.feishuEnabled),modelApiKeyId:((r=e.deployment)==null?void 0:r.modelApiKeyId)??"",modelApiKeyName:((s=e.deployment)==null?void 0:s.modelApiKeyName)??""}}}function VL(e){var n;const t=(n=e.modelName)==null?void 0:n.trim();if(t)return t;for(const i of e.subAgents){const r=VL(i);if(r)return r}return""}function Gpe(e,t={}){var r,s,a,o;const n=Hpe(e),i={...((r=e.deployment)==null?void 0:r.envValues)??{},...t,...n.fixedValues};return{...Ype(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),modelApiKeyId:((a=e.deployment)==null?void 0:a.modelApiKeyId)??"",modelApiKeyName:((o=e.deployment)==null?void 0:o.modelApiKeyName)??"",envValues:Object.fromEntries(upe(n.specs,i).map(({key:c,value:u})=>[c,u]))}}}function Opt(e,t={}){return JSON.stringify(Gpe(e,t))}function DT(e,t){return JSON.stringify({draftSnapshot:e,modelName:t.modelName,description:t.description,instruction:t.instruction,optimizations:t.optimizations})}function dg(e){return JSON.stringify({modelName:e.modelName.trim(),description:e.description.trim(),instruction:e.instruction.trim(),optimizations:e.optimizations})}function ypt({enabled:e,disabledReason:t,variants:n,draftSnapshot:i,input:r,onInput:s,onSend:a,onStartVariant:o,onDeployVariant:c,onAddVariant:u,onRemoveVariant:d,onToggleConfig:f,onCompleteConfig:h,onConfigChange:p,onOpenTrace:g}){const b=n.filter(v=>v.phase!=="ready"?!1:v.runtimeSnapshot===DT(i,v)),y=n.some(v=>v.phase==="sending"),O=b.length>0&&!y;return l.jsxs("section",{className:"cw-ab-workspace","aria-label":"A/B 调试工作台",children:[l.jsx("div",{className:"cw-ab-stage",children:e?l.jsx("div",{className:"cw-ab-grid",style:{"--cw-ab-column-count":n.length},children:n.map((v,x)=>{const w=v.modelName.trim(),E=v.description.trim(),S=v.instruction.trim(),k=dg(v),T=!!(w&&E&&S&&n.findIndex(U=>dg(U)===k)!==x),A=!w||!E||!S||T,N=!!(v.runtimeSnapshot&&v.runtimeSnapshot!==DT(i,v)),C=v.phase==="starting",M=v.phase==="ready"&&!N,L=C||v.phase==="sending",P=M&&v.phase!=="sending"&&v.messages.some(U=>U.role==="assistant"),Q=L||v.configOpen||A,j=w?E?S?T?"该配置与已有测试组相同":"":"请填写系统提示词":"请填写描述":"请先选择模型",$=C?"正在启动":N?"应用配置并重启":M||v.phase==="error"?"重新启动环境":"启动环境";return l.jsx("article",{className:"cw-ab-card",children:l.jsxs("div",{className:`cw-ab-card-inner${v.configOpen?" is-flipped":""}`,children:[l.jsxs("section",{className:"cw-ab-card-face cw-ab-card-front","aria-hidden":v.configOpen,children:[l.jsxs("header",{className:"cw-ab-card-head",children:[l.jsxs("div",{className:"cw-ab-card-title",children:[l.jsx("strong",{children:v.name}),l.jsx("span",{children:v.modelName||"默认模型"})]}),l.jsxs("div",{className:"cw-ab-card-actions",children:[l.jsx("button",{type:"button",className:"cw-ab-config-trigger",disabled:v.configOpen||L,onClick:()=>f(v.id),children:"测试配置"}),v.id!=="baseline"&&l.jsx("button",{type:"button",className:"cw-ab-remove","aria-label":`删除${v.name}`,disabled:v.configOpen||L,onClick:()=>d(v.id),children:l.jsx(PH,{className:"cw-i"})})]})]}),l.jsx("div",{className:"cw-ab-conversation",children:v.error?l.jsx(LT,{message:v.error,className:"cw-debug-error-detail",defaultExpanded:!0}):C?l.jsxs("div",{className:"cw-ab-empty cw-ab-starting",children:[l.jsx(Kn,{className:"cw-i cw-spin"}),l.jsx("span",{children:"正在创建独立测试环境"})]}):N?l.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:l.jsx("span",{children:"配置已变更,请重新启动此环境"})}):v.messages.length===0?l.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:M?l.jsxs(l.Fragment,{children:[l.jsx("strong",{className:"cw-ab-ready-title",children:"已就绪"}),l.jsx("span",{className:"cw-ab-launch-hint",children:"可在下方输入测试消息"})]}):l.jsx("span",{className:"cw-ab-launch-hint",children:j||"启动环境后即可加入本轮测试"})}):v.messages.map((U,B)=>l.jsx("div",{className:`cw-debug-msg cw-debug-msg-${U.role}`,children:l.jsx("div",{className:"cw-debug-content",children:U.role==="user"?U.content:U.error?l.jsx(LT,{message:U.error,className:"cw-debug-msg-error",defaultExpanded:!0}):U.blocks&&U.blocks.length>0?l.jsx(vA,{blocks:U.blocks,onAction:()=>{}}):U.content?U.content:B===v.messages.length-1&&v.phase==="sending"?l.jsx(dle,{}):null})},B))}),l.jsxs("footer",{className:"cw-ab-deploy-footer",children:[l.jsx("button",{type:"button",className:"cw-ab-trace",disabled:!P,title:P?`查看${v.name}调用链路`:"完成一次调试后可查看调用链路",onClick:()=>g(v.id),children:"调用链路"}),l.jsxs("button",{type:"button",className:"cw-ab-start cw-ab-footer-start",disabled:Q,title:j||void 0,onClick:()=>o(v.id),children:[M||N||v.phase==="error"?l.jsx(cSe,{className:"cw-i"}):l.jsx(Ght,{className:"cw-i cw-debug-run-icon"}),$]}),l.jsx("button",{type:"button",className:"cw-ab-deploy",disabled:L||!w,onClick:()=>c(v.id),children:"部署该配置"})]})]}),l.jsxs("section",{className:"cw-ab-card-face cw-ab-card-back","aria-hidden":!v.configOpen,children:[l.jsxs("header",{className:"cw-ab-config-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"测试配置"}),l.jsx("span",{children:v.name})]}),l.jsxs("div",{className:"cw-ab-config-head-actions",children:[v.id!=="baseline"&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger cw-ab-config-remove","aria-label":`删除${v.name}`,title:"删除配置组",disabled:L,onClick:()=>d(v.id),children:l.jsx(PH,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:`cw-ab-config-done-wrap${j?" is-disabled":""}`,tabIndex:j?0:void 0,children:[l.jsx("button",{type:"button",className:"cw-ab-config-done",disabled:!v.configOpen||A,onClick:()=>h(v.id),children:v.id==="baseline"?"完成配置":"完成并启动"}),j&&l.jsx("span",{className:"cw-ab-config-done-tip",role:"tooltip",children:j})]})]})]}),l.jsxs("div",{className:"cw-ab-config",children:[l.jsxs("label",{children:[l.jsx("span",{children:"模型"}),l.jsx("input",{value:v.modelName,placeholder:"使用 Agent 当前模型",disabled:!v.configOpen,onChange:U=>p(v.id,"modelName",U.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{rows:2,value:v.description,disabled:!v.configOpen,onChange:U=>p(v.id,"description",U.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"系统提示词"}),l.jsx("textarea",{rows:5,value:v.instruction,disabled:!v.configOpen,onChange:U=>p(v.id,"instruction",U.target.value)})]}),l.jsxs("fieldset",{className:"cw-ab-optimizations-disabled",children:[l.jsxs("legend",{children:[l.jsx("span",{children:"优化选项"}),l.jsx("em",{children:"待开放"})]}),l.jsx("div",{className:"cw-ab-optimization-list",children:Wpe.map(U=>l.jsx(yQ,{checked:v.optimizations.includes(U.id),disabled:!0,label:U.label,className:"cw-ab-optimization-checkbox"},U.id))})]}),l.jsx("p",{children:"设置完成后返回正面,再启动当前测试环境。"})]})]})]})},v.id)})}):l.jsx("div",{className:"cw-debug-empty",children:t})}),l.jsxs("div",{className:"cw-ab-composer",children:[l.jsxs("div",{className:"cw-debug-composerbox",children:[l.jsx("textarea",{className:"cw-debug-input",rows:1,value:r,placeholder:O?"输入测试消息,将发送到所有已启动测试组...":"请先启动至少一个测试组",disabled:!O,onChange:v=>s(v.target.value),onKeyDown:v=>{OQ(v.nativeEvent)||v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),a())}}),l.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!O||!r.trim(),onClick:a,children:y?l.jsx(Kn,{className:"cw-i cw-spin"}):l.jsx($we,{className:"cw-i"})})]}),e&&n.length<3&&l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft cw-ab-add",onClick:u,children:[l.jsx(Gs,{className:"cw-i"}),"添加对照组"]})]})]})}const OS=[{id:"build",label:"架构"},{id:"validate",label:"调试"},{id:"publish",label:"发布"}],Wpe=[{id:"context",label:"上下文优化",description:"压缩历史对话,保留与当前任务相关的信息"},{id:"grounding",label:"幻觉抑制",description:"对不确定内容要求依据,并明确表达未知"},{id:"tools",label:"工具调用优化",description:"减少重复调用,优先复用可信的工具结果"},{id:"latency",label:"响应加速",description:"缓存稳定上下文,降低重复推理开销"}];function xpt({mode:e}){const t=e==="validate"?"调试您的智能体":e==="publish"?"准备好部署您的智能体":"个性化您的智能体架构";return l.jsx("header",{className:"cw-workspace-header",children:l.jsx("h1",{children:t})})}function vpt({mode:e,busy:t,onChange:n,assistant:i}){const r=OS.findIndex(o=>o.id===e),s=OS[r-1],a=OS[r+1];return l.jsxs("footer",{className:"cw-workspace-footer",children:[l.jsxs("div",{className:`cw-workspace-nav-actions${i?" has-assistant":""}`,children:[l.jsx("button",{type:"button",className:`cw-workspace-nav-button${e==="build"?" is-placeholder":""}`,"aria-hidden":e==="build"||void 0,tabIndex:e==="build"?-1:0,disabled:!s||t,onClick:()=>s&&n(s.id),children:"上一步"}),l.jsx("span",{"aria-hidden":"true"}),i?l.jsx("div",{className:"cw-workspace-ai-slot",children:i}):null,e==="publish"?l.jsx("div",{id:"cw-publish-primary-action",className:"cw-publish-action-slot"}):l.jsx("button",{type:"button",className:"cw-workspace-nav-button is-primary",disabled:!a||t,onClick:()=>a&&n(a.id),children:"下一步"})]}),l.jsx("nav",{className:"cw-workspace-progress","aria-label":"Agent 创建进度",children:OS.map((o,c)=>{const u=o.id===e;return l.jsx("button",{type:"button",className:`${u?"is-active":""}${cn(o.id),children:l.jsx("span",{"aria-hidden":"true"})},o.id)})})]})}function wpt({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:i,features:r,onDeploymentTaskChange:s,createMode:a="custom",deploymentTarget:o,cloudProvider:c="volcengine",initialDeployRegion:u=Qi(c),onDeploymentComplete:d,onDeploymentStarted:f,onDraftChange:h,onDiscard:p}){var Kl,Ke,Ds,Ea,nu,$s,Jl,ec,le,gn,Wn,Vi,Ln,Tn,ra,Qs,dr,ws,ls;const[g]=m.useState(()=>bpt(i??el(c),c)),[b,y]=m.useState(g.draft),[O,v]=m.useState(g.customModelSecretValues),x=((Kl=b.deployment)==null?void 0:Kl.runtimeName)??"",w=o?o.name:Zct(b.name,x,(Ke=b.deployment)==null?void 0:Ke.runtimeNameCustomized),E=O;m.useEffect(()=>{y(te=>$h(te,c))},[c]);const[S,k]=m.useState(""),[T,A]=m.useState(!1),[N,C]=m.useState(!1),[M,L]=m.useState(!1),[P,Q]=m.useState(null),j=S.trim(),$=j.length>0&&j.length{q.current=h},[h]),m.useEffect(()=>{var te;I!==B.current&&(B.current=I,(te=q.current)==null||te.call(q,$h(b,c),X))},[c,b,X,I]);const[D,H]=m.useState("build"),[re,fe]=m.useState(!1),[Ae,J]=m.useState(0),[ie,ue]=m.useState(null),[ye,Se]=m.useState(!1),[Re,Ee]=m.useState((o==null?void 0:o.region)??u),me=(r==null?void 0:r.generatedAgentTestRun)===!0,oe=(r==null?void 0:r.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[Ne,Oe]=m.useState(()=>{const te=$h(i??el(c),c);return[{id:"baseline",name:"基准组",modelName:VL(te),description:te.description,instruction:te.instruction,optimizations:[],configOpen:!1,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]}),[Ve,We]=m.useState("baseline"),De=m.useRef(1),mt=m.useRef(!1),at=m.useRef(new Map),[Rt,qe]=m.useState(0),[W,K]=m.useState(""),[ae,pe]=m.useState(null),[z,ve]=m.useState(!1),[Be,Je]=m.useState(!1),kt=m.useRef(null),[Mt,Tt]=m.useState(""),[dt,ge]=m.useState(!1),[lt,Ge]=m.useState([]),vt=m.useRef(null),_t=m.useRef({});async function Bt(){const te=new Set([...at.current.values()].map(({run:ee})=>ee.runId)),Me=SQ().filter(ee=>!te.has(ee));Me.length&&await Promise.all(Me.map(async ee=>{try{await Tm(ee),mO(ee)}catch(_e){console.warn("清理遗留调试运行失败",_e)}}))}m.useEffect(()=>(Bt(),()=>{for(const{run:te}of at.current.values())Tm(te.runId).then(()=>mO(te.runId)).catch(Me=>console.warn("清理调试运行失败",Me));at.current.clear()}),[]),m.useEffect(()=>()=>{var te;(te=kt.current)==null||te.call(kt,!1),kt.current=null},[]);const je=m.useRef(null);je.current||(je.current=({meta:te,children:Me})=>l.jsxs("section",{ref:ee=>{_t.current[te.id]=ee},id:`cw-sec-${te.id}`,"data-step-id":te.id,className:"cw-section",children:[l.jsx("header",{className:"cw-sec-head",children:l.jsx("h2",{className:"cw-sec-title",children:te.label})}),l.jsx("div",{className:"cw-sec-body",children:Me})]}));const Ze=cpt(b,lt)?lt:[],Ie=bS(b,Ze),Wt=Ze.length===0,dn=`cw-a2a-registry-advanced-${Ze.join("-")||"root"}`,Qt=te=>y(Me=>ov(Me,Ze,ee=>({...ee,...te}))),Yt=(te,Me)=>y(ee=>{var _e;return{...ee,deployment:{...ee.deployment??{feishuEnabled:!1},envValues:{...((_e=ee.deployment)==null?void 0:_e.envValues)??{},[te]:Me}}}}),Jt=te=>Qt({a2aRegistry:{...Ie.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...te}}),Ft=(te,Me)=>{if(!(te in MH))return;const ee=MH[te];Jt({[ee]:Me}),Yt(te,Me)},Ce=te=>{if(!(Wt&&te==="a2a")){if(te==="a2a"){Qt({agentType:te,a2aRegistry:{...Ie.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}Qt({agentType:te,a2aRegistry:Ie.a2aRegistry?{...Ie.a2aRegistry,enabled:!1}:void 0})}},et=(te,Me)=>{y(te),Me&&Ge(Me)},wt=async()=>{const te=S.trim();if(!(!te||T)&&!(te.length{const Me=bS(b,te);if(!FL(Me)||te.length>=DH)return;const ee=upt(b,te,c),_e=bS(ee,te).subAgents.length-1;et(ee,[...te,_e])},on=(te,Me)=>{const ee=bS(b,te);if(!FL(ee)||te.length>=DH)return;const _e=Math.max(0,Math.min(Me,ee.subAgents.length)),tt=dpt(b,te,_e,c);et(tt,[...te,_e])},hi=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(y(el(c)),Ge([]),fe(!1))},Pe=te=>{if(te.length===0){hi();return}et(fpt(b,te),te.slice(0,-1))},st=Ie.builtinTools??[],At=m.useMemo(()=>Vne(c),[c]),Ut=m.useMemo(()=>new Set(At.map(te=>te.id)),[At]),kn=Ie.mcpTools??[],wn=Ie.selectedSkills??[],Ai=te=>{Ut.has(te)&&Qt({builtinTools:st.includes(te)?st.filter(Me=>Me!==te):[...st,te]})},Gn=hpe(Ie.agentType),xn=ZA(Ie.agentType),de=Ob(Ie,c),Le=te=>{var ee;const Me=te==="custom"&&de==="ark"?"":te==="ark"&&!((ee=Ie.modelName)!=null&&ee.trim())?t0(c):Ie.modelName;Qt({modelSource:te,modelName:Me})},ut=m.useMemo(()=>But(b),[b]),gt=xn?null:i1(Ie.name)??(ut.has(Ie.name)?"Agent 名称在当前结构中必须唯一":null),ln=gt!==null,Sn=!xn&&Ie.description.trim().length===0,In=Ie.instruction.trim().length===0,Ni=xn&&!((Ds=Ie.a2aRegistry)!=null&&Ds.registrySpaceId.trim()),Pn=te=>re&&te?`is-error cw-error-shake-${Ae%2}`:"",Vt=m.useMemo(()=>Xpe(b,ut),[b,ut]),Ji=Vt.length===0,fn=m.useMemo(()=>$h(b,c),[c,b]),pi=m.useMemo(()=>Opt(fn,E),[fn,E]),ti=Ne.find(te=>te.id===Ve)??Ne[0],vi=m.useMemo(()=>Hpe(fn),[fn]),en=m.useMemo(()=>jpe(fn,Dl(c)),[c,fn]),Ci=en.find(te=>te.label===`${Ie.name.trim()||"自定义模型"} 模型 API Key`),xs=te=>{var Me;(Me=_t.current[te])==null||Me.scrollIntoView({behavior:"smooth",block:"start"})},ni=()=>Ji?!0:(fe(!0),J(te=>te+1),Vt[0]&&(Ge(Vt[0].path),window.requestAnimationFrame(()=>xs(Vt[0].problem==="缺少子 Agent"?"type":"basic"))),!1),Ls=async()=>{pe(null);const te=[...at.current.values()];at.current.clear(),qe(0),Oe(Me=>Me.map(ee=>({...ee,phase:"idle",runtimeSnapshot:"",messages:[],error:null}))),await Promise.all(te.map(async({run:Me})=>{try{await Tm(Me.runId),mO(Me.runId)}catch(ee){console.warn("清理调试运行失败",ee)}}))},er=async te=>{const Me=at.current.get(te);if(Me){at.current.delete(te),qe(at.current.size);try{await Tm(Me.run.runId),mO(Me.run.runId)}catch(ee){console.warn("清理调试运行失败",ee)}}},Ya=te=>{const Me=at.current.get(te),ee=Ne.find(_e=>_e.id===te);!Me||!ee||pe({runId:Me.run.runId,sessionId:Me.sessionId,variantName:ee.name})},mr=te=>{const Me=kt.current;kt.current=null,Me==null||Me(te)},gr=()=>{Be||(ve(!1),mr(!1))},ul=async()=>{if(!Be){Je(!0);try{await Ls(),ve(!1),mr(!0)}finally{Je(!1)}}},Sa=async()=>D!=="validate"||Rt===0?!0:kt.current?!1:new Promise(te=>{kt.current=te,ve(!0)}),as=async te=>{var ee;if(!await Sa())return;if(Tt(""),!ni()){H("build");return}const Me=dpe(vi.specs,((ee=fn.deployment)==null?void 0:ee.envValues)??{});if(Me){Tt(`${Me.spec.comment||Me.spec.key}:${Me.error}`),H("build");return}Se(!0);try{const _e=te?Ne.find(He=>He.id===te):ti;_e&&We(_e.id);const tt=_e?{...fn,modelName:_e.modelName||fn.modelName,description:_e.description,instruction:_e.instruction}:fn,Ct=await t$(Ype(tt));tt!==b&&y(tt),ue(Ct),H("publish")}catch(_e){Tt(_e instanceof Error?_e.message:String(_e))}finally{Se(!1)}},Mn=async te=>{if(!me||ye||!ni())return;const Me=Ne.find(Dn=>Dn.id===te);if(!Me||Me.phase==="starting"||Me.phase==="sending")return;const ee=Me.modelName.trim(),_e=Me.description.trim(),tt=Me.instruction.trim(),Ct=dg(Me),He=Ne.findIndex(Dn=>Dn.id===te),ht=Ne.findIndex(Dn=>dg(Dn)===Ct);if(!ee||!_e||!tt||ht!==He)return;const Pt=DT(pi,Me);Oe(Dn=>Dn.map(Wr=>Wr.id===te?{...Wr,configOpen:!1,phase:"starting",messages:[],error:null}:Wr)),K("");let jt=null,bn="unknown";const Xi=te==="baseline"?"baseline":"comparison",Ss=Dut({agentId:String(fn.name||"unknown"),variantType:Xi});try{await er(te),await Bt();const Dn={...fn,modelName:Me.modelName||fn.modelName,description:Me.description,instruction:Me.instruction};bn="create_test_run",jt=await bee(Gpe(Dn,E),o?{runtimeId:o.runtimeId,region:o.region}:void 0),qht(jt.runId),bn="create_test_session";const Wr=await Oee(jt.runId,"test_user");at.current.set(te,{run:jt,sessionId:Wr}),qe(at.current.size),Oe(sa=>sa.map(qi=>qi.id===te?{...qi,phase:"ready",runtimeSnapshot:Pt}:qi)),Ss.succeed({debugRunId:String(jt.runId)})}catch(Dn){if(jt)try{await Tm(jt.runId),mO(jt.runId)}catch(Wr){console.warn("清理调试运行失败",Wr)}Oe(Wr=>Wr.map(sa=>sa.id===te?{...sa,phase:"error",runtimeSnapshot:"",error:Dn instanceof Error?Dn.message:String(Dn)}:sa)),Ss.fail({failedPhase:bn,...Ra(Dn,{phase:bn})})}},vs=async()=>{const te=W.trim(),Me=Ne.filter(_e=>_e.phase==="ready"&&_e.runtimeSnapshot===DT(pi,_e)&&at.current.has(_e.id));if(!te||Me.length===0)return;K("");const ee=new Set(Me.map(_e=>_e.id));Oe(_e=>_e.map(tt=>ee.has(tt.id)?{...tt,phase:"sending",messages:[...tt.messages,{role:"user",content:te},{role:"assistant",content:"",blocks:[]}]}:tt)),await Promise.all(Me.map(async _e=>{const tt=at.current.get(_e.id);if(tt)try{let Ct=Pu();for await(const He of xee({runId:tt.run.runId,userId:"test_user",sessionId:tt.sessionId,text:te})){const ht=He.error||He.errorMessage||He.error_message;if(ht||(Ct=yk(Ct,He)),Oe(Pt=>Pt.map(jt=>{if(jt.id!==_e.id)return jt;const bn=[...jt.messages],Xi={...bn[bn.length-1]};return ht?Xi.error=String(ht):(Xi.content=Ct.blocks.filter(Ss=>Ss.kind==="text").map(Ss=>Ss.text).join(""),Xi.blocks=Ct.blocks),bn[bn.length-1]=Xi,{...jt,messages:bn}})),ht)break}}catch(Ct){Oe(He=>He.map(ht=>{if(ht.id!==_e.id)return ht;const Pt=[...ht.messages],jt={...Pt[Pt.length-1]};return jt.error=Ct instanceof Error?Ct.message:String(Ct),Pt[Pt.length-1]=jt,{...ht,messages:Pt}}))}finally{Oe(Ct=>Ct.map(He=>He.id===_e.id?{...He,phase:"ready"}:He))}}))},Zl=()=>{Oe(te=>{if(te.length>=3)return te;const Me=De.current++,ee=`variant-${Me}`;return[...te,{id:ee,name:`对照组 ${Me}`,modelName:b.modelName??"",description:b.description,instruction:b.instruction,optimizations:[],configOpen:!0,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]})},Gr=async te=>{await er(te),Oe(Me=>Me.filter(ee=>ee.id!==te)),Ve===te&&We("baseline")},tr=(te,Me)=>Oe(ee=>ee.map(_e=>_e.id===te?{..._e,...Me}:_e)),No=(te,Me,ee)=>{te==="baseline"&&Me==="modelName"&&(mt.current=!0),tr(te,{[Me]:ee}),!(Ve!==te||te==="baseline")&&We("baseline")},Dr=te=>{const Me=Ne.find(Pt=>Pt.id===te);if(!Me)return;const ee=Me.modelName.trim(),_e=Me.description.trim(),tt=Me.instruction.trim(),Ct=dg(Me),He=Ne.findIndex(Pt=>Pt.id===te),ht=Ne.findIndex(Pt=>dg(Pt)===Ct);if(!(!ee||!_e||!tt||ht!==He)){if(te==="baseline"){tr(te,{configOpen:!1});return}Mn(te)}},os=async(te,Me,ee)=>{var Ct;const _e=(Ct=b.deployment)==null?void 0:Ct.network,tt=_e&&_e.mode&&_e.mode!=="public"?{mode:_e.mode,vpc_id:_e.vpcId,subnet_ids:_e.subnetIds,enable_shared_internet_access:_e.enableSharedInternetAccess}:void 0;return w1(te.name,te.files,{region:(o==null?void 0:o.region)??Re,projectName:"default",network:tt},{...ee,onStage:Me,runtimeId:o==null?void 0:o.runtimeId,runtimeName:w,appName:o==null?void 0:o.appName,description:b.description})},na=()=>{ni()&&(Oe(te=>te.map(Me=>Me.id==="baseline"&&!at.current.has(Me.id)?{...Me,modelName:mt.current?Me.modelName:VL(fn),description:fn.description,instruction:fn.instruction}:Me)),H("validate"))},Co=async te=>{if(te==="publish"){if(!ni())return;ie?H("publish"):as();return}if(te==="validate"){na();return}await Sa()&&H(te)},br=je.current,ia=te=>Yht.find(Me=>Me.id===te),ji=l.jsx("section",{className:`cw-ai-compose${T?" is-generating":""}${N?" is-success":""}`,"aria-label":"AI 自动填写 Agent 配置",children:l.jsx(xf,{initial:!1,mode:"wait",children:N?l.jsxs(wr.div,{className:"cw-ai-compose-success",role:"status",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.22,ease:[.22,1,.36,1]},children:[l.jsx("span",{className:"cw-ai-success-check","aria-hidden":!0}),l.jsx("strong",{children:"生成成功"}),l.jsx("button",{type:"button",className:"cw-ai-regenerate",onClick:()=>C(!1),children:"重新生成"})]},"success"):l.jsxs(wr.div,{className:"cw-ai-compose-entry",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.2,ease:[.22,1,.36,1]},children:[l.jsxs("form",{className:"cw-ai-compose-form",onSubmit:te=>{te.preventDefault(),wt()},children:[l.jsx("input",{type:"text",value:S,maxLength:8e3,disabled:T,placeholder:`描述目标,使用 ${tEe(c)} 模型一键生成配置`,"aria-invalid":!!$,"aria-describedby":$?"ai-requirement-error":void 0,onChange:te=>k(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),wt())}}),l.jsx("button",{type:"submit",disabled:T||!j||!!$,"aria-label":T?"正在智能生成":"智能生成",children:T?l.jsx("span",{className:"cw-ai-orb","aria-hidden":!0,children:l.jsx("span",{})}):"智能生成"})]}),$&&l.jsx("p",{className:"cw-ai-requirement-error",id:"ai-requirement-error",role:"alert",children:$})]},"compose")})});return l.jsxs("div",{className:`cw-root is-${D}`,children:[l.jsx(xpt,{mode:D}),Mt&&l.jsx(LT,{className:"cw-workspace-alert",message:Mt}),l.jsxs("main",{className:"cw-workspace-main",id:"cw-workspace-main",children:[D==="build"&&l.jsx("div",{className:"cw-build-workspace",children:l.jsxs("div",{className:"cw-editor",children:[l.jsx(px,{draft:b,direction:"horizontal",selectedPath:Ze,onSelect:Ge,onAdd:yn,onInsert:on,onDelete:Pe}),l.jsx("div",{className:"cw-detail",children:l.jsx("div",{className:"cw-detail-scroll",ref:vt,children:l.jsx("div",{className:"cw-detail-inner",children:l.jsx("div",{className:"cw-lower",children:l.jsxs("div",{className:"cw-form-col",children:[l.jsxs(br,{meta:ia("type"),children:[l.jsx(UO,{className:"cw-agent-type-options","aria-label":"Agent 类型",value:Ie.agentType??"llm",onChange:Ce,children:Aft.map(te=>{const Me=(Ie.agentType??"llm")===te.id,ee=Wt&&te.id==="a2a",_e=ee?"cw-remote-agent-disabled-hint":void 0;return l.jsxs("div",{"data-agent-type":te.id,className:`cw-agent-type-option ${Me?"is-on":""} ${ee?"is-disabled":""}`,tabIndex:ee?0:void 0,"aria-describedby":_e,children:[l.jsx(UO.Item,{value:te.id,disabled:ee,block:!0,className:"cw-agent-type-control",children:l.jsx("span",{className:"cw-agent-type-copy",children:l.jsx("strong",{children:Wht[te.id]})})}),ee&&l.jsx("span",{id:_e,className:"cw-agent-type-disabled-hint",role:"tooltip",children:"远程智能体只能作为子步骤使用"})]},te.id)})}),re&&Gn&&Ie.subAgents.length===0&&l.jsx("span",{className:"cw-error-text",children:ppt({name:Ie.name.trim()||"未命名",typeLabel:fpe(Ie.agentType).label})})]}),l.jsx(br,{meta:ia("basic"),children:l.jsxs("div",{className:"cw-form",children:[!xn&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:[Wt?"Agent 名称":"名称",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("input",{className:`cw-input ${Pn(ln)}`,value:Ie.name,placeholder:"assistant",onChange:te=>Qt({name:te.target.value})}),re&>?l.jsx("span",{className:"cw-error-text",children:gt}):l.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在执行流程中保持唯一。"})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:[Wt?"描述":"智能体描述",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${Pn(Sn)}`,value:Ie.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…",onChange:te=>Qt({description:te.target.value})}),re&&Sn?l.jsx("span",{className:"cw-error-text",children:"描述为必填项"}):l.jsx("span",{className:"cw-help",children:Wt?"完整描述会保留;部署时会自动整理为符合 Runtime 规范的单行描述。":"描述会显示在 Agent 列表与选择器中。"})]})]}),Gn?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"cw-section-desc cw-dependency-hint",children:"这是一个协作容器,本身不生成回答。请在左侧画布中 添加任务步骤,并通过拖拽调整它们的位置。"}),Ie.agentType==="loop"&&l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"最大轮次"}),l.jsx("input",{className:"cw-input",type:"number",min:1,value:Ie.maxIterations??3,onChange:te=>Qt({maxIterations:Math.max(1,Number(te.target.value)||1)})}),l.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):xn?l.jsxs("div",{className:"cw-field cw-remote-center-fields",children:[l.jsxs("div",{className:"cw-remote-center-head",children:[l.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),l.jsx(rpt,{value:((Ea=Ie.a2aRegistry)==null?void 0:Ea.registrySpaceId)??"",region:((nu=Ie.a2aRegistry)==null?void 0:nu.registryRegion)||Pl.region,invalid:re&&Ni,onChange:te=>Ft(zpe,te)}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":dt,"aria-controls":dn,onClick:()=>ge(te=>!te),children:[l.jsx("span",{children:"更多选项"}),l.jsx(U0,{className:`cw-more-options-chevron ${dt?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(xf,{initial:!1,children:dt&&l.jsx(wr.div,{id:dn,className:"cw-model-advanced",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeOut"},children:l.jsx(gO,{env:Zht,values:Fpe(Ie.a2aRegistry,{includeDefaults:!1}),onChange:Ft})})}),re&&Ni&&l.jsx("span",{className:"cw-error-text",children:"请选择 AgentKit 智能体中心"})]}):l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["系统提示词",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:l.jsx(Xht,{value:Ie.instruction,invalid:In,onChange:te=>Qt({instruction:te})})}),re&&In?l.jsx("span",{className:"cw-error-text",children:"系统提示词为必填项"}):l.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!Gn&&!xn&&l.jsxs(l.Fragment,{children:[l.jsx(br,{meta:ia("model"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field cw-model-source-field",children:[l.jsx("label",{className:"cw-label",children:"模型来源"}),l.jsx(UO,{className:"cw-model-source-options","aria-label":"模型来源",value:de,onChange:te=>{te!=="gateway"&&Le(te)},children:[{value:"ark",label:c==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",disabled:!0}].map(te=>l.jsx("div",{className:`cw-model-source-option ${de===te.value?"is-on":""}${te.disabled?" is-disabled":""}`,children:l.jsxs(UO.Item,{value:te.value,disabled:te.disabled,block:!0,className:"cw-model-source-control",children:[l.jsx("span",{children:te.label}),te.disabled&&l.jsx("span",{className:"cw-model-source-coming-soon",children:"待上线"})]})},te.value))})]}),de==="ark"?l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型配置"}),l.jsx(ipt,{value:Ie.modelName??"",cloudProvider:c,apiKeyId:($s=b.deployment)==null?void 0:$s.modelApiKeyId,apiKeyName:(Jl=b.deployment)==null?void 0:Jl.modelApiKeyName,onApiKeyChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},modelApiKeyId:te.id,modelApiKeyName:te.name}})),onChange:te=>Qt({modelName:te})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型名称"}),l.jsx("input",{className:"cw-input",value:Ie.modelName??"",onChange:te=>Qt({modelName:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label cw-label-with-link",children:[l.jsx("span",{children:"服务商 Provider"}),l.jsxs("a",{href:"https://docs.litellm.ai/docs/providers",target:"_blank",rel:"noopener noreferrer",onClick:te=>te.stopPropagation(),children:["LiteLLM 支持列表",l.jsx(e0,{"aria-hidden":"true"})]})]}),l.jsx("input",{className:"cw-input",value:Ie.modelProvider??"",placeholder:"openai",onChange:te=>Qt({modelProvider:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Base"}),l.jsx("input",{className:"cw-input",value:Ie.modelApiBase??"",placeholder:Dl(c),onChange:te=>Qt({modelApiBase:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Key"}),l.jsx("input",{className:"cw-input",type:"password",value:Ci?O[Ci.key]??"":"",placeholder:"请输入模型 API Key",autoComplete:"new-password",onChange:te=>{if(!Ci)return;const Me=te.currentTarget.value;v(ee=>({...ee,[Ci.key]:Me}))}})]})]})]})}),l.jsx(br,{meta:ia("tools"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"内置工具"}),l.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),l.jsx("div",{className:"cw-tools-list-shell",children:l.jsx(Kht,{items:At,selected:st,onToggle:Ai,scrollRows:6})}),l.jsx(xf,{initial:!1,children:st.includes("run_code")&&l.jsxs(wr.div,{className:"cw-tool-config",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-tool-config-head",children:[l.jsx("span",{className:"cw-label",children:"代码执行配置"}),l.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),l.jsx(gO,{env:((ec=Qp.find(te=>te.id==="run_code"))==null?void 0:ec.env)??[],values:((le=b.deployment)==null?void 0:le.envValues)??{},onChange:Yt})]})})]}),l.jsxs("div",{className:"cw-field cw-mcp-field",children:[l.jsx("label",{className:"cw-label",children:"MCP 工具"}),l.jsx(apt,{tools:kn,onChange:te=>Qt({mcpTools:te})})]})]})}),l.jsx(br,{meta:ia("skills"),children:l.jsx("div",{className:"cw-form",children:l.jsx(lpt,{selected:wn,onChange:te=>Qt({selectedSkills:te}),cloudProvider:c})})}),l.jsx(br,{meta:ia("knowledge"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(gS,{checked:Ie.knowledgebase,onChange:te=>Qt({knowledgebase:te}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:$S}),Ie.knowledgebase&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"知识库后端"}),l.jsx(OR,{options:PP,value:Ie.knowledgebaseBackend,onChange:te=>Qt({knowledgebaseBackend:te,knowledgebaseIndex:te==="viking"||te==="openviking"?Ie.knowledgebaseIndex:""})}),(Ie.knowledgebaseBackend??wf)==="viking"&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),l.jsx(spt,{value:Ie.knowledgebaseIndex??"",onChange:te=>{Qt({knowledgebaseIndex:te.id}),te.projectName&&Yt("DATABASE_VIKING_PROJECT",te.projectName),te.region&&Yt("DATABASE_VIKING_REGION",te.region),te.sourceKind&&Yt("DATABASE_VIKING_COLLECTION_KIND",te.sourceKind),Yt("DATABASE_VIKING_RESOURCE_ID",te.resourceId??"")}})]}),l.jsx(gO,{env:((gn=PP.find(te=>te.id===(Ie.knowledgebaseBackend??wf)))==null?void 0:gn.env)??[],values:((Wn=b.deployment)==null?void 0:Wn.envValues)??{},onChange:Yt,renderAfterField:(Ie.knowledgebaseBackend??wf)==="openviking"?te=>te.key==="DATABASE_OPENVIKING_USER_ID"?l.jsx(ept,{value:Ie.knowledgebaseIndex??"",onChange:Me=>Qt({knowledgebaseIndex:Me})}):null:void 0})]})]})}),Wt&&l.jsx(br,{meta:ia("memory"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(gS,{checked:Ie.memory.shortTerm,onChange:te=>Qt({memory:{...Ie.memory,shortTerm:te}}),title:"短期记忆",desc:"存储单会话上下文",showDescription:!0,icon:hJ}),Ie.memory.shortTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"短期记忆后端"}),l.jsx(OR,{options:RP,value:Ie.shortTermBackend,onChange:te=>Qt({shortTermBackend:te})}),l.jsx(gO,{env:((Vi=RP.find(te=>te.id===(Ie.shortTermBackend??"local")))==null?void 0:Vi.env)??[],values:((Ln=b.deployment)==null?void 0:Ln.envValues)??{},onChange:Yt})]}),l.jsx(gS,{checked:Ie.memory.longTerm,onChange:te=>Qt({memory:{...Ie.memory,longTerm:te}}),title:"长期记忆",desc:"存储跨会话上下文,通常使用向量化检索",showDescription:!0,icon:$S}),Ie.memory.longTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"长期记忆后端"}),l.jsx(OR,{options:IP,value:Ie.longTermBackend,onChange:te=>Qt({longTermBackend:te})}),l.jsx(gO,{env:((Tn=IP.find(te=>te.id===(Ie.longTermBackend??"local")))==null?void 0:Tn.env)??[],values:((ra=b.deployment)==null?void 0:ra.envValues)??{},onChange:Yt}),l.jsx(gS,{checked:!!Ie.autoSaveSession,onChange:te=>Qt({autoSaveSession:te}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:$S})]})]})})]})]})})})})})]})}),D==="validate"&&l.jsx("div",{className:"cw-validation-workspace",children:l.jsx("div",{className:"cw-validation-content",children:l.jsx(ypt,{enabled:me,disabledReason:oe,variants:Ne,draftSnapshot:pi,input:W,onInput:K,onSend:vs,onStartVariant:Mn,onDeployVariant:te=>void as(te),onAddVariant:Zl,onRemoveVariant:Gr,onToggleConfig:te=>{const Me=Ne.find(ee=>ee.id===te);Me&&tr(te,{configOpen:!Me.configOpen})},onCompleteConfig:Dr,onConfigChange:No,onOpenTrace:Ya})})}),D==="publish"&&l.jsx("div",{className:"cw-preview-body",children:ie?l.jsx(wQ,{embedded:!0,cloudProvider:c,project:ie,agentDraft:b,agentName:b.name||"未命名 Agent",agentCount:qpe(b),releaseConfiguration:ti?{modelName:ti.modelName||b.modelName||"默认模型",description:ti.description,instruction:ti.instruction,optimizations:ti.optimizations.flatMap(te=>{const Me=Wpe.find(ee=>ee.id===te);return Me?[Me.label]:[]})}:void 0,onChange:ue,onDeploy:os,onAgentAdded:n,onDeploymentTaskChange:s,deploymentActionLabel:o?"更新并发布":"部署",deploymentActionTargetId:"cw-publish-primary-action",deploymentRuntimeId:o==null?void 0:o.runtimeId,deploymentRuntimeName:w,deploymentRuntimeNameCustomized:!!o||!!((Qs=b.deployment)!=null&&Qs.runtimeNameCustomized),onDeploymentRuntimeNameChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},runtimeName:te,runtimeNameCustomized:!0}})),onDeploymentStarted:f,onDeploymentComplete:d,feishuEnabled:!!((dr=b.deployment)!=null&&dr.feishuEnabled),onFeishuEnabledChange:te=>{const Me={...b,deployment:{...b.deployment??{feishuEnabled:!1},feishuEnabled:te}};y(Me)},deploymentEnv:vi.specs,requiredSecretEnv:en,requiredSecretEnvValues:O,onRequiredSecretEnvChange:(te,Me)=>v(ee=>({...ee,[te]:Me})),deploymentEnvValues:{...(ws=fn.deployment)==null?void 0:ws.envValues,...O,...vi.fixedValues},onDeploymentEnvChange:Yt,network:(ls=b.deployment)==null?void 0:ls.network,onNetworkChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},network:te}})),deployRegion:Re,onDeployRegionChange:Ee,deploymentTelemetry:{source:"scratch",createMode:a,aiAssisted:M},onExportYaml:()=>Hht(`${fn.name||"agent"}.yaml`,Dft(fn),"text/yaml")}):l.jsxs("div",{className:"cw-publish-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"}),l.jsx("strong",{children:"正在生成发布配置"}),l.jsx("span",{children:"校验 Agent 结构并准备部署快照…"})]})})]}),l.jsx(vpt,{mode:D,busy:ye,onChange:Co,assistant:D==="build"?ji:void 0}),ae&&l.jsx(Bpe,{testRunId:ae.runId,sessionId:ae.sessionId,title:`调用链路 · ${ae.variantName}`,onClose:()=>pe(null)}),z&&l.jsx(Mf,{variant:"warning",title:"离开调试?",description:"离开调试页面后,当前环境将被清理。您可以通过重新启动环境进行新的测试。",confirmLabel:Be?"清理中...":"确定离开",closeLabel:"关闭离开调试确认",busy:Be,onCancel:gr,onConfirm:()=>void ul()}),P&&l.jsx("div",{className:"confirm-scrim",onClick:()=>Q(null),children:l.jsxs("div",{className:"confirm-box cw-ai-error-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"ai-generate-error-title","aria-describedby":"ai-generate-error-message",onClick:te=>te.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",id:"ai-generate-error-title",children:"智能生成失败"}),l.jsx("div",{className:"cw-ai-error-message",id:"ai-generate-error-message",children:P}),l.jsx("div",{className:"confirm-actions",children:l.jsx("button",{type:"button",className:"confirm-btn cw-ai-error-close",onClick:()=>Q(null),children:"关闭"})})]})})]})}const $H=50*1024*1024,XL=800,Spt={name:"code_package",files:[]};function Ept(e){let n=e.replace(/\.zip$/i,"").trim().replace(/[^A-Za-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return n||(n="uploaded_agent"),/^[A-Za-z_]/.test(n)||(n=`agent_${n}`),n==="user"&&(n="uploaded_agent"),n.slice(0,64)}function Zpe(e){const t=e.replace(/\\/g,"/").replace(/^\.\//,"");if(!t||t.endsWith("/"))return null;if(t.startsWith("/")||t.includes("\0"))throw new Error(`压缩包包含非法路径:${e}`);const n=t.split("/");if(n.some(i=>!i||i==="."||i===".."))throw new Error(`压缩包包含非法路径:${e}`);return n[0]==="__MACOSX"||n[n.length-1]===".DS_Store"?null:n.join("/")}function kpt(e){const t=e.flatMap(a=>{const o=Zpe(a.name);return o?[{path:o,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>XL)throw new Error(`代码包文件数不能超过 ${XL} 个。`);const r=new Set(t.map(a=>a.path.split("/")[0])).size===1&&t.every(a=>a.path.includes("/"))?t.map(a=>({...a,path:a.path.split("/").slice(1).join("/")})):t,s=new Set;for(const a of r){if(s.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);s.add(a.path)}return Tpt(r),r}function Tpt(e){const t=new Set(e.map(r=>r.path)),n=e.find(r=>r.path==="agentkit.yaml");let i="app.py";if(n){let r;try{r=rGe(n.content)}catch(o){throw new Error(`agentkit.yaml 无法解析:${o instanceof Error?o.message:String(o)}`)}if(r!==null&&(typeof r!="object"||Array.isArray(r)))throw new Error("agentkit.yaml 根节点必须是对象。");const s=r&&typeof r=="object"&&!Array.isArray(r)?r.common:void 0;if(s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s)))throw new Error("agentkit.yaml 的 common 必须是对象。");const a=s&&typeof s=="object"&&!Array.isArray(s)?s.entry_point:void 0;if(a!==void 0){if(typeof a!="string")throw new Error("agentkit.yaml 的 common.entry_point 必须是文件路径。");const o=Zpe(a);if(!o)throw new Error("agentkit.yaml 的 common.entry_point 不是有效文件路径。");i=o}}if(!t.has(i))throw n&&i!=="app.py"?new Error(`代码包中不存在 agentkit.yaml 声明的启动入口:${i}`):new Error("代码包根目录必须包含 app.py,或在 agentkit.yaml 的 common.entry_point 中声明已有入口。");return i}function _pt({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:i,onDeploymentComplete:r,cloudProvider:s="volcengine",initialDeployRegion:a=Qi(s)}){const o=m.useRef(null),c=m.useRef(0),[u,d]=m.useState(null),[f,h]=m.useState(""),[p,g]=m.useState(!1),[b,y]=m.useState(!1),[O,v]=m.useState(!1),[x,w]=m.useState(""),[E,S]=m.useState(a),[k,T]=m.useState();m.useEffect(()=>()=>{c.current+=1},[]);async function A(L){const P=++c.current;if(w(""),!L.name.toLowerCase().endsWith(".zip")){w("请选择 .zip 格式的代码包。");return}if(L.size>$H){w("代码包不能超过 50 MB。");return}y(!0);try{const Q=await Mpe(new Uint8Array(await L.arrayBuffer()),{maxEntries:XL,maxUncompressedBytes:$H}),j=kpt(Q);if(P!==c.current)return;h(L.name),d({name:Ept(L.name),files:j})}catch(Q){if(P!==c.current)return;h(""),d(null),w(Q instanceof Error?Q.message:String(Q))}finally{P===c.current&&y(!1)}}function N(L){var Q;const P=(Q=L.currentTarget.files)==null?void 0:Q[0];L.currentTarget.value="",P&&A(P)}function C(L){var Q;L.preventDefault(),v(!1);const P=(Q=L.dataTransfer.files)==null?void 0:Q[0];P&&A(P)}async function M(L,P,Q){const j=k&&k.mode!=="public"?{mode:k.mode,vpc_id:k.vpcId,subnet_ids:k.subnetIds,enable_shared_internet_access:k.enableSharedInternetAccess}:void 0;return w1(L.name,L.files,{region:E,projectName:"default",network:j},{...Q,onStage:P})}return l.jsxs("div",{className:"package-create package-create-preview",children:[l.jsx(wQ,{cloudProvider:s,project:u??Spt,agentName:(u==null?void 0:u.name)||"代码包",onChange:u?d:void 0,onDeploy:M,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:i,onDeploymentComplete:r,network:k,onNetworkChange:T,deployRegion:E,onDeployRegionChange:S,deploymentTelemetry:{source:"code_package",createMode:"code_package",aiAssisted:!1},onBack:e,backLabel:"返回创建方式",deployDisabled:!u||b,deployDisabledReason:b?"正在读取代码包":u?void 0:"请先上传代码包",deploymentPrimaryPane:l.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[l.jsx("div",{className:"package-source-label",children:"代码包"}),l.jsxs("div",{className:`package-dropzone${O?" is-dragging":""}${u?" is-ready":""}`,onDragEnter:L=>{L.preventDefault(),v(!0)},onDragOver:L=>L.preventDefault(),onDragLeave:L=>{L.currentTarget.contains(L.relatedTarget)||v(!1)},onDrop:C,onClick:()=>{var L;b||(L=o.current)==null||L.click()},onKeyDown:L=>{var P;!b&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),(P=o.current)==null||P.click())},role:"button",tabIndex:b?-1:0,"aria-label":u?"重新上传代码包":"上传代码包","aria-disabled":b,children:[l.jsx("strong",{children:b?"正在读取代码包…":u?f:"请上传代码包"}),l.jsx("span",{children:u?`已识别 ${u.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB;可使用 app.py,或由 agentkit.yaml 声明入口"}),l.jsx("div",{className:"package-upload-actions",children:u&&l.jsx("button",{type:"button",className:"package-upload-secondary",onClick:L=>{L.stopPropagation(),g(!0)},onKeyDown:L=>L.stopPropagation(),children:"查看文件"})}),l.jsx("input",{ref:o,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:N})]}),x&&l.jsx("div",{className:"package-create-error",role:"alert",children:x})]})}),u&&l.jsx(Qpe,{project:u,open:p,onClose:()=>g(!1),onChange:d})]})}const Apt="/web/agent-migrations",eN=39e4;class Ia extends Error{constructor(t,n,i="MIGRATION_ERROR",r=!1,s="",a=""){super(t),this.status=n,this.code=i,this.retryable=r,this.statusText=s,this.rawResponse=a,this.name="MigrationApiError"}}const Npt=new Set(["langchain","langgraph","adk","strands","agentcore","dify","any"]),Cpt=new Set(["awaiting_upload","analyzing","needs_input","analysis_ready","migrating","validating","packaging","succeeded","succeeded_with_warnings","partial","failed","cancelled","expired"]),jpt=new Set(["reasoning","message","plan","command","status"]),Rpt=new Set(["running","completed","failed"]);function yi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function Yh(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw new Error(`${t}格式错误。`);return e}function Iy(e,t){if(typeof e!="string"||!Npt.has(e))throw new Error(`${t}格式错误。`);return e}function Ipt(e){const t=yi(e,"迁移分析结果"),n=t.recommended===null?null:yi(t.recommended,"迁移建议"),i=yi(t.boundary,"迁移边界");if(t.schema_version!==1||!["needs_input","recommendation_ready","unsupported"].includes(String(t.status))||typeof t.attempt!="number"||typeof t.input_sha256!="string"||typeof t.summary!="string"||!Array.isArray(t.frameworks)||!Array.isArray(t.entries)||!Array.isArray(t.questions))throw new Error("迁移分析结果格式错误。");return{schema_version:1,status:t.status,attempt:t.attempt,input_sha256:t.input_sha256,summary:t.summary,frameworks:t.frameworks.map(r=>{const s=yi(r,"框架候选");if(!["high","medium","low"].includes(String(s.confidence))||!Array.isArray(s.evidence))throw new Error("框架候选格式错误。");return{id:Iy(s.id,"框架候选"),confidence:s.confidence,evidence:s.evidence.map(a=>{const o=yi(a,"分析证据");if(typeof o.path!="string"||typeof o.line!="number"||typeof o.reason!="string")throw new Error("分析证据格式错误。");return{path:o.path,line:o.line,reason:o.reason}})}}),recommended:n===null?null:{framework:Iy(n.framework,"推荐框架"),entry:n.entry===null||typeof n.entry=="string"?n.entry:null,reason:typeof n.reason=="string"?n.reason:""},entries:t.entries.map(r=>{const s=yi(r,"入口候选");if(typeof s.value!="string"||typeof s.evidence!="string")throw new Error("入口候选格式错误。");return{value:s.value,framework:Iy(s.framework,"入口框架"),evidence:s.evidence}}),boundary:{include:Yh(i.include,"迁移包含范围"),exclude:Yh(i.exclude,"迁移排除范围")},assumptions:Yh(t.assumptions,"分析假设"),questions:t.questions.map(r=>{const s=yi(r,"待确认问题");if(typeof s.id!="string"||typeof s.prompt!="string"||typeof s.required!="boolean")throw new Error("待确认问题格式错误。");return{id:s.id,prompt:s.prompt,required:s.required}}),warnings:Yh(t.warnings,"迁移警告")}}function Hp(e){const t=yi(e,"迁移会话"),n=yi(t.artifact,"迁移产物状态");if(typeof t.id!="string"||typeof t.state!="string"||!Cpt.has(t.state)||typeof t.message!="string"||typeof t.sourceFileName!="string"||typeof t.instruction!="string"||typeof t.createdAt!="string"&&typeof t.createdAt!="number"||typeof t.expiresAt!="string"||typeof t.sessionTtlSeconds!="number"||typeof t.canModify!="boolean"||typeof t.canUpload!="boolean"||typeof t.canAnswer!="boolean"||typeof t.canConfirm!="boolean"||typeof t.canStop!="boolean")throw new Error("迁移会话格式错误。");const i={id:t.id,state:t.state,message:t.message,sourceFileName:t.sourceFileName,instruction:t.instruction,createdAt:t.createdAt,expiresAt:t.expiresAt,sessionTtlSeconds:t.sessionTtlSeconds,canModify:t.canModify,canUpload:t.canUpload,canAnswer:t.canAnswer,canConfirm:t.canConfirm,canStop:t.canStop,artifact:{state:typeof n.state=="string"?n.state:"none",previewReady:n.previewReady===!0,downloadReady:n.downloadReady===!0,deployReady:n.deployReady===!0}};if(t.analysis!==void 0&&(i.analysis=Ipt(t.analysis)),t.analysisRef!==void 0){const r=yi(t.analysisRef,"分析结果引用");if(typeof r.attempt!="number"||typeof r.sha256!="string"||typeof r.inputSha256!="string")throw new Error("分析结果引用格式错误。");i.analysisRef={attempt:r.attempt,sha256:r.sha256,inputSha256:r.inputSha256}}if(t.confirmation!==void 0){const r=yi(t.confirmation,"迁移确认");i.confirmation={...r.framework!==void 0?{framework:Iy(r.framework,"确认框架")}:{},...r.entry===null||typeof r.entry=="string"?{entry:r.entry}:{},...typeof r.app_name=="string"?{app_name:r.app_name}:{}}}if(t.error!==void 0){const r=yi(t.error,"迁移错误");i.error={code:typeof r.code=="string"?r.code:"MIGRATION_ERROR",message:typeof r.message=="string"?r.message:t.message,retryable:r.retryable===!0}}return i}function Ppt(e){const t=yi(e,"迁移执行动态");if(typeof t.available!="boolean"||typeof t.complete!="boolean"||!Array.isArray(t.items))throw new Error("迁移执行动态格式错误。");return{available:t.available,complete:t.complete,items:t.items.map(n=>{const i=yi(n,"迁移执行动态项");if(typeof i.id!="string"||typeof i.kind!="string"||!jpt.has(i.kind)||typeof i.status!="string"||!Rpt.has(i.status)||typeof i.title!="string"||i.detail!==void 0&&typeof i.detail!="string")throw new Error("迁移执行动态项格式错误。");return{id:i.id,kind:i.kind,status:i.status,title:i.title,...typeof i.detail=="string"?{detail:i.detail}:{}}})}}function Mpt(e){const t=yi(e,"迁移产物"),n=yi(t.cli,"CLI 信息"),i=yi(t.migration,"迁移信息"),r=yi(t.startup,"启动信息"),s=yi(t.environment,"环境变量信息"),a=yi(t.verification,"校验信息"),o=yi(t.report,"迁移报告"),c=yi(t.artifact,"产物归档"),u=s.defaults===void 0?{}:yi(s.defaults,"环境变量默认值");if(t.schema_version!==1||!["succeeded","succeeded_with_warnings","partial"].includes(String(t.status))||typeof n.name!="string"||typeof n.version!="string"||!["structured","agentic"].includes(String(i.engine))||typeof i.framework!="string"||!Array.isArray(t.files)||typeof r.module!="string"||typeof r.object!="string"||!["passed","failed","degraded"].includes(String(a.status))||!Array.isArray(a.checks)||typeof o.path!="string"||c.path!=="migration-result.zip"||typeof c.size!="number"||typeof c.sha256!="string"||typeof t.created_at!="string")throw new Error("迁移产物格式错误。");const d=Yh(s.required,"必需环境变量"),f=Yh(s.optional,"可选环境变量"),h=new Set([...d,...f]),p=Object.fromEntries(Object.entries(u).map(([g,b])=>{if(!h.has(g)||typeof b!="string")throw new Error("环境变量默认值格式错误。");return[g,b]}));return{schema_version:1,...typeof t.run_id=="string"?{run_id:t.run_id}:{},cli:{name:n.name,version:n.version},migration:{engine:i.engine,framework:i.framework,...typeof i.entry=="string"?{entry:i.entry}:{},...typeof i.source_sha256=="string"?{source_sha256:i.source_sha256}:{},...typeof i.provenance_sha256=="string"?{provenance_sha256:i.provenance_sha256}:{}},status:t.status,files:t.files.map(g=>{const b=yi(g,"迁移产物文件");if(typeof b.path!="string"||typeof b.size!="number"||typeof b.sha256!="string"||typeof b.mode!="string")throw new Error("迁移产物文件格式错误。");return{path:b.path,size:b.size,sha256:b.sha256,mode:b.mode}}),startup:{module:r.module,object:r.object,...Array.isArray(r.command)&&r.command.every(g=>typeof g=="string")?{command:r.command}:{}},environment:{required:d,optional:f,defaults:p},verification:{status:a.status,checks:a.checks.map(g=>{const b=yi(g,"迁移校验项");if(typeof b.name!="string"||!["passed","failed"].includes(String(b.status)))throw new Error("迁移校验项格式错误。");return{name:b.name,status:b.status,...typeof b.detail=="string"?{detail:b.detail}:{}}})},warnings:Yh(t.warnings,"迁移产物警告"),report:{path:o.path},artifact:{path:"migration-result.zip",size:c.size,sha256:c.sha256},created_at:t.created_at}}async function cl(e,t={},n=_o){return fetch(vo(`${Apt}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}function Lpt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const n=t,i=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").join("."):"",r=typeof n.msg=="string"?n.msg:"";return r?i?`${i}: ${r}`:r:""}).filter(Boolean).join(";"):""}async function TQ(e,t){var i;const n=await e.text().catch(()=>"");try{const r=yi(JSON.parse(n),"错误响应");if(Array.isArray(r.detail)){const a=Lpt(r.detail);return new Ia(a?`请求参数校验失败:${a}`:t,e.status,"MIGRATION_REQUEST_INVALID",!1,e.statusText,n)}if(typeof r.detail=="string")return new Ia(r.detail,e.status,typeof r.code=="string"?r.code:"MIGRATION_ERROR",r.retryable===!0,e.statusText,n);const s=r.detail&&typeof r.detail=="object"?yi(r.detail,"错误详情"):r;return new Ia(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"MIGRATION_ERROR",s.retryable===!0,e.statusText,n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失";return new Ia(`${t}(HTTP ${e.status},Content-Type: ${r})。请检查代理或网关配置。`,e.status,"MIGRATION_ERROR",!1,e.statusText,n)}}async function tu(e,t){if(!e.ok)throw await TQ(e,t);if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Ia(`${t}:服务端返回非 JSON 响应(HTTP ${e.status})。请检查代理或网关配置。`,e.status,"MIGRATION_RESPONSE_INVALID",!1,e.statusText);return e.json()}async function Dpt(e){const t=yi(await tu(await cl("/capabilities",{signal:e}),"读取迁移能力失败"),"迁移能力");if(typeof t.enabled!="boolean"||typeof t.reason!="string"||typeof t.maxUploadBytes!="number"||typeof t.sessionTtlSeconds!="number"||!Array.isArray(t.frameworks))throw new Error("迁移能力格式错误。");return{enabled:t.enabled,reason:t.reason,maxUploadBytes:t.maxUploadBytes,sessionTtlSeconds:t.sessionTtlSeconds,frameworks:t.frameworks.map(n=>Iy(n,"迁移框架"))}}async function ER(e){const t=yi(await tu(await cl("/tasks",{signal:e}),"读取迁移会话失败"),"迁移会话列表");if(!Array.isArray(t.items))throw new Error("迁移会话列表格式错误。");return t.items.map(Hp)}async function $pt(e){return Hp(await tu(await cl("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.taskId,sourceFileName:e.sourceFileName,instruction:e.instruction}),signal:e.signal},eN),"创建迁移会话失败"))}async function QH(e,t,n){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}/source`,{method:"PUT",headers:{"Content-Type":"application/zip"},body:t,signal:n},eN),"上传迁移项目失败"))}async function kR(e,t){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取迁移会话失败"))}async function Qpt(e,t){return Ppt(await tu(await cl(`/tasks/${encodeURIComponent(e)}/activity`,{signal:t,cache:"no-store"}),"读取迁移执行动态失败"))}async function Bpt(e){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e.taskId)}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({framework:e.framework,entry:e.entry||null,appName:e.appName,instruction:e.instruction,analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,boundaryConfirmed:!0}),signal:e.signal},eN),"启动迁移失败"))}async function Upt(e){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e.taskId)}/answers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,answers:e.answers}),signal:e.signal},eN),"提交分析补充信息失败"))}async function zpt(e,t){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}/stop`,{method:"POST",signal:t}),"终止迁移失败"))}async function Fpt(e,t){return Mpt(await tu(await cl(`/tasks/${encodeURIComponent(e)}/artifact`,{signal:t}),"读取迁移产物失败"))}async function Vpt(e,t,n){var s;const i=new URLSearchParams({path:t}),r=await cl(`/tasks/${encodeURIComponent(e)}/artifact/file?${i}`,{signal:n},kr);if(!r.ok)throw await TQ(r,"读取迁移产物文件失败");return{blob:await r.blob(),mimeType:((s=r.headers.get("content-type"))==null?void 0:s.split(";",1)[0])||"application/octet-stream"}}function Xpt(e,t){var i;return((i=(e.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:i[1])||t}async function qpt(e,t,n){const i=await cl(`/tasks/${encodeURIComponent(e)}/download`,{signal:n},kr);if(!i.ok)throw await TQ(i,"下载迁移产物失败");const r=URL.createObjectURL(await i.blob()),s=document.createElement("a");s.href=r,s.download=Xpt(i,`${t}-migrated.zip`),s.click(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Yp({children:e,...t}){return l.jsx("svg",{...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e})}function Hpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"m10 6-6 6 6 6M4 12h16"})})}function Ypt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 3v12m-4-4 4 4 4-4M5 20h14"})})}function EE(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M6 3.5h8l4 4V20H6zM14 3.5v4h4M9 12h6M9 15.5h6"})})}function Gpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function Wpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M14.5 4.5c2.3-.9 4.2-.8 5-.6.2.8.3 2.7-.6 5l-5.1 5.1-3.8-3.8zM15.4 8.6h.1M10.3 10.5l-3.8.7-2.1 2.1 5.3.2M13.5 13.7l-.7 3.8-2.1 2.1-.2-5.3M7.2 16.8l-2.8 2.8"})})}function Zpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 16V4m-4 4 4-4 4 4M5 20h14"})})}function BH(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const Kpt=new Set(["MODEL_AGENT_API_KEY"]),Jpt=new Set(["MODEL_AGENT_NAME","MODEL_NAME"]),emt=new Set(["VOLCENGINE_ACCESS_KEY","VOLCENGINE_SECRET_KEY","VOLCENGINE_SESSION_TOKEN","BYTEPLUS_ACCESS_KEY","BYTEPLUS_SECRET_KEY","BYTEPLUS_SESSION_TOKEN","VEADK_DISABLE_EXPIRE_AT"]);function kE(e){return!emt.has(e)}function qL(e){return Kpt.has(e)||/(?:API_KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|CREDENTIAL)$/.test(e)}function tmt(e,t){const n={},i=new Set([...e.environment.required,...e.environment.optional]);for(const r of i){if(!kE(r)||qL(r))continue;const s=r==="MODEL_AGENT_API_BASE"?Dl(t):Jpt.has(r)?t0(t):e.environment.defaults[r];s!=null&&s.trim()&&(n[r]=s)}return n}const nmt=50*1024*1024,TR=1200,UH=3e3,imt=5e3,zH=500,rmt=()=>{},Kpe={langchain:"LangChain",langgraph:"LangGraph",adk:"Google ADK",strands:"Strands",agentcore:"AgentCore",dify:"Dify",any:"Any(通用迁移)"},_R=new Set(["langchain","langgraph","adk","strands","agentcore"]);function smt(e){switch(e){case"awaiting_upload":return"待上传";case"analyzing":return"分析中";case"needs_input":return"待补充";case"analysis_ready":return"待确认";case"migrating":return"迁移中";case"validating":return"校验中";case"packaging":return"打包中";case"succeeded":return"已完成";case"succeeded_with_warnings":return"已完成,有提示";case"partial":return"部分完成";case"failed":return"失败";case"cancelled":return"已终止";case"expired":return"已过期"}}function AR(e){return e.state==="partial"&&e.artifact.previewReady?"迁移产物已生成,但交付不完整,请查看迁移提示。":["succeeded","succeeded_with_warnings"].includes(e.state)&&e.artifact.previewReady?e.state==="succeeded_with_warnings"?"迁移产物已生成,请查看迁移提示。":"迁移产物已生成。":e.message}function amt(e){switch(e){case"passed":return"产物校验通过";case"failed":return"产物校验未通过";case"degraded":return"产物校验未完成"}}function NR({stage:e}){const t=[{id:"session",label:"创建迁移环境"},{id:"upload",label:"上传项目"},{id:"analysis",label:"分析项目"}],n=t.findIndex(i=>i.id===e);return l.jsx("div",{className:"migration-transfer-progress",role:"status",children:t.map((i,r)=>l.jsxs("div",{className:r=n)return{title:"迁移环境已过期",detail:"会话和产物已无法访问"};const i=Math.max(0,n-t),r=Math.floor(i/6e4),s=Math.floor(i%6e4/1e3);return{title:`迁移环境将在 ${r} 分 ${s} 秒后过期`,detail:"过期后无法查看会话,也无法预览、下载或部署产物"}}function fmt(e,t){let n=!1;const i=e.map(r=>{if(r.state==="expired")return r;const s=new Date(r.expiresAt).getTime();return!Number.isFinite(s)||ti.id!==t.id);return[t,...n].sort((i,r)=>{const s=typeof i.createdAt=="number"?i.createdAt*1e3:new Date(i.createdAt).getTime();return(typeof r.createdAt=="number"?r.createdAt*1e3:new Date(r.createdAt).getTime())-s})}function hmt(e,t){return e.find(n=>n.id===t)??null}function pmt(e,t){return e.startsWith("text/")||/(?:json|javascript|xml|yaml)/i.test(e)||/\.(?:py|ts|tsx|js|jsx|json|ya?ml|md|txt|toml|ini|cfg|env|sh|dockerfile)$/i.test(t)}function mmt({analysis:e}){var t;return l.jsxs("div",{className:"migration-analysis",children:[l.jsx(qp,{text:e.summary,allowRawHtml:!1}),l.jsxs("div",{className:"migration-analysis__facts",children:[e.recommended?l.jsxs("section",{children:[l.jsx("h3",{children:"建议迁移方式"}),l.jsx("strong",{children:Kpe[e.recommended.framework]}),l.jsx("p",{children:e.recommended.reason})]}):null,l.jsxs("section",{children:[l.jsx("h3",{children:"迁移范围"}),l.jsx("ul",{children:e.boundary.include.map(n=>l.jsx("li",{children:n},n))})]}),e.boundary.exclude.length>0?l.jsxs("section",{children:[l.jsx("h3",{children:"不在本次范围"}),l.jsx("ul",{children:e.boundary.exclude.map(n=>l.jsx("li",{children:n},n))})]}):null]}),(t=e.frameworks[0])!=null&&t.evidence.length?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看分析证据"}),l.jsx("ul",{children:e.frameworks.flatMap(n=>n.evidence.map(i=>l.jsxs("li",{children:[l.jsxs("code",{children:[i.path,":",i.line]}),l.jsx("span",{children:i.reason})]},`${n.id}:${i.path}:${i.line}`)))})]}):null,e.warnings.length>0?l.jsx("div",{className:"migration-analysis__warnings",children:e.warnings.map(n=>l.jsx("p",{children:n},n))}):null,e.assumptions.length>0?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看关键假设"}),l.jsx("ul",{children:e.assumptions.map(n=>l.jsx("li",{children:n},n))})]}):null]})}function gmt(e){return e.kind==="reasoning"&&e.detail?{kind:"thinking",text:e.detail,done:e.status!=="running"}:e.kind==="message"&&e.detail?{kind:"text",text:e.detail}:null}function bmt({activity:e,loading:t,error:n,analyzing:i}){const r=(e==null?void 0:e.items)??[];return l.jsxs("section",{className:"migration-activity","aria-label":"Codex 执行动态",children:[l.jsxs("div",{className:"migration-activity__heading",children:[l.jsx("span",{className:`migration-activity__marker${e!=null&&e.complete?" is-complete":""}`,"aria-hidden":"true"}),l.jsx("strong",{children:"Codex 执行动态"})]}),r.length>0?l.jsx("div",{className:"migration-activity__stream",children:r.map(s=>{const a=gmt(s);return a?l.jsx(vA,{blocks:[a],onAction:rmt},s.id):l.jsxs("div",{className:"migration-activity__status","data-status":s.status,children:[l.jsx("span",{className:"migration-activity__marker","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:s.title}),s.detail?l.jsx("small",{children:s.detail}):null]})]},s.id)})}):t||!(e!=null&&e.complete)?l.jsx(oi,{children:i?"Codex 正在开始分析…":"Codex 正在开始迁移…"}):null,n?l.jsx("p",{className:"migration-activity__error",role:"status",children:n}):null]})}function Omt({task:e,artifact:t}){var d;const[n,i]=m.useState(""),[r,s]=m.useState(((d=t.files[0])==null?void 0:d.path)??""),[a,o]=m.useState(null),c=t.files.find(f=>f.path===r)??t.files[0],u=m.useMemo(()=>{const f=n.trim().toLocaleLowerCase();return(f?t.files.filter(p=>p.path.toLocaleLowerCase().includes(f)):t.files).slice(0,zH)},[t.files,n]);return m.useEffect(()=>{if(!c)return;if(c.size>2*1024*1024){o({path:c.path,loading:!1,error:"该文件超过 2 MiB,请下载完整产物后查看。"});return}const f=new AbortController;let h="";return o({path:c.path,loading:!0}),Vpt(e.id,c.path,f.signal).then(async({blob:p,mimeType:g})=>{if(!f.signal.aborted){if(g.startsWith("image/")){h=URL.createObjectURL(p),o({path:c.path,loading:!1,imageUrl:h});return}if(pmt(g,c.path)){const b=await p.text();if(f.signal.aborted)return;o({path:c.path,loading:!1,text:b});return}o({path:c.path,loading:!1,error:"该文件不支持在线预览,请下载完整产物后查看。"})}}).catch(p=>{f.signal.aborted||o({path:c.path,loading:!1,error:p instanceof Error?p.message:String(p)})}),()=>{f.abort(),h&&URL.revokeObjectURL(h)}},[c,e.id]),l.jsxs("div",{className:"migration-artifact-browser",children:[l.jsxs("aside",{"aria-label":"迁移产物文件",children:[l.jsxs("label",{className:"migration-artifact-browser__search",children:[l.jsx("span",{className:"sr-only",children:"搜索产物文件"}),l.jsx("input",{value:n,onChange:f=>i(f.currentTarget.value),placeholder:"搜索文件"})]}),l.jsx("div",{className:"migration-artifact-browser__files",children:u.map(f=>l.jsxs("button",{type:"button",className:f.path===(c==null?void 0:c.path)?"is-active":"",onClick:()=>s(f.path),title:f.path,children:[l.jsx(EE,{}),l.jsx("span",{children:f.path}),l.jsx("small",{children:HL(f.size)})]},f.path))}),t.files.length>u.length?l.jsxs("p",{className:"migration-artifact-browser__limit",children:["仅展示前 ",zH," 项,请搜索具体文件。"]}):null]}),l.jsxs("section",{children:[l.jsxs("header",{children:[l.jsx("span",{title:c==null?void 0:c.path,children:(c==null?void 0:c.path)||"未选择文件"}),c?l.jsx("small",{children:HL(c.size)}):null]}),l.jsx("div",{className:"migration-artifact-browser__preview",children:c?(a==null?void 0:a.path)!==c.path||a.loading?l.jsx(oi,{children:"正在读取产物文件…"}):a.error?l.jsx("p",{role:"status",children:a.error}):a.imageUrl?l.jsx("img",{src:a.imageUrl,alt:c.path}):l.jsx(sQ,{value:a.text??"",path:c.path,readOnly:!0,onChange:()=>{}}):l.jsx("p",{children:"暂无可预览文件。"})})]})]})}function ymt({cloudProvider:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:i,onDeploymentStarted:r,onDeploymentComplete:s,initialDeployRegion:a=Qi(e)}){var st,At,Ut,kn,wn,Ai,Gn,xn;const o=m.useRef(null),c=m.useRef(""),u=m.useRef(null),[d,f]=m.useState(null),[h,p]=m.useState([]),[g,b]=m.useState(""),[y,O]=m.useState(null),[v,x]=m.useState(!1),[w,E]=m.useState(!0),[S,k]=m.useState(""),[T,A]=m.useState(""),[N,C]=m.useState(""),[M,L]=m.useState(!1),[P,Q]=m.useState(Date.now()),[j,$]=m.useState(null),[U,B]=m.useState("langchain"),[I,X]=m.useState(""),[q,D]=m.useState(""),[H,re]=m.useState({}),[fe,Ae]=m.useState(null),[J,ie]=m.useState(""),[ue,ye]=m.useState(!1),[Se,Re]=m.useState(0),[Ee,me]=m.useState(null),[oe,Ne]=m.useState(!1),[Oe,Ve]=m.useState(""),[We,De]=m.useState(!1),[mt,at]=m.useState(!1),[Rt,qe]=m.useState(a),[W,K]=m.useState(),[ae,pe]=m.useState({}),z=hmt(h,g),ve=j?Math.max(0,Math.floor((P-j)/1e3)):0,Be=Ee==null?void 0:Ee.items[Ee.items.length-1],Je=[(Ee==null?void 0:Ee.items.length)??0,(Be==null?void 0:Be.id)??"",(Be==null?void 0:Be.status)??"",((st=Be==null?void 0:Be.detail)==null?void 0:st.length)??0].join(":"),{ref:kt,onScroll:Mt}=Ese(`${(z==null?void 0:z.id)??"new"}:${(z==null?void 0:z.state)??"new"}:${Je}`);async function Tt(de,Le=!0,ut){try{const gt=await kR(de,ut);return ut!=null&&ut.aborted?null:(p(ln=>bu(ln,gt)),C(""),L(!1),gt)}catch(gt){return ut!=null&&ut.aborted||Le&&(C(gt instanceof Error?gt.message:String(gt)),L(gt instanceof Ia&>.retryable)),null}}async function dt(de){try{const Le=await ER(de);if(de!=null&&de.aborted)return;p(Le),C(""),L(!1)}catch(Le){if(de!=null&&de.aborted)return;C(Le instanceof Error?Le.message:String(Le)),L(Le instanceof Ia&&Le.retryable)}}m.useEffect(()=>{const de=new AbortController;return E(!0),A(""),Promise.all([Dpt(de.signal),ER(de.signal)]).then(([Le,ut])=>{de.signal.aborted||(f(Le),p(ut))}).catch(Le=>{de.signal.aborted||A(Le instanceof Error?Le.message:String(Le))}).finally(()=>{de.signal.aborted||E(!1)}),()=>de.abort()},[]),m.useEffect(()=>()=>{var de;(de=u.current)==null||de.abort(),u.current=null},[]),m.useEffect(()=>{const de=window.setInterval(()=>{const Le=Date.now();Q(Le),p(ut=>fmt(ut,Le))},1e3);return()=>window.clearInterval(de)},[]),m.useEffect(()=>{if(!h.some(ut=>yh(ut.state)))return;const de=new AbortController,Le=window.setInterval(()=>{ER(de.signal).then(ut=>{de.signal.aborted||p(ut),C(""),L(!1)}).catch(ut=>{de.signal.aborted||(C(ut instanceof Error?ut.message:String(ut)),L(ut instanceof Ia&&ut.retryable),ut instanceof Ia&&ut.retryable||window.clearInterval(Le))})},imt);return()=>{de.abort(),window.clearInterval(Le)}},[h.some(de=>yh(de.state))]),m.useEffect(()=>{if(!z||!yh(z.state))return;const de=new AbortController;let Le;const ut=async()=>{try{const gt=await kR(z.id,de.signal);if(de.signal.aborted)return;p(ln=>bu(ln,gt)),C(""),L(!1),yh(gt.state)&&(Le=window.setTimeout(()=>void ut(),TR))}catch(gt){if(de.signal.aborted)return;C(gt instanceof Error?gt.message:String(gt)),L(gt instanceof Ia&>.retryable),gt instanceof Ia&>.retryable&&(Le=window.setTimeout(()=>void ut(),TR))}};return Le=window.setTimeout(()=>void ut(),TR),()=>{de.abort(),Le!==void 0&&window.clearTimeout(Le)}},[z==null?void 0:z.id,z==null?void 0:z.state]),m.useEffect(()=>{const de=kt.current;de&&(de.scrollTop=de.scrollHeight,Mt())},[g,kt,Mt]),m.useEffect(()=>{if(me(null),Ve(""),Ne(!1),!z||!FH(z))return;const de=new AbortController;let Le;const ut=async()=>{Ne(!0);try{const gt=await Qpt(z.id,de.signal);if(de.signal.aborted)return;me(gt),Ve(""),!gt.complete&&yh(z.state)&&(Le=window.setTimeout(()=>void ut(),UH))}catch(gt){if(de.signal.aborted)return;Ve("暂时无法读取 Codex 执行动态,不影响当前任务。"),yh(z.state)&> instanceof Ia&>.retryable&&(Le=window.setTimeout(()=>void ut(),UH))}finally{de.signal.aborted||Ne(!1)}};return ut(),()=>{de.abort(),Le!==void 0&&window.clearTimeout(Le)}},[z==null?void 0:z.id,z==null?void 0:z.state,(At=z==null?void 0:z.analysisRef)==null?void 0:At.sha256,(Ut=z==null?void 0:z.confirmation)==null?void 0:Ut.framework]),m.useEffect(()=>{if(!(z!=null&&z.analysis)||!z.analysisRef||!["needs_input","analysis_ready"].includes(z.state))return;const de=`${z.id}:${z.analysisRef.attempt}:${z.analysisRef.sha256}`;if(c.current===de||(c.current=de,re({}),z.state!=="analysis_ready"))return;const Le=z.analysis.recommended;Le&&(B(Le.framework),X(Le.entry||""),D(VH(z.sourceFileName)))},[z]),m.useEffect(()=>{if(Ae(null),ie(""),ye(!1),at(!1),pe({}),!(z!=null&&z.artifact.previewReady))return;const de=new AbortController;return Fpt(z.id,de.signal).then(Le=>{de.signal.aborted||Ae(Le)}).catch(Le=>{de.signal.aborted||(ie(Le instanceof Error?Le.message:String(Le)),ye(Le instanceof Ia&&Le.retryable))}),()=>de.abort()},[z==null?void 0:z.id,z==null?void 0:z.artifact.previewReady,Se]),m.useEffect(()=>{if(!fe)return;const de=tmt(fe,e);pe(Le=>{var gt;const ut={...Le};for(const[ln,Sn]of Object.entries(de))(gt=ut[ln])!=null&>.trim()||(ut[ln]=Sn);return ut})},[fe,e]);function ge(de){if(!u.current&&(A(""),!!de)){if(!de.name.toLowerCase().endsWith(".zip")){O(null),A("请选择 .zip 格式的本地项目文件。");return}if(de.name.length>255||/[/\\\u0000-\u001f]/.test(de.name)){O(null),A("ZIP 文件名无效,请重命名后重新选择。");return}if(de.size>nmt){O(null),A("项目 ZIP 不能超过 50 MiB。");return}if(de.size===0){O(null),A("项目 ZIP 不能为空。");return}O(de)}}function lt(de){var ut;const Le=(ut=de.currentTarget.files)==null?void 0:ut[0];de.currentTarget.value="",ge(Le)}async function Ge(){if(!y||S||u.current)return;const de=new AbortController;u.current=de;const Le=()=>u.current===de&&!de.signal.aborted,ut=`migration-v1-${crypto.randomUUID().replace(/-/g,"")}`;k("create"),$(Date.now()),A("");try{const gt=await $pt({taskId:ut,sourceFileName:y.name,instruction:"",signal:de.signal});if(!Le())return;p(Sn=>bu(Sn,gt)),b(gt.id),k("upload"),$(null);const ln=await QH(gt.id,y,de.signal);if(!Le())return;p(Sn=>bu(Sn,ln)),O(null)}catch(gt){if(!Le())return;const ln=await Tt(ut,!1,de.signal);if(!Le())return;if(ln){if(b(ln.id),ln.state!=="awaiting_upload"){O(null);return}}else if(await dt(de.signal),!Le())return;A(gt instanceof Error?gt.message:String(gt))}finally{u.current===de&&(u.current=null,$(null),k(""))}}async function vt(){if(!(z!=null&&z.canUpload)||!y||S||u.current)return;const de=new AbortController;u.current=de;const Le=()=>u.current===de&&!de.signal.aborted;k("upload"),A("");try{const ut=await QH(z.id,y,de.signal);if(!Le())return;p(gt=>bu(gt,ut)),O(null)}catch(ut){if(!Le())return;const gt=await Tt(z.id,!0,de.signal);if(!Le())return;if(gt&>.state!=="awaiting_upload"){O(null);return}A(ut instanceof Error?ut.message:String(ut))}finally{u.current===de&&(u.current=null,k(""))}}const _t=m.useMemo(()=>{var de;return(((de=z==null?void 0:z.analysis)==null?void 0:de.entries)??[]).filter(Le=>Le.framework===U).map(Le=>({value:Le.value,label:Le.value,description:Le.evidence}))},[U,(kn=z==null?void 0:z.analysis)==null?void 0:kn.entries]),Bt=(((wn=z==null?void 0:z.analysis)==null?void 0:wn.questions)??[]).every(de=>{var Le;return!de.required||!!((Le=H[de.id])!=null&&Le.trim())}),je=lmt(q),Ze=!!(z!=null&&z.canConfirm&&z.analysisRef&&!S&&!je&&(!_R.has(U)||I.trim())),Ie=!!(z!=null&&z.canAnswer&&z.analysisRef&&!S&&Bt);async function Wt(){if(!(!(z!=null&&z.analysisRef)||!Ie)){k("answer"),A("");try{const de=await Upt({taskId:z.id,analysisAttempt:z.analysisRef.attempt,analysisSha256:z.analysisRef.sha256,inputSha256:z.analysisRef.inputSha256,answers:H});p(Le=>bu(Le,de))}catch(de){const Le=await Tt(z.id);if(Le&&Le.state!=="needs_input")return;A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function dn(){if(!(!(z!=null&&z.analysisRef)||!Ze)){k("confirm"),A("");try{const de=await Bpt({taskId:z.id,framework:U,entry:_R.has(U)?I.trim():void 0,appName:q.trim(),instruction:"",analysisAttempt:z.analysisRef.attempt,analysisSha256:z.analysisRef.sha256,inputSha256:z.analysisRef.inputSha256});p(Le=>bu(Le,de))}catch(de){const Le=await Tt(z.id);if(Le&&Le.state!=="analysis_ready")return;A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function Qt(){if(!(!(z!=null&&z.canStop)||S)){k("stop"),A("");try{const de=await zpt(z.id);p(Le=>bu(Le,de)),De(!1)}catch(de){const Le=await Tt(z.id);if(Le&&!Le.canStop){De(!1);return}A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function Yt(){if(!(!(z!=null&&z.artifact.downloadReady)||S)){k("download"),A("");try{await qpt(z.id,TE(z.sourceFileName))}catch(de){A(de instanceof Error?de.message:String(de))}finally{k("")}}}function Jt(){b(""),O(null),A(""),C(""),L(!1),Ae(null),ie(""),ye(!1),at(!1),De(!1)}const Ft=fe?{name:((Ai=z==null?void 0:z.confirmation)==null?void 0:Ai.app_name)||VH((z==null?void 0:z.sourceFileName)||"migration.zip"),files:[{path:"migration-result.json",content:`${JSON.stringify(fe,null,2)} -`}]}:null,Ce=fe?fe.environment.required.filter(kE).filter(qL).map(de=>({key:de,label:de})):[],et=fe?[...fe.environment.required.filter(kE).filter(de=>!qL(de)).map(de=>({key:de,required:!0,comment:de,placeholder:`请输入 ${de}`})),...fe.environment.optional.filter(kE).map(de=>({key:de,required:!1,comment:de,placeholder:`可选:${de}`}))]:[];async function wt(de,Le,ut){if(!z||!fe)throw new Error("迁移产物尚未准备完成。");const gt=W&&W.mode!=="public"?{mode:W.mode,vpc_id:W.vpcId,subnet_ids:W.subnetIds,enable_shared_internet_access:W.enableSharedInternetAccess}:void 0;return w1(de.name,de.files,{region:Rt,projectName:"default",network:gt},{...ut,migrationTaskId:z.id,onStage:Le})}if(mt&&Ft&&z&&fe)return l.jsx("div",{className:"migration-deployment",children:l.jsx(wQ,{cloudProvider:e,project:Ft,agentName:Ft.name,onDeploy:wt,onAgentAdded:n,onDeploymentTaskChange:i,onDeploymentStarted:r,onDeploymentComplete:s,network:W,onNetworkChange:K,deployRegion:Rt,onDeployRegionChange:qe,deploymentEnv:et,requiredSecretEnv:Ce,deploymentEnvValues:ae,onDeploymentEnvChange:(de,Le)=>pe(ut=>({...ut,[de]:Le})),deploymentTelemetry:{source:"migration",createMode:"migration",aiAssisted:!0},onBack:()=>at(!1),backLabel:"返回迁移结果",deploymentPrimaryPane:l.jsxs("section",{className:"migration-deployment-summary",children:[l.jsx("strong",{children:"迁移产物"}),l.jsx("span",{children:z.sourceFileName}),l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"迁移方式"}),l.jsx("dd",{children:fe.migration.framework})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"启动文件"}),l.jsx("dd",{children:fe.startup.module})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"文件数"}),l.jsx("dd",{children:fe.files.length})]})]})]})})});const yn=y,on=S==="create"||S==="upload",hi=!z||z.canUpload,Pe=z?dmt(z,P):null;return l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"migration-workspace",children:[l.jsxs("aside",{className:"migration-history",children:[l.jsxs("header",{children:[l.jsx("button",{type:"button",className:"migration-icon-button",onClick:t,"aria-label":"返回添加 Agent",title:"返回",children:l.jsx(Hpt,{})}),l.jsx("h1",{children:"从存量迁移"})]}),l.jsxs("button",{type:"button",className:"migration-new-button",onClick:Jt,disabled:on,children:[l.jsx(Gpt,{}),l.jsx("span",{children:"新建迁移"})]}),l.jsx("nav",{"aria-label":"迁移会话",children:w?l.jsx(oi,{children:"正在读取迁移会话…"}):h.length===0?l.jsx("p",{className:"migration-history__empty",children:"暂无迁移会话"}):h.map(de=>l.jsxs("button",{type:"button",className:de.id===g?"is-active":"",disabled:on,onClick:()=>{b(de.id),A(""),C(""),L(!1)},children:[l.jsx("span",{children:TE(de.sourceFileName)}),l.jsxs("small",{children:[l.jsx("span",{"data-state":de.state,children:smt(de.state)}),l.jsx("time",{children:umt(de.createdAt)})]})]},de.id))})]}),l.jsxs("main",{className:"migration-main",children:[l.jsxs("header",{className:"migration-main__header",children:[l.jsxs("div",{children:[l.jsx("h2",{children:z?TE(z.sourceFileName):"迁移存量 Agent 项目"}),l.jsx("p",{children:z?AR(z):"上传本地项目 ZIP,Codex 将先进行只读分析,再由你确认迁移方式。"})]}),z?l.jsxs("div",{className:"migration-main__header-actions",children:[z!=null&&z.canStop?l.jsx("button",{type:"button",className:"migration-stop-button",onClick:()=>De(!0),disabled:!!S,children:S==="stop"?"正在终止…":"终止迁移"}):null,Pe?l.jsxs("div",{className:"migration-ttl","aria-live":"off",children:[l.jsx("strong",{children:Pe.title}),l.jsx("small",{children:Pe.detail})]}):null]}):null]}),l.jsxs("div",{className:"migration-conversation",role:"log","aria-live":"polite",ref:kt,onScroll:Mt,children:[!(d!=null&&d.enabled)&&!w?l.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[l.jsx("strong",{children:"迁移能力暂不可用"}),l.jsx("p",{children:(d==null?void 0:d.reason)||"Dev Sandbox 暂不可用,请联系管理员检查配置。"})]}):null,z?l.jsxs(l.Fragment,{children:[l.jsx("article",{className:"migration-turn is-user",children:l.jsxs("div",{className:"migration-user-message",children:[l.jsxs("span",{className:"migration-file-chip",children:[l.jsx(EE,{}),l.jsx("span",{title:z.sourceFileName,children:z.sourceFileName})]}),z.instruction?l.jsx("p",{children:z.instruction}):null]})}),l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{className:"migration-assistant-content",children:[S==="upload"?l.jsxs(l.Fragment,{children:[l.jsx(NR,{stage:"upload"}),l.jsx("p",{className:"migration-running-note",children:"ZIP 上传完成后将自动开始只读分析。"})]}):z.state==="analyzing"?l.jsxs(l.Fragment,{children:[l.jsx(NR,{stage:"analysis"}),l.jsx("p",{className:"migration-running-note",children:"Codex 正在识别框架、入口和迁移边界,不会执行实际迁移。"})]}):yh(z.state)?l.jsxs(l.Fragment,{children:[l.jsx(oi,{children:AR(z)}),l.jsx("p",{className:"migration-running-note",children:"迁移执行中不能修改附件或迁移方式。你可以等待当前任务结束,或主动终止。"})]}):z.state==="needs_input"&&z.analysis?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:z.analysis.summary}),l.jsx("p",{children:"只读分析已暂停。请仅回答下面列出的问题,提交后会在同一 迁移环境中重新分析,不会开始实际迁移。"}),(Gn=z.analysis.frameworks[0])!=null&&Gn.evidence.length?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看源码证据"}),l.jsx("ul",{children:z.analysis.frameworks.flatMap(de=>de.evidence.map(Le=>l.jsxs("li",{children:[l.jsxs("code",{children:[Le.path,":",Le.line]}),l.jsx("span",{children:Le.reason})]},`${de.id}:${Le.path}:${Le.line}`)))})]}):null]}):z.state==="analysis_ready"&&z.analysis?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:"只读分析已完成。请检查建议,并确认最终迁移方式。"}),l.jsx(mmt,{analysis:z.analysis})]}):z.state==="awaiting_upload"?l.jsx("p",{children:"迁移环境已创建,请重新选择本地 ZIP 继续上传。"}):z.state==="expired"?l.jsxs("div",{className:"migration-expired",children:[l.jsx("strong",{children:"迁移环境已过期"}),l.jsx("p",{children:"迁移内容和产物已无法预览、下载或部署。如已完成 Runtime 部署,可返回智能体页面继续使用。"})]}):z.state==="failed"?((xn=z.error)==null?void 0:xn.code)==="MIGRATION_ANALYSIS_UNSUPPORTED"&&z.analysis?l.jsxs("div",{className:"migration-system-state is-error",children:[l.jsx("strong",{children:"当前 ZIP 暂时无法迁移"}),l.jsx(qp,{text:z.analysis.summary,allowRawHtml:!1}),z.analysis.warnings.length>0?l.jsx("ul",{children:z.analysis.warnings.map(de=>l.jsx("li",{children:de},de))}):null,l.jsx("p",{children:"请按提示整理项目后,新建迁移并重新上传。"})]}):l.jsxs("div",{className:"migration-system-state is-error",children:[l.jsx("strong",{children:"迁移未完成"}),l.jsx("p",{children:z.message})]}):z.state==="cancelled"?l.jsx("p",{children:"当前迁移已终止。你可以新建迁移并重新上传项目。"}):l.jsx("p",{children:AR(z)}),FH(z)&&(oe||Ee!=null&&Ee.available||Oe)?l.jsx(bmt,{activity:Ee,loading:oe,error:Oe,analyzing:z.state==="analyzing"}):null]})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{children:[l.jsx("p",{children:"请提供本地项目 ZIP。上传后我会识别框架、入口和迁移边界, 并在执行实际迁移前请你确认迁移方式。"}),l.jsx("small",{children:"仅支持本地 ZIP,最大 50 MiB;迁移环境从创建起保留 1 小时。"})]})]}),S==="create"&&y?l.jsxs(l.Fragment,{children:[l.jsx("article",{className:"migration-turn is-user",children:l.jsx("div",{className:"migration-user-message",children:l.jsxs("span",{className:"migration-file-chip",children:[l.jsx(EE,{}),l.jsx("span",{title:y.name,children:y.name})]})})}),l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{className:"migration-assistant-content",children:[l.jsx(NR,{stage:"session"}),l.jsx(oi,{as:"strong",children:"正在创建 Dev Sandbox"}),l.jsx("p",{className:"migration-running-note",children:"正在初始化迁移工作目录,并检查 AgentKit CLI、Codex 和迁移能力。环境就绪后将自动上传项目。"}),l.jsxs("small",{children:["已等待 ",cmt(ve)]})]})]})]}):null]}),(z==null?void 0:z.state)==="needs_input"&&z.analysis?l.jsxs("section",{className:"migration-confirmation","aria-label":"补充项目分析信息",children:[l.jsxs("div",{className:"migration-confirmation__heading",children:[l.jsx("strong",{children:"补充分析所需信息"}),l.jsx("span",{children:"附件保持锁定,提交后仅继续只读分析"})]}),z.analysis.questions.map(de=>l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:[de.prompt,de.required?l.jsx("b",{"aria-hidden":"true",children:"*"}):null]}),l.jsx("textarea",{value:H[de.id]||"",maxLength:4e3,required:de.required,"aria-required":de.required,onChange:Le=>{const ut=Le.currentTarget.value;re(gt=>({...gt,[de.id]:ut}))},disabled:!!S})]},de.id)),l.jsx("div",{className:"migration-confirmation__actions",children:l.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void Wt(),disabled:!Ie,children:S==="answer"?"正在继续分析…":"提交并继续分析"})})]}):null,(z==null?void 0:z.state)==="analysis_ready"&&z.analysis?l.jsxs("section",{className:"migration-confirmation","aria-label":"确认迁移方式",children:[l.jsxs("div",{className:"migration-confirmation__heading",children:[l.jsx("strong",{children:"确认迁移方式"}),l.jsx("span",{children:"确认后才会执行实际迁移"})]}),l.jsxs("div",{className:"migration-confirmation__grid",children:[l.jsx(Cp,{label:"迁移方式",value:U,options:((d==null?void 0:d.frameworks)??[]).map(de=>({value:de,label:Kpe[de]})),onChange:de=>{var gt;const Le=de;B(Le);const ut=(gt=z.analysis)==null?void 0:gt.entries.find(ln=>ln.framework===Le);X((ut==null?void 0:ut.value)||"")},placeholder:"选择迁移方式",disabled:!!S}),l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:["Agent 名称",l.jsx("b",{"aria-hidden":"true",children:"*"})]}),l.jsx("input",{value:q,onChange:de=>D(de.currentTarget.value),maxLength:63,required:!0,disabled:!!S,"aria-invalid":!!je,"aria-required":"true"}),je?l.jsx("small",{role:"alert",children:je}):null]}),_R.has(U)?_t.length>0?l.jsx(Cp,{label:"项目入口",value:I,options:_t,onChange:X,placeholder:"选择项目入口",disabled:!!S}):l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:["项目入口",l.jsx("b",{"aria-hidden":"true",children:"*"})]}),l.jsx("input",{value:I,onChange:de=>X(de.currentTarget.value),placeholder:"例如 agent.py:agent",maxLength:512,required:!0,disabled:!!S,"aria-required":"true"})]}):null]}),l.jsx("p",{className:"migration-running-note",children:"点击“确认并开始迁移”即确认上述迁移范围、排除项和关键假设。"}),l.jsx("div",{className:"migration-confirmation__actions",children:l.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void dn(),disabled:!Ze,children:S==="confirm"?"正在启动迁移…":"确认并开始迁移"})})]}):null,z&&omt(z.state)&&z.artifact.previewReady?l.jsxs("section",{className:"migration-result",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"迁移产物"}),l.jsx("span",{children:z.artifact.deployReady?"产物可预览、下载和部署。运行效果取决于源项目和部署环境变量;迁移环境过期后产物将无法访问。":"产物可预览和下载,但当前交付状态不支持部署;迁移环境过期后产物将无法访问。"})]}),l.jsxs("div",{className:"migration-result__actions",children:[l.jsxs("button",{type:"button",onClick:()=>void Yt(),disabled:!z.artifact.downloadReady||!!S,children:[l.jsx(Ypt,{}),l.jsx("span",{children:S==="download"?"下载中…":"下载 ZIP"})]}),l.jsxs("button",{type:"button",className:"is-primary",onClick:()=>at(!0),disabled:!z.artifact.deployReady||!fe,title:z.artifact.deployReady?"部署迁移产物":"当前交付状态不支持部署",children:[l.jsx(Wpt,{}),l.jsx("span",{children:"部署到 Runtime"})]})]})]}),J?l.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[l.jsx("p",{children:J}),ue?l.jsx("button",{type:"button",className:"migration-retry-button",onClick:()=>{ie(""),ye(!1),Re(de=>de+1)},children:"重新读取"}):null]}):fe?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"migration-result__summary",children:[l.jsxs("span",{children:[fe.files.length," 个文件"]}),l.jsxs("span",{children:["CLI ",fe.cli.version]}),l.jsxs("span",{children:["启动文件 ",fe.startup.module]}),l.jsx("span",{children:amt(fe.verification.status)})]}),l.jsx(Omt,{task:z,artifact:fe})]}):l.jsx(oi,{children:"正在读取迁移产物…"})]}):null,N?l.jsxs("div",{className:"migration-inline-error",role:"alert",children:[l.jsx("span",{children:N}),M?l.jsx("button",{type:"button",onClick:()=>{z&&(C(""),L(!1),kR(z.id).then(de=>p(Le=>bu(Le,de))).catch(de=>{C(de instanceof Error?de.message:String(de)),L(de instanceof Ia&&de.retryable)}))},children:"刷新状态"}):null]}):null,T?l.jsxs("div",{className:"migration-inline-error",role:"alert",children:[l.jsx("span",{children:T}),l.jsx("button",{type:"button",onClick:()=>A(""),"aria-label":"关闭错误提示",children:l.jsx(BH,{})})]}):null]}),hi&&(d!=null&&d.enabled)?l.jsxs("div",{className:"migration-composer",children:[l.jsxs("div",{className:`migration-composer__box${v?" is-dragging":""}`,onDragEnter:de=>{de.preventDefault(),!on&&x(!0)},onDragOver:de=>{de.preventDefault(),de.dataTransfer.dropEffect=on?"none":"copy"},onDragLeave:de=>{de.currentTarget.contains(de.relatedTarget)||x(!1)},onDrop:de=>{var Le;de.preventDefault(),x(!1),!on&&ge((Le=de.dataTransfer.files)==null?void 0:Le[0])},children:[l.jsx("div",{className:"migration-composer__content",children:yn?l.jsxs("div",{className:"migration-composer__file",children:[l.jsx(EE,{}),l.jsx("span",{children:yn.name}),l.jsx("small",{children:HL(yn.size)}),l.jsx("button",{type:"button",onClick:()=>O(null),"aria-label":"移除项目 ZIP",disabled:on,children:l.jsx(BH,{})})]}):l.jsx("p",{children:z?"重新选择项目 ZIP":"选择或拖入本地项目 ZIP"})}),l.jsxs("div",{className:"migration-composer__actions",children:[l.jsxs("button",{type:"button",className:"migration-attach-button",onClick:()=>{var de;return(de=o.current)==null?void 0:de.click()},disabled:on,children:[l.jsx(Zpt,{}),l.jsx("span",{children:y?"重新选择":"选择 ZIP"})]}),l.jsx("button",{type:"button",className:"migration-confirm-upload-button",onClick:()=>void(z?vt():Ge()),disabled:!y||on,children:z?"继续上传":"开始迁移"})]}),l.jsx("input",{ref:o,type:"file",accept:".zip,application/zip",onChange:lt,"aria-label":"选择本地项目 ZIP",disabled:on})]}),l.jsx("p",{children:"迁移环境从创建完成起保留 1 小时,过期后产物无法预览、下载或部署。"})]}):null]})]}),We&&z?l.jsx(Mf,{title:"终止当前迁移?",description:"终止后,当前分析或迁移进程将停止,已执行的步骤不会继续。",confirmLabel:S==="stop"?"正在终止…":"终止迁移",variant:"danger",busy:S==="stop",onCancel:()=>De(!1),onConfirm:()=>void Qt()}):null]})}const Jpe=1,xmt="MODEL_AGENT_API_KEY";function $T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vmt(e){return $T(e)&&typeof e.id=="string"&&typeof e.updatedAt=="number"&&$T(e.draft)}function tN(e){return`veadk.agentDrafts.${encodeURIComponent(e)}`}function QT(e){const t=e.deployment,n=t==null?void 0:t.envValues,i=t?{...t,...n?{envValues:Object.fromEntries(Object.entries(n).filter(([r])=>r!==xmt))}:{}}:void 0;return{...e,...i?{deployment:i}:{},subAgents:e.subAgents.map(QT),...e.workflow?{workflow:{...e.workflow,nodes:e.workflow.nodes.map(r=>({...r,agent:QT(r.agent)}))}}:{}}}function wmt(e){var i;const t=KA(e),n={...((i=t.draft.deployment)==null?void 0:i.envValues)??{},...t.envValues};return!t.draft.deployment&&Object.keys(n).length===0?QT(t.draft):QT({...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}})}function eme(e){return{...e,draft:wmt(e.draft)}}function Smt(e){const t=Array.isArray(e)?e:$T(e)&&e.version===Jpe?e.drafts:void 0;if(!Array.isArray(t)||!t.every(vmt))throw $T(e)&&typeof e.version=="number"?new Error("本机草稿版本暂不受支持,请升级 Studio 后重试。"):new Error("本机草稿数据格式无效。");return t.map(eme)}function Emt(e,t){if(!t)return[];const n=e.getItem(tN(t));if(!n)return[];try{return Smt(JSON.parse(n))}catch(i){throw i instanceof Error&&i.message.startsWith("本机草稿")?i:new Error("无法读取本机草稿,浏览器中的草稿数据可能已损坏。")}}function XH(e,t,n){if(!t)return;const i={version:Jpe,drafts:n.map(eme)};try{e.setItem(tN(t),JSON.stringify(i))}catch(r){throw r instanceof DOMException&&(r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")?new Error("浏览器存储空间不足,草稿未保存。请删除不需要的草稿或清理此站点的浏览器存储后重试。"):new Error("浏览器拒绝保存草稿,请检查站点存储权限后重试。")}}const kmt=/[;;]/;function Tmt(e){const t=new Set;for(const n of e)for(const i of n.split(kmt)){const r=i.trim();r&&t.add(r)}return[...t]}function _mt(e){return[]}const Amt=3*60*1e3,Nmt=3e3,Cmt=10*60*1e3,jmt=45e3,BT="veadk.studio.pending-update",_Q="veadk.studio.update-handoff",qH=[{id:"resolving",label:"读取目标版本信息"},{id:"downloading",label:"下载并校验完整更新包"},{id:"preparing",label:"准备 VeFaaS Function 代码"},{id:"provisioning",label:"检查并补齐 Studio 云资源"},{id:"submitting",label:"提交 Function 更新"},{id:"publishing",label:"发布新 Revision 并重启服务"}],Rmt={resolving:"读取版本信息",downloading:"下载更新包",preparing:"准备 Function 代码",provisioning:"补齐 Studio 云资源",submitting:"提交 Function 更新",publishing:"发布 Revision",checking:"检查更新",unknown:"未知阶段"};function Imt(e){return e<60?`${e} 秒`:`${Math.floor(e/60)} 分 ${e%60} 秒`}function Pmt(e,t){return e===t?!0:/^\d{14}$/.test(e)&&/^\d{14}$/.test(t)&&e>t}function Mmt(e){return!!(e!=null&&e.some(t=>t.includes("部署应用成功")||t.toLowerCase().includes("application deployed successfully")))}function Lmt(){if(typeof window>"u")return null;const e=window.localStorage.getItem(BT);if(!e)return null;try{const t=JSON.parse(e);if(typeof t.targetVersion=="string"&&typeof t.startedAt=="number")return{targetVersion:t.targetVersion,startedAt:t.startedAt}}catch{}return window.localStorage.removeItem(BT),null}function CR(e,t){window.localStorage.setItem(BT,JSON.stringify({targetVersion:e,startedAt:t}))}function yS(){window.localStorage.removeItem(BT)}function Dmt(){return typeof window>"u"?"":window.sessionStorage.getItem(_Q)??""}function $mt(e){window.sessionStorage.setItem(_Q,e)}function HH(){window.sessionStorage.removeItem(_Q)}function YH({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M19.2 8.3A8 8 0 1 0 20 13"}),l.jsx("path",{d:"M19.2 4.8v3.5h-3.5"}),l.jsx("path",{d:"M12 7.8v7.7"}),l.jsx("path",{d:"m9.2 12.7 2.8 2.8 2.8-2.8"})]})}function Qmt(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m4 6 4 4 4-4"})})}function Bmt(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})})}function GH({lines:e,phase:t,copyState:n,onCopy:i}){const r=m.useRef(null),s=m.useRef(!0),[a,o]=m.useState(e);return m.useEffect(()=>{e.length&&o(e)},[e]),m.useEffect(()=>{const c=r.current;c&&s.current&&(c.scrollTop=c.scrollHeight)},[a]),l.jsxs("section",{className:"studio-update-live-log","aria-label":"部署进度",children:[l.jsxs("div",{className:"studio-update-log-header",children:[l.jsxs("span",{children:[l.jsx("i",{className:`is-${t}`,"aria-hidden":!0}),"部署进度",l.jsx("small",{children:t==="active"?"实时":t==="complete"?"已完成":"已停止"})]}),l.jsx("button",{type:"button",onClick:()=>i(a),disabled:!a.length,children:n==="copied"?"已复制":n==="error"?"复制失败":"复制日志"})]}),l.jsx("div",{ref:r,className:"studio-update-log-lines",role:"log","aria-live":"off","aria-busy":t==="active",tabIndex:0,onScroll:c=>{const u=c.currentTarget;s.current=u.scrollHeight-u.scrollTop-u.clientHeight<24},children:a.length?a.map((c,u)=>l.jsx("div",{children:c},`${u}-${c}`)):l.jsx("p",{children:t==="active"?"等待 VeFaaS 返回更新日志…":"本次更新未返回发布日志"})})]})}function Umt({variant:e="default"}){var $,U;const[t]=m.useState(Lmt),[n,i]=m.useState(null),[r,s]=m.useState(t?"submitting":"idle"),[a,o]=m.useState(!!t),[c,u]=m.useState(""),[d,f]=m.useState((t==null?void 0:t.targetVersion)??""),[h,p]=m.useState(!1),[g,b]=m.useState("idle"),[y,O]=m.useState(0),v=m.useRef(null),x=m.useRef((t==null?void 0:t.targetVersion)??""),w=m.useRef((t==null?void 0:t.startedAt)??0),E=m.useRef(Dmt()),S=m.useRef(0);m.useEffect(()=>{if(!h)return;const B=X=>{var q;X.target instanceof Node&&!((q=v.current)!=null&&q.contains(X.target))&&p(!1)},I=X=>{X.key==="Escape"&&p(!1)};return window.addEventListener("pointerdown",B),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",B),window.removeEventListener("keydown",I)}},[h]);const k=m.useCallback(async()=>{const B=await oee(x.current||void 0,w.current||void 0);return i(B),B},[]);if(m.useEffect(()=>{let B=!0;const I=()=>{k().catch(()=>{B&&i(q=>q)})};I();const X=window.setInterval(I,Amt);return()=>{B=!1,window.clearInterval(X)}},[k]),m.useEffect(()=>{if(r!=="submitting")return;const B=window.setInterval(()=>{k().then(I=>{const X=x.current;if(X&&Pmt(I.currentVersion,X)||!X&&!I.available&&I.latestVersion){const q=Date.now();if(S.current||(S.current=q),!Mmt(I.updateLogs)&&q-S.currentCmt&&(window.clearInterval(B),yS(),s("error"),u("等待 VeFaaS 发布超时,请稍后重新检查版本"))}).catch(()=>{})},Nmt);return()=>window.clearInterval(B)},[r,k]),m.useEffect(()=>{r!=="idle"||(n==null?void 0:n.state)!=="updating"||(x.current=n.targetVersion,w.current=n.startedAt||Date.now(),CR(n.targetVersion,w.current),f(n.targetVersion),s("submitting"))},[r,n]),m.useEffect(()=>{if(r!=="submitting"){O(0);return}const B=()=>{const X=w.current||Date.now();O(Math.max(0,Math.floor((Date.now()-X)/1e3)))};B();const I=window.setInterval(B,1e3);return()=>window.clearInterval(I)},[r]),!(n!=null&&n.enabled)||!(n.available||n.state==="updating"||r!=="idle"))return null;const A=n.releases??[],N=d||(($=A[0])==null?void 0:$.version)||n.latestVersion,C=A.find(B=>B.version===N),M=Tmt((C==null?void 0:C.changelog)??[]),L=async()=>{HH(),E.current="",x.current=N,w.current=Date.now(),CR(N,w.current),s("submitting"),u(""),b("idle");try{const B=await lee(N);x.current=B.version,CR(B.version,w.current),u("更新已提交,正在等待 VeFaaS 发布新版本")}catch(B){if(B instanceof TypeError){u("连接已切换,正在确认新版本状态");return}yS(),s("error");const I=B instanceof Error?B.message:"Studio 更新失败";try{const X=await k();u(X.message||I)}catch{u(I)}}},P=(U=n.updateLogs)!=null&&U.length?n.updateLogs:(n.errorLog||n.progressMessage||c).split(` +${t}`}function Sht(e,t){if(e.length<=t)return{text:e,omitted:!1};let n=e.slice(-t);const i=n.indexOf(` +`);return i>=0&&(n=n.slice(i+1)),{text:n,omitted:!0}}function _H(e,t,n=vht){const i=wht((e==null?void 0:e.text)??"",t.text??""),r=Sht(i,n),s=r.text?r.text.split(` +`).length:0,a=!!(t.snapshotTruncated||t.truncated),o=!!(e!=null&&e.omittedEarly||r.omitted);return{...t,text:r.text,lineCount:s,truncated:!!(e!=null&&e.truncated||t.truncated||o),omittedEarly:o,snapshotTruncated:!!(e!=null&&e.snapshotTruncated||a)}}Fa.registerLanguage("python",Wae);Fa.registerLanguage("typescript",loe);Fa.registerLanguage("javascript",Vae);Fa.registerLanguage("json",Xae);Fa.registerLanguage("yaml",coe);Fa.registerLanguage("markdown",Gae);Fa.registerLanguage("bash",$ae);Fa.registerLanguage("ini",Qae);Fa.registerLanguage("dockerfile",eze);Fa.registerLanguage("makefile",Yae);function AH(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}const Eht=m.lazy(()=>$g(()=>Promise.resolve().then(()=>khe),void 0)),Dd=()=>{};function kht({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M2.75 12s3.35-5.25 9.25-5.25S21.25 12 21.25 12 17.9 17.25 12 17.25 2.75 12 2.75 12Z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2.5"})]})}function Tht({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M3 3l18 18"}),l.jsx("path",{d:"M9.7 6.95A9.7 9.7 0 0 1 12 6.68c5.9 0 9.25 5.32 9.25 5.32a16 16 0 0 1-2.28 2.85"}),l.jsx("path",{d:"M14.35 14.55A3.25 3.25 0 0 1 9.5 10.2"}),l.jsx("path",{d:"M6.25 8.12A16.4 16.4 0 0 0 2.75 12S6.1 17.32 12 17.32c.8 0 1.55-.1 2.25-.27"})]})}const gR={status:"hidden",apiKeyId:"",value:"",error:""};function _ht({open:e,isUpdate:t,onCancel:n,onConfirm:i}){const r=m.useRef(null);return m.useEffect(()=>{var o;if(!e)return;const s=document.body.style.overflow;document.body.style.overflow="hidden",(o=r.current)==null||o.focus();const a=c=>{c.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>{document.body.style.overflow=s,window.removeEventListener("keydown",a)}},[n,e]),e?zi.createPortal(l.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:s=>{s.target===s.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog pp-confirm-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"pp-confirm-title","aria-describedby":"pp-confirm-description",children:[l.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:l.jsx(mSe,{})}),l.jsx("h2",{id:"pp-confirm-title",children:t?"确认更新":"确认部署"})]}),l.jsx("button",{type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭部署确认",children:l.jsx(xa,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"pp-confirm-body",children:l.jsx("p",{id:"pp-confirm-description",children:t?"将更新并发布到当前云端 Runtime,过程可能需要几分钟。确定继续吗?":"将创建新的云端 Runtime,部署过程可能需要几分钟。确定继续吗?"})}),l.jsxs("footer",{className:"pp-confirm-actions",children:[l.jsx("button",{ref:r,type:"button",onClick:n,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:i,children:t?"确定更新":"确定部署"})]})]})}),document.body):null}function Aht({value:e,disabled:t,onChange:n}){const[i,r]=m.useState([]),[s,a]=m.useState(!0),[o,c]=m.useState(null),[u,d]=m.useState(0);m.useEffect(()=>{const p=new AbortController;return a(!0),c(null),KD(p.signal).then(g=>r(g)).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||(r([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{p.signal.aborted||a(!1)}),()=>p.abort()},[u]);const f=m.useMemo(()=>[...i].sort((p,g)=>Number(g.isCurrent)-Number(p.isCurrent)).map(p=>({value:p.uid,label:p.name.trim()||"未命名用户池",description:p.domain||p.uid,badge:p.isCurrent?"当前用户池":void 0})),[i]),h=i.find(p=>p.uid===e);return l.jsxs("div",{className:"pp-user-pool-picker",children:[l.jsx(JA,{ariaLabel:"部署用户池",value:e,placeholder:s?"正在加载用户池…":"请选择用户池",options:f,disabled:t||s||!!o,onChange:n}),o?l.jsxs("div",{className:"pp-user-pool-error",role:"alert",children:[l.jsx("span",{children:o}),l.jsx("button",{type:"button",onClick:()=>d(p=>p+1),children:"重试"})]}):s?l.jsxs("span",{className:"pp-user-pool-status","aria-live":"polite",children:[l.jsx(Kn,{"aria-hidden":"true",className:"pp-user-pool-spinner"}),"正在加载 Identity 用户池…"]}):i.length===0?l.jsx("span",{className:"pp-user-pool-status",children:"当前账号下暂无 Identity 用户池。"}):h!=null&&h.isCurrent?l.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime。"}):h?l.jsx("div",{className:"pp-user-pool-error",role:"alert",children:l.jsx("span",{children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime。"})}):l.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 使用的用户池已在列表中标注。"})]})}const Nht=[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],Cht={py:"python",pyi:"python",ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",md:"markdown",markdown:"markdown",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",cfg:"ini",conf:"ini",env:"ini",txt:"plaintext"},NH={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function CH(e){return e.replace(/&/g,"&").replace(//g,">")}function jht(e){const n=(e.split("/").pop()??e).toLowerCase();if(NH[n])return NH[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const i=n.lastIndexOf(".");if(i===-1)return null;const r=n.slice(i+1);return Cht[r]??null}function Rht(e,t){try{const n=jht(t);return n&&Fa.getLanguage(n)?Fa.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?Fa.highlightAuto(e).value:CH(e)}catch{return CH(e)}}const Iht=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],Pht=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}],Mht={phase:"update",label:"更新实例配置"},Lht={phase:"evaluation",label:"创建评测集"};function Dht(e){return e?!e.memory.shortTerm||(e.shortTermBackend||"local")==="local":!1}function $ht(e,t){const n=Number(e),i=Number(t);return!e.trim()||!t.trim()||!Number.isSafeInteger(n)||!Number.isSafeInteger(i)||n<1||i<1?{valid:!1,error:"实例数必须为大于 0 的整数。"}:n>i?{valid:!1,error:"最小实例数不能大于最大实例数。"}:{valid:!0,min:n,max:i}}function Qht(e){const t={name:"",children:new Map};for(const n of e){const i=n.path.split("/").filter(Boolean);let r=t;i.forEach((s,a)=>{let o=r.children.get(s);o||(o={name:s,children:new Map},r.children.set(s,o)),a===i.length-1&&(o.path=n.path),r=o})}return t}function Bht(e){return[...e.children.values()].sort((t,n)=>{const i=t.children.size>0&&t.path===void 0,r=n.children.size>0&&n.path===void 0;return i!==r?i?-1:1:t.name.localeCompare(n.name)})}function Uht(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function zht({left:e,right:t}){const[n,i]=m.useState(null);return m.useLayoutEffect(()=>{const r=document.getElementById("veadk-page-header-left"),s=document.getElementById("veadk-page-header-actions");r&&s&&i({left:r,right:s})},[]),n?l.jsxs(l.Fragment,{children:[zi.createPortal(e,n.left),zi.createPortal(t,n.right)]}):l.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function wQ({project:e,embedded:t=!1,deployDisabledReason:n,agentDraft:i,agentName:r,agentCount:s,releaseConfiguration:a,onChange:o,onDeploy:c,onAgentAdded:u,onDeploymentComplete:d,deploymentActionLabel:f="部署",deploymentActionTargetId:h,deploymentRuntimeId:p,deploymentRuntimeName:g,deploymentRuntimeNameCustomized:b=!1,onDeploymentRuntimeNameChange:y,onDeploymentStarted:O,onDeploymentTaskChange:v,feishuEnabled:x=!1,onFeishuEnabledChange:w,deploymentEnv:E=[],requiredSecretEnv:S=[],requiredSecretEnvValues:k,onRequiredSecretEnvChange:T,deploymentEnvValues:A={},onDeploymentEnvChange:N,network:C,onNetworkChange:M,cloudProvider:L="volcengine",deployRegion:P=Qi(L),onDeployRegionChange:Q,deploymentTelemetry:j={source:"unknown",createMode:"unknown",aiAssisted:!1},onBack:$,backLabel:U="返回配置",onExportYaml:B,deploymentPrimaryPane:I,deployDisabled:X=!1}){var dr,ws,ls,te,Me;const q=typeof o=="function",D=!!p,H=Dht(i),re=(r==null?void 0:r.trim())||(i==null?void 0:i.name)||e.name,fe=m.useMemo(()=>Zct(re),[re]),[Ae,J]=m.useState(null),ie=D?g??re:b?g??"":Ae??fe,ue=D?null:pQ(ie),[ye,Se]=m.useState(null),[Re,Ee]=m.useState(!1),me=`${P}\0${ie.trim()}`,oe=m.useRef(me);oe.current=me;const Ne=(ye==null?void 0:ye.key)===me?ye.message:null,Oe=ue??Ne,Ve=((ws=(dr=i==null?void 0:i.deployment)==null?void 0:dr.modelApiKeyId)==null?void 0:ws.trim())??"",[We,De]=m.useState(((te=(ls=e==null?void 0:e.files)==null?void 0:ls[0])==null?void 0:te.path)??null);m.useEffect(()=>{J(null),Se(null)},[re]);const[mt,at]=m.useState(new Set),[Rt,qe]=m.useState(!1),[W,K]=m.useState(""),[ae,pe]=m.useState(!1),[z,ve]=m.useState(!1),[Be,Je]=m.useState(!1),[kt,Mt]=m.useState(!1),[Tt,dt]=m.useState(null),[ge,lt]=m.useState(null),[Ge,vt]=m.useState({}),[_t,Bt]=m.useState(null),[je,Ze]=m.useState(!1),[Ie,Wt]=m.useState([]),[dn,Qt]=m.useState(gR),Yt=m.useRef(null),Jt=m.useRef(Ve);Jt.current=Ve;const[Ft,Ce]=m.useState({}),et=k??Ft,[wt,yn]=m.useState(null),[on,hi]=m.useState(bht),[Pe,st]=m.useState(null),[At,Ut]=m.useState(!1),kn=m.useId(),wn=m.useId(),Ai=m.useId(),Gn=m.useId(),[xn,de]=m.useState("api_key"),[Le,ut]=m.useState(""),gt=v1(L),ln=td(P,L),[Sn,In]=m.useState("1"),[Ni,Pn]=m.useState(H?"1":"5"),[Vt,Ji]=m.useState(!0),fn=L!=="byteplus",pi=fn&&Vt,[ti,vi]=m.useState(null),en=m.useRef(!0),Ci=S.map(ee=>`${ee.key}:${ee.label}`).join("|"),xs=m.useRef(P),ni=$ht(Sn,Ni),Ls=!D&&ni.valid&&(ni.min!==1||ni.max!==5),er=I?Pht:Iht,Ya=Ls?[...er,Mht]:er,mr=pi?[...Ya,Lht]:Ya;function gr(){var ee;(ee=Yt.current)==null||ee.abort(),Yt.current=null,Qt(gR)}async function ul(){var tt;const ee=Jt.current;if(!ee){Qt({status:"error",apiKeyId:"",value:"",error:"请先在模型配置中选择 API Key。"});return}(tt=Yt.current)==null||tt.abort();const _e=new AbortController;Yt.current=_e,Qt({status:"loading",apiKeyId:ee,value:"",error:""});try{const Ct=await kJ(ee,_e.signal);if(_e.signal.aborted||Jt.current!==ee)return;Qt({status:"visible",apiKeyId:ee,value:Ct.value,error:""})}catch(Ct){if(_e.signal.aborted)return;Qt({status:"error",apiKeyId:ee,value:"",error:Ct instanceof Error?Ct.message:"加载 API Key 失败,请重试。"})}finally{Yt.current===_e&&(Yt.current=null)}}m.useEffect(()=>{gr()},[Ve]),m.useEffect(()=>(window.addEventListener("pagehide",gr),()=>{window.removeEventListener("pagehide",gr),gr()}),[]),m.useEffect(()=>{const ee=new Set(S.map(_e=>_e.key));k===void 0&&Ce(_e=>Object.fromEntries(Object.entries(_e).filter(([tt])=>ee.has(tt)))),yn(_e=>_e&&ee.has(_e)?_e:null)},[Ci,k]),m.useEffect(()=>{!Q||D||gt.some(ee=>ee.value===P)||Q(Qi(L))},[L,P,gt,D,Q]),m.useEffect(()=>{if(!h){vi(null);return}vi(document.getElementById(h))},[h]);const Sa=ee=>l.jsxs("div",{className:`pp-network-region${At?" is-open":""}`,onKeyDown:_e=>{_e.key==="Escape"&&Ut(!1)},children:[ee&&l.jsx("span",{children:"发布区域"}),l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":At,"aria-describedby":D?kn:void 0,disabled:ae||D||!Q,onClick:()=>Ut(_e=>!_e),children:[l.jsx("span",{children:ln}),l.jsx(Uwe,{className:`pp-region-chevron${At?" is-open":""}`})]}),At&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>Ut(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:gt.map(_e=>{const tt=_e.value===P;return l.jsxs("button",{type:"button",role:"option","aria-selected":tt,className:`pp-region-option${tt?" is-selected":""}`,onClick:()=>{Q==null||Q(_e.value),Ut(!1)},children:[l.jsx("span",{children:_e.label}),tt&&l.jsx(Hc,{"aria-hidden":"true"})]},_e.value)})})]}),D&&l.jsx("span",{id:kn,className:"pp-region-help",children:"更新时沿用现有 Runtime 的部署区域,无法修改。"})]});m.useEffect(()=>(en.current=!0,()=>{en.current=!1}),[]),m.useEffect(()=>{In("1"),Pn(H?"1":"5")},[H]),m.useEffect(()=>{xs.current!==P&&(xs.current=P,hi(ee=>({tos:ee.tos.mode==="existing"?{mode:"existing"}:ee.tos,cr:ee.cr.mode==="existing"?{mode:"existing"}:ee.cr,codePipeline:ee.codePipeline.mode==="existing"?{mode:"existing"}:ee.codePipeline})),st(null))},[P]),m.useEffect(()=>{if(!Be)return;const ee=document.body.style.overflow;document.body.style.overflow="hidden";const _e=tt=>{tt.key==="Escape"&&Je(!1)};return window.addEventListener("keydown",_e),()=>{document.body.style.overflow=ee,window.removeEventListener("keydown",_e)}},[Be]);const as=m.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:Qht(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return l.jsx("div",{className:"pp-error",children:"项目数据无效"});const Mn=e.files.find(ee=>ee.path===We)??null,vs=(C==null?void 0:C.mode)??"public",Zl=()=>({agentId:String((r==null?void 0:r.trim())||e.name||"unknown"),deployAction:p?"update":"create",deploySource:j.source,createMode:j.createMode,aiAssisted:j.aiAssisted?1:0,deployRegion:String(P),runtimeNetworkType:vs,feishuEnabled:x?1:0}),Gr=new Set(S.map(ee=>ee.key)),tr=_ft(x?[...E,...Zb]:E,A).filter(ee=>!Gr.has(ee.key)),No=tr.length+S.length+Ie.length,Dr=dn.apiKeyId===Ve?dn:gR,os=Dr.status==="visible",na=Ve?Dr.status==="loading"?"正在显示 API Key":os?"隐藏 API Key":Dr.status==="error"?"重试显示 API Key":"显示 API Key":"请先选择 API Key";function Co(ee){at(_e=>{const tt=new Set(_e);return tt.has(ee)?tt.delete(ee):tt.add(ee),tt})}function br(ee,_e){o&&(o({...e,files:ee}),_e!==void 0&&De(_e))}function ia(ee){Mn&&br(e.files.map(_e=>_e.path===Mn.path?{..._e,content:ee}:_e))}function ji(){const ee=W.trim();if(qe(!1),K(""),!!ee){if(e.files.some(_e=>_e.path===ee)){De(ee);return}br([...e.files,{path:ee,content:""}],ee)}}function Kl(){if(!Mn)return;const ee=window.prompt("重命名文件",Mn.path),_e=ee==null?void 0:ee.trim();!_e||_e===Mn.path||e.files.some(tt=>tt.path===_e)||br(e.files.map(tt=>tt.path===Mn.path?{...tt,path:_e}:tt),_e)}function Ke(){var _e;if(!Mn)return;const ee=e.files.filter(tt=>tt.path!==Mn.path);br(ee,((_e=ee[0])==null?void 0:_e.path)??null)}function Ds(ee,_e){Wt(tt=>tt.map(Ct=>Ct.id===ee?{...Ct,..._e}:Ct))}function Ea(ee){Wt(_e=>_e.filter(tt=>tt.id!==ee))}function nu(){Wt(ee=>[...ee,Uht()])}function $s(ee){M&&M(ee==="public"?void 0:{...C??{mode:ee},mode:ee})}function Jl(ee){M==null||M({...C??{mode:"private"},...ee})}function ec(){var Ct,He,ht,Pt;const ee=new Map(Ie.map(jt=>({key:jt.key.trim(),value:jt.value})).filter(jt=>jt.key.length>0).map(jt=>[jt.key,jt.value])),_e=x?[...E,...Zb]:E;for(const jt of dpe(_e,A))ee.set(jt.key,jt.value);for(const jt of S){const bn=et[jt.key]??"";bn.trim()&&ee.set(jt.key,bn)}const tt=jt=>jt.agentType==="llm"&&Ob(jt,L)==="ark"||jt.subAgents.some(tt);if(i&&tt(i)){const jt=(He=(Ct=i.deployment)==null?void 0:Ct.modelApiKeyId)==null?void 0:He.trim(),bn=(Pt=(ht=i.deployment)==null?void 0:ht.modelApiKeyName)==null?void 0:Pt.trim();jt&&ee.set("MODEL_AGENT_API_KEY_ID",jt),bn&&ee.set("MODEL_AGENT_API_KEY_NAME",bn)}return[...ee].map(([jt,bn])=>({key:jt,value:bn}))}async function le(){if(!(!w||ae||kt)){dt(null),Mt(!0);try{await w(!x)}catch(ee){en.current&&dt(`更新飞书配置失败:${ee instanceof Error?ee.message:String(ee)}`)}finally{en.current&&Mt(!1)}}}async function gn(){var Ct;if(!c||ae||Re||X)return;if(Oe){dt(Oe);return}if(!D){const He=yht(on);if(He){st(He),dt(He);return}}if(st(null),!ni.valid){dt(ni.error);return}if(!D&&xn==="user_pool"&&!Le){dt("请选择用于 Runtime 鉴权的用户池。");return}if(vs!=="public"&&!((Ct=C==null?void 0:C.vpcId)!=null&&Ct.trim())){dt("使用 VPC 网络时,请填写 VPC ID。");return}const ee=S.find(He=>!(et[He.key]??"").trim());if(ee){yn(ee.key),dt(`请填写 ${ee.label},用于访问对应的自定义模型地址。`);return}yn(null);const _e=wH(E,A);if(_e){const He=E.find(ht=>ht.key===_e.key);dt(`请返回配置页填写 ${(He==null?void 0:He.comment)||(He==null?void 0:He.key)}(${He==null?void 0:He.key})。`);return}const tt=fpe(E,A);if(tt){dt(`${tt.spec.comment||tt.spec.key}:${tt.error}`);return}if(x){const He=wH(Zb,A);if(He){const ht=Zb.find(Pt=>Pt.key===He.key);dt(`启用飞书后,请填写${(ht==null?void 0:ht.comment)||(ht==null?void 0:ht.key)}。`);return}}if(!D){const He=ie.trim(),ht=`${P}\0${He}`;Ee(!0),dt(null);try{const Pt=await tee(He,P);if(!en.current||oe.current!==ht)return;if(!Pt.available){const jt="Runtime 名称已存在,请修改后重试。";Se({key:ht,message:jt}),dt(jt);return}Se(null)}catch(Pt){if(!en.current)return;dt(Pt instanceof Error?Pt.message:String(Pt));return}finally{en.current&&Ee(!1)}}ve(!0)}async function Wn(){var qi;if(!c||ae)return;if(Oe){ve(!1),dt(Oe);return}if(!ni.valid){ve(!1),dt(ni.error);return}ve(!1);const ee=ec();en.current&&(dt(null),lt(null),vt({}),Bt(null),pe(!0));const _e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tt=(r==null?void 0:r.trim())||(i==null?void 0:i.name)||e.name,Ct=ie.trim();let He=Ct;const ht=Date.now(),Pt=tpe(Zl()),jt={id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"running",phase:"prepare",label:"准备部署",agentDraft:i,instanceRange:Ls?{min:ni.min,max:ni.max}:void 0,createEvaluationSets:pi};v==null||v(jt),O==null||O(jt);let bn,Xi=jt.phase??"prepare";const Ss=Xe=>bn?{...bn,status:Xe,updatedAt:Date.now()}:void 0,Dn=Xe=>{const _n=Ss(Xe);return _n?{buildLog:_n}:{}},Wr=()=>({source:"code-pipeline",status:"running",text:"",lineCount:0,truncated:!1,updatedAt:Date.now(),pendingMessage:"正在等待构建日志…"}),sa=Xe=>{if(Xi!=="build")return;const _n=["","----- 构建失败 -----",Xe].join(` +`);return bn=_H(bn,{source:"code-pipeline",status:"error",text:_n,lineCount:_n.split(` +`).length,truncated:!1,updatedAt:Date.now()}),bn};try{const Xe=await c(e,_n=>{var dl;_n.runtimeName&&(He=_n.runtimeName),Xi=_n.phase,_n.buildLog?bn=_H(bn,_n.buildLog):_n.phase==="build"&&!bn&&(bn=Wr()),en.current&&(vt(fl=>({...fl,[_n.phase]:_n})),Bt(_n.phase)),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"running",phase:_n.phase,label:((dl=mr.find(fl=>fl.phase===_n.phase))==null?void 0:dl.label)??_n.phase,message:_n.message,pct:_n.pct,...bn?{buildLog:bn}:{}})},{taskId:_e,runtimeName:Ct,sessionStorage:H?"in-memory":"persistent",minInstance:ni.min,maxInstance:ni.max,...D?{}:{authentication:xn==="user_pool"?{type:"user_pool",userPoolUid:Le}:{type:"api_key"}},createEvaluationSets:pi,...x?{im:{feishu:{enabled:!0}}}:{},envs:ee,...D?{}:{resources:on}});en.current&&(lt(Xe),Bt(null)),Pt.succeed({runtimeId:String(Xe.runtimeId||p||"")}),v==null||v({id:_e,agentName:Xe.agentName||tt,runtimeName:Xe.runtimeName||He,runtimeId:Xe.runtimeId||p,region:Xe.region||P,startedAt:ht,status:"success",phase:"complete",label:"部署完成",message:(qi=Xe.warnings)==null?void 0:qi.join(";"),...Dn("complete")});try{await(d==null?void 0:d(Xe))}catch(_n){if(!(_n instanceof ga))throw _n;v==null||v({id:_e,agentName:Xe.agentName||tt,runtimeName:Xe.runtimeName||He,runtimeId:Xe.runtimeId||p,region:Xe.region||P,startedAt:ht,status:"success",phase:"complete",label:"部署完成,暂未连接",message:_n.message,...Dn("complete")})}}catch(Xe){const _n=Xe instanceof Error?Xe.message:String(Xe);if(Xe instanceof DOMException&&Xe.name==="AbortError"){Pt.fail({failedPhase:AH(Xi),...Ra(Xe,{phase:Xi})}),en.current&&(dt(null),Bt(null)),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。",...Dn("complete")});return}en.current&&dt(_n);const dl=sa(_n);Pt.fail({failedPhase:AH(Xi),...Ra(Xe,{phase:Xi})}),v==null||v({id:_e,agentName:tt,runtimeName:He,runtimeId:p,region:P,startedAt:ht,status:"error",phase:Xi,label:"部署失败",message:_n,...dl?{buildLog:dl}:Dn("complete"),retry:gn})}finally{en.current&&pe(!1)}}function Vi(){ve(!1)}async function Ln(){if(!(!ge||je)){Ze(!0),dt(null);try{const{addConnection:ee,addRuntimeConnection:_e,remoteAppId:tt,loadConnections:Ct}=await $g(async()=>{const{addConnection:Pt,addRuntimeConnection:jt,remoteAppId:bn,loadConnections:Xi}=await Promise.resolve().then(()=>Rq);return{addConnection:Pt,addRuntimeConnection:jt,remoteAppId:bn,loadConnections:Xi}},void 0),{probeRuntimeApps:He}=await $g(async()=>{const{probeRuntimeApps:Pt}=await Promise.resolve().then(()=>yEe);return{probeRuntimeApps:Pt}},void 0);let ht;if(ge.runtimeId){const Pt=ge.region??P,jt=await He(ge.runtimeId,Pt,{retryProbe:!0})??[];ht=_e(ge.runtimeId,ge.runtimeName,Pt,jt,jt.length>0?{[jt[0]]:ge.agentName}:void 0,ge.version)}else ht=await ee(ge.agentName,ge.url,ge.apikey,"");if(ht.apps.length===0)dt("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const Pt={[ht.apps[0]]:ge.agentName},jt={...ht,appLabels:{...ht.appLabels??{},...Pt}},Xi=Ct().map(Dn=>Dn.id===ht.id?jt:Dn);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(Xi));const{registerConnections:Ss}=await $g(async()=>{const{registerConnections:Dn}=await Promise.resolve().then(()=>Rq);return{registerConnections:Dn}},void 0);if(Ss(Xi),u){const Dn=tt(ht.id,ht.apps[0]);u(Dn,ge.agentName)}else alert(`🎉 Agent "${ge.agentName}" 已添加到左上角下拉列表!`)}}catch(ee){dt(`添加 Agent 失败:${ee instanceof Error?ee.message:String(ee)}`)}finally{Ze(!1)}}}function Tn(){const ee=Zl(),_e=Qut({agentId:ee.agentId,deployAction:ee.deployAction,deploySource:ee.deploySource,createMode:ee.createMode,aiAssisted:ee.aiAssisted});try{const tt=cht(e.files),Ct=URL.createObjectURL(tt),He=document.createElement("a");He.href=Ct,He.download=`${e.name||"project"}.zip`,document.body.appendChild(He),He.click(),document.body.removeChild(He),URL.revokeObjectURL(Ct),_e.succeed({fileCount:e.files.length,zipSizeBytes:tt.size})}catch(tt){throw _e.fail({fileCount:e.files.length,...Ra(tt)}),tt}}const ra=l.jsxs("div",{className:`pp-artifact-actions${t?" is-rail":""}`,"aria-label":"发布产物操作",children:[B&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:B,children:[l.jsx(Hwe,{className:"pp-ic"}),"导出 YAML"]}),q&&o&&l.jsx(hht,{project:e,onChange:o,className:"pp-artifact-source",label:"查看源代码"}),e.files.length>0&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:Tn,children:[l.jsx(b_,{className:"pp-ic"}),"下载源代码"]})]});function Qs(ee,_e,tt){return Bht(ee).map(Ct=>{const He=tt?`${tt}/${Ct.name}`:Ct.name,ht=Ct.path!==void 0,Pt={paddingLeft:8+_e*14};if(ht){const bn=Ct.path===We;return l.jsxs("button",{type:"button",className:`pp-row pp-file${bn?" pp-active":""}`,style:Pt,onClick:()=>De(Ct.path),title:Ct.path,children:[l.jsx(Wwe,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:Ct.name})]},He)}const jt=mt.has(He);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"pp-row pp-folder",style:Pt,onClick:()=>Co(He),children:[l.jsx(U0,{className:`pp-ic pp-chevron${jt?"":" pp-open"}`}),l.jsx(hJ,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:Ct.name})]}),!jt&&Qs(Ct,_e+1,He)]},He)})}return l.jsxs("div",{className:`pp-root${c?" is-deploy":""}${t?" is-embedded":""}${I?" has-primary-pane":""}`,children:[c&&!t&&l.jsx(zht,{left:l.jsxs("div",{className:"pp-toolbar-left",children:[$&&l.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:$,children:[l.jsx(oJ,{className:"pp-ic"}),U]}),l.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",r||e.name||"未命名 Agent",s&&s>1?` 等 ${s} 个智能体`:""]})]}),right:null}),l.jsxs("div",{className:"pp-body",children:[c&&!I&&l.jsx("section",{className:"pp-release-overview","aria-label":"发布概览",children:l.jsxs("div",{className:`pp-release-preview${t?" is-embedded":""}`,children:[l.jsxs("div",{className:"pp-flow-thumbnail",children:[i&&l.jsx(px,{draft:i,direction:"horizontal",selectedPath:[],onSelect:Dd,onAdd:Dd,onInsert:Dd,onDelete:Dd,readOnly:!0,interactivePreview:!0}),l.jsx("button",{type:"button",className:"pp-flow-expand",onClick:()=>Je(!0),"aria-label":"放大查看执行流程",title:"放大查看",children:l.jsx(np,{"aria-hidden":!0})})]}),t&&ra,!t&&l.jsxs("div",{className:"pp-release-info",children:[l.jsx("div",{className:"pp-release-card-head",children:"Agent 概览"}),l.jsxs("div",{className:"pp-release-info-body",children:[l.jsxs("div",{className:"pp-release-info-main",children:[l.jsx("h2",{children:r||e.name||"未命名 Agent"}),(i==null?void 0:i.description)&&l.jsx("p",{className:"pp-release-description",title:i.description,children:i.description}),l.jsxs("dl",{className:"pp-release-facts",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Agent 数量"}),l.jsx("dd",{children:s??1})]}),a&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:a.modelName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"描述"}),l.jsx("dd",{className:"pp-release-fact-long",children:a.description})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"系统提示词"}),l.jsx("dd",{className:"pp-release-fact-long pp-release-prompt",children:a.instruction})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"优化选项"}),l.jsx("dd",{children:a.optimizations.length>0?a.optimizations.join("、"):"未启用"})]})]})]})]}),ra]})]})]})}),l.jsxs("div",{className:"pp-files-area",children:[l.jsxs("div",{className:"pp-sidebar",children:[l.jsxs("div",{className:"pp-sidebar-head",children:[l.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),q&&l.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{qe(!0),K("")},children:l.jsx(Ywe,{className:"pp-ic"})})]}),l.jsxs("div",{className:"pp-tree",children:[Rt&&l.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:W,onChange:ee=>K(ee.target.value),onBlur:ji,onKeyDown:ee=>{ee.key==="Enter"&&ji(),ee.key==="Escape"&&(qe(!1),K(""))}}),e.files.length===0&&!Rt?l.jsx("div",{className:"pp-empty",children:"暂无文件"}):Qs(as,0,"")]})]}),l.jsxs("div",{className:"pp-main",children:[l.jsxs("div",{className:"pp-main-head",children:[l.jsx("span",{className:"pp-path",title:Mn==null?void 0:Mn.path,children:(Mn==null?void 0:Mn.path)??"未选择文件"}),l.jsx("div",{className:"pp-actions",children:q&&Mn&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Kl,children:l.jsx(lSe,{className:"pp-ic"})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Ke,children:l.jsx(If,{className:"pp-ic"})})]})})]}),l.jsx("div",{className:"pp-content",children:Mn==null?l.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):q?l.jsx("div",{className:"pp-codemirror",children:l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:l.jsx(Eht,{value:Mn.content,path:Mn.path,onChange:ia})})}):l.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:Rht(Mn.content,Mn.path)}})})]})]}),c&&l.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[l.jsx("div",{className:"pp-config-head",children:l.jsx("div",{className:"pp-config-title",children:"部署配置"})}),l.jsxs("div",{className:"pp-config-scroll",children:[I,!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("label",{className:"pp-config-label",htmlFor:wn,children:"Runtime 名称"}),l.jsxs("div",{className:"pp-runtime-name-field",children:[l.jsx("input",{id:wn,className:"pp-runtime-name-input",value:ie,disabled:ae||Re||D,maxLength:64,autoComplete:"off","aria-label":"Runtime 名称","aria-invalid":!!Oe,"aria-describedby":`${Ai}${Oe?` ${Gn}`:""}`,onChange:ee=>{const _e=ee.currentTarget.value;Se(null),dt(null),y?y(_e):J(_e)}}),l.jsx("p",{id:Ai,className:"pp-config-note",children:D?"更新时保持现有 Runtime 名称不变。":"默认根据 Root Agent 名称生成,并添加随机后缀避免重名;支持 4-64 位字母、数字、连字符和下划线"}),Oe&&l.jsx("p",{id:Gn,className:"pp-runtime-name-error",role:"alert",children:Oe})]})]}),!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"发布区域"}),Sa(!1)]}),!I&&l.jsxs("section",{className:"pp-config-section pp-auth-section",children:[l.jsx("div",{className:"pp-config-label",children:"访问鉴权"}),D?l.jsx("p",{className:"pp-config-note pp-auth-preserved-note",children:"更新时保持现有 Runtime 的鉴权方式不变。"}):l.jsxs("div",{className:"pp-auth-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"鉴权方式"}),l.jsx(JA,{ariaLabel:"部署鉴权方式",value:xn,placeholder:"请选择鉴权方式",options:Nht,disabled:ae,onChange:ee=>{dt(null),de(ee)}})]}),xn==="user_pool"&&l.jsxs("label",{children:[l.jsx("span",{children:"用户池"}),l.jsx(Aht,{value:Le,disabled:ae,onChange:ee=>{dt(null),ut(ee)}})]})]})]}),!I&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"消息渠道"}),l.jsx("div",{className:`pp-channel-card${x?" is-flipped":""}`,children:l.jsxs("div",{className:"pp-channel-card-inner",children:[l.jsxs("button",{type:"button",className:"pp-channel-card-face pp-channel-card-front","aria-pressed":x,"aria-hidden":x,tabIndex:x?-1:0,onClick:()=>void le(),disabled:x||ae||Re||kt||!w,children:[l.jsx("span",{className:"pp-channel-logo",children:l.jsx("img",{src:mQ,alt:""})}),l.jsxs("span",{className:"pp-channel-card-copy",children:[l.jsx("strong",{children:"飞书"}),l.jsx("small",{children:kt?"正在启用并更新配置…":"接收消息并通过飞书机器人回复"})]})]}),l.jsxs("div",{className:"pp-channel-card-face pp-channel-card-back","aria-hidden":!x,children:[l.jsxs("div",{className:"pp-channel-card-head",children:[l.jsx("strong",{children:"飞书配置"}),l.jsx("button",{type:"button",className:"pp-channel-remove",tabIndex:x?0:-1,onClick:()=>void le(),disabled:!x||ae||kt||!w,children:kt?"取消中…":"取消"})]}),l.jsx("div",{className:"pp-channel-fields",children:Zb.map(ee=>l.jsxs("label",{children:[l.jsxs("span",{children:[ee.comment||ee.key,ee.required&&l.jsx("small",{children:"必填"})]}),l.jsx("input",{type:ee.key.includes("SECRET")?"password":"text",value:A[ee.key]??"",placeholder:ee.placeholder,tabIndex:x?0:-1,disabled:!x||ae||!N,autoComplete:"off",onChange:_e=>N==null?void 0:N(ee.key,_e.currentTarget.value)})]},ee.key))})]})]})})]}),!D&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"实例设置"}),l.jsxs("div",{className:"pp-instance-fields",children:[l.jsxs("label",{htmlFor:"runtime-min-instance",children:[l.jsx("span",{children:"最小实例数"}),l.jsx("input",{id:"runtime-min-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Sn,disabled:ae,"aria-invalid":!ni.valid,onChange:ee=>In(ee.currentTarget.value)})]}),l.jsxs("label",{htmlFor:"runtime-max-instance",children:[l.jsx("span",{children:"最大实例数"}),l.jsx("input",{id:"runtime-max-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Ni,disabled:ae,"aria-invalid":!ni.valid,onChange:ee=>Pn(ee.currentTarget.value)})]})]}),H&&l.jsx("p",{className:"pp-instance-note",role:"note",children:"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}),!ni.valid&&l.jsx("p",{className:"pp-instance-error",role:"alert",children:ni.error})]}),l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"网络"}),I&&Sa(!0),D&&l.jsx("p",{className:"pp-config-note",children:"现有 Runtime 的区域与网络模式保持不变。"}),l.jsxs("div",{className:"pp-network-layout",children:[l.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(ee=>l.jsxs("label",{className:"pp-network-option",children:[l.jsx("input",{type:"radio",name:"deployment-network-mode",value:ee,checked:vs===ee,onChange:()=>$s(ee),disabled:ae||D||!M}),l.jsx("span",{children:ee==="public"?"公网":ee==="private"?"VPC":"公网 + VPC"})]},ee))}),vs!=="public"&&l.jsxs("div",{className:"pp-network-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"VPC ID"}),l.jsx("input",{value:(C==null?void 0:C.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:ae||D,onChange:ee=>Jl({vpcId:ee.target.value})})]}),l.jsxs("label",{children:[l.jsxs("span",{children:["子网 ID ",l.jsx("small",{children:"可选,多个用逗号分隔"})]}),l.jsx("input",{value:(C==null?void 0:C.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:ae||D,onChange:ee=>Jl({subnetIds:ee.target.value})})]}),l.jsxs("label",{className:"pp-network-check",children:[l.jsx("input",{type:"checkbox",checked:!!(C!=null&&C.enableSharedInternetAccess),disabled:ae||D,onChange:ee=>Jl({enableSharedInternetAccess:ee.target.checked})}),"VPC 内共享公网出口"]})]})]})]}),fn&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"评测集"}),l.jsxs("label",{className:"pp-evaluation-set-option",children:[l.jsx("input",{type:"checkbox",checked:Vt,disabled:ae,onChange:ee=>Ji(ee.currentTarget.checked)}),l.jsxs("span",{children:[l.jsx("strong",{children:"自动创建评测集"}),l.jsx("small",{children:"部署成功后,自动创建 Good Case 和 Bad Case 评测集。"})]})]})]}),!D&&l.jsxs("section",{className:"pp-config-section pp-resource-section",children:[l.jsx("div",{className:"pp-config-label",children:"资源配置"}),l.jsx(xht,{value:on,agentName:r||e.name||"agentkit-app",runtimeName:ie,region:P,disabled:ae,validationError:Pe,onChange:ee=>{hi(ee),st(null)}})]}),l.jsxs("section",{className:"pp-config-section pp-env-section",children:[l.jsx("div",{className:"pp-env-head",children:l.jsxs("div",{children:[l.jsxs("div",{className:"pp-config-label",children:["环境变量",l.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[No," 项"]})]}),l.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]})}),l.jsxs("button",{type:"button",className:"pp-env-add",onClick:nu,disabled:ae,children:[l.jsx(Gs,{className:"pp-ic"}),"添加变量"]}),(tr.length>0||S.length>0||Ie.length>0)&&l.jsxs("div",{className:"pp-env-table",children:[tr.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"组件自动生成"}),l.jsxs("small",{children:[tr.length," 项"]})]}),tr.map(ee=>{const _e=ee.readOnly||ee.key.startsWith("ENABLE_"),tt=ee.serverManaged&&ee.key==="MODEL_AGENT_API_KEY",Ct=tt?os?Dr.value:"由所选 API Key 注入":ee.value,He=xQ(ee,A),ht=ee.multiline||ee.format==="json";return l.jsxs("div",{className:`pp-env-row pp-env-row-derived${ht?" is-multiline":""}`,children:[l.jsxs("div",{className:"pp-env-key-fixed pp-env-key-cell","aria-label":`${ee.key} 环境变量名`,"aria-disabled":ae,children:[l.jsx("span",{title:ee.key,children:ee.key}),(ee.help||ee.comment)&&l.jsxs("span",{className:"pp-env-help",tabIndex:0,"data-help":ee.help||ee.comment,"aria-label":`${ee.key}说明:${ee.help||ee.comment}`,children:["?",l.jsx("span",{className:"pp-env-help-popover",role:"tooltip",children:ee.help||ee.comment})]}),ee.link&&l.jsx("a",{className:"pp-env-link",href:ee.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${ee.link.label}`,"aria-label":`${ee.key}:打开 OpenViking ${ee.link.label}`,children:l.jsx(e0,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"pp-env-value-wrap",children:[ht?l.jsx("textarea",{className:"pp-env-value pp-env-json-value",value:ee.value,placeholder:ee.required?"必填,尚未填写":"可选,尚未填写",readOnly:_e,disabled:ae||!_e&&!N,autoComplete:"off",spellCheck:!1,"aria-invalid":!!He,"aria-label":`${ee.key} 环境变量值`,onChange:Pt=>N==null?void 0:N(ee.key,Pt.currentTarget.value)}):l.jsxs("div",{className:tt?"pp-env-secret-control":void 0,children:[l.jsx("input",{className:"pp-env-value",type:tt?"text":ee.secret?"password":"text",value:Ct,placeholder:ee.required?"必填,尚未填写":"可选,尚未填写",readOnly:_e,disabled:ae||!_e&&!N,autoComplete:ee.secret?"new-password":"off",spellCheck:ee.secret?!1:void 0,"aria-invalid":!!He,"aria-label":`${ee.key} 环境变量值`,onChange:Pt=>N==null?void 0:N(ee.key,Pt.currentTarget.value)}),tt&&l.jsx("button",{type:"button",className:"pp-env-secret-toggle","aria-label":na,title:na,"aria-pressed":os,disabled:Dr.status==="loading"||!Ve,onClick:()=>{os?gr():ul()},children:Dr.status==="loading"?l.jsx(Kn,{className:"pp-env-secret-spinner","aria-hidden":"true"}):os?l.jsx(Tht,{}):l.jsx(kht,{})})]}),He&&l.jsx("span",{className:"pp-env-error",children:He}),tt&&Dr.status==="error"&&l.jsx("span",{className:"pp-env-reveal-error",role:"alert",children:Dr.error})]}),l.jsx("span",{className:"pp-env-source",children:_e?"自动":"同步"})]},ee.key)})]}),S.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"自定义模型凭据"}),l.jsxs("small",{children:[S.length," 项"]})]}),S.map(ee=>{const _e=wt===ee.key,tt=`${ee.key.toLowerCase()}-error`;return l.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[l.jsx("label",{className:"pp-env-key-fixed pp-env-key-cell",htmlFor:ee.key,title:ee.label,children:l.jsx("span",{children:ee.key})}),l.jsxs("div",{className:"pp-env-value-wrap",children:[l.jsx("input",{id:ee.key,className:"pp-env-value",type:"password",value:et[ee.key]??"",placeholder:"必填,仅用于本次发布",disabled:ae,autoComplete:"new-password",spellCheck:!1,"aria-invalid":_e,"aria-describedby":_e?tt:void 0,"aria-label":ee.label,onChange:Ct=>{const He=Ct.currentTarget.value;T?T(ee.key,He):Ce(ht=>({...ht,[ee.key]:He})),_e&&He.trim()&&(yn(null),dt(null))}}),_e&&l.jsx("span",{id:tt,className:"pp-env-error",role:"alert",children:"请填写此模型地址对应的 API Key。"})]}),l.jsx("span",{className:"pp-env-source",children:"本次发布"})]},ee.key)})]}),Ie.length>0&&l.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[l.jsx("span",{children:"自定义变量"}),l.jsxs("small",{children:[Ie.length," 项"]})]}),Ie.map(ee=>l.jsxs("div",{className:"pp-env-row",children:[l.jsx("input",{value:ee.key,placeholder:"名称",disabled:ae,autoComplete:"off",onChange:_e=>Ds(ee.id,{key:_e.currentTarget.value})}),l.jsx("input",{type:"text",value:ee.value,placeholder:"值",disabled:ae,autoComplete:"off",onChange:_e=>Ds(ee.id,{value:_e.currentTarget.value})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:ae,onClick:()=>Ea(ee.id),children:l.jsx(xa,{className:"pp-ic"})})]},ee.id))]})]}),(ae||ge||Object.keys(Ge).length>0)&&l.jsxs("section",{className:"pp-config-section pp-progress-section",children:[l.jsx("div",{className:"pp-config-label",children:"部署进度"}),l.jsx("ol",{className:"pp-steps",children:mr.map((ee,_e)=>{const tt=_t?mr.findIndex(Pt=>Pt.phase===_t):-1,Ct=!!Tt&&(tt===-1?_e===0:_e===tt);let He;ge?He="done":Ct?He="failed":tt===-1?He=ae?"active":"pending":_eee.phase===_t))==null?void 0:Me.label)??_t}阶段):`:""}${Tt}`,onRetry:gn,retryLabel:D?"重试更新":"重试部署"}),ge&&l.jsxs("section",{className:"pp-deploy-result",children:[l.jsx("div",{className:"pp-deploy-result-header",children:D?"更新成功":"部署成功"}),l.jsxs("div",{className:"pp-deploy-result-body",children:[ge.warnings&&ge.warnings.length>0&&l.jsx("div",{className:"pp-deploy-result-warning",role:"status",children:ge.warnings.map(ee=>l.jsx("span",{children:ee},ee))}),ge.region&&l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"区域"}),l.jsx("code",{children:td(ge.region,L)})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Agent 名称"}),l.jsx("code",{children:ge.agentName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Runtime 名称"}),l.jsx("code",{children:ge.runtimeName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"API 端点"}),l.jsx("code",{className:"pp-deploy-result-url",children:ge.url})]})]}),l.jsxs("div",{className:"pp-deploy-result-actions",children:[l.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Ln,disabled:je,children:[je?l.jsx(Kn,{className:"pp-ic spin"}):l.jsx(mJ,{className:"pp-ic"}),je?"连接中…":"立即对话"]}),ge.consoleUrl&&l.jsxs("a",{href:ge.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[l.jsx(e0,{className:"pp-ic"}),"控制台"]})]})]})]}),l.jsx("div",{className:`pp-config-actions${ti?" is-external":""}`,children:ti?zi.createPortal(l.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:gn,disabled:ae||Re||kt||X||!!n||!!Oe,title:n||Oe||void 0,children:ae?`${f}中…`:Re?"正在检查名称…":Tt?`重试${f}`:f}),ti):l.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:gn,disabled:ae||Re||kt||X||!!n||!!Oe,title:n||Oe||void 0,children:ae?`${f}中…`:Re?"正在检查名称…":Tt?`重试${f}`:f})})]})]}),Be&&i&&zi.createPortal(l.jsx("div",{className:"pp-flow-backdrop",onMouseDown:ee=>{ee.target===ee.currentTarget&&Je(!1)},children:l.jsxs("section",{className:"pp-flow-dialog",role:"dialog","aria-modal":"true","aria-label":"执行流程预览",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"执行流程"}),l.jsx("span",{children:"只读预览,可缩放与拖动画布"})]}),l.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":"关闭执行流程预览",children:l.jsx(xa,{"aria-hidden":!0})})]}),l.jsx("div",{className:"pp-flow-dialog-canvas",children:l.jsx(px,{draft:i,direction:"horizontal",selectedPath:[],onSelect:Dd,onAdd:Dd,onInsert:Dd,onDelete:Dd,readOnly:!0,interactivePreview:!0})})]})}),document.body),l.jsx(_ht,{open:z,isUpdate:D,onCancel:Vi,onConfirm:()=>void Wn()})]})}const jH=["#6366f1","#0ea5e9","#10b981","#f59e0b","#f43f5e","#a855f7","#14b8a6","#f472b6"];function bR(e){let t=0;for(let n=0;n>>0;return jH[t%jH.length]}function Fht(e){const t=new Map;e.forEach(u=>t.set(u.span_id,u));const n=new Map,i=[];for(const u of e)u.parent_span_id!=null&&t.has(u.parent_span_id)?(n.get(u.parent_span_id)??n.set(u.parent_span_id,[]).get(u.parent_span_id)).push(u):i.push(u);const r=(u,d)=>u.start_time-d.start_time,s=(u,d)=>({span:u,depth:d,children:(n.get(u.span_id)??[]).sort(r).map(f=>s(f,d+1))}),a=i.sort(r).map(u=>s(u,0)),o=e.length?Math.min(...e.map(u=>u.start_time)):0,c=e.length?Math.max(...e.map(u=>u.end_time)):1;return{rootNodes:a,min:o,total:c-o||1}}function Vht(e,t){const n=[],i=r=>{n.push(r),t.has(r.span.span_id)||r.children.forEach(i)};return e.forEach(i),n}function RH(e){const t=e/1e6;return t>=1e3?`${(t/1e3).toFixed(2)} s`:`${t.toFixed(t<10?2:1)} ms`}const Xht=e=>e.replace(/^(gen_ai|a2ui|adk)\./,"");function IH(e){return Object.entries(e.attributes).filter(([,t])=>t!=null&&typeof t!="object").map(([t,n])=>{const i=String(n);return{key:Xht(t),value:i,long:i.length>80||i.includes(` +`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function Upe({appName:e,testRunId:t,sessionId:n,endTimeMs:i,onClose:r,title:s="调用链路观测"}){const[a,o]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(new Set),[h,p]=m.useState(null);m.useEffect(()=>{o(null),u("");let E;if(t)E=xee(t,n);else if(e)E=bk(e,n,i);else{u("缺少调用链路来源");return}E.then(S=>{o(S),p(S.length?S.reduce((k,T)=>k.start_time<=T.start_time?k:T).span_id:null)}).catch(S=>u(S instanceof Error?S.message:String(S)))},[e,i,n,t]);const{rootNodes:g,min:b,total:y}=m.useMemo(()=>Fht(a??[]),[a]),O=m.useMemo(()=>Vht(g,d),[g,d]),v=(a==null?void 0:a.find(E=>E.span_id===h))??null,x=y/1e6,w=E=>f(S=>{const k=new Set(S);return k.has(E)?k.delete(E):k.add(E),k});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim",onClick:r}),l.jsxs("aside",{className:"drawer drawer--trace",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"drawer-title",children:s}),l.jsx("div",{className:"drawer-sub",children:a?`${a.length} 个调用 · ${x.toFixed(1)} ms`:"加载中"})]}),l.jsx("button",{className:"drawer-close",onClick:r,"aria-label":"关闭",children:l.jsx(xa,{className:"icon"})})]}),a==null&&!c&&l.jsxs("div",{className:"drawer-loading",children:[l.jsx(Kn,{className:"icon spin"})," 加载调用链路…"]}),c&&l.jsx("div",{className:"error",children:c}),a&&a.length===0&&l.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),O.length>0&&l.jsxs("div",{className:"trace-split",children:[l.jsx("div",{className:"trace-tree scroll",children:O.map(E=>{const S=E.span,k=(S.start_time-b)/y*100,T=Math.max((S.end_time-S.start_time)/y*100,.6),A=E.children.length>0;return l.jsxs("button",{className:`trace-row ${h===S.span_id?"active":""}`,onClick:()=>p(S.span_id),children:[l.jsxs("span",{className:"trace-label",style:{paddingLeft:E.depth*14},children:[l.jsx("span",{className:`trace-caret ${A?"":"hidden"} ${d.has(S.span_id)?"":"open"}`,onClick:N=>{N.stopPropagation(),A&&w(S.span_id)},children:l.jsx(U0,{className:"chev"})}),l.jsx("span",{className:"trace-dot",style:{background:bR(S.name)}}),l.jsx("span",{className:"trace-name",title:S.name,children:S.name})]}),l.jsx("span",{className:"trace-dur",children:RH(S.end_time-S.start_time)}),l.jsx("span",{className:"trace-track",children:l.jsx("span",{className:"trace-bar",style:{left:`${k}%`,width:`${T}%`,background:bR(S.name)}})})]},S.span_id)})}),l.jsx("div",{className:"trace-detail scroll",children:v?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"td-title",children:v.name}),l.jsxs("div",{className:"td-dur",children:[l.jsx("span",{className:"td-dot",style:{background:bR(v.name)}}),RH(v.end_time-v.start_time)]}),l.jsx("div",{className:"td-section",children:"属性"}),l.jsx("div",{className:"td-props",children:IH(v).filter(E=>!E.long).map(E=>l.jsxs("div",{className:"td-prop",children:[l.jsx("span",{className:"td-key",children:E.key}),l.jsx("span",{className:"td-val",children:E.value})]},E.key))}),IH(v).filter(E=>E.long).map(E=>l.jsxs("div",{className:"td-block",children:[l.jsx("div",{className:"td-section",children:E.key}),l.jsx("pre",{className:"td-pre",children:E.value})]},E.key))]}):l.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}const qht=m.lazy(()=>$g(()=>import("./MarkdownPromptEditor-UWDOV-0M.js"),__vite__mapDeps([0,1]))),zL="veadk.generatedAgentTestRuns",PH=4;function SQ(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(zL)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}catch{return[]}}function zpe(e){if(typeof window>"u")return;const t=Array.from(new Set(e)).slice(-20);try{t.length?window.sessionStorage.setItem(zL,JSON.stringify(t)):window.sessionStorage.removeItem(zL)}catch{}}function Hht(e){zpe([...SQ(),e])}function mO(e){zpe(SQ().filter(t=>t!==e))}function Yht(e,t,n="text/plain"){const i=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(i)}const Ght=[{id:"type",label:"Agent 类型",hint:"选择 Agent 类型",icon:hSe,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:hd,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:Xwe},{id:"tools",label:"工具",hint:"可调用的能力",icon:gSe},{id:"skills",label:"技能",hint:"声明式技能",icon:tx},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:$S},{id:"memory",label:"记忆",hint:"短期与长期记忆",icon:pJ},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:Bwe},{id:"review",label:"完成",hint:"预览并创建",icon:dSe}];function Wht({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M9 7.15v9.7a1.15 1.15 0 0 0 1.78.96l7.2-4.85a1.15 1.15 0 0 0 0-1.92l-7.2-4.85A1.15 1.15 0 0 0 9 7.15Z"}),l.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),l.jsx("path",{d:"M3 10v4",opacity:"0.45"}),l.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function MH({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4.75 7.25h14.5"}),l.jsx("path",{d:"M9.1 4.75h5.8l.75 2.5h-7.3l.75-2.5Z"}),l.jsx("path",{d:"m6.75 7.25.75 12h9l.75-12"}),l.jsx("path",{d:"M10 10.25v5.75M14 10.25v5.75"})]})}function EQ({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5"})})}function kQ({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),l.jsx("path",{d:"M4.5 4.75v3.5H8"}),l.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),l.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const Zht={llm:"智能体",sequential:"分步协作",parallel:"同时处理",loop:"循环执行",a2a:"远程智能体"},LH={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},Fpe="REGISTRY_SPACE_ID",Kht=Vne.filter(e=>e.key!==Fpe);function Vpe(e,t){var i,r,s;if(!(e!=null&&e.enabled))return{};const n={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(n.REGISTRY_TOP_K=((i=e.registryTopK)==null?void 0:i.trim())||Pl.topK,n.REGISTRY_REGION=((r=e.registryRegion)==null?void 0:r.trim())||Pl.region,n.REGISTRY_ENDPOINT=((s=e.registryEndpoint)==null?void 0:s.trim())||Pl.endpoint):(n.REGISTRY_TOP_K=e.registryTopK??"",n.REGISTRY_REGION=e.registryRegion??"",n.REGISTRY_ENDPOINT=e.registryEndpoint??""),n}function mS(e,t){return t!=="byteplus"?e:e.map(n=>n.key==="MODEL_EMBEDDING_NAME"?{...n,placeholder:tEe(t)}:n.key==="MODEL_EMBEDDING_API_BASE"?{...n,placeholder:Dl(t)}:n.key==="MODEL_IMAGE_NAME"?{...n,placeholder:iEe(t)}:n.key==="MODEL_EDIT_NAME"?{...n,placeholder:rEe(t)}:n.key==="MODEL_VIDEO_NAME"?{...n,placeholder:sEe(t)}:n.key==="MODEL_IMAGE_API_BASE"||n.key==="MODEL_EDIT_API_BASE"||n.key==="MODEL_VIDEO_API_BASE"?{...n,placeholder:Dl(t)}:n)}function Jht({items:e,selected:t,onToggle:n,scrollRows:i}){return l.jsx("div",{className:`cw-checklist ${i?"cw-checklist-tools":""}`,style:i?{"--cw-checklist-max-height":`${i*40+(i-1)*8}px`}:void 0,children:e.map(r=>{const s=t.includes(r.id);return l.jsx(yQ,{id:`cw-check-${r.id}`,className:`cw-check ${s?"is-on":""}`,checked:s,onCheckedChange:a=>{a!==s&&n(r.id)},label:l.jsx("span",{className:"cw-check-text",children:l.jsx("span",{className:"cw-check-title",children:r.label})})},r.id)})})}function OR({options:e,value:t,onChange:n}){return l.jsx("div",{className:"cw-segmented",children:e.map(i=>{var s;const r=(t??((s=e[0])==null?void 0:s.id))===i.id;return l.jsx("button",{type:"button",className:`cw-seg ${r?"is-on":""}`,onClick:()=>n(i.id),"aria-pressed":r,children:l.jsx("span",{className:"cw-seg-title",children:i.label})},i.id)})})}function ept(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function gO({env:e,values:t,onChange:n,renderAfterField:i}){return e.length===0?l.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):l.jsx("div",{className:"cw-env-fields",children:e.map(r=>{const s=t[r.key]??r.defaultValue??"",a=xQ(r,t),o=`cw-env-${r.key}`;return l.jsxs(m.Fragment,{children:[l.jsxs("label",{className:"cw-env-field",htmlFor:o,children:[l.jsxs("span",{className:"cw-env-field-head",children:[l.jsxs("span",{className:"cw-env-field-title",children:[l.jsxs("span",{className:"cw-env-field-label",children:[r.comment||r.key,r.required&&l.jsx("span",{className:"cw-req",children:"*"})]}),r.help&&l.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":r.help,"aria-label":`${r.comment||r.key}说明:${r.help}`,children:["?",l.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:r.help})]}),r.link&&l.jsx("a",{className:"cw-env-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${r.link.label}`,"aria-label":`打开 OpenViking ${r.link.label}`,onClick:c=>c.stopPropagation(),children:l.jsx(e0,{"aria-hidden":"true"})})]}),r.comment&&l.jsx("code",{title:r.key,children:r.key})]}),r.multiline||r.format==="json"?l.jsx("textarea",{id:o,className:"cw-input cw-env-textarea",value:s,placeholder:r.placeholder||"请输入参数值",autoComplete:"off",spellCheck:!1,"aria-invalid":!!a,onChange:c=>n(r.key,c.currentTarget.value)}):l.jsx("input",{id:o,className:"cw-input",type:ept(r.key)?"password":"text",value:s,placeholder:r.placeholder||"请输入参数值",autoComplete:"off","aria-invalid":!!a,onChange:c=>n(r.key,c.currentTarget.value)}),a&&l.jsx("span",{className:"cw-env-error",children:a})]}),i==null?void 0:i(r)]},r.key)})})}const yR="默认值:留空;生成项目时使用 Agent 名自动生成,例如 my_agent_kb。未配置 DATABASE_OPENVIKING_TARGET_URI 时,默认 URI 拼接为 viking://user/{知识库归属 ID,未填则 default}/resources/{资源索引}/;如果填写了 DATABASE_OPENVIKING_TARGET_URI,则直接使用该完整 URI。";function tpt({value:e,onChange:t}){const n="cw-openviking-knowledge-index";return l.jsxs("label",{className:"cw-env-field",htmlFor:n,children:[l.jsx("span",{className:"cw-env-field-head",children:l.jsxs("span",{className:"cw-env-field-title",children:[l.jsx("span",{className:"cw-env-field-label",children:"OpenViking 资源索引"}),l.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":yR,"aria-label":`OpenViking 资源索引说明:${yR}`,children:["?",l.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:yR})]})]})}),l.jsx("input",{id:n,className:"cw-input",value:e,placeholder:"",autoComplete:"off",onChange:i=>t(i.currentTarget.value)})]})}function xR(e){return e.name.trim()||"未命名智能体中心"}function vR(e){const t=e.name.trim()||e.id||"未命名知识库",n=[e.sourceLabel,e.projectName].filter(Boolean);return n.length?`${t} · ${n.join(" · ")}`:t}function npt(e){return e.available?"已开通":e.lifecycleStatus==="Retiring"?"即将下线":e.activationState&&e.activationState!=="Available"?"未开通":"暂不可用"}function ipt(e){return e.available||e.lifecycleStatus==="Retiring"}function DH({selectedLabel:e,placeholder:t,disabled:n,triggerAriaLabel:i,menuAriaLabel:r,searchAriaLabel:s,searchValue:a,searchPlaceholder:o,onSearchChange:c,empty:u,emptyLabel:d,triggerClassName:f="",optionsClassName:h="",renderOptions:p}){const[g,b]=m.useState(!1),y=m.useRef(null),O=m.useRef(null),v=m.useRef(null),x=m.useId(),[w,E]=m.useState(null);m.useEffect(()=>{if(!g)return;const T=N=>{var M;const C=N.target;C instanceof Node&&y.current&&!y.current.contains(C)&&!((M=v.current)!=null&&M.contains(C))&&b(!1)},A=N=>{var C;N.key==="Escape"&&(b(!1),(C=O.current)==null||C.focus())};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",A),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",A)}},[g]),m.useEffect(()=>{if(!g){E(null);return}const T=()=>{const A=O.current;if(!A)return;const N=A.getBoundingClientRect(),C=12,M=6,L=window.innerHeight-N.bottom-C-M,P=N.top-C-M,Q=L<300&&P>L,j=Math.max(96,Q?P:L),$=Math.min(N.width,window.innerWidth-C*2),U=Math.min(Math.max(C,N.left),window.innerWidth-C-$);E({...Q?{bottom:window.innerHeight-N.top+M}:{top:N.bottom+M},left:U,width:$,maxHeight:j,opensUp:Q})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[g]);const S=()=>b(!1),k=T=>{var M,L;if(!["ArrowDown","ArrowUp","Home","End"].includes(T.key))return;const A=Array.from(((M=v.current)==null?void 0:M.querySelectorAll('[role="option"]:not(:disabled)'))??[]);if(!A.length)return;T.preventDefault();const N=A.findIndex(P=>P===document.activeElement),C=T.key==="Home"?0:T.key==="End"?A.length-1:T.key==="ArrowUp"?N<=0?A.length-1:N-1:N<0||N===A.length-1?0:N+1;(L=A[C])==null||L.focus()};return l.jsxs("div",{className:`cw-a2a-space-select-wrap cw-catalog-select${g?" is-open":""}`,ref:y,children:[l.jsxs("button",{ref:O,type:"button",className:`cw-a2a-space-trigger ${f}`.trim(),disabled:n,"aria-haspopup":"listbox","aria-controls":g?x:void 0,"aria-expanded":g,"aria-label":i,title:e,onClick:()=>{g||c(""),b(T=>!T)},children:[l.jsx("span",{className:t?"is-placeholder":void 0,children:e}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),g&&w&&zi.createPortal(l.jsxs("div",{ref:v,className:`cw-a2a-space-menu cw-catalog-menu cw-catalog-menu-portal${w.opensUp?" is-up":""}`,style:{top:w.top,bottom:w.bottom,left:w.left,width:w.width,maxHeight:w.maxHeight},onKeyDown:k,children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:a,autoFocus:!0,autoComplete:"off","aria-label":s,placeholder:o,onChange:T=>c(T.currentTarget.value)})}),l.jsxs("div",{id:x,className:`cw-picker-options cw-catalog-options ${h}`.trim(),role:"listbox","aria-label":r,children:[p(S),u&&l.jsx("div",{className:"cw-picker-empty",children:d})]})]}),document.body)]})}function rpt({value:e,cloudProvider:t,apiKeyId:n,apiKeyName:i,onApiKeyChange:r,onChange:s}){const[a,o]=m.useState([]),[c,u]=m.useState(!1),[d,f]=m.useState([]),[h,p]=m.useState(null),[g,b]=m.useState(!1),[y,O]=m.useState(null),[v,x]=m.useState(0),[w,E]=m.useState(0),[S,k]=m.useState(""),[T,A]=m.useState("");m.useEffect(()=>{const D=new AbortController;return u(!0),O(null),EJ(D.signal,v>0).then(H=>{if(D.signal.aborted)return;o(H.keys);const re=H.keys.find(fe=>fe.id===n)??H.keys.find(fe=>fe.name===i)??H.keys.find(fe=>fe.id===H.defaultKeyId)??H.keys[0];re&&r(re)}).catch(H=>{D.signal.aborted||O(H instanceof Error?H.message:"加载 Ark API Key 失败")}).finally(()=>{D.signal.aborted||u(!1)}),()=>D.abort()},[t,v]),m.useEffect(()=>{if(!n){f([]);return}const D=new AbortController;return b(!0),O(null),p(null),TJ({signal:D.signal,apiKeyId:n,refresh:v>0||w>0}).then(H=>{D.signal.aborted||(f(H.models),p(n))}).catch(H=>{D.signal.aborted||O(H instanceof Error?H.message:"加载模型列表失败")}).finally(()=>{D.signal.aborted||b(!1)}),()=>D.abort()},[n,t,w,v]);const N=e.trim(),C=h===n,M=C?d:[],L=a.find(D=>D.id===n),P=L?L.name:n?"当前 API Key":c?"正在加载 API Key…":a.length===0?"暂无可用 API Key":"请选择 API Key",Q=m.useMemo(()=>a.filter(D=>up(S,[D.name])),[S,a]),j=M.find(D=>D.id===N),$=g&&!C?"正在刷新模型列表…":j?`${j.displayName} (${j.id})`:N||"请选择模型",U=m.useMemo(()=>M.filter(D=>up(T,[D.displayName,D.id,D.name,D.vendorName,D.activationState,D.lifecycleStatus])),[T,M]),B=!!(N&&!j&&up(T,[N])),I=M.filter(D=>D.available).length,X=t==="byteplus"?"BytePlus ModelArk":"火山方舟",q=eEe(t);return l.jsxs("div",{className:"cw-a2a-space-picker cw-model-picker",children:[l.jsxs("div",{className:"cw-model-picker-stack",children:[l.jsxs("div",{className:"cw-model-picker-field",children:[l.jsx("span",{className:"cw-model-picker-label",children:"API Key"}),l.jsx(DH,{selectedLabel:P,placeholder:!n,disabled:c,triggerAriaLabel:"选择 API Key",menuAriaLabel:"API Key 列表",searchAriaLabel:"搜索 API Key",searchValue:S,searchPlaceholder:"搜索 API Key 名称",onSearchChange:k,empty:Q.length===0,emptyLabel:"未找到匹配的 API Key",optionsClassName:"cw-model-key-options",renderOptions:D=>Q.map(H=>{const re=H.id===n;return l.jsx("button",{type:"button",role:"option","aria-selected":re,className:`cw-a2a-space-option cw-model-key-option ${re?"is-selected":""}`,title:H.name,onClick:()=>{E(fe=>fe+1),r(H),D()},children:l.jsx("span",{children:H.name})},H.id)})})]}),l.jsxs("div",{className:"cw-model-picker-field",children:[l.jsx("span",{className:"cw-model-picker-label",children:"模型"}),l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsx(DH,{selectedLabel:$,placeholder:!N,disabled:g,triggerAriaLabel:`选择${X}模型`,menuAriaLabel:`${X}模型`,searchAriaLabel:"搜索模型",searchValue:T,searchPlaceholder:"搜索名称、Model ID 或服务商",onSearchChange:A,empty:!B&&U.length===0,emptyLabel:"未找到匹配的模型",triggerClassName:"cw-model-trigger",optionsClassName:"cw-model-options",renderOptions:D=>l.jsxs(l.Fragment,{children:[B&&l.jsxs("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option cw-model-option is-selected",onClick:()=>{s(N),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:"当前配置"}),l.jsx("small",{children:N})]}),l.jsx("span",{className:"cw-model-status is-unknown",children:"状态未知"})]}),U.map(H=>{const re=H.id===N,fe=ipt(H);return!fe&&H.activationState!=="Available"?l.jsxs("button",{type:"button",role:"option","aria-selected":!1,className:"cw-a2a-space-option cw-model-option is-activation-link",title:`前往${X}开通 ${H.displayName}`,onClick:()=>{window.open(q,"_blank","noopener,noreferrer"),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:H.displayName}),l.jsxs("small",{children:[H.id,H.vendorName?` · ${H.vendorName}`:""]})]}),l.jsx("span",{className:"cw-model-status is-unavailable",children:"未开通,去开通"})]},H.id):l.jsxs("button",{type:"button",role:"option","aria-selected":re,disabled:!fe,className:`cw-a2a-space-option cw-model-option ${re?"is-selected":""}`,title:`${H.displayName} (${H.id})`,onClick:()=>{s(H.id),D()},children:[l.jsxs("span",{className:"cw-model-option-copy",children:[l.jsx("strong",{children:H.displayName}),l.jsxs("small",{children:[H.id,H.vendorName?` · ${H.vendorName}`:""]})]}),l.jsx("span",{className:`cw-model-status ${H.available?"is-available":H.lifecycleStatus==="Retiring"?"is-retiring":"is-unavailable"}`,children:npt(H)})]},H.id)})]})}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新 API Key 和模型列表","aria-label":"刷新 API Key 和模型列表",disabled:g||c,onClick:()=>x(D=>D+1),children:g||c?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]})]})]}),y?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",role:"alert",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:y})]}):g?l.jsxs("span",{className:"cw-help cw-a2a-space-status","aria-live":"polite",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载模型列表…"]}):M.length===0?l.jsx("span",{className:"cw-help",children:"当前账号下暂无可配置模型。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",M.length," 个模型,其中 ",I," 个已开通。"]})]})}function spt({value:e,region:t,invalid:n,onChange:i}){const r=t.trim()||Pl.region,[s,a]=m.useState([]),[o,c]=m.useState(!1),[u,d]=m.useState(null),[f,h]=m.useState(0),[p,g]=m.useState(!1),[b,y]=m.useState(""),O=m.useRef(null);m.useEffect(()=>{let A=!1;return c(!0),d(null),rht({region:r}).then(N=>{A||a(N)}).catch(N=>{A||(a([]),d(N instanceof Error?N.message:"加载失败"))}).finally(()=>{A||c(!1)}),()=>{A=!0}},[r,f]);const v=!e||s.some(A=>A.id===e.trim()),x=s.find(A=>A.id===e.trim()),w=x?xR(x):e&&!v?"已选择的智能体中心":"请选择智能体中心",E=o&&s.length===0,S=m.useMemo(()=>s.filter(A=>up(b,[xR(A),A.id,A.projectName])),[b,s]),k=!!(e&&!v&&up(b,["已选择的智能体中心",e]));m.useEffect(()=>{if(!p)return;const A=C=>{const M=C.target;M instanceof Node&&O.current&&!O.current.contains(M)&&g(!1)},N=C=>{C.key==="Escape"&&g(!1)};return window.addEventListener("pointerdown",A),window.addEventListener("keydown",N),()=>{window.removeEventListener("pointerdown",A),window.removeEventListener("keydown",N)}},[p]);const T=A=>{i(A),g(!1)};return l.jsxs("div",{className:`cw-a2a-space-picker${p?" is-open":""}`,ref:O,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:E,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{y(""),g(A=>!A)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:w}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),p&&l.jsxs("div",{className:"cw-a2a-space-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:b,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:A=>y(A.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[k&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>T(e),children:"已选择的智能体中心"}),S.map(A=>{const N=xR(A),C=A.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":C,className:`cw-a2a-space-option ${C?"is-selected":""}`,title:`${N} (${A.id})`,onClick:()=>T(A.id),children:N},A.id)}),!k&&S.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:o,onClick:()=>h(A=>A+1),children:o?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]}),u?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:u})]}):o?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):s.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",s.length," 个智能体中心,列表仅展示中心名称。"]})]})}function apt({value:e,onChange:t}){const[n,i]=m.useState([]),[r,s]=m.useState(!1),[a,o]=m.useState(null),[c,u]=m.useState(0),[d,f]=m.useState(!1),[h,p]=m.useState(""),g=m.useRef(null);m.useEffect(()=>{let S=!1;return s(!0),o(null),aht().then(k=>{S||i(k)}).catch(k=>{S||(i([]),o(k instanceof Error?k.message:"加载失败"))}).finally(()=>{S||s(!1)}),()=>{S=!0}},[c]);const b=!e||n.some(S=>S.id===e.trim()),y=n.find(S=>S.id===e.trim()),O=y?vR(y):e&&!b?e:"请选择 VikingDB 知识库",v=r&&n.length===0,x=m.useMemo(()=>n.filter(S=>up(h,[vR(S),S.id,S.description,S.projectName,S.resourceId,S.agentkitKnowledgeId,S.providerKnowledgeId,S.sourceLabel])),[n,h]),w=!!(e&&!b&&up(h,[e]));m.useEffect(()=>{if(!d)return;const S=T=>{const A=T.target;A instanceof Node&&g.current&&!g.current.contains(A)&&f(!1)},k=T=>{T.key==="Escape"&&f(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",k),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",k)}},[d]);const E=S=>{t(S),f(!1)};return r&&n.length===0?l.jsxs("span",{className:"cw-viking-kb-inline-status",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}),"正在加载…"]}):l.jsxs("div",{className:`cw-a2a-space-picker cw-viking-kb-picker${d?" is-open":""}`,ref:g,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:v,"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"选择 VikingDB 知识库",onClick:()=>{p(""),f(S=>!S)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:O}),l.jsx(EQ,{className:"cw-a2a-space-trigger-icon"})]}),d&&l.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:h,autoFocus:!0,autoComplete:"off","aria-label":"搜索 VikingDB 知识库",placeholder:"搜索名称或 ID",onChange:S=>p(S.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"VikingDB 知识库",children:[w&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>E({id:e,name:e,description:"",projectName:"",region:"",sourceKind:"knowledge",sourceLabel:"Knowledge Engine",resourceId:""}),children:e}),x.map(S=>{const k=vR(S),T=S.id===e,A=[S.id,S.resourceId,S.agentkitKnowledgeId,S.providerKnowledgeId].filter(Boolean).join(" / ");return l.jsx("button",{type:"button",role:"option","aria-selected":T,className:`cw-a2a-space-option ${T?"is-selected":""}`,title:A?`${k} (${A})`:k,onClick:()=>E(S),children:k},S.id)}),!w&&x.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的知识库"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:"刷新知识库列表","aria-label":"刷新知识库列表",disabled:r,onClick:()=>u(S=>S+1),children:r?l.jsx(Kn,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(kQ,{className:"cw-i cw-i-sm"})})]}),a?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(hd,{className:"cw-i"}),l.jsx("span",{children:a})]}):n.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 VikingDB 知识库。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",n.length," 个知识库,选择的知识库会用于当前 Agent。"]})]})}function opt({tools:e,onChange:t}){const n=(s,a)=>t(e.map((o,c)=>c===s?{...o,...a}:o)),i=s=>t(e.filter((a,o)=>o!==s)),r=()=>t([...e,{name:"",transport:"http",url:""}]);return l.jsxs("div",{className:"cw-mcp",children:[e.length>0&&l.jsx("div",{className:"cw-mcp-list",children:l.jsx(xf,{initial:!1,children:e.map((s,a)=>l.jsxs(wr.div,{className:"cw-mcp-row",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.16},children:[l.jsxs("div",{className:"cw-mcp-rowhead",children:[l.jsxs("div",{className:"cw-mcp-transport",children:[l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":s.transport==="http",children:l.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":s.transport==="stdio",children:l.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>i(a),"aria-label":"移除 MCP 工具",children:l.jsx(If,{className:"cw-i cw-i-sm"})})]}),l.jsx("input",{className:"cw-input",value:s.name,placeholder:"名称(用于命名,可留空)",onChange:o=>n(a,{name:o.target.value})}),s.transport==="http"?l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:s.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:o=>n(a,{url:o.target.value})}),Dft(s.url??"")&&l.jsxs("p",{className:"cw-mcp-warning",children:[l.jsx(hd,{"aria-hidden":"true"}),l.jsx("span",{children:"当前地址不是以 /mcp 结尾,请确认它是实际的 MCP Endpoint。Studio 会保留该地址,不会自动补充路径。"})]}),l.jsx("input",{className:"cw-input",value:Mft(s),placeholder:"Bearer Token(可选)",onChange:o=>t(e.map((c,u)=>u===a?Lft(c,o.target.value):c))})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:s.command??"",placeholder:"启动命令,例如 npx",onChange:o=>n(a,{command:o.target.value})}),l.jsx("input",{className:"cw-input",value:(s.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:o=>n(a,{args:o.target.value.split(/\s+/).filter(Boolean)})}),l.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),l.jsxs("button",{type:"button",className:"cw-add-sub",onClick:r,children:[l.jsx(Gs,{className:"cw-i"}),"添加 MCP 工具"]})]})}function Xpe({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M5.5 7.5h10.75a2 2 0 0 1 2 2v7.75a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V9.5a2 2 0 0 1 2-2Z"}),l.jsx("path",{d:"M7 4.75h9.5a2 2 0 0 1 2 2",opacity:".58"}),l.jsx("path",{d:"m11 10.25.72 1.48 1.63.24-1.18 1.15.28 1.62-1.45-.77-1.45.77.28-1.62-1.18-1.15 1.63-.24.72-1.48Z"}),l.jsx("path",{d:"M19.25 11.25h1.5M20 10.5V12",opacity:".72"})]})}function lpt({s:e,onRemove:t}){let n=tx,i="火山 Find Skill 技能广场";return e.source==="local"?(n=MD,i="本地"):e.source==="skillspace"&&(n=Xpe,i="AgentKit Skills 中心"),l.jsxs(wr.div,{className:"cw-selected-skill-row",layout:!0,initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16},children:[l.jsx("span",{className:"cw-selected-skill-icon","aria-hidden":!0,children:l.jsx(n,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-selected-skill-meta",children:[l.jsx("span",{className:"cw-selected-skill-name",children:e.name}),l.jsxs("span",{className:"cw-selected-skill-detail",children:[i,e.description?` · ${r1(e.description)}`:""]})]}),l.jsx("button",{type:"button",className:"cw-selected-skill-remove",onClick:t,"aria-label":`移除 ${e.name}`,title:`移除 ${e.name}`,children:l.jsx(xa,{className:"cw-i cw-i-sm"})})]},`${e.source}:${e.folder}:${e.skillId||e.slug||""}:${e.version||""}`)}const wR=[{id:"local",label:"本地文件",icon:MD},{id:"skillspace",label:"AgentKit Skills 中心",icon:Xpe},{id:"skillhub",label:"火山 Find Skill 技能广场",icon:O_}];function cpt({selected:e,onChange:t,cloudProvider:n}){const[i,r]=m.useState("local"),[s,a]=m.useState(!1),o=wR.findIndex(u=>u.id===i),c=u=>t(e.filter(d=>SR(d)!==u));return m.useEffect(()=>{if(!s)return;const u=d=>{d.key==="Escape"&&a(!1)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]),l.jsxs("div",{className:"cw-skillspane",children:[l.jsxs("button",{type:"button",className:"cw-skill-add","aria-haspopup":"dialog",onClick:()=>a(!0),children:[l.jsx("span",{className:"cw-skill-add-icon","aria-hidden":!0,children:l.jsx(Gs,{className:"cw-i"})}),l.jsx("span",{children:"添加 Skill"})]}),e.length>0&&l.jsxs("div",{className:"cw-skill-selected",children:[l.jsxs("span",{className:"cw-skill-selected-label",children:["已加入技能 · ",e.length]}),l.jsx("div",{className:"cw-selected-skill-list",children:l.jsx(xf,{initial:!1,children:e.map(u=>l.jsx(lpt,{s:u,onRemove:()=>c(SR(u))},SR(u)))})})]}),l.jsx(xf,{children:s&&l.jsx(wr.div,{className:"cw-skill-dialog-backdrop",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},onMouseDown:u=>{u.target===u.currentTarget&&a(!1)},children:l.jsxs(wr.div,{className:"cw-skill-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"cw-skill-dialog-title",initial:{opacity:0,y:10,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.99},transition:{duration:.18,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-skill-dialog-head",children:[l.jsx("h3",{id:"cw-skill-dialog-title",children:"添加 Skill"}),l.jsx("button",{type:"button",className:"cw-skill-dialog-close","aria-label":"关闭添加 Skill",onClick:()=>a(!1),children:l.jsx(xa,{className:"cw-i"})})]}),l.jsxs("div",{className:"cw-skill-dialog-body",children:[l.jsxs("div",{className:"cw-skill-sourcetabs",role:"tablist",style:{"--cw-skill-tab-slider-width":`calc((100% - 16px) / ${wR.length})`,"--cw-active-skill-tab-offset":`calc(${o*100}% + ${o*4}px)`},children:[l.jsx("span",{className:"cw-skill-tab-slider","aria-hidden":!0}),wR.map(({id:u,label:d,icon:f})=>l.jsxs("button",{type:"button",role:"tab",id:`cw-skill-tab-${u}`,"aria-controls":"cw-skill-tabpanel","aria-selected":i===u,className:`cw-skill-pickertab ${i===u?"is-on":""}`,onClick:()=>r(u),children:[l.jsx(f,{className:"cw-i cw-i-sm"}),d]},u))]}),l.jsxs("div",{id:"cw-skill-tabpanel",className:"cw-skill-tabbody",role:"tabpanel","aria-labelledby":`cw-skill-tab-${i}`,children:[i==="skillhub"&&l.jsx(Vft,{selected:e,onChange:t}),i==="local"&&l.jsx(tht,{selected:e,onChange:t}),i==="skillspace"&&l.jsx(nht,{selected:e,onChange:t,cloudProvider:n})]})]})]})})})]})}function SR(e){return e.source==="skillhub"?`hub:${e.namespace}/${e.slug}`:e.source==="local"?`local:${e.folder}`:`ss:${e.skillSpaceId}/${e.skillId}/${e.version||""}`}function gS({checked:e,onChange:t,title:n,desc:i,showDescription:r=!1}){return l.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[l.jsxs("span",{className:"cw-toggle-text",children:[l.jsx("span",{className:"cw-toggle-title",children:n}),r&&l.jsx("span",{className:"cw-toggle-help",children:i})]}),l.jsx("span",{className:"cw-switch","aria-hidden":!0,children:l.jsx(wr.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}function upt(e,t){var i;let n=e;for(const r of t)if(n=(i=n.subAgents)==null?void 0:i[r],!n)return!1;return!0}function bS(e,t){let n=e;for(const i of t)n=n.subAgents[i];return n}function ov(e,t,n){if(t.length===0)return n(e);const[i,...r]=t,s=e.subAgents.slice();return s[i]=ov(s[i],r,n),{...e,subAgents:s}}function dpt(e,t,n="volcengine"){return ov(e,t,i=>({...i,subAgents:[...i.subAgents,el(n)]}))}function fpt(e,t,n,i="volcengine"){return ov(e,t,r=>{const s=r.subAgents.slice();return s.splice(n,0,el(i)),{...r,subAgents:s}})}function hpt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),i=t[t.length-1];return ov(e,n,r=>({...r,subAgents:r.subAgents.filter((s,a)=>a!==i)}))}const FL=e=>!ZA(e.agentType),$H=3;function ppt(e,t,n=!1){var r;if(ZA(e.agentType))return n?"远程 Agent 只能作为子 Agent":(r=e.a2aRegistry)!=null&&r.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const i=i1(e.name);return i||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":ppe(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function qpe(e,t,n=[]){const i=[],r=ZA(e.agentType),s=ppt(e,t,n.length===0);return s&&i.push({path:n,name:r?"远程 Agent":e.name.trim()||"未命名",typeLabel:hpe(e.agentType).label,problem:s}),FL(e)&&e.subAgents.forEach((a,o)=>i.push(...qpe(a,t,[...n,o]))),i}function mpt(e){return`${e.typeLabel}至少需要添加一个子 Agent 后才能调试或发布。`}function Hpe(e){return 1+e.subAgents.reduce((t,n)=>t+Hpe(n),0)}function Ype(e){const t=KA(e),n=[],i={...t.envValues},r=t.draft.cloudProvider??"volcengine";let s=!1;for(const c of jpe(t.draft,Dl(r))){const u=[{key:c.apiKeyKey,required:!0,comment:c.label}];c.providerKey&&(u.push({key:c.providerKey,required:!0}),i[c.providerKey]=c.provider),c.apiBaseKey&&(u.push({key:c.apiBaseKey,required:!0}),i[c.apiBaseKey]=c.apiBase),n.push({env:u})}const a=c=>{var u,d,f,h;c.agentType==="llm"&&Ob(c,r)==="ark"&&(s=!0);for(const p of c.builtinTools??[]){const g=Qp.find(b=>b.id===p);g&&n.push({env:mS(g.env,r)})}for(const p of c.mcpTools??[])p.authTokenEnv&&n.push({env:[{key:p.authTokenEnv,required:!1,comment:`${p.name.trim()||"MCP"} Bearer Token`}]});if((u=c.a2aRegistry)!=null&&u.enabled&&(n.push({env:Vne}),Object.assign(i,Vpe(c.a2aRegistry,{includeDefaults:!0}))),c.memory.shortTerm&&n.push({env:mS(((d=RP.find(p=>p.id===(c.shortTermBackend??"local")))==null?void 0:d.env)??[],r)}),c.memory.longTerm&&n.push({env:mS(((f=IP.find(p=>p.id===(c.longTermBackend??"local")))==null?void 0:f.env)??[],r)}),c.knowledgebase&&n.push({env:mS(((h=PP.find(p=>p.id===(c.knowledgebaseBackend??wf)))==null?void 0:h.env)??[],r)}),c.tracing)for(const p of c.tracingExporters??[]){const g=vPe.find(b=>b.id===p);g&&n.push({env:g.env,enableFlag:g.enableFlag})}c.subAgents.forEach(a)};a(t.draft),s&&(n.push({env:[{key:"MODEL_AGENT_PROVIDER",required:!0},{key:"MODEL_AGENT_API_BASE",required:!0},{key:"MODEL_AGENT_API_KEY",required:!0,comment:"Ark API Key",placeholder:"由所选 API Key 注入",secret:!0,readOnly:!0,serverManaged:!0}]}),i.MODEL_AGENT_PROVIDER="openai",i.MODEL_AGENT_API_BASE=Dl(r));const o=upe(n);return{specs:o.specs,fixedValues:{...o.fixedValues,...i}}}function gpt(e,t){const n=i=>(i??"").trim().replace(/\/+$/,"");return n(e)===n(t)}function bpt(e,t,n){const i=(e??"").trim();return!i||i===t0(t)?!0:i===t0(n)?!1:n==="byteplus"&&i.includes("doubao-")}function $h(e,t){const n=e.cloudProvider??"volcengine",i=Ob(e,n),r=e.subAgents.map(u=>$h(u,t)),s=i==="ark"&&bpt(e.modelName,n,t)?t0(t):e.modelName,o=gpt(e.modelApiBase,Dl(n))||t==="byteplus"&&(e.modelApiBase??"").includes("volces.com")?Dl(t):e.modelApiBase;return e.cloudProvider!==t||s!==e.modelName||o!==e.modelApiBase||r.some((u,d)=>u!==e.subAgents[d])?{...e,cloudProvider:t,modelName:s,modelApiBase:o,subAgents:r}:e}function Opt(e,t){var o;const n=$h(e,t),i=Rpe(n,Dl(t)),r=new Set(i.map(({key:c})=>c)),s=((o=n.deployment)==null?void 0:o.envValues)??{},a=Object.fromEntries(Object.entries(s).filter(([c,u])=>r.has(c)&&!!u.trim()));return Object.keys(a).length===0?{draft:n,customModelSecretValues:a}:{draft:{...n,deployment:{...n.deployment??{feishuEnabled:!1},envValues:Object.fromEntries(Object.entries(s).filter(([c])=>!r.has(c)))}},customModelSecretValues:a}}function Gpe(e){var i,r,s;const t=KA(e).draft;return{...Mpe(t,t.cloudProvider??"volcengine"),deployment:{feishuEnabled:!!((i=e.deployment)!=null&&i.feishuEnabled),modelApiKeyId:((r=e.deployment)==null?void 0:r.modelApiKeyId)??"",modelApiKeyName:((s=e.deployment)==null?void 0:s.modelApiKeyName)??""}}}function VL(e){var n;const t=(n=e.modelName)==null?void 0:n.trim();if(t)return t;for(const i of e.subAgents){const r=VL(i);if(r)return r}return""}function Wpe(e,t={}){var r,s,a,o;const n=Ype(e),i={...((r=e.deployment)==null?void 0:r.envValues)??{},...t,...n.fixedValues};return{...Gpe(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),modelApiKeyId:((a=e.deployment)==null?void 0:a.modelApiKeyId)??"",modelApiKeyName:((o=e.deployment)==null?void 0:o.modelApiKeyName)??"",envValues:Object.fromEntries(dpe(n.specs,i).map(({key:c,value:u})=>[c,u]))}}}function ypt(e,t={}){return JSON.stringify(Wpe(e,t))}function DT(e,t){return JSON.stringify({draftSnapshot:e,modelName:t.modelName,description:t.description,instruction:t.instruction,optimizations:t.optimizations})}function dg(e){return JSON.stringify({modelName:e.modelName.trim(),description:e.description.trim(),instruction:e.instruction.trim(),optimizations:e.optimizations})}function xpt({enabled:e,disabledReason:t,variants:n,draftSnapshot:i,input:r,onInput:s,onSend:a,onStartVariant:o,onDeployVariant:c,onAddVariant:u,onRemoveVariant:d,onToggleConfig:f,onCompleteConfig:h,onConfigChange:p,onOpenTrace:g}){const b=n.filter(v=>v.phase!=="ready"?!1:v.runtimeSnapshot===DT(i,v)),y=n.some(v=>v.phase==="sending"),O=b.length>0&&!y;return l.jsxs("section",{className:"cw-ab-workspace","aria-label":"A/B 调试工作台",children:[l.jsx("div",{className:"cw-ab-stage",children:e?l.jsx("div",{className:"cw-ab-grid",style:{"--cw-ab-column-count":n.length},children:n.map((v,x)=>{const w=v.modelName.trim(),E=v.description.trim(),S=v.instruction.trim(),k=dg(v),T=!!(w&&E&&S&&n.findIndex(U=>dg(U)===k)!==x),A=!w||!E||!S||T,N=!!(v.runtimeSnapshot&&v.runtimeSnapshot!==DT(i,v)),C=v.phase==="starting",M=v.phase==="ready"&&!N,L=C||v.phase==="sending",P=M&&v.phase!=="sending"&&v.messages.some(U=>U.role==="assistant"),Q=L||v.configOpen||A,j=w?E?S?T?"该配置与已有测试组相同":"":"请填写系统提示词":"请填写描述":"请先选择模型",$=C?"正在启动":N?"应用配置并重启":M||v.phase==="error"?"重新启动环境":"启动环境";return l.jsx("article",{className:"cw-ab-card",children:l.jsxs("div",{className:`cw-ab-card-inner${v.configOpen?" is-flipped":""}`,children:[l.jsxs("section",{className:"cw-ab-card-face cw-ab-card-front","aria-hidden":v.configOpen,children:[l.jsxs("header",{className:"cw-ab-card-head",children:[l.jsxs("div",{className:"cw-ab-card-title",children:[l.jsx("strong",{children:v.name}),l.jsx("span",{children:v.modelName||"默认模型"})]}),l.jsxs("div",{className:"cw-ab-card-actions",children:[l.jsx("button",{type:"button",className:"cw-ab-config-trigger",disabled:v.configOpen||L,onClick:()=>f(v.id),children:"测试配置"}),v.id!=="baseline"&&l.jsx("button",{type:"button",className:"cw-ab-remove","aria-label":`删除${v.name}`,disabled:v.configOpen||L,onClick:()=>d(v.id),children:l.jsx(MH,{className:"cw-i"})})]})]}),l.jsx("div",{className:"cw-ab-conversation",children:v.error?l.jsx(LT,{message:v.error,className:"cw-debug-error-detail",defaultExpanded:!0}):C?l.jsxs("div",{className:"cw-ab-empty cw-ab-starting",children:[l.jsx(Kn,{className:"cw-i cw-spin"}),l.jsx("span",{children:"正在创建独立测试环境"})]}):N?l.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:l.jsx("span",{children:"配置已变更,请重新启动此环境"})}):v.messages.length===0?l.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:M?l.jsxs(l.Fragment,{children:[l.jsx("strong",{className:"cw-ab-ready-title",children:"已就绪"}),l.jsx("span",{className:"cw-ab-launch-hint",children:"可在下方输入测试消息"})]}):l.jsx("span",{className:"cw-ab-launch-hint",children:j||"启动环境后即可加入本轮测试"})}):v.messages.map((U,B)=>l.jsx("div",{className:`cw-debug-msg cw-debug-msg-${U.role}`,children:l.jsx("div",{className:"cw-debug-content",children:U.role==="user"?U.content:U.error?l.jsx(LT,{message:U.error,className:"cw-debug-msg-error",defaultExpanded:!0}):U.blocks&&U.blocks.length>0?l.jsx(vA,{blocks:U.blocks,onAction:()=>{}}):U.content?U.content:B===v.messages.length-1&&v.phase==="sending"?l.jsx(fle,{}):null})},B))}),l.jsxs("footer",{className:"cw-ab-deploy-footer",children:[l.jsx("button",{type:"button",className:"cw-ab-trace",disabled:!P,title:P?`查看${v.name}调用链路`:"完成一次调试后可查看调用链路",onClick:()=>g(v.id),children:"调用链路"}),l.jsxs("button",{type:"button",className:"cw-ab-start cw-ab-footer-start",disabled:Q,title:j||void 0,onClick:()=>o(v.id),children:[M||N||v.phase==="error"?l.jsx(uSe,{className:"cw-i"}):l.jsx(Wht,{className:"cw-i cw-debug-run-icon"}),$]}),l.jsx("button",{type:"button",className:"cw-ab-deploy",disabled:L||!w,onClick:()=>c(v.id),children:"部署该配置"})]})]}),l.jsxs("section",{className:"cw-ab-card-face cw-ab-card-back","aria-hidden":!v.configOpen,children:[l.jsxs("header",{className:"cw-ab-config-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"测试配置"}),l.jsx("span",{children:v.name})]}),l.jsxs("div",{className:"cw-ab-config-head-actions",children:[v.id!=="baseline"&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger cw-ab-config-remove","aria-label":`删除${v.name}`,title:"删除配置组",disabled:L,onClick:()=>d(v.id),children:l.jsx(MH,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:`cw-ab-config-done-wrap${j?" is-disabled":""}`,tabIndex:j?0:void 0,children:[l.jsx("button",{type:"button",className:"cw-ab-config-done",disabled:!v.configOpen||A,onClick:()=>h(v.id),children:v.id==="baseline"?"完成配置":"完成并启动"}),j&&l.jsx("span",{className:"cw-ab-config-done-tip",role:"tooltip",children:j})]})]})]}),l.jsxs("div",{className:"cw-ab-config",children:[l.jsxs("label",{children:[l.jsx("span",{children:"模型"}),l.jsx("input",{value:v.modelName,placeholder:"使用 Agent 当前模型",disabled:!v.configOpen,onChange:U=>p(v.id,"modelName",U.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"描述"}),l.jsx("textarea",{rows:2,value:v.description,disabled:!v.configOpen,onChange:U=>p(v.id,"description",U.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"系统提示词"}),l.jsx("textarea",{rows:5,value:v.instruction,disabled:!v.configOpen,onChange:U=>p(v.id,"instruction",U.target.value)})]}),l.jsxs("fieldset",{className:"cw-ab-optimizations-disabled",children:[l.jsxs("legend",{children:[l.jsx("span",{children:"优化选项"}),l.jsx("em",{children:"待开放"})]}),l.jsx("div",{className:"cw-ab-optimization-list",children:Zpe.map(U=>l.jsx(yQ,{checked:v.optimizations.includes(U.id),disabled:!0,label:U.label,className:"cw-ab-optimization-checkbox"},U.id))})]}),l.jsx("p",{children:"设置完成后返回正面,再启动当前测试环境。"})]})]})]})},v.id)})}):l.jsx("div",{className:"cw-debug-empty",children:t})}),l.jsxs("div",{className:"cw-ab-composer",children:[l.jsxs("div",{className:"cw-debug-composerbox",children:[l.jsx("textarea",{className:"cw-debug-input",rows:1,value:r,placeholder:O?"输入测试消息,将发送到所有已启动测试组...":"请先启动至少一个测试组",disabled:!O,onChange:v=>s(v.target.value),onKeyDown:v=>{OQ(v.nativeEvent)||v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),a())}}),l.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!O||!r.trim(),onClick:a,children:y?l.jsx(Kn,{className:"cw-i cw-spin"}):l.jsx(Qwe,{className:"cw-i"})})]}),e&&n.length<3&&l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft cw-ab-add",onClick:u,children:[l.jsx(Gs,{className:"cw-i"}),"添加对照组"]})]})]})}const OS=[{id:"build",label:"架构"},{id:"validate",label:"调试"},{id:"publish",label:"发布"}],Zpe=[{id:"context",label:"上下文优化",description:"压缩历史对话,保留与当前任务相关的信息"},{id:"grounding",label:"幻觉抑制",description:"对不确定内容要求依据,并明确表达未知"},{id:"tools",label:"工具调用优化",description:"减少重复调用,优先复用可信的工具结果"},{id:"latency",label:"响应加速",description:"缓存稳定上下文,降低重复推理开销"}];function vpt({mode:e}){const t=e==="validate"?"调试您的智能体":e==="publish"?"准备好部署您的智能体":"个性化您的智能体架构";return l.jsx("header",{className:"cw-workspace-header",children:l.jsx("h1",{children:t})})}function wpt({mode:e,busy:t,onChange:n,assistant:i}){const r=OS.findIndex(o=>o.id===e),s=OS[r-1],a=OS[r+1];return l.jsxs("footer",{className:"cw-workspace-footer",children:[l.jsxs("div",{className:`cw-workspace-nav-actions${i?" has-assistant":""}`,children:[l.jsx("button",{type:"button",className:`cw-workspace-nav-button${e==="build"?" is-placeholder":""}`,"aria-hidden":e==="build"||void 0,tabIndex:e==="build"?-1:0,disabled:!s||t,onClick:()=>s&&n(s.id),children:"上一步"}),l.jsx("span",{"aria-hidden":"true"}),i?l.jsx("div",{className:"cw-workspace-ai-slot",children:i}):null,e==="publish"?l.jsx("div",{id:"cw-publish-primary-action",className:"cw-publish-action-slot"}):l.jsx("button",{type:"button",className:"cw-workspace-nav-button is-primary",disabled:!a||t,onClick:()=>a&&n(a.id),children:"下一步"})]}),l.jsx("nav",{className:"cw-workspace-progress","aria-label":"Agent 创建进度",children:OS.map((o,c)=>{const u=o.id===e;return l.jsx("button",{type:"button",className:`${u?"is-active":""}${cn(o.id),children:l.jsx("span",{"aria-hidden":"true"})},o.id)})})]})}function Spt({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:i,features:r,onDeploymentTaskChange:s,createMode:a="custom",deploymentTarget:o,cloudProvider:c="volcengine",initialDeployRegion:u=Qi(c),onDeploymentComplete:d,onDeploymentStarted:f,onDraftChange:h,onDiscard:p}){var Kl,Ke,Ds,Ea,nu,$s,Jl,ec,le,gn,Wn,Vi,Ln,Tn,ra,Qs,dr,ws,ls;const[g]=m.useState(()=>Opt(i??el(c),c)),[b,y]=m.useState(g.draft),[O,v]=m.useState(g.customModelSecretValues),x=((Kl=b.deployment)==null?void 0:Kl.runtimeName)??"",w=o?o.name:Kct(b.name,x,(Ke=b.deployment)==null?void 0:Ke.runtimeNameCustomized),E=O;m.useEffect(()=>{y(te=>$h(te,c))},[c]);const[S,k]=m.useState(""),[T,A]=m.useState(!1),[N,C]=m.useState(!1),[M,L]=m.useState(!1),[P,Q]=m.useState(null),j=S.trim(),$=j.length>0&&j.length{q.current=h},[h]),m.useEffect(()=>{var te;I!==B.current&&(B.current=I,(te=q.current)==null||te.call(q,$h(b,c),X))},[c,b,X,I]);const[D,H]=m.useState("build"),[re,fe]=m.useState(!1),[Ae,J]=m.useState(0),[ie,ue]=m.useState(null),[ye,Se]=m.useState(!1),[Re,Ee]=m.useState((o==null?void 0:o.region)??u),me=(r==null?void 0:r.generatedAgentTestRun)===!0,oe=(r==null?void 0:r.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[Ne,Oe]=m.useState(()=>{const te=$h(i??el(c),c);return[{id:"baseline",name:"基准组",modelName:VL(te),description:te.description,instruction:te.instruction,optimizations:[],configOpen:!1,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]}),[Ve,We]=m.useState("baseline"),De=m.useRef(1),mt=m.useRef(!1),at=m.useRef(new Map),[Rt,qe]=m.useState(0),[W,K]=m.useState(""),[ae,pe]=m.useState(null),[z,ve]=m.useState(!1),[Be,Je]=m.useState(!1),kt=m.useRef(null),[Mt,Tt]=m.useState(""),[dt,ge]=m.useState(!1),[lt,Ge]=m.useState([]),vt=m.useRef(null),_t=m.useRef({});async function Bt(){const te=new Set([...at.current.values()].map(({run:ee})=>ee.runId)),Me=SQ().filter(ee=>!te.has(ee));Me.length&&await Promise.all(Me.map(async ee=>{try{await Tm(ee),mO(ee)}catch(_e){console.warn("清理遗留调试运行失败",_e)}}))}m.useEffect(()=>(Bt(),()=>{for(const{run:te}of at.current.values())Tm(te.runId).then(()=>mO(te.runId)).catch(Me=>console.warn("清理调试运行失败",Me));at.current.clear()}),[]),m.useEffect(()=>()=>{var te;(te=kt.current)==null||te.call(kt,!1),kt.current=null},[]);const je=m.useRef(null);je.current||(je.current=({meta:te,children:Me})=>l.jsxs("section",{ref:ee=>{_t.current[te.id]=ee},id:`cw-sec-${te.id}`,"data-step-id":te.id,className:"cw-section",children:[l.jsx("header",{className:"cw-sec-head",children:l.jsx("h2",{className:"cw-sec-title",children:te.label})}),l.jsx("div",{className:"cw-sec-body",children:Me})]}));const Ze=upt(b,lt)?lt:[],Ie=bS(b,Ze),Wt=Ze.length===0,dn=`cw-a2a-registry-advanced-${Ze.join("-")||"root"}`,Qt=te=>y(Me=>ov(Me,Ze,ee=>({...ee,...te}))),Yt=(te,Me)=>y(ee=>{var _e;return{...ee,deployment:{...ee.deployment??{feishuEnabled:!1},envValues:{...((_e=ee.deployment)==null?void 0:_e.envValues)??{},[te]:Me}}}}),Jt=te=>Qt({a2aRegistry:{...Ie.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...te}}),Ft=(te,Me)=>{if(!(te in LH))return;const ee=LH[te];Jt({[ee]:Me}),Yt(te,Me)},Ce=te=>{if(!(Wt&&te==="a2a")){if(te==="a2a"){Qt({agentType:te,a2aRegistry:{...Ie.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}Qt({agentType:te,a2aRegistry:Ie.a2aRegistry?{...Ie.a2aRegistry,enabled:!1}:void 0})}},et=(te,Me)=>{y(te),Me&&Ge(Me)},wt=async()=>{const te=S.trim();if(!(!te||T)&&!(te.length{const Me=bS(b,te);if(!FL(Me)||te.length>=$H)return;const ee=dpt(b,te,c),_e=bS(ee,te).subAgents.length-1;et(ee,[...te,_e])},on=(te,Me)=>{const ee=bS(b,te);if(!FL(ee)||te.length>=$H)return;const _e=Math.max(0,Math.min(Me,ee.subAgents.length)),tt=fpt(b,te,_e,c);et(tt,[...te,_e])},hi=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(y(el(c)),Ge([]),fe(!1))},Pe=te=>{if(te.length===0){hi();return}et(hpt(b,te),te.slice(0,-1))},st=Ie.builtinTools??[],At=m.useMemo(()=>Xne(c),[c]),Ut=m.useMemo(()=>new Set(At.map(te=>te.id)),[At]),kn=Ie.mcpTools??[],wn=Ie.selectedSkills??[],Ai=te=>{Ut.has(te)&&Qt({builtinTools:st.includes(te)?st.filter(Me=>Me!==te):[...st,te]})},Gn=ppe(Ie.agentType),xn=ZA(Ie.agentType),de=Ob(Ie,c),Le=te=>{var ee;const Me=te==="custom"&&de==="ark"?"":te==="ark"&&!((ee=Ie.modelName)!=null&&ee.trim())?t0(c):Ie.modelName;Qt({modelSource:te,modelName:Me})},ut=m.useMemo(()=>Uut(b),[b]),gt=xn?null:i1(Ie.name)??(ut.has(Ie.name)?"Agent 名称在当前结构中必须唯一":null),ln=gt!==null,Sn=!xn&&Ie.description.trim().length===0,In=Ie.instruction.trim().length===0,Ni=xn&&!((Ds=Ie.a2aRegistry)!=null&&Ds.registrySpaceId.trim()),Pn=te=>re&&te?`is-error cw-error-shake-${Ae%2}`:"",Vt=m.useMemo(()=>qpe(b,ut),[b,ut]),Ji=Vt.length===0,fn=m.useMemo(()=>$h(b,c),[c,b]),pi=m.useMemo(()=>ypt(fn,E),[fn,E]),ti=Ne.find(te=>te.id===Ve)??Ne[0],vi=m.useMemo(()=>Ype(fn),[fn]),en=m.useMemo(()=>Rpe(fn,Dl(c)),[c,fn]),Ci=en.find(te=>te.label===`${Ie.name.trim()||"自定义模型"} 模型 API Key`),xs=te=>{var Me;(Me=_t.current[te])==null||Me.scrollIntoView({behavior:"smooth",block:"start"})},ni=()=>Ji?!0:(fe(!0),J(te=>te+1),Vt[0]&&(Ge(Vt[0].path),window.requestAnimationFrame(()=>xs(Vt[0].problem==="缺少子 Agent"?"type":"basic"))),!1),Ls=async()=>{pe(null);const te=[...at.current.values()];at.current.clear(),qe(0),Oe(Me=>Me.map(ee=>({...ee,phase:"idle",runtimeSnapshot:"",messages:[],error:null}))),await Promise.all(te.map(async({run:Me})=>{try{await Tm(Me.runId),mO(Me.runId)}catch(ee){console.warn("清理调试运行失败",ee)}}))},er=async te=>{const Me=at.current.get(te);if(Me){at.current.delete(te),qe(at.current.size);try{await Tm(Me.run.runId),mO(Me.run.runId)}catch(ee){console.warn("清理调试运行失败",ee)}}},Ya=te=>{const Me=at.current.get(te),ee=Ne.find(_e=>_e.id===te);!Me||!ee||pe({runId:Me.run.runId,sessionId:Me.sessionId,variantName:ee.name})},mr=te=>{const Me=kt.current;kt.current=null,Me==null||Me(te)},gr=()=>{Be||(ve(!1),mr(!1))},ul=async()=>{if(!Be){Je(!0);try{await Ls(),ve(!1),mr(!0)}finally{Je(!1)}}},Sa=async()=>D!=="validate"||Rt===0?!0:kt.current?!1:new Promise(te=>{kt.current=te,ve(!0)}),as=async te=>{var ee;if(!await Sa())return;if(Tt(""),!ni()){H("build");return}const Me=fpe(vi.specs,((ee=fn.deployment)==null?void 0:ee.envValues)??{});if(Me){Tt(`${Me.spec.comment||Me.spec.key}:${Me.error}`),H("build");return}Se(!0);try{const _e=te?Ne.find(He=>He.id===te):ti;_e&&We(_e.id);const tt=_e?{...fn,modelName:_e.modelName||fn.modelName,description:_e.description,instruction:_e.instruction}:fn,Ct=await t$(Gpe(tt));tt!==b&&y(tt),ue(Ct),H("publish")}catch(_e){Tt(_e instanceof Error?_e.message:String(_e))}finally{Se(!1)}},Mn=async te=>{if(!me||ye||!ni())return;const Me=Ne.find(Dn=>Dn.id===te);if(!Me||Me.phase==="starting"||Me.phase==="sending")return;const ee=Me.modelName.trim(),_e=Me.description.trim(),tt=Me.instruction.trim(),Ct=dg(Me),He=Ne.findIndex(Dn=>Dn.id===te),ht=Ne.findIndex(Dn=>dg(Dn)===Ct);if(!ee||!_e||!tt||ht!==He)return;const Pt=DT(pi,Me);Oe(Dn=>Dn.map(Wr=>Wr.id===te?{...Wr,configOpen:!1,phase:"starting",messages:[],error:null}:Wr)),K("");let jt=null,bn="unknown";const Xi=te==="baseline"?"baseline":"comparison",Ss=$ut({agentId:String(fn.name||"unknown"),variantType:Xi});try{await er(te),await Bt();const Dn={...fn,modelName:Me.modelName||fn.modelName,description:Me.description,instruction:Me.instruction};bn="create_test_run",jt=await Oee(Wpe(Dn,E),o?{runtimeId:o.runtimeId,region:o.region}:void 0),Hht(jt.runId),bn="create_test_session";const Wr=await yee(jt.runId,"test_user");at.current.set(te,{run:jt,sessionId:Wr}),qe(at.current.size),Oe(sa=>sa.map(qi=>qi.id===te?{...qi,phase:"ready",runtimeSnapshot:Pt}:qi)),Ss.succeed({debugRunId:String(jt.runId)})}catch(Dn){if(jt)try{await Tm(jt.runId),mO(jt.runId)}catch(Wr){console.warn("清理调试运行失败",Wr)}Oe(Wr=>Wr.map(sa=>sa.id===te?{...sa,phase:"error",runtimeSnapshot:"",error:Dn instanceof Error?Dn.message:String(Dn)}:sa)),Ss.fail({failedPhase:bn,...Ra(Dn,{phase:bn})})}},vs=async()=>{const te=W.trim(),Me=Ne.filter(_e=>_e.phase==="ready"&&_e.runtimeSnapshot===DT(pi,_e)&&at.current.has(_e.id));if(!te||Me.length===0)return;K("");const ee=new Set(Me.map(_e=>_e.id));Oe(_e=>_e.map(tt=>ee.has(tt.id)?{...tt,phase:"sending",messages:[...tt.messages,{role:"user",content:te},{role:"assistant",content:"",blocks:[]}]}:tt)),await Promise.all(Me.map(async _e=>{const tt=at.current.get(_e.id);if(tt)try{let Ct=Pu();for await(const He of vee({runId:tt.run.runId,userId:"test_user",sessionId:tt.sessionId,text:te})){const ht=He.error||He.errorMessage||He.error_message;if(ht||(Ct=yk(Ct,He)),Oe(Pt=>Pt.map(jt=>{if(jt.id!==_e.id)return jt;const bn=[...jt.messages],Xi={...bn[bn.length-1]};return ht?Xi.error=String(ht):(Xi.content=Ct.blocks.filter(Ss=>Ss.kind==="text").map(Ss=>Ss.text).join(""),Xi.blocks=Ct.blocks),bn[bn.length-1]=Xi,{...jt,messages:bn}})),ht)break}}catch(Ct){Oe(He=>He.map(ht=>{if(ht.id!==_e.id)return ht;const Pt=[...ht.messages],jt={...Pt[Pt.length-1]};return jt.error=Ct instanceof Error?Ct.message:String(Ct),Pt[Pt.length-1]=jt,{...ht,messages:Pt}}))}finally{Oe(Ct=>Ct.map(He=>He.id===_e.id?{...He,phase:"ready"}:He))}}))},Zl=()=>{Oe(te=>{if(te.length>=3)return te;const Me=De.current++,ee=`variant-${Me}`;return[...te,{id:ee,name:`对照组 ${Me}`,modelName:b.modelName??"",description:b.description,instruction:b.instruction,optimizations:[],configOpen:!0,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]})},Gr=async te=>{await er(te),Oe(Me=>Me.filter(ee=>ee.id!==te)),Ve===te&&We("baseline")},tr=(te,Me)=>Oe(ee=>ee.map(_e=>_e.id===te?{..._e,...Me}:_e)),No=(te,Me,ee)=>{te==="baseline"&&Me==="modelName"&&(mt.current=!0),tr(te,{[Me]:ee}),!(Ve!==te||te==="baseline")&&We("baseline")},Dr=te=>{const Me=Ne.find(Pt=>Pt.id===te);if(!Me)return;const ee=Me.modelName.trim(),_e=Me.description.trim(),tt=Me.instruction.trim(),Ct=dg(Me),He=Ne.findIndex(Pt=>Pt.id===te),ht=Ne.findIndex(Pt=>dg(Pt)===Ct);if(!(!ee||!_e||!tt||ht!==He)){if(te==="baseline"){tr(te,{configOpen:!1});return}Mn(te)}},os=async(te,Me,ee)=>{var Ct;const _e=(Ct=b.deployment)==null?void 0:Ct.network,tt=_e&&_e.mode&&_e.mode!=="public"?{mode:_e.mode,vpc_id:_e.vpcId,subnet_ids:_e.subnetIds,enable_shared_internet_access:_e.enableSharedInternetAccess}:void 0;return w1(te.name,te.files,{region:(o==null?void 0:o.region)??Re,projectName:"default",network:tt},{...ee,onStage:Me,runtimeId:o==null?void 0:o.runtimeId,runtimeName:w,appName:o==null?void 0:o.appName,description:b.description})},na=()=>{ni()&&(Oe(te=>te.map(Me=>Me.id==="baseline"&&!at.current.has(Me.id)?{...Me,modelName:mt.current?Me.modelName:VL(fn),description:fn.description,instruction:fn.instruction}:Me)),H("validate"))},Co=async te=>{if(te==="publish"){if(!ni())return;ie?H("publish"):as();return}if(te==="validate"){na();return}await Sa()&&H(te)},br=je.current,ia=te=>Ght.find(Me=>Me.id===te),ji=l.jsx("section",{className:`cw-ai-compose${T?" is-generating":""}${N?" is-success":""}`,"aria-label":"AI 自动填写 Agent 配置",children:l.jsx(xf,{initial:!1,mode:"wait",children:N?l.jsxs(wr.div,{className:"cw-ai-compose-success",role:"status",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.22,ease:[.22,1,.36,1]},children:[l.jsx("span",{className:"cw-ai-success-check","aria-hidden":!0}),l.jsx("strong",{children:"生成成功"}),l.jsx("button",{type:"button",className:"cw-ai-regenerate",onClick:()=>C(!1),children:"重新生成"})]},"success"):l.jsxs(wr.div,{className:"cw-ai-compose-entry",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.2,ease:[.22,1,.36,1]},children:[l.jsxs("form",{className:"cw-ai-compose-form",onSubmit:te=>{te.preventDefault(),wt()},children:[l.jsx("input",{type:"text",value:S,maxLength:8e3,disabled:T,placeholder:`描述目标,使用 ${nEe(c)} 模型一键生成配置`,"aria-invalid":!!$,"aria-describedby":$?"ai-requirement-error":void 0,onChange:te=>k(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),wt())}}),l.jsx("button",{type:"submit",disabled:T||!j||!!$,"aria-label":T?"正在智能生成":"智能生成",children:T?l.jsx("span",{className:"cw-ai-orb","aria-hidden":!0,children:l.jsx("span",{})}):"智能生成"})]}),$&&l.jsx("p",{className:"cw-ai-requirement-error",id:"ai-requirement-error",role:"alert",children:$})]},"compose")})});return l.jsxs("div",{className:`cw-root is-${D}`,children:[l.jsx(vpt,{mode:D}),Mt&&l.jsx(LT,{className:"cw-workspace-alert",message:Mt}),l.jsxs("main",{className:"cw-workspace-main",id:"cw-workspace-main",children:[D==="build"&&l.jsx("div",{className:"cw-build-workspace",children:l.jsxs("div",{className:"cw-editor",children:[l.jsx(px,{draft:b,direction:"horizontal",selectedPath:Ze,onSelect:Ge,onAdd:yn,onInsert:on,onDelete:Pe}),l.jsx("div",{className:"cw-detail",children:l.jsx("div",{className:"cw-detail-scroll",ref:vt,children:l.jsx("div",{className:"cw-detail-inner",children:l.jsx("div",{className:"cw-lower",children:l.jsxs("div",{className:"cw-form-col",children:[l.jsxs(br,{meta:ia("type"),children:[l.jsx(UO,{className:"cw-agent-type-options","aria-label":"Agent 类型",value:Ie.agentType??"llm",onChange:Ce,children:Nft.map(te=>{const Me=(Ie.agentType??"llm")===te.id,ee=Wt&&te.id==="a2a",_e=ee?"cw-remote-agent-disabled-hint":void 0;return l.jsxs("div",{"data-agent-type":te.id,className:`cw-agent-type-option ${Me?"is-on":""} ${ee?"is-disabled":""}`,tabIndex:ee?0:void 0,"aria-describedby":_e,children:[l.jsx(UO.Item,{value:te.id,disabled:ee,block:!0,className:"cw-agent-type-control",children:l.jsx("span",{className:"cw-agent-type-copy",children:l.jsx("strong",{children:Zht[te.id]})})}),ee&&l.jsx("span",{id:_e,className:"cw-agent-type-disabled-hint",role:"tooltip",children:"远程智能体只能作为子步骤使用"})]},te.id)})}),re&&Gn&&Ie.subAgents.length===0&&l.jsx("span",{className:"cw-error-text",children:mpt({name:Ie.name.trim()||"未命名",typeLabel:hpe(Ie.agentType).label})})]}),l.jsx(br,{meta:ia("basic"),children:l.jsxs("div",{className:"cw-form",children:[!xn&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:[Wt?"Agent 名称":"名称",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("input",{className:`cw-input ${Pn(ln)}`,value:Ie.name,placeholder:"assistant",onChange:te=>Qt({name:te.target.value})}),re&>?l.jsx("span",{className:"cw-error-text",children:gt}):l.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在执行流程中保持唯一。"})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:[Wt?"描述":"智能体描述",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${Pn(Sn)}`,value:Ie.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…",onChange:te=>Qt({description:te.target.value})}),re&&Sn?l.jsx("span",{className:"cw-error-text",children:"描述为必填项"}):l.jsx("span",{className:"cw-help",children:Wt?"完整描述会保留;部署时会自动整理为符合 Runtime 规范的单行描述。":"描述会显示在 Agent 列表与选择器中。"})]})]}),Gn?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"cw-section-desc cw-dependency-hint",children:"这是一个协作容器,本身不生成回答。请在左侧画布中 添加任务步骤,并通过拖拽调整它们的位置。"}),Ie.agentType==="loop"&&l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"最大轮次"}),l.jsx("input",{className:"cw-input",type:"number",min:1,value:Ie.maxIterations??3,onChange:te=>Qt({maxIterations:Math.max(1,Number(te.target.value)||1)})}),l.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):xn?l.jsxs("div",{className:"cw-field cw-remote-center-fields",children:[l.jsxs("div",{className:"cw-remote-center-head",children:[l.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),l.jsx(spt,{value:((Ea=Ie.a2aRegistry)==null?void 0:Ea.registrySpaceId)??"",region:((nu=Ie.a2aRegistry)==null?void 0:nu.registryRegion)||Pl.region,invalid:re&&Ni,onChange:te=>Ft(Fpe,te)}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":dt,"aria-controls":dn,onClick:()=>ge(te=>!te),children:[l.jsx("span",{children:"更多选项"}),l.jsx(U0,{className:`cw-more-options-chevron ${dt?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(xf,{initial:!1,children:dt&&l.jsx(wr.div,{id:dn,className:"cw-model-advanced",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeOut"},children:l.jsx(gO,{env:Kht,values:Vpe(Ie.a2aRegistry,{includeDefaults:!1}),onChange:Ft})})}),re&&Ni&&l.jsx("span",{className:"cw-error-text",children:"请选择 AgentKit 智能体中心"})]}):l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["系统提示词",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx(m.Suspense,{fallback:l.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:l.jsx(qht,{value:Ie.instruction,invalid:In,onChange:te=>Qt({instruction:te})})}),re&&In?l.jsx("span",{className:"cw-error-text",children:"系统提示词为必填项"}):l.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!Gn&&!xn&&l.jsxs(l.Fragment,{children:[l.jsx(br,{meta:ia("model"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field cw-model-source-field",children:[l.jsx("label",{className:"cw-label",children:"模型来源"}),l.jsx(UO,{className:"cw-model-source-options","aria-label":"模型来源",value:de,onChange:te=>{te!=="gateway"&&Le(te)},children:[{value:"ark",label:c==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",disabled:!0}].map(te=>l.jsx("div",{className:`cw-model-source-option ${de===te.value?"is-on":""}${te.disabled?" is-disabled":""}`,children:l.jsxs(UO.Item,{value:te.value,disabled:te.disabled,block:!0,className:"cw-model-source-control",children:[l.jsx("span",{children:te.label}),te.disabled&&l.jsx("span",{className:"cw-model-source-coming-soon",children:"待上线"})]})},te.value))})]}),de==="ark"?l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型配置"}),l.jsx(rpt,{value:Ie.modelName??"",cloudProvider:c,apiKeyId:($s=b.deployment)==null?void 0:$s.modelApiKeyId,apiKeyName:(Jl=b.deployment)==null?void 0:Jl.modelApiKeyName,onApiKeyChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},modelApiKeyId:te.id,modelApiKeyName:te.name}})),onChange:te=>Qt({modelName:te})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型名称"}),l.jsx("input",{className:"cw-input",value:Ie.modelName??"",onChange:te=>Qt({modelName:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label cw-label-with-link",children:[l.jsx("span",{children:"服务商 Provider"}),l.jsxs("a",{href:"https://docs.litellm.ai/docs/providers",target:"_blank",rel:"noopener noreferrer",onClick:te=>te.stopPropagation(),children:["LiteLLM 支持列表",l.jsx(e0,{"aria-hidden":"true"})]})]}),l.jsx("input",{className:"cw-input",value:Ie.modelProvider??"",placeholder:"openai",onChange:te=>Qt({modelProvider:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Base"}),l.jsx("input",{className:"cw-input",value:Ie.modelApiBase??"",placeholder:Dl(c),onChange:te=>Qt({modelApiBase:te.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Key"}),l.jsx("input",{className:"cw-input",type:"password",value:Ci?O[Ci.key]??"":"",placeholder:"请输入模型 API Key",autoComplete:"new-password",onChange:te=>{if(!Ci)return;const Me=te.currentTarget.value;v(ee=>({...ee,[Ci.key]:Me}))}})]})]})]})}),l.jsx(br,{meta:ia("tools"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"内置工具"}),l.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),l.jsx("div",{className:"cw-tools-list-shell",children:l.jsx(Jht,{items:At,selected:st,onToggle:Ai,scrollRows:6})}),l.jsx(xf,{initial:!1,children:st.includes("run_code")&&l.jsxs(wr.div,{className:"cw-tool-config",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-tool-config-head",children:[l.jsx("span",{className:"cw-label",children:"代码执行配置"}),l.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),l.jsx(gO,{env:((ec=Qp.find(te=>te.id==="run_code"))==null?void 0:ec.env)??[],values:((le=b.deployment)==null?void 0:le.envValues)??{},onChange:Yt})]})})]}),l.jsxs("div",{className:"cw-field cw-mcp-field",children:[l.jsx("label",{className:"cw-label",children:"MCP 工具"}),l.jsx(opt,{tools:kn,onChange:te=>Qt({mcpTools:te})})]})]})}),l.jsx(br,{meta:ia("skills"),children:l.jsx("div",{className:"cw-form",children:l.jsx(cpt,{selected:wn,onChange:te=>Qt({selectedSkills:te}),cloudProvider:c})})}),l.jsx(br,{meta:ia("knowledge"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(gS,{checked:Ie.knowledgebase,onChange:te=>Qt({knowledgebase:te}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:$S}),Ie.knowledgebase&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"知识库后端"}),l.jsx(OR,{options:PP,value:Ie.knowledgebaseBackend,onChange:te=>Qt({knowledgebaseBackend:te,knowledgebaseIndex:te==="viking"||te==="openviking"?Ie.knowledgebaseIndex:""})}),(Ie.knowledgebaseBackend??wf)==="viking"&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),l.jsx(apt,{value:Ie.knowledgebaseIndex??"",onChange:te=>{Qt({knowledgebaseIndex:te.id}),te.projectName&&Yt("DATABASE_VIKING_PROJECT",te.projectName),te.region&&Yt("DATABASE_VIKING_REGION",te.region),te.sourceKind&&Yt("DATABASE_VIKING_COLLECTION_KIND",te.sourceKind),Yt("DATABASE_VIKING_RESOURCE_ID",te.resourceId??"")}})]}),l.jsx(gO,{env:((gn=PP.find(te=>te.id===(Ie.knowledgebaseBackend??wf)))==null?void 0:gn.env)??[],values:((Wn=b.deployment)==null?void 0:Wn.envValues)??{},onChange:Yt,renderAfterField:(Ie.knowledgebaseBackend??wf)==="openviking"?te=>te.key==="DATABASE_OPENVIKING_USER_ID"?l.jsx(tpt,{value:Ie.knowledgebaseIndex??"",onChange:Me=>Qt({knowledgebaseIndex:Me})}):null:void 0})]})]})}),Wt&&l.jsx(br,{meta:ia("memory"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(gS,{checked:Ie.memory.shortTerm,onChange:te=>Qt({memory:{...Ie.memory,shortTerm:te}}),title:"短期记忆",desc:"存储单会话上下文",showDescription:!0,icon:pJ}),Ie.memory.shortTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"短期记忆后端"}),l.jsx(OR,{options:RP,value:Ie.shortTermBackend,onChange:te=>Qt({shortTermBackend:te})}),l.jsx(gO,{env:((Vi=RP.find(te=>te.id===(Ie.shortTermBackend??"local")))==null?void 0:Vi.env)??[],values:((Ln=b.deployment)==null?void 0:Ln.envValues)??{},onChange:Yt})]}),l.jsx(gS,{checked:Ie.memory.longTerm,onChange:te=>Qt({memory:{...Ie.memory,longTerm:te}}),title:"长期记忆",desc:"存储跨会话上下文,通常使用向量化检索",showDescription:!0,icon:$S}),Ie.memory.longTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"长期记忆后端"}),l.jsx(OR,{options:IP,value:Ie.longTermBackend,onChange:te=>Qt({longTermBackend:te})}),l.jsx(gO,{env:((Tn=IP.find(te=>te.id===(Ie.longTermBackend??"local")))==null?void 0:Tn.env)??[],values:((ra=b.deployment)==null?void 0:ra.envValues)??{},onChange:Yt}),l.jsx(gS,{checked:!!Ie.autoSaveSession,onChange:te=>Qt({autoSaveSession:te}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:$S})]})]})})]})]})})})})})]})}),D==="validate"&&l.jsx("div",{className:"cw-validation-workspace",children:l.jsx("div",{className:"cw-validation-content",children:l.jsx(xpt,{enabled:me,disabledReason:oe,variants:Ne,draftSnapshot:pi,input:W,onInput:K,onSend:vs,onStartVariant:Mn,onDeployVariant:te=>void as(te),onAddVariant:Zl,onRemoveVariant:Gr,onToggleConfig:te=>{const Me=Ne.find(ee=>ee.id===te);Me&&tr(te,{configOpen:!Me.configOpen})},onCompleteConfig:Dr,onConfigChange:No,onOpenTrace:Ya})})}),D==="publish"&&l.jsx("div",{className:"cw-preview-body",children:ie?l.jsx(wQ,{embedded:!0,cloudProvider:c,project:ie,agentDraft:b,agentName:b.name||"未命名 Agent",agentCount:Hpe(b),releaseConfiguration:ti?{modelName:ti.modelName||b.modelName||"默认模型",description:ti.description,instruction:ti.instruction,optimizations:ti.optimizations.flatMap(te=>{const Me=Zpe.find(ee=>ee.id===te);return Me?[Me.label]:[]})}:void 0,onChange:ue,onDeploy:os,onAgentAdded:n,onDeploymentTaskChange:s,deploymentActionLabel:o?"更新并发布":"部署",deploymentActionTargetId:"cw-publish-primary-action",deploymentRuntimeId:o==null?void 0:o.runtimeId,deploymentRuntimeName:w,deploymentRuntimeNameCustomized:!!o||!!((Qs=b.deployment)!=null&&Qs.runtimeNameCustomized),onDeploymentRuntimeNameChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},runtimeName:te,runtimeNameCustomized:!0}})),onDeploymentStarted:f,onDeploymentComplete:d,feishuEnabled:!!((dr=b.deployment)!=null&&dr.feishuEnabled),onFeishuEnabledChange:te=>{const Me={...b,deployment:{...b.deployment??{feishuEnabled:!1},feishuEnabled:te}};y(Me)},deploymentEnv:vi.specs,requiredSecretEnv:en,requiredSecretEnvValues:O,onRequiredSecretEnvChange:(te,Me)=>v(ee=>({...ee,[te]:Me})),deploymentEnvValues:{...(ws=fn.deployment)==null?void 0:ws.envValues,...O,...vi.fixedValues},onDeploymentEnvChange:Yt,network:(ls=b.deployment)==null?void 0:ls.network,onNetworkChange:te=>y(Me=>({...Me,deployment:{...Me.deployment??{feishuEnabled:!1},network:te}})),deployRegion:Re,onDeployRegionChange:Ee,deploymentTelemetry:{source:"scratch",createMode:a,aiAssisted:M},onExportYaml:()=>Yht(`${fn.name||"agent"}.yaml`,$ft(fn),"text/yaml")}):l.jsxs("div",{className:"cw-publish-loading",role:"status",children:[l.jsx(Kn,{className:"cw-i cw-spin"}),l.jsx("strong",{children:"正在生成发布配置"}),l.jsx("span",{children:"校验 Agent 结构并准备部署快照…"})]})})]}),l.jsx(wpt,{mode:D,busy:ye,onChange:Co,assistant:D==="build"?ji:void 0}),ae&&l.jsx(Upe,{testRunId:ae.runId,sessionId:ae.sessionId,title:`调用链路 · ${ae.variantName}`,onClose:()=>pe(null)}),z&&l.jsx(Mf,{variant:"warning",title:"离开调试?",description:"离开调试页面后,当前环境将被清理。您可以通过重新启动环境进行新的测试。",confirmLabel:Be?"清理中...":"确定离开",closeLabel:"关闭离开调试确认",busy:Be,onCancel:gr,onConfirm:()=>void ul()}),P&&l.jsx("div",{className:"confirm-scrim",onClick:()=>Q(null),children:l.jsxs("div",{className:"confirm-box cw-ai-error-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"ai-generate-error-title","aria-describedby":"ai-generate-error-message",onClick:te=>te.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",id:"ai-generate-error-title",children:"智能生成失败"}),l.jsx("div",{className:"cw-ai-error-message",id:"ai-generate-error-message",children:P}),l.jsx("div",{className:"confirm-actions",children:l.jsx("button",{type:"button",className:"confirm-btn cw-ai-error-close",onClick:()=>Q(null),children:"关闭"})})]})})]})}const QH=50*1024*1024,XL=800,Ept={name:"code_package",files:[]};function kpt(e){let n=e.replace(/\.zip$/i,"").trim().replace(/[^A-Za-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return n||(n="uploaded_agent"),/^[A-Za-z_]/.test(n)||(n=`agent_${n}`),n==="user"&&(n="uploaded_agent"),n.slice(0,64)}function Kpe(e){const t=e.replace(/\\/g,"/").replace(/^\.\//,"");if(!t||t.endsWith("/"))return null;if(t.startsWith("/")||t.includes("\0"))throw new Error(`压缩包包含非法路径:${e}`);const n=t.split("/");if(n.some(i=>!i||i==="."||i===".."))throw new Error(`压缩包包含非法路径:${e}`);return n[0]==="__MACOSX"||n[n.length-1]===".DS_Store"?null:n.join("/")}function Tpt(e){const t=e.flatMap(a=>{const o=Kpe(a.name);return o?[{path:o,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>XL)throw new Error(`代码包文件数不能超过 ${XL} 个。`);const r=new Set(t.map(a=>a.path.split("/")[0])).size===1&&t.every(a=>a.path.includes("/"))?t.map(a=>({...a,path:a.path.split("/").slice(1).join("/")})):t,s=new Set;for(const a of r){if(s.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);s.add(a.path)}return _pt(r),r}function _pt(e){const t=new Set(e.map(r=>r.path)),n=e.find(r=>r.path==="agentkit.yaml");let i="app.py";if(n){let r;try{r=sGe(n.content)}catch(o){throw new Error(`agentkit.yaml 无法解析:${o instanceof Error?o.message:String(o)}`)}if(r!==null&&(typeof r!="object"||Array.isArray(r)))throw new Error("agentkit.yaml 根节点必须是对象。");const s=r&&typeof r=="object"&&!Array.isArray(r)?r.common:void 0;if(s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s)))throw new Error("agentkit.yaml 的 common 必须是对象。");const a=s&&typeof s=="object"&&!Array.isArray(s)?s.entry_point:void 0;if(a!==void 0){if(typeof a!="string")throw new Error("agentkit.yaml 的 common.entry_point 必须是文件路径。");const o=Kpe(a);if(!o)throw new Error("agentkit.yaml 的 common.entry_point 不是有效文件路径。");i=o}}if(!t.has(i))throw n&&i!=="app.py"?new Error(`代码包中不存在 agentkit.yaml 声明的启动入口:${i}`):new Error("代码包根目录必须包含 app.py,或在 agentkit.yaml 的 common.entry_point 中声明已有入口。");return i}function Apt({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:i,onDeploymentComplete:r,cloudProvider:s="volcengine",initialDeployRegion:a=Qi(s)}){const o=m.useRef(null),c=m.useRef(0),[u,d]=m.useState(null),[f,h]=m.useState(""),[p,g]=m.useState(!1),[b,y]=m.useState(!1),[O,v]=m.useState(!1),[x,w]=m.useState(""),[E,S]=m.useState(a),[k,T]=m.useState();m.useEffect(()=>()=>{c.current+=1},[]);async function A(L){const P=++c.current;if(w(""),!L.name.toLowerCase().endsWith(".zip")){w("请选择 .zip 格式的代码包。");return}if(L.size>QH){w("代码包不能超过 50 MB。");return}y(!0);try{const Q=await Lpe(new Uint8Array(await L.arrayBuffer()),{maxEntries:XL,maxUncompressedBytes:QH}),j=Tpt(Q);if(P!==c.current)return;h(L.name),d({name:kpt(L.name),files:j})}catch(Q){if(P!==c.current)return;h(""),d(null),w(Q instanceof Error?Q.message:String(Q))}finally{P===c.current&&y(!1)}}function N(L){var Q;const P=(Q=L.currentTarget.files)==null?void 0:Q[0];L.currentTarget.value="",P&&A(P)}function C(L){var Q;L.preventDefault(),v(!1);const P=(Q=L.dataTransfer.files)==null?void 0:Q[0];P&&A(P)}async function M(L,P,Q){const j=k&&k.mode!=="public"?{mode:k.mode,vpc_id:k.vpcId,subnet_ids:k.subnetIds,enable_shared_internet_access:k.enableSharedInternetAccess}:void 0;return w1(L.name,L.files,{region:E,projectName:"default",network:j},{...Q,onStage:P})}return l.jsxs("div",{className:"package-create package-create-preview",children:[l.jsx(wQ,{cloudProvider:s,project:u??Ept,agentName:(u==null?void 0:u.name)||"代码包",onChange:u?d:void 0,onDeploy:M,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:i,onDeploymentComplete:r,network:k,onNetworkChange:T,deployRegion:E,onDeployRegionChange:S,deploymentTelemetry:{source:"code_package",createMode:"code_package",aiAssisted:!1},onBack:e,backLabel:"返回创建方式",deployDisabled:!u||b,deployDisabledReason:b?"正在读取代码包":u?void 0:"请先上传代码包",deploymentPrimaryPane:l.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[l.jsx("div",{className:"package-source-label",children:"代码包"}),l.jsxs("div",{className:`package-dropzone${O?" is-dragging":""}${u?" is-ready":""}`,onDragEnter:L=>{L.preventDefault(),v(!0)},onDragOver:L=>L.preventDefault(),onDragLeave:L=>{L.currentTarget.contains(L.relatedTarget)||v(!1)},onDrop:C,onClick:()=>{var L;b||(L=o.current)==null||L.click()},onKeyDown:L=>{var P;!b&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),(P=o.current)==null||P.click())},role:"button",tabIndex:b?-1:0,"aria-label":u?"重新上传代码包":"上传代码包","aria-disabled":b,children:[l.jsx("strong",{children:b?"正在读取代码包…":u?f:"请上传代码包"}),l.jsx("span",{children:u?`已识别 ${u.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB;可使用 app.py,或由 agentkit.yaml 声明入口"}),l.jsx("div",{className:"package-upload-actions",children:u&&l.jsx("button",{type:"button",className:"package-upload-secondary",onClick:L=>{L.stopPropagation(),g(!0)},onKeyDown:L=>L.stopPropagation(),children:"查看文件"})}),l.jsx("input",{ref:o,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:N})]}),x&&l.jsx("div",{className:"package-create-error",role:"alert",children:x})]})}),u&&l.jsx(Bpe,{project:u,open:p,onClose:()=>g(!1),onChange:d})]})}const Npt="/web/agent-migrations",eN=39e4;class Ia extends Error{constructor(t,n,i="MIGRATION_ERROR",r=!1,s="",a=""){super(t),this.status=n,this.code=i,this.retryable=r,this.statusText=s,this.rawResponse=a,this.name="MigrationApiError"}}const Cpt=new Set(["langchain","langgraph","adk","strands","agentcore","dify","any"]),jpt=new Set(["awaiting_upload","analyzing","needs_input","analysis_ready","migrating","validating","packaging","succeeded","succeeded_with_warnings","partial","failed","cancelled","expired"]),Rpt=new Set(["reasoning","message","plan","command","status"]),Ipt=new Set(["running","completed","failed"]);function yi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function Yh(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw new Error(`${t}格式错误。`);return e}function Iy(e,t){if(typeof e!="string"||!Cpt.has(e))throw new Error(`${t}格式错误。`);return e}function Ppt(e){const t=yi(e,"迁移分析结果"),n=t.recommended===null?null:yi(t.recommended,"迁移建议"),i=yi(t.boundary,"迁移边界");if(t.schema_version!==1||!["needs_input","recommendation_ready","unsupported"].includes(String(t.status))||typeof t.attempt!="number"||typeof t.input_sha256!="string"||typeof t.summary!="string"||!Array.isArray(t.frameworks)||!Array.isArray(t.entries)||!Array.isArray(t.questions))throw new Error("迁移分析结果格式错误。");return{schema_version:1,status:t.status,attempt:t.attempt,input_sha256:t.input_sha256,summary:t.summary,frameworks:t.frameworks.map(r=>{const s=yi(r,"框架候选");if(!["high","medium","low"].includes(String(s.confidence))||!Array.isArray(s.evidence))throw new Error("框架候选格式错误。");return{id:Iy(s.id,"框架候选"),confidence:s.confidence,evidence:s.evidence.map(a=>{const o=yi(a,"分析证据");if(typeof o.path!="string"||typeof o.line!="number"||typeof o.reason!="string")throw new Error("分析证据格式错误。");return{path:o.path,line:o.line,reason:o.reason}})}}),recommended:n===null?null:{framework:Iy(n.framework,"推荐框架"),entry:n.entry===null||typeof n.entry=="string"?n.entry:null,reason:typeof n.reason=="string"?n.reason:""},entries:t.entries.map(r=>{const s=yi(r,"入口候选");if(typeof s.value!="string"||typeof s.evidence!="string")throw new Error("入口候选格式错误。");return{value:s.value,framework:Iy(s.framework,"入口框架"),evidence:s.evidence}}),boundary:{include:Yh(i.include,"迁移包含范围"),exclude:Yh(i.exclude,"迁移排除范围")},assumptions:Yh(t.assumptions,"分析假设"),questions:t.questions.map(r=>{const s=yi(r,"待确认问题");if(typeof s.id!="string"||typeof s.prompt!="string"||typeof s.required!="boolean")throw new Error("待确认问题格式错误。");return{id:s.id,prompt:s.prompt,required:s.required}}),warnings:Yh(t.warnings,"迁移警告")}}function Hp(e){const t=yi(e,"迁移会话"),n=yi(t.artifact,"迁移产物状态");if(typeof t.id!="string"||typeof t.state!="string"||!jpt.has(t.state)||typeof t.message!="string"||typeof t.sourceFileName!="string"||typeof t.instruction!="string"||typeof t.createdAt!="string"&&typeof t.createdAt!="number"||typeof t.expiresAt!="string"||typeof t.sessionTtlSeconds!="number"||typeof t.canModify!="boolean"||typeof t.canUpload!="boolean"||typeof t.canAnswer!="boolean"||typeof t.canConfirm!="boolean"||typeof t.canStop!="boolean")throw new Error("迁移会话格式错误。");const i={id:t.id,state:t.state,message:t.message,sourceFileName:t.sourceFileName,instruction:t.instruction,createdAt:t.createdAt,expiresAt:t.expiresAt,sessionTtlSeconds:t.sessionTtlSeconds,canModify:t.canModify,canUpload:t.canUpload,canAnswer:t.canAnswer,canConfirm:t.canConfirm,canStop:t.canStop,artifact:{state:typeof n.state=="string"?n.state:"none",previewReady:n.previewReady===!0,downloadReady:n.downloadReady===!0,deployReady:n.deployReady===!0}};if(t.analysis!==void 0&&(i.analysis=Ppt(t.analysis)),t.analysisRef!==void 0){const r=yi(t.analysisRef,"分析结果引用");if(typeof r.attempt!="number"||typeof r.sha256!="string"||typeof r.inputSha256!="string")throw new Error("分析结果引用格式错误。");i.analysisRef={attempt:r.attempt,sha256:r.sha256,inputSha256:r.inputSha256}}if(t.confirmation!==void 0){const r=yi(t.confirmation,"迁移确认");i.confirmation={...r.framework!==void 0?{framework:Iy(r.framework,"确认框架")}:{},...r.entry===null||typeof r.entry=="string"?{entry:r.entry}:{},...typeof r.app_name=="string"?{app_name:r.app_name}:{}}}if(t.error!==void 0){const r=yi(t.error,"迁移错误");i.error={code:typeof r.code=="string"?r.code:"MIGRATION_ERROR",message:typeof r.message=="string"?r.message:t.message,retryable:r.retryable===!0}}return i}function Mpt(e){const t=yi(e,"迁移执行动态");if(typeof t.available!="boolean"||typeof t.complete!="boolean"||!Array.isArray(t.items))throw new Error("迁移执行动态格式错误。");return{available:t.available,complete:t.complete,items:t.items.map(n=>{const i=yi(n,"迁移执行动态项");if(typeof i.id!="string"||typeof i.kind!="string"||!Rpt.has(i.kind)||typeof i.status!="string"||!Ipt.has(i.status)||typeof i.title!="string"||i.detail!==void 0&&typeof i.detail!="string")throw new Error("迁移执行动态项格式错误。");return{id:i.id,kind:i.kind,status:i.status,title:i.title,...typeof i.detail=="string"?{detail:i.detail}:{}}})}}function Lpt(e){const t=yi(e,"迁移产物"),n=yi(t.cli,"CLI 信息"),i=yi(t.migration,"迁移信息"),r=yi(t.startup,"启动信息"),s=yi(t.environment,"环境变量信息"),a=yi(t.verification,"校验信息"),o=yi(t.report,"迁移报告"),c=yi(t.artifact,"产物归档"),u=s.defaults===void 0?{}:yi(s.defaults,"环境变量默认值");if(t.schema_version!==1||!["succeeded","succeeded_with_warnings","partial"].includes(String(t.status))||typeof n.name!="string"||typeof n.version!="string"||!["structured","agentic"].includes(String(i.engine))||typeof i.framework!="string"||!Array.isArray(t.files)||typeof r.module!="string"||typeof r.object!="string"||!["passed","failed","degraded"].includes(String(a.status))||!Array.isArray(a.checks)||typeof o.path!="string"||c.path!=="migration-result.zip"||typeof c.size!="number"||typeof c.sha256!="string"||typeof t.created_at!="string")throw new Error("迁移产物格式错误。");const d=Yh(s.required,"必需环境变量"),f=Yh(s.optional,"可选环境变量"),h=new Set([...d,...f]),p=Object.fromEntries(Object.entries(u).map(([g,b])=>{if(!h.has(g)||typeof b!="string")throw new Error("环境变量默认值格式错误。");return[g,b]}));return{schema_version:1,...typeof t.run_id=="string"?{run_id:t.run_id}:{},cli:{name:n.name,version:n.version},migration:{engine:i.engine,framework:i.framework,...typeof i.entry=="string"?{entry:i.entry}:{},...typeof i.source_sha256=="string"?{source_sha256:i.source_sha256}:{},...typeof i.provenance_sha256=="string"?{provenance_sha256:i.provenance_sha256}:{}},status:t.status,files:t.files.map(g=>{const b=yi(g,"迁移产物文件");if(typeof b.path!="string"||typeof b.size!="number"||typeof b.sha256!="string"||typeof b.mode!="string")throw new Error("迁移产物文件格式错误。");return{path:b.path,size:b.size,sha256:b.sha256,mode:b.mode}}),startup:{module:r.module,object:r.object,...Array.isArray(r.command)&&r.command.every(g=>typeof g=="string")?{command:r.command}:{}},environment:{required:d,optional:f,defaults:p},verification:{status:a.status,checks:a.checks.map(g=>{const b=yi(g,"迁移校验项");if(typeof b.name!="string"||!["passed","failed"].includes(String(b.status)))throw new Error("迁移校验项格式错误。");return{name:b.name,status:b.status,...typeof b.detail=="string"?{detail:b.detail}:{}}})},warnings:Yh(t.warnings,"迁移产物警告"),report:{path:o.path},artifact:{path:"migration-result.zip",size:c.size,sha256:c.sha256},created_at:t.created_at}}async function cl(e,t={},n=_o){return fetch(vo(`${Npt}${e}`),{...t,headers:Dp(t.headers),signal:Ao(t.signal,n)})}function Dpt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const n=t,i=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").join("."):"",r=typeof n.msg=="string"?n.msg:"";return r?i?`${i}: ${r}`:r:""}).filter(Boolean).join(";"):""}async function TQ(e,t){var i;const n=await e.text().catch(()=>"");try{const r=yi(JSON.parse(n),"错误响应");if(Array.isArray(r.detail)){const a=Dpt(r.detail);return new Ia(a?`请求参数校验失败:${a}`:t,e.status,"MIGRATION_REQUEST_INVALID",!1,e.statusText,n)}if(typeof r.detail=="string")return new Ia(r.detail,e.status,typeof r.code=="string"?r.code:"MIGRATION_ERROR",r.retryable===!0,e.statusText,n);const s=r.detail&&typeof r.detail=="object"?yi(r.detail,"错误详情"):r;return new Ia(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"MIGRATION_ERROR",s.retryable===!0,e.statusText,n)}catch{const r=((i=e.headers.get("content-type"))==null?void 0:i.split(";",1)[0])||"Content-Type 缺失";return new Ia(`${t}(HTTP ${e.status},Content-Type: ${r})。请检查代理或网关配置。`,e.status,"MIGRATION_ERROR",!1,e.statusText,n)}}async function tu(e,t){if(!e.ok)throw await TQ(e,t);if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Ia(`${t}:服务端返回非 JSON 响应(HTTP ${e.status})。请检查代理或网关配置。`,e.status,"MIGRATION_RESPONSE_INVALID",!1,e.statusText);return e.json()}async function $pt(e){const t=yi(await tu(await cl("/capabilities",{signal:e}),"读取迁移能力失败"),"迁移能力");if(typeof t.enabled!="boolean"||typeof t.reason!="string"||typeof t.maxUploadBytes!="number"||typeof t.sessionTtlSeconds!="number"||!Array.isArray(t.frameworks))throw new Error("迁移能力格式错误。");return{enabled:t.enabled,reason:t.reason,maxUploadBytes:t.maxUploadBytes,sessionTtlSeconds:t.sessionTtlSeconds,frameworks:t.frameworks.map(n=>Iy(n,"迁移框架"))}}async function ER(e){const t=yi(await tu(await cl("/tasks",{signal:e}),"读取迁移会话失败"),"迁移会话列表");if(!Array.isArray(t.items))throw new Error("迁移会话列表格式错误。");return t.items.map(Hp)}async function Qpt(e){return Hp(await tu(await cl("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.taskId,sourceFileName:e.sourceFileName,instruction:e.instruction}),signal:e.signal},eN),"创建迁移会话失败"))}async function BH(e,t,n){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}/source`,{method:"PUT",headers:{"Content-Type":"application/zip"},body:t,signal:n},eN),"上传迁移项目失败"))}async function kR(e,t){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取迁移会话失败"))}async function Bpt(e,t){return Mpt(await tu(await cl(`/tasks/${encodeURIComponent(e)}/activity`,{signal:t,cache:"no-store"}),"读取迁移执行动态失败"))}async function Upt(e){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e.taskId)}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({framework:e.framework,entry:e.entry||null,appName:e.appName,instruction:e.instruction,analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,boundaryConfirmed:!0}),signal:e.signal},eN),"启动迁移失败"))}async function zpt(e){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e.taskId)}/answers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,answers:e.answers}),signal:e.signal},eN),"提交分析补充信息失败"))}async function Fpt(e,t){return Hp(await tu(await cl(`/tasks/${encodeURIComponent(e)}/stop`,{method:"POST",signal:t}),"终止迁移失败"))}async function Vpt(e,t){return Lpt(await tu(await cl(`/tasks/${encodeURIComponent(e)}/artifact`,{signal:t}),"读取迁移产物失败"))}async function Xpt(e,t,n){var s;const i=new URLSearchParams({path:t}),r=await cl(`/tasks/${encodeURIComponent(e)}/artifact/file?${i}`,{signal:n},kr);if(!r.ok)throw await TQ(r,"读取迁移产物文件失败");return{blob:await r.blob(),mimeType:((s=r.headers.get("content-type"))==null?void 0:s.split(";",1)[0])||"application/octet-stream"}}function qpt(e,t){var i;return((i=(e.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:i[1])||t}async function Hpt(e,t,n){const i=await cl(`/tasks/${encodeURIComponent(e)}/download`,{signal:n},kr);if(!i.ok)throw await TQ(i,"下载迁移产物失败");const r=URL.createObjectURL(await i.blob()),s=document.createElement("a");s.href=r,s.download=qpt(i,`${t}-migrated.zip`),s.click(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Yp({children:e,...t}){return l.jsx("svg",{...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e})}function Ypt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"m10 6-6 6 6 6M4 12h16"})})}function Gpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 3v12m-4-4 4 4 4-4M5 20h14"})})}function EE(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M6 3.5h8l4 4V20H6zM14 3.5v4h4M9 12h6M9 15.5h6"})})}function Wpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function Zpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M14.5 4.5c2.3-.9 4.2-.8 5-.6.2.8.3 2.7-.6 5l-5.1 5.1-3.8-3.8zM15.4 8.6h.1M10.3 10.5l-3.8.7-2.1 2.1 5.3.2M13.5 13.7l-.7 3.8-2.1 2.1-.2-5.3M7.2 16.8l-2.8 2.8"})})}function Kpt(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"M12 16V4m-4 4 4-4 4 4M5 20h14"})})}function UH(e){return l.jsx(Yp,{...e,children:l.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const Jpt=new Set(["MODEL_AGENT_API_KEY"]),emt=new Set(["MODEL_AGENT_NAME","MODEL_NAME"]),tmt=new Set(["VOLCENGINE_ACCESS_KEY","VOLCENGINE_SECRET_KEY","VOLCENGINE_SESSION_TOKEN","BYTEPLUS_ACCESS_KEY","BYTEPLUS_SECRET_KEY","BYTEPLUS_SESSION_TOKEN","VEADK_DISABLE_EXPIRE_AT"]);function kE(e){return!tmt.has(e)}function qL(e){return Jpt.has(e)||/(?:API_KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|CREDENTIAL)$/.test(e)}function nmt(e,t){const n={},i=new Set([...e.environment.required,...e.environment.optional]);for(const r of i){if(!kE(r)||qL(r))continue;const s=r==="MODEL_AGENT_API_BASE"?Dl(t):emt.has(r)?t0(t):e.environment.defaults[r];s!=null&&s.trim()&&(n[r]=s)}return n}const imt=50*1024*1024,TR=1200,zH=3e3,rmt=5e3,FH=500,smt=()=>{},Jpe={langchain:"LangChain",langgraph:"LangGraph",adk:"Google ADK",strands:"Strands",agentcore:"AgentCore",dify:"Dify",any:"Any(通用迁移)"},_R=new Set(["langchain","langgraph","adk","strands","agentcore"]);function amt(e){switch(e){case"awaiting_upload":return"待上传";case"analyzing":return"分析中";case"needs_input":return"待补充";case"analysis_ready":return"待确认";case"migrating":return"迁移中";case"validating":return"校验中";case"packaging":return"打包中";case"succeeded":return"已完成";case"succeeded_with_warnings":return"已完成,有提示";case"partial":return"部分完成";case"failed":return"失败";case"cancelled":return"已终止";case"expired":return"已过期"}}function AR(e){return e.state==="partial"&&e.artifact.previewReady?"迁移产物已生成,但交付不完整,请查看迁移提示。":["succeeded","succeeded_with_warnings"].includes(e.state)&&e.artifact.previewReady?e.state==="succeeded_with_warnings"?"迁移产物已生成,请查看迁移提示。":"迁移产物已生成。":e.message}function omt(e){switch(e){case"passed":return"产物校验通过";case"failed":return"产物校验未通过";case"degraded":return"产物校验未完成"}}function NR({stage:e}){const t=[{id:"session",label:"创建迁移环境"},{id:"upload",label:"上传项目"},{id:"analysis",label:"分析项目"}],n=t.findIndex(i=>i.id===e);return l.jsx("div",{className:"migration-transfer-progress",role:"status",children:t.map((i,r)=>l.jsxs("div",{className:r=n)return{title:"迁移环境已过期",detail:"会话和产物已无法访问"};const i=Math.max(0,n-t),r=Math.floor(i/6e4),s=Math.floor(i%6e4/1e3);return{title:`迁移环境将在 ${r} 分 ${s} 秒后过期`,detail:"过期后无法查看会话,也无法预览、下载或部署产物"}}function hmt(e,t){let n=!1;const i=e.map(r=>{if(r.state==="expired")return r;const s=new Date(r.expiresAt).getTime();return!Number.isFinite(s)||ti.id!==t.id);return[t,...n].sort((i,r)=>{const s=typeof i.createdAt=="number"?i.createdAt*1e3:new Date(i.createdAt).getTime();return(typeof r.createdAt=="number"?r.createdAt*1e3:new Date(r.createdAt).getTime())-s})}function pmt(e,t){return e.find(n=>n.id===t)??null}function mmt(e,t){return e.startsWith("text/")||/(?:json|javascript|xml|yaml)/i.test(e)||/\.(?:py|ts|tsx|js|jsx|json|ya?ml|md|txt|toml|ini|cfg|env|sh|dockerfile)$/i.test(t)}function gmt({analysis:e}){var t;return l.jsxs("div",{className:"migration-analysis",children:[l.jsx(qp,{text:e.summary,allowRawHtml:!1}),l.jsxs("div",{className:"migration-analysis__facts",children:[e.recommended?l.jsxs("section",{children:[l.jsx("h3",{children:"建议迁移方式"}),l.jsx("strong",{children:Jpe[e.recommended.framework]}),l.jsx("p",{children:e.recommended.reason})]}):null,l.jsxs("section",{children:[l.jsx("h3",{children:"迁移范围"}),l.jsx("ul",{children:e.boundary.include.map(n=>l.jsx("li",{children:n},n))})]}),e.boundary.exclude.length>0?l.jsxs("section",{children:[l.jsx("h3",{children:"不在本次范围"}),l.jsx("ul",{children:e.boundary.exclude.map(n=>l.jsx("li",{children:n},n))})]}):null]}),(t=e.frameworks[0])!=null&&t.evidence.length?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看分析证据"}),l.jsx("ul",{children:e.frameworks.flatMap(n=>n.evidence.map(i=>l.jsxs("li",{children:[l.jsxs("code",{children:[i.path,":",i.line]}),l.jsx("span",{children:i.reason})]},`${n.id}:${i.path}:${i.line}`)))})]}):null,e.warnings.length>0?l.jsx("div",{className:"migration-analysis__warnings",children:e.warnings.map(n=>l.jsx("p",{children:n},n))}):null,e.assumptions.length>0?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看关键假设"}),l.jsx("ul",{children:e.assumptions.map(n=>l.jsx("li",{children:n},n))})]}):null]})}function bmt(e){return e.kind==="reasoning"&&e.detail?{kind:"thinking",text:e.detail,done:e.status!=="running"}:e.kind==="message"&&e.detail?{kind:"text",text:e.detail}:null}function Omt({activity:e,loading:t,error:n,analyzing:i}){const r=(e==null?void 0:e.items)??[];return l.jsxs("section",{className:"migration-activity","aria-label":"Codex 执行动态",children:[l.jsxs("div",{className:"migration-activity__heading",children:[l.jsx("span",{className:`migration-activity__marker${e!=null&&e.complete?" is-complete":""}`,"aria-hidden":"true"}),l.jsx("strong",{children:"Codex 执行动态"})]}),r.length>0?l.jsx("div",{className:"migration-activity__stream",children:r.map(s=>{const a=bmt(s);return a?l.jsx(vA,{blocks:[a],onAction:smt},s.id):l.jsxs("div",{className:"migration-activity__status","data-status":s.status,children:[l.jsx("span",{className:"migration-activity__marker","aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:s.title}),s.detail?l.jsx("small",{children:s.detail}):null]})]},s.id)})}):t||!(e!=null&&e.complete)?l.jsx(oi,{children:i?"Codex 正在开始分析…":"Codex 正在开始迁移…"}):null,n?l.jsx("p",{className:"migration-activity__error",role:"status",children:n}):null]})}function ymt({task:e,artifact:t}){var d;const[n,i]=m.useState(""),[r,s]=m.useState(((d=t.files[0])==null?void 0:d.path)??""),[a,o]=m.useState(null),c=t.files.find(f=>f.path===r)??t.files[0],u=m.useMemo(()=>{const f=n.trim().toLocaleLowerCase();return(f?t.files.filter(p=>p.path.toLocaleLowerCase().includes(f)):t.files).slice(0,FH)},[t.files,n]);return m.useEffect(()=>{if(!c)return;if(c.size>2*1024*1024){o({path:c.path,loading:!1,error:"该文件超过 2 MiB,请下载完整产物后查看。"});return}const f=new AbortController;let h="";return o({path:c.path,loading:!0}),Xpt(e.id,c.path,f.signal).then(async({blob:p,mimeType:g})=>{if(!f.signal.aborted){if(g.startsWith("image/")){h=URL.createObjectURL(p),o({path:c.path,loading:!1,imageUrl:h});return}if(mmt(g,c.path)){const b=await p.text();if(f.signal.aborted)return;o({path:c.path,loading:!1,text:b});return}o({path:c.path,loading:!1,error:"该文件不支持在线预览,请下载完整产物后查看。"})}}).catch(p=>{f.signal.aborted||o({path:c.path,loading:!1,error:p instanceof Error?p.message:String(p)})}),()=>{f.abort(),h&&URL.revokeObjectURL(h)}},[c,e.id]),l.jsxs("div",{className:"migration-artifact-browser",children:[l.jsxs("aside",{"aria-label":"迁移产物文件",children:[l.jsxs("label",{className:"migration-artifact-browser__search",children:[l.jsx("span",{className:"sr-only",children:"搜索产物文件"}),l.jsx("input",{value:n,onChange:f=>i(f.currentTarget.value),placeholder:"搜索文件"})]}),l.jsx("div",{className:"migration-artifact-browser__files",children:u.map(f=>l.jsxs("button",{type:"button",className:f.path===(c==null?void 0:c.path)?"is-active":"",onClick:()=>s(f.path),title:f.path,children:[l.jsx(EE,{}),l.jsx("span",{children:f.path}),l.jsx("small",{children:HL(f.size)})]},f.path))}),t.files.length>u.length?l.jsxs("p",{className:"migration-artifact-browser__limit",children:["仅展示前 ",FH," 项,请搜索具体文件。"]}):null]}),l.jsxs("section",{children:[l.jsxs("header",{children:[l.jsx("span",{title:c==null?void 0:c.path,children:(c==null?void 0:c.path)||"未选择文件"}),c?l.jsx("small",{children:HL(c.size)}):null]}),l.jsx("div",{className:"migration-artifact-browser__preview",children:c?(a==null?void 0:a.path)!==c.path||a.loading?l.jsx(oi,{children:"正在读取产物文件…"}):a.error?l.jsx("p",{role:"status",children:a.error}):a.imageUrl?l.jsx("img",{src:a.imageUrl,alt:c.path}):l.jsx(sQ,{value:a.text??"",path:c.path,readOnly:!0,onChange:()=>{}}):l.jsx("p",{children:"暂无可预览文件。"})})]})]})}function xmt({cloudProvider:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:i,onDeploymentStarted:r,onDeploymentComplete:s,initialDeployRegion:a=Qi(e)}){var st,At,Ut,kn,wn,Ai,Gn,xn;const o=m.useRef(null),c=m.useRef(""),u=m.useRef(null),[d,f]=m.useState(null),[h,p]=m.useState([]),[g,b]=m.useState(""),[y,O]=m.useState(null),[v,x]=m.useState(!1),[w,E]=m.useState(!0),[S,k]=m.useState(""),[T,A]=m.useState(""),[N,C]=m.useState(""),[M,L]=m.useState(!1),[P,Q]=m.useState(Date.now()),[j,$]=m.useState(null),[U,B]=m.useState("langchain"),[I,X]=m.useState(""),[q,D]=m.useState(""),[H,re]=m.useState({}),[fe,Ae]=m.useState(null),[J,ie]=m.useState(""),[ue,ye]=m.useState(!1),[Se,Re]=m.useState(0),[Ee,me]=m.useState(null),[oe,Ne]=m.useState(!1),[Oe,Ve]=m.useState(""),[We,De]=m.useState(!1),[mt,at]=m.useState(!1),[Rt,qe]=m.useState(a),[W,K]=m.useState(),[ae,pe]=m.useState({}),z=pmt(h,g),ve=j?Math.max(0,Math.floor((P-j)/1e3)):0,Be=Ee==null?void 0:Ee.items[Ee.items.length-1],Je=[(Ee==null?void 0:Ee.items.length)??0,(Be==null?void 0:Be.id)??"",(Be==null?void 0:Be.status)??"",((st=Be==null?void 0:Be.detail)==null?void 0:st.length)??0].join(":"),{ref:kt,onScroll:Mt}=kse(`${(z==null?void 0:z.id)??"new"}:${(z==null?void 0:z.state)??"new"}:${Je}`);async function Tt(de,Le=!0,ut){try{const gt=await kR(de,ut);return ut!=null&&ut.aborted?null:(p(ln=>bu(ln,gt)),C(""),L(!1),gt)}catch(gt){return ut!=null&&ut.aborted||Le&&(C(gt instanceof Error?gt.message:String(gt)),L(gt instanceof Ia&>.retryable)),null}}async function dt(de){try{const Le=await ER(de);if(de!=null&&de.aborted)return;p(Le),C(""),L(!1)}catch(Le){if(de!=null&&de.aborted)return;C(Le instanceof Error?Le.message:String(Le)),L(Le instanceof Ia&&Le.retryable)}}m.useEffect(()=>{const de=new AbortController;return E(!0),A(""),Promise.all([$pt(de.signal),ER(de.signal)]).then(([Le,ut])=>{de.signal.aborted||(f(Le),p(ut))}).catch(Le=>{de.signal.aborted||A(Le instanceof Error?Le.message:String(Le))}).finally(()=>{de.signal.aborted||E(!1)}),()=>de.abort()},[]),m.useEffect(()=>()=>{var de;(de=u.current)==null||de.abort(),u.current=null},[]),m.useEffect(()=>{const de=window.setInterval(()=>{const Le=Date.now();Q(Le),p(ut=>hmt(ut,Le))},1e3);return()=>window.clearInterval(de)},[]),m.useEffect(()=>{if(!h.some(ut=>yh(ut.state)))return;const de=new AbortController,Le=window.setInterval(()=>{ER(de.signal).then(ut=>{de.signal.aborted||p(ut),C(""),L(!1)}).catch(ut=>{de.signal.aborted||(C(ut instanceof Error?ut.message:String(ut)),L(ut instanceof Ia&&ut.retryable),ut instanceof Ia&&ut.retryable||window.clearInterval(Le))})},rmt);return()=>{de.abort(),window.clearInterval(Le)}},[h.some(de=>yh(de.state))]),m.useEffect(()=>{if(!z||!yh(z.state))return;const de=new AbortController;let Le;const ut=async()=>{try{const gt=await kR(z.id,de.signal);if(de.signal.aborted)return;p(ln=>bu(ln,gt)),C(""),L(!1),yh(gt.state)&&(Le=window.setTimeout(()=>void ut(),TR))}catch(gt){if(de.signal.aborted)return;C(gt instanceof Error?gt.message:String(gt)),L(gt instanceof Ia&>.retryable),gt instanceof Ia&>.retryable&&(Le=window.setTimeout(()=>void ut(),TR))}};return Le=window.setTimeout(()=>void ut(),TR),()=>{de.abort(),Le!==void 0&&window.clearTimeout(Le)}},[z==null?void 0:z.id,z==null?void 0:z.state]),m.useEffect(()=>{const de=kt.current;de&&(de.scrollTop=de.scrollHeight,Mt())},[g,kt,Mt]),m.useEffect(()=>{if(me(null),Ve(""),Ne(!1),!z||!VH(z))return;const de=new AbortController;let Le;const ut=async()=>{Ne(!0);try{const gt=await Bpt(z.id,de.signal);if(de.signal.aborted)return;me(gt),Ve(""),!gt.complete&&yh(z.state)&&(Le=window.setTimeout(()=>void ut(),zH))}catch(gt){if(de.signal.aborted)return;Ve("暂时无法读取 Codex 执行动态,不影响当前任务。"),yh(z.state)&> instanceof Ia&>.retryable&&(Le=window.setTimeout(()=>void ut(),zH))}finally{de.signal.aborted||Ne(!1)}};return ut(),()=>{de.abort(),Le!==void 0&&window.clearTimeout(Le)}},[z==null?void 0:z.id,z==null?void 0:z.state,(At=z==null?void 0:z.analysisRef)==null?void 0:At.sha256,(Ut=z==null?void 0:z.confirmation)==null?void 0:Ut.framework]),m.useEffect(()=>{if(!(z!=null&&z.analysis)||!z.analysisRef||!["needs_input","analysis_ready"].includes(z.state))return;const de=`${z.id}:${z.analysisRef.attempt}:${z.analysisRef.sha256}`;if(c.current===de||(c.current=de,re({}),z.state!=="analysis_ready"))return;const Le=z.analysis.recommended;Le&&(B(Le.framework),X(Le.entry||""),D(XH(z.sourceFileName)))},[z]),m.useEffect(()=>{if(Ae(null),ie(""),ye(!1),at(!1),pe({}),!(z!=null&&z.artifact.previewReady))return;const de=new AbortController;return Vpt(z.id,de.signal).then(Le=>{de.signal.aborted||Ae(Le)}).catch(Le=>{de.signal.aborted||(ie(Le instanceof Error?Le.message:String(Le)),ye(Le instanceof Ia&&Le.retryable))}),()=>de.abort()},[z==null?void 0:z.id,z==null?void 0:z.artifact.previewReady,Se]),m.useEffect(()=>{if(!fe)return;const de=nmt(fe,e);pe(Le=>{var gt;const ut={...Le};for(const[ln,Sn]of Object.entries(de))(gt=ut[ln])!=null&>.trim()||(ut[ln]=Sn);return ut})},[fe,e]);function ge(de){if(!u.current&&(A(""),!!de)){if(!de.name.toLowerCase().endsWith(".zip")){O(null),A("请选择 .zip 格式的本地项目文件。");return}if(de.name.length>255||/[/\\\u0000-\u001f]/.test(de.name)){O(null),A("ZIP 文件名无效,请重命名后重新选择。");return}if(de.size>imt){O(null),A("项目 ZIP 不能超过 50 MiB。");return}if(de.size===0){O(null),A("项目 ZIP 不能为空。");return}O(de)}}function lt(de){var ut;const Le=(ut=de.currentTarget.files)==null?void 0:ut[0];de.currentTarget.value="",ge(Le)}async function Ge(){if(!y||S||u.current)return;const de=new AbortController;u.current=de;const Le=()=>u.current===de&&!de.signal.aborted,ut=`migration-v1-${crypto.randomUUID().replace(/-/g,"")}`;k("create"),$(Date.now()),A("");try{const gt=await Qpt({taskId:ut,sourceFileName:y.name,instruction:"",signal:de.signal});if(!Le())return;p(Sn=>bu(Sn,gt)),b(gt.id),k("upload"),$(null);const ln=await BH(gt.id,y,de.signal);if(!Le())return;p(Sn=>bu(Sn,ln)),O(null)}catch(gt){if(!Le())return;const ln=await Tt(ut,!1,de.signal);if(!Le())return;if(ln){if(b(ln.id),ln.state!=="awaiting_upload"){O(null);return}}else if(await dt(de.signal),!Le())return;A(gt instanceof Error?gt.message:String(gt))}finally{u.current===de&&(u.current=null,$(null),k(""))}}async function vt(){if(!(z!=null&&z.canUpload)||!y||S||u.current)return;const de=new AbortController;u.current=de;const Le=()=>u.current===de&&!de.signal.aborted;k("upload"),A("");try{const ut=await BH(z.id,y,de.signal);if(!Le())return;p(gt=>bu(gt,ut)),O(null)}catch(ut){if(!Le())return;const gt=await Tt(z.id,!0,de.signal);if(!Le())return;if(gt&>.state!=="awaiting_upload"){O(null);return}A(ut instanceof Error?ut.message:String(ut))}finally{u.current===de&&(u.current=null,k(""))}}const _t=m.useMemo(()=>{var de;return(((de=z==null?void 0:z.analysis)==null?void 0:de.entries)??[]).filter(Le=>Le.framework===U).map(Le=>({value:Le.value,label:Le.value,description:Le.evidence}))},[U,(kn=z==null?void 0:z.analysis)==null?void 0:kn.entries]),Bt=(((wn=z==null?void 0:z.analysis)==null?void 0:wn.questions)??[]).every(de=>{var Le;return!de.required||!!((Le=H[de.id])!=null&&Le.trim())}),je=cmt(q),Ze=!!(z!=null&&z.canConfirm&&z.analysisRef&&!S&&!je&&(!_R.has(U)||I.trim())),Ie=!!(z!=null&&z.canAnswer&&z.analysisRef&&!S&&Bt);async function Wt(){if(!(!(z!=null&&z.analysisRef)||!Ie)){k("answer"),A("");try{const de=await zpt({taskId:z.id,analysisAttempt:z.analysisRef.attempt,analysisSha256:z.analysisRef.sha256,inputSha256:z.analysisRef.inputSha256,answers:H});p(Le=>bu(Le,de))}catch(de){const Le=await Tt(z.id);if(Le&&Le.state!=="needs_input")return;A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function dn(){if(!(!(z!=null&&z.analysisRef)||!Ze)){k("confirm"),A("");try{const de=await Upt({taskId:z.id,framework:U,entry:_R.has(U)?I.trim():void 0,appName:q.trim(),instruction:"",analysisAttempt:z.analysisRef.attempt,analysisSha256:z.analysisRef.sha256,inputSha256:z.analysisRef.inputSha256});p(Le=>bu(Le,de))}catch(de){const Le=await Tt(z.id);if(Le&&Le.state!=="analysis_ready")return;A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function Qt(){if(!(!(z!=null&&z.canStop)||S)){k("stop"),A("");try{const de=await Fpt(z.id);p(Le=>bu(Le,de)),De(!1)}catch(de){const Le=await Tt(z.id);if(Le&&!Le.canStop){De(!1);return}A(de instanceof Error?de.message:String(de))}finally{k("")}}}async function Yt(){if(!(!(z!=null&&z.artifact.downloadReady)||S)){k("download"),A("");try{await Hpt(z.id,TE(z.sourceFileName))}catch(de){A(de instanceof Error?de.message:String(de))}finally{k("")}}}function Jt(){b(""),O(null),A(""),C(""),L(!1),Ae(null),ie(""),ye(!1),at(!1),De(!1)}const Ft=fe?{name:((Ai=z==null?void 0:z.confirmation)==null?void 0:Ai.app_name)||XH((z==null?void 0:z.sourceFileName)||"migration.zip"),files:[{path:"migration-result.json",content:`${JSON.stringify(fe,null,2)} +`}]}:null,Ce=fe?fe.environment.required.filter(kE).filter(qL).map(de=>({key:de,label:de})):[],et=fe?[...fe.environment.required.filter(kE).filter(de=>!qL(de)).map(de=>({key:de,required:!0,comment:de,placeholder:`请输入 ${de}`})),...fe.environment.optional.filter(kE).map(de=>({key:de,required:!1,comment:de,placeholder:`可选:${de}`}))]:[];async function wt(de,Le,ut){if(!z||!fe)throw new Error("迁移产物尚未准备完成。");const gt=W&&W.mode!=="public"?{mode:W.mode,vpc_id:W.vpcId,subnet_ids:W.subnetIds,enable_shared_internet_access:W.enableSharedInternetAccess}:void 0;return w1(de.name,de.files,{region:Rt,projectName:"default",network:gt},{...ut,migrationTaskId:z.id,onStage:Le})}if(mt&&Ft&&z&&fe)return l.jsx("div",{className:"migration-deployment",children:l.jsx(wQ,{cloudProvider:e,project:Ft,agentName:Ft.name,onDeploy:wt,onAgentAdded:n,onDeploymentTaskChange:i,onDeploymentStarted:r,onDeploymentComplete:s,network:W,onNetworkChange:K,deployRegion:Rt,onDeployRegionChange:qe,deploymentEnv:et,requiredSecretEnv:Ce,deploymentEnvValues:ae,onDeploymentEnvChange:(de,Le)=>pe(ut=>({...ut,[de]:Le})),deploymentTelemetry:{source:"migration",createMode:"migration",aiAssisted:!0},onBack:()=>at(!1),backLabel:"返回迁移结果",deploymentPrimaryPane:l.jsxs("section",{className:"migration-deployment-summary",children:[l.jsx("strong",{children:"迁移产物"}),l.jsx("span",{children:z.sourceFileName}),l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"迁移方式"}),l.jsx("dd",{children:fe.migration.framework})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"启动文件"}),l.jsx("dd",{children:fe.startup.module})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"文件数"}),l.jsx("dd",{children:fe.files.length})]})]})]})})});const yn=y,on=S==="create"||S==="upload",hi=!z||z.canUpload,Pe=z?fmt(z,P):null;return l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"migration-workspace",children:[l.jsxs("aside",{className:"migration-history",children:[l.jsxs("header",{children:[l.jsx("button",{type:"button",className:"migration-icon-button",onClick:t,"aria-label":"返回添加 Agent",title:"返回",children:l.jsx(Ypt,{})}),l.jsx("h1",{children:"从存量迁移"})]}),l.jsxs("button",{type:"button",className:"migration-new-button",onClick:Jt,disabled:on,children:[l.jsx(Wpt,{}),l.jsx("span",{children:"新建迁移"})]}),l.jsx("nav",{"aria-label":"迁移会话",children:w?l.jsx(oi,{children:"正在读取迁移会话…"}):h.length===0?l.jsx("p",{className:"migration-history__empty",children:"暂无迁移会话"}):h.map(de=>l.jsxs("button",{type:"button",className:de.id===g?"is-active":"",disabled:on,onClick:()=>{b(de.id),A(""),C(""),L(!1)},children:[l.jsx("span",{children:TE(de.sourceFileName)}),l.jsxs("small",{children:[l.jsx("span",{"data-state":de.state,children:amt(de.state)}),l.jsx("time",{children:dmt(de.createdAt)})]})]},de.id))})]}),l.jsxs("main",{className:"migration-main",children:[l.jsxs("header",{className:"migration-main__header",children:[l.jsxs("div",{children:[l.jsx("h2",{children:z?TE(z.sourceFileName):"迁移存量 Agent 项目"}),l.jsx("p",{children:z?AR(z):"上传本地项目 ZIP,Codex 将先进行只读分析,再由你确认迁移方式。"})]}),z?l.jsxs("div",{className:"migration-main__header-actions",children:[z!=null&&z.canStop?l.jsx("button",{type:"button",className:"migration-stop-button",onClick:()=>De(!0),disabled:!!S,children:S==="stop"?"正在终止…":"终止迁移"}):null,Pe?l.jsxs("div",{className:"migration-ttl","aria-live":"off",children:[l.jsx("strong",{children:Pe.title}),l.jsx("small",{children:Pe.detail})]}):null]}):null]}),l.jsxs("div",{className:"migration-conversation",role:"log","aria-live":"polite",ref:kt,onScroll:Mt,children:[!(d!=null&&d.enabled)&&!w?l.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[l.jsx("strong",{children:"迁移能力暂不可用"}),l.jsx("p",{children:(d==null?void 0:d.reason)||"Dev Sandbox 暂不可用,请联系管理员检查配置。"})]}):null,z?l.jsxs(l.Fragment,{children:[l.jsx("article",{className:"migration-turn is-user",children:l.jsxs("div",{className:"migration-user-message",children:[l.jsxs("span",{className:"migration-file-chip",children:[l.jsx(EE,{}),l.jsx("span",{title:z.sourceFileName,children:z.sourceFileName})]}),z.instruction?l.jsx("p",{children:z.instruction}):null]})}),l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{className:"migration-assistant-content",children:[S==="upload"?l.jsxs(l.Fragment,{children:[l.jsx(NR,{stage:"upload"}),l.jsx("p",{className:"migration-running-note",children:"ZIP 上传完成后将自动开始只读分析。"})]}):z.state==="analyzing"?l.jsxs(l.Fragment,{children:[l.jsx(NR,{stage:"analysis"}),l.jsx("p",{className:"migration-running-note",children:"Codex 正在识别框架、入口和迁移边界,不会执行实际迁移。"})]}):yh(z.state)?l.jsxs(l.Fragment,{children:[l.jsx(oi,{children:AR(z)}),l.jsx("p",{className:"migration-running-note",children:"迁移执行中不能修改附件或迁移方式。你可以等待当前任务结束,或主动终止。"})]}):z.state==="needs_input"&&z.analysis?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:z.analysis.summary}),l.jsx("p",{children:"只读分析已暂停。请仅回答下面列出的问题,提交后会在同一 迁移环境中重新分析,不会开始实际迁移。"}),(Gn=z.analysis.frameworks[0])!=null&&Gn.evidence.length?l.jsxs("details",{className:"migration-analysis__evidence",children:[l.jsx("summary",{children:"查看源码证据"}),l.jsx("ul",{children:z.analysis.frameworks.flatMap(de=>de.evidence.map(Le=>l.jsxs("li",{children:[l.jsxs("code",{children:[Le.path,":",Le.line]}),l.jsx("span",{children:Le.reason})]},`${de.id}:${Le.path}:${Le.line}`)))})]}):null]}):z.state==="analysis_ready"&&z.analysis?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:"只读分析已完成。请检查建议,并确认最终迁移方式。"}),l.jsx(gmt,{analysis:z.analysis})]}):z.state==="awaiting_upload"?l.jsx("p",{children:"迁移环境已创建,请重新选择本地 ZIP 继续上传。"}):z.state==="expired"?l.jsxs("div",{className:"migration-expired",children:[l.jsx("strong",{children:"迁移环境已过期"}),l.jsx("p",{children:"迁移内容和产物已无法预览、下载或部署。如已完成 Runtime 部署,可返回智能体页面继续使用。"})]}):z.state==="failed"?((xn=z.error)==null?void 0:xn.code)==="MIGRATION_ANALYSIS_UNSUPPORTED"&&z.analysis?l.jsxs("div",{className:"migration-system-state is-error",children:[l.jsx("strong",{children:"当前 ZIP 暂时无法迁移"}),l.jsx(qp,{text:z.analysis.summary,allowRawHtml:!1}),z.analysis.warnings.length>0?l.jsx("ul",{children:z.analysis.warnings.map(de=>l.jsx("li",{children:de},de))}):null,l.jsx("p",{children:"请按提示整理项目后,新建迁移并重新上传。"})]}):l.jsxs("div",{className:"migration-system-state is-error",children:[l.jsx("strong",{children:"迁移未完成"}),l.jsx("p",{children:z.message})]}):z.state==="cancelled"?l.jsx("p",{children:"当前迁移已终止。你可以新建迁移并重新上传项目。"}):l.jsx("p",{children:AR(z)}),VH(z)&&(oe||Ee!=null&&Ee.available||Oe)?l.jsx(Omt,{activity:Ee,loading:oe,error:Oe,analyzing:z.state==="analyzing"}):null]})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{children:[l.jsx("p",{children:"请提供本地项目 ZIP。上传后我会识别框架、入口和迁移边界, 并在执行实际迁移前请你确认迁移方式。"}),l.jsx("small",{children:"仅支持本地 ZIP,最大 50 MiB;迁移环境从创建起保留 1 小时。"})]})]}),S==="create"&&y?l.jsxs(l.Fragment,{children:[l.jsx("article",{className:"migration-turn is-user",children:l.jsx("div",{className:"migration-user-message",children:l.jsxs("span",{className:"migration-file-chip",children:[l.jsx(EE,{}),l.jsx("span",{title:y.name,children:y.name})]})})}),l.jsxs("article",{className:"migration-turn is-assistant",children:[l.jsx("div",{className:"migration-assistant-mark",children:"AI"}),l.jsxs("div",{className:"migration-assistant-content",children:[l.jsx(NR,{stage:"session"}),l.jsx(oi,{as:"strong",children:"正在创建 Dev Sandbox"}),l.jsx("p",{className:"migration-running-note",children:"正在初始化迁移工作目录,并检查 AgentKit CLI、Codex 和迁移能力。环境就绪后将自动上传项目。"}),l.jsxs("small",{children:["已等待 ",umt(ve)]})]})]})]}):null]}),(z==null?void 0:z.state)==="needs_input"&&z.analysis?l.jsxs("section",{className:"migration-confirmation","aria-label":"补充项目分析信息",children:[l.jsxs("div",{className:"migration-confirmation__heading",children:[l.jsx("strong",{children:"补充分析所需信息"}),l.jsx("span",{children:"附件保持锁定,提交后仅继续只读分析"})]}),z.analysis.questions.map(de=>l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:[de.prompt,de.required?l.jsx("b",{"aria-hidden":"true",children:"*"}):null]}),l.jsx("textarea",{value:H[de.id]||"",maxLength:4e3,required:de.required,"aria-required":de.required,onChange:Le=>{const ut=Le.currentTarget.value;re(gt=>({...gt,[de.id]:ut}))},disabled:!!S})]},de.id)),l.jsx("div",{className:"migration-confirmation__actions",children:l.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void Wt(),disabled:!Ie,children:S==="answer"?"正在继续分析…":"提交并继续分析"})})]}):null,(z==null?void 0:z.state)==="analysis_ready"&&z.analysis?l.jsxs("section",{className:"migration-confirmation","aria-label":"确认迁移方式",children:[l.jsxs("div",{className:"migration-confirmation__heading",children:[l.jsx("strong",{children:"确认迁移方式"}),l.jsx("span",{children:"确认后才会执行实际迁移"})]}),l.jsxs("div",{className:"migration-confirmation__grid",children:[l.jsx(Cp,{label:"迁移方式",value:U,options:((d==null?void 0:d.frameworks)??[]).map(de=>({value:de,label:Jpe[de]})),onChange:de=>{var gt;const Le=de;B(Le);const ut=(gt=z.analysis)==null?void 0:gt.entries.find(ln=>ln.framework===Le);X((ut==null?void 0:ut.value)||"")},placeholder:"选择迁移方式",disabled:!!S}),l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:["Agent 名称",l.jsx("b",{"aria-hidden":"true",children:"*"})]}),l.jsx("input",{value:q,onChange:de=>D(de.currentTarget.value),maxLength:63,required:!0,disabled:!!S,"aria-invalid":!!je,"aria-required":"true"}),je?l.jsx("small",{role:"alert",children:je}):null]}),_R.has(U)?_t.length>0?l.jsx(Cp,{label:"项目入口",value:I,options:_t,onChange:X,placeholder:"选择项目入口",disabled:!!S}):l.jsxs("label",{className:"migration-field",children:[l.jsxs("span",{children:["项目入口",l.jsx("b",{"aria-hidden":"true",children:"*"})]}),l.jsx("input",{value:I,onChange:de=>X(de.currentTarget.value),placeholder:"例如 agent.py:agent",maxLength:512,required:!0,disabled:!!S,"aria-required":"true"})]}):null]}),l.jsx("p",{className:"migration-running-note",children:"点击“确认并开始迁移”即确认上述迁移范围、排除项和关键假设。"}),l.jsx("div",{className:"migration-confirmation__actions",children:l.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void dn(),disabled:!Ze,children:S==="confirm"?"正在启动迁移…":"确认并开始迁移"})})]}):null,z&&lmt(z.state)&&z.artifact.previewReady?l.jsxs("section",{className:"migration-result",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("strong",{children:"迁移产物"}),l.jsx("span",{children:z.artifact.deployReady?"产物可预览、下载和部署。运行效果取决于源项目和部署环境变量;迁移环境过期后产物将无法访问。":"产物可预览和下载,但当前交付状态不支持部署;迁移环境过期后产物将无法访问。"})]}),l.jsxs("div",{className:"migration-result__actions",children:[l.jsxs("button",{type:"button",onClick:()=>void Yt(),disabled:!z.artifact.downloadReady||!!S,children:[l.jsx(Gpt,{}),l.jsx("span",{children:S==="download"?"下载中…":"下载 ZIP"})]}),l.jsxs("button",{type:"button",className:"is-primary",onClick:()=>at(!0),disabled:!z.artifact.deployReady||!fe,title:z.artifact.deployReady?"部署迁移产物":"当前交付状态不支持部署",children:[l.jsx(Zpt,{}),l.jsx("span",{children:"部署到 Runtime"})]})]})]}),J?l.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[l.jsx("p",{children:J}),ue?l.jsx("button",{type:"button",className:"migration-retry-button",onClick:()=>{ie(""),ye(!1),Re(de=>de+1)},children:"重新读取"}):null]}):fe?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"migration-result__summary",children:[l.jsxs("span",{children:[fe.files.length," 个文件"]}),l.jsxs("span",{children:["CLI ",fe.cli.version]}),l.jsxs("span",{children:["启动文件 ",fe.startup.module]}),l.jsx("span",{children:omt(fe.verification.status)})]}),l.jsx(ymt,{task:z,artifact:fe})]}):l.jsx(oi,{children:"正在读取迁移产物…"})]}):null,N?l.jsxs("div",{className:"migration-inline-error",role:"alert",children:[l.jsx("span",{children:N}),M?l.jsx("button",{type:"button",onClick:()=>{z&&(C(""),L(!1),kR(z.id).then(de=>p(Le=>bu(Le,de))).catch(de=>{C(de instanceof Error?de.message:String(de)),L(de instanceof Ia&&de.retryable)}))},children:"刷新状态"}):null]}):null,T?l.jsxs("div",{className:"migration-inline-error",role:"alert",children:[l.jsx("span",{children:T}),l.jsx("button",{type:"button",onClick:()=>A(""),"aria-label":"关闭错误提示",children:l.jsx(UH,{})})]}):null]}),hi&&(d!=null&&d.enabled)?l.jsxs("div",{className:"migration-composer",children:[l.jsxs("div",{className:`migration-composer__box${v?" is-dragging":""}`,onDragEnter:de=>{de.preventDefault(),!on&&x(!0)},onDragOver:de=>{de.preventDefault(),de.dataTransfer.dropEffect=on?"none":"copy"},onDragLeave:de=>{de.currentTarget.contains(de.relatedTarget)||x(!1)},onDrop:de=>{var Le;de.preventDefault(),x(!1),!on&&ge((Le=de.dataTransfer.files)==null?void 0:Le[0])},children:[l.jsx("div",{className:"migration-composer__content",children:yn?l.jsxs("div",{className:"migration-composer__file",children:[l.jsx(EE,{}),l.jsx("span",{children:yn.name}),l.jsx("small",{children:HL(yn.size)}),l.jsx("button",{type:"button",onClick:()=>O(null),"aria-label":"移除项目 ZIP",disabled:on,children:l.jsx(UH,{})})]}):l.jsx("p",{children:z?"重新选择项目 ZIP":"选择或拖入本地项目 ZIP"})}),l.jsxs("div",{className:"migration-composer__actions",children:[l.jsxs("button",{type:"button",className:"migration-attach-button",onClick:()=>{var de;return(de=o.current)==null?void 0:de.click()},disabled:on,children:[l.jsx(Kpt,{}),l.jsx("span",{children:y?"重新选择":"选择 ZIP"})]}),l.jsx("button",{type:"button",className:"migration-confirm-upload-button",onClick:()=>void(z?vt():Ge()),disabled:!y||on,children:z?"继续上传":"开始迁移"})]}),l.jsx("input",{ref:o,type:"file",accept:".zip,application/zip",onChange:lt,"aria-label":"选择本地项目 ZIP",disabled:on})]}),l.jsx("p",{children:"迁移环境从创建完成起保留 1 小时,过期后产物无法预览、下载或部署。"})]}):null]})]}),We&&z?l.jsx(Mf,{title:"终止当前迁移?",description:"终止后,当前分析或迁移进程将停止,已执行的步骤不会继续。",confirmLabel:S==="stop"?"正在终止…":"终止迁移",variant:"danger",busy:S==="stop",onCancel:()=>De(!1),onConfirm:()=>void Qt()}):null]})}const eme=1,vmt="MODEL_AGENT_API_KEY";function $T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wmt(e){return $T(e)&&typeof e.id=="string"&&typeof e.updatedAt=="number"&&$T(e.draft)}function tN(e){return`veadk.agentDrafts.${encodeURIComponent(e)}`}function QT(e){const t=e.deployment,n=t==null?void 0:t.envValues,i=t?{...t,...n?{envValues:Object.fromEntries(Object.entries(n).filter(([r])=>r!==vmt))}:{}}:void 0;return{...e,...i?{deployment:i}:{},subAgents:e.subAgents.map(QT),...e.workflow?{workflow:{...e.workflow,nodes:e.workflow.nodes.map(r=>({...r,agent:QT(r.agent)}))}}:{}}}function Smt(e){var i;const t=KA(e),n={...((i=t.draft.deployment)==null?void 0:i.envValues)??{},...t.envValues};return!t.draft.deployment&&Object.keys(n).length===0?QT(t.draft):QT({...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}})}function tme(e){return{...e,draft:Smt(e.draft)}}function Emt(e){const t=Array.isArray(e)?e:$T(e)&&e.version===eme?e.drafts:void 0;if(!Array.isArray(t)||!t.every(wmt))throw $T(e)&&typeof e.version=="number"?new Error("本机草稿版本暂不受支持,请升级 Studio 后重试。"):new Error("本机草稿数据格式无效。");return t.map(tme)}function kmt(e,t){if(!t)return[];const n=e.getItem(tN(t));if(!n)return[];try{return Emt(JSON.parse(n))}catch(i){throw i instanceof Error&&i.message.startsWith("本机草稿")?i:new Error("无法读取本机草稿,浏览器中的草稿数据可能已损坏。")}}function qH(e,t,n){if(!t)return;const i={version:eme,drafts:n.map(tme)};try{e.setItem(tN(t),JSON.stringify(i))}catch(r){throw r instanceof DOMException&&(r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")?new Error("浏览器存储空间不足,草稿未保存。请删除不需要的草稿或清理此站点的浏览器存储后重试。"):new Error("浏览器拒绝保存草稿,请检查站点存储权限后重试。")}}const Tmt=/[;;]/;function _mt(e){const t=new Set;for(const n of e)for(const i of n.split(Tmt)){const r=i.trim();r&&t.add(r)}return[...t]}function Amt(e){return[]}const Nmt=3*60*1e3,Cmt=3e3,jmt=10*60*1e3,Rmt=45e3,BT="veadk.studio.pending-update",_Q="veadk.studio.update-handoff",HH=[{id:"resolving",label:"读取目标版本信息"},{id:"downloading",label:"下载并校验完整更新包"},{id:"preparing",label:"准备 VeFaaS Function 代码"},{id:"provisioning",label:"检查并补齐 Studio 云资源"},{id:"submitting",label:"提交 Function 更新"},{id:"publishing",label:"发布新 Revision 并重启服务"}],Imt={resolving:"读取版本信息",downloading:"下载更新包",preparing:"准备 Function 代码",provisioning:"补齐 Studio 云资源",submitting:"提交 Function 更新",publishing:"发布 Revision",checking:"检查更新",unknown:"未知阶段"};function Pmt(e){return e<60?`${e} 秒`:`${Math.floor(e/60)} 分 ${e%60} 秒`}function Mmt(e,t){return e===t?!0:/^\d{14}$/.test(e)&&/^\d{14}$/.test(t)&&e>t}function Lmt(e){return!!(e!=null&&e.some(t=>t.includes("部署应用成功")||t.toLowerCase().includes("application deployed successfully")))}function Dmt(){if(typeof window>"u")return null;const e=window.localStorage.getItem(BT);if(!e)return null;try{const t=JSON.parse(e);if(typeof t.targetVersion=="string"&&typeof t.startedAt=="number")return{targetVersion:t.targetVersion,startedAt:t.startedAt}}catch{}return window.localStorage.removeItem(BT),null}function CR(e,t){window.localStorage.setItem(BT,JSON.stringify({targetVersion:e,startedAt:t}))}function yS(){window.localStorage.removeItem(BT)}function $mt(){return typeof window>"u"?"":window.sessionStorage.getItem(_Q)??""}function Qmt(e){window.sessionStorage.setItem(_Q,e)}function YH(){window.sessionStorage.removeItem(_Q)}function GH({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M19.2 8.3A8 8 0 1 0 20 13"}),l.jsx("path",{d:"M19.2 4.8v3.5h-3.5"}),l.jsx("path",{d:"M12 7.8v7.7"}),l.jsx("path",{d:"m9.2 12.7 2.8 2.8 2.8-2.8"})]})}function Bmt(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m4 6 4 4 4-4"})})}function Umt(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})})}function WH({lines:e,phase:t,copyState:n,onCopy:i}){const r=m.useRef(null),s=m.useRef(!0),[a,o]=m.useState(e);return m.useEffect(()=>{e.length&&o(e)},[e]),m.useEffect(()=>{const c=r.current;c&&s.current&&(c.scrollTop=c.scrollHeight)},[a]),l.jsxs("section",{className:"studio-update-live-log","aria-label":"部署进度",children:[l.jsxs("div",{className:"studio-update-log-header",children:[l.jsxs("span",{children:[l.jsx("i",{className:`is-${t}`,"aria-hidden":!0}),"部署进度",l.jsx("small",{children:t==="active"?"实时":t==="complete"?"已完成":"已停止"})]}),l.jsx("button",{type:"button",onClick:()=>i(a),disabled:!a.length,children:n==="copied"?"已复制":n==="error"?"复制失败":"复制日志"})]}),l.jsx("div",{ref:r,className:"studio-update-log-lines",role:"log","aria-live":"off","aria-busy":t==="active",tabIndex:0,onScroll:c=>{const u=c.currentTarget;s.current=u.scrollHeight-u.scrollTop-u.clientHeight<24},children:a.length?a.map((c,u)=>l.jsx("div",{children:c},`${u}-${c}`)):l.jsx("p",{children:t==="active"?"等待 VeFaaS 返回更新日志…":"本次更新未返回发布日志"})})]})}function zmt({variant:e="default"}){var $,U;const[t]=m.useState(Dmt),[n,i]=m.useState(null),[r,s]=m.useState(t?"submitting":"idle"),[a,o]=m.useState(!!t),[c,u]=m.useState(""),[d,f]=m.useState((t==null?void 0:t.targetVersion)??""),[h,p]=m.useState(!1),[g,b]=m.useState("idle"),[y,O]=m.useState(0),v=m.useRef(null),x=m.useRef((t==null?void 0:t.targetVersion)??""),w=m.useRef((t==null?void 0:t.startedAt)??0),E=m.useRef($mt()),S=m.useRef(0);m.useEffect(()=>{if(!h)return;const B=X=>{var q;X.target instanceof Node&&!((q=v.current)!=null&&q.contains(X.target))&&p(!1)},I=X=>{X.key==="Escape"&&p(!1)};return window.addEventListener("pointerdown",B),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",B),window.removeEventListener("keydown",I)}},[h]);const k=m.useCallback(async()=>{const B=await lee(x.current||void 0,w.current||void 0);return i(B),B},[]);if(m.useEffect(()=>{let B=!0;const I=()=>{k().catch(()=>{B&&i(q=>q)})};I();const X=window.setInterval(I,Nmt);return()=>{B=!1,window.clearInterval(X)}},[k]),m.useEffect(()=>{if(r!=="submitting")return;const B=window.setInterval(()=>{k().then(I=>{const X=x.current;if(X&&Mmt(I.currentVersion,X)||!X&&!I.available&&I.latestVersion){const q=Date.now();if(S.current||(S.current=q),!Lmt(I.updateLogs)&&q-S.currentjmt&&(window.clearInterval(B),yS(),s("error"),u("等待 VeFaaS 发布超时,请稍后重新检查版本"))}).catch(()=>{})},Cmt);return()=>window.clearInterval(B)},[r,k]),m.useEffect(()=>{r!=="idle"||(n==null?void 0:n.state)!=="updating"||(x.current=n.targetVersion,w.current=n.startedAt||Date.now(),CR(n.targetVersion,w.current),f(n.targetVersion),s("submitting"))},[r,n]),m.useEffect(()=>{if(r!=="submitting"){O(0);return}const B=()=>{const X=w.current||Date.now();O(Math.max(0,Math.floor((Date.now()-X)/1e3)))};B();const I=window.setInterval(B,1e3);return()=>window.clearInterval(I)},[r]),!(n!=null&&n.enabled)||!(n.available||n.state==="updating"||r!=="idle"))return null;const A=n.releases??[],N=d||(($=A[0])==null?void 0:$.version)||n.latestVersion,C=A.find(B=>B.version===N),M=_mt((C==null?void 0:C.changelog)??[]),L=async()=>{YH(),E.current="",x.current=N,w.current=Date.now(),CR(N,w.current),s("submitting"),u(""),b("idle");try{const B=await cee(N);x.current=B.version,CR(B.version,w.current),u("更新已提交,正在等待 VeFaaS 发布新版本")}catch(B){if(B instanceof TypeError){u("连接已切换,正在确认新版本状态");return}yS(),s("error");const I=B instanceof Error?B.message:"Studio 更新失败";try{const X=await k();u(X.message||I)}catch{u(I)}}},P=(U=n.updateLogs)!=null&&U.length?n.updateLogs:(n.errorLog||n.progressMessage||c).split(` `).filter(Boolean),Q=async B=>{try{await navigator.clipboard.writeText(B.join(` -`)),b("copied")}catch{b("error")}},j=()=>{var B;p(!1),b("idle"),u(""),f(x.current||((B=A[0])==null?void 0:B.version)||""),s("confirm")};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:e==="feature-link"?"welcome-feature-link studio-update-trigger--feature":`studio-update-trigger is-${r}`,title:r==="submitting"?"正在更新 Studio":r==="published"?"Studio 已更新":`更新 Studio 至 ${n.latestVersion}`,onClick:()=>{var B;r==="published"?window.location.reload():(r==="submitting"||r==="error"||(f(((B=A[0])==null?void 0:B.version)||n.latestVersion),s("confirm")),o(!0))},children:[e!=="feature-link"&&l.jsx(YH,{className:"studio-update-icon"}),r==="submitting"?l.jsx(oi,{as:"span",children:"正在更新"}):r==="published"?l.jsx("span",{children:"刷新使用新版"}):r==="error"?l.jsx("span",{children:"更新失败"}):e==="feature-link"?l.jsx("span",{children:"立即更新"}):l.jsx("span",{children:"有新版更新"})]}),a&&r!=="idle"&&zi.createPortal(l.jsx("div",{className:"confirm-scrim",role:"presentation",children:l.jsxs("section",{className:`confirm-box studio-update-dialog${r==="confirm"?"":" is-progress"}`,role:"dialog","aria-modal":"true","aria-labelledby":"studio-update-title",children:[l.jsx("div",{className:"studio-update-dialog-mark",children:l.jsx(YH,{})}),l.jsx("div",{id:"studio-update-title",className:"confirm-title",children:r==="error"?"Studio 更新失败":r==="submitting"?"正在更新 Studio":r==="published"?"Studio 更新完成":"发现新版本"}),r==="error"?l.jsxs("div",{className:"studio-update-error-panel",children:[l.jsx("p",{className:"confirm-text studio-update-error",children:c}),l.jsxs("dl",{className:"studio-update-error-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"失败阶段"}),l.jsx("dd",{children:Rmt[n.errorStage]||n.errorStage||"未知阶段"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"错误 ID"}),l.jsx("dd",{children:n.errorId||"未生成"})]})]}),n.updateLogsVisible!==!1&&l.jsx(GH,{lines:P,phase:"error",copyState:g,onCopy:B=>void Q(B)}),n.consoleUrl&&l.jsxs("a",{className:"studio-update-console-link",href:n.consoleUrl,target:"_blank",rel:"noreferrer",children:["前往 VeFaaS 控制台查看 Function 日志",l.jsx("span",{"aria-hidden":!0,children:"↗"})]})]}):r==="submitting"||r==="published"?l.jsxs("div",{className:"studio-update-progress-body",children:[l.jsxs("div",{className:"studio-update-progress-summary",children:[l.jsxs("div",{children:[l.jsx("span",{children:"目标版本"}),l.jsx("strong",{children:x.current||N})]}),l.jsxs("div",{children:[l.jsx("span",{children:r==="published"?"更新状态":"已用时"}),l.jsx("strong",{children:r==="published"?"已完成":Imt(y)})]})]}),l.jsx("ol",{className:"studio-update-progress","aria-label":"Studio 更新进度",children:qH.map((B,I)=>{const X=qH.findIndex(H=>H.id===n.progressStage),q=r==="published"||Ivoid Q(B)}),l.jsx("p",{className:"studio-update-progress-note",children:"发布阶段会短暂中断连接;关闭此窗口不会停止更新,可随时点击右上角按钮重新查看。"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"confirm-text",children:"更新会重启 Studio 服务,预计约 3–5 分钟完成更新与发布。期间正在进行的对话、 流式响应或部署任务可能中断,登录态不会受到影响。"}),l.jsxs("div",{className:"studio-update-field",ref:v,children:[l.jsx("span",{children:"选择版本"}),l.jsxs("button",{type:"button",className:"studio-update-version-trigger","aria-label":"选择版本","aria-haspopup":"listbox","aria-expanded":h,onClick:()=>p(B=>!B),onKeyDown:B=>{(B.key==="ArrowDown"||B.key==="ArrowUp")&&(B.preventDefault(),p(!0))},children:[l.jsx("span",{children:N}),l.jsx(Qmt,{})]}),h&&l.jsx("div",{className:"studio-update-version-menu",role:"listbox","aria-label":"选择版本",children:A.map(B=>{const I=B.version===N;return l.jsxs("button",{type:"button",role:"option","aria-selected":I,className:`studio-update-version-option${I?" is-selected":""}`,onClick:()=>{f(B.version),p(!1)},children:[l.jsx("span",{children:B.version}),I&&l.jsx(Bmt,{})]},B.version)})})]}),l.jsxs("dl",{className:"studio-update-versions",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:n.currentVersion})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"目标版本"}),l.jsx("dd",{children:N})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Commit"}),l.jsx("dd",{children:((C==null?void 0:C.gitSha)||n.latestGitSha).slice(0,8)})]})]}),l.jsxs("section",{className:"studio-update-changelog","aria-labelledby":"studio-update-changelog-title",children:[l.jsx("div",{id:"studio-update-changelog-title",children:"更新内容"}),M.length?l.jsx("ul",{children:M.map(B=>l.jsx("li",{children:B},B))}):l.jsx("p",{children:"暂无更新说明"})]})]}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{type:"button",className:"confirm-btn",onClick:()=>{o(!1),p(!1),r==="confirm"&&(s("idle"),u(""))},children:r==="submitting"?"后台运行":r==="confirm"?"取消":"关闭"}),r==="confirm"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:()=>void L(),children:"立即更新"}),r==="error"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:j,children:"重新尝试"})]})]})}),document.body)]})}const zmt=["多地域智能体:并行加载北京与上海 Runtime,列表下滑即可继续加载。","会话内切换:在输入框旁选择智能体,并直接开启一段新会话。","可视化执行画布:通过横向画布查看多智能体结构,并支持全屏浏览。"],WH=_mt(),Fmt=WH.length?WH:zmt;function Vmt({canUpdate:e=!1}){return l.jsxs("div",{className:"welcome-feature-pill",children:[l.jsx("span",{children:"焕然一新"}),l.jsx("span",{className:"welcome-feature-divider","aria-hidden":"true"}),l.jsx("button",{type:"button",className:"welcome-feature-link","aria-describedby":"welcome-feature-popover",children:"查看新特性"}),l.jsxs("section",{id:"welcome-feature-popover",className:"welcome-feature-popover",role:"tooltip",children:[l.jsx("strong",{children:"本次更新"}),l.jsx("ul",{children:Fmt.map(t=>l.jsx("li",{children:t},t))})]}),e&&l.jsx(Umt,{variant:"feature-link"})]})}const Xmt=1e4;async function tme(e){const t=await fetch(vo(e),{headers:Dp({Accept:"application/json"}),signal:Ao(void 0,Xmt)});if(!t.ok)throw new Error(`读取会话模式能力失败(HTTP ${t.status})`);const n=await t.json();if(typeof n.enabled!="boolean")throw new Error("会话模式能力响应格式错误");return{enabled:n.enabled,reason:typeof n.reason=="string"?n.reason:void 0,endpointExportEnabled:n.endpointExportEnabled===!0}}async function qmt(){return tme("/web/sandbox/capabilities")}async function Hmt(e){return tme(`/web/${e}/capabilities`)}function Ymt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function Gmt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 3.5v11m-4-4 4 4 4-4"}),l.jsx("path",{d:"M5 19.5h14"})]})}function ZH(e){return l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.22"}),l.jsx("path",{d:"M8 2.5A5.5 5.5 0 0 1 13.5 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Wmt({open:e,task:t,onClose:n,onRetry:i,onDownload:r}){const s=m.useId(),a=m.useRef(null),o=m.useRef(null),c=m.useRef(null),u=m.useRef(n);if(u.current=n,m.useEffect(()=>{if(!e||!t)return;c.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const b=document.body.style.overflow;document.body.style.overflow="hidden";const y=window.requestAnimationFrame(()=>{var v;return(v=o.current)==null?void 0:v.focus()}),O=v=>{var S;if(v.key==="Escape"){v.preventDefault(),u.current();return}if(v.key!=="Tab")return;const x=Array.from(((S=a.current)==null?void 0:S.querySelectorAll('button:not(:disabled), a[href], video[controls], [tabindex]:not([tabindex="-1"])'))??[]);if(x.length===0)return;const w=x[0],E=x[x.length-1];if(document.activeElement===o.current){v.preventDefault(),(v.shiftKey?E:w).focus();return}v.shiftKey&&document.activeElement===w?(v.preventDefault(),E.focus()):!v.shiftKey&&document.activeElement===E&&(v.preventDefault(),w.focus())};return window.addEventListener("keydown",O),()=>{var v;window.cancelAnimationFrame(y),document.body.style.overflow=b,window.removeEventListener("keydown",O),(v=c.current)!=null&&v.isConnected&&c.current.focus()}},[e,t==null?void 0:t.localId]),!e||!t)return null;const d=ift(t),f=t.status==="optimizing"||t.status==="generating",h=t.errorStage==="optimization"?"重试提示词优化":"重试视频生成",p=spe(t.resolvedMode??t.requestedMode),g=t.error.includes("尚未开通");return zi.createPortal(l.jsx("div",{className:"new-chat-video-task-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&n()},children:l.jsxs("section",{ref:a,className:`new-chat-video-task-dialog is-${t.status}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":f||void 0,children:[l.jsxs("header",{className:"new-chat-video-task-dialog__head",children:[l.jsxs("div",{children:[l.jsx("h2",{ref:o,id:s,tabIndex:-1,children:"视频生成任务"}),l.jsxs("p",{children:[p," · ",t.generationModel]})]}),l.jsx("button",{type:"button",className:"new-chat-video-task-dialog__close",onClick:n,"aria-label":"关闭视频生成任务弹窗",children:l.jsx(Ymt,{})})]}),l.jsxs("div",{className:"new-chat-video-task-dialog__body",children:[l.jsx("ol",{className:"new-chat-video-task-steps","aria-label":"视频生成进度","aria-live":"polite","aria-atomic":"true",children:d.map(b=>l.jsx("li",{className:`is-${b.status}`,children:l.jsxs("span",{className:"new-chat-video-task-step__label",children:[b.status==="active"?l.jsx(ZH,{className:"new-chat-video-task-step__loading"}):null,l.jsx("span",{children:b.label})]})},b.id))}),t.error?l.jsx("div",{className:"new-chat-video-task-error",role:"alert",children:l.jsx("p",{children:t.error})}):null,t.optimizedPrompt?l.jsxs("section",{className:"new-chat-video-task-prompt","aria-labelledby":`${s}-prompt`,children:[l.jsx("h3",{id:`${s}-prompt`,children:"优化后的提示词"}),l.jsx("p",{children:t.optimizedPrompt})]}):null,t.status==="generating"?l.jsxs("div",{className:"new-chat-video-task-preview is-loading",role:"status",children:[l.jsx(ZH,{className:"new-chat-video-task-preview__loading"}),l.jsxs(oi,{as:"strong",duration:2.2,spread:18,children:[p,"进行中"]}),l.jsx("span",{children:"这可能持续数分钟,生成完成后将在这里显示视频预览"})]}):t.output?l.jsx("div",{className:"new-chat-video-task-preview",children:l.jsx("video",{src:t.output.previewUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":"生成结果预览"})}):null]}),l.jsxs("footer",{className:"new-chat-video-task-dialog__actions",children:[l.jsx("p",{className:f?"is-warning":void 0,children:f?"请勿关闭弹窗,关闭后任务将丢失":t.status==="success"?"视频已生成,可预览或下载":g?"请先在模型控制台开通服务,再重试生成":"修正问题后可重试当前步骤"}),l.jsxs("div",{children:[l.jsx("button",{type:"button",className:"new-chat-video-task-button",onClick:n,children:"关闭"}),t.status==="error"?l.jsx("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:i,children:h}):t.output?l.jsxs("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:r,children:[l.jsx(Gmt,{}),"下载视频"]}):null]})]})]})}),document.body)}const Zmt="我的智能体";function Kmt({open:e,state:t,agentKind:n="codex",error:i,onCancel:r,onConfirm:s}){const a=n==="codex"?"Codex":n==="deepseek-harness"?"DeepSeek Harness":n==="openclaw"?"OpenClaw":"Hermes",o=n==="codex"?Zmt:`我的 ${a}`,c=m.useRef(null),u=m.useRef(null),d=m.useRef(null),f=m.useRef(!1),h=m.useRef(r),[p,g]=m.useState(o),[b,y]=m.useState(!0);if(h.current=r,m.useEffect(()=>{if(!e)return;g(o),y(!0);const w=document.body.style.overflow;document.body.style.overflow="hidden";const E=window.requestAnimationFrame(()=>{var k,T;(k=u.current)==null||k.focus(),(T=u.current)==null||T.select()}),S=k=>{var C;if(k.key==="Escape"){k.preventDefault(),h.current();return}if(k.key!=="Tab")return;const T=(C=c.current)==null?void 0:C.querySelectorAll("input:not(:disabled), button:not(:disabled)");if(!(T!=null&&T.length))return;const A=T[0],N=T[T.length-1];k.shiftKey&&document.activeElement===A?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),A.focus())};return window.addEventListener("keydown",S),()=>{window.cancelAnimationFrame(E),document.body.style.overflow=w,window.removeEventListener("keydown",S)}},[o,e]),!e)return null;const O=t==="loading",v=p.trim(),x=O?`正在创建 ${a} 智能体`:t==="error"?"启动失败":`创建 ${a} 智能体`;return zi.createPortal(l.jsx("div",{className:"sandbox-dialog-backdrop",onMouseDown:w=>{w.target===w.currentTarget&&!O&&r()},children:l.jsxs("form",{ref:c,className:"sandbox-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-dialog-title","aria-describedby":t==="confirm"?void 0:"sandbox-dialog-description",onSubmit:w=>{w.preventDefault(),!O&&!f.current&&v&&s(v,b)},children:[l.jsxs("div",{className:"sandbox-dialog-visual","aria-hidden":"true",children:[l.jsx("span",{className:"sandbox-dialog-orbit"}),l.jsx("span",{className:"sandbox-dialog-icon",children:O?l.jsx("span",{className:"sandbox-spinner"}):l.jsx(t1,{kind:n})})]}),l.jsxs("div",{className:"sandbox-dialog-copy",children:[l.jsx("h2",{id:"sandbox-dialog-title",children:x}),t==="error"?l.jsx("p",{id:"sandbox-dialog-description",className:"sandbox-dialog-error",role:"alert",children:i||"AgentKit 沙箱初始化失败,请稍后重新尝试。"}):O?l.jsxs("p",{id:"sandbox-dialog-description","aria-live":"polite",children:["正在创建并等待 ",a," 智能体就绪,这通常需要半分钟"]}):null,l.jsxs("label",{className:"sandbox-dialog-field",children:[l.jsxs("span",{className:"sandbox-dialog-field-label",children:[l.jsx("span",{children:"智能体名称"}),l.jsxs("span",{"aria-hidden":"true",children:[p.length,"/",Uq]})]}),l.jsx("input",{ref:u,type:"text",required:!0,value:p,maxLength:Uq,disabled:O,placeholder:o,autoComplete:"off",onChange:w=>g(w.target.value),onCompositionStart:()=>{f.current=!0},onCompositionEnd:()=>{f.current=!1},onKeyDown:w=>{const{nativeEvent:E}=w;w.key==="Enter"&&(f.current||E.isComposing||E.keyCode===229)&&w.preventDefault()}})]}),l.jsxs("div",{className:"sandbox-dialog-persistence",role:"group","aria-describedby":"sandbox-persistence-description",children:[l.jsx(yQ,{id:"sandbox-persistence",className:"sandbox-dialog-persistence-control",checked:b,disabled:O,onCheckedChange:y,label:"持久化"}),l.jsx("p",{id:"sandbox-persistence-description",className:`sandbox-dialog-persistence-description${b?"":" is-warning"}`,role:b?void 0:"status",children:b?"保留智能体数据,后续可继续使用。":"智能体将在 8 小时后清空"})]})]}),l.jsxs("footer",{className:"sandbox-dialog-actions",children:[l.jsx("button",{ref:d,type:"button",onClick:r,children:O?"取消创建":"取消"}),!O&&l.jsx("button",{type:"submit",className:"is-primary",disabled:!v,children:t==="error"?"重新尝试":"确认创建"})]})]})}),document.body)}function Jmt({agentName:e,onExit:t}){return l.jsxs("div",{className:"sandbox-session-warning",role:"status",children:[l.jsx("span",{className:"sandbox-session-warning-dot","aria-hidden":"true"}),l.jsxs("span",{className:"sandbox-session-warning-copy",children:["当前您在使用 ",e," 智能体"]}),l.jsx("button",{type:"button",onClick:t,children:"退出当前智能体"})]})}function egt({activity:e,time:t}){var n;return l.jsxs("aside",{className:"sandbox-activity-record",role:"status","aria-label":"Sandbox 操作记录",children:[l.jsxs("div",{className:"sandbox-activity-summary",children:[l.jsx("span",{className:"sandbox-activity-dot","aria-hidden":"true"}),l.jsx("span",{className:"sandbox-activity-label",children:"操作记录"}),l.jsx("strong",{children:e.title}),t?l.jsx("time",{children:t}):null]}),(n=e.details)!=null&&n.length?l.jsx("dl",{className:"sandbox-activity-details",children:e.details.map(i=>l.jsxs("div",{children:[l.jsx("dt",{children:i.label}),l.jsx("dd",{title:i.value,children:i.code?l.jsx("code",{children:i.value}):i.value})]},`${i.label}:${i.value}`))}):null]})}function tgt(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function ngt({usage:e}){const t=[["Total",e.totalTokens],["Input",e.inputTokens],...e.cachedInputTokens>0?[["Cached input",e.cachedInputTokens]]:[],["Output",e.outputTokens],...e.reasoningOutputTokens>0?[["Reasoning output",e.reasoningOutputTokens]]:[]];return l.jsx("div",{className:"sandbox-token-usage","aria-label":"Codex Token 用量",children:t.map(([n,i])=>l.jsxs("span",{title:`${n}: ${i.toLocaleString()} tokens`,children:[l.jsx("small",{children:n}),l.jsx("strong",{children:tgt(i)})]},n))})}function nme(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("path",{d:"m7.5 9 2.7 2.5L7.5 14M12.7 14h3.8"}),l.jsx("path",{d:"M3.8 7.5h16.4",opacity:".55"})]})}function ime(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("path",{d:"M3.8 8h16.4"}),l.jsx("circle",{cx:"6.5",cy:"6.3",r:".65",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"8.8",cy:"6.3",r:".65",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"m9 15 2.2-4 1.6 2.4 1.1-1.2L16 15H9Z"})]})}function AQ(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 3.4 19 6v5.3c0 4.3-2.7 7.6-7 9.3-4.3-1.7-7-5-7-9.3V6l7-2.6Z"}),l.jsx("path",{d:"m8.8 12 2 2 4.4-4.4"})]})}function _E(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M3.5 7.7h6.1l1.7 2h9.2v7.5a2.3 2.3 0 0 1-2.3 2.3H5.8a2.3 2.3 0 0 1-2.3-2.3V7.7Z"}),l.jsx("path",{d:"M3.8 7.7V6.8a2.3 2.3 0 0 1 2.3-2.3h3l1.8 2h6.9a2.3 2.3 0 0 1 2.3 2.3v.9"}),l.jsx("path",{d:"M12 13v3M10.5 14.5h3"})]})}function igt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function rgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 11.5 5.5-5.5 5.5 5.5M12 6v12"})})}function sgt(e){return l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...e,children:l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.75",fill:"currentColor"})})}function agt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("circle",{cx:"8.5",cy:"9",r:"1.4"}),l.jsx("path",{d:"m5.5 17 4.2-4.2 2.6 2.4 2.1-2.1 4.1 3.9"})]})}function ogt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6 3.5h7l5 5v12H6z"}),l.jsx("path",{d:"M13 3.5v5h5M9 13h6M9 16h5"})]})}function lgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"13.5",height:"14",rx:"2.5"}),l.jsx("path",{d:"m17 10 3.5-2v8L17 14zM7 8.5h4.5"})]})}function cgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m12 3 1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5zM18.5 15.5l.7 2.1 2.1.7-2.1.7-.7 2.1-.7-2.1-2.1-.7 2.1-.7z"})})}function ugt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function YL(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9 6 6 6-6 6"})})}function dgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.8 8.2A8 8 0 1 1 4 12M4.8 8.2V4.5M4.8 8.2h3.7"}),l.jsx("path",{d:"M12 8v4.5l3 1.8"})]})}function Pc(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M20 12a8 8 0 1 1-2.35-5.65"})})}function fgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"8",y:"8",width:"11",height:"11",rx:"2"}),l.jsx("path",{d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})]})}function hgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function lv({open:e,title:t,subtitle:n,icon:i,className:r="",onClose:s,children:a}){const o=m.useId(),c=m.useRef(null),u=m.useRef(null),d=m.useRef(s);return d.current=s,m.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const f=document.body.style.overflow;document.body.style.overflow="hidden",(p=c.current)==null||p.focus();const h=g=>{var x;if(g.key==="Escape"){g.preventDefault(),d.current();return}if(g.key!=="Tab")return;const b=(x=c.current)==null?void 0:x.closest("[role=dialog]"),y=Array.from((b==null?void 0:b.querySelectorAll('button:not(:disabled), input:not(:disabled), iframe, [tabindex]:not([tabindex="-1"])'))??[]);if(y.length===0)return;const O=y[0],v=y[y.length-1];g.shiftKey&&document.activeElement===O?(g.preventDefault(),v.focus()):!g.shiftKey&&document.activeElement===v&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{var g;document.body.style.overflow=f,window.removeEventListener("keydown",h),(g=u.current)==null||g.focus()}},[e]),e?zi.createPortal(l.jsx("div",{className:"sandbox-control-backdrop",onMouseDown:f=>{f.target===f.currentTarget&&s()},children:l.jsxs("section",{className:`sandbox-control-dialog ${r}`.trim(),role:"dialog","aria-modal":"true","aria-labelledby":o,children:[l.jsxs("header",{className:"sandbox-control-head",children:[l.jsx("span",{className:"sandbox-control-head-icon","aria-hidden":"true",children:i}),l.jsxs("div",{children:[l.jsx("h2",{id:o,children:t}),l.jsx("p",{children:n})]}),l.jsx("button",{ref:c,type:"button",className:"sandbox-control-close","aria-label":`关闭${t}`,onClick:s,children:l.jsx(ugt,{})})]}),a]})}),document.body):null}function pgt({open:e,kind:t,launch:n,loading:i,error:r,onReload:s,onClose:a}){const o=t==="terminal",c=o?"Terminal":"Sandbox Browser";return l.jsxs(lv,{open:e,title:c,subtitle:o?"连接当前 AgentKit Session 的交互式终端":"在当前 AgentKit Session 中查看与操作浏览器",icon:o?l.jsx(nme,{}):l.jsx(ime,{}),className:`sandbox-tool-dialog sandbox-tool-dialog--${t}`,onClose:a,children:[l.jsx("div",{className:"sandbox-tool-toolbar",children:l.jsxs("span",{children:[l.jsx("i",{className:i?"is-loading":n?"is-ready":""}),i?"正在连接…":n?"已连接":"尚未连接"]})}),l.jsx("div",{className:"sandbox-tool-surface",children:i?l.jsxs("div",{className:"sandbox-control-state",children:[l.jsx(Pc,{className:"spin"}),l.jsxs("strong",{children:["正在打开 ",c]}),l.jsx("span",{children:"工具正在连接当前 AgentKit Session。"})]}):r?l.jsxs("div",{className:"sandbox-control-state is-error",children:[l.jsxs("strong",{children:[c," 打开失败"]}),l.jsx("span",{children:r}),l.jsx("button",{type:"button",onClick:s,children:"重试"})]}):n?l.jsx("iframe",{src:n.url,title:c,allow:"clipboard-read; clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts"}):null})]})}function mgt({open:e,threads:t,currentThreadId:n,loading:i,error:r,onSelect:s,onClose:a}){return l.jsx(lv,{open:e,title:"恢复 Codex 对话",subtitle:"选择当前 Sandbox Session 中最近更新的 Thread",icon:l.jsx(dgt,{}),className:"sandbox-threads-dialog",onClose:a,children:l.jsx("div",{className:"sandbox-thread-list",children:i?l.jsxs("div",{className:"sandbox-control-state",children:[l.jsx(Pc,{className:"spin"}),l.jsx("strong",{children:"正在读取历史对话"})]}):r?l.jsxs("div",{className:"sandbox-control-state is-error",children:[l.jsx("strong",{children:"历史对话读取失败"}),l.jsx("span",{children:r})]}):t.length===0?l.jsx("div",{className:"sandbox-control-state",children:l.jsx("strong",{children:"暂无可恢复的对话"})}):t.map(o=>{const c=o.id===n,u=o.name||o.preview||`Thread ${o.id.slice(0,8)}`;return l.jsxs("button",{type:"button",className:c?"is-active":"",disabled:c,onClick:()=>s(o.id),children:[l.jsxs("span",{children:[l.jsx("strong",{children:u}),l.jsx("small",{children:o.preview||o.cwd||o.id})]}),l.jsx("time",{children:o.updatedAt?new Date(o.updatedAt*1e3).toLocaleString():""}),l.jsx(YL,{})]},o.id)})})})}const ggt=[{value:"read-only",label:"只读",detail:"允许读取文件,不允许写入工作空间。"},{value:"workspace-write",label:"工作区写入",detail:"允许在当前工作空间内读取与修改文件。"},{value:"danger-full-access",label:"完全访问",detail:"不启用沙箱隔离,适合明确可信的任务。",danger:!0}],bgt=[{value:"untrusted",label:"仅不可信命令",detail:"只对 Codex 判断为不可信的操作发起审批。"},{value:"on-request",label:"按需审批",detail:"Codex 可在必要时请求你确认命令或文件修改。"},{value:"never",label:"不审批",detail:"Codex 不会暂停并请求人工批准。",danger:!0}],Ogt=[{value:"user",label:"由我审批",detail:"审批请求会显示在 Studio 中,由你决定。"},{value:"auto_review",label:"自动审查",detail:"使用 Codex 自动审查流程处理审批请求。"}];function ygt({open:e,value:t,busy:n,error:i,onSave:r,onClose:s}){const[a,o]=m.useState(t);return m.useEffect(()=>{e&&o(t)},[e,t]),l.jsxs(lv,{open:e,title:"Codex 权限",subtitle:"设置会保存到当前 Sandbox Session,并同步到其中的所有 Thread",icon:l.jsx(AQ,{}),className:"sandbox-settings-dialog",onClose:s,children:[l.jsxs("div",{className:"sandbox-control-body",children:[l.jsx(jR,{label:"沙箱模式",choices:ggt,value:a.sandboxMode,disabled:n,onChange:c=>o(u=>({...u,sandboxMode:c,networkAccess:c==="danger-full-access"?!0:u.networkAccess}))}),l.jsx(jR,{label:"审批策略",choices:bgt,value:a.approvalPolicy,disabled:n,onChange:c=>o(u=>({...u,approvalPolicy:c}))}),l.jsx(jR,{label:"审批方式",choices:Ogt,value:a.approvalsReviewer,disabled:n,onChange:c=>o(u=>({...u,approvalsReviewer:c}))}),l.jsxs("label",{className:`sandbox-network-toggle${a.sandboxMode==="danger-full-access"?" is-disabled":""}`,children:[l.jsxs("span",{children:[l.jsx("strong",{children:"允许网络访问"}),l.jsx("small",{children:"控制 workspace-write 与只读模式中的外部网络访问。"})]}),l.jsx("input",{type:"checkbox",checked:a.networkAccess,disabled:n||a.sandboxMode==="danger-full-access",onChange:c=>o(u=>({...u,networkAccess:c.target.checked}))})]}),a.sandboxMode==="danger-full-access"?l.jsx("div",{className:"sandbox-control-note is-danger",children:"完全访问会关闭文件系统与网络隔离,请只在可信任务中使用。"}):null,i?l.jsx("div",{className:"sandbox-control-error",children:i}):null]}),l.jsxs("footer",{className:"sandbox-control-actions",children:[l.jsx("button",{type:"button",onClick:s,disabled:n,children:"取消"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:n,onClick:()=>r(a),children:[n?l.jsx(Pc,{className:"spin"}):null,"保存权限"]})]})]})}function jR({label:e,choices:t,value:n,disabled:i,onChange:r}){return l.jsxs("fieldset",{className:"sandbox-choice-group",disabled:i,role:"radiogroup","aria-label":e,children:[l.jsx("legend",{children:e}),l.jsx("div",{className:"sandbox-choice-list",children:t.map(s=>l.jsxs("button",{type:"button",role:"radio",className:`${n===s.value?"is-active":""}${s.danger?" is-danger":""}`.trim(),"aria-checked":n===s.value,onClick:()=>r(s.value),onKeyDown:a=>{var d,f;const o=t.findIndex(h=>h.value===s.value);let c=o;if(a.key==="ArrowRight"||a.key==="ArrowDown")c=(o+1)%t.length;else if(a.key==="ArrowLeft"||a.key==="ArrowUp")c=(o-1+t.length)%t.length;else if(a.key==="Home")c=0;else if(a.key==="End")c=t.length-1;else return;a.preventDefault(),r(t[c].value);const u=(d=a.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="radio"]');(f=u==null?void 0:u[c])==null||f.focus()},children:[l.jsx("i",{}),l.jsxs("span",{children:[l.jsx("strong",{children:s.label}),l.jsx("small",{children:s.detail})]})]},s.value))})]})}function xgt({open:e,cwd:t,locked:n,busy:i,error:r,browse:s,onSave:a,onClose:o}){const[c,u]=m.useState(t||"/"),[d,f]=m.useState(null),[h,p]=m.useState(!1),[g,b]=m.useState("");m.useEffect(()=>{if(!e)return;const O=t||"/";u(O),y(O)},[t,e]);async function y(O){p(!0),b("");try{const v=await s(O);f(v),u(v.path)}catch(v){b(v instanceof Error?v.message:String(v))}finally{p(!1)}}return l.jsxs(lv,{open:e,title:"工作空间",subtitle:"选择当前 Codex Thread 执行命令与修改文件的目录",icon:l.jsx(_E,{}),className:"sandbox-workspace-dialog",onClose:o,children:[l.jsxs("div",{className:"sandbox-control-body",children:[l.jsxs("label",{className:"sandbox-workspace-input",children:[l.jsx("span",{children:"绝对路径"}),l.jsxs("div",{children:[l.jsx("input",{value:c,disabled:i||n,spellCheck:!1,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&c.startsWith("/")&&(O.preventDefault(),y(c))}}),l.jsx("button",{type:"button",disabled:i||h||!c.startsWith("/"),onClick:()=>void y(c),children:"浏览"})]})]}),l.jsxs("div",{className:"sandbox-directory-browser",children:[l.jsxs("div",{className:"sandbox-directory-head",children:[l.jsx("span",{title:d==null?void 0:d.path,children:(d==null?void 0:d.path)??c}),h?l.jsx(Pc,{className:"spin"}):null]}),l.jsxs("div",{className:"sandbox-directory-list",children:[d!=null&&d.parent?l.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(d.parent??"/"),children:[l.jsx(_E,{}),l.jsx("span",{children:"上一级"}),l.jsx("small",{children:d.parent}),l.jsx(YL,{})]}):null,d==null?void 0:d.directories.map(O=>l.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(O.path),children:[l.jsx(_E,{}),l.jsx("span",{children:O.name}),l.jsx(YL,{})]},O.path)),!h&&(d==null?void 0:d.directories.length)===0?l.jsx("div",{className:"sandbox-directory-empty",children:"当前目录没有子目录"}):null]})]}),n?l.jsx("div",{className:"sandbox-control-note",children:"当前对话已经开始,工作空间已锁定。新建 Sandbox 会话后可重新选择。"}):null,g||r?l.jsx("div",{className:"sandbox-control-error",children:g||r}):null]}),l.jsxs("footer",{className:"sandbox-control-actions",children:[l.jsx("button",{type:"button",onClick:o,disabled:i,children:"取消"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:i||n||!c.startsWith("/"),onClick:()=>a(c),children:[i?l.jsx(Pc,{className:"spin"}):null,"使用此目录"]})]})]})}function vgt({approval:e,busy:t,error:n,onDecision:i}){var a;const r=(a=e==null?void 0:e.command)==null?void 0:a.trim(),s=(e==null?void 0:e.changes)===void 0?"":JSON.stringify(e.changes,null,2);return l.jsxs(lv,{open:e!==null,title:(e==null?void 0:e.kind)==="file"?"允许修改文件?":"允许执行命令?",subtitle:"Codex 正在等待你的决定",icon:l.jsx(AQ,{}),className:"sandbox-approval-dialog",onClose:()=>{t||i("cancel")},children:[l.jsxs("div",{className:"sandbox-control-body",children:[e!=null&&e.reason?l.jsx("div",{className:"sandbox-approval-reason",children:e.reason}):null,r?l.jsx("pre",{children:r}):null,s?l.jsx("pre",{children:s}):null,e!=null&&e.cwd?l.jsxs("div",{className:"sandbox-approval-meta",children:["执行目录 ",l.jsx("code",{children:e.cwd})]}):null,n?l.jsx("div",{className:"sandbox-control-error",children:n}):null]}),l.jsxs("footer",{className:"sandbox-control-actions sandbox-approval-actions",children:[l.jsx("button",{type:"button",disabled:t,onClick:()=>i("decline"),children:"拒绝"}),l.jsx("button",{type:"button",disabled:t,onClick:()=>i("accept"),children:"仅本次允许"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:t,onClick:()=>i("acceptForSession"),children:[t?l.jsx(Pc,{className:"spin"}):null,"本会话允许"]})]})]})}const wgt={codex:"Codex","deepseek-harness":"DeepSeek Harness",openclaw:"OpenClaw",hermes:"Hermes"};function KH(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(t)}function Sgt({session:e,onBack:t,onOpen:n,onDelete:i}){const[r,s]=m.useState(!1),[a,o]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=wgt[e.toolName],p=e.resourceType==="snapshot",g=p?e.sourceSessionId||e.snapshotId:e.id,b=async()=>{if(!(a||c)){o(!0),f("");try{await n()}catch(O){f(O instanceof Error?O.message:String(O))}finally{o(!1)}}},y=async()=>{if(!(c||a)){u(!0),f("");try{await i()}catch(O){f(O instanceof Error?O.message:String(O)),s(!1)}finally{u(!1)}}};return l.jsxs("section",{className:"sandbox-agent-details",children:[l.jsxs("header",{className:"sandbox-agent-details-header",children:[l.jsxs("button",{type:"button",className:"sandbox-agent-back",onClick:t,children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),"返回智能体"]}),l.jsxs("div",{children:[l.jsx("h1",{children:e.displayName||`${h} 智能体`}),l.jsxs("p",{children:[h," AgentKit Session 详情"]})]})]}),d?l.jsx("div",{className:"sandbox-agent-detail-error",role:"alert",children:d}):null,l.jsxs("div",{className:"sandbox-agent-detail-panel",children:[l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"智能体类型"}),l.jsx("dd",{children:h})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:YA(e.status)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"创建人"}),l.jsx("dd",{children:e.createdBy||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:p?"快照状态":"工具类型"}),l.jsx("dd",{children:p?e.snapshotStatus||"—":e.toolType||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"创建时间"}),l.jsx("dd",{children:KH(e.createdAt)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:p?"快照原因":"过期时间"}),l.jsx("dd",{children:p?e.reason||"—":KH(e.expireAt)})]}),l.jsxs("div",{className:"is-wide",children:[l.jsx("dt",{children:p?"Snapshot ID":"Session ID"}),l.jsx("dd",{children:p?e.snapshotId:g})]}),p&&e.sourceSessionId?l.jsxs("div",{className:"is-wide",children:[l.jsx("dt",{children:"来源 Session ID"}),l.jsx("dd",{children:e.sourceSessionId})]}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"sandbox-agent-delete",disabled:a||c,onClick:()=>s(!0),children:"删除智能体"}),l.jsx("button",{type:"button",className:"sandbox-agent-open",disabled:a||c,"aria-busy":a||void 0,onClick:()=>void b(),children:a?p?"唤醒中…":"打开中…":p?"唤醒智能体":"打开智能体"})]})]}),r?l.jsx("div",{className:"confirm-scrim",onClick:()=>!c&&s(!1),children:l.jsxs("div",{className:"confirm-box",role:"alertdialog","aria-modal":"true","aria-labelledby":"sandbox-agent-delete-title",onClick:O=>O.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",id:"sandbox-agent-delete-title",children:"删除智能体?"}),l.jsxs("div",{className:"confirm-text",children:["将删除“",e.displayName||`${h} 智能体`,"”及其 AgentKit ",p?"Snapshot":"Session",",此操作无法撤销。"]}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{type:"button",className:"confirm-btn",disabled:c,onClick:()=>s(!1),children:"取消"}),l.jsx("button",{type:"button",className:"confirm-btn confirm-btn--danger",disabled:c,onClick:()=>void y(),children:c?"删除中…":"确认删除"})]})]})}):null]})}const Egt="_SegmentedControl_1sl7d_1",kgt="_SegmentedControlOption_1sl7d_140",Tgt="_SegmentedControlThumb_1sl7d_219",GL={SegmentedControl:Egt,SegmentedControlOption:kgt,SegmentedControlThumb:Tgt},AE=({value:e,onChange:t,children:n,block:i,pill:r=!0,size:s="md",gutterSize:a,className:o,onClick:c,...u})=>{const d=m.useRef(null),f=m.useRef(null),h=m.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const E=v*.15,S=b.scrollLeft,k=O.offsetLeft,T=k+x;(kS+v-E)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);PMe({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),m.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||LP(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,r]);const p=g=>{g&&t&&t(g)};return l.jsxs(J$e,{ref:d,className:Ps(GL.SegmentedControl,o),type:"single",value:e,loop:!1,onValueChange:p,onClick:c,"data-block":i?"":void 0,"data-pill":r?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[l.jsx("div",{className:GL.SegmentedControlThumb,ref:f}),n]})},_gt=({children:e,...t})=>l.jsx(r3e,{className:GL.SegmentedControlOption,...t,onPointerEnter:cie,children:l.jsx("span",{className:"relative",children:e})});AE.Option=_gt;function Agt({workspace:e,onBack:t}){const[n,i]=m.useState("main"),[r,s]=m.useState(""),[a,o]=m.useState(!1),[c,u]=m.useState(""),d=e.kind==="deepseek-harness"?"DeepSeek Harness":e.kind==="openclaw"?"OpenClaw":"Hermes";m.useEffect(()=>{i("main"),s(""),u(""),o(!1)},[e.session.id]);const f=async()=>{if(i("terminal"),!(r||a)){o(!0),u("");try{const h=await Kt.launchAgentTerminal(e.kind,e.session.id);s(h.url)}catch(h){u(h instanceof Error?h.message:String(h))}finally{o(!1)}}};return l.jsxs("section",{className:"sandbox-agent-workspace",children:[l.jsxs("header",{children:[l.jsxs("div",{className:"sandbox-agent-workspace-title",children:[l.jsx("button",{type:"button",onClick:t,"aria-label":"返回智能体列表",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}),l.jsxs("div",{children:[l.jsx("h1",{children:e.session.displayName||`${d} 智能体`}),l.jsxs("p",{children:[l.jsxs("span",{children:["创建人 ",e.session.createdBy||"未知"]}),l.jsx("span",{className:"sandbox-agent-workspace-status","data-ready":e.session.status.toLowerCase()==="ready"||void 0,children:YA(e.session.status)})]})]})]}),l.jsxs(AE,{className:"sandbox-agent-workspace-tabs",value:n,size:"lg",gutterSize:"lg",block:!0,pill:!1,"aria-label":"智能体工作区",onChange:h=>{h==="terminal"?f():i("main")},children:[l.jsx(AE.Option,{value:"main",children:"主界面"}),l.jsx(AE.Option,{value:"terminal",children:"终端"})]})]}),l.jsx("div",{className:"sandbox-agent-workspace-surface",children:n==="main"?l.jsx("iframe",{src:e.webuiUrl,title:`${d} 主界面`,allow:"clipboard-read; clipboard-write"}):a?l.jsx("div",{className:"sandbox-agent-workspace-state",role:"status",children:"正在打开终端…"}):c?l.jsxs("div",{className:"sandbox-agent-workspace-state is-error",role:"alert",children:[l.jsx("p",{children:c}),l.jsx("button",{type:"button",onClick:()=>void f(),children:"重新尝试"})]}):r?l.jsx("iframe",{src:r,title:`${d} 终端`}):null})]})}const nN=[{name:"model",usage:"/model [model]",description:"显示或切换当前对话模型",keywords:["模型","switch"]},{name:"models",usage:"/models",description:"列出 app-server 可用模型",keywords:["模型列表","list"]},{name:"skill",usage:"/skill",description:"浏览并调用当前工作区可用的 Skill",keywords:["技能","workflow"]},{name:"skills",usage:"/skills",description:"浏览并调用当前工作区可用的 Skills",keywords:["技能列表","workflow","list"]},{name:"new",usage:"/new",description:"开始一个新对话",keywords:["新建","对话"]},{name:"resume",usage:"/resume [thread]",description:"打开历史会话或恢复指定 thread",keywords:["历史","恢复","session"]},{name:"fork",usage:"/fork",description:"从当前上下文分叉一个新对话",keywords:["分叉","branch"]},{name:"compact",usage:"/compact",description:"压缩当前对话上下文",keywords:["压缩","上下文"]},{name:"archive",usage:"/archive",description:"归档当前对话并新建对话",keywords:["归档","关闭"]},{name:"status",usage:"/status",description:"显示当前连接、thread、模型与 token 状态",keywords:["状态","连接","token"]},{name:"clear",usage:"/clear",description:"清空当前视图并开始新对话",keywords:["清空","重置"]},{name:"help",usage:"/help",description:"显示 Sandbox 支持的快捷命令",keywords:["帮助","命令"]}];function Ngt(e){var n;const t=e.trim().match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(t)return{name:t[1].toLocaleLowerCase(),argument:((n=t[2])==null?void 0:n.trim())??""}}function Cgt(e){const t=e.toLocaleLowerCase();return nN.filter(n=>!t||[n.name,n.description,...n.keywords].some(i=>i.toLocaleLowerCase().includes(t))).sort((n,i)=>JH(n,t)-JH(i,t)).slice(0,12)}function JH(e,t){return t?e.name===t?0:e.name.startsWith(t)?1:e.name.includes(t)?2:3:nN.indexOf(e)}function jgt(e,t){const n=t.toLocaleLowerCase();return e.filter(i=>!n||`${i.id} ${i.displayName} ${i.description}`.toLocaleLowerCase().includes(n)).sort((i,r)=>{if(!n)return Number(r.isDefault)-Number(i.isDefault);const s=i.id.toLocaleLowerCase(),a=r.id.toLocaleLowerCase(),o=(c,u)=>c===n?0:c.startsWith(n)?1:u.toLocaleLowerCase().startsWith(n)?2:3;return o(s,i.displayName)-o(a,r.displayName)}).slice(0,12)}function Rgt(){return nN.map(e=>({label:e.usage,value:e.description}))}function Igt(e,t){return e.map(n=>{const i=n.displayName.trim(),r=i&&i!==n.id?`${i} · ${n.id}`:n.id;return{label:n.id===t?"当前模型":"可用模型",value:n.description?`${r} — ${n.description}`:r,code:!1}})}function Pgt(e){const t=[{label:"Thread",value:e.threadId,code:!0},{label:"工作空间",value:e.cwd||"未设置",code:!!e.cwd}];return e.model&&t.push({label:"模型",value:e.model,code:!0}),t.push({label:"状态",value:e.busy?"运行中":"空闲"}),e.threadTotal&&t.push({label:"累计 Token",value:e.threadTotal.totalTokens.toLocaleString()}),e.modelContextWindow!==void 0&&t.push({label:"上下文窗口",value:e.modelContextWindow.toLocaleString()}),t}function rme(e){return e.messages.map(t=>{var i,r;const n=[];return t.role==="user"&&((i=t.skillNames)!=null&&i.length)&&n.push({kind:"invocation",value:{skills:t.skillNames.map(s=>({name:s,description:""}))}}),t.role==="user"&&((r=t.images)!=null&&r.length)&&n.push({kind:"attachment",files:t.images.map((s,a)=>({id:`${t.id}-image-${a}`,mimeType:s.mimeType,data:s.data,name:s.alt||s.name||"图片"}))}),t.content&&n.push({kind:"text",text:t.content}),{role:t.role,blocks:n,meta:{localId:t.id,ts:t.timestamp/1e3}}})}function Mgt({appName:e,value:t,onChange:n,onSubmit:i,onStop:r,disabled:s,busy:a,attachments:o,onAddFiles:c,onRemoveAttachment:u,actions:d,models:f,modelsLoading:h,modelsLoaded:p,currentModel:g,onRequestModels:b,skills:y,skillsLoading:O,skillsLoaded:v,selectedSkills:x,onRequestSkills:w,onSelectedSkillsChange:E}){const S=m.useRef(null),k=m.useRef(null),T=m.useRef(null),A=m.useRef(null),[N,C]=m.useState(!1),[M,L]=m.useState(0),[P,Q]=m.useState(!1);m.useLayoutEffect(()=>{const J=S.current;J&&(J.style.height="auto",J.style.height=`${Math.min(J.scrollHeight,200)}px`)},[t]);const j=m.useMemo(()=>{if(!t.startsWith("/")||t.includes(` -`))return;const J=t.slice(1),ie=J.search(/\s/),ue=(ie<0?J:J.slice(0,ie)).toLocaleLowerCase(),ye=ie<0?"":J.slice(ie).trim();if(!(ie>=0&&ue!=="model"))return{command:ue,argument:ye,modelMode:ie>=0}},[t]),$=m.useMemo(()=>{const J=/(^|\s)\$([^\s$]*)$/.exec(t);if(J)return{query:J[2],start:t.length-J[2].length-1,end:t.length}},[t]),U=m.useMemo(()=>{if($){const J=$.query.toLocaleLowerCase();return y.filter(ie=>!x.some(ue=>ue.id===ie.id||ue.name===ie.name)).filter(ie=>`${ie.name} ${ie.description}`.toLocaleLowerCase().includes(J)).slice(0,12).map(ie=>({kind:"skill",skill:ie}))}return j!=null&&j.modelMode?jgt(f,j.argument).map(J=>({kind:"model",model:J})):j?Cgt(j.command).map(J=>({kind:"command",command:J})):[]},[$,f,x,y,j]),B=!P&&!!($||j);m.useEffect(()=>{L(0)},[t]),m.useEffect(()=>{j!=null&&j.modelMode&&!p&&!h&&b()},[p,h,b,j==null?void 0:j.modelMode]),m.useEffect(()=>{$&&!v&&!O&&w()},[$,w,v,O]);const I=o.some(J=>J.status!=="ready"),X=a&&!!r,q=!s&&!a&&!I&&(t.trim().length>0||o.length>0);function D(J){Q(!1),C(!1),n(J)}function H(J){if(J.kind==="skill"){if(!$)return;const ie=t.slice(0,$.start)+t.slice($.end);E([...x,J.skill]),D(ie),Q(!0),requestAnimationFrame(()=>{var ue,ye;(ue=S.current)==null||ue.focus(),(ye=S.current)==null||ye.setSelectionRange($.start,$.start)});return}if(J.kind==="model"){D(`/model ${J.model.id}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}if(J.command.name==="model"){D("/model "),b(),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}if(J.command.name==="skill"||J.command.name==="skills"){D(`/${J.command.name}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}D(`/${J.command.name}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()})}function re(J){var ie;C(!1),(ie=J.current)==null||ie.click()}function fe(J){const ie=J.target.files?Array.from(J.target.files):[];ie.length&&c(ie),J.target.value=""}const Ae=$?"可用 Skills":j!=null&&j.modelMode?"选择模型":"Codex 快捷命令";return l.jsxs("div",{className:"composer sandbox-codex-composer",children:[o.length>0?l.jsx(xA,{appName:e,compact:!0,items:o,onRemove:u}):null,l.jsxs("div",{className:"composer-box",children:[B?l.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":Ae,children:[l.jsxs("div",{className:"composer-command-head",children:[l.jsx(cgt,{}),l.jsx("span",{children:Ae}),j!=null&&j.modelMode&&g?l.jsxs("small",{children:["当前:",g]}):null,l.jsx("kbd",{children:$?"$":"/"})]}),$&&O?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Pc,{className:"spin"})," 正在发现当前工作区的 Skills…"]}):j!=null&&j.modelMode&&h?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Pc,{className:"spin"})," 正在读取模型…"]}):U.length===0?l.jsx("div",{className:"composer-command-empty",children:$?"当前工作区没有匹配的 Skill":j!=null&&j.modelMode?"没有匹配模型,也可以直接输入模型 ID":"没有匹配的快捷命令"}):l.jsx("div",{className:"composer-command-list",children:U.map((J,ie)=>{const ue=J.kind==="command"?`command:${J.command.name}`:J.kind==="model"?`model:${J.model.id}`:`skill:${J.skill.id}`,ye=J.kind==="command"?J.command.usage:J.kind==="model"?J.model.displayName:`$${J.skill.name}`,Se=J.kind==="command"?J.command.description:J.kind==="model"?J.model.description||J.model.id:J.skill.description||"加载并执行该 Skill";return l.jsxs("button",{type:"button",role:"option","aria-selected":ie===M,className:`composer-command-item${ie===M?" is-active":""}`,onMouseDown:Re=>{Re.preventDefault(),H(J)},onMouseEnter:()=>L(ie),children:[l.jsx("span",{className:`composer-command-icon composer-command-icon--${J.kind}`,"aria-hidden":"true",children:J.kind==="command"?"/":J.kind==="model"?"◇":"$"}),l.jsxs("span",{className:"composer-command-copy",children:[l.jsx("strong",{children:ye}),l.jsx("span",{children:Se})]}),ie===M?l.jsx("kbd",{children:"↵"}):null]},ue)})})]}):null,l.jsxs("div",{className:"composer-left-controls",children:[l.jsxs("div",{className:"composer-menu-wrap",children:[l.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:s,onClick:()=>C(J=>!J),children:l.jsx(igt,{className:"icon"})}),N?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>C(!1)}),l.jsxs("div",{className:"composer-menu",role:"menu",children:[l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(k),children:[l.jsx(agt,{className:"icon"}),"上传图片"]}),l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(T),children:[l.jsx(ogt,{className:"icon"}),"上传文档或 PDF"]}),l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(A),children:[l.jsx(lgt,{className:"icon"}),"上传视频"]}),l.jsx("div",{className:"composer-menu-separator",role:"separator"}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{C(!1),d.onOpenTerminal()},children:[l.jsx(nme,{className:"icon"}),"进入终端"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{C(!1),d.onOpenBrowser()},children:[l.jsx(ime,{className:"icon"}),"查看浏览器"]})]})]}):null]}),l.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:"Codex 权限","aria-label":"Codex 权限",disabled:d.settingsBusy||a,onClick:d.onOpenPermissions,children:l.jsx(AQ,{})}),l.jsx("button",{type:"button",className:`comp-icon sandbox-composer-control${d.workspaceLocked?" is-locked":""}`,title:d.workspaceLocked?"对话已开始,工作空间已锁定":"选择工作空间","aria-label":"Codex 工作空间",disabled:d.settingsBusy||a,onClick:d.onOpenWorkspace,children:l.jsx(_E,{})}),d.endpointCopyEnabled&&d.onCopyEndpoint?l.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint","aria-label":d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint",disabled:d.endpointCopyState==="copying",onClick:d.onCopyEndpoint,children:d.endpointCopyState==="copying"?l.jsx(Pc,{className:"spin"}):d.endpointCopyState==="copied"?l.jsx(hgt,{}):l.jsx(fgt,{})}):null]}),l.jsxs("div",{className:"composer-input-stack sandbox-composer-input",children:[x.length>0?l.jsx(yA,{skillPrefix:"$",value:{skills:x.map(({name:J,description:ie})=>({name:J,description:ie}))},onRemoveSkill:J=>E(x.filter(ie=>ie.name!==J))}):null,l.jsx("textarea",{ref:S,className:"comp-input scroll",rows:1,value:t,disabled:s,placeholder:"向 AgentKit 沙箱发送消息,输入 / 查看命令,输入 $ 调用 Skill…","aria-expanded":B,onChange:J=>D(J.target.value),onBlur:()=>window.setTimeout(()=>Q(!0),0),onKeyDown:J=>{if(!OQ(J.nativeEvent)){if(B){if((J.key==="ArrowDown"||J.key==="Tab"&&!J.shiftKey)&&U.length>0){J.preventDefault(),L(ie=>(ie+1)%U.length);return}if((J.key==="ArrowUp"||J.key==="Tab"&&J.shiftKey)&&U.length>0){J.preventDefault(),L(ie=>(ie-1+U.length)%U.length);return}if(J.key==="Enter"&&!J.shiftKey&&U[M]){J.preventDefault(),H(U[M]);return}if(J.key==="Escape"){J.preventDefault(),Q(!0);return}}if(J.key==="Backspace"&&!t&&J.currentTarget.selectionStart===0&&x.length>0){J.preventDefault(),E(x.slice(0,-1));return}J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),q&&i(t))}}})]}),l.jsx("button",{type:"button",className:"comp-send",disabled:X?!1:!q,onClick:X?r:()=>i(t),"aria-label":X?"停止生成":"发送",title:X?"停止生成":void 0,children:X?l.jsx(sgt,{className:"icon"}):a?l.jsx(Pc,{className:"icon spin"}):l.jsx(rgt,{className:"icon"})})]}),l.jsx("input",{ref:k,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:fe}),l.jsx("input",{ref:T,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:fe}),l.jsx("input",{ref:A,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:fe})]})}const Lgt="_Badge_1viyg_1",Dgt={Badge:Lgt},$gt=({children:e,className:t,variant:n="soft",color:i="secondary",size:r="sm",pill:s,...a})=>l.jsx("div",{className:Ps(Dgt.Badge,t),"data-color":i,"data-size":r,"data-pill":s?"":void 0,"data-variant":n,...a,children:j$(e)});function Qgt(e){return e.trim().replace(/\/+$/,"")||window.location.origin}function Bgt(e){return["使用 AgentKit Studio Plugin 端云接力当前会话、项目和任务。请直接执行,不要让我手动打开终端。",`Studio:${Qgt(e.studioUrl)}`,`配对码:${e.pairingCode}`].join(` -`)}function sme(){return["codex plugin marketplace add volcengine/veadk-python","--sparse .agents/plugins","--sparse plugins/agentkit-studio","&& codex plugin add agentkit-studio@veadk-python"].join(" ")}function Ugt(){return["请安装 AgentKit Studio Plugin。请直接执行以下安装命令,不要让我手动打开终端。",`安装命令:${sme()}`].join(` -`)}function eY(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function tY(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"8",y:"8",width:"11",height:"11",rx:"2"}),l.jsx("path",{d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})]})}function RR(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.25 4.25L19 7"})})}function nY(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M19 8a8 8 0 1 0 .35 7"}),l.jsx("path",{d:"M19 4v4h-4"})]})}function zgt(e,t){const n=Math.max(0,Math.ceil((Date.parse(e)-t)/1e3)),i=Math.floor(n/3600),r=Math.floor(n%3600/60),s=n%60;return[i,r,s].map(a=>String(a).padStart(2,"0")).join(":")}const Fgt=[{id:"request",label:"等待端侧请求"},{id:"session",label:"创建云端 Session"},{id:"restore",label:"恢复项目"},{id:"continue",label:"发送续跑任务"}];function Vgt(e){switch(e.state){case"issued":return 0;case"creating":return 1;case"session-created":return 2;case"continuing":return 3;case"running":return 4;case"completed":return 4;case"failed":return e.failedStage==="creating-session"?1:e.failedStage==="uploading-project"||e.failedStage==="restoring-project"?2:3}}function Xgt(e,t){const n=Vgt(e);return e.state==="failed"&&t===n?"failed":tUgt(),[]),L=m.useMemo(()=>sme(),[]),P=m.useMemo(()=>h?Bgt(h):"",[h]);if(m.useEffect(()=>{if(!e)return;p(null),b(null),f("conversation"),A(null),C(""),k(!1),E(Date.now());const X=new AbortController,q=++o.current;return x(!0),Kt.createCodexProjectHandoffPairing({signal:X.signal}).then(D=>{o.current===q&&(p(D),b({state:"issued",expireAt:D.expireAt}))}).catch(D=>{(D==null?void 0:D.name)!=="AbortError"&&o.current===q&&A({message:D instanceof Error?D.message:String(D),retryPairing:!0})}).finally(()=>{o.current===q&&x(!1)}),()=>{X.abort()}},[y,e]),m.useEffect(()=>{if(!e||!h)return;E(Date.now());const X=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval(X)},[e,h]),m.useEffect(()=>{if(!e||!h)return;let X=!1,q;const D=new AbortController,H=async()=>{if(!(X||Date.now()>=Date.parse(h.expireAt))){try{const re=await Kt.getCodexProjectHandoffStatus(h.pairingCode,{signal:D.signal});if(X||(b(re),re.state==="completed"||re.state==="failed"))return;q=window.setTimeout(()=>void H(),1500);return}catch(re){if((re==null?void 0:re.name)==="AbortError"||X)return;A({message:re instanceof Error?re.message:String(re),retryPairing:!1})}q=window.setTimeout(()=>void H(),1500)}};return H(),()=>{X=!0,D.abort(),q!==void 0&&window.clearTimeout(q)}},[e,h]),m.useEffect(()=>{(g==null?void 0:g.state)!=="running"&&(g==null?void 0:g.state)!=="completed"||!h||u.current===h.pairingCode||(u.current=h.pairingCode,n())},[g==null?void 0:g.state,n,h]),m.useEffect(()=>()=>{c.current!==void 0&&window.clearTimeout(c.current)},[]),m.useEffect(()=>{if(!e)return;const X=document.body.style.overflow;document.body.style.overflow="hidden";const q=window.requestAnimationFrame(()=>{var H;return(H=s.current)==null?void 0:H.focus()}),D=H=>{var J;if(H.key==="Escape"){H.preventDefault(),a.current();return}if(H.key!=="Tab")return;const re=(J=r.current)==null?void 0:J.querySelectorAll('button:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])');if(!(re!=null&&re.length))return;const fe=re[0],Ae=re[re.length-1];H.shiftKey&&document.activeElement===fe?(H.preventDefault(),Ae.focus()):!H.shiftKey&&document.activeElement===Ae&&(H.preventDefault(),fe.focus())};return window.addEventListener("keydown",D),()=>{window.cancelAnimationFrame(q),document.body.style.overflow=X,window.removeEventListener("keydown",D)}},[e]),!e)return null;async function Q(X,q){var D;if(!(!X||N)){A(null),C(q);try{if(!((D=navigator.clipboard)!=null&&D.writeText))throw new Error("当前浏览器不支持写入剪贴板。");await navigator.clipboard.writeText(X),c.current!==void 0&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{C(H=>H===q?"":H),c.current=void 0},1400)}catch(H){C(""),A({message:H instanceof Error?H.message:String(H),retryPairing:!1})}}}async function j(){const X=g==null?void 0:g.sessionId;if(!(!X||S)){A(null),k(!0);try{await i(X)}catch(q){A({message:q instanceof Error?q.message:String(q),retryPairing:!1}),k(!1)}}}function $(X){var q;f(X),(q=document.getElementById(`sandbox-project-upload-install-${X}-tab`))==null||q.focus()}function U(X){const q=["conversation","terminal"],D=q.indexOf(d);let H=null;X.key==="ArrowRight"&&(H=(D+1)%q.length),X.key==="ArrowLeft"&&(H=(D-1+q.length)%q.length),X.key==="Home"&&(H=0),X.key==="End"&&(H=q.length-1),H!==null&&(X.preventDefault(),$(q[H]))}const B=h?zgt(h.expireAt,w):"00:00:00",I=h?w>=Date.parse(h.expireAt):!1;return zi.createPortal(l.jsx("div",{className:"sandbox-project-upload-backdrop",onMouseDown:X=>{X.target===X.currentTarget&&t()},children:l.jsxs("section",{ref:r,className:"sandbox-project-upload-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-project-upload-title","aria-describedby":"sandbox-project-upload-description",children:[l.jsxs("header",{className:"sandbox-project-upload-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"sandbox-project-upload-title-row",children:[l.jsx("h2",{id:"sandbox-project-upload-title",children:"接力到云端继续执行"}),l.jsx($gt,{className:"sandbox-project-upload-beta",color:"discovery",size:"sm",pill:!0,children:"Beta"})]}),l.jsx("p",{id:"sandbox-project-upload-description",children:"按顺序复制两段提示词,Codex 会通过插件将您的本地任务接力到云端"})]}),l.jsx("button",{ref:s,type:"button",className:"sandbox-project-upload-close",onClick:t,"aria-label":"关闭本地迁移引导",children:l.jsx(eY,{})})]}),l.jsxs("div",{className:"sandbox-project-upload-body",children:[T?l.jsxs("div",{className:"sandbox-project-upload-error",role:"alert",children:[l.jsx("span",{children:T.message}),T.retryPairing?l.jsxs("button",{type:"button",onClick:()=>O(X=>X+1),children:[l.jsx(nY,{}),"重试"]}):null]}):null,l.jsxs("section",{className:"sandbox-project-upload-stage",children:[l.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[l.jsx("span",{className:"sandbox-project-upload-stage-number",children:"1"}),l.jsxs("div",{children:[l.jsx("h3",{children:"安装插件"}),l.jsx("p",{children:"首次使用时,请选择一种安装方式。"})]}),l.jsxs("button",{type:"button",onClick:()=>void Q(d==="conversation"?M:L,d==="conversation"?"install-conversation":"install-terminal"),disabled:N!=="",children:[N===`install-${d}`?l.jsx(RR,{}):l.jsx(tY,{}),N===`install-${d}`?"已复制":d==="conversation"?"复制安装提示词":"复制安装命令"]})]}),l.jsxs("div",{className:`sandbox-project-upload-install-tabs is-${d}`,role:"tablist","aria-label":"插件安装方式",children:[l.jsx("span",{"aria-hidden":"true"}),l.jsx("button",{id:"sandbox-project-upload-install-conversation-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="conversation",tabIndex:d==="conversation"?0:-1,onClick:()=>f("conversation"),onKeyDown:U,children:"与 Codex 对话安装"}),l.jsx("button",{id:"sandbox-project-upload-install-terminal-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="terminal",tabIndex:d==="terminal"?0:-1,onClick:()=>f("terminal"),onKeyDown:U,children:"从终端安装"})]}),l.jsx("div",{id:"sandbox-project-upload-install-panel",className:`sandbox-project-upload-prompt${d==="terminal"?" is-command":""}`,role:"tabpanel","aria-labelledby":`sandbox-project-upload-install-${d}-tab`,children:l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:d==="conversation"?M:L})})})]}),l.jsxs("section",{className:"sandbox-project-upload-stage",children:[l.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[l.jsx("span",{className:"sandbox-project-upload-stage-number",children:"2"}),l.jsxs("div",{children:[l.jsx("h3",{children:"任务接力"}),l.jsx("p",{children:"插件安装完成后复制,Codex 会迁移当前项目并继续执行任务。"})]}),l.jsxs("button",{type:"button",onClick:()=>void Q(P,"handoff"),disabled:!P||v||N!=="",children:[N==="handoff"?l.jsx(RR,{}):l.jsx(tY,{}),N==="handoff"?"已复制":"复制接力提示词"]})]}),l.jsxs("div",{className:"sandbox-project-upload-pairing-notice",role:"status",children:[l.jsx("span",{children:v?"正在生成新的配对码":I?"配对码已过期":l.jsxs(l.Fragment,{children:["配对码有效期剩余 ",l.jsx("time",{children:B})]})}),l.jsxs("button",{type:"button",disabled:v,onClick:()=>O(X=>X+1),children:[l.jsx(nY,{}),v?"刷新中":"刷新配对码"]})]}),l.jsx("div",{className:"sandbox-project-upload-prompt",children:v?l.jsxs("div",{className:"sandbox-project-upload-loading",role:"status",children:[l.jsx("i",{"aria-hidden":"true"}),"正在生成配对码"]}):P?l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:P})}):l.jsx("div",{className:"sandbox-project-upload-loading",children:"配对码尚未生成。"})}),h&&g?l.jsxs("section",{className:"sandbox-project-upload-progress","aria-live":"polite","aria-label":"端云接力状态",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("span",{children:"接力状态"}),g.state!=="issued"?l.jsxs("p",{children:["已收到",g.agentName?`“${g.agentName}”`:g.projectName?`“${g.projectName}”`:"当前项目","的端云接力请求"]}):l.jsx("p",{children:"复制接力提示词后,Codex 的请求会显示在这里。"})]}),l.jsx("strong",{"data-state":g.state,children:qgt(g)})]}),l.jsx("ol",{children:Fgt.map((X,q)=>{const D=Xgt(g,q);return l.jsxs("li",{"data-state":D,children:[l.jsxs("span",{className:"sandbox-project-upload-progress-marker",children:[D==="done"?l.jsx(RR,{}):null,D==="failed"?l.jsx(eY,{}):null]}),l.jsx("span",{children:X.label})]},X.id)})}),g.state==="failed"&&g.error?l.jsx("p",{className:"sandbox-project-upload-progress-error",role:"alert",children:g.error}):null]}):null]})]}),l.jsxs("footer",{className:"sandbox-project-upload-actions",children:[l.jsx("button",{type:"button",onClick:t,children:"关闭"}),((g==null?void 0:g.state)==="running"||(g==null?void 0:g.state)==="completed")&&g.sessionId?l.jsx("button",{type:"button",className:"is-primary",disabled:S,onClick:()=>void j(),children:S?"正在进入":"进入 Codex"}):null]})]})}),document.body)}function Ygt({session:e,conversationBusy:t,onInputChange:n,onSessionPatch:i,onSnapshot:r,onActivity:s,onError:a}){const o=m.useRef((e==null?void 0:e.id)??""),c=m.useRef(0);o.current=(e==null?void 0:e.id)??"";const[u,d]=m.useState(!1),[f,h]=m.useState([]),[p,g]=m.useState(!1),[b,y]=m.useState(!1),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(!1),[k,T]=m.useState([]),[A,N]=m.useState(!1),[C,M]=m.useState([]),[L,P]=m.useState(!1),[Q,j]=m.useState(""),[$,U]=m.useState(""),[B,I]=m.useState("");m.useEffect(()=>{c.current+=1,d(!1),h([]),g(!1),y(!1),v([]),w(!1),S(!1),T([]),N(!1),M([]),P(!1),j(""),U(""),I("")},[e==null?void 0:e.id]);const X=m.useCallback(async()=>{const Ee=o.current;if(!Ee)return[];g(!0);try{const me=await Kt.listModels(Ee);return o.current===Ee&&(h(me),y(!0)),me}catch(me){return o.current===Ee&&(y(!0),a(me instanceof Error?me.message:String(me))),[]}finally{o.current===Ee&&g(!1)}},[a]),q=m.useCallback(async()=>{const Ee=o.current;if(!Ee)return[];w(!0);try{const me=await Kt.listSkills(Ee);return o.current===Ee&&(v(me),S(!0)),me}catch(me){return o.current===Ee&&(S(!0),a(me instanceof Error?me.message:String(me))),[]}finally{o.current===Ee&&w(!1)}},[a]),D=m.useCallback(async(Ee="",me=!1)=>{const oe=o.current;if(!oe)return;const Ne=++c.current;P(!0),j("");try{const Oe=await Kt.listThreads(oe,Ee?{cursor:Ee}:{});o.current===oe&&c.current===Ne&&(M(Ve=>{if(!me)return Oe.threads;const We=new Map(Ve.map(De=>[De.id,De]));for(const De of Oe.threads)We.set(De.id,De);return[...We.values()]}),U(Oe.nextCursor??""))}catch(Oe){o.current===oe&&c.current===Ne&&j(Oe instanceof Error?Oe.message:String(Oe))}finally{o.current===oe&&c.current===Ne&&P(!1)}},[]),H=m.useCallback(()=>D("",!1),[D]),re=m.useCallback(async()=>{!$||L||await D($,!0)},[D,L,$]),fe=m.useCallback(async()=>{N(!0),await H()},[H]);m.useEffect(()=>{e!=null&&e.id&&H()},[H,e==null?void 0:e.id]);function Ae(Ee){r(Ee),M(me=>[Ee.thread,...me.filter(oe=>oe.id!==Ee.thread.id)]),T([]),v([]),S(!1),N(!1)}async function J(Ee){const me=await Kt.newThread(Ee);o.current===Ee&&(Ae(me),s("已新建 Codex 对话",[{label:"Thread",value:me.threadId,code:!0}]))}async function ie(){const Ee=o.current;if(!(!Ee||u||t)){d(!0),j(""),a("");try{await J(Ee)}catch(me){if(o.current===Ee){const oe=me instanceof Error?me.message:String(me);j(oe),a(oe)}}finally{o.current===Ee&&d(!1)}}}async function ue(Ee){const me=o.current;if(!(!me||u||t)){if(Ee===(e==null?void 0:e.threadId)){N(!1);return}d(!0),a("");try{const oe=await Kt.resumeThread(me,Ee);if(o.current!==me)return;Ae(oe),s("已恢复 Codex 对话",[{label:"Thread",value:oe.threadId,code:!0}])}catch(oe){o.current===me&&a(oe instanceof Error?oe.message:String(oe))}finally{o.current===me&&d(!1)}}}async function ye(Ee){const me=o.current;if(!me||u||t)return!1;c.current+=1,P(!1),d(!0),I(Ee),j(""),a("");try{const oe=await Kt.deleteThread(me,Ee);return o.current!==me?!1:(oe.snapshot&&Ae(oe.snapshot),M(Ne=>Ne.filter(Oe=>Oe.id!==Ee)),s("已删除 Codex 历史会话",[{label:"Thread",value:Ee,code:!0}]),!0)}catch(oe){if(o.current===me){const Ne=oe instanceof Error?oe.message:String(oe);j(Ne),a(Ne)}return!1}finally{o.current===me&&(d(!1),I(""))}}async function Se(Ee){const me=e,oe=Ee.trim();if(!oe.startsWith("/"))return!1;if(!me||t||u)return!0;const Ne=Ngt(oe),Oe=Ne&&nN.find(Ve=>Ve.name===Ne.name);if(!Ne||!Oe)return a(`未知快捷命令:${oe.split(/\s/,1)[0]}。输入 /help 查看可用命令。`),!0;if(a(""),T([]),Oe.name==="model"&&!Ne.argument)return n("/model "),b||await X(),!0;if(Oe.name==="skill"||Oe.name==="skills")return n("$"),E||(await q()).length===0&&n(""),!0;if(Oe.name==="resume"&&!Ne.argument)return n(""),await fe(),!0;n(""),d(!0);try{if(Oe.name==="model"){const Ve=await Kt.setModel(me.id,Ne.argument);if(o.current!==me.id)return!0;i({model:Ve}),s("已切换 Codex 模型",[{label:"模型",value:Ve,code:!0}])}else if(Oe.name==="models"){const Ve=b?f:await X();if(o.current!==me.id)return!0;s(Ve.length>0?"Codex 可用模型":"当前没有可用模型",Igt(Ve,me.model))}else if(Oe.name==="new"||Oe.name==="clear")await J(me.id);else if(Oe.name==="resume"){const Ve=await Kt.resumeThread(me.id,Ne.argument);if(o.current!==me.id)return!0;Ae(Ve),s("已恢复 Codex 对话",[{label:"Thread",value:Ve.threadId,code:!0}])}else if(Oe.name==="fork"){const Ve=await Kt.forkThread(me.id);if(o.current!==me.id)return!0;Ae(Ve),s("已分叉 Codex 对话",[{label:"Thread",value:Ve.threadId,code:!0}])}else if(Oe.name==="compact"){if(await Kt.compactThread(me.id),o.current!==me.id)return!0;s("已开始压缩当前 Codex 对话",[{label:"Thread",value:me.threadId,code:!0}])}else if(Oe.name==="archive"){const Ve=me.threadId,We=await Kt.archiveThread(me.id,Ve);if(o.current!==me.id)return!0;We.snapshot&&Ae(We.snapshot),M(De=>De.filter(mt=>mt.id!==Ve)),s("已归档 Codex 对话",[{label:"Thread",value:Ve,code:!0}])}else if(Oe.name==="status"){const Ve=await Kt.getStatus(me.id);if(o.current!==me.id)return!0;i(Ve),s("Codex 当前状态",Pgt(Ve))}else Oe.name==="help"&&s("Sandbox 支持的 Codex 快捷命令",Rgt())}catch(Ve){o.current===me.id&&(n(oe),a(Ve instanceof Error?Ve.message:String(Ve)))}finally{o.current===me.id&&d(!1)}return!0}function Re(){v([]),S(!1),T([])}return{commandBusy:u,models:f,modelsLoading:p,modelsLoaded:b,loadModels:X,skills:O,skillsLoading:x,skillsLoaded:E,loadSkills:q,selectedSkills:k,setSelectedSkills:T,invalidateSkills:Re,threadsOpen:A,threads:C,threadsLoading:L,threadsError:Q,threadsHasMore:!!$,threadActionId:B,openThreads:fe,refreshThreads:H,loadMoreThreads:re,closeThreads:()=>{u||(N(!1),j(""))},newThread:ie,resumeThread:ue,deleteThread:ye,executeSlash:Se}}const Ggt={volcengine:"火山引擎 AgentKit 提供企业级 Agent 解决方案",byteplus:"BytePlus AgentKit 提供企业级 Agent 解决方案"},Wgt={volcengine:"https://docs.volcengine.com/docs/86681/1925174?lang=zh",byteplus:"https://docs.byteplus.com/en/docs/legal"};function Zgt(e){return e.toLowerCase()==="github"?l.jsx(Kwe,{className:"icon"}):l.jsx(eSe,{className:"icon"})}function Kgt({branding:e,cloudProvider:t,onUsername:n}){const[i,r]=m.useState(null),[s,a]=m.useState(""),[o,c]=m.useState(0),[u,d]=m.useState(""),f=m.useRef(null);m.useEffect(()=>{let y=!0;return r(null),a(""),bJ().then(O=>{y&&r(O)}).catch(O=>{y&&a(O instanceof Error?O.message:String(O))}),()=>{y=!1}},[o]);const h=i!==null&&i.length===0;m.useEffect(()=>{var y;h&&((y=f.current)==null||y.focus())},[h]);const p=bSe.test(u),g=t==="byteplus"?i$:n$,b=()=>{p&&n(u)};return l.jsxs("div",{className:"login",children:[l.jsx("header",{className:"login-top",children:l.jsxs("span",{className:"login-brand",children:[l.jsx("img",{className:"login-brand-logo",src:e.logoUrl||g,width:20,height:20,alt:"","aria-hidden":!0}),e.title]})}),l.jsx("main",{className:"login-main",children:l.jsxs("div",{className:"login-card",children:[l.jsx(oi,{as:"h1",className:"login-title",duration:4.8,spread:22,children:e.title}),s?l.jsxs("div",{className:"login-provider-error",role:"alert",children:[l.jsx("p",{children:s}),l.jsx("button",{type:"button",onClick:()=>c(y=>y+1),children:"重试"})]}):i===null?null:i.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"登录以继续使用"}),l.jsx("div",{className:"login-providers",children:i.map(y=>l.jsxs("button",{className:"login-btn",onClick:()=>ySe(y.loginUrl),children:[Zgt(y.id),l.jsxs("span",{children:["使用 ",y.label," 登录"]})]},y.id))})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"输入一个用户名即可开始"}),l.jsxs("form",{className:"login-name",onSubmit:y=>{y.preventDefault(),b()},children:[l.jsx("input",{ref:f,className:"login-name-input",value:u,onChange:y=>d(y.target.value),placeholder:"用户名(字母 + 数字,最多 16 位)",maxLength:16}),l.jsx("button",{type:"submit",className:"login-name-go",disabled:!p,"aria-label":"进入",children:l.jsx(ay,{className:"icon"})})]}),l.jsx("p",{className:"login-hint","aria-live":"polite",children:u&&!p?"只能包含大小写字母和数字,最多 16 位。":""})]}),l.jsx("p",{className:"login-powered",children:Ggt[t]}),l.jsxs("p",{className:"login-legal",children:["继续即表示你已阅读并同意 AgentKit"," ",l.jsx("a",{href:Wgt[t],target:"_blank",rel:"noreferrer",children:"产品和服务条款"})]})]})}),l.jsx("footer",{className:"login-footer",children:"© 2026 VeADK. All rights reserved."})]})}function Jgt({open:e,checking:t,error:n,onLogin:i}){const r=m.useRef(null);return m.useEffect(()=>{var a;if(!e)return;const s=document.body.style.overflow;return document.body.style.overflow="hidden",(a=r.current)==null||a.focus(),()=>{document.body.style.overflow=s}},[e]),e?zi.createPortal(l.jsx("div",{className:"auth-expired-backdrop",children:l.jsxs("section",{className:"auth-expired-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"auth-expired-title","aria-describedby":"auth-expired-description",children:[l.jsx("div",{className:"auth-expired-mark","aria-hidden":"true",children:l.jsx(cJ,{})}),l.jsxs("div",{className:"auth-expired-copy",children:[l.jsx("h2",{id:"auth-expired-title",children:"登录状态已过期"}),l.jsx("p",{id:"auth-expired-description",children:"当前编辑内容会保留。重新登录后,刚才的操作将自动继续。"}),n&&l.jsx("p",{className:"auth-expired-error",role:"alert",children:n})]}),l.jsx("footer",{className:"auth-expired-actions",children:l.jsx("button",{ref:r,type:"button",onClick:i,disabled:t,children:t?"等待登录完成…":"重新登录"})})]})}),document.body):null}const e0t=[{value:"slow",label:"执行速度慢"},{value:"crash",label:"运行崩溃"},{value:"incorrect",label:"结果不准确"},{value:"tool_error",label:"工具调用失败"},{value:"other",label:"其他问题"}];function t0t(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function n0t(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function i0t({onClose:e,onSubmit:t}){const n=m.useId(),i=m.useId(),r=m.useRef(null),s=m.useRef(null),a=m.useRef(!1),o=m.useRef(e),[c,u]=m.useState(()=>new Set),[d,f]=m.useState(""),[h,p]=m.useState(!1),[g,b]=m.useState(""),[y,O]=m.useState(!1);a.current=h,o.current=e,m.useEffect(()=>{var T;const E=document.body.style.overflow,S=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(T=s.current)==null||T.focus();const k=A=>{var L;if(A.key==="Escape"&&!a.current){A.preventDefault(),o.current();return}if(A.key!=="Tab")return;const N=Array.from(((L=r.current)==null?void 0:L.querySelectorAll("button:not(:disabled), textarea:not(:disabled)"))??[]);if(N.length===0)return;const C=N[0],M=N[N.length-1];A.shiftKey&&document.activeElement===C?(A.preventDefault(),M.focus()):!A.shiftKey&&document.activeElement===M&&(A.preventDefault(),C.focus())};return window.addEventListener("keydown",k),()=>{document.body.style.overflow=E,window.removeEventListener("keydown",k),S!=null&&S.isConnected&&S.focus()}},[]);const v=E=>{u(S=>{const k=new Set(S);return k.has(E)?k.delete(E):k.add(E),k})},x=async()=>{if(!(h||y)){p(!0),b("");try{await t({issues:[...c],description:d.trim()}),O(!0)}catch(E){b(E instanceof Error?E.message:String(E))}finally{p(!1)}}},w=c.size>0||d.trim().length>0;return zi.createPortal(l.jsx("div",{className:"issue-feedback-backdrop",onMouseDown:E=>{E.target===E.currentTarget&&!h&&e()},children:l.jsxs("section",{ref:r,className:"issue-feedback-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":y?`${i}-success`:i,"aria-busy":h||void 0,children:[l.jsxs("header",{className:"issue-feedback-head",children:[l.jsx("h2",{id:n,children:"问题反馈"}),l.jsx("button",{type:"button",className:"issue-feedback-close",onClick:e,disabled:h,"aria-label":"关闭问题反馈",children:l.jsx(t0t,{})})]}),y?l.jsxs("div",{className:"issue-feedback-success",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"issue-feedback-success-mark","aria-hidden":"true",children:l.jsx(n0t,{})}),l.jsxs("div",{children:[l.jsx("h3",{children:"上报成功,感谢您的反馈"}),l.jsx("p",{id:`${i}-success`,children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):l.jsxs("div",{className:"issue-feedback-body",children:[l.jsx("p",{id:i,className:"issue-feedback-intro",children:"请选择遇到的问题,也可以补充具体表现。"}),l.jsx("p",{className:"issue-feedback-privacy",role:"alert",children:"您的对话数据将会上报到 AgentKit 团队,请注意隐私保护。"}),l.jsx("div",{className:"issue-feedback-chips","aria-label":"常见问题",children:e0t.map(E=>l.jsx("button",{type:"button",className:"issue-feedback-chip","aria-pressed":c.has(E.value),onClick:()=>v(E.value),disabled:h,children:E.label},E.value))}),l.jsxs("label",{className:"issue-feedback-field",children:[l.jsx("span",{children:"问题描述"}),l.jsx("textarea",{ref:s,value:d,onChange:E=>f(E.target.value),placeholder:"请描述问题发生时的表现(选填)",maxLength:4e3,rows:5,disabled:h})]}),g&&l.jsx("p",{className:"issue-feedback-error",role:"alert",children:g})]}),l.jsx("footer",{className:"issue-feedback-actions",children:y?l.jsx("button",{type:"button",className:"is-primary",onClick:e,children:"完成"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:e,disabled:h,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:()=>void x(),disabled:!w||h,children:h?"正在上报…":"提交反馈"})]})})]})}),document.body)}function r0t(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),t&&(i.href=t),r.href=e,r.href}const s0t=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Tf(e){const t=[];for(let n=0,i=e.length;nno||e.height>no)&&(e.width>no&&e.height>no?e.width>e.height?(e.height*=no/e.width,e.width=no):(e.width*=no/e.height,e.height=no):e.width>no?(e.height*=no/e.width,e.width=no):(e.width*=no/e.height,e.height=no))}function u0t(e,t={}){return e.toBlob?new Promise(n=>{e.toBlob(n,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(n=>{const i=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),r=i.length,s=new Uint8Array(r);for(let a=0;a{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>t(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=e})}async function d0t(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function f0t(e,t,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${t}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(e),d0t(r)}const Va=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Va(n,t)};function h0t(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function p0t(e,t){return ame(t).map(n=>{const i=e.getPropertyValue(n),r=e.getPropertyPriority(n);return`${n}: ${i}${r?" !important":""};`}).join(" ")}function m0t(e,t,n,i){const r=`.${e}:${t}`,s=n.cssText?h0t(n):p0t(n,i);return document.createTextNode(`${r}{${s}}`)}function iY(e,t,n,i){const r=window.getComputedStyle(e,n),s=r.getPropertyValue("content");if(s===""||s==="none")return;const a=s0t();try{t.className=`${t.className} ${a}`}catch{return}const o=document.createElement("style");o.appendChild(m0t(a,n,r,i)),t.appendChild(o)}function g0t(e,t,n){iY(e,t,":before",n),iY(e,t,":after",n)}const rY="application/font-woff",sY="image/jpeg",b0t={woff:rY,woff2:rY,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:sY,jpeg:sY,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function O0t(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function NQ(e){const t=O0t(e).toLowerCase();return b0t[t]||""}function y0t(e){return e.split(/,/)[1]}function WL(e){return e.search(/^(data:)/)!==-1}function x0t(e,t){return`data:${t};base64,${e}`}async function lme(e,t,n){const i=await fetch(e,t);if(i.status===404)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((s,a)=>{const o=new FileReader;o.onerror=a,o.onloadend=()=>{try{s(n({res:i,result:o.result}))}catch(c){a(c)}},o.readAsDataURL(r)})}const IR={};function v0t(e,t,n){let i=e.replace(/\?.*/,"");return n&&(i=e),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),t?`[${t}]${i}`:i}async function CQ(e,t,n){const i=v0t(e,t,n.includeQueryParams);if(IR[i]!=null)return IR[i];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{const s=await lme(e,n.fetchRequestInit,({res:a,result:o})=>(t||(t=a.headers.get("Content-Type")||""),y0t(o)));r=x0t(s,t)}catch(s){r=n.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;s&&(a=typeof s=="string"?s:s.message),a&&console.warn(a)}return IR[i]=r,r}async function w0t(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):zT(t)}async function S0t(e,t){if(e.currentSrc){const s=document.createElement("canvas"),a=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,a==null||a.drawImage(e,0,0,s.width,s.height);const o=s.toDataURL();return zT(o)}const n=e.poster,i=NQ(n),r=await CQ(n,i,t);return zT(r)}async function E0t(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await iN(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function k0t(e,t){return Va(e,HTMLCanvasElement)?w0t(e):Va(e,HTMLVideoElement)?S0t(e,t):Va(e,HTMLIFrameElement)?E0t(e,t):e.cloneNode(cme(e))}const T0t=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",cme=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function _0t(e,t,n){var i,r;if(cme(t))return t;let s=[];return T0t(e)&&e.assignedNodes?s=Tf(e.assignedNodes()):Va(e,HTMLIFrameElement)&&(!((i=e.contentDocument)===null||i===void 0)&&i.body)?s=Tf(e.contentDocument.body.childNodes):s=Tf(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),s.length===0||Va(e,HTMLVideoElement)||await s.reduce((a,o)=>a.then(()=>iN(o,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function A0t(e,t,n){const i=t.style;if(!i)return;const r=window.getComputedStyle(e);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):ame(n).forEach(s=>{let a=r.getPropertyValue(s);s==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),Va(e,HTMLIFrameElement)&&s==="display"&&a==="inline"&&(a="block"),s==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),i.setProperty(s,a,r.getPropertyPriority(s))})}function N0t(e,t){Va(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Va(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function C0t(e,t){if(Va(e,HTMLSelectElement)){const n=t,i=Array.from(n.children).find(r=>e.value===r.getAttribute("value"));i&&i.setAttribute("selected","")}}function j0t(e,t,n){return Va(t,Element)&&(A0t(e,t,n),g0t(e,t,n),N0t(e,t),C0t(e,t)),t}async function R0t(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const i={};for(let s=0;sk0t(i,t)).then(i=>_0t(e,i,t)).then(i=>j0t(e,i,t)).then(i=>R0t(i,t))}const ume=/url\((['"]?)([^'"]+?)\1\)/g,I0t=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,P0t=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function M0t(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function L0t(e){const t=[];return e.replace(ume,(n,i,r)=>(t.push(r),n)),t.filter(n=>!WL(n))}async function D0t(e,t,n,i,r){try{const s=n?r0t(t,n):t,a=NQ(t);let o;return r||(o=await CQ(s,a,i)),e.replace(M0t(t),`$1${o}$3`)}catch{}return e}function $0t(e,{preferredFontFormat:t}){return t?e.replace(P0t,n=>{for(;;){const[i,,r]=I0t.exec(n)||[];if(!r)return"";if(r===t)return`src: ${i};`}}):e}function dme(e){return e.search(ume)!==-1}async function fme(e,t,n){if(!dme(e))return e;const i=$0t(e,n);return L0t(i).reduce((s,a)=>s.then(o=>D0t(o,a,t,n)),Promise.resolve(i))}async function vm(e,t,n){var i;const r=(i=t.style)===null||i===void 0?void 0:i.getPropertyValue(e);if(r){const s=await fme(r,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function Q0t(e,t){await vm("background",e,t)||await vm("background-image",e,t),await vm("mask",e,t)||await vm("-webkit-mask",e,t)||await vm("mask-image",e,t)||await vm("-webkit-mask-image",e,t)}async function B0t(e,t){const n=Va(e,HTMLImageElement);if(!(n&&!WL(e.src))&&!(Va(e,SVGImageElement)&&!WL(e.href.baseVal)))return;const i=n?e.src:e.href.baseVal,r=await CQ(i,NQ(i),t);await new Promise((s,a)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...c)=>{try{s(t.onImageErrorHandler(...c))}catch(u){a(u)}}:a;const o=e;o.decode&&(o.decode=s),o.loading==="lazy"&&(o.loading="eager"),n?(e.srcset="",e.src=r):e.href.baseVal=r})}async function U0t(e,t){const i=Tf(e.childNodes).map(r=>hme(r,t));await Promise.all(i).then(()=>e)}async function hme(e,t){Va(e,Element)&&(await Q0t(e,t),await B0t(e,t),await U0t(e,t))}function z0t(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const i=t.style;return i!=null&&Object.keys(i).forEach(r=>{n[r]=i[r]}),e}const aY={};async function oY(e){let t=aY[e];if(t!=null)return t;const i=await(await fetch(e)).text();return t={url:e,cssText:i},aY[e]=t,t}async function lY(e,t){let n=e.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async a=>{let o=a.replace(i,"$1");return o.startsWith("https://")||(o=new URL(o,e.url).href),lme(o,t.fetchRequestInit,({result:c})=>(n=n.replace(a,`url(${c})`),[a,c]))});return Promise.all(s).then(()=>n)}function cY(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let i=e.replace(n,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=r.exec(i);if(c===null)break;t.push(c[0])}i=i.replace(r,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",o=new RegExp(a,"gi");for(;;){let c=s.exec(i);if(c===null){if(c=o.exec(i),c===null)break;s.lastIndex=o.lastIndex}else o.lastIndex=s.lastIndex;t.push(c[0])}return t}async function F0t(e,t){const n=[],i=[];return e.forEach(r=>{if("cssRules"in r)try{Tf(r.cssRules||[]).forEach((s,a)=>{if(s.type===CSSRule.IMPORT_RULE){let o=a+1;const c=s.href,u=oY(c).then(d=>lY(d,t)).then(d=>cY(d).forEach(f=>{try{r.insertRule(f,f.startsWith("@import")?o+=1:r.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:f,error:h})}})).catch(d=>{console.error("Error loading remote css",d.toString())});i.push(u)}})}catch(s){const a=e.find(o=>o.href==null)||document.styleSheets[0];r.href!=null&&i.push(oY(r.href).then(o=>lY(o,t)).then(o=>cY(o).forEach(c=>{a.insertRule(c,a.cssRules.length)})).catch(o=>{console.error("Error loading remote stylesheet",o)})),console.error("Error inlining remote css file",s)}}),Promise.all(i).then(()=>(e.forEach(r=>{if("cssRules"in r)try{Tf(r.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${r.href}`,s)}}),n))}function V0t(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>dme(t.style.getPropertyValue("src")))}async function X0t(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Tf(e.ownerDocument.styleSheets),i=await F0t(n,t);return V0t(i)}function pme(e){return e.trim().replace(/["']/g,"")}function q0t(e){const t=new Set;function n(i){(i.style.fontFamily||getComputedStyle(i).fontFamily).split(",").forEach(s=>{t.add(pme(s))}),Array.from(i.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function H0t(e,t){const n=await X0t(e,t),i=q0t(e);return(await Promise.all(n.filter(s=>i.has(pme(s.style.fontFamily))).map(s=>{const a=s.parentStyleSheet?s.parentStyleSheet.href:null;return fme(s.cssText,a,t)}))).join(` -`)}async function Y0t(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await H0t(e,t);if(n){const i=document.createElement("style"),r=document.createTextNode(n);i.appendChild(r),e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}}async function G0t(e,t={}){const{width:n,height:i}=ome(e,t),r=await iN(e,t,!0);return await Y0t(r,t),await hme(r,t),z0t(r,t),await f0t(r,n,i)}async function W0t(e,t={}){const{width:n,height:i}=ome(e,t),r=await G0t(e,t),s=await zT(r),a=document.createElement("canvas"),o=a.getContext("2d"),c=t.pixelRatio||l0t(),u=t.canvasWidth||n,d=t.canvasHeight||i;return a.width=u*c,a.height=d*c,t.skipAutoScale||c0t(a),a.style.width=`${u}`,a.style.height=`${d}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(s,0,0,a.width,a.height),a}async function Z0t(e,t={}){const n=await W0t(e,t);return await u0t(n)}const K0t=16384,J0t=32e6;function ebt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function tbt(){const e=getComputedStyle(document.documentElement).getPropertyValue("--background").trim();return e?`hsl(${e})`:"white"}function nbt(e,t){const n=Math.min(Math.max(window.devicePixelRatio||1,1),2),i=K0t/Math.max(e,t),r=Math.sqrt(J0t/Math.max(e*t,1));return Math.min(n,i,r)}function ibt(e){const t=e.closest(".transcript");if(!t)return[e];const n=Array.from(t.children).filter(r=>r instanceof HTMLElement&&r.matches(".turn--user, .turn--assistant")),i=n.indexOf(e);return i>=0?n.slice(0,i+1):[e]}function rbt(e){const t=document.createElement("section");t.className="share-message-export",t.setAttribute("aria-hidden","true");for(const i of ibt(e)){const r=i.cloneNode(!0);r.removeAttribute("data-share-message-source"),r.classList.remove("is-feedback-target"),r.style.opacity="1",r.style.transform="none",r.style.animation="none",r.querySelectorAll("[data-share-image-exclude]").forEach(s=>s.remove()),t.append(r)}const n=document.createElement("p");return n.className="share-message-export-note",n.textContent="上述会话由 AgentKit Studio 导出,仅供参考",t.append(n),document.body.append(t),t}async function sbt(e){var n;(n=document.fonts)!=null&&n.ready&&await document.fonts.ready;const t=rbt(e);try{const i=Math.ceil(t.scrollWidth),r=Math.ceil(t.scrollHeight),s=nbt(i,r);if(s<.2)throw new Error("当前会话过长,暂时无法生成单张图片。");const a=await Z0t(t,{width:i,height:r,pixelRatio:s,backgroundColor:tbt(),cacheBust:!0,style:{position:"static",top:"auto",left:"auto",width:`${i}px`,height:`${r}px`,margin:"0",overflow:"visible",animation:"none"}});if(!a)throw new Error("图片生成失败,请重试。");return a}finally{t.remove()}}function abt(){return`agentkit-conversation-${new Date().toISOString().replace(/[:.]/g,"-")}.png`}function obt({targetTurn:e,onClose:t}){const n=m.useId(),i=m.useId(),r=m.useRef(null),s=m.useRef(null),a=m.useRef(t),o=m.useRef(void 0),[c,u]=m.useState("generating"),[d,f]=m.useState(0),[h,p]=m.useState(null),[g,b]=m.useState(""),[y,O]=m.useState(""),[v,x]=m.useState("idle");a.current=t,m.useEffect(()=>{var A;const S=document.body.style.overflow,k=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(A=s.current)==null||A.focus();const T=N=>{var P;if(N.key==="Escape"){N.preventDefault(),a.current();return}if(N.key!=="Tab")return;const C=Array.from(((P=r.current)==null?void 0:P.querySelectorAll("button:not(:disabled)"))??[]);if(C.length===0)return;const M=C[0],L=C[C.length-1];N.shiftKey&&document.activeElement===M?(N.preventDefault(),L.focus()):!N.shiftKey&&document.activeElement===L&&(N.preventDefault(),M.focus())};return window.addEventListener("keydown",T),()=>{document.body.style.overflow=S,window.removeEventListener("keydown",T),o.current!==void 0&&window.clearTimeout(o.current),k!=null&&k.isConnected&&k.focus()}},[]),m.useEffect(()=>{let S=!1,k="";return u("generating"),p(null),b(""),O(""),x("idle"),sbt(e).then(T=>{if(k=URL.createObjectURL(T),S){URL.revokeObjectURL(k);return}p(T),b(k),u("ready")}).catch(T=>{S||(u("error"),O(T instanceof Error?T.message:String(T)))}),()=>{S=!0,k&&URL.revokeObjectURL(k)}},[d,e]);const w=async()=>{var S;if(!(!h||v==="copying")){x("copying"),O("");try{if(!((S=navigator.clipboard)!=null&&S.write)||typeof ClipboardItem>"u")throw new Error("当前浏览器不支持复制图片,请下载后使用。");await navigator.clipboard.write([new ClipboardItem({"image/png":h})]),x("copied"),o.current=window.setTimeout(()=>x("idle"),1500)}catch(k){x("idle"),O(k instanceof Error?k.message:String(k))}}},E=()=>{if(!h)return;const S=URL.createObjectURL(h),k=document.createElement("a");k.href=S,k.download=abt(),k.style.display="none",document.body.append(k),k.click(),k.remove(),window.setTimeout(()=>URL.revokeObjectURL(S),1e3)};return zi.createPortal(l.jsx("div",{className:"share-message-backdrop",onMouseDown:S=>{S.target===S.currentTarget&&t()},children:l.jsxs("section",{ref:r,className:"share-message-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":i,"aria-busy":c==="generating",children:[l.jsxs("header",{className:"share-message-head",children:[l.jsxs("div",{children:[l.jsx("h2",{id:n,children:"分享为图片"}),l.jsx("p",{id:i,children:"包含截至当前回复的全部输入与输出。"})]}),l.jsx("button",{ref:s,type:"button",className:"share-message-close","aria-label":"关闭",title:"关闭",onClick:t,children:l.jsx(ebt,{})})]}),l.jsxs("div",{className:"share-message-body",children:[c==="generating"?l.jsx("div",{className:"share-message-generating",role:"status",children:l.jsx(oi,{children:"正在生成图片…"})}):c==="error"?l.jsxs("div",{className:"share-message-failure",children:[l.jsx("p",{role:"alert",children:y||"图片生成失败,请重试。"}),l.jsx("button",{type:"button",onClick:()=>f(S=>S+1),children:"重试生成"})]}):l.jsx("div",{className:"share-message-preview",children:l.jsx("img",{src:g,alt:"会话记录分享图片预览"})}),c!=="error"&&y&&l.jsx("p",{className:"share-message-error",role:"alert",children:y})]}),l.jsxs("footer",{className:"share-message-actions",children:[l.jsx("button",{type:"button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",onClick:E,disabled:!h||c!=="ready",children:"下载 PNG"}),l.jsx("button",{type:"button",className:"is-primary",onClick:()=>void w(),disabled:!h||c!=="ready"||v==="copying",children:v==="copying"?"正在复制…":v==="copied"?"已复制":"复制图片"})]})]})}),document.body)}const lbt=(e,t)=>{const n=e.currentTarget,i={x:e.clientX,y:e.clientY},r=cbt(i,n.getBoundingClientRect()),s=ubt(i,r),a=dbt(t.getBoundingClientRect());return hbt([...s,...a])};function cbt(e,t){const n=Math.abs(t.top-e.y),i=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function ubt(e,t,n=5){const i=[];switch(t){case"top":i.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":i.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":i.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":i.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return i}function dbt(e){const{top:t,right:n,bottom:i,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:i},{x:r,y:i}]}function fbt(e,t){const{x:n,y:i}=e;let r=!1;for(let s=0,a=t.length-1;si!=h>i&&n<(f-u)*(i-d)/(h-d)+u&&(r=!r)}return r}function hbt(e){const t=e.slice();return t.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),pbt(t)}function pbt(e){if(e.length<=1)return e.slice();const t=[];for(let i=0;i=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const mbt="_Transition_1wdpp_1",gbt="_Popover_1wdpp_3",mme={Transition:mbt,Popover:gbt},gme=m.createContext(null),rN=()=>{const e=m.use(gme);if(!e)throw new Error("Popover components must be wrapped in ");return e},Py=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:i=150,children:r})=>{const[s,a]=m.useState(!1),[o,c]=m.useState(!1),u=m.useRef(null),d=m.useRef(null),f=m.useRef(void 0),h=m.useRef(!1),p=m.useRef(!1),g=e??s,[b,y]=m.useState(!1);R$(()=>y(!1),b?500:null);const O=eM(t),v=eM(k=>{var T,A;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((T=u.current)==null||T.focus()),h.current=!1),(A=O.current)==null||A.call(O,k),a(k),n&&y(k))}),x=m.useCallback(k=>{v.current(k)},[v]),w=m.useCallback(()=>{f.current=setTimeout(()=>x(!0),i)},[x,i]),E=m.useCallback(()=>{clearTimeout(f.current)},[]);m.useEffect(()=>()=>{clearTimeout(f.current)},[]);const S=m.useMemo(()=>({open:g,setOpen:x,shake:o,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:E,isPointerInTransitRef:p,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,o,c,n,b,h,p,w,E]);return l.jsx(gme,{value:S,children:l.jsx(E$e,{open:g,onOpenChange:x,modal:!1,children:r})})},bbt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:i,showOnHover:r,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:o,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=rN(),f=m.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},p=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(o(),f.current=!1)};return l.jsx(k$e,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:r?p:void 0,onPointerLeave:r?g:void 0,onFocus:r?()=>i(!0):void 0,onBlur:r?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||i(!1)},50)}:void 0,children:e})},bme=({children:e,avoidCollisions:t,width:n,minWidth:i,maxWidth:r,side:s,sideOffset:a=8,align:o,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:p,contentRef:g}=rN(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=uie(O),x=v[v.length-1];x==null||x.focus()}};return m.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),l.jsx(_$e,{forceMount:!0,ref:g,className:Ps(mme.Popover,d),style:C$({"popover-width":n,"popover-min-width":i,"popover-max-width":r}),onCloseAutoFocus:h?ZS:void 0,"data-animate":p?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:o,alignOffset:c??(o==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:ZS,onEscapeKeyDown:ZS,onKeyDown:b,children:e})},Obt=e=>{const{setOpen:t,triggerRef:n,contentRef:i,isPointerInTransitRef:r,hoverOpenFocusedWithTab:s}=rN(),[a,o]=m.useState(null),c=m.useCallback(()=>{o(null),r.current=!1},[r]),u=m.useCallback((d,f)=>{const h=lbt(d,f);o(h),r.current=!0},[r]);return m.useEffect(()=>()=>c(),[c]),m.useEffect(()=>{const d=n.current,f=i.current;if(!d||!f)return;const h=g=>u(g,f),p=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",p),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",p)}},[i,n,u,c]),m.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,p=i.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(p==null?void 0:p.contains(g)),O=!fbt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,i]),m.useEffect(()=>{const d=f=>{if(i.current&&f.key==="Tab"&&!f.shiftKey){const[h]=uie(i.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[i,s]),l.jsx(bme,{...e})},ybt=e=>{const{open:t,showOnHover:n,setOpen:i}=rN();return ase(t,()=>{i(!1)}),l.jsx(T$e,{forceMount:!0,children:l.jsx(hie,{enterDuration:600,exitDuration:300,className:mme.Transition,disableAnimations:!0,children:t&&(n?l.jsx(Obt,{...e},"popover-hover"):l.jsx(bme,{...e},"popover"))})})};Py.Trigger=bbt;Py.Content=ybt;const xbt="_Container_13560_1",vbt="_Textarea_13560_174",uY={Container:xbt,Textarea:vbt},wbt=e=>{const t=m.useRef(null),i=`search-ui-input-${m.useId()}`,{id:r,name:s,variant:a="outline",size:o="md",gutterSize:c,className:u,autoComplete:d,disabled:f=!1,readOnly:h=!1,invalid:p=!1,allowAutofillExtensions:g=!!s,onFocus:b,onBlur:y,onAnimationStart:O,onAutofill:v,autoSelect:x,rows:w=3,maxRows:E,autoResize:S,ref:k,onChange:T,...A}=e,[N,C]=m.useState(!1),M=S?Math.max(E??10,w):w;m.useEffect(()=>{var Q;x&&((Q=t.current)==null||Q.select())},[x]);const L=Q=>{O==null||O(Q),Q.animationName==="native-autofill-in"&&(v==null||v())},P=m.useCallback(()=>{if(!S||!t.current||M===void 0)return;t.current.style.height="0px";const Q=t.current.scrollHeight;t.current.style.height=Q+"px"},[S,M]);return m.useEffect(()=>{P()},[e.value,w,P]),l.jsx("div",{className:Ps(uY.Container,u),"data-variant":a,"data-size":o,"data-gutter-size":c,"data-focused":N,"data-disabled":f?"":void 0,"data-readonly":h?"":void 0,"data-invalid":p?"":void 0,style:C$({"textarea-min-rows":`${w}`,"textarea-max-rows":`${M}`}),children:l.jsx("textarea",{...A,onChange:Q=>{T==null||T(Q),P()},ref:die([t,k]),id:r||(g?void 0:i),className:uY.Textarea,name:s,readOnly:h,disabled:f,rows:w,onFocus:Q=>{C(!0),b==null||b(Q)},onBlur:Q=>{C(!1),y==null||y(Q)},onAnimationStart:L,"data-lpignore":g?void 0:!0,"data-1p-ignore":g?void 0:!0})})},Sbt=2e3,Ebt=700,Ome=1200;function jQ(e,t){const n=Array.from(e);return n.length<=t?e:`${n.slice(0,t-1).join("").trimEnd()}…`}function yme(e){return jQ(e.trim(),Ebt)}function xme(e){return jQ(e,Ome)}function dY(e){return e.trim().length>0}function kbt(e,t){const n=yme(e),i=xme(t.trim());return jQ(`选中片段:${n} +`)),b("copied")}catch{b("error")}},j=()=>{var B;p(!1),b("idle"),u(""),f(x.current||((B=A[0])==null?void 0:B.version)||""),s("confirm")};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:e==="feature-link"?"welcome-feature-link studio-update-trigger--feature":`studio-update-trigger is-${r}`,title:r==="submitting"?"正在更新 Studio":r==="published"?"Studio 已更新":`更新 Studio 至 ${n.latestVersion}`,onClick:()=>{var B;r==="published"?window.location.reload():(r==="submitting"||r==="error"||(f(((B=A[0])==null?void 0:B.version)||n.latestVersion),s("confirm")),o(!0))},children:[e!=="feature-link"&&l.jsx(GH,{className:"studio-update-icon"}),r==="submitting"?l.jsx(oi,{as:"span",children:"正在更新"}):r==="published"?l.jsx("span",{children:"刷新使用新版"}):r==="error"?l.jsx("span",{children:"更新失败"}):e==="feature-link"?l.jsx("span",{children:"立即更新"}):l.jsx("span",{children:"有新版更新"})]}),a&&r!=="idle"&&zi.createPortal(l.jsx("div",{className:"confirm-scrim",role:"presentation",children:l.jsxs("section",{className:`confirm-box studio-update-dialog${r==="confirm"?"":" is-progress"}`,role:"dialog","aria-modal":"true","aria-labelledby":"studio-update-title",children:[l.jsx("div",{className:"studio-update-dialog-mark",children:l.jsx(GH,{})}),l.jsx("div",{id:"studio-update-title",className:"confirm-title",children:r==="error"?"Studio 更新失败":r==="submitting"?"正在更新 Studio":r==="published"?"Studio 更新完成":"发现新版本"}),r==="error"?l.jsxs("div",{className:"studio-update-error-panel",children:[l.jsx("p",{className:"confirm-text studio-update-error",children:c}),l.jsxs("dl",{className:"studio-update-error-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"失败阶段"}),l.jsx("dd",{children:Imt[n.errorStage]||n.errorStage||"未知阶段"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"错误 ID"}),l.jsx("dd",{children:n.errorId||"未生成"})]})]}),n.updateLogsVisible!==!1&&l.jsx(WH,{lines:P,phase:"error",copyState:g,onCopy:B=>void Q(B)}),n.consoleUrl&&l.jsxs("a",{className:"studio-update-console-link",href:n.consoleUrl,target:"_blank",rel:"noreferrer",children:["前往 VeFaaS 控制台查看 Function 日志",l.jsx("span",{"aria-hidden":!0,children:"↗"})]})]}):r==="submitting"||r==="published"?l.jsxs("div",{className:"studio-update-progress-body",children:[l.jsxs("div",{className:"studio-update-progress-summary",children:[l.jsxs("div",{children:[l.jsx("span",{children:"目标版本"}),l.jsx("strong",{children:x.current||N})]}),l.jsxs("div",{children:[l.jsx("span",{children:r==="published"?"更新状态":"已用时"}),l.jsx("strong",{children:r==="published"?"已完成":Pmt(y)})]})]}),l.jsx("ol",{className:"studio-update-progress","aria-label":"Studio 更新进度",children:HH.map((B,I)=>{const X=HH.findIndex(H=>H.id===n.progressStage),q=r==="published"||Ivoid Q(B)}),l.jsx("p",{className:"studio-update-progress-note",children:"发布阶段会短暂中断连接;关闭此窗口不会停止更新,可随时点击右上角按钮重新查看。"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"confirm-text",children:"更新会重启 Studio 服务,预计约 3–5 分钟完成更新与发布。期间正在进行的对话、 流式响应或部署任务可能中断,登录态不会受到影响。"}),l.jsxs("div",{className:"studio-update-field",ref:v,children:[l.jsx("span",{children:"选择版本"}),l.jsxs("button",{type:"button",className:"studio-update-version-trigger","aria-label":"选择版本","aria-haspopup":"listbox","aria-expanded":h,onClick:()=>p(B=>!B),onKeyDown:B=>{(B.key==="ArrowDown"||B.key==="ArrowUp")&&(B.preventDefault(),p(!0))},children:[l.jsx("span",{children:N}),l.jsx(Bmt,{})]}),h&&l.jsx("div",{className:"studio-update-version-menu",role:"listbox","aria-label":"选择版本",children:A.map(B=>{const I=B.version===N;return l.jsxs("button",{type:"button",role:"option","aria-selected":I,className:`studio-update-version-option${I?" is-selected":""}`,onClick:()=>{f(B.version),p(!1)},children:[l.jsx("span",{children:B.version}),I&&l.jsx(Umt,{})]},B.version)})})]}),l.jsxs("dl",{className:"studio-update-versions",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:n.currentVersion})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"目标版本"}),l.jsx("dd",{children:N})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Commit"}),l.jsx("dd",{children:((C==null?void 0:C.gitSha)||n.latestGitSha).slice(0,8)})]})]}),l.jsxs("section",{className:"studio-update-changelog","aria-labelledby":"studio-update-changelog-title",children:[l.jsx("div",{id:"studio-update-changelog-title",children:"更新内容"}),M.length?l.jsx("ul",{children:M.map(B=>l.jsx("li",{children:B},B))}):l.jsx("p",{children:"暂无更新说明"})]})]}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{type:"button",className:"confirm-btn",onClick:()=>{o(!1),p(!1),r==="confirm"&&(s("idle"),u(""))},children:r==="submitting"?"后台运行":r==="confirm"?"取消":"关闭"}),r==="confirm"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:()=>void L(),children:"立即更新"}),r==="error"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:j,children:"重新尝试"})]})]})}),document.body)]})}const Fmt=["多地域智能体:并行加载北京与上海 Runtime,列表下滑即可继续加载。","会话内切换:在输入框旁选择智能体,并直接开启一段新会话。","可视化执行画布:通过横向画布查看多智能体结构,并支持全屏浏览。"],ZH=Amt(),Vmt=ZH.length?ZH:Fmt;function Xmt({canUpdate:e=!1}){return l.jsxs("div",{className:"welcome-feature-pill",children:[l.jsx("span",{children:"焕然一新"}),l.jsx("span",{className:"welcome-feature-divider","aria-hidden":"true"}),l.jsx("button",{type:"button",className:"welcome-feature-link","aria-describedby":"welcome-feature-popover",children:"查看新特性"}),l.jsxs("section",{id:"welcome-feature-popover",className:"welcome-feature-popover",role:"tooltip",children:[l.jsx("strong",{children:"本次更新"}),l.jsx("ul",{children:Vmt.map(t=>l.jsx("li",{children:t},t))})]}),e&&l.jsx(zmt,{variant:"feature-link"})]})}const qmt=1e4;async function nme(e){const t=await fetch(vo(e),{headers:Dp({Accept:"application/json"}),signal:Ao(void 0,qmt)});if(!t.ok)throw new Error(`读取会话模式能力失败(HTTP ${t.status})`);const n=await t.json();if(typeof n.enabled!="boolean")throw new Error("会话模式能力响应格式错误");return{enabled:n.enabled,reason:typeof n.reason=="string"?n.reason:void 0,endpointExportEnabled:n.endpointExportEnabled===!0}}async function Hmt(){return nme("/web/sandbox/capabilities")}async function Ymt(e){return nme(`/web/${e}/capabilities`)}function Gmt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function Wmt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 3.5v11m-4-4 4 4 4-4"}),l.jsx("path",{d:"M5 19.5h14"})]})}function KH(e){return l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.22"}),l.jsx("path",{d:"M8 2.5A5.5 5.5 0 0 1 13.5 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Zmt({open:e,task:t,onClose:n,onRetry:i,onDownload:r}){const s=m.useId(),a=m.useRef(null),o=m.useRef(null),c=m.useRef(null),u=m.useRef(n);if(u.current=n,m.useEffect(()=>{if(!e||!t)return;c.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const b=document.body.style.overflow;document.body.style.overflow="hidden";const y=window.requestAnimationFrame(()=>{var v;return(v=o.current)==null?void 0:v.focus()}),O=v=>{var S;if(v.key==="Escape"){v.preventDefault(),u.current();return}if(v.key!=="Tab")return;const x=Array.from(((S=a.current)==null?void 0:S.querySelectorAll('button:not(:disabled), a[href], video[controls], [tabindex]:not([tabindex="-1"])'))??[]);if(x.length===0)return;const w=x[0],E=x[x.length-1];if(document.activeElement===o.current){v.preventDefault(),(v.shiftKey?E:w).focus();return}v.shiftKey&&document.activeElement===w?(v.preventDefault(),E.focus()):!v.shiftKey&&document.activeElement===E&&(v.preventDefault(),w.focus())};return window.addEventListener("keydown",O),()=>{var v;window.cancelAnimationFrame(y),document.body.style.overflow=b,window.removeEventListener("keydown",O),(v=c.current)!=null&&v.isConnected&&c.current.focus()}},[e,t==null?void 0:t.localId]),!e||!t)return null;const d=rft(t),f=t.status==="optimizing"||t.status==="generating",h=t.errorStage==="optimization"?"重试提示词优化":"重试视频生成",p=ape(t.resolvedMode??t.requestedMode),g=t.error.includes("尚未开通");return zi.createPortal(l.jsx("div",{className:"new-chat-video-task-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&n()},children:l.jsxs("section",{ref:a,className:`new-chat-video-task-dialog is-${t.status}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":f||void 0,children:[l.jsxs("header",{className:"new-chat-video-task-dialog__head",children:[l.jsxs("div",{children:[l.jsx("h2",{ref:o,id:s,tabIndex:-1,children:"视频生成任务"}),l.jsxs("p",{children:[p," · ",t.generationModel]})]}),l.jsx("button",{type:"button",className:"new-chat-video-task-dialog__close",onClick:n,"aria-label":"关闭视频生成任务弹窗",children:l.jsx(Gmt,{})})]}),l.jsxs("div",{className:"new-chat-video-task-dialog__body",children:[l.jsx("ol",{className:"new-chat-video-task-steps","aria-label":"视频生成进度","aria-live":"polite","aria-atomic":"true",children:d.map(b=>l.jsx("li",{className:`is-${b.status}`,children:l.jsxs("span",{className:"new-chat-video-task-step__label",children:[b.status==="active"?l.jsx(KH,{className:"new-chat-video-task-step__loading"}):null,l.jsx("span",{children:b.label})]})},b.id))}),t.error?l.jsx("div",{className:"new-chat-video-task-error",role:"alert",children:l.jsx("p",{children:t.error})}):null,t.optimizedPrompt?l.jsxs("section",{className:"new-chat-video-task-prompt","aria-labelledby":`${s}-prompt`,children:[l.jsx("h3",{id:`${s}-prompt`,children:"优化后的提示词"}),l.jsx("p",{children:t.optimizedPrompt})]}):null,t.status==="generating"?l.jsxs("div",{className:"new-chat-video-task-preview is-loading",role:"status",children:[l.jsx(KH,{className:"new-chat-video-task-preview__loading"}),l.jsxs(oi,{as:"strong",duration:2.2,spread:18,children:[p,"进行中"]}),l.jsx("span",{children:"这可能持续数分钟,生成完成后将在这里显示视频预览"})]}):t.output?l.jsx("div",{className:"new-chat-video-task-preview",children:l.jsx("video",{src:t.output.previewUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":"生成结果预览"})}):null]}),l.jsxs("footer",{className:"new-chat-video-task-dialog__actions",children:[l.jsx("p",{className:f?"is-warning":void 0,children:f?"请勿关闭弹窗,关闭后任务将丢失":t.status==="success"?"视频已生成,可预览或下载":g?"请先在模型控制台开通服务,再重试生成":"修正问题后可重试当前步骤"}),l.jsxs("div",{children:[l.jsx("button",{type:"button",className:"new-chat-video-task-button",onClick:n,children:"关闭"}),t.status==="error"?l.jsx("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:i,children:h}):t.output?l.jsxs("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:r,children:[l.jsx(Wmt,{}),"下载视频"]}):null]})]})]})}),document.body)}const Kmt="我的智能体";function Jmt({open:e,state:t,agentKind:n="codex",error:i,onCancel:r,onConfirm:s}){const a=n==="codex"?"Codex":n==="deepseek-harness"?"DeepSeek Harness":n==="openclaw"?"OpenClaw":"Hermes",o=n==="codex"?Kmt:`我的 ${a}`,c=m.useRef(null),u=m.useRef(null),d=m.useRef(null),f=m.useRef(!1),h=m.useRef(r),[p,g]=m.useState(o),[b,y]=m.useState(!0);if(h.current=r,m.useEffect(()=>{if(!e)return;g(o),y(!0);const w=document.body.style.overflow;document.body.style.overflow="hidden";const E=window.requestAnimationFrame(()=>{var k,T;(k=u.current)==null||k.focus(),(T=u.current)==null||T.select()}),S=k=>{var C;if(k.key==="Escape"){k.preventDefault(),h.current();return}if(k.key!=="Tab")return;const T=(C=c.current)==null?void 0:C.querySelectorAll("input:not(:disabled), button:not(:disabled)");if(!(T!=null&&T.length))return;const A=T[0],N=T[T.length-1];k.shiftKey&&document.activeElement===A?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),A.focus())};return window.addEventListener("keydown",S),()=>{window.cancelAnimationFrame(E),document.body.style.overflow=w,window.removeEventListener("keydown",S)}},[o,e]),!e)return null;const O=t==="loading",v=p.trim(),x=O?`正在创建 ${a} 智能体`:t==="error"?"启动失败":`创建 ${a} 智能体`;return zi.createPortal(l.jsx("div",{className:"sandbox-dialog-backdrop",onMouseDown:w=>{w.target===w.currentTarget&&!O&&r()},children:l.jsxs("form",{ref:c,className:"sandbox-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-dialog-title","aria-describedby":t==="confirm"?void 0:"sandbox-dialog-description",onSubmit:w=>{w.preventDefault(),!O&&!f.current&&v&&s(v,b)},children:[l.jsxs("div",{className:"sandbox-dialog-visual","aria-hidden":"true",children:[l.jsx("span",{className:"sandbox-dialog-orbit"}),l.jsx("span",{className:"sandbox-dialog-icon",children:O?l.jsx("span",{className:"sandbox-spinner"}):l.jsx(t1,{kind:n})})]}),l.jsxs("div",{className:"sandbox-dialog-copy",children:[l.jsx("h2",{id:"sandbox-dialog-title",children:x}),t==="error"?l.jsx("p",{id:"sandbox-dialog-description",className:"sandbox-dialog-error",role:"alert",children:i||"AgentKit 沙箱初始化失败,请稍后重新尝试。"}):O?l.jsxs("p",{id:"sandbox-dialog-description","aria-live":"polite",children:["正在创建并等待 ",a," 智能体就绪,这通常需要半分钟"]}):null,l.jsxs("label",{className:"sandbox-dialog-field",children:[l.jsxs("span",{className:"sandbox-dialog-field-label",children:[l.jsx("span",{children:"智能体名称"}),l.jsxs("span",{"aria-hidden":"true",children:[p.length,"/",Uq]})]}),l.jsx("input",{ref:u,type:"text",required:!0,value:p,maxLength:Uq,disabled:O,placeholder:o,autoComplete:"off",onChange:w=>g(w.target.value),onCompositionStart:()=>{f.current=!0},onCompositionEnd:()=>{f.current=!1},onKeyDown:w=>{const{nativeEvent:E}=w;w.key==="Enter"&&(f.current||E.isComposing||E.keyCode===229)&&w.preventDefault()}})]}),l.jsxs("div",{className:"sandbox-dialog-persistence",role:"group","aria-describedby":"sandbox-persistence-description",children:[l.jsx(yQ,{id:"sandbox-persistence",className:"sandbox-dialog-persistence-control",checked:b,disabled:O,onCheckedChange:y,label:"持久化"}),l.jsx("p",{id:"sandbox-persistence-description",className:`sandbox-dialog-persistence-description${b?"":" is-warning"}`,role:b?void 0:"status",children:b?"保留智能体数据,后续可继续使用。":"智能体将在 8 小时后清空"})]})]}),l.jsxs("footer",{className:"sandbox-dialog-actions",children:[l.jsx("button",{ref:d,type:"button",onClick:r,children:O?"取消创建":"取消"}),!O&&l.jsx("button",{type:"submit",className:"is-primary",disabled:!v,children:t==="error"?"重新尝试":"确认创建"})]})]})}),document.body)}function egt({agentName:e,onExit:t}){return l.jsxs("div",{className:"sandbox-session-warning",role:"status",children:[l.jsx("span",{className:"sandbox-session-warning-dot","aria-hidden":"true"}),l.jsxs("span",{className:"sandbox-session-warning-copy",children:["当前您在使用 ",e," 智能体"]}),l.jsx("button",{type:"button",onClick:t,children:"退出当前智能体"})]})}function tgt({activity:e,time:t}){var n;return l.jsxs("aside",{className:"sandbox-activity-record",role:"status","aria-label":"Sandbox 操作记录",children:[l.jsxs("div",{className:"sandbox-activity-summary",children:[l.jsx("span",{className:"sandbox-activity-dot","aria-hidden":"true"}),l.jsx("span",{className:"sandbox-activity-label",children:"操作记录"}),l.jsx("strong",{children:e.title}),t?l.jsx("time",{children:t}):null]}),(n=e.details)!=null&&n.length?l.jsx("dl",{className:"sandbox-activity-details",children:e.details.map(i=>l.jsxs("div",{children:[l.jsx("dt",{children:i.label}),l.jsx("dd",{title:i.value,children:i.code?l.jsx("code",{children:i.value}):i.value})]},`${i.label}:${i.value}`))}):null]})}function ngt(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function igt({usage:e}){const t=[["Total",e.totalTokens],["Input",e.inputTokens],...e.cachedInputTokens>0?[["Cached input",e.cachedInputTokens]]:[],["Output",e.outputTokens],...e.reasoningOutputTokens>0?[["Reasoning output",e.reasoningOutputTokens]]:[]];return l.jsx("div",{className:"sandbox-token-usage","aria-label":"Codex Token 用量",children:t.map(([n,i])=>l.jsxs("span",{title:`${n}: ${i.toLocaleString()} tokens`,children:[l.jsx("small",{children:n}),l.jsx("strong",{children:ngt(i)})]},n))})}function ime(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("path",{d:"m7.5 9 2.7 2.5L7.5 14M12.7 14h3.8"}),l.jsx("path",{d:"M3.8 7.5h16.4",opacity:".55"})]})}function rme(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("path",{d:"M3.8 8h16.4"}),l.jsx("circle",{cx:"6.5",cy:"6.3",r:".65",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"8.8",cy:"6.3",r:".65",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"m9 15 2.2-4 1.6 2.4 1.1-1.2L16 15H9Z"})]})}function AQ(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 3.4 19 6v5.3c0 4.3-2.7 7.6-7 9.3-4.3-1.7-7-5-7-9.3V6l7-2.6Z"}),l.jsx("path",{d:"m8.8 12 2 2 4.4-4.4"})]})}function _E(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M3.5 7.7h6.1l1.7 2h9.2v7.5a2.3 2.3 0 0 1-2.3 2.3H5.8a2.3 2.3 0 0 1-2.3-2.3V7.7Z"}),l.jsx("path",{d:"M3.8 7.7V6.8a2.3 2.3 0 0 1 2.3-2.3h3l1.8 2h6.9a2.3 2.3 0 0 1 2.3 2.3v.9"}),l.jsx("path",{d:"M12 13v3M10.5 14.5h3"})]})}function rgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function sgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 11.5 5.5-5.5 5.5 5.5M12 6v12"})})}function agt(e){return l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...e,children:l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.75",fill:"currentColor"})})}function ogt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2.5"}),l.jsx("circle",{cx:"8.5",cy:"9",r:"1.4"}),l.jsx("path",{d:"m5.5 17 4.2-4.2 2.6 2.4 2.1-2.1 4.1 3.9"})]})}function lgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M6 3.5h7l5 5v12H6z"}),l.jsx("path",{d:"M13 3.5v5h5M9 13h6M9 16h5"})]})}function cgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.5",y:"5",width:"13.5",height:"14",rx:"2.5"}),l.jsx("path",{d:"m17 10 3.5-2v8L17 14zM7 8.5h4.5"})]})}function ugt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m12 3 1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5zM18.5 15.5l.7 2.1 2.1.7-2.1.7-.7 2.1-.7-2.1-2.1-.7 2.1-.7z"})})}function dgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function YL(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m9 6 6 6-6 6"})})}function fgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.8 8.2A8 8 0 1 1 4 12M4.8 8.2V4.5M4.8 8.2h3.7"}),l.jsx("path",{d:"M12 8v4.5l3 1.8"})]})}function Pc(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"M20 12a8 8 0 1 1-2.35-5.65"})})}function hgt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"8",y:"8",width:"11",height:"11",rx:"2"}),l.jsx("path",{d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})]})}function pgt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function lv({open:e,title:t,subtitle:n,icon:i,className:r="",onClose:s,children:a}){const o=m.useId(),c=m.useRef(null),u=m.useRef(null),d=m.useRef(s);return d.current=s,m.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const f=document.body.style.overflow;document.body.style.overflow="hidden",(p=c.current)==null||p.focus();const h=g=>{var x;if(g.key==="Escape"){g.preventDefault(),d.current();return}if(g.key!=="Tab")return;const b=(x=c.current)==null?void 0:x.closest("[role=dialog]"),y=Array.from((b==null?void 0:b.querySelectorAll('button:not(:disabled), input:not(:disabled), iframe, [tabindex]:not([tabindex="-1"])'))??[]);if(y.length===0)return;const O=y[0],v=y[y.length-1];g.shiftKey&&document.activeElement===O?(g.preventDefault(),v.focus()):!g.shiftKey&&document.activeElement===v&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{var g;document.body.style.overflow=f,window.removeEventListener("keydown",h),(g=u.current)==null||g.focus()}},[e]),e?zi.createPortal(l.jsx("div",{className:"sandbox-control-backdrop",onMouseDown:f=>{f.target===f.currentTarget&&s()},children:l.jsxs("section",{className:`sandbox-control-dialog ${r}`.trim(),role:"dialog","aria-modal":"true","aria-labelledby":o,children:[l.jsxs("header",{className:"sandbox-control-head",children:[l.jsx("span",{className:"sandbox-control-head-icon","aria-hidden":"true",children:i}),l.jsxs("div",{children:[l.jsx("h2",{id:o,children:t}),l.jsx("p",{children:n})]}),l.jsx("button",{ref:c,type:"button",className:"sandbox-control-close","aria-label":`关闭${t}`,onClick:s,children:l.jsx(dgt,{})})]}),a]})}),document.body):null}function mgt({open:e,kind:t,launch:n,loading:i,error:r,onReload:s,onClose:a}){const o=t==="terminal",c=o?"Terminal":"Sandbox Browser";return l.jsxs(lv,{open:e,title:c,subtitle:o?"连接当前 AgentKit Session 的交互式终端":"在当前 AgentKit Session 中查看与操作浏览器",icon:o?l.jsx(ime,{}):l.jsx(rme,{}),className:`sandbox-tool-dialog sandbox-tool-dialog--${t}`,onClose:a,children:[l.jsx("div",{className:"sandbox-tool-toolbar",children:l.jsxs("span",{children:[l.jsx("i",{className:i?"is-loading":n?"is-ready":""}),i?"正在连接…":n?"已连接":"尚未连接"]})}),l.jsx("div",{className:"sandbox-tool-surface",children:i?l.jsxs("div",{className:"sandbox-control-state",children:[l.jsx(Pc,{className:"spin"}),l.jsxs("strong",{children:["正在打开 ",c]}),l.jsx("span",{children:"工具正在连接当前 AgentKit Session。"})]}):r?l.jsxs("div",{className:"sandbox-control-state is-error",children:[l.jsxs("strong",{children:[c," 打开失败"]}),l.jsx("span",{children:r}),l.jsx("button",{type:"button",onClick:s,children:"重试"})]}):n?l.jsx("iframe",{src:n.url,title:c,allow:"clipboard-read; clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts"}):null})]})}function ggt({open:e,threads:t,currentThreadId:n,loading:i,error:r,onSelect:s,onClose:a}){return l.jsx(lv,{open:e,title:"恢复 Codex 对话",subtitle:"选择当前 Sandbox Session 中最近更新的 Thread",icon:l.jsx(fgt,{}),className:"sandbox-threads-dialog",onClose:a,children:l.jsx("div",{className:"sandbox-thread-list",children:i?l.jsxs("div",{className:"sandbox-control-state",children:[l.jsx(Pc,{className:"spin"}),l.jsx("strong",{children:"正在读取历史对话"})]}):r?l.jsxs("div",{className:"sandbox-control-state is-error",children:[l.jsx("strong",{children:"历史对话读取失败"}),l.jsx("span",{children:r})]}):t.length===0?l.jsx("div",{className:"sandbox-control-state",children:l.jsx("strong",{children:"暂无可恢复的对话"})}):t.map(o=>{const c=o.id===n,u=o.name||o.preview||`Thread ${o.id.slice(0,8)}`;return l.jsxs("button",{type:"button",className:c?"is-active":"",disabled:c,onClick:()=>s(o.id),children:[l.jsxs("span",{children:[l.jsx("strong",{children:u}),l.jsx("small",{children:o.preview||o.cwd||o.id})]}),l.jsx("time",{children:o.updatedAt?new Date(o.updatedAt*1e3).toLocaleString():""}),l.jsx(YL,{})]},o.id)})})})}const bgt=[{value:"read-only",label:"只读",detail:"允许读取文件,不允许写入工作空间。"},{value:"workspace-write",label:"工作区写入",detail:"允许在当前工作空间内读取与修改文件。"},{value:"danger-full-access",label:"完全访问",detail:"不启用沙箱隔离,适合明确可信的任务。",danger:!0}],Ogt=[{value:"untrusted",label:"仅不可信命令",detail:"只对 Codex 判断为不可信的操作发起审批。"},{value:"on-request",label:"按需审批",detail:"Codex 可在必要时请求你确认命令或文件修改。"},{value:"never",label:"不审批",detail:"Codex 不会暂停并请求人工批准。",danger:!0}],ygt=[{value:"user",label:"由我审批",detail:"审批请求会显示在 Studio 中,由你决定。"},{value:"auto_review",label:"自动审查",detail:"使用 Codex 自动审查流程处理审批请求。"}];function xgt({open:e,value:t,busy:n,error:i,onSave:r,onClose:s}){const[a,o]=m.useState(t);return m.useEffect(()=>{e&&o(t)},[e,t]),l.jsxs(lv,{open:e,title:"Codex 权限",subtitle:"设置会保存到当前 Sandbox Session,并同步到其中的所有 Thread",icon:l.jsx(AQ,{}),className:"sandbox-settings-dialog",onClose:s,children:[l.jsxs("div",{className:"sandbox-control-body",children:[l.jsx(jR,{label:"沙箱模式",choices:bgt,value:a.sandboxMode,disabled:n,onChange:c=>o(u=>({...u,sandboxMode:c,networkAccess:c==="danger-full-access"?!0:u.networkAccess}))}),l.jsx(jR,{label:"审批策略",choices:Ogt,value:a.approvalPolicy,disabled:n,onChange:c=>o(u=>({...u,approvalPolicy:c}))}),l.jsx(jR,{label:"审批方式",choices:ygt,value:a.approvalsReviewer,disabled:n,onChange:c=>o(u=>({...u,approvalsReviewer:c}))}),l.jsxs("label",{className:`sandbox-network-toggle${a.sandboxMode==="danger-full-access"?" is-disabled":""}`,children:[l.jsxs("span",{children:[l.jsx("strong",{children:"允许网络访问"}),l.jsx("small",{children:"控制 workspace-write 与只读模式中的外部网络访问。"})]}),l.jsx("input",{type:"checkbox",checked:a.networkAccess,disabled:n||a.sandboxMode==="danger-full-access",onChange:c=>o(u=>({...u,networkAccess:c.target.checked}))})]}),a.sandboxMode==="danger-full-access"?l.jsx("div",{className:"sandbox-control-note is-danger",children:"完全访问会关闭文件系统与网络隔离,请只在可信任务中使用。"}):null,i?l.jsx("div",{className:"sandbox-control-error",children:i}):null]}),l.jsxs("footer",{className:"sandbox-control-actions",children:[l.jsx("button",{type:"button",onClick:s,disabled:n,children:"取消"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:n,onClick:()=>r(a),children:[n?l.jsx(Pc,{className:"spin"}):null,"保存权限"]})]})]})}function jR({label:e,choices:t,value:n,disabled:i,onChange:r}){return l.jsxs("fieldset",{className:"sandbox-choice-group",disabled:i,role:"radiogroup","aria-label":e,children:[l.jsx("legend",{children:e}),l.jsx("div",{className:"sandbox-choice-list",children:t.map(s=>l.jsxs("button",{type:"button",role:"radio",className:`${n===s.value?"is-active":""}${s.danger?" is-danger":""}`.trim(),"aria-checked":n===s.value,onClick:()=>r(s.value),onKeyDown:a=>{var d,f;const o=t.findIndex(h=>h.value===s.value);let c=o;if(a.key==="ArrowRight"||a.key==="ArrowDown")c=(o+1)%t.length;else if(a.key==="ArrowLeft"||a.key==="ArrowUp")c=(o-1+t.length)%t.length;else if(a.key==="Home")c=0;else if(a.key==="End")c=t.length-1;else return;a.preventDefault(),r(t[c].value);const u=(d=a.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="radio"]');(f=u==null?void 0:u[c])==null||f.focus()},children:[l.jsx("i",{}),l.jsxs("span",{children:[l.jsx("strong",{children:s.label}),l.jsx("small",{children:s.detail})]})]},s.value))})]})}function vgt({open:e,cwd:t,locked:n,busy:i,error:r,browse:s,onSave:a,onClose:o}){const[c,u]=m.useState(t||"/"),[d,f]=m.useState(null),[h,p]=m.useState(!1),[g,b]=m.useState("");m.useEffect(()=>{if(!e)return;const O=t||"/";u(O),y(O)},[t,e]);async function y(O){p(!0),b("");try{const v=await s(O);f(v),u(v.path)}catch(v){b(v instanceof Error?v.message:String(v))}finally{p(!1)}}return l.jsxs(lv,{open:e,title:"工作空间",subtitle:"选择当前 Codex Thread 执行命令与修改文件的目录",icon:l.jsx(_E,{}),className:"sandbox-workspace-dialog",onClose:o,children:[l.jsxs("div",{className:"sandbox-control-body",children:[l.jsxs("label",{className:"sandbox-workspace-input",children:[l.jsx("span",{children:"绝对路径"}),l.jsxs("div",{children:[l.jsx("input",{value:c,disabled:i||n,spellCheck:!1,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&c.startsWith("/")&&(O.preventDefault(),y(c))}}),l.jsx("button",{type:"button",disabled:i||h||!c.startsWith("/"),onClick:()=>void y(c),children:"浏览"})]})]}),l.jsxs("div",{className:"sandbox-directory-browser",children:[l.jsxs("div",{className:"sandbox-directory-head",children:[l.jsx("span",{title:d==null?void 0:d.path,children:(d==null?void 0:d.path)??c}),h?l.jsx(Pc,{className:"spin"}):null]}),l.jsxs("div",{className:"sandbox-directory-list",children:[d!=null&&d.parent?l.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(d.parent??"/"),children:[l.jsx(_E,{}),l.jsx("span",{children:"上一级"}),l.jsx("small",{children:d.parent}),l.jsx(YL,{})]}):null,d==null?void 0:d.directories.map(O=>l.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(O.path),children:[l.jsx(_E,{}),l.jsx("span",{children:O.name}),l.jsx(YL,{})]},O.path)),!h&&(d==null?void 0:d.directories.length)===0?l.jsx("div",{className:"sandbox-directory-empty",children:"当前目录没有子目录"}):null]})]}),n?l.jsx("div",{className:"sandbox-control-note",children:"当前对话已经开始,工作空间已锁定。新建 Sandbox 会话后可重新选择。"}):null,g||r?l.jsx("div",{className:"sandbox-control-error",children:g||r}):null]}),l.jsxs("footer",{className:"sandbox-control-actions",children:[l.jsx("button",{type:"button",onClick:o,disabled:i,children:"取消"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:i||n||!c.startsWith("/"),onClick:()=>a(c),children:[i?l.jsx(Pc,{className:"spin"}):null,"使用此目录"]})]})]})}function wgt({approval:e,busy:t,error:n,onDecision:i}){var a;const r=(a=e==null?void 0:e.command)==null?void 0:a.trim(),s=(e==null?void 0:e.changes)===void 0?"":JSON.stringify(e.changes,null,2);return l.jsxs(lv,{open:e!==null,title:(e==null?void 0:e.kind)==="file"?"允许修改文件?":"允许执行命令?",subtitle:"Codex 正在等待你的决定",icon:l.jsx(AQ,{}),className:"sandbox-approval-dialog",onClose:()=>{t||i("cancel")},children:[l.jsxs("div",{className:"sandbox-control-body",children:[e!=null&&e.reason?l.jsx("div",{className:"sandbox-approval-reason",children:e.reason}):null,r?l.jsx("pre",{children:r}):null,s?l.jsx("pre",{children:s}):null,e!=null&&e.cwd?l.jsxs("div",{className:"sandbox-approval-meta",children:["执行目录 ",l.jsx("code",{children:e.cwd})]}):null,n?l.jsx("div",{className:"sandbox-control-error",children:n}):null]}),l.jsxs("footer",{className:"sandbox-control-actions sandbox-approval-actions",children:[l.jsx("button",{type:"button",disabled:t,onClick:()=>i("decline"),children:"拒绝"}),l.jsx("button",{type:"button",disabled:t,onClick:()=>i("accept"),children:"仅本次允许"}),l.jsxs("button",{type:"button",className:"is-primary",disabled:t,onClick:()=>i("acceptForSession"),children:[t?l.jsx(Pc,{className:"spin"}):null,"本会话允许"]})]})]})}const Sgt={codex:"Codex","deepseek-harness":"DeepSeek Harness",openclaw:"OpenClaw",hermes:"Hermes"};function JH(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(t)}function Egt({session:e,onBack:t,onOpen:n,onDelete:i}){const[r,s]=m.useState(!1),[a,o]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(""),h=Sgt[e.toolName],p=e.resourceType==="snapshot",g=p?e.sourceSessionId||e.snapshotId:e.id,b=async()=>{if(!(a||c)){o(!0),f("");try{await n()}catch(O){f(O instanceof Error?O.message:String(O))}finally{o(!1)}}},y=async()=>{if(!(c||a)){u(!0),f("");try{await i()}catch(O){f(O instanceof Error?O.message:String(O)),s(!1)}finally{u(!1)}}};return l.jsxs("section",{className:"sandbox-agent-details",children:[l.jsxs("header",{className:"sandbox-agent-details-header",children:[l.jsxs("button",{type:"button",className:"sandbox-agent-back",onClick:t,children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),"返回智能体"]}),l.jsxs("div",{children:[l.jsx("h1",{children:e.displayName||`${h} 智能体`}),l.jsxs("p",{children:[h," AgentKit Session 详情"]})]})]}),d?l.jsx("div",{className:"sandbox-agent-detail-error",role:"alert",children:d}):null,l.jsxs("div",{className:"sandbox-agent-detail-panel",children:[l.jsxs("dl",{children:[l.jsxs("div",{children:[l.jsx("dt",{children:"智能体类型"}),l.jsx("dd",{children:h})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:YA(e.status)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"创建人"}),l.jsx("dd",{children:e.createdBy||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:p?"快照状态":"工具类型"}),l.jsx("dd",{children:p?e.snapshotStatus||"—":e.toolType||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"创建时间"}),l.jsx("dd",{children:JH(e.createdAt)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:p?"快照原因":"过期时间"}),l.jsx("dd",{children:p?e.reason||"—":JH(e.expireAt)})]}),l.jsxs("div",{className:"is-wide",children:[l.jsx("dt",{children:p?"Snapshot ID":"Session ID"}),l.jsx("dd",{children:p?e.snapshotId:g})]}),p&&e.sourceSessionId?l.jsxs("div",{className:"is-wide",children:[l.jsx("dt",{children:"来源 Session ID"}),l.jsx("dd",{children:e.sourceSessionId})]}):null]}),l.jsxs("footer",{children:[l.jsx("button",{type:"button",className:"sandbox-agent-delete",disabled:a||c,onClick:()=>s(!0),children:"删除智能体"}),l.jsx("button",{type:"button",className:"sandbox-agent-open",disabled:a||c,"aria-busy":a||void 0,onClick:()=>void b(),children:a?p?"唤醒中…":"打开中…":p?"唤醒智能体":"打开智能体"})]})]}),r?l.jsx("div",{className:"confirm-scrim",onClick:()=>!c&&s(!1),children:l.jsxs("div",{className:"confirm-box",role:"alertdialog","aria-modal":"true","aria-labelledby":"sandbox-agent-delete-title",onClick:O=>O.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",id:"sandbox-agent-delete-title",children:"删除智能体?"}),l.jsxs("div",{className:"confirm-text",children:["将删除“",e.displayName||`${h} 智能体`,"”及其 AgentKit ",p?"Snapshot":"Session",",此操作无法撤销。"]}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{type:"button",className:"confirm-btn",disabled:c,onClick:()=>s(!1),children:"取消"}),l.jsx("button",{type:"button",className:"confirm-btn confirm-btn--danger",disabled:c,onClick:()=>void y(),children:c?"删除中…":"确认删除"})]})]})}):null]})}const kgt="_SegmentedControl_1sl7d_1",Tgt="_SegmentedControlOption_1sl7d_140",_gt="_SegmentedControlThumb_1sl7d_219",GL={SegmentedControl:kgt,SegmentedControlOption:Tgt,SegmentedControlThumb:_gt},AE=({value:e,onChange:t,children:n,block:i,pill:r=!0,size:s="md",gutterSize:a,className:o,onClick:c,...u})=>{const d=m.useRef(null),f=m.useRef(null),h=m.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const E=v*.15,S=b.scrollLeft,k=O.offsetLeft,T=k+x;(kS+v-E)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);MMe({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),m.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||LP(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,r]);const p=g=>{g&&t&&t(g)};return l.jsxs(e3e,{ref:d,className:Ps(GL.SegmentedControl,o),type:"single",value:e,loop:!1,onValueChange:p,onClick:c,"data-block":i?"":void 0,"data-pill":r?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[l.jsx("div",{className:GL.SegmentedControlThumb,ref:f}),n]})},Agt=({children:e,...t})=>l.jsx(s3e,{className:GL.SegmentedControlOption,...t,onPointerEnter:uie,children:l.jsx("span",{className:"relative",children:e})});AE.Option=Agt;function Ngt({workspace:e,onBack:t}){const[n,i]=m.useState("main"),[r,s]=m.useState(""),[a,o]=m.useState(!1),[c,u]=m.useState(""),d=e.kind==="deepseek-harness"?"DeepSeek Harness":e.kind==="openclaw"?"OpenClaw":"Hermes";m.useEffect(()=>{i("main"),s(""),u(""),o(!1)},[e.session.id]);const f=async()=>{if(i("terminal"),!(r||a)){o(!0),u("");try{const h=await Kt.launchAgentTerminal(e.kind,e.session.id);s(h.url)}catch(h){u(h instanceof Error?h.message:String(h))}finally{o(!1)}}};return l.jsxs("section",{className:"sandbox-agent-workspace",children:[l.jsxs("header",{children:[l.jsxs("div",{className:"sandbox-agent-workspace-title",children:[l.jsx("button",{type:"button",onClick:t,"aria-label":"返回智能体列表",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m14.5 6-6 6 6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}),l.jsxs("div",{children:[l.jsx("h1",{children:e.session.displayName||`${d} 智能体`}),l.jsxs("p",{children:[l.jsxs("span",{children:["创建人 ",e.session.createdBy||"未知"]}),l.jsx("span",{className:"sandbox-agent-workspace-status","data-ready":e.session.status.toLowerCase()==="ready"||void 0,children:YA(e.session.status)})]})]})]}),l.jsxs(AE,{className:"sandbox-agent-workspace-tabs",value:n,size:"lg",gutterSize:"lg",block:!0,pill:!1,"aria-label":"智能体工作区",onChange:h=>{h==="terminal"?f():i("main")},children:[l.jsx(AE.Option,{value:"main",children:"主界面"}),l.jsx(AE.Option,{value:"terminal",children:"终端"})]})]}),l.jsx("div",{className:"sandbox-agent-workspace-surface",children:n==="main"?l.jsx("iframe",{src:e.webuiUrl,title:`${d} 主界面`,allow:"clipboard-read; clipboard-write"}):a?l.jsx("div",{className:"sandbox-agent-workspace-state",role:"status",children:"正在打开终端…"}):c?l.jsxs("div",{className:"sandbox-agent-workspace-state is-error",role:"alert",children:[l.jsx("p",{children:c}),l.jsx("button",{type:"button",onClick:()=>void f(),children:"重新尝试"})]}):r?l.jsx("iframe",{src:r,title:`${d} 终端`}):null})]})}const nN=[{name:"model",usage:"/model [model]",description:"显示或切换当前对话模型",keywords:["模型","switch"]},{name:"models",usage:"/models",description:"列出 app-server 可用模型",keywords:["模型列表","list"]},{name:"skill",usage:"/skill",description:"浏览并调用当前工作区可用的 Skill",keywords:["技能","workflow"]},{name:"skills",usage:"/skills",description:"浏览并调用当前工作区可用的 Skills",keywords:["技能列表","workflow","list"]},{name:"new",usage:"/new",description:"开始一个新对话",keywords:["新建","对话"]},{name:"resume",usage:"/resume [thread]",description:"打开历史会话或恢复指定 thread",keywords:["历史","恢复","session"]},{name:"fork",usage:"/fork",description:"从当前上下文分叉一个新对话",keywords:["分叉","branch"]},{name:"compact",usage:"/compact",description:"压缩当前对话上下文",keywords:["压缩","上下文"]},{name:"archive",usage:"/archive",description:"归档当前对话并新建对话",keywords:["归档","关闭"]},{name:"status",usage:"/status",description:"显示当前连接、thread、模型与 token 状态",keywords:["状态","连接","token"]},{name:"clear",usage:"/clear",description:"清空当前视图并开始新对话",keywords:["清空","重置"]},{name:"help",usage:"/help",description:"显示 Sandbox 支持的快捷命令",keywords:["帮助","命令"]}];function Cgt(e){var n;const t=e.trim().match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(t)return{name:t[1].toLocaleLowerCase(),argument:((n=t[2])==null?void 0:n.trim())??""}}function jgt(e){const t=e.toLocaleLowerCase();return nN.filter(n=>!t||[n.name,n.description,...n.keywords].some(i=>i.toLocaleLowerCase().includes(t))).sort((n,i)=>eY(n,t)-eY(i,t)).slice(0,12)}function eY(e,t){return t?e.name===t?0:e.name.startsWith(t)?1:e.name.includes(t)?2:3:nN.indexOf(e)}function Rgt(e,t){const n=t.toLocaleLowerCase();return e.filter(i=>!n||`${i.id} ${i.displayName} ${i.description}`.toLocaleLowerCase().includes(n)).sort((i,r)=>{if(!n)return Number(r.isDefault)-Number(i.isDefault);const s=i.id.toLocaleLowerCase(),a=r.id.toLocaleLowerCase(),o=(c,u)=>c===n?0:c.startsWith(n)?1:u.toLocaleLowerCase().startsWith(n)?2:3;return o(s,i.displayName)-o(a,r.displayName)}).slice(0,12)}function Igt(){return nN.map(e=>({label:e.usage,value:e.description}))}function Pgt(e,t){return e.map(n=>{const i=n.displayName.trim(),r=i&&i!==n.id?`${i} · ${n.id}`:n.id;return{label:n.id===t?"当前模型":"可用模型",value:n.description?`${r} — ${n.description}`:r,code:!1}})}function Mgt(e){const t=[{label:"Thread",value:e.threadId,code:!0},{label:"工作空间",value:e.cwd||"未设置",code:!!e.cwd}];return e.model&&t.push({label:"模型",value:e.model,code:!0}),t.push({label:"状态",value:e.busy?"运行中":"空闲"}),e.threadTotal&&t.push({label:"累计 Token",value:e.threadTotal.totalTokens.toLocaleString()}),e.modelContextWindow!==void 0&&t.push({label:"上下文窗口",value:e.modelContextWindow.toLocaleString()}),t}function sme(e){return e.messages.map(t=>{var i,r;const n=[];return t.role==="user"&&((i=t.skillNames)!=null&&i.length)&&n.push({kind:"invocation",value:{skills:t.skillNames.map(s=>({name:s,description:""}))}}),t.role==="user"&&((r=t.images)!=null&&r.length)&&n.push({kind:"attachment",files:t.images.map((s,a)=>({id:`${t.id}-image-${a}`,mimeType:s.mimeType,data:s.data,name:s.alt||s.name||"图片"}))}),t.content&&n.push({kind:"text",text:t.content}),{role:t.role,blocks:n,meta:{localId:t.id,ts:t.timestamp/1e3}}})}function Lgt({appName:e,value:t,onChange:n,onSubmit:i,onStop:r,disabled:s,busy:a,attachments:o,onAddFiles:c,onRemoveAttachment:u,actions:d,models:f,modelsLoading:h,modelsLoaded:p,currentModel:g,onRequestModels:b,skills:y,skillsLoading:O,skillsLoaded:v,selectedSkills:x,onRequestSkills:w,onSelectedSkillsChange:E}){const S=m.useRef(null),k=m.useRef(null),T=m.useRef(null),A=m.useRef(null),[N,C]=m.useState(!1),[M,L]=m.useState(0),[P,Q]=m.useState(!1);m.useLayoutEffect(()=>{const J=S.current;J&&(J.style.height="auto",J.style.height=`${Math.min(J.scrollHeight,200)}px`)},[t]);const j=m.useMemo(()=>{if(!t.startsWith("/")||t.includes(` +`))return;const J=t.slice(1),ie=J.search(/\s/),ue=(ie<0?J:J.slice(0,ie)).toLocaleLowerCase(),ye=ie<0?"":J.slice(ie).trim();if(!(ie>=0&&ue!=="model"))return{command:ue,argument:ye,modelMode:ie>=0}},[t]),$=m.useMemo(()=>{const J=/(^|\s)\$([^\s$]*)$/.exec(t);if(J)return{query:J[2],start:t.length-J[2].length-1,end:t.length}},[t]),U=m.useMemo(()=>{if($){const J=$.query.toLocaleLowerCase();return y.filter(ie=>!x.some(ue=>ue.id===ie.id||ue.name===ie.name)).filter(ie=>`${ie.name} ${ie.description}`.toLocaleLowerCase().includes(J)).slice(0,12).map(ie=>({kind:"skill",skill:ie}))}return j!=null&&j.modelMode?Rgt(f,j.argument).map(J=>({kind:"model",model:J})):j?jgt(j.command).map(J=>({kind:"command",command:J})):[]},[$,f,x,y,j]),B=!P&&!!($||j);m.useEffect(()=>{L(0)},[t]),m.useEffect(()=>{j!=null&&j.modelMode&&!p&&!h&&b()},[p,h,b,j==null?void 0:j.modelMode]),m.useEffect(()=>{$&&!v&&!O&&w()},[$,w,v,O]);const I=o.some(J=>J.status!=="ready"),X=a&&!!r,q=!s&&!a&&!I&&(t.trim().length>0||o.length>0);function D(J){Q(!1),C(!1),n(J)}function H(J){if(J.kind==="skill"){if(!$)return;const ie=t.slice(0,$.start)+t.slice($.end);E([...x,J.skill]),D(ie),Q(!0),requestAnimationFrame(()=>{var ue,ye;(ue=S.current)==null||ue.focus(),(ye=S.current)==null||ye.setSelectionRange($.start,$.start)});return}if(J.kind==="model"){D(`/model ${J.model.id}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}if(J.command.name==="model"){D("/model "),b(),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}if(J.command.name==="skill"||J.command.name==="skills"){D(`/${J.command.name}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()});return}D(`/${J.command.name}`),Q(!0),requestAnimationFrame(()=>{var ie;return(ie=S.current)==null?void 0:ie.focus()})}function re(J){var ie;C(!1),(ie=J.current)==null||ie.click()}function fe(J){const ie=J.target.files?Array.from(J.target.files):[];ie.length&&c(ie),J.target.value=""}const Ae=$?"可用 Skills":j!=null&&j.modelMode?"选择模型":"Codex 快捷命令";return l.jsxs("div",{className:"composer sandbox-codex-composer",children:[o.length>0?l.jsx(xA,{appName:e,compact:!0,items:o,onRemove:u}):null,l.jsxs("div",{className:"composer-box",children:[B?l.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":Ae,children:[l.jsxs("div",{className:"composer-command-head",children:[l.jsx(ugt,{}),l.jsx("span",{children:Ae}),j!=null&&j.modelMode&&g?l.jsxs("small",{children:["当前:",g]}):null,l.jsx("kbd",{children:$?"$":"/"})]}),$&&O?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Pc,{className:"spin"})," 正在发现当前工作区的 Skills…"]}):j!=null&&j.modelMode&&h?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(Pc,{className:"spin"})," 正在读取模型…"]}):U.length===0?l.jsx("div",{className:"composer-command-empty",children:$?"当前工作区没有匹配的 Skill":j!=null&&j.modelMode?"没有匹配模型,也可以直接输入模型 ID":"没有匹配的快捷命令"}):l.jsx("div",{className:"composer-command-list",children:U.map((J,ie)=>{const ue=J.kind==="command"?`command:${J.command.name}`:J.kind==="model"?`model:${J.model.id}`:`skill:${J.skill.id}`,ye=J.kind==="command"?J.command.usage:J.kind==="model"?J.model.displayName:`$${J.skill.name}`,Se=J.kind==="command"?J.command.description:J.kind==="model"?J.model.description||J.model.id:J.skill.description||"加载并执行该 Skill";return l.jsxs("button",{type:"button",role:"option","aria-selected":ie===M,className:`composer-command-item${ie===M?" is-active":""}`,onMouseDown:Re=>{Re.preventDefault(),H(J)},onMouseEnter:()=>L(ie),children:[l.jsx("span",{className:`composer-command-icon composer-command-icon--${J.kind}`,"aria-hidden":"true",children:J.kind==="command"?"/":J.kind==="model"?"◇":"$"}),l.jsxs("span",{className:"composer-command-copy",children:[l.jsx("strong",{children:ye}),l.jsx("span",{children:Se})]}),ie===M?l.jsx("kbd",{children:"↵"}):null]},ue)})})]}):null,l.jsxs("div",{className:"composer-left-controls",children:[l.jsxs("div",{className:"composer-menu-wrap",children:[l.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:s,onClick:()=>C(J=>!J),children:l.jsx(rgt,{className:"icon"})}),N?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>C(!1)}),l.jsxs("div",{className:"composer-menu",role:"menu",children:[l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(k),children:[l.jsx(ogt,{className:"icon"}),"上传图片"]}),l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(T),children:[l.jsx(lgt,{className:"icon"}),"上传文档或 PDF"]}),l.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>re(A),children:[l.jsx(cgt,{className:"icon"}),"上传视频"]}),l.jsx("div",{className:"composer-menu-separator",role:"separator"}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{C(!1),d.onOpenTerminal()},children:[l.jsx(ime,{className:"icon"}),"进入终端"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{C(!1),d.onOpenBrowser()},children:[l.jsx(rme,{className:"icon"}),"查看浏览器"]})]})]}):null]}),l.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:"Codex 权限","aria-label":"Codex 权限",disabled:d.settingsBusy||a,onClick:d.onOpenPermissions,children:l.jsx(AQ,{})}),l.jsx("button",{type:"button",className:`comp-icon sandbox-composer-control${d.workspaceLocked?" is-locked":""}`,title:d.workspaceLocked?"对话已开始,工作空间已锁定":"选择工作空间","aria-label":"Codex 工作空间",disabled:d.settingsBusy||a,onClick:d.onOpenWorkspace,children:l.jsx(_E,{})}),d.endpointCopyEnabled&&d.onCopyEndpoint?l.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint","aria-label":d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint",disabled:d.endpointCopyState==="copying",onClick:d.onCopyEndpoint,children:d.endpointCopyState==="copying"?l.jsx(Pc,{className:"spin"}):d.endpointCopyState==="copied"?l.jsx(pgt,{}):l.jsx(hgt,{})}):null]}),l.jsxs("div",{className:"composer-input-stack sandbox-composer-input",children:[x.length>0?l.jsx(yA,{skillPrefix:"$",value:{skills:x.map(({name:J,description:ie})=>({name:J,description:ie}))},onRemoveSkill:J=>E(x.filter(ie=>ie.name!==J))}):null,l.jsx("textarea",{ref:S,className:"comp-input scroll",rows:1,value:t,disabled:s,placeholder:"向 AgentKit 沙箱发送消息,输入 / 查看命令,输入 $ 调用 Skill…","aria-expanded":B,onChange:J=>D(J.target.value),onBlur:()=>window.setTimeout(()=>Q(!0),0),onKeyDown:J=>{if(!OQ(J.nativeEvent)){if(B){if((J.key==="ArrowDown"||J.key==="Tab"&&!J.shiftKey)&&U.length>0){J.preventDefault(),L(ie=>(ie+1)%U.length);return}if((J.key==="ArrowUp"||J.key==="Tab"&&J.shiftKey)&&U.length>0){J.preventDefault(),L(ie=>(ie-1+U.length)%U.length);return}if(J.key==="Enter"&&!J.shiftKey&&U[M]){J.preventDefault(),H(U[M]);return}if(J.key==="Escape"){J.preventDefault(),Q(!0);return}}if(J.key==="Backspace"&&!t&&J.currentTarget.selectionStart===0&&x.length>0){J.preventDefault(),E(x.slice(0,-1));return}J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),q&&i(t))}}})]}),l.jsx("button",{type:"button",className:"comp-send",disabled:X?!1:!q,onClick:X?r:()=>i(t),"aria-label":X?"停止生成":"发送",title:X?"停止生成":void 0,children:X?l.jsx(agt,{className:"icon"}):a?l.jsx(Pc,{className:"icon spin"}):l.jsx(sgt,{className:"icon"})})]}),l.jsx("input",{ref:k,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:fe}),l.jsx("input",{ref:T,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:fe}),l.jsx("input",{ref:A,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:fe})]})}const Dgt="_Badge_1viyg_1",$gt={Badge:Dgt},Qgt=({children:e,className:t,variant:n="soft",color:i="secondary",size:r="sm",pill:s,...a})=>l.jsx("div",{className:Ps($gt.Badge,t),"data-color":i,"data-size":r,"data-pill":s?"":void 0,"data-variant":n,...a,children:j$(e)});function Bgt(e){return e.trim().replace(/\/+$/,"")||window.location.origin}function Ugt(e){return["使用 AgentKit Studio Plugin 端云接力当前会话、项目和任务。请直接执行,不要让我手动打开终端。",`Studio:${Bgt(e.studioUrl)}`,`配对码:${e.pairingCode}`].join(` +`)}function ame(){return["codex plugin marketplace add volcengine/veadk-python","--sparse .agents/plugins","--sparse plugins/agentkit-studio","&& codex plugin add agentkit-studio@veadk-python"].join(" ")}function zgt(){return["请安装 AgentKit Studio Plugin。请直接执行以下安装命令,不要让我手动打开终端。",`安装命令:${ame()}`].join(` +`)}function tY(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function nY(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"8",y:"8",width:"11",height:"11",rx:"2"}),l.jsx("path",{d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})]})}function RR(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.25 4.25L19 7"})})}function iY(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M19 8a8 8 0 1 0 .35 7"}),l.jsx("path",{d:"M19 4v4h-4"})]})}function Fgt(e,t){const n=Math.max(0,Math.ceil((Date.parse(e)-t)/1e3)),i=Math.floor(n/3600),r=Math.floor(n%3600/60),s=n%60;return[i,r,s].map(a=>String(a).padStart(2,"0")).join(":")}const Vgt=[{id:"request",label:"等待端侧请求"},{id:"session",label:"创建云端 Session"},{id:"restore",label:"恢复项目"},{id:"continue",label:"发送续跑任务"}];function Xgt(e){switch(e.state){case"issued":return 0;case"creating":return 1;case"session-created":return 2;case"continuing":return 3;case"running":return 4;case"completed":return 4;case"failed":return e.failedStage==="creating-session"?1:e.failedStage==="uploading-project"||e.failedStage==="restoring-project"?2:3}}function qgt(e,t){const n=Xgt(e);return e.state==="failed"&&t===n?"failed":tzgt(),[]),L=m.useMemo(()=>ame(),[]),P=m.useMemo(()=>h?Ugt(h):"",[h]);if(m.useEffect(()=>{if(!e)return;p(null),b(null),f("conversation"),A(null),C(""),k(!1),E(Date.now());const X=new AbortController,q=++o.current;return x(!0),Kt.createCodexProjectHandoffPairing({signal:X.signal}).then(D=>{o.current===q&&(p(D),b({state:"issued",expireAt:D.expireAt}))}).catch(D=>{(D==null?void 0:D.name)!=="AbortError"&&o.current===q&&A({message:D instanceof Error?D.message:String(D),retryPairing:!0})}).finally(()=>{o.current===q&&x(!1)}),()=>{X.abort()}},[y,e]),m.useEffect(()=>{if(!e||!h)return;E(Date.now());const X=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval(X)},[e,h]),m.useEffect(()=>{if(!e||!h)return;let X=!1,q;const D=new AbortController,H=async()=>{if(!(X||Date.now()>=Date.parse(h.expireAt))){try{const re=await Kt.getCodexProjectHandoffStatus(h.pairingCode,{signal:D.signal});if(X||(b(re),re.state==="completed"||re.state==="failed"))return;q=window.setTimeout(()=>void H(),1500);return}catch(re){if((re==null?void 0:re.name)==="AbortError"||X)return;A({message:re instanceof Error?re.message:String(re),retryPairing:!1})}q=window.setTimeout(()=>void H(),1500)}};return H(),()=>{X=!0,D.abort(),q!==void 0&&window.clearTimeout(q)}},[e,h]),m.useEffect(()=>{(g==null?void 0:g.state)!=="running"&&(g==null?void 0:g.state)!=="completed"||!h||u.current===h.pairingCode||(u.current=h.pairingCode,n())},[g==null?void 0:g.state,n,h]),m.useEffect(()=>()=>{c.current!==void 0&&window.clearTimeout(c.current)},[]),m.useEffect(()=>{if(!e)return;const X=document.body.style.overflow;document.body.style.overflow="hidden";const q=window.requestAnimationFrame(()=>{var H;return(H=s.current)==null?void 0:H.focus()}),D=H=>{var J;if(H.key==="Escape"){H.preventDefault(),a.current();return}if(H.key!=="Tab")return;const re=(J=r.current)==null?void 0:J.querySelectorAll('button:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])');if(!(re!=null&&re.length))return;const fe=re[0],Ae=re[re.length-1];H.shiftKey&&document.activeElement===fe?(H.preventDefault(),Ae.focus()):!H.shiftKey&&document.activeElement===Ae&&(H.preventDefault(),fe.focus())};return window.addEventListener("keydown",D),()=>{window.cancelAnimationFrame(q),document.body.style.overflow=X,window.removeEventListener("keydown",D)}},[e]),!e)return null;async function Q(X,q){var D;if(!(!X||N)){A(null),C(q);try{if(!((D=navigator.clipboard)!=null&&D.writeText))throw new Error("当前浏览器不支持写入剪贴板。");await navigator.clipboard.writeText(X),c.current!==void 0&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{C(H=>H===q?"":H),c.current=void 0},1400)}catch(H){C(""),A({message:H instanceof Error?H.message:String(H),retryPairing:!1})}}}async function j(){const X=g==null?void 0:g.sessionId;if(!(!X||S)){A(null),k(!0);try{await i(X)}catch(q){A({message:q instanceof Error?q.message:String(q),retryPairing:!1}),k(!1)}}}function $(X){var q;f(X),(q=document.getElementById(`sandbox-project-upload-install-${X}-tab`))==null||q.focus()}function U(X){const q=["conversation","terminal"],D=q.indexOf(d);let H=null;X.key==="ArrowRight"&&(H=(D+1)%q.length),X.key==="ArrowLeft"&&(H=(D-1+q.length)%q.length),X.key==="Home"&&(H=0),X.key==="End"&&(H=q.length-1),H!==null&&(X.preventDefault(),$(q[H]))}const B=h?Fgt(h.expireAt,w):"00:00:00",I=h?w>=Date.parse(h.expireAt):!1;return zi.createPortal(l.jsx("div",{className:"sandbox-project-upload-backdrop",onMouseDown:X=>{X.target===X.currentTarget&&t()},children:l.jsxs("section",{ref:r,className:"sandbox-project-upload-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-project-upload-title","aria-describedby":"sandbox-project-upload-description",children:[l.jsxs("header",{className:"sandbox-project-upload-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"sandbox-project-upload-title-row",children:[l.jsx("h2",{id:"sandbox-project-upload-title",children:"接力到云端继续执行"}),l.jsx(Qgt,{className:"sandbox-project-upload-beta",color:"discovery",size:"sm",pill:!0,children:"Beta"})]}),l.jsx("p",{id:"sandbox-project-upload-description",children:"按顺序复制两段提示词,Codex 会通过插件将您的本地任务接力到云端"})]}),l.jsx("button",{ref:s,type:"button",className:"sandbox-project-upload-close",onClick:t,"aria-label":"关闭本地迁移引导",children:l.jsx(tY,{})})]}),l.jsxs("div",{className:"sandbox-project-upload-body",children:[T?l.jsxs("div",{className:"sandbox-project-upload-error",role:"alert",children:[l.jsx("span",{children:T.message}),T.retryPairing?l.jsxs("button",{type:"button",onClick:()=>O(X=>X+1),children:[l.jsx(iY,{}),"重试"]}):null]}):null,l.jsxs("section",{className:"sandbox-project-upload-stage",children:[l.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[l.jsx("span",{className:"sandbox-project-upload-stage-number",children:"1"}),l.jsxs("div",{children:[l.jsx("h3",{children:"安装插件"}),l.jsx("p",{children:"首次使用时,请选择一种安装方式。"})]}),l.jsxs("button",{type:"button",onClick:()=>void Q(d==="conversation"?M:L,d==="conversation"?"install-conversation":"install-terminal"),disabled:N!=="",children:[N===`install-${d}`?l.jsx(RR,{}):l.jsx(nY,{}),N===`install-${d}`?"已复制":d==="conversation"?"复制安装提示词":"复制安装命令"]})]}),l.jsxs("div",{className:`sandbox-project-upload-install-tabs is-${d}`,role:"tablist","aria-label":"插件安装方式",children:[l.jsx("span",{"aria-hidden":"true"}),l.jsx("button",{id:"sandbox-project-upload-install-conversation-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="conversation",tabIndex:d==="conversation"?0:-1,onClick:()=>f("conversation"),onKeyDown:U,children:"与 Codex 对话安装"}),l.jsx("button",{id:"sandbox-project-upload-install-terminal-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="terminal",tabIndex:d==="terminal"?0:-1,onClick:()=>f("terminal"),onKeyDown:U,children:"从终端安装"})]}),l.jsx("div",{id:"sandbox-project-upload-install-panel",className:`sandbox-project-upload-prompt${d==="terminal"?" is-command":""}`,role:"tabpanel","aria-labelledby":`sandbox-project-upload-install-${d}-tab`,children:l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:d==="conversation"?M:L})})})]}),l.jsxs("section",{className:"sandbox-project-upload-stage",children:[l.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[l.jsx("span",{className:"sandbox-project-upload-stage-number",children:"2"}),l.jsxs("div",{children:[l.jsx("h3",{children:"任务接力"}),l.jsx("p",{children:"插件安装完成后复制,Codex 会迁移当前项目并继续执行任务。"})]}),l.jsxs("button",{type:"button",onClick:()=>void Q(P,"handoff"),disabled:!P||v||N!=="",children:[N==="handoff"?l.jsx(RR,{}):l.jsx(nY,{}),N==="handoff"?"已复制":"复制接力提示词"]})]}),l.jsxs("div",{className:"sandbox-project-upload-pairing-notice",role:"status",children:[l.jsx("span",{children:v?"正在生成新的配对码":I?"配对码已过期":l.jsxs(l.Fragment,{children:["配对码有效期剩余 ",l.jsx("time",{children:B})]})}),l.jsxs("button",{type:"button",disabled:v,onClick:()=>O(X=>X+1),children:[l.jsx(iY,{}),v?"刷新中":"刷新配对码"]})]}),l.jsx("div",{className:"sandbox-project-upload-prompt",children:v?l.jsxs("div",{className:"sandbox-project-upload-loading",role:"status",children:[l.jsx("i",{"aria-hidden":"true"}),"正在生成配对码"]}):P?l.jsx("pre",{tabIndex:0,children:l.jsx("code",{children:P})}):l.jsx("div",{className:"sandbox-project-upload-loading",children:"配对码尚未生成。"})}),h&&g?l.jsxs("section",{className:"sandbox-project-upload-progress","aria-live":"polite","aria-label":"端云接力状态",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("span",{children:"接力状态"}),g.state!=="issued"?l.jsxs("p",{children:["已收到",g.agentName?`“${g.agentName}”`:g.projectName?`“${g.projectName}”`:"当前项目","的端云接力请求"]}):l.jsx("p",{children:"复制接力提示词后,Codex 的请求会显示在这里。"})]}),l.jsx("strong",{"data-state":g.state,children:Hgt(g)})]}),l.jsx("ol",{children:Vgt.map((X,q)=>{const D=qgt(g,q);return l.jsxs("li",{"data-state":D,children:[l.jsxs("span",{className:"sandbox-project-upload-progress-marker",children:[D==="done"?l.jsx(RR,{}):null,D==="failed"?l.jsx(tY,{}):null]}),l.jsx("span",{children:X.label})]},X.id)})}),g.state==="failed"&&g.error?l.jsx("p",{className:"sandbox-project-upload-progress-error",role:"alert",children:g.error}):null]}):null]})]}),l.jsxs("footer",{className:"sandbox-project-upload-actions",children:[l.jsx("button",{type:"button",onClick:t,children:"关闭"}),((g==null?void 0:g.state)==="running"||(g==null?void 0:g.state)==="completed")&&g.sessionId?l.jsx("button",{type:"button",className:"is-primary",disabled:S,onClick:()=>void j(),children:S?"正在进入":"进入 Codex"}):null]})]})}),document.body)}function Ggt({session:e,conversationBusy:t,onInputChange:n,onSessionPatch:i,onSnapshot:r,onActivity:s,onError:a}){const o=m.useRef((e==null?void 0:e.id)??""),c=m.useRef(0);o.current=(e==null?void 0:e.id)??"";const[u,d]=m.useState(!1),[f,h]=m.useState([]),[p,g]=m.useState(!1),[b,y]=m.useState(!1),[O,v]=m.useState([]),[x,w]=m.useState(!1),[E,S]=m.useState(!1),[k,T]=m.useState([]),[A,N]=m.useState(!1),[C,M]=m.useState([]),[L,P]=m.useState(!1),[Q,j]=m.useState(""),[$,U]=m.useState(""),[B,I]=m.useState("");m.useEffect(()=>{c.current+=1,d(!1),h([]),g(!1),y(!1),v([]),w(!1),S(!1),T([]),N(!1),M([]),P(!1),j(""),U(""),I("")},[e==null?void 0:e.id]);const X=m.useCallback(async()=>{const Ee=o.current;if(!Ee)return[];g(!0);try{const me=await Kt.listModels(Ee);return o.current===Ee&&(h(me),y(!0)),me}catch(me){return o.current===Ee&&(y(!0),a(me instanceof Error?me.message:String(me))),[]}finally{o.current===Ee&&g(!1)}},[a]),q=m.useCallback(async()=>{const Ee=o.current;if(!Ee)return[];w(!0);try{const me=await Kt.listSkills(Ee);return o.current===Ee&&(v(me),S(!0)),me}catch(me){return o.current===Ee&&(S(!0),a(me instanceof Error?me.message:String(me))),[]}finally{o.current===Ee&&w(!1)}},[a]),D=m.useCallback(async(Ee="",me=!1)=>{const oe=o.current;if(!oe)return;const Ne=++c.current;P(!0),j("");try{const Oe=await Kt.listThreads(oe,Ee?{cursor:Ee}:{});o.current===oe&&c.current===Ne&&(M(Ve=>{if(!me)return Oe.threads;const We=new Map(Ve.map(De=>[De.id,De]));for(const De of Oe.threads)We.set(De.id,De);return[...We.values()]}),U(Oe.nextCursor??""))}catch(Oe){o.current===oe&&c.current===Ne&&j(Oe instanceof Error?Oe.message:String(Oe))}finally{o.current===oe&&c.current===Ne&&P(!1)}},[]),H=m.useCallback(()=>D("",!1),[D]),re=m.useCallback(async()=>{!$||L||await D($,!0)},[D,L,$]),fe=m.useCallback(async()=>{N(!0),await H()},[H]);m.useEffect(()=>{e!=null&&e.id&&H()},[H,e==null?void 0:e.id]);function Ae(Ee){r(Ee),M(me=>[Ee.thread,...me.filter(oe=>oe.id!==Ee.thread.id)]),T([]),v([]),S(!1),N(!1)}async function J(Ee){const me=await Kt.newThread(Ee);o.current===Ee&&(Ae(me),s("已新建 Codex 对话",[{label:"Thread",value:me.threadId,code:!0}]))}async function ie(){const Ee=o.current;if(!(!Ee||u||t)){d(!0),j(""),a("");try{await J(Ee)}catch(me){if(o.current===Ee){const oe=me instanceof Error?me.message:String(me);j(oe),a(oe)}}finally{o.current===Ee&&d(!1)}}}async function ue(Ee){const me=o.current;if(!(!me||u||t)){if(Ee===(e==null?void 0:e.threadId)){N(!1);return}d(!0),a("");try{const oe=await Kt.resumeThread(me,Ee);if(o.current!==me)return;Ae(oe),s("已恢复 Codex 对话",[{label:"Thread",value:oe.threadId,code:!0}])}catch(oe){o.current===me&&a(oe instanceof Error?oe.message:String(oe))}finally{o.current===me&&d(!1)}}}async function ye(Ee){const me=o.current;if(!me||u||t)return!1;c.current+=1,P(!1),d(!0),I(Ee),j(""),a("");try{const oe=await Kt.deleteThread(me,Ee);return o.current!==me?!1:(oe.snapshot&&Ae(oe.snapshot),M(Ne=>Ne.filter(Oe=>Oe.id!==Ee)),s("已删除 Codex 历史会话",[{label:"Thread",value:Ee,code:!0}]),!0)}catch(oe){if(o.current===me){const Ne=oe instanceof Error?oe.message:String(oe);j(Ne),a(Ne)}return!1}finally{o.current===me&&(d(!1),I(""))}}async function Se(Ee){const me=e,oe=Ee.trim();if(!oe.startsWith("/"))return!1;if(!me||t||u)return!0;const Ne=Cgt(oe),Oe=Ne&&nN.find(Ve=>Ve.name===Ne.name);if(!Ne||!Oe)return a(`未知快捷命令:${oe.split(/\s/,1)[0]}。输入 /help 查看可用命令。`),!0;if(a(""),T([]),Oe.name==="model"&&!Ne.argument)return n("/model "),b||await X(),!0;if(Oe.name==="skill"||Oe.name==="skills")return n("$"),E||(await q()).length===0&&n(""),!0;if(Oe.name==="resume"&&!Ne.argument)return n(""),await fe(),!0;n(""),d(!0);try{if(Oe.name==="model"){const Ve=await Kt.setModel(me.id,Ne.argument);if(o.current!==me.id)return!0;i({model:Ve}),s("已切换 Codex 模型",[{label:"模型",value:Ve,code:!0}])}else if(Oe.name==="models"){const Ve=b?f:await X();if(o.current!==me.id)return!0;s(Ve.length>0?"Codex 可用模型":"当前没有可用模型",Pgt(Ve,me.model))}else if(Oe.name==="new"||Oe.name==="clear")await J(me.id);else if(Oe.name==="resume"){const Ve=await Kt.resumeThread(me.id,Ne.argument);if(o.current!==me.id)return!0;Ae(Ve),s("已恢复 Codex 对话",[{label:"Thread",value:Ve.threadId,code:!0}])}else if(Oe.name==="fork"){const Ve=await Kt.forkThread(me.id);if(o.current!==me.id)return!0;Ae(Ve),s("已分叉 Codex 对话",[{label:"Thread",value:Ve.threadId,code:!0}])}else if(Oe.name==="compact"){if(await Kt.compactThread(me.id),o.current!==me.id)return!0;s("已开始压缩当前 Codex 对话",[{label:"Thread",value:me.threadId,code:!0}])}else if(Oe.name==="archive"){const Ve=me.threadId,We=await Kt.archiveThread(me.id,Ve);if(o.current!==me.id)return!0;We.snapshot&&Ae(We.snapshot),M(De=>De.filter(mt=>mt.id!==Ve)),s("已归档 Codex 对话",[{label:"Thread",value:Ve,code:!0}])}else if(Oe.name==="status"){const Ve=await Kt.getStatus(me.id);if(o.current!==me.id)return!0;i(Ve),s("Codex 当前状态",Mgt(Ve))}else Oe.name==="help"&&s("Sandbox 支持的 Codex 快捷命令",Igt())}catch(Ve){o.current===me.id&&(n(oe),a(Ve instanceof Error?Ve.message:String(Ve)))}finally{o.current===me.id&&d(!1)}return!0}function Re(){v([]),S(!1),T([])}return{commandBusy:u,models:f,modelsLoading:p,modelsLoaded:b,loadModels:X,skills:O,skillsLoading:x,skillsLoaded:E,loadSkills:q,selectedSkills:k,setSelectedSkills:T,invalidateSkills:Re,threadsOpen:A,threads:C,threadsLoading:L,threadsError:Q,threadsHasMore:!!$,threadActionId:B,openThreads:fe,refreshThreads:H,loadMoreThreads:re,closeThreads:()=>{u||(N(!1),j(""))},newThread:ie,resumeThread:ue,deleteThread:ye,executeSlash:Se}}const Wgt={volcengine:"火山引擎 AgentKit 提供企业级 Agent 解决方案",byteplus:"BytePlus AgentKit 提供企业级 Agent 解决方案"},Zgt={volcengine:"https://docs.volcengine.com/docs/86681/1925174?lang=zh",byteplus:"https://docs.byteplus.com/en/docs/legal"};function Kgt(e){return e.toLowerCase()==="github"?l.jsx(Jwe,{className:"icon"}):l.jsx(tSe,{className:"icon"})}function Jgt({branding:e,cloudProvider:t,onUsername:n}){const[i,r]=m.useState(null),[s,a]=m.useState(""),[o,c]=m.useState(0),[u,d]=m.useState(""),f=m.useRef(null);m.useEffect(()=>{let y=!0;return r(null),a(""),OJ().then(O=>{y&&r(O)}).catch(O=>{y&&a(O instanceof Error?O.message:String(O))}),()=>{y=!1}},[o]);const h=i!==null&&i.length===0;m.useEffect(()=>{var y;h&&((y=f.current)==null||y.focus())},[h]);const p=OSe.test(u),g=t==="byteplus"?i$:n$,b=()=>{p&&n(u)};return l.jsxs("div",{className:"login",children:[l.jsx("header",{className:"login-top",children:l.jsxs("span",{className:"login-brand",children:[l.jsx("img",{className:"login-brand-logo",src:e.logoUrl||g,width:20,height:20,alt:"","aria-hidden":!0}),e.title]})}),l.jsx("main",{className:"login-main",children:l.jsxs("div",{className:"login-card",children:[l.jsx(oi,{as:"h1",className:"login-title",duration:4.8,spread:22,children:e.title}),s?l.jsxs("div",{className:"login-provider-error",role:"alert",children:[l.jsx("p",{children:s}),l.jsx("button",{type:"button",onClick:()=>c(y=>y+1),children:"重试"})]}):i===null?null:i.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"登录以继续使用"}),l.jsx("div",{className:"login-providers",children:i.map(y=>l.jsxs("button",{className:"login-btn",onClick:()=>xSe(y.loginUrl),children:[Kgt(y.id),l.jsxs("span",{children:["使用 ",y.label," 登录"]})]},y.id))})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"输入一个用户名即可开始"}),l.jsxs("form",{className:"login-name",onSubmit:y=>{y.preventDefault(),b()},children:[l.jsx("input",{ref:f,className:"login-name-input",value:u,onChange:y=>d(y.target.value),placeholder:"用户名(字母 + 数字,最多 16 位)",maxLength:16}),l.jsx("button",{type:"submit",className:"login-name-go",disabled:!p,"aria-label":"进入",children:l.jsx(ay,{className:"icon"})})]}),l.jsx("p",{className:"login-hint","aria-live":"polite",children:u&&!p?"只能包含大小写字母和数字,最多 16 位。":""})]}),l.jsx("p",{className:"login-powered",children:Wgt[t]}),l.jsxs("p",{className:"login-legal",children:["继续即表示你已阅读并同意 AgentKit"," ",l.jsx("a",{href:Zgt[t],target:"_blank",rel:"noreferrer",children:"产品和服务条款"})]})]})}),l.jsx("footer",{className:"login-footer",children:"© 2026 VeADK. All rights reserved."})]})}function e0t({open:e,checking:t,error:n,onLogin:i}){const r=m.useRef(null);return m.useEffect(()=>{var a;if(!e)return;const s=document.body.style.overflow;return document.body.style.overflow="hidden",(a=r.current)==null||a.focus(),()=>{document.body.style.overflow=s}},[e]),e?zi.createPortal(l.jsx("div",{className:"auth-expired-backdrop",children:l.jsxs("section",{className:"auth-expired-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"auth-expired-title","aria-describedby":"auth-expired-description",children:[l.jsx("div",{className:"auth-expired-mark","aria-hidden":"true",children:l.jsx(uJ,{})}),l.jsxs("div",{className:"auth-expired-copy",children:[l.jsx("h2",{id:"auth-expired-title",children:"登录状态已过期"}),l.jsx("p",{id:"auth-expired-description",children:"当前编辑内容会保留。重新登录后,刚才的操作将自动继续。"}),n&&l.jsx("p",{className:"auth-expired-error",role:"alert",children:n})]}),l.jsx("footer",{className:"auth-expired-actions",children:l.jsx("button",{ref:r,type:"button",onClick:i,disabled:t,children:t?"等待登录完成…":"重新登录"})})]})}),document.body):null}const t0t=[{value:"slow",label:"执行速度慢"},{value:"crash",label:"运行崩溃"},{value:"incorrect",label:"结果不准确"},{value:"tool_error",label:"工具调用失败"},{value:"other",label:"其他问题"}];function n0t(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function i0t(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function r0t({onClose:e,onSubmit:t}){const n=m.useId(),i=m.useId(),r=m.useRef(null),s=m.useRef(null),a=m.useRef(!1),o=m.useRef(e),[c,u]=m.useState(()=>new Set),[d,f]=m.useState(""),[h,p]=m.useState(!1),[g,b]=m.useState(""),[y,O]=m.useState(!1);a.current=h,o.current=e,m.useEffect(()=>{var T;const E=document.body.style.overflow,S=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(T=s.current)==null||T.focus();const k=A=>{var L;if(A.key==="Escape"&&!a.current){A.preventDefault(),o.current();return}if(A.key!=="Tab")return;const N=Array.from(((L=r.current)==null?void 0:L.querySelectorAll("button:not(:disabled), textarea:not(:disabled)"))??[]);if(N.length===0)return;const C=N[0],M=N[N.length-1];A.shiftKey&&document.activeElement===C?(A.preventDefault(),M.focus()):!A.shiftKey&&document.activeElement===M&&(A.preventDefault(),C.focus())};return window.addEventListener("keydown",k),()=>{document.body.style.overflow=E,window.removeEventListener("keydown",k),S!=null&&S.isConnected&&S.focus()}},[]);const v=E=>{u(S=>{const k=new Set(S);return k.has(E)?k.delete(E):k.add(E),k})},x=async()=>{if(!(h||y)){p(!0),b("");try{await t({issues:[...c],description:d.trim()}),O(!0)}catch(E){b(E instanceof Error?E.message:String(E))}finally{p(!1)}}},w=c.size>0||d.trim().length>0;return zi.createPortal(l.jsx("div",{className:"issue-feedback-backdrop",onMouseDown:E=>{E.target===E.currentTarget&&!h&&e()},children:l.jsxs("section",{ref:r,className:"issue-feedback-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":y?`${i}-success`:i,"aria-busy":h||void 0,children:[l.jsxs("header",{className:"issue-feedback-head",children:[l.jsx("h2",{id:n,children:"问题反馈"}),l.jsx("button",{type:"button",className:"issue-feedback-close",onClick:e,disabled:h,"aria-label":"关闭问题反馈",children:l.jsx(n0t,{})})]}),y?l.jsxs("div",{className:"issue-feedback-success",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"issue-feedback-success-mark","aria-hidden":"true",children:l.jsx(i0t,{})}),l.jsxs("div",{children:[l.jsx("h3",{children:"上报成功,感谢您的反馈"}),l.jsx("p",{id:`${i}-success`,children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):l.jsxs("div",{className:"issue-feedback-body",children:[l.jsx("p",{id:i,className:"issue-feedback-intro",children:"请选择遇到的问题,也可以补充具体表现。"}),l.jsx("p",{className:"issue-feedback-privacy",role:"alert",children:"您的对话数据将会上报到 AgentKit 团队,请注意隐私保护。"}),l.jsx("div",{className:"issue-feedback-chips","aria-label":"常见问题",children:t0t.map(E=>l.jsx("button",{type:"button",className:"issue-feedback-chip","aria-pressed":c.has(E.value),onClick:()=>v(E.value),disabled:h,children:E.label},E.value))}),l.jsxs("label",{className:"issue-feedback-field",children:[l.jsx("span",{children:"问题描述"}),l.jsx("textarea",{ref:s,value:d,onChange:E=>f(E.target.value),placeholder:"请描述问题发生时的表现(选填)",maxLength:4e3,rows:5,disabled:h})]}),g&&l.jsx("p",{className:"issue-feedback-error",role:"alert",children:g})]}),l.jsx("footer",{className:"issue-feedback-actions",children:y?l.jsx("button",{type:"button",className:"is-primary",onClick:e,children:"完成"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:e,disabled:h,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:()=>void x(),disabled:!w||h,children:h?"正在上报…":"提交反馈"})]})})]})}),document.body)}function s0t(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),t&&(i.href=t),r.href=e,r.href}const a0t=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Tf(e){const t=[];for(let n=0,i=e.length;nno||e.height>no)&&(e.width>no&&e.height>no?e.width>e.height?(e.height*=no/e.width,e.width=no):(e.width*=no/e.height,e.height=no):e.width>no?(e.height*=no/e.width,e.width=no):(e.width*=no/e.height,e.height=no))}function d0t(e,t={}){return e.toBlob?new Promise(n=>{e.toBlob(n,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(n=>{const i=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),r=i.length,s=new Uint8Array(r);for(let a=0;a{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>t(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=e})}async function f0t(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function h0t(e,t,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${t}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(e),f0t(r)}const Va=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Va(n,t)};function p0t(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function m0t(e,t){return ome(t).map(n=>{const i=e.getPropertyValue(n),r=e.getPropertyPriority(n);return`${n}: ${i}${r?" !important":""};`}).join(" ")}function g0t(e,t,n,i){const r=`.${e}:${t}`,s=n.cssText?p0t(n):m0t(n,i);return document.createTextNode(`${r}{${s}}`)}function rY(e,t,n,i){const r=window.getComputedStyle(e,n),s=r.getPropertyValue("content");if(s===""||s==="none")return;const a=a0t();try{t.className=`${t.className} ${a}`}catch{return}const o=document.createElement("style");o.appendChild(g0t(a,n,r,i)),t.appendChild(o)}function b0t(e,t,n){rY(e,t,":before",n),rY(e,t,":after",n)}const sY="application/font-woff",aY="image/jpeg",O0t={woff:sY,woff2:sY,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:aY,jpeg:aY,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function y0t(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function NQ(e){const t=y0t(e).toLowerCase();return O0t[t]||""}function x0t(e){return e.split(/,/)[1]}function WL(e){return e.search(/^(data:)/)!==-1}function v0t(e,t){return`data:${t};base64,${e}`}async function cme(e,t,n){const i=await fetch(e,t);if(i.status===404)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((s,a)=>{const o=new FileReader;o.onerror=a,o.onloadend=()=>{try{s(n({res:i,result:o.result}))}catch(c){a(c)}},o.readAsDataURL(r)})}const IR={};function w0t(e,t,n){let i=e.replace(/\?.*/,"");return n&&(i=e),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),t?`[${t}]${i}`:i}async function CQ(e,t,n){const i=w0t(e,t,n.includeQueryParams);if(IR[i]!=null)return IR[i];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{const s=await cme(e,n.fetchRequestInit,({res:a,result:o})=>(t||(t=a.headers.get("Content-Type")||""),x0t(o)));r=v0t(s,t)}catch(s){r=n.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;s&&(a=typeof s=="string"?s:s.message),a&&console.warn(a)}return IR[i]=r,r}async function S0t(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):zT(t)}async function E0t(e,t){if(e.currentSrc){const s=document.createElement("canvas"),a=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,a==null||a.drawImage(e,0,0,s.width,s.height);const o=s.toDataURL();return zT(o)}const n=e.poster,i=NQ(n),r=await CQ(n,i,t);return zT(r)}async function k0t(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await iN(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function T0t(e,t){return Va(e,HTMLCanvasElement)?S0t(e):Va(e,HTMLVideoElement)?E0t(e,t):Va(e,HTMLIFrameElement)?k0t(e,t):e.cloneNode(ume(e))}const _0t=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",ume=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function A0t(e,t,n){var i,r;if(ume(t))return t;let s=[];return _0t(e)&&e.assignedNodes?s=Tf(e.assignedNodes()):Va(e,HTMLIFrameElement)&&(!((i=e.contentDocument)===null||i===void 0)&&i.body)?s=Tf(e.contentDocument.body.childNodes):s=Tf(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),s.length===0||Va(e,HTMLVideoElement)||await s.reduce((a,o)=>a.then(()=>iN(o,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function N0t(e,t,n){const i=t.style;if(!i)return;const r=window.getComputedStyle(e);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):ome(n).forEach(s=>{let a=r.getPropertyValue(s);s==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),Va(e,HTMLIFrameElement)&&s==="display"&&a==="inline"&&(a="block"),s==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),i.setProperty(s,a,r.getPropertyPriority(s))})}function C0t(e,t){Va(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Va(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function j0t(e,t){if(Va(e,HTMLSelectElement)){const n=t,i=Array.from(n.children).find(r=>e.value===r.getAttribute("value"));i&&i.setAttribute("selected","")}}function R0t(e,t,n){return Va(t,Element)&&(N0t(e,t,n),b0t(e,t,n),C0t(e,t),j0t(e,t)),t}async function I0t(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const i={};for(let s=0;sT0t(i,t)).then(i=>A0t(e,i,t)).then(i=>R0t(e,i,t)).then(i=>I0t(i,t))}const dme=/url\((['"]?)([^'"]+?)\1\)/g,P0t=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,M0t=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function L0t(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function D0t(e){const t=[];return e.replace(dme,(n,i,r)=>(t.push(r),n)),t.filter(n=>!WL(n))}async function $0t(e,t,n,i,r){try{const s=n?s0t(t,n):t,a=NQ(t);let o;return r||(o=await CQ(s,a,i)),e.replace(L0t(t),`$1${o}$3`)}catch{}return e}function Q0t(e,{preferredFontFormat:t}){return t?e.replace(M0t,n=>{for(;;){const[i,,r]=P0t.exec(n)||[];if(!r)return"";if(r===t)return`src: ${i};`}}):e}function fme(e){return e.search(dme)!==-1}async function hme(e,t,n){if(!fme(e))return e;const i=Q0t(e,n);return D0t(i).reduce((s,a)=>s.then(o=>$0t(o,a,t,n)),Promise.resolve(i))}async function vm(e,t,n){var i;const r=(i=t.style)===null||i===void 0?void 0:i.getPropertyValue(e);if(r){const s=await hme(r,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function B0t(e,t){await vm("background",e,t)||await vm("background-image",e,t),await vm("mask",e,t)||await vm("-webkit-mask",e,t)||await vm("mask-image",e,t)||await vm("-webkit-mask-image",e,t)}async function U0t(e,t){const n=Va(e,HTMLImageElement);if(!(n&&!WL(e.src))&&!(Va(e,SVGImageElement)&&!WL(e.href.baseVal)))return;const i=n?e.src:e.href.baseVal,r=await CQ(i,NQ(i),t);await new Promise((s,a)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...c)=>{try{s(t.onImageErrorHandler(...c))}catch(u){a(u)}}:a;const o=e;o.decode&&(o.decode=s),o.loading==="lazy"&&(o.loading="eager"),n?(e.srcset="",e.src=r):e.href.baseVal=r})}async function z0t(e,t){const i=Tf(e.childNodes).map(r=>pme(r,t));await Promise.all(i).then(()=>e)}async function pme(e,t){Va(e,Element)&&(await B0t(e,t),await U0t(e,t),await z0t(e,t))}function F0t(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const i=t.style;return i!=null&&Object.keys(i).forEach(r=>{n[r]=i[r]}),e}const oY={};async function lY(e){let t=oY[e];if(t!=null)return t;const i=await(await fetch(e)).text();return t={url:e,cssText:i},oY[e]=t,t}async function cY(e,t){let n=e.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async a=>{let o=a.replace(i,"$1");return o.startsWith("https://")||(o=new URL(o,e.url).href),cme(o,t.fetchRequestInit,({result:c})=>(n=n.replace(a,`url(${c})`),[a,c]))});return Promise.all(s).then(()=>n)}function uY(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let i=e.replace(n,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=r.exec(i);if(c===null)break;t.push(c[0])}i=i.replace(r,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",o=new RegExp(a,"gi");for(;;){let c=s.exec(i);if(c===null){if(c=o.exec(i),c===null)break;s.lastIndex=o.lastIndex}else o.lastIndex=s.lastIndex;t.push(c[0])}return t}async function V0t(e,t){const n=[],i=[];return e.forEach(r=>{if("cssRules"in r)try{Tf(r.cssRules||[]).forEach((s,a)=>{if(s.type===CSSRule.IMPORT_RULE){let o=a+1;const c=s.href,u=lY(c).then(d=>cY(d,t)).then(d=>uY(d).forEach(f=>{try{r.insertRule(f,f.startsWith("@import")?o+=1:r.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:f,error:h})}})).catch(d=>{console.error("Error loading remote css",d.toString())});i.push(u)}})}catch(s){const a=e.find(o=>o.href==null)||document.styleSheets[0];r.href!=null&&i.push(lY(r.href).then(o=>cY(o,t)).then(o=>uY(o).forEach(c=>{a.insertRule(c,a.cssRules.length)})).catch(o=>{console.error("Error loading remote stylesheet",o)})),console.error("Error inlining remote css file",s)}}),Promise.all(i).then(()=>(e.forEach(r=>{if("cssRules"in r)try{Tf(r.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${r.href}`,s)}}),n))}function X0t(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>fme(t.style.getPropertyValue("src")))}async function q0t(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Tf(e.ownerDocument.styleSheets),i=await V0t(n,t);return X0t(i)}function mme(e){return e.trim().replace(/["']/g,"")}function H0t(e){const t=new Set;function n(i){(i.style.fontFamily||getComputedStyle(i).fontFamily).split(",").forEach(s=>{t.add(mme(s))}),Array.from(i.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function Y0t(e,t){const n=await q0t(e,t),i=H0t(e);return(await Promise.all(n.filter(s=>i.has(mme(s.style.fontFamily))).map(s=>{const a=s.parentStyleSheet?s.parentStyleSheet.href:null;return hme(s.cssText,a,t)}))).join(` +`)}async function G0t(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Y0t(e,t);if(n){const i=document.createElement("style"),r=document.createTextNode(n);i.appendChild(r),e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}}async function W0t(e,t={}){const{width:n,height:i}=lme(e,t),r=await iN(e,t,!0);return await G0t(r,t),await pme(r,t),F0t(r,t),await h0t(r,n,i)}async function Z0t(e,t={}){const{width:n,height:i}=lme(e,t),r=await W0t(e,t),s=await zT(r),a=document.createElement("canvas"),o=a.getContext("2d"),c=t.pixelRatio||c0t(),u=t.canvasWidth||n,d=t.canvasHeight||i;return a.width=u*c,a.height=d*c,t.skipAutoScale||u0t(a),a.style.width=`${u}`,a.style.height=`${d}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(s,0,0,a.width,a.height),a}async function K0t(e,t={}){const n=await Z0t(e,t);return await d0t(n)}const J0t=16384,ebt=32e6;function tbt(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m7 7 10 10"}),l.jsx("path",{d:"m17 7-10 10"})]})}function nbt(){const e=getComputedStyle(document.documentElement).getPropertyValue("--background").trim();return e?`hsl(${e})`:"white"}function ibt(e,t){const n=Math.min(Math.max(window.devicePixelRatio||1,1),2),i=J0t/Math.max(e,t),r=Math.sqrt(ebt/Math.max(e*t,1));return Math.min(n,i,r)}function rbt(e){const t=e.closest(".transcript");if(!t)return[e];const n=Array.from(t.children).filter(r=>r instanceof HTMLElement&&r.matches(".turn--user, .turn--assistant")),i=n.indexOf(e);return i>=0?n.slice(0,i+1):[e]}function sbt(e){const t=document.createElement("section");t.className="share-message-export",t.setAttribute("aria-hidden","true");for(const i of rbt(e)){const r=i.cloneNode(!0);r.removeAttribute("data-share-message-source"),r.classList.remove("is-feedback-target"),r.style.opacity="1",r.style.transform="none",r.style.animation="none",r.querySelectorAll("[data-share-image-exclude]").forEach(s=>s.remove()),t.append(r)}const n=document.createElement("p");return n.className="share-message-export-note",n.textContent="上述会话由 AgentKit Studio 导出,仅供参考",t.append(n),document.body.append(t),t}async function abt(e){var n;(n=document.fonts)!=null&&n.ready&&await document.fonts.ready;const t=sbt(e);try{const i=Math.ceil(t.scrollWidth),r=Math.ceil(t.scrollHeight),s=ibt(i,r);if(s<.2)throw new Error("当前会话过长,暂时无法生成单张图片。");const a=await K0t(t,{width:i,height:r,pixelRatio:s,backgroundColor:nbt(),cacheBust:!0,style:{position:"static",top:"auto",left:"auto",width:`${i}px`,height:`${r}px`,margin:"0",overflow:"visible",animation:"none"}});if(!a)throw new Error("图片生成失败,请重试。");return a}finally{t.remove()}}function obt(){return`agentkit-conversation-${new Date().toISOString().replace(/[:.]/g,"-")}.png`}function lbt({targetTurn:e,onClose:t}){const n=m.useId(),i=m.useId(),r=m.useRef(null),s=m.useRef(null),a=m.useRef(t),o=m.useRef(void 0),[c,u]=m.useState("generating"),[d,f]=m.useState(0),[h,p]=m.useState(null),[g,b]=m.useState(""),[y,O]=m.useState(""),[v,x]=m.useState("idle");a.current=t,m.useEffect(()=>{var A;const S=document.body.style.overflow,k=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(A=s.current)==null||A.focus();const T=N=>{var P;if(N.key==="Escape"){N.preventDefault(),a.current();return}if(N.key!=="Tab")return;const C=Array.from(((P=r.current)==null?void 0:P.querySelectorAll("button:not(:disabled)"))??[]);if(C.length===0)return;const M=C[0],L=C[C.length-1];N.shiftKey&&document.activeElement===M?(N.preventDefault(),L.focus()):!N.shiftKey&&document.activeElement===L&&(N.preventDefault(),M.focus())};return window.addEventListener("keydown",T),()=>{document.body.style.overflow=S,window.removeEventListener("keydown",T),o.current!==void 0&&window.clearTimeout(o.current),k!=null&&k.isConnected&&k.focus()}},[]),m.useEffect(()=>{let S=!1,k="";return u("generating"),p(null),b(""),O(""),x("idle"),abt(e).then(T=>{if(k=URL.createObjectURL(T),S){URL.revokeObjectURL(k);return}p(T),b(k),u("ready")}).catch(T=>{S||(u("error"),O(T instanceof Error?T.message:String(T)))}),()=>{S=!0,k&&URL.revokeObjectURL(k)}},[d,e]);const w=async()=>{var S;if(!(!h||v==="copying")){x("copying"),O("");try{if(!((S=navigator.clipboard)!=null&&S.write)||typeof ClipboardItem>"u")throw new Error("当前浏览器不支持复制图片,请下载后使用。");await navigator.clipboard.write([new ClipboardItem({"image/png":h})]),x("copied"),o.current=window.setTimeout(()=>x("idle"),1500)}catch(k){x("idle"),O(k instanceof Error?k.message:String(k))}}},E=()=>{if(!h)return;const S=URL.createObjectURL(h),k=document.createElement("a");k.href=S,k.download=obt(),k.style.display="none",document.body.append(k),k.click(),k.remove(),window.setTimeout(()=>URL.revokeObjectURL(S),1e3)};return zi.createPortal(l.jsx("div",{className:"share-message-backdrop",onMouseDown:S=>{S.target===S.currentTarget&&t()},children:l.jsxs("section",{ref:r,className:"share-message-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":i,"aria-busy":c==="generating",children:[l.jsxs("header",{className:"share-message-head",children:[l.jsxs("div",{children:[l.jsx("h2",{id:n,children:"分享为图片"}),l.jsx("p",{id:i,children:"包含截至当前回复的全部输入与输出。"})]}),l.jsx("button",{ref:s,type:"button",className:"share-message-close","aria-label":"关闭",title:"关闭",onClick:t,children:l.jsx(tbt,{})})]}),l.jsxs("div",{className:"share-message-body",children:[c==="generating"?l.jsx("div",{className:"share-message-generating",role:"status",children:l.jsx(oi,{children:"正在生成图片…"})}):c==="error"?l.jsxs("div",{className:"share-message-failure",children:[l.jsx("p",{role:"alert",children:y||"图片生成失败,请重试。"}),l.jsx("button",{type:"button",onClick:()=>f(S=>S+1),children:"重试生成"})]}):l.jsx("div",{className:"share-message-preview",children:l.jsx("img",{src:g,alt:"会话记录分享图片预览"})}),c!=="error"&&y&&l.jsx("p",{className:"share-message-error",role:"alert",children:y})]}),l.jsxs("footer",{className:"share-message-actions",children:[l.jsx("button",{type:"button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",onClick:E,disabled:!h||c!=="ready",children:"下载 PNG"}),l.jsx("button",{type:"button",className:"is-primary",onClick:()=>void w(),disabled:!h||c!=="ready"||v==="copying",children:v==="copying"?"正在复制…":v==="copied"?"已复制":"复制图片"})]})]})}),document.body)}const cbt=(e,t)=>{const n=e.currentTarget,i={x:e.clientX,y:e.clientY},r=ubt(i,n.getBoundingClientRect()),s=dbt(i,r),a=fbt(t.getBoundingClientRect());return pbt([...s,...a])};function ubt(e,t){const n=Math.abs(t.top-e.y),i=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function dbt(e,t,n=5){const i=[];switch(t){case"top":i.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":i.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":i.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":i.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return i}function fbt(e){const{top:t,right:n,bottom:i,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:i},{x:r,y:i}]}function hbt(e,t){const{x:n,y:i}=e;let r=!1;for(let s=0,a=t.length-1;si!=h>i&&n<(f-u)*(i-d)/(h-d)+u&&(r=!r)}return r}function pbt(e){const t=e.slice();return t.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),mbt(t)}function mbt(e){if(e.length<=1)return e.slice();const t=[];for(let i=0;i=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(r.y-a.y)>=(s.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const gbt="_Transition_1wdpp_1",bbt="_Popover_1wdpp_3",gme={Transition:gbt,Popover:bbt},bme=m.createContext(null),rN=()=>{const e=m.use(bme);if(!e)throw new Error("Popover components must be wrapped in ");return e},Py=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:i=150,children:r})=>{const[s,a]=m.useState(!1),[o,c]=m.useState(!1),u=m.useRef(null),d=m.useRef(null),f=m.useRef(void 0),h=m.useRef(!1),p=m.useRef(!1),g=e??s,[b,y]=m.useState(!1);R$(()=>y(!1),b?500:null);const O=eM(t),v=eM(k=>{var T,A;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((T=u.current)==null||T.focus()),h.current=!1),(A=O.current)==null||A.call(O,k),a(k),n&&y(k))}),x=m.useCallback(k=>{v.current(k)},[v]),w=m.useCallback(()=>{f.current=setTimeout(()=>x(!0),i)},[x,i]),E=m.useCallback(()=>{clearTimeout(f.current)},[]);m.useEffect(()=>()=>{clearTimeout(f.current)},[]);const S=m.useMemo(()=>({open:g,setOpen:x,shake:o,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:E,isPointerInTransitRef:p,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,o,c,n,b,h,p,w,E]);return l.jsx(bme,{value:S,children:l.jsx(k$e,{open:g,onOpenChange:x,modal:!1,children:r})})},Obt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:i,showOnHover:r,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:o,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=rN(),f=m.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},p=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(o(),f.current=!1)};return l.jsx(T$e,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:r?p:void 0,onPointerLeave:r?g:void 0,onFocus:r?()=>i(!0):void 0,onBlur:r?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||i(!1)},50)}:void 0,children:e})},Ome=({children:e,avoidCollisions:t,width:n,minWidth:i,maxWidth:r,side:s,sideOffset:a=8,align:o,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:p,contentRef:g}=rN(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=die(O),x=v[v.length-1];x==null||x.focus()}};return m.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),l.jsx(A$e,{forceMount:!0,ref:g,className:Ps(gme.Popover,d),style:C$({"popover-width":n,"popover-min-width":i,"popover-max-width":r}),onCloseAutoFocus:h?ZS:void 0,"data-animate":p?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:o,alignOffset:c??(o==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:ZS,onEscapeKeyDown:ZS,onKeyDown:b,children:e})},ybt=e=>{const{setOpen:t,triggerRef:n,contentRef:i,isPointerInTransitRef:r,hoverOpenFocusedWithTab:s}=rN(),[a,o]=m.useState(null),c=m.useCallback(()=>{o(null),r.current=!1},[r]),u=m.useCallback((d,f)=>{const h=cbt(d,f);o(h),r.current=!0},[r]);return m.useEffect(()=>()=>c(),[c]),m.useEffect(()=>{const d=n.current,f=i.current;if(!d||!f)return;const h=g=>u(g,f),p=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",p),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",p)}},[i,n,u,c]),m.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,p=i.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(p==null?void 0:p.contains(g)),O=!hbt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,i]),m.useEffect(()=>{const d=f=>{if(i.current&&f.key==="Tab"&&!f.shiftKey){const[h]=die(i.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[i,s]),l.jsx(Ome,{...e})},xbt=e=>{const{open:t,showOnHover:n,setOpen:i}=rN();return ose(t,()=>{i(!1)}),l.jsx(_$e,{forceMount:!0,children:l.jsx(pie,{enterDuration:600,exitDuration:300,className:gme.Transition,disableAnimations:!0,children:t&&(n?l.jsx(ybt,{...e},"popover-hover"):l.jsx(Ome,{...e},"popover"))})})};Py.Trigger=Obt;Py.Content=xbt;const vbt="_Container_13560_1",wbt="_Textarea_13560_174",dY={Container:vbt,Textarea:wbt},Sbt=e=>{const t=m.useRef(null),i=`search-ui-input-${m.useId()}`,{id:r,name:s,variant:a="outline",size:o="md",gutterSize:c,className:u,autoComplete:d,disabled:f=!1,readOnly:h=!1,invalid:p=!1,allowAutofillExtensions:g=!!s,onFocus:b,onBlur:y,onAnimationStart:O,onAutofill:v,autoSelect:x,rows:w=3,maxRows:E,autoResize:S,ref:k,onChange:T,...A}=e,[N,C]=m.useState(!1),M=S?Math.max(E??10,w):w;m.useEffect(()=>{var Q;x&&((Q=t.current)==null||Q.select())},[x]);const L=Q=>{O==null||O(Q),Q.animationName==="native-autofill-in"&&(v==null||v())},P=m.useCallback(()=>{if(!S||!t.current||M===void 0)return;t.current.style.height="0px";const Q=t.current.scrollHeight;t.current.style.height=Q+"px"},[S,M]);return m.useEffect(()=>{P()},[e.value,w,P]),l.jsx("div",{className:Ps(dY.Container,u),"data-variant":a,"data-size":o,"data-gutter-size":c,"data-focused":N,"data-disabled":f?"":void 0,"data-readonly":h?"":void 0,"data-invalid":p?"":void 0,style:C$({"textarea-min-rows":`${w}`,"textarea-max-rows":`${M}`}),children:l.jsx("textarea",{...A,onChange:Q=>{T==null||T(Q),P()},ref:fie([t,k]),id:r||(g?void 0:i),className:dY.Textarea,name:s,readOnly:h,disabled:f,rows:w,onFocus:Q=>{C(!0),b==null||b(Q)},onBlur:Q=>{C(!1),y==null||y(Q)},onAnimationStart:L,"data-lpignore":g?void 0:!0,"data-1p-ignore":g?void 0:!0})})},Ebt=2e3,kbt=700,yme=1200;function jQ(e,t){const n=Array.from(e);return n.length<=t?e:`${n.slice(0,t-1).join("").trimEnd()}…`}function xme(e){return jQ(e.trim(),kbt)}function vme(e){return jQ(e,yme)}function fY(e){return e.trim().length>0}function Tbt(e,t){const n=xme(e),i=vme(t.trim());return jQ(`选中片段:${n} -批注:${i}`,Sbt)}function fY(e){return e?e instanceof Element?e:e.parentElement:null}function Tbt(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;const n=fY(t.anchorNode),i=fY(t.focusNode);if(!n||!i||!e.contains(n)||!e.contains(i)||!n.closest(".bubble")||!i.closest(".bubble"))return null;const r=t.toString().trim();if(!r)return null;const s=t.getRangeAt(0).getBoundingClientRect();return s.width<=0||s.height<=0?null:{text:r,anchor:{left:s.left+s.width/2,top:s.top,height:s.height}}}function _bt({anchor:e,selectedText:t,onClose:n,onSubmit:i}){const r=m.useRef(!1),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(""),[f,h]=m.useState(!1),p=yme(t),g=m.useCallback(()=>{var y;(y=window.getSelection())==null||y.removeAllRanges(),n()},[n]);r.current=o,m.useEffect(()=>{const y=()=>{r.current||g()},O=v=>{const x=v.target;x instanceof Element&&x.closest(".response-annotation-popover")||r.current||g()};return window.addEventListener("resize",y),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",O,!0)}},[g]);const b=async()=>{if(!(o||f||!dY(s))){c(!0),d("");try{await i(s.trim()),h(!0)}catch(y){d(y instanceof Error?y.message:String(y))}finally{c(!1)}}};return l.jsxs(Py,{open:!0,onOpenChange:y=>{!y&&!o&&g()},children:[l.jsx(Py.Trigger,{children:l.jsx("span",{className:"response-annotation-anchor",style:{left:e.left,top:e.top,height:e.height},"aria-hidden":"true"})}),l.jsx(Py.Content,{side:"top",sideOffset:8,align:"center",minWidth:"auto",className:"response-annotation-popover",children:f?l.jsxs("div",{className:"response-annotation-success",role:"status","aria-live":"polite",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"已加入 Bad case 评测集"}),l.jsx("p",{children:"这条批注已关联当前问题和完整模型回复。"})]}),l.jsx(zu,{type:"button",color:"secondary",size:"sm",pill:!1,onClick:g,children:"完成"})]}):l.jsxs("form",{className:"response-annotation-form","aria-label":"批注选中的模型回复","aria-busy":o||void 0,onSubmit:y=>{y.preventDefault(),b()},children:[l.jsx("div",{className:"response-annotation-header",children:l.jsx("h2",{children:"添加批注"})}),l.jsx("blockquote",{title:p,children:p}),l.jsxs("label",{className:"response-annotation-field",children:[l.jsx("span",{children:"批注内容"}),l.jsx(wbt,{value:s,rows:3,maxRows:6,autoResize:!0,maxLength:Ome,disabled:o,invalid:!!u,"aria-label":"批注内容",placeholder:"说明问题或期望的修改方式",onChange:y=>{a(xme(y.target.value)),u&&d("")}})]}),u&&l.jsxs("p",{className:"response-annotation-error",role:"alert",children:[u,",请重试。"]}),l.jsxs("div",{className:"response-annotation-actions",children:[l.jsx(zu,{className:"response-annotation-action",type:"button",color:"secondary",variant:"ghost",size:"sm",pill:!1,disabled:o,onClick:g,children:"取消"}),l.jsx(zu,{className:"response-annotation-action",type:"submit",color:"primary",size:"sm",pill:!1,loading:o,disabled:!dY(s),children:"加入 Bad Case"})]})]})})]})}const Abt=[{value:"conversation",label:"对话"},{value:"agents",label:"智能体"},{value:"applications",label:"自动化"},{value:"search",label:"搜索"},{value:"other",label:"其他"}],Nbt=[{value:"page_slow",label:"页面加载慢"},{value:"feature_unavailable",label:"功能无法使用"},{value:"display_error",label:"页面显示异常"},{value:"no_response",label:"操作无响应"},{value:"other",label:"其他问题"}],Cbt=["点击后没有反应","页面一直处于加载状态","部分内容显示不完整","操作后出现错误提示"];function jbt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function Rbt({initialModule:e,onSubmit:t}){const n=m.useRef(null),[i,r]=m.useState(()=>new Set),[s,a]=m.useState(e),[o,c]=m.useState(""),[u,d]=m.useState(!1),[f,h]=m.useState(""),[p,g]=m.useState(!1),b=x=>{r(w=>{const E=new Set(w);return E.has(x)?E.delete(x):E.add(x),E})},y=x=>{var w;c(E=>E.trim()?E.includes(x)?E:`${E.trimEnd()} -${x}`:x),(w=n.current)==null||w.focus()},O=async x=>{if(x.preventDefault(),!(u||p)){d(!0),h("");try{await t({module:s,issues:[...i],description:o.trim()}),g(!0)}catch(w){h(w instanceof Error?w.message:String(w))}finally{d(!1)}}},v=i.size>0||o.trim().length>0;return l.jsxs("div",{className:"platform-feedback-page",children:[l.jsxs("header",{className:"platform-feedback-header",children:[l.jsx("h1",{children:"问题反馈"}),l.jsx("p",{children:"告诉我们您在使用 AgentKit Studio 时遇到的问题。"})]}),l.jsx("div",{className:"platform-feedback-scroll",children:p?l.jsxs("section",{className:"platform-feedback-success","aria-labelledby":"feedback-success-title","aria-live":"polite",role:"status",children:[l.jsx("span",{className:"platform-feedback-success-icon","aria-hidden":"true",children:l.jsx(jbt,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"feedback-success-title",children:"上报成功,感谢您的反馈"}),l.jsx("p",{children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):l.jsxs("form",{className:"platform-feedback-form",onSubmit:x=>void O(x),children:[l.jsxs("section",{className:"platform-feedback-section",children:[l.jsx("div",{className:"platform-feedback-section-heading",children:l.jsx("h2",{children:"所属模块"})}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"所属模块",children:Abt.map(x=>l.jsx("button",{type:"button","aria-pressed":s===x.value,onClick:()=>a(x.value),disabled:u,children:x.label},x.value))})]}),l.jsx("section",{className:"platform-feedback-section",children:l.jsxs("div",{className:"platform-feedback-suggestions",children:[l.jsx("span",{children:"常见问题(可多选)"}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"问题类型",children:Nbt.map(x=>l.jsx("button",{type:"button","aria-pressed":i.has(x.value),onClick:()=>b(x.value),disabled:u,children:x.label},x.value))})]})}),l.jsxs("section",{className:"platform-feedback-section",children:[l.jsxs("label",{className:"platform-feedback-field",children:[l.jsx("span",{children:"问题描述"}),l.jsx("textarea",{ref:n,value:o,onChange:x=>c(x.target.value),placeholder:"请描述问题发生时的页面、操作和表现",maxLength:4e3,rows:6,disabled:u})]}),l.jsxs("div",{className:"platform-feedback-suggestions",children:[l.jsx("span",{children:"快捷补充"}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"问题描述推荐",children:Cbt.map(x=>l.jsx("button",{type:"button",onClick:()=>y(x),disabled:u,children:x},x))})]})]}),l.jsx("p",{className:"platform-feedback-privacy",role:"alert",children:"您的数据将会上报到 AgentKit 团队,请注意隐私保护。"}),f&&l.jsx("p",{className:"platform-feedback-error",role:"alert",children:f}),l.jsx("div",{className:"platform-feedback-actions",children:l.jsx("button",{type:"submit",disabled:!v||u,children:u?"正在上报…":"提交反馈"})})]})})]})}function Ibt({node:e,ctx:t}){const n=e.variant??"default";return l.jsx("button",{type:"button",className:`a2ui-button a2ui-button--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,onClick:()=>t.dispatchAction(e.action,e),children:t.render(e.child)})}Up("Button",Ibt);function Pbt({node:e,ctx:t}){return l.jsx("div",{className:"a2ui-card","data-a2ui-id":e.id,"data-a2ui-component":e.component,children:t.render(e.child)})}Up("Card",Pbt);const Mbt={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly",stretch:"stretch"},Lbt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};function vme(e){return Mbt[e]??"flex-start"}function wme(e){return Lbt[e]??"stretch"}function Dbt({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-column","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"column",justifyContent:vme(e.justify),alignItems:wme(e.align)},children:n.map(i=>t.render(i))})}Up("Column",Dbt);function $bt({node:e}){const t=e.axis==="vertical";return l.jsx("div",{className:`a2ui-divider ${t?"a2ui-divider--v":"a2ui-divider--h"}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component})}Up("Divider",$bt);const Qbt={send:"✈️",check:"✅",close:"✖️",star:"⭐",favorite:"❤️",info:"ℹ️",help:"❓",error:"⛔",calendarToday:"📅",event:"📅",schedule:"🕒",locationOn:"📍",accountCircle:"👤",mail:"✉️",call:"📞",home:"🏠",settings:"⚙️",search:"🔍"};function Bbt({node:e}){const t=e.name??"";return l.jsx("span",{className:"a2ui-icon",title:t,"aria-label":t,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:Qbt[t]??"•"})}Up("Icon",Bbt);function Ubt({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-row","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"row",justifyContent:vme(e.justify),alignItems:wme(e.align??"center")},children:n.map(i=>t.render(i))})}Up("Row",Ubt);const zbt=new Set(["h1","h2","h3","h4","h5"]);function Fbt({node:e,ctx:t}){const n=e.variant??"body",i=t.resolveString(e.text),r=zbt.has(n)?n:"p";return l.jsx(r,{className:`a2ui-text a2ui-text--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:i})}Up("Text",Fbt);function Vbt(e){return e==="agents"?"agents":e==="applications"?"applications":e==="search"?"search":["conversation","new-chat","sandbox"].includes(e)?"conversation":"other"}async function PR(e){const[t,n,i,r]=await Promise.allSettled([qmt(),Hmt("deepseek-harness"),aA(),e?ZD(e):Promise.resolve([])]);return{agentId:e,ready:!0,harnessEnabled:!!e&&r.status==="fulfilled",builtinTools:r.status==="fulfilled"?r.value:[],temporaryEnabled:t.status==="fulfilled"&&t.value.enabled,deepseekHarnessEnabled:n.status==="fulfilled"&&n.value.enabled,sandboxEndpointExportEnabled:t.status==="fulfilled"&&t.value.endpointExportEnabled===!0,skillCustomizationEnabled:i.status==="fulfilled"&&i.value.enabled}}const vl={app:"veadk.appName",view:"veadk.view",session:"veadk.sessionId"},Xbt=600,qbt=1e3,Hbt=5e3,Ybt=500,Gbt=new Set,Wbt=[];function xl(){return{skills:[]}}async function Zbt(e){let t;if(e.threadId)try{const r=await Kt.readThread(e.id,e.threadId);if(r.messages.length>0)return r}catch(r){t=r}const n=await Kt.listThreads(e.id),i=n.threads.find(r=>r.id!==e.threadId)??n.threads[0];if(!i){if(t)throw t;return null}return Kt.resumeThread(e.id,i.id)}function hY(e,t){const n=rme(e),i=n[n.length-1];return!t||(i==null?void 0:i.role)!=="user"?n:[...n,{role:"assistant",blocks:[],meta:{localId:`sandbox-background-${e.threadId}`}}]}function MR(e){return`${tN(e)}.active`}function ZL(e){return`veadk.agentOrder.${encodeURIComponent(e)}`}function Kbt(e){if(!e)return[];try{const t=JSON.parse(localStorage.getItem(ZL(e))||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function KL(e,t){if(e.name===t||e.id===t)return e;for(const n of e.children){const i=KL(n,t);if(i)return i}}function Sme(e){const t=[];for(const n of e.children)n.mentionable&&(t.push({name:n.name,description:n.description,type:n.type,path:n.path}),t.push(...Sme(n)));return t}function pY(){const e=typeof localStorage<"u"?localStorage.getItem(vl.view):null;return["menu","intelligent","custom","template","workflow"].includes(e??"")?"custom":e==="package"||e==="migration"?e:null}function mY(e){const t=e.trim().toLowerCase();switch(t){case"creating":case"starting":case"initializing":case"pending":case"running":case"ready":case"failed":case"error":case"stopped":case"expired":case"deleting":case"deleted":return t;default:return"unknown"}}function Jbt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.75",y:"3.75",width:"16.5",height:"16.5",rx:"3.25"}),l.jsx("path",{d:"M12 8.5v7M8.5 12h7"}),l.jsx("path",{d:"M6.75 6.75h1M16.25 17.25h1",opacity:"0.6"})]})}function eOt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14.75",rx:"2.25"}),l.jsx("path",{d:"M3.5 9h17M9.25 12.25 7.1 14.4l2.15 2.15M14.75 12.25l2.15 2.15-2.15 2.15M12.8 11.85l-1.6 5.1"})]})}function tOt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"2.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),l.jsx("path",{d:"M5.25 8.5h1.5M5.25 11.5h1.5"}),l.jsx("rect",{x:"14.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),l.jsx("path",{d:"M17.25 15.5h1.5M17.25 12.5h1.5M8.75 12h6.5m-2.5-2.5 2.5 2.5-2.5 2.5"})]})}function nOt(){return l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[l.jsx("rect",{x:"3",y:"4",width:"14",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("rect",{x:"6",y:"10.4",width:"13",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.7"}),l.jsx("rect",{x:"9",y:"16.8",width:"9",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.45"})]})}function JL(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function iOt(e){if(!e)return"";const t=[];return e.ts&&t.push(JL(e.ts)),e.tokens!=null&&t.push(`${e.tokens.toLocaleString()} tokens`),t.join(" · ")}function Ud(e){return e.blocks.map(t=>t.kind==="text"?t.text:"").join("").trim()}function LR(e,t){for(let n=t-1;n>=0;n-=1)if(e[n].role==="user")return Ud(e[n]);return""}const rOt="send_a2ui_json_to_client";function sOt(e){return e.blocks.some(t=>t.kind==="text"?t.text.trim().length>0:t.kind==="attachment"||t.kind==="artifact"?t.files.length>0:t.kind==="tool"?!(t.name===rOt&&t.done):t.kind==="agent-transfer"?!1:t.kind==="a2ui"?Sse(t.messages).some(n=>n.components[n.rootId]):t.kind==="auth")}function DR(e){return e.blocks.some(t=>t.kind==="auth"&&!t.done)}function aOt(e){return new Promise((t,n)=>{let i="";try{i=new URL(e,window.location.href).protocol}catch{}if(i!=="http:"&&i!=="https:"){n(new Error("授权链接不是 http/https 地址,已阻止打开。"));return}const r=window.open(e,"veadk_oauth","width=520,height=720");if(!r){n(new Error("弹窗被拦截,请允许弹窗后重试。"));return}let s=!1;const a=()=>{clearInterval(u),window.removeEventListener("message",c)},o=d=>{if(!s){s=!0,a();try{r.close()}catch{}t(d)}},c=d=>{if(d.origin!==window.location.origin)return;const f=d.data;f&&f.veadkOAuth&&typeof f.url=="string"&&o(f.url)};window.addEventListener("message",c);const u=setInterval(()=>{if(!s){if(r.closed){a();const d=window.prompt("授权完成后,请粘贴回调页面(浏览器地址栏)的完整 URL:");d&&d.trim()?(s=!0,t(d.trim())):n(new Error("授权已取消。"));return}try{const d=r.location.href;d&&d!=="about:blank"&&new URL(d).origin===window.location.origin&&/[?&](code|state|error)=/.test(d)&&o(d)}catch{}}},500)})}function oOt(e,t){const n=JSON.parse(JSON.stringify(e??{})),i=n.exchangedAuthCredential??n.exchanged_auth_credential??{},r=i.oauth2??{};return r.authResponseUri=t,r.auth_response_uri=t,i.oauth2=r,n.exchangedAuthCredential=i,n}function gY({text:e}){const[t,n]=m.useState(!1);return l.jsx("button",{className:"icon-btn",title:t?"已复制":"复制",disabled:!e,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},children:t?l.jsx(Hc,{className:"icon"}):l.jsx(g_,{className:"icon"})})}function lOt({onClick:e}){return l.jsx("button",{type:"button",className:"icon-btn","aria-label":"分享为图片",title:"分享为图片",onClick:e,children:l.jsx(Iwe,{className:"icon","aria-hidden":"true"})})}const bY=["今天想做点什么?","有什么可以帮你的?","需要我帮你查点什么吗?","有问题尽管问我","嗨,我们开始吧","开始一段新对话吧","今天想先解决哪件事?","把你的想法告诉我吧","我们从哪里开始?","有什么任务交给我?","准备好一起推进了吗?","说说你现在最关心的问题","今天也一起把事情做好","我在,随时可以开始"],OY=()=>bY[Math.floor(Math.random()*bY.length)];function $R(e){var t;for(const n of e)(t=n.previewUrl)!=null&&t.startsWith("blob:")&&URL.revokeObjectURL(n.previewUrl)}function yY(){return`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`}function xY(e){var n;if(e.type)return e.type;const t=(n=e.name.split(".").pop())==null?void 0:n.toLowerCase();return t==="md"||t==="markdown"?"text/markdown":t==="txt"?"text/plain":"application/octet-stream"}const cOt={"read-only":"只读","workspace-write":"工作区写入","danger-full-access":"完全访问"},uOt={untrusted:"仅不可信命令","on-request":"按需审批",never:"不审批"},dOt={user:"由我审批",auto_review:"自动审查"};function fOt(e,t){const n=e.kind==="file"?"文件修改":"命令执行";return t==="accept"?`已允许本次${n}`:t==="acceptForSession"?`已在本会话中允许${n}`:t==="decline"?`已拒绝${n}`:`已取消${n}审批`}function hOt(e){var n,i,r;const t=[];return(n=e.command)!=null&&n.trim()&&t.push({label:"命令",value:e.command.trim(),code:!0}),(i=e.grantRoot)!=null&&i.trim()&&t.push({label:"授权路径",value:e.grantRoot.trim(),code:!0}),(r=e.cwd)!=null&&r.trim()&&t.push({label:"执行目录",value:e.cwd.trim(),code:!0}),t}function vY(e){return e.flatMap(t=>t.apps.map(n=>Ll(t.id,n)))}function pOt(e,t){var n;return((n=e.find(i=>i.runtimeId&&i.apps.some(r=>Ll(i.id,r)===t)))==null?void 0:n.runtimeId)??""}function mOt(e,t){for(const n of e){const i=n.apps.find(r=>Ll(n.id,r)===t);if(i&&n.runtimeId)return{runtimeId:n.runtimeId,region:n.region??"cn-beijing",appName:i}}return null}function wY(e){return e.taskMode==="text_to_video"?[]:(e.taskMode==="first_last_frame"?[e.firstFrame?{file:e.firstFrame,kind:"first_frame"}:null,e.lastFrame?{file:e.lastFrame,kind:"last_frame"}:null]:[e.referenceImage?{file:e.referenceImage,kind:"reference_image"}:null,e.referenceVideo?{file:e.referenceVideo,kind:"reference_video"}:null]).filter(n=>n!==null)}function gOt(e,t){return`video-${e.replace(/[^A-Za-z0-9_-]/g,"").slice(0,36)||"result"}.${t}`}function bO(e,t){return`${e}${t}`}function bOt(){var r6;const[e,t]=m.useState([]),[n,i]=m.useState(""),[r,s]=m.useState([]),[a,o]=m.useState(""),c=m.useRef(null),u=m.useRef(0),[d,f]=m.useState(!1),[h,p]=m.useState([]),[g,b]=m.useState(null),[y,O]=m.useState([]),[v,x]=m.useState(!1),[w,E]=m.useState(!1),[S,k]=m.useState(""),[T,A]=m.useState(!1),[N,C]=m.useState(!1),[M,L]=m.useState(null),[P,Q]=m.useState(null),[j,$]=m.useState(!1),[U,B]=m.useState(""),[I,X]=m.useState(null),[q,D]=m.useState(!1),[H,re]=m.useState(""),[fe,Ae]=m.useState(!1),[J,ie]=m.useState("idle"),[ue,ye]=m.useState(!1),[Se,Re]=m.useState("confirm"),[Ee,me]=m.useState(""),[oe,Ne]=m.useState("codex"),[Oe,Ve]=m.useState(!1),[We,De]=m.useState(!1),[mt,at]=m.useState(0),[Rt,qe]=m.useState(null),[W,K]=m.useState(null),[ae,pe]=m.useState(null),z=m.useRef(null),ve=m.useRef(null),Be=m.useRef((g==null?void 0:g.id)??""),Je=m.useRef(""),kt=m.useRef(0),Mt=m.useRef(void 0),Tt=m.useRef(new Set);Be.current=(g==null?void 0:g.id)??"",m.useEffect(()=>()=>{Mt.current!==void 0&&window.clearTimeout(Mt.current);for(const R of Tt.current)URL.revokeObjectURL(R);Tt.current.clear()},[]);function dt(R){const V=URL.createObjectURL(R);return Tt.current.add(V),V}function ge(R){!R||!Tt.current.delete(R)||URL.revokeObjectURL(R)}function lt(){for(const R of Tt.current)URL.revokeObjectURL(R);Tt.current.clear()}const Ge=m.useCallback(()=>{Mt.current!==void 0&&(window.clearTimeout(Mt.current),Mt.current=void 0),ie("idle")},[]);m.useEffect(()=>{Ge()},[Ge,g==null?void 0:g.id]);const[vt,_t]=m.useState({}),[Bt,je]=m.useState({}),Ze=a?vt[a]??[]:h,Ie=g?y:Ze,Wt=a?Bt[bO(n,a)]??FS:FS,dn=(R,V)=>_t(F=>({...F,[R]:typeof V=="function"?V(F[R]??[]):V})),Qt=(R,V,F)=>{const se=bO(R,V);je(Te=>{const we=Te[se]??FS,xe=vee(we,F);return xe===we?Te:{...Te,[se]:xe}})};function Yt(R,V,F=[],se=""){if(Be.current!==R)return;const Te=crypto.randomUUID(),we={role:"system",blocks:[],activity:{id:Te,title:V,...F.length>0?{details:F}:{}},meta:{localId:Te,ts:Date.now()/1e3}};O(xe=>{if(!se)return[...xe,we];const Fe=xe.findIndex(it=>{var It;return((It=it.meta)==null?void 0:It.localId)===se});return Fe<0?[...xe,we]:[...xe.slice(0,Fe),we,...xe.slice(Fe)]})}const[Jt,Ft]=m.useState(""),[Ce,et]=m.useState("agent"),[wt,yn]=m.useState("agent"),[on,hi]=m.useState("create"),[Pe,st]=m.useState(null),[At,Ut]=m.useState(null),[kn,wn]=m.useState(null),[Ai,Gn]=m.useState(!1),xn=m.useRef(null),de=m.useRef(null),[Le,ut]=m.useState({}),gt=m.useRef(new Map),ln=Le.ready===!0&&Le.agentId===n,[Sn,In]=m.useState([]),[Ni,Pn]=m.useState(xl),[Vt,Ji]=m.useState(null),[fn,pi]=m.useState(0),[ti,vi]=m.useState(!1),[en,Ci]=m.useState(null),[xs,ni]=m.useState(!1),[Ls,er]=m.useState([]),[Ya,mr]=m.useState(!1),gr=m.useRef(new Set),[ul,Sa]=m.useState(()=>new Set),[as,Mn]=m.useState(()=>new Set),[vs,Zl]=m.useState(()=>new Set),Gr=m.useRef(new Map),tr=m.useRef(new Map),No=m.useRef(void 0),Dr=m.useRef(()=>{}),os=(R,V)=>Sa(F=>{const se=new Set(F);return V?se.add(R):se.delete(R),se}),na=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V),tr.current.delete(R),Mn(F=>new Set(F).add(R))},Co=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V),tr.current.delete(R),Mn(F=>{if(!F.has(R))return F;const se=new Set(F);return se.delete(R),se})},br=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V);const F=window.setTimeout(()=>{Co(R)},2400);tr.current.set(R,F)},ia=(R,V)=>{Zl(F=>{if(F.has(R)===V)return F;const se=new Set(F);return se.delete(R),se})},ji=m.useRef(""),[Kl,Ke]=m.useState("");function Ds(R,V,F){const se=xn.current;if(!se||se.localId!==R||se.runId!==V)return null;const Te=mH(se,F);return xn.current=Te,wn(Te),Te}async function Ea(R,V,F){var we;(we=de.current)==null||we.abort();const se=new AbortController;de.current=se;let Te=F;try{let xe=xn.current;if(!xe||xe.localId!==R||xe.runId!==V)return;if(Te==="optimization"&&xe.assetIds.length===0){const it=wY(xe.config);if(it.length>0){const It=await Promise.all(it.map(bt=>gdt(bt.file,bt.kind,se.signal)));if(se.signal.aborted||(xe=Ds(R,V,{type:"assets_uploaded",assetIds:It.map(bt=>bt.assetId)}),!xe))return}}if(Te==="optimization"){const it=await bdt({prompt:xe.requestedPrompt,taskMode:xe.requestedMode,assetIds:xe.assetIds,ratio:xe.config.aspectRatio,resolution:xe.config.resolution,durationSeconds:xe.config.durationSeconds},se.signal);if(se.signal.aborted||(xe=Ds(R,V,{type:"optimization_succeeded",optimizedPrompt:it.enhancedPrompt,resolvedMode:it.resolvedTaskMode,enhancerModel:it.enhancerModel}),!xe))return;Te="generation"}if(!xe.optimizedPrompt||!xe.resolvedMode)throw new Error("提示词优化结果不完整,请重新优化后再试。");const Fe=await Odt({enhancedPrompt:xe.optimizedPrompt,resolvedTaskMode:xe.resolvedMode,assetIds:xe.assetIds,ratio:xe.config.aspectRatio,resolution:xe.config.resolution,durationSeconds:xe.config.durationSeconds},se.signal);if(se.signal.aborted||(xe=Ds(R,V,{type:"generation_started",remoteTaskId:Fe.taskId,generationModel:Fe.generationModel}),!xe))return;for(;!se.signal.aborted;){const it=await ydt(Fe.taskId,se.signal);if(se.signal.aborted)return;if(it.status==="failed")throw new Error(it.error||"视频生成失败,请稍后重试。");if(it.status==="succeeded"){if(!it.videoUrl)throw new Error("视频任务已完成,但服务端未返回预览地址。");Ds(R,V,{type:"generation_succeeded",output:{previewUrl:vdt(it.videoUrl),fileName:gOt(Fe.taskId,it.outputFormat),mimeType:it.outputFormat==="mov"?"video/quicktime":"video/mp4"}});return}await new Promise(It=>window.setTimeout(It,1800))}}catch(xe){if(se.signal.aborted)return;Ds(R,V,{type:"failed",stage:Te,error:xe instanceof Error?xe.message:String(xe)})}}function nu(R,V,F){if(ape(xn.current)){Gn(!0);return}if(V.taskMode==="video_editing"&&!V.referenceVideo){Ke("视频编辑需要先添加待编辑视频。");return}if(V.taskMode==="video_extension"&&!V.referenceVideo){Ke("视频续写需要先添加基础视频。");return}if(V.taskMode==="reference_to_video"&&!V.referenceImage&&!V.referenceVideo){Ke("参考素材生视频需要至少添加一项参考图片或参考视频。");return}if(V.taskMode==="text_to_video"&&(V.referenceImage||V.referenceVideo||V.firstFrame||V.lastFrame)){Ke("文生视频不使用参考素材,请先移除已添加的图片或视频。");return}if(V.taskMode==="first_last_frame"&&!V.firstFrame){Ke("首尾帧生成需要先添加首帧图片。");return}if(F.supportedModes.length>0&&V.taskMode!=="auto"&&!F.supportedModes.includes(V.taskMode)){Ke("当前平台暂不支持所选视频任务模式。");return}const se=wY(V);if(se.length>0&&!F.assetStorageAvailable){Ke(F.assetStorageUnavailableReason||"管理员未配置持久化存储");return}const Te=se.find(({file:xe})=>F.maxAssetBytes>0&&xe.size>F.maxAssetBytes);if(Te){Ke(`${Te.file.name} 超出当前平台允许的素材大小。`);return}const we=nft({prompt:R,config:V,enhancerModel:F.enhancerModel,generationModel:F.generationModel});xn.current=we,wn(we),Gn(!0),Ft(""),Ke(""),Ea(we.localId,we.runId,"optimization")}function $s(){const R=xn.current;if(!R||R.status!=="error"||!R.errorStage)return;const V=R.errorStage,F=mH(R,{type:"retry",stage:V});xn.current=F,wn(F),Gn(!0),Ea(F.localId,F.runId,V)}async function Jl(){const R=xn.current;if(!(!(R!=null&&R.remoteTaskId)||!R.output))try{const V=await xdt(R.remoteTaskId),F=URL.createObjectURL(V),se=document.createElement("a");se.href=F,se.download=R.output.fileName,se.click(),window.setTimeout(()=>URL.revokeObjectURL(F),1e3)}catch(V){Ke(V instanceof Error?V.message:String(V))}}m.useEffect(()=>()=>{var R;(R=de.current)==null||R.abort()},[]);const[ec,le]=m.useState(""),[gn,Wn]=m.useState(()=>new Set),[Vi,Ln]=m.useState(null),[Tn,ra]=m.useState(null),[Qs,dr]=m.useState(null),[ws,ls]=m.useState(null);m.useEffect(()=>{dr(null)},[n,a]);const[te,Me]=m.useState(!1),[ee,_e]=m.useState(),[tt,Ct]=m.useState(OY),[He,ht]=m.useState(null),[Pt,jt]=m.useState(!1),[bn,Xi]=m.useState(!1),[Ss,Dn]=m.useState(""),Wr=m.useRef(!1),[sa,qi]=m.useState(null),[Xe,_n]=m.useState(""),[dl,fl]=m.useState(),[mi,Zn]=m.useState(null),cv=(mi==null?void 0:mi.capabilities.runtimeScope)??"mine",[yb,uv]=m.useState({newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,agentUsage:!1,addAgentkit:!0}),[tc,dv]=m.useState("cloud"),[hl,sN]=m.useState(nx),[$n,fv]=m.useState("volcengine"),[hv,pv]=m.useState(""),[Sd,Gp]=m.useState(""),[pl,xb]=m.useState(!1),[Ed,vb]=m.useState(!1),[aN,mv]=m.useState(!1),[oN,Wp]=m.useState({}),[lN,wb]=m.useState({}),[gv,iu]=m.useState({}),bv=ul.has(a),ru=as.has(a),ah=bv||d,cN=!!a&&xs,jo=g?v:ah,uN=jo||!g&&ru,vn=Ygt({session:g,conversationBusy:v,onInputChange:Ft,onSessionPatch:R=>{const V=Be.current;b(F=>(F==null?void 0:F.id)===V?{...F,...R}:F)},onSnapshot:R=>{const V=Be.current;lt(),O(rme(R)),b(F=>(F==null?void 0:F.id)===V?{...F,threadId:R.threadId,cwd:R.cwd??F.cwd,model:R.model??F.model,workspaceLocked:R.workspaceLocked,permissions:R.permissions,busy:!1}:F)},onActivity:(R,V=[])=>{const F=Be.current;F&&Yt(F,R,V)},onError:Ke});m.useEffect(()=>{const R=g;if(!R||!v||ve.current)return;let V=!1,F;const se=new AbortController,Te=async()=>{try{const we=await Kt.getStatus(R.id,{signal:se.signal});if(V||Be.current!==R.id)return;const xe=we.threadId?await Kt.readThread(R.id,we.threadId,{signal:se.signal}):null;if(V||Be.current!==R.id)return;if(xe&&O(hY(xe,we.busy)),b(Fe=>(Fe==null?void 0:Fe.id)===R.id?{...Fe,...we,...xe?{threadId:xe.threadId,cwd:xe.cwd??we.cwd,model:xe.model??we.model,workspaceLocked:xe.workspaceLocked,permissions:xe.permissions}:{}}:Fe),x(we.busy),!we.busy){const Fe=xe==null?void 0:xe.messages[xe.messages.length-1];(Fe==null?void 0:Fe.role)==="user"&&Ke("云端 Codex 已结束,但没有生成回复,请重新发送任务。");return}}catch(we){if((we==null?void 0:we.name)==="AbortError"||V)return;x(!1),b(xe=>(xe==null?void 0:xe.id)===R.id?{...xe,busy:!1}:xe),Ke(we instanceof Error?we.message:String(we));return}F=window.setTimeout(Te,1500)};return F=window.setTimeout(Te,1500),()=>{V=!0,se.abort(),F!==void 0&&window.clearTimeout(F)}},[v,g==null?void 0:g.id]);const dN=oN[a]??"",fN=lN[a]??Gbt,hN=gv[a]??Wbt,nr=Vt==null?void 0:Vt.graph,Ov=[Vt==null?void 0:Vt.name,nr==null?void 0:nr.name,nr==null?void 0:nr.id].filter(R=>!!R),Sb=Ni.targetAgent&&nr?KL(nr,Ni.targetAgent.name):nr,yv=(Sb==null?void 0:Sb.skills)??(Ni.targetAgent?[]:(Vt==null?void 0:Vt.skills)??[]),xv=nr?Sme(nr):[],Eb=(nr==null?void 0:nr.instruction)??((r6=Vt==null?void 0:Vt.draft)==null?void 0:r6.instruction),vv=Vt&&Eb!==void 0?SEe({instruction:Eb,tools:[...new Set([...(nr==null?void 0:nr.tools)??Vt.tools,...(en==null?void 0:en.tools.map(R=>R.name))??[],...Ls])],skills:(nr==null?void 0:nr.skills)??Vt.skills}):null;function Zp(R){$R(R);for(const V of R)V.status==="uploading"?gr.current.add(V.id):V.uri&&zS(n,V.uri).catch(F=>Ke(String(F)))}async function kb(R){try{await rP(n,Xe,R),await iP(n,Xe,R),s(V=>V.filter(F=>F.id!==R)),_t(V=>{const{[R]:F,...se}=V;return se})}catch(V){Ke(String(V))}}function wv(R){const V=Sn.find(Te=>Te.id===R);if(!V)return;const F=Sn.filter(Te=>Te.id!==R);$R([V]),V.status==="uploading"&&gr.current.add(R),In(F),F.length===0&&!Jt.trim()&&!!a&&Ie.length===0?(ji.current="",o(""),kb(a)):V.uri&&zS(n,V.uri).catch(Te=>Ke(String(Te)))}const Y=(R,V)=>{var we,xe,Fe,it,It;const F=V.author&&V.author!=="user"?V.author:void 0;F&&(Wp(bt=>({...bt,[R]:F})),wb(bt=>({...bt,[R]:new Set(bt[R]??[]).add(F)})),iu(bt=>{var ct;return(ct=bt[R])!=null&&ct.length?bt:{...bt,[R]:[F]}}));const se=((we=V.actions)==null?void 0:we.transferToAgent)??((xe=V.actions)==null?void 0:xe.transfer_to_agent);se&&iu(bt=>{const ct=bt[R]??[];return ct[ct.length-1]===se?bt:{...bt,[R]:[...ct,se]}}),(((Fe=V.actions)==null?void 0:Fe.endOfAgent)??((it=V.actions)==null?void 0:it.end_of_agent)??((It=V.actions)==null?void 0:It.escalate))&&iu(bt=>{const ct=bt[R]??[];return ct.length<=1?bt:{...bt,[R]:ct.slice(0,-1)}})},[he,be]=m.useState(pY),[Ue,xt]=m.useState([]),[Xt,Ri]=m.useState({}),nc=m.useCallback(R=>{xt(V=>{const F=V.findIndex(Te=>Te.id===R.id);if(F===-1)return[R,...V];const se=[...V];return se[F]={...se[F],...R},se})},[]),[gi,ic]=m.useState(!0),[Tb,Zr]=m.useState(!1),[Eme,pN]=m.useState("skills"),[kme,mN]=m.useState("技能库"),[Tme,Sv]=m.useState(null),[gN,_r]=m.useState(!1),[bN,ui]=m.useState(!1),[_me,aa]=m.useState(null),[Ame,Ev]=m.useState("custom"),[ON,yN]=m.useState([]),kd=m.useRef([]),Td=m.useRef(null),Kp=m.useRef(null),[RQ,kv]=m.useState([]),[Kr,ml]=m.useState(""),Ro=m.useRef(null),[Tv,Jr]=m.useState(!1),[oh,ii]=m.useState(!1),[IQ,xN]=m.useState(""),[Nme,Cme]=m.useState("good"),[jme,_v]=m.useState("basic"),[Rme,Ime]=m.useState("good"),[_b,Av]=m.useState(""),[Pme,Mme]=m.useState(null),[su,Hi]=m.useState(!1),[vN,rc]=m.useState(!1),[sc,Ga]=m.useState(null),wN=m.useRef(null),[gl,Ab]=m.useState(()=>{const R=Al();return gb(R),R}),[Lme,PQ]=m.useState(!1),[Dme,MQ]=m.useState(""),[LQ,Nv]=m.useState(null),[$me,DQ]=m.useState({}),[Qme,$Q]=m.useState(()=>new Set),[ac,oc]=m.useState(null),[Nb,Cv]=m.useState(Qi($n)),[QQ,oa]=m.useState(""),[BQ,la]=m.useState(""),[Jn,Bs]=m.useState(null),[Bme,SN]=m.useState(!1),jv=m.useRef(!1),Jp=m.useRef(!1),lc=m.useCallback(R=>{if(!Xe)return!1;try{XH(localStorage,Xe,R)}catch(V){return le(V instanceof Error?V.message:"浏览器拒绝保存草稿,请稍后重试。"),!1}return kd.current=R,yN(R),le(""),!0},[Xe]),cc=m.useCallback(R=>{var V;R&&((V=Td.current)==null?void 0:V.id)!==R||(Td.current=null,Kp.current!==null&&(window.clearTimeout(Kp.current),Kp.current=null))},[]),_d=m.useCallback(()=>{const R=Td.current;if(!R)return!0;const V=lc([R,...kd.current.filter(F=>F.id!==R.id)]);return V&&cc(),V},[cc,lc]),Ume=m.useCallback((R,V,F)=>{!R||!Xe||(Td.current&&Td.current.id!==R&&_d(),Td.current={id:R,draft:V,updatedAt:Date.now(),deploymentTarget:F},Kp.current!==null&&window.clearTimeout(Kp.current),Kp.current=window.setTimeout(_d,Xbt))},[_d,Xe]),EN=m.useCallback(R=>{!R||!Xe||(cc(R),lc(kd.current.filter(V=>V.id!==R)))},[cc,lc,Xe]),UQ=m.useCallback(R=>{if(!Xe||R.length===0)return;const V=new Set(R.map(F=>F.id));Td.current&&V.has(Td.current.id)&&cc(),lc(kd.current.filter(F=>!V.has(F.id))),Ri(F=>Object.fromEntries(Object.entries(F).filter(([se])=>!V.has(se)))),V.has(Kr)&&(ml(""),aa(null),oc(null),Ro.current=null,localStorage.removeItem(MR(Xe)))},[cc,lc,Kr,Xe]),zQ=m.useCallback(R=>{if(!R||!Xe)return;cc(R);const V=Ro.current,F=kd.current.filter(se=>se.id!==R);lc((V==null?void 0:V.id)===R?[V,...F]:F)},[cc,lc,Xe]);m.useEffect(()=>(window.addEventListener("pagehide",_d),()=>{window.removeEventListener("pagehide",_d)}),[_d]),m.useEffect(()=>{if(!Xe){cc(),kd.current=[],yN([]),kv([]),ml(""),le(""),Ro.current=null;return}let R=[],V="";try{R=Emt(localStorage,Xe),localStorage.getItem(tN(Xe))!==null&&XH(localStorage,Xe,R),V=localStorage.getItem(MR(Xe))||"",le("")}catch(se){le(se instanceof Error?se.message:"无法读取本机草稿,请稍后重试。")}kd.current=R,yN(R),kv(Kbt(Xe));const F=R.find(se=>se.id===V);Ro.current=F??null,he==="custom"&&F&&(ml(F.id),aa(F.draft),oc(F.deploymentTarget??null))},[cc,Xe]),m.useEffect(()=>{if(!Xe)return;const R=MR(Xe);try{he==="custom"&&Kr?localStorage.setItem(R,Kr):localStorage.removeItem(R)}catch{le("浏览器拒绝保存当前草稿位置,请检查站点存储权限后重试。")}},[he,Kr,Xe]);const zme=m.useCallback(R=>{if(!Xe)return;const V=[...new Set(R.filter(Boolean))];kv(V),localStorage.setItem(ZL(Xe),JSON.stringify(V))},[Xe]),Fme=m.useCallback(async R=>{const V=R.filter(it=>!!it.runtimeId&&it.canDelete===!0);if(V.length===0)return;const F=pOt(gl,n),se=new Set(V.map(it=>it.runtimeId));$Q(it=>{const It=new Set(it);for(const bt of se)It.add(bt);return It}),hS(se);const Te=new Set,we=new Set,xe=new Set,Fe=[];for(const it of V)try{if(!it.region)throw new Error("Runtime 缺少地域信息,无法删除");await fee(it.runtimeId,it.region),IT(it.runtimeId),Te.add(it.runtimeId),we.add(it.id)}catch(It){const bt=It instanceof Error?It.message:String(It);xe.add(it.runtimeId),Fe.push(`${it.label}: ${bt}`)}if(Te.size>0&&(hS(Te),Ab(Al()),Nv(It=>{if(!It)return It;const bt=new Set(It);for(const ct of Te)bt.delete(ct);return bt}),DQ(It=>Object.fromEntries(Object.entries(It).filter(([bt])=>!Te.has(bt)))),kv(It=>{const bt=It.filter(ct=>!we.has(ct));return Xe&&localStorage.setItem(ZL(Xe),JSON.stringify(bt)),bt}),lc(kd.current.filter(It=>{var bt;return!((bt=It.deploymentTarget)!=null&&bt.runtimeId)||!Te.has(It.deploymentTarget.runtimeId)})),(F?Te.has(F):V.some(It=>It.id===n))&&(pge(),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),oa(""),la(""),Hi(!0),Ke("")),Jn!=null&&Jn.runtime&&Te.has(Jn.runtime.runtimeId)&&(be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),oa(""),la(""),Hi(!0),Ke(""))),xe.size>0&&$Q(it=>{const It=new Set(it);for(const bt of xe)It.delete(bt);return It}),Fe.length>0){const it=Fe.slice(0,3).join(";"),It=Fe.length>3?`;另有 ${Fe.length-3} 个失败`:"";throw new Error(`${Fe.length} 个 Agent 删除失败:${it}${It}`)}},[Jn,n,lc,gl,Xe]),kN=m.useCallback(async()=>{PQ(!0),MQ("");try{const R=[];let V="";do{const F=await S_({scope:cv,region:"all",pageSize:100,nextToken:V});R.push(...F.runtimes),V=F.nextToken}while(V&&R.length<2e3);Nv(new Set(R.map(F=>F.runtimeId))),DQ(Object.fromEntries(R.map(F=>[F.runtimeId,{canDelete:F.canDelete}])))}catch(R){MQ(R instanceof Error?R.message:String(R))}finally{PQ(!1)}},[cv]);function Vme(R){console.log("create agent draft:",R),be(null),Nd()}function TN(R,V){console.log("Agent added, navigating to:",R,V),Ab(Al()),Nv(null),hS(),EN(Kr),ml(""),Ro.current=null,oc(null),oa(""),la(R),_v("basic"),be(null),ii(!0),i(R)}const _N=m.useCallback(R=>{be(null),ui(!1),Hi(!1),Bs(null),ii(!0),la(""),_v("basic"),oa(R.id),Ke("")},[]),AN=m.useCallback(R=>{_d();const V=Kr?{...R,draftId:Kr}:R;Kr&&Ri(F=>({...F,[Kr]:R.id})),nc(V),_N(V)},[Kr,_d,_N,nc]),NN=m.useCallback(async R=>{if(!R.runtimeId)throw new Error("部署完成,但未返回 Runtime ID。");const V=Kr;V&&(EN(V),Ri(we=>{if(!we[V])return we;const xe={...we};return delete xe[V],xe})),ml(""),Ro.current=null,oc(null);const F=(ac==null?void 0:ac.region)??Nb,se=await SE(R.runtimeId,R.runtimeName,R.region??F,R.version,{waitForReady:!0,agentName:R.agentName});Ab(Al()),pi(we=>we+1);const Te=await PR(se);gt.current.set(se,Te),ut(Te),Nv(we=>{const xe=new Set(we??[]);return xe.add(R.runtimeId),xe}),hS(),la(se),_v("basic"),oa(""),be(null),ii(!0),i(se)},[Kr,Nb,EN,ac]),Cb=m.useRef(null),CN=m.useRef(new Map),Xme=m.useRef(0),FQ=m.useRef(new Map),VQ=gl.some(R=>!!(R.runtimeId&&R.region)&&R.apps.some(V=>Ll(R.id,V)===n));m.useLayoutEffect(()=>{const R=new Map;Ie.forEach((V,F)=>{var xe;const se=((xe=V.meta)==null?void 0:xe.eventId)??"",Te=!!(VQ&&se&&Ud(V)),we=F===Ie.length-1&&(jo||ru);R.set(F,{enabled:!!(Te&&$n!=="byteplus"&&!we&&!DR(V)),turn:V,input:Te?LR(Ie,F):""})}),FQ.current=R},[jo,$n,ru,VQ,Ie]);const XQ=m.useCallback(()=>{var xe;const R=window.getSelection(),V=(R==null?void 0:R.anchorNode)instanceof Element?R.anchorNode:(xe=R==null?void 0:R.anchorNode)==null?void 0:xe.parentElement,F=V==null?void 0:V.closest(".turn--assistant");if(!F)return;const se=Number(F.dataset.responseAnnotationIndex);if(!Number.isInteger(se))return;const Te=FQ.current.get(se);if(!(Te!=null&&Te.enabled))return;const we=Tbt(F,R);we&&dr({selectionId:++Xme.current,turn:Te.turn,input:Te.input,selectedText:we.text,anchor:we.anchor})},[]);m.useEffect(()=>{let R=null;const V=F=>{F.target instanceof Element&&F.target.closest(".response-annotation-popover")||(R!==null&&window.cancelAnimationFrame(R),R=window.requestAnimationFrame(()=>{R=null,XQ()}))};return document.addEventListener("mouseup",V,!0),document.addEventListener("keyup",V,!0),()=>{R!==null&&window.cancelAnimationFrame(R),document.removeEventListener("mouseup",V,!0),document.removeEventListener("keyup",V,!0)}},[XQ]);const lh=m.useRef(!0),Ad=m.useRef(!1),ch=m.useRef(null),qQ=m.useRef({key:"",turnCount:0}),jN=(g==null?void 0:g.id)??a;m.useLayoutEffect(()=>{const R=Cb.current,V=qQ.current,F=V.key!==jN,se=!F&&Ie.length>V.turnCount;if(qQ.current={key:jN,turnCount:Ie.length},!R||Ie.length===0||!F&&!se)return;lh.current=!0,Ad.current=!1,ch.current!==null&&(window.clearTimeout(ch.current),ch.current=null);const Te=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(F||Te){R.scrollTop=R.scrollHeight;return}Ad.current=!0,R.scrollTo({top:R.scrollHeight,behavior:"smooth"}),ch.current=window.setTimeout(()=>{Ad.current=!1,ch.current=null},450)},[jN,Ie.length]),m.useLayoutEffect(()=>{const R=Cb.current;!R||!lh.current||Ad.current||(R.scrollTop=R.scrollHeight)},[jo,Ie]),m.useEffect(()=>{if(!_b||oh||Ie.length===0)return;const R=CN.current.get(_b);if(!R)return;lh.current=!1,R.scrollIntoView({behavior:"smooth",block:"center"});const V=window.setTimeout(()=>{Av("")},2600);return()=>window.clearTimeout(V)},[_b,oh,Ie]),m.useEffect(()=>()=>{ch.current!==null&&window.clearTimeout(ch.current)},[]);const qme=m.useCallback(()=>{const R=Cb.current;!R||Ad.current||(lh.current=R.scrollHeight-R.scrollTop-R.clientHeight<32)},[]),Hme=m.useCallback(R=>{R.deltaY<0&&(Ad.current=!1,lh.current=!1)},[]),Yme=m.useCallback(()=>{Ad.current=!1,lh.current=!1},[]),Gme=m.useCallback(()=>{const R=Cb.current;!R||!lh.current||Ad.current||(R.scrollTop=R.scrollHeight)},[]),RN=m.useCallback(()=>{qi(null),JI().then(R=>{_n(R.userId),fl(R.info),vb(!!R.local),ht(R.status),R.status==="authenticated"&&(jv.current=!0,Jp.current=!0,localStorage.removeItem(vl.app),i(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Hi(!1))}).catch(R=>{qi(R instanceof Error?R.message:String(R))})},[]);m.useEffect(()=>{RN()},[RN]),m.useEffect(()=>{const R=()=>{Dn(""),jt(!0)};return window.addEventListener(eP,R),_Se()&&R(),()=>window.removeEventListener(eP,R)},[]);const Wme=m.useCallback(async()=>{if(Wr.current)return;Wr.current=!0;const R=xSe();if(!R){Wr.current=!1,Dn("登录窗口被浏览器拦截,请允许弹出窗口后重试。");return}Xi(!0),Dn("");try{for(;;){await new Promise(V=>window.setTimeout(V,1e3));try{const V=await JI();if(V.status==="authenticated"){_n(V.userId),fl(V.info),vb(!!V.local),ht(V.status),jt(!1),ASe(),R.close();return}}catch{}if(R.closed){Dn("登录窗口已关闭,请重新登录以继续当前操作。");return}}}finally{Wr.current=!1,Xi(!1)}},[]);m.useEffect(()=>{Ed&&Xe&&o9(Xe)},[Ed,Xe]),m.useEffect(()=>{if(He!=="authenticated"||!Xe){ut({});return}const R=gt.current.get(n);if(R){ut(R);return}let V=!1;return ut({}),PR(n).then(F=>{V||(gt.current.set(n,F),ut(F))}),()=>{V=!0}},[n,He,Xe]),m.useLayoutEffect(()=>{!ln||Le.skillCustomizationEnabled!==!1||wt!=="skill"||(yn("agent"),st(null),Ut(null))},[Le.skillCustomizationEnabled,ln,wt]),m.useEffect(()=>{if(He!=="authenticated"||!Xe){Zn(null);return}let R=!1;return Zn(null),aee().then(V=>{R||Zn(V)}).catch(V=>{console.warn("[app] /web/access failed; using ordinary-user access:",V),R||Zn(see)}),()=>{R=!0}},[He,Xe]),m.useEffect(()=>{ree().then(R=>{const V="prod";jut({enabled:R.telemetry.enabled,environment:V});const F=R.telemetry.studio;Rut({userPoolId:(F==null?void 0:F.userPoolId)??"",studioDeployId:(F==null?void 0:F.deployId)??"",applicationId:(F==null?void 0:F.applicationId)??"",functionId:(F==null?void 0:F.functionId)??"",studioRegion:(F==null?void 0:F.region)??"",studioProject:(F==null?void 0:F.project)??"",studioVersion:(F==null?void 0:F.version)||R.version,environment:V,cloudProvider:R.provider,accountId:(F==null?void 0:F.accountId)??""}),Put({authState:"anonymous"}),uv(R.features),dv(R.agentsSource),fv(R.provider),Gp((F==null?void 0:F.region)||Qi(R.provider)),sN(R.branding),pv(R.version),xb(!0)})},[]),m.useEffect(()=>{if(He!=="authenticated"||!dl||!mi||!pl)return;const R=String(mi.telemetry.userId).trim();R&&(Iut({userUniqueId:R,accountId:mi.telemetry.accountId??"",userRole:mi.role==="admin"?"admin":"member",userSource:Ed?"local":"sso"}),Mut({agentsSource:tc}))},[mi,tc,He,Ed,pl,dl]),m.useEffect(()=>{Cv(R=>{const V=Qi($n);return!R||$n==="byteplus"&&R.startsWith("cn-")||$n==="volcengine"&&R.startsWith("ap-")?V:R})},[$n]),m.useEffect(()=>{mi&&(mi.capabilities.createAgents||(be(null),aa(null),_r(!1),ui(!1),xt([])),mi.capabilities.manageAgents||ii(!1))},[mi]);let ka={kind:"home"};if(He==="authenticated"){if(ws!==null)ka={kind:"page",title:"问题反馈"};else if(vN)ka={kind:"page",title:"系统信息"};else if(sc)ka={kind:"page",title:sc==="catalog"?"自动化":Zhe(sc).name};else if(W)ka={kind:"page",title:W.session.displayName||"智能体"};else if(Rt)ka={kind:"page",title:Rt.displayName||"智能体"};else if(su||oh)ka={kind:"page",title:(Jn==null?void 0:Jn.name)||"智能体"};else if(bN)ka={kind:"page",title:"创建智能体"};else if(Tv)ka={kind:"page",title:"搜索"};else if(gN)ka={kind:"page",title:"添加智能体"};else if(Tb)ka={kind:"page",title:kme||"库"};else if(he)ka={kind:"page",title:he==="custom"?ac!=null&&ac.name?`更新 ${ac.name}`:"创建智能体":he==="package"?"从代码包添加":"迁移智能体"};else if(g){const R=vn.threads.find(V=>V.id===g.threadId);ka={kind:"conversation",title:(R==null?void 0:R.name)||(R==null?void 0:R.preview)||g.displayName}}else if(a){const R=r.find(F=>F.id===a),V=E_(R==null?void 0:R.events);ka=V==="新会话"?{kind:"home"}:{kind:"conversation",title:V}}}const HQ=fdt(hl.title,ka);m.useEffect(()=>{He!=="authenticated"||tc!=="cloud"||!pl||!oh||Jn||kN()},[Jn,tc,He,oh,kN,pl]),m.useEffect(()=>{document.title=HQ;let R=document.querySelector('link[rel~="icon"]');R||(R=document.createElement("link"),R.rel="icon",document.head.appendChild(R)),R.removeAttribute("type"),R.href=hl.logoUrl||($n==="byteplus"?i$:n$)},[$n,hl.logoUrl,HQ]),m.useEffect(()=>{fetch("/web/runtime-config",{signal:AbortSignal.timeout(1e4)}).then(R=>R.ok?R.json():null).then(R=>{R&&ic(!!R.credentials)}).catch(R=>{console.warn("[app] /web/runtime-config probe failed; workbench stays hidden:",R)})},[]);function Zme(R){o9(R),jv.current=!0,Jp.current=!0,localStorage.removeItem(vl.app),Zn(null),be(null),aa(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Nd(),i(""),Hi(!1),_n(R),fl({name:R}),vb(!0),ht("authenticated")}function Kme(){Zn(null),Ed?(OSe(),_n(""),fl(void 0),ht("unauthenticated")):wSe()}m.useEffect(()=>{if(He==="authenticated"){if(tc==="cloud"){const R=vY(gl);i(V=>V&&R.includes(V)?V:(V&&(Jp.current=!0,localStorage.removeItem(vl.app)),""));return}TJ().then(R=>{t(R);const V=vY(gl);i(F=>F&&(R.includes(F)||V.includes(F))?F:(F&&(Jp.current=!0,localStorage.removeItem(vl.app)),""))}).catch(R=>Ke(String(R)))}},[He,tc,gl]),m.useEffect(()=>{n?(Jp.current=!1,localStorage.setItem(vl.app,n)):localStorage.removeItem(vl.app)},[n]),m.useEffect(()=>{let R=!1;if(Ci(null),er([]),su||Jn||!n||!Xe||!a){ni(!1);return}return ni(!0),aP(n,Xe,a).then(V=>{R||(Ci(V),ZD(n).then(F=>{R||er(F)}).catch(()=>{R||er([])}))}).catch(()=>{R||Ci(null)}).finally(()=>{R||ni(!1)}),()=>{R=!0}},[Jn,n,su,Xe,a]),m.useEffect(()=>{let R=!1;if(Ji(null),Pn(xl()),He!=="authenticated"||su||Jn||!n){vi(!1);return}return vi(!0),GJ(n).then(V=>{R||Ji(V)}).catch(()=>{R||Ji(null)}).finally(()=>{R||vi(!1)}),()=>{R=!0}},[Jn,n,fn,He,su]),m.useEffect(()=>{mi&&localStorage.setItem(vl.view,mi.capabilities.createAgents?he??"chat":"chat")},[mi,he]),m.useEffect(()=>{localStorage.setItem(vl.session,a),ji.current=a},[a]),m.useEffect(()=>{const R=mOt(gl,n);if(!R||!Xe){Dr.current=()=>{},Zl(bt=>bt.size===0?bt:new Set);return}const{runtimeId:V,region:F,appName:se}=R;let Te=!1,we=0;function xe(){No.current!==void 0&&(window.clearTimeout(No.current),No.current=void 0)}function Fe(bt){xe(),No.current=window.setTimeout(()=>void it(),bt)}async function it(){const bt=++we;try{const ct=await LJ({runtimeId:V,region:F,appName:se,userId:Xe});if(Te||bt!==we)return;const Qn=new Set(ct.items.filter(Nt=>Nt.state==="running").map(Nt=>Nt.sessionId));if(Zl(Nt=>Nt.size===Qn.size&&[...Qn].every($r=>Nt.has($r))?Nt:Qn),Qn.size>0){Fe(qbt);return}const Fn=ct.items.filter(Nt=>Nt.state==="pending").map(Nt=>Date.parse(Nt.dueAt)).filter(Number.isFinite);Fn.length>0&&Fe(Math.max(Ybt,Math.min(...Fn)-Date.now()))}catch{!Te&&bt===we&&Fe(Hbt)}}const It=()=>{xe(),it()};return Dr.current=It,It(),()=>{Te=!0,we+=1,xe(),Dr.current===It&&(Dr.current=()=>{})}},[n,gl,Xe]),m.useEffect(()=>()=>Gr.current.forEach(R=>R.abort()),[]),m.useEffect(()=>()=>tr.current.forEach(R=>{window.clearTimeout(R)}),[]),m.useEffect(()=>()=>{var R,V;(R=z.current)==null||R.abort(),(V=ve.current)==null||V.abort()},[]),m.useEffect(()=>{if(su||Jn||g||!n||!Xe)return;let R=!1;return(async()=>{const V=await jb(n);if(!R){if(!jv.current){jv.current=!0;const F=localStorage.getItem(vl.session)||"";if(pY()===null&&F&&V.some(se=>se.id===F)){Rb(F);return}}Nd()}})(),()=>{R=!0}},[Jn,n,su,g,Xe]),m.useEffect(()=>{const R=wN.current;R&&R.app===n&&(wN.current=null,Rb(R.sid))},[n]);function YQ(R,V){Jr(!1),R===n?Rb(V):(wN.current={app:R,sid:V},i(R))}async function jb(R){const V=u.current+1;u.current=V;try{const F=await qD(R,Xe),se=await Promise.allSettled(F.map(xe=>{var Fe;return(Fe=xe.events)!=null&&Fe.length?Promise.resolve(xe):gk(R,Xe,xe.id)})),Te=se.find(xe=>xe.status==="rejected"&&!/get session failed:\s*404\b/i.test(String(xe.reason)));if((Te==null?void 0:Te.status)==="rejected")throw Te.reason;const we=se.flatMap(xe=>xe.status==="fulfilled"?[xe.value]:[]);return u.current!==V||(je(xe=>{const Fe={...xe};for(const it of we)Fe[bO(R,it.id)]=h9(it.events??[]);return Fe}),s(we)),we}catch(F){return u.current===V&&Ke(String(F)),[]}}function IN(R="codex",V=!1){g||(Ke(""),me(""),Re("confirm"),Ne(R),Ve(V),ye(!0))}function Jme(){var R;(R=z.current)==null||R.abort(),z.current=null,ye(!1),Re("confirm"),me(""),!g&&Ce!=="agent"&&!Oe&&et("agent")}async function ege(R,V){var Te;(Te=z.current)==null||Te.abort();const F=new AbortController;z.current=F,Re("loading"),me("");const se=Lut({sandboxKind:oe,sandboxSource:Oe?"my_agents":"new_chat"});try{const we=oe==="codex"?await Kt.startSession({displayName:R,persistent:V,signal:F.signal}):await Kt.startAgentSession(oe,{displayName:R,persistent:V,signal:F.signal});if(z.current!==F){se.fail({errorKind:"abort"});return}if(se.succeed({sandboxId:String(we.id)}),Oe){at(Fe=>Fe+1),ye(!1),Re("confirm"),Hi(!0);return}if(oe!=="codex"){const Fe=await Kt.openAgentSession(oe,we.id,{signal:F.signal});if(z.current!==F)return;ji.current="",o(""),p([]),Ft(""),Pn(xl()),et(oe==="deepseek-harness"?"deepseek-harness":"agent"),Zp(Sn),In([]),lt(),O([]),b(null),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),Hi(!1),qe(null),K(Fe),ye(!1),Re("confirm");return}const xe=await Kt.connectSession(we.id,{signal:F.signal});if(z.current!==F)return;ji.current="",o(""),p([]),Ft(""),Pn(xl()),et("temporary"),Zp(Sn),In([]),lt(),O([]),b(xe),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),Hi(!1),qe(null),K(null),ye(!1),Re("confirm")}catch(we){if(se.fail(Ra(we)),(we==null?void 0:we.name)==="AbortError"||z.current!==F)return;me(we instanceof Error?we.message:String(we)),Re("error")}finally{z.current===F&&(z.current=null)}}async function Rv(R,V="my_agents"){Ke("");const F=rR({targetId:String(R.id),agentKind:R.toolName,connectSource:V});try{const se=R.resourceType==="snapshot"?await Kt.resumeSnapshot(R.toolName,R.snapshotId):R;if(R.resourceType==="snapshot"&&at(we=>we+1),se.toolName==="codex"){const we=await Kt.connectSession(se.id),xe=await Zbt(we);F.succeed({sandboxStatus:mY(we.status)}),ji.current="",o(""),p([]),Ft(""),Pn(xl()),lt(),xe?(O(hY(xe,we.busy)),b({...we,threadId:xe.threadId,cwd:xe.cwd??we.cwd,workspaceLocked:xe.workspaceLocked,permissions:xe.permissions,...xe.model?{model:xe.model}:{}})):(O([]),b(we)),x(we.busy),qe(null),K(null),Hi(!1),ii(!1);return}const Te=await Kt.openAgentSession(se.toolName,se.id);F.succeed({sandboxStatus:mY(Te.session.status)}),K(Te),qe(null),Hi(!1),ii(!1)}catch(se){throw F.fail(Ra(se)),Ke(se instanceof Error?se.message:String(se)),se}}async function tge(R){const F=(await Kt.listSessions()).find(se=>se.resourceType==="session"&&se.toolName==="codex"&&se.id===R);if(!F)throw new Error("云端 Codex Session 暂未出现在列表中,请稍后重试。");await Rv(F,"my_agents"),De(!1)}function nge(R){qe(R),K(null),Hi(!1),ii(!1),Ke("")}async function ige(R){R.resourceType==="snapshot"?await Kt.deleteSnapshot(R.toolName,R.snapshotId):((g==null?void 0:g.id)===R.id&&uc(),R.toolName==="codex"?await Kt.deleteSession(R.id):await Kt.deleteAgentSession(R.toolName,R.id)),qe(null),K(null),at(V=>V+1),Hi(!0)}async function rge(){const R=ae;if(!R)return;await vn.deleteThread(R.id)&&pe(null)}function uc(){var V;(V=ve.current)==null||V.abort(),ve.current=null,Be.current="",Je.current="",x(!1),lt(),O([]),In([]),Ft(""),Ke(""),et("agent"),E(!1),k(""),A(!1),C(!1),L(null),Q(null),$(!1),B(""),X(null),D(!1),re(""),Ge(),pe(null),Ae(!1),kt.current+=1;const R=g;b(null),R&&Kt.closeSession(R.id).catch(F=>Ke(String(F)))}async function PN(R){const V=g;if(V){L(R),Q(null),B(""),$(!0);try{const F=R==="terminal"?await Kt.launchTerminal(V.id):await Kt.launchBrowser(V.id);Q(F)}catch(F){B(F instanceof Error?F.message:String(F))}finally{$(!1)}}}async function sge(){var V;const R=g;if(!(!R||J==="copying")){ie("copying"),Ke("");try{if(!((V=navigator.clipboard)!=null&&V.writeText))throw new Error("当前浏览器不支持写入剪贴板。");const F=await Kt.getEndpoint(R.id);if(await navigator.clipboard.writeText(F.endpoint),Be.current!==R.id)return;ie("copied"),Mt.current!==void 0&&window.clearTimeout(Mt.current),Mt.current=window.setTimeout(()=>{ie("idle"),Mt.current=void 0},1600)}catch(F){if(Be.current!==R.id)return;ie("idle"),Ke(F instanceof Error?F.message:String(F))}}}async function age(R){const V=g;if(!(!V||w)){E(!0),k("");try{const F=await Kt.updatePermissions(V.id,R);b(se=>(se==null?void 0:se.id)===V.id?{...se,permissions:F}:se),Yt(V.id,"已更新当前 Sandbox Session 的 Codex 权限",[{label:"沙箱模式",value:cOt[F.sandboxMode]},{label:"审批策略",value:uOt[F.approvalPolicy]},{label:"审批方式",value:dOt[F.approvalsReviewer]},{label:"网络访问",value:F.networkAccess?"允许":"关闭"}]),Be.current===V.id&&A(!1)}catch(F){k(F instanceof Error?F.message:String(F))}finally{E(!1)}}}const oge=m.useCallback(async R=>{const V=g==null?void 0:g.id;if(!V)throw new Error("当前没有已连接的 Sandbox。");return Kt.listDirectories(V,R)},[g==null?void 0:g.id]);async function lge(R){const V=g;if(!(!V||V.workspaceLocked||w)){E(!0),k("");try{const F=await Kt.updateWorkspace(V.id,R);b(se=>(se==null?void 0:se.id)===V.id?{...se,cwd:F}:se),vn.invalidateSkills(),Yt(V.id,"已更新工作空间",[{label:"工作目录",value:F,code:!0}]),Be.current===V.id&&C(!1)}catch(F){k(F instanceof Error?F.message:String(F))}finally{E(!1)}}}async function cge(R){const V=g,F=I;if(!(!V||!F||q)){D(!0),re("");try{await Kt.resolveApproval(V.id,F.id,R),Yt(V.id,fOt(F,R),hOt(F),Je.current),X(se=>(se==null?void 0:se.id)===F.id?null:se)}catch(se){re(se instanceof Error?se.message:String(se))}finally{D(!1)}}}async function uge(R){const V=g;if(!V||fe)return;const F=++kt.current;Ke(""),Ae(!0);const se=Array.from(R).map(Te=>{const we={id:yY(),mimeType:xY(Te),name:Te.name,sizeBytes:Te.size,status:"uploading",previewUrl:dt(Te)};return{file:Te,attachment:we}});In(Te=>[...Te,...se.map(({attachment:we})=>we)]);try{const we=(await Promise.all(se.map(async({file:xe,attachment:Fe})=>{try{const it=await Kt.uploadFile(V.id,xe);return kt.current!==F?null:(In(It=>It.map(bt=>bt.id===Fe.id?{...bt,id:it.id,uri:it.path,name:it.name,mimeType:it.mimeType,sizeBytes:it.sizeBytes,status:"ready"}:bt)),it)}catch(it){if(kt.current!==F)return null;const It=it instanceof Error?it.message:String(it);return In(bt=>bt.map(ct=>ct.id===Fe.id?{...ct,status:"error",error:It}:ct)),Ke(It),null}}))).filter(xe=>xe!==null);kt.current===F&&we.length>0&&Yt(V.id,we.length===1?"已上传文件到 Sandbox":`已上传 ${we.length} 个文件到 Sandbox`,we.map((xe,Fe)=>({label:we.length===1?"文件":`文件 ${Fe+1}`,value:xe.path,code:!0})))}finally{if(kt.current===F)Ae(!1);else for(const{attachment:Te}of se)ge(Te.previewUrl)}}function dge(R){const V=Sn.find(F=>F.id===R);V&&(ge(V.previewUrl),In(F=>F.filter(se=>se.id!==R)))}function fge(){var V;const R=g==null?void 0:g.id;(V=ve.current)==null||V.abort(),R&&Kt.interruptSession(R).catch(F=>Ke(F instanceof Error?F.message:String(F)))}async function GQ(R,V=[],F=[]){var $r;const se=g,Te=V.filter(Lt=>Lt.status==="ready"&&Lt.uri);if(!se||v||!R.trim()&&Te.length===0)return;Ke(""),X(null),re("");const we=eH({agentId:String(se.id),agentKind:se.toolName,messageSource:"composer",sessionState:"existing",sessionId:String(se.id)}),xe=new AbortController;($r=ve.current)==null||$r.abort(),ve.current=xe;const Fe=[];F.length>0&&Fe.push({kind:"invocation",value:{skills:F.map(({name:Lt,description:qn})=>({name:Lt,description:qn}))}}),Te.length>0&&Fe.push({kind:"attachment",files:Te.map(Lt=>({id:Lt.id,mimeType:Lt.mimeType,name:Lt.name,sizeBytes:Lt.sizeBytes,previewUrl:Lt.previewUrl}))}),R.trim()&&Fe.push({kind:"text",text:R});const it=Te.map(Lt=>Lt.uri).filter(Lt=>!!Lt),bt=[F.map(Lt=>`$${Lt.name}`).join(" "),R.trim()].filter(Boolean).join(" "),ct=it.length>0?[bt,"以下文件已上传到当前 Sandbox 工作空间,请在任务中使用:",...it.map(Lt=>`- ${Lt}`)].filter(Boolean).join(` +批注:${i}`,Ebt)}function hY(e){return e?e instanceof Element?e:e.parentElement:null}function _bt(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;const n=hY(t.anchorNode),i=hY(t.focusNode);if(!n||!i||!e.contains(n)||!e.contains(i)||!n.closest(".bubble")||!i.closest(".bubble"))return null;const r=t.toString().trim();if(!r)return null;const s=t.getRangeAt(0).getBoundingClientRect();return s.width<=0||s.height<=0?null:{text:r,anchor:{left:s.left+s.width/2,top:s.top,height:s.height}}}function Abt({anchor:e,selectedText:t,onClose:n,onSubmit:i}){const r=m.useRef(!1),[s,a]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(""),[f,h]=m.useState(!1),p=xme(t),g=m.useCallback(()=>{var y;(y=window.getSelection())==null||y.removeAllRanges(),n()},[n]);r.current=o,m.useEffect(()=>{const y=()=>{r.current||g()},O=v=>{const x=v.target;x instanceof Element&&x.closest(".response-annotation-popover")||r.current||g()};return window.addEventListener("resize",y),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",O,!0)}},[g]);const b=async()=>{if(!(o||f||!fY(s))){c(!0),d("");try{await i(s.trim()),h(!0)}catch(y){d(y instanceof Error?y.message:String(y))}finally{c(!1)}}};return l.jsxs(Py,{open:!0,onOpenChange:y=>{!y&&!o&&g()},children:[l.jsx(Py.Trigger,{children:l.jsx("span",{className:"response-annotation-anchor",style:{left:e.left,top:e.top,height:e.height},"aria-hidden":"true"})}),l.jsx(Py.Content,{side:"top",sideOffset:8,align:"center",minWidth:"auto",className:"response-annotation-popover",children:f?l.jsxs("div",{className:"response-annotation-success",role:"status","aria-live":"polite",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"已加入 Bad case 评测集"}),l.jsx("p",{children:"这条批注已关联当前问题和完整模型回复。"})]}),l.jsx(zu,{type:"button",color:"secondary",size:"sm",pill:!1,onClick:g,children:"完成"})]}):l.jsxs("form",{className:"response-annotation-form","aria-label":"批注选中的模型回复","aria-busy":o||void 0,onSubmit:y=>{y.preventDefault(),b()},children:[l.jsx("div",{className:"response-annotation-header",children:l.jsx("h2",{children:"添加批注"})}),l.jsx("blockquote",{title:p,children:p}),l.jsxs("label",{className:"response-annotation-field",children:[l.jsx("span",{children:"批注内容"}),l.jsx(Sbt,{value:s,rows:3,maxRows:6,autoResize:!0,maxLength:yme,disabled:o,invalid:!!u,"aria-label":"批注内容",placeholder:"说明问题或期望的修改方式",onChange:y=>{a(vme(y.target.value)),u&&d("")}})]}),u&&l.jsxs("p",{className:"response-annotation-error",role:"alert",children:[u,",请重试。"]}),l.jsxs("div",{className:"response-annotation-actions",children:[l.jsx(zu,{className:"response-annotation-action",type:"button",color:"secondary",variant:"ghost",size:"sm",pill:!1,disabled:o,onClick:g,children:"取消"}),l.jsx(zu,{className:"response-annotation-action",type:"submit",color:"primary",size:"sm",pill:!1,loading:o,disabled:!fY(s),children:"加入 Bad Case"})]})]})})]})}const Nbt=[{value:"conversation",label:"对话"},{value:"agents",label:"智能体"},{value:"applications",label:"自动化"},{value:"search",label:"搜索"},{value:"other",label:"其他"}],Cbt=[{value:"page_slow",label:"页面加载慢"},{value:"feature_unavailable",label:"功能无法使用"},{value:"display_error",label:"页面显示异常"},{value:"no_response",label:"操作无响应"},{value:"other",label:"其他问题"}],jbt=["点击后没有反应","页面一直处于加载状态","部分内容显示不完整","操作后出现错误提示"];function Rbt(e){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function Ibt({initialModule:e,onSubmit:t}){const n=m.useRef(null),[i,r]=m.useState(()=>new Set),[s,a]=m.useState(e),[o,c]=m.useState(""),[u,d]=m.useState(!1),[f,h]=m.useState(""),[p,g]=m.useState(!1),b=x=>{r(w=>{const E=new Set(w);return E.has(x)?E.delete(x):E.add(x),E})},y=x=>{var w;c(E=>E.trim()?E.includes(x)?E:`${E.trimEnd()} +${x}`:x),(w=n.current)==null||w.focus()},O=async x=>{if(x.preventDefault(),!(u||p)){d(!0),h("");try{await t({module:s,issues:[...i],description:o.trim()}),g(!0)}catch(w){h(w instanceof Error?w.message:String(w))}finally{d(!1)}}},v=i.size>0||o.trim().length>0;return l.jsxs("div",{className:"platform-feedback-page",children:[l.jsxs("header",{className:"platform-feedback-header",children:[l.jsx("h1",{children:"问题反馈"}),l.jsx("p",{children:"告诉我们您在使用 AgentKit Studio 时遇到的问题。"})]}),l.jsx("div",{className:"platform-feedback-scroll",children:p?l.jsxs("section",{className:"platform-feedback-success","aria-labelledby":"feedback-success-title","aria-live":"polite",role:"status",children:[l.jsx("span",{className:"platform-feedback-success-icon","aria-hidden":"true",children:l.jsx(Rbt,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"feedback-success-title",children:"上报成功,感谢您的反馈"}),l.jsx("p",{children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):l.jsxs("form",{className:"platform-feedback-form",onSubmit:x=>void O(x),children:[l.jsxs("section",{className:"platform-feedback-section",children:[l.jsx("div",{className:"platform-feedback-section-heading",children:l.jsx("h2",{children:"所属模块"})}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"所属模块",children:Nbt.map(x=>l.jsx("button",{type:"button","aria-pressed":s===x.value,onClick:()=>a(x.value),disabled:u,children:x.label},x.value))})]}),l.jsx("section",{className:"platform-feedback-section",children:l.jsxs("div",{className:"platform-feedback-suggestions",children:[l.jsx("span",{children:"常见问题(可多选)"}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"问题类型",children:Cbt.map(x=>l.jsx("button",{type:"button","aria-pressed":i.has(x.value),onClick:()=>b(x.value),disabled:u,children:x.label},x.value))})]})}),l.jsxs("section",{className:"platform-feedback-section",children:[l.jsxs("label",{className:"platform-feedback-field",children:[l.jsx("span",{children:"问题描述"}),l.jsx("textarea",{ref:n,value:o,onChange:x=>c(x.target.value),placeholder:"请描述问题发生时的页面、操作和表现",maxLength:4e3,rows:6,disabled:u})]}),l.jsxs("div",{className:"platform-feedback-suggestions",children:[l.jsx("span",{children:"快捷补充"}),l.jsx("div",{className:"platform-feedback-pills","aria-label":"问题描述推荐",children:jbt.map(x=>l.jsx("button",{type:"button",onClick:()=>y(x),disabled:u,children:x},x))})]})]}),l.jsx("p",{className:"platform-feedback-privacy",role:"alert",children:"您的数据将会上报到 AgentKit 团队,请注意隐私保护。"}),f&&l.jsx("p",{className:"platform-feedback-error",role:"alert",children:f}),l.jsx("div",{className:"platform-feedback-actions",children:l.jsx("button",{type:"submit",disabled:!v||u,children:u?"正在上报…":"提交反馈"})})]})})]})}function Pbt({node:e,ctx:t}){const n=e.variant??"default";return l.jsx("button",{type:"button",className:`a2ui-button a2ui-button--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,onClick:()=>t.dispatchAction(e.action,e),children:t.render(e.child)})}Up("Button",Pbt);function Mbt({node:e,ctx:t}){return l.jsx("div",{className:"a2ui-card","data-a2ui-id":e.id,"data-a2ui-component":e.component,children:t.render(e.child)})}Up("Card",Mbt);const Lbt={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly",stretch:"stretch"},Dbt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};function wme(e){return Lbt[e]??"flex-start"}function Sme(e){return Dbt[e]??"stretch"}function $bt({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-column","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"column",justifyContent:wme(e.justify),alignItems:Sme(e.align)},children:n.map(i=>t.render(i))})}Up("Column",$bt);function Qbt({node:e}){const t=e.axis==="vertical";return l.jsx("div",{className:`a2ui-divider ${t?"a2ui-divider--v":"a2ui-divider--h"}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component})}Up("Divider",Qbt);const Bbt={send:"✈️",check:"✅",close:"✖️",star:"⭐",favorite:"❤️",info:"ℹ️",help:"❓",error:"⛔",calendarToday:"📅",event:"📅",schedule:"🕒",locationOn:"📍",accountCircle:"👤",mail:"✉️",call:"📞",home:"🏠",settings:"⚙️",search:"🔍"};function Ubt({node:e}){const t=e.name??"";return l.jsx("span",{className:"a2ui-icon",title:t,"aria-label":t,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:Bbt[t]??"•"})}Up("Icon",Ubt);function zbt({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-row","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"row",justifyContent:wme(e.justify),alignItems:Sme(e.align??"center")},children:n.map(i=>t.render(i))})}Up("Row",zbt);const Fbt=new Set(["h1","h2","h3","h4","h5"]);function Vbt({node:e,ctx:t}){const n=e.variant??"body",i=t.resolveString(e.text),r=Fbt.has(n)?n:"p";return l.jsx(r,{className:`a2ui-text a2ui-text--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:i})}Up("Text",Vbt);function Xbt(e){return e==="agents"?"agents":e==="applications"?"applications":e==="search"?"search":["conversation","new-chat","sandbox"].includes(e)?"conversation":"other"}async function PR(e){const[t,n,i,r]=await Promise.allSettled([Hmt(),Ymt("deepseek-harness"),aA(),e?ZD(e):Promise.resolve([])]);return{agentId:e,ready:!0,harnessEnabled:!!e&&r.status==="fulfilled",builtinTools:r.status==="fulfilled"?r.value:[],temporaryEnabled:t.status==="fulfilled"&&t.value.enabled,deepseekHarnessEnabled:n.status==="fulfilled"&&n.value.enabled,sandboxEndpointExportEnabled:t.status==="fulfilled"&&t.value.endpointExportEnabled===!0,skillCustomizationEnabled:i.status==="fulfilled"&&i.value.enabled}}const vl={app:"veadk.appName",view:"veadk.view",session:"veadk.sessionId"},qbt=600,Hbt=1e3,Ybt=5e3,Gbt=500,Wbt=new Set,Zbt=[];function xl(){return{skills:[]}}async function Kbt(e){let t;if(e.threadId)try{const r=await Kt.readThread(e.id,e.threadId);if(r.messages.length>0)return r}catch(r){t=r}const n=await Kt.listThreads(e.id),i=n.threads.find(r=>r.id!==e.threadId)??n.threads[0];if(!i){if(t)throw t;return null}return Kt.resumeThread(e.id,i.id)}function pY(e,t){const n=sme(e),i=n[n.length-1];return!t||(i==null?void 0:i.role)!=="user"?n:[...n,{role:"assistant",blocks:[],meta:{localId:`sandbox-background-${e.threadId}`}}]}function MR(e){return`${tN(e)}.active`}function ZL(e){return`veadk.agentOrder.${encodeURIComponent(e)}`}function Jbt(e){if(!e)return[];try{const t=JSON.parse(localStorage.getItem(ZL(e))||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function KL(e,t){if(e.name===t||e.id===t)return e;for(const n of e.children){const i=KL(n,t);if(i)return i}}function Eme(e){const t=[];for(const n of e.children)n.mentionable&&(t.push({name:n.name,description:n.description,type:n.type,path:n.path}),t.push(...Eme(n)));return t}function mY(){const e=typeof localStorage<"u"?localStorage.getItem(vl.view):null;return["menu","intelligent","custom","template","workflow"].includes(e??"")?"custom":e==="package"||e==="migration"?e:null}function gY(e){const t=e.trim().toLowerCase();switch(t){case"creating":case"starting":case"initializing":case"pending":case"running":case"ready":case"failed":case"error":case"stopped":case"expired":case"deleting":case"deleted":return t;default:return"unknown"}}function eOt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.75",y:"3.75",width:"16.5",height:"16.5",rx:"3.25"}),l.jsx("path",{d:"M12 8.5v7M8.5 12h7"}),l.jsx("path",{d:"M6.75 6.75h1M16.25 17.25h1",opacity:"0.6"})]})}function tOt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14.75",rx:"2.25"}),l.jsx("path",{d:"M3.5 9h17M9.25 12.25 7.1 14.4l2.15 2.15M14.75 12.25l2.15 2.15-2.15 2.15M12.8 11.85l-1.6 5.1"})]})}function nOt({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"2.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),l.jsx("path",{d:"M5.25 8.5h1.5M5.25 11.5h1.5"}),l.jsx("rect",{x:"14.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),l.jsx("path",{d:"M17.25 15.5h1.5M17.25 12.5h1.5M8.75 12h6.5m-2.5-2.5 2.5 2.5-2.5 2.5"})]})}function iOt(){return l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[l.jsx("rect",{x:"3",y:"4",width:"14",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("rect",{x:"6",y:"10.4",width:"13",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.7"}),l.jsx("rect",{x:"9",y:"16.8",width:"9",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.45"})]})}function JL(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function rOt(e){if(!e)return"";const t=[];return e.ts&&t.push(JL(e.ts)),e.tokens!=null&&t.push(`${e.tokens.toLocaleString()} tokens`),t.join(" · ")}function Ud(e){return e.blocks.map(t=>t.kind==="text"?t.text:"").join("").trim()}function LR(e,t){for(let n=t-1;n>=0;n-=1)if(e[n].role==="user")return Ud(e[n]);return""}const sOt="send_a2ui_json_to_client";function aOt(e){return e.blocks.some(t=>t.kind==="text"?t.text.trim().length>0:t.kind==="attachment"||t.kind==="artifact"?t.files.length>0:t.kind==="tool"?!(t.name===sOt&&t.done):t.kind==="agent-transfer"?!1:t.kind==="a2ui"?Ese(t.messages).some(n=>n.components[n.rootId]):t.kind==="auth")}function DR(e){return e.blocks.some(t=>t.kind==="auth"&&!t.done)}function oOt(e){return new Promise((t,n)=>{let i="";try{i=new URL(e,window.location.href).protocol}catch{}if(i!=="http:"&&i!=="https:"){n(new Error("授权链接不是 http/https 地址,已阻止打开。"));return}const r=window.open(e,"veadk_oauth","width=520,height=720");if(!r){n(new Error("弹窗被拦截,请允许弹窗后重试。"));return}let s=!1;const a=()=>{clearInterval(u),window.removeEventListener("message",c)},o=d=>{if(!s){s=!0,a();try{r.close()}catch{}t(d)}},c=d=>{if(d.origin!==window.location.origin)return;const f=d.data;f&&f.veadkOAuth&&typeof f.url=="string"&&o(f.url)};window.addEventListener("message",c);const u=setInterval(()=>{if(!s){if(r.closed){a();const d=window.prompt("授权完成后,请粘贴回调页面(浏览器地址栏)的完整 URL:");d&&d.trim()?(s=!0,t(d.trim())):n(new Error("授权已取消。"));return}try{const d=r.location.href;d&&d!=="about:blank"&&new URL(d).origin===window.location.origin&&/[?&](code|state|error)=/.test(d)&&o(d)}catch{}}},500)})}function lOt(e,t){const n=JSON.parse(JSON.stringify(e??{})),i=n.exchangedAuthCredential??n.exchanged_auth_credential??{},r=i.oauth2??{};return r.authResponseUri=t,r.auth_response_uri=t,i.oauth2=r,n.exchangedAuthCredential=i,n}function bY({text:e}){const[t,n]=m.useState(!1);return l.jsx("button",{className:"icon-btn",title:t?"已复制":"复制",disabled:!e,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},children:t?l.jsx(Hc,{className:"icon"}):l.jsx(g_,{className:"icon"})})}function cOt({onClick:e}){return l.jsx("button",{type:"button",className:"icon-btn","aria-label":"分享为图片",title:"分享为图片",onClick:e,children:l.jsx(Pwe,{className:"icon","aria-hidden":"true"})})}const OY=["今天想做点什么?","有什么可以帮你的?","需要我帮你查点什么吗?","有问题尽管问我","嗨,我们开始吧","开始一段新对话吧","今天想先解决哪件事?","把你的想法告诉我吧","我们从哪里开始?","有什么任务交给我?","准备好一起推进了吗?","说说你现在最关心的问题","今天也一起把事情做好","我在,随时可以开始"],yY=()=>OY[Math.floor(Math.random()*OY.length)];function $R(e){var t;for(const n of e)(t=n.previewUrl)!=null&&t.startsWith("blob:")&&URL.revokeObjectURL(n.previewUrl)}function xY(){return`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`}function vY(e){var n;if(e.type)return e.type;const t=(n=e.name.split(".").pop())==null?void 0:n.toLowerCase();return t==="md"||t==="markdown"?"text/markdown":t==="txt"?"text/plain":"application/octet-stream"}const uOt={"read-only":"只读","workspace-write":"工作区写入","danger-full-access":"完全访问"},dOt={untrusted:"仅不可信命令","on-request":"按需审批",never:"不审批"},fOt={user:"由我审批",auto_review:"自动审查"};function hOt(e,t){const n=e.kind==="file"?"文件修改":"命令执行";return t==="accept"?`已允许本次${n}`:t==="acceptForSession"?`已在本会话中允许${n}`:t==="decline"?`已拒绝${n}`:`已取消${n}审批`}function pOt(e){var n,i,r;const t=[];return(n=e.command)!=null&&n.trim()&&t.push({label:"命令",value:e.command.trim(),code:!0}),(i=e.grantRoot)!=null&&i.trim()&&t.push({label:"授权路径",value:e.grantRoot.trim(),code:!0}),(r=e.cwd)!=null&&r.trim()&&t.push({label:"执行目录",value:e.cwd.trim(),code:!0}),t}function wY(e){return e.flatMap(t=>t.apps.map(n=>Ll(t.id,n)))}function mOt(e,t){var n;return((n=e.find(i=>i.runtimeId&&i.apps.some(r=>Ll(i.id,r)===t)))==null?void 0:n.runtimeId)??""}function gOt(e,t){for(const n of e){const i=n.apps.find(r=>Ll(n.id,r)===t);if(i&&n.runtimeId)return{runtimeId:n.runtimeId,region:n.region??"cn-beijing",appName:i}}return null}function SY(e){return e.taskMode==="text_to_video"?[]:(e.taskMode==="first_last_frame"?[e.firstFrame?{file:e.firstFrame,kind:"first_frame"}:null,e.lastFrame?{file:e.lastFrame,kind:"last_frame"}:null]:[e.referenceImage?{file:e.referenceImage,kind:"reference_image"}:null,e.referenceVideo?{file:e.referenceVideo,kind:"reference_video"}:null]).filter(n=>n!==null)}function bOt(e,t){return`video-${e.replace(/[^A-Za-z0-9_-]/g,"").slice(0,36)||"result"}.${t}`}function bO(e,t){return`${e}${t}`}function OOt(){var r6;const[e,t]=m.useState([]),[n,i]=m.useState(""),[r,s]=m.useState([]),[a,o]=m.useState(""),c=m.useRef(null),u=m.useRef(0),[d,f]=m.useState(!1),[h,p]=m.useState([]),[g,b]=m.useState(null),[y,O]=m.useState([]),[v,x]=m.useState(!1),[w,E]=m.useState(!1),[S,k]=m.useState(""),[T,A]=m.useState(!1),[N,C]=m.useState(!1),[M,L]=m.useState(null),[P,Q]=m.useState(null),[j,$]=m.useState(!1),[U,B]=m.useState(""),[I,X]=m.useState(null),[q,D]=m.useState(!1),[H,re]=m.useState(""),[fe,Ae]=m.useState(!1),[J,ie]=m.useState("idle"),[ue,ye]=m.useState(!1),[Se,Re]=m.useState("confirm"),[Ee,me]=m.useState(""),[oe,Ne]=m.useState("codex"),[Oe,Ve]=m.useState(!1),[We,De]=m.useState(!1),[mt,at]=m.useState(0),[Rt,qe]=m.useState(null),[W,K]=m.useState(null),[ae,pe]=m.useState(null),z=m.useRef(null),ve=m.useRef(null),Be=m.useRef((g==null?void 0:g.id)??""),Je=m.useRef(""),kt=m.useRef(0),Mt=m.useRef(void 0),Tt=m.useRef(new Set);Be.current=(g==null?void 0:g.id)??"",m.useEffect(()=>()=>{Mt.current!==void 0&&window.clearTimeout(Mt.current);for(const R of Tt.current)URL.revokeObjectURL(R);Tt.current.clear()},[]);function dt(R){const V=URL.createObjectURL(R);return Tt.current.add(V),V}function ge(R){!R||!Tt.current.delete(R)||URL.revokeObjectURL(R)}function lt(){for(const R of Tt.current)URL.revokeObjectURL(R);Tt.current.clear()}const Ge=m.useCallback(()=>{Mt.current!==void 0&&(window.clearTimeout(Mt.current),Mt.current=void 0),ie("idle")},[]);m.useEffect(()=>{Ge()},[Ge,g==null?void 0:g.id]);const[vt,_t]=m.useState({}),[Bt,je]=m.useState({}),Ze=a?vt[a]??[]:h,Ie=g?y:Ze,Wt=a?Bt[bO(n,a)]??FS:FS,dn=(R,V)=>_t(F=>({...F,[R]:typeof V=="function"?V(F[R]??[]):V})),Qt=(R,V,F)=>{const se=bO(R,V);je(Te=>{const we=Te[se]??FS,xe=wee(we,F);return xe===we?Te:{...Te,[se]:xe}})};function Yt(R,V,F=[],se=""){if(Be.current!==R)return;const Te=crypto.randomUUID(),we={role:"system",blocks:[],activity:{id:Te,title:V,...F.length>0?{details:F}:{}},meta:{localId:Te,ts:Date.now()/1e3}};O(xe=>{if(!se)return[...xe,we];const Fe=xe.findIndex(it=>{var It;return((It=it.meta)==null?void 0:It.localId)===se});return Fe<0?[...xe,we]:[...xe.slice(0,Fe),we,...xe.slice(Fe)]})}const[Jt,Ft]=m.useState(""),[Ce,et]=m.useState("agent"),[wt,yn]=m.useState("agent"),[on,hi]=m.useState("create"),[Pe,st]=m.useState(null),[At,Ut]=m.useState(null),[kn,wn]=m.useState(null),[Ai,Gn]=m.useState(!1),xn=m.useRef(null),de=m.useRef(null),[Le,ut]=m.useState({}),gt=m.useRef(new Map),ln=Le.ready===!0&&Le.agentId===n,[Sn,In]=m.useState([]),[Ni,Pn]=m.useState(xl),[Vt,Ji]=m.useState(null),[fn,pi]=m.useState(0),[ti,vi]=m.useState(!1),[en,Ci]=m.useState(null),[xs,ni]=m.useState(!1),[Ls,er]=m.useState([]),[Ya,mr]=m.useState(!1),gr=m.useRef(new Set),[ul,Sa]=m.useState(()=>new Set),[as,Mn]=m.useState(()=>new Set),[vs,Zl]=m.useState(()=>new Set),Gr=m.useRef(new Map),tr=m.useRef(new Map),No=m.useRef(void 0),Dr=m.useRef(()=>{}),os=(R,V)=>Sa(F=>{const se=new Set(F);return V?se.add(R):se.delete(R),se}),na=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V),tr.current.delete(R),Mn(F=>new Set(F).add(R))},Co=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V),tr.current.delete(R),Mn(F=>{if(!F.has(R))return F;const se=new Set(F);return se.delete(R),se})},br=R=>{const V=tr.current.get(R);V!==void 0&&window.clearTimeout(V);const F=window.setTimeout(()=>{Co(R)},2400);tr.current.set(R,F)},ia=(R,V)=>{Zl(F=>{if(F.has(R)===V)return F;const se=new Set(F);return se.delete(R),se})},ji=m.useRef(""),[Kl,Ke]=m.useState("");function Ds(R,V,F){const se=xn.current;if(!se||se.localId!==R||se.runId!==V)return null;const Te=gH(se,F);return xn.current=Te,wn(Te),Te}async function Ea(R,V,F){var we;(we=de.current)==null||we.abort();const se=new AbortController;de.current=se;let Te=F;try{let xe=xn.current;if(!xe||xe.localId!==R||xe.runId!==V)return;if(Te==="optimization"&&xe.assetIds.length===0){const it=SY(xe.config);if(it.length>0){const It=await Promise.all(it.map(bt=>bdt(bt.file,bt.kind,se.signal)));if(se.signal.aborted||(xe=Ds(R,V,{type:"assets_uploaded",assetIds:It.map(bt=>bt.assetId)}),!xe))return}}if(Te==="optimization"){const it=await Odt({prompt:xe.requestedPrompt,taskMode:xe.requestedMode,assetIds:xe.assetIds,ratio:xe.config.aspectRatio,resolution:xe.config.resolution,durationSeconds:xe.config.durationSeconds},se.signal);if(se.signal.aborted||(xe=Ds(R,V,{type:"optimization_succeeded",optimizedPrompt:it.enhancedPrompt,resolvedMode:it.resolvedTaskMode,enhancerModel:it.enhancerModel}),!xe))return;Te="generation"}if(!xe.optimizedPrompt||!xe.resolvedMode)throw new Error("提示词优化结果不完整,请重新优化后再试。");const Fe=await ydt({enhancedPrompt:xe.optimizedPrompt,resolvedTaskMode:xe.resolvedMode,assetIds:xe.assetIds,ratio:xe.config.aspectRatio,resolution:xe.config.resolution,durationSeconds:xe.config.durationSeconds},se.signal);if(se.signal.aborted||(xe=Ds(R,V,{type:"generation_started",remoteTaskId:Fe.taskId,generationModel:Fe.generationModel}),!xe))return;for(;!se.signal.aborted;){const it=await xdt(Fe.taskId,se.signal);if(se.signal.aborted)return;if(it.status==="failed")throw new Error(it.error||"视频生成失败,请稍后重试。");if(it.status==="succeeded"){if(!it.videoUrl)throw new Error("视频任务已完成,但服务端未返回预览地址。");Ds(R,V,{type:"generation_succeeded",output:{previewUrl:wdt(it.videoUrl),fileName:bOt(Fe.taskId,it.outputFormat),mimeType:it.outputFormat==="mov"?"video/quicktime":"video/mp4"}});return}await new Promise(It=>window.setTimeout(It,1800))}}catch(xe){if(se.signal.aborted)return;Ds(R,V,{type:"failed",stage:Te,error:xe instanceof Error?xe.message:String(xe)})}}function nu(R,V,F){if(ope(xn.current)){Gn(!0);return}if(V.taskMode==="video_editing"&&!V.referenceVideo){Ke("视频编辑需要先添加待编辑视频。");return}if(V.taskMode==="video_extension"&&!V.referenceVideo){Ke("视频续写需要先添加基础视频。");return}if(V.taskMode==="reference_to_video"&&!V.referenceImage&&!V.referenceVideo){Ke("参考素材生视频需要至少添加一项参考图片或参考视频。");return}if(V.taskMode==="text_to_video"&&(V.referenceImage||V.referenceVideo||V.firstFrame||V.lastFrame)){Ke("文生视频不使用参考素材,请先移除已添加的图片或视频。");return}if(V.taskMode==="first_last_frame"&&!V.firstFrame){Ke("首尾帧生成需要先添加首帧图片。");return}if(F.supportedModes.length>0&&V.taskMode!=="auto"&&!F.supportedModes.includes(V.taskMode)){Ke("当前平台暂不支持所选视频任务模式。");return}const se=SY(V);if(se.length>0&&!F.assetStorageAvailable){Ke(F.assetStorageUnavailableReason||"管理员未配置持久化存储");return}const Te=se.find(({file:xe})=>F.maxAssetBytes>0&&xe.size>F.maxAssetBytes);if(Te){Ke(`${Te.file.name} 超出当前平台允许的素材大小。`);return}const we=ift({prompt:R,config:V,enhancerModel:F.enhancerModel,generationModel:F.generationModel});xn.current=we,wn(we),Gn(!0),Ft(""),Ke(""),Ea(we.localId,we.runId,"optimization")}function $s(){const R=xn.current;if(!R||R.status!=="error"||!R.errorStage)return;const V=R.errorStage,F=gH(R,{type:"retry",stage:V});xn.current=F,wn(F),Gn(!0),Ea(F.localId,F.runId,V)}async function Jl(){const R=xn.current;if(!(!(R!=null&&R.remoteTaskId)||!R.output))try{const V=await vdt(R.remoteTaskId),F=URL.createObjectURL(V),se=document.createElement("a");se.href=F,se.download=R.output.fileName,se.click(),window.setTimeout(()=>URL.revokeObjectURL(F),1e3)}catch(V){Ke(V instanceof Error?V.message:String(V))}}m.useEffect(()=>()=>{var R;(R=de.current)==null||R.abort()},[]);const[ec,le]=m.useState(""),[gn,Wn]=m.useState(()=>new Set),[Vi,Ln]=m.useState(null),[Tn,ra]=m.useState(null),[Qs,dr]=m.useState(null),[ws,ls]=m.useState(null);m.useEffect(()=>{dr(null)},[n,a]);const[te,Me]=m.useState(!1),[ee,_e]=m.useState(),[tt,Ct]=m.useState(yY),[He,ht]=m.useState(null),[Pt,jt]=m.useState(!1),[bn,Xi]=m.useState(!1),[Ss,Dn]=m.useState(""),Wr=m.useRef(!1),[sa,qi]=m.useState(null),[Xe,_n]=m.useState(""),[dl,fl]=m.useState(),[mi,Zn]=m.useState(null),cv=(mi==null?void 0:mi.capabilities.runtimeScope)??"mine",[yb,uv]=m.useState({newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,agentUsage:!1,addAgentkit:!0}),[tc,dv]=m.useState("cloud"),[hl,sN]=m.useState(nx),[$n,fv]=m.useState("volcengine"),[hv,pv]=m.useState(""),[Sd,Gp]=m.useState(""),[pl,xb]=m.useState(!1),[Ed,vb]=m.useState(!1),[aN,mv]=m.useState(!1),[oN,Wp]=m.useState({}),[lN,wb]=m.useState({}),[gv,iu]=m.useState({}),bv=ul.has(a),ru=as.has(a),ah=bv||d,cN=!!a&&xs,jo=g?v:ah,uN=jo||!g&&ru,vn=Ggt({session:g,conversationBusy:v,onInputChange:Ft,onSessionPatch:R=>{const V=Be.current;b(F=>(F==null?void 0:F.id)===V?{...F,...R}:F)},onSnapshot:R=>{const V=Be.current;lt(),O(sme(R)),b(F=>(F==null?void 0:F.id)===V?{...F,threadId:R.threadId,cwd:R.cwd??F.cwd,model:R.model??F.model,workspaceLocked:R.workspaceLocked,permissions:R.permissions,busy:!1}:F)},onActivity:(R,V=[])=>{const F=Be.current;F&&Yt(F,R,V)},onError:Ke});m.useEffect(()=>{const R=g;if(!R||!v||ve.current)return;let V=!1,F;const se=new AbortController,Te=async()=>{try{const we=await Kt.getStatus(R.id,{signal:se.signal});if(V||Be.current!==R.id)return;const xe=we.threadId?await Kt.readThread(R.id,we.threadId,{signal:se.signal}):null;if(V||Be.current!==R.id)return;if(xe&&O(pY(xe,we.busy)),b(Fe=>(Fe==null?void 0:Fe.id)===R.id?{...Fe,...we,...xe?{threadId:xe.threadId,cwd:xe.cwd??we.cwd,model:xe.model??we.model,workspaceLocked:xe.workspaceLocked,permissions:xe.permissions}:{}}:Fe),x(we.busy),!we.busy){const Fe=xe==null?void 0:xe.messages[xe.messages.length-1];(Fe==null?void 0:Fe.role)==="user"&&Ke("云端 Codex 已结束,但没有生成回复,请重新发送任务。");return}}catch(we){if((we==null?void 0:we.name)==="AbortError"||V)return;x(!1),b(xe=>(xe==null?void 0:xe.id)===R.id?{...xe,busy:!1}:xe),Ke(we instanceof Error?we.message:String(we));return}F=window.setTimeout(Te,1500)};return F=window.setTimeout(Te,1500),()=>{V=!0,se.abort(),F!==void 0&&window.clearTimeout(F)}},[v,g==null?void 0:g.id]);const dN=oN[a]??"",fN=lN[a]??Wbt,hN=gv[a]??Zbt,nr=Vt==null?void 0:Vt.graph,Ov=[Vt==null?void 0:Vt.name,nr==null?void 0:nr.name,nr==null?void 0:nr.id].filter(R=>!!R),Sb=Ni.targetAgent&&nr?KL(nr,Ni.targetAgent.name):nr,yv=(Sb==null?void 0:Sb.skills)??(Ni.targetAgent?[]:(Vt==null?void 0:Vt.skills)??[]),xv=nr?Eme(nr):[],Eb=(nr==null?void 0:nr.instruction)??((r6=Vt==null?void 0:Vt.draft)==null?void 0:r6.instruction),vv=Vt&&Eb!==void 0?EEe({instruction:Eb,tools:[...new Set([...(nr==null?void 0:nr.tools)??Vt.tools,...(en==null?void 0:en.tools.map(R=>R.name))??[],...Ls])],skills:(nr==null?void 0:nr.skills)??Vt.skills}):null;function Zp(R){$R(R);for(const V of R)V.status==="uploading"?gr.current.add(V.id):V.uri&&zS(n,V.uri).catch(F=>Ke(String(F)))}async function kb(R){try{await rP(n,Xe,R),await iP(n,Xe,R),s(V=>V.filter(F=>F.id!==R)),_t(V=>{const{[R]:F,...se}=V;return se})}catch(V){Ke(String(V))}}function wv(R){const V=Sn.find(Te=>Te.id===R);if(!V)return;const F=Sn.filter(Te=>Te.id!==R);$R([V]),V.status==="uploading"&&gr.current.add(R),In(F),F.length===0&&!Jt.trim()&&!!a&&Ie.length===0?(ji.current="",o(""),kb(a)):V.uri&&zS(n,V.uri).catch(Te=>Ke(String(Te)))}const Y=(R,V)=>{var we,xe,Fe,it,It;const F=V.author&&V.author!=="user"?V.author:void 0;F&&(Wp(bt=>({...bt,[R]:F})),wb(bt=>({...bt,[R]:new Set(bt[R]??[]).add(F)})),iu(bt=>{var ct;return(ct=bt[R])!=null&&ct.length?bt:{...bt,[R]:[F]}}));const se=((we=V.actions)==null?void 0:we.transferToAgent)??((xe=V.actions)==null?void 0:xe.transfer_to_agent);se&&iu(bt=>{const ct=bt[R]??[];return ct[ct.length-1]===se?bt:{...bt,[R]:[...ct,se]}}),(((Fe=V.actions)==null?void 0:Fe.endOfAgent)??((it=V.actions)==null?void 0:it.end_of_agent)??((It=V.actions)==null?void 0:It.escalate))&&iu(bt=>{const ct=bt[R]??[];return ct.length<=1?bt:{...bt,[R]:ct.slice(0,-1)}})},[he,be]=m.useState(mY),[Ue,xt]=m.useState([]),[Xt,Ri]=m.useState({}),nc=m.useCallback(R=>{xt(V=>{const F=V.findIndex(Te=>Te.id===R.id);if(F===-1)return[R,...V];const se=[...V];return se[F]={...se[F],...R},se})},[]),[gi,ic]=m.useState(!0),[Tb,Zr]=m.useState(!1),[kme,pN]=m.useState("skills"),[Tme,mN]=m.useState("技能库"),[_me,Sv]=m.useState(null),[gN,_r]=m.useState(!1),[bN,ui]=m.useState(!1),[Ame,aa]=m.useState(null),[Nme,Ev]=m.useState("custom"),[ON,yN]=m.useState([]),kd=m.useRef([]),Td=m.useRef(null),Kp=m.useRef(null),[RQ,kv]=m.useState([]),[Kr,ml]=m.useState(""),Ro=m.useRef(null),[Tv,Jr]=m.useState(!1),[oh,ii]=m.useState(!1),[IQ,xN]=m.useState(""),[Cme,jme]=m.useState("good"),[Rme,_v]=m.useState("basic"),[Ime,Pme]=m.useState("good"),[_b,Av]=m.useState(""),[Mme,Lme]=m.useState(null),[su,Hi]=m.useState(!1),[vN,rc]=m.useState(!1),[sc,Ga]=m.useState(null),wN=m.useRef(null),[gl,Ab]=m.useState(()=>{const R=Al();return gb(R),R}),[Dme,PQ]=m.useState(!1),[$me,MQ]=m.useState(""),[LQ,Nv]=m.useState(null),[Qme,DQ]=m.useState({}),[Bme,$Q]=m.useState(()=>new Set),[ac,oc]=m.useState(null),[Nb,Cv]=m.useState(Qi($n)),[QQ,oa]=m.useState(""),[BQ,la]=m.useState(""),[Jn,Bs]=m.useState(null),[Ume,SN]=m.useState(!1),jv=m.useRef(!1),Jp=m.useRef(!1),lc=m.useCallback(R=>{if(!Xe)return!1;try{qH(localStorage,Xe,R)}catch(V){return le(V instanceof Error?V.message:"浏览器拒绝保存草稿,请稍后重试。"),!1}return kd.current=R,yN(R),le(""),!0},[Xe]),cc=m.useCallback(R=>{var V;R&&((V=Td.current)==null?void 0:V.id)!==R||(Td.current=null,Kp.current!==null&&(window.clearTimeout(Kp.current),Kp.current=null))},[]),_d=m.useCallback(()=>{const R=Td.current;if(!R)return!0;const V=lc([R,...kd.current.filter(F=>F.id!==R.id)]);return V&&cc(),V},[cc,lc]),zme=m.useCallback((R,V,F)=>{!R||!Xe||(Td.current&&Td.current.id!==R&&_d(),Td.current={id:R,draft:V,updatedAt:Date.now(),deploymentTarget:F},Kp.current!==null&&window.clearTimeout(Kp.current),Kp.current=window.setTimeout(_d,qbt))},[_d,Xe]),EN=m.useCallback(R=>{!R||!Xe||(cc(R),lc(kd.current.filter(V=>V.id!==R)))},[cc,lc,Xe]),UQ=m.useCallback(R=>{if(!Xe||R.length===0)return;const V=new Set(R.map(F=>F.id));Td.current&&V.has(Td.current.id)&&cc(),lc(kd.current.filter(F=>!V.has(F.id))),Ri(F=>Object.fromEntries(Object.entries(F).filter(([se])=>!V.has(se)))),V.has(Kr)&&(ml(""),aa(null),oc(null),Ro.current=null,localStorage.removeItem(MR(Xe)))},[cc,lc,Kr,Xe]),zQ=m.useCallback(R=>{if(!R||!Xe)return;cc(R);const V=Ro.current,F=kd.current.filter(se=>se.id!==R);lc((V==null?void 0:V.id)===R?[V,...F]:F)},[cc,lc,Xe]);m.useEffect(()=>(window.addEventListener("pagehide",_d),()=>{window.removeEventListener("pagehide",_d)}),[_d]),m.useEffect(()=>{if(!Xe){cc(),kd.current=[],yN([]),kv([]),ml(""),le(""),Ro.current=null;return}let R=[],V="";try{R=kmt(localStorage,Xe),localStorage.getItem(tN(Xe))!==null&&qH(localStorage,Xe,R),V=localStorage.getItem(MR(Xe))||"",le("")}catch(se){le(se instanceof Error?se.message:"无法读取本机草稿,请稍后重试。")}kd.current=R,yN(R),kv(Jbt(Xe));const F=R.find(se=>se.id===V);Ro.current=F??null,he==="custom"&&F&&(ml(F.id),aa(F.draft),oc(F.deploymentTarget??null))},[cc,Xe]),m.useEffect(()=>{if(!Xe)return;const R=MR(Xe);try{he==="custom"&&Kr?localStorage.setItem(R,Kr):localStorage.removeItem(R)}catch{le("浏览器拒绝保存当前草稿位置,请检查站点存储权限后重试。")}},[he,Kr,Xe]);const Fme=m.useCallback(R=>{if(!Xe)return;const V=[...new Set(R.filter(Boolean))];kv(V),localStorage.setItem(ZL(Xe),JSON.stringify(V))},[Xe]),Vme=m.useCallback(async R=>{const V=R.filter(it=>!!it.runtimeId&&it.canDelete===!0);if(V.length===0)return;const F=mOt(gl,n),se=new Set(V.map(it=>it.runtimeId));$Q(it=>{const It=new Set(it);for(const bt of se)It.add(bt);return It}),hS(se);const Te=new Set,we=new Set,xe=new Set,Fe=[];for(const it of V)try{if(!it.region)throw new Error("Runtime 缺少地域信息,无法删除");await hee(it.runtimeId,it.region),IT(it.runtimeId),Te.add(it.runtimeId),we.add(it.id)}catch(It){const bt=It instanceof Error?It.message:String(It);xe.add(it.runtimeId),Fe.push(`${it.label}: ${bt}`)}if(Te.size>0&&(hS(Te),Ab(Al()),Nv(It=>{if(!It)return It;const bt=new Set(It);for(const ct of Te)bt.delete(ct);return bt}),DQ(It=>Object.fromEntries(Object.entries(It).filter(([bt])=>!Te.has(bt)))),kv(It=>{const bt=It.filter(ct=>!we.has(ct));return Xe&&localStorage.setItem(ZL(Xe),JSON.stringify(bt)),bt}),lc(kd.current.filter(It=>{var bt;return!((bt=It.deploymentTarget)!=null&&bt.runtimeId)||!Te.has(It.deploymentTarget.runtimeId)})),(F?Te.has(F):V.some(It=>It.id===n))&&(mge(),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),oa(""),la(""),Hi(!0),Ke("")),Jn!=null&&Jn.runtime&&Te.has(Jn.runtime.runtimeId)&&(be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),oa(""),la(""),Hi(!0),Ke(""))),xe.size>0&&$Q(it=>{const It=new Set(it);for(const bt of xe)It.delete(bt);return It}),Fe.length>0){const it=Fe.slice(0,3).join(";"),It=Fe.length>3?`;另有 ${Fe.length-3} 个失败`:"";throw new Error(`${Fe.length} 个 Agent 删除失败:${it}${It}`)}},[Jn,n,lc,gl,Xe]),kN=m.useCallback(async()=>{PQ(!0),MQ("");try{const R=[];let V="";do{const F=await S_({scope:cv,region:"all",pageSize:100,nextToken:V});R.push(...F.runtimes),V=F.nextToken}while(V&&R.length<2e3);Nv(new Set(R.map(F=>F.runtimeId))),DQ(Object.fromEntries(R.map(F=>[F.runtimeId,{canDelete:F.canDelete}])))}catch(R){MQ(R instanceof Error?R.message:String(R))}finally{PQ(!1)}},[cv]);function Xme(R){console.log("create agent draft:",R),be(null),Nd()}function TN(R,V){console.log("Agent added, navigating to:",R,V),Ab(Al()),Nv(null),hS(),EN(Kr),ml(""),Ro.current=null,oc(null),oa(""),la(R),_v("basic"),be(null),ii(!0),i(R)}const _N=m.useCallback(R=>{be(null),ui(!1),Hi(!1),Bs(null),ii(!0),la(""),_v("basic"),oa(R.id),Ke("")},[]),AN=m.useCallback(R=>{_d();const V=Kr?{...R,draftId:Kr}:R;Kr&&Ri(F=>({...F,[Kr]:R.id})),nc(V),_N(V)},[Kr,_d,_N,nc]),NN=m.useCallback(async R=>{if(!R.runtimeId)throw new Error("部署完成,但未返回 Runtime ID。");const V=Kr;V&&(EN(V),Ri(we=>{if(!we[V])return we;const xe={...we};return delete xe[V],xe})),ml(""),Ro.current=null,oc(null);const F=(ac==null?void 0:ac.region)??Nb,se=await SE(R.runtimeId,R.runtimeName,R.region??F,R.version,{waitForReady:!0,agentName:R.agentName});Ab(Al()),pi(we=>we+1);const Te=await PR(se);gt.current.set(se,Te),ut(Te),Nv(we=>{const xe=new Set(we??[]);return xe.add(R.runtimeId),xe}),hS(),la(se),_v("basic"),oa(""),be(null),ii(!0),i(se)},[Kr,Nb,EN,ac]),Cb=m.useRef(null),CN=m.useRef(new Map),qme=m.useRef(0),FQ=m.useRef(new Map),VQ=gl.some(R=>!!(R.runtimeId&&R.region)&&R.apps.some(V=>Ll(R.id,V)===n));m.useLayoutEffect(()=>{const R=new Map;Ie.forEach((V,F)=>{var xe;const se=((xe=V.meta)==null?void 0:xe.eventId)??"",Te=!!(VQ&&se&&Ud(V)),we=F===Ie.length-1&&(jo||ru);R.set(F,{enabled:!!(Te&&$n!=="byteplus"&&!we&&!DR(V)),turn:V,input:Te?LR(Ie,F):""})}),FQ.current=R},[jo,$n,ru,VQ,Ie]);const XQ=m.useCallback(()=>{var xe;const R=window.getSelection(),V=(R==null?void 0:R.anchorNode)instanceof Element?R.anchorNode:(xe=R==null?void 0:R.anchorNode)==null?void 0:xe.parentElement,F=V==null?void 0:V.closest(".turn--assistant");if(!F)return;const se=Number(F.dataset.responseAnnotationIndex);if(!Number.isInteger(se))return;const Te=FQ.current.get(se);if(!(Te!=null&&Te.enabled))return;const we=_bt(F,R);we&&dr({selectionId:++qme.current,turn:Te.turn,input:Te.input,selectedText:we.text,anchor:we.anchor})},[]);m.useEffect(()=>{let R=null;const V=F=>{F.target instanceof Element&&F.target.closest(".response-annotation-popover")||(R!==null&&window.cancelAnimationFrame(R),R=window.requestAnimationFrame(()=>{R=null,XQ()}))};return document.addEventListener("mouseup",V,!0),document.addEventListener("keyup",V,!0),()=>{R!==null&&window.cancelAnimationFrame(R),document.removeEventListener("mouseup",V,!0),document.removeEventListener("keyup",V,!0)}},[XQ]);const lh=m.useRef(!0),Ad=m.useRef(!1),ch=m.useRef(null),qQ=m.useRef({key:"",turnCount:0}),jN=(g==null?void 0:g.id)??a;m.useLayoutEffect(()=>{const R=Cb.current,V=qQ.current,F=V.key!==jN,se=!F&&Ie.length>V.turnCount;if(qQ.current={key:jN,turnCount:Ie.length},!R||Ie.length===0||!F&&!se)return;lh.current=!0,Ad.current=!1,ch.current!==null&&(window.clearTimeout(ch.current),ch.current=null);const Te=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(F||Te){R.scrollTop=R.scrollHeight;return}Ad.current=!0,R.scrollTo({top:R.scrollHeight,behavior:"smooth"}),ch.current=window.setTimeout(()=>{Ad.current=!1,ch.current=null},450)},[jN,Ie.length]),m.useLayoutEffect(()=>{const R=Cb.current;!R||!lh.current||Ad.current||(R.scrollTop=R.scrollHeight)},[jo,Ie]),m.useEffect(()=>{if(!_b||oh||Ie.length===0)return;const R=CN.current.get(_b);if(!R)return;lh.current=!1,R.scrollIntoView({behavior:"smooth",block:"center"});const V=window.setTimeout(()=>{Av("")},2600);return()=>window.clearTimeout(V)},[_b,oh,Ie]),m.useEffect(()=>()=>{ch.current!==null&&window.clearTimeout(ch.current)},[]);const Hme=m.useCallback(()=>{const R=Cb.current;!R||Ad.current||(lh.current=R.scrollHeight-R.scrollTop-R.clientHeight<32)},[]),Yme=m.useCallback(R=>{R.deltaY<0&&(Ad.current=!1,lh.current=!1)},[]),Gme=m.useCallback(()=>{Ad.current=!1,lh.current=!1},[]),Wme=m.useCallback(()=>{const R=Cb.current;!R||!lh.current||Ad.current||(R.scrollTop=R.scrollHeight)},[]),RN=m.useCallback(()=>{qi(null),JI().then(R=>{_n(R.userId),fl(R.info),vb(!!R.local),ht(R.status),R.status==="authenticated"&&(jv.current=!0,Jp.current=!0,localStorage.removeItem(vl.app),i(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Hi(!1))}).catch(R=>{qi(R instanceof Error?R.message:String(R))})},[]);m.useEffect(()=>{RN()},[RN]),m.useEffect(()=>{const R=()=>{Dn(""),jt(!0)};return window.addEventListener(eP,R),ASe()&&R(),()=>window.removeEventListener(eP,R)},[]);const Zme=m.useCallback(async()=>{if(Wr.current)return;Wr.current=!0;const R=vSe();if(!R){Wr.current=!1,Dn("登录窗口被浏览器拦截,请允许弹出窗口后重试。");return}Xi(!0),Dn("");try{for(;;){await new Promise(V=>window.setTimeout(V,1e3));try{const V=await JI();if(V.status==="authenticated"){_n(V.userId),fl(V.info),vb(!!V.local),ht(V.status),jt(!1),NSe(),R.close();return}}catch{}if(R.closed){Dn("登录窗口已关闭,请重新登录以继续当前操作。");return}}}finally{Wr.current=!1,Xi(!1)}},[]);m.useEffect(()=>{Ed&&Xe&&o9(Xe)},[Ed,Xe]),m.useEffect(()=>{if(He!=="authenticated"||!Xe){ut({});return}const R=gt.current.get(n);if(R){ut(R);return}let V=!1;return ut({}),PR(n).then(F=>{V||(gt.current.set(n,F),ut(F))}),()=>{V=!0}},[n,He,Xe]),m.useLayoutEffect(()=>{!ln||Le.skillCustomizationEnabled!==!1||wt!=="skill"||(yn("agent"),st(null),Ut(null))},[Le.skillCustomizationEnabled,ln,wt]),m.useEffect(()=>{if(He!=="authenticated"||!Xe){Zn(null);return}let R=!1;return Zn(null),oee().then(V=>{R||Zn(V)}).catch(V=>{console.warn("[app] /web/access failed; using ordinary-user access:",V),R||Zn(aee)}),()=>{R=!0}},[He,Xe]),m.useEffect(()=>{see().then(R=>{const V="prod";Rut({enabled:R.telemetry.enabled,environment:V});const F=R.telemetry.studio;Iut({userPoolId:(F==null?void 0:F.userPoolId)??"",studioDeployId:(F==null?void 0:F.deployId)??"",applicationId:(F==null?void 0:F.applicationId)??"",functionId:(F==null?void 0:F.functionId)??"",studioRegion:(F==null?void 0:F.region)??"",studioProject:(F==null?void 0:F.project)??"",studioVersion:(F==null?void 0:F.version)||R.version,environment:V,cloudProvider:R.provider,accountId:(F==null?void 0:F.accountId)??""}),Mut({authState:"anonymous"}),uv(R.features),dv(R.agentsSource),fv(R.provider),Gp((F==null?void 0:F.region)||Qi(R.provider)),sN(R.branding),pv(R.version),xb(!0)})},[]),m.useEffect(()=>{if(He!=="authenticated"||!dl||!mi||!pl)return;const R=String(mi.telemetry.userId).trim();R&&(Put({userUniqueId:R,accountId:mi.telemetry.accountId??"",userRole:mi.role==="admin"?"admin":"member",userSource:Ed?"local":"sso"}),Lut({agentsSource:tc}))},[mi,tc,He,Ed,pl,dl]),m.useEffect(()=>{Cv(R=>{const V=Qi($n);return!R||$n==="byteplus"&&R.startsWith("cn-")||$n==="volcengine"&&R.startsWith("ap-")?V:R})},[$n]),m.useEffect(()=>{mi&&(mi.capabilities.createAgents||(be(null),aa(null),_r(!1),ui(!1),xt([])),mi.capabilities.manageAgents||ii(!1))},[mi]);let ka={kind:"home"};if(He==="authenticated"){if(ws!==null)ka={kind:"page",title:"问题反馈"};else if(vN)ka={kind:"page",title:"系统信息"};else if(sc)ka={kind:"page",title:sc==="catalog"?"自动化":Khe(sc).name};else if(W)ka={kind:"page",title:W.session.displayName||"智能体"};else if(Rt)ka={kind:"page",title:Rt.displayName||"智能体"};else if(su||oh)ka={kind:"page",title:(Jn==null?void 0:Jn.name)||"智能体"};else if(bN)ka={kind:"page",title:"创建智能体"};else if(Tv)ka={kind:"page",title:"搜索"};else if(gN)ka={kind:"page",title:"添加智能体"};else if(Tb)ka={kind:"page",title:Tme||"库"};else if(he)ka={kind:"page",title:he==="custom"?ac!=null&&ac.name?`更新 ${ac.name}`:"创建智能体":he==="package"?"从代码包添加":"迁移智能体"};else if(g){const R=vn.threads.find(V=>V.id===g.threadId);ka={kind:"conversation",title:(R==null?void 0:R.name)||(R==null?void 0:R.preview)||g.displayName}}else if(a){const R=r.find(F=>F.id===a),V=E_(R==null?void 0:R.events);ka=V==="新会话"?{kind:"home"}:{kind:"conversation",title:V}}}const HQ=hdt(hl.title,ka);m.useEffect(()=>{He!=="authenticated"||tc!=="cloud"||!pl||!oh||Jn||kN()},[Jn,tc,He,oh,kN,pl]),m.useEffect(()=>{document.title=HQ;let R=document.querySelector('link[rel~="icon"]');R||(R=document.createElement("link"),R.rel="icon",document.head.appendChild(R)),R.removeAttribute("type"),R.href=hl.logoUrl||($n==="byteplus"?i$:n$)},[$n,hl.logoUrl,HQ]),m.useEffect(()=>{fetch("/web/runtime-config",{signal:AbortSignal.timeout(1e4)}).then(R=>R.ok?R.json():null).then(R=>{R&&ic(!!R.credentials)}).catch(R=>{console.warn("[app] /web/runtime-config probe failed; workbench stays hidden:",R)})},[]);function Kme(R){o9(R),jv.current=!0,Jp.current=!0,localStorage.removeItem(vl.app),Zn(null),be(null),aa(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Nd(),i(""),Hi(!1),_n(R),fl({name:R}),vb(!0),ht("authenticated")}function Jme(){Zn(null),Ed?(ySe(),_n(""),fl(void 0),ht("unauthenticated")):SSe()}m.useEffect(()=>{if(He==="authenticated"){if(tc==="cloud"){const R=wY(gl);i(V=>V&&R.includes(V)?V:(V&&(Jp.current=!0,localStorage.removeItem(vl.app)),""));return}_J().then(R=>{t(R);const V=wY(gl);i(F=>F&&(R.includes(F)||V.includes(F))?F:(F&&(Jp.current=!0,localStorage.removeItem(vl.app)),""))}).catch(R=>Ke(String(R)))}},[He,tc,gl]),m.useEffect(()=>{n?(Jp.current=!1,localStorage.setItem(vl.app,n)):localStorage.removeItem(vl.app)},[n]),m.useEffect(()=>{let R=!1;if(Ci(null),er([]),su||Jn||!n||!Xe||!a){ni(!1);return}return ni(!0),aP(n,Xe,a).then(V=>{R||(Ci(V),ZD(n).then(F=>{R||er(F)}).catch(()=>{R||er([])}))}).catch(()=>{R||Ci(null)}).finally(()=>{R||ni(!1)}),()=>{R=!0}},[Jn,n,su,Xe,a]),m.useEffect(()=>{let R=!1;if(Ji(null),Pn(xl()),He!=="authenticated"||su||Jn||!n){vi(!1);return}return vi(!0),WJ(n).then(V=>{R||Ji(V)}).catch(()=>{R||Ji(null)}).finally(()=>{R||vi(!1)}),()=>{R=!0}},[Jn,n,fn,He,su]),m.useEffect(()=>{mi&&localStorage.setItem(vl.view,mi.capabilities.createAgents?he??"chat":"chat")},[mi,he]),m.useEffect(()=>{localStorage.setItem(vl.session,a),ji.current=a},[a]),m.useEffect(()=>{const R=gOt(gl,n);if(!R||!Xe){Dr.current=()=>{},Zl(bt=>bt.size===0?bt:new Set);return}const{runtimeId:V,region:F,appName:se}=R;let Te=!1,we=0;function xe(){No.current!==void 0&&(window.clearTimeout(No.current),No.current=void 0)}function Fe(bt){xe(),No.current=window.setTimeout(()=>void it(),bt)}async function it(){const bt=++we;try{const ct=await DJ({runtimeId:V,region:F,appName:se,userId:Xe});if(Te||bt!==we)return;const Qn=new Set(ct.items.filter(Nt=>Nt.state==="running").map(Nt=>Nt.sessionId));if(Zl(Nt=>Nt.size===Qn.size&&[...Qn].every($r=>Nt.has($r))?Nt:Qn),Qn.size>0){Fe(Hbt);return}const Fn=ct.items.filter(Nt=>Nt.state==="pending").map(Nt=>Date.parse(Nt.dueAt)).filter(Number.isFinite);Fn.length>0&&Fe(Math.max(Gbt,Math.min(...Fn)-Date.now()))}catch{!Te&&bt===we&&Fe(Ybt)}}const It=()=>{xe(),it()};return Dr.current=It,It(),()=>{Te=!0,we+=1,xe(),Dr.current===It&&(Dr.current=()=>{})}},[n,gl,Xe]),m.useEffect(()=>()=>Gr.current.forEach(R=>R.abort()),[]),m.useEffect(()=>()=>tr.current.forEach(R=>{window.clearTimeout(R)}),[]),m.useEffect(()=>()=>{var R,V;(R=z.current)==null||R.abort(),(V=ve.current)==null||V.abort()},[]),m.useEffect(()=>{if(su||Jn||g||!n||!Xe)return;let R=!1;return(async()=>{const V=await jb(n);if(!R){if(!jv.current){jv.current=!0;const F=localStorage.getItem(vl.session)||"";if(mY()===null&&F&&V.some(se=>se.id===F)){Rb(F);return}}Nd()}})(),()=>{R=!0}},[Jn,n,su,g,Xe]),m.useEffect(()=>{const R=wN.current;R&&R.app===n&&(wN.current=null,Rb(R.sid))},[n]);function YQ(R,V){Jr(!1),R===n?Rb(V):(wN.current={app:R,sid:V},i(R))}async function jb(R){const V=u.current+1;u.current=V;try{const F=await qD(R,Xe),se=await Promise.allSettled(F.map(xe=>{var Fe;return(Fe=xe.events)!=null&&Fe.length?Promise.resolve(xe):gk(R,Xe,xe.id)})),Te=se.find(xe=>xe.status==="rejected"&&!/get session failed:\s*404\b/i.test(String(xe.reason)));if((Te==null?void 0:Te.status)==="rejected")throw Te.reason;const we=se.flatMap(xe=>xe.status==="fulfilled"?[xe.value]:[]);return u.current!==V||(je(xe=>{const Fe={...xe};for(const it of we)Fe[bO(R,it.id)]=h9(it.events??[]);return Fe}),s(we)),we}catch(F){return u.current===V&&Ke(String(F)),[]}}function IN(R="codex",V=!1){g||(Ke(""),me(""),Re("confirm"),Ne(R),Ve(V),ye(!0))}function ege(){var R;(R=z.current)==null||R.abort(),z.current=null,ye(!1),Re("confirm"),me(""),!g&&Ce!=="agent"&&!Oe&&et("agent")}async function tge(R,V){var Te;(Te=z.current)==null||Te.abort();const F=new AbortController;z.current=F,Re("loading"),me("");const se=Dut({sandboxKind:oe,sandboxSource:Oe?"my_agents":"new_chat"});try{const we=oe==="codex"?await Kt.startSession({displayName:R,persistent:V,signal:F.signal}):await Kt.startAgentSession(oe,{displayName:R,persistent:V,signal:F.signal});if(z.current!==F){se.fail({errorKind:"abort"});return}if(se.succeed({sandboxId:String(we.id)}),Oe){at(Fe=>Fe+1),ye(!1),Re("confirm"),Hi(!0);return}if(oe!=="codex"){const Fe=await Kt.openAgentSession(oe,we.id,{signal:F.signal});if(z.current!==F)return;ji.current="",o(""),p([]),Ft(""),Pn(xl()),et(oe==="deepseek-harness"?"deepseek-harness":"agent"),Zp(Sn),In([]),lt(),O([]),b(null),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),Hi(!1),qe(null),K(Fe),ye(!1),Re("confirm");return}const xe=await Kt.connectSession(we.id,{signal:F.signal});if(z.current!==F)return;ji.current="",o(""),p([]),Ft(""),Pn(xl()),et("temporary"),Zp(Sn),In([]),lt(),O([]),b(xe),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),Hi(!1),qe(null),K(null),ye(!1),Re("confirm")}catch(we){if(se.fail(Ra(we)),(we==null?void 0:we.name)==="AbortError"||z.current!==F)return;me(we instanceof Error?we.message:String(we)),Re("error")}finally{z.current===F&&(z.current=null)}}async function Rv(R,V="my_agents"){Ke("");const F=rR({targetId:String(R.id),agentKind:R.toolName,connectSource:V});try{const se=R.resourceType==="snapshot"?await Kt.resumeSnapshot(R.toolName,R.snapshotId):R;if(R.resourceType==="snapshot"&&at(we=>we+1),se.toolName==="codex"){const we=await Kt.connectSession(se.id),xe=await Kbt(we);F.succeed({sandboxStatus:gY(we.status)}),ji.current="",o(""),p([]),Ft(""),Pn(xl()),lt(),xe?(O(pY(xe,we.busy)),b({...we,threadId:xe.threadId,cwd:xe.cwd??we.cwd,workspaceLocked:xe.workspaceLocked,permissions:xe.permissions,...xe.model?{model:xe.model}:{}})):(O([]),b(we)),x(we.busy),qe(null),K(null),Hi(!1),ii(!1);return}const Te=await Kt.openAgentSession(se.toolName,se.id);F.succeed({sandboxStatus:gY(Te.session.status)}),K(Te),qe(null),Hi(!1),ii(!1)}catch(se){throw F.fail(Ra(se)),Ke(se instanceof Error?se.message:String(se)),se}}async function nge(R){const F=(await Kt.listSessions()).find(se=>se.resourceType==="session"&&se.toolName==="codex"&&se.id===R);if(!F)throw new Error("云端 Codex Session 暂未出现在列表中,请稍后重试。");await Rv(F,"my_agents"),De(!1)}function ige(R){qe(R),K(null),Hi(!1),ii(!1),Ke("")}async function rge(R){R.resourceType==="snapshot"?await Kt.deleteSnapshot(R.toolName,R.snapshotId):((g==null?void 0:g.id)===R.id&&uc(),R.toolName==="codex"?await Kt.deleteSession(R.id):await Kt.deleteAgentSession(R.toolName,R.id)),qe(null),K(null),at(V=>V+1),Hi(!0)}async function sge(){const R=ae;if(!R)return;await vn.deleteThread(R.id)&&pe(null)}function uc(){var V;(V=ve.current)==null||V.abort(),ve.current=null,Be.current="",Je.current="",x(!1),lt(),O([]),In([]),Ft(""),Ke(""),et("agent"),E(!1),k(""),A(!1),C(!1),L(null),Q(null),$(!1),B(""),X(null),D(!1),re(""),Ge(),pe(null),Ae(!1),kt.current+=1;const R=g;b(null),R&&Kt.closeSession(R.id).catch(F=>Ke(String(F)))}async function PN(R){const V=g;if(V){L(R),Q(null),B(""),$(!0);try{const F=R==="terminal"?await Kt.launchTerminal(V.id):await Kt.launchBrowser(V.id);Q(F)}catch(F){B(F instanceof Error?F.message:String(F))}finally{$(!1)}}}async function age(){var V;const R=g;if(!(!R||J==="copying")){ie("copying"),Ke("");try{if(!((V=navigator.clipboard)!=null&&V.writeText))throw new Error("当前浏览器不支持写入剪贴板。");const F=await Kt.getEndpoint(R.id);if(await navigator.clipboard.writeText(F.endpoint),Be.current!==R.id)return;ie("copied"),Mt.current!==void 0&&window.clearTimeout(Mt.current),Mt.current=window.setTimeout(()=>{ie("idle"),Mt.current=void 0},1600)}catch(F){if(Be.current!==R.id)return;ie("idle"),Ke(F instanceof Error?F.message:String(F))}}}async function oge(R){const V=g;if(!(!V||w)){E(!0),k("");try{const F=await Kt.updatePermissions(V.id,R);b(se=>(se==null?void 0:se.id)===V.id?{...se,permissions:F}:se),Yt(V.id,"已更新当前 Sandbox Session 的 Codex 权限",[{label:"沙箱模式",value:uOt[F.sandboxMode]},{label:"审批策略",value:dOt[F.approvalPolicy]},{label:"审批方式",value:fOt[F.approvalsReviewer]},{label:"网络访问",value:F.networkAccess?"允许":"关闭"}]),Be.current===V.id&&A(!1)}catch(F){k(F instanceof Error?F.message:String(F))}finally{E(!1)}}}const lge=m.useCallback(async R=>{const V=g==null?void 0:g.id;if(!V)throw new Error("当前没有已连接的 Sandbox。");return Kt.listDirectories(V,R)},[g==null?void 0:g.id]);async function cge(R){const V=g;if(!(!V||V.workspaceLocked||w)){E(!0),k("");try{const F=await Kt.updateWorkspace(V.id,R);b(se=>(se==null?void 0:se.id)===V.id?{...se,cwd:F}:se),vn.invalidateSkills(),Yt(V.id,"已更新工作空间",[{label:"工作目录",value:F,code:!0}]),Be.current===V.id&&C(!1)}catch(F){k(F instanceof Error?F.message:String(F))}finally{E(!1)}}}async function uge(R){const V=g,F=I;if(!(!V||!F||q)){D(!0),re("");try{await Kt.resolveApproval(V.id,F.id,R),Yt(V.id,hOt(F,R),pOt(F),Je.current),X(se=>(se==null?void 0:se.id)===F.id?null:se)}catch(se){re(se instanceof Error?se.message:String(se))}finally{D(!1)}}}async function dge(R){const V=g;if(!V||fe)return;const F=++kt.current;Ke(""),Ae(!0);const se=Array.from(R).map(Te=>{const we={id:xY(),mimeType:vY(Te),name:Te.name,sizeBytes:Te.size,status:"uploading",previewUrl:dt(Te)};return{file:Te,attachment:we}});In(Te=>[...Te,...se.map(({attachment:we})=>we)]);try{const we=(await Promise.all(se.map(async({file:xe,attachment:Fe})=>{try{const it=await Kt.uploadFile(V.id,xe);return kt.current!==F?null:(In(It=>It.map(bt=>bt.id===Fe.id?{...bt,id:it.id,uri:it.path,name:it.name,mimeType:it.mimeType,sizeBytes:it.sizeBytes,status:"ready"}:bt)),it)}catch(it){if(kt.current!==F)return null;const It=it instanceof Error?it.message:String(it);return In(bt=>bt.map(ct=>ct.id===Fe.id?{...ct,status:"error",error:It}:ct)),Ke(It),null}}))).filter(xe=>xe!==null);kt.current===F&&we.length>0&&Yt(V.id,we.length===1?"已上传文件到 Sandbox":`已上传 ${we.length} 个文件到 Sandbox`,we.map((xe,Fe)=>({label:we.length===1?"文件":`文件 ${Fe+1}`,value:xe.path,code:!0})))}finally{if(kt.current===F)Ae(!1);else for(const{attachment:Te}of se)ge(Te.previewUrl)}}function fge(R){const V=Sn.find(F=>F.id===R);V&&(ge(V.previewUrl),In(F=>F.filter(se=>se.id!==R)))}function hge(){var V;const R=g==null?void 0:g.id;(V=ve.current)==null||V.abort(),R&&Kt.interruptSession(R).catch(F=>Ke(F instanceof Error?F.message:String(F)))}async function GQ(R,V=[],F=[]){var $r;const se=g,Te=V.filter(Lt=>Lt.status==="ready"&&Lt.uri);if(!se||v||!R.trim()&&Te.length===0)return;Ke(""),X(null),re("");const we=tH({agentId:String(se.id),agentKind:se.toolName,messageSource:"composer",sessionState:"existing",sessionId:String(se.id)}),xe=new AbortController;($r=ve.current)==null||$r.abort(),ve.current=xe;const Fe=[];F.length>0&&Fe.push({kind:"invocation",value:{skills:F.map(({name:Lt,description:qn})=>({name:Lt,description:qn}))}}),Te.length>0&&Fe.push({kind:"attachment",files:Te.map(Lt=>({id:Lt.id,mimeType:Lt.mimeType,name:Lt.name,sizeBytes:Lt.sizeBytes,previewUrl:Lt.previewUrl}))}),R.trim()&&Fe.push({kind:"text",text:R});const it=Te.map(Lt=>Lt.uri).filter(Lt=>!!Lt),bt=[F.map(Lt=>`$${Lt.name}`).join(" "),R.trim()].filter(Boolean).join(" "),ct=it.length>0?[bt,"以下文件已上传到当前 Sandbox 工作空间,请在任务中使用:",...it.map(Lt=>`- ${Lt}`)].filter(Boolean).join(` -`):bt,Qn=crypto.randomUUID(),Fn=crypto.randomUUID(),Nt=[{role:"user",blocks:Fe,meta:{localId:Qn,ts:Date.now()/1e3}},{role:"assistant",blocks:[],meta:{localId:Fn}}];Je.current=Fn,O(Lt=>[...Lt,...Nt]),x(!0),b(Lt=>(Lt==null?void 0:Lt.id)===se.id?{...Lt,busy:!0,workspaceLocked:!0}:Lt);try{const Lt=await Kt.sendMessage({sessionId:se.id,text:ct,skillIds:F.map(qn=>qn.id)},{signal:xe.signal,onApproval:qn=>{xe.signal.aborted||ve.current!==xe||(re(""),X(qn))},onApprovalResolved:qn=>{xe.signal.aborted||ve.current!==xe||X(tn=>(tn==null?void 0:tn.id)===qn?null:tn)},onBlocks:qn=>{xe.signal.aborted||ve.current!==xe||O(tn=>{const qt=tn.slice(),On=qt.findIndex(Vn=>{var zs;return((zs=Vn.meta)==null?void 0:zs.localId)===Fn}),di=qt[On];return(di==null?void 0:di.role)==="assistant"&&(qt[On]={...di,blocks:qn}),qt})},onUsage:qn=>{xe.signal.aborted||ve.current!==xe||O(tn=>{const qt=tn.slice(),On=qt.findIndex(Vn=>{var zs;return((zs=Vn.meta)==null?void 0:zs.localId)===Fn}),di=qt[On];return(di==null?void 0:di.role)==="assistant"&&(qt[On]={...di,meta:{...di.meta,sandboxUsage:qn.usage}}),qt})}});if(xe.signal.aborted||ve.current!==xe){we.fail({sessionId:String(se.id),failedPhase:"sandbox_send",errorKind:"abort"});return}we.succeed({sessionId:String(se.id)}),O(qn=>{const tn=qn.slice(),qt=tn.findIndex(di=>{var Vn;return((Vn=di.meta)==null?void 0:Vn.localId)===Fn}),On=tn[qt];return(On==null?void 0:On.role)==="assistant"&&(tn[qt]={...On,blocks:Lt.blocks,meta:{...On.meta,ts:Date.now()/1e3,...Lt.usage?{sandboxUsage:Lt.usage.usage}:{}}}),tn}),vn.refreshThreads()}catch(Lt){if(we.fail({sessionId:String(se.id),failedPhase:"sandbox_send",...Ra(Lt)}),(Lt==null?void 0:Lt.name)==="AbortError"||ve.current!==xe)return;O(qn=>qn.filter(tn=>{var qt,On;return((qt=tn.meta)==null?void 0:qt.localId)!==Qn&&((On=tn.meta)==null?void 0:On.localId)!==Fn})),Ft(R),In(V),vn.setSelectedSkills(F),Ke(`内置智能体发送失败:${Lt instanceof Error?Lt.message:String(Lt)}`);try{const qn=await Kt.getSettings(se.id);b(tn=>(tn==null?void 0:tn.id)===se.id?{...tn,...qn}:tn)}catch{}}finally{ve.current===xe&&(ve.current=null,Je.current===Fn&&(Je.current=""),x(!1),X(null),b(Lt=>(Lt==null?void 0:Lt.id)===se.id?{...Lt,busy:!1}:Lt))}}async function hge(R){if(await vn.executeSlash(R)||!g||v||vn.commandBusy)return;const V=Sn,F=vn.selectedSkills;Ft(""),In([]),vn.setSelectedSkills([]),await GQ(R.trim(),V,F)}function Nd(){uc(),Ke(""),Ct(OY()),et("agent"),Ut(null),st(null);const R=a&&Ze.length===0&&Sn.length>0?a:"";ji.current="",o(""),Ci(null),er([]),f(!1),p([]),Pn(xl()),Zp(Sn),In([]),R&&kb(R)}function pge(){var R;Jp.current=!0,localStorage.removeItem(vl.app),a&&((R=Gr.current.get(a))==null||R.abort()),c.current=null,Nd(),i(""),ut({}),Ji(null)}function mge(){ls(null),be(null),Zr(!1),Sv(null),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Nd()}async function gge(R){var V;try{(V=Gr.current.get(R))==null||V.abort(),ia(R,!1),await rP(n,Xe,R),await iP(n,Xe,R);const F=tr.current.get(R);F!==void 0&&window.clearTimeout(F),tr.current.delete(R),Mn(se=>{if(!se.has(R))return se;const Te=new Set(se);return Te.delete(R),Te}),_t(se=>{const{[R]:Te,...we}=se;return we}),je(se=>{const Te=bO(n,R);if(!(Te in se))return se;const{[Te]:we,...xe}=se;return xe}),R===a&&Nd(),await jb(n)}catch(F){Ke(String(F))}}async function Rb(R){if(g&&uc(),R!==a&&(ji.current=R,Ke(""),f(!1),p([]),et("agent"),Ut(null),Pn(xl()),Ci(null),er([]),o(R),vt[R]===void 0)){mv(!0);try{const V=await gk(n,Xe,R);dn(R,QEe(V.events??[],V.state)),je(F=>({...F,[bO(n,R)]:h9(V.events??[])}))}catch(V){Ke(String(V))}finally{mv(!1)}}}async function bge(R){if(!R.sessionId||!R.messageId){Ke("这条案例缺少会话定位信息,无法跳转。");return}Jr(!1),be(null),_r(!1),ui(!1),Zr(!1),ii(!1),xN(n),Cme(R.kind),Av(R.messageId),await Rb(R.sessionId)}function Oge(){const R=IQ||n;Jr(!1),be(null),_r(!1),ui(!1),Zr(!1),oa(""),la(R),_v("evaluations"),Ime(Nme),ii(!0),xN(""),Av("")}function yge(R){const V=new Map,F=new Map;for(const se of R){if(!se.sessionId||!se.messageId)continue;const Te=V.get(se.sessionId)??new Set;if(Te.add(se.messageId),V.set(se.sessionId,Te),se.runtimeId&&se.userId){const we=[se.runtimeId,n,se.userId,se.sessionId].join(":"),xe=F.get(we)??{runtimeId:se.runtimeId,appName:n,userId:se.userId,sessionId:se.sessionId,eventIds:new Set};xe.eventIds.add(se.messageId),F.set(we,xe)}}if(V.size!==0){_t(se=>{const Te={...se};for(const[we,xe]of V){const Fe=Te[we];Fe&&(Te[we]=Fe.map(it=>{var It;return(It=it.meta)!=null&&It.eventId&&xe.has(it.meta.eventId)?{...it,meta:{...it.meta,feedback:void 0}}:it}))}return Te}),s(se=>se.map(Te=>{const we=V.get(Te.id);if(!we||!Te.state)return Te;const xe={...Te.state};for(const Fe of we)delete xe[`veadk_feedback:${Fe}`];return{...Te,state:xe}})),Wn(se=>{const Te=new Set(se);for(const we of V.values())for(const xe of we)Te.delete(xe);return Te});for(const se of F.values())xJ({runtimeId:se.runtimeId,appName:se.appName,userId:se.userId,sessionId:se.sessionId,eventIds:[...se.eventIds]});Mme(se=>se&&(R.some(Te=>Te.id===se.id||Te.messageId===se.messageId)?null:se))}}async function WQ(R=!0){if(a)return a;c.current||(c.current=PJ(n,Xe));const V=c.current;try{const F=await V;R&&o(F);const se=Date.now()/1e3,Te={id:F,lastUpdateTime:se,events:[]};return s(we=>[Te,...we.filter(xe=>xe.id!==F)]),F}finally{c.current===V&&(c.current=null)}}async function xge(R){if(!n||!Xe||!a||!en)return!1;mr(!0),Ke("");try{const V=await oP(n,Xe,a,R,en.revision);return Ci(V),!0}catch(V){return Ke(String(V)),!1}finally{mr(!1)}}async function vge(R){if(!(!n||!Xe||!a||!en)){mr(!0),Ke("");try{const V=await HJ(n,Xe,a,R,en.revision);Ci(V)}catch(V){Ke(String(V))}finally{mr(!1)}}}async function wge(R){Ke("");let V;try{V=await WQ()}catch(se){Ke(String(se));return}const F=Array.from(R).map(se=>({file:se,attachment:{id:yY(),mimeType:xY(se),name:se.name,sizeBytes:se.size,status:"uploading"}}));In(se=>[...se,...F.map(Te=>Te.attachment)]),await Promise.all(F.map(async({file:se,attachment:Te})=>{try{const we=await FJ(n,Xe,V,se);if(gr.current.delete(Te.id)){we.uri&&await zS(n,we.uri);return}In(xe=>xe.map(Fe=>Fe.id===Te.id?we:Fe))}catch(we){if(gr.current.delete(Te.id))return;const xe=we instanceof Error?we.message:String(we);In(Fe=>Fe.map(it=>it.id===Te.id?{...it,status:"error",error:xe}:it)),Ke(xe)}}))}async function ZQ(R,V=[],F=xl(),se="composer"){if(!R.trim()&&V.length===0||ah||cN||!n||!Xe)return;Ke("");const Te=!a,we=Te?"new":"existing",xe=!!Us,Fe=Us?eH({agentId:String(n),agentKind:"runtime",messageSource:se,sessionState:we,...a?{sessionId:String(a)}:{}}):null,it=[];(F.skills.length>0||F.targetAgent)&&it.push({kind:"invocation",value:F}),V.length&&it.push({kind:"attachment",files:V.map(Nt=>({id:Nt.id,mimeType:Nt.mimeType,data:Nt.data,uri:Nt.uri,name:Nt.name,sizeBytes:Nt.sizeBytes}))}),R.trim()&&it.push({kind:"text",text:R});const It=[{role:"user",blocks:it,meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}];Te&&(p(It),f(!0));const bt=At;let ct;try{ct=await WQ(!Te)}catch(Nt){Te&&(p([]),f(!1),Ft(R),Pn(F)),xe&&(Fe==null||Fe.fail({failedPhase:"create_session",...Ra(Nt)})),Ke(String(Nt));return}let Qn=U2(en);if(bt)try{let Nt=await aP(n,Xe,ct);const $r=rft[bt].filter(Lt=>{var qn;return(qn=Le.builtinTools)==null?void 0:qn.includes(Lt)});for(const Lt of[...ope[bt],...$r])Nt.tools.some(qn=>qn.name===Lt)||(Nt=await oP(n,Xe,ct,{kind:"tool",name:Lt},Nt.revision));Ci(Nt),Qn=U2(Nt)}catch(Nt){Te&&(p([]),f(!1),Ft(R),Pn(F)),xe&&(Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"mount_task_capabilities",...Ra(Nt)})),Ke(`任务能力挂载失败:${String(Nt)}`);return}dn(ct,Nt=>Te?It:[...Nt,...It]),Te&&(ji.current=ct,o(ct),p([]),f(!1));const Fn=new AbortController;Gr.current.set(ct,Fn),os(ct,!0),na(ct),ji.current=ct,Wp(Nt=>({...Nt,[ct]:""})),wb(Nt=>({...Nt,[ct]:new Set})),iu(Nt=>({...Nt,[ct]:[]}));try{let Nt=Pu(),$r="",Lt=0,qn=Date.now()/1e3,tn="",qt="",On=!1,di=null;for await(const Vn of lP({appName:n,userId:Xe,sessionId:ct,text:R,attachments:V,invocation:F,signal:Fn.signal,sessionCapabilities:Qn})){if(Fn.signal.aborted)break;const zs=Vn.error??Vn.errorMessage??Vn.error_message;if(typeof zs=="string"&&zs){On=!0,di=zs,ji.current===ct&&Ke(zs);break}Y(ct,Vn);const ou=Vn.author&&Vn.author!=="user"?Vn.author:"";ou&&ou!==$r&&($r=ou,Nt=Pu()),Nt=yk(Nt,Vn);const ir=Vn.usageMetadata??Vn.usage_metadata;Qt(n,ct,Vn),ir!=null&&ir.totalTokenCount&&(Lt=ir.totalTokenCount),Vn.timestamp&&(qn=Vn.timestamp),Vn.id&&(tn=Vn.id);const es=Vn.invocationId??Vn.invocation_id;es&&(qt=es);const Di=Nt.blocks,Wa={author:$r||void 0,tokens:Lt||void 0,ts:qn,eventId:tn||void 0,invocationId:qt||void 0};dn(ct,Pv=>{var Lb;const lu=Pv.slice(),cu=lu[lu.length-1];return(cu==null?void 0:cu.role)==="assistant"&&(!((Lb=cu.meta)!=null&&Lb.author)||cu.meta.author===$r)?lu[lu.length-1]={...cu,blocks:Di,meta:Wa}:lu.push({role:"assistant",blocks:Di,meta:Wa}),lu})}jb(n),xe&&Fn.signal.aborted?Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",errorKind:"abort"}):xe&&(On?Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",...Ra(di??"run_sse failed")}):Fe==null||Fe.succeed({sessionId:String(ct)})),!Fn.signal.aborted&&!On&&tn&&Dr.current()}catch(Nt){xe&&(Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",...Ra(Nt)})),(Nt==null?void 0:Nt.name)!=="AbortError"&&!Fn.signal.aborted&&ji.current===ct&&Ke(String(Nt))}finally{Gr.current.get(ct)===Fn&&Gr.current.delete(ct),os(ct,!1),br(ct),Wp(Nt=>({...Nt,[ct]:""})),iu(Nt=>({...Nt,[ct]:[]}))}}function Sge(){var R;a&&((R=Gr.current.get(a))==null||R.abort())}function Ege(R,V){var Te,we;const F=((Te=R==null?void 0:R.event)==null?void 0:Te.name)??V.id,se=((we=R==null?void 0:R.event)==null?void 0:we.context)??{};ZQ(`[ui-action] ${F}: ${JSON.stringify(se)}`,[],xl(),"a2ui_action")}async function kge(R){var it,It,bt;if(!R.authUri)throw new Error("事件中没有授权地址。");if(!n||!Xe||!a)throw new Error("会话尚未就绪。");const V=a,F=await aOt(R.authUri),se=oOt(R.authConfig,F),Te=ct=>ct.map(Qn=>Qn.kind==="auth"&&!Qn.done?{...Qn,done:!0}:Qn);dn(V,ct=>{const Qn=ct.slice(),Fn=Qn[Qn.length-1];return(Fn==null?void 0:Fn.role)==="assistant"&&(Qn[Qn.length-1]={...Fn,blocks:Te(Fn.blocks)}),Qn});const we=Ie[Ie.length-1],xe=Te(we&&we.role==="assistant"?we.blocks:[]),Fe=new AbortController;Gr.current.set(V,Fe),os(V,!0),na(V);try{let ct=Pu(),Qn=((it=we==null?void 0:we.meta)==null?void 0:it.author)??"",Fn=xe,Nt=0,$r=Date.now()/1e3,Lt=((It=we==null?void 0:we.meta)==null?void 0:It.eventId)??"",qn=((bt=we==null?void 0:we.meta)==null?void 0:bt.invocationId)??"",tn=!1;for await(const qt of lP({appName:n,userId:Xe,sessionId:a,text:"",functionResponses:[{id:R.callId,name:"adk_request_credential",response:se}],signal:Fe.signal,sessionCapabilities:U2(en)})){if(Fe.signal.aborted)break;const On=qt.error??qt.errorMessage??qt.error_message;if(typeof On=="string"&&On){tn=!0,ji.current===V&&Ke(On);break}Y(V,qt);const di=qt.author&&qt.author!=="user"?qt.author:"";di&&di!==Qn&&(Qn=di,Fn=[],ct=Pu()),ct=yk(ct,qt);const Vn=qt.usageMetadata??qt.usage_metadata;Qt(n,V,qt),Vn!=null&&Vn.totalTokenCount&&(Nt=Vn.totalTokenCount),qt.timestamp&&($r=qt.timestamp),qt.id&&(Lt=qt.id);const zs=qt.invocationId??qt.invocation_id;zs&&(qn=zs);const ou=[...Fn,...ct.blocks];dn(V,ir=>{var Pv,lu,cu,Lb,s6;const es=ir.slice(),Di=es[es.length-1],Wa={author:Qn||((Pv=Di==null?void 0:Di.meta)==null?void 0:Pv.author),tokens:Nt||((lu=Di==null?void 0:Di.meta)==null?void 0:lu.tokens),ts:$r,eventId:Lt||((cu=Di==null?void 0:Di.meta)==null?void 0:cu.eventId),invocationId:qn||((Lb=Di==null?void 0:Di.meta)==null?void 0:Lb.invocationId)};return(Di==null?void 0:Di.role)==="assistant"&&(!((s6=Di.meta)!=null&&s6.author)||Di.meta.author===Qn)?es[es.length-1]={...Di,blocks:ou,meta:Wa}:es.push({role:"assistant",blocks:ou,meta:Wa}),es})}jb(n),!Fe.signal.aborted&&!tn&&Lt&&Dr.current()}catch(ct){(ct==null?void 0:ct.name)!=="AbortError"&&!Fe.signal.aborted&&ji.current===V&&Ke(String(ct))}finally{Gr.current.get(V)===Fe&&Gr.current.delete(V),os(V,!1),br(V),Wp(ct=>({...ct,[V]:""})),iu(ct=>({...ct,[V]:[]}))}}if(sa)return l.jsxs("div",{className:"boot boot-error",children:[l.jsx("p",{children:sa}),l.jsx("button",{type:"button",onClick:RN,children:"重试"})]});if(He===null)return l.jsx("div",{className:"boot"});if(He==="unauthenticated")return l.jsx(Kgt,{branding:hl,cloudProvider:$n,onUsername:Zme});if(!mi)return l.jsx("div",{className:"boot"});const Io=mi.capabilities.createAgents,MN=mi.capabilities.manageAgents,Tge=yb.agentUsage&&MN,Ib=Io?he:null,KQ=Io&&bN,JQ=Io&&gN,e6=oh&&!!(Jn||QQ||BQ),t6=Mhe(e,gl),Pb=t6.filter(R=>R.runtimeId&&(LQ===null||LQ.has(R.runtimeId))).map(R=>{var V;return{...R,canDelete:R.runtimeId?((V=$me[R.runtimeId])==null?void 0:V.canDelete)===!0:!1}}),_ge=(()=>{if(Pb.length===0)return Pb;const R=new Map(RQ.map((V,F)=>[V,F]));return[...Pb].sort((V,F)=>{const se=R.get(V.id),Te=R.get(F.id);return se!=null&&Te!=null?se-Te:se!=null?-1:Te!=null?1:Pb.indexOf(V)-Pb.indexOf(F)})})(),LN=R=>{var V;return((V=t6.find(F=>F.id===R))==null?void 0:V.label)??R},An=gl.find(R=>R.runtimeId&&R.apps.some(V=>Ll(R.id,V)===n)),Us=An&&An.runtimeId&&An.region?{runtimeId:An.runtimeId,name:An.name,region:An.region}:void 0,Mb=(Us==null?void 0:Us.runtimeId)??"",au=An?An.apps.find(R=>Ll(An.id,R)===n)??(Vt==null?void 0:Vt.appName)??An.apps[0]??An.name:"",Age=async R=>{var we,xe,Fe;const V=Vi,F=a;if(!V||!F)throw new Error("当前会话不可用,请关闭后重试。");const se=((we=V.turn.meta)==null?void 0:we.invocationId)??"",Te=Mb?[]:await bk(n,F).catch(()=>[]);await sP({source:"agent_exec",module:"conversation",issues:R.issues,problem:"",description:R.description,page:"conversation",appName:au||n,runtimeId:Mb,region:(Us==null?void 0:Us.region)??"cn-beijing",sessionId:F,eventId:((xe=V.turn.meta)==null?void 0:xe.eventId)??((Fe=V.turn.meta)==null?void 0:Fe.localId)??"",invocationId:se,input:V.input,output:Ud(V.turn),toolCalls:p9(V.turn),trace:NEe(Te,se)})},Nge=async R=>{const V=g?"":a,F=g||V?Ie:[],se=V&&n&&!Mb?await bk(n,V).catch(()=>[]):[];await sP({source:"platform",module:R.module,issues:R.issues,problem:"",description:R.description,page:ws??"unknown",appName:au||n,runtimeId:Mb,region:(Us==null?void 0:Us.region)??"cn-beijing",sessionId:V,eventId:"",invocationId:"",input:F.filter(Te=>Te.role==="user").map(Ud).filter(Boolean).join(` +`):bt,Qn=crypto.randomUUID(),Fn=crypto.randomUUID(),Nt=[{role:"user",blocks:Fe,meta:{localId:Qn,ts:Date.now()/1e3}},{role:"assistant",blocks:[],meta:{localId:Fn}}];Je.current=Fn,O(Lt=>[...Lt,...Nt]),x(!0),b(Lt=>(Lt==null?void 0:Lt.id)===se.id?{...Lt,busy:!0,workspaceLocked:!0}:Lt);try{const Lt=await Kt.sendMessage({sessionId:se.id,text:ct,skillIds:F.map(qn=>qn.id)},{signal:xe.signal,onApproval:qn=>{xe.signal.aborted||ve.current!==xe||(re(""),X(qn))},onApprovalResolved:qn=>{xe.signal.aborted||ve.current!==xe||X(tn=>(tn==null?void 0:tn.id)===qn?null:tn)},onBlocks:qn=>{xe.signal.aborted||ve.current!==xe||O(tn=>{const qt=tn.slice(),On=qt.findIndex(Vn=>{var zs;return((zs=Vn.meta)==null?void 0:zs.localId)===Fn}),di=qt[On];return(di==null?void 0:di.role)==="assistant"&&(qt[On]={...di,blocks:qn}),qt})},onUsage:qn=>{xe.signal.aborted||ve.current!==xe||O(tn=>{const qt=tn.slice(),On=qt.findIndex(Vn=>{var zs;return((zs=Vn.meta)==null?void 0:zs.localId)===Fn}),di=qt[On];return(di==null?void 0:di.role)==="assistant"&&(qt[On]={...di,meta:{...di.meta,sandboxUsage:qn.usage}}),qt})}});if(xe.signal.aborted||ve.current!==xe){we.fail({sessionId:String(se.id),failedPhase:"sandbox_send",errorKind:"abort"});return}we.succeed({sessionId:String(se.id)}),O(qn=>{const tn=qn.slice(),qt=tn.findIndex(di=>{var Vn;return((Vn=di.meta)==null?void 0:Vn.localId)===Fn}),On=tn[qt];return(On==null?void 0:On.role)==="assistant"&&(tn[qt]={...On,blocks:Lt.blocks,meta:{...On.meta,ts:Date.now()/1e3,...Lt.usage?{sandboxUsage:Lt.usage.usage}:{}}}),tn}),vn.refreshThreads()}catch(Lt){if(we.fail({sessionId:String(se.id),failedPhase:"sandbox_send",...Ra(Lt)}),(Lt==null?void 0:Lt.name)==="AbortError"||ve.current!==xe)return;O(qn=>qn.filter(tn=>{var qt,On;return((qt=tn.meta)==null?void 0:qt.localId)!==Qn&&((On=tn.meta)==null?void 0:On.localId)!==Fn})),Ft(R),In(V),vn.setSelectedSkills(F),Ke(`内置智能体发送失败:${Lt instanceof Error?Lt.message:String(Lt)}`);try{const qn=await Kt.getSettings(se.id);b(tn=>(tn==null?void 0:tn.id)===se.id?{...tn,...qn}:tn)}catch{}}finally{ve.current===xe&&(ve.current=null,Je.current===Fn&&(Je.current=""),x(!1),X(null),b(Lt=>(Lt==null?void 0:Lt.id)===se.id?{...Lt,busy:!1}:Lt))}}async function pge(R){if(await vn.executeSlash(R)||!g||v||vn.commandBusy)return;const V=Sn,F=vn.selectedSkills;Ft(""),In([]),vn.setSelectedSkills([]),await GQ(R.trim(),V,F)}function Nd(){uc(),Ke(""),Ct(yY()),et("agent"),Ut(null),st(null);const R=a&&Ze.length===0&&Sn.length>0?a:"";ji.current="",o(""),Ci(null),er([]),f(!1),p([]),Pn(xl()),Zp(Sn),In([]),R&&kb(R)}function mge(){var R;Jp.current=!0,localStorage.removeItem(vl.app),a&&((R=Gr.current.get(a))==null||R.abort()),c.current=null,Nd(),i(""),ut({}),Ji(null)}function gge(){ls(null),be(null),Zr(!1),Sv(null),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Nd()}async function bge(R){var V;try{(V=Gr.current.get(R))==null||V.abort(),ia(R,!1),await rP(n,Xe,R),await iP(n,Xe,R);const F=tr.current.get(R);F!==void 0&&window.clearTimeout(F),tr.current.delete(R),Mn(se=>{if(!se.has(R))return se;const Te=new Set(se);return Te.delete(R),Te}),_t(se=>{const{[R]:Te,...we}=se;return we}),je(se=>{const Te=bO(n,R);if(!(Te in se))return se;const{[Te]:we,...xe}=se;return xe}),R===a&&Nd(),await jb(n)}catch(F){Ke(String(F))}}async function Rb(R){if(g&&uc(),R!==a&&(ji.current=R,Ke(""),f(!1),p([]),et("agent"),Ut(null),Pn(xl()),Ci(null),er([]),o(R),vt[R]===void 0)){mv(!0);try{const V=await gk(n,Xe,R);dn(R,BEe(V.events??[],V.state)),je(F=>({...F,[bO(n,R)]:h9(V.events??[])}))}catch(V){Ke(String(V))}finally{mv(!1)}}}async function Oge(R){if(!R.sessionId||!R.messageId){Ke("这条案例缺少会话定位信息,无法跳转。");return}Jr(!1),be(null),_r(!1),ui(!1),Zr(!1),ii(!1),xN(n),jme(R.kind),Av(R.messageId),await Rb(R.sessionId)}function yge(){const R=IQ||n;Jr(!1),be(null),_r(!1),ui(!1),Zr(!1),oa(""),la(R),_v("evaluations"),Pme(Cme),ii(!0),xN(""),Av("")}function xge(R){const V=new Map,F=new Map;for(const se of R){if(!se.sessionId||!se.messageId)continue;const Te=V.get(se.sessionId)??new Set;if(Te.add(se.messageId),V.set(se.sessionId,Te),se.runtimeId&&se.userId){const we=[se.runtimeId,n,se.userId,se.sessionId].join(":"),xe=F.get(we)??{runtimeId:se.runtimeId,appName:n,userId:se.userId,sessionId:se.sessionId,eventIds:new Set};xe.eventIds.add(se.messageId),F.set(we,xe)}}if(V.size!==0){_t(se=>{const Te={...se};for(const[we,xe]of V){const Fe=Te[we];Fe&&(Te[we]=Fe.map(it=>{var It;return(It=it.meta)!=null&&It.eventId&&xe.has(it.meta.eventId)?{...it,meta:{...it.meta,feedback:void 0}}:it}))}return Te}),s(se=>se.map(Te=>{const we=V.get(Te.id);if(!we||!Te.state)return Te;const xe={...Te.state};for(const Fe of we)delete xe[`veadk_feedback:${Fe}`];return{...Te,state:xe}})),Wn(se=>{const Te=new Set(se);for(const we of V.values())for(const xe of we)Te.delete(xe);return Te});for(const se of F.values())vJ({runtimeId:se.runtimeId,appName:se.appName,userId:se.userId,sessionId:se.sessionId,eventIds:[...se.eventIds]});Lme(se=>se&&(R.some(Te=>Te.id===se.id||Te.messageId===se.messageId)?null:se))}}async function WQ(R=!0){if(a)return a;c.current||(c.current=MJ(n,Xe));const V=c.current;try{const F=await V;R&&o(F);const se=Date.now()/1e3,Te={id:F,lastUpdateTime:se,events:[]};return s(we=>[Te,...we.filter(xe=>xe.id!==F)]),F}finally{c.current===V&&(c.current=null)}}async function vge(R){if(!n||!Xe||!a||!en)return!1;mr(!0),Ke("");try{const V=await oP(n,Xe,a,R,en.revision);return Ci(V),!0}catch(V){return Ke(String(V)),!1}finally{mr(!1)}}async function wge(R){if(!(!n||!Xe||!a||!en)){mr(!0),Ke("");try{const V=await YJ(n,Xe,a,R,en.revision);Ci(V)}catch(V){Ke(String(V))}finally{mr(!1)}}}async function Sge(R){Ke("");let V;try{V=await WQ()}catch(se){Ke(String(se));return}const F=Array.from(R).map(se=>({file:se,attachment:{id:xY(),mimeType:vY(se),name:se.name,sizeBytes:se.size,status:"uploading"}}));In(se=>[...se,...F.map(Te=>Te.attachment)]),await Promise.all(F.map(async({file:se,attachment:Te})=>{try{const we=await VJ(n,Xe,V,se);if(gr.current.delete(Te.id)){we.uri&&await zS(n,we.uri);return}In(xe=>xe.map(Fe=>Fe.id===Te.id?we:Fe))}catch(we){if(gr.current.delete(Te.id))return;const xe=we instanceof Error?we.message:String(we);In(Fe=>Fe.map(it=>it.id===Te.id?{...it,status:"error",error:xe}:it)),Ke(xe)}}))}async function ZQ(R,V=[],F=xl(),se="composer"){if(!R.trim()&&V.length===0||ah||cN||!n||!Xe)return;Ke("");const Te=!a,we=Te?"new":"existing",xe=!!Us,Fe=Us?tH({agentId:String(n),agentKind:"runtime",messageSource:se,sessionState:we,...a?{sessionId:String(a)}:{}}):null,it=[];(F.skills.length>0||F.targetAgent)&&it.push({kind:"invocation",value:F}),V.length&&it.push({kind:"attachment",files:V.map(Nt=>({id:Nt.id,mimeType:Nt.mimeType,data:Nt.data,uri:Nt.uri,name:Nt.name,sizeBytes:Nt.sizeBytes}))}),R.trim()&&it.push({kind:"text",text:R});const It=[{role:"user",blocks:it,meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}];Te&&(p(It),f(!0));const bt=At;let ct;try{ct=await WQ(!Te)}catch(Nt){Te&&(p([]),f(!1),Ft(R),Pn(F)),xe&&(Fe==null||Fe.fail({failedPhase:"create_session",...Ra(Nt)})),Ke(String(Nt));return}let Qn=U2(en);if(bt)try{let Nt=await aP(n,Xe,ct);const $r=sft[bt].filter(Lt=>{var qn;return(qn=Le.builtinTools)==null?void 0:qn.includes(Lt)});for(const Lt of[...lpe[bt],...$r])Nt.tools.some(qn=>qn.name===Lt)||(Nt=await oP(n,Xe,ct,{kind:"tool",name:Lt},Nt.revision));Ci(Nt),Qn=U2(Nt)}catch(Nt){Te&&(p([]),f(!1),Ft(R),Pn(F)),xe&&(Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"mount_task_capabilities",...Ra(Nt)})),Ke(`任务能力挂载失败:${String(Nt)}`);return}dn(ct,Nt=>Te?It:[...Nt,...It]),Te&&(ji.current=ct,o(ct),p([]),f(!1));const Fn=new AbortController;Gr.current.set(ct,Fn),os(ct,!0),na(ct),ji.current=ct,Wp(Nt=>({...Nt,[ct]:""})),wb(Nt=>({...Nt,[ct]:new Set})),iu(Nt=>({...Nt,[ct]:[]}));try{let Nt=Pu(),$r="",Lt=0,qn=Date.now()/1e3,tn="",qt="",On=!1,di=null;for await(const Vn of lP({appName:n,userId:Xe,sessionId:ct,text:R,attachments:V,invocation:F,signal:Fn.signal,sessionCapabilities:Qn})){if(Fn.signal.aborted)break;const zs=Vn.error??Vn.errorMessage??Vn.error_message;if(typeof zs=="string"&&zs){On=!0,di=zs,ji.current===ct&&Ke(zs);break}Y(ct,Vn);const ou=Vn.author&&Vn.author!=="user"?Vn.author:"";ou&&ou!==$r&&($r=ou,Nt=Pu()),Nt=yk(Nt,Vn);const ir=Vn.usageMetadata??Vn.usage_metadata;Qt(n,ct,Vn),ir!=null&&ir.totalTokenCount&&(Lt=ir.totalTokenCount),Vn.timestamp&&(qn=Vn.timestamp),Vn.id&&(tn=Vn.id);const es=Vn.invocationId??Vn.invocation_id;es&&(qt=es);const Di=Nt.blocks,Wa={author:$r||void 0,tokens:Lt||void 0,ts:qn,eventId:tn||void 0,invocationId:qt||void 0};dn(ct,Pv=>{var Lb;const lu=Pv.slice(),cu=lu[lu.length-1];return(cu==null?void 0:cu.role)==="assistant"&&(!((Lb=cu.meta)!=null&&Lb.author)||cu.meta.author===$r)?lu[lu.length-1]={...cu,blocks:Di,meta:Wa}:lu.push({role:"assistant",blocks:Di,meta:Wa}),lu})}jb(n),xe&&Fn.signal.aborted?Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",errorKind:"abort"}):xe&&(On?Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",...Ra(di??"run_sse failed")}):Fe==null||Fe.succeed({sessionId:String(ct)})),!Fn.signal.aborted&&!On&&tn&&Dr.current()}catch(Nt){xe&&(Fe==null||Fe.fail({sessionId:String(ct),failedPhase:"run_sse",...Ra(Nt)})),(Nt==null?void 0:Nt.name)!=="AbortError"&&!Fn.signal.aborted&&ji.current===ct&&Ke(String(Nt))}finally{Gr.current.get(ct)===Fn&&Gr.current.delete(ct),os(ct,!1),br(ct),Wp(Nt=>({...Nt,[ct]:""})),iu(Nt=>({...Nt,[ct]:[]}))}}function Ege(){var R;a&&((R=Gr.current.get(a))==null||R.abort())}function kge(R,V){var Te,we;const F=((Te=R==null?void 0:R.event)==null?void 0:Te.name)??V.id,se=((we=R==null?void 0:R.event)==null?void 0:we.context)??{};ZQ(`[ui-action] ${F}: ${JSON.stringify(se)}`,[],xl(),"a2ui_action")}async function Tge(R){var it,It,bt;if(!R.authUri)throw new Error("事件中没有授权地址。");if(!n||!Xe||!a)throw new Error("会话尚未就绪。");const V=a,F=await oOt(R.authUri),se=lOt(R.authConfig,F),Te=ct=>ct.map(Qn=>Qn.kind==="auth"&&!Qn.done?{...Qn,done:!0}:Qn);dn(V,ct=>{const Qn=ct.slice(),Fn=Qn[Qn.length-1];return(Fn==null?void 0:Fn.role)==="assistant"&&(Qn[Qn.length-1]={...Fn,blocks:Te(Fn.blocks)}),Qn});const we=Ie[Ie.length-1],xe=Te(we&&we.role==="assistant"?we.blocks:[]),Fe=new AbortController;Gr.current.set(V,Fe),os(V,!0),na(V);try{let ct=Pu(),Qn=((it=we==null?void 0:we.meta)==null?void 0:it.author)??"",Fn=xe,Nt=0,$r=Date.now()/1e3,Lt=((It=we==null?void 0:we.meta)==null?void 0:It.eventId)??"",qn=((bt=we==null?void 0:we.meta)==null?void 0:bt.invocationId)??"",tn=!1;for await(const qt of lP({appName:n,userId:Xe,sessionId:a,text:"",functionResponses:[{id:R.callId,name:"adk_request_credential",response:se}],signal:Fe.signal,sessionCapabilities:U2(en)})){if(Fe.signal.aborted)break;const On=qt.error??qt.errorMessage??qt.error_message;if(typeof On=="string"&&On){tn=!0,ji.current===V&&Ke(On);break}Y(V,qt);const di=qt.author&&qt.author!=="user"?qt.author:"";di&&di!==Qn&&(Qn=di,Fn=[],ct=Pu()),ct=yk(ct,qt);const Vn=qt.usageMetadata??qt.usage_metadata;Qt(n,V,qt),Vn!=null&&Vn.totalTokenCount&&(Nt=Vn.totalTokenCount),qt.timestamp&&($r=qt.timestamp),qt.id&&(Lt=qt.id);const zs=qt.invocationId??qt.invocation_id;zs&&(qn=zs);const ou=[...Fn,...ct.blocks];dn(V,ir=>{var Pv,lu,cu,Lb,s6;const es=ir.slice(),Di=es[es.length-1],Wa={author:Qn||((Pv=Di==null?void 0:Di.meta)==null?void 0:Pv.author),tokens:Nt||((lu=Di==null?void 0:Di.meta)==null?void 0:lu.tokens),ts:$r,eventId:Lt||((cu=Di==null?void 0:Di.meta)==null?void 0:cu.eventId),invocationId:qn||((Lb=Di==null?void 0:Di.meta)==null?void 0:Lb.invocationId)};return(Di==null?void 0:Di.role)==="assistant"&&(!((s6=Di.meta)!=null&&s6.author)||Di.meta.author===Qn)?es[es.length-1]={...Di,blocks:ou,meta:Wa}:es.push({role:"assistant",blocks:ou,meta:Wa}),es})}jb(n),!Fe.signal.aborted&&!tn&&Lt&&Dr.current()}catch(ct){(ct==null?void 0:ct.name)!=="AbortError"&&!Fe.signal.aborted&&ji.current===V&&Ke(String(ct))}finally{Gr.current.get(V)===Fe&&Gr.current.delete(V),os(V,!1),br(V),Wp(ct=>({...ct,[V]:""})),iu(ct=>({...ct,[V]:[]}))}}if(sa)return l.jsxs("div",{className:"boot boot-error",children:[l.jsx("p",{children:sa}),l.jsx("button",{type:"button",onClick:RN,children:"重试"})]});if(He===null)return l.jsx("div",{className:"boot"});if(He==="unauthenticated")return l.jsx(Jgt,{branding:hl,cloudProvider:$n,onUsername:Kme});if(!mi)return l.jsx("div",{className:"boot"});const Io=mi.capabilities.createAgents,MN=mi.capabilities.manageAgents,_ge=yb.agentUsage&&MN,Ib=Io?he:null,KQ=Io&&bN,JQ=Io&&gN,e6=oh&&!!(Jn||QQ||BQ),t6=Lhe(e,gl),Pb=t6.filter(R=>R.runtimeId&&(LQ===null||LQ.has(R.runtimeId))).map(R=>{var V;return{...R,canDelete:R.runtimeId?((V=Qme[R.runtimeId])==null?void 0:V.canDelete)===!0:!1}}),Age=(()=>{if(Pb.length===0)return Pb;const R=new Map(RQ.map((V,F)=>[V,F]));return[...Pb].sort((V,F)=>{const se=R.get(V.id),Te=R.get(F.id);return se!=null&&Te!=null?se-Te:se!=null?-1:Te!=null?1:Pb.indexOf(V)-Pb.indexOf(F)})})(),LN=R=>{var V;return((V=t6.find(F=>F.id===R))==null?void 0:V.label)??R},An=gl.find(R=>R.runtimeId&&R.apps.some(V=>Ll(R.id,V)===n)),Us=An&&An.runtimeId&&An.region?{runtimeId:An.runtimeId,name:An.name,region:An.region}:void 0,Mb=(Us==null?void 0:Us.runtimeId)??"",au=An?An.apps.find(R=>Ll(An.id,R)===n)??(Vt==null?void 0:Vt.appName)??An.apps[0]??An.name:"",Nge=async R=>{var we,xe,Fe;const V=Vi,F=a;if(!V||!F)throw new Error("当前会话不可用,请关闭后重试。");const se=((we=V.turn.meta)==null?void 0:we.invocationId)??"",Te=Mb?[]:await bk(n,F).catch(()=>[]);await sP({source:"agent_exec",module:"conversation",issues:R.issues,problem:"",description:R.description,page:"conversation",appName:au||n,runtimeId:Mb,region:(Us==null?void 0:Us.region)??"cn-beijing",sessionId:F,eventId:((xe=V.turn.meta)==null?void 0:xe.eventId)??((Fe=V.turn.meta)==null?void 0:Fe.localId)??"",invocationId:se,input:V.input,output:Ud(V.turn),toolCalls:p9(V.turn),trace:CEe(Te,se)})},Cge=async R=>{const V=g?"":a,F=g||V?Ie:[],se=V&&n&&!Mb?await bk(n,V).catch(()=>[]):[];await sP({source:"platform",module:R.module,issues:R.issues,problem:"",description:R.description,page:ws??"unknown",appName:au||n,runtimeId:Mb,region:(Us==null?void 0:Us.region)??"cn-beijing",sessionId:V,eventId:"",invocationId:"",input:F.filter(Te=>Te.role==="user").map(Ud).filter(Boolean).join(` `),output:F.filter(Te=>Te.role==="assistant").map(Ud).filter(Boolean).join(` -`),toolCalls:F.flatMap(p9),trace:se})},DN=async(R,V,F="",se="",Te=!0)=>{var bt,ct,Qn,Fn,Nt,$r,Lt,qn;const we=(bt=R.meta)==null?void 0:bt.eventId,xe=a;if(!we||!xe||!Us)return"当前回复暂不支持加入评测集";if($n==="byteplus")return"BytePlus 暂不支持 AgentKit 评测集";const Fe=Ud(R),it=(ct=R.meta)==null?void 0:ct.feedback,It={...it,rating:V,comment:se,syncStatus:"syncing",updatedAt:Date.now()/1e3};dn(xe,tn=>tn.map(qt=>{var On;return((On=qt.meta)==null?void 0:On.eventId)===we?{...qt,meta:{...qt.meta,feedback:It}}:qt})),Wn(tn=>new Set(tn).add(we)),An!=null&&An.runtimeId&&au&&US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Qn=R.meta)==null?void 0:Qn.invocationId,rating:V,input:F,output:Fe,comment:se,createdAt:(Fn=R.meta)!=null&&Fn.ts?new Date(R.meta.ts*1e3).toISOString():void 0});try{const tn=await MJ({appName:n,userId:Xe,sessionId:xe,eventId:we,rating:V,comment:se});dn(xe,qt=>qt.map(On=>{var di;return((di=On.meta)==null?void 0:di.eventId)===we?{...On,meta:{...On.meta,feedback:tn}}:On})),s(qt=>qt.map(On=>On.id===xe?{...On,state:{...On.state??{},[`veadk_feedback:${we}`]:tn}}:On)),An!=null&&An.runtimeId&&au&&(US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Nt=R.meta)==null?void 0:Nt.invocationId,rating:tn.rating,input:F,output:Fe,comment:se,createdAt:($r=R.meta)!=null&&$r.ts?new Date(R.meta.ts*1e3).toISOString():void 0}),QJ({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,pageSize:100}))}catch(tn){const qt=tn instanceof Error?tn.message:String(tn);return dn(xe,On=>On.map(di=>{var Vn;return((Vn=di.meta)==null?void 0:Vn.eventId)===we?{...di,meta:{...di.meta,feedback:it}}:di})),An!=null&&An.runtimeId&&au&&US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Lt=R.meta)==null?void 0:Lt.invocationId,rating:(it==null?void 0:it.rating)??null,input:F,output:Fe,comment:(it==null?void 0:it.comment)??"",createdAt:(qn=R.meta)!=null&&qn.ts?new Date(R.meta.ts*1e3).toISOString():void 0}),Te&&ji.current===xe&&Ke(qt),qt}finally{Wn(tn=>{const qt=new Set(tn);return qt.delete(we),qt})}return null},Cge=async R=>{const V=Qs;if(!V)return;const F=await DN(V.turn,"bad",V.input,kbt(V.selectedText,R),!1);if(F)throw new Error(F)},Iv=async R=>{Ab(Al());let V=gt.current.get(R);V||(V=await PR(R),gt.current.set(R,V)),ut(V),pi(F=>F+1),i(R),Bs(null),oa(""),la(""),Hi(!1),ii(!1),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),Nd()},jge=async R=>{await Iv(R)},Rge=R=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}Hi(!1),ii(!1),Cv(R),aa(null),be(null),ui(!0),Ke("")},Ige=async(R,V)=>{if(!R.runtime)throw new Error("缺少 Runtime 信息,无法连接智能体。");const F=rR({targetId:String(R.runtime.runtimeId),agentKind:"runtime",connectSource:V});try{const se=await SE(R.runtime.runtimeId,R.name,R.runtime.region,R.runtime.currentVersion);return F.succeed({runtimeRegion:R.runtime.region,runtimeIsMine:R.isMine?1:0}),se}catch(se){throw F.fail(Ra(se)),se}},n6=async(R,V={})=>{if(R.runtime)try{const F=await Ige(R,V.source??"my_agents");await Iv(F)}catch(F){const se=F instanceof Error?F.message:String(F);if(Ke(se),V.rethrow)throw new Error(se)}},Pge=R=>{R.runtime&&(Bs(R),oa(""),la(""),Hi(!1),ii(!0),Ke(""))},Mge=R=>{if(!Io){Ke("当前账号没有创建智能体的权限。");return}IN(R,!0)},$N=()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),oa(""),la(""),Hi(!0),rc(!1),Ga(null),Ke("")},Lge=()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga("catalog"),Ke("")},Dge=async R=>{if(xN(""),Av(""),R.runtimeId&&R.id.startsWith("detail:")){const V=rR({targetId:String(R.runtimeId),agentKind:"runtime",connectSource:"agent_workspace"});try{const F=await SE(R.runtimeId,R.label,R.region??Qi($n),R.currentVersion);V.succeed({runtimeRegion:R.region}),await Iv(F)}catch(F){V.fail(Ra(F)),Ke(F instanceof Error?F.message:String(F))}return}await Iv(R.id)},QN=Jn!=null&&Jn.runtime?gl.find(R=>{var V;return R.runtimeId===((V=Jn.runtime)==null?void 0:V.runtimeId)}):void 0,Cd=Jn!=null&&Jn.runtime?{id:`detail:${Jn.runtime.runtimeId}`,label:Jn.name,app:Jn.appName??Jn.name,remote:!0,runtimeApp:QN==null?void 0:QN.apps[0],runtimeId:Jn.runtime.runtimeId,region:Jn.runtime.region,currentVersion:Jn.runtime.currentVersion,canDelete:Jn.runtime.canDelete}:null,i6=ws!==null?"feedback":Tb?"library":vN?null:sc?"applications":Tv?"search":su||oh||Rt||W?"agents":a||he||Tb||gN||bN?null:"new-chat";return l.jsxs("div",{className:"layout",children:[l.jsx(ske,{branding:hl,cloudProvider:$n,access:mi,features:yb,sessions:r,currentSessionId:a,activePage:i6,streamingSids:ul,evaluatingSids:vs,sandboxHistory:g?{threads:vn.threads,currentThreadId:g.threadId,loading:vn.threadsLoading,error:vn.threadsError,hasMore:vn.threadsHasMore,busyThreadId:vn.threadActionId,newDisabled:v||vn.commandBusy,onNew:()=>void vn.newThread(),onSelect:R=>void vn.resumeThread(R),onLoadMore:()=>void vn.loadMoreThreads(),onDelete:pe}:void 0,onNewChat:mge,onSearch:()=>{ls(null),g&&uc(),be(null),Zr(!1),_r(!1),ui(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Jr(!0),Ke("")},onQuickCreate:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}g&&uc(),ji.current="",o(""),Zr(!1),_r(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),be(null),aa(null),Cv(Qi($n)),ui(!0),Ke("")},onLibrary:()=>{g&&uc(),be(null),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Sv(null),pN("skills"),mN("技能库"),Zr(!0),Ke("")},onAddAgent:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}g&&uc(),ji.current="",be(null),Zr(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),o(""),ui(!1),_r(!0),Ke("")},onMyAgents:$N,onApplications:Lge,onSystemInfo:()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),Ga(null),rc(!0),Ke("")},onIssueFeedback:()=>{ws===null&&(rc(!1),ls(i6??(g?"sandbox":a?"conversation":"workspace")),Ke(""))},onPickSession:R=>{ls(null),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Ke(""),Rb(R)},onDeleteSession:gge,userInfo:dl,onLogout:Kme}),(()=>{var V;const R=l.jsxs("div",{className:`composer-slot${g?" sandbox-composer-wrap":""}`,children:[g&&l.jsx(Jmt,{agentName:g.toolName==="codex"?"Codex":g.toolName==="deepseek-harness"?"DeepSeek Harness":g.toolName==="openclaw"?"OpenClaw":"Hermes",onExit:Nd}),g?l.jsx(Mgt,{appName:n,value:Jt,onChange:Ft,onSubmit:F=>void hge(F),onStop:v?fge:void 0,disabled:!1,busy:v||vn.commandBusy,attachments:Sn,onAddFiles:uge,onRemoveAttachment:dge,actions:{onOpenTerminal:()=>void PN("terminal"),onOpenBrowser:()=>void PN("browser"),onOpenPermissions:()=>{k(""),A(!0)},onOpenWorkspace:()=>{k(""),C(!0)},onCopyEndpoint:sge,endpointCopyEnabled:Le.sandboxEndpointExportEnabled===!0,endpointCopyState:J,workspaceLocked:g.workspaceLocked,settingsBusy:w,uploadBusy:fe||v},models:vn.models,modelsLoading:vn.modelsLoading,modelsLoaded:vn.modelsLoaded,currentModel:g.model,onRequestModels:()=>void vn.loadModels(),skills:vn.skills,skillsLoading:vn.skillsLoading,skillsLoaded:vn.skillsLoaded,selectedSkills:vn.selectedSkills,onRequestSkills:()=>void vn.loadSkills(),onSelectedSkillsChange:vn.setSelectedSkills}):l.jsx(dft,{cloudProvider:$n,sessionId:a,sessionInitializing:d,appName:n,agentName:n?LN(n):"Agent",value:Jt,onChange:Ft,videoTask:kn,onOpenVideoTask:()=>{xn.current&&Gn(!0)},onVideoSubmit:nu,onSubmit:()=>{var we;const F=Jt;if(!g&&Ie.length===0&&wt==="skill"){if(!F.trim())return;let xe;if(on==="create")xe={operation:"create",initialIntent:F.trim(),selectPublishSpace:!0};else{const Fe=Pe;if(!Fe){Ke("请先选择需要优化的 Skill。");return}xe={operation:"optimize",initialIntent:F.trim(),space:Fe.space,source:{kind:"skill-center",skillId:Fe.skill.skillId,version:Fe.skill.version,region:Fe.space.region||Qi($n),projectName:Fe.space.projectName,skillSpaceId:Fe.space.id,skillSpaceName:Fe.space.name,name:Fe.skill.skillName||Fe.skill.skillId,description:Fe.skill.skillDescription}}}Ft(""),Ke(""),Sv(xe),pN("skills"),mN(xe.operation==="create"?"创建技能":`优化 ${((we=xe.source)==null?void 0:we.name)||"技能"}`),Zr(!0);return}if(Ft(""),g){GQ(F);return}const se=Sn,Te=Ni;In([]),Pn(xl()),ZQ(F,se,Te),$R(se)},onStop:bv?Sge:void 0,disabled:g?!1:!Xe||Ce==="temporary"||Ce==="deepseek-harness"||wt==="agent"&&Ce==="agent"&&!n||wt==="skill"&&on==="optimize"&&!Pe,busy:g?v:ah,showMeta:Ie.length>0&&!g,attachments:g?[]:Sn,skills:g?[]:yv,agents:g?[]:xv,invocation:g?xl():Ni,capabilitiesLoading:!g&&ti,modelName:((V=Vt==null?void 0:Vt.model)==null?void 0:V.trim())||Wt.modelName,tokenUsage:Wt,systemTokenEstimate:vv,allowAttachments:!g,onInvocationChange:Pn,onAddFiles:wge,onRemoveAttachment:wv,newChatMode:g?"agent":Ce,newChatWorkspaceMode:g?"agent":wt,newChatSkillAction:on,newChatSkillTarget:Pe,skillCustomizationEnabled:ln&&Le.skillCustomizationEnabled===!0,newChatTask:g?null:At,newChatLayout:!g&&Ie.length===0,showWorkspaceTabs:!g&&Ie.length===0,showAgentPicker:!g&&Ie.length===0&&wt==="agent"&&Ce==="agent",agentPickerDisabled:!Xe||ah,selectedRuntimeId:Us==null?void 0:Us.runtimeId,runtimeScope:mi.capabilities.runtimeScope,onSelectRuntime:async F=>{var se;await n6({id:F.runtimeId,name:F.name,description:((se=F.description)==null?void 0:se.trim())||"暂无描述",createdAt:F.createdAt??"",specificationLabel:"地域",specification:td(F.region,$n),isMine:F.isMine,runtime:{runtimeId:F.runtimeId,region:F.region,currentVersion:F.currentVersion,canDelete:F.canDelete}},{rethrow:!0,source:"new_chat_picker"})},onSelectSandboxSession:F=>Rv(F,"new_chat_picker"),showModeSelector:!1,onWorkspaceModeChange:F=>{yn(F),F!=="agent"&&Ut(null),Ke("")},onSkillActionChange:hi,onSkillTargetChange:st,temporaryEnabled:ln&&Le.temporaryEnabled,deepseekHarnessEnabled:ln&&Le.deepseekHarnessEnabled,harnessEnabled:ln&&Le.harnessEnabled,builtinTools:ln?Le.builtinTools:[],onModeChange:F=>{if(!(F==="temporary"&&!Le.temporaryEnabled)){if(F==="temporary"){Ut(null),et(F),IN();return}if(!(F==="deepseek-harness"&&!Le.deepseekHarnessEnabled)){if(F==="deepseek-harness"){Ut(null),et(F),IN("deepseek-harness");return}et(F),F!=="agent"&&Ut(null),Ke("")}}},onTaskChange:Ut})]});return l.jsx("section",{className:"main-shell",children:l.jsxs("main",{className:`main${g?" is-sandbox-session":""}`,children:[Kl&&l.jsx("div",{className:"error",role:"alert",children:Kl}),ec&&l.jsx("div",{className:"error",role:"alert",children:ec}),aN&&l.jsxs("div",{className:"session-loading",children:[l.jsx(Kn,{className:"icon spin"})," 加载会话…"]}),IQ&&!e6&&!KQ&&!JQ&&!Tv&&!Tb&&Ib===null&&l.jsx("div",{className:"case-return-bar",children:l.jsxs("button",{type:"button",onClick:Oge,children:[l.jsx(aJ,{"aria-hidden":!0}),l.jsx("span",{children:"返回评测案例"})]})}),ws!==null?l.jsx(Rbt,{initialModule:Vbt(ws),onSubmit:Nge}):vN?l.jsx(mut,{version:hv,localMode:tc==="local",role:(mi==null?void 0:mi.role)??"user",provider:$n,region:Sd||Qi($n)}):sc==="coding-agents"?l.jsx(ddt,{onBack:()=>Ga("catalog")}):sc==="feishu"?l.jsx(Hut,{onBack:()=>Ga("catalog")}):sc&&sc!=="catalog"?l.jsx(xut,{automation:sc,onBack:()=>Ga("catalog")}):sc==="catalog"?l.jsx(lut,{onOpen:Ga}):W?l.jsx(Agt,{workspace:W,onBack:$N}):Rt?l.jsx(Sgt,{session:Rt,onBack:$N,onOpen:()=>Rv(Rt,"sandbox_detail"),onDelete:()=>ige(Rt)}):su?l.jsx(Ict,{cloudProvider:$n,canCreate:Io,runtimeScope:mi.capabilities.runtimeScope,onCreateAgent:Rge,onOpenCodexProjectUpload:()=>De(!0),onUseAgent:F=>n6(F,{source:"my_agents"}),onViewAgentDetails:Pge,onCreateSandboxAgent:Mge,onUseSandboxAgent:F=>Rv(F,"my_agents"),onViewSandboxAgentDetails:nge,sandboxRefreshKey:mt,connectedRuntimeId:Mb,hiddenRuntimeIds:Qme,drafts:ON,deploymentTasks:Ue,draftDeploymentTaskIds:Xt,onViewDeploymentTask:_N,onEditDraft:F=>{Hi(!1),aa(F.draft),Ev("custom"),ml(F.id),Ro.current=F,oc(F.deploymentTarget??null),oa(""),la(""),be("custom"),Ke("")},onDeleteDraft:F=>UQ([F])}):e6?l.jsx(rct,{agents:Cd?[Cd]:_ge,drafts:ON,agentOrder:RQ,selectedAgentId:n,agentInfo:Vt,agentInfoAgentId:n,loadingAgentInfo:ti,canCreate:Io,canUpdate:Io||MN,canViewUsage:Tge,loadingAgents:Lme,agentsError:Dme,deploymentTasks:Ue,focusedDeploymentTaskId:QQ,focusedAgentId:(Cd==null?void 0:Cd.id)??BQ,focusedAgentSection:jme,focusedCaseKind:Rme,feedbackCasePreview:Pme,detailOnly:!0,onRetryAgents:()=>void kN(),onAgentOrderChange:zme,onDeleteAgents:Fme,onDeleteDrafts:UQ,onSelectAgent:jge,onTalkAgent:Dge,onOpenFeedbackCase:F=>void bge(F),onFeedbackCasesDeleted:yge,onCreateAgent:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}ii(!1),ui(!0),be(null),aa(null),oc(null),Cv(Qi($n)),ml(""),Ro.current=null,oa(""),la(""),Ke("")},onUpdateAgent:(F,se)=>{var it,It;if(!MN&&!Io){Ke("当前账号没有管理 Agent 的权限。");return}if(!se.canUpdate){Ke(se.reason||"当前 Runtime 不支持原地更新。");return}if(!se.runtime.runtimeId){Ke("仅支持更新已部署的云端智能体。");return}if(!se.runtime.region){Ke("Runtime 缺少地域信息,无法更新。");return}if(!((it=se.agent)!=null&&it.appName)){Ke("Runtime 缺少智能体名称,无法更新。");return}const Te=Object.fromEntries(se.runtime.envs.filter(({key:bt})=>!SH(bt)).map(({key:bt,value:ct})=>[bt,ct])),we=Object.fromEntries(Object.entries(((It=F.deployment)==null?void 0:It.envValues)??{}).filter(([bt])=>!SH(bt))),xe=Qft({...F,deployment:{...F.deployment??{feishuEnabled:!1},network:se.runtime.network,envValues:{...Te,...we}}},se.runtime.envs);ii(!1),aa(xe),Ev("custom");const Fe=`runtime-${se.runtime.runtimeId}`;ml(Fe),Ro.current=ON.find(bt=>bt.id===Fe)??null,oa(""),la(""),oc({runtimeId:se.runtime.runtimeId,name:se.runtime.name||se.agent.name||F.name,region:se.runtime.region,appName:se.agent.appName,currentVersion:se.runtime.currentVersion}),be("custom"),Ke("")},onEditDraft:F=>{ii(!1),aa(F.draft),Ev("custom"),ml(F.id),Ro.current=F,oc(F.deploymentTarget??null),oa(""),la(""),be("custom"),Ke("")}},(Cd==null?void 0:Cd.id)??"workspace"):KQ?l.jsx(fft,{title:"您想以哪种方式添加 Agent 来运行?",sub:"选择最适合你的方式,下一步即可开始",cards:[{key:"scratch",icon:Jbt,title:"从 0 快速创建",desc:"用智能 / 自定义 / 模板 / 工作流的方式从零创建一个 Agent。",onClick:()=>{ui(!1),aa(null),Ev("custom"),oc(null),oa(""),la(""),ml(`draft-${Date.now().toString(36)}`),Ro.current=null,be("custom")}},{key:"package",icon:eOt,title:"从代码包添加和部署",desc:"上传 Agent 项目压缩包,查看代码并直接部署到 AgentKit Runtime。",onClick:()=>{ui(!1),aa(null),be("package")}},{key:"migration",icon:tOt,title:"从存量迁移",desc:"从您的 LangChain / Dify 等存量项目迁移至 AgentKit Runtime",onClick:()=>{ui(!1),aa(null),be("migration")}}]}):Tv?l.jsx(ZEe,{userId:Xe,appId:n,agentInfo:Vt,capabilitiesLoading:ti,agentLabel:LN,onOpenSession:YQ}):JQ?l.jsx(Plt,{onAdded:F=>{Ab(Al()),_r(!1),i(F)},onCancel:()=>_r(!1)}):Tb?l.jsx(Nlt,{cloudProvider:$n,activeTab:Eme,onTabChange:pN,onPageTitleChange:mN,skillInitialWorkspace:Tme,onSkillInitialWorkspaceConsumed:()=>Sv(null),artifactSources:n?[{appName:n,agentId:(An==null?void 0:An.runtimeId)??n,agentName:LN(n),runtimeId:An==null?void 0:An.runtimeId,region:An==null?void 0:An.region,sessions:r}]:[],artifactUserId:Xe,onArtifactActivate:()=>{n&&Xe&&jb(n)},onArtifactSourceOpen:YQ}):Ib!==null&&!gi?l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",padding:24,textAlign:"center",color:"var(--text-secondary, #6b7280)"},children:[l.jsxs("div",{style:{fontSize:18,fontWeight:600},children:["需要配置",$n==="byteplus"?"BytePlus":"火山引擎"," AK/SK"]}),l.jsxs("div",{style:{maxWidth:420,lineHeight:1.6},children:["智能体工作台需要",$n==="byteplus"?" BytePlus ":" Volcengine ","凭据才能使用。请在运行环境中设置"," ",l.jsx("code",{children:$n==="byteplus"?"BYTEPLUS_ACCESS_KEY":"VOLCENGINE_ACCESS_KEY"})," ","与"," ",l.jsx("code",{children:$n==="byteplus"?"BYTEPLUS_SECRET_KEY":"VOLCENGINE_SECRET_KEY"})," ","后重试。"]})]}):Ib==="custom"?l.jsx(wpt,{cloudProvider:$n,initialDraft:_me??void 0,onBack:()=>{be(null),ui(!0)},onCreate:Vme,onAgentAdded:TN,features:yb,onDeploymentTaskChange:nc,createMode:Ame,deploymentTarget:ac??void 0,initialDeployRegion:Nb,onDraftChange:(F,se)=>{Kr&&(se?Ume(Kr,F,ac??void 0):zQ(Kr))},onDiscard:Kr?()=>{zQ(Kr),ml(""),Ro.current=null,aa(null),oc(null),oa(""),la(n),be(null),ui(!1),ii(!0),Ke("")}:void 0,onDeploymentStarted:AN,onDeploymentComplete:NN},Kr||"custom"):Ib==="package"?l.jsx(_pt,{cloudProvider:$n,onBack:()=>{be(null),ui(!0)},onAgentAdded:TN,onDeploymentTaskChange:nc,onDeploymentStarted:AN,onDeploymentComplete:NN,initialDeployRegion:Nb}):Ib==="migration"?l.jsx(ymt,{cloudProvider:$n,onBack:()=>{be(null),ui(!0)},onAgentAdded:TN,onDeploymentTaskChange:nc,onDeploymentStarted:AN,onDeploymentComplete:NN,initialDeployRegion:Nb}):Ie.length===0&&!ln?l.jsxs("div",{className:"session-loading",children:[l.jsx(Kn,{className:"icon spin"})," 正在检查 Agent 能力…"]}):Ie.length===0?l.jsx("div",{className:"welcome",children:l.jsxs("div",{className:"welcome-primary",children:[l.jsxs("div",{className:"welcome-heading",children:[l.jsx(Vmt,{canUpdate:mi.role==="admin"}),l.jsx("h1",{className:"welcome-title",children:g?"让灵感自由生长":tt})]}),R]})},`welcome-${Le.agentId??n}`):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`transcript${uN?" is-streaming":""}`,ref:Cb,onScroll:qme,onWheel:Hme,onTouchMove:Yme,children:Ie.map((F,se)=>{var tn,qt,On,di,Vn,zs,ou;const Te=se===Ie.length-1;if(F.role==="system")return F.activity?l.jsx("div",{className:"turn turn--system",children:l.jsx(egt,{activity:F.activity,time:JL((tn=F.meta)==null?void 0:tn.ts)})},F.activity.id):null;if(F.role==="user"){const ir=F.blocks.map(Wa=>Wa.kind==="text"?Wa.text:"").join(""),es=F.blocks.flatMap(Wa=>Wa.kind==="attachment"?Wa.files:[]),Di=F.blocks.find(Wa=>Wa.kind==="invocation");return l.jsxs(wr.div,{className:"turn turn--user",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[(Di==null?void 0:Di.kind)==="invocation"&&l.jsx(yA,{value:Di.value}),es.length>0&&l.jsx(xA,{appName:n,items:es}),ir&&l.jsx("div",{className:"bubble",children:l.jsx(qp,{text:ir})}),l.jsxs("div",{className:"turn-actions turn-actions--right","data-share-image-exclude":"true",children:[((qt=F.meta)==null?void 0:qt.ts)&&l.jsx("span",{className:"meta-text",children:JL(F.meta.ts)}),l.jsx(gY,{text:ir})]})]},se)}const we=((On=F.meta)==null?void 0:On.author)??"",xe=we&&nr?KL(nr,we):void 0,Fe=!!(we&&Ov.length>0&&!Ov.includes(we)),it=(xe==null?void 0:xe.name)||we,It=(xe==null?void 0:xe.description)||(Fe?"正在执行主 Agent 移交的任务。":"");if(F.blocks.length>0&&F.blocks.every(ir=>ir.kind==="agent-transfer"))return null;const bt=F.blocks.length===0,ct=((Vn=(di=F.meta)==null?void 0:di.feedback)==null?void 0:Vn.rating)??null,Qn=((zs=F.meta)==null?void 0:zs.eventId)??"",Fn=gn.has(Qn),Nt=!!(Us&&Qn&&Ud(F)),$r=Nt?LR(Ie,se):"",qn=!!(Nt&&$n!=="byteplus"&&!(Te&&(jo||ru))&&!DR(F));return l.jsxs(wr.div,{"data-share-message-source":"true","data-response-annotation-index":se,ref:ir=>{Qn&&(ir?CN.current.set(Qn,ir):CN.current.delete(Qn))},className:["turn turn--assistant",Fe?"turn--subagent":"",_b&&_b===Qn?"is-feedback-target":""].filter(Boolean).join(" "),tabIndex:qn?0:void 0,"aria-label":qn?"模型回复;选中文字后可添加批注":void 0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[Fe&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"subagent-run-label",children:[l.jsxs("span",{className:"subagent-run-handoff",children:[l.jsx(Fwe,{}),l.jsx("span",{children:"智能体移交"})]}),l.jsx("span",{className:"subagent-run-title",children:it})]}),l.jsx("p",{className:"subagent-run-description",title:It,children:It})]}),bt?Te&&jo?l.jsx(dle,{}):null:l.jsxs(l.Fragment,{children:[l.jsx(vA,{appName:n,blocks:F.blocks,streaming:Te&&(jo||ru),onStreamFrame:Te?Gme:void 0,onStreamComplete:Te&&!jo&&ru?()=>Co(a):void 0,onAction:Ege,onAuth:kge,onArtifactDownload:(ir,es)=>HD(n,Xe,a,ir,es),onArtifactPreview:(ir,es)=>YD(n,Xe,a,ir,es)}),!(Te&&jo)&&!sOt(F)&&l.jsx("div",{className:"turn-empty",children:"本次没有返回可显示的内容。"}),!(Te&&jo)&&!DR(F)&&l.jsxs("div",{className:"turn-meta","data-share-image-exclude":"true",children:[g&&((ou=F.meta)!=null&&ou.sandboxUsage)?l.jsx(ngt,{usage:F.meta.sandboxUsage}):null,l.jsxs("div",{className:"turn-actions",children:[Nt&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:`icon-btn feedback-btn${ct==="good"?" feedback-btn--good":""}`,"aria-label":"赞","aria-pressed":ct==="good","aria-busy":Fn,title:ct==="good"?"取消点赞":"赞",disabled:Fn,onClick:()=>void DN(F,ct==="good"?null:"good",$r),children:l.jsx(JEe,{className:"icon",filled:ct==="good"})}),l.jsx("button",{type:"button",className:`icon-btn feedback-btn${ct==="bad"?" feedback-btn--bad":""}`,"aria-label":"踩","aria-pressed":ct==="bad","aria-busy":Fn,title:ct==="bad"?"取消点踩":"踩",disabled:Fn,onClick:()=>void DN(F,ct==="bad"?null:"bad",$r),children:l.jsx(eke,{className:"icon",filled:ct==="bad"})})]}),!g&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"icon-btn","aria-label":"问题反馈",title:"问题反馈",onClick:()=>Ln({turn:F,input:LR(Ie,se)}),children:l.jsx(Eee,{className:"icon"})}),l.jsx("button",{type:"button",className:"icon-btn",title:"Tracing 火焰图",onClick:()=>{var ir;_e((ir=F.meta)!=null&&ir.ts?F.meta.ts*1e3:Date.now()),Me(!0)},children:l.jsx(nOt,{})})]}),l.jsx(gY,{text:Ud(F)}),l.jsx(lOt,{onClick:ir=>{const es=ir.currentTarget.closest("[data-share-message-source]");es&&ra({targetTurn:es})}})]}),F.meta&&l.jsx("span",{className:"meta-text",children:iOt(F.meta)})]})]})]},se)})}),!g&&l.jsx(qPe,{appName:n,info:Vt,loading:ti,activeAgent:dN,seenAgents:fN,execPath:hN,capabilities:en,capabilityLoading:xs,capabilityMutating:Ya,builtinTools:Ls,onAddCapability:xge,onRemoveCapability:F=>void vge(F)}),l.jsx("div",{className:"conversation-composer-slot",children:R})]})]})})})(),Vi&&a&&l.jsx(i0t,{onClose:()=>Ln(null),onSubmit:Age}),Tn&&l.jsx(obt,{targetTurn:Tn.targetTurn,onClose:()=>ra(null)}),Qs&&a&&l.jsx(_bt,{anchor:Qs.anchor,selectedText:Qs.selectedText,onClose:()=>dr(R=>(R==null?void 0:R.selectionId)===Qs.selectionId?null:R),onSubmit:Cge},Qs.selectionId),te&&a&&l.jsx(Bpe,{appName:n,sessionId:a,endTimeMs:ee,onClose:()=>Me(!1)}),l.jsx(Kmt,{open:ue,state:Se,agentKind:oe,error:Ee,onCancel:Jme,onConfirm:(R,V)=>void ege(R,V)}),l.jsx(Hgt,{open:We,onClose:()=>De(!1),onRefreshAgents:()=>at(R=>R+1),onOpenSession:tge}),ae?l.jsx(Mf,{title:"删除 Codex 历史会话",description:`将删除“${ae.name||ae.preview||`Thread ${ae.id.slice(0,8)}`}”,并从历史会话中移除。`,confirmLabel:"确认删除",variant:"danger",busy:vn.threadActionId===ae.id,onCancel:()=>{vn.threadActionId||pe(null)},onConfirm:()=>void rge()}):null,g?l.jsxs(l.Fragment,{children:[l.jsx(pgt,{open:M!==null,kind:M??"terminal",launch:P,loading:j,error:U,onReload:()=>{M&&PN(M)},onClose:()=>{L(null),Q(null),$(!1),B("")}}),l.jsx(ygt,{open:T,value:g.permissions,busy:w||v,error:S,onSave:R=>void age(R),onClose:()=>{w||(A(!1),k(""))}}),l.jsx(xgt,{open:N,cwd:g.cwd,locked:g.workspaceLocked,busy:w,error:S,browse:oge,onSave:R=>void lge(R),onClose:()=>{w||(C(!1),k(""))}}),l.jsx(mgt,{open:vn.threadsOpen,threads:vn.threads,currentThreadId:g.threadId,loading:vn.threadsLoading,error:vn.threadsError,onSelect:R=>void vn.resumeThread(R),onClose:vn.closeThreads}),l.jsx(vgt,{approval:I,busy:q,error:H,onDecision:R=>void cge(R)})]}):null,l.jsx(Jgt,{open:Pt,checking:bn,error:Ss,onLogin:()=>void Wme()}),l.jsx(Wmt,{open:Ai,task:kn,onClose:()=>Gn(!1),onRetry:$s,onDownload:()=>void Jl()}),Bme&&l.jsx("div",{className:"confirm-scrim",onClick:()=>SN(!1),children:l.jsxs("div",{className:"confirm-box",onClick:R=>R.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",children:"返回创建首页?"}),l.jsx("div",{className:"confirm-text",children:"返回后当前填写的内容将会丢失,确定要返回吗?"}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{className:"confirm-btn",onClick:()=>SN(!1),children:"取消"}),l.jsx("button",{className:"confirm-btn confirm-btn--danger",onClick:()=>{aa(null),be(null),ui(!0),SN(!1)},children:"确定返回"})]})]})})]})}const SY="veadk.preloadRecoveryAt";window.addEventListener("vite:preloadError",e=>{const t=Date.now();let n=0;try{n=Number(sessionStorage.getItem(SY)||"0")}catch{}if(!(t-n<1e4)){e.preventDefault();try{sessionStorage.setItem(SY,String(t))}catch{}window.location.reload()}});(()=>{if(!(window.opener&&window.opener!==window&&/[?&](code|state|error)=/.test(window.location.search)))return!1;try{window.opener.postMessage({veadkOAuth:!0,url:window.location.href},window.location.origin)}catch{}return window.close(),!0})()||DOe.createRoot(document.getElementById("root")).render(l.jsx(mn.StrictMode,{children:l.jsx(YOe,{reducedMotion:"user",children:l.jsx(_we,{maskOpacity:.9,children:l.jsx(bOt,{})})})}));export{zi as $,Ere as A,yUe as B,kre as C,Bie as D,TUe as E,DLe as F,r8e as G,N0 as H,Mre as I,T7e as J,oUe as K,lUe as L,P7e as M,e7e as N,t7e as O,Gie as P,Eae as Q,ire as R,_5e as S,J$e as T,l as U,Js as V,Ht as W,Li as X,Rn as Y,_Ot as Z,bUe as _,w3e as a,m as a0,dA as a1,wo as a2,AOt as a3,fy as a4,Sp as a5,Df as a6,Sr as a7,bd as a8,V_ as a9,$$ as aa,F_ as ab,tl as ac,hae as ad,v3e as b,G0 as c,qr as d,y3e as e,mn as f,Pre as g,Sre as h,x3e as i,r3e as j,rse as k,oLe as l,wz as m,f0 as n,Ti as o,NOt as p,Eie as q,Xl as r,K_ as s,tA as t,Lf as u,kOt as v,p3 as w,n8e as x,Ex as y,Yn as z}; +`),toolCalls:F.flatMap(p9),trace:se})},DN=async(R,V,F="",se="",Te=!0)=>{var bt,ct,Qn,Fn,Nt,$r,Lt,qn;const we=(bt=R.meta)==null?void 0:bt.eventId,xe=a;if(!we||!xe||!Us)return"当前回复暂不支持加入评测集";if($n==="byteplus")return"BytePlus 暂不支持 AgentKit 评测集";const Fe=Ud(R),it=(ct=R.meta)==null?void 0:ct.feedback,It={...it,rating:V,comment:se,syncStatus:"syncing",updatedAt:Date.now()/1e3};dn(xe,tn=>tn.map(qt=>{var On;return((On=qt.meta)==null?void 0:On.eventId)===we?{...qt,meta:{...qt.meta,feedback:It}}:qt})),Wn(tn=>new Set(tn).add(we)),An!=null&&An.runtimeId&&au&&US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Qn=R.meta)==null?void 0:Qn.invocationId,rating:V,input:F,output:Fe,comment:se,createdAt:(Fn=R.meta)!=null&&Fn.ts?new Date(R.meta.ts*1e3).toISOString():void 0});try{const tn=await LJ({appName:n,userId:Xe,sessionId:xe,eventId:we,rating:V,comment:se});dn(xe,qt=>qt.map(On=>{var di;return((di=On.meta)==null?void 0:di.eventId)===we?{...On,meta:{...On.meta,feedback:tn}}:On})),s(qt=>qt.map(On=>On.id===xe?{...On,state:{...On.state??{},[`veadk_feedback:${we}`]:tn}}:On)),An!=null&&An.runtimeId&&au&&(US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Nt=R.meta)==null?void 0:Nt.invocationId,rating:tn.rating,input:F,output:Fe,comment:se,createdAt:($r=R.meta)!=null&&$r.ts?new Date(R.meta.ts*1e3).toISOString():void 0}),BJ({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,pageSize:100}))}catch(tn){const qt=tn instanceof Error?tn.message:String(tn);return dn(xe,On=>On.map(di=>{var Vn;return((Vn=di.meta)==null?void 0:Vn.eventId)===we?{...di,meta:{...di.meta,feedback:it}}:di})),An!=null&&An.runtimeId&&au&&US({runtimeId:An.runtimeId,region:An.region??Qi($n),appName:au,userId:Xe,sessionId:xe,messageId:we,invocationId:(Lt=R.meta)==null?void 0:Lt.invocationId,rating:(it==null?void 0:it.rating)??null,input:F,output:Fe,comment:(it==null?void 0:it.comment)??"",createdAt:(qn=R.meta)!=null&&qn.ts?new Date(R.meta.ts*1e3).toISOString():void 0}),Te&&ji.current===xe&&Ke(qt),qt}finally{Wn(tn=>{const qt=new Set(tn);return qt.delete(we),qt})}return null},jge=async R=>{const V=Qs;if(!V)return;const F=await DN(V.turn,"bad",V.input,Tbt(V.selectedText,R),!1);if(F)throw new Error(F)},Iv=async R=>{Ab(Al());let V=gt.current.get(R);V||(V=await PR(R),gt.current.set(R,V)),ut(V),pi(F=>F+1),i(R),Bs(null),oa(""),la(""),Hi(!1),ii(!1),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),Nd()},Rge=async R=>{await Iv(R)},Ige=R=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}Hi(!1),ii(!1),Cv(R),aa(null),be(null),ui(!0),Ke("")},Pge=async(R,V)=>{if(!R.runtime)throw new Error("缺少 Runtime 信息,无法连接智能体。");const F=rR({targetId:String(R.runtime.runtimeId),agentKind:"runtime",connectSource:V});try{const se=await SE(R.runtime.runtimeId,R.name,R.runtime.region,R.runtime.currentVersion);return F.succeed({runtimeRegion:R.runtime.region,runtimeIsMine:R.isMine?1:0}),se}catch(se){throw F.fail(Ra(se)),se}},n6=async(R,V={})=>{if(R.runtime)try{const F=await Pge(R,V.source??"my_agents");await Iv(F)}catch(F){const se=F instanceof Error?F.message:String(F);if(Ke(se),V.rethrow)throw new Error(se)}},Mge=R=>{R.runtime&&(Bs(R),oa(""),la(""),Hi(!1),ii(!0),Ke(""))},Lge=R=>{if(!Io){Ke("当前账号没有创建智能体的权限。");return}IN(R,!0)},$N=()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),oa(""),la(""),Hi(!0),rc(!1),Ga(null),Ke("")},Dge=()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga("catalog"),Ke("")},$ge=async R=>{if(xN(""),Av(""),R.runtimeId&&R.id.startsWith("detail:")){const V=rR({targetId:String(R.runtimeId),agentKind:"runtime",connectSource:"agent_workspace"});try{const F=await SE(R.runtimeId,R.label,R.region??Qi($n),R.currentVersion);V.succeed({runtimeRegion:R.region}),await Iv(F)}catch(F){V.fail(Ra(F)),Ke(F instanceof Error?F.message:String(F))}return}await Iv(R.id)},QN=Jn!=null&&Jn.runtime?gl.find(R=>{var V;return R.runtimeId===((V=Jn.runtime)==null?void 0:V.runtimeId)}):void 0,Cd=Jn!=null&&Jn.runtime?{id:`detail:${Jn.runtime.runtimeId}`,label:Jn.name,app:Jn.appName??Jn.name,remote:!0,runtimeApp:QN==null?void 0:QN.apps[0],runtimeId:Jn.runtime.runtimeId,region:Jn.runtime.region,currentVersion:Jn.runtime.currentVersion,canDelete:Jn.runtime.canDelete}:null,i6=ws!==null?"feedback":Tb?"library":vN?null:sc?"applications":Tv?"search":su||oh||Rt||W?"agents":a||he||Tb||gN||bN?null:"new-chat";return l.jsxs("div",{className:"layout",children:[l.jsx(ake,{branding:hl,cloudProvider:$n,access:mi,features:yb,sessions:r,currentSessionId:a,activePage:i6,streamingSids:ul,evaluatingSids:vs,sandboxHistory:g?{threads:vn.threads,currentThreadId:g.threadId,loading:vn.threadsLoading,error:vn.threadsError,hasMore:vn.threadsHasMore,busyThreadId:vn.threadActionId,newDisabled:v||vn.commandBusy,onNew:()=>void vn.newThread(),onSelect:R=>void vn.resumeThread(R),onLoadMore:()=>void vn.loadMoreThreads(),onDelete:pe}:void 0,onNewChat:gge,onSearch:()=>{ls(null),g&&uc(),be(null),Zr(!1),_r(!1),ui(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Jr(!0),Ke("")},onQuickCreate:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}g&&uc(),ji.current="",o(""),Zr(!1),_r(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),be(null),aa(null),Cv(Qi($n)),ui(!0),Ke("")},onLibrary:()=>{g&&uc(),be(null),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Sv(null),pN("skills"),mN("技能库"),Zr(!0),Ke("")},onAddAgent:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}g&&uc(),ji.current="",be(null),Zr(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),o(""),ui(!1),_r(!0),Ke("")},onMyAgents:$N,onApplications:Dge,onSystemInfo:()=>{ls(null),g&&uc(),ji.current="",o(""),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),Ga(null),rc(!0),Ke("")},onIssueFeedback:()=>{ws===null&&(rc(!1),ls(i6??(g?"sandbox":a?"conversation":"workspace")),Ke(""))},onPickSession:R=>{ls(null),be(null),Zr(!1),_r(!1),ui(!1),Jr(!1),ii(!1),Bs(null),qe(null),K(null),Hi(!1),rc(!1),Ga(null),Ke(""),Rb(R)},onDeleteSession:bge,userInfo:dl,onLogout:Jme}),(()=>{var V;const R=l.jsxs("div",{className:`composer-slot${g?" sandbox-composer-wrap":""}`,children:[g&&l.jsx(egt,{agentName:g.toolName==="codex"?"Codex":g.toolName==="deepseek-harness"?"DeepSeek Harness":g.toolName==="openclaw"?"OpenClaw":"Hermes",onExit:Nd}),g?l.jsx(Lgt,{appName:n,value:Jt,onChange:Ft,onSubmit:F=>void pge(F),onStop:v?hge:void 0,disabled:!1,busy:v||vn.commandBusy,attachments:Sn,onAddFiles:dge,onRemoveAttachment:fge,actions:{onOpenTerminal:()=>void PN("terminal"),onOpenBrowser:()=>void PN("browser"),onOpenPermissions:()=>{k(""),A(!0)},onOpenWorkspace:()=>{k(""),C(!0)},onCopyEndpoint:age,endpointCopyEnabled:Le.sandboxEndpointExportEnabled===!0,endpointCopyState:J,workspaceLocked:g.workspaceLocked,settingsBusy:w,uploadBusy:fe||v},models:vn.models,modelsLoading:vn.modelsLoading,modelsLoaded:vn.modelsLoaded,currentModel:g.model,onRequestModels:()=>void vn.loadModels(),skills:vn.skills,skillsLoading:vn.skillsLoading,skillsLoaded:vn.skillsLoaded,selectedSkills:vn.selectedSkills,onRequestSkills:()=>void vn.loadSkills(),onSelectedSkillsChange:vn.setSelectedSkills}):l.jsx(fft,{cloudProvider:$n,sessionId:a,sessionInitializing:d,appName:n,agentName:n?LN(n):"Agent",value:Jt,onChange:Ft,videoTask:kn,onOpenVideoTask:()=>{xn.current&&Gn(!0)},onVideoSubmit:nu,onSubmit:()=>{var we;const F=Jt;if(!g&&Ie.length===0&&wt==="skill"){if(!F.trim())return;let xe;if(on==="create")xe={operation:"create",initialIntent:F.trim(),selectPublishSpace:!0};else{const Fe=Pe;if(!Fe){Ke("请先选择需要优化的 Skill。");return}xe={operation:"optimize",initialIntent:F.trim(),space:Fe.space,source:{kind:"skill-center",skillId:Fe.skill.skillId,version:Fe.skill.version,region:Fe.space.region||Qi($n),projectName:Fe.space.projectName,skillSpaceId:Fe.space.id,skillSpaceName:Fe.space.name,name:Fe.skill.skillName||Fe.skill.skillId,description:Fe.skill.skillDescription}}}Ft(""),Ke(""),Sv(xe),pN("skills"),mN(xe.operation==="create"?"创建技能":`优化 ${((we=xe.source)==null?void 0:we.name)||"技能"}`),Zr(!0);return}if(Ft(""),g){GQ(F);return}const se=Sn,Te=Ni;In([]),Pn(xl()),ZQ(F,se,Te),$R(se)},onStop:bv?Ege:void 0,disabled:g?!1:!Xe||Ce==="temporary"||Ce==="deepseek-harness"||wt==="agent"&&Ce==="agent"&&!n||wt==="skill"&&on==="optimize"&&!Pe,busy:g?v:ah,showMeta:Ie.length>0&&!g,attachments:g?[]:Sn,skills:g?[]:yv,agents:g?[]:xv,invocation:g?xl():Ni,capabilitiesLoading:!g&&ti,modelName:((V=Vt==null?void 0:Vt.model)==null?void 0:V.trim())||Wt.modelName,tokenUsage:Wt,systemTokenEstimate:vv,allowAttachments:!g,onInvocationChange:Pn,onAddFiles:Sge,onRemoveAttachment:wv,newChatMode:g?"agent":Ce,newChatWorkspaceMode:g?"agent":wt,newChatSkillAction:on,newChatSkillTarget:Pe,skillCustomizationEnabled:ln&&Le.skillCustomizationEnabled===!0,newChatTask:g?null:At,newChatLayout:!g&&Ie.length===0,showWorkspaceTabs:!g&&Ie.length===0,showAgentPicker:!g&&Ie.length===0&&wt==="agent"&&Ce==="agent",agentPickerDisabled:!Xe||ah,selectedRuntimeId:Us==null?void 0:Us.runtimeId,runtimeScope:mi.capabilities.runtimeScope,onSelectRuntime:async F=>{var se;await n6({id:F.runtimeId,name:F.name,description:((se=F.description)==null?void 0:se.trim())||"暂无描述",createdAt:F.createdAt??"",specificationLabel:"地域",specification:td(F.region,$n),isMine:F.isMine,runtime:{runtimeId:F.runtimeId,region:F.region,currentVersion:F.currentVersion,canDelete:F.canDelete}},{rethrow:!0,source:"new_chat_picker"})},onSelectSandboxSession:F=>Rv(F,"new_chat_picker"),showModeSelector:!1,onWorkspaceModeChange:F=>{yn(F),F!=="agent"&&Ut(null),Ke("")},onSkillActionChange:hi,onSkillTargetChange:st,temporaryEnabled:ln&&Le.temporaryEnabled,deepseekHarnessEnabled:ln&&Le.deepseekHarnessEnabled,harnessEnabled:ln&&Le.harnessEnabled,builtinTools:ln?Le.builtinTools:[],onModeChange:F=>{if(!(F==="temporary"&&!Le.temporaryEnabled)){if(F==="temporary"){Ut(null),et(F),IN();return}if(!(F==="deepseek-harness"&&!Le.deepseekHarnessEnabled)){if(F==="deepseek-harness"){Ut(null),et(F),IN("deepseek-harness");return}et(F),F!=="agent"&&Ut(null),Ke("")}}},onTaskChange:Ut})]});return l.jsx("section",{className:"main-shell",children:l.jsxs("main",{className:`main${g?" is-sandbox-session":""}`,children:[Kl&&l.jsx("div",{className:"error",role:"alert",children:Kl}),ec&&l.jsx("div",{className:"error",role:"alert",children:ec}),aN&&l.jsxs("div",{className:"session-loading",children:[l.jsx(Kn,{className:"icon spin"})," 加载会话…"]}),IQ&&!e6&&!KQ&&!JQ&&!Tv&&!Tb&&Ib===null&&l.jsx("div",{className:"case-return-bar",children:l.jsxs("button",{type:"button",onClick:yge,children:[l.jsx(oJ,{"aria-hidden":!0}),l.jsx("span",{children:"返回评测案例"})]})}),ws!==null?l.jsx(Ibt,{initialModule:Xbt(ws),onSubmit:Cge}):vN?l.jsx(gut,{version:hv,localMode:tc==="local",role:(mi==null?void 0:mi.role)??"user",provider:$n,region:Sd||Qi($n)}):sc==="coding-agents"?l.jsx(fdt,{onBack:()=>Ga("catalog")}):sc==="feishu"?l.jsx(Yut,{onBack:()=>Ga("catalog")}):sc&&sc!=="catalog"?l.jsx(vut,{automation:sc,onBack:()=>Ga("catalog")}):sc==="catalog"?l.jsx(cut,{onOpen:Ga}):W?l.jsx(Ngt,{workspace:W,onBack:$N}):Rt?l.jsx(Egt,{session:Rt,onBack:$N,onOpen:()=>Rv(Rt,"sandbox_detail"),onDelete:()=>rge(Rt)}):su?l.jsx(Pct,{cloudProvider:$n,canCreate:Io,runtimeScope:mi.capabilities.runtimeScope,onCreateAgent:Ige,onOpenCodexProjectUpload:()=>De(!0),onUseAgent:F=>n6(F,{source:"my_agents"}),onViewAgentDetails:Mge,onCreateSandboxAgent:Lge,onUseSandboxAgent:F=>Rv(F,"my_agents"),onViewSandboxAgentDetails:ige,sandboxRefreshKey:mt,connectedRuntimeId:Mb,hiddenRuntimeIds:Bme,drafts:ON,deploymentTasks:Ue,draftDeploymentTaskIds:Xt,onViewDeploymentTask:_N,onEditDraft:F=>{Hi(!1),aa(F.draft),Ev("custom"),ml(F.id),Ro.current=F,oc(F.deploymentTarget??null),oa(""),la(""),be("custom"),Ke("")},onDeleteDraft:F=>UQ([F])}):e6?l.jsx(sct,{agents:Cd?[Cd]:Age,drafts:ON,agentOrder:RQ,selectedAgentId:n,agentInfo:Vt,agentInfoAgentId:n,loadingAgentInfo:ti,canCreate:Io,canUpdate:Io||MN,canViewUsage:_ge,loadingAgents:Dme,agentsError:$me,deploymentTasks:Ue,focusedDeploymentTaskId:QQ,focusedAgentId:(Cd==null?void 0:Cd.id)??BQ,focusedAgentSection:Rme,focusedCaseKind:Ime,feedbackCasePreview:Mme,detailOnly:!0,onRetryAgents:()=>void kN(),onAgentOrderChange:Fme,onDeleteAgents:Vme,onDeleteDrafts:UQ,onSelectAgent:Rge,onTalkAgent:$ge,onOpenFeedbackCase:F=>void Oge(F),onFeedbackCasesDeleted:xge,onCreateAgent:()=>{if(!Io){Ke("当前账号没有添加 Agent 的权限。");return}ii(!1),ui(!0),be(null),aa(null),oc(null),Cv(Qi($n)),ml(""),Ro.current=null,oa(""),la(""),Ke("")},onUpdateAgent:(F,se)=>{var it,It;if(!MN&&!Io){Ke("当前账号没有管理 Agent 的权限。");return}if(!se.canUpdate){Ke(se.reason||"当前 Runtime 不支持原地更新。");return}if(!se.runtime.runtimeId){Ke("仅支持更新已部署的云端智能体。");return}if(!se.runtime.region){Ke("Runtime 缺少地域信息,无法更新。");return}if(!((it=se.agent)!=null&&it.appName)){Ke("Runtime 缺少智能体名称,无法更新。");return}const Te=Object.fromEntries(se.runtime.envs.filter(({key:bt})=>!EH(bt)).map(({key:bt,value:ct})=>[bt,ct])),we=Object.fromEntries(Object.entries(((It=F.deployment)==null?void 0:It.envValues)??{}).filter(([bt])=>!EH(bt))),xe=Bft({...F,deployment:{...F.deployment??{feishuEnabled:!1},network:se.runtime.network,envValues:{...Te,...we}}},se.runtime.envs);ii(!1),aa(xe),Ev("custom");const Fe=`runtime-${se.runtime.runtimeId}`;ml(Fe),Ro.current=ON.find(bt=>bt.id===Fe)??null,oa(""),la(""),oc({runtimeId:se.runtime.runtimeId,name:se.runtime.name||se.agent.name||F.name,region:se.runtime.region,appName:se.agent.appName,currentVersion:se.runtime.currentVersion}),be("custom"),Ke("")},onEditDraft:F=>{ii(!1),aa(F.draft),Ev("custom"),ml(F.id),Ro.current=F,oc(F.deploymentTarget??null),oa(""),la(""),be("custom"),Ke("")}},(Cd==null?void 0:Cd.id)??"workspace"):KQ?l.jsx(hft,{title:"您想以哪种方式添加 Agent 来运行?",sub:"选择最适合你的方式,下一步即可开始",cards:[{key:"scratch",icon:eOt,title:"从 0 快速创建",desc:"用智能 / 自定义 / 模板 / 工作流的方式从零创建一个 Agent。",onClick:()=>{ui(!1),aa(null),Ev("custom"),oc(null),oa(""),la(""),ml(`draft-${Date.now().toString(36)}`),Ro.current=null,be("custom")}},{key:"package",icon:tOt,title:"从代码包添加和部署",desc:"上传 Agent 项目压缩包,查看代码并直接部署到 AgentKit Runtime。",onClick:()=>{ui(!1),aa(null),be("package")}},{key:"migration",icon:nOt,title:"从存量迁移",desc:"从您的 LangChain / Dify 等存量项目迁移至 AgentKit Runtime",onClick:()=>{ui(!1),aa(null),be("migration")}}]}):Tv?l.jsx(KEe,{userId:Xe,appId:n,agentInfo:Vt,capabilitiesLoading:ti,agentLabel:LN,onOpenSession:YQ}):JQ?l.jsx(Mlt,{onAdded:F=>{Ab(Al()),_r(!1),i(F)},onCancel:()=>_r(!1)}):Tb?l.jsx(Clt,{cloudProvider:$n,activeTab:kme,onTabChange:pN,onPageTitleChange:mN,skillInitialWorkspace:_me,onSkillInitialWorkspaceConsumed:()=>Sv(null),artifactSources:n?[{appName:n,agentId:(An==null?void 0:An.runtimeId)??n,agentName:LN(n),runtimeId:An==null?void 0:An.runtimeId,region:An==null?void 0:An.region,sessions:r}]:[],artifactUserId:Xe,onArtifactActivate:()=>{n&&Xe&&jb(n)},onArtifactSourceOpen:YQ}):Ib!==null&&!gi?l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",padding:24,textAlign:"center",color:"var(--text-secondary, #6b7280)"},children:[l.jsxs("div",{style:{fontSize:18,fontWeight:600},children:["需要配置",$n==="byteplus"?"BytePlus":"火山引擎"," AK/SK"]}),l.jsxs("div",{style:{maxWidth:420,lineHeight:1.6},children:["智能体工作台需要",$n==="byteplus"?" BytePlus ":" Volcengine ","凭据才能使用。请在运行环境中设置"," ",l.jsx("code",{children:$n==="byteplus"?"BYTEPLUS_ACCESS_KEY":"VOLCENGINE_ACCESS_KEY"})," ","与"," ",l.jsx("code",{children:$n==="byteplus"?"BYTEPLUS_SECRET_KEY":"VOLCENGINE_SECRET_KEY"})," ","后重试。"]})]}):Ib==="custom"?l.jsx(Spt,{cloudProvider:$n,initialDraft:Ame??void 0,onBack:()=>{be(null),ui(!0)},onCreate:Xme,onAgentAdded:TN,features:yb,onDeploymentTaskChange:nc,createMode:Nme,deploymentTarget:ac??void 0,initialDeployRegion:Nb,onDraftChange:(F,se)=>{Kr&&(se?zme(Kr,F,ac??void 0):zQ(Kr))},onDiscard:Kr?()=>{zQ(Kr),ml(""),Ro.current=null,aa(null),oc(null),oa(""),la(n),be(null),ui(!1),ii(!0),Ke("")}:void 0,onDeploymentStarted:AN,onDeploymentComplete:NN},Kr||"custom"):Ib==="package"?l.jsx(Apt,{cloudProvider:$n,onBack:()=>{be(null),ui(!0)},onAgentAdded:TN,onDeploymentTaskChange:nc,onDeploymentStarted:AN,onDeploymentComplete:NN,initialDeployRegion:Nb}):Ib==="migration"?l.jsx(xmt,{cloudProvider:$n,onBack:()=>{be(null),ui(!0)},onAgentAdded:TN,onDeploymentTaskChange:nc,onDeploymentStarted:AN,onDeploymentComplete:NN,initialDeployRegion:Nb}):Ie.length===0&&!ln?l.jsxs("div",{className:"session-loading",children:[l.jsx(Kn,{className:"icon spin"})," 正在检查 Agent 能力…"]}):Ie.length===0?l.jsx("div",{className:"welcome",children:l.jsxs("div",{className:"welcome-primary",children:[l.jsxs("div",{className:"welcome-heading",children:[l.jsx(Xmt,{canUpdate:mi.role==="admin"}),l.jsx("h1",{className:"welcome-title",children:g?"让灵感自由生长":tt})]}),R]})},`welcome-${Le.agentId??n}`):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`transcript${uN?" is-streaming":""}`,ref:Cb,onScroll:Hme,onWheel:Yme,onTouchMove:Gme,children:Ie.map((F,se)=>{var tn,qt,On,di,Vn,zs,ou;const Te=se===Ie.length-1;if(F.role==="system")return F.activity?l.jsx("div",{className:"turn turn--system",children:l.jsx(tgt,{activity:F.activity,time:JL((tn=F.meta)==null?void 0:tn.ts)})},F.activity.id):null;if(F.role==="user"){const ir=F.blocks.map(Wa=>Wa.kind==="text"?Wa.text:"").join(""),es=F.blocks.flatMap(Wa=>Wa.kind==="attachment"?Wa.files:[]),Di=F.blocks.find(Wa=>Wa.kind==="invocation");return l.jsxs(wr.div,{className:"turn turn--user",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[(Di==null?void 0:Di.kind)==="invocation"&&l.jsx(yA,{value:Di.value}),es.length>0&&l.jsx(xA,{appName:n,items:es}),ir&&l.jsx("div",{className:"bubble",children:l.jsx(qp,{text:ir})}),l.jsxs("div",{className:"turn-actions turn-actions--right","data-share-image-exclude":"true",children:[((qt=F.meta)==null?void 0:qt.ts)&&l.jsx("span",{className:"meta-text",children:JL(F.meta.ts)}),l.jsx(bY,{text:ir})]})]},se)}const we=((On=F.meta)==null?void 0:On.author)??"",xe=we&&nr?KL(nr,we):void 0,Fe=!!(we&&Ov.length>0&&!Ov.includes(we)),it=(xe==null?void 0:xe.name)||we,It=(xe==null?void 0:xe.description)||(Fe?"正在执行主 Agent 移交的任务。":"");if(F.blocks.length>0&&F.blocks.every(ir=>ir.kind==="agent-transfer"))return null;const bt=F.blocks.length===0,ct=((Vn=(di=F.meta)==null?void 0:di.feedback)==null?void 0:Vn.rating)??null,Qn=((zs=F.meta)==null?void 0:zs.eventId)??"",Fn=gn.has(Qn),Nt=!!(Us&&Qn&&Ud(F)),$r=Nt?LR(Ie,se):"",qn=!!(Nt&&$n!=="byteplus"&&!(Te&&(jo||ru))&&!DR(F));return l.jsxs(wr.div,{"data-share-message-source":"true","data-response-annotation-index":se,ref:ir=>{Qn&&(ir?CN.current.set(Qn,ir):CN.current.delete(Qn))},className:["turn turn--assistant",Fe?"turn--subagent":"",_b&&_b===Qn?"is-feedback-target":""].filter(Boolean).join(" "),tabIndex:qn?0:void 0,"aria-label":qn?"模型回复;选中文字后可添加批注":void 0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[Fe&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"subagent-run-label",children:[l.jsxs("span",{className:"subagent-run-handoff",children:[l.jsx(Vwe,{}),l.jsx("span",{children:"智能体移交"})]}),l.jsx("span",{className:"subagent-run-title",children:it})]}),l.jsx("p",{className:"subagent-run-description",title:It,children:It})]}),bt?Te&&jo?l.jsx(fle,{}):null:l.jsxs(l.Fragment,{children:[l.jsx(vA,{appName:n,blocks:F.blocks,streaming:Te&&(jo||ru),onStreamFrame:Te?Wme:void 0,onStreamComplete:Te&&!jo&&ru?()=>Co(a):void 0,onAction:kge,onAuth:Tge,onArtifactDownload:(ir,es)=>HD(n,Xe,a,ir,es),onArtifactPreview:(ir,es)=>YD(n,Xe,a,ir,es)}),!(Te&&jo)&&!aOt(F)&&l.jsx("div",{className:"turn-empty",children:"本次没有返回可显示的内容。"}),!(Te&&jo)&&!DR(F)&&l.jsxs("div",{className:"turn-meta","data-share-image-exclude":"true",children:[g&&((ou=F.meta)!=null&&ou.sandboxUsage)?l.jsx(igt,{usage:F.meta.sandboxUsage}):null,l.jsxs("div",{className:"turn-actions",children:[Nt&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:`icon-btn feedback-btn${ct==="good"?" feedback-btn--good":""}`,"aria-label":"赞","aria-pressed":ct==="good","aria-busy":Fn,title:ct==="good"?"取消点赞":"赞",disabled:Fn,onClick:()=>void DN(F,ct==="good"?null:"good",$r),children:l.jsx(eke,{className:"icon",filled:ct==="good"})}),l.jsx("button",{type:"button",className:`icon-btn feedback-btn${ct==="bad"?" feedback-btn--bad":""}`,"aria-label":"踩","aria-pressed":ct==="bad","aria-busy":Fn,title:ct==="bad"?"取消点踩":"踩",disabled:Fn,onClick:()=>void DN(F,ct==="bad"?null:"bad",$r),children:l.jsx(tke,{className:"icon",filled:ct==="bad"})})]}),!g&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"icon-btn","aria-label":"问题反馈",title:"问题反馈",onClick:()=>Ln({turn:F,input:LR(Ie,se)}),children:l.jsx(kee,{className:"icon"})}),l.jsx("button",{type:"button",className:"icon-btn",title:"Tracing 火焰图",onClick:()=>{var ir;_e((ir=F.meta)!=null&&ir.ts?F.meta.ts*1e3:Date.now()),Me(!0)},children:l.jsx(iOt,{})})]}),l.jsx(bY,{text:Ud(F)}),l.jsx(cOt,{onClick:ir=>{const es=ir.currentTarget.closest("[data-share-message-source]");es&&ra({targetTurn:es})}})]}),F.meta&&l.jsx("span",{className:"meta-text",children:rOt(F.meta)})]})]})]},se)})}),!g&&l.jsx(HPe,{appName:n,info:Vt,loading:ti,activeAgent:dN,seenAgents:fN,execPath:hN,capabilities:en,capabilityLoading:xs,capabilityMutating:Ya,builtinTools:Ls,onAddCapability:vge,onRemoveCapability:F=>void wge(F)}),l.jsx("div",{className:"conversation-composer-slot",children:R})]})]})})})(),Vi&&a&&l.jsx(r0t,{onClose:()=>Ln(null),onSubmit:Nge}),Tn&&l.jsx(lbt,{targetTurn:Tn.targetTurn,onClose:()=>ra(null)}),Qs&&a&&l.jsx(Abt,{anchor:Qs.anchor,selectedText:Qs.selectedText,onClose:()=>dr(R=>(R==null?void 0:R.selectionId)===Qs.selectionId?null:R),onSubmit:jge},Qs.selectionId),te&&a&&l.jsx(Upe,{appName:n,sessionId:a,endTimeMs:ee,onClose:()=>Me(!1)}),l.jsx(Jmt,{open:ue,state:Se,agentKind:oe,error:Ee,onCancel:ege,onConfirm:(R,V)=>void tge(R,V)}),l.jsx(Ygt,{open:We,onClose:()=>De(!1),onRefreshAgents:()=>at(R=>R+1),onOpenSession:nge}),ae?l.jsx(Mf,{title:"删除 Codex 历史会话",description:`将删除“${ae.name||ae.preview||`Thread ${ae.id.slice(0,8)}`}”,并从历史会话中移除。`,confirmLabel:"确认删除",variant:"danger",busy:vn.threadActionId===ae.id,onCancel:()=>{vn.threadActionId||pe(null)},onConfirm:()=>void sge()}):null,g?l.jsxs(l.Fragment,{children:[l.jsx(mgt,{open:M!==null,kind:M??"terminal",launch:P,loading:j,error:U,onReload:()=>{M&&PN(M)},onClose:()=>{L(null),Q(null),$(!1),B("")}}),l.jsx(xgt,{open:T,value:g.permissions,busy:w||v,error:S,onSave:R=>void oge(R),onClose:()=>{w||(A(!1),k(""))}}),l.jsx(vgt,{open:N,cwd:g.cwd,locked:g.workspaceLocked,busy:w,error:S,browse:lge,onSave:R=>void cge(R),onClose:()=>{w||(C(!1),k(""))}}),l.jsx(ggt,{open:vn.threadsOpen,threads:vn.threads,currentThreadId:g.threadId,loading:vn.threadsLoading,error:vn.threadsError,onSelect:R=>void vn.resumeThread(R),onClose:vn.closeThreads}),l.jsx(wgt,{approval:I,busy:q,error:H,onDecision:R=>void uge(R)})]}):null,l.jsx(e0t,{open:Pt,checking:bn,error:Ss,onLogin:()=>void Zme()}),l.jsx(Zmt,{open:Ai,task:kn,onClose:()=>Gn(!1),onRetry:$s,onDownload:()=>void Jl()}),Ume&&l.jsx("div",{className:"confirm-scrim",onClick:()=>SN(!1),children:l.jsxs("div",{className:"confirm-box",onClick:R=>R.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",children:"返回创建首页?"}),l.jsx("div",{className:"confirm-text",children:"返回后当前填写的内容将会丢失,确定要返回吗?"}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{className:"confirm-btn",onClick:()=>SN(!1),children:"取消"}),l.jsx("button",{className:"confirm-btn confirm-btn--danger",onClick:()=>{aa(null),be(null),ui(!0),SN(!1)},children:"确定返回"})]})]})})]})}const EY="veadk.preloadRecoveryAt";window.addEventListener("vite:preloadError",e=>{const t=Date.now();let n=0;try{n=Number(sessionStorage.getItem(EY)||"0")}catch{}if(!(t-n<1e4)){e.preventDefault();try{sessionStorage.setItem(EY,String(t))}catch{}window.location.reload()}});(()=>{if(!(window.opener&&window.opener!==window&&/[?&](code|state|error)=/.test(window.location.search)))return!1;try{window.opener.postMessage({veadkOAuth:!0,url:window.location.href},window.location.origin)}catch{}return window.close(),!0})()||$Oe.createRoot(document.getElementById("root")).render(l.jsx(mn.StrictMode,{children:l.jsx(GOe,{reducedMotion:"user",children:l.jsx(Awe,{maskOpacity:.9,children:l.jsx(OOt,{})})})}));export{zi as $,kre as A,xUe as B,Tre as C,Uie as D,_Ue as E,$Le as F,s8e as G,N0 as H,Lre as I,_7e as J,lUe as K,cUe as L,M7e as M,t7e as N,n7e as O,Wie as P,kae as Q,rre as R,A5e as S,e3e as T,l as U,Js as V,Ht as W,Li as X,Rn as Y,AOt as Z,OUe as _,S3e as a,m as a0,dA as a1,wo as a2,NOt as a3,fy as a4,Sp as a5,Df as a6,Sr as a7,bd as a8,V_ as a9,$$ as aa,F_ as ab,tl as ac,pae as ad,w3e as b,G0 as c,qr as d,x3e as e,mn as f,Mre as g,Ere as h,v3e as i,s3e as j,sse as k,lLe as l,wz as m,f0 as n,Ti as o,COt as p,kie as q,Xl as r,K_ as s,tA as t,Lf as u,TOt as v,p3 as w,i8e as x,Ex as y,Yn as z}; diff --git a/veadk/webui/index.html b/veadk/webui/index.html index 97922a620..9ab596100 100644 --- a/veadk/webui/index.html +++ b/veadk/webui/index.html @@ -5,7 +5,7 @@ AgentKit Studio - +